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.
13 ; Linearly interpolating texture mapper inner loop
19 global _asm_tmap_scanline_lin
20 global asm_tmap_scanline_lin
24 %include "tmap_inc.asm"
30 ; --------------------------------------------------------------------------------------------------
32 ; _xleft fixed point left x coordinate
33 ; _xright fixed point right x coordinate
34 ; _y fixed point y coordinate
35 ; _pixptr address of source pixel map
36 ; _u fixed point initial u coordinate
37 ; _v fixed point initial v coordinate
38 ; _du_dx fixed point du/dx
39 ; _dv_dx fixed point dv/dx
41 ; for (x = (int) xleft; x <= (int) xright; x++) {
42 ; _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
51 _asm_tmap_scanline_lin:
52 asm_tmap_scanline_lin:
55 ; Setup for loop: _loop_count iterations = (int) xright - (int) xleft
56 ; esi source pixel pointer = pixptr
57 ; edi initial row pointer = y*320+x
59 ; set esi = pointer to start of texture map data
62 ; set edi = address of first pixel to modify
64 cmp edi,[_window_bottom]
67 imul edi,[_bytes_per_row]
74 add edi,[_write_buffer]
76 ; set _loop_count = # of iterations
78 cmp eax,[_window_right]
80 mov eax,[_window_right]
81 eax_ok1: cmp eax,[_window_left]
83 mov eax,[_window_left]
89 cmp eax,[_window_width]
91 mov eax,[_window_width]
95 ; edi destination pixel pointer
116 test dword [_Transparency_on],-1
117 jne near transparent_texture
119 %define _size (_end1 - _start1)/num_iters
121 sub eax,[_loop_count]
123 inc eax ; sort of a hack, but we can get -1 here and want to be graceful
124 jns j_eax_ok1 ; if we jump, we had -1, which is kind of ok, if not, we int 3
125 int 3 ; oops, going to jump behind _start1, very bad...
126 sub eax,eax ; ok to continue
127 j_eax_ok1: imul eax,eax,_size
134 ; "OPTIMIZATIONS" maybe not worth making
135 ; Getting rid of the esi from the mov al,[esi+eax] instruction.
136 ; This would require moving into eax at the top of the loop, rather than doing the sub eax,eax.
137 ; You would have to align your bitmaps so that the two shlds would create the proper base address.
138 ; In other words, your bitmap data would have to begin at 4096x (for 64x64 bitmaps).
139 ; I did timings without converting the sub to a mov eax,esi and setting esi to the proper value.
140 ; There was a speedup of about 1% to 1.5% without converting the sub to a mov.
141 ; Getting rid of the edi by doing a mov nnnn[edi],al instead of mov [edi],al.
142 ; The problem with this is you would have a dword offset for nnnn. My timings indicate it is slower. (I think.)
143 ; Combining u,v and du,dv into single longwords.
144 ; The problem with this is you then must do a 16 bit operation to extract them, and you don't have enough
145 ; instructions to separate a destination operand from being used by the next instruction. It shaves out one
146 ; register instruction (an add reg,reg), but adds a 16 bit operation, and the setup is more complicated.
153 ; esi pointer to source bitmap
156 mov eax,ebp ; clear for
157 add ebp,edx ; update v coordinate
158 shr eax,26 ; shift in v coordinate
159 shld eax,ebx,6 ; shift in u coordinate while shifting up v coordinate
160 add ebx,ecx ; update u coordinate
161 mov al,[esi+eax] ; get pixel from source bitmap
163 inc edi ; XPARENT ADDED BY JOHN
165 ; inner loop if bitmaps are 256x256
166 ; your register usage is bogus, and you must clear ecx
168 ; this is only about 10% faster in the inner loop
169 ; this method would adapt to writing two pixels at a time better than
170 ; the 64x64 method because you wouldn't run out of registers
171 ; Note that this method assumes that both dv_dx and du_dx are in edx.
173 ; where each field is 8 bits, vi = integer v coordinate, vf = fractional v coordinate, etc.
188 ; ----------------------------------------------------------------------------------------
189 ; if texture map has transparency, use this code.
191 test dword [_loop_count],-1
194 mov eax,ebp ; clear for
195 add ebp,edx ; update v coordinate
196 shr eax,26 ; shift in v coordinate
197 shld eax,ebx,6 ; shift in u coordinate while shifting up v coordinate
198 add ebx,ecx ; update u coordinate
199 mov al,[esi+eax] ; get pixel from source bitmap
203 transp: inc edi ; XPARENT ADDED BY JOHN
205 dec dword [_loop_count]
212 ; This is the inner loop to write two pixels at a time
213 ; This is about 2.5% faster overall (on Mike's 66 MHz 80486 DX2, VLB)
214 ; You must write code to even align edi and do half as many iterations, and write
215 ; the beginning and ending extra pixels, if necessary.
216 ; sub eax,eax ; clear for
217 ; shld eax,ebp,6 ; shift in v coordinate
218 ; add ebp,_fx_dv_dx ; update v coordinate
219 ; shld eax,ebx,6 ; shift in u coordinate while shifting up v coordinate
220 ; add ebx,ecx ; update u coordinate
221 ; mov dl,[esi+eax] ; get pixel from source bitmap
223 ; sub eax,eax ; clear for
224 ; shld eax,ebp,6 ; shift in v coordinate
225 ; add ebp,_fx_dv_dx ; update v coordinate
226 ; shld eax,ebx,6 ; shift in u coordinate while shifting up v coordinate
227 ; add ebx,ecx ; update u coordinate
228 ; mov dh,[esi+eax] ; get pixel from source bitmap