From a440388cdacc5bf004847ebc5869a127685dde3b Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 1 Feb 2010 05:23:20 +0000 Subject: [PATCH] core: don't execute builtin SWI when intvec is relocated to an abnormal location --- desmume/src/arm_instructions.cpp | 11 +++++++++-- desmume/src/thumb_instructions.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/desmume/src/arm_instructions.cpp b/desmume/src/arm_instructions.cpp index 2f5e13457..e0b9bb9da 100644 --- a/desmume/src/arm_instructions.cpp +++ b/desmume/src/arm_instructions.cpp @@ -6844,8 +6844,15 @@ TEMPLATE static u32 FASTCALL OP_SWI(const u32 i) IdeasLog(cpu); return 0; } - - if(cpu->swi_tab) + + //if the user has changed the intVector to point away from the nds bioses, + //then it doesn't really make any sense to use the builtin SWI's since + //the bios ones aren't getting called anyway + bool bypassBuiltinSWI = + (cpu->intVector == 0x00000000 && PROCNUM==0) + || (cpu->intVector == 0xFFFF0000 && PROCNUM==1); + + if(cpu->swi_tab && !bypassBuiltinSWI) { swinum &= 0x1F; //printf("%d ARM SWI %d \n",PROCNUM,swinum); diff --git a/desmume/src/thumb_instructions.cpp b/desmume/src/thumb_instructions.cpp index c71d288ad..97df29448 100644 --- a/desmume/src/thumb_instructions.cpp +++ b/desmume/src/thumb_instructions.cpp @@ -959,7 +959,14 @@ TEMPLATE static u32 FASTCALL OP_SWI_THUMB(const u32 i) return 0; } - if(cpu->swi_tab) { + //if the user has changed the intVector to point away from the nds bioses, + //then it doesn't really make any sense to use the builtin SWI's since + //the bios ones aren't getting called anyway + bool bypassBuiltinSWI = + (cpu->intVector == 0x00000000 && PROCNUM==0) + || (cpu->intVector == 0xFFFF0000 && PROCNUM==1); + + if(cpu->swi_tab && !bypassBuiltinSWI) { //zero 25-dec-2008 - in arm, we were masking to 0x1F. //this is probably safer since an invalid opcode could crash the emu //zero 30-jun-2009 - but they say that the ideas 0xFF should crash the device...