[Settings] Add Disk Seek Timing choice

This commit is contained in:
LuigiBlood 2021-01-29 23:37:27 +01:00
parent b6325104a5
commit 6f05e7a2f2
16 changed files with 226 additions and 49 deletions

View File

@ -236,6 +236,7 @@ enum LanguageStringID
TAB_RECOMPILER = 411,
TAB_DEFAULTS = 412,
TAB_DISKDRIVE = 413,
TAB_DISKSETTINGS = 414,
//Plugin Dialog
PLUG_ABOUT = 420,
@ -337,6 +338,9 @@ enum LanguageStringID
ROM_UNALIGNED_DMA = 5410,
ROM_RANDOMIZE_SIPI_INTERRUPTS = 5420,
ROM_MEM_SIZE_NOTE = 5430,
ROM_DISK_SEEK_TIMING = 5440,
ROM_DISK_SEEK_TIMING_TURBO = 5441,
ROM_DISK_SEEK_TIMING_SLOW = 5442,
//Core Styles
CORE_INTERPTER = 540,

View File

@ -203,6 +203,7 @@ void CLanguage::LoadDefaultStrings(void)
DEF_STR(TAB_RECOMPILER, "Recompiler");
DEF_STR(TAB_DEFAULTS, "Defaults");
DEF_STR(TAB_DISKDRIVE, "64DD");
DEF_STR(TAB_DISKSETTINGS, "64DD");
//Plugin Dialog
DEF_STR(PLUG_ABOUT, "About");
@ -303,6 +304,9 @@ void CLanguage::LoadDefaultStrings(void)
DEF_STR(ROM_UNALIGNED_DMA, "Unaligned DMA");
DEF_STR(ROM_RANDOMIZE_SIPI_INTERRUPTS, "Randomize SI/PI interrupts");
DEF_STR(ROM_MEM_SIZE_NOTE, "Note: 8 MB is forced for Unknown ROMs.");
DEF_STR(ROM_DISK_SEEK_TIMING, "Disk Seek Timing:");
DEF_STR(ROM_DISK_SEEK_TIMING_TURBO, "Turbo");
DEF_STR(ROM_DISK_SEEK_TIMING_SLOW, "Slow");
//Core Styles
DEF_STR(CORE_INTERPTER, "Interpreter");

View File

@ -107,60 +107,73 @@ void DiskCommand()
if (isSeek)
{
//Emulate Seek Times, send interrupt later
uint32_t seektime = 0;
//Start Motor, can take half a second, delay the response
if (g_Reg->ASIC_STATUS & DD_STATUS_MTR_N_SPIN)
if ((DISK_SEEK_TYPE)g_Settings->LoadDword(Game_DiskSeekTiming) == DiskSeek_Turbo)
{
seektime += (0x5A00000 / 2);
g_Reg->ASIC_STATUS &= ~DD_STATUS_MTR_N_SPIN;
//Instant Response for Turbo
//Set timer for seek response
g_SystemTimer->SetTimer(g_SystemTimer->DDSeekTimer, 0, false);
//Set timer for motor
g_SystemTimer->SetTimer(g_SystemTimer->DDMotorTimer, 0, false);
}
//Get Zone to calculate seek times
uint32_t track = g_Reg->ASIC_CUR_TK >> 16 & 0x0FFF;
uint32_t zone = 0;
uint32_t zonebound = 0;
for (uint8_t i = 0; i < 8; i++)
else /* if ((DISK_SEEK_TYPE)g_Settings->LoadDword(Game_DiskSeekTiming) == DiskSeek_Slow) */
{
zonebound += ddZoneTrackSize[i];
if (track < zonebound)
//Emulate Seek Times, send interrupt later
uint32_t seektime = 0;
//Start Motor, can take half a second, delay the response
if (g_Reg->ASIC_STATUS & DD_STATUS_MTR_N_SPIN)
{
zone = i;
if (g_Reg->ASIC_CUR_TK & 0x10000000)
zone++;
seektime += (0x5A00000 / 2);
g_Reg->ASIC_STATUS &= ~DD_STATUS_MTR_N_SPIN;
}
//Get Zone to calculate seek times
uint32_t track = g_Reg->ASIC_CUR_TK >> 16 & 0x0FFF;
uint32_t zone = 0;
uint32_t zonebound = 0;
for (uint8_t i = 0; i < 8; i++)
{
zonebound += ddZoneTrackSize[i];
if (track < zonebound)
{
zone = i;
if (g_Reg->ASIC_CUR_TK & 0x10000000)
zone++;
break;
}
}
//Add seek delay depending on the zone (this is inaccurate timing, but close enough)
seektime += 0x179200;
switch (zone)
{
case 0:
case 1:
default:
seektime += track * 38;
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
seektime += 0x13C * 38 + (track - 0x13C) * 46;
break;
case 8:
seektime += 0x13C * 38 + 0x2E9 * 46 + (track - 0x425) * 58;
break;
}
//Set timer for seek response
g_SystemTimer->SetTimer(g_SystemTimer->DDSeekTimer, seektime, false);
//Set timer for motor to shutdown in 5 seconds, reset the timer if other seek commands were sent
g_SystemTimer->SetTimer(g_SystemTimer->DDMotorTimer, 0x5A00000 * 5, false);
}
//Add seek delay depending on the zone (this is inaccurate timing, but close enough)
seektime += 0x179200;
switch (zone)
{
case 0:
case 1:
default:
seektime += track * 38;
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
seektime += 0x13C * 38 + (track - 0x13C) * 46;
break;
case 8:
seektime += 0x13C * 38 + 0x2E9 * 46 + (track - 0x425) * 58;
break;
}
//Set timer for seek response
g_SystemTimer->SetTimer(g_SystemTimer->DDSeekTimer, seektime, false);
//Set timer for motor to shutdown in 5 seconds, reset the timer if other seek commands were sent
g_SystemTimer->SetTimer(g_SystemTimer->DDMotorTimer, 0x5A00000 * 5, false);
}
else
{

View File

@ -59,6 +59,11 @@ enum SAVE_DISK_TYPE
SaveDisk_ShadowFile = 0, SaveDisk_RAMFile = 1,
};
enum DISK_SEEK_TYPE
{
DiskSeek_Turbo = 0, DiskSeek_Slow = 1,
};
enum FUNC_LOOKUP_METHOD
{
FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3,

View File

@ -148,6 +148,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Default_UnalignedDMA, new CSettingTypeApplication("Defaults", "Unaligned DMA", false));
AddHandler(Default_RandomizeSIPIInterrupts, new CSettingTypeApplication("Defaults", "Randomize SI/PI Interrupts", true));
AddHandler(Default_SMM_Protect_Memory, new CSettingTypeApplication("Defaults", "SMM-Protect", false));
AddHandler(Default_DiskSeekTiming, new CSettingTypeApplication("Defaults", "Disk Seek Timing", (uint32_t)DiskSeek_Turbo));
AddHandler(Rdb_GoodName, new CSettingTypeRomDatabase("Good Name", Game_GameName));
AddHandler(Rdb_RPCKey, new CSettingTypeRomDatabase("RPC Key", Game_RPCKey));
@ -192,6 +193,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
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(Rdb_DiskSeekTiming, new CSettingTypeRomDatabase("DiskSeekTiming", Default_DiskSeekTiming));
AddHandler(Game_IniKey, new CSettingTypeTempString(""));
AddHandler(Game_File, new CSettingTypeTempString(""));
@ -253,6 +255,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Game_UnalignedDMA, new CSettingTypeGame("Unaligned DMA", Rdb_UnalignedDMA));
AddHandler(Game_RandomizeSIPIInterrupts, new CSettingTypeGame("Randomize SI/PI Interrupts", Rdb_RandomizeSIPIInterrupts));
AddHandler(Game_RPCKey, new CSettingTypeTempString(""));
AddHandler(Game_DiskSeekTiming, new CSettingTypeGame("DiskSeekTiming", Rdb_DiskSeekTiming));
//User Interface
AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("Settings", "Display CPU Usage", (uint32_t)false));

View File

@ -84,6 +84,7 @@ enum SettingID
Default_UnalignedDMA,
Default_RandomizeSIPIInterrupts,
Default_SMM_Protect_Memory,
Default_DiskSeekTiming,
//RDB Settings
Rdb_GoodName,
@ -125,6 +126,7 @@ enum SettingID
Rdb_UnalignedDMA,
Rdb_RandomizeSIPIInterrupts,
Rdb_RPCKey,
Rdb_DiskSeekTiming,
//Individual Game Settings
Game_IniKey,
@ -183,6 +185,7 @@ enum SettingID
Game_UnalignedDMA,
Game_RandomizeSIPIInterrupts,
Game_RPCKey,
Game_DiskSeekTiming,
// General Game running info
GameRunning_LoadingInProgress,

View File

@ -100,6 +100,7 @@
<ClCompile Include="UserInterface\Settings\SettingsPage-Defaults.cpp" />
<ClCompile Include="UserInterface\Settings\SettingsPage-Directories.cpp" />
<ClCompile Include="UserInterface\Settings\SettingsPage-DiskDrive.cpp" />
<ClCompile Include="UserInterface\Settings\SettingsPage-Game-DiskDrive.cpp" />
<ClCompile Include="UserInterface\Settings\SettingsPage-Game-General.cpp" />
<ClCompile Include="UserInterface\Settings\SettingsPage-Game-Plugin.cpp" />
<ClCompile Include="UserInterface\Settings\SettingsPage-Game-Recompiler.cpp" />
@ -175,6 +176,7 @@
<ClInclude Include="UserInterface\Settings\SettingsPage-Defaults.h" />
<ClInclude Include="UserInterface\Settings\SettingsPage-Directories.h" />
<ClInclude Include="UserInterface\Settings\SettingsPage-DiskDrive.h" />
<ClInclude Include="UserInterface\Settings\SettingsPage-Game-DiskDrive.h" />
<ClInclude Include="UserInterface\Settings\SettingsPage-Game-General.h" />
<ClInclude Include="UserInterface\Settings\SettingsPage-Game-Plugin.h" />
<ClInclude Include="UserInterface\Settings\SettingsPage-Game-Recompiler.h" />

View File

@ -252,6 +252,9 @@
<ClCompile Include="UserInterface\EnhancementUI.cpp">
<Filter>Source Files\User Interface Source</Filter>
</ClCompile>
<ClCompile Include="UserInterface\Settings\SettingsPage-Game-DiskDrive.cpp">
<Filter>Source Files\User Interface Source\Settings Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="UserInterface\resource.h">
@ -488,6 +491,9 @@
<ClInclude Include="UserInterface\EnhancementUI.h">
<Filter>Header Files\User Interface Headers</Filter>
</ClInclude>
<ClInclude Include="UserInterface\Settings\SettingsPage-Game-DiskDrive.h">
<Filter>Header Files\User Interface Headers\Settings Header</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\divider.cur">

View File

@ -32,6 +32,7 @@ CDefaultsOptionsPage::CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay)
SetDlgItemText(IDC_UNALIGNED_DMA, wGS(ROM_UNALIGNED_DMA).c_str());
SetDlgItemText(IDC_RANDOMIZE_SIPI_INTERRUPTS, wGS(ROM_RANDOMIZE_SIPI_INTERRUPTS).c_str());
SetDlgItemText(IDC_PROTECT_MEMORY, wGS(ADVANCE_SMM_PROTECT).c_str());
SetDlgItemText(IDC_DISKSEEKTIMING_TEXT1, wGS(ROM_DISK_SEEK_TIMING).c_str());
CModifiedComboBox * ComboBox;
ComboBox = AddModComboBox(GetDlgItem(IDC_RDRAM_SIZE), Default_RDRamSize);
@ -67,6 +68,15 @@ CDefaultsOptionsPage::CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay)
AddModCheckBox(GetDlgItem(IDC_UNALIGNED_DMA), Default_UnalignedDMA);
AddModCheckBox(GetDlgItem(IDC_RANDOMIZE_SIPI_INTERRUPTS), Default_RandomizeSIPIInterrupts);
AddModCheckBox(GetDlgItem(IDC_PROTECT_MEMORY), Default_SMM_Protect_Memory);
AddModCheckBox(GetDlgItem(IDC_DISKSEEKTIMING), Default_DiskSeekTiming);
ComboBox = AddModComboBox(GetDlgItem(IDC_DISKSEEKTIMING), Default_DiskSeekTiming);
if (ComboBox)
{
//ComboBox->SetTextField(GetDlgItem(IDC_COUNTFACT_TEXT));
ComboBox->AddItem(wGS(ROM_DISK_SEEK_TIMING_TURBO).c_str(), DiskSeek_Turbo);
ComboBox->AddItem(wGS(ROM_DISK_SEEK_TIMING_SLOW).c_str(), DiskSeek_Slow);
}
if (!g_Settings->LoadBool(Setting_SyncViaAudioEnabled))
{

View File

@ -25,6 +25,7 @@ class CDefaultsOptionsPage :
COMMAND_ID_HANDLER_EX(IDC_PROTECT_MEMORY, CheckBoxChanged)
COMMAND_HANDLER_EX(IDC_RDRAM_SIZE, LBN_SELCHANGE, ComboBoxChanged)
COMMAND_HANDLER_EX(IDC_COUNTFACT, LBN_SELCHANGE, ComboBoxChanged)
COMMAND_HANDLER_EX(IDC_DISKSEEKTIMING, LBN_SELCHANGE, ComboBoxChanged)
COMMAND_HANDLER_EX(IDC_VIREFRESH, EN_UPDATE, EditBoxChanged)
COMMAND_HANDLER_EX(IDC_COUNTPERBYTE, EN_UPDATE, EditBoxChanged)
COMMAND_HANDLER_EX(IDC_RDRAM_SIZE, EN_UPDATE, EditBoxChanged)

View File

@ -0,0 +1,62 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include "SettingsPage.h"
#include "SettingsPage-Game-DiskDrive.h"
CGameDiskDrivePage::CGameDiskDrivePage(HWND hParent, const RECT & rcDispay)
{
if (!Create(hParent, rcDispay))
{
return;
}
//Set the text for all gui Items
SetDlgItemText(IDC_DISKSEEKTIMING_TEXT2, wGS(ROM_DISK_SEEK_TIMING).c_str());
CModifiedComboBox* ComboBox;
ComboBox = AddModComboBox(GetDlgItem(IDC_DISKSEEKTIMING2), Game_DiskSeekTiming);
if (ComboBox)
{
//ComboBox->SetTextField(GetDlgItem(IDC_MEMORY_SIZE_TEXT));
ComboBox->AddItem(wGS(ROM_DISK_SEEK_TIMING_TURBO).c_str(), DiskSeek_Turbo);
ComboBox->AddItem(wGS(ROM_DISK_SEEK_TIMING_SLOW).c_str(), DiskSeek_Slow);
}
UpdatePageSettings();
}
void CGameDiskDrivePage::ShowPage()
{
ShowWindow(SW_SHOW);
}
void CGameDiskDrivePage::HidePage()
{
ShowWindow(SW_HIDE);
}
void CGameDiskDrivePage::ApplySettings(bool UpdateScreen)
{
CSettingsPageImpl<CGameDiskDrivePage>::ApplySettings(UpdateScreen);
}
bool CGameDiskDrivePage::EnableReset(void)
{
if (CSettingsPageImpl<CGameDiskDrivePage>::EnableReset()) { return true; }
return false;
}
void CGameDiskDrivePage::ResetPage()
{
CSettingsPageImpl<CGameDiskDrivePage>::ResetPage();
}

View File

@ -0,0 +1,35 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
#include "../WTLControls/ModifiedCheckBox.h"
#include <Project64-core/N64System/N64Types.h>
class CGameDiskDrivePage :
public CSettingsPageImpl<CGameDiskDrivePage>,
public CSettingsPage
{
BEGIN_MSG_MAP_EX(CGameDiskDrivePage)
COMMAND_HANDLER_EX(IDC_DISKSEEKTIMING2, LBN_SELCHANGE, ComboBoxChanged)
END_MSG_MAP()
enum { IDD = IDD_Settings_GameDiskDrive };
public:
CGameDiskDrivePage(HWND hParent, const RECT & rcDispay);
LanguageStringID PageTitle(void) { return TAB_DISKSETTINGS; }
void HidePage(void);
void ShowPage(void);
void ApplySettings(bool UpdateScreen);
bool EnableReset(void);
void ResetPage(void);
};

View File

@ -587,6 +587,7 @@ public:
#include "SettingsPage-Game-General.h"
#include "SettingsPage-Game-Plugin.h"
#include "SettingsPage-Game-Recompiler.h"
#include "SettingsPage-Game-DiskDrive.h"
#include "SettingsPage-Game-Status.h"
#include "SettingsPage-GameBrowser.h"
#include "SettingsPage-KeyboardShortcuts.h"

View File

@ -164,6 +164,7 @@ LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
GameSettings->AddPage(new CGameGeneralPage(this->m_hWnd, rcSettingInfo));
GameSettings->AddPage(new CGameRecompilePage(this->m_hWnd, rcSettingInfo));
GameSettings->AddPage(new CGamePluginPage(this->m_hWnd, rcSettingInfo));
GameSettings->AddPage(new CGameDiskDrivePage(this->m_hWnd, rcSettingInfo));
if (g_Settings->LoadBool(Setting_RdbEditor))
{
GameSettings->AddPage(new CGameStatusPage(this->m_hWnd, rcSettingInfo));

View File

@ -1243,6 +1243,8 @@ BEGIN
CONTROL "Unaligned DMA",IDC_UNALIGNED_DMA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,118,91,10
CONTROL "Protect Memory",IDC_PROTECT_MEMORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,118,91,10
RTEXT "Note: 8 MB is forced for Unknown ROMs.",IDC_MEMORY_SIZE_NOTE,6,22,205,8
COMBOBOX IDC_DISKSEEKTIMING,102,132,109,49,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Disk Seek Timing:",IDC_DISKSEEKTIMING_TEXT1,6,134,91,10
END
IDD_Enhancement_Config DIALOGEX 0, 0, 206, 214
@ -1390,6 +1392,14 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,109,62,50,14
END
IDD_Settings_GameDiskDrive DIALOGEX 0, 0, 218, 182
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
COMBOBOX IDC_DISKSEEKTIMING2,102,8,109,49,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Disk Seek Timing:",IDC_DISKSEEKTIMING_TEXT2,6,10,91,10
END
/////////////////////////////////////////////////////////////////////////////
//
@ -1849,6 +1859,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 76
END
IDD_Settings_GameDiskDrive, DIALOG
BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 216
TOPMARGIN, 4
BOTTOMMARGIN, 176
END
END
#endif // APSTUDIO_INVOKED
@ -2221,6 +2239,10 @@ BEGIN
0
END
IDD_Settings_GameDiskDrive AFX_DIALOG_LAYOUT
BEGIN
0
END
/////////////////////////////////////////////////////////////////////////////
//

View File

@ -80,6 +80,7 @@
#define IDD_Debugger_Search_SetValue 210
#define IDD_Settings_DiskDrive 215
#define IDD_Support_RequestCode 216
#define IDD_Settings_GameDiskDrive 217
#define IDC_MENU_ITEM_TEXT 1000
#define IDC_CLOSE_BUTTON 1001
#define IDC_LIST2 1003
@ -265,6 +266,7 @@
#define IDC_ROM_FASTSP 1101
#define IDC_INFO 1101
#define IDC_OVER_CLOCK_MODIFIER_TEXT 1101
#define IDC_DISKSEEKTIMING_TEXT1 1101
#define IDC_AUDIO_SIGNAL 1102
#define IDC_DIR_TEXTURE_FRAME 1102
#define IDC_ENTER_CODE 1102
@ -707,9 +709,12 @@
#define IDC_SCRIPTS_GRP 1578
#define IDC_F4_LBL 1579
#define IDC_OUTPUT_GRP 1579
#define IDC_DISKSEEKTIMING_TEXT2 1579
#define IDC_F5_LBL 1580
#define IDC_EVAL_LBL 1580
#define IDC_DISKSEEKTIMING 1580
#define IDC_F6_LBL 1581
#define IDC_DISKSEEKTIMING2 1581
#define IDC_F7_LBL 1582
#define IDC_F8_LBL 1583
#define IDC_F9_LBL 1584
@ -922,9 +927,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 222
#define _APS_NEXT_RESOURCE_VALUE 225
#define _APS_NEXT_COMMAND_VALUE 40121
#define _APS_NEXT_CONTROL_VALUE 1578
#define _APS_NEXT_CONTROL_VALUE 1582
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif