123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038 |
- #include "asm_i386.h"
- #include "quakeasm.h"
- #include "asm_draw.h"
- #include "d_ifacea.h"
- #if id386
- .text
- LClampHigh0:
- movl C(bbextents),%esi
- jmp LClampReentry0
- LClampHighOrLow0:
- jg LClampHigh0
- xorl %esi,%esi
- jmp LClampReentry0
- LClampHigh1:
- movl C(bbextentt),%edx
- jmp LClampReentry1
- LClampHighOrLow1:
- jg LClampHigh1
- xorl %edx,%edx
- jmp LClampReentry1
- LClampLow2:
- movl $2048,%ebp
- jmp LClampReentry2
- LClampHigh2:
- movl C(bbextents),%ebp
- jmp LClampReentry2
- LClampLow3:
- movl $2048,%ecx
- jmp LClampReentry3
- LClampHigh3:
- movl C(bbextentt),%ecx
- jmp LClampReentry3
- LClampLow4:
- movl $2048,%eax
- jmp LClampReentry4
- LClampHigh4:
- movl C(bbextents),%eax
- jmp LClampReentry4
- LClampLow5:
- movl $2048,%ebx
- jmp LClampReentry5
- LClampHigh5:
- movl C(bbextentt),%ebx
- jmp LClampReentry5
- #define pspans 4+16
- .align 4
- .globl C(D_DrawSpans8)
- C(D_DrawSpans8):
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
- flds C(d_sdivzstepu)
- fmuls fp_8
- movl C(cacheblock),%edx
- flds C(d_tdivzstepu)
- fmuls fp_8
- movl pspans(%esp),%ebx
- flds C(d_zistepu)
- fmuls fp_8
- movl %edx,pbase
- fstps zi8stepu
- fstps tdivz8stepu
- fstps sdivz8stepu
- LSpanLoop:
- fildl espan_t_v(%ebx)
- fildl espan_t_u(%ebx)
- fld %st(1)
- fmuls C(d_sdivzstepv)
- fld %st(1)
- fmuls C(d_sdivzstepu)
- fld %st(2)
- fmuls C(d_tdivzstepu)
-
- fxch %st(1)
-
- faddp %st(0),%st(2)
-
- fxch %st(1)
-
- fld %st(3)
-
- fmuls C(d_tdivzstepv)
-
-
- fxch %st(1)
-
- fadds C(d_sdivzorigin)
-
- fxch %st(4)
-
- fmuls C(d_zistepv)
-
- fxch %st(1)
-
- faddp %st(0),%st(2)
-
- fxch %st(2)
-
- fmuls C(d_zistepu)
-
-
- fxch %st(1)
-
- fadds C(d_tdivzorigin)
-
- fxch %st(2)
- faddp %st(0),%st(1)
- flds fp_64k
- fxch %st(1)
- fadds C(d_ziorigin)
-
-
- fdivr %st(0),%st(1)
- movl C(d_viewbuffer),%ecx
- movl espan_t_v(%ebx),%eax
- movl %ebx,pspantemp
- movl C(tadjust),%edx
- movl C(sadjust),%esi
- movl C(d_scantable)(,%eax,4),%edi
- addl %ecx,%edi
- movl espan_t_u(%ebx),%ecx
- addl %ecx,%edi
- movl espan_t_count(%ebx),%ecx
- cmpl $8,%ecx
- ja LSetupNotLast1
- decl %ecx
- jz LCleanup1
- movl %ecx,spancountminus1
- fxch %st(1)
- fld %st(0)
- fmul %st(4),%st(0)
- fxch %st(1)
- fmul %st(3),%st(0)
- fxch %st(1)
- fistpl s
- fistpl t
- fildl spancountminus1
- flds C(d_tdivzstepu)
- flds C(d_zistepu)
- fmul %st(2),%st(0)
- fxch %st(1)
- fmul %st(2),%st(0)
- fxch %st(2)
- fmuls C(d_sdivzstepu)
-
- fxch %st(1)
-
- faddp %st(0),%st(3)
- fxch %st(1)
- faddp %st(0),%st(3)
- faddp %st(0),%st(3)
- flds fp_64k
- fdiv %st(1),%st(0)
-
- jmp LFDIVInFlight1
- LCleanup1:
- fxch %st(1)
- fld %st(0)
- fmul %st(4),%st(0)
- fxch %st(1)
- fmul %st(3),%st(0)
- fxch %st(1)
- fistpl s
- fistpl t
- jmp LFDIVInFlight1
- .align 4
- LSetupNotLast1:
- fxch %st(1)
- fld %st(0)
- fmul %st(4),%st(0)
- fxch %st(1)
- fmul %st(3),%st(0)
- fxch %st(1)
- fistpl s
- fistpl t
- fadds zi8stepu
- fxch %st(2)
- fadds sdivz8stepu
- fxch %st(2)
- flds tdivz8stepu
- faddp %st(0),%st(2)
- flds fp_64k
- fdiv %st(1),%st(0)
-
-
- LFDIVInFlight1:
- addl s,%esi
- addl t,%edx
- movl C(bbextents),%ebx
- movl C(bbextentt),%ebp
- cmpl %ebx,%esi
- ja LClampHighOrLow0
- LClampReentry0:
- movl %esi,s
- movl pbase,%ebx
- shll $16,%esi
- cmpl %ebp,%edx
- movl %esi,sfracf
- ja LClampHighOrLow1
- LClampReentry1:
- movl %edx,t
- movl s,%esi
- shll $16,%edx
- movl t,%eax
- sarl $16,%esi
- movl %edx,tfracf
- sarl $16,%eax
- movl C(cachewidth),%edx
- imull %edx,%eax
- addl %ebx,%esi
- addl %eax,%esi
-
- cmpl $8,%ecx
- jna LLastSegment
- LNotLastSegment:
- fld %st(0)
- fmul %st(4),%st(0)
- fxch %st(1)
- fmul %st(3),%st(0)
- fxch %st(1)
- fistpl snext
- fistpl tnext
- movl snext,%eax
- movl tnext,%edx
- movb (%esi),%bl
- subl $8,%ecx
- movl C(sadjust),%ebp
- movl %ecx,counttemp
- movl C(tadjust),%ecx
- movb %bl,(%edi)
- addl %eax,%ebp
- addl %edx,%ecx
- movl C(bbextents),%eax
- movl C(bbextentt),%edx
- cmpl $2048,%ebp
- jl LClampLow2
- cmpl %eax,%ebp
- ja LClampHigh2
- LClampReentry2:
- cmpl $2048,%ecx
- jl LClampLow3
- cmpl %edx,%ecx
- ja LClampHigh3
- LClampReentry3:
- movl %ebp,snext
- movl %ecx,tnext
- subl s,%ebp
- subl t,%ecx
-
- movl %ecx,%eax
- movl %ebp,%edx
- sarl $19,%eax
- jz LZero
- sarl $19,%edx
- movl C(cachewidth),%ebx
- imull %ebx,%eax
- jmp LSetUp1
- LZero:
- sarl $19,%edx
- movl C(cachewidth),%ebx
- LSetUp1:
- addl %edx,%eax
-
- movl tfracf,%edx
- movl %eax,advancetable+4
- addl %ebx,%eax
-
- shll $13,%ebp
- movl sfracf,%ebx
- shll $13,%ecx
- movl %eax,advancetable
- movl %ecx,tstep
- addl %ecx,%edx
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- sbbl %ecx,%ecx
- movb (%esi),%al
- addl %ebp,%ebx
- movb %al,1(%edi)
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- sbbl %ecx,%ecx
- movb %al,2(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- sbbl %ecx,%ecx
- movb %al,3(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- movl counttemp,%ecx
- cmpl $8,%ecx
- ja LSetupNotLast2
- decl %ecx
- jz LFDIVInFlight2
- movl %ecx,spancountminus1
- fildl spancountminus1
- flds C(d_zistepu)
- fmul %st(1),%st(0)
- flds C(d_tdivzstepu)
- fmul %st(2),%st(0)
- fxch %st(1)
- faddp %st(0),%st(3)
- fxch %st(1)
- fmuls C(d_sdivzstepu)
- fxch %st(1)
- faddp %st(0),%st(3)
- flds fp_64k
- fxch %st(1)
- faddp %st(0),%st(4)
- fdiv %st(1),%st(0)
-
- jmp LFDIVInFlight2
- .align 4
- LSetupNotLast2:
- fadds zi8stepu
- fxch %st(2)
- fadds sdivz8stepu
- fxch %st(2)
- flds tdivz8stepu
- faddp %st(0),%st(2)
- flds fp_64k
- fdiv %st(1),%st(0)
-
-
- LFDIVInFlight2:
- movl %ecx,counttemp
- addl tstep,%edx
- sbbl %ecx,%ecx
- movb %al,4(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- sbbl %ecx,%ecx
- movb %al,5(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- sbbl %ecx,%ecx
- movb %al,6(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl $8,%edi
- movl %edx,tfracf
- movl snext,%edx
- movl %ebx,sfracf
- movl tnext,%ebx
- movl %edx,s
- movl %ebx,t
- movl counttemp,%ecx
- cmpl $8,%ecx
- movb %al,-1(%edi)
- ja LNotLastSegment
- LLastSegment:
- testl %ecx,%ecx
- jz LNoSteps
- fld %st(0)
- fmul %st(4),%st(0)
- fxch %st(1)
- fmul %st(3),%st(0)
- fxch %st(1)
- fistpl snext
- fistpl tnext
- movb (%esi),%al
- movl C(tadjust),%ebx
- movb %al,(%edi)
- movl C(sadjust),%eax
- addl snext,%eax
- addl tnext,%ebx
- movl C(bbextents),%ebp
- movl C(bbextentt),%edx
- cmpl $2048,%eax
- jl LClampLow4
- cmpl %ebp,%eax
- ja LClampHigh4
- LClampReentry4:
- movl %eax,snext
- cmpl $2048,%ebx
- jl LClampLow5
- cmpl %edx,%ebx
- ja LClampHigh5
- LClampReentry5:
- cmpl $1,%ecx
- je LOnlyOneStep
-
- subl s,%eax
- subl t,%ebx
- addl %eax,%eax
- addl %ebx,%ebx
- imull reciprocal_table-8(,%ecx,4)
- movl %edx,%ebp
- movl %ebx,%eax
- imull reciprocal_table-8(,%ecx,4)
- LSetEntryvec:
- movl entryvec_table(,%ecx,4),%ebx
- movl %edx,%eax
- movl %ebx,jumptemp
- movl %ebp,%ecx
- sarl $16,%edx
- movl C(cachewidth),%ebx
- sarl $16,%ecx
- imull %ebx,%edx
- addl %ecx,%edx
-
- movl tfracf,%ecx
- movl %edx,advancetable+4
- addl %ebx,%edx
-
- shll $16,%ebp
- movl sfracf,%ebx
- shll $16,%eax
- movl %edx,advancetable
- movl %eax,tstep
- movl %ecx,%edx
- addl %eax,%edx
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- jmp *jumptemp
- LNoSteps:
- movb (%esi),%al
- subl $7,%edi
- jmp LEndSpan
- LOnlyOneStep:
- subl s,%eax
- subl t,%ebx
- movl %eax,%ebp
- movl %ebx,%edx
- jmp LSetEntryvec
- .globl Entry2_8
- Entry2_8:
- subl $6,%edi
- movb (%esi),%al
- jmp LLEntry2_8
- .globl Entry3_8
- Entry3_8:
- subl $5,%edi
- addl %eax,%edx
- movb (%esi),%al
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- jmp LLEntry3_8
- .globl Entry4_8
- Entry4_8:
- subl $4,%edi
- addl %eax,%edx
- movb (%esi),%al
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- jmp LLEntry4_8
- .globl Entry5_8
- Entry5_8:
- subl $3,%edi
- addl %eax,%edx
- movb (%esi),%al
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- jmp LLEntry5_8
- .globl Entry6_8
- Entry6_8:
- subl $2,%edi
- addl %eax,%edx
- movb (%esi),%al
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- jmp LLEntry6_8
- .globl Entry7_8
- Entry7_8:
- decl %edi
- addl %eax,%edx
- movb (%esi),%al
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- jmp LLEntry7_8
- .globl Entry8_8
- Entry8_8:
- addl %eax,%edx
- movb (%esi),%al
- sbbl %ecx,%ecx
- addl %ebp,%ebx
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- sbbl %ecx,%ecx
- movb %al,1(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- LLEntry7_8:
- sbbl %ecx,%ecx
- movb %al,2(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- LLEntry6_8:
- sbbl %ecx,%ecx
- movb %al,3(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- LLEntry5_8:
- sbbl %ecx,%ecx
- movb %al,4(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- addl tstep,%edx
- LLEntry4_8:
- sbbl %ecx,%ecx
- movb %al,5(%edi)
- addl %ebp,%ebx
- movb (%esi),%al
- adcl advancetable+4(,%ecx,4),%esi
- LLEntry3_8:
- movb %al,6(%edi)
- movb (%esi),%al
- LLEntry2_8:
- LEndSpan:
- fstp %st(0)
- fstp %st(0)
- fstp %st(0)
- movl pspantemp,%ebx
- movl espan_t_pnext(%ebx),%ebx
- testl %ebx,%ebx
- movb %al,7(%edi)
- jnz LSpanLoop
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
- .text
- LClamp:
- movl $0x40000000,%edx
- xorl %ebx,%ebx
- fstp %st(0)
- jmp LZDraw
- LClampNeg:
- movl $0x40000000,%edx
- xorl %ebx,%ebx
- fstp %st(0)
- jmp LZDrawNeg
- #define pzspans 4+16
- .globl C(D_DrawZSpans)
- C(D_DrawZSpans):
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
- flds C(d_zistepu)
- movl C(d_zistepu),%eax
- movl pzspans(%esp),%esi
- testl %eax,%eax
- jz LFNegSpan
- fmuls Float2ToThe31nd
- fistpl izistep
-
- movl izistep,%ebx
- LFSpanLoop:
- fildl espan_t_v(%esi)
- fildl espan_t_u(%esi)
- movl espan_t_v(%esi),%ecx
- movl C(d_pzbuffer),%edi
- fmuls C(d_zistepu)
- fxch %st(1)
- fmuls C(d_zistepv)
- fxch %st(1)
- fadds C(d_ziorigin)
- imull C(d_zrowbytes),%ecx
- faddp %st(0),%st(1)
- fcoms float_point5
- addl %ecx,%edi
- movl espan_t_u(%esi),%edx
- addl %edx,%edx
- movl espan_t_count(%esi),%ecx
- addl %edx,%edi
- pushl %esi
- fnstsw %ax
- testb $0x45,%ah
- jz LClamp
- fmuls Float2ToThe31nd
- fistpl izi
-
-
- movl izi,%edx
- LZDraw:
- testl $2,%edi
- jz LFMiddle
- movl %edx,%eax
- addl %ebx,%edx
- shrl $16,%eax
- decl %ecx
- movw %ax,(%edi)
- addl $2,%edi
- LFMiddle:
- pushl %ecx
- shrl $1,%ecx
- jz LFLast
- shrl $1,%ecx
- jnc LFMiddleLoop
- movl %edx,%eax
- addl %ebx,%edx
- shrl $16,%eax
- movl %edx,%esi
- addl %ebx,%edx
- andl $0xFFFF0000,%esi
- orl %esi,%eax
- movl %eax,(%edi)
- addl $4,%edi
- andl %ecx,%ecx
- jz LFLast
- LFMiddleLoop:
- movl %edx,%eax
- addl %ebx,%edx
- shrl $16,%eax
- movl %edx,%esi
- addl %ebx,%edx
- andl $0xFFFF0000,%esi
- orl %esi,%eax
- movl %edx,%ebp
- movl %eax,(%edi)
- addl %ebx,%edx
- shrl $16,%ebp
- movl %edx,%esi
- addl %ebx,%edx
- andl $0xFFFF0000,%esi
- orl %esi,%ebp
- movl %ebp,4(%edi)
- addl $8,%edi
- decl %ecx
- jnz LFMiddleLoop
- LFLast:
- popl %ecx
- popl %esi
- andl $1,%ecx
- jz LFSpanDone
- shrl $16,%edx
- movw %dx,(%edi)
- LFSpanDone:
- movl espan_t_pnext(%esi),%esi
- testl %esi,%esi
- jnz LFSpanLoop
- jmp LFDone
- LFNegSpan:
- fmuls FloatMinus2ToThe31nd
- fistpl izistep
-
- movl izistep,%ebx
- LFNegSpanLoop:
- fildl espan_t_v(%esi)
- fildl espan_t_u(%esi)
- movl espan_t_v(%esi),%ecx
- movl C(d_pzbuffer),%edi
- fmuls C(d_zistepu)
- fxch %st(1)
- fmuls C(d_zistepv)
- fxch %st(1)
- fadds C(d_ziorigin)
- imull C(d_zrowbytes),%ecx
- faddp %st(0),%st(1)
- fcoms float_point5
- addl %ecx,%edi
- movl espan_t_u(%esi),%edx
- addl %edx,%edx
- movl espan_t_count(%esi),%ecx
- addl %edx,%edi
- pushl %esi
- fnstsw %ax
- testb $0x45,%ah
- jz LClampNeg
- fmuls Float2ToThe31nd
- fistpl izi
-
-
- movl izi,%edx
- LZDrawNeg:
- testl $2,%edi
- jz LFNegMiddle
- movl %edx,%eax
- subl %ebx,%edx
- shrl $16,%eax
- decl %ecx
- movw %ax,(%edi)
- addl $2,%edi
- LFNegMiddle:
- pushl %ecx
- shrl $1,%ecx
- jz LFNegLast
- shrl $1,%ecx
- jnc LFNegMiddleLoop
- movl %edx,%eax
- subl %ebx,%edx
- shrl $16,%eax
- movl %edx,%esi
- subl %ebx,%edx
- andl $0xFFFF0000,%esi
- orl %esi,%eax
- movl %eax,(%edi)
- addl $4,%edi
- andl %ecx,%ecx
- jz LFNegLast
- LFNegMiddleLoop:
- movl %edx,%eax
- subl %ebx,%edx
- shrl $16,%eax
- movl %edx,%esi
- subl %ebx,%edx
- andl $0xFFFF0000,%esi
- orl %esi,%eax
- movl %edx,%ebp
- movl %eax,(%edi)
- subl %ebx,%edx
- shrl $16,%ebp
- movl %edx,%esi
- subl %ebx,%edx
- andl $0xFFFF0000,%esi
- orl %esi,%ebp
- movl %ebp,4(%edi)
- addl $8,%edi
- decl %ecx
- jnz LFNegMiddleLoop
- LFNegLast:
- popl %ecx
- popl %esi
- andl $1,%ecx
- jz LFNegSpanDone
- shrl $16,%edx
- movw %dx,(%edi)
- LFNegSpanDone:
- movl espan_t_pnext(%esi),%esi
- testl %esi,%esi
- jnz LFNegSpanLoop
- LFDone:
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
- #endif
|