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
Balatro: the TI-84 Plus CE version plays
Mason3635db34fd9e764
diff --git a/games/balatro/Makefile b/games/balatro/Makefileindex aaf3b6f2..88d21f9b 100644--- a/games/balatro/Makefile+++ b/games/balatro/Makefile@@ -78,4 +78,6 @@ PORT_ID = balatroPORT_NAME = BalatroPORT_SRC = src/art.c src/assets.c src/bg.c src/cons.c src/data.c src/draw.c src/ev.c src/flame.c src/fx.c src/game.c src/gfx.c src/jokers.c src/main.c src/save.c src/score.c src/ui.c src/util.cPORT_FLAGS = -Isrc+# the TI-84 Plus CE has a version of its own (ce/, a CE toolchain project): make port TARGET=ti84ce builds it+PORT_CE = ceinclude ../../platform/port.mkdiff --git a/games/balatro/ce/makefile b/games/balatro/ce/makefileindex 265aa6ab..2167c6b1 100644--- a/games/balatro/ce/makefile+++ b/games/balatro/ce/makefile@@ -84,6 +84,6 @@ HOST_SRC = $(wildcard src/*.c) $(EXTRA_C_SOURCES) tools/host.chost: $(BINDIR)/host/balatro$(BINDIR)/host/balatro: $(HOST_SRC) $(wildcard src/*.h) $(DEPS) $(BINDIR)/art.stamp$(Q)mkdir -p $(@D)- $(Q)$(HOSTCC) -std=gnu11 -O1 -g -Wall -DNP_HOST=1 $(filter-out -Xclang -mdouble=64,$(CEFLAGS)) \+ $(Q)$(HOSTCC) -std=gnu11 -O1 -g -Wall $(HOSTFLAGS) -DNP_HOST=1 $(filter-out -Xclang -mdouble=64,$(CEFLAGS)) \$(shell pkg-config --cflags sdl3 2>/dev/null) $(HOST_SRC) $(shell pkg-config --libs sdl3 2>/dev/null) -lm -o $@$(Q)echo [host] $@diff --git a/games/balatro/ce/src/bg_ce.c b/games/balatro/ce/src/bg_ce.cindex 00619e1e..67134894 100644--- a/games/balatro/ce/src/bg_ce.c+++ b/games/balatro/ce/src/bg_ce.c@@ -8,7 +8,7 @@#include "ce.h"uint8_t ce_bg_ver;-static const uint8_t *field[2];+static const uint8_t *field[3]; /* the run's (right of the sidebar), the title's top and bottom halves */static int mode;static float colours[3][3], target[3][3], contrast = 1, contrast_target = 1, spin, spin_target;static int lut_dirty = 1;@@ -20,7 +20,8 @@ int ce_bg_init(void) {size_t n;field[0] = ce_appvar("BALBG0", &n);field[1] = ce_appvar("BALBG1", &n);- return field[0] && field[1];+ field[2] = ce_appvar("BALBG2", &n);+ return field[0] && field[1] && field[2];}static float fabsf_(float x) { return x < 0 ? -x : x; }@@ -145,7 +146,7 @@ void ce_bg_row(uint8_t *dst, int y, int x0) {for (; x < BG_RUN_X; x++) dst[x] = row[BG_RUN_X - x < BG_RUN_W ? BG_RUN_X - x : 0]; /* (mirrored: a sidebar covers it) */memcpy(dst + x, row + (x - BG_RUN_X), (size_t)(SCR_W - x));} else {- const uint8_t *row = field[1] + (y >> 1) * BG_TITLE_W;- for (int x = x0 & ~1; x < SCR_W; x += 2) dst[x] = dst[x + 1] = row[x >> 1];+ const uint8_t *row = y < SCR_H / 2 ? field[1] + y * SCR_W : field[2] + (y - SCR_H / 2) * SCR_W;+ memcpy(dst + x0, row + x0, (size_t)(SCR_W - x0));}}diff --git a/games/balatro/ce/src/ce_main.c b/games/balatro/ce/src/ce_main.cindex 212ae506..8a932169 100644--- a/games/balatro/ce/src/ce_main.c+++ b/games/balatro/ce/src/ce_main.c@@ -143,9 +143,10 @@ void ce_archive(const char *op1);/* the code's appvars (where each goes), then the others */#define NCODE 4-static const char BOOTDATA var_names[][9] = {"BALCV0", "BALCV1", "BALCP", "BALCB", "BALLUT", "BALFIRE", "BALBG0",- "BALBG1", "BALED", "BALART0", "BALART1", "BALART2", "BALART3", "BALART4"};-#define NVARS (NCODE + 5 + CE_ART_NVARS)+static const char BOOTDATA var_names[][9] = {"BALCV0", "BALCV1", "BALCP", "BALCB", "BALLUT", "BALFIRE",+ "BALBG0", "BALBG1", "BALBG2", "BALED", "BALART0", "BALART1",+ "BALART2", "BALART3", "BALART4", "BALART5"};+#define NVARS (NCODE + 6 + CE_ART_NVARS)static const char BOOTDATA save_name[9] = "NPbalato";static const char BOOTDATA msg_missing[] = "Balatro: a file is missing";static const char BOOTDATA msg_send[] = "Send every Balatro file:";diff --git a/games/balatro/ce/tools/host.c b/games/balatro/ce/tools/host.cindex ff7ec0ee..1612f2e2 100644--- a/games/balatro/ce/tools/host.c+++ b/games/balatro/ce/tools/host.c@@ -1,5 +1,5 @@/* The TI-84 Plus CE version on a computer, for testing: the calculator's 8-bit screen and palette, its keys, its- * appvars (gen/*.bin, as tools/mkart.py makes them) and the save (a file), with SDL 3 for a window.+ * appvars (the .bin files in gen/, as tools/mkart.py makes them) and the save (a file), with SDL 3 for a window.** In the environment, as platform/sdl/np_sdl.c: NP_HEADLESS=1 for no window (and a clock that only moves when the* game sleeps: fast, and the same every run), NP_KEYS "1500-1700:ok,3000:back" holds keys from one time to anotherdiff --git a/games/balatro/ce/tools/mkart.py b/games/balatro/ce/tools/mkart.pyindex b90bdd06..2326b8d5 100644--- a/games/balatro/ce/tools/mkart.py+++ b/games/balatro/ce/tools/mkart.py@@ -138,15 +138,24 @@ def paint(sx, sy, mode, t_real, t_spin, spin, contrast):BAYER = [[0, 8, 2, 10], [12, 4, 14, 6], [3, 11, 1, 9], [15, 7, 13, 5]]-def field(mode, x0, w, h, step):- """the paint (0..255) every `step` pixels, then as levels 0..15 (ordered dither), as palette indices"""+def field(mode, x0, w, h, cell):+ """The paint as src/bg.c draws it: worked out on a grid every `cell` pixels (each point the mean of 4 samples a+ pixel around it, as bg.c's passes average them), interpolated between the points for every pixel, then as levels+ 0..15 (ordered dither), as palette indices."""+ gw, gh = (w + cell - 1) // cell + 2, (h + cell - 1) // cell + 2+ t = 20.0 if mode else 36.0+ jit = ((-1, -1), (1, 1), (1, -1), (-1, 1))+ grid = [[sum(paint(x0 + gx * cell + jx, gy * cell + jy, mode, t, 0.0, 0.0, 1.0) for jx, jy in jit) / 4.0+ for gx in range(gw)] for gy in range(gh)]out = bytearray()for y in range(h):+ gy, fy = y // cell, (y % cell) / cellfor x in range(w):- sx, sy = x0 + x * step + (step - 1) / 2, y * step + (step - 1) / 2- v = paint(sx, sy, mode, 20.0 if mode else 36.0, 0.0, 0.0, 1.0)- lv = (v * (LEVELS - 1) * 16 // 255 + BAYER[y & 3][x & 3]) // 16- out.append(SWIRL0 + min(LEVELS - 1, lv))+ gx, fx = x // cell, (x % cell) / cell+ v = (grid[gy][gx] * (1 - fx) + grid[gy][gx + 1] * fx) * (1 - fy) + \+ (grid[gy + 1][gx] * (1 - fx) + grid[gy + 1][gx + 1] * fx) * fy+ lv = int((v * (LEVELS - 1) * 16 / 255 + BAYER[y & 3][x & 3]) // 16)+ out.append(SWIRL0 + max(0, min(LEVELS - 1, lv)))return bytes(out)@@ -482,15 +491,18 @@ def main():fonts += [(name, tab), (name + "_bits", bits)]parts = {}for name, blob in (("shade", shade), ("grey", grey), ("edlut", edl), ("fcol", fcols), ("text", texts)) + tuple(fonts):+ if len(lut) & 1:+ lut.append(0) # (the fonts' tables have 16-bit fields)parts[name] = len(lut)lut += blob# the background: the run's paint right of the sidebar, the title's at half size- bg_run = field(0, 102, 218, 240, 1)- bg_title = field(1, 0, 160, 120, 2)+ bg_run = field(0, 102, 218, 240, 4)+ bg_title = field(1, 0, 320, 240, 2)blobs = dict(vars_)blobs["BALLUT"] = lutblobs["BALBG0"] = bg_run- blobs["BALBG1"] = bg_title+ blobs["BALBG1"] = bg_title[:len(bg_title) // 2]+ blobs["BALBG2"] = bg_title[len(bg_title) // 2:]blobs["BALFIRE"] = fgridsblobs["BALED"] = edpif max(len(b) for b in blobs.values()) > MAXVAR:@@ -522,7 +534,7 @@ def main():f"#define FL_W {FL_W}", f"#define FL_H {FL_H}", f"#define FL_FRAMES {FL_FRAMES}", f"#define FL_LEVELS {FL_LEVELS}",f"#define FL_GC {FL_GC}", f"#define FL_GR {FL_GR}", f"#define FL_ROWS {FL_ROWS}","#define FL_I {" + ",".join(f"{v}f" for v in FL_I) + "}",- "#define BG_RUN_X 102", "#define BG_RUN_W 218", "#define BG_TITLE_W 160", "#define BG_TITLE_H 120",+ "#define BG_RUN_X 102", "#define BG_RUN_W 218","extern const char ce_art_vars[CE_ART_NVARS][9];", "extern const uint16_t ce_palette[176];", "#endif"]open(os.path.join(outdir, "ce_art.h"), "w").write("\n".join(h) + "\n")total = sum(len(b) for b in blobs.values())diff --git a/games/balatro/src/game.c b/games/balatro/src/game.cindex c7c86644..8a3bd27e 100644--- a/games/balatro/src/game.c+++ b/games/balatro/src/game.c@@ -1112,7 +1112,7 @@ int shop_reroll(void) {}static void redeem(int v) {- R.vouchers |= 1u << v;+ R.vouchers |= (uint32_t)1 << v;switch (v) {case V_OVERSTOCK_NORM: case V_OVERSTOCK_PLUS:R.shop_jokers_max++;