From 143d2a107afdd2ba3cc39389678f956d6b42e3bd Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 22 Aug 2023 20:37:18 +0200 Subject: [PATCH] port: save config on exit --- port/include/config.h | 2 ++ port/src/config.c | 1 - port/src/main.c | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/port/include/config.h b/port/include/config.h index 6c814782c..124776d14 100644 --- a/port/include/config.h +++ b/port/include/config.h @@ -2,6 +2,8 @@ #include +#define CONFIG_FNAME "./pd.ini" + void configInit(void); s32 configLoad(const char *fname); s32 configSave(const char *fname); diff --git a/port/src/config.c b/port/src/config.c index 48009d078..7926b81e1 100644 --- a/port/src/config.c +++ b/port/src/config.c @@ -8,7 +8,6 @@ #define CONFIG_MAX_STR 512 #define CONFIG_MAX_SECNAME 128 -#define CONFIG_FNAME "./pd.ini" enum configtype { CONFIG_END, diff --git a/port/src/main.c b/port/src/main.c index dd72d562b..994de5c5b 100644 --- a/port/src/main.c +++ b/port/src/main.c @@ -52,6 +52,12 @@ void bootCreateSched(void) } } +static void cleanup(void) +{ + configSave(CONFIG_FNAME); + // TODO: actually shut down all subsystems +} + int main(int argc, const char **argv) { fsInit(); @@ -61,6 +67,8 @@ int main(int argc, const char **argv) audioInit(); romdataInit(); + atexit(cleanup); + bootCreateSched(); osMemSize = configGetInt("Game.MemorySize", 16) * 1024 * 1024;