DS_LSRS.ASM 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 : Draw Shape Routines for library. *
  23. ;* *
  24. ;* File Name : DS_LSRS.ASM *
  25. ;* *
  26. ;* Programmer : Scott K. Bowen *
  27. ;* *
  28. ;* Start Date : August 24, 1993 *
  29. ;* *
  30. ;* Last Update : June 2, 1994 [BR] *
  31. ;* *
  32. ;*-------------------------------------------------------------------------*
  33. ;* Functions: *
  34. ;* Left_Scale_Reverse_Skip -- Skips past a scaled row of pixels *
  35. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  36. ;********************* Model & Processor Directives ************************
  37. IDEAL
  38. P386
  39. MODEL USE32 FLAT
  40. ;******************************** Includes *********************************
  41. INCLUDE "shape.inc"
  42. ;********************************* Code ************************************
  43. CODESEG
  44. ;***************************************************************************
  45. ;* Left_Scale_Reverse_Skip -- Skips past a scaled row of pixels *
  46. ;* *
  47. ;* INPUT: *
  48. ;* ECX = number of uncompressed bytes to skip *
  49. ;* ESI = shape (source) buffer data address *
  50. ;* EDI = viewport (destination) address *
  51. ;* [WidthCount] = shape's width *
  52. ;* *
  53. ;* OUTPUT: *
  54. ;* ECX - negative # pixels (not bytes) overrun, or 0 *
  55. ;* EDX - XTotal initializer value *
  56. ;* ESI - updated to the current location in the shape data *
  57. ;* EDI - decremented by # pixels (not bytes) overrun *
  58. ;* [WidthCount] - decremented by # bytes skipped *
  59. ;* *
  60. ;* The value returned in EDX reflects what XTotal's accumulated value *
  61. ;* should be at the new pixel location. If no bytes are overrun, this *
  62. ;* will be whatever is stored in [XTotalInit] (which will be 0 if no *
  63. ;* pixels are left-clipped). *
  64. ;* *
  65. ;* WARNINGS: none *
  66. ;* *
  67. ;* HISTORY: *
  68. ;* 04/20/1992 PWG : Created. *
  69. ;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
  70. ;* 06/02/1994 BR : Converted to 32-bit *
  71. ;*=========================================================================*
  72. PROC Left_Scale_Reverse_Skip NOLANGUAGE NEAR
  73. sub [WidthCount],ecx ; we process ECX bytes of real width
  74. ;--------------------------------------------------------------------
  75. ; Put shape data address in EDI so we can do a scasb on it
  76. ;--------------------------------------------------------------------
  77. xchg esi,edi ; xchange ESI and EDI
  78. jcxz ??getrem ; exit if no bytes to skip
  79. ;--------------------------------------------------------------------
  80. ; Search through the string and count down the info we have handled.
  81. ; If we find a run (0 followed by a count byte), then handle it.
  82. ;--------------------------------------------------------------------
  83. ??cliptop:
  84. mov eax,0 ; set al to 0 (we're scanning for 0)
  85. repne scasb ; scan through source data
  86. jz short ??on_run ; if it is a run then deal with it
  87. ;--------------------------------------------------------------------
  88. ; Default exit point: store default x-scale bits & exit
  89. ;--------------------------------------------------------------------
  90. ??getrem:
  91. mov edx,[XTotalInit] ; store out the remainder
  92. jmp short ??out ; we're done, get outta here
  93. ;--------------------------------------------------------------------
  94. ; If we have a run then get the next byte which is the length.
  95. ;--------------------------------------------------------------------
  96. ??on_run:
  97. mov al,[BYTE PTR edi] ; get the count of zeros to run
  98. inc edi ; advance past the count
  99. inc ecx ; the 0 found doesn't count
  100. sub ecx,eax ; subtract the count from remaining
  101. jg ??cliptop ; if more bytes left, scan again
  102. jz ??getrem ; exactly enough bytes; exit
  103. ;--------------------------------------------------------------------
  104. ; Overrun exit point: ECX is negative by the # of bytes overrun.
  105. ; - adjust [WidthCount] by # of overrun bytes
  106. ; - compute the remainder at the new location (EDX)
  107. ; - compute the number of destination pixels to skip (ECX)
  108. ; - adjust EDI by # of overrun bytes
  109. ;--------------------------------------------------------------------
  110. ;
  111. ;............... adjust [WidthCount] by overrun bytes ...............
  112. ;
  113. add [WidthCount],ecx ; adjust overrun in bytes
  114. ;
  115. ;................. put x-scale roundoff bits in EDX .................
  116. ;
  117. mov eax,ecx ; get the number of bytes we overran
  118. neg eax ; negate it since overun is negative
  119. add eax,[LeftClipBytes] ; add the number of bytes we leftclip
  120. mul [ScaleX] ; convert to pixels plus roundoff bits
  121. mov edx,0 ; clear EDX
  122. mov dl,al ; DL = x-scaling roundoff bits
  123. ;
  124. ;................ put negative overrun pixels in ECX ................
  125. ;
  126. shr eax,8 ; EAX = total # left pixels
  127. sub eax,[LeftClipPixels] ; EAX = # pixels overrun
  128. mov ecx,eax ; store # overrun pixels
  129. neg ecx ; make it negative
  130. ;
  131. ;................ adjust dest ptr by overrun pixels .................
  132. ;
  133. sub esi,eax ; decrement ESI (EDI) by overrun pixels
  134. ;--------------------------------------------------------------------
  135. ; Put shape address back into ESI, adjust EDI
  136. ;--------------------------------------------------------------------
  137. ??out:
  138. xchg esi,edi ; xchange ESI and EDI
  139. ret ; return back to the real function
  140. ENDP Left_Scale_Reverse_Skip
  141. END
  142. ;**************************** End of ds_lsrs.asm ****************************
  143.