MCPcopy Create free account
hub / github.com/TASEmulators/fceux / loadPreferences

Function loadPreferences

src/drivers/win/pref.cpp:440–490  ·  view source on GitHub ↗

* Loads the debugging preferences from disk * * @param romname Name of the active ROM file * @return 0 or an error code. **/

Source from the content-addressed store, hash-verified

438* @return 0 or an error code.
439**/
440int loadPreferences(const char* romname)
441{
442 if (debuggerSaveLoadDEBFiles == false) {
443 return 0;
444 }
445
446 FILE* f;
447 int result;
448 int i;
449
450 myNumWPs = 0;
451
452 // Get the name of the preferences file
453 char* filename = (char*)malloc(strlen(romname) + 5);
454 strcpy(filename, romname);
455 strcat(filename, ".deb");
456
457 f = fopen(filename, "rb");
458 free(filename);
459
460 if (f)
461 {
462 result = loadDebuggerPreferences(f) || loadHexPreferences(f);
463 if (result)
464 {
465 // there was error when loading the .deb, reset the data to default
466 DeleteAllDebuggerBookmarks();
467 myNumWPs = 0;
468 break_on_instructions = break_on_cycles = FCEUI_Debugger().badopbreak = false;
469 break_instructions_limit = break_cycles_limit = 0;
470 hexBookmarks.bookmarkCount = 0;
471 }
472 fclose(f);
473 } else
474 {
475 result = 0;
476 }
477
478 // This prevents information from traveling between debugger interations.
479 // It needs to be run pretty much regardless of whether there's a .deb file or not,
480 // successful read or failure. Otherwise, it's basically leaving previous info around.
481 for (i=myNumWPs;i<=64;i++)
482 {
483 watchpoint[i].address = 0;
484 watchpoint[i].endaddress = 0;
485 watchpoint[i].flags = 0;
486 }
487
488 // Attempt to load the preferences
489 return result;
490}

Callers 1

FCEUI_LoadGameVirtualFunction · 0.85

Calls 3

loadDebuggerPreferencesFunction · 0.85
loadHexPreferencesFunction · 0.85

Tested by

no test coverage detected