From bd1367a536629088403a84cad44338b7c92630b5 Mon Sep 17 00:00:00 2001 From: luigi__ Date: Thu, 4 Dec 2008 21:58:24 +0000 Subject: [PATCH] Modified the GXSTAT register handling, this is still an ugly hack but some games (like Super Mario 64) don't freeze anymore. --- desmume/src/MMU.cpp | 11 ++++++++--- desmume/src/NDSSystem.cpp | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 7e66753f2..b89b9d44e 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -228,6 +228,8 @@ u32 MMU_ARM7_WAIT16[16]={ u32 MMU_ARM7_WAIT32[16]={ 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 5, 1, 1, 1, 1, 1, }; + +u32 gxIRQ = 0; // VRAM mapping u8 *LCDdst[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; @@ -774,12 +776,14 @@ u32 FASTCALL _MMU_read32(u32 adr) // This is hacked due to the only current 3D core case 0x04000600: // Geometry Engine Status Register (R and R/W) { - u32 gxstat = ( 2 | + /* u32 gxstat = ( 2 | (MMU.fifos[proc].full<<24)| (MMU.fifos[proc].half<<25)| (MMU.fifos[proc].empty<<26)| (MMU.fifos[proc].irq<<30) - ); + );*/ + u32 gxstat = (2 | (3 << 25) | (gxIRQ << 30)); + return gxstat; } @@ -2258,7 +2262,8 @@ void FASTCALL _MMU_write32(u32 adr, u32 val) case 0x04000600: // Geometry Engine Status Register (R and R/W) { - MMU.fifos[proc].irq = (val>>30) & 0x03; + //MMU.fifos[proc].irq = (val>>30) & 0x03; + gxIRQ = ((val >> 30) & 0x3); return; } case REG_DISPA_WININ: diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 2e91667c0..a62a8e3eb 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -41,6 +41,8 @@ NDSSystem nds; +extern u32 gxIRQ; + static u32 calc_CRC16( u32 start, const u8 *data, int count) { int i,j; @@ -1549,8 +1551,10 @@ NDS_exec(s32 nb, BOOL force) if(MMU.reg_IE[0]&(1<<21)) // IRQ21 { - if (MMU.fifos[0].irq==1) NDS_makeARM9Int(21); - if (MMU.fifos[0].irq==2) NDS_makeARM9Int(21); + // if (MMU.fifos[0].irq==1) NDS_makeARM9Int(21); + // if (MMU.fifos[0].irq==2) NDS_makeARM9Int(21); + if (gxIRQ == 1) NDS_makeARM9Int(21); + if (gxIRQ == 2) NDS_makeARM9Int(21); } if((MMU.reg_IF[0]&MMU.reg_IE[0]) && (MMU.reg_IME[0]))