diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index f5cceed009..c21f96a204 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -121,7 +121,8 @@ static __forceinline void cpuRcntSet() if( nextCounter < 0 ) nextCounter = 0; } -void rcntInit() { +void rcntInit() +{ int i; memzero(counters); @@ -140,7 +141,8 @@ void rcntInit() { vsyncCounter.Mode = MODE_VRENDER; vsyncCounter.sCycle = cpuRegs.cycle; - UpdateVSyncRate(); + // Set the video mode to user's default request: + gsSetRegionMode( (GS_RegionMode)EmuConfig.GS.DefaultRegionMode ); for (i=0; i<4; i++) rcntReset(i); cpuRcntSet(); diff --git a/pcsx2/Interpreter.cpp b/pcsx2/Interpreter.cpp index 8ba6a727ef..0ac11c2daa 100644 --- a/pcsx2/Interpreter.cpp +++ b/pcsx2/Interpreter.cpp @@ -388,6 +388,30 @@ static void intExecute() } catch( Exception::ExitCpuExecute& ) { } } +static void intExecuteBiosStub() +{ + Console.WriteLn( Color_StrongGreen, "(R5900-Interp) Executing Bios Stub..." ); + while( (cpuRegs.pc != 0x00200008) && (cpuRegs.pc != 0x00100008) ) { + execI(); + } + + // ... some maual bios injection hack from a century ago, me thinks. Leaving the + // code intact for posterity. --air + + // { + // FILE* f = fopen("eebios.bin", "wb"); + // fwrite(PSM(0x80000000), 0x100000, 1, f); + // fclose(f); + // exit(0); + + // f = fopen("iopbios.bin", "wb"); + // fwrite(PS2MEM_PSX, 0x80000, 1, f); + // fclose(f); + // } + + Console.WriteLn( Color_StrongGreen, "(R5900-Interp) Execute Bios Stub Complete"); +} + static void intCheckExecutionState() { if( GetCoreThread().HasPendingStateChangeRequest() ) @@ -415,6 +439,7 @@ R5900cpu intCpu = intReset, intStep, intExecute, + intExecuteBiosStub, intCheckExecutionState, intClear, diff --git a/pcsx2/R5900.cpp b/pcsx2/R5900.cpp index 9c44bed69d..489a72a610 100644 --- a/pcsx2/R5900.cpp +++ b/pcsx2/R5900.cpp @@ -59,12 +59,12 @@ void cpuReset() memzero(fpuRegs); memzero(tlb); - cpuRegs.pc = 0xbfc00000; ///set pc reg to stack - cpuRegs.CP0.n.Config = 0x440; - cpuRegs.CP0.n.Status.val = 0x70400004; //0x10900000 <-- wrong; // COP0 enabled | BEV = 1 | TS = 1 - cpuRegs.CP0.n.PRid = 0x00002e20; // PRevID = Revision ID, same as R5900 - fpuRegs.fprc[0] = 0x00002e00; // fpu Revision.. - fpuRegs.fprc[31] = 0x01000001; // fpu Status/Control + cpuRegs.pc = 0xbfc00000; //set pc reg to stack + cpuRegs.CP0.n.Config = 0x440; + cpuRegs.CP0.n.Status.val= 0x70400004; //0x10900000 <-- wrong; // COP0 enabled | BEV = 1 | TS = 1 + cpuRegs.CP0.n.PRid = 0x00002e20; // PRevID = Revision ID, same as R5900 + fpuRegs.fprc[0] = 0x00002e00; // fpu Revision.. + fpuRegs.fprc[31] = 0x01000001; // fpu Status/Control g_nextBranchCycle = cpuRegs.cycle + 4; EEsCycle = 0; @@ -533,54 +533,6 @@ __forceinline void cpuTestHwInts() { cpuTestTIMRInts(); } -// This function performs a "hackish" execution of the BIOS stub, which initializes EE -// memory and hardware. It forcefully breaks execution when the stub is finished, prior -// to the PS2 logos being displayed. This allows us to "shortcut" right into a game -// without having to wait through the logos or endure game/bios localization checks. -// -// Use of this function must be followed by the proper injection of the elf header's code -// execution entry point into cpuRegs.pc. Failure to modify cpuRegs.pc will result in the -// bios continuing its normal unimpeeded splashscreen execution. -// -void cpuExecuteBios() -{ - // Set the video mode to user's default request: - gsSetRegionMode( (GS_RegionMode)EmuConfig.GS.DefaultRegionMode ); - - Console.WriteLn( "Executing Bios Stub..." ); - - g_ExecBiosHack = true; - while( cpuRegs.pc != 0x00200008 && - cpuRegs.pc != 0x00100008 ) - { - Cpu->Execute(); - } - g_ExecBiosHack = false; - -// { -// FILE* f = fopen("eebios.bin", "wb"); -// fwrite(PSM(0x80000000), 0x100000, 1, f); -// fclose(f); -// exit(0); - -// f = fopen("iopbios.bin", "wb"); -// fwrite(PS2MEM_PSX, 0x80000, 1, f); -// fclose(f); -// } - -// REC_CLEARM(0x00200008); -// REC_CLEARM(0x00100008); -// REC_CLEARM(cpuRegs.pc); - - // Reset the EErecs here, because the bios generates "slow" blocks that have - // g_ExecBiosHack checks in them. This deletes them so that the recs replace them - // with new faster versions: - Cpu->Reset(); - - Console.Warning("Execute Bios Stub Complete"); - //GSprintf(5, "PCSX2 " PCSX2_VERSION "\nExecuteBios Complete\n"); -} - __forceinline void CPU_INT( u32 n, s32 ecycle) { if( n != 2 && cpuRegs.interrupt & (1<ExecuteBiosStub(); loadElfFile( elf_file ); } diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 3bd37c096d..b1441f63f4 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -28,8 +28,8 @@ #include "System/SysThreads.h" #include "GS.h" -#ifdef __LINUX__ -#include +#if !PCSX2_SEH +# include #endif using namespace x86Emitter; @@ -38,8 +38,8 @@ using namespace R5900; #define PC_GETBLOCK(x) PC_GETBLOCK_(x, recLUT) u32 maxrecmem = 0; -static uptr recLUT[0x10000]; -static uptr hwLUT[0x10000]; +static __aligned16 uptr recLUT[0x10000]; +static __aligned16 uptr hwLUT[0x10000]; #define HWADDR(mem) (hwLUT[mem >> 16] + (mem)) @@ -731,6 +731,26 @@ static void recExecute() #endif } +static void recExecuteBiosStub() +{ + Console.WriteLn( Color_StrongGreen, "(R5900-32) Executing Bios Stub..." ); + g_ExecBiosHack = true; + + recExecute(); + pxAssertDev( cpuRegs.pc == 0x00200008 || cpuRegs.pc == 0x00100008, + "Bios stub execution terminated on an abnormal address." + ); + + g_ExecBiosHack = false; + Console.WriteLn( Color_StrongGreen, "(R5900-32) Execute Bios Stub Complete"); + + // Reset the EErecs here, because the bios generates "slow" blocks that have + // g_ExecBiosHack checks in them. This deletes them so that the recs replace them + // with new faster versions: + recResetEE(); +} + + //////////////////////////////////////////////////// void R5900::Dynarec::OpcodeImpl::recSYSCALL( void ) { @@ -1721,7 +1741,8 @@ R5900cpu recCpu = recResetEE, recStep, recExecute, - + recExecuteBiosStub, + recCheckExecutionState, recClear, };