Nearly working Debugger list Saving and Loading.

It loads correctly. It saves correctly in most cases.
The issue is that it randomly overwrites the debugger's list for an opened game if you cycle through the recent files list, or it otherwise fails to load the opened game's .deb file.
This commit is contained in:
ugetab 2009-09-17 06:36:09 +00:00
parent 995d178b42
commit 86ce4304cb
6 changed files with 90 additions and 4 deletions

View File

@ -95,7 +95,7 @@ extern uint8 PPU[4],PALRAM[0x20],SPRAM[0x100],VRAMBuffer,PPUGenLatch,XOffset;
extern uint32 RefreshAddr;
extern int debug_loggingCD;
extern int numWPs;
extern int numWPs;
///encapsulates the operational state of the debugger core
class DebuggerState {

View File

@ -893,6 +893,7 @@ void DebuggerExit()
{
FCEUI_Debugger().badopbreak = 0;
debugger_open = 0;
inDebugger = false;
DestroyWindow(hDebug);
}
@ -1015,6 +1016,13 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
numWPs = myNumWPs;
if (numWPs < 64) {
watchpoint[numWPs + 1].address = 0;
watchpoint[numWPs + 1].endaddress = 0;
watchpoint[numWPs + 1].flags = 0;
}
}
else
{
@ -1027,6 +1035,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
FCEUI_Debugger().badopbreak = false;
debugger_open = 1;
inDebugger = true;
FillBreakList(hwndDlg);
break;
}

View File

@ -28,6 +28,7 @@ extern void AddBreakList();
void UpdateDebugger();
void DoDebug(uint8 halt);
void DebuggerExit();
extern bool inDebugger;

View File

@ -29,6 +29,7 @@
#include "../../debug.h"
extern char symbDebugEnabled;
bool wasinDebugger = false;
/**
* Stores debugger preferences in a file
@ -42,7 +43,7 @@ int storeDebuggerPreferences(FILE* f)
// Flag that says whether symbolic debugging should be enabled
if (fwrite(&symbDebugEnabled, 1, 1, f) != 1) return 1;
// Write the number of active CPU bookmarks
if (fwrite(&bookmarks, sizeof(unsigned int), 1, f) != 1) return 1;
// Write the addresses of those bookmarks
@ -125,6 +126,24 @@ int storePreferences(char* romname)
{
FILE* f;
char* filename;
int result;
int Counter;
// Prevent any attempts at file usage if the debugger is open
//if (inDebugger) return 0;
wasinDebugger = inDebugger;
// Prevent any attempts at file usage if the debugger is open
if (wasinDebugger) {
DebuggerExit();
}
while ((inDebugger) || (Counter == 300000)) {
Counter++;
}
//while (inDebugger);
if (!debuggerWasActive)
{
@ -138,7 +157,13 @@ int storePreferences(char* romname)
free(filename);
return !f || storeDebuggerPreferences(f) || storeHexPreferences(f);
result = !f || storeDebuggerPreferences(f) || storeHexPreferences(f);
if (f) {
fclose(f);
}
return result;
}
int myNumWPs = 0;
@ -153,6 +178,7 @@ int loadDebugDataFailed = 0;
int loadDebuggerPreferences(FILE* f)
{
unsigned int i;
// Read flag that says if symbolic debugging is enabled
if (fread(&symbDebugEnabled, sizeof(symbDebugEnabled), 1, f) != 1) return 1;
@ -268,6 +294,10 @@ int loadHexPreferences(FILE* f)
int loadPreferences(char* romname)
{
FILE* f;
int result;
myNumWPs = 0;
// Get the name of the preferences file
char* filename = (char*)malloc(strlen(romname) + 5);
sprintf(filename, "%s.deb", romname);
@ -275,6 +305,16 @@ int loadPreferences(char* romname)
f = fopen(filename, "rb");
free(filename);
result = f ? loadDebuggerPreferences(f) || loadHexPreferences(f) : 0;
if (f) {
fclose(f);
}
if (wasinDebugger){
DoDebug(0);
}
// Attempt to load the preferences
return f ? loadDebuggerPreferences(f) || loadHexPreferences(f) : 0;
return result;
}

View File

@ -21,6 +21,7 @@
#include <windows.h>
extern int myNumWPs;
extern bool inDebugger;
int storePreferences(char* romname);
int loadPreferences(char* romname);

View File

@ -50,6 +50,10 @@
#include "vsuni.h"
#include "ines.h"
#ifdef WIN32
#include "drivers/win/pref.h"
#endif
#include <fstream>
#include <sstream>
@ -93,6 +97,23 @@ static void CloseGame(void)
{
if(GameInfo)
{
#ifdef WIN32
// ################################## Start of SP CODE ###########################
//This subroutine works if used here, but it randomly overwrites the
//list of opened games when those games are later closed, I believe.
//
//The problem may be a load issue, but the save is what commits the error.
//
//extern char LoadedRomFName[2048];
//if (storePreferences(LoadedRomFName))
//{
// FCEUD_PrintError("Couldn't store debugging data");
//}
// ################################## End of SP CODE ###########################
#endif
if(FCEUnetplay)
{
FCEUD_NetworkClose();
@ -435,6 +456,19 @@ endlseq:
FCEU_fclose(fp);
#ifdef WIN32
// ################################## Start of SP CODE ###########################
extern char LoadedRomFName[2048];
extern int loadDebugDataFailed;
if ((loadDebugDataFailed = loadPreferences(LoadedRomFName)))
{
FCEUD_PrintError("Couldn't load debugging data");
}
// ################################## End of SP CODE ###########################
#endif
FCEU_ResetVidSys();
if(GameInfo->type!=GIT_NSF)
@ -658,6 +692,7 @@ void FCEUI_CloseGame(void)
{
if(!FCEU_IsValidUI(FCEUI_CLOSEGAME))
return;
CloseGame();
}