I_EMASK.asm 5.6 KB

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