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.

Hill Climb Racing: in the releases and tests, host checks

Mason3635c69aef0e82d
diff --git a/Makefile b/Makefile
index 5c2e790c..1bbd8884 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
+BIG_APPS = Celeste HollowKnight Undertale ChampionIsland FinalEarth2 NumPowder NumBlocks NumDrive SubwaySurfers FiveNightsAtFreddys Doom BindingOfIsaac HillClimbRacing
# 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
@@ -208,6 +208,7 @@ APP_hollowknight = games/hollowknight/output/hollowknight.nwa:HollowKnight.nwa
APP_undertale = games/undertale/output/undertale.nwa:Undertale.nwa
APP_subway = games/subway/output/subway.nwa:SubwaySurfers.nwa
APP_fnaf = games/fnaf/output/fnaf.nwa:FiveNightsAtFreddys.nwa
+APP_hillclimb = games/hillclimb/output/hillclimb.nwa:HillClimbRacing.nwa
APP_finalearth2 = games/finalearth2/output/finalearth2.nwa:FinalEarth2.nwa
APP_numpowder = games/numpowder/output/numpowder.nwa:NumPowder.nwa
APP_doom = games/doom/output/doom.nwa:Doom.nwa
@@ -228,6 +229,7 @@ apps: | $(B)
$(MAKE) -C games/undertale build NWLINK="$(NWLINK)"
$(MAKE) -C games/subway build NWLINK="$(NWLINK)"
$(MAKE) -C games/fnaf build NWLINK="$(NWLINK)"
+ $(MAKE) -C games/hillclimb build NWLINK="$(NWLINK)"
$(MAKE) -C games/finalearth2 build NWLINK="$(NWLINK)"
$(MAKE) -C games/numpowder build NWLINK="$(NWLINK)"
$(MAKE) -C games/doom build NWLINK="$(NWLINK)"
@@ -248,6 +250,7 @@ apps: | $(B)
cp $(word 1,$(subst :, ,$(APP_undertale))) $(B)/apps/$(word 2,$(subst :, ,$(APP_undertale)))
cp $(word 1,$(subst :, ,$(APP_subway))) $(B)/apps/$(word 2,$(subst :, ,$(APP_subway)))
cp $(word 1,$(subst :, ,$(APP_fnaf))) $(B)/apps/$(word 2,$(subst :, ,$(APP_fnaf)))
+ cp $(word 1,$(subst :, ,$(APP_hillclimb))) $(B)/apps/$(word 2,$(subst :, ,$(APP_hillclimb)))
cp $(word 1,$(subst :, ,$(APP_finalearth2))) $(B)/apps/$(word 2,$(subst :, ,$(APP_finalearth2)))
cp $(word 1,$(subst :, ,$(APP_numpowder))) $(B)/apps/$(word 2,$(subst :, ,$(APP_numpowder)))
cp $(word 1,$(subst :, ,$(APP_doom))) $(B)/apps/$(word 2,$(subst :, ,$(APP_doom)))
@@ -309,6 +312,7 @@ clean:
-$(MAKE) -C games/undertale clean
-$(MAKE) -C games/subway clean
-$(MAKE) -C games/fnaf clean
+ -$(MAKE) -C games/hillclimb clean
-$(MAKE) -C games/finalearth2 clean
-$(MAKE) -C games/numpowder clean
-$(MAKE) -C games/doom clean
diff --git a/games/hillclimb/src/run.c b/games/hillclimb/src/run.c
index 50b7e633..d81ca0b5 100644
--- a/games/hillclimb/src/run.c
+++ b/games/hillclimb/src/run.c
@@ -364,13 +364,13 @@ static void draw_bridges(void) {
float px = e ? b1 : b0, py = stage_floor(px);
gfx_tube(scr_x(px), scr_y(py - 0.3f), scr_x(px), scr_y(py + 1.3f), 0.12f * s, rgb565(0x6B4423), 255);
}
- int n = (int)((b1 - b0) / 0.55f);
+ int n = (int)((b1 - b0) / 0.8f);
float lx = 0, ly = 0;
for (int i = 0; i <= n; i++) {
float px = b0 + (b1 - b0) * (float)i / (float)n, py = stage_floor(px);
float a = atan2f(stage_floor(px + 0.1f) - stage_floor(px - 0.1f), 0.2f);
float sx = scr_x(px), sy = scr_y(py - 0.14f);
- gfx_image(IMG_PLANK, sx, sy, s / img(IMG_PLANK)->ppm4 * 4.0f * 0.5f, a, 255);
+ gfx_image(IMG_PLANK, sx, sy, s / img(IMG_PLANK)->ppm4 * 4.0f * 0.8f, a, 255);
float rx = scr_x(px), ry = scr_y(py + 1.0f);
if (i) gfx_tube(lx, ly, rx, ry, 0.035f * s, rgb565(0x8A6A3A), 255);
lx = rx, ly = ry;
diff --git a/games/hillclimb/src/stage.c b/games/hillclimb/src/stage.c
index 3ca352a0..4cda6a74 100644
--- a/games/hillclimb/src/stage.c
+++ b/games/hillclimb/src/stage.c
@@ -143,7 +143,7 @@ float stage_ground(float x) {
if (!stage_bridge(x, &x0, &x1)) return h;
float t = (x - x0) / (x1 - x0), b = bridge_y(x, x0, x1) - 0.4f;
if (h > b) h = b;
- return h - 9.0f * powf(sinf(3.14159265f * t), 0.35f);
+ return h - 4.5f * powf(sinf(3.14159265f * t), 0.35f);
}
/* ------------------------------------------------------------------ ceilings */
diff --git a/games/hillclimb/tests/check.py b/games/hillclimb/tests/check.py
new file mode 100644
index 00000000..2efcea88
--- /dev/null
+++ b/games/hillclimb/tests/check.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python3
+"""Checks of Hill Climb Racing on a computer (make test): the host build, with AddressSanitizer and UBSan, through
+the menus, buying, every stage with every vehicle, the ends of a run and the saves.
+
+ python3 tests/check.py build/play"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+
+PLAY = sys.argv[1] if len(sys.argv) > 1 else "build/play"
+ENV = dict(os.environ, ASAN_OPTIONS="detect_leaks=0", UBSAN_OPTIONS="halt_on_error=1:print_stacktrace=1")
+failures = []
+STAGES = ["Countryside", "Desert", "Arctic", "Highway", "Cave", "Moon", "Mars", "Alien Planet", "Arctic Cave", "Forest"]
+VEHICLES = ["Hill Climber", "Motocross Bike", "Monster Truck", "Quad Bike", "Race Car", "Rally Car", "Dune Buggy", "Tank"]
+MODE_RUN, MODE_END = 4, 6
+
+
+def run(args, saves, what):
+ p = subprocess.run([PLAY, "--saves", saves, "--out", os.path.join(saves, "shots")] + args, capture_output=True,
+ text=True, env=ENV, timeout=900)
+ if p.returncode or "runtime error" in p.stderr or "AddressSanitizer" in p.stderr:
+ failures.append(f"{what}: crashed or a sanitizer error\n{p.stderr[-2000:]}")
+ return None
+ m = re.search(r"END mode (\d+) dist (-?\d+) coins (\d+) total (\d+) over (\d) end (\d) level (\d+) flips (\d+) "
+ r"saved (\d+) running (\d)", p.stdout)
+ if not m:
+ failures.append(f"{what}: no end state\n{p.stdout[-500:]}")
+ return None
+ k = ["mode", "dist", "coins", "total", "over", "end", "level", "flips", "saved", "running"]
+ return dict(zip(k, map(int, m.groups())))
+
+
+def check(cond, what):
+ if not cond:
+ failures.append(what)
+ return cond
+
+
+def fresh():
+ return tempfile.mkdtemp(prefix="hillclimb_check_")
+
+
+def main():
+ # the menus: title, garage, stage, how to drive, then the run; Home there keeps the run's coins and quits
+ d = fresh()
+ keys = "30:ok,70:ok,110:ok,150:ok,170-900:right,950:home"
+ s = run(["--frames", "1000", "--keys", keys], d, "menus")
+ if s and check(s["running"] == 0, "Home did not quit"):
+ check(s["saved"] > 0 and s["saved"] == s["total"], f"the run's coins were not kept on Home: {s}")
+ check(os.path.exists(os.path.join(d, "hillclimb.sav")), "no hillclimb.sav")
+ copy = open(os.path.join(d, "hillclimb_saves.py"), "rb").read() if os.path.exists(
+ os.path.join(d, "hillclimb_saves.py")) else b""
+ check(b"#>hillclimb.sav:" in copy, "hillclimb_saves.py does not hold the save")
+ # installing apps again erases everything but scripts: the save comes back from the copy
+ os.remove(os.path.join(d, "hillclimb.sav"))
+ s2 = run(["--frames", "60", "--keys", "50:home"], d, "the save from its copy")
+ if s2:
+ check(s2["saved"] == s["saved"], f"the coins did not come back from hillclimb_saves.py: {s2['saved']}")
+ shutil.rmtree(d, ignore_errors=True)
+
+ # buying: with 10,000 coins, the Hill Climber's engine to level 2 (4,000), then its suspension (4,000)
+ d = fresh()
+ keys = "30:ok,70:down,90:ok,110:right,130:ok,150:right,170:ok,200:home"
+ s = run(["--frames", "260", "--coins", "10000", "--keys", keys], d, "buying upgrades")
+ if s:
+ check(s["saved"] == 2000, f"two upgrades of 4,000 should leave 2,000 coins, not {s['saved']}")
+ shutil.rmtree(d, ignore_errors=True)
+
+ # every stage with every vehicle, a player driving: no crash, and it gets somewhere
+ for st in range(len(STAGES)):
+ for v in range(len(VEHICLES)):
+ d = fresh()
+ s = run(["--run", f"{st},{v}", "--levels", "6,6,6,6", "--auto", "--frames", "2400"], d,
+ f"{STAGES[st]} with the {VEHICLES[v]}")
+ if s:
+ check(s["dist"] > 60, f"{STAGES[st]} with the {VEHICLES[v]}: only {s['dist']} m")
+ shutil.rmtree(d, ignore_errors=True)
+
+ # the ends of a run: Bill's neck (the bike flipped on the Moon, gas held) and an empty tank (reversing)
+ d = fresh()
+ s = run(["--run", "5,1", "--keys", "0-1500:right", "--frames", "1500"], d, "driver down")
+ if s:
+ check(s["mode"] == MODE_END and s["end"] == 0, f"the bike held at full gas on the Moon did not go down: {s}")
+ shutil.rmtree(d, ignore_errors=True)
+ d = fresh()
+ s = run(["--run", "0,0", "--keys", "0-3200:left", "--frames", "3200"], d, "out of fuel")
+ if s:
+ check(s["mode"] == MODE_END and s["end"] == 1, f"reversing into the wall did not run out of fuel: {s}")
+ shutil.rmtree(d, ignore_errors=True)
+
+ # a long run: levels reached, coins collected, the best kept
+ d = fresh()
+ s = run(["--run", "0,0", "--levels", "10,10,10,8", "--auto", "--frames", "9000"], d, "a long run")
+ if s:
+ check(s["level"] >= 2 and s["coins"] > 1000, f"a long run on the Countryside: {s}")
+ shutil.rmtree(d, ignore_errors=True)
+
+ for f in failures:
+ print("FAIL", f)
+ print("ok" if not failures else f"{len(failures)} failures")
+ sys.exit(1 if failures else 0)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/games/hillclimb/tests/play.c b/games/hillclimb/tests/play.c
index 03644c10..1974c65c 100644
--- a/games/hillclimb/tests/play.c
+++ b/games/hillclimb/tests/play.c
@@ -58,7 +58,8 @@ static uint32_t autopilot(void) {
if (d < -0.35f) return K_RIGHT;
return 0;
}
- if (d > 0.75f) return 0; /* rearing up: ease off */
+ if (d > 0.6f) return K_LEFT; /* rearing up: a touch of brake brings the nose down */
+ if (d > 0.3f && c->ch.w > 0.6f) return 0; /* coming up fast: ease off */
if (car_speed(c) < 0.3f && run.fuel <= 0) return 0;
return K_RIGHT;
}
@@ -88,7 +89,18 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[i], "--coins")) coins = atol(argv[++i]);
else if (!strcmp(argv[i], "--auto")) autop = true;
else if (!strcmp(argv[i], "--trace")) trace = atoi(argv[++i]);
- else if (!strcmp(argv[i], "--slopes")) { /* the steepest slope of each 100 m of a stage, in degrees */
+ else if (!strcmp(argv[i], "--things")) { /* where the first bridges, tunnels and fuel cans of a stage are */
+ stage_set(atoi(argv[++i]));
+ float b0, b1, c, f;
+ for (float x = 0; x < 2000; x += 1) {
+ if (stage_bridge(x, &b0, &b1)) printf("bridge %.0f to %.0f\n", b0, b1), x = b1;
+ }
+ bool in = false;
+ for (float x = 0; x < 2000; x += 1)
+ if (stage_ceiling(x, &c) != in) in = !in, printf("ceiling %s at %.0f\n", in ? "starts" : "ends", x);
+ for (int k = 0; k < 8 && stage_fuel(k, &f); k++) printf("fuel %.0f\n", f);
+ return 0;
+ } else if (!strcmp(argv[i], "--slopes")) { /* the steepest slope of each 100 m of a stage, in degrees */
stage_set(atoi(argv[++i]));
for (int s = 0; s < 4000; s += 100) {
float most = 0, lo = 1e9f, hi = -1e9f;
diff --git a/tests/test_games.py b/tests/test_games.py
index aa678f38..e2f5ce05 100644
--- a/tests/test_games.py
+++ b/tests/test_games.py
@@ -145,6 +145,11 @@ GAMES = {
# paused: Back, and the night goes on
"fnaf": ("FiveNightsAtFreddys.nwa", "fnafres.sav", presses((1500, "down"), (1800, "ok")), 9000,
presses((1500, "back")), 5000),
+ # the title, the garage, the stage, how to drive, then the Hill Climber up the Countryside: Home keeps the run's
+ # coins and best; next time straight from the stage to a second run
+ "hillclimb": ("HillClimbRacing.nwa", "hillclimb.sav",
+ presses((1500, "ok"), (2500, "ok"), (3500, "ok"), (4500, "ok"), (5000, "right", 6000)), 12000,
+ presses((1500, "ok"), (2500, "ok"), (3500, "ok"), (4000, "right", 2500)), 7500),
# the intro, then OK draws for a while (the autosave on Home); next time it comes back and more is drawn
"numpowder": ("NumPowder.nwa", "numpowder.sav", presses((2000, "ok"), (3000, "ok", 1500)), 6000,
presses((2000, "ok"), (2500, "right", 600), (3200, "ok", 800)), 5000),
@@ -191,7 +196,8 @@ SEEDS = {
COPIES = {"championisland": "champion_saves.py", "numblocks": "numblocks_saves.py", "celeste": "celeste_saves.py",
"hollowknight": "hollowknight_saves.py", "finalearth2": "finalearth2_saves.py",
"numpowder": "numpowder_saves.py", "undertale": "undertale_saves.py", "subway": "subway_saves.py",
- "fnaf": "fnaf_saves.py", "doom": "doom_saves.py", "isaac": "isaac_saves.py"}
+ "fnaf": "fnaf_saves.py", "doom": "doom_saves.py", "isaac": "isaac_saves.py",
+ "hillclimb": "hillclimb_saves.py"}
CHECKS = {
# the island remembers where Lucky was; after the reinstall, from the copy
"championisland": (lambda v: v[:3] == b"CI1" and b"PLAYER_LOC" in v,) * 2,
@@ -218,6 +224,11 @@ CHECKS = {
lambda v: v[:4] == b"ISR1" and struct.unpack_from("<I", v, 16)[0] > 80),
# a simulation saved ("NPWD"); after the reinstall, from the copy, it goes on and is saved again
"numpowder": (lambda v: v[:4] == b"NPWD",) * 2,
+ # a run banked ("HCR1", runs at 212) with a best on the Countryside (at 48); after the reinstall, from the copy,
+ # a second one
+ "hillclimb": (lambda v: v[:4] == b"HCR1" and struct.unpack_from("<I", v, 212)[0] == 1
+ and struct.unpack_from("<H", v, 48)[0] > 0,
+ lambda v: v[:4] == b"HCR1" and struct.unpack_from("<I", v, 212)[0] == 2),
# a game saved ("HKSV", then the play time at 152); after the reinstall, from the copy, it goes on
"hollowknight": (lambda v: v[:4] == b"HKSV" and struct.unpack_from("<f", v, 152)[0] > 0,
lambda v: v[:4] == b"HKSV" and struct.unpack_from("<f", v, 152)[0] > 10),
diff --git a/tools/release.py b/tools/release.py
index 6f0a1b95..de00efaf 100644
--- a/tools/release.py
+++ b/tools/release.py
@@ -35,6 +35,8 @@ ALONE = {
"calculator with NumPlay: install it on its own"),
"fnaf": ("Five Nights at Freddy's", "survive five nights at Freddy Fazbear's Pizza, then the 6th and the Custom "
"Night, with the game's own pictures. Too big to share the calculator with NumPlay: install it on its own"),
+ "hillclimb": ("Hill Climb Racing", "Newton Bill's ride up the hills: ten stages, eight vehicles and their "
+ "upgrades. Too big to share the calculator with NumPlay: install it on its own"),
"championisland": ("Champion Island", "the Doodle Champion Island Games. Too big to share the calculator with "
"NumPlay: install it on its own"),
"numpowder": ("NumPowder", "The Powder Toy on the calculator: sand, water, fire, acid, electricity and nearly 200 "