Skip to content

Commit 55c98d6

Browse files
committed
fixes pointers to flash menu data and f_close() was hanging on non-opened file
1 parent 0680021 commit 55c98d6

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

code/veccart/main.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
// Externs
5252
extern GameFileRecord* pActiveGameData;
53-
extern char* multicart_start;
54-
extern char* multicart_end;
53+
extern char multicart_start;
54+
extern char multicart_end;
5555

5656
//Memory for the menu ROM and the running cartridge.
5757
//We keep both in memory so we can quickly exchange them when a reset has been detected.
@@ -117,7 +117,7 @@ void loadRom(char *fn) {
117117

118118
void loadRomWithHighScore(char *fn, bool load_hs_mode, bool use_embedded_menu) {
119119
FIL f;
120-
FRESULT fr;
120+
FRESULT fr = FR_NO_FILE; // assume no file, so we can test if we ever opened the file later
121121
UINT r = 0;
122122
int n;
123123
UINT x;
@@ -129,7 +129,9 @@ void loadRomWithHighScore(char *fn, bool load_hs_mode, bool use_embedded_menu) {
129129
n = sizeof(menuData);
130130
}
131131
if (romData == menuData && use_embedded_menu == true) {
132-
memcpy(menuData, multicart_start, multicart_start-multicart_end);
132+
xprintf("Copying %lu bytes of menu data... ", &multicart_end - &multicart_start);
133+
memcpy(menuData, &multicart_start, &multicart_end - &multicart_start);
134+
xprintf("OK!\n");
133135
} else {
134136
fr = f_open(&f, fn, FA_READ);
135137
if (fr) {
@@ -207,7 +209,9 @@ void loadRomWithHighScore(char *fn, bool load_hs_mode, bool use_embedded_menu) {
207209
parmRam[0xe0] = 0x66; // High Score flag (IDLE:0x66, LOAD2VEC:0x77, SAVE2STM:0x88)
208210
}
209211
}
210-
f_close(&f);
212+
if (fr != FR_NO_FILE) {
213+
f_close(&f);
214+
}
211215
}
212216

213217
//Stream data, for the Bad Apple demo

0 commit comments

Comments
 (0)