Merge remote-tracking branch 'refs/remotes/project64/master'

This commit is contained in:
Samuel Yuan 2015-11-15 00:30:03 -05:00
commit 6eae2b05e2
12 changed files with 3168 additions and 3108 deletions

View File

@ -11,38 +11,37 @@
#include "stdafx.h"
CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
m_FlashRam(FlashRam),
m_Sram(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;
default: g_Notify->DisplayError(stdstr_f("Unhandled CicChip(%d) in first DMA",g_Rom->CicChipID()).ToUTF16().c_str());
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());
}
}
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;
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
uint32_t PI_RD_LEN_REG = ((g_Reg->PI_RD_LEN_REG) & 0x00FFFFFFul) + 1;
if ((PI_RD_LEN_REG & 1) != 0)
{
PI_RD_LEN_REG += 1;
}
if ( g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG > g_MMU->RdramSize())
if (g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG > g_MMU->RdramSize())
{
if (bHaveDebugger())
{
@ -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)
{
@ -122,7 +121,7 @@ void CDMA::PI_DMA_READ()
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaToFlashram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG
);
@ -134,7 +133,7 @@ void CDMA::PI_DMA_READ()
}
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
g_Notify->DisplayError(stdstr_f("**** FLashRam DMA Read address %08X *****",g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
g_Notify->DisplayError(stdstr_f("**** FLashRam DMA Read address %08X *****", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
@ -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)
{
@ -160,7 +159,7 @@ void CDMA::PI_DMA_WRITE()
}
g_Reg->PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
if ( g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG > g_MMU->RdramSize())
if (g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG > g_MMU->RdramSize())
{
if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG).ToUTF16().c_str()); }
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
@ -169,7 +168,7 @@ void CDMA::PI_DMA_WRITE()
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 <= 0x08088000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
{
@ -178,7 +177,7 @@ void CDMA::PI_DMA_WRITE()
if (g_System->m_SaveUsing == SaveChip_Sram)
{
m_Sram.DmaFromSram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG
);
@ -190,7 +189,7 @@ void CDMA::PI_DMA_WRITE()
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaFromFlashram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG
);
@ -201,33 +200,33 @@ void CDMA::PI_DMA_WRITE()
return;
}
if ( g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FFFFFFF)
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())
{
for (i = 0; i < PI_WR_LEN_REG; i ++)
for (i = 0; i < PI_WR_LEN_REG; i++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
}
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,15 +238,15 @@ 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 ++)
for (i = 0; i < Len; i++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
for (i = Len; i < PI_WR_LEN_REG - Len; i ++)
for (i = Len; i < PI_WR_LEN_REG - Len; i++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
}
}
g_Reg->PI_CART_ADDR_REG += 0x10000000;
@ -259,13 +258,13 @@ void CDMA::PI_DMA_WRITE()
}
if (g_Recompiler && g_System->bSMM_PIDMA())
{
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG,CRecompiler::Remove_DMA);
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA);
}
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()
@ -305,19 +303,19 @@ void CDMA::SP_DMA_READ()
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
memcpy( g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF), g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG,
g_Reg->SP_RD_LEN_REG + 1 );
memcpy(g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF), g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG,
g_Reg->SP_RD_LEN_REG + 1);
g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
@ -345,19 +343,19 @@ void CDMA::SP_DMA_WRITE()
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
memcpy( g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG, g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF),
memcpy(g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG, g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF),
g_Reg->SP_WR_LEN_REG + 1);
g_Reg->SP_DMA_BUSY_REG = 0;

View File

@ -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
@ -22,12 +25,12 @@ public:
void PI_DMA_WRITE();
protected:
CDMA (CFlashram & FlashRam, CSram & Sram);
//void SI_DMA_READ();
//void SI_DMA_WRITE();
CDMA(CFlashram & FlashRam, CSram & Sram);
private:
CDMA(const CDMA&); // Disable copy constructor
CDMA& operator=(const CDMA&); // Disable assignment
CFlashram & m_FlashRam;
CSram & m_Sram;

View File

@ -9,13 +9,16 @@
* *
****************************************************************************/
#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):
m_ReadOnly(ReadOnly),
m_hFile(NULL)
CEeprom::CEeprom(bool ReadOnly) :
m_ReadOnly(ReadOnly),
m_hFile(NULL)
{
memset(m_EEPROM,0xFF,sizeof(m_EEPROM));
memset(m_EEPROM, 0xFF, sizeof(m_EEPROM));
}
CEeprom::~CEeprom()
@ -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;
@ -64,7 +67,7 @@ void CEeprom::EepromCommand ( BYTE * Command)
else
{
Command[3] = 0x00;
Command[4] = g_System->m_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0;
Command[4] = g_System->m_SaveUsing == SaveChip_Eeprom_4K ? 0x80 : 0xC0;
Command[5] = 0x00;
}
break;
@ -77,7 +80,7 @@ void CEeprom::EepromCommand ( BYTE * Command)
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
ReadFrom(&Command[4],Command[3]);
ReadFrom(&Command[4], Command[3]);
break;
case 5: //Write to Eeprom
if (Command[0] != 10 && bHaveDebugger())
@ -88,7 +91,7 @@ void CEeprom::EepromCommand ( BYTE * Command)
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
WriteTo(&Command[4],Command[3]);
WriteTo(&Command[4], Command[3]);
break;
case 6: //RTC Status query
Command[3] = 0x00;
@ -131,7 +134,7 @@ void CEeprom::EepromCommand ( BYTE * Command)
default:
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{
g_Notify->DisplayError(stdstr_f("Unknown EepromCommand %d",Command[2]).ToUTF16().c_str());
g_Notify->DisplayError(stdstr_f("Unknown EepromCommand %d", Command[2]).ToUTF16().c_str());
}
}
}
@ -141,9 +144,9 @@ void CEeprom::LoadEeprom()
CPath FileName;
DWORD dwRead;
memset(m_EEPROM,0xFF,sizeof(m_EEPROM));
memset(m_EEPROM, 0xFF, sizeof(m_EEPROM));
FileName.SetDriveDirectory( g_Settings->LoadStringVal(Directory_NativeSave).c_str());
FileName.SetDriveDirectory(g_Settings->LoadStringVal(Directory_NativeSave).c_str());
FileName.SetName(g_Settings->LoadStringVal(Game_GameName).c_str());
FileName.SetExtension("eep");
@ -152,47 +155,47 @@ void CEeprom::LoadEeprom()
FileName.DirectoryCreate();
}
m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,
m_hFile = CreateFile(FileName, m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (m_hFile == INVALID_HANDLE_VALUE)
{
WriteTraceF(TraceError,__FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError());
WriteTraceF(TraceError, __FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X", (LPCTSTR)FileName, m_ReadOnly, GetLastError());
g_Notify->DisplayError(GS(MSG_FAIL_OPEN_EEPROM));
return;
}
SetFilePointer(m_hFile,0,NULL,FILE_BEGIN);
ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL);
SetFilePointer(m_hFile, 0, NULL, FILE_BEGIN);
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)
{
LoadEeprom();
}
for (i=0; i < 8; i++)
for (i = 0; i < 8; i++)
{
Buffer[i] = m_EEPROM[line*8+i];
Buffer[i] = m_EEPROM[line * 8 + i];
}
}
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)
{
LoadEeprom();
}
for (i=0;i<8;i++)
for (i = 0; i < 8; i++)
{
m_EEPROM[line*8+i]=Buffer[i];
m_EEPROM[line * 8 + i] = Buffer[i];
}
SetFilePointer(m_hFile,line*8,NULL,FILE_BEGIN);
WriteFile( m_hFile,Buffer,8,&dwWritten,NULL );
SetFilePointer(m_hFile, line * 8, NULL, FILE_BEGIN);
WriteFile(m_hFile, Buffer, 8, &dwWritten, NULL);
FlushFileBuffers(m_hFile);
}

View File

@ -14,17 +14,21 @@ class CEeprom :
private CDebugSettings
{
public:
CEeprom ( bool ReadOnly );
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;
};

View File

@ -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);
}
}
@ -377,12 +363,12 @@ void CN64System::StartEmulationThread(ThreadInfo * Info)
{
if (g_Settings->LoadBool(Setting_CN64TimeCritical))
{
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
}
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())

View File

@ -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;

View File

@ -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);

File diff suppressed because it is too large Load Diff

View File

@ -73,30 +73,30 @@ public:
bool operator==(const CRegInfo& right) const;
bool operator!=(const CRegInfo& right) const;
static REG_STATE ConstantsType ( int64_t Value );
static REG_STATE ConstantsType(int64_t Value);
void FixRoundModel ( FPU_ROUND RoundMethod );
void ChangeFPURegFormat ( int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel );
void Load_FPR_ToTop ( int32_t Reg, int32_t RegToLoad, FPU_STATE Format);
bool RegInStack ( int32_t Reg, FPU_STATE Format );
void UnMap_AllFPRs ();
void UnMap_FPR ( int32_t Reg, bool WriteBackValue );
x86FpuValues StackPosition( int32_t Reg );
void FixRoundModel(FPU_ROUND RoundMethod);
void ChangeFPURegFormat(int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel);
void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Format);
bool RegInStack(int32_t Reg, FPU_STATE Format);
void UnMap_AllFPRs();
void UnMap_FPR(int32_t Reg, bool WriteBackValue);
x86FpuValues StackPosition(int32_t Reg);
x86Reg FreeX86Reg ();
x86Reg Free8BitX86Reg ();
void Map_GPR_32bit ( int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad );
void Map_GPR_64bit ( int32_t MipsReg, int32_t MipsRegToLoad );
x86Reg Get_MemoryStack () const;
x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true );
x86Reg Map_TempReg ( x86Reg Reg, int32_t MipsReg, bool LoadHiWord );
void ProtectGPR ( uint32_t Reg );
void UnProtectGPR ( uint32_t Reg );
void ResetX86Protection ();
x86Reg UnMap_TempReg ();
void UnMap_GPR ( uint32_t Reg, bool WriteBackValue );
bool UnMap_X86reg ( x86Reg Reg );
void WriteBackRegisters ();
x86Reg FreeX86Reg();
x86Reg Free8BitX86Reg();
void Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad);
void Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad);
x86Reg Get_MemoryStack() const;
x86Reg Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool LoadValue = true);
x86Reg Map_TempReg(x86Reg Reg, int32_t MipsReg, bool LoadHiWord);
void ProtectGPR(uint32_t Reg);
void UnProtectGPR(uint32_t Reg);
void ResetX86Protection();
x86Reg UnMap_TempReg();
void UnMap_GPR(uint32_t Reg, bool WriteBackValue);
bool UnMap_X86reg(x86Reg Reg);
void WriteBackRegisters();
bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); }
@ -114,33 +114,33 @@ public:
bool Is32BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); }
bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
REG_STATE GetMipsRegState ( int32_t Reg ) const { return m_MIPS_RegState[Reg]; }
uint64_t GetMipsReg ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UDW; }
int64_t GetMipsReg_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].DW; }
uint32_t GetMipsRegLo ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UW[0]; }
int32_t GetMipsRegLo_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].W[0]; }
uint32_t GetMipsRegHi ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UW[1]; }
int32_t GetMipsRegHi_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].W[1]; }
CX86Ops::x86Reg GetMipsRegMapLo ( int32_t Reg ) const { return m_RegMapLo[Reg]; }
CX86Ops::x86Reg GetMipsRegMapHi ( int32_t Reg ) const { return m_RegMapHi[Reg]; }
REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; }
int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; }
uint32_t GetMipsRegLo(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[0]; }
int32_t GetMipsRegLo_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[0]; }
uint32_t GetMipsRegHi(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[1]; }
int32_t GetMipsRegHi_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[1]; }
CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; }
CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; }
uint32_t GetX86MapOrder ( x86Reg Reg ) const { return m_x86reg_MapOrder[Reg]; }
bool GetX86Protected ( x86Reg Reg ) const { return m_x86reg_Protected[Reg]; }
REG_MAPPED GetX86Mapped ( x86Reg Reg ) const { return m_x86reg_MappedTo[Reg]; }
uint32_t GetX86MapOrder(x86Reg Reg) const { return m_x86reg_MapOrder[Reg]; }
bool GetX86Protected(x86Reg Reg) const { return m_x86reg_Protected[Reg]; }
REG_MAPPED GetX86Mapped(x86Reg Reg) const { return m_x86reg_MappedTo[Reg]; }
uint32_t GetBlockCycleCount() const { return m_CycleCount; }
void SetMipsReg ( int32_t Reg, uint64_t Value ) { m_MIPS_RegVal[Reg].UDW = Value; }
void SetMipsReg_S ( int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
void SetMipsRegLo ( int32_t Reg, uint32_t Value ) { m_MIPS_RegVal[Reg].UW[0] = Value; }
void SetMipsRegHi ( int32_t Reg, uint32_t Value ) { m_MIPS_RegVal[Reg].UW[1] = Value; }
void SetMipsRegMapLo ( int32_t GetMipsReg, x86Reg Reg ) { m_RegMapLo[GetMipsReg] = Reg; }
void SetMipsRegMapHi ( int32_t GetMipsReg, x86Reg Reg ) { m_RegMapHi[GetMipsReg] = Reg; }
void SetMipsRegState ( int32_t GetMipsReg, REG_STATE State ) { m_MIPS_RegState[GetMipsReg] = State; }
void SetMipsReg(int32_t Reg, uint64_t Value) { m_MIPS_RegVal[Reg].UDW = Value; }
void SetMipsReg_S(int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; }
void SetMipsRegHi(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[1] = Value; }
void SetMipsRegMapLo(int32_t GetMipsReg, x86Reg Reg) { m_RegMapLo[GetMipsReg] = Reg; }
void SetMipsRegMapHi(int32_t GetMipsReg, x86Reg Reg) { m_RegMapHi[GetMipsReg] = Reg; }
void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
void SetX86MapOrder ( x86Reg Reg, uint32_t Order ) { m_x86reg_MapOrder[Reg] = Order; }
void SetX86Protected ( x86Reg Reg, bool Protected ) { m_x86reg_Protected[Reg] = Protected; }
void SetX86Mapped ( x86Reg Reg, REG_MAPPED Mapping ) { m_x86reg_MappedTo[Reg] = Mapping; }
void SetX86MapOrder(x86Reg Reg, uint32_t Order) { m_x86reg_MapOrder[Reg] = Order; }
void SetX86Protected(x86Reg Reg, bool Protected) { m_x86reg_Protected[Reg] = Protected; }
void SetX86Mapped(x86Reg Reg, REG_MAPPED Mapping) { m_x86reg_MappedTo[Reg] = Mapping; }
void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }

View File

@ -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");

View File

@ -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;