home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SLOWRUNS.ZIP / SLOWSRC.ZIP / MAGIC3.H < prev    next >
C/C++ Source or Header  |  1997-06-30  |  6KB  |  183 lines

  1. #define GRAPHICS_MODE13        0x13      /* 320x200x256 */
  2. #define TEXT_MODE            0x03      /* 80x25 text mode */
  3.  
  4. #define COLOR_MASK            0x3C6     // the bit mask register
  5. #define COLOR_REGISTER_RD    0x3C7   // set read index at this I/O
  6. #define COLOR_REGISTER_WR    0x3C8    // set write index at this I/O
  7. #define COLOR_DATA            0x3C9    // the R/W data is here
  8.  
  9. #define ROM_CHAR_SET_SEG     0xF000    // segment of 8x8 ROM character set
  10. #define ROM_CHAR_SET_OFF    0xFA6E  // beginning offset of 8x8 ROM character set
  11. #define ROM_CHAR_HEIGHT        8
  12. #define ROM_CHAR_WIDTH        8
  13. #define MODE13_WIDTH        (unsigned int)320        // offset to next line of 8x8 ROM character
  14.  
  15. #define MODE_Y_WIDTH        (unsigned int)80    // offset to next line of video buffer
  16.  
  17. #define MODE_X_WIDTH        (unsigned int)80
  18.  
  19. #define SCREEN_WIDTH      (unsigned int)320
  20. #define SCREEN_HEIGHT     (unsigned int)200
  21.  
  22. #define SPRITE_WIDTH      16
  23. #define SPRITE_HEIGHT     16
  24.  
  25. #define MAX_SPRITE_FRAMES 24
  26. #define SPRITE_DEAD       0
  27. #define SPRITE_ALIVE      1
  28. #define SPRITE_DYING      2
  29.  
  30.  
  31. // Mode Z defines ////////////////
  32. // ...the VGA card controller ports
  33.  
  34. #define SEQUENCER                0x3C4    // the sequencer's index port
  35. #define CRT_CONTROLLER            0x3D4    // the crt controller's index port
  36. #define GFX_CONTROLLER            0x3CE    // the graphics controller's index port
  37. #define GC_DATA_REG                0x3CF
  38. #define ATTR_CONTROLLER_FF      0x3DA    // the attribute controller's Flip Flop
  39. #define ATTR_CONTROLLER_DATA    0x3C0    // the attribute controller's data port
  40.  
  41. #define VGA_INPUT_STATUS_1        0x3DA   // vertical retrace flag
  42. #define VGA_VRETRACE_MASK         0x08    // masks off unwanted bit of status reg
  43.  
  44. #define VR_BIT (0x08)
  45. #define DISPLAY_ENABLE (0x01)
  46.  
  47. // ...defines for the CRT controller registers of interest
  48.  
  49. #define CRT_MAX_SCANLINE        0x09    // the maximum scanline register
  50.                                         // used to select how many scanlines
  51.                                         // per row
  52.  
  53. #define CRT_ADDR_MODE            0x14    // the address mode register
  54.                                         // used to select byte addressing
  55.                                         // for VGA
  56.                                         // also known as the underline register
  57.  
  58. #define CRT_MODE_CONTROL        0x17    // the mode control register
  59.                                         // used to select single byte addressing
  60.  
  61. // ...defines for the GFX controller registers of interest
  62.  
  63. #define GFX_WRITE_MODE            0x05    // the memory write mode register
  64.                                         // used to deselect even/odd plane
  65.                                         // addressing
  66.  
  67. #define GFX_MISC                0x06    // the miscellaneous register
  68.                                         // used to deselect the chaining
  69.                                         // of memory
  70.  
  71. // ...defines for the SEQUENCER registers of interest
  72.  
  73. #define SEQ_PLANE_ENABLE        0x02    // plane enable register, used to select
  74.                                         // which planes are written to by a
  75.                                         // CPU write
  76.  
  77. #define SEQ_MEMORY_MODE            0x04    // the memory mode register
  78.                                         // used to deselect memory chain mode
  79.                                         // and odd/even memory addressing
  80.  
  81. // MODEX DEFINES /////////////////////////////////////////////////
  82.  
  83. #define MISC_OUTPUT_REG                0x3C2
  84.  
  85. #define CRTC_INDEX_REG                0x3D4
  86.  
  87. #define VERT_TOTAL_INDEX            0x06
  88. #define OVERFLOW_INDEX                0x07
  89. #define MAX_SCAN_LINE_INDEX            0x09
  90. #define VERT_RETRACE_START_INDEX    0x10
  91. #define VERT_RETRACE_END_INDEX        0x11
  92. #define VERT_DISPLAY_END_INDEX        0x12
  93. #define UNDERLINE_LOCATION_INDEX    0x14
  94. #define START_VERT_BLANK_INDEX        0x15
  95. #define END_VERT_BLANK_INDEX        0x16
  96. #define MODE_CONTROL_INDEX            0x17
  97.  
  98. // M A C R O S - for use with MODE Z //////////////////////////////
  99.  
  100. #define SET_BITS(x,bits)    (x | bits)     // used to set bits in a word
  101. #define RESET_BITS(x,bits)  (x & ~bits) // used to reset bits in a word
  102.  
  103.  
  104. // S T R U C T U R E S //////////////////
  105. // this structure holds a RGB triple in three unsigned bytes
  106. typedef struct RGB_color_typ
  107. {
  108.     unsigned char red;        //red component of color 0-63
  109.     unsigned char green;    //green component of color 0-63
  110.     unsigned char blue;        //blue component of color 0-63
  111. } RGB_color, *RGB_color_ptr;
  112.  
  113. typedef struct RGB_palette_typ
  114. {
  115.     int start_reg;    // index of the starting register that is saved
  116.     int end_reg;    // index of the ending register that is saved
  117.     RGB_color colors[256];     // the storage area for the palette
  118. } RGB_palette, *RGB_palette_ptr;
  119.  
  120. // G L O B A L S /////////////////////////////////////////////////////////////
  121.  
  122. extern unsigned char far *video_buffer;   // video ram byte ptr
  123. extern unsigned char far *rom_char_set;   // rom characters 8x8
  124.  
  125. // ...The following are all function prototypes used by MAGIC3.C
  126.  
  127. void Time_Delay(int clicks);
  128.  
  129. // Elementary Graphics Functions
  130.  
  131. void Set_Graphics_Mode(int mode);
  132. void Fill_Screen(int color);
  133.  
  134. void Write_Pixel(int x, int y, int color);
  135. int Read_Pixel(int x, int y);
  136.  
  137. void Line_H(int x1, int x2, int y, int color);
  138. void Line_V(int y1, int y2, int x, int color);
  139.  
  140. void Draw_Rectangle(int x1, int y1, int x2, int y2, int color);
  141.  
  142. // palette functions
  143.  
  144. void Write_Color_Reg(int index, RGB_color_ptr color);
  145. RGB_color_ptr Read_Color_Reg(int index, RGB_color_ptr color);
  146. void Read_Palette(int start_reg, int end_reg, RGB_palette_ptr the_palette);
  147. void Write_Palette(int start_reg,int end_reg, RGB_palette_ptr the_palette);
  148.  
  149. void Print_Char(int xc, int yc, char c, int color, int transparent);
  150. void Print_String(int x, int y, int color, char *string, int transparent);
  151.  
  152. // mode Z functions
  153.  
  154. void Set_Mode_Z(void);
  155. void Fill_Screen_Z(int color);
  156. void Write_Pixel_Z(int x, int y, int color);
  157.  
  158. void Line_H_Mode_Z(int x1, int x2, int y, int color);
  159. void Line_V_Mode_Z(int y1, int y2, int x, int color);
  160.  
  161. // Mode Y Functions
  162.  
  163. void Set_Mode_Y(void);
  164. void Fill_Screen_Y(int color);
  165. void Write_Pixel_Y(int x, int y, int color);
  166.  
  167. void Print_Char_Mode_Y(int xc, int yc, char c, int color, int transparent);
  168. void Print_String_Mode_Y(int x, int y, int color, char *string, int transparent);
  169.  
  170. void Line_H_Mode_Y(int x1, int x2, int y, int color);
  171. void Line_V_Mode_Y(int y1, int y2, int x, int color);
  172.  
  173. // Mode X Functions
  174.  
  175. void Set_Mode_X(void);
  176.  
  177. // new routines hijacked from someone elses material...
  178.  
  179. void Wait_Vertical_Retrace_End(void);
  180. void Wait_Display_Mode(void);
  181. void Wait_Retrace_Mode(void);
  182. int Vertical_Retrace_Occuring(void);
  183.