⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r_spr8.asm

📁 Quake 2 Source code for students by Theerthan You can also download from idsoftwares.com
💻 ASM
📖 第 1 页 / 共 2 页
字号:
 jl Lp4	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp4	
 mov ds:word ptr[6+ecx],bp	
 mov ds:byte ptr[3+edi],al	
Lp4:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	

 cmp bp,ds:word ptr[8+ecx]	
 jl Lp5	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp5	
 mov ds:word ptr[8+ecx],bp	
 mov ds:byte ptr[4+edi],al	
Lp5:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	

;
; start FDIV for end of next segment in flight, so it can overlap
;
 pop eax	
 cmp eax,8	; more than one segment after this?
 ja LSetupNotLast2	; yes

 dec eax	
 jz LFDIVInFlight2	; if only one pixel, no need to start an FDIV
 mov ds:dword ptr[spancountminus1],eax	
 fild ds:dword ptr[spancountminus1]	

 fld ds:dword ptr[_d_zistepu]	; _d_zistepu | spancountminus1
 fmul st(0),st(1)	; _d_zistepu*scm1 | scm1
 fld ds:dword ptr[_d_tdivzstepu]	; _d_tdivzstepu | _d_zistepu*scm1 | scm1
 fmul st(0),st(2)	; _d_tdivzstepu*scm1 | _d_zistepu*scm1 | scm1
 fxch st(1)	; _d_zistepu*scm1 | _d_tdivzstepu*scm1 | scm1
 faddp st(3),st(0)	; _d_tdivzstepu*scm1 | scm1
 fxch st(1)	; scm1 | _d_tdivzstepu*scm1
 fmul ds:dword ptr[_d_sdivzstepu]	; _d_sdivzstepu*scm1 | _d_tdivzstepu*scm1
 fxch st(1)	; _d_tdivzstepu*scm1 | _d_sdivzstepu*scm1
 faddp st(3),st(0)	; _d_sdivzstepu*scm1
 fld ds:dword ptr[fp_64k]	; 64k | _d_sdivzstepu*scm1
 fxch st(1)	; _d_sdivzstepu*scm1 | 64k
 faddp st(4),st(0)	; 64k

 fdiv st(0),st(1)	; this is what we've gone to all this trouble to
;  overlap
 jmp LFDIVInFlight2	

 align 4	
LSetupNotLast2:	
 fadd ds:dword ptr[zi8stepu]	
 fxch st(2)	
 fadd ds:dword ptr[sdivz8stepu]	
 fxch st(2)	
 fld ds:dword ptr[tdivz8stepu]	
 faddp st(2),st(0)	
 fld ds:dword ptr[fp_64k]	
 fdiv st(0),st(1)	; z = 1/1/z
; this is what we've gone to all this trouble to
;  overlap
LFDIVInFlight2:	
 push eax	

 cmp bp,ds:word ptr[10+ecx]	
 jl Lp6	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp6	
 mov ds:word ptr[10+ecx],bp	
 mov ds:byte ptr[5+edi],al	
Lp6:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	

 cmp bp,ds:word ptr[12+ecx]	
 jl Lp7	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp7	
 mov ds:word ptr[12+ecx],bp	
 mov ds:byte ptr[6+edi],al	
Lp7:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	

 cmp bp,ds:word ptr[14+ecx]	
 jl Lp8	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp8	
 mov ds:word ptr[14+ecx],bp	
 mov ds:byte ptr[7+edi],al	
Lp8:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	

 add edi,8	
 add ecx,16	
 mov ds:dword ptr[tfracf],edx	
 mov edx,ds:dword ptr[snext]	
 mov ds:dword ptr[sfracf],ebx	
 mov ebx,ds:dword ptr[tnext]	
 mov ds:dword ptr[s],edx	
 mov ds:dword ptr[t],ebx	

 mov ds:dword ptr[pz],ecx	
 mov ds:dword ptr[izi],ebp	

 pop ecx	; retrieve count

;
; determine whether last span or not
;
 cmp ecx,8	; are there multiple segments remaining?
 ja LNotLastSegment	; yes

;
; last segment of scan
;
LLastSegment:	

;
; advance s/z, t/z, and 1/z, and calculate s & t at end of span and steps to
; get there. The number of pixels left is variable, and we want to land on the
; last pixel, not step one past it, so we can't run into arithmetic problems
;
 test ecx,ecx	
 jz LNoSteps	; just draw the last pixel and we're done

; pick up after the FDIV that was left in flight previously


 fld st(0)	; duplicate it
 fmul st(0),st(4)	; s = s/z * z
 fxch st(1)	
 fmul st(0),st(3)	; t = t/z * z
 fxch st(1)	
 fistp ds:dword ptr[snext]	
 fistp ds:dword ptr[tnext]	

 mov ebx,ds:dword ptr[_tadjust]	
 mov eax,ds:dword ptr[_sadjust]	

 add eax,ds:dword ptr[snext]	
 add ebx,ds:dword ptr[tnext]	

 mov ebp,ds:dword ptr[_bbextents]	
 mov edx,ds:dword ptr[_bbextentt]	

 cmp eax,2048	
 jl LClampLow4	
 cmp eax,ebp	
 ja LClampHigh4	
LClampReentry4:	
 mov ds:dword ptr[snext],eax	

 cmp ebx,2048	
 jl LClampLow5	
 cmp ebx,edx	
 ja LClampHigh5	
LClampReentry5:	

 cmp ecx,1	; don't bother 
 je LOnlyOneStep	; if two pixels in segment, there's only one step,
;  of the segment length
 sub eax,ds:dword ptr[s]	
 sub ebx,ds:dword ptr[t]	

 add eax,eax	; convert to 15.17 format so multiply by 1.31
 add ebx,ebx	;  reciprocal yields 16.48
 imul ds:dword ptr[reciprocal_table-8+ecx*4]	; sstep = (snext - s) / (spancount-1)
 mov ebp,edx	

 mov eax,ebx	
 imul ds:dword ptr[reciprocal_table-8+ecx*4]	; tstep = (tnext - t) / (spancount-1)

LSetEntryvec:	
;
; set up advancetable
;
 mov ebx,ds:dword ptr[spr8entryvec_table+ecx*4]	
 mov eax,edx	
 push ebx	; entry point into code for RET later
 mov ecx,ebp	
 sar ecx,16	; sstep >>= 16;
 mov ebx,ds:dword ptr[_cachewidth]	
 sar edx,16	; tstep >>= 16;
 jz LIsZeroLast	
 imul edx,ebx	; (tstep >> 16) * cachewidth;
LIsZeroLast:	
 add edx,ecx	; add in sstep
; (tstep >> 16) * cachewidth + (sstep >> 16);
 mov ecx,ds:dword ptr[tfracf]	
 mov ds:dword ptr[advancetable+4],edx	; advance base in t
 add edx,ebx	; ((tstep >> 16) + 1) * cachewidth +
;  (sstep >> 16);
 shl ebp,16	; left-justify sstep fractional part
 mov ebx,ds:dword ptr[sfracf]	
 shl eax,16	; left-justify tstep fractional part
 mov ds:dword ptr[advancetable],edx	; advance extra in t

 mov ds:dword ptr[tstep],eax	
 mov ds:dword ptr[sstep],ebp	
 mov edx,ecx	

 mov ecx,ds:dword ptr[pz]	
 mov ebp,ds:dword ptr[izi]	

 ret	; jump to the number-of-pixels handler

;----------------------------------------

LNoSteps:	
 mov ecx,ds:dword ptr[pz]	
 sub edi,7	; adjust for hardwired offset
 sub ecx,14	
 jmp LEndSpan	


LOnlyOneStep:	
 sub eax,ds:dword ptr[s]	
 sub ebx,ds:dword ptr[t]	
 mov ebp,eax	
 mov edx,ebx	
 jmp LSetEntryvec	

;----------------------------------------

 public Spr8Entry2_8	
Spr8Entry2_8:	
 sub edi,6	; adjust for hardwired offsets
 sub ecx,12	
 mov al,ds:byte ptr[esi]	
 jmp LLEntry2_8	

;----------------------------------------

 public Spr8Entry3_8	
Spr8Entry3_8:	
 sub edi,5	; adjust for hardwired offsets
 sub ecx,10	
 jmp LLEntry3_8	

;----------------------------------------

 public Spr8Entry4_8	
Spr8Entry4_8:	
 sub edi,4	; adjust for hardwired offsets
 sub ecx,8	
 jmp LLEntry4_8	

;----------------------------------------

 public Spr8Entry5_8	
Spr8Entry5_8:	
 sub edi,3	; adjust for hardwired offsets
 sub ecx,6	
 jmp LLEntry5_8	

;----------------------------------------

 public Spr8Entry6_8	
Spr8Entry6_8:	
 sub edi,2	; adjust for hardwired offsets
 sub ecx,4	
 jmp LLEntry6_8	

;----------------------------------------

 public Spr8Entry7_8	
Spr8Entry7_8:	
 dec edi	; adjust for hardwired offsets
 sub ecx,2	
 jmp LLEntry7_8	

;----------------------------------------

 public Spr8Entry8_8	
Spr8Entry8_8:	
 cmp bp,ds:word ptr[ecx]	
 jl Lp9	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp9	
 mov ds:word ptr[ecx],bp	
 mov ds:byte ptr[edi],al	
Lp9:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	
LLEntry7_8:	
 cmp bp,ds:word ptr[2+ecx]	
 jl Lp10	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp10	
 mov ds:word ptr[2+ecx],bp	
 mov ds:byte ptr[1+edi],al	
Lp10:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	
LLEntry6_8:	
 cmp bp,ds:word ptr[4+ecx]	
 jl Lp11	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp11	
 mov ds:word ptr[4+ecx],bp	
 mov ds:byte ptr[2+edi],al	
Lp11:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	
LLEntry5_8:	
 cmp bp,ds:word ptr[6+ecx]	
 jl Lp12	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp12	
 mov ds:word ptr[6+ecx],bp	
 mov ds:byte ptr[3+edi],al	
Lp12:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	
LLEntry4_8:	
 cmp bp,ds:word ptr[8+ecx]	
 jl Lp13	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp13	
 mov ds:word ptr[8+ecx],bp	
 mov ds:byte ptr[4+edi],al	
Lp13:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	
LLEntry3_8:	
 cmp bp,ds:word ptr[10+ecx]	
 jl Lp14	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp14	
 mov ds:word ptr[10+ecx],bp	
 mov ds:byte ptr[5+edi],al	
Lp14:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	
LLEntry2_8:	
 cmp bp,ds:word ptr[12+ecx]	
 jl Lp15	
 mov al,ds:byte ptr[esi]	
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp15	
 mov ds:word ptr[12+ecx],bp	
 mov ds:byte ptr[6+edi],al	
Lp15:	
 add ebp,ds:dword ptr[izistep]	
 adc ebp,0	
 add edx,ds:dword ptr[tstep]	
 sbb eax,eax	
 add ebx,ds:dword ptr[sstep]	
 adc esi,ds:dword ptr[advancetable+4+eax*4]	

LEndSpan:	
 cmp bp,ds:word ptr[14+ecx]	
 jl Lp16	
 mov al,ds:byte ptr[esi]	; load first texel in segment
 cmp al,offset TRANSPARENT_COLOR	
 jz Lp16	
 mov ds:word ptr[14+ecx],bp	
 mov ds:byte ptr[7+edi],al	
Lp16:	

;
; clear s/z, t/z, 1/z from FP stack
;
 fstp st(0)	
 fstp st(0)	
 fstp st(0)	

 pop ebx	; restore spans pointer
LNextSpan:	
 add ebx,offset sspan_t_size	; point to next span
 mov ecx,ds:dword ptr[sspan_t_count+ebx]	
 cmp ecx,0	; any more spans?
 jg LSpanLoop	; yes
 jz LNextSpan	; yes, but this one's empty

 pop ebx	; restore register variables
 pop esi	
 pop edi	
 pop ebp	; restore the caller's stack frame
 ret	

_TEXT ENDS
endif	; id386
 END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -