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.

Dune: built, tested and released like the other big games

Mason363165598aa5269
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f3764a16..6a6db4b7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -73,6 +73,7 @@ jobs:
make -C games/cookieclicker host test
make -C games/jetpackjoyride host test
make -C games/donkeykong host test
+ make -C games/dune host test
make -C games/invaders host test
make -C games/sudoku host test
make -C games/uttt host test
diff --git a/Makefile b/Makefile
index 790c435d..6f0faffb 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ RAM_LIMIT = 148928
# custom builds of Epsilon 25.2's source give apps less: 133652 bytes; every game fits there too, in NumPlay and on
# its own (their big buffers are on the stack, 32 KB apart from that RAM, or in the RAM the software has left)
CUSTOM_RAM = 133652
-BIG_APPS = Celeste HollowKnight Undertale ChampionIsland FinalEarth2 NumPowder NumBlocks NumDrive SubwaySurfers FiveNightsAtFreddys Doom BindingOfIsaac HillClimbRacing PlantsVsZombies SonicTheHedgehog CookieClicker LevelDevil JetpackJoyride StickmanHook DonkeyKong
+BIG_APPS = Celeste HollowKnight Undertale ChampionIsland FinalEarth2 NumPowder NumBlocks NumDrive SubwaySurfers FiveNightsAtFreddys Doom BindingOfIsaac HillClimbRacing PlantsVsZombies SonicTheHedgehog CookieClicker LevelDevil JetpackJoyride StickmanHook DonkeyKong Dune
# the calculator's space for installed apps (0x90200000 to 0x903F0000 in its flash)
APP_SPACE = 2031616
# Upsilon, the N0110 and N0115's custom software, gives .nwa apps less RAM: NumPlay-Upsilon.nwa has
@@ -253,6 +253,7 @@ apps: | $(B)
$(MAKE) -C games/jetpackjoyride build NWLINK="$(NWLINK)"
$(MAKE) -C games/stickmanhook build NWLINK="$(NWLINK)"
$(MAKE) -C games/donkeykong build NWLINK="$(NWLINK)"
+ $(MAKE) -C games/dune build NWLINK="$(NWLINK)"
cd games/tetris/tetris && NWLINK="$(NWLINK)" $(CARGO) build --release --quiet
cp $(word 1,$(subst :, ,$(APP_numdash))) $(B)/apps/$(word 2,$(subst :, ,$(APP_numdash)))
cp $(word 1,$(subst :, ,$(APP_crossyroad))) $(B)/apps/$(word 2,$(subst :, ,$(APP_crossyroad)))
@@ -281,6 +282,7 @@ apps: | $(B)
cp $(word 1,$(subst :, ,$(APP_jetpackjoyride))) $(B)/apps/$(word 2,$(subst :, ,$(APP_jetpackjoyride)))
cp $(word 1,$(subst :, ,$(APP_stickmanhook))) $(B)/apps/$(word 2,$(subst :, ,$(APP_stickmanhook)))
cp $(word 1,$(subst :, ,$(APP_donkeykong))) $(B)/apps/$(word 2,$(subst :, ,$(APP_donkeykong)))
+ cp $(word 1,$(subst :, ,$(APP_dune))) $(B)/apps/$(word 2,$(subst :, ,$(APP_dune)))
arm-none-eabi-strip --strip-unneeded $(B)/apps/Tetris.nwa
STD_APPS = $(foreach g,$(STD_GAMES),$(B)/apps/$(NWA_$(g)))
@@ -289,17 +291,6 @@ $(STD_APPS): $(B)/apps/%.nwa: FORCE | $(B)
$(MAKE) --no-print-directory -C games/$(APPID_$*) build NWLINK="$(NWLINK)"
cp games/$(APPID_$*)/output/$(APPID_$*).nwa $@
-# Dune is published as its own app.
-.PHONY: check-dune
-apps: $(B)/apps/Dune.nwa
-$(B)/apps/Dune.nwa: FORCE | $(B)
- $(MAKE) --no-print-directory -C games/dune build NWLINK="$(NWLINK)"
- mkdir -p $(B)/apps
- cp games/dune/output/dune.nwa $@
-check: check-dune
-check-dune: $(B)/apps/Dune.nwa
- $(NWLINK) nwa-bin $< $(B)/apps/Dune.bin --ram-length $(UPSILON_RAM)
-
# ------------------------------------------------------------------ simulator
SIM_numdash = games/numdash/build/sim-module.o
SIM_crossyroad = games/crossyroad/output/sim-module.o
diff --git a/games/dune/Makefile b/games/dune/Makefile
index c95e6672..197eecf0 100644
--- a/games/dune/Makefile
+++ b/games/dune/Makefile
@@ -13,7 +13,7 @@ NWLINK ?= npx --yes -- [email protected]
BUILD_DIR = output
SRC = src/main.c src/game.c src/draw.c src/save.c src/art.c src/plat_eadk.c
-HEADERS = $(wildcard src/*.h) ../common/epsilon_app.h ../common/epsilon_files.h ../common/np_lz.h
+HEADERS = $(wildcard src/*.h) ../common/epsilon_app.h ../common/epsilon_files.h
CFLAGS = -std=gnu11 $(shell $(NWLINK) eadk-cflags-device) -DPLATFORM_DEVICE=1
CFLAGS += -Os -Wall -Wextra -Wno-unused-parameter -fno-math-errno -fsingle-precision-constant
diff --git a/games/dune/src/save.c b/games/dune/src/save.c
index f73c2ede..84c7bac5 100644
--- a/games/dune/src/save.c
+++ b/games/dune/src/save.c
@@ -1,8 +1,7 @@
-/* The save (save.h): a packed file with a magic, a version, its size and a checksum; anything else (a file
+/* The save (save.h): a bytes file with a magic, a version, its size and a checksum; anything else (a file
* from another version, damaged, cut short) is not read: the copy in the Python script is tried, then a fresh
* start. */
#include <string.h>
-#include "../../common/np_lz.h"
#include "plat.h"
#include "save.h"
@@ -34,13 +33,12 @@ bool dn_file_ok(const dn_file *f, dn_run *scratch) {
static const char head[] = "# Dune keeps a copy of your best, your coins and what you bought\n"
"# here, so that installing it again doesn't erase them.\n";
static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-static uint8_t packed[NP_LZ_BOUND(sizeof(dn_file))];
-static uint16_t table[NP_LZ_HASH];
-static uint8_t copy[1 + sizeof head + 2 + sizeof DN_SAVE_NAME + 1 + (NP_LZ_BOUND(sizeof(dn_file)) + 2) / 3 * 4 + 2];
+static uint8_t copy[1 + sizeof head + 2 + sizeof DN_SAVE_NAME + 1 + (sizeof(dn_file) + 2) / 3 * 4 + 2];
-/* the copy: the file packed (np_lz), in base 64, in a comment line of a script */
+/* the copy: the file in base 64, in a comment line of a script */
static bool copy_write(const dn_file *f) {
- uint32_t len = np_lz_pack((const uint8_t *)f, sizeof *f, packed, table), nl = sizeof DN_SAVE_NAME - 1;
+ const uint8_t *bytes = (const uint8_t *)f;
+ uint32_t len = sizeof *f, nl = sizeof DN_SAVE_NAME - 1;
uint8_t *p = copy;
*p++ = 0; /* (a script's first byte: not imported) */
memcpy(p, head, sizeof head - 1), p += sizeof head - 1;
@@ -48,7 +46,7 @@ static bool copy_write(const dn_file *f) {
memcpy(p, DN_SAVE_NAME, nl), p += nl;
*p++ = ':';
for (uint32_t i = 0; i < len; i += 3, p += 4) {
- uint32_t left = len - i, v = (uint32_t)packed[i] << 16 | (left > 1 ? (uint32_t)packed[i + 1] << 8 : 0) | (left > 2 ? packed[i + 2] : 0);
+ uint32_t left = len - i, v = (uint32_t)bytes[i] << 16 | (left > 1 ? (uint32_t)bytes[i + 1] << 8 : 0) | (left > 2 ? bytes[i + 2] : 0);
p[0] = (uint8_t)b64[v >> 18 & 63];
p[1] = (uint8_t)b64[v >> 12 & 63];
p[2] = left > 1 ? (uint8_t)b64[v >> 6 & 63] : '=';
@@ -73,17 +71,18 @@ static bool copy_read(dn_file *f) {
const uint8_t *l = c + i + 3 + nl;
uint32_t m = 0;
while (l + m < c + n && l[m] != '\n' && l[m]) m++;
- if (m % 4 || m / 4 * 3 > sizeof packed) return false;
+ if (m != (sizeof *f + 2) / 3 * 4) return false;
+ uint8_t *bytes = (uint8_t *)f;
uint32_t o = 0;
for (uint32_t k = 0; k < m; k += 4) {
int v0 = b64v(l[k]), v1 = b64v(l[k + 1]), v2 = l[k + 2] == '=' ? 0 : b64v(l[k + 2]), v3 = l[k + 3] == '=' ? 0 : b64v(l[k + 3]);
if (v0 < 0 || v1 < 0 || v2 < 0 || v3 < 0) return false;
uint32_t w = (uint32_t)(v0 << 18 | v1 << 12 | v2 << 6 | v3);
- packed[o++] = (uint8_t)(w >> 16);
- if (l[k + 2] != '=') packed[o++] = (uint8_t)(w >> 8);
- if (l[k + 3] != '=') packed[o++] = (uint8_t)w;
+ if (o < sizeof *f) bytes[o++] = (uint8_t)(w >> 16);
+ if (o < sizeof *f) bytes[o++] = (uint8_t)(w >> 8);
+ if (o < sizeof *f) bytes[o++] = (uint8_t)w;
}
- return np_lz_unpack(packed, o, (uint8_t *)f, sizeof *f) == (int32_t)sizeof *f;
+ return true;
}
return false;
}
diff --git a/tests/test_games.py b/tests/test_games.py
index 9f5357c1..65dd601b 100644
--- a/tests/test_games.py
+++ b/tests/test_games.py
@@ -230,6 +230,9 @@ GAMES = {
# time, from the copy, it opens paused: Back, a second more, paused again, quit with On/Off
"donkeykong": ("DonkeyKong.nwa", "donkeykong.sav", presses((1500, "ok"), (2500, "ok"), (3600, "back")), 5000,
presses((1500, "back"), (2700, "back")), 4000),
+ # the title, Play, the first press (the guide goes) and the ball rolls; Home keeps the run. Next time, from the
+ # copy, it opens paused: Back, and it rolls on
+ "dune": ("Dune.nwa", "dune.sav", presses((1500, "ok"), (2600, "ok")), 5000, presses((1500, "back")), 3500),
# a level, its message, then play; then back to the level select
"portal": ("PortalReturns.nwa", "portal.sav",
presses((1500, "ok"), (2500, "ok"), (3500, "ok")) + every(4000, 7000, 400, "right", 300), 8000,
@@ -274,7 +277,7 @@ COPIES = {"championisland": "champion_saves.py", "numblocks": "numblocks_saves.p
"hillclimb": "hillclimb_saves.py", "pvz": "pvz_saves.py", "sonic": "sonic_saves.py",
"cookieclicker": "cookieclicker_saves.py", "leveldevil": "leveldevil_saves.py",
"jetpackjoyride": "jetpackjoyride_saves.py", "stickmanhook": "stickmanhook_saves.py",
- "donkeykong": "donkeykong_saves.py"}
+ "donkeykong": "donkeykong_saves.py", "dune": "dune_saves.py"}
def dk_frames(v):
@@ -408,6 +411,9 @@ CHECKS = {
# a game kept ("DKG1", the game at 23, one game played) a second in; after the reinstall, from the copy, it goes on
"donkeykong": (lambda v: v[:4] == b"DKG1" and v[23] == 1 and v[12] == 1 and dk_frames(v) >= 30,
lambda v: v[:4] == b"DKG1" and v[23] == 1 and v[12] == 1 and dk_frames(v) >= 90),
+ # a run kept ("DUNE", has_run at 27, the run's frames at 328); after the reinstall, from the copy, it goes on
+ "dune": (lambda v: len(v) == 1548 and v[:4] == b"DUNE" and v[27] == 1 and struct.unpack_from("<I", v, 328)[0] >= 200,
+ lambda v: len(v) == 1548 and v[:4] == b"DUNE" and v[27] == 1 and struct.unpack_from("<I", v, 328)[0] >= 300),
"breakout": (lambda v: len(v) == 12 and v[:2] == b"B\2" and v[4] == 1 and struct.unpack_from("<I", v, 8)[0] >= 10,
lambda v: v[4] == 0 and struct.unpack_from("<I", v, 8)[0] >= 1), # best kept, shake off
# Air Hockey and the easy computer chosen; then the normal computer and Tanks, the tallies kept
diff --git a/tools/release.py b/tools/release.py
index 90ee0e05..04916e25 100644
--- a/tools/release.py
+++ b/tools/release.py
@@ -42,7 +42,7 @@ ALONE = {
"jetpackjoyride": ("Jetpack Joyride", "Barry's run through the lab, with five vehicles and the Final Spin"),
"stickmanhook": ("Stickman Hook", "swing from hook to hook: 39 levels made by hand, then endless ones"),
"donkeykong": ("Donkey Kong", "the 1981 arcade game: barrels, pies, elevators and rivets, up to Pauline"),
- "dune": ("Dune", "Mountains and seven cosmetic balls with an English interface, adapted by Bobydeluxe; installed separately"),
+ "dune": ("Dune", "roll down the dunes and fly over the line, with the shop's 26 balls and 7 landscapes"),
}
VARIANTS = [
("NumPlay-Invisible.nwa", "The same app, hidden: a blank icon with no name"),