Skip to content

Commit b1fefed

Browse files
committed
Fix NOR game launch bug in recent menu
1 parent 08d874d commit b1fefed

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ unsigned load_nds(const char *filename, const void *dldi_driver);
288288
const void *get_vfile_ptr(const char *fname);
289289
int get_vfile_size(const char *fname);
290290

291-
bool check_superfw(const uint8_t *h, uint32_t *ver);
292-
bool validate_superfw_variant(const uint8_t *fw);
293-
bool validate_superfw_checksum(const uint8_t *fw, unsigned fwsize);
294-
295291
// Test/validation stuff
296292
unsigned sram_test();
297293
int sdram_test(progress_abort_fn progcb);

src/flash.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@ bool flash_verify(uint32_t baseaddr, const uint8_t *buf, unsigned size);
4646
void flash_erase_fsm_start(t_flash_erase_state *st, uint32_t baseaddr, unsigned sectsize, unsigned sectorcnt);
4747
int flash_erase_fsm_step(t_flash_erase_state *st);
4848

49+
bool check_superfw(const uint8_t *h, uint32_t *ver);
50+
bool validate_superfw_variant(const uint8_t *fw);
51+
bool validate_superfw_checksum(const uint8_t *fw, unsigned fwsize);
52+
4953
extern t_flash_info flashinfo;
5054

src/menu.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ static struct {
345345
// Launch GBA game from NOR memory
346346
struct {
347347
t_load_gba_lcfg l; // ROM loading info and settings;
348+
const t_flash_game_entry *e; // NOR game entry on RAM
348349
} norld;
349350

350351
// Save file menu (.sav files)
@@ -855,6 +856,9 @@ static void browser_open_nor(const t_flash_game_entry * e) {
855856
// Load and set default and sane settings honoring defaults and preferences.
856857
prepare_gba_settings(&spop.p.norld.l, game_uses_dsaving, lh_sett.rtcts, game_no_save, e->game_name);
857858

859+
// Save entry pointer
860+
spop.p.norld.e = e;
861+
858862
// Show load ROM menu.
859863
spop.pop_num = POPUP_GBA_NORLOAD;
860864
spop.submenu = GbaLoadPopInfo;
@@ -1316,7 +1320,7 @@ void render_flashbrowser(volatile uint8_t *frame) {
13161320
if (smenu.fbrowser.seloff + i >= smenu.fbrowser.maxentries)
13171321
break;
13181322

1319-
t_flash_game_entry *e = &sdr_state->nordata.games[smenu.fbrowser.seloff + i];
1323+
const t_flash_game_entry *e = &sdr_state->nordata.games[smenu.fbrowser.seloff + i];
13201324
render_icon(2, (i+1)*16, ICON_GBACART);
13211325

13221326
// Animate the row entries if they are too long!
@@ -1632,7 +1636,7 @@ void render_gba_norload(volatile uint8_t *frame) {
16321636
draw_text_ovf("⯇", frame, 10, 23, 64);
16331637
draw_rightj_text("⯈", frame, SCREEN_WIDTH - 10, 23);
16341638

1635-
t_flash_game_entry *e = &sdr_state->nordata.games[smenu.fbrowser.selector];
1639+
const t_flash_game_entry *e = spop.p.norld.e;
16361640
if (spop.submenu == GbaLoadPopInfo) {
16371641
int save_type = GET_GATTR_SAVEM(e->gattrs);
16381642
render_gbarom_info(frame, e->game_name, false, (const char*)&e->gamecode, e->gamever, save_type);
@@ -2532,7 +2536,7 @@ static void keypress_popup_norload(unsigned newkeys) {
25322536
if (newkeys & KEY_BUTTDOWN)
25332537
spop.selector = MIN(GBALdSetCNT - 1, spop.selector + 1);
25342538

2535-
const t_flash_game_entry *e = &sdr_state->nordata.games[smenu.fbrowser.selector];
2539+
const t_flash_game_entry *e = spop.p.norld.e;
25362540
bool uses_dsave = e->gattrs & GATTR_SAVEDS;
25372541
bool uses_igm = e->gattrs & GATTR_IGM;
25382542
bool uses_rtc = e->gattrs & GATTR_RTC;
@@ -2600,7 +2604,6 @@ static void keypress_popup_norload(unsigned newkeys) {
26002604

26012605
if (newkeys & KEY_BUTTA) {
26022606
if (spop.submenu == GbaLoadPopInfo) {
2603-
const t_flash_game_entry *e = &sdr_state->nordata.games[smenu.fbrowser.selector];
26042607
const int stype = GET_GATTR_SAVEM(e->gattrs);
26052608
const EnumSavetype st = stype < 0 ? SaveTypeNone : stype;
26062609
bool uses_dsave = e->gattrs & GATTR_SAVEDS;
@@ -2649,8 +2652,6 @@ static void keypress_popup_norload(unsigned newkeys) {
26492652
.rtcts = spop.p.norld.l.rtcval
26502653
};
26512654

2652-
const t_flash_game_entry *e = &sdr_state->nordata.games[smenu.fbrowser.selector];
2653-
26542655
// We load the loading settings to ensure we do not overwrite them.
26552656
load_rom_settings(e->game_name, &ld_sett, NULL);
26562657
save_rom_settings(e->game_name, &ld_sett, &lh_sett);

0 commit comments

Comments
 (0)