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
Progress survives updates; Reset asks for OK to be held
Mason363222bc8b50f5b
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 8d6e082f..10954ffb 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -47,6 +47,7 @@ jobs:run: |python3 tests/test_games.py build/appspython3 tests/test_uninstall.py build/NumPlay.nwa --game numdrive+ python3 tests/test_progress.py build/NumPlay.nwa- uses: actions/upload-artifact@v4with:diff --git a/README.md b/README.mdindex e8fdd114..24c00959 100644--- a/README.md+++ b/README.md@@ -86,6 +86,8 @@ You need your calculator, its USB cable, and a computer with **Google Chrome** o6. **Play!** On your calculator, press the **Home** key (the little house), go to the end of the apps and open **NumPlay**.> [!TIP]+> **Updating?** Install the new file the same way. Your progress comes back by itself: NumPlay keeps a copy of it in a Python script called `numplay_saves.py`, the one kind of file the website keeps. (This works for updates from version 1.2.1 on.)+>> Already have other apps from that website? It swaps them for the new ones, so add them again in step 5 to keep them. The calculator's own apps are never touched.>> Nothing happens when you plug it in? Try another cable: some only charge.diff --git a/VERSION b/VERSIONindex 26aaba0e..6085e946 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-1.2.0+1.2.1diff --git a/docs/play.md b/docs/play.mdindex 7ccc8898..8ec80ab9 100644--- a/docs/play.md+++ b/docs/play.md@@ -11,10 +11,12 @@The last card, **Settings**, can:-- **Reset** a game's progress, or every game's at once (it asks first; levels you made are kept)+- **Reset** a game's progress, or every game's at once: hold **OK** on the red button to confirm (levels you made are kept)- **Uninstall** the games you don't play, to free up space- **Start as Matrices**: NumPlay opens as a plain matrix calculator. Your secret way in opens the games: pick the x,n,t key, var, Toolbox, π, √, or *Examples* in the Toolbox menu. A small gray hint in the corner names it (turn it off with **Show a hint**)+Your progress is also copied into a Python script, `numplay_saves.py`, so updating NumPlay doesn't erase it. Leave it there; if it gets deleted, NumPlay writes it again.+In every game, **Back** pauses, and the pause menu has a small **Quit game** button. It always asks first, since Back sits right next to OK.## NumDashdiff --git a/launcher/src/main.c b/launcher/src/main.cindex 9c8c2c88..9a3804c1 100644--- a/launcher/src/main.c+++ b/launcher/src/main.c@@ -29,6 +29,9 @@ static bool home_pressed;int main(void) {np_session_begin();np_finish_pending_uninstalls();+ /* just updated? the saves come back from their copy, then the copy is refreshed */+ np_progress_restore();+ np_progress_backup();/* started as Matrices (Settings): NumPlay opens only through its secret */np_config_t cfg;np_config_load(&cfg);@@ -42,10 +45,12 @@ int main(void) {if (r == -2) break;if (r == -1) {np_settings();+ np_progress_backup();continue;}home_pressed = false;np_game_run(r);+ np_progress_backup();/* Home in a game goes all the way home, like everywhere on the calculator */if (home_pressed) break;np_wait_release();diff --git a/launcher/src/np.h b/launcher/src/np.hindex 1bd07d42..32383620 100644--- a/launcher/src/np.h+++ b/launcher/src/np.h@@ -84,6 +84,10 @@ typedef struct {} np_config_t;void np_config_load(np_config_t *c);bool np_config_save(const np_config_t *c);+/* A copy of every save in numplay_saves.py, a Python script: the only kind of+ file the NumWorks installer keeps when NumPlay is updated. */+void np_progress_backup(void);+void np_progress_restore(void); /* only when none of the saves are left *//* Matrices, the disguise: true when the secret was used (open NumPlay), false to quit */bool np_matrices(const np_config_t *c);diff --git a/launcher/src/settings.c b/launcher/src/settings.cindex 3eb2740f..8968ba31 100644--- a/launcher/src/settings.c+++ b/launcher/src/settings.c@@ -166,7 +166,7 @@ enum { ACT_UNINSTALL, ACT_RESET, ACT_RESET_ALL };typedef struct {int game;int choice; /* 0 cancel, 1 uninstall or reset */- float hold; /* 0..1 while OK is held on "Uninstall" */+ float hold; /* 0..1 while OK is held on "Uninstall" or "Reset" */bool hinted;int stage; /* 0 confirm, 1 working, 2 done, 3 error */int error;@@ -187,7 +187,23 @@ static const char *error_text(int e) {}}-/* Reset and Reset all: a plain question (Cancel first), then done */+/* The red button fills up while OK is held: a stray press of OK, right next+ to Back, can't erase anything. */+static void hold_button(const dialog_t *d, const char *label) {+ int bx = 172, by = 198, bw = 110, bh = 28;+ if (d->choice == 1) {+ gfx_rrect(bx, by + 2, bw, bh, bh / 2, 0, 64);+ gfx_rrect(bx, by, bw, bh, bh / 2, gfx_rgb(DANGER), 256);+ int fill = (int)(bw * d->hold);+ if (fill > 0) gfx_rrect(bx, by, NP_MAX(fill, bh), bh, bh / 2, 0xFFFF, 110);+ gfx_text_center(&np_font_body, bx + bw / 2, by + 18, d->hinted ? "Hold OK" : label, 0xFFFF, 256);+ } else {+ gfx_rrect(bx, by, bw, bh, bh / 2, 0xFFFF, 40);+ gfx_text_center(&np_font_body, bx + bw / 2, by + 18, label, 0xFFFF, 200);+ }+}++/* Reset and Reset all: a question (Cancel first, hold OK to reset), then done */static void reset_scene(dialog_t *d) {const char *title = d->action == ACT_RESET_ALL ? "every game" : np_games[d->game].title;char line[64], body[128];@@ -215,7 +231,7 @@ static void reset_scene(dialog_t *d) {gfx_paragraph(&np_font_small, 160, y + 4, 290, 13, "Games stay installed, and levels you made in an editor are kept.",0xFFFF, 170);ui_button(38, 198, 110, 28, "Cancel", d->choice == 0, 0x555D70, 256);- ui_button(172, 198, 110, 28, "Reset", d->choice == 1, DANGER, 256);+ hold_button(d, "Reset");}static void dialog_scene(void *ctx) {@@ -269,24 +285,11 @@ static void dialog_scene(void *ctx) {strcat(body, " and all of its saved progress. You can't undo this.");int y = gfx_paragraph(&np_font_body, 160, 102, 280, 16, body, 0xFFFF, 240);gfx_paragraph(&np_font_small, 160, y + 4, 290, 13,- "To play it again, you'll have to reinstall all of NumPlay from my.numworks.com/apps, and "- "reinstalling may reset your progress in every game.",+ "To play it again, reinstall NumPlay from my.numworks.com/apps. Your other games keep their "+ "progress.",0xFFFF, 170);ui_button(38, 198, 110, 28, "Cancel", d->choice == 0, 0x555D70, 256);- /* the uninstall button fills up while OK is held */- int bx = 172, by = 198, bw = 110, bh = 28;- if (d->choice == 1) {- gfx_rrect(bx, by + 2, bw, bh, bh / 2, 0, 64);- gfx_rrect(bx, by, bw, bh, bh / 2, gfx_rgb(DANGER), 256);- int fill = (int)(bw * d->hold);- if (fill > 0) {- gfx_rrect(bx, by, NP_MAX(fill, bh), bh, bh / 2, 0xFFFF, 110);- }- gfx_text_center(&np_font_body, bx + bw / 2, by + 18, d->hinted ? "Hold OK" : "Uninstall", 0xFFFF, 256);- } else {- gfx_rrect(bx, by, bw, bh, bh / 2, 0xFFFF, 40);- gfx_text_center(&np_font_body, bx + bw / 2, by + 18, "Uninstall", 0xFFFF, 200);- }+ hold_button(d, "Uninstall");}static dialog_t *active_dialog;@@ -305,24 +308,44 @@ static void wait_ok(dialog_t *d) {}}-/* Reset (game >= 0) or Reset all (game < 0), after asking. */-static void reset_flow(int game) {- dialog_t d = {game < 0 ? 0 : game, 0, 0, false, 0, 0, 0, 0, game < 0 ? ACT_RESET_ALL : ACT_RESET};+/* Cancel, or OK held on the red button: true once it has been held long enough */+static bool hold_to_confirm(dialog_t *d) {ui_keys_t k = {np_keys(), 0, 0};- ui_frame(dialog_scene, &d);+ uint32_t last = np_millis();+ bool dirty = true;for (;;) {+ uint32_t now = np_millis(), dt = now - last;+ last = now;uint32_t p = ui_poll(&k);- if (p & (K_BACK | K_HOME)) return;- if (p & (K_LEFT | K_RIGHT)) {- d.choice = (p & K_RIGHT) != 0;- ui_frame(dialog_scene, &d);- }+ if (p & (K_BACK | K_HOME)) return false;+ if (p & K_LEFT) d->choice = 0, d->hold = 0, dirty = true;+ if (p & K_RIGHT) d->choice = 1, dirty = true;if (p & K_OK) {- if (d.choice == 0) return;- break;+ if (d->choice == 0) return false;+ d->hinted = true; /* a short press only shows how */+ dirty = true;+ }+ if (d->choice == 1 && (k.held & K_OK)) {+ d->hold += dt / (float)HOLD_MS;+ dirty = true;+ if (d->hold >= 1) return true;+ } else if (d->hold > 0) {+ d->hold = NP_MAX(d->hold - dt / 300.f, 0.f);+ dirty = true;+ }+ if (dirty) {+ ui_frame(dialog_scene, d);+ dirty = false;+ } else {+ np_sleep(16);}- np_sleep(16);}+}++/* Reset (game >= 0) or Reset all (game < 0), after asking. */+static void reset_flow(int game) {+ dialog_t d = {game < 0 ? 0 : game, 0, 0, false, 0, 0, 0, 0, game < 0 ? ACT_RESET_ALL : ACT_RESET};+ if (!hold_to_confirm(&d)) return;if (game >= 0) np_reset_game(game);elsefor (int i = 0; i < np_game_count; i++) np_reset_game(i);@@ -341,36 +364,7 @@ static bool uninstall_flow(int game) {wait_ok(&d);return false;}- ui_keys_t k = {np_keys(), 0, 0};- uint32_t last = np_millis();- bool dirty = true;- for (;;) {- uint32_t now = np_millis(), dt = now - last;- last = now;- uint32_t p = ui_poll(&k);- if (p & (K_BACK | K_HOME)) return false;- if (p & K_LEFT) d.choice = 0, d.hold = 0, dirty = true;- if (p & K_RIGHT) d.choice = 1, dirty = true;- if (p & K_OK) {- if (d.choice == 0) return false;- d.hinted = true;- dirty = true;- }- if (d.choice == 1 && (k.held & K_OK)) {- d.hold += dt / (float)HOLD_MS;- dirty = true;- if (d.hold >= 1) break;- } else if (d.hold > 0) {- d.hold = NP_MAX(d.hold - dt / 300.f, 0.f);- dirty = true;- }- if (dirty) {- ui_frame(dialog_scene, &d);- dirty = false;- } else {- np_sleep(16);- }- }+ if (!hold_to_confirm(&d)) return false;d.stage = 1;d.freed = np_game_size(game);ui_frame(dialog_scene, &d);diff --git a/launcher/src/storage.c b/launcher/src/storage.cindex 65b06cdc..107ceffe 100644--- a/launcher/src/storage.c+++ b/launcher/src/storage.c@@ -1,6 +1,7 @@/* Save files in Epsilon's file system, with the careful record handling shared- * with the games (games/common/epsilon_files.h): deleting a game's saves, and- * NumPlay's own settings. */+ * with the games (games/common/epsilon_files.h): deleting a game's saves,+ * NumPlay's own settings, and a copy of every save kept in a Python script. */+#include <string.h>#include "np.h"#include "../../games/common/epsilon_files.h"@@ -36,3 +37,126 @@ bool np_config_save(const np_config_t *c) {uint8_t d[4] = {CONFIG_MAGIC, 1, (uint8_t)(c->disguise | (c->hint ? 0 : 2)), c->secret};return ef_write(CONFIG_NAME, d, sizeof d);}++/* ---------------------------------------------------------------- progress copy+ * Installing apps restarts the calculator, which empties its file system; the+ * NumWorks installer puts back the Python scripts only. So NumPlay keeps every+ * save in a script too, as comment lines "#>name:base64", and after an update+ * (none of those files left) writes them back. */+#define COPY_NAME "numplay_saves.py"+static const char copy_head[] =+ "# NumPlay keeps a copy of your game progress here, so that\n"+ "# updating NumPlay doesn't erase it. If you delete this file,\n"+ "# NumPlay writes it again: your progress stays either way.\n";+static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";++static uint32_t b64_len(uint32_t n) { return (n + 2) / 3 * 4; }+static void b64_encode(const uint8_t *in, uint32_t n, uint8_t *out) {+ for (uint32_t i = 0; i < n; i += 3, out += 4) {+ uint32_t v = (uint32_t)in[i] << 16 | (i + 1 < n ? in[i + 1] << 8 : 0) | (i + 2 < n ? in[i + 2] : 0);+ for (int k = 0; k < 4; k++) out[k] = k <= (int)(n - i) ? (uint8_t)b64[v >> (18 - 6 * k) & 63] : '=';+ }+}+static int b64_value(uint8_t c) {+ for (int i = 0; i < 64; i++)+ if ((uint8_t)b64[i] == c) return i;+ return -1;+}++/* Every save file NumPlay knows, each name once; false when i is past the end */+static bool save_name(int i, const char **name) {+ if (i-- == 0) return *name = CONFIG_NAME, true;+ for (int g = 0; g < np_game_count; g++)+ for (const char *const *r = np_games[g].records; r && *r; r++) {+ bool seen = false;+ for (int h = 0; h <= g && !seen; h++)+ for (const char *const *q = np_games[h].records; q && *q && q != r && !seen; q++) seen = !strcmp(*q, *r);+ if (seen) continue;+ if (i-- == 0) return *name = *r, true;+ }+ return false;+}++static uint8_t *body(const char *name, uint32_t *len) { return (uint8_t *)(uintptr_t)ef_read(name, len); }++/* The copy's lines: calls line(name, data, len, text, text_len) for each */+static bool copy_line(const uint8_t *text, uint32_t n, uint32_t *at, char name[32], const uint8_t **data,+ uint32_t *len) {+ while (*at < n) {+ const uint8_t *l = text + *at, *e = l;+ while (e < text + n && *e != '\n') e++;+ *at = (uint32_t)(e - text) + 1;+ const uint8_t *colon = l;+ while (colon < e && *colon != ':') colon++;+ if (e - l < 3 || l[0] != '#' || l[1] != '>' || colon == e || colon - l - 2 >= 32) continue;+ for (int i = 0; i < colon - l - 2; i++) name[i] = (char)l[2 + i];+ name[colon - l - 2] = 0;+ *data = colon + 1;+ *len = (uint32_t)(e - colon - 1);+ return true;+ }+ return false;+}++void np_progress_restore(void) {+ uint32_t n = 0;+ const uint8_t *c = ef_read(COPY_NAME, &n);+ if (!c || n < 2) return;+ c++, n--; /* the script's status byte */+ char name[32];+ const uint8_t *data;+ uint32_t at = 0, len;+ /* only after an update: while any of these files is here, they are newer */+ while (copy_line(c, n, &at, name, &data, &len))+ if (ef_read(name, &(uint32_t){0})) return;+ for (at = 0; copy_line(c, n, &at, name, &data, &len);) {+ uint32_t size = len / 4 * 3, off = (uint32_t)(data - c);+ if (len % 4 || !len) continue;+ size -= (data[len - 1] == '=') + (data[len - 2] == '=');+ if (!ef_write(name, NULL, size)) continue; /* appended: the copy stays where it is */+ c = ef_read(COPY_NAME, &n) + 1, n--;+ data = c + off;+ uint32_t got;+ uint8_t *out = body(name, &got);+ for (uint32_t i = 0, o = 0; i < len && out; i += 4) {+ int v[4];+ for (int k = 0; k < 4; k++) v[k] = data[i + k] == '=' ? 0 : b64_value(data[i + k]);+ if (v[0] < 0 || v[1] < 0 || v[2] < 0 || v[3] < 0) break;+ uint32_t w = (uint32_t)(v[0] << 18 | v[1] << 12 | v[2] << 6 | v[3]);+ for (int k = 0; k < 3 && o < got; k++) out[o++] = (uint8_t)(w >> (16 - 8 * k));+ }+ }+}++void np_progress_backup(void) {+ const char *name;+ uint32_t total = 1 + sizeof copy_head - 1 + 1, len; /* status byte, text, terminating zero */+ for (int i = 0; save_name(i, &name); i++)+ if (ef_read(name, &len)) total += 2 + (uint32_t)strlen(name) + 1 + b64_len(len) + 1;+ /* never lose the copy for want of room: keep the old one then */+ ef_fs_t fs;+ if (!ef_open(&fs)) return;+ int end = ef_end(&fs);+ if (end < 0) return;+ uint32_t old = 0;+ int was = ef_find(&fs, COPY_NAME, end);+ if (was >= 0) old = ef_rd16(fs.buf + was);+ uint32_t need = 2 + sizeof COPY_NAME + total;+ if (need != old && (uint32_t)end + 2 + need > fs.size + old) return;+ if (!ef_write(COPY_NAME, NULL, total)) return;+ uint8_t *o = body(COPY_NAME, &len);+ if (!o || len != total) return;+ *o++ = 0; /* not imported by the Python shell */+ for (const char *h = copy_head; *h; h++) *o++ = (uint8_t)*h;+ for (int i = 0; save_name(i, &name); i++) {+ const uint8_t *d = ef_read(name, &len);+ if (!d) continue;+ *o++ = '#', *o++ = '>';+ for (const char *q = name; *q; q++) *o++ = (uint8_t)*q;+ *o++ = ':';+ b64_encode(d, len, o);+ o += b64_len(len);+ *o++ = '\n';+ }+ *o = 0;+}diff --git a/tests/test_progress.py b/tests/test_progress.pynew file mode 100644index 00000000..55a764c9--- /dev/null+++ b/tests/test_progress.py@@ -0,0 +1,172 @@+#!/usr/bin/env python3+"""Checks that progress survives an update of NumPlay.++Installing apps restarts the calculator and the NumWorks installer puts back+the Python scripts only, so NumPlay keeps a copy of every save in+numplay_saves.py. In the ARM emulator:++1. saves of every game: NumPlay writes the copy, a valid Python script;+2. "update" (every file but the scripts deleted): the saves come back, byte+ for byte, and the other scripts are untouched;+3. Reset asks for OK to be held: a short press resets nothing;+4. holding OK resets the game, and the copy follows: after another update,+ the game starts over while the others keep their progress.++Usage: test_progress.py build/NumPlay.nwa [--out DIR]+"""+import argparse+import base64+import json+import os+import random+import struct+import sys+import tempfile++sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "tools"))+import emu # noqa: E402++K = emu.KEYS+COPY = "numplay_saves.py"+++def records(buf):+ out, p = [], 0+ while p + 2 <= len(buf):+ n, = struct.unpack_from("<H", buf, p)+ if n == 0:+ return out+ if n < 4 or p + n > len(buf):+ raise ValueError(f"corrupt record at {p}")+ name = buf[p + 2:buf.index(b"\0", p + 2)].decode("latin1")+ out.append((name, bytes(buf[p + 3 + len(name):p + n])))+ p += n+ raise ValueError("no end of the record list")+++def write_storage(path, recs):+ buf = bytearray(emu.STORAGE_SIZE)+ p = 0+ for name, content in recs:+ size = 2 + len(name) + 1 + len(content)+ struct.pack_into("<H", buf, p, size)+ buf[p + 2:p + size] = name.encode() + b"\0" + content+ p += size+ open(path, "wb").write(buf)+++def presses(*items):+ return [(t, t + (d[0] if d else 90), K[k]) for t, k, *d in items]+++def run(nwa, storage, keys, home, out, tag):+ c = emu.Calculator(nwa, storage_file=storage)+ c.enable_checks(reads=True)+ c.keys = keys + [(home, home + 400, K["home"])]+ c.pending_shots = [(t, os.path.join(out, f"{tag}_{t}.png")) for t in (home - 150,)]+ c.run(home + 3000)+ problems = []+ if not c.exited:+ problems.append(f"{tag}: did not quit on Home")+ if c.violations:+ problems += [f"{tag}: {v}" for v in sorted(set(c.violations))[:5]]+ return dict(records(open(storage, "rb").read())), problems+++def check_copy(recs, expected):+ """The copy is a Python script holding exactly `expected`."""+ problems = []+ c = recs.get(COPY)+ if c is None:+ return [f"{COPY} not written"]+ if c[0] != 0 or c[-1] != 0 or 0 in c[1:-1]:+ problems.append(f"{COPY}: not a script (status byte {c[0]}, zero inside or missing at the end)")+ try:+ text = c[1:-1].decode("ascii")+ except UnicodeDecodeError:+ return problems + [f"{COPY}: not plain text"]+ copied = {}+ for line in text.split("\n"):+ if line and not line.startswith("#"):+ problems.append(f"{COPY}: a line that isn't a comment: {line[:40]!r}")+ if line.startswith("#>"):+ name, _, data = line[2:].partition(":")+ copied[name] = base64.b64decode(data)+ if copied != expected:+ problems.append(f"{COPY} holds {sorted(copied)}, expected {sorted(expected)}"+ + ("" if set(copied) != set(expected) else " (contents differ)"))+ return problems+++def main():+ ap = argparse.ArgumentParser()+ ap.add_argument("nwa")+ ap.add_argument("--out", default="build/test_progress")+ a = ap.parse_args()+ os.makedirs(a.out, exist_ok=True)+ games = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "games", "games.json")))+ rnd = random.Random(7)+ script = ("pi.py", b"\x01print(3.14159)\n\x00")+ # a save for every file the games write (binary, zeros included), and NumPlay's settings+ saves = {"numplay.set": bytes([ord("N"), 1, 0, 0])}+ for g in games:+ for r in g["records"]:+ saves.setdefault(r, bytes(rnd.randrange(256) for _ in range(rnd.choice([1, 2, 8, 30, 64, 192, 700]))))+ first = games[0]+ reset_files = set(first.get("reset", first["records"]))+ problems = []+ with tempfile.TemporaryDirectory() as d:+ st = os.path.join(d, "storage.bin")+ write_storage(st, [script] + sorted(saves.items()))+ # 1. the copy is written+ recs, p = run(a.nwa, st, [], 2500, a.out, "1_copy")+ problems += p + check_copy(recs, saves)++ def update(): # what the installer leaves: the Python scripts+ write_storage(st, [(n, v) for n, v in records(open(st, "rb").read()) if n.endswith(".py")])++ # 2. after an update, everything comes back+ update()+ recs, p = run(a.nwa, st, [], 2500, a.out, "2_restore")+ problems += p+ for n, v in saves.items():+ if recs.get(n) != v:+ problems.append(f"after an update, {n} " + ("missing" if n not in recs else "differs"))+ if recs.get(script[0]) != script[1]:+ problems.append("the other script changed")++ # to the settings card, open it, Reset on the first game's row, then the red button+ n = len(games)+ lead = [(1200 + 300 * i, "right") for i in range(n)] + [(1500 + 300 * n, "ok"), (2600 + 300 * n, "ok"),+ (3400 + 300 * n, "right")]+ t = 3900 + 300 * n+ # 3. a short press only shows "Hold OK": nothing is reset+ keys = presses(*lead, (t, "ok"), (t + 700, "back"), (t + 1500, "back"))+ recs, p = run(a.nwa, st, keys, t + 2500, a.out, "3_short")+ problems += p+ if any(recs.get(f) != saves[f] for f in reset_files):+ problems.append("a short press of OK reset the game")+ # 4. held, it resets; the copy follows, so an update doesn't bring it back+ keys = presses(*lead, (t, "ok", 1900), (t + 2600, "ok"), (t + 3300, "back"))+ recs, p = run(a.nwa, st, keys, t + 4300, a.out, "4_hold")+ problems += p+ if any(f in recs for f in reset_files):+ problems.append(f"holding OK did not reset {first['title']}")+ kept = {k: v for k, v in saves.items() if k not in reset_files}+ problems += check_copy(recs, kept)+ update()+ recs, p = run(a.nwa, st, [], 2500, a.out, "5_update_after_reset")+ problems += p+ if any(f in recs for f in reset_files):+ problems.append(f"{first['title']} came back after an update, though it was reset")+ for k, v in kept.items():+ if recs.get(k) != v:+ problems.append(f"after reset and update, {k} " + ("missing" if k not in recs else "differs"))+ for x in problems:+ print(" ", x)+ print("PASS" if not problems else "FAIL")+ sys.exit(1 if problems else 0)+++if __name__ == "__main__":+ main()