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.

1.6 KB
Raw Blame
#!/usr/bin/env python3
"""Turns games/games.json into make variables (order, screenshots).

A game with an "app" entry (its release file, e.g. "Snake.nwa") is in the
standard layout of games/numvisuals: its Makefile's `build`, `module` and
`sim-module` targets make output/<id>.nwa, module.o and sim-module.o, so the
top-level Makefile needs nothing else for it (STD_GAMES).

GAMES are the games of NumPlay.nwa; OPTIONAL_GAMES, those marked "default": false, are only
in the kit the customizer website links a NumPlay of your own from, and so are XL_GAMES, marked
"xl": true (not in OPTIONAL_GAMES): the big games, each a release file of its own too, whose
module is made from that .nwa, for a NumPlay on calculators with Enlarged Extra Apps (Makefile)."""
import json
import sys

games = json.load(open(sys.argv[1]))
print("# Generated by tools/games_mk.py from games/games.json")
print("GAMES := " + " ".join(g["id"] for g in games if g.get("default", True)))
print("OPTIONAL_GAMES := " + " ".join(g["id"] for g in games if not g.get("default", True) and not g.get("xl")))
print("XL_GAMES := " + " ".join(g["id"] for g in games if g.get("xl")))
for n, g in enumerate(games, 1):
    i = g["id"]
    print(f"INDEX_{i} := {n}")
    print(f"SHOTS_{i} := " + " ".join(f"games/{i}/{s}" for s in g["shots"]))
    print(f"SHOTS_REL_{i} := " + " ".join(g["shots"]))
    if g.get("colors"):
        print(f"COLORS_{i} := --colors {g['colors']}")
    if g.get("app"):
        print(f"NWA_{i} := {g['app']}")
        print(f"APPID_{g['app'][:-4]} := {i}")
print("STD_GAMES := " + " ".join(g["id"] for g in games if g.get("app")))