IB_RD.asm 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. ; Seven Kingdoms: Ancient Adversaries
  2. ;
  3. ; Copyright 1997,1998 Enlight Software Ltd.
  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 2 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. ;Filename : IB_RD.ASM
  19. ;Description : decompress and color remapping handling with color key transparency
  20. INCLUDE IMGFUN.inc
  21. INCLUDE COLCODE.inc
  22. .CODE
  23. ;-------- BEGIN OF FUNCTION IMGremapDecompress ----------
  24. ;
  25. ; Decompress bitmap on image buffer with Transparency.
  26. ; It handles color key transparency. The color key code is 255.
  27. ;
  28. ; R - color remapping
  29. ; D - decompression
  30. ;
  31. ; Syntax : IMGremapDecompress(desPtr, srcPtr, colorTable )
  32. ;
  33. ; char *desPtr - the pointer to the compressed surface buffer
  34. ; char *srcPtr - the pointer to the decompressed surface buffer
  35. ; char *colorTable - a 256-entry color remapping table
  36. ;
  37. ;-------------------------------------------------
  38. ;
  39. ; Format of the compressed data
  40. ; compressed decompressed
  41. ; FF FF
  42. ; FE (-2) FF FF
  43. ; FD (-3) FF FF FF
  44. ; FC (-4) FF FF FF FF
  45. ; FB (-5) FF FF FF FF FF
  46. ; FA (-6) FF FF FF FF FF FF
  47. ; F9 (-7) FF FF FF FF FF FF FF
  48. ; F8 B FF ... <B times>
  49. ;-------------------------------------------------
  50. ;
  51. ; Format of the bitmap data :
  52. ;
  53. ; <short> width
  54. ; <short> height
  55. ; <char..> bitmap image
  56. ;
  57. ;-------------------------------------------------
  58. PUBLIC IMGremapDecompress
  59. IMGremapDecompress PROC desPtr, srcPtr, colorTable
  60. STARTPROC
  61. MOV AX,DS
  62. MOV ES,AX
  63. MOV ESI,srcPtr
  64. MOV EDI,desPtr
  65. LODSW ; width
  66. MOV CX,AX
  67. STOSW
  68. LODSW ; height
  69. STOSW
  70. MUL CX
  71. ; DX:AX stores the decompressed size
  72. ; move it to EDX
  73. SHL EDX, 16
  74. MOV DX, AX
  75. ; load colour map
  76. MOV EBX, colorTable
  77. XOR ECX, ECX
  78. @@next:
  79. LODSB ; get compressed data
  80. PRE_REMAP
  81. ; test data between F8-FF
  82. JUMP_IF_TRANS al, @@compressed
  83. POST_REMAP
  84. STOSB
  85. DEC EDX ; test if completed
  86. JNZ @@next
  87. JMP @@endloop
  88. @@compressed:
  89. JUMP_IF_NOT_MANY_TRANS al, @@compressed2
  90. ; F8 B
  91. LODSB ; load the count
  92. MOV CL,AL
  93. MOV AL,0FFH
  94. SUB EDX,ECX ; test if completed
  95. ;PUSHF
  96. REP STOSB
  97. ;POPF
  98. JA @@next
  99. JMP @@endloop
  100. @@compressed2:
  101. ; F9 - FF
  102. MOV CL,AL ; repetition = -al
  103. MOV AL,0FFH
  104. DECODE_FEW_TRANS_CODE cl
  105. SUB EDX,ECX ; test if completed
  106. ;PUSHF
  107. REP STOSB
  108. ;POPF
  109. JA @@next
  110. @@endloop:
  111. @@end: ENDPROC
  112. IMGremapDecompress ENDP
  113. ;----------- END OF FUNCTION IMGbltTransRemap ----------
  114. END