From 34e95ff1c2aee51d02f461cf44311680778552c0 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Tue, 18 Feb 2014 17:20:37 -0800 Subject: [PATCH] Updated LazyUSF and bumped its optimization settings --- .../lazyusf/lazyusf.xcodeproj/project.pbxproj | 38 +- Frameworks/lazyusf/lazyusf/cpu.c | 70 +-- Frameworks/lazyusf/lazyusf/dma.c | 3 + Frameworks/lazyusf/lazyusf/interpreter_cpu.c | 24 +- Frameworks/lazyusf/lazyusf/interpreter_ops.c | 526 +++++++++--------- Frameworks/lazyusf/lazyusf/opcode.h | 12 +- Frameworks/lazyusf/lazyusf/tlb.c | 30 +- Frameworks/lazyusf/lazyusf/tlb.h | 8 +- Frameworks/lazyusf/lazyusf/usf.c | 3 + Frameworks/lazyusf/lazyusf/usf.h | 9 +- Frameworks/lazyusf/lazyusf/usf_internal.h | 2 + 11 files changed, 366 insertions(+), 359 deletions(-) diff --git a/Frameworks/lazyusf/lazyusf.xcodeproj/project.pbxproj b/Frameworks/lazyusf/lazyusf.xcodeproj/project.pbxproj index 1a03570c3..a9ffea242 100644 --- a/Frameworks/lazyusf/lazyusf.xcodeproj/project.pbxproj +++ b/Frameworks/lazyusf/lazyusf.xcodeproj/project.pbxproj @@ -8,27 +8,27 @@ /* Begin PBXBuildFile section */ 83C8B6AB18AF58080071B040 /* audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B65918AF58080071B040 /* audio.c */; }; - 83C8B6AC18AF58080071B040 /* audio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65A18AF58080071B040 /* audio.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 83C8B6AD18AF58080071B040 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65B18AF58080071B040 /* config.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6AC18AF58080071B040 /* audio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65A18AF58080071B040 /* audio.h */; }; + 83C8B6AD18AF58080071B040 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65B18AF58080071B040 /* config.h */; }; 83C8B6AE18AF58080071B040 /* cpu.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B65C18AF58080071B040 /* cpu.c */; }; - 83C8B6AF18AF58080071B040 /* cpu.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65D18AF58080071B040 /* cpu.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6AF18AF58080071B040 /* cpu.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65D18AF58080071B040 /* cpu.h */; }; 83C8B6B018AF58080071B040 /* dma.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B65E18AF58080071B040 /* dma.c */; }; - 83C8B6B118AF58080071B040 /* dma.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65F18AF58080071B040 /* dma.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6B118AF58080071B040 /* dma.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65F18AF58080071B040 /* dma.h */; }; 83C8B6B218AF58080071B040 /* exception.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66018AF58080071B040 /* exception.c */; }; - 83C8B6B318AF58080071B040 /* exception.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66118AF58080071B040 /* exception.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6B318AF58080071B040 /* exception.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66118AF58080071B040 /* exception.h */; }; 83C8B6B418AF58080071B040 /* interpreter_cpu.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66218AF58080071B040 /* interpreter_cpu.c */; }; - 83C8B6B518AF58080071B040 /* interpreter_cpu.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66318AF58080071B040 /* interpreter_cpu.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6B518AF58080071B040 /* interpreter_cpu.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66318AF58080071B040 /* interpreter_cpu.h */; }; 83C8B6B618AF58080071B040 /* interpreter_ops.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66418AF58080071B040 /* interpreter_ops.c */; }; - 83C8B6B718AF58080071B040 /* interpreter_ops.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66518AF58080071B040 /* interpreter_ops.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6B718AF58080071B040 /* interpreter_ops.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66518AF58080071B040 /* interpreter_ops.h */; }; 83C8B6B818AF58080071B040 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66618AF58080071B040 /* main.c */; }; - 83C8B6B918AF58080071B040 /* main.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66718AF58080071B040 /* main.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6B918AF58080071B040 /* main.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66718AF58080071B040 /* main.h */; }; 83C8B6BA18AF58080071B040 /* memory.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66818AF58080071B040 /* memory.c */; }; - 83C8B6BB18AF58080071B040 /* memory.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66918AF58080071B040 /* memory.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 83C8B6BC18AF58080071B040 /* opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66A18AF58080071B040 /* opcode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6BB18AF58080071B040 /* memory.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66918AF58080071B040 /* memory.h */; }; + 83C8B6BC18AF58080071B040 /* opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66A18AF58080071B040 /* opcode.h */; }; 83C8B6BD18AF58080071B040 /* pif.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66B18AF58080071B040 /* pif.c */; }; - 83C8B6BE18AF58080071B040 /* pif.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66C18AF58080071B040 /* pif.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6BE18AF58080071B040 /* pif.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66C18AF58080071B040 /* pif.h */; }; 83C8B6BF18AF58080071B040 /* registers.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66D18AF58080071B040 /* registers.c */; }; - 83C8B6C018AF58080071B040 /* registers.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66E18AF58080071B040 /* registers.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6C018AF58080071B040 /* registers.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66E18AF58080071B040 /* registers.h */; }; 83C8B6C118AF58080071B040 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B67018AF58080071B040 /* config.h */; }; 83C8B6C218AF58080071B040 /* execute.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B67118AF58080071B040 /* execute.h */; }; 83C8B6C318AF58080071B040 /* rsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B67218AF58080071B040 /* rsp.c */; }; @@ -80,14 +80,13 @@ 83C8B6F118AF58090071B040 /* vsubc.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A118AF58080071B040 /* vsubc.h */; }; 83C8B6F218AF58090071B040 /* vu.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A218AF58080071B040 /* vu.h */; }; 83C8B6F318AF58090071B040 /* vxor.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A318AF58080071B040 /* vxor.h */; }; - 83C8B6F418AF58090071B040 /* rsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A418AF58080071B040 /* rsp.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6F418AF58090071B040 /* rsp.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A418AF58080071B040 /* rsp.h */; }; 83C8B6F518AF58090071B040 /* tlb.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B6A518AF58080071B040 /* tlb.c */; }; - 83C8B6F618AF58090071B040 /* tlb.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A618AF58080071B040 /* tlb.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 83C8B6F718AF58090071B040 /* types.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A718AF58080071B040 /* types.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C8B6F618AF58090071B040 /* tlb.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A618AF58080071B040 /* tlb.h */; }; + 83C8B6F718AF58090071B040 /* types.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A718AF58080071B040 /* types.h */; }; 83C8B6F818AF58090071B040 /* usf_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A818AF58080071B040 /* usf_internal.h */; }; 83C8B6F918AF58090071B040 /* usf.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B6A918AF58080071B040 /* usf.c */; }; 83C8B6FA18AF58090071B040 /* usf.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6AA18AF58080071B040 /* usf.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 83C8B6FE18AF59E70071B040 /* lazyusf-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 83C8B6FD18AF59E70071B040 /* lazyusf-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -337,6 +336,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 83C8B6FA18AF58090071B040 /* usf.h in Headers */, 83C8B6AC18AF58080071B040 /* audio.h in Headers */, 83C8B6B118AF58080071B040 /* dma.h in Headers */, 83C8B6AD18AF58080071B040 /* config.h in Headers */, @@ -352,7 +352,6 @@ 83C8B6B718AF58080071B040 /* interpreter_ops.h in Headers */, 83C8B6B318AF58080071B040 /* exception.h in Headers */, 83C8B6AF18AF58080071B040 /* cpu.h in Headers */, - 83C8B6FA18AF58090071B040 /* usf.h in Headers */, 83C8B6F118AF58090071B040 /* vsubc.h in Headers */, 83C8B6F018AF58090071B040 /* vsub.h in Headers */, 83C8B6E018AF58080071B040 /* vmudn.h in Headers */, @@ -459,7 +458,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 83C8B6FE18AF59E70071B040 /* lazyusf-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -568,6 +566,7 @@ "DEBUG=1", ARCH_MIN_SSE2, ); + GCC_WARN_PEDANTIC = YES; INFOPLIST_FILE = "lazyusf/lazyusf-Info.plist"; INSTALL_PATH = "@loader_path/../Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -583,10 +582,12 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_VERSION = A; + GCC_OPTIMIZATION_LEVEL = fast; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherit)", ARCH_MIN_SSE2, ); + GCC_WARN_PEDANTIC = YES; INFOPLIST_FILE = "lazyusf/lazyusf-Info.plist"; INSTALL_PATH = "@loader_path/../Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -614,6 +615,7 @@ 83C8B64C18AF57770071B040 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Frameworks/lazyusf/lazyusf/cpu.c b/Frameworks/lazyusf/lazyusf/cpu.c index 1d7ee9345..6596e8a47 100644 --- a/Frameworks/lazyusf/lazyusf/cpu.c +++ b/Frameworks/lazyusf/lazyusf/cpu.c @@ -25,6 +25,8 @@ */ #include +#include + #include "main.h" #include "cpu.h" #include "usf.h" @@ -111,13 +113,13 @@ void CloseCpu (usf_state_t * state) { int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1, uint32_t Reg2) { OPCODE Command; - if (!r4300i_LW_VAddr(state, PC + 4, (uint32_t*)&Command.Hex)) { + if (!r4300i_LW_VAddr(state, PC + 4, (uint32_t*)&Command.u.Hex)) { return 1; } - switch (Command.op) { + switch (Command.u.b.op) { case R4300i_SPECIAL: - switch (Command.funct) { + switch (Command.u.e.funct) { case R4300i_SPECIAL_SLL: case R4300i_SPECIAL_SRL: case R4300i_SPECIAL_SRA: @@ -151,9 +153,9 @@ int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1 case R4300i_SPECIAL_DSLL32: case R4300i_SPECIAL_DSRL32: case R4300i_SPECIAL_DSRA32: - if (Command.rd == 0) { return 0; } - if (Command.rd == Reg1) { return 1; } - if (Command.rd == Reg2) { return 1; } + if (Command.u.e.rd == 0) { return 0; } + if (Command.u.e.rd == Reg1) { return 1; } + if (Command.u.e.rd == Reg2) { return 1; } break; case R4300i_SPECIAL_MULT: case R4300i_SPECIAL_MULTU: @@ -169,16 +171,16 @@ int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1 } break; case R4300i_CP0: - switch (Command.rs) { + switch (Command.u.b.rs) { case R4300i_COP0_MT: break; case R4300i_COP0_MF: - if (Command.rt == 0) { return 0; } - if (Command.rt == Reg1) { return 1; } - if (Command.rt == Reg2) { return 1; } + if (Command.u.b.rt == 0) { return 0; } + if (Command.u.b.rt == Reg1) { return 1; } + if (Command.u.b.rt == Reg2) { return 1; } break; default: - if ( (Command.rs & 0x10 ) != 0 ) { - switch( state->Opcode.funct ) { + if ( (Command.u.b.rs & 0x10 ) != 0 ) { + switch( state->Opcode.u.e.funct ) { case R4300i_COP0_CO_TLBR: break; case R4300i_COP0_CO_TLBWI: break; case R4300i_COP0_CO_TLBWR: break; @@ -191,11 +193,11 @@ int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1 } break; case R4300i_CP1: - switch (Command.fmt) { + switch (Command.u.f.fmt) { case R4300i_COP1_MF: - if (Command.rt == 0) { return 0; } - if (Command.rt == Reg1) { return 1; } - if (Command.rt == Reg2) { return 1; } + if (Command.u.b.rt == 0) { return 0; } + if (Command.u.b.rt == Reg1) { return 1; } + if (Command.u.b.rt == Reg2) { return 1; } break; case R4300i_COP1_CF: break; case R4300i_COP1_MT: break; @@ -229,9 +231,9 @@ int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1 case R4300i_LD: case R4300i_LWC1: case R4300i_LDC1: - if (Command.rt == 0) { return 0; } - if (Command.rt == Reg1) { return 1; } - if (Command.rt == Reg2) { return 1; } + if (Command.u.b.rt == 0) { return 0; } + if (Command.u.b.rt == Reg1) { return 1; } + if (Command.u.b.rt == Reg2) { return 1; } break; case R4300i_CACHE: break; case R4300i_SB: break; @@ -252,24 +254,24 @@ int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1 int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) { OPCODE Command; - if (!r4300i_LW_VAddr(state, JumpPC, &Command.Hex)) { return 1; } + if (!r4300i_LW_VAddr(state, JumpPC, &Command.u.Hex)) { return 1; } - switch (Command.op) { + switch (Command.u.b.op) { case R4300i_SPECIAL: - switch (Command.funct) { - case R4300i_SPECIAL_JR: return DelaySlotEffectsCompare(state,JumpPC,Command.rs,0); - case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(state,JumpPC,Command.rs,31); + switch (Command.u.e.funct) { + case R4300i_SPECIAL_JR: return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,0); + case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,31); } break; case R4300i_REGIMM: - switch (Command.rt) { + switch (Command.u.b.rt) { case R4300i_REGIMM_BLTZ: case R4300i_REGIMM_BGEZ: case R4300i_REGIMM_BLTZL: case R4300i_REGIMM_BGEZL: case R4300i_REGIMM_BLTZAL: case R4300i_REGIMM_BGEZAL: - return DelaySlotEffectsCompare(state,JumpPC,Command.rs,0); + return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,0); } break; case R4300i_JAL: @@ -279,11 +281,11 @@ int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) { case R4300i_BNE: case R4300i_BLEZ: case R4300i_BGTZ: - return DelaySlotEffectsCompare(state,JumpPC,Command.rs,Command.rt); + return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,Command.u.b.rt); case R4300i_CP1: - switch (Command.fmt) { + switch (Command.u.f.fmt) { case R4300i_COP1_BC: - switch (Command.ft) { + switch (Command.u.f.ft) { case R4300i_COP1_BC_BCF: case R4300i_COP1_BC_BCT: case R4300i_COP1_BC_BCFL: @@ -292,14 +294,14 @@ int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) { int32_t EffectDelaySlot; OPCODE NewCommand; - if (!r4300i_LW_VAddr(state, JumpPC + 4, &NewCommand.Hex)) { return 1; } + if (!r4300i_LW_VAddr(state, JumpPC + 4, &NewCommand.u.Hex)) { return 1; } EffectDelaySlot = 0; - if (NewCommand.op == R4300i_CP1) { - if (NewCommand.fmt == R4300i_COP1_S && (NewCommand.funct & 0x30) == 0x30 ) { + if (NewCommand.u.b.op == R4300i_CP1) { + if (NewCommand.u.f.fmt == R4300i_COP1_S && (NewCommand.u.e.funct & 0x30) == 0x30 ) { EffectDelaySlot = 1; } - if (NewCommand.fmt == R4300i_COP1_D && (NewCommand.funct & 0x30) == 0x30 ) { + if (NewCommand.u.f.fmt == R4300i_COP1_D && (NewCommand.u.e.funct & 0x30) == 0x30 ) { EffectDelaySlot = 1; } } @@ -314,7 +316,7 @@ int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) { case R4300i_BNEL: case R4300i_BLEZL: case R4300i_BGTZL: - return DelaySlotEffectsCompare(state,JumpPC,Command.rs,Command.rt); + return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,Command.u.b.rt); } return 1; } diff --git a/Frameworks/lazyusf/lazyusf/dma.c b/Frameworks/lazyusf/lazyusf/dma.c index 2c279069c..f5849625e 100644 --- a/Frameworks/lazyusf/lazyusf/dma.c +++ b/Frameworks/lazyusf/lazyusf/dma.c @@ -23,6 +23,9 @@ * should be forwarded to them so if they want them. * */ + +#include + #include "main.h" #include "cpu.h" diff --git a/Frameworks/lazyusf/lazyusf/interpreter_cpu.c b/Frameworks/lazyusf/lazyusf/interpreter_cpu.c index 4e103b56d..f0f3f9c4d 100644 --- a/Frameworks/lazyusf/lazyusf/interpreter_cpu.c +++ b/Frameworks/lazyusf/lazyusf/interpreter_cpu.c @@ -46,45 +46,45 @@ void (* R4300i_CoP1_W[64])(usf_state_t *); void (* R4300i_CoP1_L[64])(usf_state_t *); void R4300i_opcode_SPECIAL (usf_state_t * state) { - ((void (*)()) R4300i_Special[ state->Opcode.funct ])(state); + ((void (*)()) R4300i_Special[ state->Opcode.u.e.funct ])(state); } void R4300i_opcode_REGIMM (usf_state_t * state) { - ((void (*)()) R4300i_Regimm[ state->Opcode.rt ])(state); + ((void (*)()) R4300i_Regimm[ state->Opcode.u.b.rt ])(state); } void R4300i_opcode_COP0 (usf_state_t * state) { - ((void (*)()) R4300i_CoP0[ state->Opcode.rs ])(state); + ((void (*)()) R4300i_CoP0[ state->Opcode.u.b.rs ])(state); } void R4300i_opcode_COP0_CO (usf_state_t * state) { - ((void (*)()) R4300i_CoP0_Function[ state->Opcode.funct ])(state); + ((void (*)()) R4300i_CoP0_Function[ state->Opcode.u.e.funct ])(state); } void R4300i_opcode_COP1 (usf_state_t * state) { - ((void (*)()) R4300i_CoP1[ state->Opcode.fmt ])(state); + ((void (*)()) R4300i_CoP1[ state->Opcode.u.f.fmt ])(state); } void R4300i_opcode_COP1_BC (usf_state_t * state) { - ((void (*)()) R4300i_CoP1_BC[ state->Opcode.ft ])(state); + ((void (*)()) R4300i_CoP1_BC[ state->Opcode.u.f.ft ])(state); } void R4300i_opcode_COP1_S (usf_state_t * state) { // controlfp(RoundingModel); - ((void (*)()) R4300i_CoP1_S[ state->Opcode.funct ])(state); + ((void (*)()) R4300i_CoP1_S[ state->Opcode.u.e.funct ])(state); } void R4300i_opcode_COP1_D (usf_state_t * state) { // controlfp(RoundingModel); - ((void (*)()) R4300i_CoP1_D[ state->Opcode.funct ])(state); + ((void (*)()) R4300i_CoP1_D[ state->Opcode.u.e.funct ])(state); } void R4300i_opcode_COP1_W (usf_state_t * state) { - ((void (*)()) R4300i_CoP1_W[ state->Opcode.funct ])(state); + ((void (*)()) R4300i_CoP1_W[ state->Opcode.u.e.funct ])(state); } void R4300i_opcode_COP1_L (usf_state_t * state) { - ((void (*)()) R4300i_CoP1_L[ state->Opcode.funct ])(state); + ((void (*)()) R4300i_CoP1_L[ state->Opcode.u.e.funct ])(state); } @@ -684,7 +684,7 @@ void ExecuteInterpreterOpCode (usf_state_t * state) { if (*state->WaitMode) state->Timers->Timer = -1; - if (!r4300i_LW_VAddr(state, state->PROGRAM_COUNTER, &state->Opcode.Hex)) { + if (!r4300i_LW_VAddr(state, state->PROGRAM_COUNTER, &state->Opcode.u.Hex)) { DoTLBMiss(state, state->NextInstruction == JUMP,state->PROGRAM_COUNTER); state->NextInstruction = NORMAL; return; @@ -698,7 +698,7 @@ void ExecuteInterpreterOpCode (usf_state_t * state) { RANDOM_REGISTER = 31; } - R4300i_Opcode[ state->Opcode.op ](state); + R4300i_Opcode[ state->Opcode.u.b.op ](state); if (state->GPR[0].DW != 0) { state->GPR[0].DW = 0; diff --git a/Frameworks/lazyusf/lazyusf/interpreter_ops.c b/Frameworks/lazyusf/lazyusf/interpreter_ops.c index 452645a82..0859b6319 100644 --- a/Frameworks/lazyusf/lazyusf/interpreter_ops.c +++ b/Frameworks/lazyusf/lazyusf/interpreter_ops.c @@ -63,22 +63,22 @@ /************************* OpCode functions *************************/ void r4300i_J (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = (state->PROGRAM_COUNTER & 0xF0000000) + (state->Opcode.target << 2); + state->JumpToLocation = (state->PROGRAM_COUNTER & 0xF0000000) + (state->Opcode.u.d.target << 2); TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,0,0); } void r4300i_JAL (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = (state->PROGRAM_COUNTER & 0xF0000000) + (state->Opcode.target << 2); + state->JumpToLocation = (state->PROGRAM_COUNTER & 0xF0000000) + (state->Opcode.u.d.target << 2); TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,0,0); state->GPR[31].DW= (int32_t)(state->PROGRAM_COUNTER + 8); } void r4300i_BEQ (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW == state->GPR[state->Opcode.rt].DW) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,state->Opcode.rt); + if (state->GPR[state->Opcode.u.b.rs].DW == state->GPR[state->Opcode.u.b.rt].DW) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,state->Opcode.u.b.rt); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -86,9 +86,9 @@ void r4300i_BEQ (usf_state_t * state) { void r4300i_BNE (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW != state->GPR[state->Opcode.rt].DW) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,state->Opcode.rt); + if (state->GPR[state->Opcode.u.b.rs].DW != state->GPR[state->Opcode.u.b.rt].DW) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,state->Opcode.u.b.rt); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -96,9 +96,9 @@ void r4300i_BNE (usf_state_t * state) { void r4300i_BLEZ (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW <= 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + if (state->GPR[state->Opcode.u.b.rs].DW <= 0) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -106,61 +106,61 @@ void r4300i_BLEZ (usf_state_t * state) { void r4300i_BGTZ (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW > 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + if (state->GPR[state->Opcode.u.b.rs].DW > 0) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } } void r4300i_ADDI (usf_state_t * state) { - if (state->Opcode.rt == 0) { return; } - state->GPR[state->Opcode.rt].DW = (state->GPR[state->Opcode.rs].W[0] + ((int16_t)state->Opcode.immediate)); + if (state->Opcode.u.b.rt == 0) { return; } + state->GPR[state->Opcode.u.b.rt].DW = (state->GPR[state->Opcode.u.b.rs].W[0] + ((int16_t)state->Opcode.u.c.immediate)); } void r4300i_ADDIU (usf_state_t * state) { - state->GPR[state->Opcode.rt].DW = (state->GPR[state->Opcode.rs].W[0] + ((int16_t)state->Opcode.immediate)); + state->GPR[state->Opcode.u.b.rt].DW = (state->GPR[state->Opcode.u.b.rs].W[0] + ((int16_t)state->Opcode.u.c.immediate)); } void r4300i_SLTI (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW < (int64_t)((int16_t)state->Opcode.immediate)) { - state->GPR[state->Opcode.rt].DW = 1; + if (state->GPR[state->Opcode.u.b.rs].DW < (int64_t)((int16_t)state->Opcode.u.c.immediate)) { + state->GPR[state->Opcode.u.b.rt].DW = 1; } else { - state->GPR[state->Opcode.rt].DW = 0; + state->GPR[state->Opcode.u.b.rt].DW = 0; } } void r4300i_SLTIU (usf_state_t * state) { - int32_t imm32 = (int16_t)state->Opcode.immediate; + int32_t imm32 = (int16_t)state->Opcode.u.c.immediate; int64_t imm64; imm64 = imm32; - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rs].UDW < (uint64_t)imm64?1:0; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rs].UDW < (uint64_t)imm64?1:0; } void r4300i_ANDI (usf_state_t * state) { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rs].DW & state->Opcode.immediate; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rs].DW & state->Opcode.u.c.immediate; } void r4300i_ORI (usf_state_t * state) { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rs].DW | state->Opcode.immediate; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rs].DW | state->Opcode.u.c.immediate; } void r4300i_XORI (usf_state_t * state) { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rs].DW ^ state->Opcode.immediate; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rs].DW ^ state->Opcode.u.c.immediate; } void r4300i_LUI (usf_state_t * state) { - if (state->Opcode.rt == 0) { return; } - state->GPR[state->Opcode.rt].DW = (int32_t)((int16_t)state->Opcode.offset << 16); + if (state->Opcode.u.b.rt == 0) { return; } + state->GPR[state->Opcode.u.b.rt].DW = (int32_t)((int16_t)state->Opcode.u.b.offset << 16); } void r4300i_BEQL (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW == state->GPR[state->Opcode.rt].DW) { + if (state->GPR[state->Opcode.u.b.rs].DW == state->GPR[state->Opcode.u.b.rt].DW) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,state->Opcode.rt); + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,state->Opcode.u.b.rt); } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -168,10 +168,10 @@ void r4300i_BEQL (usf_state_t * state) { } void r4300i_BNEL (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW != state->GPR[state->Opcode.rt].DW) { + if (state->GPR[state->Opcode.u.b.rs].DW != state->GPR[state->Opcode.u.b.rt].DW) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,state->Opcode.rt); + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,state->Opcode.u.b.rt); } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -179,10 +179,10 @@ void r4300i_BNEL (usf_state_t * state) { } void r4300i_BLEZL (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW <= 0) { + if (state->GPR[state->Opcode.u.b.rs].DW <= 0) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -190,10 +190,10 @@ void r4300i_BLEZL (usf_state_t * state) { } void r4300i_BGTZL (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW > 0) { + if (state->GPR[state->Opcode.u.b.rs].DW > 0) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -201,7 +201,7 @@ void r4300i_BGTZL (usf_state_t * state) { } void r4300i_DADDIU (usf_state_t * state) { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rs].DW + (int64_t)((int16_t)state->Opcode.immediate); + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rs].DW + (int64_t)((int16_t)state->Opcode.u.c.immediate); } uint64_t LDL_MASK[8] = { 0ULL,0xFFULL,0xFFFFULL,0xFFFFFFULL,0xFFFFFFFFULL,0xFFFFFFFFFFULL, 0xFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFULL }; @@ -211,14 +211,14 @@ void r4300i_LDL (usf_state_t * state) { uint32_t Offset, Address; uint64_t Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 7; if (!r4300i_LD_VAddr(state,(Address & ~7),&Value)) { return; } - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rt].DW & LDL_MASK[Offset]; - state->GPR[state->Opcode.rt].DW += Value << LDL_SHIFT[Offset]; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rt].DW & LDL_MASK[Offset]; + state->GPR[state->Opcode.u.b.rt].DW += Value << LDL_SHIFT[Offset]; } uint64_t LDR_MASK[8] = { 0xFFFFFFFFFFFFFF00ULL, 0xFFFFFFFFFFFF0000ULL, @@ -231,38 +231,38 @@ void r4300i_LDR (usf_state_t * state) { uint32_t Offset, Address; uint64_t Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 7; if (!r4300i_LD_VAddr(state,(Address & ~7),&Value)) { return; } - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rt].DW & LDR_MASK[Offset]; - state->GPR[state->Opcode.rt].DW += Value >> LDR_SHIFT[Offset]; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rt].DW & LDR_MASK[Offset]; + state->GPR[state->Opcode.u.b.rt].DW += Value >> LDR_SHIFT[Offset]; } void r4300i_LB (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; - if (state->Opcode.rt == 0) { return; } - if (!r4300i_LB_VAddr(state,Address,&state->GPR[state->Opcode.rt].UB[0])) { + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; + if (state->Opcode.u.b.rt == 0) { return; } + if (!r4300i_LB_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UB[0])) { TLB_READ_EXCEPTION(Address); } else { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rt].B[0]; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rt].B[0]; } } void r4300i_LH (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (!r4300i_LH_VAddr(state,Address,&state->GPR[state->Opcode.rt].UHW[0])) { + if (!r4300i_LH_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UHW[0])) { //if (ShowTLBMisses) { DisplayError("LH TLB: %X",Address); //} TLB_READ_EXCEPTION(Address); } else { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rt].HW[0]; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rt].HW[0]; } } @@ -272,58 +272,58 @@ int32_t LWL_SHIFT[4] = { 0, 8, 16, 24}; void r4300i_LWL (usf_state_t * state) { uint32_t Offset, Address, Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 3; if (!r4300i_LW_VAddr(state,(Address & ~3),&Value)) { return; } - state->GPR[state->Opcode.rt].DW = (int32_t)(state->GPR[state->Opcode.rt].W[0] & LWL_MASK[Offset]); - state->GPR[state->Opcode.rt].DW += (int32_t)(Value << LWL_SHIFT[Offset]); + state->GPR[state->Opcode.u.b.rt].DW = (int32_t)(state->GPR[state->Opcode.u.b.rt].W[0] & LWL_MASK[Offset]); + state->GPR[state->Opcode.u.b.rt].DW += (int32_t)(Value << LWL_SHIFT[Offset]); } void r4300i_LW (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; // if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (state->Opcode.rt == 0) { return; } + if (state->Opcode.u.b.rt == 0) { return; } - if (!r4300i_LW_VAddr(state,Address,&state->GPR[state->Opcode.rt].UW[0])) { + if (!r4300i_LW_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UW[0])) { //if (ShowTLBMisses) { //printf("LW TLB: %X",Address); //} TLB_READ_EXCEPTION(Address); } else { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rt].W[0]; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rt].W[0]; } } void r4300i_LBU (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; - if (!r4300i_LB_VAddr(state,Address,&state->GPR[state->Opcode.rt].UB[0])) { + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; + if (!r4300i_LB_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UB[0])) { //if (ShowTLBMisses) { DisplayError("LBU TLB: %X",Address); //} TLB_READ_EXCEPTION(Address); } else { - state->GPR[state->Opcode.rt].UDW = state->GPR[state->Opcode.rt].UB[0]; + state->GPR[state->Opcode.u.b.rt].UDW = state->GPR[state->Opcode.u.b.rt].UB[0]; } } void r4300i_LHU (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (!r4300i_LH_VAddr(state,Address,&state->GPR[state->Opcode.rt].UHW[0])) { + if (!r4300i_LH_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UHW[0])) { //if (ShowTLBMisses) { DisplayError("LHU TLB: %X",Address); //} TLB_READ_EXCEPTION(Address); } else { - state->GPR[state->Opcode.rt].UDW = state->GPR[state->Opcode.rt].UHW[0]; + state->GPR[state->Opcode.u.b.rt].UDW = state->GPR[state->Opcode.u.b.rt].UHW[0]; } } @@ -333,42 +333,42 @@ int32_t LWR_SHIFT[4] = { 24, 16 ,8, 0 }; void r4300i_LWR (usf_state_t * state) { uint32_t Offset, Address, Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 3; if (!r4300i_LW_VAddr(state,(Address & ~3),&Value)) { return; } - state->GPR[state->Opcode.rt].DW = (int32_t)(state->GPR[state->Opcode.rt].W[0] & LWR_MASK[Offset]); - state->GPR[state->Opcode.rt].DW += (int32_t)(Value >> LWR_SHIFT[Offset]); + state->GPR[state->Opcode.u.b.rt].DW = (int32_t)(state->GPR[state->Opcode.u.b.rt].W[0] & LWR_MASK[Offset]); + state->GPR[state->Opcode.u.b.rt].DW += (int32_t)(Value >> LWR_SHIFT[Offset]); } void r4300i_LWU (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (state->Opcode.rt == 0) { return; } + if (state->Opcode.u.b.rt == 0) { return; } - if (!r4300i_LW_VAddr(state,Address,&state->GPR[state->Opcode.rt].UW[0])) { + if (!r4300i_LW_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UW[0])) { //if (ShowTLBMisses) { DisplayError("LWU TLB: %X",Address); //} TLB_READ_EXCEPTION(Address); } else { - state->GPR[state->Opcode.rt].UDW = state->GPR[state->Opcode.rt].UW[0]; + state->GPR[state->Opcode.u.b.rt].UDW = state->GPR[state->Opcode.u.b.rt].UW[0]; } } void r4300i_SB (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; - if (!r4300i_SB_VAddr(state,Address,state->GPR[state->Opcode.rt].UB[0])) { + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; + if (!r4300i_SB_VAddr(state,Address,state->GPR[state->Opcode.u.b.rt].UB[0])) { } } void r4300i_SH (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address,0); } - if (!r4300i_SH_VAddr(state,Address,state->GPR[state->Opcode.rt].UHW[0])) { + if (!r4300i_SH_VAddr(state,Address,state->GPR[state->Opcode.u.b.rt].UHW[0])) { } } @@ -378,7 +378,7 @@ int32_t SWL_SHIFT[4] = { 0, 8, 16, 24 }; void r4300i_SWL (usf_state_t * state) { uint32_t Offset, Address, Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 3; if (!r4300i_LW_VAddr(state,(Address & ~3),&Value)) { @@ -386,7 +386,7 @@ void r4300i_SWL (usf_state_t * state) { } Value &= SWL_MASK[Offset]; - Value += state->GPR[state->Opcode.rt].UW[0] >> SWL_SHIFT[Offset]; + Value += state->GPR[state->Opcode.u.b.rt].UW[0] >> SWL_SHIFT[Offset]; if (!r4300i_SW_VAddr(state,(Address & ~0x03),Value)) { } @@ -394,13 +394,13 @@ void r4300i_SWL (usf_state_t * state) { void r4300i_SW (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,0); } - if (!r4300i_SW_VAddr(state,Address,state->GPR[state->Opcode.rt].UW[0])) { + if (!r4300i_SW_VAddr(state,Address,state->GPR[state->Opcode.u.b.rt].UW[0])) { } //TranslateVaddr(&Address); //if (Address == 0x00090AA0) { - // LogMessage("%X: Write %X to %X",state->PROGRAM_COUNTER,state->GPR[state->Opcode.rt].UW[0],state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset); + // LogMessage("%X: Write %X to %X",state->PROGRAM_COUNTER,state->GPR[state->Opcode.u.b.rt].UW[0],state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset); //} } @@ -418,7 +418,7 @@ void r4300i_SDL (usf_state_t * state) { uint32_t Offset, Address; uint64_t Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 7; if (!r4300i_LD_VAddr(state,(Address & ~7),&Value)) { @@ -426,7 +426,7 @@ void r4300i_SDL (usf_state_t * state) { } Value &= SDL_MASK[Offset]; - Value += state->GPR[state->Opcode.rt].UDW >> SDL_SHIFT[Offset]; + Value += state->GPR[state->Opcode.u.b.rt].UDW >> SDL_SHIFT[Offset]; if (!r4300i_SD_VAddr(state,(Address & ~7),Value)) { } @@ -447,7 +447,7 @@ void r4300i_SDR (usf_state_t * state) { uint32_t Offset, Address; uint64_t Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 7; if (!r4300i_LD_VAddr(state,(Address & ~7),&Value)) { @@ -455,7 +455,7 @@ void r4300i_SDR (usf_state_t * state) { } Value &= SDR_MASK[Offset]; - Value += state->GPR[state->Opcode.rt].UDW << SDR_SHIFT[Offset]; + Value += state->GPR[state->Opcode.u.b.rt].UDW << SDR_SHIFT[Offset]; if (!r4300i_SD_VAddr(state,(Address & ~7),Value)) { } @@ -467,7 +467,7 @@ int32_t SWR_SHIFT[4] = { 24, 16 , 8, 0 }; void r4300i_SWR (usf_state_t * state) { uint32_t Offset, Address, Value; - Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; Offset = Address & 3; if (!r4300i_LW_VAddr(state,(Address & ~3),&Value)) { @@ -475,7 +475,7 @@ void r4300i_SWR (usf_state_t * state) { } Value &= SWR_MASK[Offset]; - Value += state->GPR[state->Opcode.rt].UW[0] << SWR_SHIFT[Offset]; + Value += state->GPR[state->Opcode.u.b.rt].UW[0] << SWR_SHIFT[Offset]; if (!r4300i_SW_VAddr(state,(Address & ~0x03),Value)) { } @@ -486,19 +486,19 @@ void r4300i_CACHE (usf_state_t * state) { } void r4300i_LL (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; uintptr_t ll = 0; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (state->Opcode.rt == 0) { return; } + if (state->Opcode.u.b.rt == 0) { return; } - if (!r4300i_LW_VAddr(state,Address,&state->GPR[state->Opcode.rt].UW[0])) { + if (!r4300i_LW_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UW[0])) { //if (ShowTLBMisses) { DisplayError("LW TLB: %X",Address); //} TLB_READ_EXCEPTION(Address); } else { - state->GPR[state->Opcode.rt].DW = state->GPR[state->Opcode.rt].W[0]; + state->GPR[state->Opcode.u.b.rt].DW = state->GPR[state->Opcode.u.b.rt].W[0]; } state->LLBit = 1; state->LLAddr = Address; @@ -508,10 +508,10 @@ void r4300i_LL (usf_state_t * state) { } void r4300i_LWC1 (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (uint32_t)((int16_t)state->Opcode.offset); + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (uint32_t)((int16_t)state->Opcode.u.b.offset); TEST_COP1_USABLE_EXCEPTION if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (!r4300i_LW_VAddr(state,Address,&*(uint32_t *)state->FPRFloatLocation[state->Opcode.ft])) { + if (!r4300i_LW_VAddr(state,Address,&*(uint32_t *)state->FPRFloatLocation[state->Opcode.u.f.ft])) { //if (ShowTLBMisses) { DisplayError("LWC1 TLB: %X",Address); //} @@ -520,92 +520,92 @@ void r4300i_LWC1 (usf_state_t * state) { } void r4300i_SC (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,0); } if (state->LLBit == 1) { - if (!r4300i_SW_VAddr(state,Address,state->GPR[state->Opcode.rt].UW[0])) { + if (!r4300i_SW_VAddr(state,Address,state->GPR[state->Opcode.u.b.rt].UW[0])) { DisplayError("SW TLB: %X",Address); } } - state->GPR[state->Opcode.rt].UW[0] = state->LLBit; + state->GPR[state->Opcode.u.b.rt].UW[0] = state->LLBit; } void r4300i_LD (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (!r4300i_LD_VAddr(state,Address,&state->GPR[state->Opcode.rt].UDW)) { + if (!r4300i_LD_VAddr(state,Address,&state->GPR[state->Opcode.u.b.rt].UDW)) { } } void r4300i_LDC1 (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; TEST_COP1_USABLE_EXCEPTION if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address,1); } - if (!r4300i_LD_VAddr(state,Address,&*(uint64_t *)state->FPRDoubleLocation[state->Opcode.ft])) { + if (!r4300i_LD_VAddr(state,Address,&*(uint64_t *)state->FPRDoubleLocation[state->Opcode.u.f.ft])) { } } void r4300i_SWC1 (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; TEST_COP1_USABLE_EXCEPTION if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,0); } - if (!r4300i_SW_VAddr(state,Address,*(uint32_t *)state->FPRFloatLocation[state->Opcode.ft])) { + if (!r4300i_SW_VAddr(state,Address,*(uint32_t *)state->FPRFloatLocation[state->Opcode.u.f.ft])) { } } void r4300i_SDC1 (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; TEST_COP1_USABLE_EXCEPTION if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address,0); } - if (!r4300i_SD_VAddr(state,Address,*(int64_t *)state->FPRDoubleLocation[state->Opcode.ft])) { + if (!r4300i_SD_VAddr(state,Address,*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.ft])) { } } void r4300i_SD (usf_state_t * state) { - uint32_t Address = state->GPR[state->Opcode.base].UW[0] + (int16_t)state->Opcode.offset; + uint32_t Address = state->GPR[state->Opcode.u.c.base].UW[0] + (int16_t)state->Opcode.u.b.offset; if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address,0); } - if (!r4300i_SD_VAddr(state,Address,state->GPR[state->Opcode.rt].UDW)) { + if (!r4300i_SD_VAddr(state,Address,state->GPR[state->Opcode.u.b.rt].UDW)) { } } /********************** R4300i state->Opcodes: Special **********************/ void r4300i_SPECIAL_SLL (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].W[0] << state->Opcode.sa); + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].W[0] << state->Opcode.u.e.sa); } void r4300i_SPECIAL_SRL (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (int32_t)(state->GPR[state->Opcode.rt].UW[0] >> state->Opcode.sa); + state->GPR[state->Opcode.u.e.rd].DW = (int32_t)(state->GPR[state->Opcode.u.b.rt].UW[0] >> state->Opcode.u.e.sa); } void r4300i_SPECIAL_SRA (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].W[0] >> state->Opcode.sa); + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].W[0] >> state->Opcode.u.e.sa); } void r4300i_SPECIAL_SLLV (usf_state_t * state) { - if (state->Opcode.rd == 0) { return; } - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].W[0] << (state->GPR[state->Opcode.rs].UW[0] & 0x1F)); + if (state->Opcode.u.e.rd == 0) { return; } + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].W[0] << (state->GPR[state->Opcode.u.b.rs].UW[0] & 0x1F)); } void r4300i_SPECIAL_SRLV (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (int32_t)(state->GPR[state->Opcode.rt].UW[0] >> (state->GPR[state->Opcode.rs].UW[0] & 0x1F)); + state->GPR[state->Opcode.u.e.rd].DW = (int32_t)(state->GPR[state->Opcode.u.b.rt].UW[0] >> (state->GPR[state->Opcode.u.b.rs].UW[0] & 0x1F)); } void r4300i_SPECIAL_SRAV (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].W[0] >> (state->GPR[state->Opcode.rs].UW[0] & 0x1F)); + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].W[0] >> (state->GPR[state->Opcode.u.b.rs].UW[0] & 0x1F)); } void r4300i_SPECIAL_JR (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->GPR[state->Opcode.rs].UW[0]; + state->JumpToLocation = state->GPR[state->Opcode.u.b.rs].UW[0]; } void r4300i_SPECIAL_JALR (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->GPR[state->Opcode.rs].UW[0]; - state->GPR[state->Opcode.rd].DW = (int32_t)(state->PROGRAM_COUNTER + 8); + state->JumpToLocation = state->GPR[state->Opcode.u.b.rs].UW[0]; + state->GPR[state->Opcode.u.e.rd].DW = (int32_t)(state->PROGRAM_COUNTER + 8); } void r4300i_SPECIAL_SYSCALL (usf_state_t * state) { @@ -623,57 +623,57 @@ void r4300i_SPECIAL_SYNC (usf_state_t * state) { } void r4300i_SPECIAL_MFHI (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->HI.DW; + state->GPR[state->Opcode.u.e.rd].DW = state->HI.DW; } void r4300i_SPECIAL_MTHI (usf_state_t * state) { - state->HI.DW = state->GPR[state->Opcode.rs].DW; + state->HI.DW = state->GPR[state->Opcode.u.b.rs].DW; } void r4300i_SPECIAL_MFLO (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->LO.DW; + state->GPR[state->Opcode.u.e.rd].DW = state->LO.DW; } void r4300i_SPECIAL_MTLO (usf_state_t * state) { - state->LO.DW = state->GPR[state->Opcode.rs].DW; + state->LO.DW = state->GPR[state->Opcode.u.b.rs].DW; } void r4300i_SPECIAL_DSLLV (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rt].DW << (state->GPR[state->Opcode.rs].UW[0] & 0x3F); + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rt].DW << (state->GPR[state->Opcode.u.b.rs].UW[0] & 0x3F); } void r4300i_SPECIAL_DSRLV (usf_state_t * state) { - state->GPR[state->Opcode.rd].UDW = state->GPR[state->Opcode.rt].UDW >> (state->GPR[state->Opcode.rs].UW[0] & 0x3F); + state->GPR[state->Opcode.u.e.rd].UDW = state->GPR[state->Opcode.u.b.rt].UDW >> (state->GPR[state->Opcode.u.b.rs].UW[0] & 0x3F); } void r4300i_SPECIAL_DSRAV (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rt].DW >> (state->GPR[state->Opcode.rs].UW[0] & 0x3F); + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rt].DW >> (state->GPR[state->Opcode.u.b.rs].UW[0] & 0x3F); } void r4300i_SPECIAL_MULT (usf_state_t * state) { - state->HI.DW = (int64_t)(state->GPR[state->Opcode.rs].W[0]) * (int64_t)(state->GPR[state->Opcode.rt].W[0]); + state->HI.DW = (int64_t)(state->GPR[state->Opcode.u.b.rs].W[0]) * (int64_t)(state->GPR[state->Opcode.u.b.rt].W[0]); state->LO.DW = state->HI.W[0]; state->HI.DW = state->HI.W[1]; } void r4300i_SPECIAL_MULTU (usf_state_t * state) { - state->HI.DW = (uint64_t)(state->GPR[state->Opcode.rs].UW[0]) * (uint64_t)(state->GPR[state->Opcode.rt].UW[0]); + state->HI.DW = (uint64_t)(state->GPR[state->Opcode.u.b.rs].UW[0]) * (uint64_t)(state->GPR[state->Opcode.u.b.rt].UW[0]); state->LO.DW = state->HI.W[0]; state->HI.DW = state->HI.W[1]; } void r4300i_SPECIAL_DIV (usf_state_t * state) { - if ( state->GPR[state->Opcode.rt].UDW != 0 ) { - state->LO.DW = state->GPR[state->Opcode.rs].W[0] / state->GPR[state->Opcode.rt].W[0]; - state->HI.DW = state->GPR[state->Opcode.rs].W[0] % state->GPR[state->Opcode.rt].W[0]; + if ( state->GPR[state->Opcode.u.b.rt].UDW != 0 ) { + state->LO.DW = state->GPR[state->Opcode.u.b.rs].W[0] / state->GPR[state->Opcode.u.b.rt].W[0]; + state->HI.DW = state->GPR[state->Opcode.u.b.rs].W[0] % state->GPR[state->Opcode.u.b.rt].W[0]; } else { } } void r4300i_SPECIAL_DIVU (usf_state_t * state) { - if ( state->GPR[state->Opcode.rt].UDW != 0 ) { - state->LO.DW = (int32_t)(state->GPR[state->Opcode.rs].UW[0] / state->GPR[state->Opcode.rt].UW[0]); - state->HI.DW = (int32_t)(state->GPR[state->Opcode.rs].UW[0] % state->GPR[state->Opcode.rt].UW[0]); + if ( state->GPR[state->Opcode.u.b.rt].UDW != 0 ) { + state->LO.DW = (int32_t)(state->GPR[state->Opcode.u.b.rs].UW[0] / state->GPR[state->Opcode.u.b.rt].UW[0]); + state->HI.DW = (int32_t)(state->GPR[state->Opcode.u.b.rs].UW[0] % state->GPR[state->Opcode.u.b.rt].UW[0]); } else { } } @@ -681,10 +681,10 @@ void r4300i_SPECIAL_DIVU (usf_state_t * state) { void r4300i_SPECIAL_DMULT (usf_state_t * state) { MIPS_DWORD Tmp[3]; - state->LO.UDW = (uint64_t)state->GPR[state->Opcode.rs].UW[0] * (uint64_t)state->GPR[state->Opcode.rt].UW[0]; - Tmp[0].UDW = (int64_t)state->GPR[state->Opcode.rs].W[1] * (int64_t)(uint64_t)state->GPR[state->Opcode.rt].UW[0]; - Tmp[1].UDW = (int64_t)(uint64_t)state->GPR[state->Opcode.rs].UW[0] * (int64_t)state->GPR[state->Opcode.rt].W[1]; - state->HI.UDW = (int64_t)state->GPR[state->Opcode.rs].W[1] * (int64_t)state->GPR[state->Opcode.rt].W[1]; + state->LO.UDW = (uint64_t)state->GPR[state->Opcode.u.b.rs].UW[0] * (uint64_t)state->GPR[state->Opcode.u.b.rt].UW[0]; + Tmp[0].UDW = (int64_t)state->GPR[state->Opcode.u.b.rs].W[1] * (int64_t)(uint64_t)state->GPR[state->Opcode.u.b.rt].UW[0]; + Tmp[1].UDW = (int64_t)(uint64_t)state->GPR[state->Opcode.u.b.rs].UW[0] * (int64_t)state->GPR[state->Opcode.u.b.rt].W[1]; + state->HI.UDW = (int64_t)state->GPR[state->Opcode.u.b.rs].W[1] * (int64_t)state->GPR[state->Opcode.u.b.rt].W[1]; Tmp[2].UDW = (uint64_t)state->LO.UW[1] + (uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]; state->LO.UDW += ((uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]) << 32; @@ -694,10 +694,10 @@ void r4300i_SPECIAL_DMULT (usf_state_t * state) { void r4300i_SPECIAL_DMULTU (usf_state_t * state) { MIPS_DWORD Tmp[3]; - state->LO.UDW = (uint64_t)state->GPR[state->Opcode.rs].UW[0] * (uint64_t)state->GPR[state->Opcode.rt].UW[0]; - Tmp[0].UDW = (uint64_t)state->GPR[state->Opcode.rs].UW[1] * (uint64_t)state->GPR[state->Opcode.rt].UW[0]; - Tmp[1].UDW = (uint64_t)state->GPR[state->Opcode.rs].UW[0] * (uint64_t)state->GPR[state->Opcode.rt].UW[1]; - state->HI.UDW = (uint64_t)state->GPR[state->Opcode.rs].UW[1] * (uint64_t)state->GPR[state->Opcode.rt].UW[1]; + state->LO.UDW = (uint64_t)state->GPR[state->Opcode.u.b.rs].UW[0] * (uint64_t)state->GPR[state->Opcode.u.b.rt].UW[0]; + Tmp[0].UDW = (uint64_t)state->GPR[state->Opcode.u.b.rs].UW[1] * (uint64_t)state->GPR[state->Opcode.u.b.rt].UW[0]; + Tmp[1].UDW = (uint64_t)state->GPR[state->Opcode.u.b.rs].UW[0] * (uint64_t)state->GPR[state->Opcode.u.b.rt].UW[1]; + state->HI.UDW = (uint64_t)state->GPR[state->Opcode.u.b.rs].UW[1] * (uint64_t)state->GPR[state->Opcode.u.b.rt].UW[1]; Tmp[2].UDW = (uint64_t)state->LO.UW[1] + (uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]; state->LO.UDW += ((uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]) << 32; @@ -705,120 +705,120 @@ void r4300i_SPECIAL_DMULTU (usf_state_t * state) { } void r4300i_SPECIAL_DDIV (usf_state_t * state) { - if ( state->GPR[state->Opcode.rt].UDW != 0 ) { - state->LO.DW = state->GPR[state->Opcode.rs].DW / state->GPR[state->Opcode.rt].DW; - state->HI.DW = state->GPR[state->Opcode.rs].DW % state->GPR[state->Opcode.rt].DW; + if ( state->GPR[state->Opcode.u.b.rt].UDW != 0 ) { + state->LO.DW = state->GPR[state->Opcode.u.b.rs].DW / state->GPR[state->Opcode.u.b.rt].DW; + state->HI.DW = state->GPR[state->Opcode.u.b.rs].DW % state->GPR[state->Opcode.u.b.rt].DW; } else { } } void r4300i_SPECIAL_DDIVU (usf_state_t * state) { - if ( state->GPR[state->Opcode.rt].UDW != 0 ) { - state->LO.UDW = state->GPR[state->Opcode.rs].UDW / state->GPR[state->Opcode.rt].UDW; - state->HI.UDW = state->GPR[state->Opcode.rs].UDW % state->GPR[state->Opcode.rt].UDW; + if ( state->GPR[state->Opcode.u.b.rt].UDW != 0 ) { + state->LO.UDW = state->GPR[state->Opcode.u.b.rs].UDW / state->GPR[state->Opcode.u.b.rt].UDW; + state->HI.UDW = state->GPR[state->Opcode.u.b.rs].UDW % state->GPR[state->Opcode.u.b.rt].UDW; } else { } } void r4300i_SPECIAL_ADD (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].W[0] + state->GPR[state->Opcode.rt].W[0]; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].W[0] + state->GPR[state->Opcode.u.b.rt].W[0]; } void r4300i_SPECIAL_ADDU (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].W[0] + state->GPR[state->Opcode.rt].W[0]; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].W[0] + state->GPR[state->Opcode.u.b.rt].W[0]; } void r4300i_SPECIAL_SUB (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].W[0] - state->GPR[state->Opcode.rt].W[0]; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].W[0] - state->GPR[state->Opcode.u.b.rt].W[0]; } void r4300i_SPECIAL_SUBU (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].W[0] - state->GPR[state->Opcode.rt].W[0]; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].W[0] - state->GPR[state->Opcode.u.b.rt].W[0]; } void r4300i_SPECIAL_AND (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].DW & state->GPR[state->Opcode.rt].DW; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].DW & state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_SPECIAL_OR (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].DW | state->GPR[state->Opcode.rt].DW; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].DW | state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_SPECIAL_XOR (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].DW ^ state->GPR[state->Opcode.rt].DW; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].DW ^ state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_SPECIAL_NOR (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = ~(state->GPR[state->Opcode.rs].DW | state->GPR[state->Opcode.rt].DW); + state->GPR[state->Opcode.u.e.rd].DW = ~(state->GPR[state->Opcode.u.b.rs].DW | state->GPR[state->Opcode.u.b.rt].DW); } void r4300i_SPECIAL_SLT (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW < state->GPR[state->Opcode.rt].DW) { - state->GPR[state->Opcode.rd].DW = 1; + if (state->GPR[state->Opcode.u.b.rs].DW < state->GPR[state->Opcode.u.b.rt].DW) { + state->GPR[state->Opcode.u.e.rd].DW = 1; } else { - state->GPR[state->Opcode.rd].DW = 0; + state->GPR[state->Opcode.u.e.rd].DW = 0; } } void r4300i_SPECIAL_SLTU (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].UDW < state->GPR[state->Opcode.rt].UDW) { - state->GPR[state->Opcode.rd].DW = 1; + if (state->GPR[state->Opcode.u.b.rs].UDW < state->GPR[state->Opcode.u.b.rt].UDW) { + state->GPR[state->Opcode.u.e.rd].DW = 1; } else { - state->GPR[state->Opcode.rd].DW = 0; + state->GPR[state->Opcode.u.e.rd].DW = 0; } } void r4300i_SPECIAL_DADD (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].DW + state->GPR[state->Opcode.rt].DW; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].DW + state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_SPECIAL_DADDU (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].DW + state->GPR[state->Opcode.rt].DW; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].DW + state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_SPECIAL_DSUB (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].DW - state->GPR[state->Opcode.rt].DW; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].DW - state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_SPECIAL_DSUBU (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = state->GPR[state->Opcode.rs].DW - state->GPR[state->Opcode.rt].DW; + state->GPR[state->Opcode.u.e.rd].DW = state->GPR[state->Opcode.u.b.rs].DW - state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_SPECIAL_TEQ (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW == state->GPR[state->Opcode.rt].DW) { + if (state->GPR[state->Opcode.u.b.rs].DW == state->GPR[state->Opcode.u.b.rt].DW) { } } void r4300i_SPECIAL_DSLL (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].DW << state->Opcode.sa); + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].DW << state->Opcode.u.e.sa); } void r4300i_SPECIAL_DSRL (usf_state_t * state) { - state->GPR[state->Opcode.rd].UDW = (state->GPR[state->Opcode.rt].UDW >> state->Opcode.sa); + state->GPR[state->Opcode.u.e.rd].UDW = (state->GPR[state->Opcode.u.b.rt].UDW >> state->Opcode.u.e.sa); } void r4300i_SPECIAL_DSRA (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].DW >> state->Opcode.sa); + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].DW >> state->Opcode.u.e.sa); } void r4300i_SPECIAL_DSLL32 (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].DW << (state->Opcode.sa + 32)); + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].DW << (state->Opcode.u.e.sa + 32)); } void r4300i_SPECIAL_DSRL32 (usf_state_t * state) { - state->GPR[state->Opcode.rd].UDW = (state->GPR[state->Opcode.rt].UDW >> (state->Opcode.sa + 32)); + state->GPR[state->Opcode.u.e.rd].UDW = (state->GPR[state->Opcode.u.b.rt].UDW >> (state->Opcode.u.e.sa + 32)); } void r4300i_SPECIAL_DSRA32 (usf_state_t * state) { - state->GPR[state->Opcode.rd].DW = (state->GPR[state->Opcode.rt].DW >> (state->Opcode.sa + 32)); + state->GPR[state->Opcode.u.e.rd].DW = (state->GPR[state->Opcode.u.b.rt].DW >> (state->Opcode.u.e.sa + 32)); } /********************** R4300i state->Opcodes: RegImm **********************/ void r4300i_REGIMM_BLTZ (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW < 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + if (state->GPR[state->Opcode.u.b.rs].DW < 0) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -826,19 +826,19 @@ void r4300i_REGIMM_BLTZ (usf_state_t * state) { void r4300i_REGIMM_BGEZ (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW >= 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + if (state->GPR[state->Opcode.u.b.rs].DW >= 0) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } } void r4300i_REGIMM_BLTZL (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW < 0) { + if (state->GPR[state->Opcode.u.b.rs].DW < 0) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -846,10 +846,10 @@ void r4300i_REGIMM_BLTZL (usf_state_t * state) { } void r4300i_REGIMM_BGEZL (usf_state_t * state) { - if (state->GPR[state->Opcode.rs].DW >= 0) { + if (state->GPR[state->Opcode.u.b.rs].DW >= 0) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -858,9 +858,9 @@ void r4300i_REGIMM_BGEZL (usf_state_t * state) { void r4300i_REGIMM_BLTZAL (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW < 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + if (state->GPR[state->Opcode.u.b.rs].DW < 0) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -869,9 +869,9 @@ void r4300i_REGIMM_BLTZAL (usf_state_t * state) { void r4300i_REGIMM_BGEZAL (usf_state_t * state) { state->NextInstruction = DELAY_SLOT; - if (state->GPR[state->Opcode.rs].DW >= 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; - TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.rs,0); + if (state->GPR[state->Opcode.u.b.rs].DW >= 0) { + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; + TestInterpreterJump(state,state->PROGRAM_COUNTER,state->JumpToLocation,state->Opcode.u.b.rs,0); } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -879,11 +879,11 @@ void r4300i_REGIMM_BGEZAL (usf_state_t * state) { } /************************** COP0 functions **************************/ void r4300i_COP0_MF (usf_state_t * state) { - state->GPR[state->Opcode.rt].DW = (int32_t)state->CP0[state->Opcode.rd]; + state->GPR[state->Opcode.u.b.rt].DW = (int32_t)state->CP0[state->Opcode.u.e.rd]; } void r4300i_COP0_MT (usf_state_t * state) { - switch (state->Opcode.rd) { + switch (state->Opcode.u.e.rd) { case 0: //Index case 2: //EntryLo0 case 3: //EntryLo1 @@ -897,33 +897,33 @@ void r4300i_COP0_MT (usf_state_t * state) { case 28: //Tag lo case 29: //Tag Hi case 30: //ErrEPC - state->CP0[state->Opcode.rd] = state->GPR[state->Opcode.rt].UW[0]; + state->CP0[state->Opcode.u.e.rd] = state->GPR[state->Opcode.u.b.rt].UW[0]; break; case 4: //Context - state->CP0[state->Opcode.rd] = state->GPR[state->Opcode.rt].UW[0] & 0xFF800000; + state->CP0[state->Opcode.u.e.rd] = state->GPR[state->Opcode.u.b.rt].UW[0] & 0xFF800000; break; case 9: //Count - state->CP0[state->Opcode.rd]= state->GPR[state->Opcode.rt].UW[0]; + state->CP0[state->Opcode.u.e.rd]= state->GPR[state->Opcode.u.b.rt].UW[0]; ChangeCompareTimer(state); break; case 11: //Compare - state->CP0[state->Opcode.rd] = state->GPR[state->Opcode.rt].UW[0]; + state->CP0[state->Opcode.u.e.rd] = state->GPR[state->Opcode.u.b.rt].UW[0]; FAKE_CAUSE_REGISTER &= ~CAUSE_IP7; ChangeCompareTimer(state); break; case 12: //Status - if ((state->CP0[state->Opcode.rd] ^ state->GPR[state->Opcode.rt].UW[0]) != 0) { - state->CP0[state->Opcode.rd] = state->GPR[state->Opcode.rt].UW[0]; + if ((state->CP0[state->Opcode.u.e.rd] ^ state->GPR[state->Opcode.u.b.rt].UW[0]) != 0) { + state->CP0[state->Opcode.u.e.rd] = state->GPR[state->Opcode.u.b.rt].UW[0]; SetFpuLocations(state); } else { - state->CP0[state->Opcode.rd] = state->GPR[state->Opcode.rt].UW[0]; + state->CP0[state->Opcode.u.e.rd] = state->GPR[state->Opcode.u.b.rt].UW[0]; } - if ((state->CP0[state->Opcode.rd] & 0x18) != 0) { + if ((state->CP0[state->Opcode.u.e.rd] & 0x18) != 0) { } CheckInterrupts(state); break; case 13: //cause - state->CP0[state->Opcode.rd] &= 0xFFFFCFF; + state->CP0[state->Opcode.u.e.rd] &= 0xFFFFCFF; break; default: R4300i_UnknownOpcode(state); @@ -964,36 +964,36 @@ void r4300i_COP0_CO_ERET (usf_state_t * state) { /************************** COP1 functions **************************/ void r4300i_COP1_MF (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - state->GPR[state->Opcode.rt].DW = *(int32_t *)state->FPRFloatLocation[state->Opcode.fs]; + state->GPR[state->Opcode.u.b.rt].DW = *(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fs]; } void r4300i_COP1_DMF (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - state->GPR[state->Opcode.rt].DW = *(int64_t *)state->FPRDoubleLocation[state->Opcode.fs]; + state->GPR[state->Opcode.u.b.rt].DW = *(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fs]; } void r4300i_COP1_CF (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - if (state->Opcode.fs != 31 && state->Opcode.fs != 0) { + if (state->Opcode.u.f.fs != 31 && state->Opcode.u.f.fs != 0) { return; } - state->GPR[state->Opcode.rt].DW = (int32_t)state->FPCR[state->Opcode.fs]; + state->GPR[state->Opcode.u.b.rt].DW = (int32_t)state->FPCR[state->Opcode.u.f.fs]; } void r4300i_COP1_MT (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(int32_t *)state->FPRFloatLocation[state->Opcode.fs] = state->GPR[state->Opcode.rt].W[0]; + *(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fs] = state->GPR[state->Opcode.u.b.rt].W[0]; } void r4300i_COP1_DMT (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(int64_t *)state->FPRDoubleLocation[state->Opcode.fs] = state->GPR[state->Opcode.rt].DW; + *(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fs] = state->GPR[state->Opcode.u.b.rt].DW; } void r4300i_COP1_CT (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - if (state->Opcode.fs == 31) { - state->FPCR[state->Opcode.fs] = state->GPR[state->Opcode.rt].W[0]; + if (state->Opcode.u.f.fs == 31) { + state->FPCR[state->Opcode.u.f.fs] = state->GPR[state->Opcode.u.b.rt].W[0]; return; } } @@ -1003,7 +1003,7 @@ void r4300i_COP1_BCF (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION state->NextInstruction = DELAY_SLOT; if ((state->FPCR[31] & FPCSR_C) == 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -1013,7 +1013,7 @@ void r4300i_COP1_BCT (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION state->NextInstruction = DELAY_SLOT; if ((state->FPCR[31] & FPCSR_C) != 0) { - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; } else { state->JumpToLocation = state->PROGRAM_COUNTER + 8; } @@ -1023,7 +1023,7 @@ void r4300i_COP1_BCFL (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION if ((state->FPCR[31] & FPCSR_C) == 0) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -1034,7 +1034,7 @@ void r4300i_COP1_BCTL (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION if ((state->FPCR[31] & FPCSR_C) != 0) { state->NextInstruction = DELAY_SLOT; - state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.offset << 2) + 4; + state->JumpToLocation = state->PROGRAM_COUNTER + ((int16_t)state->Opcode.u.b.offset << 2) + 4; } else { state->NextInstruction = JUMP; state->JumpToLocation = state->PROGRAM_COUNTER + 8; @@ -1051,96 +1051,96 @@ INLINE void Float_RoundToInteger64( int64_t * Dest, float * Source ) { void r4300i_COP1_S_ADD (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.fs] + *(float *)state->FPRFloatLocation[state->Opcode.ft]); + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs] + *(float *)state->FPRFloatLocation[state->Opcode.u.f.ft]); } void r4300i_COP1_S_SUB (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.fs] - *(float *)state->FPRFloatLocation[state->Opcode.ft]); + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs] - *(float *)state->FPRFloatLocation[state->Opcode.u.f.ft]); } void r4300i_COP1_S_MUL (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.fs] * *(float *)state->FPRFloatLocation[state->Opcode.ft]); + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs] * *(float *)state->FPRFloatLocation[state->Opcode.u.f.ft]); } void r4300i_COP1_S_DIV (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.fs] / *(float *)state->FPRFloatLocation[state->Opcode.ft]); + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs] / *(float *)state->FPRFloatLocation[state->Opcode.u.f.ft]); } void r4300i_COP1_S_SQRT (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (float)sqrt(*(float *)state->FPRFloatLocation[state->Opcode.fs]); + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (float)sqrt(*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_ABS (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (float)fabs(*(float *)state->FPRFloatLocation[state->Opcode.fs]); + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (float)fabs(*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_MOV (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = *(float *)state->FPRFloatLocation[state->Opcode.fs]; + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = *(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]; } void r4300i_COP1_S_NEG (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.fs] * -1.0f); + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs] * -1.0f); } void r4300i_COP1_S_TRUNC_L (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION //_controlfp(_RC_CHOP,_MCW_RC); - Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_CEIL_L (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION //_controlfp(_RC_UP,_MCW_RC); - Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_FLOOR_L (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION - Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_ROUND_W (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_TRUNC_W (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION //_controlfp(_RC_CHOP,_MCW_RC); - Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_CEIL_W (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION //_controlfp(_RC_UP,_MCW_RC); - Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_FLOOR_W (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_CVT_D (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = (double)(*(float *)state->FPRFloatLocation[state->Opcode.fs]); + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = (double)(*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_CVT_W (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_CVT_L (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.fd],&*(float *)state->FPRFloatLocation[state->Opcode.fs]); + Float_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd],&*(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_S_CMP (usf_state_t * state) { @@ -1149,15 +1149,15 @@ void r4300i_COP1_S_CMP (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Temp0 = *(float *)state->FPRFloatLocation[state->Opcode.fs]; - Temp1 = *(float *)state->FPRFloatLocation[state->Opcode.ft]; + Temp0 = *(float *)state->FPRFloatLocation[state->Opcode.u.f.fs]; + Temp1 = *(float *)state->FPRFloatLocation[state->Opcode.u.f.ft]; if(0) { //if (_isnan(Temp0) || _isnan(Temp1)) { less = 0; equal = 0; unorded = 1; - if ((state->Opcode.funct & 8) != 0) { + if ((state->Opcode.u.e.funct & 8) != 0) { } } else { less = Temp0 < Temp1; @@ -1165,8 +1165,8 @@ void r4300i_COP1_S_CMP (usf_state_t * state) { unorded = 0; } - condition = ((state->Opcode.funct & 4) && less) | ((state->Opcode.funct & 2) && equal) | - ((state->Opcode.funct & 1) && unorded); + condition = ((state->Opcode.u.e.funct & 4) && less) | ((state->Opcode.u.e.funct & 2) && equal) | + ((state->Opcode.u.e.funct & 1) && unorded); if (condition) { state->FPCR[31] |= FPCSR_C; @@ -1187,92 +1187,92 @@ INLINE void Double_RoundToInteger64( int64_t * Dest, double * Source ) { void r4300i_COP1_D_ADD (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.fs] + *(double *)state->FPRDoubleLocation[state->Opcode.ft]; + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.ft]; } void r4300i_COP1_D_SUB (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.fs] - *(double *)state->FPRDoubleLocation[state->Opcode.ft]; + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] - *(double *)state->FPRDoubleLocation[state->Opcode.u.f.ft]; } void r4300i_COP1_D_MUL (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.fs] * *(double *)state->FPRDoubleLocation[state->Opcode.ft]; + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] * *(double *)state->FPRDoubleLocation[state->Opcode.u.f.ft]; } void r4300i_COP1_D_DIV (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.fs] / *(double *)state->FPRDoubleLocation[state->Opcode.ft]; + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] / *(double *)state->FPRDoubleLocation[state->Opcode.u.f.ft]; } void r4300i_COP1_D_SQRT (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = (double)sqrt(*(double *)state->FPRDoubleLocation[state->Opcode.fs]); + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = (double)sqrt(*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_D_ABS (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = fabs(*(double *)state->FPRDoubleLocation[state->Opcode.fs]); + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = fabs(*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_D_MOV (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(int64_t *)state->FPRDoubleLocation[state->Opcode.fd] = *(int64_t *)state->FPRDoubleLocation[state->Opcode.fs]; + *(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = *(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fs]; } void r4300i_COP1_D_NEG (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = (*(double *)state->FPRDoubleLocation[state->Opcode.fs] * -1.0); + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = (*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] * -1.0); } void r4300i_COP1_D_TRUNC_L (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger64(&*(int64_t *)state->FPRFloatLocation[state->Opcode.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.fs] ); + Double_RoundToInteger64(&*(int64_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] ); } void r4300i_COP1_D_CEIL_L (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger64(&*(int64_t *)state->FPRFloatLocation[state->Opcode.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.fs] ); + Double_RoundToInteger64(&*(int64_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] ); } void r4300i_COP1_D_FLOOR_L (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.fd],&*(double *)state->FPRFloatLocation[state->Opcode.fs]); + Double_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd],&*(double *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_D_ROUND_W (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.fs] ); + Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] ); } void r4300i_COP1_D_TRUNC_W (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.fs] ); + Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] ); } void r4300i_COP1_D_CEIL_W (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.fs] ); + Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] ); } void r4300i_COP1_D_FLOOR_W (usf_state_t * state) { //added by Witten TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger32(&*(int32_t *)state->FPRDoubleLocation[state->Opcode.fd],&*(double *)state->FPRFloatLocation[state->Opcode.fs]); + Double_RoundToInteger32(&*(int32_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd],&*(double *)state->FPRFloatLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_D_CVT_S (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (float)*(double *)state->FPRDoubleLocation[state->Opcode.fs]; + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (float)*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs]; } void r4300i_COP1_D_CVT_W (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.fs] ); + Double_RoundToInteger32(&*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs] ); } void r4300i_COP1_D_CVT_L (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Double_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.fs]); + Double_RoundToInteger64(&*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fd],&*(double *)state->FPRDoubleLocation[state->Opcode.u.f.fs]); } void r4300i_COP1_D_CMP (usf_state_t * state) { @@ -1281,15 +1281,15 @@ void r4300i_COP1_D_CMP (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - Temp0.DW = *(int64_t *)state->FPRDoubleLocation[state->Opcode.fs]; - Temp1.DW = *(int64_t *)state->FPRDoubleLocation[state->Opcode.ft]; + Temp0.DW = *(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fs]; + Temp1.DW = *(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.ft]; if(0) { //if (_isnan(Temp0.D) || _isnan(Temp1.D)) { less = 0; equal = 0; unorded = 1; - if ((state->Opcode.funct & 8) != 0) { + if ((state->Opcode.u.e.funct & 8) != 0) { } } else { less = Temp0.D < Temp1.D; @@ -1297,8 +1297,8 @@ void r4300i_COP1_D_CMP (usf_state_t * state) { unorded = 0; } - condition = ((state->Opcode.funct & 4) && less) | ((state->Opcode.funct & 2) && equal) | - ((state->Opcode.funct & 1) && unorded); + condition = ((state->Opcode.u.e.funct & 4) && less) | ((state->Opcode.u.e.funct & 2) && equal) | + ((state->Opcode.u.e.funct & 1) && unorded); if (condition) { state->FPCR[31] |= FPCSR_C; @@ -1310,27 +1310,27 @@ void r4300i_COP1_D_CMP (usf_state_t * state) { /************************** COP1: W functions ************************/ void r4300i_COP1_W_CVT_S (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (float)*(int32_t *)state->FPRFloatLocation[state->Opcode.fs]; + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (float)*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fs]; } void r4300i_COP1_W_CVT_D (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = (double)*(int32_t *)state->FPRFloatLocation[state->Opcode.fs]; + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = (double)*(int32_t *)state->FPRFloatLocation[state->Opcode.u.f.fs]; } /************************** COP1: L functions ************************/ void r4300i_COP1_L_CVT_S (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(float *)state->FPRFloatLocation[state->Opcode.fd] = (float)*(int64_t *)state->FPRDoubleLocation[state->Opcode.fs]; + *(float *)state->FPRFloatLocation[state->Opcode.u.f.fd] = (float)*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fs]; } void r4300i_COP1_L_CVT_D (usf_state_t * state) { TEST_COP1_USABLE_EXCEPTION - *(double *)state->FPRDoubleLocation[state->Opcode.fd] = (double)*(int64_t *)state->FPRDoubleLocation[state->Opcode.fs]; + *(double *)state->FPRDoubleLocation[state->Opcode.u.f.fd] = (double)*(int64_t *)state->FPRDoubleLocation[state->Opcode.u.f.fs]; } /************************** Other functions **************************/ void R4300i_UnknownOpcode (usf_state_t * state) { - DisplayError("Unkniown X86 Opcode.\tPC:%08x\tOp:%08x\n", state->PROGRAM_COUNTER,state->Opcode.Hex); + DisplayError("Unknown R4300i Opcode.\tPC:%08x\tOp:%08x\n", state->PROGRAM_COUNTER,state->Opcode.u.Hex); StopEmulation(state); } diff --git a/Frameworks/lazyusf/lazyusf/opcode.h b/Frameworks/lazyusf/lazyusf/opcode.h index cf2fe39ef..636f32374 100644 --- a/Frameworks/lazyusf/lazyusf/opcode.h +++ b/Frameworks/lazyusf/lazyusf/opcode.h @@ -39,19 +39,19 @@ typedef struct { unsigned rt : 5; unsigned rs : 5; unsigned op : 6; - }; + } b; struct { unsigned immediate : 16; unsigned : 5; unsigned base : 5; unsigned : 6; - }; + } c; struct { unsigned target : 26; unsigned : 6; - }; + } d; struct { unsigned funct : 6; @@ -60,7 +60,7 @@ typedef struct { unsigned : 5; unsigned : 5; unsigned : 6; - }; + } e; struct { unsigned : 6; @@ -69,8 +69,8 @@ typedef struct { unsigned ft : 5; unsigned fmt : 5; unsigned : 6; - }; - }; + } f; + } u; } OPCODE; diff --git a/Frameworks/lazyusf/lazyusf/tlb.c b/Frameworks/lazyusf/lazyusf/tlb.c index a3f8f2aec..e1b3d166c 100644 --- a/Frameworks/lazyusf/lazyusf/tlb.c +++ b/Frameworks/lazyusf/lazyusf/tlb.c @@ -24,6 +24,8 @@ * */ +#include + #include "main.h" #include "cpu.h" @@ -78,21 +80,21 @@ void SetupTLB_Entry (usf_state_t * state, int Entry) { if (!state->tlb[Entry].EntryDefined) { return; } FastIndx = Entry << 1; - state->FastTlb[FastIndx].VSTART=state->tlb[Entry].EntryHi.VPN2 << 13; - state->FastTlb[FastIndx].VEND = state->FastTlb[FastIndx].VSTART + (state->tlb[Entry].PageMask.Mask << 12) + 0xFFF; - state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo0.PFN << 12; - state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo0.V; - state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo0.D; - state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.GLOBAL & state->tlb[Entry].EntryLo1.GLOBAL; + state->FastTlb[FastIndx].VSTART=state->tlb[Entry].EntryHi.b.VPN2 << 13; + state->FastTlb[FastIndx].VEND = state->FastTlb[FastIndx].VSTART + (state->tlb[Entry].PageMask.b.Mask << 12) + 0xFFF; + state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo0.b.PFN << 12; + state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo0.b.V; + state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo0.b.D; + state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.b.GLOBAL & state->tlb[Entry].EntryLo1.b.GLOBAL; state->FastTlb[FastIndx].ValidEntry = 0; FastIndx = (Entry << 1) + 1; - state->FastTlb[FastIndx].VSTART=(state->tlb[Entry].EntryHi.VPN2 << 13) + ((state->tlb[Entry].PageMask.Mask << 12) + 0xFFF + 1); - state->FastTlb[FastIndx].VEND = state->FastTlb[FastIndx].VSTART + (state->tlb[Entry].PageMask.Mask << 12) + 0xFFF; - state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo1.PFN << 12; - state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo1.V; - state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo1.D; - state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.GLOBAL & state->tlb[Entry].EntryLo1.GLOBAL; + state->FastTlb[FastIndx].VSTART=(state->tlb[Entry].EntryHi.b.VPN2 << 13) + ((state->tlb[Entry].PageMask.b.Mask << 12) + 0xFFF + 1); + state->FastTlb[FastIndx].VEND = state->FastTlb[FastIndx].VSTART + (state->tlb[Entry].PageMask.b.Mask << 12) + 0xFFF; + state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo1.b.PFN << 12; + state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo1.b.V; + state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo1.b.D; + state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.b.GLOBAL & state->tlb[Entry].EntryLo1.b.GLOBAL; state->FastTlb[FastIndx].ValidEntry = 0; for ( FastIndx = Entry << 1; FastIndx <= (Entry << 1) + 1; FastIndx++) { @@ -126,8 +128,8 @@ void TLB_Probe (usf_state_t * state) { INDEX_REGISTER |= 0x80000000; for (Counter = 0; Counter < 32; Counter ++) { - uint32_t TlbValue = state->tlb[Counter].EntryHi.Value & (~state->tlb[Counter].PageMask.Mask << 13); - uint32_t EntryHi = ENTRYHI_REGISTER & (~state->tlb[Counter].PageMask.Mask << 13); + uint32_t TlbValue = state->tlb[Counter].EntryHi.Value & (~state->tlb[Counter].PageMask.b.Mask << 13); + uint32_t EntryHi = ENTRYHI_REGISTER & (~state->tlb[Counter].PageMask.b.Mask << 13); if (TlbValue == EntryHi) { uint32_t Global = (state->tlb[Counter].EntryHi.Value & 0x100) != 0; diff --git a/Frameworks/lazyusf/lazyusf/tlb.h b/Frameworks/lazyusf/lazyusf/tlb.h index 7127d132d..3807cf0c8 100644 --- a/Frameworks/lazyusf/lazyusf/tlb.h +++ b/Frameworks/lazyusf/lazyusf/tlb.h @@ -36,7 +36,7 @@ typedef struct { unsigned zero : 13; unsigned Mask : 12; unsigned zero2 : 7; - } ; + } b; } PageMask; @@ -49,7 +49,7 @@ typedef struct { unsigned Zero : 4; unsigned G : 1; unsigned VPN2 : 19; - }; + } b; } EntryHi; @@ -64,7 +64,7 @@ typedef struct { unsigned C : 3; unsigned PFN : 20; unsigned ZERO: 6; - }; + } b; } EntryLo0; @@ -79,7 +79,7 @@ typedef struct { unsigned C : 3; unsigned PFN : 20; unsigned ZERO: 6; - } ; + } b; } EntryLo1; } TLB; diff --git a/Frameworks/lazyusf/lazyusf/usf.c b/Frameworks/lazyusf/lazyusf/usf.c index 5528fbd48..bdc85e908 100644 --- a/Frameworks/lazyusf/lazyusf/usf.c +++ b/Frameworks/lazyusf/lazyusf/usf.c @@ -1,5 +1,6 @@ #include +#include #include "usf.h" #include "cpu.h" @@ -218,6 +219,8 @@ void usf_restart(void * state) { if ( USF_STATE->MemoryState ) StartEmulationFromSave(USF_STATE, USF_STATE->savestatespace); + + USF_STATE->samples_in_buffer = 0; } void usf_shutdown(void * state) diff --git a/Frameworks/lazyusf/lazyusf/usf.h b/Frameworks/lazyusf/lazyusf/usf.h index c227aa0bb..c601a8cf4 100644 --- a/Frameworks/lazyusf/lazyusf/usf.h +++ b/Frameworks/lazyusf/lazyusf/usf.h @@ -3,20 +3,13 @@ #define _CRT_SECURE_NO_WARNINGS -#include -#include -#include -#include #include +#include typedef struct usf_state usf_state_t; typedef struct usf_state_helper usf_state_helper_t; -#include "usf.h" -#include "cpu.h" -#include "memory.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/Frameworks/lazyusf/lazyusf/usf_internal.h b/Frameworks/lazyusf/lazyusf/usf_internal.h index af6a54473..2a688294f 100644 --- a/Frameworks/lazyusf/lazyusf/usf_internal.h +++ b/Frameworks/lazyusf/lazyusf/usf_internal.h @@ -1,6 +1,8 @@ #ifndef _USF_INTERNAL_H_ #define _USF_INTERNAL_H_ +#include "cpu.h" + struct usf_state_helper { size_t offset_to_structure;