REMAP.ASM 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 A S S O C I A T E S **
  20. ;***************************************************************************
  21. ;* *
  22. ;* Project Name : Westwood 32 bit Library *
  23. ;* *
  24. ;* File Name : REMAP.ASM *
  25. ;* *
  26. ;* Programmer : Phil W. Gorrow *
  27. ;* *
  28. ;* Start Date : July 1, 1994 *
  29. ;* *
  30. ;* Last Update : July 1, 1994 [PWG] *
  31. ;* *
  32. ;*-------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  35. IDEAL
  36. P386
  37. MODEL USE32 FLAT
  38. INCLUDE ".\drawbuff.inc"
  39. INCLUDE ".\gbuffer.inc"
  40. CODESEG
  41. PROC Buffer_Remap C NEAR
  42. USES eax,ebx,ecx,edx,esi,edi
  43. ;*===================================================================
  44. ;* Define the arguements that our function takes.
  45. ;*===================================================================
  46. ARG this_object:DWORD
  47. ARG x0_pixel:DWORD
  48. ARG y0_pixel:DWORD
  49. ARG region_width:DWORD
  50. ARG region_height:DWORD
  51. ARG remap :DWORD
  52. ;*===================================================================
  53. ; Define some locals so that we can handle things quickly
  54. ;*===================================================================
  55. local x1_pixel : DWORD
  56. local y1_pixel : DWORD
  57. local win_width : dword
  58. local counter_x : dword
  59. cmp [ remap ] , 0
  60. jz ??real_out
  61. ; Clip Source Rectangle against source Window boundaries.
  62. mov esi , [ this_object ] ; get ptr to src
  63. xor ecx , ecx
  64. xor edx , edx
  65. mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
  66. mov ebx , [ x0_pixel ]
  67. mov eax , [ x0_pixel ]
  68. add ebx , [ region_width ]
  69. shld ecx , eax , 1
  70. mov [ x1_pixel ] , ebx
  71. inc edi
  72. shld edx , ebx , 1
  73. sub eax , edi
  74. sub ebx , edi
  75. shld ecx , eax , 1
  76. shld edx , ebx , 1
  77. mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
  78. mov ebx , [ y0_pixel ]
  79. mov eax , [ y0_pixel ]
  80. add ebx , [ region_height ]
  81. shld ecx , eax , 1
  82. mov [ y1_pixel ] , ebx
  83. inc edi
  84. shld edx , ebx , 1
  85. sub eax , edi
  86. sub ebx , edi
  87. shld ecx , eax , 1
  88. shld edx , ebx , 1
  89. xor cl , 5
  90. xor dl , 5
  91. mov al , cl
  92. test dl , cl
  93. jnz ??real_out
  94. or al , dl
  95. jz ??do_remap
  96. test cl , 1000b
  97. jz ??scr_left_ok
  98. mov [ x0_pixel ] , 0
  99. ??scr_left_ok:
  100. test cl , 0010b
  101. jz ??scr_bottom_ok
  102. mov [ y0_pixel ] , 0
  103. ??scr_bottom_ok:
  104. test dl , 0100b
  105. jz ??scr_right_ok
  106. mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
  107. mov [ x1_pixel ] , eax
  108. ??scr_right_ok:
  109. test dl , 0001b
  110. jz ??do_remap
  111. mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
  112. mov [ y1_pixel ] , eax
  113. ??do_remap:
  114. cld
  115. mov edi , [ (GraphicViewPort esi) . GVPOffset ]
  116. mov eax , [ (GraphicViewPort esi) . GVPXAdd ]
  117. mov ebx , [ x1_pixel ]
  118. add eax , [ (GraphicViewPort esi) . GVPWidth ]
  119. add eax , [ (GraphicViewPort esi) . GVPPitch ]
  120. mov esi , eax
  121. mul [ y0_pixel ]
  122. add edi , [ x0_pixel ]
  123. sub ebx , [ x0_pixel ]
  124. jle ??real_out
  125. add edi , eax
  126. sub esi , ebx
  127. mov ecx , [ y1_pixel ]
  128. sub ecx , [ y0_pixel ]
  129. jle ??real_out
  130. mov eax , [ remap ]
  131. mov [ counter_x ] , ebx
  132. xor edx , edx
  133. ??outer_loop:
  134. mov ebx , [ counter_x ]
  135. ??inner_loop:
  136. mov dl , [ edi ]
  137. mov dl , [ eax + edx ]
  138. mov [ edi ] , dl
  139. inc edi
  140. dec ebx
  141. jnz ??inner_loop
  142. add edi , esi
  143. dec ecx
  144. jnz ??outer_loop
  145. ??real_out:
  146. ret
  147. ENDP Buffer_Remap
  148. END