From 7031bd9c0c4280a2540fb3383deeaf140362aca0 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 22 Feb 2017 17:42:11 -0600 Subject: [PATCH] matrix stacks: fix new asserts in nanostray2 weapon shooting and dual strike combat anims (re #39) --- desmume/src/gfx3d.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 7f697abea..8504a2e60 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -949,12 +949,12 @@ static void gfx3d_glPushMatrix() if(mode == MATRIXMODE_PROJECTION || mode == MATRIXMODE_TEXTURE) { - u32& index = mtxStack[mode].position; - MatrixCopy(MatrixStackGetPos(&mtxStack[mode], index&1), mtxCurrent[mode]); + MatrixCopy(MatrixStackGetPos(&mtxStack[mode], 0), mtxCurrent[mode]); + u32& index = mtxStack[mode].position; + if(index == 1) MMU_new.gxstat.se = 1; //unknown if this applies to the texture matrix index += 1; - index &= 3; - if(index >= 2) MMU_new.gxstat.se = 1; //unknown if this applies to the texture matrix + index &= 1; } else { @@ -979,16 +979,12 @@ static void gfx3d_glPopMatrix(u32 v) if(mode == MATRIXMODE_PROJECTION || mode == MATRIXMODE_TEXTURE) { - //parameter ignored and treated as sensible, as a pop argument anyway - v = 1; - + //parameter is ignored and treated as sensible (always 1) + u32& index = mtxStack[mode].position; - - index -= v; - index &= 3; - if(index >= 2) MMU_new.gxstat.se = 1; //unknown if this applies to the texture matrix - - MatrixCopy(mtxCurrent[mode], MatrixStackGetPos(&mtxStack[mode], index&1)); + index ^= 1; + if(index == 1) MMU_new.gxstat.se = 1; //unknown if this applies to the texture matrix + MatrixCopy(mtxCurrent[mode], MatrixStackGetPos(&mtxStack[mode], 0)); } else {