home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / dflt14.zip / SYSTEM.H < prev    next >
Text File  |  1992-06-29  |  5KB  |  171 lines

  1. /* --------------- system.h -------------- */
  2. #ifndef SYSTEM_H
  3. #define SYSTEM_H
  4.  
  5. #if MSC | WATCOM
  6. #include <direct.h>
  7. #else
  8. #include <dir.h>
  9. #endif
  10.  
  11. #define swap(a,b){int x=a;a=b;b=x;}
  12. /* ----- interrupt vectors ----- */
  13. #define TIMER  8
  14. #define VIDEO  0x10
  15. #define KEYBRD 0x16
  16. #define DOS    0x21
  17. #define CRIT   0x24
  18. #define MOUSE  0x33
  19. #define KEYBOARDVECT 9
  20. /* ------- platform-dependent values ------ */
  21. #define KEYBOARDPORT 0x60
  22. #define FREQUENCY 100
  23. #define COUNT (1193280L / FREQUENCY)
  24. #define ZEROFLAG 0x40
  25. #define MAXSAVES 50
  26. #define SCREENWIDTH  (peekb(0x40,0x4a) & 255)
  27. #define SCREENHEIGHT (isVGA() || isEGA() ? peekb(0x40,0x84)+1 : 25)
  28. #define clearBIOSbuffer() *(int far *)(MK_FP(0x40,0x1a)) = \
  29.                           *(int far *)(MK_FP(0x40,0x1c));
  30. #define waitforkeyboard() while ((keyportvalue & 0x80) == 0) \
  31.                           clearBIOSbuffer()
  32. /* ----- keyboard BIOS (0x16) functions -------- */
  33. #define READKB 0
  34. #define KBSTAT 1
  35. /* ------- video BIOS (0x10) functions --------- */
  36. #define SETCURSORTYPE 1
  37. #define SETCURSOR     2
  38. #define READCURSOR    3
  39. #define READATTRCHAR  8
  40. #define WRITEATTRCHAR 9
  41. #define HIDECURSOR 0x20
  42. /* ------- the interrupt function registers -------- */
  43. typedef struct {
  44.     int bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,fl;
  45. } IREGS;
  46. /* ---------- keyboard prototypes -------- */
  47. int AltConvert(int);
  48. int getkey(void);
  49. int getshift(void);
  50. BOOL keyhit(void);
  51. void beep(void);
  52. /* ---------- cursor prototypes -------- */
  53. void curr_cursor(int *x, int *y);
  54. void cursor(int x, int y);
  55. void hidecursor(void);
  56. void unhidecursor(void);
  57. void savecursor(void);
  58. void restorecursor(void);
  59. void normalcursor(void);
  60. void set_cursor_type(unsigned t);
  61. void videomode(void);
  62. void SwapCursorStack(void);
  63. /* ---------- mouse prototypes ---------- */
  64. BOOL mouse_installed(void);
  65. int mousebuttons(void);
  66. void get_mouseposition(int *x, int *y);
  67. void set_mouseposition(int x, int y);
  68. void show_mousecursor(void);
  69. void hide_mousecursor(void);
  70. int button_releases(void);
  71. void resetmouse(void);
  72. void set_mousetravel(int, int, int, int);
  73. #define leftbutton()     (mousebuttons()&1)
  74. #define rightbutton()     (mousebuttons()&2)
  75. #define waitformouse()     while(mousebuttons());
  76. /* ------------ timer macros -------------- */
  77. #define timed_out(timer)         (timer==0)
  78. #define set_timer(timer, secs)     timer=(secs)*182/10+1
  79. #define disable_timer(timer)     timer = -1
  80. #define timer_running(timer)     (timer > 0)
  81. #define countdown(timer)         --timer
  82. #define timer_disabled(timer)     (timer == -1)
  83. /* ----------- video adaptor prototypes ----------- */
  84. BOOL isEGA(void);
  85. BOOL isVGA(void);
  86. void Set25(void);
  87. void Set43(void);
  88. void Set50(void);
  89.  
  90. #ifndef TURBOC
  91. #ifndef BCPP
  92. /* ============= Color Macros ============ */
  93. #define BLACK         0
  94. #define BLUE          1
  95. #define GREEN         2
  96. #define CYAN          3
  97. #define RED           4
  98. #define MAGENTA       5
  99. #define BROWN         6
  100. #define LIGHTGRAY     7
  101. #define DARKGRAY      8
  102. #define LIGHTBLUE     9
  103. #define LIGHTGREEN   10
  104. #define LIGHTCYAN    11
  105. #define LIGHTRED     12
  106. #define LIGHTMAGENTA 13
  107. #define YELLOW       14
  108. #define WHITE        15
  109. #define keyhit       kbhit
  110. #endif
  111. #endif
  112.  
  113. #if MSC | WATCOM
  114. /* ============= Compatibility Macros ============ */
  115. #define asm __asm
  116. #undef FP_OFF
  117. #undef FP_SEG
  118. #undef MK_FP
  119. #define FP_OFF(p)    ((unsigned)(p))
  120. #define FP_SEG(p)    ((unsigned)((unsigned long)(p) >> 16))
  121. #define MK_FP(s,o)   ((void far *) \
  122.                (((unsigned long)(s) << 16) | (unsigned)(o)))
  123. #define findfirst(p,f,a) _dos_findfirst(p,a,f)
  124. #define findnext(f)      _dos_findnext(f)
  125. #define ffblk            find_t
  126. #define ff_name          name
  127. #define ff_fsize         size
  128. #define ff_attrib        attrib
  129. #define poke(a,b,c)  (*((int  far*)MK_FP((a),(b))) = (int)(c))
  130. #define pokeb(a,b,c) (*((char far*)MK_FP((a),(b))) = (char)(c))
  131. #define peek(a,b)    (*((int  far*)MK_FP((a),(b))))
  132. #define peekb(a,b)   (*((char far*)MK_FP((a),(b))))
  133. #define getvect(v)   _dos_getvect(v)
  134. #define setvect(v,f) _dos_setvect(v,f)
  135. #define fnsplit          _splitpath
  136. #define fnmerge          _makepath
  137. #define EXTENSION         2
  138. #define FILENAME          4
  139. #define DIRECTORY         8
  140. #define DRIVE            16
  141. int getdisk(void);
  142. #define setdisk(d)       _dos_setdrive((d)+1, NULL)
  143. #define bioskey          _bios_keybrd
  144. #define MAXPATH          80
  145. #define MAXDRIVE          3
  146. #define MAXDIR           66
  147. #define MAXFILE           9
  148. #define MAXEXT            5
  149. #endif
  150.  
  151. typedef enum messages {
  152. #ifdef WATCOM
  153.     WATCOMFIX1 = -1,
  154. #endif
  155.     #undef DFlatMsg
  156.     #define DFlatMsg(m) m,
  157.     #include "dflatmsg.h"
  158.     MESSAGECOUNT
  159. } MESSAGE;
  160.  
  161. typedef enum window_class    {
  162. #ifdef WATCOM
  163.     WATCOMFIX2 = -1,
  164. #endif
  165.     #define ClassDef(c,b,p,a) c,
  166.     #include "classes.h"
  167.     CLASSCOUNT
  168. } CLASS;
  169.  
  170. #endif
  171.