PACK2PLN.ASM 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. ; $Header: g:/library/wwlib32/file/rcs/pack2pln.asm 1.1 1994/04/22 18:07:46 scott_bowen Exp $
  19. ;***************************************************************************
  20. ;** 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 **
  21. ;***************************************************************************
  22. ;* *
  23. ;* Project Name : Library *
  24. ;* *
  25. ;* File Name : PACK2PLN.ASM *
  26. ;* *
  27. ;* Programmer : Scott K. Bowen *
  28. ;* *
  29. ;* Start Date : November 20, 1991 *
  30. ;* *
  31. ;* Last Update : April 22, 1994 [SKB] *
  32. ;* *
  33. ;*-------------------------------------------------------------------------*
  34. ;* Functions: *
  35. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  36. IDEAL
  37. P386
  38. MODEL USE32 FLAT
  39. LOCALS ??
  40. ;******************************************************************************
  41. ; External declares so these functions can be called
  42. ;
  43. GLOBAL Pack_2_Plane:NEAR
  44. CODESEG
  45. ;***************************************************************************
  46. ;* PACK_2_PLANE -- packed to planar scanline conversion *
  47. ;* *
  48. ;* INPUT: BYTE *buffer (far) -- pointer to planar output buffer *
  49. ;* BYTE *pageptr (far) -- pointer to current row in packed page *
  50. ;* WORD planebit -- current bit used in plane -- use only low byte *
  51. ;* *
  52. ;* OUTPUT: *
  53. ;* Return result in buffer. *
  54. ;* WARNINGS: *
  55. ;* *
  56. ;* HISTORY: *
  57. ;* 11/20/1991 SB : Created. *
  58. ;* 04/22/1994 SKB : Converted to 32 bit library. *
  59. ;*=========================================================================*
  60. ; *
  61. ; This is the original function that is converted to asm
  62. ;
  63. ;PRIVATE VOID Pack_2_Plane(UBYTE * buffer, BYTE * pageptr, BYTE planebit)
  64. ;{
  65. ; WORD currbit=0x80; // current bit to be written to
  66. ; WORD pixel; // current pixel in row used as a counter;
  67. ;
  68. ; buffer--; // will be incremented at the start
  69. ; for (currbit = 0, pixel = 0; pixel < 320; pixel++) {
  70. ; if (!currbit) {
  71. ; currbit = 0x80; // reset bit 7
  72. ; buffer++; // go to next byte in buffer
  73. ; *buffer = 0; // clear byte so we only need to set bits needed
  74. ; }
  75. ; if (planebit & *pageptr++)
  76. ; *buffer |= currbit; // set bit in destination if plane was set is source
  77. ;
  78. ; currbit >>= 1; // shift destination bit one right
  79. ; }
  80. ;}
  81. PROC Pack_2_Plane C NEAR
  82. USES ebx,ecx,esi,edi
  83. ARG buffer:DWORD
  84. ARG page:DWORD
  85. ARG planebit:WORD
  86. mov edi,[buffer]
  87. mov esi,[page]
  88. mov ax,[planebit] ; move bit set for current plane (planebit) to ax
  89. ; the low byte will only be used
  90. mov ecx,320d ; set counter to 320 columns (320x200 picture)
  91. mov ah,80h ; set bit 7 of current_bit
  92. dec edi ; this will get incremented at the start
  93. ??top_loop: ; while (columns left)
  94. cmp ah,80h ; if current_bit is bit 7
  95. jnz short ??same_dest
  96. ; Then
  97. inc edi ; buffer++ increment pointer
  98. mov [BYTE PTR edi],0 ; *buffer = 0
  99. ??same_dest: ; EndIf
  100. mov bl,al
  101. and bl,[esi] ; if (planebit & *pageptr)
  102. jz short ??no_set_bit
  103. or [BYTE PTR edi],ah ; Then *buffer |= current_bit
  104. ??no_set_bit:
  105. inc esi ; pageptr++ goto next in source byte
  106. ror ah,1 ; rotate current_bit right one
  107. dec ecx ;
  108. jnz ??top_loop
  109. ret
  110. ENDP Pack_2_Plane
  111. END
  112.