2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-02-09 21:15:56 +00:00
|
|
|
*/
|
|
|
|
|
2009-09-08 12:08:10 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
#include "PrecompiledHeader.h"
|
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
#include "Counters.h"
|
|
|
|
|
|
|
|
#include "Memory.h"
|
|
|
|
#include "Hw.h"
|
|
|
|
#include "DebugTools/Debug.h"
|
|
|
|
#include "R3000A.h"
|
|
|
|
#include "VUmicro.h"
|
|
|
|
#include "COP0.h"
|
|
|
|
|
|
|
|
#include "GS.h"
|
2009-08-25 09:19:45 +00:00
|
|
|
#include "Gif.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
#include "IPU/IPU.h"
|
|
|
|
#include "Vif.h"
|
|
|
|
#include "VifDma.h"
|
|
|
|
#include "SPR.h"
|
|
|
|
#include "Sif.h"
|
|
|
|
|
2009-10-23 20:24:59 +00:00
|
|
|
#include "System/SysThreads.h"
|
|
|
|
|
2009-03-01 21:49:17 +00:00
|
|
|
#include "R5900Exceptions.h"
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
using namespace R5900; // for R5900 disasm tools
|
|
|
|
|
|
|
|
s32 EEsCycle; // used to sync the IOP to the EE
|
|
|
|
u32 EEoCycle;
|
|
|
|
|
2009-10-05 02:15:49 +00:00
|
|
|
__aligned16 cpuRegisters cpuRegs;
|
|
|
|
__aligned16 fpuRegisters fpuRegs;
|
|
|
|
__aligned16 tlbs tlb[48];
|
2009-02-09 21:15:56 +00:00
|
|
|
R5900cpu *Cpu = NULL;
|
|
|
|
|
2009-08-15 06:17:43 +00:00
|
|
|
bool g_ExecBiosHack = false; // set if the BIOS has already been executed
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
static bool cpuIsInitialized = false;
|
2009-07-11 15:43:28 +00:00
|
|
|
static const uint eeWaitCycles = 3072;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
bool eeEventTestIsActive = false;
|
|
|
|
|
2009-03-01 22:12:19 +00:00
|
|
|
R5900Exception::BaseExcept::~BaseExcept() throw (){}
|
2009-03-01 21:49:17 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
void cpuReset()
|
|
|
|
{
|
User Interface:
* Fixed and added better Emulation/System menu updating. Suspend/Resume is more consistent, and Reset grays itself out after being used.
* Entering plugin configurations auto-suspends the emulator.
* Changing plugins in the Configuration PAnel takes effect now without a restart.
* Added preliminary support for an ExtensibleConfirmation Dialog box (contains a sizer you can add content to, and also has an optional "[x] Do not show this again" checkbox).
Bugfixes:
* Added some mutex protection to cdvdNewDiskCB; "just in case."
* Resolved several recursion and deadlock scenarios when (very!) rapidly suspending, resuming, and resetting the emu.
Developments / Code Cleanups:
* Renamed SysCoreThread ExecutionModes: Suspend/Resume are now Opened/Closed (which more accurately reflects the fact they opena nd close the plugins, and helps avoid ambiguity with the "Paused" state).
* Added Exception::ThreadTimedOut, which is now thrown from Semaphore::Wait when recursive wxApp::Yield() calls are detected, and a deadlock occurs (basically cancels the current action which, most of the time, allows for full recovery).
* Major Threading namespace cleanups, documentations, etc.
* Removed wxScopedArray (scopedarray.h) and replaced it with a better implemeneted ScopedArray class.
* Removed toUTF8 class, which I only added a couple weeks ago because I didn't realize wxCharBuffer had an implicit typecast to (char*).
* Implemented more Source/Listener events for Pcsx2App. CoreThread events are sourced properly now, and added SettingsApplied and SettingsLoadSave Sources.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2010 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-16 03:58:29 +00:00
|
|
|
if( mtgsThread.IsOpen() )
|
|
|
|
mtgsThread.WaitGS(); // GS better be done processing before we reset the EE, just in case.
|
2009-10-09 15:17:53 +00:00
|
|
|
|
2009-10-23 20:24:59 +00:00
|
|
|
SysClearExecutionCache();
|
|
|
|
|
2009-03-04 11:33:45 +00:00
|
|
|
cpuIsInitialized = true;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
memReset();
|
|
|
|
psxMemReset();
|
|
|
|
vuMicroMemReset();
|
|
|
|
|
2009-09-23 12:53:32 +00:00
|
|
|
memzero(cpuRegs);
|
|
|
|
memzero(fpuRegs);
|
|
|
|
memzero(tlb);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
EEoCycle = cpuRegs.cycle;
|
|
|
|
|
|
|
|
hwReset();
|
|
|
|
vif0Reset();
|
2009-03-20 01:26:38 +00:00
|
|
|
vif1Reset();
|
2009-02-09 21:15:56 +00:00
|
|
|
rcntInit();
|
|
|
|
psxReset();
|
|
|
|
}
|
|
|
|
|
2009-04-08 17:15:51 +00:00
|
|
|
__releaseinline void cpuException(u32 code, u32 bd)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
cpuRegs.branch = 0; // Tells the interpreter that an exception occurred during a branch.
|
2009-03-20 01:26:38 +00:00
|
|
|
bool errLevel2, checkStatus;
|
2009-02-09 21:15:56 +00:00
|
|
|
u32 offset;
|
|
|
|
cpuRegs.CP0.n.Cause = code & 0xffff;
|
|
|
|
|
2009-03-20 01:26:38 +00:00
|
|
|
if(cpuRegs.CP0.n.Status.b.ERL == 0)
|
|
|
|
{
|
|
|
|
//Error Level 0-1
|
|
|
|
errLevel2 = FALSE;
|
|
|
|
checkStatus = (cpuRegs.CP0.n.Status.b.BEV == 0); // for TLB/general exceptions
|
|
|
|
|
|
|
|
if (((code & 0x7C) >= 0x8) && ((code & 0x7C) <= 0xC))
|
|
|
|
offset = 0x0; //TLB Refill
|
|
|
|
else if ((code & 0x7C) == 0x0)
|
|
|
|
offset = 0x200; //Interrupt
|
|
|
|
else
|
|
|
|
offset = 0x180; // Everything else
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Error Level 2
|
|
|
|
errLevel2 = TRUE;
|
|
|
|
checkStatus = (cpuRegs.CP0.n.Status.b.DEV == 0); // for perf/debug exceptions
|
2009-02-09 21:15:56 +00:00
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Error("*PCSX2* FIX ME: Level 2 cpuException");
|
2009-03-20 01:26:38 +00:00
|
|
|
if ((code & 0x38000) <= 0x8000 )
|
|
|
|
{
|
|
|
|
//Reset / NMI
|
2009-02-09 21:15:56 +00:00
|
|
|
cpuRegs.pc = 0xBFC00000;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Notice("Reset request");
|
2009-02-09 21:15:56 +00:00
|
|
|
UpdateCP0Status();
|
|
|
|
return;
|
2009-03-20 01:26:38 +00:00
|
|
|
}
|
|
|
|
else if((code & 0x38000) == 0x10000)
|
|
|
|
offset = 0x80; //Performance Counter
|
|
|
|
else if((code & 0x38000) == 0x18000)
|
|
|
|
offset = 0x100; //Debug
|
|
|
|
else
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Error("Unknown Level 2 Exception!! Cause %x", code);
|
2009-03-20 01:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cpuRegs.CP0.n.Status.b.EXL == 0)
|
|
|
|
{
|
|
|
|
cpuRegs.CP0.n.Status.b.EXL = 1;
|
|
|
|
if (bd)
|
|
|
|
{
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Notice("branch delay!!");
|
2009-03-20 01:26:38 +00:00
|
|
|
cpuRegs.CP0.n.EPC = cpuRegs.pc - 4;
|
|
|
|
cpuRegs.CP0.n.Cause |= 0x80000000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cpuRegs.CP0.n.EPC = cpuRegs.pc;
|
|
|
|
cpuRegs.CP0.n.Cause &= ~0x80000000;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-03-20 01:26:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offset = 0x180; //Override the cause
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
if (errLevel2) Console.Notice("cpuException: Status.EXL = 1 cause %x", code);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-03-20 01:26:38 +00:00
|
|
|
|
|
|
|
if (checkStatus)
|
|
|
|
cpuRegs.pc = 0x80000000 + offset;
|
|
|
|
else
|
|
|
|
cpuRegs.pc = 0xBFC00200 + offset;
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
UpdateCP0Status();
|
|
|
|
}
|
|
|
|
|
2009-03-20 01:26:38 +00:00
|
|
|
void cpuTlbMiss(u32 addr, u32 bd, u32 excode)
|
|
|
|
{
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Error("cpuTlbMiss pc:%x, cycl:%x, addr: %x, status=%x, code=%x",
|
2009-09-08 05:37:40 +00:00
|
|
|
cpuRegs.pc, cpuRegs.cycle, addr, cpuRegs.CP0.n.Status.val, excode);
|
2009-02-27 01:43:43 +00:00
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
if (bd) Console.Notice("branch delay!!");
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-03-20 01:26:38 +00:00
|
|
|
assert(0); // temporary
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
cpuRegs.CP0.n.BadVAddr = addr;
|
|
|
|
cpuRegs.CP0.n.Context &= 0xFF80000F;
|
|
|
|
cpuRegs.CP0.n.Context |= (addr >> 9) & 0x007FFFF0;
|
|
|
|
cpuRegs.CP0.n.EntryHi = (addr & 0xFFFFE000) | (cpuRegs.CP0.n.EntryHi & 0x1FFF);
|
|
|
|
|
|
|
|
cpuRegs.CP0.n.Cause = excode;
|
|
|
|
if (!(cpuRegs.CP0.n.Status.val & 0x2)) { // EXL bit
|
|
|
|
cpuRegs.CP0.n.EPC = cpuRegs.pc - 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cpuRegs.CP0.n.Status.val & 0x1) == 0) {
|
|
|
|
cpuRegs.pc = 0x80000000;
|
|
|
|
} else {
|
|
|
|
cpuRegs.pc = 0x80000180;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpuRegs.CP0.n.Status.b.EXL = 1;
|
|
|
|
UpdateCP0Status();
|
|
|
|
// Log=1; varLog|= 0x40000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cpuTlbMissR(u32 addr, u32 bd) {
|
|
|
|
cpuTlbMiss(addr, bd, EXC_CODE_TLBL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cpuTlbMissW(u32 addr, u32 bd) {
|
|
|
|
cpuTlbMiss(addr, bd, EXC_CODE_TLBS);
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline void _cpuTestMissingINTC() {
|
|
|
|
if (cpuRegs.CP0.n.Status.val & 0x400 &&
|
|
|
|
psHu32(INTC_STAT) & psHu32(INTC_MASK)) {
|
|
|
|
if ((cpuRegs.interrupt & (1 << 30)) == 0) {
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Error("*PCSX2*: Error, missing INTC Interrupt");
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline void _cpuTestMissingDMAC() {
|
|
|
|
if (cpuRegs.CP0.n.Status.val & 0x800 &&
|
|
|
|
(psHu16(0xe012) & psHu16(0xe010) ||
|
|
|
|
psHu16(0xe010) & 0x8000)) {
|
|
|
|
if ((cpuRegs.interrupt & (1 << 31)) == 0) {
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Error("*PCSX2*: Error, missing DMAC Interrupt");
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cpuTestMissingHwInts() {
|
|
|
|
if ((cpuRegs.CP0.n.Status.val & 0x10007) == 0x10001) {
|
|
|
|
_cpuTestMissingINTC();
|
|
|
|
_cpuTestMissingDMAC();
|
|
|
|
// _cpuTestTIMR();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// sets a branch test to occur some time from an arbitrary starting point.
|
2009-04-08 17:15:51 +00:00
|
|
|
__forceinline void cpuSetNextBranch( u32 startCycle, s32 delta )
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
// typecast the conditional to signed so that things don't blow up
|
|
|
|
// if startCycle is greater than our next branch cycle.
|
|
|
|
|
|
|
|
if( (int)(g_nextBranchCycle - startCycle) > delta )
|
|
|
|
{
|
|
|
|
g_nextBranchCycle = startCycle + delta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// sets a branch to occur some time from the current cycle
|
2009-04-08 17:15:51 +00:00
|
|
|
__forceinline void cpuSetNextBranchDelta( s32 delta )
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-04-08 17:15:51 +00:00
|
|
|
cpuSetNextBranch( cpuRegs.cycle, delta );
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// tests the cpu cycle agaisnt the given start and delta values.
|
|
|
|
// Returns true if the delta time has passed.
|
2009-04-08 17:15:51 +00:00
|
|
|
__forceinline int cpuTestCycle( u32 startCycle, s32 delta )
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
// typecast the conditional to signed so that things don't explode
|
|
|
|
// if the startCycle is ahead of our current cpu cycle.
|
|
|
|
|
|
|
|
return (int)(cpuRegs.cycle - startCycle) >= delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
// tells the EE to run the branch test the next time it gets a chance.
|
|
|
|
__forceinline void cpuSetBranch()
|
|
|
|
{
|
|
|
|
g_nextBranchCycle = cpuRegs.cycle;
|
|
|
|
}
|
|
|
|
|
2009-04-08 17:15:51 +00:00
|
|
|
__forceinline void cpuClearInt( uint i )
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
jASSUME( i < 32 );
|
|
|
|
cpuRegs.interrupt &= ~(1 << i);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __forceinline void TESTINT( u8 n, void (*callback)() )
|
|
|
|
{
|
|
|
|
if( !(cpuRegs.interrupt & (1 << n)) ) return;
|
|
|
|
|
|
|
|
if( cpuTestCycle( cpuRegs.sCycle[n], cpuRegs.eCycle[n] ) )
|
|
|
|
{
|
|
|
|
cpuClearInt( n );
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cpuSetNextBranch( cpuRegs.sCycle[n], cpuRegs.eCycle[n] );
|
|
|
|
}
|
|
|
|
|
|
|
|
static __forceinline void _cpuTestInterrupts()
|
|
|
|
{
|
|
|
|
/* These are 'pcsx2 interrupts', they handle asynchronous stuff
|
|
|
|
that depends on the cycle timings */
|
|
|
|
|
|
|
|
TESTINT(1, vif1Interrupt);
|
|
|
|
TESTINT(2, gsInterrupt);
|
|
|
|
TESTINT(5, EEsif0Interrupt);
|
|
|
|
TESTINT(6, EEsif1Interrupt);
|
|
|
|
|
|
|
|
// Profile-guided Optimization (sorta)
|
|
|
|
// The following ints are rarely called. Encasing them in a conditional
|
|
|
|
// as follows helps speed up most games.
|
|
|
|
|
|
|
|
if( cpuRegs.interrupt & ( 1 | (3 << 3) | (3<<8) | (3<<10)) )
|
|
|
|
{
|
|
|
|
TESTINT(0, vif0Interrupt);
|
|
|
|
#ifndef IPU_INLINE_IRQS
|
|
|
|
TESTINT(3, ipu0Interrupt);
|
|
|
|
TESTINT(4, ipu1Interrupt);
|
|
|
|
#endif
|
|
|
|
TESTINT(8, SPRFROMinterrupt);
|
|
|
|
TESTINT(9, SPRTOinterrupt);
|
|
|
|
|
|
|
|
TESTINT(10, vifMFIFOInterrupt);
|
|
|
|
TESTINT(11, gifMFIFOInterrupt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static __forceinline void _cpuTestTIMR()
|
|
|
|
{
|
|
|
|
cpuRegs.CP0.n.Count += cpuRegs.cycle-s_iLastCOP0Cycle;
|
|
|
|
s_iLastCOP0Cycle = cpuRegs.cycle;
|
|
|
|
|
|
|
|
// fixme: this looks like a hack to make up for the fact that the TIMR
|
|
|
|
// doesn't yet have a proper mechanism for setting itself up on a nextBranchCycle.
|
|
|
|
// A proper fix would schedule the TIMR to trigger at a specific cycle anytime
|
|
|
|
// the Count or Compare registers are modified.
|
|
|
|
|
|
|
|
if ( (cpuRegs.CP0.n.Status.val & 0x8000) &&
|
|
|
|
cpuRegs.CP0.n.Count >= cpuRegs.CP0.n.Compare && cpuRegs.CP0.n.Count < cpuRegs.CP0.n.Compare+1000 )
|
|
|
|
{
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Status("timr intr: %x, %x", cpuRegs.CP0.n.Count, cpuRegs.CP0.n.Compare);
|
2009-02-09 21:15:56 +00:00
|
|
|
cpuException(0x808000, cpuRegs.branch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static __forceinline void _cpuTestPERF()
|
|
|
|
{
|
2009-03-10 19:21:54 +00:00
|
|
|
// Perfs are updated when read by games (COP0's MFC0/MTC0 instructions), so we need
|
|
|
|
// only update them at semi-regular intervals to keep cpuRegs.cycle from wrapping
|
|
|
|
// around twice on us btween updates. Hence this function is called from the cpu's
|
|
|
|
// Counters update.
|
|
|
|
|
2009-03-11 19:08:08 +00:00
|
|
|
COP0_UpdatePCCR();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Checks the COP0.Status for exception enablings.
|
|
|
|
// Exception handling for certain modes is *not* currently supported, this function filters
|
|
|
|
// them out. Exceptions while the exception handler is active (EIE), or exceptions of any
|
|
|
|
// level other than 0 are ignored here.
|
|
|
|
|
|
|
|
static bool cpuIntsEnabled()
|
|
|
|
{
|
|
|
|
return cpuRegs.CP0.n.Status.b.EIE && cpuRegs.CP0.n.Status.b.IE &&
|
|
|
|
!cpuRegs.CP0.n.Status.b.EXL && (cpuRegs.CP0.n.Status.b.ERL == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if cpuRegs.cycle is greater than this cycle, should check cpuBranchTest for updates
|
|
|
|
u32 g_nextBranchCycle = 0;
|
|
|
|
|
|
|
|
// Shared portion of the branch test, called from both the Interpreter
|
|
|
|
// and the recompiler. (moved here to help alleviate redundant code)
|
2009-08-25 15:38:48 +00:00
|
|
|
__forceinline void _cpuBranchTest_Shared()
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
eeEventTestIsActive = true;
|
|
|
|
g_nextBranchCycle = cpuRegs.cycle + eeWaitCycles;
|
|
|
|
|
|
|
|
// ---- Counters -------------
|
2009-08-31 03:47:05 +00:00
|
|
|
// Important: the vsync counter must be the first to be checked. It includes emulation
|
|
|
|
// escape/suspend hooks, and it's really a good idea to suspend/resume emulation before
|
|
|
|
// doing any actual meaninful branchtest logic.
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
if( cpuTestCycle( nextsCounter, nextCounter ) )
|
|
|
|
{
|
2009-08-25 15:38:48 +00:00
|
|
|
rcntUpdate();
|
2009-02-09 21:15:56 +00:00
|
|
|
_cpuTestPERF();
|
|
|
|
}
|
|
|
|
|
2009-08-31 03:47:05 +00:00
|
|
|
rcntUpdate_hScanline();
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
_cpuTestTIMR();
|
|
|
|
|
|
|
|
// ---- Interrupts -------------
|
|
|
|
// Handles all interrupts except 30 and 31, which are handled later.
|
|
|
|
|
|
|
|
if( cpuRegs.interrupt & ~(3<<30) )
|
|
|
|
_cpuTestInterrupts();
|
|
|
|
|
|
|
|
// ---- IOP -------------
|
|
|
|
// * It's important to run a psxBranchTest before calling ExecuteBlock. This
|
|
|
|
// is because the IOP does not always perform branch tests before returning
|
|
|
|
// (during the prev branch) and also so it can act on the state the EE has
|
|
|
|
// given it before executing any code.
|
|
|
|
//
|
|
|
|
// * The IOP cannot always be run. If we run IOP code every time through the
|
|
|
|
// cpuBranchTest, the IOP generally starts to run way ahead of the EE.
|
|
|
|
|
2009-08-31 03:47:05 +00:00
|
|
|
EEsCycle += cpuRegs.cycle - EEoCycle;
|
|
|
|
EEoCycle = cpuRegs.cycle;
|
|
|
|
|
|
|
|
if( EEsCycle > 0 )
|
|
|
|
iopBranchAction = true;
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
psxBranchTest();
|
|
|
|
|
|
|
|
if( iopBranchAction )
|
|
|
|
{
|
|
|
|
//if( EEsCycle < -450 )
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
// Console.WriteLn( " IOP ahead by: %d cycles", -EEsCycle );
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
// Experimental and Probably Unnecessry Logic -->
|
|
|
|
// Check if the EE already has an exception pending, and if so we shouldn't
|
|
|
|
// waste too much time updating the IOP. Theory being that the EE and IOP should
|
|
|
|
// run closely in sync during raised exception events. But in practice it didn't
|
|
|
|
// seem to make much of a difference.
|
|
|
|
|
|
|
|
// Note: The IOP is very good about chaining blocks together so it tends to
|
|
|
|
// run lots of cycles, even with only 32 (4 IOP) cycles specified here. That's
|
|
|
|
// probably why it doesn't improve sync much.
|
|
|
|
|
|
|
|
/*bool eeExceptPending = cpuIntsEnabled() &&
|
|
|
|
//( cpuRegs.CP0.n.Status.b.EIE && cpuRegs.CP0.n.Status.b.IE && (cpuRegs.CP0.n.Status.b.ERL == 0) ) &&
|
|
|
|
//( (cpuRegs.CP0.n.Status.val & 0x10007) == 0x10001 ) &&
|
|
|
|
( (cpuRegs.interrupt & (3<<30)) != 0 );
|
|
|
|
|
|
|
|
if( eeExceptPending )
|
|
|
|
{
|
|
|
|
// ExecuteBlock returns a negative value, so subtract it from the cycle count
|
|
|
|
// specified to get the total cycles processed! :D
|
|
|
|
int cycleCount = std::min( EEsCycle, (s32)(eeWaitCycles>>4) );
|
|
|
|
int cyclesRun = cycleCount - psxCpu->ExecuteBlock( cycleCount );
|
|
|
|
EEsCycle -= cyclesRun;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
//Console.Notice( "IOP Exception-Pending Execution -- EEsCycle: %d", EEsCycle );
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
else*/
|
|
|
|
{
|
|
|
|
EEsCycle = psxCpu->ExecuteBlock( EEsCycle );
|
|
|
|
}
|
|
|
|
|
|
|
|
iopBranchAction = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---- VU0 -------------
|
|
|
|
|
|
|
|
if (VU0.VI[REG_VPU_STAT].UL & 0x1)
|
|
|
|
{
|
|
|
|
// We're in a BranchTest. All dynarec registers are flushed
|
|
|
|
// so there is no need to freeze registers here.
|
|
|
|
CpuVU0.ExecuteBlock();
|
|
|
|
|
|
|
|
// This might be needed to keep the EE and VU0 in sync.
|
|
|
|
// A better fix will require hefty changes to the VU recs. -_-
|
|
|
|
if(VU0.VI[REG_VPU_STAT].UL & 0x1)
|
|
|
|
cpuSetNextBranchDelta( 768 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: We don't update the VU1 here because it runs it's micro-programs in
|
|
|
|
// one shot always. That is, when a program is executed the VU1 doesn't even
|
|
|
|
// bother to return until the program is completely finished.
|
|
|
|
|
|
|
|
// ---- Schedule Next Event Test --------------
|
|
|
|
|
|
|
|
if( EEsCycle > 192 )
|
|
|
|
{
|
|
|
|
// EE's running way ahead of the IOP still, so we should branch quickly to give the
|
|
|
|
// IOP extra timeslices in short order.
|
|
|
|
|
|
|
|
cpuSetNextBranchDelta( 48 );
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
//Console.Notice( "EE ahead of the IOP -- Rapid Branch! %d", EEsCycle );
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The IOP could be running ahead/behind of us, so adjust the iop's next branch by its
|
|
|
|
// relative position to the EE (via EEsCycle)
|
|
|
|
cpuSetNextBranchDelta( ((g_psxNextBranchCycle-psxRegs.cycle)*8) - EEsCycle );
|
|
|
|
|
|
|
|
// Apply the hsync counter's nextCycle
|
2009-03-19 04:16:24 +00:00
|
|
|
cpuSetNextBranch( hsyncCounter.sCycle, hsyncCounter.CycleT );
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
// Apply vsync and other counter nextCycles
|
|
|
|
cpuSetNextBranch( nextsCounter, nextCounter );
|
|
|
|
|
|
|
|
eeEventTestIsActive = false;
|
|
|
|
|
|
|
|
// ---- INTC / DMAC Exceptions -----------------
|
|
|
|
// Raise the INTC and DMAC interrupts here, which usually throw exceptions.
|
|
|
|
// This should be done last since the IOP and the VU0 can raise several EE
|
|
|
|
// exceptions.
|
|
|
|
|
|
|
|
//if ((cpuRegs.CP0.n.Status.val & 0x10007) == 0x10001)
|
|
|
|
if( cpuIntsEnabled() )
|
|
|
|
{
|
|
|
|
TESTINT(30, intcInterrupt);
|
|
|
|
TESTINT(31, dmacInterrupt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-31 15:06:27 +00:00
|
|
|
__releaseinline void cpuTestINTCInts()
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
if( cpuRegs.interrupt & (1 << 30) ) return;
|
|
|
|
//if( (cpuRegs.CP0.n.Status.val & 0x10407) != 0x10401 ) return;
|
|
|
|
if( !cpuIntsEnabled() ) return;
|
|
|
|
if( (psHu32(INTC_STAT) & psHu32(INTC_MASK)) == 0 ) return;
|
|
|
|
|
|
|
|
cpuRegs.interrupt|= 1 << 30;
|
|
|
|
cpuRegs.sCycle[30] = cpuRegs.cycle;
|
2009-02-09 22:13:22 +00:00
|
|
|
cpuRegs.eCycle[30] = 4; //Needs to be 4 to account for bus delays/pipelines etc
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
// only set the next branch delta if the exception won't be handled for
|
|
|
|
// the current branch...
|
|
|
|
if( !eeEventTestIsActive )
|
|
|
|
cpuSetNextBranchDelta( 4 );
|
|
|
|
else if(psxCycleEE > 0)
|
|
|
|
{
|
|
|
|
psxBreak += psxCycleEE; // record the number of cycles the IOP didn't run.
|
|
|
|
psxCycleEE = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline void cpuTestDMACInts()
|
|
|
|
{
|
|
|
|
if ( cpuRegs.interrupt & (1 << 31) ) return;
|
|
|
|
if ((cpuRegs.CP0.n.Status.val & 0x10807) != 0x10801) return;
|
|
|
|
|
|
|
|
if ( ( (psHu16(0xe012) & psHu16(0xe010)) == 0) &&
|
|
|
|
( (psHu16(0xe010) & 0x8000) == 0) ) return;
|
|
|
|
|
|
|
|
cpuRegs.interrupt|= 1 << 31;
|
|
|
|
cpuRegs.sCycle[31] = cpuRegs.cycle;
|
2009-02-09 22:13:22 +00:00
|
|
|
cpuRegs.eCycle[31] = 4; //Needs to be 4 to account for bus delays/pipelines etc
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
// only set the next branch delta if the exception won't be handled for
|
|
|
|
// the current branch...
|
|
|
|
if( !eeEventTestIsActive )
|
|
|
|
cpuSetNextBranchDelta( 4 );
|
|
|
|
else if(psxCycleEE > 0)
|
|
|
|
{
|
|
|
|
psxBreak += psxCycleEE; // record the number of cycles the IOP didn't run.
|
|
|
|
psxCycleEE = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline void cpuTestTIMRInts() {
|
|
|
|
if ((cpuRegs.CP0.n.Status.val & 0x10007) == 0x10001) {
|
|
|
|
_cpuTestPERF();
|
|
|
|
_cpuTestTIMR();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-31 15:06:27 +00:00
|
|
|
__forceinline void cpuTestHwInts() {
|
2009-02-09 21:15:56 +00:00
|
|
|
cpuTestINTCInts();
|
|
|
|
cpuTestDMACInts();
|
|
|
|
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.
|
2009-08-15 06:17:43 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
void cpuExecuteBios()
|
|
|
|
{
|
|
|
|
// Set the video mode to user's default request:
|
2009-08-04 08:21:10 +00:00
|
|
|
gsSetRegionMode( (GS_RegionMode)EmuConfig.Video.DefaultRegionMode );
|
2009-02-09 21:15:56 +00:00
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Status( "Executing Bios Stub..." );
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-08-15 06:17:43 +00:00
|
|
|
g_ExecBiosHack = true;
|
|
|
|
while( cpuRegs.pc != 0x00200008 &&
|
|
|
|
cpuRegs.pc != 0x00100008 )
|
|
|
|
{
|
2009-08-25 15:38:48 +00:00
|
|
|
Cpu->Execute();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-08-15 06:17:43 +00:00
|
|
|
g_ExecBiosHack = false;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
// {
|
|
|
|
// 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);
|
|
|
|
|
2009-08-15 06:17:43 +00:00
|
|
|
// 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
|
2009-02-09 21:15:56 +00:00
|
|
|
// with new faster versions:
|
|
|
|
Cpu->Reset();
|
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.Notice("Execute Bios Stub Complete");
|
2009-02-09 21:15:56 +00:00
|
|
|
//GSprintf(5, "PCSX2 " PCSX2_VERSION "\nExecuteBios Complete\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline void CPU_INT( u32 n, s32 ecycle)
|
|
|
|
{
|
|
|
|
cpuRegs.interrupt|= 1 << n;
|
|
|
|
cpuRegs.sCycle[n] = cpuRegs.cycle;
|
|
|
|
cpuRegs.eCycle[n] = ecycle;
|
|
|
|
|
|
|
|
// Interrupt is happening soon: make sure both EE and IOP are aware.
|
|
|
|
|
|
|
|
if( ecycle <= 28 && psxCycleEE > 0 )
|
|
|
|
{
|
|
|
|
// If running in the IOP, force it to break immediately into the EE.
|
|
|
|
// the EE's branch test is due to run.
|
|
|
|
|
|
|
|
psxBreak += psxCycleEE; // record the number of cycles the IOP didn't run.
|
|
|
|
psxCycleEE = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpuSetNextBranchDelta( cpuRegs.eCycle[n] );
|
|
|
|
}
|