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
Hollow Knight: a shop's charm lesson lets the Knight go
Mason363a47a17bd49c5
diff --git a/games/hollowknight/src/data.h b/games/hollowknight/src/data.hindex f9c6c114..8e909a9a 100644--- a/games/hollowknight/src/data.h+++ b/games/hollowknight/src/data.h@@ -927,6 +927,8 @@#define VMEV_FIRST_MAP_DOWN 45#define VMEV_FK_RAGE_COMPLETE 46#define VMEV_UPDATE_SHAMAN {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 79, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}+#define VMEV_SHOP_REGION_INACTIVE {255, 255, 67, 82, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 85, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}+#define VMEV_SHOP_REGION_ACTIVE {255, 255, 61, 77, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 75, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}#define VMSTR_NPC_TITLE 14#define VMSTR_VISITED 691#define VMSTR_DISPLAY_RIGHT 692diff --git a/games/hollowknight/src/game.h b/games/hollowknight/src/game.hindex 3e87bbe9..e9334aab 100644--- a/games/hollowknight/src/game.h+++ b/games/hollowknight/src/game.h@@ -401,6 +401,7 @@ void notice_icon(int k); /* (the next notice's icon: the scripts' NOTICE_ICOvoid notice_show(int text); /* a relic's notice: its icon, its name */void charm_notice(int id); /* a charm's (in the tutorial, as it is made: its charm) */void charm_tute(void);+void charm_tute_input(void);void charm_tute_close(void);void notices_close(void); /* (DESTROY JOURNAL MSG: the inventory opens)*/bool bench_respawn(const char *name); /* RESPAWN: the Knight asleep on the bench so named */diff --git a/games/hollowknight/src/msg.c b/games/hollowknight/src/msg.cindex 63100223..1250fb91 100644--- a/games/hollowknight/src/msg.c+++ b/games/hollowknight/src/msg.c@@ -200,7 +200,9 @@ static struct {uint8_t kind;int16_t icon, text, next_icon;float t, t_down; /* (time up; time since it went down: -1 not yet) */-} nt = {NT_OFF, -1, -1, -1, 0, -1};+ bool input; /* (the tutorial's Input: a key sends it down, then the Knight's control back, as a shop's) */+ uint32_t prev_keys;+} nt = {NT_OFF, -1, -1, -1, 0, -1, false, 0};static void notices_off(void) { nt.kind = NT_OFF; }void notices_close(void) { notices_off(); }@@ -209,7 +211,7 @@ void notice_icon(int k) { nt.next_icon = k >= 0 && k < (int)(sizeof notice_iconsstatic void notice_start(int kind, int icon, int text) {m.st = MS_OFF; /* (the item message: gone, as a new one shows) */- nt.kind = (uint8_t)kind, nt.icon = (int16_t)icon, nt.text = (int16_t)text, nt.t = 0, nt.t_down = -1;+ nt.kind = (uint8_t)kind, nt.icon = (int16_t)icon, nt.text = (int16_t)text, nt.t = 0, nt.t_down = -1, nt.input = false;}void notice_show(int text) { notice_start(NT_RELIC, nt.next_icon, text); }@@ -223,19 +225,42 @@ void charm_notice(int id) {void charm_tute(void) { notice_start(NT_TUTE, -1, -1); }+/* (a shop's: Input on; the shop region off until it is gone, SHOP REGION INACTIVE, then ACTIVE) */+void charm_tute_input(void) {+ static const uint8_t inactive[NUM_ROOMS] = VMEV_SHOP_REGION_INACTIVE;+ notice_start(NT_TUTE, -1, -1);+ nt.input = true, nt.prev_keys = g_hero.keys;+ if (inactive[g_room.id] != 255) vm_broadcast(inactive[g_room.id]);+}+void charm_tute_close(void) {if (nt.kind == NT_TUTE && nt.t_down < 0) nt.t_down = 0;}static void notices_tick(void) {if (nt.kind == NT_OFF) return;+ uint32_t pressed = g_hero.keys & ~nt.prev_keys;+ nt.prev_keys = g_hero.keys;nt.t += DT;if (nt.t_down >= 0) nt.t_down += DT;if (nt.kind != NT_TUTE) {if (nt.t >= 4.25f && nt.t_down < 0) nt.t_down = 0;if (nt.t_down >= 1) nt.kind = NT_OFF;- } else if (nt.t_down >= 1)+ return;+ }+ /* (Stop, Wait For Input: the inventory, a spell, the nail or a jump sends it Down) */+ if (nt.input && nt.t >= 5 && nt.t_down < 0 && (pressed & (K_INV | K_SPELL | K_ATTACK | K_JUMP))) nt.t_down = 0;+ if (nt.t_down >= 1) {nt.kind = NT_OFF;+ if (nt.input) {+ /* (Regain Control?, Destroy: SHOP REGION ACTIVE) */+ static const uint8_t active[NUM_ROOMS] = VMEV_SHOP_REGION_ACTIVE;+ hero_regain_control();+ g_pd.disable_pause = false;+ hero_start_anim_control();+ if (active[g_room.id] != 255) vm_broadcast(active[g_room.id]);+ }+ }}/* a part's alpha: up over `up` after `delay`, down over `down` once it went down */diff --git a/games/hollowknight/src/shop.c b/games/hollowknight/src/shop.cindex 55348c96..25f461f5 100644--- a/games/hollowknight/src/shop.c+++ b/games/hollowknight/src/shop.c@@ -169,7 +169,7 @@ static bool give(const Item *it) {g_pd.charms_owned++;if (!pd_flag(PDF_HAS_CHARM)) {pd_set_flag(PDF_HAS_CHARM, true);- charm_tute();+ charm_tute_input();return true;}return false;diff --git a/games/hollowknight/tests/check.py b/games/hollowknight/tests/check.pyindex 4d9cd601..e33ff17b 100644--- a/games/hollowknight/tests/check.py+++ b/games/hollowknight/tests/check.py@@ -17,6 +17,7 @@overcharmed on the fifth try and off again, kept by Home in the inventory and a load- the stag stations: each seen (their blanker faded out), come in by its gate, by the stag (called by its bell) andloaded at its bench+- each shop's first charm bought: its lesson sent away by a key, the Knight free again- the Snail Shaman's temple, played as one game: his spell taken, the Elder Baldur killed, his talk opening the gate, andso after a save and a load too; its lifeblood cocoon broken through a load and a rest there, whole after another bench- the way to the False Knight, played room by room as one game (the Knight unhurt): from a new game's fall into King's@@ -83,6 +84,8 @@ def main():with tempfile.TemporaryDirectory() as saves:rc, out = play("--gates", "stations", env={"HKSAVES": saves})results.append(report("stag stations: seen, the rides", rc, out, ("FAIL",)))+ rc, out = play("--gates", "shopcharm")+ results.append(report("a shop's first charm: its lesson, the Knight free after it", rc, out, ("FAIL",)))with tempfile.TemporaryDirectory() as saves:rc, out = play("--gates", "shaman", env={"HKSAVES": saves})results.append(report("the Snail Shaman: his spell, the Elder Baldur, his gate, saved and loaded", rc, out, ("FAIL",)))diff --git a/games/hollowknight/tests/play.c b/games/hollowknight/tests/play.cindex 8530d1a5..d2e948f1 100644--- a/games/hollowknight/tests/play.c+++ b/games/hollowknight/tests/play.c@@ -818,6 +818,43 @@ static int texts_test(void) {return text_fails ? 1 : 0;}+/* each shop's first charm: bought (each row from the top, as bought until one is a charm), its lesson up as the shop+ * closes, then sent away by a key once it stops, the Knight's control given back (a shop's lesson: Input) */+static int shop_charm_test(void) {+ static const struct { const char *room; float x; const char *flags; } shops[] = {+ {"Room_mapper", 17.35f, "123,149"}, {"Room_shop", 15.6f, "23,122"}, {"Room_Charm_Shop", 17.14f, "124"}};+ int fails = 0;+ shielded = true;+ for (unsigned k = 0; k < sizeof shops / sizeof shops[0]; k++) {+ text_room(shops[k].room, shops[k].x, 6.5f, shops[k].flags);+ run_ticks(80, 0);+ bool lesson = false;+ for (int row = 0; row < 12 && !pd_flag(PDF_HAS_CHARM); row++) {+ for (int t = 0; t < 30 && !hero_free(); t++) run_ticks(50, 0); /* (the shop down, or what it gave) */+ run_ticks(3, K_UP);+ run_ticks(150, 0);+ for (int i = 0; i < 8 && !shop_open(); i++) run_ticks(2, K_OK | K_JUMP), run_ticks(60, 0); /* (its talk first) */+ for (int i = 0; i < row; i++) run_ticks(2, K_DOWN), run_ticks(20, 0);+ run_ticks(2, K_OK), run_ticks(40, 0);+ run_ticks(2, K_OK), run_ticks(150, 0);+ if (pd_flag(PDF_HAS_CHARM)) lesson = !shop_open() && !hero_free();+ if (shop_open()) run_ticks(2, K_BACK), run_ticks(60, 0), run_ticks(2, K_BACK), run_ticks(60, 0);+ }+ run_ticks(300, 0); /* (its stop, 5 s after it came up) */+ bool waits = !hero_free();+ run_ticks(2, K_JUMP);+ run_ticks(100, 0);+ bool ok = pd_flag(PDF_HAS_CHARM) && lesson && waits && hero_free();+ printf("%s shop charm: %s: %s\n", ok ? "ok " : "FAIL", shops[k].room,+ !pd_flag(PDF_HAS_CHARM) ? "no charm bought" : !lesson ? "no lesson" : !waits ? "the lesson gone by itself"+ : !hero_free() ? "the Knight without control after it" : "bought, the lesson sent away, the Knight free");+ fails += !ok;+ }+ shielded = false;+ printf("shop charm: %d failing\n", fails);+ return fails ? 1 : 0;+}+/* the way to the False Knight (Mason363/NumPlay#172), played as one game, room by room, each room's keys from when the* Knight comes into it: from the new game's fall into King's Pass, through Dirtmouth and down its well, past the Temple of* the Black Egg, down through the tollbooth into Crossroads_03 (its lever's gates open: the game's Knight opens them from@@ -947,6 +984,7 @@ static int gates_test(const char *which) {if (!strcmp(which, "charms")) return charms_test();if (!strcmp(which, "stations")) return stations_test();if (!strcmp(which, "shaman")) return shaman_test();+ if (!strcmp(which, "shopcharm")) return shop_charm_test();if (!strncmp(which, "wander:", 7)) { /* (wander:ROOM|all:seed:ticks) */char room[64];int seed = 1, ticks = 6000;diff --git a/games/hollowknight/tools/vm.py b/games/hollowknight/tools/vm.pyindex 3d4e546d..ad794dd6 100644--- a/games/hollowknight/tools/vm.py+++ b/games/hollowknight/tools/vm.py@@ -252,8 +252,8 @@ for e in ("FINISHED", "CONVO_FINISH", "CONVO START", "CONVO END", "BIG TITLE STAEVENTS.id(e)FIXED_EVENTS = len(EVENTS.list) # (src/data.h: VMEV_*)# events the game's code sends that only some rooms' scripts know, numbered as each room numbers its own (src/data.h:-# VMEV_*, by room): the Elder Baldur's corpse's-NAMED_EVENTS = ("UPDATE SHAMAN",)+# VMEV_*, by room): the Elder Baldur's corpse's, a shop's charm lesson's+NAMED_EVENTS = ("UPDATE SHAMAN", "SHOP REGION INACTIVE", "SHOP REGION ACTIVE")# ---------------------------------------------------------------- the actions it runs: name -> (opcode, operands)# operand kinds: f i b s o value slots (u16), F I B S O V output variables (u8: 255 none), e event (u8), t event target,