Project64-core: Make Setting_EnableDisk be a setting in GameSettings

This commit is contained in:
zilmar 2022-01-04 10:07:52 +10:30
parent 219b9149d6
commit 09f90d9b53
10 changed files with 212 additions and 157 deletions

View File

@ -1453,7 +1453,7 @@ void CMipsMemoryVM::Load32CartridgeDomain1Address3(void)
void CMipsMemoryVM::Load32CartridgeDomain2Address1(void)
{
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (m_MemLookupAddress & 0x1FFFFFFF)
{
@ -2050,7 +2050,7 @@ void CMipsMemoryVM::Write32PeripheralInterface(void)
case 0x04600000: g_Reg->PI_DRAM_ADDR_REG = m_MemLookupValue.UW[0]; break;
case 0x04600004:
g_Reg->PI_CART_ADDR_REG = m_MemLookupValue.UW[0];
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
DiskDMACheck();
}
@ -2139,7 +2139,7 @@ void CMipsMemoryVM::Write32SerialInterface(void)
void CMipsMemoryVM::Write32CartridgeDomain2Address1(void)
{
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (m_MemLookupAddress & 0xFFFFFFF)
{

View File

@ -7,6 +7,7 @@
#include <Project64-core/N64System/Mips/FlashRam.h>
#include <Project64-core/N64System/Mips/Sram.h>
#include <Project64-core/N64System/Mips/Dma.h>
#include <Project64-core\Settings\GameSettings.h>
#ifdef __arm__
#include <sys/ucontext.h>
@ -40,7 +41,8 @@ class CMipsMemoryVM :
private CPifRam,
private CFlashram,
private CSram,
private CDMA
private CDMA,
private CGameSettings
{
public:
CMipsMemoryVM(bool SavesReadOnly);

View File

@ -499,12 +499,18 @@ bool CN64System::RunFileImage(const char * FileLoc)
if (g_Rom->IsLoadedRomDDIPL())
{
if (g_Rom->CicChipID() == CIC_NUS_8303)
{
g_Settings->SaveString(File_DiskIPLPath, FileLoc);
}
else if (g_Rom->CicChipID() == CIC_NUS_DDUS)
{
g_Settings->SaveString(File_DiskIPLUSAPath, FileLoc);
}
else if (g_Rom->CicChipID() == CIC_NUS_8401)
{
g_Settings->SaveString(File_DiskIPLTOOLPath, FileLoc);
}
}
RunLoadedImage();
return true;
}
@ -1762,7 +1768,7 @@ bool CN64System::SaveState()
zipOpenNewFileInZip(file, SaveFile.GetNameExtension().c_str(), nullptr, nullptr, 0, nullptr, 0, nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0));
zipWriteInFileInZip(file, &RdramSize, sizeof(uint32_t));
if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk)
if (EnableDisk() && g_Disk)
{
// Keep base ROM information (64DD IPL / compatible game ROM)
zipWriteInFileInZip(file, &g_Rom->GetRomAddress()[0x10], 0x20);
@ -1832,7 +1838,7 @@ bool CN64System::SaveState()
hSaveFile.SeekToBegin();
hSaveFile.Write(&SaveID_0, sizeof(uint32_t));
hSaveFile.Write(&RdramSize, sizeof(uint32_t));
if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk)
if (EnableDisk() && g_Disk)
{
// Keep base ROM information (64DD IPL / compatible game ROM)
hSaveFile.Write(&g_Rom->GetRomAddress()[0x10], 0x20);
@ -2013,7 +2019,7 @@ bool CN64System::LoadState(const char * FileName)
uint8_t LoadHeader[64];
unzReadCurrentFile(file, LoadHeader, 0x40);
if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk)
if (EnableDisk() && g_Disk)
{
// Base ROM information (64DD IPL / compatible game ROM) and disk info check
if ((memcmp(LoadHeader, &g_Rom->GetRomAddress()[0x10], 0x20) != 0 ||
@ -2108,7 +2114,7 @@ bool CN64System::LoadState(const char * FileName)
// Check header
uint8_t LoadHeader[64];
hSaveFile.Read(LoadHeader, 0x40);
if (g_Settings->LoadBool(Setting_EnableDisk) && g_Disk)
if (EnableDisk() && g_Disk)
{
// Base ROM information (64DD IPL / compatible game ROM) and disk info check
if ((memcmp(LoadHeader, &g_Rom->GetRomAddress()[0x10], 0x20) != 0 ||

View File

@ -6547,7 +6547,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
break;
case 0x05000000:
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (PAddr)
{
@ -6874,7 +6874,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr)
case 0x04600000: MoveArmRegToVariable(Reg, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break;
case 0x04600004:
MoveArmRegToVariable(Reg, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG");
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
m_RegWorkingSet.BeforeCallDirect();
CallFunction(AddressOf(&DiskDMACheck), "DiskDMACheck");
@ -7003,7 +7003,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr)
break;
case 0x05000000:
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (PAddr)
{
@ -7324,7 +7324,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
break;
case 0x05000000:
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (PAddr)
{

View File

@ -3,11 +3,13 @@
#include <Project64-core/N64System/Mips/Register.h>
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
#include <Project64-core\Settings\GameSettings.h>
class CArmRecompilerOps :
public CRecompilerOps,
private CArmOps,
protected CSystemRegisters
protected CSystemRegisters,
private CGameSettings
{
public:
CArmRecompilerOps();
@ -29,163 +31,163 @@ public:
void COP1_BCT_Compare();
// Opcode functions
void J ();
void JAL ();
void ADDI ();
void ADDIU ();
void SLTI ();
void SLTIU ();
void ANDI ();
void ORI ();
void XORI ();
void LUI ();
void DADDIU ();
void LDL ();
void LDR ();
void LB ();
void LH ();
void LWL ();
void LW ();
void LBU ();
void LHU ();
void LWR ();
void LWU ();
void SB ();
void SH ();
void SWL ();
void SW ();
void SWR ();
void SDL ();
void SDR ();
void CACHE ();
void LL ();
void LWC1 ();
void LDC1 ();
void LD ();
void SC ();
void SWC1 ();
void SDC1 ();
void SD ();
void J();
void JAL();
void ADDI();
void ADDIU();
void SLTI();
void SLTIU();
void ANDI();
void ORI();
void XORI();
void LUI();
void DADDIU();
void LDL();
void LDR();
void LB();
void LH();
void LWL();
void LW();
void LBU();
void LHU();
void LWR();
void LWU();
void SB();
void SH();
void SWL();
void SW();
void SWR();
void SDL();
void SDR();
void CACHE();
void LL();
void LWC1();
void LDC1();
void LD();
void SC();
void SWC1();
void SDC1();
void SD();
// R4300i opcodes: Special
void SPECIAL_SLL ();
void SPECIAL_SRL ();
void SPECIAL_SRA ();
void SPECIAL_SLLV ();
void SPECIAL_SRLV ();
void SPECIAL_SRAV ();
void SPECIAL_JR ();
void SPECIAL_JALR ();
void SPECIAL_SLL();
void SPECIAL_SRL();
void SPECIAL_SRA();
void SPECIAL_SLLV();
void SPECIAL_SRLV();
void SPECIAL_SRAV();
void SPECIAL_JR();
void SPECIAL_JALR();
void SPECIAL_SYSCALL();
void SPECIAL_MFLO ();
void SPECIAL_MTLO ();
void SPECIAL_MFHI ();
void SPECIAL_MTHI ();
void SPECIAL_DSLLV ();
void SPECIAL_DSRLV ();
void SPECIAL_DSRAV ();
void SPECIAL_MULT ();
void SPECIAL_MULTU ();
void SPECIAL_DIV ();
void SPECIAL_DIVU ();
void SPECIAL_DMULT ();
void SPECIAL_DMULTU ();
void SPECIAL_DDIV ();
void SPECIAL_DDIVU ();
void SPECIAL_ADD ();
void SPECIAL_ADDU ();
void SPECIAL_SUB ();
void SPECIAL_SUBU ();
void SPECIAL_AND ();
void SPECIAL_OR ();
void SPECIAL_XOR ();
void SPECIAL_NOR ();
void SPECIAL_SLT ();
void SPECIAL_SLTU ();
void SPECIAL_DADD ();
void SPECIAL_DADDU ();
void SPECIAL_DSUB ();
void SPECIAL_DSUBU ();
void SPECIAL_DSLL ();
void SPECIAL_DSRL ();
void SPECIAL_DSRA ();
void SPECIAL_DSLL32 ();
void SPECIAL_DSRL32 ();
void SPECIAL_DSRA32 ();
void SPECIAL_MFLO();
void SPECIAL_MTLO();
void SPECIAL_MFHI();
void SPECIAL_MTHI();
void SPECIAL_DSLLV();
void SPECIAL_DSRLV();
void SPECIAL_DSRAV();
void SPECIAL_MULT();
void SPECIAL_MULTU();
void SPECIAL_DIV();
void SPECIAL_DIVU();
void SPECIAL_DMULT();
void SPECIAL_DMULTU();
void SPECIAL_DDIV();
void SPECIAL_DDIVU();
void SPECIAL_ADD();
void SPECIAL_ADDU();
void SPECIAL_SUB();
void SPECIAL_SUBU();
void SPECIAL_AND();
void SPECIAL_OR();
void SPECIAL_XOR();
void SPECIAL_NOR();
void SPECIAL_SLT();
void SPECIAL_SLTU();
void SPECIAL_DADD();
void SPECIAL_DADDU();
void SPECIAL_DSUB();
void SPECIAL_DSUBU();
void SPECIAL_DSLL();
void SPECIAL_DSRL();
void SPECIAL_DSRA();
void SPECIAL_DSLL32();
void SPECIAL_DSRL32();
void SPECIAL_DSRA32();
// COP0 functions
void COP0_MF ();
void COP0_MT ();
void COP0_MF();
void COP0_MT();
// COP0 CO functions
void COP0_CO_TLBR ();
void COP0_CO_TLBWI ();
void COP0_CO_TLBWR ();
void COP0_CO_TLBP ();
void COP0_CO_ERET ();
void COP0_CO_TLBR();
void COP0_CO_TLBWI();
void COP0_CO_TLBWR();
void COP0_CO_TLBP();
void COP0_CO_ERET();
// COP1 functions
void COP1_MF ();
void COP1_DMF ();
void COP1_CF ();
void COP1_MT ();
void COP1_DMT ();
void COP1_CT ();
void COP1_MF();
void COP1_DMF();
void COP1_CF();
void COP1_MT();
void COP1_DMT();
void COP1_CT();
// COP1: S functions
void COP1_S_ADD ();
void COP1_S_SUB ();
void COP1_S_MUL ();
void COP1_S_DIV ();
void COP1_S_ABS ();
void COP1_S_NEG ();
void COP1_S_SQRT ();
void COP1_S_MOV ();
void COP1_S_ROUND_L ();
void COP1_S_TRUNC_L ();
void COP1_S_CEIL_L ();
void COP1_S_FLOOR_L ();
void COP1_S_ROUND_W ();
void COP1_S_TRUNC_W ();
void COP1_S_CEIL_W ();
void COP1_S_FLOOR_W ();
void COP1_S_CVT_D ();
void COP1_S_CVT_W ();
void COP1_S_CVT_L ();
void COP1_S_CMP ();
void COP1_S_ADD();
void COP1_S_SUB();
void COP1_S_MUL();
void COP1_S_DIV();
void COP1_S_ABS();
void COP1_S_NEG();
void COP1_S_SQRT();
void COP1_S_MOV();
void COP1_S_ROUND_L();
void COP1_S_TRUNC_L();
void COP1_S_CEIL_L();
void COP1_S_FLOOR_L();
void COP1_S_ROUND_W();
void COP1_S_TRUNC_W();
void COP1_S_CEIL_W();
void COP1_S_FLOOR_W();
void COP1_S_CVT_D();
void COP1_S_CVT_W();
void COP1_S_CVT_L();
void COP1_S_CMP();
// COP1: D functions
void COP1_D_ADD ();
void COP1_D_SUB ();
void COP1_D_MUL ();
void COP1_D_DIV ();
void COP1_D_ABS ();
void COP1_D_NEG ();
void COP1_D_SQRT ();
void COP1_D_MOV ();
void COP1_D_ROUND_L ();
void COP1_D_TRUNC_L ();
void COP1_D_CEIL_L ();
void COP1_D_FLOOR_L ();
void COP1_D_ROUND_W ();
void COP1_D_TRUNC_W ();
void COP1_D_CEIL_W ();
void COP1_D_FLOOR_W ();
void COP1_D_CVT_S ();
void COP1_D_CVT_W ();
void COP1_D_CVT_L ();
void COP1_D_CMP ();
void COP1_D_ADD();
void COP1_D_SUB();
void COP1_D_MUL();
void COP1_D_DIV();
void COP1_D_ABS();
void COP1_D_NEG();
void COP1_D_SQRT();
void COP1_D_MOV();
void COP1_D_ROUND_L();
void COP1_D_TRUNC_L();
void COP1_D_CEIL_L();
void COP1_D_FLOOR_L();
void COP1_D_ROUND_W();
void COP1_D_TRUNC_W();
void COP1_D_CEIL_W();
void COP1_D_FLOOR_W();
void COP1_D_CVT_S();
void COP1_D_CVT_W();
void COP1_D_CVT_L();
void COP1_D_CMP();
// COP1: W functions
void COP1_W_CVT_S ();
void COP1_W_CVT_D ();
void COP1_W_CVT_S();
void COP1_W_CVT_D();
// COP1: L functions
void COP1_L_CVT_S ();
void COP1_L_CVT_D ();
void COP1_L_CVT_S();
void COP1_L_CVT_D();
// Other functions
void UnknownOpcode ();
void UnknownOpcode();
private:
void EnterCodeBlock();

View File

@ -3443,7 +3443,7 @@ void CX86RecompilerOps::LW_KnownAddress(x86Reg Reg, uint32_t VAddr)
break;
case 0x05000000:
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (PAddr)
{
@ -11261,7 +11261,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
break;
case 0x05000000:
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (PAddr)
{
@ -11603,7 +11603,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr)
case 0x04600000: MoveX86regToVariable(Reg, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break;
case 0x04600004:
MoveX86regToVariable(Reg, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG");
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
m_RegWorkingSet.BeforeCallDirect();
Call_Direct(AddressOf(&DiskDMACheck), "DiskDMACheck");
@ -11763,7 +11763,7 @@ void CX86RecompilerOps::SW_Register(x86Reg Reg, uint32_t VAddr)
break;
case 0x05000000:
// 64DD registers
if (g_Settings->LoadBool(Setting_EnableDisk))
if (EnableDisk())
{
switch (PAddr)
{

View File

@ -11,6 +11,7 @@
#include <Project64-core/N64System/Interpreter/InterpreterOps.h>
#include <Project64-core/Settings/N64SystemSettings.h>
#include <Project64-core/Settings/RecompilerSettings.h>
#include <Project64-core\Settings\GameSettings.h>
class CCodeBlock;
class CCodeSection;
@ -20,7 +21,8 @@ class CX86RecompilerOps :
protected R4300iOp,
protected CX86Ops,
protected CN64SystemSettings,
protected CRecompilerSettings
protected CRecompilerSettings,
private CGameSettings
{
public:
// Trap functions

View File

@ -33,6 +33,28 @@ uint32_t CGameSettings::m_OverClockModifier = 1;
DISK_SEEK_TYPE CGameSettings::m_DiskSeekTimingType = DiskSeek_Turbo;
bool CGameSettings::m_EnhancmentOverClock = false;
uint32_t CGameSettings::m_EnhancmentOverClockModifier = 1;
bool CGameSettings::m_EnableDisk = false;
int32_t CGameSettings::m_RefCount = 0;
CGameSettings::CGameSettings()
{
m_RefCount += 1;
if (m_RefCount == 1)
{
g_Settings->RegisterChangeCB(Setting_EnableDisk, nullptr, EnableDiskChanged);
EnableDiskChanged(nullptr);
}
}
CGameSettings::~CGameSettings()
{
m_RefCount -= 1;
if (m_RefCount == 0)
{
g_Settings->RegisterChangeCB(Setting_EnableDisk, nullptr, EnableDiskChanged);
}
}
void CGameSettings::RefreshGameSettings()
{
@ -105,3 +127,8 @@ void CGameSettings::SetOverClockModifier(bool EnhancmentOverClock, uint32_t Enha
if (m_OverClockModifier < 1) { m_OverClockModifier = 1; }
if (m_OverClockModifier > 20) { m_OverClockModifier = 20; }
}
void CGameSettings::EnableDiskChanged(void *)
{
m_EnableDisk = g_Settings->LoadBool(Setting_EnableDisk);
}

View File

@ -6,6 +6,9 @@
class CGameSettings
{
public:
CGameSettings();
virtual ~CGameSettings();
void RefreshGameSettings(void);
inline static bool UseHleGfx(void) { return m_UseHleGfx; }
@ -36,14 +39,21 @@ public:
inline static CPU_TYPE CpuType(void) { return m_CpuType; }
inline static uint32_t OverClockModifier(void) { return m_OverClockModifier; }
inline static DISK_SEEK_TYPE DiskSeekTimingType(void) { return m_DiskSeekTimingType; };
inline static bool EnableDisk(void) { return m_EnableDisk; }
void RefreshSyncToAudio(void);
static void SetOverClockModifier(bool EnhancmentOverClock, uint32_t EnhancmentOverClockModifier);
protected:
static void SpeedChanged(int32_t SpeedLimit);
static void EnableDiskChanged(void);
private:
CGameSettings(const CGameSettings&);
CGameSettings& operator=(const CGameSettings&);
static void EnableDiskChanged(void *);
// Settings that can be changed on the fly
static bool m_UseHleGfx;
static bool m_bRomInMemory;
@ -75,4 +85,6 @@ private:
static DISK_SEEK_TYPE m_DiskSeekTimingType;
static bool m_EnhancmentOverClock;
static uint32_t m_EnhancmentOverClockModifier;
static bool m_EnableDisk;
static int32_t m_RefCount;
};

View File

@ -814,9 +814,13 @@ void CRomBrowser::RomList_OpenRom(uint32_t /*pnmh*/)
}
if ((CPath(pRomInfo->szFullFileName).GetExtension() != "ndd") && (CPath(pRomInfo->szFullFileName).GetExtension() != "d64"))
{
CN64System::RunFileImage(pRomInfo->szFullFileName);
}
else
{
CN64System::RunDiskImage(pRomInfo->szFullFileName);
}
}
void CRomBrowser::RomList_PopupMenu(uint32_t /*pnmh*/)