VESA.ASM 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. ;** 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 **
  20. ;***************************************************************************
  21. ;* *
  22. ;* Project Name : Westwood 32 bit Library *
  23. ;* *
  24. ;* File Name : VESA.ASM *
  25. ;* *
  26. ;* Programmer : Phil W. Gorrow *
  27. ;* *
  28. ;* Start Date : December 8, 1994 *
  29. ;* *
  30. ;* Last Update : December 8, 1994 [PWG] *
  31. ;* *
  32. ;*-------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* Vesa_Asm_Set_Win -- Sets the current vesa window from Asm *
  35. ;* Vesa_Asm_Next_Window -- Sets to the next vesa window *
  36. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  37. IDEAL
  38. P386
  39. MODEL USE32 FLAT
  40. LOCALS ??
  41. INCLUDE "svgaprim.inc"
  42. GLOBAL RMVesaVector : DWORD
  43. GLOBAL RMVesaRegs : DWORD
  44. DPMI_INTR EQU 31h
  45. STRUC DPMI_REGS
  46. _edi dd ?
  47. _esi dd ?
  48. _ebp dd ?
  49. dd ?
  50. _ebx dd ?
  51. _edx dd ?
  52. _ecx dd ?
  53. _eax dd ?
  54. Flags dw ?
  55. _es dw ?
  56. _ds dw ?
  57. _fs dw ?
  58. _gs dw ?
  59. _ip dw ?
  60. _cs dw ?
  61. _sp dw ?
  62. _ss dw ?
  63. dd ?
  64. ENDS
  65. DATASEG
  66. cpu_video_page dd 0h
  67. cpu_page_limit dd 0b0000h
  68. CurrentBank DD 0h ; current vesa bank
  69. RealFunc DPMI_REGS ? ; structure to call a real mode int
  70. CODESEG
  71. ;***************************************************************************
  72. ;* VESA_ASM_SET_WIN -- Sets the current vesa window from Asm *
  73. ;* *
  74. ;* INPUT: edi - offset to set the window for *
  75. ;* *
  76. ;* OUTPUT: edi - adjusted offset for window *
  77. ;* *
  78. ;* PROTO: void Vesa_Asm_Set_Win(void); *
  79. ;* *
  80. ;* HISTORY: *
  81. ;* 12/08/1994 PWG : Created. *
  82. ;*=========================================================================*
  83. PROC Vesa_Asm_Set_Win C near
  84. push eax
  85. push edi
  86. push ecx
  87. push ebx
  88. mov eax , edi
  89. and eax , 0ffff0000h
  90. add eax , 010000h
  91. mov [ cpu_page_limit ] , eax
  92. lea eax , [ edi - 0a0000h ]
  93. and eax , 0ffff0000h
  94. mov [ cpu_video_page ] , eax
  95. shr eax , 14
  96. cmp eax , [ CurrentBank ]
  97. jz ??no_change
  98. mov [CurrentBank],eax ; it will be new current bank
  99. mov ebx , [ BankTable + eax ] ; find gran value of new bank
  100. mov edi , [ RMVesaRegs ] ; clean up RMRegister bank
  101. xor eax , eax
  102. mov ecx , 34h / 4 ; size of RMRegs Bank
  103. rep stosd
  104. mov edi , [ RMVesaRegs ]
  105. mov [(type DPMI_REGS ptr edi ) . _eax ] , 04f05h
  106. mov [(type DPMI_REGS ptr edi ) . _ebx ] , 0
  107. mov [(type DPMI_REGS ptr edi ) . _edx ] , ebx
  108. mov eax , 0300h
  109. xor ecx , ecx ; set amount to copy of stack
  110. mov ebx , [ RMVesaVector] ; set pointer to func to call
  111. int DPMI_INTR ; make the call
  112. ??no_change:
  113. pop ebx
  114. pop ecx
  115. pop edi
  116. pop eax
  117. and edi,0000ffffh ; adjust edi to be 64k
  118. add edi,0a0000h
  119. ret
  120. ENDP Vesa_Asm_Set_Win
  121. END