TEMP.ASM 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  2. ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  3. ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  4. ;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  5. ;IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  6. ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  7. ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  8. ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  9. ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  10. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  11. public tmap_loop_fast_nolight
  12. tmap_loop_fast_nolight:
  13. align 4
  14. NotDwordAligned1_nolight:
  15. test edi, 11b
  16. jz DwordAligned1_nolight
  17. xchg ebx, esi
  18. ; compute v coordinate
  19. mov eax,ebp ; get v
  20. cdq
  21. idiv ecx ; eax = (v/z)
  22. and eax,3fh ; mask with height-1
  23. mov ebx,eax
  24. ; compute u coordinate
  25. mov eax,esi ; get u
  26. cdq
  27. idiv ecx ; eax = (u/z)
  28. shl eax,26
  29. shld ebx,eax,6 ; esi = v*64+u
  30. ; read 1 pixel
  31. mov al,es:[ebx] ; get pixel from source bitmap
  32. ; write 1 pixel
  33. mov [edi],al
  34. inc edi
  35. ; update deltas
  36. add ebp,_fx_dv_dx
  37. add esi,_fx_du_dx
  38. add ecx,_fx_dz_dx
  39. xchg esi, ebx
  40. dec _loop_count
  41. jns NotDwordAligned1_nolight
  42. jmp _none_to_do
  43. DwordAligned1_nolight:
  44. mov eax, _loop_count
  45. inc eax
  46. mov num_left_over, eax
  47. shr eax, NBITS
  48. cmp eax, 0
  49. je tmap_loop
  50. mov _loop_count, eax ; _loop_count = pixels / NPIXS
  51. ;OPshl eax, NBITS
  52. lea eax, [eax*8]
  53. sub num_left_over, eax ; num_left_over = obvious
  54. ; compute initial v coordinate
  55. mov eax,ebp ; get v
  56. PDIV
  57. mov V0, eax
  58. ; compute initial u coordinate
  59. mov eax,ebx ; get u
  60. PDIV
  61. mov U0, eax
  62. ; Set deltas to NPIXS pixel increments
  63. mov eax, _fx_du_dx
  64. ;OPshl eax, NBITS
  65. lea eax, [eax*8]
  66. mov DU1, eax
  67. mov eax, _fx_dv_dx
  68. ;OPshl eax, NBITS
  69. lea eax, [eax*8]
  70. mov DV1, eax
  71. mov eax, _fx_dz_dx
  72. ;OPshl eax, NBITS
  73. lea eax, [eax*8]
  74. mov DZ1, eax
  75. align 4
  76. TopOfLoop4_nolight:
  77. add ebx, DU1
  78. add ebp, DV1
  79. add ecx, DZ1
  80. ; Done with ebx, ebp, ecx until next iteration
  81. push ebx
  82. push ecx
  83. push ebp
  84. push edi
  85. ; Find fixed U1
  86. mov eax, ebx
  87. PDIV
  88. mov ebx, eax ; ebx = U1 until pop's
  89. ; Find fixed V1
  90. mov eax, ebp
  91. PDIV
  92. mov ebp, eax ; ebp = V1 until pop's
  93. mov ecx, U0 ; ecx = U0 until pop's
  94. mov edi, V0 ; edi = V0 until pop's
  95. ; Make ESI = V0:U0 in 6:10,6:10 format
  96. mov eax, ecx
  97. shr eax, 6
  98. mov esi, edi
  99. shl esi, 10
  100. mov si, ax
  101. ; Make EDX = DV:DU in 6:10,6:10 format
  102. mov eax, ebx
  103. sub eax, ecx
  104. sar eax, NBITS+6
  105. mov edx, ebp
  106. sub edx, edi
  107. shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
  108. mov dx, ax ; put delta u in low word
  109. ; Save the U1 and V1 so we don't have to divide on the
  110. ; next iteration
  111. mov U0, ebx
  112. mov V0, ebp
  113. pop edi ; Restore EDI before using it
  114. REPT (1 SHL (NBITS-2))
  115. REPT 4
  116. ; Do 1 pixel
  117. mov eax, esi ; get u,v
  118. shr eax, 26 ; shift out all but int(v)
  119. shld ax,si,6 ; shift in u, shifting up v
  120. mov cl, es:[eax] ; load into buffer register
  121. add esi, edx ; inc u,v
  122. ror ecx, 8 ; move to next dest pixel
  123. ENDM
  124. mov [edi],ecx ; Draw 4 pixels to display
  125. add edi,4
  126. ENDM
  127. pop ebp
  128. pop ecx
  129. pop ebx
  130. dec _loop_count
  131. jnz TopOfLoop4_nolight
  132. EndOfLoop4_nolight:
  133. cmp num_left_over, 0
  134. je _none_to_do
  135. DoEndPixels_nolight:
  136. add ebx, DU1
  137. add ebp, DV1
  138. add ecx, DZ1
  139. push edi ; use edi as a temporary variable
  140. ; Find fixed U1
  141. mov eax, ebx
  142. PDIV
  143. mov ebx, eax ; ebx = U1 until pop's
  144. ; Find fixed V1
  145. mov eax, ebp
  146. PDIV
  147. mov ebp, eax ; ebp = V1 until pop's
  148. mov ecx, U0 ; ecx = U0 until pop's
  149. mov edi, V0 ; edi = V0 until pop's
  150. ; Make ESI = V0:U0 in 6:10,6:10 format
  151. mov eax, ecx
  152. shr eax, 6
  153. mov esi, edi
  154. shl esi, 10
  155. mov si, ax
  156. ; Make EDX = DV:DU in 6:10,6:10 format
  157. mov eax, ebx
  158. sub eax, ecx
  159. sar eax, NBITS+6
  160. mov edx, ebp
  161. sub edx, edi
  162. shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
  163. mov dx, ax ; put delta u in low word
  164. pop edi ; Restore EDI before using it
  165. mov ecx, num_left_over
  166. ITERATION = 0
  167. REPT (1 SHL NBITS)
  168. ; Do 1 pixel
  169. mov eax, esi ; get u,v
  170. shr eax, 26 ; shift out all but int(v)
  171. shld ax,si,6 ; shift in u, shifting up v
  172. mov al, es:[eax] ; load into buffer register
  173. add esi, edx ; inc u,v
  174. mov [edi+ITERATION], al ; write pixel
  175. dec ecx
  176. jz _none_to_do
  177. ITERATION = ITERATION + 1
  178. ENDM
  179. ; Should never get here!!!!!
  180. int 3
  181. jmp _none_to_do
  182.