diff --git a/tools/ps2test/main.cpp b/tools/ps2test/main.cpp index 5ca95ff..330400a 100755 --- a/tools/ps2test/main.cpp +++ b/tools/ps2test/main.cpp @@ -28,7 +28,20 @@ int *__errno() { return &errno; } // NONINTERLACED has half the vertical units uint128 packetbuf[128]; -uint128 chainbuf[128]; +uint128 vuXYZScale; +uint128 vuXYZOffset; +extern uint32 geometryCall[]; +extern uint32 skinPipe[]; + +uint128 *curVifPtr; +uint128 lightpacket[128]; +int32 numLightQ; + + + +rw::World *world; +rw::Camera *camera; + int frames; @@ -40,6 +53,22 @@ printquad(uint128 p) printf("%016lx %016lx\n", lp[1], lp[0]); } +void +printquad4(uint128 p) +{ + uint32 *lp; + lp = (uint32*)&p; + printf("%08x %08x %08x %08x\n", lp[0], lp[1], lp[2], lp[3]); +} + +void +dump4(uint128 *p, int n) +{ +printf("data at %p\n", p); + while(n--) + printquad4(*p++); +} + struct DmaChannel { uint32 chcr; uint32 pad0[3]; uint32 madr; uint32 pad1[3]; @@ -393,29 +422,6 @@ drawtri(void) toGIFchain(packetbuf); } - -rw::Matrix projMat, viewMat, worldMat; - -extern uint32 MyDmaPacket[]; -extern rw::RawMatrix vuMat; -extern rw::RawMatrix vuLightMat; -extern float vuXYZScale[]; -extern float vuXYZOffset[]; -extern float vuOffset[]; -extern uint64 vuGIFtag[]; -extern float vuMatcolor[]; -extern float vuSurfProps[]; -extern float vuAmbLight[]; -extern uint32 vuGeometry[]; -extern uint32 mpgCall[]; -extern uint32 textureCall[]; -extern uint32 geometryCall[]; -extern uint32 defaultPipe[]; -extern uint32 skinPipe[]; - -rw::World *world; -rw::Camera *camera; - void printMatrix(rw::Matrix *m) { @@ -436,59 +442,120 @@ printMatrix(rw::Matrix *m) m->flags); } +// This is not proper data, just for testing +void +setupLight(rw::Atomic *atomic) +{ + using namespace rw; + Matrix *lightmat; + float32 *lp; + + numLightQ = 0; + lp = (float32*)lightpacket; + + // TODO: this is the wrong matrix. we actually want to + // transform the light, not all normals. + lightmat = atomic->getFrame()->getLTM(); + *lp++ = lightmat->right.x; + *lp++ = lightmat->right.y; + *lp++ = lightmat->right.z; + *lp++ = 0.0f; + *lp++ = lightmat->up.x; + *lp++ = lightmat->up.y; + *lp++ = lightmat->up.z; + *lp++ = 0.0f; + *lp++ = lightmat->at.x; + *lp++ = lightmat->at.y; + *lp++ = lightmat->at.z; + *lp++ = 0.0f; + *lp++ = lightmat->pos.x; + *lp++ = lightmat->pos.y; + *lp++ = lightmat->pos.z; + *lp++ = 1.0f; + // TODO: make a proper light block + // ambient + *lp++ = 80.0f; + *lp++ = 80.0f; + *lp++ = 80.0f; + *lp++ = 0.0f; + // directional + *lp++ = 0.5f; + *lp++ = -0.5f; + *lp++ = -0.7071f; + *lp++ = 0.0f; + numLightQ = 6; +} + +void +setupTransform(rw::Atomic *atomic, rw::Matrix *trans) +{ + rw::Matrix::mult(trans, atomic->getFrame()->getLTM(), &camera->viewMatrix); +} + +enum { + DMAcnt = 0x10000000, + DMAref = 0x30000000, + DMAcall = 0x50000000, + DMAret = 0x60000000, + DMAend = 0x70000000, + + V4_32 = 0x6C +}; + +#define UNPACK(type, nq, offset) ((type)<<24 | (nq)<<16 | (offset)) +#define STCYCL(WL,CL) (0x01000000 | (WL)<<8 | (CL)) void drawAtomic(rw::Atomic *atomic) { using namespace rw; - int i; + Matrix trans; Geometry *geo; - Matrix *vp; - - printf("view matrix\n"); - printMatrix(&camera->viewMatrix); - printf("camera matrix\n"); - printMatrix(camera->getFrame()->getLTM()); - printf("atomic ltm\n"); - printMatrix(atomic->getFrame()->getLTM()); - -/* - RpAtomicPS2AllGetMeshHeaderMeshCache(atomic, ps2AllPipeData); - RpAtomicPS2AllGatherObjMetrics(atomic); - RpAtomicPS2AllMorphSetup(atomic, ps2AllPipeData); - RpAtomicPS2AllObjInstanceTest(atomic, ps2AllPipeData); - RpAtomicPS2AllClear(atomic); - RpAtomicPS2AllTransformSetup(atomic, transform); - RpAtomicPS2AllFrustumTest(atomic, &inFrustum); - RpAtomicPS2AllPrimTypeTransTypeSetup(ps2AllPipeData, inFrustum); - RpAtomicPS2AllMatModulateSetup(atomic, ps2AllPipeData); - RpAtomicPS2AllLightingSetup(ps2AllPipeData); -*/ - - // Transform Setup - Matrix::mult((Matrix*)&vuMat, atomic->getFrame()->getLTM(), &camera->viewMatrix); - vuMat.rightw = vuMat.right.z; - vuMat.upw = vuMat.up.z; - vuMat.atw = vuMat.at.z; - vuMat.posw = vuMat.pos.z; - - *(Matrix*)&vuLightMat = *atomic->getFrame()->getLTM(); - vuLightMat.rightw = 0.0f; - vuLightMat.upw = 0.0f; - vuLightMat.atw = 0.0f; - vuLightMat.posw = 1.0f; + ps2::ObjPipeline *pipe; + ps2::MatPipeline *matpipe; + Material *material; + uint128 tmp, *lp; + uint32 *vec; + RGBAf color; + int i; geo = atomic->geometry; - if(!(geo->flags & Geometry::NATIVE)){ - printf("not instanced!\n"); + pipe = (ps2::ObjPipeline*)atomic->getPipeline(); + if(pipe->platform != PLATFORM_PS2) return; - } - vuAmbLight[0] = 80; - vuAmbLight[1] = 80; - vuAmbLight[2] = 80; - vuAmbLight[3] = 0; + setupLight(atomic); + setupTransform(atomic, &trans); + + curVifPtr = packetbuf; + // upload lights + MAKEQ(tmp, DMAcnt | numLightQ+8, 0, STCYCL(4,4), UNPACK(V4_32, numLightQ, 0x3d0)); + *curVifPtr++ = tmp; + for(lp = lightpacket; numLightQ--;) + *curVifPtr++ = *lp++; + + // upload transformation matrix + MAKEQ(tmp, 0, 0, STCYCL(4,4), UNPACK(V4_32, 4, 0x3f0)); + *curVifPtr++ = tmp; + vec = (uint32*)&trans.right; + MAKEQ(tmp, vec[0], vec[1], vec[2], vec[2]); + *curVifPtr++ = tmp; + vec = (uint32*)&trans.up; + MAKEQ(tmp, vec[0], vec[1], vec[2], vec[2]); + *curVifPtr++ = tmp; + vec = (uint32*)&trans.at; + MAKEQ(tmp, vec[0], vec[1], vec[2], vec[2]); + *curVifPtr++ = tmp; + vec = (uint32*)&trans.pos; + MAKEQ(tmp, vec[0], vec[1], vec[2], vec[2]); + *curVifPtr++ = tmp; + + // upload camera/screen info + MAKEQ(tmp, 0, 0, STCYCL(4,4), UNPACK(V4_32, 2, 0x3f7)); + *curVifPtr++ = tmp; + *curVifPtr++ = vuXYZScale; + *curVifPtr++ = vuXYZOffset; assert(geo->instData != NULL); rw::ps2::InstanceDataHeader *instData = @@ -496,27 +563,49 @@ drawAtomic(rw::Atomic *atomic) rw::MeshHeader *meshHeader = geo->meshHeader; rw::Mesh *mesh; for(i = 0; i < instData->numMeshes; i++){ - geometryCall[1] = (uint32)instData->instanceMeshes[i].data; - vuMatcolor[0] = 1.0f; - vuMatcolor[1] = 1.0f; - vuMatcolor[2] = 1.0f; - vuMatcolor[3] = 1.0f; + material = instData->instanceMeshes[i].material; + matpipe = pipe->groupPipeline; + if(matpipe == nil) + matpipe = (ps2::MatPipeline*)material->pipeline; + if(matpipe == nil) + matpipe = ps2::defaultMatPipe; - vuGIFtag[0] = GIF_MAKE_TAG(0, 1, 1, GS_MAKE_PRIM(GS_PRIM_TRI_STRIP,1,0,0,0,0,0,0,0), GIF_PACKED, 3); - vuGIFtag[1] = 0x412; - - geometryCall[3] = 0x020000DC; - mpgCall[1] = (uint32)skinPipe; -// geometryCall[3] = 0x02000114; -// mpgCall[1] = (uint32)defaultPipe; - toVIF1chain(MyDmaPacket); + // call vu code + MAKEQ(tmp, DMAcall, (uint32)skinPipe, 0, 0); + *curVifPtr++ = tmp; + // unpack GIF tag, material color, surface properties + MAKEQ(tmp, DMAcnt | 3, 0, STCYCL(4,4), UNPACK(V4_32, 3, 0x3fa)); + *curVifPtr++ = tmp; + MAKE128(tmp, 0x412, + GIF_MAKE_TAG(0, 1, 1, GS_MAKE_PRIM(GS_PRIM_TRI_STRIP,1,0,0,0,0,0,0,0), GIF_PACKED, 3)); + *curVifPtr++ = tmp; + convColor(&color, &material->color); + color.alpha *= 128.0f/255.0f; + MAKEQ(tmp, *(uint32*)&color.red, *(uint32*)&color.green, + *(uint32*)&color.blue, *(uint32*)&color.alpha); + *curVifPtr++ = tmp; + MAKEQ(tmp, *(uint32*)&material->surfaceProps.ambient, + *(uint32*)&material->surfaceProps.specular, + *(uint32*)&material->surfaceProps.diffuse, + 0.0f); // extra + *curVifPtr++ = tmp; + // call geometry + MAKEQ(tmp, DMAcall, (uint32)instData->instanceMeshes[i].data, 0x03000000, 0x02000000 | matpipe->vifOffset); + *curVifPtr++ = tmp; } + MAKEQ(tmp, DMAend, 0, 0, 0); + *curVifPtr++ = tmp; + for(lp = packetbuf; lp < curVifPtr; lp++) + printquad4(*lp); + toVIF1chain(packetbuf); } void beginCamera(void) { uint128 *p, tmp; + float32 *f; + p = packetbuf; MAKE128(tmp, 0xe, GIF_MAKE_TAG(2, 1, 0, 0, GIF_PACKED, 1)); *p++ = tmp; @@ -525,14 +614,16 @@ beginCamera(void) MAKE128(tmp, GS_TEST_1, GS_MAKE_TEST(0, 0, 0, 0, 0, 0, 1, 2)); *p++ = tmp; toGIF(packetbuf, 3); - vuXYZScale[0] = WIDTH; - vuXYZScale[1] = HEIGHT; - vuXYZScale[2] = camera->zScale; - vuXYZScale[3] = 0.0f; - vuXYZOffset[0] = 2048.0f; - vuXYZOffset[1] = 2048.0f; - vuXYZOffset[2] = camera->zShift; - vuXYZOffset[3] = 0.0f; + f = (float32*)&vuXYZScale; + f[0] = WIDTH; + f[1] = HEIGHT; + f[2] = camera->zScale; + f[3] = 0.0f; + f = (float32*)&vuXYZOffset; + f[0] = 2048.0f; + f[1] = 2048.0f; + f[2] = camera->zShift; + f[3] = 0.0f; } rw::EngineStartParams engineStartParams; @@ -636,12 +727,9 @@ main() GsPutDispCtx(&gsCtx.disp[1]); // PCSX2 needs a delay for some reason { int i; for(i = 0; i < 1000000; i++); } - clearscreen(0, 0, 0); - drawtest(); - drawtri(); - - vuOffset[0] = 0.0f; - vuOffset[1] = 0.0f; + clearscreen(0x80, 0x80, 0x80); +// drawtest(); +// drawtri(); camera->beginUpdate(); beginCamera(); diff --git a/tools/ps2test/ps2.h b/tools/ps2test/ps2.h index 86122da..ced015a 100755 --- a/tools/ps2test/ps2.h +++ b/tools/ps2test/ps2.h @@ -7,10 +7,10 @@ typedef unsigned int uint128 __attribute__((mode(TI))); #define MAKE128(RES,MSB,LSB) \ __asm__ ( "pcpyld %0, %1, %2" : "=r" (RES) : "r" ((uint64)MSB), "r" ((uint64)LSB)) -#define UINT64(LOW,HIGH) ((uint64)HIGH<<32 | (uint64)LOW) +#define UINT64(LOW,HIGH) (((uint64)HIGH)<<32 | ((uint64)LOW)) #define MAKEQ(RES,W0,W1,W2,W3) MAKE128(RES,UINT64(W2,W3),UINT64(W0,W1)) -#define BIT64(v,s) ((uint64)(v) << (s)) +#define BIT64(v,s) (((uint64)(v)) << (s)) #include "mem.h" #include "gs.h" diff --git a/tools/ps2test/vu/defaultpipe.dsm b/tools/ps2test/vu/defaultpipe.dsm index bc971bf..ae3fa39 100755 --- a/tools/ps2test/vu/defaultpipe.dsm +++ b/tools/ps2test/vu/defaultpipe.dsm @@ -11,34 +11,15 @@ .equ outBuf2, (outBuf1+outSize) .equ lightMat, 0x3d0 -.equ lightDir, 0x3d4 +.equ ambientLight, 0x3d4 +.equ lightDir, 0x3d5 + .equ matrix, 0x3f0 .equ XYZScale, 0x3f7 .equ XYZOffset, 0x3f8 .equ gifTag, 0x3fa .equ matColor, 0x3fb -.equ ambientLight, 0x3fd - -/* This is the the projection matrix we start with: - * 1/2w 0 ox/2w + 1/2 -ox/2w - * 0 -1/2h -oy/2h + 1/2 oy/2h - * 0 0 1 0 - * 0 0 1 0 - * To get rid of the +1/2 in the combined matrix we - * subtract the z-row/2 from the x- and y-rows. - * - * The z-row is then set to [0 0 0 1] such that multiplication - * by XYZscale gives [0 0 0 zScale]. After perspective division - * and addition of XYZoffset we then get zScale/w + zShift for z. - * - * XYZScale scales xy to the resolution and z by zScale. - * XYZOffset translates xy to the GS coordinate system (where - * [2048, 2048] is the center of the frame buffer) and add zShift to z. - */ - -; constant: -; VF28-VF31 transformation matrix -; VF25 XYZ offset +.equ surfProps, 0x3fc .balign 16,0 @@ -47,23 +28,7 @@ DMAret * MPG 0, * .vu Start: - SUB.z VF28, VF28, VF28 LOI 0.5 ; right.z = 0 - SUB.z VF29, VF29, VF29 LQ VF28, matrix(VI00) ; up.z = 0 - load matrix - SUB.z VF30, VF30, VF30 LQ VF29, matrix+1(VI00) ; at.z = 0 - load matrix - ADDw.z VF31, VF00, VF00 LQ VF30, matrix+2(VI00) ; at.z = 1 - load matrix - NOP LQ VF31, matrix+3(VI00) ; - load matrix - MULi.w VF20, VF28, I LQ.xyz VF01, XYZScale(VI00) ; fix matrix - load scale - MULi.w VF21, VF29, I NOP ; fix matrix - MULi.w VF22, VF30, I NOP ; fix matrix - MULi.w VF23, VF31, I NOP ; fix matrix - SUBw.xy VF28, VF28, VF20 NOP ; fix matrix - SUBw.xy VF29, VF29, VF21 NOP ; fix matrix - SUBw.xy VF30, VF30, VF22 NOP ; fix matrix - SUBw.xy VF31, VF31, VF23 NOP ; fix matrix - MUL.xy VF28, VF28, VF01 LQ.xyz VF25, XYZOffset(VI00) ; scale matrix - MUL.xy VF29, VF29, VF01 IADDIU VI12, VI00, outBuf1 ; scale matrix - MUL.xy VF30, VF30, VF01 IADDIU VI13, VI00, outBuf2 ; scale matrix - MUL.xyz VF31, VF31, VF01 NOP ; scale matrix +#include "setup_persp.vu" Cnt: NOP XTOP VI02 ; input pointer NOP LQ VF01, gifTag(VI00) diff --git a/tools/ps2test/vu/light.vu b/tools/ps2test/vu/light.vu index cd941d6..8f7a31c 100755 --- a/tools/ps2test/vu/light.vu +++ b/tools/ps2test/vu/light.vu @@ -1,94 +1,94 @@ ; Ambient light: - NOP LQ VF26, ambientLight(VI00) - NOP XITOP VI01 - NOP IADDIU VI03, VI12, 2 + NOP LQ VF26, ambientLight(VI00) + NOP XITOP VI01 + NOP IADDIU VI03, VI12, 2 Ambloop: - NOP LQ VF03, 0(VI03) ; output color - NOP NOP - NOP NOP - NOP NOP - ITOF0 VF03, VF03 NOP - NOP NOP - NOP NOP - NOP NOP - ADD VF03, VF03, VF26 NOP - NOP NOP - NOP NOP - NOP NOP - FTOI0 VF03, VF03 NOP - NOP IADDI VI01, VI01, -1 - NOP IADDIU VI03, VI03, numOutAttribs - NOP IBNE VI01, VI00, Ambloop - NOP SQ VF03, -numOutAttribs(VI03) + NOP LQ VF03, 0(VI03) ; output color + NOP NOP + NOP NOP + NOP NOP + ITOF0 VF03, VF03 NOP + NOP NOP + NOP NOP + NOP NOP + ADD.xyz VF03, VF03, VF26 NOP + NOP NOP + NOP NOP + NOP NOP + FTOI0 VF03, VF03 NOP + NOP IADDI VI01, VI01, -1 + NOP IADDIU VI03, VI03, numOutAttribs + NOP IBNE VI01, VI00, Ambloop + NOP SQ VF03, -numOutAttribs(VI03) ; end amblight ; Direct Light - NOP LQ VF26, lightDir(VI00) - NOP XITOP VI01 - NOP XTOP VI02 - NOP IADDIU VI03, VI12, 2 + NOP LQ VF26, lightDir(VI00) + NOP XITOP VI01 + NOP XTOP VI02 + NOP IADDIU VI03, VI12, 2 SUB.xyz VF26, VF00, VF26 NOP Dirloop: - NOP LQ VF01, 3(VI02); ; normal - NOP LQ VF02, 0(VI03); ; output color - NOP NOP - NOP NOP - MUL VF03, VF01, VF26 NOP - ITOF0 VF02, VF02 NOP - NOP NOP - NOP NOP + NOP LQ VF01, 3(VI02); ; normal + NOP LQ VF02, 0(VI03); ; output color + NOP NOP + NOP NOP + MUL VF03, VF01, VF26 NOP + ITOF0 VF02, VF02 NOP + NOP NOP + NOP NOP ADDy.x VF03, VF03, VF03y NOP - NOP NOP - NOP NOP - NOP NOP + NOP NOP + NOP NOP + NOP NOP ADDz.x VF03, VF03, VF03z NOP - NOP NOP - NOP NOP - NOP NOP - MAX.x VF03, VF00, VF03 NOP ; clamp to 0 - NOP[I] LOI 255 - NOP NOP - NOP NOP - MULi.x VF03, VF03, I NOP - NOP NOP - NOP NOP - NOP NOP + NOP NOP + NOP NOP + NOP NOP + MAX.x VF03, VF00, VF03 NOP ; clamp to 0 + NOP[I] LOI 255 + NOP NOP + NOP NOP + MULi.x VF03, VF03, I NOP + NOP NOP + NOP NOP + NOP NOP ADDx.xyz VF02, VF02, VF03x NOP - NOP NOP - NOP NOP - NOP NOP - FTOI0 VF02, VF02 NOP - NOP IADDI VI01, VI01, -1 - NOP IADDIU VI02, VI02, numInAttribs - NOP IADDIU VI03, VI03, numOutAttribs - NOP IBNE VI01, VI00, Dirloop - NOP SQ VF02, -numOutAttribs(VI03) + NOP NOP + NOP NOP + NOP NOP + FTOI0 VF02, VF02 NOP + NOP IADDI VI01, VI01, -1 + NOP IADDIU VI02, VI02, numInAttribs + NOP IADDIU VI03, VI03, numOutAttribs + NOP IBNE VI01, VI00, Dirloop + NOP SQ VF02, -numOutAttribs(VI03) ; end dirlight ; Material color and clamp - NOP LQ VF27, matColor(VI00) - NOP XITOP VI01 - NOP IADDIU VI03, VI12, 2 + NOP LQ VF27, matColor(VI00) + NOP XITOP VI01 + NOP IADDIU VI03, VI12, 2 Colorloop: - NOP LQ VF03, 0(VI03) - NOP NOP - NOP NOP - NOP NOP - ITOF0 VF03, VF03 NOP - NOP NOP - NOP NOP - NOP NOP -;; MUL VF03, VF03, VF27 NOP - NOP[I] LOI 255 - NOP NOP - NOP NOP - MINIi VF03, VF03, I NOP - NOP NOP - NOP NOP - NOP NOP - FTOI0 VF03, VF03 NOP - NOP IADDI VI01, VI01, -1 - NOP IADDIU VI03, VI03, numOutAttribs - NOP IBNE VI01, VI00, Colorloop - NOP SQ VF03, -numOutAttribs(VI03) + NOP LQ VF03, 0(VI03) + NOP NOP + NOP NOP + NOP NOP + ITOF0 VF03, VF03 NOP + NOP NOP + NOP NOP + NOP NOP + MUL VF03, VF03, VF27 NOP + NOP[I] LOI 255 + NOP NOP + NOP NOP + MINIi VF03, VF03, I NOP + NOP NOP + NOP NOP + NOP NOP + FTOI0 VF03, VF03 NOP + NOP IADDI VI01, VI01, -1 + NOP IADDIU VI03, VI03, numOutAttribs + NOP IBNE VI01, VI00, Colorloop + NOP SQ VF03, -numOutAttribs(VI03) ; end material color diff --git a/tools/ps2test/vu/setup_persp.vu b/tools/ps2test/vu/setup_persp.vu new file mode 100755 index 0000000..b9ea42f --- /dev/null +++ b/tools/ps2test/vu/setup_persp.vu @@ -0,0 +1,39 @@ +/* This is the the projection matrix we start with: + * 1/2w 0 ox/2w + 1/2 -ox/2w + * 0 -1/2h -oy/2h + 1/2 oy/2h + * 0 0 1 0 + * 0 0 1 0 + * To get rid of the +1/2 in the combined matrix we + * subtract the z-row/2 from the x- and y-rows. + * + * The z-row is then set to [0 0 0 1] such that multiplication + * by XYZscale gives [0 0 0 zScale]. After perspective division + * and addition of XYZoffset we then get zScale/w + zShift for z. + * + * XYZScale scales xy to the resolution and z by zScale. + * XYZOffset translates xy to the GS coordinate system (where + * [2048, 2048] is the center of the frame buffer) and add zShift to z. + */ + +; constant: +; VF28-VF31 transformation matrix +; VF25 XYZ offset + + + SUB.z VF28, VF28, VF28 LOI 0.5 ; right.z = 0 + SUB.z VF29, VF29, VF29 LQ VF28, matrix(VI00) ; up.z = 0 - load matrix + SUB.z VF30, VF30, VF30 LQ VF29, matrix+1(VI00) ; at.z = 0 - load matrix + ADDw.z VF31, VF00, VF00 LQ VF30, matrix+2(VI00) ; at.z = 1 - load matrix + NOP LQ VF31, matrix+3(VI00) ; - load matrix + MULi.w VF20, VF28, I LQ.xyz VF01, XYZScale(VI00) ; fix matrix - load scale + MULi.w VF21, VF29, I NOP ; fix matrix + MULi.w VF22, VF30, I NOP ; fix matrix + MULi.w VF23, VF31, I NOP ; fix matrix + SUBw.xy VF28, VF28, VF20 NOP ; fix matrix + SUBw.xy VF29, VF29, VF21 NOP ; fix matrix + SUBw.xy VF30, VF30, VF22 NOP ; fix matrix + SUBw.xy VF31, VF31, VF23 NOP ; fix matrix + MUL.xy VF28, VF28, VF01 LQ.xyz VF25, XYZOffset(VI00) ; scale matrix + MUL.xy VF29, VF29, VF01 IADDIU VI12, VI00, outBuf1 ; scale matrix + MUL.xy VF30, VF30, VF01 IADDIU VI13, VI00, outBuf2 ; scale matrix + MUL.xyz VF31, VF31, VF01 NOP ; scale matrix diff --git a/tools/ps2test/vu/skinpipe.dsm b/tools/ps2test/vu/skinpipe.dsm index a3a8122..18536cd 100755 --- a/tools/ps2test/vu/skinpipe.dsm +++ b/tools/ps2test/vu/skinpipe.dsm @@ -11,34 +11,15 @@ .equ outBuf2, (outBuf1+outSize) .equ lightMat, 0x3d0 -.equ lightDir, 0x3d4 +.equ ambientLight, 0x3d4 +.equ lightDir, 0x3d5 + .equ matrix, 0x3f0 .equ XYZScale, 0x3f7 .equ XYZOffset, 0x3f8 .equ gifTag, 0x3fa .equ matColor, 0x3fb -.equ ambientLight, 0x3fd - -/* This is the the projection matrix we start with: - * 1/2w 0 ox/2w + 1/2 -ox/2w - * 0 -1/2h -oy/2h + 1/2 oy/2h - * 0 0 1 0 - * 0 0 1 0 - * To get rid of the +1/2 in the combined matrix we - * subtract the z-row/2 from the x- and y-rows. - * - * The z-row is then set to [0 0 0 1] such that multiplication - * by XYZscale gives [0 0 0 zScale]. After perspective division - * and addition of XYZoffset we then get zScale/w + zShift for z. - * - * XYZScale scales xy to the resolution and z by zScale. - * XYZOffset translates xy to the GS coordinate system (where - * [2048, 2048] is the center of the frame buffer) and add zShift to z. - */ - -; constant: -; VF28-VF31 transformation matrix -; VF25 XYZ offset +.equ surfProps, 0x3fc .balign 16,0 @@ -47,23 +28,7 @@ DMAret * MPG 0, * .vu Start: - SUB.z VF28, VF28, VF28 LOI 0.5 ; right.z = 0 - SUB.z VF29, VF29, VF29 LQ VF28, matrix(VI00) ; up.z = 0 - load matrix - SUB.z VF30, VF30, VF30 LQ VF29, matrix+1(VI00) ; at.z = 0 - load matrix - ADDw.z VF31, VF00, VF00 LQ VF30, matrix+2(VI00) ; at.z = 1 - load matrix - NOP LQ VF31, matrix+3(VI00) ; - load matrix - MULi.w VF20, VF28, I LQ.xyz VF01, XYZScale(VI00) ; fix matrix - load scale - MULi.w VF21, VF29, I NOP ; fix matrix - MULi.w VF22, VF30, I NOP ; fix matrix - MULi.w VF23, VF31, I NOP ; fix matrix - SUBw.xy VF28, VF28, VF20 NOP ; fix matrix - SUBw.xy VF29, VF29, VF21 NOP ; fix matrix - SUBw.xy VF30, VF30, VF22 NOP ; fix matrix - SUBw.xy VF31, VF31, VF23 NOP ; fix matrix - MUL.xy VF28, VF28, VF01 LQ.xyz VF25, XYZOffset(VI00) ; scale matrix - MUL.xy VF29, VF29, VF01 IADDIU VI12, VI00, outBuf1 ; scale matrix - MUL.xy VF30, VF30, VF01 IADDIU VI13, VI00, outBuf2 ; scale matrix - MUL.xyz VF31, VF31, VF01 NOP ; scale matrix +#include "setup_persp.vu" Cnt: NOP XTOP VI02 ; input pointer NOP LQ VF01, gifTag(VI00) diff --git a/tools/ps2test/vu/vu.dsm b/tools/ps2test/vu/vu.dsm deleted file mode 100755 index 58c10d6..0000000 --- a/tools/ps2test/vu/vu.dsm +++ /dev/null @@ -1,98 +0,0 @@ -.data -.global MyDmaPacket -.global vuLightMat -.global vuMat -.global vuXYZScale -.global vuXYZOffset -.global vuOffset -.global vuGIFtag -.global vuMatcolor -.global vuSurfProps -.global vuAmbLight -.global mpgCall -.global textureCall -.global geometryCall - -.align 4 - -MyDmaPacket: -DMAcnt * -.EndDmaData - -mpgCall: -DMAcall *, 0 ;vuProg -.EndDmaData - -/* -#define vuSDLightOffset 0x3d0 -#define vuSDBlockLow 0x3c3 -#define vuSDBlockHigh 0x3f0 -#define vuSDmat0 vuSDBlockHigh -#define vuSDmat1 vuSDBlockHigh+1 -#define vuSDmat2 vuSDBlockHigh+2 -#define vuSDmat3 vuSDBlockHigh+3 -#define vuSDnearClip vuSDBlockHigh+4 -#define vuSDfarClip vuSDBlockHigh+5 -#define vuSDxMaxyMax vuSDBlockHigh+6 -#define vuSDcamWcamHzScale vuSDBlockHigh+7 -#define vuSDoffXoffYzShift vuSDBlockHigh+8 -#define vuSDrealOffset vuSDBlockHigh+9 -#define vuSDgifTag vuSDBlockHigh+10 -#define vuSDcolScale vuSDBlockHigh+11 -#define vuSDsurfProps vuSDBlockHigh+12 -#define vuSDpingPongAddr vuSDBlockHigh+13 -#define vuSDpingPongCount vuSDBlockHigh+14 -#define vuSDClipvec1 vuSDBlockHigh+13 -#define vuSDClipvec2 vuSDBlockHigh+14 -#define vuSDVUSwitch vuSDBlockHigh+15 -*/ - -DMAcnt * - UNPACK 4, 4, V4_32, 0x3d0, * -vuLightMat: - .float 1.0, 0.0, 0.0, 0.0 - .float 0.0, 1.0, 0.0, 0.0 - .float 0.0, 0.0, 1.0, 0.0 - .float 0.0, 0.0, 0.0, 1.0 -lightDir: - .float 0.5, -0.5, -0.70710, 0.0 - .EndUnpack - - UNPACK 4, 4, V4_32, 0x3f0, * -vuMat: - .float 0.0, 0.0, 0.0, 0.0 - .float 0.0, 0.0, 0.0, 0.0 - .float 0.0, 0.0, 0.0, 0.0 - .float 0.0, 0.0, 0.0, 0.0 - .EndUnpack - - UNPACK 4, 4, V4_32, 0x3f7, * -vuXYZScale: - .float 0.0, 0.0, 0.0, 0.0 -vuXYZOffset: - .float 0.0, 0.0, 0.0, 0.0 -vuOffset: - .float 0.0, 0.0, 0.0, 0.0 -vuGIFtag: - .int 0x00008000, 0x3005C000, 0x0000000412, 0x00000000 -vuMatcolor: - .float 1.0, 1.0, 1.0, 0.5 -vuSurfProps: - .float 1.0, 1.0, 1.0, 1.0 -vuAmbLight: - .float 0, 0, 0, 0 - .EndUnpack -.EndDmaData - -;;textureCall: -;;DMAcall *, 0 -;;.EndDmaData - -geometryCall: -DMAcall *, 0 ;vuGeometry - BASE 0 - OFFSET 0x0 -.EndDmaData - -DMAend -