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,355 +11,353 @@
#include "stdafx.h" #include "stdafx.h"
CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) : CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
m_FlashRam(FlashRam), m_FlashRam(FlashRam),
m_Sram(Sram) m_Sram(Sram)
{ {
} }
void CDMA::OnFirstDMA() void CDMA::OnFirstDMA()
{ {
switch (g_Rom->CicChipID()) switch (g_Rom->CicChipID())
{ {
case CIC_NUS_6101: *(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: *(DWORD *)&((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_UNKNOWN:
case CIC_NUS_6102: *(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: *(DWORD *)&((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: *(DWORD *)&((g_MMU->Rdram())[0x3F0]) = g_MMU->RdramSize(); break; case CIC_NUS_6105: *(uint32_t *)&((g_MMU->Rdram())[0x3F0]) = g_MMU->RdramSize(); break;
case CIC_NUS_6106: *(DWORD *)&((g_MMU->Rdram())[0x318]) = 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()); default: g_Notify->DisplayError(stdstr_f("Unhandled CicChip(%d) in first DMA", g_Rom->CicChipID()).ToUTF16().c_str());
} }
} }
void CDMA::PI_DMA_READ() void CDMA::PI_DMA_READ()
{ {
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY; // 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) if ((PI_RD_LEN_REG & 1) != 0)
{ {
PI_RD_LEN_REG += 1; 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()) if (bHaveDebugger())
{ {
g_Notify->DisplayError(stdstr_f("PI_DMA_READ not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG).ToUTF16().c_str()); g_Notify->DisplayError(stdstr_f("PI_DMA_READ not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG).ToUTF16().c_str());
} }
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; return;
} }
//Write ROM Area (for 64DD Convert) //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)) if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF && g_Settings->LoadBool(Game_AllowROMWrites))
{ {
DWORD i; uint32_t i;
BYTE * ROM = g_Rom->GetRomAddress(); uint8_t * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram(); uint8_t * RDRAM = g_MMU->Rdram();
DWORD OldProtect; DWORD OldProtect;
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READWRITE, &OldProtect); VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READWRITE, &OldProtect);
g_Reg->PI_CART_ADDR_REG -= 0x10000000; g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_RD_LEN_REG < g_Rom->GetRomSize()) if (g_Reg->PI_CART_ADDR_REG + PI_RD_LEN_REG < g_Rom->GetRomSize())
{ {
for (i = 0; i < PI_RD_LEN_REG; i++) for (i = 0; i < PI_RD_LEN_REG; i++)
{ {
*(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)) = *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3));
} }
} }
else else
{ {
DWORD Len; uint32_t Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG; Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i++) for (i = 0; i < Len; i++)
{ {
*(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)) = *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3));
} }
} }
g_Reg->PI_CART_ADDR_REG += 0x10000000; g_Reg->PI_CART_ADDR_REG += 0x10000000;
if (!g_System->DmaUsed()) if (!g_System->DmaUsed())
{ {
g_System->SetDmaUsed(true); g_System->SetDmaUsed(true);
OnFirstDMA(); OnFirstDMA();
} }
if (g_Recompiler && g_System->bSMM_PIDMA()) 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);
} }
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READONLY, &OldProtect); VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READONLY, &OldProtect);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; 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) if (g_System->m_SaveUsing == SaveChip_Auto)
{ {
g_System->m_SaveUsing = SaveChip_Sram; g_System->m_SaveUsing = SaveChip_Sram;
} }
if (g_System->m_SaveUsing == SaveChip_Sram) if (g_System->m_SaveUsing == SaveChip_Sram)
{ {
m_Sram.DmaToSram( m_Sram.DmaToSram(
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, g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG PI_RD_LEN_REG
); );
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; return;
} }
if (g_System->m_SaveUsing == SaveChip_FlashRam) if (g_System->m_SaveUsing == SaveChip_FlashRam)
{ {
m_FlashRam.DmaToFlashram( 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, g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG PI_RD_LEN_REG
); );
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; return;
} }
} }
if (g_System->m_SaveUsing == SaveChip_FlashRam) 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->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; return;
} }
if (bHaveDebugger()) if (bHaveDebugger())
{ {
g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you dmaing to ? : %08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str()); g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you dmaing to ? : %08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
} }
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; return;
} }
void CDMA::PI_DMA_WRITE() 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) if ((PI_WR_LEN_REG & 1) != 0)
{ {
PI_WR_LEN_REG += 1; /* fixes AI Shougi 3, Doraemon 3, etc. */ PI_WR_LEN_REG += 1; /* fixes AI Shougi 3, Doraemon 3, etc. */
} }
g_Reg->PI_STATUS_REG |= PI_STATUS_DMA_BUSY; 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()); } 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; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; 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) if (g_System->m_SaveUsing == SaveChip_Auto)
{ {
g_System->m_SaveUsing = SaveChip_Sram; g_System->m_SaveUsing = SaveChip_Sram;
} }
if (g_System->m_SaveUsing == SaveChip_Sram) if (g_System->m_SaveUsing == SaveChip_Sram)
{ {
m_Sram.DmaFromSram( 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, g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG PI_WR_LEN_REG
); );
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
return; return;
} }
if (g_System->m_SaveUsing == SaveChip_FlashRam) if (g_System->m_SaveUsing == SaveChip_FlashRam)
{ {
m_FlashRam.DmaFromFlashram( 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, g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG PI_WR_LEN_REG
); );
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
} }
return; 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 tofix
#ifdef ROM_IN_MAPSPACE #ifdef ROM_IN_MAPSPACE
if (WrittenToRom) if (WrittenToRom)
{ {
DWORD OldProtect; uint32_t OldProtect;
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect); VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
} }
#endif #endif
#endif #endif
BYTE * ROM = g_Rom->GetRomAddress(); uint8_t * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram(); uint8_t * RDRAM = g_MMU->Rdram();
g_Reg->PI_CART_ADDR_REG -= 0x10000000; g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize()) 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()) 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()) while (cart >= g_Rom->GetRomSize())
{ {
cart -= g_Rom->GetRomSize(); cart -= 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 + ((cart + i) ^ 3)); *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((cart + i) ^ 3));
} }
} }
else else
{ {
DWORD Len; uint32_t Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG; 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; g_Reg->PI_CART_ADDR_REG += 0x10000000;
if (!g_System->DmaUsed()) if (!g_System->DmaUsed())
{ {
g_System->SetDmaUsed(true); g_System->SetDmaUsed(true);
OnFirstDMA(); OnFirstDMA();
} }
if (g_Recompiler && g_System->bSMM_PIDMA()) 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->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
//ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9) + 50); //ChangeTimer(PiTimer,(int32_t)(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));
return; return;
} }
if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory))
{
g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in ROM: %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();
if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory))
{
g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in ROM: %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();
} }
void CDMA::SP_DMA_READ() void CDMA::SP_DMA_READ()
{ {
g_Reg->SP_DRAM_ADDR_REG &= 0x1FFFFFFF; g_Reg->SP_DRAM_ADDR_REG &= 0x1FFFFFFF;
if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize()) if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
{ {
if (bHaveDebugger()) if (bHaveDebugger())
{ {
g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str()); g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str());
} }
g_Reg->SP_DMA_BUSY_REG = 0; g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY; g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
return; return;
} }
if (g_Reg->SP_RD_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000) if (g_Reg->SP_RD_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{ {
if (bHaveDebugger()) if (bHaveDebugger())
{ {
g_Notify->DisplayError(__FUNCTIONW__ L"\nCould not fit copy in memory segment"); g_Notify->DisplayError(__FUNCTIONW__ L"\nCould not fit copy in memory segment");
} }
return; return;
} }
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0) 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) 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) 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, 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_RD_LEN_REG + 1);
g_Reg->SP_DMA_BUSY_REG = 0; g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY; g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
} }
void CDMA::SP_DMA_WRITE() void CDMA::SP_DMA_WRITE()
{ {
if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize()) if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
{ {
if (bHaveDebugger()) if (bHaveDebugger())
{ {
g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str()); g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str());
} }
return; return;
} }
if (g_Reg->SP_WR_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000) if (g_Reg->SP_WR_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{ {
if (bHaveDebugger()) if (bHaveDebugger())
{ {
g_Notify->DisplayError(L"SP DMA WRITE\ncould not fit copy in memory segement"); g_Notify->DisplayError(L"SP DMA WRITE\ncould not fit copy in memory segement");
} }
return; return;
} }
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0) 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) 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) 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_WR_LEN_REG + 1);
g_Reg->SP_DMA_BUSY_REG = 0; g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY; g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
} }

View File

@ -9,27 +9,30 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\Settings\Debug Settings.h>
#include <Project64\N64 System\Mips\FlashRam.h>
#include <Project64\N64 System\Mips\Sram.h>
class CDMA : class CDMA :
private CDebugSettings private CDebugSettings
{ {
CDMA(); CDMA();
public: public:
void SP_DMA_READ(); void SP_DMA_READ();
void SP_DMA_WRITE(); void SP_DMA_WRITE();
void PI_DMA_READ(); void PI_DMA_READ();
void PI_DMA_WRITE(); void PI_DMA_WRITE();
protected: protected:
CDMA (CFlashram & FlashRam, CSram & Sram); CDMA(CFlashram & FlashRam, CSram & Sram);
//void SI_DMA_READ();
//void SI_DMA_WRITE();
private: private:
CFlashram & m_FlashRam; CDMA(const CDMA&); // Disable copy constructor
CSram & m_Sram; CDMA& operator=(const CDMA&); // Disable assignment
void OnFirstDMA(); CFlashram & m_FlashRam;
CSram & m_Sram;
void OnFirstDMA();
}; };

View File

@ -9,190 +9,193 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include "Eeprom.h"
#include <Project64\N64 System\System Globals.h>
#include <Project64\N64 System\N64 Class.h>
#include <time.h> #include <time.h>
CEeprom::CEeprom(bool ReadOnly): CEeprom::CEeprom(bool ReadOnly) :
m_ReadOnly(ReadOnly), m_ReadOnly(ReadOnly),
m_hFile(NULL) m_hFile(NULL)
{ {
memset(m_EEPROM,0xFF,sizeof(m_EEPROM)); memset(m_EEPROM, 0xFF, sizeof(m_EEPROM));
} }
CEeprom::~CEeprom() CEeprom::~CEeprom()
{ {
if (m_hFile) if (m_hFile)
{ {
CloseHandle(m_hFile); CloseHandle(m_hFile);
m_hFile = NULL; m_hFile = NULL;
} }
} }
unsigned char byte2bcd(int n) uint8_t byte2bcd(int32_t n)
{ {
n %= 100; 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; time_t curtime_time;
struct tm curtime; struct tm curtime;
if (g_System->m_SaveUsing == SaveChip_Auto) if (g_System->m_SaveUsing == SaveChip_Auto)
{ {
g_System->m_SaveUsing = SaveChip_Eeprom_4K; g_System->m_SaveUsing = SaveChip_Eeprom_4K;
} }
switch (Command[2]) switch (Command[2])
{ {
case 0: // check case 0: // check
if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K) if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K)
{ {
Command[1] |= 0x80; Command[1] |= 0x80;
break; break;
} }
if (Command[1] != 3) if (Command[1] != 3)
{ {
Command[1] |= 0x40; Command[1] |= 0x40;
if ((Command[1] & 3) > 0) if ((Command[1] & 3) > 0)
Command[3] = 0x00; Command[3] = 0x00;
if ((Command[1] & 3) > 1) if ((Command[1] & 3) > 1)
Command[4] = (g_System->m_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0; Command[4] = (g_System->m_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0;
if ((Command[1] & 3) > 2) if ((Command[1] & 3) > 2)
Command[5] = 0x00; Command[5] = 0x00;
} }
else else
{ {
Command[3] = 0x00; 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; Command[5] = 0x00;
} }
break; break;
case 4: // Read from Eeprom case 4: // Read from Eeprom
if (Command[0] != 2 && bHaveDebugger()) if (Command[0] != 2 && bHaveDebugger())
{ {
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
} }
if (Command[1] != 8 && bHaveDebugger()) if (Command[1] != 8 && bHaveDebugger())
{ {
g_Notify->DisplayError(L"What am I meant to do with this Eeprom 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; break;
case 5: //Write to Eeprom case 5: //Write to Eeprom
if (Command[0] != 10 && bHaveDebugger()) if (Command[0] != 10 && bHaveDebugger())
{ {
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
} }
if (Command[1] != 1 && bHaveDebugger()) if (Command[1] != 1 && bHaveDebugger())
{ {
g_Notify->DisplayError(L"What am I meant to do with this Eeprom 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; break;
case 6: //RTC Status query case 6: //RTC Status query
Command[3] = 0x00; Command[3] = 0x00;
Command[4] = 0x10; Command[4] = 0x10;
Command[5] = 0x00; Command[5] = 0x00;
break; break;
case 7: //Read RTC block case 7: //Read RTC block
switch (Command[3]) switch (Command[3])
{ {
case 0: //Block number case 0: //Block number
Command[4] = 0x00; Command[4] = 0x00;
Command[5] = 0x02; Command[5] = 0x02;
Command[12] = 0x00; Command[12] = 0x00;
break; break;
case 1: case 1:
//read block, Command[2], Unimplemented //read block, Command[2], Unimplemented
break; break;
case 2: //Set RTC Time case 2: //Set RTC Time
time(&curtime_time); time(&curtime_time);
memcpy(&curtime, localtime(&curtime_time), sizeof(curtime)); // fd's fix memcpy(&curtime, localtime(&curtime_time), sizeof(curtime)); // fd's fix
Command[4] = byte2bcd(curtime.tm_sec); Command[4] = byte2bcd(curtime.tm_sec);
Command[5] = byte2bcd(curtime.tm_min); Command[5] = byte2bcd(curtime.tm_min);
Command[6] = 0x80 + byte2bcd(curtime.tm_hour); Command[6] = 0x80 + byte2bcd(curtime.tm_hour);
Command[7] = byte2bcd(curtime.tm_mday); Command[7] = byte2bcd(curtime.tm_mday);
Command[8] = byte2bcd(curtime.tm_wday); Command[8] = byte2bcd(curtime.tm_wday);
Command[9] = byte2bcd(curtime.tm_mon + 1); Command[9] = byte2bcd(curtime.tm_mon + 1);
Command[10] = byte2bcd(curtime.tm_year); Command[10] = byte2bcd(curtime.tm_year);
Command[11] = byte2bcd(curtime.tm_year / 100); Command[11] = byte2bcd(curtime.tm_year / 100);
Command[12] = 0x00; // status Command[12] = 0x00; // status
break; break;
} }
break; break;
case 8: case 8:
//Write RTC, unimplemented //Write RTC, unimplemented
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{ {
g_Notify->DisplayError(L"Write RTC, unimplemented"); g_Notify->DisplayError(L"Write RTC, unimplemented");
} }
break; break;
default: default:
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) 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());
} }
} }
} }
void CEeprom::LoadEeprom() void CEeprom::LoadEeprom()
{ {
CPath FileName; CPath FileName;
DWORD dwRead; 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.SetName(g_Settings->LoadStringVal(Game_GameName).c_str());
FileName.SetExtension("eep"); FileName.SetExtension("eep");
if (!FileName.DirectoryExists()) if (!FileName.DirectoryExists())
{ {
FileName.DirectoryCreate(); 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); FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (m_hFile == INVALID_HANDLE_VALUE) 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)); g_Notify->DisplayError(GS(MSG_FAIL_OPEN_EEPROM));
return; return;
} }
SetFilePointer(m_hFile,0,NULL,FILE_BEGIN); SetFilePointer(m_hFile, 0, NULL, FILE_BEGIN);
ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL); 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) if (m_hFile == NULL)
{ {
LoadEeprom(); 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; DWORD dwWritten;
int i; int32_t i;
if (m_hFile == NULL) if (m_hFile == NULL)
{ {
LoadEeprom(); 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); SetFilePointer(m_hFile, line * 8, NULL, FILE_BEGIN);
WriteFile( m_hFile,Buffer,8,&dwWritten,NULL ); WriteFile(m_hFile, Buffer, 8, &dwWritten, NULL);
FlushFileBuffers(m_hFile); FlushFileBuffers(m_hFile);
} }

View File

@ -11,20 +11,24 @@
#pragma once #pragma once
class CEeprom : class CEeprom :
private CDebugSettings private CDebugSettings
{ {
public: public:
CEeprom ( bool ReadOnly ); CEeprom(bool ReadOnly);
~CEeprom(); ~CEeprom();
void EepromCommand ( BYTE * Command ); void EepromCommand(uint8_t * Command);
private: private:
void LoadEeprom (); CEeprom(void); // Disable default constructor
void ReadFrom ( BYTE * Buffer, int line ); CEeprom(const CEeprom&); // Disable copy constructor
void WriteTo ( BYTE * Buffer, int line ); CEeprom& operator=(const CEeprom&); // Disable assignment
BYTE m_EEPROM[0x800]; void LoadEeprom();
bool m_ReadOnly; void ReadFrom(uint8_t * Buffer, int32_t line);
HANDLE m_hFile; void WriteTo(uint8_t * Buffer, int32_t line);
uint8_t m_EEPROM[0x800];
bool m_ReadOnly;
void * m_hFile;
}; };

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <common/Util.h>
#pragma warning(disable:4355) // Disable 'this' : used in base member initializer list #pragma warning(disable:4355) // Disable 'this' : used in base member initializer list
@ -44,7 +45,7 @@ m_CPU_ThreadID(0),
m_hPauseEvent(true), m_hPauseEvent(true),
m_CheatsSlectionChanged(false) m_CheatsSlectionChanged(false)
{ {
DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz); uint32_t gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
if (gameHertz == 0) if (gameHertz == 0)
{ {
gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60; gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60;
@ -180,10 +181,10 @@ bool CN64System::RunFileImage(const char * FileLoc)
{ {
return false; return false;
} }
WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading");
g_Settings->SaveString(Game_File, "");
//Mark the rom as loading //Mark the rom as loading
WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading");
g_Settings->SaveString(Game_File, "");
g_Settings->SaveBool(GameRunning_LoadingInProgress, true); g_Settings->SaveBool(GameRunning_LoadingInProgress, true);
//Try to load the passed N64 rom //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; bool bRes = true;
@ -268,7 +269,7 @@ bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId)
return bRes; return bRes;
} }
void CN64System::StartEmulation2(bool NewThread) void CN64System::StartEmulation2(bool NewThread)
{ {
if (NewThread) if (NewThread)
{ {
@ -280,7 +281,7 @@ void CN64System::StartEmulation2(bool NewThread)
CInterpreterCPU::BuildCPU(); 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)) if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled))
{ {
@ -321,40 +322,25 @@ void CN64System::StartEmulation2(bool NewThread)
{ {
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
Notify().ShowRomBrowser();
} }
else
{
ThreadInfo * Info = new ThreadInfo;
HANDLE * hThread = new HANDLE;
*hThread = NULL;
Notify().MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); //create the needed info into a structure to pass as one parameter
//for creating a thread
Info->ThreadHandle = hThread;
ThreadInfo * Info = new ThreadInfo; *hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, (LPDWORD)&Info->ThreadID);
HANDLE * hThread = new HANDLE; }
*hThread = NULL;
//create the needed info into a structure to pass as one parameter
//for creating a thread
Info->ThreadHandle = hThread;
*hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID);
} }
else else
{ {
//mark the emulation as starting and fix up menus //mark the emulation as starting and fix up menus
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); 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(); ExecuteCPU();
} }
} }
@ -367,22 +353,22 @@ void CN64System::StartEmulation(bool NewThread)
} }
__except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
{ {
char Message[600]; wchar_t message[400];
sprintf(Message, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); swprintf(message, sizeof(message), L"Exception caught\nFile: %s\nLine: %d", __FILEW__, __LINE__);
MessageBox(NULL, Message, "Exception", MB_OK); g_Notify->DisplayError(message);
} }
} }
void CN64System::StartEmulationThread(ThreadInfo * Info) void CN64System::StartEmulationThread(ThreadInfo * Info)
{ {
if (g_Settings->LoadBool(Setting_CN64TimeCritical)) if (g_Settings->LoadBool(Setting_CN64TimeCritical))
{ {
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
} }
CoInitialize(NULL); CoInitialize(NULL);
EmulationStarting(*Info->ThreadHandle, Info->ThreadID); EmulationStarting(Info->ThreadHandle, Info->ThreadID);
delete Info->ThreadHandle; delete Info->ThreadHandle;
delete Info; delete Info;
@ -458,8 +444,8 @@ void CN64System::Pause()
g_Notify->DisplayMessage(5, MSG_CPU_PAUSED); g_Notify->DisplayMessage(5, MSG_CPU_PAUSED);
m_hPauseEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT); m_hPauseEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT);
m_hPauseEvent.Reset(); m_hPauseEvent.Reset();
g_Settings->SaveBool(GameRunning_CPU_Paused, false); g_Settings->SaveBool(GameRunning_CPU_Paused, (uint32_t)false);
Notify().DisplayMessage(5, MSG_CPU_RESUMED); g_Notify->DisplayMessage(5, MSG_CPU_RESUMED);
} }
void CN64System::GameReset() void CN64System::GameReset()
@ -495,7 +481,6 @@ void CN64System::PluginReset()
} }
} }
} }
Notify().RefreshMenu();
if (m_Recomp) if (m_Recomp)
{ {
m_Recomp->Reset(); m_Recomp->Reset();
@ -827,22 +812,22 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemory & MMU)
m_Reg.m_PROGRAM_COUNTER = 0xBFC00000; m_Reg.m_PROGRAM_COUNTER = 0xBFC00000;
/* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values /* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values
switch (g_Rom->CicChipID()) { switch (g_Rom->CicChipID()) {
case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break; case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break;
case CIC_UNKNOWN: case CIC_UNKNOWN:
case CIC_NUS_6102: PIF_Ram[37] = 0x02; 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; case CIC_NUS_6103: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x78; break;
case CIC_NUS_6105: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x91; break; case CIC_NUS_6105: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x91; break;
case CIC_NUS_6106: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x85; break; case CIC_NUS_6106: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x85; break;
}*/ }*/
} }
} }
void CN64System::ExecuteCPU() void CN64System::ExecuteCPU()
{ {
//reset code //reset code
g_Settings->SaveBool(GameRunning_CPU_Running, true);
g_Settings->SaveBool(GameRunning_CPU_Paused, false); g_Settings->SaveBool(GameRunning_CPU_Paused, false);
g_Settings->SaveBool(GameRunning_CPU_Running, true);
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
m_EndEmulation = false; m_EndEmulation = false;
@ -865,8 +850,7 @@ void CN64System::ExecuteCPU()
#endif #endif
default: ExecuteInterpret(); break; default: ExecuteInterpret(); break;
} }
g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false); g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
Notify().WindowMode();
m_Plugins->RomClosed(); m_Plugins->RomClosed();
if (m_SyncCPU) if (m_SyncCPU)
{ {
@ -887,31 +871,24 @@ void CN64System::ExecuteRecompiler()
void CN64System::ExecuteSyncCPU() void CN64System::ExecuteSyncCPU()
{ {
Notify().BringToTop();
m_Recomp->Run(); m_Recomp->Run();
} }
void CN64System::CpuStopped() void CN64System::CpuStopped()
{ {
g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false);
Notify().WindowMode();
if (!m_InReset) if (!m_InReset)
{ {
Notify().RefreshMenu(); g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
Notify().MakeWindowOnTop(false);
g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED);
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
Notify().ShowRomBrowser();
}
} }
if (m_SyncCPU) if (m_SyncCPU)
{ {
m_SyncCPU->CpuStopped(); 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; int CyclesToExecute = Cycles - m_CyclesToSkip;
@ -1038,7 +1015,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
if (bFastSP() && m_Recomp) 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; ErrorFound = true;
} }
@ -1197,7 +1174,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
if (m_NextTimer != SecondCPU->m_NextTimer) 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_TLB.RecordDifference(Error, SecondCPU->m_TLB);
m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer); m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer);
@ -1207,13 +1184,13 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
} }
if (bFastSP() && m_Recomp) 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++) for (int z = 0, n = (RdramSize() >> 2); z < n; z++)
{ {
if (Rdram[z] != Rdram2[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++) for (int z = 0; z < (0x1000 >> 2); z++)
{ {
if (Imem[z] != Imem2[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]); 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++) for (int z = 0; z < (0x1000 >> 2); z++)
{ {
if (Dmem[z] != Dmem2[z]) if (Dmem[z] != Dmem2[z])
@ -1308,8 +1285,8 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
Error.Log("Code at PC:\r\n"); Error.Log("Code at PC:\r\n");
for (count = -10; count < 10; count++) for (count = -10; count < 10; count++)
{ {
DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2); uint32_t OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2);
if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) if (g_MMU->LW_VAddr(Addr, OpcodeValue))
{ {
Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); 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"); Error.Log("Code at Last Sync PC:\r\n");
for (count = 0; count < 50; count++) for (count = 0; count < 50; count++)
{ {
DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2); uint32_t OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2);
if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) if (g_MMU->LW_VAddr(Addr, OpcodeValue))
{ {
Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); 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; uint32_t SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23;
DWORD RdramSize = g_Settings->LoadDword(Game_RDRamSize); uint32_t RdramSize = g_Settings->LoadDword(Game_RDRamSize);
DWORD MiInterReg = g_Reg->MI_INTR_REG; uint32_t MiInterReg = g_Reg->MI_INTR_REG;
DWORD NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer); uint32_t NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer);
if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) if (g_Settings->LoadDword(Setting_AutoZipInstantSave))
{ {
zipFile file; zipFile file;
@ -1404,25 +1381,25 @@ bool CN64System::SaveState()
file = zipOpen(FileName.c_str(), 0); file = zipOpen(FileName.c_str(), 0);
zipOpenNewFileInZip(file, CurrentSaveName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); 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, &SaveID_0, sizeof(SaveID_0));
zipWriteInFileInZip(file, &RdramSize, sizeof(DWORD)); zipWriteInFileInZip(file, &RdramSize, sizeof(uint32_t));
zipWriteInFileInZip(file, g_Rom->GetRomAddress(), 0x40); 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_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER));
zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(__int64) * 32); zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(int64_t) * 32);
zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(__int64) * 32); zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(int64_t) * 32);
zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(DWORD) * 32); zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(uint32_t) * 32);
zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(uint32_t) * 32);
zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(__int64)); zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(int64_t));
zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(__int64)); zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(int64_t));
zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10);
zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10);
zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10);
zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4);
zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14);
zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6);
zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); 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, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40); zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40);
zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize); zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize);
@ -1450,26 +1427,27 @@ bool CN64System::SaveState()
//Write info to file //Write info to file
SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN);
WriteFile(hSaveFile, &SaveID_0, sizeof(DWORD), &dwWritten, NULL); DWORD dwWritten;
WriteFile(hSaveFile, &RdramSize, sizeof(DWORD), &dwWritten, NULL); 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, 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_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_GPR, sizeof(int64_t) * 32, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(int64_t) * 32, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(uint32_t) * 32, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(uint32_t) * 32, &dwWritten, NULL);
WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwWritten, NULL); WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(int64_t), &dwWritten, NULL);
WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwWritten, NULL); WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(int64_t), &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwWritten, NULL); WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8, &dwWritten, NULL);
WriteFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &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_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwWritten, NULL);
WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL); WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL);
WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL); WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL);
@ -1534,9 +1512,9 @@ bool CN64System::LoadState()
return LoadState(FileName); 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; bool LoadedZipFile = false, AudioResetOnLoad;
old_status = g_Reg->VI_STATUS_REG; old_status = g_Reg->VI_STATUS_REG;
old_width = g_Reg->VI_WIDTH_REG; old_width = g_Reg->VI_WIDTH_REG;
@ -1561,7 +1539,7 @@ bool CN64System::LoadState(LPCSTR FileName)
{ {
port = unzGoToFirstFile(file); port = unzGoToFirstFile(file);
} }
DWORD Value; uint32_t Value;
while (port == UNZ_OK) while (port == UNZ_OK)
{ {
unz_file_info info; unz_file_info info;
@ -1592,7 +1570,7 @@ bool CN64System::LoadState(LPCSTR FileName)
unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize)); unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize));
//Check header //Check header
BYTE LoadHeader[64]; uint8_t LoadHeader[64];
unzReadCurrentFile(file, LoadHeader, 0x40); unzReadCurrentFile(file, LoadHeader, 0x40);
if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0)
{ {
@ -1610,21 +1588,21 @@ bool CN64System::LoadState(LPCSTR FileName)
g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize);
unzReadCurrentFile(file, &NextVITimer, sizeof(NextVITimer)); unzReadCurrentFile(file, &NextVITimer, sizeof(NextVITimer));
unzReadCurrentFile(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); 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_GPR, sizeof(int64_t) * 32);
unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(__int64) * 32); unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(int64_t) * 32);
unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(DWORD) * 32); unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(uint32_t) * 32);
unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(uint32_t) * 32);
unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(__int64)); unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(int64_t));
unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(__int64)); unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(int64_t));
unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10);
unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10);
unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10);
unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4);
unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14);
unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6);
unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); 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, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40); unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40);
unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize); unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize);
@ -1655,22 +1633,24 @@ bool CN64System::LoadState(LPCSTR FileName)
} }
SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN);
DWORD dwRead;
ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL); ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL);
if (Value != 0x23D8A6C8) if (Value != 0x23D8A6C8)
return false; return false;
ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL); ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL);
//Check header //Check header
BYTE LoadHeader[64]; uint8_t LoadHeader[64];
ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL); ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL);
if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0)
{ {
//if (inFullScreen) { return false; } //if (inFullScreen) { return false; }
int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
if (result == IDNO) if (result == IDNO)
{
return false; return false;
}
} }
Reset(false, true); Reset(false, true);
m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4);
@ -1679,21 +1659,21 @@ bool CN64System::LoadState(LPCSTR FileName)
ReadFile(hSaveFile, &NextVITimer, sizeof(NextVITimer), &dwRead, NULL); 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_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_GPR, sizeof(int64_t) * 32, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(int64_t) * 32, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(uint32_t) * 32, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(uint32_t) * 32, &dwRead, NULL);
ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwRead, NULL); ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(int64_t), &dwRead, NULL);
ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwRead, NULL); ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(int64_t), &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwRead, NULL); ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8, &dwRead, NULL);
ReadFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &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, (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.PifRam(), 0x40, &dwRead, NULL);
ReadFile(hSaveFile, m_MMU_VM.Rdram(), SaveRDRAMSize, &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*/; SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/;
DWORD Task = 0; uint32_t Task = 0;
if (m_RspBroke) 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) if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0)
{ {
WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen"); WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen");
@ -1894,7 +1874,7 @@ void CN64System::SyncToAudio()
WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i); WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i);
break; break;
} }
Sleep(1); pjutil::Sleep(1);
} }
if (bShowCPUPer()) if (bShowCPUPer())
{ {
@ -1905,7 +1885,7 @@ void CN64System::SyncToAudio()
void CN64System::RefreshScreen() void CN64System::RefreshScreen()
{ {
SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/; 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 (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); }
//if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); } //if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); }
@ -1954,7 +1934,6 @@ void CN64System::RefreshScreen()
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught");
WriteTrace(TraceError, __FUNCTION__ ": Exception caught"); WriteTrace(TraceError, __FUNCTION__ ": Exception caught");
} }
g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0);
if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio()) if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio())

View File

@ -15,7 +15,7 @@
typedef std::list<SystemEvent> EVENT_LIST; 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 CPlugins;
class CRSP_Plugin; class CRSP_Plugin;
@ -36,11 +36,6 @@ public:
CN64System(CPlugins * Plugins, bool SavesReadOnly); CN64System(CPlugins * Plugins, bool SavesReadOnly);
virtual ~CN64System(void); virtual ~CN64System(void);
struct ThreadInfo {
HANDLE * ThreadHandle;
DWORD ThreadID;
};
CProfiling m_Profile; CProfiling m_Profile;
CCheats m_Cheats; CCheats m_Cheats;
bool m_EndEmulation; bool m_EndEmulation;
@ -64,21 +59,21 @@ public:
void Pause(); void Pause();
void RunRSP(); void RunRSP();
bool SaveState(); bool SaveState();
bool LoadState(LPCSTR FileName); bool LoadState(const char * FileName);
bool LoadState(); bool LoadState();
bool DmaUsed() const { return m_DMAUsed; } bool DmaUsed() const { return m_DMAUsed; }
void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; }
void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; } void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; }
bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; } 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 //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 #ifdef TEST_SP_TRACKING
DWORD m_CurrentSP; uint32_t m_CurrentSP;
#endif #endif
//For Sync CPU //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 SyncCPU(CN64System * const SecondCPU);
void SyncCPUPC(CN64System * const SecondCPU); void SyncCPUPC(CN64System * const SecondCPU);
void SyncSystem(); void SyncSystem();
@ -94,8 +89,14 @@ private:
friend CSystemTimer; friend CSystemTimer;
//Used for loading and potentially executing the CPU in its own thread. //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 void StartEmulationThread(ThreadInfo * Info);
static bool EmulationStarting(HANDLE hThread, DWORD ThreadId); static bool EmulationStarting(void * hThread, uint32_t ThreadId);
void ExecuteCPU(); void ExecuteCPU();
void RefreshScreen(); void RefreshScreen();
@ -114,7 +115,7 @@ private:
void CpuStopped(); void CpuStopped();
//Function in CMipsMemory_CallBack //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 //Functions in CTLB_CB
void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly);
@ -133,34 +134,34 @@ private:
CAudio m_Audio; CAudio m_Audio;
CSpeedLimitor m_Limitor; CSpeedLimitor m_Limitor;
bool m_InReset; bool m_InReset;
int m_NextTimer; int32_t m_NextTimer;
CSystemTimer m_SystemTimer; CSystemTimer m_SystemTimer;
bool m_bCleanFrameBox; bool m_bCleanFrameBox;
bool m_bInitialized; bool m_bInitialized;
bool m_RspBroke; bool m_RspBroke;
bool m_DMAUsed; bool m_DMAUsed;
DWORD m_Buttons[4]; uint32_t m_Buttons[4];
bool m_TestTimer; bool m_TestTimer;
DWORD m_NextInstruction; uint32_t m_NextInstruction;
DWORD m_JumpToLocation; uint32_t m_JumpToLocation;
uint32_t m_TLBLoadAddress; uint32_t m_TLBLoadAddress;
uint32_t m_TLBStoreAddress; uint32_t m_TLBStoreAddress;
DWORD m_SyncCount; uint32_t m_SyncCount;
bool m_CheatsSlectionChanged; bool m_CheatsSlectionChanged;
//When Syncing cores this is the PC where it last Sync'ed correctly //When Syncing cores this is the PC where it last Sync'ed correctly
DWORD m_LastSuccessSyncPC[10]; uint32_t m_LastSuccessSyncPC[10];
int m_CyclesToSkip; int32_t m_CyclesToSkip;
//Handle to the cpu thread //Handle to the cpu thread
HANDLE m_CPU_Handle; void * m_CPU_Handle;
DWORD m_CPU_ThreadID; uint32_t m_CPU_ThreadID;
//Handle to pause mutex //Handle to pause mutex
SyncEvent m_hPauseEvent; SyncEvent m_hPauseEvent;
//No of Alist and Dlist sent to the RSP //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 //list of function that have been called .. used in profiling
FUNC_CALLS m_FunctionCalls; FUNC_CALLS m_FunctionCalls;

File diff suppressed because it is too large Load Diff

View File

@ -13,64 +13,64 @@
class CCodeBlock; class CCodeBlock;
class CCodeSection : class CCodeSection :
private CRecompilerOps private CRecompilerOps
{ {
public: public:
typedef std::list<CCodeSection *> SECTION_LIST; typedef std::list<CCodeSection *> SECTION_LIST;
CCodeSection(CCodeBlock * CodeBlock, uint32_t EnterPC, uint32_t ID, bool LinkAllowed); CCodeSection(CCodeBlock * CodeBlock, uint32_t EnterPC, uint32_t ID, bool LinkAllowed);
~CCodeSection(); ~CCodeSection();
void SetDelaySlot(); void SetDelaySlot();
void SetJumpAddress(uint32_t JumpPC, uint32_t TargetPC, bool PermLoop); void SetJumpAddress(uint32_t JumpPC, uint32_t TargetPC, bool PermLoop);
void SetContinueAddress(uint32_t JumpPC, uint32_t TargetPC); void SetContinueAddress(uint32_t JumpPC, uint32_t TargetPC);
void CompileCop1Test(); void CompileCop1Test();
bool GenerateX86Code(uint32_t Test); bool GenerateX86Code(uint32_t Test);
void GenerateSectionLinkage(); void GenerateSectionLinkage();
void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)); void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value));
void DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID); void DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID);
bool FixConstants(uint32_t Test); bool FixConstants(uint32_t Test);
CCodeSection * ExistingSection(uint32_t Addr, uint32_t Test); CCodeSection * ExistingSection(uint32_t Addr, uint32_t Test);
bool SectionAccessible(uint32_t SectionId, uint32_t Test); bool SectionAccessible(uint32_t SectionId, uint32_t Test);
bool DisplaySectionInformation(uint32_t ID, uint32_t Test); bool DisplaySectionInformation(uint32_t ID, uint32_t Test);
void DisplaySectionInformation(); void DisplaySectionInformation();
void AddParent(CCodeSection * Parent); void AddParent(CCodeSection * Parent);
void SwitchParent(CCodeSection * OldParent, CCodeSection * NewParent); void SwitchParent(CCodeSection * OldParent, CCodeSection * NewParent);
/* Block Connection info */ /* Block Connection info */
SECTION_LIST m_ParentSection; SECTION_LIST m_ParentSection;
CCodeBlock * const m_BlockInfo; CCodeBlock * const m_BlockInfo;
const uint32_t m_SectionID; const uint32_t m_SectionID;
const uint32_t m_EnterPC; const uint32_t m_EnterPC;
uint32_t m_EndPC; uint32_t m_EndPC;
CCodeSection * m_ContinueSection; CCodeSection * m_ContinueSection;
CCodeSection * m_JumpSection; CCodeSection * m_JumpSection;
bool m_EndSection; // if this section does not link bool m_EndSection; // if this section does not link
bool m_LinkAllowed; // are other sections allowed to find block to link to it bool m_LinkAllowed; // are other sections allowed to find block to link to it
uint32_t m_Test; uint32_t m_Test;
uint32_t m_Test2; uint32_t m_Test2;
uint8_t * m_CompiledLocation; uint8_t * m_CompiledLocation;
bool m_InLoop; bool m_InLoop;
bool m_DelaySlot; bool m_DelaySlot;
/* Register Info */ /* Register Info */
CRegInfo m_RegEnter; CRegInfo m_RegEnter;
/* Jump Info */ /* Jump Info */
CJumpInfo m_Jump; CJumpInfo m_Jump;
CJumpInfo m_Cont; CJumpInfo m_Cont;
private: private:
CCodeSection(void); // Disable default constructor CCodeSection(void); // Disable default constructor
CCodeSection(const CCodeSection&); // Disable copy constructor CCodeSection(const CCodeSection&); // Disable copy constructor
CCodeSection& operator=(const CCodeSection&); // Disable assignment CCodeSection& operator=(const CCodeSection&); // Disable assignment
void UnlinkParent(CCodeSection * Parent, bool ContinueSection); void UnlinkParent(CCodeSection * Parent, bool ContinueSection);
void InheritConstants(); void InheritConstants();
void TestRegConstantStates(CRegInfo & Base, CRegInfo & Reg); void TestRegConstantStates(CRegInfo & Base, CRegInfo & Reg);
void SyncRegState(const CRegInfo & SyncTo); void SyncRegState(const CRegInfo & SyncTo);
bool IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test); bool IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test);
bool ParentContinue(); bool ParentContinue();
bool InheritParentInfo(); bool InheritParentInfo();
bool SetupRegisterForLoop(); bool SetupRegisterForLoop();
}; };

File diff suppressed because it is too large Load Diff

View File

@ -19,48 +19,48 @@ public:
//enums //enums
enum REG_STATE enum REG_STATE
{ {
STATE_UNKNOWN = 0x00, STATE_UNKNOWN = 0x00,
STATE_KNOWN_VALUE = 0x01, STATE_KNOWN_VALUE = 0x01,
STATE_X86_MAPPED = 0x02, STATE_X86_MAPPED = 0x02,
STATE_SIGN = 0x04, STATE_SIGN = 0x04,
STATE_32BIT = 0x08, STATE_32BIT = 0x08,
STATE_MODIFIED = 0x10, STATE_MODIFIED = 0x10,
STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3 STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3
STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11 STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11
STATE_MAPPED_32_SIGN = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN), // = 15 STATE_MAPPED_32_SIGN = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN), // = 15
STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9 STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9
STATE_CONST_32_SIGN = (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN), // = 13 STATE_CONST_32_SIGN = (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN), // = 13
STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1 STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1
}; };
enum REG_MAPPED enum REG_MAPPED
{ {
NotMapped = 0, NotMapped = 0,
GPR_Mapped = 1, GPR_Mapped = 1,
Temp_Mapped = 2, Temp_Mapped = 2,
Stack_Mapped = 3, Stack_Mapped = 3,
}; };
enum FPU_STATE enum FPU_STATE
{ {
FPU_Any = -1, FPU_Any = -1,
FPU_Unknown = 0, FPU_Unknown = 0,
FPU_Dword = 1, FPU_Dword = 1,
FPU_Qword = 2, FPU_Qword = 2,
FPU_Float = 3, FPU_Float = 3,
FPU_Double = 4, FPU_Double = 4,
}; };
enum FPU_ROUND enum FPU_ROUND
{ {
RoundUnknown = -1, RoundUnknown = -1,
RoundDefault = 0, RoundDefault = 0,
RoundTruncate = 1, RoundTruncate = 1,
RoundNearest = 2, RoundNearest = 2,
RoundDown = 3, RoundDown = 3,
RoundUp = 4, RoundUp = 4,
}; };
public: public:
@ -73,30 +73,30 @@ public:
bool operator==(const CRegInfo& right) const; bool operator==(const CRegInfo& right) const;
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 FixRoundModel(FPU_ROUND RoundMethod);
void ChangeFPURegFormat ( int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel ); 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); void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Format);
bool RegInStack ( int32_t Reg, FPU_STATE Format ); bool RegInStack(int32_t Reg, FPU_STATE Format);
void UnMap_AllFPRs (); void UnMap_AllFPRs();
void UnMap_FPR ( int32_t Reg, bool WriteBackValue ); void UnMap_FPR(int32_t Reg, bool WriteBackValue);
x86FpuValues StackPosition( int32_t Reg ); x86FpuValues StackPosition(int32_t Reg);
x86Reg FreeX86Reg (); x86Reg FreeX86Reg();
x86Reg Free8BitX86Reg (); x86Reg Free8BitX86Reg();
void Map_GPR_32bit ( int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad ); void Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad);
void Map_GPR_64bit ( int32_t MipsReg, int32_t MipsRegToLoad ); void Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad);
x86Reg Get_MemoryStack () const; x86Reg Get_MemoryStack() const;
x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true ); x86Reg Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool LoadValue = true);
x86Reg Map_TempReg ( x86Reg Reg, int32_t MipsReg, bool LoadHiWord ); x86Reg Map_TempReg(x86Reg Reg, int32_t MipsReg, bool LoadHiWord);
void ProtectGPR ( uint32_t Reg ); void ProtectGPR(uint32_t Reg);
void UnProtectGPR ( uint32_t Reg ); void UnProtectGPR(uint32_t Reg);
void ResetX86Protection (); void ResetX86Protection();
x86Reg UnMap_TempReg (); x86Reg UnMap_TempReg();
void UnMap_GPR ( uint32_t Reg, bool WriteBackValue ); void UnMap_GPR(uint32_t Reg, bool WriteBackValue);
bool UnMap_X86reg ( x86Reg Reg ); bool UnMap_X86reg(x86Reg Reg);
void WriteBackRegisters (); void WriteBackRegisters();
bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); } 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); } 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 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)); } 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]; } 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; } 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; } 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]; } 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]; } 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]; } 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]; } 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 GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; }
CX86Ops::x86Reg GetMipsRegMapHi ( int32_t Reg ) const { return m_RegMapHi[Reg]; } CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; }
uint32_t GetX86MapOrder ( x86Reg Reg ) const { return m_x86reg_MapOrder[Reg]; } uint32_t GetX86MapOrder(x86Reg Reg) const { return m_x86reg_MapOrder[Reg]; }
bool GetX86Protected ( x86Reg Reg ) const { return m_x86reg_Protected[Reg]; } bool GetX86Protected(x86Reg Reg) const { return m_x86reg_Protected[Reg]; }
REG_MAPPED GetX86Mapped ( x86Reg Reg ) const { return m_x86reg_MappedTo[Reg]; } REG_MAPPED GetX86Mapped(x86Reg Reg) const { return m_x86reg_MappedTo[Reg]; }
uint32_t GetBlockCycleCount() const { return m_CycleCount; } uint32_t GetBlockCycleCount() const { return m_CycleCount; }
void SetMipsReg ( int32_t Reg, uint64_t Value ) { m_MIPS_RegVal[Reg].UDW = Value; } 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 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 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 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 SetMipsRegMapLo(int32_t GetMipsReg, x86Reg Reg) { m_RegMapLo[GetMipsReg] = Reg; }
void SetMipsRegMapHi ( int32_t GetMipsReg, x86Reg Reg ) { m_RegMapHi[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 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 SetX86MapOrder(x86Reg Reg, uint32_t Order) { m_x86reg_MapOrder[Reg] = Order; }
void SetX86Protected ( x86Reg Reg, bool Protected ) { m_x86reg_Protected[Reg] = Protected; } void SetX86Protected(x86Reg Reg, bool Protected) { m_x86reg_Protected[Reg] = Protected; }
void SetX86Mapped ( x86Reg Reg, REG_MAPPED Mapping ) { m_x86reg_MappedTo[Reg] = Mapping; } void SetX86Mapped(x86Reg Reg, REG_MAPPED Mapping) { m_x86reg_MappedTo[Reg] = Mapping; }
void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; } 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_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); 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(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); 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_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); 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(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
} }
@ -150,6 +152,15 @@ void CMainGui::SetWindowCaption(const wchar_t * title)
Caption(WinTitle); Caption(WinTitle);
} }
void CMainGui::ShowRomBrowser(void)
{
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
ShowRomList();
HighLightLastRom();
}
}
void RomBowserEnabledChanged(CMainGui * Gui) void RomBowserEnabledChanged(CMainGui * Gui)
{ {
if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) if (Gui && g_Settings->LoadBool(RomBrowser_Enabled))
@ -171,6 +182,15 @@ void RomBowserEnabledChanged(CMainGui * Gui)
void CMainGui::LoadingInProgressChanged(CMainGui * Gui) void CMainGui::LoadingInProgressChanged(CMainGui * Gui)
{ {
Gui->RefreshMenu(); 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) void CMainGui::GameLoaded(CMainGui * Gui)
@ -181,7 +201,6 @@ void CMainGui::GameLoaded(CMainGui * Gui)
WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom");
Gui->AddRecentRom(FileLoc.c_str()); Gui->AddRecentRom(FileLoc.c_str());
Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str());
Gui->HideRomList(); Gui->HideRomList();
} }
} }
@ -191,6 +210,33 @@ void CMainGui::GamePaused(CMainGui * Gui)
Gui->RefreshMenu(); 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) void RomBowserColoumnsChanged(CMainGui * Gui)
{ {
Gui->ResetRomBrowserColomuns(); Gui->ResetRomBrowserColomuns();
@ -375,6 +421,7 @@ bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System)
WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); WriteTrace(TraceError, __FUNCTION__ ": Failed to create event");
bRes = false; bRes = false;
} }
Notify().RefreshMenu();
return bRes; return bRes;
} }
@ -908,6 +955,20 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
_this->m_ResetPlugins = true; _this->m_ResetPlugins = true;
} }
break; 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: case WM_COMMAND:
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");

View File

@ -25,8 +25,9 @@ enum
{ {
WM_HIDE_CUROSR = WM_USER + 10, WM_HIDE_CUROSR = WM_USER + 10,
WM_MAKE_FOCUS = WM_USER + 17, WM_MAKE_FOCUS = WM_USER + 17,
WM_RESET_PLUGIN = WM_USER + 18, WM_RESET_PLUGIN = WM_USER + 18,
WM_BORWSER_TOP = WM_USER + 40, WM_GAME_CLOSED = WM_USER + 19,
WM_BORWSER_TOP = WM_USER + 40,
}; };
class CMainGui : class CMainGui :
@ -105,6 +106,7 @@ private:
void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE
void AddRecentRom(const char * ImagePath); void AddRecentRom(const char * ImagePath);
void SetWindowCaption(const wchar_t * Caption); void SetWindowCaption(const wchar_t * Caption);
void ShowRomBrowser(void);
friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD);
friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD);
@ -116,6 +118,7 @@ private:
static void LoadingInProgressChanged(CMainGui * Gui); static void LoadingInProgressChanged(CMainGui * Gui);
static void GameLoaded(CMainGui * Gui); static void GameLoaded(CMainGui * Gui);
static void GamePaused(CMainGui * Gui); static void GamePaused(CMainGui * Gui);
static void GameCpuRunning(CMainGui * Gui);
CBaseMenu * m_Menu; CBaseMenu * m_Menu;