mirror of https://github.com/aap/librw.git
work on ps2test
This commit is contained in:
parent
aec8c202c6
commit
7280647085
|
@ -28,7 +28,20 @@ int *__errno() { return &errno; }
|
||||||
// NONINTERLACED has half the vertical units
|
// NONINTERLACED has half the vertical units
|
||||||
|
|
||||||
uint128 packetbuf[128];
|
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;
|
int frames;
|
||||||
|
|
||||||
|
@ -40,6 +53,22 @@ printquad(uint128 p)
|
||||||
printf("%016lx %016lx\n", lp[1], lp[0]);
|
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 {
|
struct DmaChannel {
|
||||||
uint32 chcr; uint32 pad0[3];
|
uint32 chcr; uint32 pad0[3];
|
||||||
uint32 madr; uint32 pad1[3];
|
uint32 madr; uint32 pad1[3];
|
||||||
|
@ -393,29 +422,6 @@ drawtri(void)
|
||||||
toGIFchain(packetbuf);
|
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
|
void
|
||||||
printMatrix(rw::Matrix *m)
|
printMatrix(rw::Matrix *m)
|
||||||
{
|
{
|
||||||
|
@ -436,59 +442,120 @@ printMatrix(rw::Matrix *m)
|
||||||
m->flags);
|
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
|
void
|
||||||
drawAtomic(rw::Atomic *atomic)
|
drawAtomic(rw::Atomic *atomic)
|
||||||
{
|
{
|
||||||
using namespace rw;
|
using namespace rw;
|
||||||
|
|
||||||
int i;
|
Matrix trans;
|
||||||
Geometry *geo;
|
Geometry *geo;
|
||||||
Matrix *vp;
|
ps2::ObjPipeline *pipe;
|
||||||
|
ps2::MatPipeline *matpipe;
|
||||||
printf("view matrix\n");
|
Material *material;
|
||||||
printMatrix(&camera->viewMatrix);
|
uint128 tmp, *lp;
|
||||||
printf("camera matrix\n");
|
uint32 *vec;
|
||||||
printMatrix(camera->getFrame()->getLTM());
|
RGBAf color;
|
||||||
printf("atomic ltm\n");
|
int i;
|
||||||
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;
|
|
||||||
|
|
||||||
geo = atomic->geometry;
|
geo = atomic->geometry;
|
||||||
if(!(geo->flags & Geometry::NATIVE)){
|
pipe = (ps2::ObjPipeline*)atomic->getPipeline();
|
||||||
printf("not instanced!\n");
|
if(pipe->platform != PLATFORM_PS2)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
vuAmbLight[0] = 80;
|
setupLight(atomic);
|
||||||
vuAmbLight[1] = 80;
|
setupTransform(atomic, &trans);
|
||||||
vuAmbLight[2] = 80;
|
|
||||||
vuAmbLight[3] = 0;
|
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);
|
assert(geo->instData != NULL);
|
||||||
rw::ps2::InstanceDataHeader *instData =
|
rw::ps2::InstanceDataHeader *instData =
|
||||||
|
@ -496,27 +563,49 @@ drawAtomic(rw::Atomic *atomic)
|
||||||
rw::MeshHeader *meshHeader = geo->meshHeader;
|
rw::MeshHeader *meshHeader = geo->meshHeader;
|
||||||
rw::Mesh *mesh;
|
rw::Mesh *mesh;
|
||||||
for(i = 0; i < instData->numMeshes; i++){
|
for(i = 0; i < instData->numMeshes; i++){
|
||||||
geometryCall[1] = (uint32)instData->instanceMeshes[i].data;
|
material = instData->instanceMeshes[i].material;
|
||||||
vuMatcolor[0] = 1.0f;
|
matpipe = pipe->groupPipeline;
|
||||||
vuMatcolor[1] = 1.0f;
|
if(matpipe == nil)
|
||||||
vuMatcolor[2] = 1.0f;
|
matpipe = (ps2::MatPipeline*)material->pipeline;
|
||||||
vuMatcolor[3] = 1.0f;
|
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);
|
// call vu code
|
||||||
vuGIFtag[1] = 0x412;
|
MAKEQ(tmp, DMAcall, (uint32)skinPipe, 0, 0);
|
||||||
|
*curVifPtr++ = tmp;
|
||||||
geometryCall[3] = 0x020000DC;
|
// unpack GIF tag, material color, surface properties
|
||||||
mpgCall[1] = (uint32)skinPipe;
|
MAKEQ(tmp, DMAcnt | 3, 0, STCYCL(4,4), UNPACK(V4_32, 3, 0x3fa));
|
||||||
// geometryCall[3] = 0x02000114;
|
*curVifPtr++ = tmp;
|
||||||
// mpgCall[1] = (uint32)defaultPipe;
|
MAKE128(tmp, 0x412,
|
||||||
toVIF1chain(MyDmaPacket);
|
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
|
void
|
||||||
beginCamera(void)
|
beginCamera(void)
|
||||||
{
|
{
|
||||||
uint128 *p, tmp;
|
uint128 *p, tmp;
|
||||||
|
float32 *f;
|
||||||
|
|
||||||
p = packetbuf;
|
p = packetbuf;
|
||||||
MAKE128(tmp, 0xe, GIF_MAKE_TAG(2, 1, 0, 0, GIF_PACKED, 1));
|
MAKE128(tmp, 0xe, GIF_MAKE_TAG(2, 1, 0, 0, GIF_PACKED, 1));
|
||||||
*p++ = tmp;
|
*p++ = tmp;
|
||||||
|
@ -525,14 +614,16 @@ beginCamera(void)
|
||||||
MAKE128(tmp, GS_TEST_1, GS_MAKE_TEST(0, 0, 0, 0, 0, 0, 1, 2));
|
MAKE128(tmp, GS_TEST_1, GS_MAKE_TEST(0, 0, 0, 0, 0, 0, 1, 2));
|
||||||
*p++ = tmp;
|
*p++ = tmp;
|
||||||
toGIF(packetbuf, 3);
|
toGIF(packetbuf, 3);
|
||||||
vuXYZScale[0] = WIDTH;
|
f = (float32*)&vuXYZScale;
|
||||||
vuXYZScale[1] = HEIGHT;
|
f[0] = WIDTH;
|
||||||
vuXYZScale[2] = camera->zScale;
|
f[1] = HEIGHT;
|
||||||
vuXYZScale[3] = 0.0f;
|
f[2] = camera->zScale;
|
||||||
vuXYZOffset[0] = 2048.0f;
|
f[3] = 0.0f;
|
||||||
vuXYZOffset[1] = 2048.0f;
|
f = (float32*)&vuXYZOffset;
|
||||||
vuXYZOffset[2] = camera->zShift;
|
f[0] = 2048.0f;
|
||||||
vuXYZOffset[3] = 0.0f;
|
f[1] = 2048.0f;
|
||||||
|
f[2] = camera->zShift;
|
||||||
|
f[3] = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
rw::EngineStartParams engineStartParams;
|
rw::EngineStartParams engineStartParams;
|
||||||
|
@ -636,12 +727,9 @@ main()
|
||||||
GsPutDispCtx(&gsCtx.disp[1]);
|
GsPutDispCtx(&gsCtx.disp[1]);
|
||||||
// PCSX2 needs a delay for some reason
|
// PCSX2 needs a delay for some reason
|
||||||
{ int i; for(i = 0; i < 1000000; i++); }
|
{ int i; for(i = 0; i < 1000000; i++); }
|
||||||
clearscreen(0, 0, 0);
|
clearscreen(0x80, 0x80, 0x80);
|
||||||
drawtest();
|
// drawtest();
|
||||||
drawtri();
|
// drawtri();
|
||||||
|
|
||||||
vuOffset[0] = 0.0f;
|
|
||||||
vuOffset[1] = 0.0f;
|
|
||||||
|
|
||||||
camera->beginUpdate();
|
camera->beginUpdate();
|
||||||
beginCamera();
|
beginCamera();
|
||||||
|
|
|
@ -7,10 +7,10 @@ typedef unsigned int uint128 __attribute__((mode(TI)));
|
||||||
|
|
||||||
#define MAKE128(RES,MSB,LSB) \
|
#define MAKE128(RES,MSB,LSB) \
|
||||||
__asm__ ( "pcpyld %0, %1, %2" : "=r" (RES) : "r" ((uint64)MSB), "r" ((uint64)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 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 "mem.h"
|
||||||
#include "gs.h"
|
#include "gs.h"
|
||||||
|
|
|
@ -11,34 +11,15 @@
|
||||||
.equ outBuf2, (outBuf1+outSize)
|
.equ outBuf2, (outBuf1+outSize)
|
||||||
|
|
||||||
.equ lightMat, 0x3d0
|
.equ lightMat, 0x3d0
|
||||||
.equ lightDir, 0x3d4
|
.equ ambientLight, 0x3d4
|
||||||
|
.equ lightDir, 0x3d5
|
||||||
|
|
||||||
.equ matrix, 0x3f0
|
.equ matrix, 0x3f0
|
||||||
.equ XYZScale, 0x3f7
|
.equ XYZScale, 0x3f7
|
||||||
.equ XYZOffset, 0x3f8
|
.equ XYZOffset, 0x3f8
|
||||||
.equ gifTag, 0x3fa
|
.equ gifTag, 0x3fa
|
||||||
.equ matColor, 0x3fb
|
.equ matColor, 0x3fb
|
||||||
.equ ambientLight, 0x3fd
|
.equ surfProps, 0x3fc
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
|
|
||||||
.balign 16,0
|
.balign 16,0
|
||||||
|
@ -47,23 +28,7 @@ DMAret *
|
||||||
MPG 0, *
|
MPG 0, *
|
||||||
.vu
|
.vu
|
||||||
Start:
|
Start:
|
||||||
SUB.z VF28, VF28, VF28 LOI 0.5 ; right.z = 0
|
#include "setup_persp.vu"
|
||||||
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
|
|
||||||
Cnt:
|
Cnt:
|
||||||
NOP XTOP VI02 ; input pointer
|
NOP XTOP VI02 ; input pointer
|
||||||
NOP LQ VF01, gifTag(VI00)
|
NOP LQ VF01, gifTag(VI00)
|
||||||
|
|
|
@ -11,7 +11,7 @@ Ambloop:
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
ADD VF03, VF03, VF26 NOP
|
ADD.xyz VF03, VF03, VF26 NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
|
@ -78,7 +78,7 @@ Colorloop:
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
;; MUL VF03, VF03, VF27 NOP
|
MUL VF03, VF03, VF27 NOP
|
||||||
NOP[I] LOI 255
|
NOP[I] LOI 255
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
|
|
|
@ -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
|
|
@ -11,34 +11,15 @@
|
||||||
.equ outBuf2, (outBuf1+outSize)
|
.equ outBuf2, (outBuf1+outSize)
|
||||||
|
|
||||||
.equ lightMat, 0x3d0
|
.equ lightMat, 0x3d0
|
||||||
.equ lightDir, 0x3d4
|
.equ ambientLight, 0x3d4
|
||||||
|
.equ lightDir, 0x3d5
|
||||||
|
|
||||||
.equ matrix, 0x3f0
|
.equ matrix, 0x3f0
|
||||||
.equ XYZScale, 0x3f7
|
.equ XYZScale, 0x3f7
|
||||||
.equ XYZOffset, 0x3f8
|
.equ XYZOffset, 0x3f8
|
||||||
.equ gifTag, 0x3fa
|
.equ gifTag, 0x3fa
|
||||||
.equ matColor, 0x3fb
|
.equ matColor, 0x3fb
|
||||||
.equ ambientLight, 0x3fd
|
.equ surfProps, 0x3fc
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
|
|
||||||
.balign 16,0
|
.balign 16,0
|
||||||
|
@ -47,23 +28,7 @@ DMAret *
|
||||||
MPG 0, *
|
MPG 0, *
|
||||||
.vu
|
.vu
|
||||||
Start:
|
Start:
|
||||||
SUB.z VF28, VF28, VF28 LOI 0.5 ; right.z = 0
|
#include "setup_persp.vu"
|
||||||
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
|
|
||||||
Cnt:
|
Cnt:
|
||||||
NOP XTOP VI02 ; input pointer
|
NOP XTOP VI02 ; input pointer
|
||||||
NOP LQ VF01, gifTag(VI00)
|
NOP LQ VF01, gifTag(VI00)
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
Loading…
Reference in New Issue