diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 296ba97c8..945e158cd 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -21,13 +21,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//#define RENDER3D - #include #include #include - -//#include "gl_vertex.h" +#include #include "debug.h" #include "NDSSystem.h" @@ -3573,12 +3570,14 @@ struct armcpu_memory_iface arm9_direct_memory_iface = { u32 FASTCALL MMU_read32(u32 proc, u32 adr) { + assert((adr&3)==0); if(proc==0) return _MMU_read32<0ul>(adr); else return _MMU_read32<1ul>(adr); } u16 FASTCALL MMU_read16(u32 proc, u32 adr) { + assert((adr&1)==0); if(proc==0) return _MMU_read16<0ul>(adr); else return _MMU_read16<1ul>(adr); } @@ -3591,12 +3590,14 @@ u8 FASTCALL MMU_read8(u32 proc, u32 adr) void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val) { + assert((adr&3)==0); if(proc==0) _MMU_write32<0ul>(adr,val); else _MMU_write32<1ul>(adr,val); } void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val) { + assert((adr&1)==0); if(proc==0) _MMU_write16<0ul>(adr,val); else _MMU_write16<1ul>(adr,val); } diff --git a/desmume/src/MMU.h b/desmume/src/MMU.h index fe2ed8fb2..aef1780ca 100644 --- a/desmume/src/MMU.h +++ b/desmume/src/MMU.h @@ -60,6 +60,11 @@ typedef struct { //Unused ram u8 UNUSED_RAM[4]; + + //this is here so that we can trap glitchy emulator code + //which is accessing offsets 5,6,7 of unused ram due to unaligned accesses + //(also since the emulator doesn't prevent unaligned accesses) + u8 MORE_UNUSED_RAM[4]; u8 * * MMU_MEM[2]; u32 * MMU_MASK[2]; diff --git a/desmume/src/armcpu.cpp b/desmume/src/armcpu.cpp index 30de9603b..0ac79f4dd 100644 --- a/desmume/src/armcpu.cpp +++ b/desmume/src/armcpu.cpp @@ -19,12 +19,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include +#include #include "arm_instructions.h" #include "thumb_instructions.h" #include "cp15.h" #include "bios.h" -#include -#include + template static u32 armcpu_prefetch(); @@ -538,6 +540,8 @@ u32 armcpu_exec() { u32 c = 1; + assert(ARMPROC.instruct_adr!=0x00000000); + #ifdef GDB_STUB if (ARMPROC.stalled) return STALLED_CYCLE_COUNT;