Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Apps wait for keys to be let go before quitting; Celeste saves as it goes
Mason363c19f5f95b54d
diff --git a/games/celeste/src/celeste.h b/games/celeste/src/celeste.hindex 8b4f391a..592df130 100644--- a/games/celeste/src/celeste.h+++ b/games/celeste/src/celeste.h@@ -334,4 +334,5 @@ void game_init(void);void game_frame(void); /* one update at 60 Hz (and drawing when due) */void game_draw(void);void game_save(void);+void game_autosave(void);#endifdiff --git a/games/celeste/src/game.c b/games/celeste/src/game.cindex ae888738..8b1667b6 100644--- a/games/celeste/src/game.c+++ b/games/celeste/src/game.c@@ -75,6 +75,14 @@ void game_level_exit(int mode) {else menu_open_overworld(mode == LEXIT_COMPLETED && !g_level.in_credits, mode == LEXIT_COMPLETED && g_should_advance);}+/* a new room: the run is saved as Home would keep it, so a calculator that ends the app before it can save (or runs+ * out of battery) loses at most a room */+void game_autosave(void) {+ if (!g_in_level) return;+ g_save.has_session = g_session.in_area;+ save_write_quick();+}+/* Home: the run is kept (Save & Quit) */void game_save(void) {if (g_in_level) g_save.has_session = g_session.in_area; /* (from the menus, the run Save & Quit kept stays) */@@ -89,6 +97,7 @@ void game_frame(void) {return;}if (g_menu) menu_update();+ if (g_in_level && g_frame % (60 * 20) == 0 && g_frame) game_autosave(); /* and every 20 seconds */if (g_in_level) level_update(), hud_update();else wipe_update();g_frame++;diff --git a/games/celeste/src/level.c b/games/celeste/src/level.cindex b4649c70..4a9a4e6d 100644--- a/games/celeste/src/level.c+++ b/games/celeste/src/level.c@@ -643,6 +643,7 @@ static void transition_update(void) {g_level.transitioning = false;g_level.wind_pattern = g_level.room->info[RR_WIND];need_textures();+ game_autosave();}}diff --git a/games/celeste/src/level.h b/games/celeste/src/level.hindex 54d90214..45da584f 100644--- a/games/celeste/src/level.h+++ b/games/celeste/src/level.h@@ -201,6 +201,7 @@ extern SaveData g_save;void save_load(void);bool save_write(void); /* false: storage full */+bool save_write_quick(void); /* the same, without the copy in celeste_saves.py */ModeStats *save_mode(void); /* the current side's */bool save_check_berry(int index); /* SaveData.CheckStrawberry */void save_add_berry(int index, bool golden);diff --git a/games/celeste/src/save.c b/games/celeste/src/save.cindex f4e43e7f..10563905 100644--- a/games/celeste/src/save.c+++ b/games/celeste/src/save.c@@ -126,12 +126,18 @@ void save_load(void) {}bool save_write(void) {- g_save.checksum = checksum(offsetof(SaveData, checksum));- bool ok = plat_save(SAVE_NAME, &g_save, sizeof g_save);+ bool ok = save_write_quick();save_copy();return ok;}+/* the save alone, without its copy: while a chapter is played (its room in the cache would push out what the room+ * uses); the copy is written again at the chapter's end and on leaving */+bool save_write_quick(void) {+ g_save.checksum = checksum(offsetof(SaveData, checksum));+ return plat_save(SAVE_NAME, &g_save, sizeof g_save);+}+ModeStats *save_mode(void) { return &g_save.modes[g_session.area][g_session.mode]; }bool save_check_berry(int index) { return index >= 0 && (save_mode()->berries >> index & 1); }diff --git a/games/common/epsilon_app.h b/games/common/epsilon_app.hindex 10fb2cf0..7334c8db 100644--- a/games/common/epsilon_app.h+++ b/games/common/epsilon_app.h@@ -42,6 +42,7 @@ typedef struct {} epsilon_userland_t;#if PLATFORM_DEVICE && !defined(HOST)+#include <eadk.h>/* The header of the software running this app, or NULL; *upsilon tells which. */__attribute__((unused)) static const epsilon_userland_t *epsilon_userland_of(bool *upsilon) {@@ -109,9 +110,12 @@ __attribute__((unused)) static void np_app_begin(void) {epsilon_home_held = true;}-/* Call as `return np_app_end();` from main: nothing in RAM is used after. */+/* Call as `return np_app_end();` from main: nothing in RAM is used after.+ * A key still held as the app ends (OK or EXE on a Quit button) would reach the home screen, which opens the+ * app again at once: the keys are let go first (for two seconds at most). */__attribute__((unused, noinline)) static int np_app_end(void) {if (numplay_launcher) return 0;+ for (int i = 0; i < 200 && eadk_keyboard_scan(); i++) eadk_timing_msleep(10);bool unlock = epsilon_home_held;for (volatile uint32_t *p = (volatile uint32_t *)(void *)_data_section_start_ram; p < (volatile uint32_t *)(void *)_heap_end; p++)*p = 0;diff --git a/launcher/src/sys.c b/launcher/src/sys.cindex 170c2a0f..4acaa349 100644--- a/launcher/src/sys.c+++ b/launcher/src/sys.c@@ -81,6 +81,8 @@ void np_session_begin(void) {}int np_session_end(void) {+ /* a key still held (OK, EXE) would reach the home screen, which would open NumPlay again */+ np_wait_release();bool unlock = session_locked;for (volatile uint32_t *p = (volatile uint32_t *)(void *)_data_section_start_ram; p < (volatile uint32_t *)(void *)_heap_end; p++)*p = 0;