home *** CD-ROM | disk | FTP | other *** search
/ Teach Yourself Game Programming in 21 Days / TYGAMES_R.ISO / source / day_11 / graph11.h < prev    next >
Text File  |  1994-08-25  |  4KB  |  149 lines

  1. // GRAPH11.H
  2.  
  3.  
  4. // D E F I N E S //////////////////////////////////////////////////////////////
  5.  
  6. #define KEYBOARD_INT    0x09   // the keyboard interrupt number
  7. #define KEY_BUFFER      0x60   // the location of the keyboard buffer
  8. #define KEY_CONTROL     0x61   // the location of the keyboard controller
  9. #define INT_CONTROL     0x20   // the location of the interrupt controller
  10.  
  11. // make and break codes for the arrow keys (note the make codes are the
  12. // same as the scan codes and the break codes are just the scan codes plus
  13. // 128.  For example the scan code for the UP key is 72 which is the make
  14. // code.  if we add 128 to this then the result is 128+72 = 200.
  15.  
  16. // arrow keys
  17.  
  18. #define MAKE_RIGHT      77
  19. #define MAKE_LEFT       75
  20. #define MAKE_UP         72
  21. #define MAKE_DOWN       80
  22.  
  23. // some useful control keys
  24.  
  25. #define MAKE_ENTER      28
  26. #define MAKE_TAB        15
  27. #define MAKE_SPACE      57
  28. #define MAKE_CTRL       29
  29. #define MAKE_ALT        56
  30. #define MAKE_ESC        1
  31.  
  32. // and now the break codes
  33.  
  34. #define BREAK_RIGHT     205
  35. #define BREAK_LEFT      203
  36. #define BREAK_UP        200
  37. #define BREAK_DOWN      208
  38.  
  39. #define BREAK_ENTER     156
  40. #define BREAK_TAB       143
  41. #define BREAK_SPACE     185
  42. #define BREAK_CTRL      157
  43. #define BREAK_ALT       184
  44. #define BREAK_ESC       129
  45.  
  46. // indices into arrow key state table
  47.  
  48. #define INDEX_UP        0
  49. #define INDEX_DOWN      1
  50. #define INDEX_RIGHT     2
  51. #define INDEX_LEFT      3
  52.  
  53. #define INDEX_ENTER     4
  54. #define INDEX_TAB       5
  55. #define INDEX_SPACE     6
  56. #define INDEX_CTRL      7
  57. #define INDEX_ALT       8
  58. #define INDEX_ESC       9
  59.  
  60. #define NUM_KEYS       10  // number of keys in look up table
  61.  
  62. // timer defines
  63.  
  64. #define CONTROL_8253  0x43  // the 8253's control register
  65. #define CONTROL_WORD  0x3C  // the control word to set mode 2,binary least/most
  66. #define COUNTER_0     0x40  // counter 0
  67. #define COUNTER_1     0x41  // counter 1
  68. #define COUNTER_2     0x42  // counter 2
  69.  
  70. #define TIMER_60HZ    0x4DAE // 60 hz
  71. #define TIMER_50HZ    0x5D37 // 50 hz
  72. #define TIMER_40HZ    0x7486 // 40 hz
  73. #define TIMER_30HZ    0x965C // 30 hz
  74. #define TIMER_20HZ    0xE90B // 20 hz
  75. #define TIMER_18HZ    0xFFFF // 18.2 hz (the standard count and the slowest possible)
  76.  
  77. // interrupt table defines
  78.  
  79. #define TIME_KEEPER_INT     0x1C    // the time keeper interrupt
  80.  
  81. // multi-tasking kernal defines
  82.  
  83. #define MAX_TASKS      16  // this should be enough to turn your brains to mush
  84. #define TASK_INACTIVE  0   // this is an inactive task
  85. #define TASK_ACTIVE    1   // this is an active task
  86. #define NUM_STARS 50
  87.  
  88. // M A C R O S ///////////////////////////////////////////////////////////////
  89.  
  90. #define LOW_BYTE(n) (n & 0x00ff)       // extracts the low-byte of a word
  91. #define HI_BYTE(n)  ((n>>8) & 0x00ff)  // extracts the hi-byte of a word
  92.  
  93. // S T U C T U R E S /////////////////////////////////////////////////////////
  94.  
  95. // this is a single task structure
  96.  
  97. typedef struct task_typ
  98.         {
  99.  
  100.         int id;             // the id number for this task
  101.         int state;          // the state of this task
  102.         void (far *task)(); // the function pointer to the task itself
  103.  
  104.         } task, *task_ptr;
  105.  
  106. // P R O T O T Y P E S ///////////////////////////////////////////////////////
  107.  
  108. void _interrupt _far New_Key_Int();
  109.  
  110. void Install_Keyboard(void);
  111.  
  112. void Delete_Keyboard(void);
  113.  
  114. void Change_Timer(unsigned int new_count);
  115.  
  116. // multi-tasking stuff
  117.  
  118. void Initialize_Kernal(void);
  119.  
  120. void Start_Kernal(void);
  121.  
  122. void Stop_Kernal(void);
  123.  
  124. int Add_Task(void (far *function)());
  125.  
  126. int Delete_Task(int id);
  127.  
  128. void _interrupt far Multi_Kernal(void);
  129.  
  130. // E X T E R N A L  G L O B A L S ////////////////////////////////////////////
  131.  
  132. extern void (_interrupt _far *Old_Key_Isr)();  // holds old keyboard interrupt handler
  133.  
  134. extern int raw_key;  // the global raw keyboard data
  135.  
  136. // the arrow key state table
  137.  
  138. extern int key_table[NUM_KEYS];
  139.  
  140.  
  141. extern void (_interrupt far *Old_Time_Isr)();  // used to hold old interrupt vector
  142.  
  143. // multi-tasking stuff
  144.  
  145. extern task tasks[MAX_TASKS];             // this is the task list for the system
  146.  
  147. extern int num_tasks;                 // tracks number of active tasks
  148.  
  149.