Merge remote-tracking branch 'refs/remotes/project64/master'
This commit is contained in:
commit
6eae2b05e2
|
@ -14,20 +14,19 @@ CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
|
|||
m_FlashRam(FlashRam),
|
||||
m_Sram(Sram)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CDMA::OnFirstDMA()
|
||||
{
|
||||
switch (g_Rom->CicChipID())
|
||||
{
|
||||
case CIC_NUS_6101: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_5167: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6101: *(uint32_t *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_5167: *(uint32_t *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_UNKNOWN:
|
||||
case CIC_NUS_6102: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6103: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6105: *(DWORD *)&((g_MMU->Rdram())[0x3F0]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6106: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6102: *(uint32_t *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6103: *(uint32_t *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6105: *(uint32_t *)&((g_MMU->Rdram())[0x3F0]) = g_MMU->RdramSize(); break;
|
||||
case CIC_NUS_6106: *(uint32_t *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
default: g_Notify->DisplayError(stdstr_f("Unhandled CicChip(%d) in first DMA", g_Rom->CicChipID()).ToUTF16().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +34,7 @@ void CDMA::OnFirstDMA()
|
|||
void CDMA::PI_DMA_READ()
|
||||
{
|
||||
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
|
||||
DWORD PI_RD_LEN_REG = ((g_Reg->PI_RD_LEN_REG) & 0x00FFFFFFul) + 1;
|
||||
uint32_t PI_RD_LEN_REG = ((g_Reg->PI_RD_LEN_REG) & 0x00FFFFFFul) + 1;
|
||||
|
||||
if ((PI_RD_LEN_REG & 1) != 0)
|
||||
{
|
||||
|
@ -57,9 +56,9 @@ void CDMA::PI_DMA_READ()
|
|||
//Write ROM Area (for 64DD Convert)
|
||||
if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF && g_Settings->LoadBool(Game_AllowROMWrites))
|
||||
{
|
||||
DWORD i;
|
||||
BYTE * ROM = g_Rom->GetRomAddress();
|
||||
BYTE * RDRAM = g_MMU->Rdram();
|
||||
uint32_t i;
|
||||
uint8_t * ROM = g_Rom->GetRomAddress();
|
||||
uint8_t * RDRAM = g_MMU->Rdram();
|
||||
|
||||
DWORD OldProtect;
|
||||
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READWRITE, &OldProtect);
|
||||
|
@ -74,7 +73,7 @@ void CDMA::PI_DMA_READ()
|
|||
}
|
||||
else
|
||||
{
|
||||
DWORD Len;
|
||||
uint32_t Len;
|
||||
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
|
||||
for (i = 0; i < Len; i++)
|
||||
{
|
||||
|
@ -101,7 +100,7 @@ void CDMA::PI_DMA_READ()
|
|||
return;
|
||||
}
|
||||
|
||||
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08088000)
|
||||
if (g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
|
||||
{
|
||||
if (g_System->m_SaveUsing == SaveChip_Auto)
|
||||
{
|
||||
|
@ -152,7 +151,7 @@ void CDMA::PI_DMA_READ()
|
|||
|
||||
void CDMA::PI_DMA_WRITE()
|
||||
{
|
||||
DWORD PI_WR_LEN_REG = ((g_Reg->PI_WR_LEN_REG) & 0x00FFFFFFul) + 1;
|
||||
uint32_t PI_WR_LEN_REG = ((g_Reg->PI_WR_LEN_REG) & 0x00FFFFFFul) + 1;
|
||||
|
||||
if ((PI_WR_LEN_REG & 1) != 0)
|
||||
{
|
||||
|
@ -203,20 +202,20 @@ void CDMA::PI_DMA_WRITE()
|
|||
|
||||
if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FFFFFFF)
|
||||
{
|
||||
DWORD i;
|
||||
uint32_t i;
|
||||
|
||||
#ifdef tofix
|
||||
#ifdef ROM_IN_MAPSPACE
|
||||
if (WrittenToRom)
|
||||
{
|
||||
DWORD OldProtect;
|
||||
uint32_t OldProtect;
|
||||
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
BYTE * ROM = g_Rom->GetRomAddress();
|
||||
BYTE * RDRAM = g_MMU->Rdram();
|
||||
uint8_t * ROM = g_Rom->GetRomAddress();
|
||||
uint8_t * RDRAM = g_MMU->Rdram();
|
||||
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
|
||||
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize())
|
||||
{
|
||||
|
@ -227,7 +226,7 @@ void CDMA::PI_DMA_WRITE()
|
|||
}
|
||||
else if (g_Reg->PI_CART_ADDR_REG >= g_Rom->GetRomSize())
|
||||
{
|
||||
DWORD cart = g_Reg->PI_CART_ADDR_REG - g_Rom->GetRomSize();
|
||||
uint32_t cart = g_Reg->PI_CART_ADDR_REG - g_Rom->GetRomSize();
|
||||
while (cart >= g_Rom->GetRomSize())
|
||||
{
|
||||
cart -= g_Rom->GetRomSize();
|
||||
|
@ -239,7 +238,7 @@ void CDMA::PI_DMA_WRITE()
|
|||
}
|
||||
else
|
||||
{
|
||||
DWORD Len;
|
||||
uint32_t Len;
|
||||
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
|
||||
for (i = 0; i < Len; i++)
|
||||
{
|
||||
|
@ -264,8 +263,8 @@ void CDMA::PI_DMA_WRITE()
|
|||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
//ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9) + 50);
|
||||
//ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9));
|
||||
//ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9) + 50);
|
||||
//ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -276,7 +275,6 @@ void CDMA::PI_DMA_WRITE()
|
|||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
|
||||
}
|
||||
|
||||
void CDMA::SP_DMA_READ()
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
#include <Project64\Settings\Debug Settings.h>
|
||||
#include <Project64\N64 System\Mips\FlashRam.h>
|
||||
#include <Project64\N64 System\Mips\Sram.h>
|
||||
|
||||
class CDMA :
|
||||
private CDebugSettings
|
||||
|
@ -24,10 +27,10 @@ public:
|
|||
protected:
|
||||
CDMA(CFlashram & FlashRam, CSram & Sram);
|
||||
|
||||
//void SI_DMA_READ();
|
||||
//void SI_DMA_WRITE();
|
||||
|
||||
private:
|
||||
CDMA(const CDMA&); // Disable copy constructor
|
||||
CDMA& operator=(const CDMA&); // Disable assignment
|
||||
|
||||
CFlashram & m_FlashRam;
|
||||
CSram & m_Sram;
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#include "stdafx.h"
|
||||
#include "Eeprom.h"
|
||||
#include <Project64\N64 System\System Globals.h>
|
||||
#include <Project64\N64 System\N64 Class.h>
|
||||
#include <time.h>
|
||||
|
||||
CEeprom::CEeprom(bool ReadOnly) :
|
||||
|
@ -27,13 +30,13 @@ CEeprom::~CEeprom()
|
|||
}
|
||||
}
|
||||
|
||||
unsigned char byte2bcd(int n)
|
||||
uint8_t byte2bcd(int32_t n)
|
||||
{
|
||||
n %= 100;
|
||||
return (unsigned char)(((n / 10) << 4) | (n % 10));
|
||||
return (uint8_t)(((n / 10) << 4) | (n % 10));
|
||||
}
|
||||
|
||||
void CEeprom::EepromCommand ( BYTE * Command)
|
||||
void CEeprom::EepromCommand(uint8_t * Command)
|
||||
{
|
||||
time_t curtime_time;
|
||||
struct tm curtime;
|
||||
|
@ -164,9 +167,9 @@ void CEeprom::LoadEeprom()
|
|||
ReadFile(m_hFile, m_EEPROM, sizeof(m_EEPROM), &dwRead, NULL);
|
||||
}
|
||||
|
||||
void CEeprom::ReadFrom(BYTE * Buffer, int line)
|
||||
void CEeprom::ReadFrom(uint8_t * Buffer, int32_t line)
|
||||
{
|
||||
int i;
|
||||
int32_t i;
|
||||
|
||||
if (m_hFile == NULL)
|
||||
{
|
||||
|
@ -179,10 +182,10 @@ void CEeprom::ReadFrom(BYTE * Buffer, int line)
|
|||
}
|
||||
}
|
||||
|
||||
void CEeprom::WriteTo(BYTE * Buffer, int line)
|
||||
void CEeprom::WriteTo(uint8_t * Buffer, int32_t line)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
int i;
|
||||
int32_t i;
|
||||
|
||||
if (m_hFile == NULL)
|
||||
{
|
||||
|
|
|
@ -17,14 +17,18 @@ public:
|
|||
CEeprom(bool ReadOnly);
|
||||
~CEeprom();
|
||||
|
||||
void EepromCommand ( BYTE * Command );
|
||||
void EepromCommand(uint8_t * Command);
|
||||
|
||||
private:
|
||||
void LoadEeprom ();
|
||||
void ReadFrom ( BYTE * Buffer, int line );
|
||||
void WriteTo ( BYTE * Buffer, int line );
|
||||
CEeprom(void); // Disable default constructor
|
||||
CEeprom(const CEeprom&); // Disable copy constructor
|
||||
CEeprom& operator=(const CEeprom&); // Disable assignment
|
||||
|
||||
BYTE m_EEPROM[0x800];
|
||||
void LoadEeprom();
|
||||
void ReadFrom(uint8_t * Buffer, int32_t line);
|
||||
void WriteTo(uint8_t * Buffer, int32_t line);
|
||||
|
||||
uint8_t m_EEPROM[0x800];
|
||||
bool m_ReadOnly;
|
||||
HANDLE m_hFile;
|
||||
void * m_hFile;
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#include "stdafx.h"
|
||||
#include <common/Util.h>
|
||||
|
||||
#pragma warning(disable:4355) // Disable 'this' : used in base member initializer list
|
||||
|
||||
|
@ -44,7 +45,7 @@ m_CPU_ThreadID(0),
|
|||
m_hPauseEvent(true),
|
||||
m_CheatsSlectionChanged(false)
|
||||
{
|
||||
DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
|
||||
uint32_t gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
|
||||
if (gameHertz == 0)
|
||||
{
|
||||
gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60;
|
||||
|
@ -180,10 +181,10 @@ bool CN64System::RunFileImage(const char * FileLoc)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading");
|
||||
g_Settings->SaveString(Game_File, "");
|
||||
|
||||
//Mark the rom as loading
|
||||
WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading");
|
||||
g_Settings->SaveString(Game_File, "");
|
||||
g_Settings->SaveBool(GameRunning_LoadingInProgress, true);
|
||||
|
||||
//Try to load the passed N64 rom
|
||||
|
@ -236,7 +237,7 @@ void CN64System::CloseSystem()
|
|||
}
|
||||
}
|
||||
|
||||
bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId)
|
||||
bool CN64System::EmulationStarting(void * hThread, uint32_t ThreadId)
|
||||
{
|
||||
bool bRes = true;
|
||||
|
||||
|
@ -280,7 +281,7 @@ void CN64System::StartEmulation2(bool NewThread)
|
|||
|
||||
CInterpreterCPU::BuildCPU();
|
||||
|
||||
DWORD CpuType = g_Settings->LoadDword(Game_CpuType);
|
||||
uint32_t CpuType = g_Settings->LoadDword(Game_CpuType);
|
||||
|
||||
if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled))
|
||||
{
|
||||
|
@ -321,12 +322,9 @@ void CN64System::StartEmulation2(bool NewThread)
|
|||
{
|
||||
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
|
||||
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
|
||||
|
||||
Notify().ShowRomBrowser();
|
||||
}
|
||||
|
||||
Notify().MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop));
|
||||
|
||||
else
|
||||
{
|
||||
ThreadInfo * Info = new ThreadInfo;
|
||||
HANDLE * hThread = new HANDLE;
|
||||
*hThread = NULL;
|
||||
|
@ -335,26 +333,14 @@ void CN64System::StartEmulation2(bool NewThread)
|
|||
//for creating a thread
|
||||
Info->ThreadHandle = hThread;
|
||||
|
||||
*hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID);
|
||||
*hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, (LPDWORD)&Info->ThreadID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//mark the emulation as starting and fix up menus
|
||||
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
|
||||
|
||||
if (g_Settings->LoadBool(Setting_AutoFullscreen))
|
||||
{
|
||||
WriteTrace(TraceDebug, __FUNCTION__ " 15");
|
||||
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
|
||||
stdstr Status = g_Settings->LoadStringVal(Rdb_Status);
|
||||
|
||||
char String[100];
|
||||
RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
|
||||
if (_stricmp(String, "true") == 0)
|
||||
{
|
||||
Notify().ChangeFullScreen();
|
||||
}
|
||||
}
|
||||
ExecuteCPU();
|
||||
}
|
||||
}
|
||||
|
@ -367,9 +353,9 @@ void CN64System::StartEmulation(bool NewThread)
|
|||
}
|
||||
__except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
|
||||
{
|
||||
char Message[600];
|
||||
sprintf(Message, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__);
|
||||
MessageBox(NULL, Message, "Exception", MB_OK);
|
||||
wchar_t message[400];
|
||||
swprintf(message, sizeof(message), L"Exception caught\nFile: %s\nLine: %d", __FILEW__, __LINE__);
|
||||
g_Notify->DisplayError(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +368,7 @@ void CN64System::StartEmulationThread(ThreadInfo * Info)
|
|||
|
||||
CoInitialize(NULL);
|
||||
|
||||
EmulationStarting(*Info->ThreadHandle, Info->ThreadID);
|
||||
EmulationStarting(Info->ThreadHandle, Info->ThreadID);
|
||||
delete Info->ThreadHandle;
|
||||
delete Info;
|
||||
|
||||
|
@ -458,8 +444,8 @@ void CN64System::Pause()
|
|||
g_Notify->DisplayMessage(5, MSG_CPU_PAUSED);
|
||||
m_hPauseEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT);
|
||||
m_hPauseEvent.Reset();
|
||||
g_Settings->SaveBool(GameRunning_CPU_Paused, false);
|
||||
Notify().DisplayMessage(5, MSG_CPU_RESUMED);
|
||||
g_Settings->SaveBool(GameRunning_CPU_Paused, (uint32_t)false);
|
||||
g_Notify->DisplayMessage(5, MSG_CPU_RESUMED);
|
||||
}
|
||||
|
||||
void CN64System::GameReset()
|
||||
|
@ -495,7 +481,6 @@ void CN64System::PluginReset()
|
|||
}
|
||||
}
|
||||
}
|
||||
Notify().RefreshMenu();
|
||||
if (m_Recomp)
|
||||
{
|
||||
m_Recomp->Reset();
|
||||
|
@ -841,8 +826,8 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemory & MMU)
|
|||
void CN64System::ExecuteCPU()
|
||||
{
|
||||
//reset code
|
||||
g_Settings->SaveBool(GameRunning_CPU_Running, true);
|
||||
g_Settings->SaveBool(GameRunning_CPU_Paused, false);
|
||||
g_Settings->SaveBool(GameRunning_CPU_Running, true);
|
||||
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
|
||||
|
||||
m_EndEmulation = false;
|
||||
|
@ -865,8 +850,7 @@ void CN64System::ExecuteCPU()
|
|||
#endif
|
||||
default: ExecuteInterpret(); break;
|
||||
}
|
||||
g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false);
|
||||
Notify().WindowMode();
|
||||
g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
|
||||
m_Plugins->RomClosed();
|
||||
if (m_SyncCPU)
|
||||
{
|
||||
|
@ -887,31 +871,24 @@ void CN64System::ExecuteRecompiler()
|
|||
|
||||
void CN64System::ExecuteSyncCPU()
|
||||
{
|
||||
Notify().BringToTop();
|
||||
m_Recomp->Run();
|
||||
}
|
||||
|
||||
void CN64System::CpuStopped()
|
||||
{
|
||||
g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false);
|
||||
Notify().WindowMode();
|
||||
if (!m_InReset)
|
||||
{
|
||||
Notify().RefreshMenu();
|
||||
Notify().MakeWindowOnTop(false);
|
||||
g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
|
||||
g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED);
|
||||
if (g_Settings->LoadDword(RomBrowser_Enabled))
|
||||
{
|
||||
Notify().ShowRomBrowser();
|
||||
}
|
||||
}
|
||||
if (m_SyncCPU)
|
||||
{
|
||||
m_SyncCPU->CpuStopped();
|
||||
}
|
||||
m_CPU_Handle = NULL;
|
||||
}
|
||||
|
||||
void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, DWORD const Cycles)
|
||||
void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycles)
|
||||
{
|
||||
int CyclesToExecute = Cycles - m_CyclesToSkip;
|
||||
|
||||
|
@ -1038,7 +1015,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
|
|||
|
||||
if (bFastSP() && m_Recomp)
|
||||
{
|
||||
if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)))
|
||||
if (m_Recomp->MemoryStackPos() != (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)))
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
|
@ -1197,7 +1174,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
|
||||
if (m_NextTimer != SecondCPU->m_NextTimer)
|
||||
{
|
||||
Error.LogF("Current Time: %X %X\r\n", (DWORD)m_NextTimer, (DWORD)SecondCPU->m_NextTimer);
|
||||
Error.LogF("Current Time: %X %X\r\n", (uint32_t)m_NextTimer, (uint32_t)SecondCPU->m_NextTimer);
|
||||
}
|
||||
m_TLB.RecordDifference(Error, SecondCPU->m_TLB);
|
||||
m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer);
|
||||
|
@ -1207,13 +1184,13 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
}
|
||||
if (bFastSP() && m_Recomp)
|
||||
{
|
||||
if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)))
|
||||
if (m_Recomp->MemoryStackPos() != (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)))
|
||||
{
|
||||
Error.LogF("MemoryStack = %X should be: %X\r\n", m_Recomp->MemoryStackPos(), (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)));
|
||||
Error.LogF("MemoryStack = %X should be: %X\r\n", m_Recomp->MemoryStackPos(), (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)));
|
||||
}
|
||||
}
|
||||
|
||||
DWORD * Rdram = (DWORD *)m_MMU_VM.Rdram(), *Rdram2 = (DWORD *)SecondCPU->m_MMU_VM.Rdram();
|
||||
uint32_t * Rdram = (uint32_t *)m_MMU_VM.Rdram(), *Rdram2 = (uint32_t *)SecondCPU->m_MMU_VM.Rdram();
|
||||
for (int z = 0, n = (RdramSize() >> 2); z < n; z++)
|
||||
{
|
||||
if (Rdram[z] != Rdram2[z])
|
||||
|
@ -1222,7 +1199,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
}
|
||||
}
|
||||
|
||||
DWORD * Imem = (DWORD *)m_MMU_VM.Imem(), *Imem2 = (DWORD *)SecondCPU->m_MMU_VM.Imem();
|
||||
uint32_t * Imem = (uint32_t *)m_MMU_VM.Imem(), *Imem2 = (uint32_t *)SecondCPU->m_MMU_VM.Imem();
|
||||
for (int z = 0; z < (0x1000 >> 2); z++)
|
||||
{
|
||||
if (Imem[z] != Imem2[z])
|
||||
|
@ -1230,7 +1207,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
Error.LogF("Imem[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]);
|
||||
}
|
||||
}
|
||||
DWORD * Dmem = (DWORD *)m_MMU_VM.Dmem(), *Dmem2 = (DWORD *)SecondCPU->m_MMU_VM.Dmem();
|
||||
uint32_t * Dmem = (uint32_t *)m_MMU_VM.Dmem(), *Dmem2 = (uint32_t *)SecondCPU->m_MMU_VM.Dmem();
|
||||
for (int z = 0; z < (0x1000 >> 2); z++)
|
||||
{
|
||||
if (Dmem[z] != Dmem2[z])
|
||||
|
@ -1308,8 +1285,8 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
Error.Log("Code at PC:\r\n");
|
||||
for (count = -10; count < 10; count++)
|
||||
{
|
||||
DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2);
|
||||
if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue))
|
||||
uint32_t OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2);
|
||||
if (g_MMU->LW_VAddr(Addr, OpcodeValue))
|
||||
{
|
||||
Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr));
|
||||
}
|
||||
|
@ -1318,8 +1295,8 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
Error.Log("Code at Last Sync PC:\r\n");
|
||||
for (count = 0; count < 50; count++)
|
||||
{
|
||||
DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2);
|
||||
if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue))
|
||||
uint32_t OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2);
|
||||
if (g_MMU->LW_VAddr(Addr, OpcodeValue))
|
||||
{
|
||||
Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr));
|
||||
}
|
||||
|
@ -1393,10 +1370,10 @@ bool CN64System::SaveState()
|
|||
}
|
||||
}
|
||||
|
||||
DWORD dwWritten, SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23;
|
||||
DWORD RdramSize = g_Settings->LoadDword(Game_RDRamSize);
|
||||
DWORD MiInterReg = g_Reg->MI_INTR_REG;
|
||||
DWORD NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer);
|
||||
uint32_t SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23;
|
||||
uint32_t RdramSize = g_Settings->LoadDword(Game_RDRamSize);
|
||||
uint32_t MiInterReg = g_Reg->MI_INTR_REG;
|
||||
uint32_t NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer);
|
||||
if (g_Settings->LoadDword(Setting_AutoZipInstantSave))
|
||||
{
|
||||
zipFile file;
|
||||
|
@ -1404,25 +1381,25 @@ bool CN64System::SaveState()
|
|||
file = zipOpen(FileName.c_str(), 0);
|
||||
zipOpenNewFileInZip(file, CurrentSaveName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
|
||||
zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0));
|
||||
zipWriteInFileInZip(file, &RdramSize, sizeof(DWORD));
|
||||
zipWriteInFileInZip(file, &RdramSize, sizeof(uint32_t));
|
||||
zipWriteInFileInZip(file, g_Rom->GetRomAddress(), 0x40);
|
||||
zipWriteInFileInZip(file, &NextViTimer, sizeof(DWORD));
|
||||
zipWriteInFileInZip(file, &NextViTimer, sizeof(uint32_t));
|
||||
zipWriteInFileInZip(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER));
|
||||
zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(__int64) * 32);
|
||||
zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(__int64) * 32);
|
||||
zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(DWORD) * 32);
|
||||
zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(DWORD) * 32);
|
||||
zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(__int64));
|
||||
zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(__int64));
|
||||
zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10);
|
||||
zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13);
|
||||
zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8);
|
||||
zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4);
|
||||
zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(int64_t) * 32);
|
||||
zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(int64_t) * 32);
|
||||
zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(uint32_t) * 32);
|
||||
zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(uint32_t) * 32);
|
||||
zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(int64_t));
|
||||
zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(int64_t));
|
||||
zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10);
|
||||
zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6);
|
||||
zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
|
||||
zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
|
||||
zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4);
|
||||
zipWriteInFileInZip(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40);
|
||||
zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize);
|
||||
|
@ -1450,26 +1427,27 @@ bool CN64System::SaveState()
|
|||
|
||||
//Write info to file
|
||||
SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN);
|
||||
WriteFile(hSaveFile, &SaveID_0, sizeof(DWORD), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &RdramSize, sizeof(DWORD), &dwWritten, NULL);
|
||||
DWORD dwWritten;
|
||||
WriteFile(hSaveFile, &SaveID_0, sizeof(uint32_t), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &RdramSize, sizeof(uint32_t), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, g_Rom->GetRomAddress(), 0x40, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &NextViTimer, sizeof(DWORD), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &NextViTimer, sizeof(uint32_t), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_GPR, sizeof(int64_t) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(int64_t) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(uint32_t) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(uint32_t) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(int64_t), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(int64_t), &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, &g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL);
|
||||
WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL);
|
||||
|
@ -1534,9 +1512,9 @@ bool CN64System::LoadState()
|
|||
return LoadState(FileName);
|
||||
}
|
||||
|
||||
bool CN64System::LoadState(LPCSTR FileName)
|
||||
bool CN64System::LoadState(const char * FileName)
|
||||
{
|
||||
DWORD dwRead, Value, SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate;
|
||||
uint32_t Value, SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate;
|
||||
bool LoadedZipFile = false, AudioResetOnLoad;
|
||||
old_status = g_Reg->VI_STATUS_REG;
|
||||
old_width = g_Reg->VI_WIDTH_REG;
|
||||
|
@ -1561,7 +1539,7 @@ bool CN64System::LoadState(LPCSTR FileName)
|
|||
{
|
||||
port = unzGoToFirstFile(file);
|
||||
}
|
||||
DWORD Value;
|
||||
uint32_t Value;
|
||||
while (port == UNZ_OK)
|
||||
{
|
||||
unz_file_info info;
|
||||
|
@ -1592,7 +1570,7 @@ bool CN64System::LoadState(LPCSTR FileName)
|
|||
unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize));
|
||||
//Check header
|
||||
|
||||
BYTE LoadHeader[64];
|
||||
uint8_t LoadHeader[64];
|
||||
unzReadCurrentFile(file, LoadHeader, 0x40);
|
||||
if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0)
|
||||
{
|
||||
|
@ -1610,21 +1588,21 @@ bool CN64System::LoadState(LPCSTR FileName)
|
|||
g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize);
|
||||
unzReadCurrentFile(file, &NextVITimer, sizeof(NextVITimer));
|
||||
unzReadCurrentFile(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER));
|
||||
unzReadCurrentFile(file, m_Reg.m_GPR, sizeof(__int64) * 32);
|
||||
unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(__int64) * 32);
|
||||
unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(DWORD) * 32);
|
||||
unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(DWORD) * 32);
|
||||
unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(__int64));
|
||||
unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(__int64));
|
||||
unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10);
|
||||
unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10);
|
||||
unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10);
|
||||
unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4);
|
||||
unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14);
|
||||
unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6);
|
||||
unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13);
|
||||
unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8);
|
||||
unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4);
|
||||
unzReadCurrentFile(file, m_Reg.m_GPR, sizeof(int64_t) * 32);
|
||||
unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(int64_t) * 32);
|
||||
unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(uint32_t) * 32);
|
||||
unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(uint32_t) * 32);
|
||||
unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(int64_t));
|
||||
unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(int64_t));
|
||||
unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10);
|
||||
unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10);
|
||||
unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10);
|
||||
unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4);
|
||||
unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14);
|
||||
unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6);
|
||||
unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
|
||||
unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
|
||||
unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4);
|
||||
unzReadCurrentFile(file, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40);
|
||||
unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize);
|
||||
|
@ -1655,23 +1633,25 @@ bool CN64System::LoadState(LPCSTR FileName)
|
|||
}
|
||||
|
||||
SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN);
|
||||
DWORD dwRead;
|
||||
ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL);
|
||||
if (Value != 0x23D8A6C8)
|
||||
return false;
|
||||
|
||||
ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL);
|
||||
//Check header
|
||||
BYTE LoadHeader[64];
|
||||
uint8_t LoadHeader[64];
|
||||
ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL);
|
||||
if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0)
|
||||
{
|
||||
//if (inFullScreen) { return false; }
|
||||
int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE),
|
||||
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
|
||||
int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
|
||||
|
||||
if (result == IDNO)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reset(false, true);
|
||||
m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4);
|
||||
m_MMU_VM.UnProtectMemory(0xA4000000, 0xA4001FFC);
|
||||
|
@ -1679,21 +1659,21 @@ bool CN64System::LoadState(LPCSTR FileName)
|
|||
|
||||
ReadFile(hSaveFile, &NextVITimer, sizeof(NextVITimer), &dwRead, NULL);
|
||||
ReadFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwRead, NULL);
|
||||
ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_GPR, sizeof(int64_t) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(int64_t) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(uint32_t) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(uint32_t) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(int64_t), &dwRead, NULL);
|
||||
ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(int64_t), &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_MMU_VM.PifRam(), 0x40, &dwRead, NULL);
|
||||
ReadFile(hSaveFile, m_MMU_VM.Rdram(), SaveRDRAMSize, &dwRead, NULL);
|
||||
|
@ -1797,10 +1777,10 @@ void CN64System::RunRSP()
|
|||
{
|
||||
SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/;
|
||||
|
||||
DWORD Task = 0;
|
||||
uint32_t Task = 0;
|
||||
if (m_RspBroke)
|
||||
{
|
||||
g_MMU->LW_VAddr(0xA4000FC0, (uint32_t &)Task);
|
||||
g_MMU->LW_VAddr(0xA4000FC0, Task);
|
||||
if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0)
|
||||
{
|
||||
WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen");
|
||||
|
@ -1894,7 +1874,7 @@ void CN64System::SyncToAudio()
|
|||
WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i);
|
||||
break;
|
||||
}
|
||||
Sleep(1);
|
||||
pjutil::Sleep(1);
|
||||
}
|
||||
if (bShowCPUPer())
|
||||
{
|
||||
|
@ -1905,7 +1885,7 @@ void CN64System::SyncToAudio()
|
|||
void CN64System::RefreshScreen()
|
||||
{
|
||||
SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/;
|
||||
DWORD VI_INTR_TIME = 500000;
|
||||
uint32_t VI_INTR_TIME = 500000;
|
||||
|
||||
if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); }
|
||||
//if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); }
|
||||
|
@ -1954,7 +1934,6 @@ void CN64System::RefreshScreen()
|
|||
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught");
|
||||
WriteTrace(TraceError, __FUNCTION__ ": Exception caught");
|
||||
}
|
||||
|
||||
g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0);
|
||||
|
||||
if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio())
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
typedef std::list<SystemEvent> EVENT_LIST;
|
||||
|
||||
typedef std::map<DWORD, DWORD> FUNC_CALLS;
|
||||
typedef std::map<uint32_t, uint32_t> FUNC_CALLS;
|
||||
|
||||
class CPlugins;
|
||||
class CRSP_Plugin;
|
||||
|
@ -36,11 +36,6 @@ public:
|
|||
CN64System(CPlugins * Plugins, bool SavesReadOnly);
|
||||
virtual ~CN64System(void);
|
||||
|
||||
struct ThreadInfo {
|
||||
HANDLE * ThreadHandle;
|
||||
DWORD ThreadID;
|
||||
};
|
||||
|
||||
CProfiling m_Profile;
|
||||
CCheats m_Cheats;
|
||||
bool m_EndEmulation;
|
||||
|
@ -64,21 +59,21 @@ public:
|
|||
void Pause();
|
||||
void RunRSP();
|
||||
bool SaveState();
|
||||
bool LoadState(LPCSTR FileName);
|
||||
bool LoadState(const char * FileName);
|
||||
bool LoadState();
|
||||
|
||||
bool DmaUsed() const { return m_DMAUsed; }
|
||||
void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; }
|
||||
void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; }
|
||||
bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; }
|
||||
DWORD GetButtons(int Control) const { return m_Buttons[Control]; }
|
||||
uint32_t GetButtons(int32_t Control) const { return m_Buttons[Control]; }
|
||||
|
||||
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core
|
||||
#ifdef TEST_SP_TRACKING
|
||||
DWORD m_CurrentSP;
|
||||
uint32_t m_CurrentSP;
|
||||
#endif
|
||||
//For Sync CPU
|
||||
void UpdateSyncCPU(CN64System * const SecondCPU, DWORD const Cycles);
|
||||
void UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycles);
|
||||
void SyncCPU(CN64System * const SecondCPU);
|
||||
void SyncCPUPC(CN64System * const SecondCPU);
|
||||
void SyncSystem();
|
||||
|
@ -94,8 +89,14 @@ private:
|
|||
friend CSystemTimer;
|
||||
|
||||
//Used for loading and potentially executing the CPU in its own thread.
|
||||
struct ThreadInfo
|
||||
{
|
||||
void * ThreadHandle;
|
||||
uint32_t ThreadID;
|
||||
};
|
||||
|
||||
static void StartEmulationThread(ThreadInfo * Info);
|
||||
static bool EmulationStarting(HANDLE hThread, DWORD ThreadId);
|
||||
static bool EmulationStarting(void * hThread, uint32_t ThreadId);
|
||||
|
||||
void ExecuteCPU();
|
||||
void RefreshScreen();
|
||||
|
@ -114,7 +115,7 @@ private:
|
|||
void CpuStopped();
|
||||
|
||||
//Function in CMipsMemory_CallBack
|
||||
virtual bool WriteToProtectedMemory(uint32_t Address, int length);
|
||||
virtual bool WriteToProtectedMemory(uint32_t Address, int32_t length);
|
||||
|
||||
//Functions in CTLB_CB
|
||||
void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly);
|
||||
|
@ -133,34 +134,34 @@ private:
|
|||
CAudio m_Audio;
|
||||
CSpeedLimitor m_Limitor;
|
||||
bool m_InReset;
|
||||
int m_NextTimer;
|
||||
int32_t m_NextTimer;
|
||||
CSystemTimer m_SystemTimer;
|
||||
bool m_bCleanFrameBox;
|
||||
bool m_bInitialized;
|
||||
bool m_RspBroke;
|
||||
bool m_DMAUsed;
|
||||
DWORD m_Buttons[4];
|
||||
uint32_t m_Buttons[4];
|
||||
bool m_TestTimer;
|
||||
DWORD m_NextInstruction;
|
||||
DWORD m_JumpToLocation;
|
||||
uint32_t m_NextInstruction;
|
||||
uint32_t m_JumpToLocation;
|
||||
uint32_t m_TLBLoadAddress;
|
||||
uint32_t m_TLBStoreAddress;
|
||||
DWORD m_SyncCount;
|
||||
uint32_t m_SyncCount;
|
||||
bool m_CheatsSlectionChanged;
|
||||
|
||||
//When Syncing cores this is the PC where it last Sync'ed correctly
|
||||
DWORD m_LastSuccessSyncPC[10];
|
||||
int m_CyclesToSkip;
|
||||
uint32_t m_LastSuccessSyncPC[10];
|
||||
int32_t m_CyclesToSkip;
|
||||
|
||||
//Handle to the cpu thread
|
||||
HANDLE m_CPU_Handle;
|
||||
DWORD m_CPU_ThreadID;
|
||||
void * m_CPU_Handle;
|
||||
uint32_t m_CPU_ThreadID;
|
||||
|
||||
//Handle to pause mutex
|
||||
SyncEvent m_hPauseEvent;
|
||||
|
||||
//No of Alist and Dlist sent to the RSP
|
||||
DWORD m_AlistCount, m_DlistCount, m_UnknownCount;
|
||||
uint32_t m_AlistCount, m_DlistCount, m_UnknownCount;
|
||||
|
||||
//list of function that have been called .. used in profiling
|
||||
FUNC_CALLS m_FunctionCalls;
|
||||
|
|
|
@ -9,6 +9,16 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#include "stdafx.h"
|
||||
#include "Code Section.h"
|
||||
#include <Project64\N64 System\Mips\OpCode.h>
|
||||
#include <Project64\N64 System\System Globals.h>
|
||||
#include <Project64\N64 System\Mips\Memory Class.h>
|
||||
#include <Project64\N64 System\Recompiler\x86CodeLog.h>
|
||||
#include <Project64\N64 System\Recompiler\Code Block.h>
|
||||
#include <Project64\N64 System\N64 Class.h>
|
||||
#include <Project64\N64 System\Interpreter\Interpreter CPU.h>
|
||||
#include <Project64\N64 System\Recompiler\Loop Analysis.h>
|
||||
#include <Project64\N64 System\Recompiler\Section Info.h>
|
||||
|
||||
void InPermLoop();
|
||||
|
||||
|
@ -442,6 +452,7 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
// if (g_SyncSystem) {
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
//}
|
||||
// MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction");
|
||||
PushImm32(stdstr_f("0x%08X",CompilePC() + 4).c_str(),CompilePC() + 4);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
****************************************************************************/
|
||||
#include "stdafx.h"
|
||||
|
||||
unsigned int CRegInfo::m_fpuControl = 0;
|
||||
uint32_t CRegInfo::m_fpuControl = 0;
|
||||
|
||||
char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" };
|
||||
|
||||
|
@ -470,10 +470,7 @@ CX86Ops::x86Reg CRegInfo::Free8BitX86Reg()
|
|||
if (GetX86Mapped(x86_ECX) == NotMapped && !GetX86Protected(x86_ECX)) { return x86_ECX; }
|
||||
|
||||
x86Reg Reg = UnMap_8BitTempReg();
|
||||
if (Reg > 0)
|
||||
{
|
||||
return Reg;
|
||||
}
|
||||
if (Reg > 0) { return Reg; }
|
||||
|
||||
int32_t count, MapCount[10], MapReg[10];
|
||||
for (count = 0; count < 10; count++)
|
||||
|
|
|
@ -50,6 +50,7 @@ m_ResetInfo(NULL)
|
|||
g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
|
||||
g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
|
||||
g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
|
||||
g_Settings->RegisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
|
||||
g_Settings->RegisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
|
||||
g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
|
||||
}
|
||||
|
@ -68,6 +69,7 @@ CMainGui::~CMainGui(void)
|
|||
g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
|
||||
g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
|
||||
g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
|
||||
g_Settings->UnregisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
|
||||
g_Settings->UnregisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
|
||||
g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
|
||||
}
|
||||
|
@ -150,6 +152,15 @@ void CMainGui::SetWindowCaption(const wchar_t * title)
|
|||
Caption(WinTitle);
|
||||
}
|
||||
|
||||
void CMainGui::ShowRomBrowser(void)
|
||||
{
|
||||
if (g_Settings->LoadDword(RomBrowser_Enabled))
|
||||
{
|
||||
ShowRomList();
|
||||
HighLightLastRom();
|
||||
}
|
||||
}
|
||||
|
||||
void RomBowserEnabledChanged(CMainGui * Gui)
|
||||
{
|
||||
if (Gui && g_Settings->LoadBool(RomBrowser_Enabled))
|
||||
|
@ -171,6 +182,15 @@ void RomBowserEnabledChanged(CMainGui * Gui)
|
|||
void CMainGui::LoadingInProgressChanged(CMainGui * Gui)
|
||||
{
|
||||
Gui->RefreshMenu();
|
||||
if (!g_Settings->LoadBool(GameRunning_LoadingInProgress) && g_Settings->LoadStringVal(Game_File).length() == 0)
|
||||
{
|
||||
Notify().WindowMode();
|
||||
if (g_Settings->LoadDword(RomBrowser_Enabled))
|
||||
{
|
||||
Gui->ShowRomBrowser();
|
||||
}
|
||||
Gui->MakeWindowOnTop(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CMainGui::GameLoaded(CMainGui * Gui)
|
||||
|
@ -181,7 +201,6 @@ void CMainGui::GameLoaded(CMainGui * Gui)
|
|||
WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom");
|
||||
Gui->AddRecentRom(FileLoc.c_str());
|
||||
Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str());
|
||||
|
||||
Gui->HideRomList();
|
||||
}
|
||||
}
|
||||
|
@ -191,6 +210,33 @@ void CMainGui::GamePaused(CMainGui * Gui)
|
|||
Gui->RefreshMenu();
|
||||
}
|
||||
|
||||
void CMainGui::GameCpuRunning(CMainGui * Gui)
|
||||
{
|
||||
if (g_Settings->LoadBool(GameRunning_CPU_Running))
|
||||
{
|
||||
Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop));
|
||||
if (g_Settings->LoadBool(Setting_AutoFullscreen))
|
||||
{
|
||||
WriteTrace(TraceDebug, __FUNCTION__ " 15");
|
||||
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
|
||||
stdstr Status = g_Settings->LoadStringVal(Rdb_Status);
|
||||
|
||||
char String[100];
|
||||
RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
|
||||
if (_stricmp(String, "true") == 0)
|
||||
{
|
||||
g_Notify->ChangeFullScreen();
|
||||
}
|
||||
}
|
||||
Gui->RefreshMenu();
|
||||
Gui->BringToTop();
|
||||
}
|
||||
else
|
||||
{
|
||||
PostMessage(Gui->m_hMainWindow, WM_GAME_CLOSED, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void RomBowserColoumnsChanged(CMainGui * Gui)
|
||||
{
|
||||
Gui->ResetRomBrowserColomuns();
|
||||
|
@ -375,6 +421,7 @@ bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System)
|
|||
WriteTrace(TraceError, __FUNCTION__ ": Failed to create event");
|
||||
bRes = false;
|
||||
}
|
||||
Notify().RefreshMenu();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
|
@ -908,6 +955,20 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
|
|||
_this->m_ResetPlugins = true;
|
||||
}
|
||||
break;
|
||||
case WM_GAME_CLOSED:
|
||||
{
|
||||
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
|
||||
Notify().WindowMode();
|
||||
if (g_Settings->LoadDword(RomBrowser_Enabled))
|
||||
{
|
||||
_this->ShowRomBrowser();
|
||||
}
|
||||
_this->RefreshMenu();
|
||||
_this->MakeWindowOnTop(false);
|
||||
_this->SetStatusText(0, L"");
|
||||
_this->SetStatusText(1, L"");
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
{
|
||||
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
|
||||
|
|
|
@ -26,6 +26,7 @@ enum
|
|||
WM_HIDE_CUROSR = WM_USER + 10,
|
||||
WM_MAKE_FOCUS = WM_USER + 17,
|
||||
WM_RESET_PLUGIN = WM_USER + 18,
|
||||
WM_GAME_CLOSED = WM_USER + 19,
|
||||
WM_BORWSER_TOP = WM_USER + 40,
|
||||
};
|
||||
|
||||
|
@ -105,6 +106,7 @@ private:
|
|||
void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE
|
||||
void AddRecentRom(const char * ImagePath);
|
||||
void SetWindowCaption(const wchar_t * Caption);
|
||||
void ShowRomBrowser(void);
|
||||
|
||||
friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD);
|
||||
friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD);
|
||||
|
@ -116,6 +118,7 @@ private:
|
|||
static void LoadingInProgressChanged(CMainGui * Gui);
|
||||
static void GameLoaded(CMainGui * Gui);
|
||||
static void GamePaused(CMainGui * Gui);
|
||||
static void GameCpuRunning(CMainGui * Gui);
|
||||
|
||||
CBaseMenu * m_Menu;
|
||||
|
||||
|
|
Loading…
Reference in New Issue