VGA.I 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. ;
  2. ; Command & Conquer Red Alert(tm)
  3. ; Copyright 2025 Electronic Arts Inc.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 3 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ;****************************************************************************
  19. ;*
  20. ;* C O N F I D E N T I A L -- W E S T W O O D S T U D I O S
  21. ;*
  22. ;*---------------------------------------------------------------------------
  23. ;*
  24. ;* FILE
  25. ;* vga.i
  26. ;*
  27. ;* DESCRIPTION
  28. ;* VGA hardware definitions. (32-Bit protected mode)
  29. ;*
  30. ;* PROGRAMMER
  31. ;* Denzil E. Long, Jr.
  32. ;*
  33. ;* DATE
  34. ;* January 26, 1995
  35. ;*
  36. ;****************************************************************************
  37. ;----------------------------------------------------------------------------
  38. ; VGA Registers
  39. ;----------------------------------------------------------------------------
  40. R_SEQUENCER EQU 03C4h ;Sequencer Controller Index reg
  41. SEQ_RESET EQU 00h ;Reset
  42. SEQ_MAP_MASK EQU 02h ;Index in Sequencer of Map Mask reg
  43. SEQ_MEMORY_MODE EQU 04h ;Memory Mode
  44. R_GRAPHICS_CONTROLLER EQU 03CEh ;Graphics Controller Index reg
  45. GC_READ_MAP EQU 04h ;Index in GController of Read Map reg
  46. GC_MODE EQU 05h ;Read/Write Modes
  47. GC_MISC EQU 06h ;Read/Write Modes
  48. GC_BITMASK EQU 08h ;Index in GController of BitMask reg
  49. R_CRT_CONTROLLER EQU 03D4h ;CRT Controller Index reg
  50. CRT_VERT_TOTAL EQU 06h ;Vertical total
  51. CRT_OVERFLOW EQU 07h ;Overflow
  52. CRT_MAX_SCANLINE EQU 09h ;Max scan line
  53. CRT_STARTADDR_HIGH EQU 0Ch ;Bitmap start address high byte
  54. CRT_STARTADDR_LOW EQU 0Dh ;Bitmap start address low byte
  55. CRT_VERTRET_START EQU 010h ;Vertical retrace pulse start
  56. CRT_VERTRET_END EQU 011h ;Vertical retrace pulse end
  57. CRT_VERTDISP_END EQU 012h ;Vertical display end
  58. CRT_UNDERLINE EQU 014h ;Underline location
  59. CRT_START_VB EQU 015h ;Start vertical blank
  60. CRT_END_VB EQU 016h ;End vertical blank
  61. CRT_MODE_CONTROL EQU 017h ;Mode control
  62. R_MISC_OUTPUT EQU 03C2h ;Miscellaneous Output reg
  63. ;----------------------------------------------------------------------------
  64. ; Palette Registers
  65. ;----------------------------------------------------------------------------
  66. PEL_READ_ADDR EQU 03C7h
  67. PEL_WRITE_ADDR EQU 03C8h
  68. PEL_DATA EQU 03C9h
  69. ;----------------------------------------------------------------------------
  70. ; XMode planes, for the Map Mask register
  71. ;----------------------------------------------------------------------------
  72. XPLANE_1 EQU 1
  73. XPLANE_2 EQU 2
  74. XPLANE_3 EQU 4
  75. XPLANE_4 EQU 8
  76. ;----------------------------------------------------------------------------
  77. ;
  78. ; NAME
  79. ; SET_PLANE - Set an XMode plane.
  80. ;
  81. ; SYNOPSIS
  82. ; SET_PLANE plane
  83. ;
  84. ; INPUTS
  85. ; plane - Number of Xmode plane to set.
  86. ;
  87. ; USES
  88. ; eax, edx
  89. ;
  90. ;----------------------------------------------------------------------------
  91. MACRO SET_PLANE plane
  92. mov edx,R_SEQUENCER
  93. mov eax,SEQ_MAP_MASK
  94. out dx,al
  95. inc edx
  96. mov eax,plane
  97. out dx,al
  98. ENDM
  99. ;----------------------------------------------------------------------------
  100. ;
  101. ; NAME
  102. ; SET_BITMASK - Set the BitMask register.
  103. ;
  104. ; SYNOPSIS
  105. ; SET_BITMASK mask
  106. ;
  107. ; INPUTS
  108. ; mask - Bitmask to use.
  109. ;
  110. ; USES
  111. ; eax, edx
  112. ;
  113. ;----------------------------------------------------------------------------
  114. MACRO SET_BITMASK mask
  115. mov edx,R_GRAPHICS_CONTROLLER
  116. mov eax,GC_BITMASK
  117. out dx,al
  118. inc edx
  119. mov eax,mask
  120. out dx,al
  121. ENDM
  122. ;----------------------------------------------------------------------------
  123. ;
  124. ; NAME
  125. ; SET_WRITEMODE - Set the VGA writemode.
  126. ;
  127. ; SYNOPSIS
  128. ; SET_WRITEMODE mode
  129. ;
  130. ; INPUTS
  131. ; mode - Write mode.
  132. ;
  133. ; USES
  134. ; eax, edx
  135. ;
  136. ;----------------------------------------------------------------------------
  137. MACRO SET_WRITEMODE mode
  138. mov edx,R_GRAPHICS_CONTROLLER
  139. mov eax,GC_MODE
  140. out dx,al
  141. inc edx
  142. in al,dx ;Read the register
  143. and al,0FCh ;Turn off 2 lower bits
  144. or al,mode ;Set write mode
  145. out dx,al
  146. ENDM
  147. ;----------------------------------------------------------------------------
  148. ;
  149. ; NAME
  150. ; OUTPORT - Output data to a VGA register.
  151. ;
  152. ; SYNOPSIS
  153. ; OUTPORT port,register,data
  154. ;
  155. ; INPUTS
  156. ; port - Port address.
  157. ; register - Register to write to.
  158. ; data - Data to write.
  159. ;
  160. ; USES
  161. ; eax, edx
  162. ;
  163. ;----------------------------------------------------------------------------
  164. MACRO OUTPORT port,register,data
  165. mov edx,port
  166. mov al,register
  167. out dx,al
  168. inc edx
  169. mov al,data
  170. out dx,al
  171. ENDM
  172. ;----------------------------------------------------------------------------
  173. ;
  174. ; NAME
  175. ; INPORT - Input data from a VGA register.
  176. ;
  177. ; SYNOPSIS
  178. ; data = INPORT port,register
  179. ;
  180. ; INPUTS
  181. ; port - Port address.
  182. ; register - Register to read from.
  183. ;
  184. ; RESULT
  185. ; data - Value read from port in AL.
  186. ;
  187. ; USES
  188. ; eax, edx
  189. ;
  190. ;----------------------------------------------------------------------------
  191. MACRO INPORT port,register
  192. mov edx,port
  193. mov al,register
  194. out dx,al
  195. inc edx
  196. in al,dx
  197. ENDM