.equ vertexTop, 0x3f0 .equ numInAttribs, 3 .equ numOutAttribs, 3 .equ numOutBuf, 2 .equ vertCount, ((vertexTop-numOutBuf)/(numInAttribs*2+numOutAttribs*numOutBuf)) .equ offset, (vertCount*numInAttribs) .equ outBuf1, (2*offset) ;.equ outSize, ((vertexTop-outBuf1-numOutBuf)/numOutBuf) .equ outSize, (1 + vertCount*numOutAttribs) .equ outBuf2, (outBuf1+outSize) .include "defines.inc" #define IN_VERTEX(n,r) 0 + (n)*numInAttribs(r) #define IN_UV(n,r) 1 + (n)*numInAttribs(r) #define IN_RGBA(n,r) 2 + (n)*numInAttribs(r) #define OUT_STQ(n,r) 0 + (n)*numOutAttribs(r) #define OUT_RGBA(n,r) 1 + (n)*numOutAttribs(r) #define OUT_XYZ(n,r) 2 + (n)*numOutAttribs(r) .balign 16,0 .global vu1_im2d vu1_im2d: DMAret * MPG 0, * .vu start: nop iaddiu vi12,vi00,outBuf1 nop iaddiu vi13,vi00,outBuf2 nop lq vf04,xyzwOffset(vi00) nop lq vf05,colorScale(vi00) nop lq vf06,colorScale(vi00) restart: nop ilw.x vi09,codeSwitch(vi00) ; process switch nop xtop vi02 ; input pointer nop jr vi09 nop xtop vi01 ; vertex count NoFog: nop xtop vi02 ; input pointer mulz.w vf01,vf00,vf00 lq vf13,IN_RGBA(0,vi02) ; clear ADC flag - load rgba nop lq.xyz vf11,IN_VERTEX(0,vi02) ; - load xyz nop lq.xyz vf02,IN_UV(0,vi02) ; - load uvq nop lq vf03,gifTag(vi00) ; - GIF tag itof0 vf13,vf13 xitop vi01 ; rgba to float - vertex count add.xy vf11,vf11,vf04 iaddiu vi05,vi00,0x4000 ; add xy offset mulz.xy vf02,vf02,vf02 iadd vi05,vi05,vi05 ; - EOP bit nop ior vi05,vi05,vi01 ; - enter vertex count nop sq vf03,0(vi12) ; - store GIF tag nop isw.x vi05,0(vi12) nop iaddiu vi03,vi12,1 ; - output pointer nop iadd vi05,vi03,vi01 .rept numOutAttribs-1 nop iadd vi05,vi05,vi01 .endr NoFogLoop: mul vf03,vf13,vf05 lq.xyz vf12,IN_UV(1,vi02) nop lq vf13,IN_RGBA(1,vi02) ftoi4.xyz vf01,vf11 lq.xyz vf11,IN_VERTEX(1,vi02) nop iaddiu vi02,vi02,numInAttribs ftoi0 vf03,vf03 iaddiu vi03,vi03,numOutAttribs itof0 vf13,vf13 sq vf02,OUT_STQ(-1,vi03) add.xy vf11,vf11,vf04 sq vf01,OUT_XYZ(-1,vi03) mulz.xy vf02,vf12,vf12 ibne vi03,vi05,NoFogLoop addx.z vf02,vf12,vf00 sq vf03,OUT_RGBA(-1,vi03) nop b End nop nop Fog: nop loi 255.0 nop xtop vi02 ; input pointer nop lq vf21,IN_VERTEX(0,vi02) ; - load xyzw nop lq vf13,IN_RGBA(0,vi02) ; - load rgba nop lq.xyz vf02,IN_UV(0,vi02) ; - load uvq addax acc,vf04,vf00 lq vf03,gifTag(vi00) ; - GIF tag madd vf21,vf05,vf21 xitop vi01 ; - vertex count itof0 vf13,vf13 iaddiu vi05,vi00,0x4000 ; nop iadd vi05,vi05,vi05 ; - EOP bit nop ior vi05,vi05,vi01 ; - enter vertex count minii.w vf11,vf21,i sq vf03,0(vi12) ; - store GIF tag addx.xyz vf01,vf21,vf00 isw.x vi05,0(vi12) nop iaddiu vi03,vi12,1 ; - output pointer nop iadd vi05,vi03,vi01 .rept numInAttribs-1 nop iadd vi05,vi05,vi01 .endr FogLoop: mul vf03,vf13,vf06 nop addax acc,vf04,vf00 lq vf21,IN_VERTEX(1,vi02) maxw.w vf01,vf11,vf00 nop mulz.xy vf02,vf02,vf02 lq vf13,IN_RGBA(1,vi02) ftoi0 vf03,vf03 lq.xyz vf12,IN_UV(1,vi02) madd vf21,vf05,vf21 iaddiu vi02,vi02,numInAttribs ftoi4 vf01,vf01 iaddiu vi03,vi03,numOutAttribs itof0 vf13,vf13 sq vf02,OUT_STQ(-1,vi03) addx vf02,vf12,vf00 sq vf03,OUT_RGBA(-1,vi03) minii.w vf11,vf21,i ibne vi03,vi05,FogLoop addx.xyz vf01,vf21,vf00 sq vf01,OUT_XYZ(-1,vi03) nop b End nop nop End: nop xgkick vi12 nop iadd vi15,vi00,vi12 nop[e] iadd vi12,vi00,vi13 nop iadd vi13,vi00,vi15 nop b restart nop nop .EndMPG .EndDmaData .global vu1_im2d_desc vu1_im2d_desc: .word NoFog, 0, 0, 0 .word Fog, 0, 0, 0