home *** CD-ROM | disk | FTP | other *** search
/ Black Art of 3D Game Programming / Black_Art_of_3D_Game_Programming.iso / source / msc / library / black3.h < prev    next >
Text File  |  1994-10-31  |  5KB  |  137 lines

  1.  
  2. // Header file for chapter 3 - BLACK3.H
  3.  
  4. // D E F I N E S /////////////////////////////////////////////////////////////
  5.  
  6. #define GRAPHICS_MODE13     0x13  // 320x200x256
  7. #define TEXT_MODE           0x03  // 80x25 text mode
  8.  
  9. #define COLOR_MASK        0x3C6 // the bit mask register
  10. #define COLOR_REGISTER_RD 0x3C7 // set read index at this I/O
  11. #define COLOR_REGISTER_WR 0x3C8 // set write index at this I/O
  12. #define COLOR_DATA        0x3C9 // the R/W data is here
  13.  
  14. #define ROM_CHAR_SET_SEG 0xF000   // segment of 8x8 ROM character set
  15. #define ROM_CHAR_SET_OFF 0xFA6E   // begining offset of 8x8 ROM character set
  16.  
  17. #define ROM_CHAR_WIDTH      8     // width of ROM 8x8 character set in pixels
  18. #define ROM_CHAR_HEIGHT     8     // height of ROM 8x8 character set in pixels
  19.  
  20. #define MODE13_WIDTH   (unsigned int)320 // mode 13h screen dimensions
  21. #define MODE13_HEIGHT  (unsigned int)200
  22.  
  23. // the VGA card controller ports
  24.  
  25. #define SEQUENCER             0x3C4    // the sequencer's index port
  26. #define CRT_CONTROLLER        0x3D4    // the crt controller's index port
  27. #define GFX_CONTROLLER        0x3CE    // the graphics controller's index port
  28. #define ATTR_CONTROLLER_FF    0x3DA    // the attribute controller's Flip Flop
  29. #define ATTR_CONTROLLER_DATA  0x3C0    // the attribute controller's data port
  30.  
  31. // defines for the CRT controller registers of interest
  32.  
  33. #define CRT_MAX_SCANLINE      0x09     // the maximum scanline register
  34.                                        // used to select how many scanlines
  35.                                        // per row
  36.  
  37. #define CRT_ADDR_MODE         0x14     // the address mode register
  38.                                        // used to select byte addressing
  39.                                        // for VGA
  40.                                        // also known as the underline register
  41.  
  42. #define CRT_MODE_CONTROL      0x17     // the mode control register
  43.                                        // used to select single byte addressing
  44.  
  45.  
  46. // defines for the GFX controller registers of interest
  47.  
  48. #define GFX_WRITE_MODE       0x05      // the memory write mode register
  49.                                        // used to deselect even/odd plane
  50.                                        // addressing
  51.  
  52. #define GFX_MISC             0x06      // the miscellaneous register
  53.                                        // used to deselect the chaining
  54.                                        // of memory
  55.  
  56.  
  57. // defines for the SEQUENCER registers of interest
  58.  
  59. #define SEQ_PLANE_ENABLE     0x02      // plane enable register, used to select
  60.                                        // which planes are written to by a
  61.                                        // CPU write
  62. #define SEQ_MEMORY_MODE      0x04      // the memory mode register
  63.                                        // used to deselect memory chain mode
  64.                                        // and odd/even memory addressing
  65.  
  66. // M A C R O S ///////////////////////////////////////////////////////////////
  67.  
  68. #define SET_BITS(x,bits)   (x | bits)
  69. #define RESET_BITS(x,bits) (x & ~bits)
  70.  
  71. // S T R U C T U R E S ///////////////////////////////////////////////////////
  72.  
  73. // this structure holds a RGB triple in three unsigned bytes
  74.  
  75. typedef struct RGB_color_typ
  76.         {
  77.  
  78.         unsigned char red;    // red   component of color 0-63
  79.         unsigned char green;  // green component of color 0-63
  80.         unsigned char blue;   // blue  component of color 0-63
  81.  
  82.         } RGB_color, *RGB_color_ptr;
  83.  
  84. // this structure holds an entire color palette
  85.  
  86. typedef struct RGB_palette_typ
  87.         {
  88.         int start_reg;   // index of the starting register that is save
  89.         int end_reg;     // index of the ending registe that is saved
  90.  
  91.         RGB_color colors[256];   // the storage area for the palette
  92.  
  93.         } RGB_palette, *RGB_palette_ptr;
  94.  
  95. // P R O T O T Y P E S ///////////////////////////////////////////////////////
  96.  
  97. void Print_Char(int xc,int yc,char c,int color,int transparent);
  98.  
  99. void Print_String(int x,int y,int color, char *string,int transparent);
  100.  
  101. void Write_Pixel(int x,int y,int color);
  102.  
  103. int Read_Pixel(int x,int y);
  104.  
  105. void Set_Graphics_Mode(int mode);
  106.  
  107. void Time_Delay(int clicks);
  108.  
  109. void Line_H(int x1,int x2,int y,int color);
  110.  
  111. void Line_V(int y1,int y2,int x,int color);
  112.  
  113. void Write_Color_Reg(int index, RGB_color_ptr color);
  114.  
  115. void Read_Palette(int start_reg,int end_reg, RGB_palette_ptr the_palette);
  116.  
  117. void Write_Palette(int start_reg,int end_reg, RGB_palette_ptr the_palette);
  118.  
  119. RGB_color_ptr Read_Color_Reg(int index, RGB_color_ptr color);
  120.  
  121. void Draw_Rectangle(int x1,int y1,int x2,int y2,int color);
  122.  
  123. void Fill_Screen(int color);
  124.  
  125. void Fill_Screen_Z(int color);
  126.  
  127. void Write_Pixel_Z(int x,int y,int color);
  128.  
  129. void Set_Mode_Z(void);
  130.  
  131. // G L O B A L S /////////////////////////////////////////////////////////////
  132.  
  133. extern unsigned char far *video_buffer;   // video ram byte ptr
  134. extern unsigned char far *rom_char_set;   // rom characters 8x8
  135.  
  136.  
  137.