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.

Merge the big games into the kit, for NumPlays with Enlarged Extra Apps

Mason363ac01d75bb403
diff --cc Makefile
index da9ffb49,ddfce6f9..a009550b
--- a/Makefile
+++ b/Makefile
@@@ -108,6 -116,8 +116,8 @@@ MODULES = $(foreach g,$(GAMES),$(B)/mod
# ------------------------------------------------------------------ generated glue
$(B)/gen/numplay.ld: games/games.json tools/gen_games.py $(foreach g,$(GAMES) $(OPTIONAL_GAMES),$(B)/modules/$(g).o)
+ # (and the big games' modules, which take minutes: only for the kit)
-$(B)/gen/numplay.ld: $(if $(filter kit,$(MAKECMDGOALS)),$(foreach g,$(XL_GAMES),$(B)/modules/$(g).o))
++$(B)/gen/numplay.ld: $(if $(filter kit kit-langs,$(MAKECMDGOALS)),$(foreach g,$(XL_GAMES),$(B)/modules/$(g).o))
$(PY) tools/gen_games.py games/games.json $(B)/modules $(B)/gen
$(B)/gen/shots_%.c: games/games.json tools/shots.py $$(SHOTS_$$*) | $(B)
@@@ -175,18 -184,8 +191,19 @@@ $(B)/%.nwa: $(KIT)/base.o $(B)/arm/aren
kit: $(KIT)/base.o $(B)/arm/arena.o $(KIT_GAMES) $(B)/NumPlay.nwa \
$(foreach v,$(VARIANTS),$(B)/variant/$(v)-name.o $(B)/variant/$(v)-icon.o)
$(PY) tools/kit.py games/games.json $(B) $(B)/site-kit --version $(VERSION) --variants "$(VARIANTS)" \
- --default "$(GAMES)" --upsilon "$(UPSILON_GAMES)" --app-space $(APP_SPACE) --ram $(CUSTOM_RAM) \
- --upsilon-ram $(UPSILON_RAM) --nwlink "$(NWLINK)" --langs "$(LANGS)"
+ --default "$(GAMES)" --upsilon "$(UPSILON_GAMES)" --app-space $(APP_SPACE) --xl-app-space $(XL_APP_SPACE) \
- --ram $(CUSTOM_RAM) --ram-limit $(RAM_LIMIT) --upsilon-ram $(UPSILON_RAM) --nwlink "$(NWLINK)"
++ --ram $(CUSTOM_RAM) --ram-limit $(RAM_LIMIT) --upsilon-ram $(UPSILON_RAM) --nwlink "$(NWLINK)" --langs "$(LANGS)"
+
- # ...and in French and Chinese, from each language's tree (make lang), in site-kit/<code>
++# ...and in French and Chinese, from each language's tree (make lang), in site-kit/<code> (without the big
++# games, which are in English: the website uses them in English NumPlays)
+kit-langs: kit
+ @for l in $(LANGS); do \
+ [ -d $(B)/lang/$$l ] || $(PY) tools/lang.py tree $$l $(B)/lang/$$l || exit 1; \
- $(MAKE) -C $(B)/lang/$$l kit NWLINK="$(NWLINK)" || exit 1; \
++ $(MAKE) -C $(B)/lang/$$l kit XL_GAMES= NWLINK="$(NWLINK)" || exit 1; \
+ rm -rf $(B)/site-kit/$$l && mkdir -p $(B)/site-kit/$$l && \
+ cp -R $(B)/lang/$$l/build/site-kit/kit.json $(B)/lang/$$l/build/site-kit/base.o.gz \
+ $(B)/lang/$$l/build/site-kit/arena.o.gz $(B)/lang/$$l/build/site-kit/games $(B)/site-kit/$$l/ || exit 1; \
+ done
check: nwa apps
@x=$$(cat $(B)/gen/arena_extra); \
diff --cc games/games.json
index 01acec85,481594f5..2136dde1
--- a/games/games.json
+++ b/games/games.json
@@@ -451,34 -451,351 +451,381 @@@
"app": "Sokoban.nwa",
"repo": "https://github.com/Mason363/NumPlay/tree/main/games/sokoban"
},
+ {
+ "id": "retrogo",
+ "title": "Retro-Go",
+ "tagline": "Game Boy, NES and Sega games",
+ "credit": "Based on Retro-Go by ducalex",
+ "top": "0xE84B39",
+ "bottom": "0x1E1430",
+ "accent": "0x3199DC",
+ "records": [
+ "retrogo.cfg",
+ "rg_*"
+ ],
+ "reset": [
+ "rg_*"
+ ],
+ "shots": [
+ "docs/shot.png"
+ ],
+ "app": "RetroGo.nwa",
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/retrogo",
+ "default": false,
+ "roms": true,
+ "systems": [
+ 1,
+ 2,
+ 3,
+ 4,
+ 5
+ ]
++ },
+ {
+ "id": "celeste",
+ "title": "Celeste",
+ "tagline": "Climb the mountain",
+ "credit": "Based on Celeste by Maddy Makes Games",
+ "top": "0x5865C8",
+ "bottom": "0x161A3A",
+ "accent": "0xFF5A6E",
+ "colors": 16,
+ "records": [
+ "celeste.sav",
+ "celeste_saves.py"
+ ],
+ "shots": [
+ "docs/forsaken.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/celeste",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "hollowknight",
+ "title": "Hollow Knight",
+ "tagline": "Explore Hallownest",
+ "credit": "Based on Hollow Knight by Team Cherry",
+ "top": "0x4C5E7E",
+ "bottom": "0x0B0F17",
+ "accent": "0xE8EEF5",
+ "colors": 16,
+ "heap": 20480,
+ "records": [
+ "hk1.sav",
+ "hk2.sav",
+ "hk3.sav",
+ "hk4.sav",
+ "hollowknight_saves.py"
+ ],
+ "shots": [
+ "docs/kingspass.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/hollowknight",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "undertale",
+ "title": "Undertale",
+ "tagline": "Fall into the Underground",
+ "credit": "Based on Undertale by Toby Fox",
+ "top": "0x3A3A46",
+ "bottom": "0x050506",
+ "accent": "0xE8241C",
+ "colors": 16,
+ "records": [
+ "undertale.sav",
+ "utresume.sav",
+ "utconfig.sav",
+ "undertale_saves.py"
+ ],
+ "reset": [
+ "undertale.sav",
+ "utresume.sav",
+ "undertale_saves.py"
+ ],
+ "shots": [
+ "docs/flowers.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/undertale",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "championisland",
+ "title": "Champion Island",
+ "tagline": "Seven sports, one island",
+ "credit": "Based on Google's Champion Island Games",
+ "top": "0x3FA9F5",
+ "bottom": "0x15507A",
+ "accent": "0xF5B83D",
+ "colors": 16,
+ "heap": 24576,
+ "records": [
+ "champion.sav",
+ "champion_saves.py"
+ ],
+ "shots": [
+ "docs/pingpong.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/championisland",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "finalearth2",
+ "title": "The Final Earth 2",
+ "tagline": "Build a city in space",
+ "credit": "Based on the game by Florian van Strien",
+ "top": "0x4B3B8F",
+ "bottom": "0x140F33",
+ "accent": "0x6EDC5A",
+ "colors": 16,
+ "records": [
+ "finalearth2.sav",
+ "fe2meta.dat",
+ "finalearth2_saves.py"
+ ],
+ "shots": [
+ "docs/city.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/finalearth2",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "numpowder",
+ "title": "NumPowder",
+ "tagline": "Sand, water, fire and more",
+ "credit": "Inspired by The Powder Toy",
+ "top": "0xC9A15A",
+ "bottom": "0x3B2A12",
+ "accent": "0x3C8DFF",
+ "colors": 16,
+ "heap": 53000,
+ "records": [
+ "numpowder.cfg",
+ "numpowder.sav",
+ "numpowder1.sav",
+ "numpowder2.sav",
+ "numpowder3.sav",
+ "numpowder4.sav",
+ "numpowder_saves.py"
+ ],
+ "reset": [
+ "numpowder.cfg",
+ "numpowder.sav",
+ "numpowder_saves.py"
+ ],
+ "shots": [
+ "docs/sand_water.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/numpowder",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "subway",
+ "title": "Subway Surfers",
+ "tagline": "Dodge the trains",
+ "credit": "Based on Subway Surfers by SYBO and Kiloo",
+ "top": "0x3A8FD8",
+ "bottom": "0x173A5E",
+ "accent": "0xFFC93C",
+ "colors": 16,
+ "heap": 101920,
+ "records": [
+ "subway.sav",
+ "subway_saves.py"
+ ],
+ "shots": [
+ "docs/run.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/subway",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "fnaf",
+ "title": "Five Nights at Freddy's",
+ "tagline": "Survive five nights",
+ "credit": "Based on the game by Scott Cawthon",
+ "top": "0x4A3A30",
+ "bottom": "0x0A0806",
+ "accent": "0xD8A93A",
+ "colors": 16,
+ "records": [
+ "fnaf.sav",
+ "fnafres.sav",
+ "fnaf_saves.py"
+ ],
+ "shots": [
+ "docs/office.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/fnaf",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "doom",
+ "title": "Doom",
+ "tagline": "Rip and tear",
+ "credit": "Based on Doom by id Software",
+ "top": "0x6B4A2E",
+ "bottom": "0x1A0F08",
+ "accent": "0xD8261C",
+ "colors": 16,
+ "heap": 20480,
+ "records": [
+ "doomsav0.dsg",
+ "doomsav1.dsg",
+ "doomsav2.dsg",
+ "doomsav3.dsg",
+ "doomsav4.dsg",
+ "doomsav5.dsg",
+ "doomres.sav",
+ "doom.cfg",
+ "doom_saves.py"
+ ],
+ "reset": [
+ "doomsav0.dsg",
+ "doomsav1.dsg",
+ "doomsav2.dsg",
+ "doomsav3.dsg",
+ "doomsav4.dsg",
+ "doomsav5.dsg",
+ "doomres.sav",
+ "doom_saves.py"
+ ],
+ "shots": [
+ "docs/hangar.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/doom",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "isaac",
+ "title": "The Binding of Isaac",
+ "tagline": "Cry through the basement",
+ "credit": "Based on the game by Edmund McMillen",
+ "top": "0x7A5A44",
+ "bottom": "0x23170F",
+ "accent": "0xE04848",
+ "colors": 16,
+ "records": [
+ "isaac.sav",
+ "isaacrun.sav",
+ "isaac_saves.py"
+ ],
+ "shots": [
+ "docs/basement.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/isaac",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "hillclimb",
+ "title": "Hill Climb Racing",
+ "tagline": "Drive up, don't flip",
+ "credit": "Based on Hill Climb Racing by Fingersoft",
+ "top": "0x5BBEF0",
+ "bottom": "0x2D5A1A",
+ "accent": "0xE53935",
+ "colors": 16,
+ "heap": 32768,
+ "records": [
+ "hillclimb.sav",
+ "hillclimb_saves.py"
+ ],
+ "shots": [
+ "docs/countryside.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/hillclimb",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "pvz",
+ "title": "Plants vs. Zombies",
+ "tagline": "Plant your lawn",
+ "credit": "Based on the game by PopCap Games",
+ "top": "0x6CC04A",
+ "bottom": "0x1F4A17",
+ "accent": "0xFFE040",
+ "colors": 16,
+ "records": [
+ "pvz.sav",
+ "pvzlevel.sav",
+ "pvz_saves.py"
+ ],
+ "shots": [
+ "docs/day.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/pvz",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "sonic",
+ "title": "Sonic the Hedgehog",
+ "tagline": "Run through six zones",
+ "credit": "Based on the game by Sonic Team",
+ "top": "0x2E6FE0",
+ "bottom": "0x0E2766",
+ "accent": "0xFFD000",
+ "colors": 16,
+ "records": [
+ "sonic.sav",
+ "sonic_saves.py"
+ ],
+ "shots": [
+ "docs/ghz.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/sonic",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "cookieclicker",
+ "title": "Cookie Clicker",
+ "tagline": "Bake billions of cookies",
+ "credit": "Based on Cookie Clicker by Orteil",
+ "top": "0x4E6E9E",
+ "bottom": "0x1A2438",
+ "accent": "0xD9A35A",
+ "colors": 16,
+ "records": [
+ "cookieclicker.sav",
+ "cookieclicker_saves.py"
+ ],
+ "shots": [
+ "docs/shot.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/cookieclicker",
+ "default": false,
+ "xl": true
+ },
+ {
+ "id": "leveldevil",
+ "title": "Level Devil",
+ "tagline": "Run to the door",
+ "credit": "Based on Level Devil by Unept",
+ "top": "0xF2A33C",
+ "bottom": "0x6E3A12",
+ "accent": "0xE8402A",
+ "colors": 16,
+ "records": [
+ "leveldevil.sav",
+ "leveldevil_saves.py"
+ ],
+ "shots": [
+ "docs/title.png"
+ ],
+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/leveldevil",
+ "default": false,
+ "xl": true
}
]
diff --cc tools/kit.py
index e50a7719,c7df9983..379c8439
--- a/tools/kit.py
+++ b/tools/kit.py
@@@ -89,10 -97,11 +97,12 @@@ def main()
ap.add_argument("--default", required=True)
ap.add_argument("--upsilon", default="")
ap.add_argument("--app-space", type=int, required=True)
+ ap.add_argument("--xl-app-space", type=int, required=True)
ap.add_argument("--ram", type=int, required=True)
+ ap.add_argument("--ram-limit", type=int, default=148928)
ap.add_argument("--upsilon-ram", type=int, required=True)
ap.add_argument("--nwlink", default="nwlink")
+ ap.add_argument("--langs", default="", help="the languages make kit-langs adds (site-kit/<code>)")
a = ap.parse_args()
B, O = a.build, a.out
manifest = json.load(open(a.manifest))
@@@ -148,28 -154,34 +158,34 @@@
games.append({
"id": i, "index": n, "title": g["title"], "tagline": g["tagline"], "credit": g.get("credit"),
"top": g["top"], "bottom": g["bottom"], "accent": g["accent"],
- "flash": flash, "ram": ram, "default": i in default, "upsilon": i in upsilon,
+ "flash": flash, "ram": ram, "heap": g.get("heap", 0), "default": i in default, "upsilon": i in upsilon,
- "roms": bool(g.get("roms")), "xl": bool(g.get("xl")),
+ "roms": bool(g.get("roms")), "systems": g.get("systems"), "xl": bool(g.get("xl")),
"bytes": os.path.getsize(os.path.join(O, "games", i + ".o.gz")),
- "icon": bool(icon), "thumb": os.path.exists(thumb)})
+ "icon": bool(icon), "thumb": os.path.exists(thumb), "preview": preview})
# ---- check: the default games, linked from the kit, are NumPlay.nwa on the calculator
- ld_script = os.path.join(tmp, "custom.ld")
- open(ld_script, "w").write(script["head"] + "".join(script["blocks"][i] for i in default) + script["tail"])
+ def link(ids, nwa):
+ ld_script = nwa[:-4] + ".ld"
+ open(ld_script, "w").write(script["head"] + "".join(script["blocks"][i] for i in ids) + script["tail"])
+ subprocess.run(["arm-none-eabi-ld"] + LINK + ["-T", ld_script, local["base.o"], local["arena.o"],
+ local["NumPlay-name.o"], local["NumPlay-icon.o"]] + [local[i] for i in ids] +
+ ["-o", nwa], check=True)
+ subprocess.run(["arm-none-eabi-strip", "--strip-unneeded", nwa], check=True)
+ # only what the installer gives may be left undefined (a game's weak `numplay_launcher`, say,
+ # must find the launcher's; a game's heap is in the arena, its malloc's the launcher's)
+ nm = subprocess.run(["arm-none-eabi-nm", "-u", nwa], capture_output=True, text=True, check=True).stdout
+ loose = [l.split()[-1] for l in nm.splitlines()
+ if not re.match(r"(eadk_|_heap_end$|_data_section_|_bss_section_)", l.split()[-1])
+ and l.split() not in (["w", "__sf"], ["w", "_printf_float"])] # (newlib's own weak hooks)
+ if loose:
+ sys.exit(f"kit: {ids[0] if len(ids) == 1 else 'NumPlay'} leaves undefined: {' '.join(loose)}")
nwa = os.path.join(tmp, "custom.nwa")
- subprocess.run(["arm-none-eabi-ld"] + LINK + ["-T", ld_script, local["base.o"], local["arena.o"],
- local["NumPlay-name.o"], local["NumPlay-icon.o"]] + [local[i] for i in default] +
- ["-o", nwa], check=True)
- subprocess.run(["arm-none-eabi-strip", "--strip-unneeded", nwa], check=True)
- # only what the installer gives may be left undefined (a game's weak `numplay_launcher`, say,
- # must find the launcher's)
- nm = subprocess.run(["arm-none-eabi-nm", "-u", nwa], capture_output=True, text=True, check=True).stdout
- loose = [l.split()[-1] for l in nm.splitlines()
- if not re.match(r"(eadk_|_heap_|_data_section_|_bss_section_|_sbrk$)", l.split()[-1])
- and l.split() not in (["w", "__sf"], ["w", "_printf_float"])] # (newlib's own weak hooks)
- if loose:
- sys.exit(f"kit: left undefined: {' '.join(loose)}")
- ram = 148928
+ link(default, nwa)
+ # a big game calls nothing in base.o but the launcher (KIT_API in the Makefile): linked alone with it
+ for g in games:
+ if g["xl"]:
+ link([g["id"]], os.path.join(tmp, f"xl-{g['id']}.nwa"))
+ ram = a.ram_limit
bins = []
for f in (nwa, os.path.join(B, "NumPlay.nwa")):
b = f + ".bin" if f == nwa else os.path.join(tmp, "make.bin")
@@@ -183,11 -195,18 +199,18 @@@
if not 0 <= runtime < 4096:
sys.exit(f"kit: installed_size says {installed_size(nwa)}, nwlink {len(bins[0])}")
base = len(bins[0]) - sum(g["flash"] for g in games if g["default"])
-
- kit = {"version": a.version, "appSpace": a.app_space, "ram": a.ram, "upsilonRam": a.upsilon_ram,
+ # NumPlay's own RAM before the arena (the installer's few bytes too), as the calculator lays it out
+ elf = os.path.join(tmp, "custom.elf")
+ subprocess.run([a.nwlink, "nwa-elf", nwa, elf, "--ram-start", "0x20000000", "--ram-length", str(ram)],
+ check=True, stdout=subprocess.DEVNULL)
+ nm = subprocess.run(["arm-none-eabi-nm", elf], capture_output=True, text=True, check=True).stdout
+ launcher_ram = next(int(l.split()[0], 16) for l in nm.splitlines() if l.split()[-1] == "np_arena") - 0x20000000
+
+ kit = {"version": a.version, "appSpace": a.app_space, "xlAppSpace": a.xl_app_space, "ram": a.ram,
+ "ramLimit": a.ram_limit, "upsilonRam": a.upsilon_ram, "launcherRam": launcher_ram,
"arena": int(re.search(r"\.space (\d+)", open(os.path.join(B, "gen", "arena.s")).read()).group(1)),
"base": base, "runtime": runtime, "numplay": len(bins[0]), "link": LINK, "variants": variants,
- "script": script, "games": games}
+ "langs": ["en"] + a.langs.split(), "script": script, "games": games}
json.dump(kit, open(os.path.join(O, "kit.json"), "w"), indent=1)
shutil.rmtree(tmp)
print(f"kit: {len(games)} games, NumPlay.nwa's {len(bins[0])} bytes linked again from {O}")