change relative vertex submission to use the same overflow logic as boxtest, although i have no test csae for this. fix bugs in matrix stack which broke sims apartment pets.
This commit is contained in:
parent
ca086a3b85
commit
583fa3089d
|
@ -342,7 +342,7 @@ static u8 MM4x3ind = 0;
|
||||||
static u8 MM3x3ind = 0;
|
static u8 MM3x3ind = 0;
|
||||||
|
|
||||||
// Data for vertex submission
|
// Data for vertex submission
|
||||||
static CACHE_ALIGN float coord[4] = {0.0, 0.0, 0.0, 0.0};
|
static CACHE_ALIGN u16 u16coord[4] = {0, 0, 0, 0};
|
||||||
static char coordind = 0;
|
static char coordind = 0;
|
||||||
static u32 vtxFormat = 0;
|
static u32 vtxFormat = 0;
|
||||||
static BOOL inBegin = FALSE;
|
static BOOL inBegin = FALSE;
|
||||||
|
@ -521,7 +521,7 @@ void gfx3d_reset()
|
||||||
texturePalette = 0;
|
texturePalette = 0;
|
||||||
polyAttrPending = 0;
|
polyAttrPending = 0;
|
||||||
mode = 0;
|
mode = 0;
|
||||||
memset(coord, 0, sizeof(coord));
|
u16coord[0] = u16coord[1] = u16coord[2] = u16coord[3] = 0;
|
||||||
coordind = 0;
|
coordind = 0;
|
||||||
vtxFormat = 0;
|
vtxFormat = 0;
|
||||||
memset(trans, 0, sizeof(trans));
|
memset(trans, 0, sizeof(trans));
|
||||||
|
@ -584,6 +584,12 @@ void gfx3d_reset()
|
||||||
//Submit a vertex to the GE
|
//Submit a vertex to the GE
|
||||||
static void SetVertex()
|
static void SetVertex()
|
||||||
{
|
{
|
||||||
|
float coord[3] = {
|
||||||
|
float16table[u16coord[0]],
|
||||||
|
float16table[u16coord[1]],
|
||||||
|
float16table[u16coord[2]]
|
||||||
|
};
|
||||||
|
|
||||||
ALIGN(16) float coordTransformed[4] = { coord[0], coord[1], coord[2], 1.f };
|
ALIGN(16) float coordTransformed[4] = { coord[0], coord[1], coord[2], 1.f };
|
||||||
|
|
||||||
if (texCoordinateTransform == 3)
|
if (texCoordinateTransform == 3)
|
||||||
|
@ -812,11 +818,15 @@ void gfx3d_glPopMatrix(s32 i)
|
||||||
//this command always works on both pos and vector when either pos or pos-vector are the current mtx mode
|
//this command always works on both pos and vector when either pos or pos-vector are the current mtx mode
|
||||||
short mymode = (mode==1?2:mode);
|
short mymode = (mode==1?2:mode);
|
||||||
|
|
||||||
|
//6 bits, sign extended
|
||||||
|
//this was necessary to fix sims apartment pets
|
||||||
|
i = (i<<26)>>26;
|
||||||
|
|
||||||
if (i > mtxStack[mymode].position)
|
if (i > mtxStack[mymode].position)
|
||||||
{
|
{
|
||||||
//was commented out before zero sep modifications
|
//was commented out before zero sep modifications
|
||||||
MMU_new.gxstat.se = 1;
|
//handled in matrix now
|
||||||
|
//MMU_new.gxstat.se = 1;
|
||||||
// T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
// T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
|
@ -1198,14 +1208,17 @@ BOOL gfx3d_glVertex16b(unsigned int v)
|
||||||
{
|
{
|
||||||
if(coordind==0)
|
if(coordind==0)
|
||||||
{
|
{
|
||||||
coord[0] = float16table[v&0xFFFF];
|
//coord[0] = float16table[v&0xFFFF];
|
||||||
coord[1] = float16table[v>>16];
|
//coord[1] = float16table[v>>16];
|
||||||
|
u16coord[0] = v&0xFFFF;
|
||||||
|
u16coord[1] = (v>>16)&0xFFFF;
|
||||||
|
|
||||||
++coordind;
|
++coordind;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
coord[2] = float16table[v&0xFFFF];
|
//coord[2] = float16table[v&0xFFFF];
|
||||||
|
u16coord[2] = v&0xFFFF;
|
||||||
|
|
||||||
coordind = 0;
|
coordind = 0;
|
||||||
SetVertex ();
|
SetVertex ();
|
||||||
|
@ -1216,9 +1229,12 @@ BOOL gfx3d_glVertex16b(unsigned int v)
|
||||||
|
|
||||||
void gfx3d_glVertex10b(u32 v)
|
void gfx3d_glVertex10b(u32 v)
|
||||||
{
|
{
|
||||||
coord[0] = float10Table[v&1023];
|
//coord[0] = float10Table[v&1023];
|
||||||
coord[1] = float10Table[(v>>10)&1023];
|
//coord[1] = float10Table[(v>>10)&1023];
|
||||||
coord[2] = float10Table[(v>>20)&1023];
|
//coord[2] = float10Table[(v>>20)&1023];
|
||||||
|
u16coord[0] = (v&1023)<<6;
|
||||||
|
u16coord[1] = ((v>>10)&1023)<<6;
|
||||||
|
u16coord[2] = ((v>>20)&1023)<<6;
|
||||||
|
|
||||||
GFX_DELAY(8);
|
GFX_DELAY(8);
|
||||||
SetVertex ();
|
SetVertex ();
|
||||||
|
@ -1226,8 +1242,10 @@ void gfx3d_glVertex10b(u32 v)
|
||||||
|
|
||||||
void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v)
|
void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v)
|
||||||
{
|
{
|
||||||
coord[one] = float16table[v&0xffff];
|
//coord[one] = float16table[v&0xffff];
|
||||||
coord[two] = float16table[v>>16];
|
//coord[two] = float16table[v>>16];
|
||||||
|
u16coord[one] = v&0xffff;
|
||||||
|
u16coord[two] = (v>>16)&0xFFFF;
|
||||||
|
|
||||||
SetVertex ();
|
SetVertex ();
|
||||||
|
|
||||||
|
@ -1236,9 +1254,14 @@ void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v)
|
||||||
|
|
||||||
void gfx3d_glVertex_rel(u32 v)
|
void gfx3d_glVertex_rel(u32 v)
|
||||||
{
|
{
|
||||||
coord[0] += float10RelTable[v&1023];
|
//coord[0] += float10RelTable[v&1023];
|
||||||
coord[1] += float10RelTable[(v>>10)&1023];
|
//coord[1] += float10RelTable[(v>>10)&1023];
|
||||||
coord[2] += float10RelTable[(v>>20)&1023];
|
//coord[2] += float10RelTable[(v>>20)&1023];
|
||||||
|
|
||||||
|
u16coord[0] += (u16)(((s16)((v&1023)<<6))>>6);
|
||||||
|
u16coord[1] += (u16)(((s16)(((v>>10)&1023)<<6))>>6);
|
||||||
|
u16coord[2] += (u16)(((s16)(((v>>20)&1023)<<6))>>6);
|
||||||
|
|
||||||
|
|
||||||
SetVertex ();
|
SetVertex ();
|
||||||
|
|
||||||
|
@ -1526,7 +1549,7 @@ void gfx3d_glVecTest(u32 v)
|
||||||
{
|
{
|
||||||
GFX_DELAY(5);
|
GFX_DELAY(5);
|
||||||
|
|
||||||
//printf("VECTEST\n");
|
printf("VECTEST\n");
|
||||||
|
|
||||||
CACHE_ALIGN float normal[4] = { normalTable[v&1023],
|
CACHE_ALIGN float normal[4] = { normalTable[v&1023],
|
||||||
normalTable[(v>>10)&1023],
|
normalTable[(v>>10)&1023],
|
||||||
|
@ -2127,7 +2150,7 @@ SFORMAT SF_GFX3D[]={
|
||||||
{ "MM4I", 1, 1, &MM4x4ind},
|
{ "MM4I", 1, 1, &MM4x4ind},
|
||||||
{ "MM3I", 1, 1, &MM4x3ind},
|
{ "MM3I", 1, 1, &MM4x3ind},
|
||||||
{ "MMxI", 1, 1, &MM3x3ind},
|
{ "MMxI", 1, 1, &MM3x3ind},
|
||||||
{ "GCOR", 4, 1, coord},
|
{ "GSCO", 4, 1, u16coord},
|
||||||
{ "GCOI", 1, 1, &coordind},
|
{ "GCOI", 1, 1, &coordind},
|
||||||
{ "GVFM", 4, 1, &vtxFormat},
|
{ "GVFM", 4, 1, &vtxFormat},
|
||||||
{ "GTRN", 4, 4, trans},
|
{ "GTRN", 4, 4, trans},
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
#include "MMU.h"
|
||||||
|
|
||||||
void _NOSSE_MatrixMultVec4x4 (const float *matrix, float *vecPtr)
|
void _NOSSE_MatrixMultVec4x4 (const float *matrix, float *vecPtr)
|
||||||
{
|
{
|
||||||
|
@ -217,12 +218,17 @@ MatrixStack::MatrixStack(int size)
|
||||||
|
|
||||||
void MatrixStackSetStackPosition (MatrixStack *stack, int pos)
|
void MatrixStackSetStackPosition (MatrixStack *stack, int pos)
|
||||||
{
|
{
|
||||||
|
//printf("SetPosition: %d by %d",stack->position,pos);
|
||||||
stack->position += pos;
|
stack->position += pos;
|
||||||
|
|
||||||
if (stack->position < 0)
|
//this wraparound behavior fixed sims apartment pets which was constantly going up to 32
|
||||||
stack->position = 0;
|
s32 newpos = stack->position;
|
||||||
else if (stack->position > stack->size)
|
stack->position &= (stack->size);
|
||||||
stack->position = stack->size+1;
|
|
||||||
|
if(newpos != stack->position)
|
||||||
|
MMU_new.gxstat.se = 1;
|
||||||
|
|
||||||
|
//printf(" to %d (size %d)\n",stack->position,stack->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixStackPushMatrix (MatrixStack *stack, const float *ptr)
|
void MatrixStackPushMatrix (MatrixStack *stack, const float *ptr)
|
||||||
|
|
|
@ -39,8 +39,8 @@ struct MatrixStack
|
||||||
{
|
{
|
||||||
MatrixStack(int size);
|
MatrixStack(int size);
|
||||||
float *matrix;
|
float *matrix;
|
||||||
int position;
|
s32 position;
|
||||||
int size;
|
s32 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
void MatrixInit (float *matrix);
|
void MatrixInit (float *matrix);
|
||||||
|
|
Loading…
Reference in New Issue