From a5d9f7d069e8f3e15bbfc7a8a005a09f25b24f0a Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Sat, 21 Oct 2023 02:11:13 +0100 Subject: [PATCH] Improve error conditions --- src/flashcart/ed64/ed64.c | 10 +++++++--- src/flashcart/ed64/ed64_state.c | 6 +++--- src/flashcart/ed64/ed64_state.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/flashcart/ed64/ed64.c b/src/flashcart/ed64/ed64.c index 89df5e71..b3de5823 100644 --- a/src/flashcart/ed64/ed64.c +++ b/src/flashcart/ed64/ed64.c @@ -31,10 +31,10 @@ static flashcart_err_t ed64_init (void) { ed64_state_load(¤t_state); - if (current_state.is_warm_start == true) { + if (current_state.is_expecting_save_writeback == true) { // make sure next boot doesnt trigger the check changing its state. - current_state.is_warm_start = false; + current_state.is_expecting_save_writeback = false; ed64_state_save(¤t_state); // Now save the content back to the SD card! @@ -75,6 +75,8 @@ static flashcart_err_t ed64_init (void) { } } else { + current_state.is_expecting_save_writeback = false; + current_state.is_fram_save_type = false; current_state.last_save_path = ""; ed64_state_save(¤t_state); } @@ -214,6 +216,8 @@ static flashcart_err_t ed64_load_save (char *save_path) { return FLASHCART_ERR_LOAD; } + current_state.is_fram_save_type = false; + ed64_save_type_t type = ed64_ll_get_save_type(); switch (type) { case SAVE_TYPE_EEPROM_4K: @@ -237,7 +241,7 @@ static flashcart_err_t ed64_load_save (char *save_path) { current_state.last_save_path = save_path; - current_state.is_warm_start = true; + current_state.is_expecting_save_writeback = true; ed64_state_save(¤t_state); return FLASHCART_OK; diff --git a/src/flashcart/ed64/ed64_state.c b/src/flashcart/ed64/ed64_state.c index 39dcc640..ee29bab7 100644 --- a/src/flashcart/ed64/ed64_state.c +++ b/src/flashcart/ed64/ed64_state.c @@ -9,7 +9,7 @@ #endif static ed64_pseudo_writeback_t init = { - .is_warm_start = false, + .is_expecting_save_writeback = false, .is_fram_save_type = false, .last_save_path = "" }; @@ -22,7 +22,7 @@ void ed64_state_load (ed64_pseudo_writeback_t *state) { mini_t *ini = mini_try_load(ED64_STATE_FILE_PATH); - state->is_warm_start = mini_get_bool(ini, "ed64", "is_warm_start", init.is_warm_start); + state->is_expecting_save_writeback = mini_get_bool(ini, "ed64", "is_expecting_save_writeback", init.is_expecting_save_writeback); state->is_fram_save_type = mini_get_bool(ini, "ed64", "is_fram_save_type", init.is_fram_save_type); state->last_save_path = strdup(mini_get_string(ini, "ed64", "last_save_path", init.last_save_path)); @@ -32,7 +32,7 @@ void ed64_state_load (ed64_pseudo_writeback_t *state) { void ed64_state_save (ed64_pseudo_writeback_t *state) { mini_t *ini = mini_create(ED64_STATE_FILE_PATH); - mini_set_bool(ini, "ed64", "is_warm_start", state->is_warm_start); + mini_set_bool(ini, "ed64", "is_expecting_save_writeback", state->is_expecting_save_writeback); mini_set_bool(ini, "ed64", "is_fram_save_type", state->is_fram_save_type); mini_set_string(ini, "ed64", "last_save_path", state->last_save_path); diff --git a/src/flashcart/ed64/ed64_state.h b/src/flashcart/ed64/ed64_state.h index ee4b20bd..3f53a148 100644 --- a/src/flashcart/ed64/ed64_state.h +++ b/src/flashcart/ed64/ed64_state.h @@ -10,7 +10,7 @@ /** @brief ED64 Pseudo Writeback Structure */ typedef struct { /** @brief The reset button was used */ - bool is_warm_start; + bool is_expecting_save_writeback; /** @brief The last save type was flash ram */ bool is_fram_save_type; /** @brief The path to the last loaded ROM */