Updated LazyUSF and bumped its optimization settings

CQTexperiment
Chris Moeller 2014-02-18 17:20:37 -08:00
parent 5bf11d551e
commit 34e95ff1c2
11 changed files with 366 additions and 359 deletions

View File

@ -8,27 +8,27 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
83C8B6AB18AF58080071B040 /* audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B65918AF58080071B040 /* audio.c */; }; 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, ); }; }; 83C8B6AC18AF58080071B040 /* audio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65A18AF58080071B040 /* audio.h */; };
83C8B6AD18AF58080071B040 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65B18AF58080071B040 /* config.h */; settings = {ATTRIBUTES = (Public, ); }; }; 83C8B6AD18AF58080071B040 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B65B18AF58080071B040 /* config.h */; };
83C8B6AE18AF58080071B040 /* cpu.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B65C18AF58080071B040 /* cpu.c */; }; 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 */; }; 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 */; }; 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 */; }; 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 */; }; 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 */; }; 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 */; }; 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, ); }; }; 83C8B6BB18AF58080071B040 /* memory.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66918AF58080071B040 /* memory.h */; };
83C8B6BC18AF58080071B040 /* opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66A18AF58080071B040 /* opcode.h */; settings = {ATTRIBUTES = (Public, ); }; }; 83C8B6BC18AF58080071B040 /* opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B66A18AF58080071B040 /* opcode.h */; };
83C8B6BD18AF58080071B040 /* pif.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B66B18AF58080071B040 /* pif.c */; }; 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 */; }; 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 */; }; 83C8B6C118AF58080071B040 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B67018AF58080071B040 /* config.h */; };
83C8B6C218AF58080071B040 /* execute.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B67118AF58080071B040 /* execute.h */; }; 83C8B6C218AF58080071B040 /* execute.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B67118AF58080071B040 /* execute.h */; };
83C8B6C318AF58080071B040 /* rsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B67218AF58080071B040 /* rsp.c */; }; 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 */; }; 83C8B6F118AF58090071B040 /* vsubc.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A118AF58080071B040 /* vsubc.h */; };
83C8B6F218AF58090071B040 /* vu.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A218AF58080071B040 /* vu.h */; }; 83C8B6F218AF58090071B040 /* vu.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A218AF58080071B040 /* vu.h */; };
83C8B6F318AF58090071B040 /* vxor.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A318AF58080071B040 /* vxor.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 */; }; 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, ); }; }; 83C8B6F618AF58090071B040 /* tlb.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A618AF58080071B040 /* tlb.h */; };
83C8B6F718AF58090071B040 /* types.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A718AF58080071B040 /* types.h */; settings = {ATTRIBUTES = (Public, ); }; }; 83C8B6F718AF58090071B040 /* types.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A718AF58080071B040 /* types.h */; };
83C8B6F818AF58090071B040 /* usf_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A818AF58080071B040 /* usf_internal.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 */; }; 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, ); }; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -337,6 +336,7 @@
isa = PBXHeadersBuildPhase; isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
83C8B6FA18AF58090071B040 /* usf.h in Headers */,
83C8B6AC18AF58080071B040 /* audio.h in Headers */, 83C8B6AC18AF58080071B040 /* audio.h in Headers */,
83C8B6B118AF58080071B040 /* dma.h in Headers */, 83C8B6B118AF58080071B040 /* dma.h in Headers */,
83C8B6AD18AF58080071B040 /* config.h in Headers */, 83C8B6AD18AF58080071B040 /* config.h in Headers */,
@ -352,7 +352,6 @@
83C8B6B718AF58080071B040 /* interpreter_ops.h in Headers */, 83C8B6B718AF58080071B040 /* interpreter_ops.h in Headers */,
83C8B6B318AF58080071B040 /* exception.h in Headers */, 83C8B6B318AF58080071B040 /* exception.h in Headers */,
83C8B6AF18AF58080071B040 /* cpu.h in Headers */, 83C8B6AF18AF58080071B040 /* cpu.h in Headers */,
83C8B6FA18AF58090071B040 /* usf.h in Headers */,
83C8B6F118AF58090071B040 /* vsubc.h in Headers */, 83C8B6F118AF58090071B040 /* vsubc.h in Headers */,
83C8B6F018AF58090071B040 /* vsub.h in Headers */, 83C8B6F018AF58090071B040 /* vsub.h in Headers */,
83C8B6E018AF58080071B040 /* vmudn.h in Headers */, 83C8B6E018AF58080071B040 /* vmudn.h in Headers */,
@ -459,7 +458,6 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
83C8B6FE18AF59E70071B040 /* lazyusf-Info.plist in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -568,6 +566,7 @@
"DEBUG=1", "DEBUG=1",
ARCH_MIN_SSE2, ARCH_MIN_SSE2,
); );
GCC_WARN_PEDANTIC = YES;
INFOPLIST_FILE = "lazyusf/lazyusf-Info.plist"; INFOPLIST_FILE = "lazyusf/lazyusf-Info.plist";
INSTALL_PATH = "@loader_path/../Frameworks"; INSTALL_PATH = "@loader_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@ -583,10 +582,12 @@
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;
GCC_OPTIMIZATION_LEVEL = fast;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherit)", "$(inherit)",
ARCH_MIN_SSE2, ARCH_MIN_SSE2,
); );
GCC_WARN_PEDANTIC = YES;
INFOPLIST_FILE = "lazyusf/lazyusf-Info.plist"; INFOPLIST_FILE = "lazyusf/lazyusf-Info.plist";
INSTALL_PATH = "@loader_path/../Frameworks"; INSTALL_PATH = "@loader_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@ -614,6 +615,7 @@
83C8B64C18AF57770071B040 /* Release */, 83C8B64C18AF57770071B040 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
}; };
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };

View File

@ -25,6 +25,8 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "main.h" #include "main.h"
#include "cpu.h" #include "cpu.h"
#include "usf.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) { int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1, uint32_t Reg2) {
OPCODE Command; 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; return 1;
} }
switch (Command.op) { switch (Command.u.b.op) {
case R4300i_SPECIAL: case R4300i_SPECIAL:
switch (Command.funct) { switch (Command.u.e.funct) {
case R4300i_SPECIAL_SLL: case R4300i_SPECIAL_SLL:
case R4300i_SPECIAL_SRL: case R4300i_SPECIAL_SRL:
case R4300i_SPECIAL_SRA: 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_DSLL32:
case R4300i_SPECIAL_DSRL32: case R4300i_SPECIAL_DSRL32:
case R4300i_SPECIAL_DSRA32: case R4300i_SPECIAL_DSRA32:
if (Command.rd == 0) { return 0; } if (Command.u.e.rd == 0) { return 0; }
if (Command.rd == Reg1) { return 1; } if (Command.u.e.rd == Reg1) { return 1; }
if (Command.rd == Reg2) { return 1; } if (Command.u.e.rd == Reg2) { return 1; }
break; break;
case R4300i_SPECIAL_MULT: case R4300i_SPECIAL_MULT:
case R4300i_SPECIAL_MULTU: case R4300i_SPECIAL_MULTU:
@ -169,16 +171,16 @@ int32_t DelaySlotEffectsCompare (usf_state_t * state, uint32_t PC, uint32_t Reg1
} }
break; break;
case R4300i_CP0: case R4300i_CP0:
switch (Command.rs) { switch (Command.u.b.rs) {
case R4300i_COP0_MT: break; case R4300i_COP0_MT: break;
case R4300i_COP0_MF: case R4300i_COP0_MF:
if (Command.rt == 0) { return 0; } if (Command.u.b.rt == 0) { return 0; }
if (Command.rt == Reg1) { return 1; } if (Command.u.b.rt == Reg1) { return 1; }
if (Command.rt == Reg2) { return 1; } if (Command.u.b.rt == Reg2) { return 1; }
break; break;
default: default:
if ( (Command.rs & 0x10 ) != 0 ) { if ( (Command.u.b.rs & 0x10 ) != 0 ) {
switch( state->Opcode.funct ) { switch( state->Opcode.u.e.funct ) {
case R4300i_COP0_CO_TLBR: break; case R4300i_COP0_CO_TLBR: break;
case R4300i_COP0_CO_TLBWI: break; case R4300i_COP0_CO_TLBWI: break;
case R4300i_COP0_CO_TLBWR: 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; break;
case R4300i_CP1: case R4300i_CP1:
switch (Command.fmt) { switch (Command.u.f.fmt) {
case R4300i_COP1_MF: case R4300i_COP1_MF:
if (Command.rt == 0) { return 0; } if (Command.u.b.rt == 0) { return 0; }
if (Command.rt == Reg1) { return 1; } if (Command.u.b.rt == Reg1) { return 1; }
if (Command.rt == Reg2) { return 1; } if (Command.u.b.rt == Reg2) { return 1; }
break; break;
case R4300i_COP1_CF: break; case R4300i_COP1_CF: break;
case R4300i_COP1_MT: 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_LD:
case R4300i_LWC1: case R4300i_LWC1:
case R4300i_LDC1: case R4300i_LDC1:
if (Command.rt == 0) { return 0; } if (Command.u.b.rt == 0) { return 0; }
if (Command.rt == Reg1) { return 1; } if (Command.u.b.rt == Reg1) { return 1; }
if (Command.rt == Reg2) { return 1; } if (Command.u.b.rt == Reg2) { return 1; }
break; break;
case R4300i_CACHE: break; case R4300i_CACHE: break;
case R4300i_SB: 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) { int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) {
OPCODE Command; 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: case R4300i_SPECIAL:
switch (Command.funct) { switch (Command.u.e.funct) {
case R4300i_SPECIAL_JR: return DelaySlotEffectsCompare(state,JumpPC,Command.rs,0); case R4300i_SPECIAL_JR: return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,0);
case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(state,JumpPC,Command.rs,31); case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,31);
} }
break; break;
case R4300i_REGIMM: case R4300i_REGIMM:
switch (Command.rt) { switch (Command.u.b.rt) {
case R4300i_REGIMM_BLTZ: case R4300i_REGIMM_BLTZ:
case R4300i_REGIMM_BGEZ: case R4300i_REGIMM_BGEZ:
case R4300i_REGIMM_BLTZL: case R4300i_REGIMM_BLTZL:
case R4300i_REGIMM_BGEZL: case R4300i_REGIMM_BGEZL:
case R4300i_REGIMM_BLTZAL: case R4300i_REGIMM_BLTZAL:
case R4300i_REGIMM_BGEZAL: case R4300i_REGIMM_BGEZAL:
return DelaySlotEffectsCompare(state,JumpPC,Command.rs,0); return DelaySlotEffectsCompare(state,JumpPC,Command.u.b.rs,0);
} }
break; break;
case R4300i_JAL: case R4300i_JAL:
@ -279,11 +281,11 @@ int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) {
case R4300i_BNE: case R4300i_BNE:
case R4300i_BLEZ: case R4300i_BLEZ:
case R4300i_BGTZ: 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: case R4300i_CP1:
switch (Command.fmt) { switch (Command.u.f.fmt) {
case R4300i_COP1_BC: case R4300i_COP1_BC:
switch (Command.ft) { switch (Command.u.f.ft) {
case R4300i_COP1_BC_BCF: case R4300i_COP1_BC_BCF:
case R4300i_COP1_BC_BCT: case R4300i_COP1_BC_BCT:
case R4300i_COP1_BC_BCFL: case R4300i_COP1_BC_BCFL:
@ -292,14 +294,14 @@ int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) {
int32_t EffectDelaySlot; int32_t EffectDelaySlot;
OPCODE NewCommand; 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; EffectDelaySlot = 0;
if (NewCommand.op == R4300i_CP1) { if (NewCommand.u.b.op == R4300i_CP1) {
if (NewCommand.fmt == R4300i_COP1_S && (NewCommand.funct & 0x30) == 0x30 ) { if (NewCommand.u.f.fmt == R4300i_COP1_S && (NewCommand.u.e.funct & 0x30) == 0x30 ) {
EffectDelaySlot = 1; 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; EffectDelaySlot = 1;
} }
} }
@ -314,7 +316,7 @@ int32_t DelaySlotEffectsJump (usf_state_t * state, uint32_t JumpPC) {
case R4300i_BNEL: case R4300i_BNEL:
case R4300i_BLEZL: case R4300i_BLEZL:
case R4300i_BGTZL: 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; return 1;
} }

View File

@ -23,6 +23,9 @@
* should be forwarded to them so if they want them. * should be forwarded to them so if they want them.
* *
*/ */
#include <string.h>
#include "main.h" #include "main.h"
#include "cpu.h" #include "cpu.h"

View File

@ -46,45 +46,45 @@ void (* R4300i_CoP1_W[64])(usf_state_t *);
void (* R4300i_CoP1_L[64])(usf_state_t *); void (* R4300i_CoP1_L[64])(usf_state_t *);
void R4300i_opcode_SPECIAL (usf_state_t * state) { 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_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_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_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_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_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) { void R4300i_opcode_COP1_S (usf_state_t * state) {
// controlfp(RoundingModel); // 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) { void R4300i_opcode_COP1_D (usf_state_t * state) {
// controlfp(RoundingModel); // 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_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_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 (*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); DoTLBMiss(state, state->NextInstruction == JUMP,state->PROGRAM_COUNTER);
state->NextInstruction = NORMAL; state->NextInstruction = NORMAL;
return; return;
@ -698,7 +698,7 @@ void ExecuteInterpreterOpCode (usf_state_t * state) {
RANDOM_REGISTER = 31; RANDOM_REGISTER = 31;
} }
R4300i_Opcode[ state->Opcode.op ](state); R4300i_Opcode[ state->Opcode.u.b.op ](state);
if (state->GPR[0].DW != 0) { if (state->GPR[0].DW != 0) {
state->GPR[0].DW = 0; state->GPR[0].DW = 0;

File diff suppressed because it is too large Load Diff

View File

@ -39,19 +39,19 @@ typedef struct {
unsigned rt : 5; unsigned rt : 5;
unsigned rs : 5; unsigned rs : 5;
unsigned op : 6; unsigned op : 6;
}; } b;
struct { struct {
unsigned immediate : 16; unsigned immediate : 16;
unsigned : 5; unsigned : 5;
unsigned base : 5; unsigned base : 5;
unsigned : 6; unsigned : 6;
}; } c;
struct { struct {
unsigned target : 26; unsigned target : 26;
unsigned : 6; unsigned : 6;
}; } d;
struct { struct {
unsigned funct : 6; unsigned funct : 6;
@ -60,7 +60,7 @@ typedef struct {
unsigned : 5; unsigned : 5;
unsigned : 5; unsigned : 5;
unsigned : 6; unsigned : 6;
}; } e;
struct { struct {
unsigned : 6; unsigned : 6;
@ -69,8 +69,8 @@ typedef struct {
unsigned ft : 5; unsigned ft : 5;
unsigned fmt : 5; unsigned fmt : 5;
unsigned : 6; unsigned : 6;
}; } f;
}; } u;
} OPCODE; } OPCODE;

View File

@ -24,6 +24,8 @@
* *
*/ */
#include <string.h>
#include "main.h" #include "main.h"
#include "cpu.h" #include "cpu.h"
@ -78,21 +80,21 @@ void SetupTLB_Entry (usf_state_t * state, int Entry) {
if (!state->tlb[Entry].EntryDefined) { return; } if (!state->tlb[Entry].EntryDefined) { return; }
FastIndx = Entry << 1; FastIndx = Entry << 1;
state->FastTlb[FastIndx].VSTART=state->tlb[Entry].EntryHi.VPN2 << 13; state->FastTlb[FastIndx].VSTART=state->tlb[Entry].EntryHi.b.VPN2 << 13;
state->FastTlb[FastIndx].VEND = state->FastTlb[FastIndx].VSTART + (state->tlb[Entry].PageMask.Mask << 12) + 0xFFF; state->FastTlb[FastIndx].VEND = state->FastTlb[FastIndx].VSTART + (state->tlb[Entry].PageMask.b.Mask << 12) + 0xFFF;
state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo0.PFN << 12; state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo0.b.PFN << 12;
state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo0.V; state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo0.b.V;
state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo0.D; state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo0.b.D;
state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.GLOBAL & state->tlb[Entry].EntryLo1.GLOBAL; state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.b.GLOBAL & state->tlb[Entry].EntryLo1.b.GLOBAL;
state->FastTlb[FastIndx].ValidEntry = 0; state->FastTlb[FastIndx].ValidEntry = 0;
FastIndx = (Entry << 1) + 1; 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].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.Mask << 12) + 0xFFF; state->FastTlb[FastIndx].VEND = state->FastTlb[FastIndx].VSTART + (state->tlb[Entry].PageMask.b.Mask << 12) + 0xFFF;
state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo1.PFN << 12; state->FastTlb[FastIndx].PHYSSTART = state->tlb[Entry].EntryLo1.b.PFN << 12;
state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo1.V; state->FastTlb[FastIndx].VALID = state->tlb[Entry].EntryLo1.b.V;
state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo1.D; state->FastTlb[FastIndx].DIRTY = state->tlb[Entry].EntryLo1.b.D;
state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.GLOBAL & state->tlb[Entry].EntryLo1.GLOBAL; state->FastTlb[FastIndx].GLOBAL = state->tlb[Entry].EntryLo0.b.GLOBAL & state->tlb[Entry].EntryLo1.b.GLOBAL;
state->FastTlb[FastIndx].ValidEntry = 0; state->FastTlb[FastIndx].ValidEntry = 0;
for ( FastIndx = Entry << 1; FastIndx <= (Entry << 1) + 1; FastIndx++) { for ( FastIndx = Entry << 1; FastIndx <= (Entry << 1) + 1; FastIndx++) {
@ -126,8 +128,8 @@ void TLB_Probe (usf_state_t * state) {
INDEX_REGISTER |= 0x80000000; INDEX_REGISTER |= 0x80000000;
for (Counter = 0; Counter < 32; Counter ++) { for (Counter = 0; Counter < 32; Counter ++) {
uint32_t TlbValue = state->tlb[Counter].EntryHi.Value & (~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.Mask << 13); uint32_t EntryHi = ENTRYHI_REGISTER & (~state->tlb[Counter].PageMask.b.Mask << 13);
if (TlbValue == EntryHi) { if (TlbValue == EntryHi) {
uint32_t Global = (state->tlb[Counter].EntryHi.Value & 0x100) != 0; uint32_t Global = (state->tlb[Counter].EntryHi.Value & 0x100) != 0;

View File

@ -36,7 +36,7 @@ typedef struct {
unsigned zero : 13; unsigned zero : 13;
unsigned Mask : 12; unsigned Mask : 12;
unsigned zero2 : 7; unsigned zero2 : 7;
} ; } b;
} PageMask; } PageMask;
@ -49,7 +49,7 @@ typedef struct {
unsigned Zero : 4; unsigned Zero : 4;
unsigned G : 1; unsigned G : 1;
unsigned VPN2 : 19; unsigned VPN2 : 19;
}; } b;
} EntryHi; } EntryHi;
@ -64,7 +64,7 @@ typedef struct {
unsigned C : 3; unsigned C : 3;
unsigned PFN : 20; unsigned PFN : 20;
unsigned ZERO: 6; unsigned ZERO: 6;
}; } b;
} EntryLo0; } EntryLo0;
@ -79,7 +79,7 @@ typedef struct {
unsigned C : 3; unsigned C : 3;
unsigned PFN : 20; unsigned PFN : 20;
unsigned ZERO: 6; unsigned ZERO: 6;
} ; } b;
} EntryLo1; } EntryLo1;
} TLB; } TLB;

View File

@ -1,5 +1,6 @@
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "usf.h" #include "usf.h"
#include "cpu.h" #include "cpu.h"
@ -218,6 +219,8 @@ void usf_restart(void * state)
{ {
if ( USF_STATE->MemoryState ) if ( USF_STATE->MemoryState )
StartEmulationFromSave(USF_STATE, USF_STATE->savestatespace); StartEmulationFromSave(USF_STATE, USF_STATE->savestatespace);
USF_STATE->samples_in_buffer = 0;
} }
void usf_shutdown(void * state) void usf_shutdown(void * state)

View File

@ -3,20 +3,13 @@
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
typedef struct usf_state usf_state_t; typedef struct usf_state usf_state_t;
typedef struct usf_state_helper usf_state_helper_t; typedef struct usf_state_helper usf_state_helper_t;
#include "usf.h"
#include "cpu.h"
#include "memory.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,6 +1,8 @@
#ifndef _USF_INTERNAL_H_ #ifndef _USF_INTERNAL_H_
#define _USF_INTERNAL_H_ #define _USF_INTERNAL_H_
#include "cpu.h"
struct usf_state_helper struct usf_state_helper
{ {
size_t offset_to_structure; size_t offset_to_structure;