Global Variable: rename _Rom to g_Rom

This commit is contained in:
zilmar 2012-11-17 13:24:42 +11:00
parent 1992505c7f
commit 7f248146b2
13 changed files with 45 additions and 45 deletions

View File

@ -356,7 +356,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return;
}
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < _Rom->GetRomSize())) { return; }
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) { return; }
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) {
if (!LogOptions.LogRomHeader) { return; }

View File

@ -74,7 +74,7 @@ LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndC
break;
case IDC_BTN_ROM:
m_PAddrStart.SetValue(0x10000000,true,true);
m_SearchLen.SetValue(_Rom->GetRomSize(),true,true);
m_SearchLen.SetValue(g_Rom->GetRomSize(),true,true);
break;
case IDC_BTN_SPMEM:
m_PAddrStart.SetValue(0x04000000,true,true);

View File

@ -7,13 +7,13 @@ CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
}
void CDMA::OnFirstDMA (void) {
switch (_Rom->CicChipID()) {
switch (g_Rom->CicChipID()) {
case 1: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case 2: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case 3: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case 5: *(DWORD *)&((g_MMU->Rdram())[0x3F0]) = g_MMU->RdramSize(); break;
case 6: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
default: g_Notify->DisplayError("Unhandled CicChip(%d) in first DMA",_Rom->CicChipID());
default: g_Notify->DisplayError("Unhandled CicChip(%d) in first DMA",g_Rom->CicChipID());
}
}
@ -121,16 +121,16 @@ void CDMA::PI_DMA_WRITE (void) {
}
#endif
#endif
BYTE * ROM = _Rom->GetRomAddress();
BYTE * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram();
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + g_Reg->PI_WR_LEN_REG + 1 < _Rom->GetRomSize()) {
if (g_Reg->PI_CART_ADDR_REG + g_Reg->PI_WR_LEN_REG + 1 < g_Rom->GetRomSize()) {
for (i = 0; i < g_Reg->PI_WR_LEN_REG + 1; i ++) {
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
} else {
DWORD Len;
Len = _Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i ++) {
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}

View File

@ -91,21 +91,21 @@ BOOL CMipsMemoryVM::Initialize ( void )
{
m_RomMapped = true;
m_Rom = m_RDRAM + 0x10000000;
m_RomSize = _Rom->GetRomSize();
if(VirtualAlloc(m_Rom, _Rom->GetRomSize(), MEM_COMMIT, PAGE_READWRITE)==NULL)
m_RomSize = g_Rom->GetRomSize();
if(VirtualAlloc(m_Rom, g_Rom->GetRomSize(), MEM_COMMIT, PAGE_READWRITE)==NULL)
{
WriteTraceF(TraceError,"CMipsMemoryVM::Initialize:: Failed to Allocate Rom (Size: 0x%X)",_Rom->GetRomSize());
WriteTraceF(TraceError,"CMipsMemoryVM::Initialize:: Failed to Allocate Rom (Size: 0x%X)",g_Rom->GetRomSize());
FreeMemory();
return false;
}
memcpy(m_Rom,_Rom->GetRomAddress(),_Rom->GetRomSize());
memcpy(m_Rom,g_Rom->GetRomAddress(),g_Rom->GetRomSize());
DWORD OldProtect;
VirtualProtect(m_Rom,_Rom->GetRomSize(),PAGE_READONLY, &OldProtect);
VirtualProtect(m_Rom,g_Rom->GetRomSize(),PAGE_READONLY, &OldProtect);
} else {
m_RomMapped = false;
m_Rom = _Rom->GetRomAddress();
m_RomSize = _Rom->GetRomSize();
m_Rom = g_Rom->GetRomAddress();
m_RomSize = g_Rom->GetRomSize();
}
CPifRam::Reset();
@ -1983,7 +1983,7 @@ int CMipsMemoryVM::SH_NonMemory ( DWORD PAddr, WORD Value ) {
int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
if (PAddr >= 0x10000000 && PAddr < 0x16000000)
{
if ((PAddr - 0x10000000) < _Rom->GetRomSize()) {
if ((PAddr - 0x10000000) < g_Rom->GetRomSize()) {
m_RomWrittenTo = TRUE;
m_RomWroteValue = Value;
#ifdef ROM_IN_MAPSPACE

View File

@ -33,7 +33,7 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
m_Limitor.SetHertz(g_Settings->LoadDword(Game_ScreenHertz));
m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats));
switch (_Rom->GetCountry())
switch (g_Rom->GetCountry())
{
case Germany: case french: case Italian:
case Europe: case Spanish: case Australia:
@ -237,16 +237,16 @@ void CN64System::stLoadFileImage ( FileImageInfo * Info )
g_Notify->RefreshMenu();
//Try to load the passed N64 rom
if (_Rom == NULL)
if (g_Rom == NULL)
{
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Allocating global rom object");
_Rom = new CN64Rom();
g_Rom = new CN64Rom();
} else {
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Use existing global rom object");
}
WriteTraceF(TraceDebug,"CN64System::stLoadFileImage: Loading \"%s\"",ImageInfo.FileName.c_str());
if (_Rom->LoadN64Image(ImageInfo.FileName.c_str()))
if (g_Rom->LoadN64Image(ImageInfo.FileName.c_str()))
{
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Add Recent Rom");
g_Notify->AddRecentRom(ImageInfo.FileName.c_str());
@ -259,9 +259,9 @@ void CN64System::stLoadFileImage ( FileImageInfo * Info )
g_Notify->RefreshMenu();
} else {
WriteTraceF(TraceError,"CN64System::stLoadFileImage: LoadN64Image failed (\"%s\")",ImageInfo.FileName.c_str());
g_Notify->DisplayError(_Rom->GetError());
delete _Rom;
_Rom = NULL;
g_Notify->DisplayError(g_Rom->GetError());
delete g_Rom;
g_Rom = NULL;
g_Settings->SaveBool(GameRunning_LoadingInProgress,false);
g_Notify->RefreshMenu();
return;
@ -409,9 +409,9 @@ void CN64System::SelectCheats ( WND_HANDLE hParent )
}
void CN64System::DisplayRomInfo ( WND_HANDLE hParent ) {
if (!_Rom) { return; }
if (!g_Rom) { return; }
RomInformation Info(_Rom);
RomInformation Info(g_Rom);
Info.DisplayInformation(hParent);
}
@ -493,7 +493,7 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory)
InitRegisters(PostPif,m_MMU_VM);
if (PostPif)
{
memcpy((m_MMU_VM.Dmem()+0x40), (_Rom->GetRomAddress() + 0x040), 0xFBC);
memcpy((m_MMU_VM.Dmem()+0x40), (g_Rom->GetRomAddress() + 0x040), 0xFBC);
}
} else {
m_Reg.Reset();
@ -630,11 +630,11 @@ void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU )
m_Reg.m_GPR[29].DW=0xFFFFFFFFA4001FF0;
m_Reg.m_GPR[30].DW=0x0000000000000000;
switch (_Rom->GetCountry()) {
switch (g_Rom->GetCountry()) {
case Germany: case french: case Italian:
case Europe: case Spanish: case Australia:
case X_PAL: case Y_PAL:
switch (_Rom->CicChipID()) {
switch (g_Rom->CicChipID()) {
case CIC_NUS_6102:
m_Reg.m_GPR[5].DW=0xFFFFFFFFC0F1D859;
m_Reg.m_GPR[14].DW=0x000000002DE108EA;
@ -664,7 +664,7 @@ void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU )
break;
case NTSC_BETA: case X_NTSC: case USA: case Japan:
default:
switch (_Rom->CicChipID()) {
switch (g_Rom->CicChipID()) {
case CIC_NUS_6102:
m_Reg.m_GPR[5].DW=0xFFFFFFFFC95973D5;
m_Reg.m_GPR[14].DW=0x000000002449A366;
@ -688,7 +688,7 @@ void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU )
m_Reg.m_GPR[31].DW=0xFFFFFFFFA4001550;
}
switch (_Rom->CicChipID()) {
switch (g_Rom->CicChipID()) {
case CIC_NUS_6101:
m_Reg.m_GPR[22].DW=0x000000000000003F;
break;
@ -748,7 +748,7 @@ void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU )
m_Reg.m_PROGRAM_COUNTER = 0xBFC00000;
/* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values
switch (_Rom->CicChipID()) {
switch (g_Rom->CicChipID()) {
case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break;
case CIC_NUS_6102: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x3F; break;
case CIC_NUS_6103: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x78; break;
@ -1214,7 +1214,7 @@ bool CN64System::SaveState(void)
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,_Rom->GetRomAddress(),0x40);
zipWriteInFileInZip(file,g_Rom->GetRomAddress(),0x40);
zipWriteInFileInZip(file,&NextViTimer,sizeof(DWORD));
zipWriteInFileInZip(file,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER));
zipWriteInFileInZip(file,m_Reg.m_GPR,sizeof(__int64)*32);
@ -1258,7 +1258,7 @@ bool CN64System::SaveState(void)
SetFilePointer(hSaveFile,0,NULL,FILE_BEGIN);
WriteFile( hSaveFile,&SaveID_0,sizeof(DWORD),&dwWritten,NULL);
WriteFile( hSaveFile,&RdramSize,sizeof(DWORD),&dwWritten,NULL);
WriteFile( hSaveFile,_Rom->GetRomAddress(),0x40,&dwWritten,NULL);
WriteFile( hSaveFile,g_Rom->GetRomAddress(),0x40,&dwWritten,NULL);
WriteFile( hSaveFile,&NextViTimer,sizeof(DWORD),&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);
@ -1384,7 +1384,7 @@ bool CN64System::LoadState(LPCSTR FileName) {
BYTE LoadHeader[64];
unzReadCurrentFile(file,LoadHeader,0x40);
if (memcmp(LoadHeader,_Rom->GetRomAddress(),0x40) != 0) {
if (memcmp(LoadHeader,g_Rom->GetRomAddress(),0x40) != 0) {
//if (inFullScreen) { return FALSE; }
int result = MessageBox(NULL,GS(MSG_SAVE_STATE_HEADER),GS(MSG_MSGBOX_TITLE),
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
@ -1444,7 +1444,7 @@ bool CN64System::LoadState(LPCSTR FileName) {
//Check header
BYTE LoadHeader[64];
ReadFile( hSaveFile,LoadHeader,0x40,&dwRead,NULL);
if (memcmp(LoadHeader,_Rom->GetRomAddress(),0x40) != 0) {
if (memcmp(LoadHeader,g_Rom->GetRomAddress(),0x40) != 0) {
//if (inFullScreen) { return FALSE; }
int result = MessageBox(NULL,GS(MSG_SAVE_STATE_HEADER),GS(MSG_MSGBOX_TITLE),
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);

View File

@ -443,7 +443,7 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
m_RomIdent.Format("%08X-%08X-C:%X",*(DWORD *)(&m_ROMImage[0x10]),*(DWORD *)(&m_ROMImage[0x14]),m_ROMImage[0x3D]);
CalculateCicChip();
if (!LoadBootCodeOnly && _Rom == this)
if (!LoadBootCodeOnly && g_Rom == this)
{
SaveRomSettingID();
}

View File

@ -9,7 +9,7 @@ CTLB * g_TLB = NULL; //TLB Unit
CRegisters * g_Reg = NULL; //Current Register Set attacted to the g_MMU
CNotification * g_Notify = NULL;
CPlugins * g_Plugins = NULL;
CN64Rom * _Rom = NULL; //The current rom that this system is executing.. it can only execute one file at the time
CN64Rom * g_Rom = NULL; //The current rom that this system is executing.. it can only execute one file at the time
CAudio * _Audio = NULL;
CMemoryLabel * _Labels = NULL;
CSystemTimer * _SystemTimer = NULL;

View File

@ -9,7 +9,7 @@ extern CMipsMemory * g_MMU; //Memory of the n64
extern CTLB * g_TLB; //TLB Unit
extern CRegisters * g_Reg; //Current Register Set attached to the g_MMU
extern CPlugins * g_Plugins;
extern CN64Rom * _Rom; //The current rom that this system is executing.. it can only execute one file at the time
extern CN64Rom * g_Rom; //The current rom that this system is executing.. it can only execute one file at the time
extern CAudio * _Audio;
extern CMemoryLabel * _Labels;
extern CSystemTimer * _SystemTimer;

View File

@ -184,7 +184,7 @@ bool CAudioPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
Info.hwnd = (HWND)RenderWindow->m_hMainWindow;
Info.hinst = GetModuleHandle(NULL);
Info.MemoryBswaped = TRUE;
Info.HEADER = _Rom->GetRomAddress();
Info.HEADER = g_Rom->GetRomAddress();
Info.RDRAM = g_MMU->Rdram();
Info.DMEM = g_MMU->Dmem();
Info.IMEM = g_MMU->Imem();

View File

@ -189,7 +189,7 @@ bool CControl_Plugin::Initiate ( CN64System * System, CMainGui * RenderWindow )
m_Initilized = true;
} else {
ControlInfo.Controls = m_PluginControllers;
ControlInfo.HEADER = _Rom->GetRomAddress();
ControlInfo.HEADER = g_Rom->GetRomAddress();
ControlInfo.hinst = GetModuleHandle(NULL);
ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow;
ControlInfo.MemoryBswaped = TRUE;

View File

@ -250,7 +250,7 @@ bool CGfxPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
Info.CheckInterrupts = DummyCheckInterrupts;
Info.hWnd = (HWND)RenderWindow->m_hMainWindow;
Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd;
Info.HEADER = _Rom->GetRomAddress();
Info.HEADER = g_Rom->GetRomAddress();
Info.RDRAM = g_MMU->Rdram();
Info.DMEM = g_MMU->Dmem();
Info.IMEM = g_MMU->Imem();

View File

@ -762,8 +762,8 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
RomCheats.SelectCheats(hWnd,true);
}
if (_Rom) {
_Rom->SaveRomSettingID();
if (g_Rom) {
g_Rom->SaveRomSettingID();
} else {
Rom.ClearRomSettingID();
}
@ -797,8 +797,8 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
WriteTrace(TraceGfxPlugin,"OnRomBrowserMenuItem: Starting");
g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam),hWnd,RomHeader);
WriteTrace(TraceGfxPlugin,"OnRomBrowserMenuItem: Done");
if (_Rom) {
_Rom->SaveRomSettingID();
if (g_Rom) {
g_Rom->SaveRomSettingID();
} else {
g_Settings->SaveString(Game_IniKey,"");
}

View File

@ -336,7 +336,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lps
}
WriteTrace(TraceDebug,"WinMain - cleaning up global objects");
if (_Rom) { delete _Rom; _Rom = NULL; }
if (g_Rom) { delete g_Rom; g_Rom = NULL; }
if (g_Plugins) { delete g_Plugins; g_Plugins = NULL; }
if (g_Settings) { delete g_Settings; g_Settings = NULL; }
if (_Lang) { delete _Lang; _Lang = NULL; }