C5_ASM.ASM 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. ; Catacomb Armageddon Source Code
  2. ; Copyright (C) 1993-2014 Flat Rock Software
  3. ;
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License along
  15. ; with this program; if not, write to the Free Software Foundation, Inc.,
  16. ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. IDEAL
  18. MODEL MEDIUM,C
  19. INCLUDE "ID_ASM.EQU"
  20. VIEWWIDTH = (40*8) ;33
  21. GC_INDEX = 03CEh
  22. DATASEG
  23. EVEN
  24. ;=================== Tables filled in by DrawVWall ==========================
  25. ;
  26. ; wallheight has the height (scale number) of that collumn of scaled wall
  27. ; it is pre bounded to 1-MAXSCALE (the actuial height on screen is 2*height)
  28. ;
  29. wallheight dw VIEWWIDTH dup (?)
  30. ;
  31. ; wallwidth has the pixel width (1-7) of that collumn
  32. ;
  33. wallwidth dw VIEWWIDTH dup (?)
  34. ;
  35. ; wallseg has the segment of the wall picture
  36. ;
  37. wallseg dw VIEWWIDTH dup (?)
  38. ;
  39. ; wallofs has the offset of the wall picture
  40. ;
  41. wallofs dw VIEWWIDTH dup (?)
  42. ;============================================================================
  43. ;
  44. ; screenbyte is just position/8
  45. ;
  46. LABEL screenbyte WORD
  47. pos = 0
  48. REPT VIEWWIDTH
  49. dw pos/8
  50. pos = pos+1
  51. ENDM
  52. ;
  53. ; screenbit is (position&7)*16
  54. ;
  55. LABEL screenbit WORD
  56. pos = 0
  57. REPT VIEWWIDTH
  58. dw (pos AND 7)*16
  59. pos = pos+1
  60. ENDM
  61. ;
  62. ; Use offset: screenbit[]+pixwidth*2
  63. ; acess from bitmasks-2+offset for one biased pixwidth
  64. ; the low byte of bitmasks is for the first screen byte, the high byte
  65. ; is the bitmask for the second screen byte (if non 0)
  66. ;
  67. bitmasks dw 0080h,00c0h,00e0h,00f0h,00f8h,00fch,00feh,00ffh
  68. dw 0040h,0060h,0070h,0078h,007ch,007eh,007fh,807fh
  69. dw 0020h,0030h,0038h,003ch,003eh,003fh,803fh,0c03fh
  70. dw 0010h,0018h,001ch,001eh,001fh,801fh,0c01fh,0e01fh
  71. dw 0008h,000ch,000eh,000fh,800fh,0c00fh,0e00fh,0f00fh
  72. dw 0004h,0006h,0007h,8007h,0c007h,0e007h,0f007h,0f807h
  73. dw 0002h,0003h,8003h,0c003h,0e003h,0f003h,0f803h,0fc03h
  74. dw 0001h,8001h,0c001h,0e001h,0f001h,0f801h,0fc01h,0fe01h
  75. ;
  76. ; wallscalecall is a far pointer to the start of a compiled scaler
  77. ; The low word will never change, while the high word is set to
  78. ; compscaledirectory[scale]
  79. ;
  80. wallscalecall dd (65*6) ; offset of t_compscale->code[0]
  81. PUBLIC wallheight,wallwidth,wallseg,wallofs,screenbyte,screenbit
  82. PUBLIC bitmasks,wallscalecall
  83. EXTRN scaledirectory:WORD ; array of MAXSCALE segment pointers to
  84. ; compiled scalers
  85. EXTRN screenseg:WORD ; basically just 0xa000
  86. EXTRN bufferofs:WORD ; offset of the current work screen
  87. EXTRN ylookup:WORD
  88. EXTRN screenpage:WORD
  89. CODESEG
  90. ;============================================================================
  91. ;
  92. ; ScaleWalls
  93. ;
  94. ; AX AL is scratched in bit mask setting and scaling
  95. ; BX table index
  96. ; CX pixwidth*2
  97. ; DX GC_INDEX
  98. ; SI offset into wall data to scale from, allways 0,64,128,...4032
  99. ; DI byte at top of screen that the collumn is contained in
  100. ; BP x pixel * 2, index into VIEWWIDTH wide tables
  101. ; DS segment of the wall data to texture map
  102. ; ES screenseg
  103. ; SS addressing DGROUP variables
  104. ;
  105. ;============================================================================
  106. PROC ScaleWalls
  107. PUBLIC ScaleWalls
  108. USES SI,DI,BP
  109. xor bp,bp ; start at location 0 in the tables
  110. mov dx,GC_INDEX+1
  111. mov es,[screenseg]
  112. ;
  113. ; scale one collumn of data, possibly across two bytes
  114. ;
  115. nextcollumn:
  116. mov bx,[wallheight+bp] ; height of walls (1-MAXSCALE)
  117. shl bx,1
  118. mov ax,[ss:scaledirectory+bx] ; segment of the compiled scaler
  119. mov [WORD PTR ss:wallscalecall+2],ax
  120. mov cx,[wallwidth+bp]
  121. or cx,cx
  122. jnz okwidth
  123. mov cx,2
  124. jmp next
  125. okwidth:
  126. shl cx,1
  127. mov ds,[wallseg+bp]
  128. mov si,[wallofs+bp]
  129. mov di,[screenbyte+bp] ; byte at the top of the scaled collumn
  130. add di,[ss:bufferofs] ; offset of current page flip
  131. mov bx,[screenbit+bp] ; 0-7 << 4
  132. add bx,cx
  133. mov ax,[ss:bitmasks-2+bx]
  134. out dx,al ; set bit mask register
  135. call [DWORD PTR ss:wallscalecall] ; scale the line of pixels
  136. or ah,ah ; is there anything in the second byte?
  137. jnz secondbyte
  138. ;
  139. ; next
  140. ;
  141. next:
  142. add bp,cx
  143. cmp bp,VIEWWIDTH*2
  144. jb nextcollumn
  145. jmp done
  146. ;
  147. ; draw a second byte for vertical strips that cross two bytes
  148. ;
  149. secondbyte:
  150. mov al,ah
  151. inc di ; next byte over
  152. out dx,al ; set bit mask register
  153. call [DWORD PTR ss:wallscalecall] ; scale the line of pixels
  154. ;
  155. ; next
  156. ;
  157. add bp,cx
  158. cmp bp,VIEWWIDTH*2
  159. jb nextcollumn
  160. done:
  161. mov ax,ss
  162. mov ds,ax
  163. ret
  164. ENDP
  165. ;---------------------------------------------------------------------------
  166. ;
  167. ; RadarBlip()
  168. ;
  169. ; Displays a 'blip' (1 pixel wide X 2 pixel high) on the radar at
  170. ; an (X,Y) relative to (RADAR_X,RADAR_Y) (defined below...)
  171. ;
  172. ;---------------------------------------------------------------------------
  173. PROC RadarBlip x:WORD, y:WORD, color:WORD
  174. USES SI,DI
  175. PUBLIC RadarBlip
  176. mov ax,[screenseg]
  177. mov es,ax
  178. xor di,di
  179. lea si,[ylookup]
  180. add si,[y]
  181. add si,[y]
  182. add di,[si]
  183. mov ax,[x]
  184. shr ax,1
  185. shr ax,1
  186. shr ax,1
  187. add di,ax
  188. mov ax,[x]
  189. and ax,7
  190. mov cl,al
  191. mov ah,080h
  192. shr ah,cl
  193. cli
  194. mov al,GC_BITMASK
  195. mov dx,GC_INDEX
  196. out dx,ax
  197. sti
  198. mov ax,[color]
  199. mov ah,[es:di] ; read into latches
  200. mov [es:di],al ; write latches / color bit
  201. ret
  202. ENDP
  203. END