C3_ASM.ASM 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. ; Catacomb 3-D 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. VIEWWIDTH = (33*8)
  20. GC_INDEX = 03CEh
  21. DATASEG
  22. EVEN
  23. ;=================== Tables filled in by DrawVWall ==========================
  24. ;
  25. ; wallheight has the height (scale number) of that collumn of scaled wall
  26. ; it is pre bounded to 1-MAXSCALE (the actuial height on screen is 2*height)
  27. ;
  28. wallheight dw VIEWWIDTH dup (?)
  29. ;
  30. ; wallwidth has the pixel width (1-7) of that collumn
  31. ;
  32. wallwidth dw VIEWWIDTH dup (?)
  33. ;
  34. ; wallseg has the segment of the wall picture
  35. ;
  36. wallseg dw VIEWWIDTH dup (?)
  37. ;
  38. ; wallofs has the offset of the wall picture
  39. ;
  40. wallofs dw VIEWWIDTH dup (?)
  41. ;============================================================================
  42. ;
  43. ; screenbyte is just position/8
  44. ;
  45. LABEL screenbyte WORD
  46. pos = 0
  47. REPT VIEWWIDTH
  48. dw pos/8
  49. pos = pos+1
  50. ENDM
  51. ;
  52. ; screenbit is (position&7)*16
  53. ;
  54. LABEL screenbit WORD
  55. pos = 0
  56. REPT VIEWWIDTH
  57. dw (pos AND 7)*16
  58. pos = pos+1
  59. ENDM
  60. ;
  61. ; Use offset: screenbit[]+pixwidth*2
  62. ; acess from bitmasks-2+offset for one biased pixwidth
  63. ; the low byte of bitmasks is for the first screen byte, the high byte
  64. ; is the bitmask for the second screen byte (if non 0)
  65. ;
  66. bitmasks dw 0080h,00c0h,00e0h,00f0h,00f8h,00fch,00feh,00ffh
  67. dw 0040h,0060h,0070h,0078h,007ch,007eh,007fh,807fh
  68. dw 0020h,0030h,0038h,003ch,003eh,003fh,803fh,0c03fh
  69. dw 0010h,0018h,001ch,001eh,001fh,801fh,0c01fh,0e01fh
  70. dw 0008h,000ch,000eh,000fh,800fh,0c00fh,0e00fh,0f00fh
  71. dw 0004h,0006h,0007h,8007h,0c007h,0e007h,0f007h,0f807h
  72. dw 0002h,0003h,8003h,0c003h,0e003h,0f003h,0f803h,0fc03h
  73. dw 0001h,8001h,0c001h,0e001h,0f001h,0f801h,0fc01h,0fe01h
  74. ;
  75. ; wallscalecall is a far pointer to the start of a compiled scaler
  76. ; The low word will never change, while the high word is set to
  77. ; compscaledirectory[scale]
  78. ;
  79. wallscalecall dd (65*6) ; offset of t_compscale->code[0]
  80. PUBLIC wallheight,wallwidth,wallseg,wallofs,screenbyte,screenbit
  81. PUBLIC bitmasks,wallscalecall
  82. EXTRN scaledirectory:WORD ; array of MAXSCALE segment pointers to
  83. ; compiled scalers
  84. EXTRN screenseg:WORD ; basically just 0xa000
  85. EXTRN bufferofs:WORD ; offset of the current work screen
  86. CODESEG
  87. ;============================================================================
  88. ;
  89. ; ScaleWalls
  90. ;
  91. ; AX AL is scratched in bit mask setting and scaling
  92. ; BX table index
  93. ; CX pixwidth*2
  94. ; DX GC_INDEX
  95. ; SI offset into wall data to scale from, allways 0,64,128,...4032
  96. ; DI byte at top of screen that the collumn is contained in
  97. ; BP x pixel * 2, index into VIEWWIDTH wide tables
  98. ; DS segment of the wall data to texture map
  99. ; ES screenseg
  100. ; SS addressing DGROUP variables
  101. ;
  102. ;============================================================================
  103. PROC ScaleWalls
  104. PUBLIC ScaleWalls
  105. USES SI,DI,BP
  106. xor bp,bp ; start at location 0 in the tables
  107. mov dx,GC_INDEX+1
  108. mov es,[screenseg]
  109. ;
  110. ; scale one collumn of data, possibly across two bytes
  111. ;
  112. nextcollumn:
  113. mov bx,[wallheight+bp] ; height of walls (1-MAXSCALE)
  114. shl bx,1
  115. mov ax,[ss:scaledirectory+bx] ; segment of the compiled scaler
  116. mov [WORD PTR ss:wallscalecall+2],ax
  117. mov cx,[wallwidth+bp]
  118. or cx,cx
  119. jnz okwidth
  120. mov cx,2
  121. jmp next
  122. okwidth:
  123. shl cx,1
  124. mov ds,[wallseg+bp]
  125. mov si,[wallofs+bp]
  126. mov di,[screenbyte+bp] ; byte at the top of the scaled collumn
  127. add di,[ss:bufferofs] ; offset of current page flip
  128. mov bx,[screenbit+bp] ; 0-7 << 4
  129. add bx,cx
  130. mov ax,[ss:bitmasks-2+bx]
  131. out dx,al ; set bit mask register
  132. call [DWORD PTR ss:wallscalecall] ; scale the line of pixels
  133. or ah,ah ; is there anything in the second byte?
  134. jnz secondbyte
  135. ;
  136. ; next
  137. ;
  138. next:
  139. add bp,cx
  140. cmp bp,VIEWWIDTH*2
  141. jb nextcollumn
  142. jmp done
  143. ;
  144. ; draw a second byte for vertical strips that cross two bytes
  145. ;
  146. secondbyte:
  147. mov al,ah
  148. inc di ; next byte over
  149. out dx,al ; set bit mask register
  150. call [DWORD PTR ss:wallscalecall] ; scale the line of pixels
  151. ;
  152. ; next
  153. ;
  154. add bp,cx
  155. cmp bp,VIEWWIDTH*2
  156. jb nextcollumn
  157. done:
  158. mov ax,ss
  159. mov ds,ax
  160. ret
  161. ENDP
  162. END