LINEAR.ASM 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. .386
  2. .MODEL small
  3. INCLUDE defs.inc
  4. ;============================================================================
  5. ;
  6. ; unwound vertical scaling code
  7. ;
  8. ; eax light table pointer, 0 lowbyte overwritten
  9. ; ebx all 0, low byte overwritten
  10. ; ecx fractional step value
  11. ; edx fractional scale value
  12. ; esi start of source pixels
  13. ; edi bottom pixel in screenbuffer to blit into
  14. ;
  15. ; ebx should be set to 0 0 0 dh to feed the pipeline
  16. ;
  17. ; The graphics wrap vertically at 128 pixels
  18. ;============================================================================
  19. .DATA
  20. EXTRN _centery:DWORD
  21. SCALEDEFINE MACRO number
  22. dd vscale&number
  23. ENDM
  24. ALIGN 4
  25. scalecalls LABEL
  26. LINE = 0
  27. REPT SCREENHEIGHT+1
  28. SCALEDEFINE %LINE
  29. LINE = LINE+1
  30. ENDM
  31. ;=================================
  32. .CODE
  33. ;================
  34. ;
  35. ; R_DrawColumn
  36. ;
  37. ;================
  38. PROC R_DrawColumn_
  39. PUBLIC R_DrawColumn_
  40. PUSHR
  41. mov ebp,[_dc_yh]
  42. mov ebx,ebp
  43. mov edi,[_ylookup+ebx*4]
  44. mov ebx,[_dc_x]
  45. add edi,[_columnofs + ebx*4]
  46. mov eax,[_dc_yl]
  47. sub ebp,eax ; ebp = pixel count
  48. or ebp,ebp
  49. js done
  50. mov ecx,[_dc_iscale]
  51. sub eax,[_centery]
  52. imul ecx
  53. mov edx,[_dc_texturemid]
  54. add edx,eax
  55. shl edx,9 ; 7 significant bits, 25 frac
  56. shl ecx,9 ; 7 significant bits, 25 frac
  57. mov esi,[_dc_source]
  58. mov eax,[_dc_colormap]
  59. xor ebx,ebx
  60. shld ebx,edx,7 ; get address of first location
  61. call [scalecalls+4+ebp*4]
  62. done:
  63. POPR
  64. ret
  65. ;============ HIGH DETAIL ============
  66. SCALELABEL MACRO number
  67. vscale&number:
  68. ENDM
  69. LINE = SCREENHEIGHT
  70. REPT SCREENHEIGHT-1
  71. SCALELABEL %LINE
  72. mov al,[esi+ebx] ; get source pixel
  73. add edx,ecx ; calculate next location
  74. mov al,[eax] ; translate the color
  75. ; xor ebx,ebx
  76. ; shld ebx,edx,7 ; get address of next location
  77. mov ebx,edx
  78. shr ebx,25
  79. mov [edi-(LINE-1)*SCREENWIDTH],al ; draw a pixel to the buffer
  80. LINE = LINE-1
  81. ENDM
  82. vscale1:
  83. mov al,[esi+ebx]
  84. mov al,[eax]
  85. mov [edi],al
  86. vscale0:
  87. ret
  88. ENDP
  89. ;============================================================================
  90. ;
  91. ; unwound horizontal texture mapping code
  92. ;
  93. ; eax lighttable
  94. ; ebx scratch register
  95. ; ecx position 6.10 bits x, 6.10 bits y
  96. ; edx step 6.10 bits x, 6.10 bits y
  97. ; esi start of block
  98. ; edi dest
  99. ; ebp fff to mask bx
  100. ;
  101. ; ebp should by preset from ebx / ecx before calling
  102. ;============================================================================
  103. OP_SHLD = 0fh
  104. .DATA
  105. MAPDEFINE MACRO number
  106. dd hmap&number
  107. ENDM
  108. ALIGN 4
  109. mapcalls LABEL
  110. LINE = 0
  111. REPT SCREENWIDTH+1
  112. MAPDEFINE %LINE
  113. LINE = LINE+1
  114. ENDM
  115. callpoint dd 0
  116. returnpoint dd 0
  117. .CODE
  118. ;================
  119. ;
  120. ; R_DrawSpan
  121. ;
  122. ; Horizontal texture mapping
  123. ;
  124. ;================
  125. PROC R_DrawSpan_
  126. PUBLIC R_DrawSpan_
  127. PUSHR
  128. IFE SKIPPRIMITIVES
  129. mov eax,[_ds_x1]
  130. mov ebx,[_ds_x2]
  131. mov eax,[mapcalls+eax*4]
  132. mov [callpoint],eax ; spot to jump into unwound
  133. mov eax,[mapcalls+4+ebx*4]
  134. mov [returnpoint],eax ; spot to patch a ret at
  135. mov BYTE PTR [eax], OP_RET
  136. ;
  137. ; build composite position
  138. ;
  139. mov ecx,[_ds_xfrac]
  140. shl ecx,10
  141. and ecx,0ffff0000h
  142. mov eax,[_ds_yfrac]
  143. shr eax,6
  144. and eax,0ffffh
  145. or ecx,eax
  146. ;
  147. ; build composite step
  148. ;
  149. mov edx,[_ds_xstep]
  150. shl edx,10
  151. and edx,0ffff0000h
  152. mov eax,[_ds_ystep]
  153. shr eax,6
  154. and eax,0ffffh
  155. or edx,eax
  156. mov esi,[_ds_source]
  157. mov edi,[_ds_y]
  158. mov edi,[_ylookup+edi*4]
  159. add edi,[_columnofs]
  160. mov eax,[_ds_colormap]
  161. ;
  162. ; feed the pipeline and jump in
  163. ;
  164. mov ebp,0fffh ; used to mask off slop high bits from position
  165. shld ebx,ecx,22 ; shift y units in
  166. shld ebx,ecx,6 ; shift x units in
  167. and ebx,ebp ; mask off slop bits
  168. call [callpoint]
  169. mov ebx,[returnpoint]
  170. mov BYTE PTR [ebx],OP_MOVAL ; remove the ret patched in
  171. ENDIF
  172. POPR
  173. ret
  174. ;============= HIGH DETAIL ============
  175. .CODE
  176. MAPLABEL MACRO number
  177. hmap&number:
  178. ENDM
  179. LINE = 0
  180. PCOL = 0
  181. REPT SCREENWIDTH/4
  182. PLANE = 0
  183. REPT 4
  184. MAPLABEL %LINE
  185. LINE = LINE + 1
  186. mov al,[esi+ebx] ; get source pixel
  187. shld ebx,ecx,22 ; shift y units in
  188. shld ebx,ecx,6 ; shift x units in
  189. mov al,[eax] ; translate color
  190. and ebx,ebp ; mask off slop bits
  191. add ecx,edx ; position += step
  192. mov [edi+PLANE+PCOL*4],al ; write pixel
  193. PLANE = PLANE + 1
  194. ENDM
  195. PCOL = PCOL + 1
  196. ENDM
  197. hmap320:
  198. ret
  199. ENDP
  200. END