TMAP_FLT.ASM 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. ;
  12. ; $Source: f:/miner/source/texmap/rcs/tmap_flt.asm $
  13. ; $Revision: 1.10 $
  14. ; $Author: john $
  15. ; $Date: 1995/02/20 18:22:53 $
  16. ;
  17. ; Flat shader derived from texture mapper (kind of slow)
  18. ;
  19. ; $Log: tmap_flt.asm $
  20. ; Revision 1.10 1995/02/20 18:22:53 john
  21. ; Put all the externs in the assembly modules into tmap_inc.asm.
  22. ; Also, moved all the C versions of the inner loops into a new module,
  23. ; scanline.c.
  24. ;
  25. ; Revision 1.9 1995/02/20 17:08:51 john
  26. ; Added code so that you can build the tmapper with no assembly!
  27. ;
  28. ; Revision 1.8 1994/12/02 23:29:21 mike
  29. ; change jb/ja to jl/jg.
  30. ;
  31. ; Revision 1.7 1994/11/12 16:39:35 mike
  32. ; jae to ja.
  33. ;
  34. ; Revision 1.6 1994/08/09 11:27:53 john
  35. ; Added cthru mode.
  36. ;
  37. ; Revision 1.5 1994/07/08 17:43:11 john
  38. ; Added flat-shaded-zbuffered polygon.
  39. ;
  40. ; Revision 1.4 1994/04/08 16:25:43 mike
  41. ; optimize inner loop of flat shader.
  42. ;
  43. ; Revision 1.3 1994/03/31 08:34:20 mike
  44. ; Optimized (well, speeded-up) inner loop for tmap-based flat shader.
  45. ;
  46. ; Revision 1.2 1993/11/22 10:24:57 mike
  47. ; *** empty log message ***
  48. ;
  49. ; Revision 1.1 1993/09/08 17:29:46 mike
  50. ; Initial revision
  51. ;
  52. ;
  53. ;
  54. .386
  55. public asm_tmap_scanline_flat_
  56. include tmap_inc.asm
  57. _DATA SEGMENT DWORD PUBLIC USE32 'DATA'
  58. _DATA ENDS
  59. DGROUP GROUP _DATA
  60. _TEXT SEGMENT DWORD PUBLIC USE32 'CODE'
  61. ASSUME DS:_DATA
  62. ASSUME CS:_TEXT
  63. ; --------------------------------------------------------------------------------------------------
  64. ; Enter:
  65. ; _xleft fixed point left x coordinate
  66. ; _xright fixed point right x coordinate
  67. ; _y fixed point y coordinate
  68. ;**; _pixptr address of source pixel map
  69. ; for (x = (int) xleft; x <= (int) xright; x++) {
  70. ; _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
  71. ; _setpixel(x,y);
  72. ;
  73. ; z += dz_dx;
  74. ; }
  75. asm_tmap_scanline_flat_:
  76. pusha
  77. ; Setup for loop: _loop_count iterations = (int) xright - (int) xleft
  78. ;**; esi source pixel pointer = pixptr
  79. ; edi initial row pointer = y*320+x
  80. ; set esi = pointer to start of texture map data
  81. ;** mov esi,_pixptr
  82. ; set edi = address of first pixel to modify
  83. mov edi,_fx_y
  84. cmp edi,_window_bottom
  85. ja _none_to_do
  86. imul edi,_bytes_per_row
  87. mov eax,_fx_xleft
  88. test eax, eax
  89. jns eax_ok
  90. sub eax,eax
  91. eax_ok:
  92. add edi,eax
  93. add edi,write_buffer
  94. ; set _loop_count = # of iterations
  95. mov eax,_fx_xright
  96. cmp eax,_window_right
  97. jl eax_ok1
  98. mov eax,_window_right
  99. eax_ok1: cmp eax,_window_left
  100. jg eax_ok2
  101. mov eax,_window_left
  102. eax_ok2:
  103. mov ebx,_fx_xleft
  104. sub eax,ebx
  105. js _none_to_do
  106. cmp eax,_window_width
  107. jbe _ok_to_do
  108. mov eax,_window_width
  109. dec eax
  110. _ok_to_do:
  111. mov ecx,eax
  112. ; edi = destination pixel pointer
  113. cmp _tmap_flat_cthru_table, 0
  114. jne do_flat_cthru
  115. mov al,_tmap_flat_color
  116. ; word align
  117. inc ecx
  118. test edi,1
  119. je edi_even
  120. mov es:[edi],al
  121. inc edi
  122. dec ecx
  123. je _none_to_do
  124. edi_even: shr ecx,1
  125. je _no_full_words
  126. mov ah,al
  127. rep stosw
  128. _no_full_words: adc ecx,ecx ; if cy set, then write one more pixel (ecx == 0)
  129. rep stosb ; write 0 or 1 pixel
  130. _none_to_do: popa
  131. ret
  132. do_flat_cthru:
  133. mov esi, _tmap_flat_cthru_table
  134. xor eax, eax
  135. cmp ecx, 0
  136. je _none_to_do
  137. ; edi = dest, esi = table, ecx = count
  138. flat_cthru_loop:
  139. mov al, es:[edi] ; get already drawn pixel
  140. mov al, [eax+esi] ; xlat thru cthru table
  141. mov es:[edi],al ; write it
  142. inc edi
  143. dec ecx
  144. jnz flat_cthru_loop
  145. popa
  146. ret
  147. _TEXT ends
  148. end
  149.