mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-25 03:56:54 +01:00
Add state ini (not used yet)
prefix temp files with ed_ for the moment.
This commit is contained in:
parent
0f17c610e0
commit
7b4a675193
@ -12,18 +12,18 @@
|
||||
#include "../flashcart_utils.h"
|
||||
#include "ed64_ll.h"
|
||||
#include "ed64.h"
|
||||
#include "ed64_state.h"
|
||||
|
||||
// #include "../menu/settings.h"
|
||||
|
||||
// This is a trial hack before using the settings API.
|
||||
// FIXME: Use one file using the ed64_pseudo_writeback_t struct.
|
||||
#ifndef LAST_SAVE_FILE_PATH
|
||||
#define LAST_SAVE_FILE_PATH "/menu/last_rom.tmp"
|
||||
#define LAST_SAVE_FILE_PATH "/menu/ed_last_rom.tmp"
|
||||
#endif
|
||||
#ifndef RESET_CHECK_FILE_PATH
|
||||
#define RESET_CHECK_FILE_PATH "/menu/reset.tmp"
|
||||
#define RESET_CHECK_FILE_PATH "/menu/ed_reset.tmp"
|
||||
#endif
|
||||
#ifndef FLASHRAM_CHECK_FILE_PATH
|
||||
#define FLASHRAM_CHECK_FILE_PATH "/menu/flashram.tmp"
|
||||
#define FLASHRAM_CHECK_FILE_PATH "/menu/ed_flashram.tmp"
|
||||
#endif
|
||||
|
||||
extern int ed_exit (void);
|
||||
|
42
src/flashcart/ed64/ed64_state.c
Normal file
42
src/flashcart/ed64/ed64_state.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <libdragon.h>
|
||||
#include <mini.c/src/mini.h>
|
||||
|
||||
#include "ed64_state.h"
|
||||
#include "utils/fs.h"
|
||||
|
||||
#ifndef ED64_STATE_FILE_PATH
|
||||
#define ED64_STATE_FILE_PATH "sd:/menu/ed64_state.ini"
|
||||
#endif
|
||||
|
||||
static ed64_pseudo_writeback_t init = {
|
||||
.is_warm_start = false,
|
||||
.last_rom_save_type = false,
|
||||
.last_rom_path = ""
|
||||
};
|
||||
|
||||
|
||||
void ed64_state_load (ed64_pseudo_writeback_t *state) {
|
||||
if (!file_exists(ED64_STATE_FILE_PATH)) {
|
||||
ed64_state_save(&init);
|
||||
}
|
||||
|
||||
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->last_rom_save_type = mini_get_bool(ini, "ed64", "last_rom_save_type", init.last_rom_save_type);
|
||||
state->last_rom_path = strdup(mini_get_string(ini, "ed64", "last_rom_path", init.last_rom_path));
|
||||
|
||||
mini_free(ini);
|
||||
}
|
||||
|
||||
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", "last_rom_save_type", state->last_rom_save_type);
|
||||
mini_set_string(ini, "ed64", "last_rom_path", state->last_rom_path);
|
||||
|
||||
mini_save(ini);
|
||||
|
||||
mini_free(ini);
|
||||
}
|
26
src/flashcart/ed64/ed64_state.h
Normal file
26
src/flashcart/ed64/ed64_state.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @file settings.h
|
||||
* @brief Menu Settings
|
||||
* @ingroup menu
|
||||
*/
|
||||
|
||||
#ifndef FLASHCART_ED64_STATE_H__
|
||||
#define LASHCART_ED64_STATE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** @brief ed64 pseudo Writeback Structure */
|
||||
typedef struct {
|
||||
/** @brief The reset button was used */
|
||||
bool is_warm_start;
|
||||
/** @brief The last save type used */
|
||||
bool last_rom_save_type; // FIXME: for the moment only a bool for flashram
|
||||
/** @brief The path to the last loaded ROM */
|
||||
char *last_rom_path;
|
||||
} ed64_pseudo_writeback_t;
|
||||
|
||||
void ed64_state_load (ed64_pseudo_writeback_t *state);
|
||||
void ed64_state_save (ed64_pseudo_writeback_t *state);
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user