From a9eb5760eca8e4c9979974d54de6d5f999c3dfd7 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Mon, 7 Apr 2014 12:46:26 -0700 Subject: [PATCH] Updated lazyusf --- Frameworks/lazyusf/lazyusf/interpreter_cpu.c | 2 +- Frameworks/lazyusf/lazyusf/memory.c | 56 +++++++++++++------- Frameworks/lazyusf/lazyusf/rsp/rsp.h | 2 + Frameworks/lazyusf/lazyusf/rsp/su.h | 2 +- Frameworks/lazyusf/lazyusf/rsp/vu/cf.h | 2 + Frameworks/lazyusf/lazyusf/rsp/vu/vand.h | 2 +- Frameworks/lazyusf/lazyusf/rsp/vu/vnand.h | 2 +- Frameworks/lazyusf/lazyusf/rsp/vu/vnor.h | 2 +- Frameworks/lazyusf/lazyusf/rsp/vu/vnxor.h | 2 +- Frameworks/lazyusf/lazyusf/rsp/vu/vor.h | 2 +- Frameworks/lazyusf/lazyusf/rsp/vu/vxor.h | 2 +- 11 files changed, 50 insertions(+), 26 deletions(-) diff --git a/Frameworks/lazyusf/lazyusf/interpreter_cpu.c b/Frameworks/lazyusf/lazyusf/interpreter_cpu.c index 4f2283fb4..0ec966d02 100644 --- a/Frameworks/lazyusf/lazyusf/interpreter_cpu.c +++ b/Frameworks/lazyusf/lazyusf/interpreter_cpu.c @@ -732,7 +732,7 @@ void StartInterpreterCPU (usf_state_t * state) { ExecuteInterpreterOpCode(state); if (!--safety_count) { if (last_sample_buffer_count == state->sample_buffer_count) { - DisplayError( state, "Emulator core is not generating any samples after 400 million instructions" ); + DisplayError( state, "Emulator core is not generating any samples after 20 million instructions" ); break; } else { safety_count = safety_count_max; diff --git a/Frameworks/lazyusf/lazyusf/memory.c b/Frameworks/lazyusf/lazyusf/memory.c index 6bb506975..861c8bd42 100644 --- a/Frameworks/lazyusf/lazyusf/memory.c +++ b/Frameworks/lazyusf/lazyusf/memory.c @@ -191,15 +191,19 @@ int32_t r4300i_LB_NonMemory ( usf_state_t * state, uint32_t PAddr, uint32_t * Va } uint32_t r4300i_LB_VAddr ( usf_state_t * state, uint32_t VAddr, uint8_t * Value ) { - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } - *Value = *(uint8_t *)(state->TLB_Map[VAddr >> 12] + (VAddr ^ 3)); + uintptr_t address; + address = state->TLB_Map[VAddr >> 12]; + if (address == 0) { return 0; } + *Value = *(uint8_t *)(address + (VAddr ^ 3)); return 1; } uint32_t r4300i_LD_VAddr ( usf_state_t * state, uint32_t VAddr, uint64_t * Value ) { - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } - *((uint32_t *)(Value) + 1) = *(uint32_t *)(state->TLB_Map[VAddr >> 12] + VAddr); - *((uint32_t *)(Value)) = *(uint32_t *)(state->TLB_Map[VAddr >> 12] + VAddr + 4); + uintptr_t address; + address = state->TLB_Map[VAddr >> 12]; + if (address == 0) { return 0; } + *((uint32_t *)(Value) + 1) = *(uint32_t *)(address + VAddr); + *((uint32_t *)(Value)) = *(uint32_t *)(address + VAddr + 4); return 1; } @@ -216,8 +220,11 @@ int32_t r4300i_LH_NonMemory ( usf_state_t * state, uint32_t PAddr, uint32_t * Va } uint32_t r4300i_LH_VAddr ( usf_state_t * state, uint32_t VAddr, uint16_t * Value ) { - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } - *Value = *(uint16_t *)(state->TLB_Map[VAddr >> 12] + (VAddr ^ 2)); + uintptr_t address; + address = state->TLB_Map[VAddr >> 12]; + if (address == 0) + return 0; + *Value = *(uint16_t *)(address + (VAddr ^ 2)); return 1; } @@ -383,9 +390,11 @@ void r4300i_LW_PAddr ( usf_state_t * state, uint32_t PAddr, uint32_t * Value ) { } uint32_t r4300i_LW_VAddr ( usf_state_t * state, uint32_t VAddr, uint32_t * Value ) { - uintptr_t address = (state->TLB_Map[VAddr >> 12] + VAddr); + uintptr_t address = state->TLB_Map[VAddr >> 12]; + if (address == 0) + return 0; - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } + address += VAddr; if((address - (uintptr_t)state->RDRAM) > state->RdramSize) { address = address - (uintptr_t)state->RDRAM; @@ -417,8 +426,11 @@ int32_t r4300i_SB_NonMemory ( usf_state_t * state, uint32_t PAddr, uint8_t Value } uint32_t r4300i_SB_VAddr ( usf_state_t * state, uint32_t VAddr, uint8_t Value ) { - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } - *(uint8_t *)(state->TLB_Map[VAddr >> 12] + (VAddr ^ 3)) = Value; + uintptr_t address; + address = state->TLB_Map[VAddr >> 12]; + + if (address == 0) { return 0; } + *(uint8_t *)(address + (VAddr ^ 3)) = Value; return 1; } @@ -445,15 +457,20 @@ int32_t r4300i_SH_NonMemory ( usf_state_t * state, uint32_t PAddr, uint16_t Valu } uint32_t r4300i_SD_VAddr ( usf_state_t * state, uint32_t VAddr, uint64_t Value ) { - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } - *(uint32_t *)(state->TLB_Map[VAddr >> 12] + VAddr) = *((uint32_t *)(&Value) + 1); - *(uint32_t *)(state->TLB_Map[VAddr >> 12] + VAddr + 4) = *((uint32_t *)(&Value)); + uintptr_t address; + address = state->TLB_Map[VAddr >> 12]; + if (address == 0) { return 0; } + *(uint32_t *)(address + VAddr) = *((uint32_t *)(&Value) + 1); + *(uint32_t *)(address + VAddr + 4) = *((uint32_t *)(&Value)); return 1; } uint32_t r4300i_SH_VAddr ( usf_state_t * state, uint32_t VAddr, uint16_t Value ) { - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } - *(uint16_t *)(state->TLB_Map[VAddr >> 12] + (VAddr ^ 2)) = Value; + uintptr_t address; + address = state->TLB_Map[VAddr >> 12]; + + if (address == 0) { return 0; } + *(uint16_t *)(address + (VAddr ^ 2)) = Value; return 1; } @@ -766,10 +783,13 @@ int32_t r4300i_SW_NonMemory ( usf_state_t * state, uint32_t PAddr, uint32_t Valu } uint32_t r4300i_SW_VAddr ( usf_state_t * state, uint32_t VAddr, uint32_t Value ) { - uintptr_t address = (state->TLB_Map[VAddr >> 12] + VAddr); - if (state->TLB_Map[VAddr >> 12] == 0) { return 0; } + uintptr_t address; + address = state->TLB_Map[VAddr >> 12]; + if (address == 0) { return 0; } + address = (address + VAddr); + if((address - (uintptr_t)state->RDRAM) > state->RdramSize) { address = address - (uintptr_t)state->RDRAM; return r4300i_SW_NonMemory(state, (uint32_t) address, Value); diff --git a/Frameworks/lazyusf/lazyusf/rsp/rsp.h b/Frameworks/lazyusf/lazyusf/rsp/rsp.h index 0b40ccc91..1ba9287af 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/rsp.h +++ b/Frameworks/lazyusf/lazyusf/rsp/rsp.h @@ -58,10 +58,12 @@ NOINLINE static void message(usf_state_t * state, const char* body, int priority */ #define CHARACTERS_PER_LINE (80) /* typical standard DOS text file limit per line */ +#if 0 NOINLINE static void update_conf(const char* source) { (void)source; } +#endif #ifdef SP_EXECUTE_LOG extern void step_SP_commands(usf_state_t * state, int PC, uint32_t inst); diff --git a/Frameworks/lazyusf/lazyusf/rsp/su.h b/Frameworks/lazyusf/lazyusf/rsp/su.h index 86ffb95fd..248422e1a 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/su.h +++ b/Frameworks/lazyusf/lazyusf/rsp/su.h @@ -53,7 +53,7 @@ static void set_PC(usf_state_t * state, int address) return; } -#if (0) +#if ANDROID #define MASK_SA(sa) (sa & 31) /* Force masking in software. */ #else diff --git a/Frameworks/lazyusf/lazyusf/rsp/vu/cf.h b/Frameworks/lazyusf/lazyusf/rsp/vu/cf.h index d4b31a910..9e080c2f0 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/vu/cf.h +++ b/Frameworks/lazyusf/lazyusf/rsp/vu/cf.h @@ -180,6 +180,7 @@ void set_VCC(usf_state_t * state, unsigned short VCC) state->clip[i] = (VCC >> (i + 0x8)) & 1; return; /* Little endian becomes big. */ } +#if 0 void set_VCE(usf_state_t * state, unsigned char VCE) { register int i; @@ -189,3 +190,4 @@ void set_VCE(usf_state_t * state, unsigned char VCE) return; /* Little endian becomes big. */ } #endif +#endif diff --git a/Frameworks/lazyusf/lazyusf/rsp/vu/vand.h b/Frameworks/lazyusf/lazyusf/rsp/vu/vand.h index 98c5d1139..ebe9434c7 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/vu/vand.h +++ b/Frameworks/lazyusf/lazyusf/rsp/vu/vand.h @@ -13,7 +13,7 @@ \******************************************************************************/ #include "vu.h" -INLINE void do_and(usf_state_t * state, short* VD, short* VS, short* VT) +static INLINE void do_and(usf_state_t * state, short* VD, short* VS, short* VT) { register int i; diff --git a/Frameworks/lazyusf/lazyusf/rsp/vu/vnand.h b/Frameworks/lazyusf/lazyusf/rsp/vu/vnand.h index 87daf31ef..b71edf891 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/vu/vnand.h +++ b/Frameworks/lazyusf/lazyusf/rsp/vu/vnand.h @@ -13,7 +13,7 @@ \******************************************************************************/ #include "vu.h" -INLINE void do_nand(usf_state_t * state, short* VD, short* VS, short* VT) +static INLINE void do_nand(usf_state_t * state, short* VD, short* VS, short* VT) { register int i; diff --git a/Frameworks/lazyusf/lazyusf/rsp/vu/vnor.h b/Frameworks/lazyusf/lazyusf/rsp/vu/vnor.h index a47f43ce0..de744b41b 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/vu/vnor.h +++ b/Frameworks/lazyusf/lazyusf/rsp/vu/vnor.h @@ -13,7 +13,7 @@ \******************************************************************************/ #include "vu.h" -INLINE void do_nor(usf_state_t * state, short* VD, short* VS, short* VT) +static INLINE void do_nor(usf_state_t * state, short* VD, short* VS, short* VT) { register int i; diff --git a/Frameworks/lazyusf/lazyusf/rsp/vu/vnxor.h b/Frameworks/lazyusf/lazyusf/rsp/vu/vnxor.h index 9f2176fec..ac0bdb7d6 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/vu/vnxor.h +++ b/Frameworks/lazyusf/lazyusf/rsp/vu/vnxor.h @@ -13,7 +13,7 @@ \******************************************************************************/ #include "vu.h" -INLINE void do_nxor(usf_state_t * state, short* VD, short* VS, short* VT) +static INLINE void do_nxor(usf_state_t * state, short* VD, short* VS, short* VT) { register int i; diff --git a/Frameworks/lazyusf/lazyusf/rsp/vu/vor.h b/Frameworks/lazyusf/lazyusf/rsp/vu/vor.h index e92246d68..ce588c422 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/vu/vor.h +++ b/Frameworks/lazyusf/lazyusf/rsp/vu/vor.h @@ -13,7 +13,7 @@ \******************************************************************************/ #include "vu.h" -INLINE void do_or(usf_state_t * state, short* VD, short* VS, short* VT) +static INLINE void do_or(usf_state_t * state, short* VD, short* VS, short* VT) { register int i; diff --git a/Frameworks/lazyusf/lazyusf/rsp/vu/vxor.h b/Frameworks/lazyusf/lazyusf/rsp/vu/vxor.h index 04454e688..364e0594d 100644 --- a/Frameworks/lazyusf/lazyusf/rsp/vu/vxor.h +++ b/Frameworks/lazyusf/lazyusf/rsp/vu/vxor.h @@ -13,7 +13,7 @@ \******************************************************************************/ #include "vu.h" -INLINE void do_xor(usf_state_t * state, short* VD, short* VS, short* VT) +static INLINE void do_xor(usf_state_t * state, short* VD, short* VS, short* VT) { register int i;