Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions desmume/src/frontend/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#define SCREENS_PIXEL_SIZE 98304
volatile bool execute = false;
static bool rom_opened = false;
TieredRegion hooked_regions [HOOK_COUNT];
std::map<unsigned int, memory_cb_fnc> hooks[HOOK_COUNT];

Expand Down Expand Up @@ -97,11 +98,23 @@ EXPORTED void desmume_set_language(u8 lang)
EXPORTED int desmume_open(const char *filename)
{
int i;
if (rom_opened) {
NDS_FreeROM();
}
clear_savestates();
i = NDS_LoadROM(filename);
if (i > 0) {
rom_opened = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if rom_opened was already true, it will stay true even if i <= 0

}
return i;
}

EXPORTED void desmume_close()
{
NDS_FreeROM();
rom_opened = false;
}

EXPORTED void desmume_set_savetype(int type) {
backup_setManualBackupType(type);
}
Expand Down
3 changes: 3 additions & 0 deletions desmume/src/frontend/interface/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ EXPORTED void desmume_free(void);

// 0 = Japanese, 1 = English, 2 = French, 3 = German, 4 = Italian, 5 = Spanish
EXPORTED void desmume_set_language(u8 language);
// Opens a new ROM, if a ROM was already opened, a new one is opened and the old was is automatically free'd.
EXPORTED int desmume_open(const char *filename);
// Frees and closes a ROM opened with desmume_open.
EXPORTED void desmume_close();
EXPORTED void desmume_set_savetype(int type);
EXPORTED void desmume_pause(void);
EXPORTED void desmume_resume(void);
Expand Down