fix a serious bug which crippled 3d engine loading from savestates. this should be ported to release branch. also add some missing dma state to savestate.

This commit is contained in:
zeromus 2009-01-31 03:40:20 +00:00
parent 09229a159e
commit 2578a0a291
4 changed files with 25 additions and 17 deletions

View File

@ -99,7 +99,13 @@ static float normalTable[1024];
#define fix10_2float(v) (((float)((s32)(v))) / (float)(1<<9))
// Matrix stack handling
static CACHE_ALIGN MatrixStack mtxStack[4];
static CACHE_ALIGN MatrixStack mtxStack[4] = {
MatrixStack(1), // Projection stack
MatrixStack(31), // Coordinate stack
MatrixStack(31), // Directional stack
MatrixStack(1), // Texture stack
};
static CACHE_ALIGN float mtxCurrent [4][16];
static CACHE_ALIGN float mtxTemporal[16];
static u32 mode = 0;
@ -252,11 +258,6 @@ void gfx3d_reset()
listTwiddle = 1;
twiddleLists();
MatrixStackSetMaxSize(&mtxStack[0], 1); // Projection stack
MatrixStackSetMaxSize(&mtxStack[1], 31); // Coordinate stack
MatrixStackSetMaxSize(&mtxStack[2], 31); // Directional stack
MatrixStackSetMaxSize(&mtxStack[3], 1); // Texture stack
MatrixInit (mtxCurrent[0]);
MatrixInit (mtxCurrent[1]);
MatrixInit (mtxCurrent[2]);
@ -910,6 +911,9 @@ void gfx3d_glNormal(unsigned long v)
normalTable[(v>>10)&1023],
normalTable[(v>>20)&1023]};
//use the current normal transform matrix
MatrixMultVec3x3 (mtxCurrent[2], normal);
if (texCoordinateTransform == 2)
{
last_s =( (normal[0] *mtxCurrent[3][0] + normal[1] *mtxCurrent[3][4] +
@ -918,8 +922,6 @@ void gfx3d_glNormal(unsigned long v)
normal[2] *mtxCurrent[3][9]) + _t);
}
//use the current normal transform matrix
MatrixMultVec3x3 (mtxCurrent[2], normal);
//apply lighting model
{

View File

@ -26,6 +26,7 @@
extern "C" {
void MatrixInit (float *matrix)
{
memset (matrix, 0, sizeof(float)*16);
@ -161,13 +162,6 @@ int MATRIXFASTCALL MatrixCompare (const float* matrixDST, const float* matrixSRC
return memcmp((void*)matrixDST, matrixSRC, sizeof(float)*16);
}
void MatrixStackInit (MatrixStack *stack)
{
stack->matrix = NULL;
stack->position = 0;
stack->size = 0;
}
void MatrixStackSetMaxSize (MatrixStack *stack, int size)
{
int i;
@ -188,6 +182,11 @@ void MatrixStackSetMaxSize (MatrixStack *stack, int size)
}
MatrixStack::MatrixStack(int size)
{
MatrixStackSetMaxSize(this,size);
}
void MatrixStackSetStackPosition (MatrixStack *stack, int pos)
{
stack->position += pos;

View File

@ -25,12 +25,13 @@
extern "C" {
typedef struct MatrixStack
struct MatrixStack
{
MatrixStack(int size);
float *matrix;
int position;
int size;
} MatrixStack;
};
void MatrixInit (float *matrix);

View File

@ -163,6 +163,9 @@ SFORMAT SF_NDS[]={
{ 0 }
};
extern u32 DMASrc[2][4];
extern u32 DMADst[2][4];
SFORMAT SF_MMU[]={
{ "M7BI", 1, 0x4000, MMU.ARM7_BIOS},
{ "M7ER", 1, 0x10000, MMU.ARM7_ERAM},
@ -184,10 +187,13 @@ SFORMAT SF_MMU[]={
{ "MIME", 4, 2, MMU.reg_IME},
{ "MIE_", 4, 2, MMU.reg_IE},
{ "MIF_", 4, 2, MMU.reg_IF},
{ "MDST", 4, 8, MMU.DMAStartTime},
{ "MDCY", 4, 8, MMU.DMACycle},
{ "MDCR", 4, 8, MMU.DMACrt},
{ "MDMA", 4, 8, MMU.DMAing},
{ "MDSR", 4, 8, DMASrc},
{ "MDDS", 4, 8, DMADst},
{ "MDV1", 4, 1, &MMU.divRunning},
{ "MDV2", 8, 1, &MMU.divResult},