DS_LS.ASM 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_LS.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_Skip -- Skips bytes in a data stream *
  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_Skip -- Skips bytes in a data stream *
  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 overrun, or 0 *
  55. ;* EDX - XTotal initializer value (0 since there's no scaling)*
  56. ;* ESI - updated to the current location in the shape data *
  57. ;* EDI - incremented by # pixels overrun *
  58. ;* [WidthCount] - decremented by # bytes skipped *
  59. ;* *
  60. ;* WARNINGS: none *
  61. ;* *
  62. ;* HISTORY: *
  63. ;* 04/14/1992 PWG : Created. *
  64. ;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
  65. ;* 06/02/1994 BR : Converted to 32-bit *
  66. ;*=========================================================================*
  67. PROC Left_Skip NOLANGUAGE NEAR
  68. sub [WidthCount],ecx ; we process ECX bytes of real width
  69. ;--------------------------------------------------------------------
  70. ; Put shape data address in EDI so we can do a scasb on it
  71. ;--------------------------------------------------------------------
  72. xchg esi,edi ; xchange ESI and EDI
  73. jecxz ??out ; exit if ECX is 0 (no bytes to skip)
  74. ;--------------------------------------------------------------------
  75. ; Search through the string and count down the info we have handled.
  76. ; If we find a run (0 followed by a count byte), then handle it.
  77. ;--------------------------------------------------------------------
  78. ??cliptop:
  79. mov eax,0 ; set al to 0 (we're scanning for 0)
  80. repne scasb ; scan through source data
  81. jz ??on_run ; if it is a run then deal with it
  82. jecxz ??out ; if we're done then get outta here
  83. ;--------------------------------------------------------------------
  84. ; If we have a run then get the next byte which is the length.
  85. ;--------------------------------------------------------------------
  86. ??on_run:
  87. mov al,[BYTE PTR edi] ; get the count of zeros to run
  88. inc edi ; advance past the count
  89. inc ecx ; the 0 found doesn't count
  90. sub ecx,eax ; subtract the count from remaining
  91. jg ??cliptop ; if more bytes left, scan again
  92. ;--------------------------------------------------------------------
  93. ; Put shape address back into ESI, adjust EDI
  94. ;--------------------------------------------------------------------
  95. ??out:
  96. xchg esi,edi ; xchange ESI and EDI
  97. sub edi,ecx ; increment EDI by overrun pixels
  98. add [WidthCount],ecx ; adjust by # bytes overrun
  99. mov edx,0 ; no scaling, so clear EDX
  100. ret ; return back to the real function
  101. ENDP Left_Skip
  102. END
  103. ;**************************** End of ds_ls.asm *****************************
  104.