Skip to content

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.

Celeste: installs on calculator software 23.2 and 24 too: 144.6 KB of fixed RAM (the LZMA decoder's probabilities on the stack), under the 148928 bytes the oldest gives apps

Mason Chenc2f09e514497
diff --git a/games/celeste/Makefile b/games/celeste/Makefile
index 73714f8d..9f41c579 100644
--- a/games/celeste/Makefile
+++ b/games/celeste/Makefile
@@ -26,8 +26,10 @@ LDFLAGS += -Wl,--gc-sections -flinker-output=nolto-rel
.PHONY: build check clean host data test
build: $(BUILD_DIR)/celeste.nwa
+# the RAM the calculator gives apps (data + bss) depends on its software: 153676 bytes on 25.2, 149500 on 24.10,
+# 148928 on 23.2; checked against the least
check: $(BUILD_DIR)/celeste.nwa
- $(Q) $(NWLINK) nwa-bin --ram-length 153676 $< $(BUILD_DIR)/celeste.bin
+ $(Q) $(NWLINK) nwa-bin --ram-length 148928 $< $(BUILD_DIR)/celeste.bin
@echo "BIN $(BUILD_DIR)/celeste.bin: $$(wc -c < $(BUILD_DIR)/celeste.bin) bytes"
$(BUILD_DIR)/data.o: src/data.S src/data.bin | $(BUILD_DIR)
diff --git a/games/celeste/src/res.c b/games/celeste/src/res.c
index e32b72ae..e8802573 100644
--- a/games/celeste/src/res.c
+++ b/games/celeste/src/res.c
@@ -36,7 +36,7 @@ bool pal_opaque(uint16_t pal) {
/* ---------------------------------------------------------------- LZMA streams */
#define DICT_SIZE 9600 /* (tools/pack.py DICT: the strip, all of it) */
extern uint16_t g_strip[]; /* gfx.c: the ring buffer borrows the strip */
-static CLzmaProb probs[1984 + 768]; /* NUM_BASE_PROBS + LZMA_LIT_SIZE << (lc + lp) */
+#define NPROBS (1984 + 768) /* NUM_BASE_PROBS + LZMA_LIT_SIZE << (lc + lp) */
static void pack_info(uint16_t p, const uint8_t **data, uint32_t *comp, uint32_t *raw) {
const uint8_t *s = section(SEC_PACKS) + 4 + 12 * p;
@@ -51,12 +51,14 @@ static void lz_run(uint16_t p, uint32_t from, uint32_t to, Sink sink, void *ctx,
uint32_t comp, raw;
pack_info(p, &src, &comp, &raw);
if (to > raw) to = raw;
+ /* (its probabilities on the stack, 5.5 KB of the calculator's 32: older calculator software gives apps less RAM) */
+ CLzmaProb probs[NPROBS];
CLzmaDec dec;
memset(&dec, 0, sizeof dec);
dec.prop.lc = 0, dec.prop.lp = 0, dec.prop.pb = 0, dec.prop.dicSize = DICT_SIZE;
dec.probs = probs;
dec.probs_1664 = probs + 1664;
- dec.numProbs = 1984 + 768;
+ dec.numProbs = NPROBS;
dec.dic = (Byte *)(void *)g_strip;
dec.dicBufSize = DICT_SIZE;
LzmaDec_Init(&dec);