home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / developmen / s3c111 / WIN.C < prev    next >
C/C++ Source or Header  |  1994-12-09  |  3KB  |  137 lines

  1. /* S3 Users comment in the next line */
  2. /* #define s3 1 */
  3.  
  4. /* Tell the compiler to invoke the linker when finished */
  5. #link "-i0 -om:\img\win.img e_gen.o e_win.o e_io.o win.o stdio.o"
  6.  
  7.  
  8. /*
  9.  Link usage:
  10.  
  11. #link  "[-eEXT][-sN][-iN] -oOUTFILE INFILE(S)..."
  12.  
  13. where:
  14.  -eEXT : Set default INFILE extensions to EXT
  15.    -sN : Set Image stack to N paragraphs (default=160)
  16.    -iN : Use startup module N: 
  17.           0 = Nothing with no command line
  18.           1 = Shell with no command line
  19.           2 = Nothing with C type command line
  20.           3 = Shell with C type command line (default)
  21.           4 = Nothing with LBC type command line
  22.           5 = Shell with LBC type command line
  23.  
  24. Use #linkpath "pathname" to set the default directory
  25. for the linker.
  26.  
  27. */
  28.  
  29. /* Tell the compiler to run the finished image file when 
  30.    everything has compiled and linked */
  31.  
  32. #run "m:\img\win.img"
  33.  
  34. /*
  35. Use #runpath "pathname" to set the default initial directory 
  36. for the image file.
  37. */
  38.  
  39.  
  40. #include <stdio.h>
  41.  
  42.  
  43.  
  44. /* These defines should be in their appropriate include
  45.    files. We've kidnapped them to make this demo easier to
  46.    compile.
  47. */ 
  48.  
  49. #define WS_FONT_BASE 0x4000
  50.  
  51. #define W_BORD_CUSHION 0x01
  52. #define W_BORD_SHADOW_D 0x08
  53. #define W_BORD_SHADOW_ON 0x10
  54.  
  55. #define WM_KEY 1
  56. #define P_FINQ 12
  57.  
  58. /* There are currently no struct types in the compiler,
  59.    for the time being we'll use defines.
  60. */
  61.  
  62. typedef struct
  63. {
  64.  unsigned int window_handle;
  65.  unsigned int font_handle;
  66.  unsigned int line_height;
  67.  unsigned int char_width;
  68. } CONSOLE_INFO;
  69.  
  70. typedef struct /* The WS_EV struct runs in parallel to the WS_EVENT struct */ 
  71.  { /* but is in a simplified form without the WS_EVENT_X */ 
  72.  /* sub structure */
  73.  short  type;
  74.  unsigned short handle;
  75.  unsigned short time;
  76.  int p[100];
  77.  } WS_EV;
  78.  
  79. typedef struct
  80.     {
  81.     short x; /* Horizontal coordinate */ 
  82.     short y; /* Vertical coordinate */ 
  83.     } P_POINT;
  84.  
  85. typedef struct
  86.     {
  87.     P_POINT tl; /* Top left point */ 
  88.     P_POINT br; /* Bottom right point */ 
  89.     } P_RECT;
  90.  
  91. /* Notify the user that an error has occured */
  92.  
  93. error(e,s)
  94. int e;
  95. char *s;
  96. {
  97.     GenNotifyError (e,s,0,0,0);
  98.     exit(0);
  99. }
  100.  
  101.  
  102. main(argc,argv)
  103. int argc,*argv;
  104. {
  105.     CONSOLE_INFO    cinfo;
  106.     WS_EV    event;
  107.  
  108. #ifdef s3
  109. /* Open an s3 shell with no cursor, 20x5 chars big */
  110.     openshell(WS_FONT_BASE+4,TRUE,FALSE,20,5);
  111. #else
  112. /* Open an s3a shell with no cursor, 50x17 chars big */
  113.     openshell(WS_FONT_BASE+4,FALSE,FALSE,50,17);
  114. #endif
  115.  
  116. /* Get the shell's window handle */
  117.     IoWithWait(P_FINQ,stdout,cinfo,0);
  118.  
  119. /* Create a graphics context and print to it*/
  120.     gCreateGC(cinfo.window_handle,0,0);
  121.     gPrintText(10,20,"Hello world",11);
  122.  
  123. /* Make a simple border around our window */
  124.     gBorder(W_BORD_SHADOW_ON|W_BORD_SHADOW_D|W_BORD_CUSHION);
  125.  
  126. /* Wait for a keypress */
  127.     wGetEvent(event);
  128.     do{
  129.             IoWaitForSignal();
  130.     }while (event.type!=WM_KEY);
  131.  
  132.  
  133. /* ALWAYS remember to use exit() to end the program */
  134.     exit(0);
  135. }
  136.  
  137.