#ifdef protected lua function calls. This fixes linking problems.

This commit is contained in:
yabause 2009-10-16 15:47:24 +00:00
parent d4c92e2f8a
commit 9cd9f8ab58
2 changed files with 32 additions and 0 deletions

View File

@ -30,7 +30,9 @@
#include "registers.h" #include "registers.h"
#include "mc.h" #include "mc.h"
#include "bits.h" #include "bits.h"
#ifdef HAVE_LUA
#include "lua-engine.h" #include "lua-engine.h"
#endif
#define ARMCPU_ARM7 1 #define ARMCPU_ARM7 1
#define ARMCPU_ARM9 0 #define ARMCPU_ARM9 0
@ -550,7 +552,9 @@ FORCEINLINE u8 _MMU_read08(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u3
if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm
} }
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 1, /*FIXME*/ 0, LUAMEMHOOK_READ); CallRegisteredLuaMemHook(addr, 1, /*FIXME*/ 0, LUAMEMHOOK_READ);
#endif
if(PROCNUM==ARMCPU_ARM9) if(PROCNUM==ARMCPU_ARM9)
if((addr&(~0x3FFF)) == MMU.DTCMRegion) if((addr&(~0x3FFF)) == MMU.DTCMRegion)
@ -575,7 +579,9 @@ FORCEINLINE u16 _MMU_read16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u
if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm
} }
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 2, /*FIXME*/ 0, LUAMEMHOOK_READ); CallRegisteredLuaMemHook(addr, 2, /*FIXME*/ 0, LUAMEMHOOK_READ);
#endif
//special handling for execution from arm9, since we spend so much time in there //special handling for execution from arm9, since we spend so much time in there
if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE) if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE)
@ -613,7 +619,9 @@ FORCEINLINE u32 _MMU_read32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u
if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm
} }
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 4, /*FIXME*/ 0, LUAMEMHOOK_READ); CallRegisteredLuaMemHook(addr, 4, /*FIXME*/ 0, LUAMEMHOOK_READ);
#endif
//special handling for execution from arm9, since we spend so much time in there //special handling for execution from arm9, since we spend so much time in there
if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE) if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE)
@ -670,19 +678,25 @@ FORCEINLINE void _MMU_write08(const int PROCNUM, const MMU_ACCESS_TYPE AT, const
if((addr&(~0x3FFF)) == MMU.DTCMRegion) if((addr&(~0x3FFF)) == MMU.DTCMRegion)
{ {
T1WriteByte(MMU.ARM9_DTCM, addr & 0x3FFF, val); T1WriteByte(MMU.ARM9_DTCM, addr & 0x3FFF, val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 1, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 1, val, LUAMEMHOOK_WRITE);
#endif
return; return;
} }
if ( (addr & 0x0F000000) == 0x02000000) { if ( (addr & 0x0F000000) == 0x02000000) {
T1WriteByte( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val); T1WriteByte( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 1, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 1, val, LUAMEMHOOK_WRITE);
#endif
return; return;
} }
if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write08(addr,val); if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write08(addr,val);
else _MMU_ARM7_write08(addr,val); else _MMU_ARM7_write08(addr,val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 1, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 1, val, LUAMEMHOOK_WRITE);
#endif
} }
FORCEINLINE void _MMU_write16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u16 val) FORCEINLINE void _MMU_write16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u16 val)
@ -698,19 +712,25 @@ FORCEINLINE void _MMU_write16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const
if((addr&(~0x3FFF)) == MMU.DTCMRegion) if((addr&(~0x3FFF)) == MMU.DTCMRegion)
{ {
T1WriteWord(MMU.ARM9_DTCM, addr & 0x3FFE, val); T1WriteWord(MMU.ARM9_DTCM, addr & 0x3FFE, val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 2, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 2, val, LUAMEMHOOK_WRITE);
#endif
return; return;
} }
if ( (addr & 0x0F000000) == 0x02000000) { if ( (addr & 0x0F000000) == 0x02000000) {
T1WriteWord( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK16, val); T1WriteWord( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK16, val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 2, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 2, val, LUAMEMHOOK_WRITE);
#endif
return; return;
} }
if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write16(addr,val); if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write16(addr,val);
else _MMU_ARM7_write16(addr,val); else _MMU_ARM7_write16(addr,val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 2, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 2, val, LUAMEMHOOK_WRITE);
#endif
} }
FORCEINLINE void _MMU_write32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u32 val) FORCEINLINE void _MMU_write32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u32 val)
@ -726,19 +746,25 @@ FORCEINLINE void _MMU_write32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const
if((addr&(~0x3FFF)) == MMU.DTCMRegion) if((addr&(~0x3FFF)) == MMU.DTCMRegion)
{ {
T1WriteLong(MMU.ARM9_DTCM, addr & 0x3FFC, val); T1WriteLong(MMU.ARM9_DTCM, addr & 0x3FFC, val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 4, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 4, val, LUAMEMHOOK_WRITE);
#endif
return; return;
} }
if ( (addr & 0x0F000000) == 0x02000000) { if ( (addr & 0x0F000000) == 0x02000000) {
T1WriteLong( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK32, val); T1WriteLong( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK32, val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 4, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 4, val, LUAMEMHOOK_WRITE);
#endif
return; return;
} }
if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write32(addr,val); if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write32(addr,val);
else _MMU_ARM7_write32(addr,val); else _MMU_ARM7_write32(addr,val);
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(addr, 4, val, LUAMEMHOOK_WRITE); CallRegisteredLuaMemHook(addr, 4, val, LUAMEMHOOK_WRITE);
#endif
} }

View File

@ -31,7 +31,9 @@
#include "Disassembler.h" #include "Disassembler.h"
#include "NDSSystem.h" #include "NDSSystem.h"
#include "MMU_timing.h" #include "MMU_timing.h"
#ifdef HAVE_LUA
#include "lua-engine.h" #include "lua-engine.h"
#endif
template<u32> static u32 armcpu_prefetch(); template<u32> static u32 armcpu_prefetch();
@ -541,7 +543,9 @@ u32 armcpu_exec()
|| (TEST_COND(CONDITION(ARMPROC.instruction), CODE(ARMPROC.instruction), ARMPROC.CPSR)) //handles any condition || (TEST_COND(CONDITION(ARMPROC.instruction), CODE(ARMPROC.instruction), ARMPROC.CPSR)) //handles any condition
) )
{ {
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(ARMPROC.instruct_adr, 4, ARMPROC.instruction, LUAMEMHOOK_EXEC); // should report even if condition=false? CallRegisteredLuaMemHook(ARMPROC.instruct_adr, 4, ARMPROC.instruction, LUAMEMHOOK_EXEC); // should report even if condition=false?
#endif
if(PROCNUM==0) { if(PROCNUM==0) {
#ifdef DEVELOPER #ifdef DEVELOPER
DEBUG_statistics.instructionHits[0].arm[INSTRUCTION_INDEX(ARMPROC.instruction)]++; DEBUG_statistics.instructionHits[0].arm[INSTRUCTION_INDEX(ARMPROC.instruction)]++;
@ -568,7 +572,9 @@ u32 armcpu_exec()
return MMU_fetchExecuteCycles<PROCNUM>(cExecute, cFetch); return MMU_fetchExecuteCycles<PROCNUM>(cExecute, cFetch);
} }
#ifdef HAVE_LUA
CallRegisteredLuaMemHook(ARMPROC.instruct_adr, 2, ARMPROC.instruction, LUAMEMHOOK_EXEC); CallRegisteredLuaMemHook(ARMPROC.instruct_adr, 2, ARMPROC.instruction, LUAMEMHOOK_EXEC);
#endif
if(PROCNUM==0) if(PROCNUM==0)
{ {
#ifdef DEVELOPER #ifdef DEVELOPER