I_EREMAP.asm 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 : I_EREMAP.ASM
  19. ;Description : Blt exploration remap of 32x32 to the display surface buffer
  20. ; a modified version, 16 mask
  21. ; second modification, 8-bit remap table selector instead of 1-bit tone mask
  22. INCLUDE IMGFUN.inc
  23. ; ------------ Define constant ------------
  24. PUBLIC IMGexploreRemap32x32
  25. MASKCOLOUR = 0
  26. EAST_BIT_MASK = 1
  27. CENTRE_BIT_MASK = 2
  28. WEST_BIT_MASK = 4
  29. NORTH1_MASK_OFFS = 0
  30. SOUTH1_MASK_OFFS = 0100h
  31. WEST1_MASK_OFFS = 0200h
  32. EAST1_MASK_OFFS = 0300h
  33. NW_MASK_OFFS = 0400h
  34. NE_MASK_OFFS = 0500h
  35. SW_MASK_OFFS = 0600h
  36. SE_MASK_OFFS = 0700h
  37. XNW_MASK_OFFS = 0800h
  38. XNE_MASK_OFFS = 0900h
  39. XSW_MASK_OFFS = 0a00h
  40. XSE_MASK_OFFS = 0b00h
  41. NORTH2_MASK_OFFS = 0c00h
  42. SOUTH2_MASK_OFFS = 0d00h
  43. WEST2_MASK_OFFS = 0e00h
  44. EAST2_MASK_OFFS = 0f00h
  45. .DATA
  46. ; bit 0 = north sqaure, bit 1 = north west square, bit 2 = west square
  47. NW_SQR_DECISION DD XSE_MASK_OFFS, WEST1_MASK_OFFS, XSE_MASK_OFFS, WEST1_MASK_OFFS
  48. DD NORTH1_MASK_OFFS, NW_MASK_OFFS, NORTH1_MASK_OFFS, -1
  49. ; bit 0 = east square, bit 1 = north east square, bit 2 = north square
  50. NE_SQR_DECISION DD XSW_MASK_OFFS, NORTH2_MASK_OFFS, XSW_MASK_OFFS, NORTH2_MASK_OFFS
  51. DD EAST1_MASK_OFFS, NE_MASK_OFFS, EAST1_MASK_OFFS, -1
  52. ; bit 0 = south square, bit 1 = south west square, bit 2 = west square
  53. SW_SQR_DECISION DD XNE_MASK_OFFS, WEST2_MASK_OFFS, XNE_MASK_OFFS, WEST2_MASK_OFFS
  54. DD SOUTH1_MASK_OFFS, SW_MASK_OFFS, SOUTH1_MASK_OFFS, -1
  55. ; bit 0 = east square, bit 1 = south east square, bit 2 = south square
  56. SE_SQR_DECISION DD XNW_MASK_OFFS, SOUTH2_MASK_OFFS, XNW_MASK_OFFS, SOUTH2_MASK_OFFS
  57. DD EAST2_MASK_OFFS, SE_MASK_OFFS, EAST2_MASK_OFFS, -1
  58. buf_pitch DD ?
  59. .CODE
  60. ;------------ BEGIN OF MACRO REMAPDOT ----------
  61. REMAPDOT MACRO
  62. LOCAL @@remapdot1
  63. LODSB
  64. MOVSX EAX, AL
  65. MOV EBX, [EDX + 4*EAX]
  66. MOV AL, [EDI]
  67. XLATB [EBX]
  68. STOSB
  69. ENDM
  70. ;------------ END OF MACRO REMAPDOT ----------
  71. ;------------ BEGIN OF FUNCTION IMGremap16x16 -----------
  72. IMGremap16x16 PROC
  73. ; input :
  74. ; EDI = destination
  75. ; ESI = bitmapPtr
  76. ; EDX = colorRemapArray
  77. ;
  78. PUSH EAX
  79. PUSH EBX
  80. PUSH ECX
  81. PUSH EDX
  82. PUSH ESI
  83. PUSH EDI
  84. CLD
  85. MOV ECX, 16
  86. @@line0:
  87. REMAPDOT
  88. REMAPDOT
  89. REMAPDOT
  90. REMAPDOT
  91. REMAPDOT
  92. REMAPDOT
  93. REMAPDOT
  94. REMAPDOT
  95. REMAPDOT
  96. REMAPDOT
  97. REMAPDOT
  98. REMAPDOT
  99. REMAPDOT
  100. REMAPDOT
  101. REMAPDOT
  102. REMAPDOT
  103. ADD EDI, buf_pitch
  104. SUB EDI, 16
  105. DEC ECX
  106. JNZ @@line0
  107. @@line2: POP EDI
  108. POP ESI
  109. POP EDX
  110. POP ECX
  111. POP EBX
  112. POP EAX
  113. RET
  114. IMGremap16x16 ENDP
  115. ;------------ END OF FUNCTION IMGremap16x16 -----------
  116. ;---------- BEGIN OF FUNCTION IMGexploreRemap32x32 -------
  117. ;
  118. ; Smooth the area between explore and unexplored square
  119. ;
  120. ; Syntax : IMGexploreRemap32x32( imageBuf, pitch, x, y, maskPtr, colorTableArray, northRow, thisRow, southRow)
  121. ;
  122. ; char *imageBuf - the pointer to the display surface buffer
  123. ; int pitch - the pitch of the display surface buffer
  124. ; int x,y - where to put the image on the surface buffer
  125. ; char *maskPtr - pointer of masks, (address of 'EXPLMASK.BIN' is loaded)
  126. ; northRow - explored_flag of adjacent location
  127. ; bit 0 - north east square (0=unexplored, 1=explored)
  128. ; bit 1 - north square
  129. ; bit 2 - north west square
  130. ; thisRow - bit 0 - east square
  131. ; bit 1 - this square
  132. ; bit 2 - west square
  133. ; southRow - bit 0 - south east square
  134. ; bit 1 - south square
  135. ; bit 2 - south west square
  136. ;
  137. ;--------------------------------------------------------
  138. IMGexploreRemap32x32 PROC imageBuf, pitch, x, y, maskPtr, colorTableArray, northRow, thisRow, southRow
  139. STARTPROC
  140. MOV EAX, imageBuf
  141. MOV image_buf, EAX
  142. MOV EDX, pitch
  143. MOV buf_pitch, EDX
  144. MOV EDX, colorTableArray
  145. ; north west 16x16
  146. @@nw0: XOR EBX, EBX
  147. MOV EAX, northRow
  148. AND AL, CENTRE_BIT_MASK OR WEST_BIT_MASK
  149. SHR AL, 1
  150. MOV BL, AL
  151. MOV EAX, thisRow
  152. AND AL, WEST_BIT_MASK
  153. OR BL, AL
  154. CMP BL,7
  155. JE @@ne0
  156. MOV EAX, [NW_SQR_DECISION + 4*EBX]
  157. MOV ESI, maskPtr
  158. ADD ESI, EAX
  159. CALC_ADDR EDI, x ,y, pitch
  160. CALL IMGremap16x16
  161. ; north east 16x16
  162. @@ne0: XOR EBX, EBX
  163. MOV EAX, northRow
  164. AND AL, CENTRE_BIT_MASK OR EAST_BIT_MASK
  165. SHL AL, 1
  166. MOV BL, AL
  167. MOV EAX, thisRow
  168. AND AL, EAST_BIT_MASK
  169. OR BL, AL
  170. CMP BL, 7
  171. JE @@sw0
  172. MOV EAX, [NE_SQR_DECISION + 4*EBX]
  173. MOV ESI, maskPtr
  174. ADD ESI, EAX
  175. CALC_ADDR_2 EDI, x, y, 16, 0, pitch
  176. CALL IMGremap16x16
  177. ; south west 16x16
  178. @@sw0: XOR EBX, EBX
  179. MOV EAX, southRow
  180. AND AL, CENTRE_BIT_MASK OR WEST_BIT_MASK
  181. SHR AL, 1
  182. MOV BL, AL
  183. MOV EAX, thisRow
  184. AND AL, WEST_BIT_MASK
  185. OR BL, AL
  186. CMP BL, 7
  187. JE @@se0
  188. MOV EAX, [SW_SQR_DECISION + 4*EBX]
  189. MOV ESI, maskPtr
  190. ADD ESI, EAX
  191. CALC_ADDR_2 EDI, x, y, 0, 16, pitch
  192. CALL IMGremap16x16
  193. ; south east 16x16
  194. @@se0: XOR EBX, EBX
  195. MOV EAX, southRow
  196. AND AL, CENTRE_BIT_MASK OR EAST_BIT_MASK
  197. SHL AL, 1
  198. MOV BL, AL
  199. MOV EAX, thisRow
  200. AND AL, EAST_BIT_MASK
  201. OR BL, AL
  202. CMP BL, 7
  203. JE @@end
  204. MOV EAX, [SE_SQR_DECISION + 4*EBX]
  205. MOV ESI, maskPtr
  206. ADD ESI, EAX
  207. CALC_ADDR_2 EDI, x, y, 16, 16, pitch
  208. CALL IMGremap16x16
  209. @@end: ENDPROC
  210. IMGexploreRemap32x32 ENDP
  211. ;------------ END OF FUNCTION IMGexploreRemap32x32 -------
  212. END