vga.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // Wengier: BLINK support
  2. #ifndef VDOS_VGA_H
  3. #define VDOS_VGA_H
  4. #include "vDos.h"
  5. class PageHandler;
  6. enum VGAModes {
  7. M_EGA,
  8. M_TEXT,
  9. M_ERROR
  10. };
  11. struct VideoModeBlock {
  12. Bit16u mode;
  13. VGAModes type;
  14. Bitu swidth, sheight;
  15. Bitu twidth, theight;
  16. Bitu cwidth, cheight;
  17. Bitu ptotal, pstart, plength;
  18. Bitu htotal, vtotal;
  19. Bitu hdispend, vdispend;
  20. };
  21. extern VideoModeBlock ModeList_VGA[];
  22. extern VideoModeBlock * CurMode;
  23. typedef struct {
  24. // Video drawing
  25. Bitu display_start;
  26. bool retrace; // A retrace is active
  27. Bitu scan_len;
  28. Bitu cursor_start;
  29. // Specific stuff memory write/read handling
  30. Bit8u read_mode;
  31. Bit8u write_mode;
  32. Bit8u read_map_select;
  33. Bit8u color_dont_care;
  34. Bit8u color_compare;
  35. Bit8u data_rotate;
  36. Bit8u raster_op;
  37. Bit32u full_bit_mask;
  38. Bit32u full_map_mask;
  39. Bit32u full_not_map_mask;
  40. Bit32u full_set_reset;
  41. Bit32u full_not_enable_set_reset;
  42. Bit32u full_enable_set_reset;
  43. Bit32u full_enable_and_set_reset;
  44. } VGA_Config;
  45. typedef struct {
  46. Bitu width;
  47. Bitu height;
  48. bool vertRetrace;
  49. struct {
  50. Bitu address;
  51. Bit8u sline, eline;
  52. Bit8u count;
  53. bool blinkon;
  54. Bit8u enabled;
  55. } cursor;
  56. } VGA_Draw;
  57. typedef struct {
  58. Bit8u index;
  59. Bit8u reset;
  60. Bit8u clocking_mode;
  61. Bit8u map_mask;
  62. Bit8u character_map_select;
  63. Bit8u memory_mode;
  64. } VGA_Seq;
  65. typedef struct {
  66. Bit8u palette[16];
  67. Bit8u mode_control;
  68. Bit8u horizontal_pel_panning;
  69. Bit8u color_plane_enable;
  70. Bit8u color_select;
  71. Bit8u index;
  72. } VGA_Attr;
  73. typedef struct {
  74. Bit8u horizontal_total;
  75. Bit8u horizontal_display_end;
  76. Bit8u start_horizontal_blanking;
  77. Bit8u end_horizontal_blanking;
  78. Bit8u start_horizontal_retrace;
  79. Bit8u end_horizontal_retrace;
  80. Bit8u vertical_total;
  81. Bit8u overflow;
  82. Bit8u preset_row_scan;
  83. Bit8u maximum_scan_line;
  84. Bit8u cursor_start;
  85. Bit8u cursor_end;
  86. Bit8u start_address_high;
  87. Bit8u start_address_low;
  88. Bit8u cursor_location_high;
  89. Bit8u cursor_location_low;
  90. Bit8u vertical_retrace_start;
  91. Bit8u vertical_retrace_end;
  92. Bit8u vertical_display_end;
  93. Bit8u offset;
  94. Bit8u underline_location;
  95. Bit8u start_vertical_blanking;
  96. Bit8u end_vertical_blanking;
  97. Bit8u mode_control;
  98. Bit8u line_compare;
  99. Bit8u index;
  100. } VGA_Crtc;
  101. typedef struct {
  102. Bit8u index;
  103. Bit8u set_reset;
  104. Bit8u enable_set_reset;
  105. Bit8u color_compare;
  106. Bit8u data_rotate;
  107. Bit8u read_map_select;
  108. Bit8u mode;
  109. Bit8u miscellaneous;
  110. Bit8u color_dont_care;
  111. Bit8u bit_mask;
  112. } VGA_Gfx;
  113. typedef struct {
  114. Bit8u red;
  115. Bit8u green;
  116. Bit8u blue;
  117. } RGBEntry;
  118. typedef struct {
  119. Bit8u pel_mask;
  120. Bit8u pel_index;
  121. Bit8u state;
  122. Bit8u write_index;
  123. Bit8u read_index;
  124. Bit8u combine[16];
  125. RGBEntry rgb[256];
  126. // Bit16u xlat16[256];
  127. Bit8u hidac_counter;
  128. } VGA_Dac;
  129. typedef union {
  130. Bit32u d;
  131. Bit8u b[4];
  132. } VGA_Latch;
  133. typedef struct {
  134. VGAModes mode; // The mode the vga system is in
  135. Bit8u misc_output;
  136. VGA_Draw draw;
  137. VGA_Config config;
  138. bool attrindex;
  139. // Internal module groups
  140. VGA_Seq seq;
  141. VGA_Attr attr;
  142. VGA_Crtc crtc;
  143. VGA_Gfx gfx;
  144. VGA_Dac dac;
  145. VGA_Latch latch;
  146. Bit8u* memlinear;
  147. Bit8u* fastmem; // Memory for fast (usually 16-color) rendering, always twice as big as vmemsize
  148. Bit32u vmemsize;
  149. } VGA_Type;
  150. void VGA_VerticalTimer(void);
  151. void VGA_DetermineMode(void);
  152. void VGA_SetupHandlers(void);
  153. void VGA_StartResize(void);
  154. void VGA_ResetVertTimer(bool delay);
  155. // Some DAC/Attribute functions
  156. void VGA_DAC_CombineColor(Bit8u attr,Bit8u pal);
  157. void VGA_ATTR_SetPalette(Bit8u index,Bit8u val);
  158. // The VGA Subfunction startups
  159. void VGA_SetupAttr(void);
  160. void VGA_SetupDAC(void);
  161. void VGA_SetupCRTC(void);
  162. void VGA_SetupMisc(void);
  163. void VGA_SetupGFX(void);
  164. void VGA_SetupSEQ(void);
  165. void VGA_SetupOther(void);
  166. extern VGA_Type vga;
  167. extern Bit32u ExpandTable[256];
  168. extern Bit32u FillTable[16];
  169. extern Bit32u Expand16Table[4][16];
  170. #endif