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
Celeste: Back dashes and talks, backspace pauses
Mason Chena1e2319fed6a
diff --git a/docs/play.md b/docs/play.mdindex 50c0f811..cdcdb006 100644--- a/docs/play.md+++ b/docs/play.md@@ -83,9 +83,9 @@ Celeste comes as its own app, `Celeste.nwa`: it is too big to share the calculat| --- | --- || **Arrows** | Move, and aim the dash || **OK** | Jump |-| **⌫** | Dash, and talk |+| **Back** | Dash, and talk || **toolbox** | Grab, climb |-| **Back** | Pause |+| **⌫** | Pause || **Home** | Save and quit |Choose Climb, then a chapter, then Start. Madeline can dash once in the air (twice later on), and grab and climb walls until she gets tired. In menus, **OK** or **EXE** confirms and **Back** goes back. The first time you open Celeste it shows these keys; you can change them in Options, then Keyboard Config. Home saves and quits, and Climb then offers Continue. Your progress is also copied into `celeste_saves.py`, so installing the app again doesn't erase it.diff --git a/games/celeste/README.md b/games/celeste/README.mdindex c2717b4f..7ad5041e 100644--- a/games/celeste/README.md+++ b/games/celeste/README.md@@ -52,7 +52,7 @@Choose Climb, then a chapter, then Start. Each chapter is a series of rooms: get Madeline to the next one. She can dash once in the air (twice later on), and grab and climb walls until she gets tired. A death sends her back to the start of the room.-Back pauses: from there you can skip a scene, retry the room, restart the chapter, change the options, save and quit, or go back to the chapter select.+⌫ pauses: from there you can skip a scene, retry the room, restart the chapter, change the options, save and quit, or go back to the chapter select.## Controls@@ -60,9 +60,9 @@ Back pauses: from there you can skip a scene, retry the room, restart the chapte| --- | --- || Arrows | Move, and aim the dash || OK | Jump |-| ⌫ | Dash, and talk |+| Back | Dash, and talk || Toolbox | Grab, climb |-| Back | Pause |+| ⌫ | Pause || Home | Save and quit |In menus, OK or EXE confirms and Back goes back. You can change the keys in Options, then Keyboard Config. The game shows these keys the first time you open it, and again from Options, then Key Sheet.diff --git a/games/celeste/src/celeste.h b/games/celeste/src/celeste.hindex a5ded317..85609b0a 100644--- a/games/celeste/src/celeste.h+++ b/games/celeste/src/celeste.h@@ -61,6 +61,9 @@ enum {};uint32_t plat_keys(void);extern uint8_t g_bind[4]; /* jump, dash, grab, talk: EADK keys */+#define KEY_BACK 5 /* (EADK keys) */+#define KEY_BACKSPACE 17 /* pause */+const char *key_label(int k); /* an EADK key's name, as on the key sheet */void plat_default_binds(void);int plat_key_pressed(void); /* the EADK key that went down this frame, -1 if none */int uitoa(int v, char *out); /* v in digits, 0-terminated; the length */diff --git a/games/celeste/src/menu.c b/games/celeste/src/menu.cindex c2376b35..f63a75f6 100644--- a/games/celeste/src/menu.c+++ b/games/celeste/src/menu.c@@ -173,7 +173,7 @@ void menu_open_title(void) { go(g_save.key_sheet_seen ? S_TITLE : S_SHEET, 0); }void menu_open_main(void) { go(S_MAIN, 0); }/* ---------------------------------------------------------------- the key sheet (as NumBlocks has it) */-static const char *key_name(int k) {+const char *key_label(int k) {static const char *const names[53] = {[4] = "OK", [5] = "Back", [6] = "Home", [12] = "shift", [13] = "alpha", [14] = "x,n,t", [15] = "var", [16] = "toolbox",[17] = "<x", [18] = "e^x", [19] = "ln", [20] = "log", [21] = "i", [22] = ",", [23] = "x^y", [24] = "sin",@@ -183,15 +183,21 @@ static const char *key_name(int k) {return k < 53 && names[k] ? names[k] : "?";}static const char *const ACTION_KEYS[4] = {"KEY_CONFIG_JUMP", "KEY_CONFIG_DASH", "KEY_CONFIG_GRAB", "KEY_CONFIG_TALK"};-static const char *action_on(int k) {+static const char *action_on(int k) { /* what a key does: its actions, or pause */+ static char what[48];+ if (k == KEY_BACKSPACE) return ui_str("KEY_CONFIG_PAUSE");+ what[0] = 0;for (int a = 0; a < 4; a++)- if (g_bind[a] == k) return ui_str(ACTION_KEYS[a]);- return NULL;+ if (g_bind[a] == k && strlen(what) + strlen(ui_str(ACTION_KEYS[a])) + 3 < sizeof what) {+ if (what[0]) strcat(what, ", ");+ strcat(what, ui_str(ACTION_KEYS[a]));+ }+ return what[0] ? what : NULL;}static void key_cap(float x, float y, float w, int k, const char *what) { /* a key: bright with what it does */box(x, y, w, 162, what ? rgb(0xA0A0A0) : rgb(0x505050), 255);box(x + 6, y + 6, w - 12, 150, what ? rgb(0x282828) : rgb(0x181818), 255);- say(key_name(k), x + w / 2, y + (what ? 46 : 81), 0.5f, 0.5f, 0.8f, what ? WHITE : rgb(0x707070), 255);+ say(key_label(k), x + w / 2, y + (what ? 46 : 81), 0.5f, 0.5f, 0.8f, what ? WHITE : rgb(0x707070), 255);if (what) say(what, x + w / 2, y + 116, 0.5f, 0.5f, 0.8f, rgb(0xFFFFA0), 255);}static void sheet_draw(void) {@@ -204,7 +210,7 @@ static void sheet_draw(void) {say("Move", 240, 270, 0.5f, 0.5f, 0.8f, rgb(0xFFFFA0), 255);key_cap(780, 150, 360, 6, "Save, quit");key_cap(1416, 70, 480, 4, action_on(4));- key_cap(1416, 250, 480, 5, ui_str("KEY_CONFIG_PAUSE"));+ key_cap(1416, 250, 480, KEY_BACK, action_on(KEY_BACK));for (int r = 0; r < 3; r++)for (int c = 0; c < 6; c++) {int k = 12 + r * 6 + c;@@ -454,13 +460,15 @@ static void options_update(void) {else go(S_MAIN, 1);}}-static bool bindable(int k) { return k == 4 || (k >= 12 && k <= 51 && k != 35 && k != 41 && k != 47); }+static bool bindable(int k) { /* OK, Back and the keys under the arrows but backspace (pause) */+ return k == 4 || k == KEY_BACK || (k >= 12 && k <= 51 && k != KEY_BACKSPACE && k != 35 && k != 41 && k != 47);+}static void keys_draw(void) {if (M.back == S_MAIN) backdrop();else box(0, 0, 1920, 1080, 0, 178);say(ui_str("KEY_CONFIG_TITLE"), 960, 200, 0.5f, 0.5f, 2, GRAY, 255);say(ui_str("KEY_CONFIG_GAMEPLAY"), 960, 330, 0.5f, 0.5f, 0.6f, GRAY, 255);- for (int a = 0; a < 4; a++) menu_item(ui_str(ACTION_KEYS[a]), M.binding == a ? "..." : key_name(g_bind[a]), a, 410 + a * ITEM_H, false);+ for (int a = 0; a < 4; a++) menu_item(ui_str(ACTION_KEYS[a]), M.binding == a ? "..." : key_label(g_bind[a]), a, 410 + a * ITEM_H, false);menu_item(ui_str("KEY_CONFIG_RESET"), NULL, 4, 450 + ITEM_H * 4, false);if (M.binding >= 0) {char w[48];diff --git a/games/celeste/src/npc.c b/games/celeste/src/npc.cindex eae6db46..57056ef3 100644--- a/games/celeste/src/npc.c+++ b/games/celeste/src/npc.c@@ -196,16 +196,8 @@ Ent *hahaha_new(V2 at, const char *ifset) {/* ---------------------------------------------------------------- BirdTutorialGui */Tutorial g_tuts[2]; /* (one bird shows its bubbles at a time) */-/* the calculator's keys (Input.GuiButton): a key cap with its name */-static const char *key_name(int action) {- switch (action) {- case IN_JUMP: return "OK";- case IN_DASH: return "Backspace";- case IN_GRAB: return "Toolbox";- case IN_TALK: return "Backspace";- default: return "Back";- }-}+/* the calculator's keys (Input.GuiButton): a key cap with the name of the key bound */+static const char *key_name(int action) { return key_label(action < 4 ? g_bind[action] : KEY_BACKSPACE); }/* the width of a control in interface pixels */static float control_width(const GuiControl *c) {switch (c->kind) {diff --git a/games/celeste/src/plat_eadk.c b/games/celeste/src/plat_eadk.cindex 2a7aeba1..a1b487c8 100644--- a/games/celeste/src/plat_eadk.c+++ b/games/celeste/src/plat_eadk.c@@ -9,7 +9,7 @@/* key bindings: one EADK key per game action (settings can change them) */uint8_t g_bind[4]; /* jump, dash, grab, talk */void plat_default_binds(void) {- g_bind[0] = eadk_key_ok, g_bind[1] = eadk_key_backspace, g_bind[2] = eadk_key_toolbox, g_bind[3] = eadk_key_backspace;+ g_bind[0] = eadk_key_ok, g_bind[1] = eadk_key_back, g_bind[2] = eadk_key_toolbox, g_bind[3] = eadk_key_back;}static uint64_t scan, scan_prev;/* the key that went down this frame (an EADK key), -1 if none */@@ -31,7 +31,8 @@ uint32_t plat_keys(void) {if (k & KEY(g_bind[2])) r |= K_GRAB;if (k & KEY(g_bind[3])) r |= K_TALK;if (k & (KEY(eadk_key_ok) | KEY(eadk_key_exe))) r |= K_OK;- if (k & KEY(eadk_key_back)) r |= K_BACK | K_PAUSE;+ if (k & KEY(eadk_key_back)) r |= K_BACK; /* (menus: cancel) */+ if (k & KEY(eadk_key_backspace)) r |= K_PAUSE;if (k & (KEY(eadk_key_home) | KEY(eadk_key_on_off))) r |= K_HOME;if (k) r |= K_ANY;return r;diff --git a/games/celeste/src/plat_host.c b/games/celeste/src/plat_host.cindex 5d333dc5..d5862c64 100644--- a/games/celeste/src/plat_host.c+++ b/games/celeste/src/plat_host.c@@ -9,7 +9,7 @@ uint32_t host_time, host_keys;uint32_t plat_keys(void) { return host_keys; }uint8_t g_bind[4];-void plat_default_binds(void) { g_bind[0] = 4, g_bind[1] = 17, g_bind[2] = 16, g_bind[3] = 17; }+void plat_default_binds(void) { g_bind[0] = 4, g_bind[1] = 5, g_bind[2] = 16, g_bind[3] = 5; }int plat_key_pressed(void) { return -1; }uint32_t plat_millis(void) { return host_time; }void plat_sleep(uint32_t ms) { host_time += ms; }diff --git a/games/celeste/src/save.c b/games/celeste/src/save.cindex 6a7c8c05..c7b057a8 100644--- a/games/celeste/src/save.c+++ b/games/celeste/src/save.c@@ -44,6 +44,7 @@ static void save_new(void) {g_save.size = sizeof g_save;plat_default_binds();memcpy(g_save.bind, g_bind, 4);+ g_save.binds_set = 1;}/* The copy: installing apps from the NumWorks website keeps only Python scripts, so the save is@@ -114,6 +115,11 @@ void save_load(void) {memset(&g_save, 0, sizeof g_save);if (p && len <= sizeof g_save) memcpy(&g_save, p, len); /* the record is not aligned: copy it */if (!(p && whole(len)) && !restore_copy()) save_new();+ if (!g_save.binds_set) { /* 1.6.0's keys: what was on backspace (pause now) goes to Back, as the defaults did */+ for (int a = 0; a < 4; a++)+ if (g_save.bind[a] == KEY_BACKSPACE) g_save.bind[a] = KEY_BACK;+ g_save.binds_set = 1;+ }if (g_save.bind[0] && g_save.bind[1] && g_save.bind[2] && g_save.bind[3]) memcpy(g_bind, g_save.bind, 4);else plat_default_binds(), memcpy(g_save.bind, g_bind, 4);}diff --git a/games/celeste/tests/check.py b/games/celeste/tests/check.pyindex f3bf619f..16e83b53 100644--- a/games/celeste/tests/check.py+++ b/games/celeste/tests/check.py@@ -8,6 +8,7 @@ AddressSanitizer and UBSan, through the menus, the saves and every room.import osimport reimport shutil+import structimport subprocessimport sysimport tempfile@@ -67,6 +68,26 @@ s2 = session(out)check(s2 and s2[4] >= t0, f"the save did not come back from celeste_saves.py: {s2}")shutil.rmtree(d, ignore_errors=True)+# a 1.6.0 save: its keys on backspace (pause now) go to Back, as its defaults (dash and talk on backspace) did+def fnv(b):+ h = 2166136261+ for x in b:+ h = ((h ^ x) * 16777619) & 0xFFFFFFFF+ return h+++for old, new in (([4, 17, 16, 17], "4 5 16 5"), ([17, 16, 4, 29], "5 16 4 29")):+ d = tempfile.mkdtemp(prefix="celeste_check_")+ v1 = bytearray(1552)+ struct.pack_into("<IHH", v1, 0, 0x43454C53, 1, 1552)+ v1[1071] = 1 # the key sheet seen+ v1[1100:1104] = bytes(old)+ struct.pack_into("<I", v1, 1544, fnv(v1[:1544]))+ open(d + "/celeste.sav", "wb").write(v1)+ out = run([], 10, saves=d, what="a 1.6.0 save's keys")+ check("keys " + new in out, f"the keys {old} of a 1.6.0 save did not become {new}: {out[-60:]}")+ shutil.rmtree(d, ignore_errors=True)+# the pause menu: Retry is a deathout = run(["--chapter", "1", "--room", "1"], 300, "200-201:p,215-216:d,230-231:o", what="Retry from the pause menu")s = session(out)diff --git a/games/celeste/tests/play.c b/games/celeste/tests/play.cindex 814d118d..9bc06a1b 100644--- a/games/celeste/tests/play.c+++ b/games/celeste/tests/play.c@@ -180,5 +180,6 @@ int main(int argc, char **argv) {printf("session: chapter %d area %d mode %d deaths %u time %u berries %llx; save berries %llx deaths %u\n",g_session.chapter, g_session.area, g_session.mode, g_session.deaths, g_session.time,(unsigned long long)g_session.berries, (unsigned long long)save_mode()->berries, save_mode()->deaths);+ printf("keys %d %d %d %d\n", g_bind[0], g_bind[1], g_bind[2], g_bind[3]);return 0;}