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.

NumPlay Studio: Celeste, Hollow Knight and Champion Island on their own

Mason3636e445c18b470
diff --git a/Makefile b/Makefile
index a009550b..32023397 100644
--- a/Makefile
+++ b/Makefile
@@ -192,7 +192,8 @@ 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) --xl-app-space $(XL_APP_SPACE) \
- --ram $(CUSTOM_RAM) --ram-limit $(RAM_LIMIT) --upsilon-ram $(UPSILON_RAM) --nwlink "$(NWLINK)" --langs "$(LANGS)"
+ --ram $(CUSTOM_RAM) --ram-limit $(RAM_LIMIT) --upsilon-ram $(UPSILON_RAM) --nwlink "$(NWLINK)" --langs "$(LANGS)" \
+ --alone "$(foreach g,$(XL_GAMES),$(g)=$(APP_$(g)))"
# ...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)
diff --git a/customize/app.css b/customize/app.css
index ce37dbab..f0cdc83a 100644
--- a/customize/app.css
+++ b/customize/app.css
@@ -217,6 +217,7 @@ body.dragging .drop-hint { opacity: 1; }
.chip.lang span { font-size: 13px; font-weight: 750; min-width: 22px; text-align: center; }
.chip .caret { color: var(--mute); transition: transform var(--t) var(--ease); }
.chip[aria-expanded="true"] .caret { transform: rotate(180deg); }
+.chip:disabled { opacity: 0.35; cursor: default; box-shadow: none; } /* (a game on its own: its own icon and language) */
.chip:hover { transform: translateY(-2px); }
.install {
position: relative; border: 0; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
diff --git a/customize/app.js b/customize/app.js
index 6c8e9985..08c78bd2 100644
--- a/customize/app.js
+++ b/customize/app.js
@@ -60,7 +60,17 @@
const romBytes = (r) => ROM_ENTRY + align4(r.bytes.length);
const iconUrl = () => st.app.icon === 'custom' && custom ? custom.url : KIT + 'variants/' + st.app.icon + '.png';
const ordered = () => st.order.filter((id) => st.picked.has(id));
+ // a big game too big to go beside the launcher in 1.94 MB (kit.json "alone") goes on its own there,
+ // as its own app: as if you installed just that game
+ const alone = (id) => st.cap === 'std' && !!byId[id].alone;
+ const solo = () => ordered().find(alone) || null;
+ let before = null; // your games while one of those is picked, back when it's taken out
function items() {
+ const s = solo();
+ if (s) {
+ const g = byId[s];
+ return [{ key: s, id: s, name: g.title, bytes: g.alone.size, color: hex(g.top), icon: g.icon ? KIT + 'icons/' + s + '.png' : null }];
+ }
const out = [{ key: '_core', name: st.app.name.trim() || 'NumPlay', bytes: langKit().base, color: '#3a3a3c', icon: iconUrl() }];
for (const id of ordered()) {
const g = byId[id];
@@ -205,18 +215,24 @@
// the icons, in the order they go in the launcher
for (const [id, b] of buttons) {
- const g = byId[id], on = st.picked.has(id), english = !g.xl || st.lang === 'en', fits = english && used + flash(id) <= cap;
+ const g = byId[id], on = st.picked.has(id), english = !g.xl || st.lang === 'en' || alone(id);
+ const fits = english && (alone(id) || used + flash(id) <= cap);
b.classList.toggle('on', on);
b.classList.toggle('off', !on && fits);
b.classList.toggle('nofit', !on && !fits);
b.setAttribute('aria-pressed', on);
- b.dataset.tip = g.title + '|' + (english ? size(flash(id)) + ' · drag to move' : 'in English NumPlays only');
+ b.dataset.tip = g.title + '|' + (alone(id) ? size(g.alone.size) + ', on its own' : english ? size(flash(id)) + ' · drag to move' : 'in English NumPlays only');
}
for (const box of [$('#small'), $('#big')]) {
const want2 = st.order.map((id) => buttons.get(id)).filter((b) => b && b.parentNode === box);
if ([...box.children].some((c, i) => c !== want2[i])) for (const b of want2) box.appendChild(b);
}
for (const b of document.querySelectorAll('.cap button')) b.setAttribute('aria-checked', b.dataset.cap === st.cap);
+ // (a game on its own has its own icon, name and language)
+ const s = solo(), file = s ? byId[s].alone.file : 'NumPlay.nwa';
+ for (const c of [$('#app-chip'), $('#lang-chip')]) c.disabled = !!s;
+ $('#download').setAttribute('aria-label', 'Download ' + file);
+ $('#download').dataset.tip = 'Download ' + file;
$('#app-chip-icon').src = iconUrl();
$('#lang-chip-label').textContent = LANGS[st.lang][0];
renderCarts();
@@ -282,9 +298,20 @@
setTimeout(() => render(), 500);
}
function toggle(id, quiet) {
- const b = buttons.get(id);
- if (st.picked.has(id)) st.picked.delete(id);
- else {
+ const b = buttons.get(id), s = solo();
+ if (st.picked.has(id)) {
+ st.picked.delete(id);
+ if (alone(id) && before) { st.picked = new Set(before); before = null; }
+ } else if (alone(id)) {
+ if (!s) before = ordered();
+ st.picked = new Set([id]);
+ bump(b, 'bounce');
+ if (!quiet) {
+ toast(byId[id].title + ' fills the whole calculator, so it goes on its own. Pick it again to get your games back');
+ fetchBytes(KIT + 'apps/' + id + '.nwa.gz').catch(() => {});
+ }
+ } else {
+ if (s) { bump(b, 'shake'); if (!quiet) toast(byId[s].title + ' takes the whole calculator. Pick it again to take it out'); return; }
if (byId[id].xl && st.lang !== 'en') { bump(b, 'shake'); toast('The big games are in English: pick English to add them'); return; }
const over = usedBytes() + flash(id) - capacity();
if (over > 0) { bump(b, 'shake'); if (!quiet) overflow(over); return; }
@@ -296,6 +323,7 @@
}
async function addRoms(files) {
+ if (solo()) { toast(byId[solo()].title + " takes the whole calculator, so there's no room for Retro-Go"); return; }
const ok = new Set(rg && rg.systems ? rg.systems : [1, 2, 3]);
for (const f of files) {
const ext = (f.name.split('.').pop() || '').toLowerCase(), sys = EXT[ext];
@@ -453,7 +481,8 @@
st.app.open = open[0] === 'matrices' ? 'matrices' : 'numplay';
st.app.secret = Math.min(SECRETS.length - 1, Math.max(0, parseInt(open[1], 10) || 0));
st.app.hint = !open.includes('nohint');
- if (st.lang !== 'en') for (const id of [...st.picked]) if (byId[id].xl) st.picked.delete(id); // (English only)
+ if (st.lang !== 'en') for (const id of [...st.picked]) if (byId[id].xl && !alone(id)) st.picked.delete(id); // (English only)
+ if (solo()) st.picked = new Set([solo()]);
// a pick that no longer fits the calculator (the kit grew): drop the biggest games until it does
const big = ordered().sort((a, b) => flash(a) - flash(b));
while (usedBytes() > capacity() && big.length) st.picked.delete(big.pop());
@@ -639,6 +668,8 @@
}
async function build() {
+ const one = solo();
+ if (one) return { bytes: await fetchBytes(KIT + 'apps/' + one + '.nwa.gz'), file: byId[one].alone.file };
await loadKit(st.lang);
const k = langKit();
const sel = ordered();
@@ -667,11 +698,11 @@
const nwa = s.m.FS.readFile('out.nwa');
const n = installedSize(nwa) + k.runtime;
if (n > capacity()) throw new Error("That's " + size(n - capacity()) + ' more than the calculator holds');
- return nwa;
+ return { bytes: nwa, file: 'NumPlay.nwa' };
}
- function download(bytes) {
- const a = el('a', '', { download: 'NumPlay.nwa', href: URL.createObjectURL(new Blob([bytes], { type: 'application/octet-stream' })) });
+ function download(bytes, file) {
+ const a = el('a', '', { download: file, href: URL.createObjectURL(new Blob([bytes], { type: 'application/octet-stream' })) });
document.body.appendChild(a);
a.click();
setTimeout(() => { URL.revokeObjectURL(a.href); a.remove(); }, 2000);
@@ -680,16 +711,18 @@
if (btn.classList.contains('busy')) return;
btn.classList.add('busy');
try {
- download(await build());
- if (sheet) openSheet();
+ const out = await build();
+ download(out.bytes, out.file);
+ if (sheet) openSheet(out.file);
} catch (e) {
console.error(e);
- toast(/more than/.test(e.message) ? e.message : "Couldn't make NumPlay.nwa, try again");
+ toast(/more than/.test(e.message) ? e.message : solo() ? "Couldn't get " + byId[solo()].alone.file + ', try again' : "Couldn't make NumPlay.nwa, try again");
} finally {
btn.classList.remove('busy');
}
}
function prefetch() {
+ if (solo()) { fetchBytes(KIT + 'apps/' + solo() + '.nwa.gz').catch(() => {}); return; }
loadTools().catch(() => {});
loadKit(st.lang).then(() => {
const lang = st.lang === 'en' ? '' : st.lang + '/';
@@ -756,7 +789,7 @@
const b = el('button', '', { type: 'button', role: 'radio', 'aria-checked': st.lang === l });
b.textContent = LANGS[l][1];
b.addEventListener('click', async () => {
- if (l !== 'en' && ordered().some((id) => byId[id].xl)) { toast('The big games are in English: take them out first'); return; }
+ if (l !== 'en' && ordered().some((id) => byId[id].xl && !alone(id))) { toast('The big games are in English: take them out first'); return; }
try { await loadKit(l); } catch (e) { toast("That language didn't load, try again"); return; }
st.lang = l;
closePops(); renderApp(); render();
@@ -776,7 +809,11 @@
'<p class="xl-warn">It only works on older calculator software. On the newest, the calculator shows exam mode.</p>' +
'<div class="xl-buttons"><a class="xl-guide" href="' + NWAGRA + '" target="_blank" rel="noopener">nwagyu\'s guide</a><button type="button" class="install xl-ok">Use 6 MB</button></div>';
document.body.appendChild(pop);
- pop.querySelector('.xl-ok').addEventListener('click', () => { st.cap = 'xl'; store('numplay-xl-seen', '1'); closePops(); render(); });
+ pop.querySelector('.xl-ok').addEventListener('click', () => {
+ st.cap = 'xl';
+ if (before) { st.picked = new Set([...before, ...st.picked]); before = null; } // (6 MB has room for it all)
+ store('numplay-xl-seen', '1'); closePops(); render();
+ });
}
openPop(pop, btn, true);
}
@@ -977,8 +1014,9 @@
}
// ------------------------------------------------------------------ the sheet, tips and toasts
- function openSheet() {
+ function openSheet(file) {
const s = $('#sheet');
+ for (const f of s.querySelectorAll('.sheet-file')) f.textContent = file;
for (const li of s.querySelectorAll('.xl-only')) li.hidden = st.cap !== 'xl';
s.hidden = false;
s.querySelector('.sheet-card a.install').focus();
@@ -1085,9 +1123,16 @@
for (const b of document.querySelectorAll('.cap button'))
b.addEventListener('click', () => {
if (b.dataset.cap === 'std' && st.cap === 'xl') {
+ st.cap = 'std';
+ const one = solo();
+ if (one && ordered().length > 1) { // (it goes on its own in 1.94 MB: the rest come back when it's out)
+ before = ordered().filter((id) => !alone(id));
+ st.picked = new Set([one]);
+ toast(byId[one].title + ' goes on its own in 1.94 MB. Pick it again to get your other games back');
+ }
const over = usedBytes() - kit.appSpace;
- if (over > 0) { bump(b, 'shake'); toast('Take ' + size(over) + ' of games out first'); return; }
- st.cap = 'std'; closePops(); render(); return;
+ if (over > 0) { st.cap = 'xl'; bump(b, 'shake'); toast('Take ' + size(over) + ' of games out first'); return; }
+ closePops(); render(); return;
}
if (b.dataset.cap === 'xl' && st.cap !== 'xl') askXL(b);
});
diff --git a/customize/index.html b/customize/index.html
index 3bf9b60b..b5938a29 100644
--- a/customize/index.html
+++ b/customize/index.html
@@ -147,7 +147,7 @@
<button type="button" class="sheet-close" aria-label="Close">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>
</button>
- <h2 id="sheet-title">NumPlay.nwa is on its way</h2>
+ <h2 id="sheet-title"><span class="sheet-file">NumPlay.nwa</span> is on its way</h2>
<ol class="steps">
<li><span class="step-icon">
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="2" width="12" height="20" rx="2.5"/><rect x="8.5" y="4.5" width="7" height="5" rx="0.5"/><path d="M9 13h.01M12 13h.01M15 13h.01M9 16h.01M12 16h.01M15 16h.01M9 19h.01M12 19h.01M15 19h.01"/></svg>
@@ -157,7 +157,7 @@
</span><span>Click the <a href="https://nwagyu.org/guide/help/enlarge-your-memory.html" target="_blank" rel="noopener">Nwagra</a> bookmark on the installer page</span></li>
<li><span class="step-icon">
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 15V3"/><path d="M7 8l5-5 5 5"/><path d="M4 15v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"/></svg>
- </span><span>Drop NumPlay.nwa there</span></li>
+ </span><span>Drop <span class="sheet-file">NumPlay.nwa</span> there</span></li>
</ol>
<a class="install wide" href="https://my.numworks.com/apps" target="_blank" rel="noopener">Open the installer</a>
<a class="star-ask" href="https://github.com/Mason363/NumPlay" target="_blank" rel="noopener">
diff --git a/tests/test_kit.py b/tests/test_kit.py
index 25a13fd5..019ade8a 100644
--- a/tests/test_kit.py
+++ b/tests/test_kit.py
@@ -3,7 +3,8 @@
the kit's objects, with a script of script.json's parts), and plays their games through the launcher
in the ARM emulator, with tests/test_games.py's sessions:
-- alone: each big game alone in a NumPlay of the calculator's app space (APP_SPACE), where it fits;
+- alone: each big game alone in a NumPlay of the calculator's app space (APP_SPACE), where it fits, and
+ where it doesn't, its own app in the kit for the website to hand out (kit.json "alone");
- sets: several big games, and big games with small ones, in a NumPlay for Enlarged Extra Apps (up to
6291456 bytes, 0x90200000 to the external flash's end: the emulator's apps go on there while the
userland header still says the app area ends at 0x903F0000, as on a calculator with nwagyu's Nwagra);
@@ -177,11 +178,27 @@ def main():
size, msg = installed(nwa, k["appSpace"])
g = kit.games[i]
if size is None or size > k["appSpace"]:
- # too big for the app space next to the launcher: then only with Enlarged Extra Apps
+ # too big for the app space next to the launcher: in NumPlay only with Enlarged Extra Apps, and the
+ # website hands out its own app instead (kit.json "alone": build/apps' file, as it is)
big, msg2 = installed(nwa, k["xlAppSpace"])
problems = [] if big and big > k["appSpace"] else [f"nwa-bin: {msg or msg2}"]
+ own = g.get("alone") or {}
+ gz = os.path.join(a.kit, "apps", i + ".nwa.gz")
+ app = os.path.join(ROOT, "build", "apps", own.get("file", "?"))
+ if not own or not os.path.exists(gz):
+ problems.append("the kit hasn't got it on its own (kit.json alone, apps/)")
+ else:
+ with gzip.open(gz) as f:
+ data = f.read()
+ if not os.path.exists(app) or open(app, "rb").read() != data:
+ problems.append(f"apps/{i}.nwa.gz isn't build/apps/{own['file']}")
+ mine = os.path.join(tmp, f"own-{i}.nwa")
+ open(mine, "wb").write(data)
+ n, msg3 = installed(mine, k["appSpace"])
+ if n is None or n > k["appSpace"] or n != own["size"]:
+ problems.append(f"on its own: {n} bytes, kit.json says {own['size']} ({msg3})")
failed |= report(f"alone {i}", problems, f"{big} bytes, {big - k['appSpace']} over the app space: "
- "only with Enlarged Extra Apps" if big else "")
+ f"only with Enlarged Extra Apps, else {own.get('file')} on its own" if big else "")
continue
emu.configure("n0120", "epsilon", a.ram or (CUSTOM_RAM if kit.ram(i) <= CUSTOM_RAM else RAM_LIMIT))
problems, stack, heap = session(nwa, ids, i, a.out, f"alone_{i}")
diff --git a/tools/kit.py b/tools/kit.py
index 379c8439..24afa222 100644
--- a/tools/kit.py
+++ b/tools/kit.py
@@ -10,7 +10,9 @@ gives NumPlay.nwa's bytes on the calculator, and that each big game ("xl", for c
with Enlarged Extra Apps: up to xlAppSpace bytes of apps) links with the launcher alone. The
blocks of the script go in the games' order ("index"), so the big games come last: past the
app area, where Enlarged Extra Apps put them, only they look for the calculator's files there
-(EPSILON_XL in games/common/epsilon_app.h).
+(EPSILON_XL in games/common/epsilon_app.h). A big game too big to fit beside the launcher in the
+app area ("alone") comes as its own app too (apps/<id>.nwa.gz, --alone): the website hands it out
+as it is, for calculators without Enlarged Extra Apps.
A game's "ram" in kit.json is what it takes in the arena (its .data, its .bss and the least heap
it needs): it fits a calculator when ram + launcherRam (NumPlay's own RAM, before the arena) is
@@ -18,6 +20,7 @@ at most what the calculator's software gives apps ("ram", "ramLimit", "upsilonRa
Usage: kit.py games.json BUILD OUT --version V --variants "..." --default "ids" --upsilon "ids"
--app-space N --xl-app-space N --ram N --ram-limit N --upsilon-ram N --nwlink NWLINK
+ --alone "id=game.nwa:Name.nwa ..."
"""
import argparse
import gzip
@@ -103,6 +106,7 @@ def main():
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>)")
+ ap.add_argument("--alone", default="", help="each big game's own app, id=game.nwa:Name.nwa")
a = ap.parse_args()
B, O = a.build, a.out
manifest = json.load(open(a.manifest))
@@ -111,7 +115,7 @@ def main():
script = json.load(open(os.path.join(B, "gen", "script.json")))
if os.path.exists(O):
shutil.rmtree(O)
- for d in ("games", "icons", "thumbs", "variants"):
+ for d in ("games", "icons", "thumbs", "variants", "apps"):
os.makedirs(os.path.join(O, d))
# ---- the objects, stripped of what no link needs, and gzipped
@@ -199,6 +203,20 @@ def main():
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"])
+ # a big game that only fits the app area without the launcher goes on its own, as its own app
+ apps = dict(x.split("=", 1) for x in a.alone.split())
+ for g in games:
+ if not g["xl"] or installed_size(os.path.join(tmp, f"xl-{g['id']}.nwa")) + runtime <= a.app_space:
+ continue
+ if g["id"] not in apps:
+ sys.exit(f"kit: {g['id']} doesn't fit beside the launcher, and --alone hasn't got its own app")
+ src, name = apps[g["id"]].split(":")
+ b = os.path.join(tmp, "alone.bin")
+ subprocess.run([a.nwlink, "nwa-bin", "--ram-length", str(ram), src, b], check=True, stdout=subprocess.DEVNULL)
+ if os.path.getsize(b) > a.app_space:
+ sys.exit(f"kit: {name} doesn't fit the app area even on its own")
+ gz(src, os.path.join(O, "apps", g["id"] + ".nwa.gz"))
+ g["alone"] = {"file": name, "size": os.path.getsize(b)}
# 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)],