fix for loading savestates which mismatch current 8MB debug mode setting

This commit is contained in:
zeromus 2009-03-19 18:58:14 +00:00
parent 2a66e41ad5
commit d87ac68255
7 changed files with 51 additions and 24 deletions

View File

@ -98,6 +98,7 @@ static const int save_types[7][2] = {
};
u16 partie = 1;
u32 _MMU_MAIN_MEM_MASK = 0x3FFFFF;
#define ROM_MASK 3

View File

@ -204,12 +204,11 @@ u8 FASTCALL _MMU_ARM7_read08(u32 adr);
u16 FASTCALL _MMU_ARM7_read16(u32 adr);
u32 FASTCALL _MMU_ARM7_read32(u32 adr);
//in debug builds we have twice as much memory
#ifdef DEVELOPER
#define _MMU_MAIN_MEM_MASK 0x7FFFFF
#else
#define _MMU_MAIN_MEM_MASK 0x3FFFFF
#endif
extern u32 _MMU_MAIN_MEM_MASK;
inline void SetupMMU(bool debugConsole) {
if(debugConsole) _MMU_MAIN_MEM_MASK = 0x7FFFFF;
else _MMU_MAIN_MEM_MASK = 0x3FFFFF;
}
FORCEINLINE u8 _MMU_read08(const int PROCNUM, u32 addr) {
if(PROCNUM==ARMCPU_ARM9)

View File

@ -969,6 +969,8 @@ void NDS_Reset( void)
nds.lignerendu = FALSE;
nds.touchX = nds.touchY = 0;
nds.isTouch = 0;
nds.debugConsole = CommonSettings.DebugConsole;
SetupMMU(nds.debugConsole);
_MMU_write16<ARMCPU_ARM9>(0x04000130, 0x3FF);
_MMU_write16<ARMCPU_ARM7>(0x04000130, 0x3FF);
@ -1440,7 +1442,9 @@ u32 NDS_exec(s32 nb)
nds.ARM9Cycle += armcpu_exec<ARMCPU_ARM9>();
}
#ifdef _WIN32
#ifdef DEVELOPER
DisassemblerTools_Refresh(ARMCPU_ARM9);
#endif
#endif
}
@ -1486,7 +1490,9 @@ u32 NDS_exec(s32 nb)
nds.ARM7Cycle += (armcpu_exec<ARMCPU_ARM7>()<<1);
}
#ifdef _WIN32
#ifdef DEVELOPER
DisassemblerTools_Refresh(ARMCPU_ARM7);
#endif
#endif
}

View File

@ -142,6 +142,9 @@ typedef struct
s32 runCycleCollector[16];
s32 idleFrameCounter;
//if the game was booted on a debug console, this is set
BOOL debugConsole;
bool isInVblank() const { return VCount >= 192; }
bool isIn3dVblank() const { return VCount >= 192 && VCount<215; }
} NDSSystem;
@ -289,6 +292,7 @@ extern struct TCommonSettings {
, SWIFromBIOS(false)
, UseExtFirmware(false)
, BootFromFirmware(false)
, DebugConsole(false)
{
strcpy(ARM9BIOS, "biosnds9.bin");
strcpy(ARM7BIOS, "biosnds7.bin");
@ -304,6 +308,7 @@ extern struct TCommonSettings {
bool UseExtFirmware;
char Firmware[256];
bool BootFromFirmware;
bool DebugConsole;
} CommonSettings;
extern char ROMserial[20];

View File

@ -131,11 +131,10 @@ SFORMAT SF_ARM9[]={
SFORMAT SF_MEM[]={
{ "ITCM", 1, 0x8000, ARM9Mem.ARM9_ITCM},
{ "DTCM", 1, 0x4000, ARM9Mem.ARM9_DTCM},
//for legacy purposes, WRAX is a separate variable. shouldnt be a problem.
{ "WRAM", 1, 0x400000, ARM9Mem.MAIN_MEM},
#ifdef DEVELOPER
//expanded memory is only saved and loaded if this is a debug console
{ "WRAX", 1, 0x400000, ARM9Mem.MAIN_MEM+0x400000},
#endif
//NOTE - this is not as large as the allocated memory.
//the memory is overlarge due to the way our memory map system is setup
@ -166,6 +165,7 @@ SFORMAT SF_NDS[]={
{ "_TPX", 2, 1, &nds.touchX},
{ "_TPY", 2, 1, &nds.touchY},
{ "_TPB", 4, 1, &nds.isTouch},
{ "_DBG", 4, 1, &nds.debugConsole},
{ 0 }
};
@ -785,6 +785,8 @@ static void loadstate()
_MMU_write16<ARMCPU_ARM9>(i, _MMU_read16<ARMCPU_ARM9>(i));
for (int i = REG_BASE_DISPB; i<=REG_BASE_DISPB + 0x7F; i+=2)
_MMU_write16<ARMCPU_ARM9>(i, _MMU_read16<ARMCPU_ARM9>(i));
SetupMMU(nds.debugConsole);
}
static bool savestate_load(std::istream* is)
@ -832,18 +834,24 @@ static bool savestate_load(std::istream* is)
//the full reset wipes more things, so we can make sure that they are being restored correctly
NDS_Reset();
//reset some options to their old defaults which werent saved
nds.debugConsole = FALSE;
//GPU_Reset(MainScreen.gpu, 0);
//GPU_Reset(SubScreen.gpu, 1);
//gfx3d_reset();
//gpu3D->NDS_3D_Reset();
//SPU_Reset();
memorystream mstemp(&buf);
bool x = ReadStateChunks(&mstemp,(s32)len);
loadstate();
if(nds.debugConsole!=0 != CommonSettings.DebugConsole) {
printf("WARNING: forcing console debug mode to: debugmode=%s\n",nds.debugConsole?"TRUE":"FALSE");
}
return x;
}

View File

@ -1445,14 +1445,15 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
sndvolume = GetPrivateProfileInt("Sound","Volume",100, IniName);
SPU_SetVolume(sndvolume);
CommonSettings.UseExtBIOS = GetPrivateProfileInt("BIOS", "UseExtBIOS", false, IniName);
CommonSettings.DebugConsole = GetPrivateProfileInt("Emulation", "DebugConsole", FALSE, IniName);
CommonSettings.UseExtBIOS = GetPrivateProfileInt("BIOS", "UseExtBIOS", FALSE, IniName);
GetPrivateProfileString("BIOS", "ARM9BIOSFile", "bios9.bin", CommonSettings.ARM9BIOS, 256, IniName);
GetPrivateProfileString("BIOS", "ARM7BIOSFile", "bios7.bin", CommonSettings.ARM7BIOS, 256, IniName);
CommonSettings.SWIFromBIOS = GetPrivateProfileInt("BIOS", "SWIFromBIOS", false, IniName);
CommonSettings.SWIFromBIOS = GetPrivateProfileInt("BIOS", "SWIFromBIOS", FALSE, IniName);
CommonSettings.UseExtFirmware = GetPrivateProfileInt("Firmware", "UseExtFirmware", false, IniName);
CommonSettings.UseExtFirmware = GetPrivateProfileInt("Firmware", "UseExtFirmware", FALSE, IniName);
GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName);
CommonSettings.BootFromFirmware = GetPrivateProfileInt("Firmware", "BootFromFirmware", false, IniName);
CommonSettings.BootFromFirmware = GetPrivateProfileInt("Firmware", "BootFromFirmware", FALSE, IniName);
/* Read the firmware settings from the init file */
win_fw_config.fav_colour = GetPrivateProfileInt("Firmware","favColor", 10, IniName);
@ -2272,6 +2273,15 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
NDS_releaseTouch();
return 0;
case WM_INITMENU: {
HMENU menu = (HMENU)wParam;
//last minute modification of menu before display
#ifndef DEVELOPER
RemoveMenu(menu,IDM_DISASSEMBLER,MF_BYCOMMAND);
#endif
break;
}
case WM_COMMAND:
if(HIWORD(wParam) == 0 || HIWORD(wParam) == 1)
{
@ -2981,14 +2991,10 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
{
HWND cur;
cur = GetDlgItem(hDlg, IDC_CHECKBOX_DEBUGGERMODE);
EnableWindow(cur, FALSE);
CheckDlgButton(hDlg, IDC_CHECKBOX_DEBUGGERMODE, ((CommonSettings.DebugConsole == true) ? BST_CHECKED : BST_UNCHECKED));
CheckDlgButton(hDlg, IDC_USEEXTBIOS, ((CommonSettings.UseExtBIOS == true) ? BST_CHECKED : BST_UNCHECKED));
cur = GetDlgItem(hDlg, IDC_ARM9BIOS);
SetWindowText(cur, CommonSettings.ARM9BIOS);
cur = GetDlgItem(hDlg, IDC_ARM7BIOS);
SetWindowText(cur, CommonSettings.ARM7BIOS);
SetDlgItemText(hDlg, IDC_ARM9BIOS, CommonSettings.ARM9BIOS);
SetDlgItemText(hDlg, IDC_ARM7BIOS, CommonSettings.ARM7BIOS);
CheckDlgButton(hDlg, IDC_BIOSSWIS, ((CommonSettings.SWIFromBIOS == true) ? BST_CHECKED : BST_UNCHECKED));
if(CommonSettings.UseExtBIOS == false)
@ -3006,8 +3012,7 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
}
CheckDlgButton(hDlg, IDC_USEEXTFIRMWARE, ((CommonSettings.UseExtFirmware == true) ? BST_CHECKED : BST_UNCHECKED));
cur = GetDlgItem(hDlg, IDC_FIRMWARE);
SetWindowText(cur, CommonSettings.Firmware);
SetDlgItemText(hDlg, IDC_FIRMWARE, CommonSettings.Firmware);
CheckDlgButton(hDlg, IDC_FIRMWAREBOOT, ((CommonSettings.BootFromFirmware == true) ? BST_CHECKED : BST_UNCHECKED));
if(CommonSettings.UseExtFirmware == false)
@ -3049,6 +3054,9 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
GetWindowText(cur, CommonSettings.Firmware, 256);
CommonSettings.BootFromFirmware = IsDlgButtonChecked(hDlg, IDC_FIRMWAREBOOT);
CommonSettings.DebugConsole = IsDlgButtonChecked(hDlg, IDC_CHECKBOX_DEBUGGERMODE);
WritePrivateProfileInt("Emulation", "DebugConsole", ((CommonSettings.DebugConsole == true) ? 1 : 0), IniName);
WritePrivateProfileInt("BIOS", "UseExtBIOS", ((CommonSettings.UseExtBIOS == true) ? 1 : 0), IniName);
WritePrivateProfileString("BIOS", "ARM9BIOSFile", CommonSettings.ARM9BIOS, IniName);
WritePrivateProfileString("BIOS", "ARM7BIOSFile", CommonSettings.ARM7BIOS, IniName);

View File

@ -1223,7 +1223,7 @@ FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK", IDOK, 130, 250, 50, 14, BS_DEFPUSHBUTTON
PUSHBUTTON "Cancel", IDCANCEL, 185, 250, 50, 14, BS_PUSHBUTTON
AUTOCHECKBOX "8MB Debugger Mode", IDC_CHECKBOX_DEBUGGERMODE, 15, 35, 82, 10, BS_AUTOCHECKBOX
AUTOCHECKBOX "Use 8MB debugger mode when starting execution", IDC_CHECKBOX_DEBUGGERMODE, 15, 35, 182, 10, BS_AUTOCHECKBOX
LTEXT "If you have to ask, you don't need to change these.", IDC_STATIC, 15, 20, 169, 8, SS_LEFT
GROUPBOX "BIOS", IDC_STATIC, 5, 55, 230, 105
AUTOCHECKBOX "Use external BIOS images", IDC_USEEXTBIOS, 15, 70, 210, 10, BS_AUTOCHECKBOX