diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 7e80aab53..48384cfac 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -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 { diff --git a/desmume/src/matrix.cpp b/desmume/src/matrix.cpp index de4c31c37..4d74a8581 100644 --- a/desmume/src/matrix.cpp +++ b/desmume/src/matrix.cpp @@ -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; diff --git a/desmume/src/matrix.h b/desmume/src/matrix.h index 38d37de16..bd8d729d1 100644 --- a/desmume/src/matrix.h +++ b/desmume/src/matrix.h @@ -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); diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 49c45497c..e22a0cc7c 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -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},