Skip to content

Commit 695dcea

Browse files
committed
add public api method for saving rom profile in chip8 context
1 parent cea15aa commit 695dcea

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

shared/chip8.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ void chip8_reset(bool verbose) {
251251

252252
}
253253

254+
void chip8_save_profile(void){
255+
profiles_save_current();
256+
gui.save_profile_flag = 0;
257+
}
258+
254259
void chip8_run(){
255260
int event;
256261
unsigned int t1;
@@ -274,10 +279,7 @@ void chip8_run(){
274279
if (event & USER_QUIT) return;
275280
if (event & LOAD_ROM) chip8_load_rom(NULL);
276281
if (event & SOFT_RESET) chip8_reset(true);
277-
if (event & SAVE_PROFILE) {
278-
profiles_save_current();
279-
gui.save_profile_flag = 0;
280-
}
282+
if (event & SAVE_PROFILE) chip8_save_profile();
281283

282284
/* Update toast timers */
283285
toast_update((double)interval / 1000.0);

shared/chip8.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ void chip8_update_timers(void);
105105
void chip8_step_cpu(int cycles);
106106
void chip8_reset(bool verbose);
107107
int chip8_load_bootrom(void);
108+
void chip8_save_profile(void);
108109
void chip8_fetch_opcode(void);
109110
void chip8_execute_opcode(void);
110111

112+
111113
#ifdef __cplusplus
112114
}
113115
#endif

shared/profiles.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static void profiles_write_to_file(void) {
273273
fclose(file);
274274
}
275275

276-
void profiles_save_current(void) {
276+
void profiles_save_current() {
277277
if (!chip8.rom_loaded || !chip8.rom || chip8.rom_size == 0) {
278278
toast_show(TOAST_ERROR, "No ROM loaded. Cannot save profile.");
279279
return;

0 commit comments

Comments
 (0)