mirror of
https://github.com/aap/librw.git
synced 2024-11-25 13:15:43 +00:00
upload PS2 texture over PATH2
This commit is contained in:
parent
0bb7ec468a
commit
34f0e5550b
@ -174,11 +174,12 @@ gsPollVsynch(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gsFlip(void)
|
gsFlip(int synch)
|
||||||
{
|
{
|
||||||
struct GsState *g = gsCurState;
|
struct GsState *g = gsCurState;
|
||||||
g->activeFb = (g->activeFb+1) & 1;
|
g->activeFb = (g->activeFb+1) & 1;
|
||||||
g->visibleFb = (g->visibleFb+1) & 1;
|
g->visibleFb = (g->visibleFb+1) & 1;
|
||||||
|
if(synch)
|
||||||
gsPollVsynch();
|
gsPollVsynch();
|
||||||
gsSelectActiveFb(g->activeFb);
|
gsSelectActiveFb(g->activeFb);
|
||||||
gsSelectVisibleFb(g->visibleFb);
|
gsSelectVisibleFb(g->visibleFb);
|
||||||
|
@ -47,7 +47,7 @@ void gsInit(void);
|
|||||||
void gsUpdateContext(void);
|
void gsUpdateContext(void);
|
||||||
void gsSelectVisibleFb(int n);
|
void gsSelectVisibleFb(int n);
|
||||||
void gsSelectActiveFb(int n);
|
void gsSelectActiveFb(int n);
|
||||||
void gsFlip(void);
|
void gsFlip(int synch);
|
||||||
void gsClear(void);
|
void gsClear(void);
|
||||||
void gsNormalizedToScreen(float *v1, uint32 *v2);
|
void gsNormalizedToScreen(float *v1, uint32 *v2);
|
||||||
|
|
||||||
|
@ -27,43 +27,51 @@ extern float vuMatcolor[];
|
|||||||
extern float vuSurfProps[];
|
extern float vuSurfProps[];
|
||||||
extern uint32 vuGeometry[];
|
extern uint32 vuGeometry[];
|
||||||
extern uint32 mpgCall[];
|
extern uint32 mpgCall[];
|
||||||
|
extern uint32 textureCall[];
|
||||||
extern uint32 geometryCall[];
|
extern uint32 geometryCall[];
|
||||||
extern uint32 defaultPipe[];
|
extern uint32 defaultPipe[];
|
||||||
extern uint32 skinPipe[];
|
extern uint32 skinPipe[];
|
||||||
|
|
||||||
rw::Clump *clump;
|
rw::Clump *clump;
|
||||||
|
|
||||||
GIF_DECLARE_PACKET(gifDmaBuf2, 256)
|
uint64 __attribute__((aligned (16))) rasterPacket[16];
|
||||||
|
|
||||||
uint32
|
void
|
||||||
uploadRaster(rw::Raster *ras)
|
uploadRaster(rw::Raster *ras)
|
||||||
{
|
{
|
||||||
GsState *g = gsCurState;
|
GsState *g = gsCurState;
|
||||||
|
uint64 *dp;
|
||||||
|
uint32 *wp;
|
||||||
uint32 destAddr = g->currentMemPtr;
|
uint32 destAddr = g->currentMemPtr;
|
||||||
uint32 size = ras->width*ras->height*4;
|
uint32 size = ras->width*ras->height*4;
|
||||||
g->currentMemPtr += size;
|
g->currentMemPtr += size;
|
||||||
|
|
||||||
GIF_BEGIN_PACKET(gifDmaBuf2);
|
// set up transfer
|
||||||
GIF_TAG(gifDmaBuf2, 4, 1, 0, 0, 0, 1, 0x0e);
|
wp = (uint32*)rasterPacket;
|
||||||
GIF_DATA_AD(gifDmaBuf2, GS_BITBLTBUF,
|
*wp++ = 0x10000000 | 6; // DMAcnt; 6 qw
|
||||||
MAKE_GS_BITBLTBUF(0, 0, 0,
|
*wp++ = 0;
|
||||||
destAddr/4/64, ras->width/64, PSMCT32));
|
*wp++ = 0;
|
||||||
GIF_DATA_AD(gifDmaBuf2, GS_TRXPOS,
|
*wp++ = 0x50000000 | 6; // DIRECT; 6 qw
|
||||||
MAKE_GS_TRXPOS(0, 0, 0, 0, 0));
|
dp = (uint64*)wp;
|
||||||
GIF_DATA_AD(gifDmaBuf2, GS_TRXREG,
|
*dp++ = MAKE_GIF_TAG(4, 1, 0, 0, 0, 1);
|
||||||
MAKE_GS_TRXREG(ras->width, ras->height));
|
*dp++ = 0x0e;
|
||||||
GIF_DATA_AD(gifDmaBuf2, GS_TRXDIR, 0);
|
*dp++ = MAKE_GS_BITBLTBUF(0,0,0,destAddr/4/64, ras->width/64, PSMCT32);
|
||||||
GIF_SEND_PACKET(gifDmaBuf2);
|
*dp++ = GS_BITBLTBUF;
|
||||||
|
*dp++ = MAKE_GS_TRXPOS(0, 0, 0, 0, 0);
|
||||||
|
*dp++ = GS_TRXPOS;
|
||||||
|
*dp++ = MAKE_GS_TRXREG(ras->width, ras->height);
|
||||||
|
*dp++ = GS_TRXREG;
|
||||||
|
*dp++ = 0;
|
||||||
|
*dp++ = GS_TRXDIR;
|
||||||
|
*dp++ = MAKE_GIF_TAG(size/0x10, 1, 0, 0, 2, 0);
|
||||||
|
*dp++ = 0;
|
||||||
|
|
||||||
GIF_BEGIN_PACKET(gifDmaBuf2);
|
// the data
|
||||||
GIF_TAG(gifDmaBuf2, size/0x10, 1, 0, 0, 2, 0, 0);
|
wp = (uint32*)dp;
|
||||||
GIF_SEND_PACKET(gifDmaBuf2);
|
*wp++ = 0x30000000 | size/0x10; // DMAref
|
||||||
|
*wp++ = (uint32)ras->texels;
|
||||||
FlushCache(0);
|
*wp++ = 0;
|
||||||
SET_REG32(D2_QWC, MAKE_DN_QWC(size/0x10));
|
*wp++ = 0x50000000 | size/0x10;
|
||||||
SET_REG32(D2_MADR, MAKE_DN_MADR(ras->texels, 0));
|
|
||||||
SET_REG32(D2_CHCR, MAKE_DN_CHCR(1, 0, 0, 0, 0, 1));
|
|
||||||
DMA_WAIT(D2_CHCR);
|
|
||||||
|
|
||||||
int logw = 0, logh = 0;
|
int logw = 0, logh = 0;
|
||||||
int s;
|
int s;
|
||||||
@ -72,17 +80,33 @@ uploadRaster(rw::Raster *ras)
|
|||||||
for(s = 1; s < ras->height; s *= 2)
|
for(s = 1; s < ras->height; s *= 2)
|
||||||
logh++;
|
logh++;
|
||||||
|
|
||||||
GIF_BEGIN_PACKET(gifDmaBuf2);
|
// set texturing registers
|
||||||
GIF_TAG(gifDmaBuf2, 3, 1, 0, 0, 0, 1, 0x0e);
|
*wp++ = 0x60000000 | 4; // DMAret; 4 qw
|
||||||
GIF_DATA_AD(gifDmaBuf2, GS_TEXFLUSH, 1);
|
*wp++ = 0;
|
||||||
GIF_DATA_AD(gifDmaBuf2, GS_TEX0_1,
|
*wp++ = 0;
|
||||||
MAKE_GS_TEX0(destAddr/4/64, ras->width/64, PSMCT32,
|
*wp++ = 0x50000000 | 4; // DIRECT; 4 qw
|
||||||
logw, logh, 0, 0, 0, 0, 0, 0, 0));
|
dp = (uint64*)wp;
|
||||||
GIF_DATA_AD(gifDmaBuf2, GS_TEX1_1,
|
*dp++ = MAKE_GIF_TAG(3, 1, 0, 0, 0, 1);
|
||||||
MAKE_GS_TEX1(0, 0, 1, 1, 0, 0, 0));
|
*dp++ = 0x0e;
|
||||||
GIF_SEND_PACKET(gifDmaBuf2);
|
*dp++ = 1;
|
||||||
|
*dp++ = GS_TEXFLUSH;
|
||||||
|
*dp++ = MAKE_GS_TEX0(destAddr/4/64, ras->width/64, PSMCT32,
|
||||||
|
logw, logh, 0, 0, 0, 0, 0, 0, 0);
|
||||||
|
*dp++ = GS_TEX0_1;
|
||||||
|
*dp++ = MAKE_GS_TEX1(0, 0, 1, 1, 0, 0, 0);
|
||||||
|
*dp++ = GS_TEX1_1;
|
||||||
|
}
|
||||||
|
|
||||||
return destAddr;
|
void
|
||||||
|
dumpRasterPacket(int n)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
uint32 *p = (uint32*)rasterPacket;
|
||||||
|
for(i = 0; i < n; i++){
|
||||||
|
printf("%p %p %p %p\n", p[0], p[1], p[2], p[3]);
|
||||||
|
p += 4;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -119,7 +143,13 @@ drawAtomic(rw::Atomic *atomic)
|
|||||||
vuMatcolor[2] /= 2.0f;
|
vuMatcolor[2] /= 2.0f;
|
||||||
tex = 0x10;
|
tex = 0x10;
|
||||||
uploadRaster(mesh->material->texture->raster);
|
uploadRaster(mesh->material->texture->raster);
|
||||||
|
}else{
|
||||||
|
rasterPacket[0] = 0x60000000;
|
||||||
|
rasterPacket[1] = 0x00000000;
|
||||||
|
rasterPacket[2] = 0x00000000;
|
||||||
|
rasterPacket[3] = 0x00000000;
|
||||||
}
|
}
|
||||||
|
textureCall[1] = (uint32)rasterPacket;
|
||||||
vuGIFtag[0] = MAKE_GIF_TAG(0,1,1,0xC|tex,0,3);
|
vuGIFtag[0] = MAKE_GIF_TAG(0,1,1,0xC|tex,0,3);
|
||||||
vuGIFtag[1] = 0x412;
|
vuGIFtag[1] = 0x412;
|
||||||
if(rw::skinGlobals.offset && skin){
|
if(rw::skinGlobals.offset && skin){
|
||||||
@ -151,6 +181,7 @@ draw(void)
|
|||||||
matTranslate(viewMat, 0.0f, 0.0f, -34.0f);
|
matTranslate(viewMat, 0.0f, 0.0f, -34.0f);
|
||||||
// matTranslate(viewMat, 0.0f, 0.0f, -10.0f);
|
// matTranslate(viewMat, 0.0f, 0.0f, -10.0f);
|
||||||
// matTranslate(viewMat, 0.0f, 0.0f, -8.0f);
|
// matTranslate(viewMat, 0.0f, 0.0f, -8.0f);
|
||||||
|
// matTranslate(viewMat, 0.0f, 0.0f, -4.0f);
|
||||||
matRotateX(viewMat, rot);
|
matRotateX(viewMat, rot);
|
||||||
matRotateY(viewMat, rot);
|
matRotateY(viewMat, rot);
|
||||||
matRotateZ(viewMat, rot);
|
matRotateZ(viewMat, rot);
|
||||||
@ -246,7 +277,7 @@ main()
|
|||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
draw();
|
draw();
|
||||||
gsFlip();
|
gsFlip(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
.global vuMatcolor
|
.global vuMatcolor
|
||||||
.global vuSurfProps
|
.global vuSurfProps
|
||||||
.global mpgCall
|
.global mpgCall
|
||||||
|
.global textureCall
|
||||||
.global geometryCall
|
.global geometryCall
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
@ -48,11 +49,16 @@ vuMatcolor:
|
|||||||
vuSurfProps:
|
vuSurfProps:
|
||||||
.float 1.0, 1.0, 1.0, 1.0
|
.float 1.0, 1.0, 1.0, 1.0
|
||||||
; .float 160, 160, 160, 0 ; some ambient light
|
; .float 160, 160, 160, 0 ; some ambient light
|
||||||
.float 20, 20, 20, 0 ; some ambient light
|
.float 80, 80, 80, 0
|
||||||
|
; .float 20, 20, 20, 0
|
||||||
; .float 0, 0, 0, 0
|
; .float 0, 0, 0, 0
|
||||||
.EndUnpack
|
.EndUnpack
|
||||||
.EndDmaData
|
.EndDmaData
|
||||||
|
|
||||||
|
textureCall:
|
||||||
|
DMAcall *, 0
|
||||||
|
.EndDmaData
|
||||||
|
|
||||||
geometryCall:
|
geometryCall:
|
||||||
DMAcall *, 0 ;vuGeometry
|
DMAcall *, 0 ;vuGeometry
|
||||||
BASE 0
|
BASE 0
|
||||||
|
Loading…
Reference in New Issue
Block a user