Implement Randomize SI/PI interrupts setting

closes #1656
This commit is contained in:
Duncan Ogilvie 2019-10-03 00:18:19 +02:00
parent 04cafeea52
commit 18686e710c
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
15 changed files with 70 additions and 29 deletions

View File

@ -325,6 +325,7 @@ public enum LanguageStringID
ROM_DELAY_DP(539),
ROM_OVER_CLOCK_MODIFIER(5400),
ROM_UNALIGNED_DMA(5410),
ROM_RANDOMIZE_SIPI_INTERRUPTS(5420),
//Core Styles
CORE_INTERPTER(540),

View File

@ -334,6 +334,7 @@ enum LanguageStringID
ROM_DELAY_DP = 539,
ROM_OVER_CLOCK_MODIFIER = 5400,
ROM_UNALIGNED_DMA = 5410,
ROM_RANDOMIZE_SIPI_INTERRUPTS = 5420,
//Core Styles
CORE_INTERPTER = 540,

View File

@ -300,6 +300,7 @@ void CLanguage::LoadDefaultStrings(void)
DEF_STR(ROM_DELAY_DP, "Delay DP interrupt:");
DEF_STR(ROM_OVER_CLOCK_MODIFIER, "Overclock modifier:");
DEF_STR(ROM_UNALIGNED_DMA, "Unaligned DMA");
DEF_STR(ROM_RANDOMIZE_SIPI_INTERRUPTS, "Randomize SI/PI interrupts");
//Core Styles
DEF_STR(CORE_INTERPTER, "Interpreter");

View File

@ -460,11 +460,17 @@ void CDMA::PI_DMA_WRITE()
{
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA);
}
g_SystemTimer->SetTimer(g_SystemTimer->PiTimer, PI_WR_LEN_REG/8 + (g_Random->next() % 0x40), false);
//g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
//g_Reg->MI_INTR_REG |= MI_INTR_PI;
//g_Reg->CheckInterrupts();
if(g_System->bRandomizeSIPIInterrupts())
{
g_SystemTimer->SetTimer(g_SystemTimer->PiTimer, PI_WR_LEN_REG / 8 + (g_Random->next() % 0x40), false);
}
else
{
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
}
//ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9) + 50);
//ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9));
return;

View File

@ -329,16 +329,29 @@ void CPifRam::SI_DMA_READ()
LogMessage("");
}
if (g_System->bDelaySI())
if(g_System->bRandomizeSIPIInterrupts())
{
g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900 + (g_Random->next() % 0x40), false);
if(g_System->bDelaySI())
{
g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900 + (g_Random->next() % 0x40), false);
}
else
{
g_SystemTimer->SetTimer(CSystemTimer::SiTimer, g_Random->next() % 0x40, false);
}
}
else
{
g_SystemTimer->SetTimer(CSystemTimer::SiTimer, g_Random->next() % 0x40, false);
//g_Reg->MI_INTR_REG |= MI_INTR_SI;
//g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
//g_Reg->CheckInterrupts();
if(g_System->bDelaySI())
{
g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900, false);
}
else
{
g_Reg->MI_INTR_REG |= MI_INTR_SI;
g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
g_Reg->CheckInterrupts();
}
}
}

View File

@ -149,7 +149,8 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Default_32Bit, new CSettingTypeApplication("Defaults", "32bit", true));
AddHandler(Default_SyncViaAudio, new CSettingTypeApplication("Defaults", "Audio-Sync Audio", true));
AddHandler(Default_FixedAudio, new CSettingTypeApplication("Defaults", "Fixed Audio", true));
AddHandler(Default_UnalignedDMA, new CSettingTypeApplication("Defaults", "Unaligned DMA", false));
AddHandler(Default_UnalignedDMA, new CSettingTypeApplication("Defaults", "Unaligned DMA", false));
AddHandler(Default_RandomizeSIPIInterrupts, new CSettingTypeApplication("Defaults", "Randomize SI/PI Interrupts", true));
AddHandler(Rdb_GoodName, new CSettingTypeRomDatabase("Good Name", Game_GameName));
AddHandler(Rdb_SaveChip, new CSettingTypeRDBSaveChip("Save Type", (uint32_t)SaveChip_Auto));
@ -196,6 +197,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Rdb_AllowROMWrites, new CSettingTypeRDBYesNo("AllowROMWrites", false));
AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false));
AddHandler(Rdb_UnalignedDMA, new CSettingTypeRomDatabase("Unaligned DMA", Default_UnalignedDMA));
AddHandler(Rdb_RandomizeSIPIInterrupts, new CSettingTypeRomDatabase("Randomize SI/PI Interrupts", Default_RandomizeSIPIInterrupts));
AddHandler(Game_IniKey, new CSettingTypeTempString(""));
AddHandler(Game_File, new CSettingTypeTempString(""));
@ -255,6 +257,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Game_OverClockModifier, new CSettingTypeGame("OverClockModifier", (uint32_t)1));
AddHandler(Game_FullSpeed, new CSettingTypeTempBool(true, "Full Speed"));
AddHandler(Game_UnalignedDMA, new CSettingTypeGame("Unaligned DMA", Rdb_UnalignedDMA));
AddHandler(Game_RandomizeSIPIInterrupts, new CSettingTypeGame("Randomize SI/PI Interrupts", Rdb_RandomizeSIPIInterrupts));
//User Interface
AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("Settings", "Display CPU Usage", (uint32_t)false));

View File

@ -25,6 +25,7 @@ uint32_t CGameSettings::m_ViRefreshRate = 1500;
uint32_t CGameSettings::m_AiCountPerBytes = 500;
bool CGameSettings::m_DelayDP = false;
bool CGameSettings::m_DelaySI = false;
bool CGameSettings::m_bRandomizeSIPIInterrupts = true;
uint32_t CGameSettings::m_RdramSize = 0;
bool CGameSettings::m_bFixedAudio = true;
bool CGameSettings::m_bSyncToAudio = true;
@ -55,6 +56,7 @@ void CGameSettings::RefreshGameSettings()
m_CountPerOp = g_Settings->LoadDword(Game_CounterFactor);
m_RdramSize = g_Settings->LoadDword(Game_RDRamSize);
m_DelaySI = g_Settings->LoadBool(Game_DelaySI);
m_bRandomizeSIPIInterrupts = g_Settings->LoadBool(Game_RandomizeSIPIInterrupts);
m_DelayDP = g_Settings->LoadBool(Game_DelayDP);
m_bFixedAudio = g_Settings->LoadBool(Game_FixedAudio);
m_FullSpeed = g_Settings->LoadBool(Game_FullSpeed);

View File

@ -29,6 +29,7 @@ public:
inline static uint32_t AiCountPerBytes(void) { return m_AiCountPerBytes; }
inline static bool bDelayDP(void) { return m_DelayDP; }
inline static bool bDelaySI(void) { return m_DelaySI; }
inline static bool bRandomizeSIPIInterrupts(void) { return m_bRandomizeSIPIInterrupts; }
inline static uint32_t RdramSize(void) { return m_RdramSize; }
inline static bool bFixedAudio(void) { return m_bFixedAudio; }
inline static bool bSyncToAudio(void) { return m_bSyncToAudio; }
@ -63,6 +64,7 @@ private:
static uint32_t m_AiCountPerBytes;
static bool m_DelayDP;
static bool m_DelaySI;
static bool m_bRandomizeSIPIInterrupts;
static uint32_t m_RdramSize;
static bool m_bFixedAudio;
static bool m_bSyncToAudio;

View File

@ -77,7 +77,8 @@ enum SettingID
Default_32Bit,
Default_SyncViaAudio,
Default_FixedAudio,
Default_UnalignedDMA,
Default_UnalignedDMA,
Default_RandomizeSIPIInterrupts,
//RDB Settings
Rdb_GoodName,
@ -117,6 +118,7 @@ enum SettingID
Rdb_AllowROMWrites,
Rdb_CRC_Recalc,
Rdb_UnalignedDMA,
Rdb_RandomizeSIPIInterrupts,
//Individual Game Settings
Game_IniKey,
@ -173,6 +175,7 @@ enum SettingID
Game_OverClockModifier,
Game_FullSpeed,
Game_UnalignedDMA,
Game_RandomizeSIPIInterrupts,
// General Game running info
GameRunning_LoadingInProgress,

View File

@ -28,7 +28,8 @@ CDefaultsOptionsPage::CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay)
SetDlgItemTextW(m_hWnd, IDC_ROM_32BIT, wGS(ROM_32BIT).c_str());
SetDlgItemTextW(m_hWnd, IDC_ROM_FIXEDAUDIO, wGS(ROM_FIXED_AUDIO).c_str());
SetDlgItemTextW(m_hWnd, IDC_SYNC_AUDIO, wGS(ROM_SYNC_AUDIO).c_str());
SetDlgItemTextW(m_hWnd, IDC_UNALIGNED_DMA, wGS(ROM_UNALIGNED_DMA).c_str());
SetDlgItemTextW(m_hWnd, IDC_UNALIGNED_DMA, wGS(ROM_UNALIGNED_DMA).c_str());
SetDlgItemTextW(m_hWnd, IDC_RANDOMIZE_SIPI_INTERRUPTS, wGS(ROM_RANDOMIZE_SIPI_INTERRUPTS).c_str());
CModifiedComboBox * ComboBox;
ComboBox = AddModComboBox(GetDlgItem(IDC_RDRAM_SIZE), Default_RDRamSize);
@ -61,7 +62,8 @@ CDefaultsOptionsPage::CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay)
AddModCheckBox(GetDlgItem(IDC_ROM_32BIT), Default_32Bit);
AddModCheckBox(GetDlgItem(IDC_SYNC_AUDIO), Default_SyncViaAudio);
AddModCheckBox(GetDlgItem(IDC_ROM_FIXEDAUDIO), Default_FixedAudio);
AddModCheckBox(GetDlgItem(IDC_UNALIGNED_DMA), Default_UnalignedDMA);
AddModCheckBox(GetDlgItem(IDC_UNALIGNED_DMA), Default_UnalignedDMA);
AddModCheckBox(GetDlgItem(IDC_RANDOMIZE_SIPI_INTERRUPTS), Default_RandomizeSIPIInterrupts);
if (!g_Settings->LoadBool(Setting_SyncViaAudioEnabled))
{

View File

@ -20,7 +20,8 @@ class CDefaultsOptionsPage :
COMMAND_ID_HANDLER_EX(IDC_ROM_32BIT, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_SYNC_AUDIO, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_ROM_FIXEDAUDIO, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_UNALIGNED_DMA, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_UNALIGNED_DMA, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_RANDOMIZE_SIPI_INTERRUPTS, CheckBoxChanged)
COMMAND_HANDLER_EX(IDC_RDRAM_SIZE, LBN_SELCHANGE, ComboBoxChanged)
COMMAND_HANDLER_EX(IDC_COUNTFACT, LBN_SELCHANGE, ComboBoxChanged)
COMMAND_HANDLER_EX(IDC_VIREFRESH, EN_UPDATE, EditBoxChanged)

View File

@ -38,6 +38,7 @@ CGameGeneralPage::CGameGeneralPage(HWND hParent, const RECT & rcDispay)
SetDlgItemTextW(m_hWnd, IDC_DELAY_SI, wGS(ROM_DELAY_SI).c_str());
SetDlgItemTextW(m_hWnd, IDC_AUDIO_SIGNAL, wGS(ROM_AUDIO_SIGNAL).c_str());
SetDlgItemTextW(m_hWnd, IDC_UNALIGNED_DMA, wGS(ROM_UNALIGNED_DMA).c_str());
SetDlgItemTextW(m_hWnd, IDC_RANDOMIZE_SIPI_INTERRUPTS, wGS(ROM_RANDOMIZE_SIPI_INTERRUPTS).c_str());
AddModCheckBox(GetDlgItem(IDC_ROM_32BIT), Game_32Bit);
AddModCheckBox(GetDlgItem(IDC_SYNC_AUDIO), Game_SyncViaAudio);
@ -47,6 +48,7 @@ CGameGeneralPage::CGameGeneralPage(HWND hParent, const RECT & rcDispay)
AddModCheckBox(GetDlgItem(IDC_DELAY_SI), Game_DelaySI);
AddModCheckBox(GetDlgItem(IDC_AUDIO_SIGNAL), Game_RspAudioSignal);
AddModCheckBox(GetDlgItem(IDC_UNALIGNED_DMA), Game_UnalignedDMA);
AddModCheckBox(GetDlgItem(IDC_RANDOMIZE_SIPI_INTERRUPTS), Game_RandomizeSIPIInterrupts);
CModifiedComboBox * ComboBox;
ComboBox = AddModComboBox(GetDlgItem(IDC_RDRAM_SIZE), Game_RDRamSize);

View File

@ -29,6 +29,7 @@ class CGameGeneralPage :
COMMAND_ID_HANDLER_EX(IDC_DELAY_SI, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_AUDIO_SIGNAL, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_UNALIGNED_DMA, CheckBoxChanged)
COMMAND_ID_HANDLER_EX(IDC_RANDOMIZE_SIPI_INTERRUPTS, CheckBoxChanged)
COMMAND_HANDLER_EX(IDC_VIREFRESH, EN_UPDATE, EditBoxChanged)
COMMAND_HANDLER_EX(IDC_COUNTPERBYTE, EN_UPDATE, EditBoxChanged)
COMMAND_HANDLER_EX(IDC_OVER_CLOCK_MODIFIER, EN_UPDATE, EditBoxChanged)

View File

@ -199,7 +199,7 @@ BEGIN
EDITTEXT IDC_INFO_MD5,77,59,153,13,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP
END
IDD_Settings_GameGeneral DIALOGEX 0, 0, 218, 169
IDD_Settings_GameGeneral DIALOGEX 0, 0, 218, 182
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@ -227,7 +227,8 @@ BEGIN
CONTROL "Delay DP Interrupt",IDC_DELAY_DP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,143,91,10
CONTROL "Delay SI Interrupt",IDC_DELAY_SI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,143,91,10
CONTROL "RSP Audio Signal",IDC_AUDIO_SIGNAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,154,91,10
CONTROL "Unaligned DMA",IDC_UNALIGNED_DMA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,154,91,10
CONTROL "Randomize SI/PI interrupts",IDC_RANDOMIZE_SIPI_INTERRUPTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,154,107,10
CONTROL "Unaligned DMA",IDC_UNALIGNED_DMA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,165,91,10
END
IDD_Settings_Accelerator DIALOGEX 0, 0, 218, 183
@ -577,19 +578,19 @@ BEGIN
EDITTEXT IDC_INFO3,69,51,104,15,ES_AUTOHSCROLL | ES_READONLY
END
IDD_Settings_Config DIALOGEX 0, 0, 357, 207
IDD_Settings_Config DIALOGEX 0, 0, 357, 217
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,194,186,50,14
PUSHBUTTON "Cancel",IDCANCEL,248,186,50,14
CONTROL "Tree1",IDC_PAGELIST,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,8,7,116,169
CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,180,343,1
PUSHBUTTON "Reset Page",IDC_RESET_PAGE,7,186,58,14,WS_DISABLED
CONTROL "",IDC_SETTING_INFO,"Static",SS_ETCHEDFRAME,131,7,219,170
PUSHBUTTON "Apply",IDAPPLY,301,186,50,14,WS_DISABLED
PUSHBUTTON "Reset All",IDC_RESET_ALL,68,186,52,14,WS_DISABLED
DEFPUSHBUTTON "OK",IDOK,194,196,50,14
PUSHBUTTON "Cancel",IDCANCEL,248,196,50,14
CONTROL "Tree1",IDC_PAGELIST,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,8,7,116,180
CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,192,343,1
PUSHBUTTON "Reset Page",IDC_RESET_PAGE,7,196,58,14,WS_DISABLED
CONTROL "",IDC_SETTING_INFO,"Static",SS_ETCHEDFRAME,131,7,219,181
PUSHBUTTON "Apply",IDAPPLY,301,196,50,14,WS_DISABLED
PUSHBUTTON "Reset All",IDC_RESET_ALL,68,196,52,14,WS_DISABLED
END
IDD_Settings_GameRecompiler DIALOGEX 0, 0, 230, 156
@ -1271,7 +1272,8 @@ BEGIN
CONTROL "32 Bit Engine",IDC_ROM_32BIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,58,91,10
CONTROL "Fixed Audio Timing",IDC_ROM_FIXEDAUDIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,69,91,10
CONTROL "Sync using Audio",IDC_SYNC_AUDIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,69,91,10
CONTROL "Unaligned DMA",IDC_UNALIGNED_DMA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,81,91,10
CONTROL "Randomize SI/PI interrupts",IDC_RANDOMIZE_SIPI_INTERRUPTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,81,107,10
CONTROL "Unaligned DMA",IDC_UNALIGNED_DMA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,93,91,10
END
IDD_Enhancement_Config DIALOGEX 0, 0, 206, 214
@ -1461,7 +1463,7 @@ BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 216
TOPMARGIN, 4
BOTTOMMARGIN, 163
BOTTOMMARGIN, 176
END
IDD_Settings_Accelerator, DIALOG
@ -1617,7 +1619,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 350
TOPMARGIN, 7
BOTTOMMARGIN, 200
BOTTOMMARGIN, 210
END
IDD_Settings_GameRecompiler, DIALOG

View File

@ -352,6 +352,7 @@
#define IDC_RDB 1158
#define IDC_UNALIGNED_DMA 1158
#define IDC_RDB_AUTHOR 1159
#define IDC_RANDOMIZE_SIPI_INTERRUPTS 1159
#define IDC_RDB_VERSION 1160
#define IDC_RDB_DATE 1161
#define IDC_CHT 1162