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.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Upsilon and the N0110/N0115: NumPlay-Upsilon.nwa, and the slower models keep the games' speed
Mason Chen176a028ee4d1
diff --git a/Makefile b/Makefileindex 79abb945..09ffaec2 100644--- a/Makefile+++ b/Makefile@@ -19,6 +19,11 @@ B = buildRAM_LIMIT = 153676# 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+# the games that fit it (NumPlay draws their text there: see launcher/src/compat.c)+UPSILON_RAM = 107674+UPSILON_GAMES = crossyroad portal tetris chess flappybird pacman snake connectfour solitaire g2048 minesweeper \+ breakout numvisuals# NumPlay and its discreet versions: the same app, with another name and icon# on the calculator's home screen. Each one is a release file.@@ -49,9 +54,9 @@ ARM_CFLAGS = -std=gnu11 $(EADK_CFLAGS) -DNP_VERSION='"$(VERSION)"' -Os -Wall -WeARM_LINK = -nostartfiles --specs=nano.specs -Wl,--relocatable -Wl,--gc-sections -Wl,-e,main \-Wl,-u,eadk_app_name -Wl,-u,eadk_app_icon -Wl,-u,eadk_api_level-.PHONY: all nwa apps check sim emu clean FORCE+.PHONY: all nwa apps check sim emu clean lang FORCEall: nwa apps-nwa: $(foreach v,$(VARIANTS),$(B)/$(v).nwa)+nwa: $(foreach v,$(VARIANTS),$(B)/$(v).nwa) $(B)/NumPlay-Upsilon.nwa$(B):mkdir -p $(B)/modules $(B)/gen $(B)/arm $(B)/apps $(B)/sim@@ -84,6 +89,7 @@ $(B)/modules/%.o: FORCE | $(B)$(ARM_LD) -r -d -T tools/module.ld $(MOD_$*) -o $(B)/modules/$*.1.o$(ARM_OBJCOPY) --keep-global-symbol=$(or $(ENTRY_$*),$(ENTRY)) \--redefine-sym eadk_keyboard_scan=np_keyboard_scan --redefine-sym eadk_event_get=np_event_get \+ --redefine-sym eadk_display_draw_string=np_display_draw_string \$(B)/modules/$*.1.o $(B)/modules/$*.2.o$(PY) tools/npmodule.py $(B)/modules/$*.2.o $@ --game $* --index $(INDEX_$*) \--entry $(or $(ENTRY_$*),$(ENTRY)) --json $(B)/modules/$*.json@@ -112,7 +118,8 @@ $(B)/arm/shots_%.o: $(B)/gen/shots_%.c launcher/src/np.h$(ARM_CC) $(ARM_CFLAGS) -c $< -o $@$(B)/arm/arena.o $(B)/arm/marks.o: $(B)/arm/%.o: $(B)/gen/gametable.c$(ARM_CC) $(EADK_CFLAGS) -c $(B)/gen/$*.s -o $@-.SECONDARY: $(foreach v,$(VARIANTS),$(B)/variant/$(v)-name.o $(B)/variant/$(v)-icon.o)+.SECONDARY: $(foreach v,$(VARIANTS),$(B)/variant/$(v)-name.o $(B)/variant/$(v)-icon.o) \+ $(foreach g,$(GAMES),$(B)/arm/shots_$(g).o)$(B)/variant/%-name.o: launcher/app_name.c Makefile | $(B)mkdir -p $(B)/variant$(ARM_CC) $(ARM_CFLAGS) '-DNP_APP_NAME=$(NAME_$*)' -c $< -o $@@@ -127,11 +134,46 @@ $(B)/%.nwa: $(ARM_OBJS) $(MODULES) $(B)/variant/%-name.o $(B)/variant/%-icon.o@if [ "$*" = NumPlay ]; then $(PY) tools/sizes.py $@ $(B)/modules; ficheck: nwa+ @$(NWLINK) nwa-bin --ram-length $(UPSILON_RAM) $(B)/NumPlay-Upsilon.nwa $(B)/NumPlay-Upsilon.bin && \+ echo "NumPlay-Upsilon.nwa installs as $$(wc -c < $(B)/NumPlay-Upsilon.bin) bytes; its RAM fits in $(UPSILON_RAM) bytes"@for v in $(VARIANTS); do $(NWLINK) nwa-bin --ram-length $(RAM_LIMIT) $(B)/$$v.nwa $(B)/$$v.bin || exit 1; \n=$$(wc -c < $(B)/$$v.bin); \echo "$$v.nwa installs as $$n bytes ($$(( $(APP_SPACE) - n )) to spare); its RAM fits in $(RAM_LIMIT) bytes"; \[ $$n -le $(APP_SPACE) ] || { echo "$$v.nwa is bigger than the calculator's app space ($(APP_SPACE) bytes)"; exit 1; }; done+# ------------------------------------------------------------------ NumPlay-Upsilon.nwa+$(B)/gen-upsilon/gametable.c: games/games.json tools/gen_games.py $(foreach g,$(UPSILON_GAMES),$(B)/modules/$(g).o)+ $(PY) tools/gen_games.py games/games.json $(B)/modules $(B)/gen-upsilon --only "$(UPSILON_GAMES)"+$(B)/arm-upsilon/gametable.o: $(B)/gen-upsilon/gametable.c launcher/src/np.h+ mkdir -p $(B)/arm-upsilon+ $(ARM_CC) $(ARM_CFLAGS) -c $< -o $@+$(B)/arm-upsilon/arena.o $(B)/arm-upsilon/marks.o: $(B)/arm-upsilon/%.o: $(B)/gen-upsilon/gametable.c+ mkdir -p $(B)/arm-upsilon+ $(ARM_CC) $(EADK_CFLAGS) -c $(B)/gen-upsilon/$*.s -o $@+UPSILON_OBJS = $(patsubst launcher/src/%.c,$(B)/arm/%.o,$(LAUNCHER_SRC)) $(B)/arm-upsilon/gametable.o \+ $(B)/arm-upsilon/arena.o $(B)/arm-upsilon/marks.o $(foreach g,$(UPSILON_GAMES),$(B)/arm/shots_$(g).o) \+ $(foreach g,$(UPSILON_GAMES),$(B)/modules/$(g).o)+$(B)/NumPlay-Upsilon.nwa: $(UPSILON_OBJS) $(B)/variant/NumPlay-name.o $(B)/variant/NumPlay-icon.o+ $(ARM_CC) $(ARM_CFLAGS) $(ARM_LINK) -Wl,-T,$(B)/gen-upsilon/numplay.ld -flinker-output=nolto-rel \+ $^ -lm -lgcc -o $@+ arm-none-eabi-strip --strip-unneeded $@++# ------------------------------------------------------------------ NumPlay in other languages+# tools/lang.py copies what builds NumPlay to build/lang/<code> with the translations in place+# (launcher/lang/<code>.txt, games/<game>/lang/<code>.txt), and NumPlay is built there.+LANGS = fr zh+LANG_fr = French+LANG_zh = Chinese+lang: $(foreach l,$(LANGS),$(B)/NumPlay-$(LANG_$(l)).nwa)+$(foreach l,$(LANGS),$(B)/NumPlay-$(LANG_$(l)).nwa): $(B)/NumPlay-%.nwa: FORCE | $(B)+ $(eval L := $(if $(filter French,$*),fr,zh))+ $(PY) tools/lang.py tree $(L) $(B)/lang/$(L)+ $(MAKE) -C $(B)/lang/$(L) build/NumPlay.nwa NWLINK="$(NWLINK)"+ $(NWLINK) nwa-bin --ram-length $(RAM_LIMIT) $(B)/lang/$(L)/build/NumPlay.nwa $(B)/lang/$(L)/build/NumPlay.bin+ @n=$$(wc -c < $(B)/lang/$(L)/build/NumPlay.bin); echo "NumPlay-$*.nwa installs as $$n bytes ($$(( $(APP_SPACE) - n )) to spare)"; \+ [ $$n -le $(APP_SPACE) ] || { echo "NumPlay-$*.nwa is bigger than the calculator's app space"; exit 1; }+ cp $(B)/lang/$(L)/build/NumPlay.nwa $@+# ------------------------------------------------------------------ games on their ownAPP_numdash = games/numdash/build/numdash.nwa:NumDash.nwaAPP_crossyroad = games/crossyroad/output/crossyroad.nwa:CrossyRoad.nwadiff --git a/games/championisland/src/ci.h b/games/championisland/src/ci.hindex 8645b7fe..fafd28e0 100644--- a/games/championisland/src/ci.h+++ b/games/championisland/src/ci.h@@ -82,6 +82,8 @@ void plat_push(int x, int y, int w, int h, const uint16_t *px);void plat_fill(int x, int y, int w, int h, uint16_t c);void plat_vsync(void);bool plat_save(const char *name, const void *data, uint32_t len);+/* an N0110 or N0115 (216 MHz, the N0120 has 550): a frame drawn late lets the game catch up */+bool plat_slow(void);const uint8_t *plat_load(const char *name, uint32_t *len);uint32_t plat_random(void);diff --git a/games/championisland/src/main.c b/games/championisland/src/main.cindex 9e96369f..4444888d 100644--- a/games/championisland/src/main.c+++ b/games/championisland/src/main.c@@ -67,9 +67,15 @@ int main(void) {#endifci_init();uint32_t next = plat_millis();+ bool slow = plat_slow();while (game_running) {uint32_t t0 = plat_millis();game_tick();+ /* (an N0110 or N0115, a frame behind: one more tick before drawing, so the game keeps its speed) */+ if (slow && game_running && (int32_t)(t0 - next) > 1000 / FPS) {+ game_tick();+ next += 1000 / FPS + (game.ticks % 3 == 0 ? 1 : 0);+ }if (!game_running) break;game_draw();perf_frames++;diff --git a/games/championisland/src/plat_eadk.c b/games/championisland/src/plat_eadk.cindex cd8e85cb..a758aad6 100644--- a/games/championisland/src/plat_eadk.c+++ b/games/championisland/src/plat_eadk.c@@ -45,3 +45,4 @@ void plat_seed(uint32_t s) { seed = s ? s : 1; }void plat_begin(void) { np_app_begin(); plat_seed((uint32_t)eadk_timing_millis() * 2654435761u); }int plat_end(void) { return np_app_end(); }+bool plat_slow(void) { return epsilon_slow_model(); }diff --git a/games/championisland/src/plat_host.c b/games/championisland/src/plat_host.cindex c292fc93..aa1d6d15 100644--- a/games/championisland/src/plat_host.c+++ b/games/championisland/src/plat_host.c@@ -54,6 +54,7 @@ uint32_t plat_random(void) {void plat_seed(uint32_t s) { seed = s ? s : 1; }void plat_begin(void) {}int plat_end(void) { return 0; }+bool plat_slow(void) { return false; }/* writes the screen as a PPM image */void host_shot(const char *path) {diff --git a/games/common/epsilon_app.h b/games/common/epsilon_app.hindex 497d0a2d..10fb2cf0 100644--- a/games/common/epsilon_app.h+++ b/games/common/epsilon_app.h@@ -15,6 +15,15 @@* firmware slot, 64 KiB later on models with an extra data sector. Only* addresses in external flash are probed, which exist on every model.*+ * Upsilon. The custom software of the N0110 and N0115 runs .nwa apps too. Its+ * header has the same first words but no device name (the footer comes two+ * words sooner, then Omega's magic), and it has none of the system calls for+ * Home (10, 13), checksums (15, 16) or flash: those are never made there.+ *+ * Models. The N0110 and N0115 (216 MHz) keep their userland right after the+ * kernel and their RAM at 0x20000000; the N0120 (550 MHz) has an extra data+ * sector before the userland and its RAM at 0x24000000.+ ** Include it in one file per app. */#ifndef EPSILON_APP_H#define EPSILON_APP_H@@ -28,26 +37,46 @@ typedef struct {uint32_t storage_ram, storage_size;uint32_t apps_flash_start, apps_flash_end;uint32_t apps_ram_start, apps_ram_end;- uint32_t name_flash_start, name_flash_end;+ uint32_t name_flash_start, name_flash_end; /* (not on Upsilon: the footer, then Omega's magic) */uint32_t footer;} epsilon_userland_t;#if PLATFORM_DEVICE && !defined(HOST)-/* The header of the software running this app, or NULL. */-__attribute__((unused)) static const epsilon_userland_t *epsilon_userland(void) {+/* The header of the software running this app, or NULL; *upsilon tells which. */+__attribute__((unused)) static const epsilon_userland_t *epsilon_userland_of(bool *upsilon) {static const uint32_t where[] = {0x90010000u, 0x90020000u, 0x90410000u, 0x90420000u};- uint32_t self = (uint32_t)(uintptr_t)&epsilon_userland;+ uint32_t self = (uint32_t)(uintptr_t)&epsilon_userland_of;const epsilon_userland_t *found = NULL;+ bool ups = false;for (unsigned i = 0; i < sizeof where / sizeof where[0]; i++) {const volatile epsilon_userland_t *h = (const volatile epsilon_userland_t *)(uintptr_t)where[i];- if (h->magic != 0xDEC0EDFEu || h->footer != 0xDEC0EDFEu) continue;+ const volatile uint32_t *w = (const volatile uint32_t *)(uintptr_t)where[i];+ if (h->magic != 0xDEC0EDFEu) continue;+ bool official = h->footer == 0xDEC0EDFEu, omega = w[9] == 0xDEC0EDFEu && w[10] == 0xEFBEADDEu;+ if (!official && !omega) continue;if (self < h->apps_flash_start || self >= h->apps_flash_end) continue;if (found) return NULL; /* ambiguous: better not guess */found = (const epsilon_userland_t *)h;+ ups = omega;}+ if (upsilon) *upsilon = found && ups;return found;}+__attribute__((unused)) static const epsilon_userland_t *epsilon_userland(void) { return epsilon_userland_of(NULL); }++/* Upsilon (or Omega) runs this app: none of Epsilon's extra system calls. */+__attribute__((unused)) static bool epsilon_is_upsilon(void) {+ bool u = false;+ epsilon_userland_of(&u);+ return u;+}++/* An N0110 or N0115: 2.5 times slower than the N0120. */+__attribute__((unused)) static bool epsilon_slow_model(void) {+ const epsilon_userland_t *h = epsilon_userland();+ return h ? h->storage_ram < 0x24000000u : false;+}/* The record area of Epsilon's file system (after its magic word), or NULL. */__attribute__((unused)) static uint8_t *epsilon_storage(uint32_t *size) {@@ -74,7 +103,8 @@ static bool epsilon_home_held;/* Epsilon's circuit breaker: while locked, Home cannot interrupt the app* (system calls 10 and 13, unchanged since 2021). */__attribute__((unused)) static void np_app_begin(void) {- if (numplay_launcher || !epsilon_userland()) return;+ bool upsilon = false;+ if (numplay_launcher || !epsilon_userland_of(&upsilon) || upsilon) return;__asm__ volatile("svc 10" ::: "r0", "r1", "r2", "r3", "r12", "memory");epsilon_home_held = true;}@@ -95,6 +125,8 @@ __attribute__((unused)) static uint8_t *epsilon_storage(uint32_t *size) {(void)size;return NULL;}+static inline bool epsilon_is_upsilon(void) { return false; }+static inline bool epsilon_slow_model(void) { return false; }static inline void np_app_begin(void) {}static inline int np_app_end(void) { return 0; }#endifdiff --git a/games/common/epsilon_files.h b/games/common/epsilon_files.hindex c2d13b8e..ae81760b 100644--- a/games/common/epsilon_files.h+++ b/games/common/epsilon_files.h@@ -88,6 +88,14 @@ static uint32_t ef_name_crc(const char *full) {static uint32_t *ef_cache(const ef_fs_t *fs, int end) {uint32_t *after = (uint32_t *)(void *)(fs->buf + fs->size + 4), *found = NULL;uint32_t base = (uint32_t)(uintptr_t)fs->buf;+ if (epsilon_is_upsilon()) {+ /* Upsilon's file system (Epsilon 15's) ends with the delegate, then the cache: (checksum,+ * pointer), at fixed places. Clearing a cache is always safe; only check it is one. */+ uint32_t delegate = after[0], ptr = after[2];+ if (delegate && (delegate < 0x20000000u || delegate >= 0x20040000u)) return NULL;+ if (ptr && (ptr < base || ptr >= base + (uint32_t)end)) return NULL;+ return after; /* [1] and [2] are cleared, as below */+ }for (int i = 1; i < 96; i++) {uint32_t *w = after + i;uint32_t accessible = w[0], crc = w[1], ptr = w[2];diff --git a/games/common/np_text.h b/games/common/np_text.hnew file mode 100644index 00000000..f29f1304--- /dev/null+++ b/games/common/np_text.h@@ -0,0 +1,157 @@+/* Text in other languages: NumPlay-French.nwa, NumPlay-Chinese.nwa and the+ * games on their own in those languages are built from the same sources.+ *+ * T("...") marks a text players read. In English it is the text itself; for a+ * language build, tools/lang.py copies the sources and puts each text's+ * translation (from games/<game>/lang/<code>.txt) in its place, so every+ * file carries only its own language. Sources and translations are UTF-8.+ *+ * Drawing them, each game with its own font:+ * - np_utf8() reads one letter (a code point) at a time;+ * - accented Latin letters (French) are the game's own letter with an accent+ * drawn over it (or a cedilla under it): np_latin() names both, and+ * np_accent() draws the accent at the game's scale;+ * - other letters (Chinese) come from a 12-pixel font (Fusion Pixel, SIL Open+ * Font License): np_xglyph() gives a letter's 1-bit rows, from a table that+ * tools/lang.py makes with only the letters the build uses; the launcher+ * holds it for all its games (launcher/src/np_xfont.h).+ *+ * Only NumPlay itself is built in other languages. NP_TEXT_EXTRA is 1 there+ * (tools/lang.py sets it): code that handles letters beyond ASCII sits behind+ * it, so the English apps carry none of it. */+#ifndef NP_TEXT_H+#define NP_TEXT_H+#include <stdbool.h>+#include <stdint.h>++#define T(s) (s)+#define NP_TEXT_EXTRA 0++/* The next code point of a UTF-8 string, *s moved past it (0 at the end). */+static inline uint32_t np_utf8(const char **s) {+ const uint8_t *p = (const uint8_t *)*s;+ uint32_t c = p[0];+ if (c < 0x80) {+ if (c) (*s)++;+ return c;+ }+ int n = c >= 0xF0 ? 3 : c >= 0xE0 ? 2 : c >= 0xC0 ? 1 : 0;+ c &= 0x3F >> n;+ for (int i = 1; i <= n; i++) {+ if ((p[i] & 0xC0) != 0x80) {+ (*s) += i;+ return '?';+ }+ c = c << 6 | (p[i] & 0x3F);+ }+ (*s) += n + 1;+ return n ? c : '?';+}++/* The cells a text takes in a fixed-width font (games drawing with the firmware's font, 7 or 10 pixels a+ * letter): a letter each, two for a Chinese one (launcher/src/compat.c draws them in two cells). */+static inline int np_text_cells(const char *s) {+ int n = 0;+ while (*s) {+ uint32_t c = NP_TEXT_EXTRA ? np_utf8(&s) : (uint8_t)*s++;+ n += c >= 0x2E80 ? 2 : 1;+ }+ return n;+}++/* Accents of np_latin() */+enum { NP_ACC_NONE, NP_ACC_ACUTE, NP_ACC_GRAVE, NP_ACC_CIRC, NP_ACC_DIAER, NP_ACC_CEDIL, NP_ACC_TILDE, NP_ACC_RING };++/* A Latin letter with an accent: returns the accent, *base the plain letter+ * (0 when cp is no such letter). Ligatures (œ, æ, ß) and a few signs give+ * *second too, a letter to draw after the first. Guillemets, typographic+ * quotes and others give plain ASCII stand-ins. */+static inline int np_latin(uint32_t cp, char *base, char *second) {+ static const char letters[] = "AAAAAAACEEEEIIIIDNOOOOOxOUUUUYTsaaaaaaaceeeeiiiidnooooo/ouuuuyty";+ static const uint8_t accents[] = {+ 2, 1, 3, 6, 4, 7, 0, 5, 2, 1, 3, 4, 2, 1, 3, 4, 0, 6, 2, 1, 3, 6, 4, 0, 0, 2, 1, 3, 4, 1, 0, 0,+ 2, 1, 3, 6, 4, 7, 0, 5, 2, 1, 3, 4, 2, 1, 3, 4, 0, 6, 2, 1, 3, 6, 4, 0, 0, 2, 1, 3, 4, 1, 0, 4};+ *second = 0;+ if (cp >= 0xC0 && cp <= 0xFF) {+ *base = letters[cp - 0xC0];+ if (cp == 0xC6 || cp == 0xE6) *second = cp == 0xC6 ? 'E' : 'e';+ if (cp == 0xDF) *second = 's';+ return accents[cp - 0xC0];+ }+ *base = 0;+ switch (cp) {+ case 0x152: *base = 'O', *second = 'E'; break;+ case 0x153: *base = 'o', *second = 'e'; break;+ case 0x178: *base = 'Y'; return NP_ACC_DIAER;+ case 0xAB: *base = '<', *second = '<'; break; /* « */+ case 0xBB: *base = '>', *second = '>'; break; /* » */+ case 0xB0: *base = 'o'; break; /* ° */+ case 0xA0: case 0x202F: *base = ' '; break; /* (no-break spaces) */+ case 0x2018: case 0x2019: *base = '\''; break;+ case 0x201C: case 0x201D: *base = '"'; break;+ case 0x2026: *base = '.', *second = '.'; break;+ case 0x2013: case 0x2014: *base = '-'; break;+ }+ return NP_ACC_NONE;+}++/* Draws an accent 5 x 2 font pixels big, its top-left at (x, y), each font+ * pixel a scale x scale square, with plot(x, y, ctx) per screen pixel. The+ * game knows its letters: the accent goes centered over a letter (or under+ * it, for a cedilla), in the rows its font leaves free above lowercase+ * letters, or on the first rows of a capital, as small capitals do. */+static inline void np_accent(int acc, int x, int y, int scale, void (*plot)(int x, int y, void *ctx), void *ctx) {+ /* bits 0-4 the upper row, 5-9 the lower one, left to right */+ static const uint16_t marks[] = {0, 0x088, 0x082, 0x144, 0x140, 0x0C4, 0x154, 0x14E};+ if (acc <= NP_ACC_NONE || acc > NP_ACC_RING) return;+ for (int j = 0; j < 2; j++)+ for (int i = 0; i < 5; i++)+ if (marks[acc] >> (j * 5 + i) & 1)+ for (int a = 0; a < scale; a++)+ for (int b = 0; b < scale; b++) plot(x + i * scale + b, y + j * scale + a, ctx);+}++/* ---- the 12-pixel font */+typedef struct {+ uint16_t cp; /* (Chinese and its punctuation are all below 0x10000) */+ uint8_t adv, w, h; /* advance; the bitmap's size */+ int8_t x, y; /* the bitmap's top-left from the pen, y down from the top of a 12-pixel line */+ uint16_t off; /* its first bit in rows: w x h bits, row by row, the first pixel first */+} np_xglyph_t;+typedef struct {+ uint32_t count;+ const np_xglyph_t *glyphs; /* sorted by code point */+ const uint8_t *rows; /* bits, lowest first in each byte */+} np_xfont_t;++extern const np_xfont_t np_xfont; /* the launcher's (launcher/src/np_xfont.h) */++/* The glyph of cp in the 12-pixel font, or NULL. */+static inline const np_xglyph_t *np_xglyph(uint32_t cp) {+ uint32_t lo = 0, hi = np_xfont.count;+ while (lo < hi) {+ uint32_t m = (lo + hi) / 2;+ if (np_xfont.glyphs[m].cp < cp) lo = m + 1;+ else hi = m;+ }+ return lo < np_xfont.count && np_xfont.glyphs[lo].cp == cp ? &np_xfont.glyphs[lo] : 0;+}++/* Draws cp from the 12-pixel font with its line's top at (x, top), each font+ * pixel a scale x scale square; returns the advance (0 if the font has none). */+static inline int np_xdraw(uint32_t cp, int x, int top, int scale, void (*plot)(int x, int y, void *ctx), void *ctx) {+ const np_xglyph_t *g = np_xglyph(cp);+ if (!g) return 0;+ uint32_t bit = (uint32_t)g->off * 8;+ for (int j = 0; j < g->h; j++)+ for (int i = 0; i < g->w; i++, bit++)+ if (np_xfont.rows[bit >> 3] >> (bit & 7) & 1)+ for (int a = 0; a < scale; a++)+ for (int b = 0; b < scale; b++) plot(x + (g->x + i) * scale + b, top + (g->y + j) * scale + a, ctx);+ return g->adv * scale;+}+static inline int np_xadvance(uint32_t cp, int scale) {+ const np_xglyph_t *g = np_xglyph(cp);+ return g ? g->adv * scale : 0;+}+#endifdiff --git a/games/numdrive/host/platform_host.c b/games/numdrive/host/platform_host.cindex 0579da7c..17b46c24 100644--- a/games/numdrive/host/platform_host.c+++ b/games/numdrive/host/platform_host.c@@ -261,4 +261,5 @@ static void s_checkpoint(void) {#endifvoid plat_begin(void) {}+bool plat_slow(void) { return false; }int plat_end(int code) { return code; }diff --git a/games/numdrive/src/main.c b/games/numdrive/src/main.cindex fdaceb20..896aa47e 100644--- a/games/numdrive/src/main.c+++ b/games/numdrive/src/main.c@@ -122,7 +122,7 @@ int main(int argc, char **argv) {bool dirty = true, qyes = false;uint64_t prev = 0;uint32_t last = plat_millis();- int acc = 0;+ int acc = 0, max_steps = plat_slow() ? 6 : 3;for (;;) {uint64_t k = plat_keys();uint64_t hit = k & ~prev;@@ -140,7 +140,8 @@ int main(int argc, char **argv) {last = now;steps = acc / 50;if (steps < 1) steps = 1;- if (steps > 3) steps = 3, acc = 0;+ /* (an N0110 or N0115 draws fewer frames: more steps each, so the game keeps its speed) */+ if (steps > max_steps) steps = max_steps, acc = 0;acc -= steps * 50;if (acc < 0) acc = 0;#elsediff --git a/games/numdrive/src/platform.h b/games/numdrive/src/platform.hindex f6e0f953..b94f680c 100644--- a/games/numdrive/src/platform.h+++ b/games/numdrive/src/platform.h@@ -27,5 +27,7 @@ void plat_frame_done(void); /* host harness hook (captures frames) */* it ends (games/common/epsilon_app.h). plat_end returns `code`. */void plat_begin(void);int plat_end(int code);+/* an N0110 or N0115 (216 MHz, the N0120 has 550): more catching up per frame */+bool plat_slow(void);#endifdiff --git a/games/numdrive/src/platform_eadk.c b/games/numdrive/src/platform_eadk.cindex 315315ff..ed30569f 100644--- a/games/numdrive/src/platform_eadk.c+++ b/games/numdrive/src/platform_eadk.c@@ -3,6 +3,7 @@#include "../../common/epsilon_app.h"void plat_begin(void) { np_app_begin(); }+bool plat_slow(void) { return epsilon_slow_model(); }int plat_end(int code) {np_app_end();return code;diff --git a/launcher/src/compat.c b/launcher/src/compat.cnew file mode 100644index 00000000..0de921d4--- /dev/null+++ b/launcher/src/compat.c@@ -0,0 +1,102 @@+/* Text drawn by the calculator's software, for the games that use it (the+ * build renames their eadk_display_draw_string to this).+ *+ * On Epsilon, the firmware draws it. Upsilon's .nwa apps may not reach the+ * firmware's text function the way Epsilon's do, so there NumPlay draws it+ * itself, in cells of the firmware's sizes (7 x 14, or 10 x 18 large) so that+ * the games' layouts stay as they are, with NumPlay's own font. So it does too+ * in a language build for a text with letters the firmware has no font for+ * (Chinese: two cells each, from the 12-pixel font of games/common/np_text.h). */+#include "np.h"+#include "font.h"+#include "sys.h"+#include "../../games/common/np_text.h"++static color_t blend(color_t bg, color_t fg, int a16) {+ if (a16 >= 15) return fg;+ if (a16 <= 0) return bg;+ uint32_t B = (bg | (uint32_t)bg << 16) & 0x07E0F81F, F = (fg | (uint32_t)fg << 16) & 0x07E0F81F;+ uint32_t M = ((B * (uint32_t)(16 - a16) + F * (uint32_t)a16) >> 4) & 0x07E0F81F;+ return (color_t)(M | M >> 16);+}++static void draw_cell(const np_font_t *f, int cw, int ch, int x, int y, char c, color_t fg, color_t bg) {+ color_t cell[10 * 18];+ for (int i = 0; i < cw * ch; i++) cell[i] = bg;+ unsigned k = (uint8_t)c;+ if (k >= f->first && k < (unsigned)f->first + f->count) {+ const np_glyph_t *g = &f->glyphs[k - f->first];+ int pen = (cw - g->advance) / 2, base = (ch + f->ascent - f->descent) / 2;+ const uint8_t *d = f->data + g->offset;+ for (int j = 0; j < g->h; j++)+ for (int i = 0; i < g->w; i++) {+ int n = j * g->w + i, a = (d[n >> 1] >> ((n & 1) * 4)) & 15;+ int px = pen + g->x + i, py = base + g->y + j;+ if (a && px >= 0 && px < cw && py >= 0 && py < ch) cell[py * cw + px] = blend(bg, fg, a);+ }+ }+ if (x + cw > 320 || y + ch > 240) return;+ eadk_display_push_rect((eadk_rect_t){(uint16_t)x, (uint16_t)y, (uint16_t)cw, (uint16_t)ch}, cell);+}++typedef struct {+ color_t *cell;+ int cw, ch;+ color_t fg;+} cell_plot_t;+static void cell_plot(int x, int y, void *ctx) {+ cell_plot_t *p = ctx;+ if (x >= 0 && x < p->cw && y >= 0 && y < p->ch) p->cell[y * p->cw + x] = p->fg;+}++/* a Chinese letter in two cells */+static void draw_wide(uint32_t cp, int cw, int ch, int x, int y, color_t fg, color_t bg) {+ color_t cell[20 * 18];+ for (int i = 0; i < 2 * cw * ch; i++) cell[i] = bg;+ cell_plot_t p = {cell, 2 * cw, ch, fg};+ np_xdraw(cp, (2 * cw - 12) / 2, (ch - 12) / 2, 1, cell_plot, &p);+ if (x + 2 * cw > 320 || y + ch > 240) return;+ eadk_display_push_rect((eadk_rect_t){(uint16_t)x, (uint16_t)y, (uint16_t)(2 * cw), (uint16_t)ch}, cell);+}++static bool has_wide(const char *s) {+ while (*s)+ if (np_utf8(&s) >= 0x2E80) return true;+ return false;+}++void np_display_draw_string(const char *text, eadk_point_t point, bool large_font, eadk_color_t text_color,+ eadk_color_t background_color) {+ if (!np_upsilon() && !(NP_TEXT_EXTRA && has_wide(text))) { /* (always, in the simulator) */+ eadk_display_draw_string(text, point, large_font, text_color, background_color);+ return;+ }+ const np_font_t *f = large_font ? &np_font_body : &np_font_small;+ int cw = large_font ? 10 : 7, ch = large_font ? 18 : 14, x = point.x, y = point.y;+ for (const char *s = text; *s;) {+ if (*s == '\n') {+ x = point.x, y += ch, s++;+ continue;+ }+ if (!NP_TEXT_EXTRA) {+ if ((uint8_t)*s >= 0x80 && ((uint8_t)*s & 0xC0) == 0x80) { /* the rest of a UTF-8 letter */+ s++;+ continue;+ }+ draw_cell(f, cw, ch, x, y, (uint8_t)*s >= 0x80 ? '?' : *s, text_color, background_color);+ s++, x += cw;+ continue;+ }+ uint32_t cp = np_utf8(&s);+ if (cp >= 0x2E80 && np_xglyph(cp)) {+ draw_wide(cp, cw, ch, x, y, text_color, background_color);+ x += 2 * cw;+ continue;+ }+ char base = (char)cp, second = 0;+ if (cp >= 0x80 && (np_latin(cp, &base, &second), !base)) base = '?';+ draw_cell(f, cw, ch, x, y, base, text_color, background_color);+ x += cw;+ if (second) draw_cell(f, cw, ch, x, y, second, text_color, background_color), x += cw;+ }+}diff --git a/launcher/src/flash.c b/launcher/src/flash.cindex 687a4088..95755323 100644--- a/launcher/src/flash.c+++ b/launcher/src/flash.c@@ -25,7 +25,7 @@ bool np_uninstall_supported(void) {#else/* The flash system calls have kept their numbers and arguments since* Epsilon 20; older or unknown software is left alone. */- return np_userland() && np_software_major() >= 21;+ return np_userland() && !np_upsilon() && np_software_major() >= 21;#endif}diff --git a/launcher/src/matrices.c b/launcher/src/matrices.cindex 7bfb3086..d42669c0 100644--- a/launcher/src/matrices.c+++ b/launcher/src/matrices.c@@ -6,6 +6,7 @@#include <string.h>#include "np.h"#include "sys.h"+#include "../../games/common/np_text.h"#define C_BAR RGB(0xFF, 0xB6, 0x31)#define C_TAB RGB(0x63, 0x69, 0x73)@@ -28,7 +29,7 @@ enum {static const int8_t digit_keys[10] = {48, 42, 43, 44, 36, 37, 38, 30, 31, 32};static const uint8_t secret_keys[NP_SECRET_COUNT] = {KEY_XNT, KEY_VAR, KEY_TOOLBOX, KEY_PI, KEY_SQRT, 255};/* the hint, if Settings keeps it: the secret's name, bottom left in light gray */-static const char *const secret_hints[NP_SECRET_COUNT] = {"x,n,t", "var", "Toolbox", "\xCF\x80", "\xE2\x88\x9A", "Examples"};+static const char *const secret_hints[NP_SECRET_COUNT] = {"x,n,t", "var", T("Toolbox"), "\xCF\x80", "\xE2\x88\x9A", T("Examples")};static const char *hint;static struct {@@ -42,11 +43,12 @@ static void fill(int x, int y, int w, int h, color_t c) {if (w > 0 && h > 0) eadk_display_push_rect_uniform((eadk_rect_t){x, y, w, h}, c);}static void text(const char *s, int x, int y, bool big, color_t fg, color_t bg) {- eadk_display_draw_string(s, (eadk_point_t){x, y}, big, fg, bg);+ np_display_draw_string(s, (eadk_point_t){x, y}, big, fg, bg);}static int width(const char *s, bool big) {int n = 0;- for (; *s; s++) n += (*s & 0xC0) != 0x80; /* characters, not UTF-8 bytes */+ /* characters, not UTF-8 bytes; a Chinese one takes two cells (launcher/src/compat.c) */+ for (; *s; s++) n += (*s & 0xC0) == 0x80 ? 0 : NP_TEXT_EXTRA && (uint8_t)*s >= 0xE3 ? 2 : 1;return n * (big ? 10 : 7);}static void ctext(const char *s, int cx, int y, bool big, color_t fg, color_t bg) {@@ -153,7 +155,7 @@ static bool inverse(float m[MAXN][MAXN], int n, float out[MAXN][MAXN]) {static void status_bar(void) {fill(0, 0, SCREEN_W, 18, C_BAR);text("rad", 4, 2, false, C_WHITE, C_BAR);- ctext("MATRICES", 160, 2, false, C_WHITE, C_BAR);+ ctext(T("MATRICES"), 160, 2, false, C_WHITE, C_BAR);/* battery */int level = np_battery_level();fill(296, 5, 15, 8, C_WHITE);@@ -164,7 +166,7 @@ static void status_bar(void) {}static void tabs(void) {- static const char *const names[2] = {"Matrix", "Results"};+ static const char *const names[2] = {T("Matrix"), T("Results")};for (int t = 0; t < 2; t++) {color_t bg = t == M.tab ? C_WHITE : C_TAB, fg = t == M.tab ? C_TAB : C_WHITE;fill(t * 160, 18, 160, 22, bg);@@ -181,7 +183,7 @@ static int grid_x(void) { return (SCREEN_W - (24 + M.n * cell_w())) / 2 + 24; }static void dimension_line(void) {color_t bg = M.row < 0 ? C_SEL : C_WHITE;fill(0, 46, SCREEN_W, 30, bg);- text("Dimension", 10, 53, true, C_TEXT, bg);+ text(T("Dimension"), 10, 53, true, C_TEXT, bg);char s[8] = "0\xC3\x97" "0"; /* n×n */s[0] = (char)('0' + M.n), s[3] = (char)('0' + M.n);text(s, SCREEN_W - 12 - width(s, true), 53, true, C_TEXT, bg);@@ -252,12 +254,12 @@ static void results_tab(void) {char s[16];int y = 46;fill(0, y, SCREEN_W, 28, C_WHITE);- text("Determinant", 10, y + 7, false, C_GRAY, C_WHITE);+ text(T("Determinant"), 10, y + 7, false, C_GRAY, C_WHITE);fmt(det(M.a, M.n), s);text(s, SCREEN_W - 12 - width(s, true), y + 5, true, C_TEXT, C_WHITE);y += 29;fill(0, y, SCREEN_W, 28, C_WHITE);- text("Trace", 10, y + 7, false, C_GRAY, C_WHITE);+ text(T("Trace"), 10, y + 7, false, C_GRAY, C_WHITE);float tr = 0;for (int i = 0; i < M.n; i++) tr += M.a[i][i];fmt(tr, s);@@ -265,13 +267,13 @@ static void results_tab(void) {y += 29;int h = M.n * 16 + 12;fill(0, y, SCREEN_W, SCREEN_H - y, C_WHITE);- text("Inverse", 10, y + 6, false, C_GRAY, C_WHITE);+ text(T("Inverse"), 10, y + 6, false, C_GRAY, C_WHITE);float inv[MAXN][MAXN];if (inverse(M.a, M.n, inv)) small_matrix(inv, SCREEN_W - 20 - (8 + M.n * 46), y + 6);- else text("Not invertible", SCREEN_W - 12 - width("Not invertible", false), y + 6, false, C_TEXT, C_WHITE);+ else text(T("Not invertible"), SCREEN_W - 12 - width(T("Not invertible"), false), y + 6, false, C_TEXT, C_WHITE);y += h;fill(0, y, SCREEN_W, 1, C_LINE);- text("Transpose", 10, y + 6, false, C_GRAY, C_WHITE);+ text(T("Transpose"), 10, y + 6, false, C_GRAY, C_WHITE);float t[MAXN][MAXN];for (int r = 0; r < M.n; r++)for (int c = 0; c < M.n; c++) t[r][c] = M.a[c][r];@@ -279,13 +281,13 @@ static void results_tab(void) {}/* ---- the Toolbox menu */-static const char *const menu_items[3] = {"Identity matrix", "Clear", "Examples"};+static const char *const menu_items[3] = {T("Identity matrix"), T("Clear"), T("Examples")};static void menu_draw(void) {int x = 150, y = 60, w = 162;fill(x - 1, y - 1, w + 2, 1 + 22 + 3 * 30 + 1, C_LINE);fill(x, y, w, 22, C_TAB);- text("Matrices", x + 8, y + 4, false, C_WHITE, C_TAB);+ text(T("Matrices"), x + 8, y + 4, false, C_WHITE, C_TAB);for (int i = 0; i < 3; i++) {color_t bg = i == M.menu ? C_SEL : C_WHITE;fill(x, y + 22 + i * 30, w, 29, bg);diff --git a/launcher/src/np_xfont.h b/launcher/src/np_xfont.hnew file mode 100644index 00000000..29fcf1d4--- /dev/null+++ b/launcher/src/np_xfont.h@@ -0,0 +1,3 @@+/* Made by tools/xfont.py for a language build: the letters its texts use that the games' fonts don't+ have. English needs none. See games/common/np_text.h. */+const np_xfont_t np_xfont = {0, 0, 0};diff --git a/launcher/src/sys.c b/launcher/src/sys.cindex 92447371..170c2a0f 100644--- a/launcher/src/sys.c+++ b/launcher/src/sys.c@@ -22,18 +22,25 @@r0; \})-static bool valid_header(uint32_t address) {+/* 1 for Epsilon's header, 2 for Upsilon's (no device name: the footer two words sooner, then+ * Omega's magic; and none of the system calls for Home, checksums or flash), 0 if neither */+static int header_kind(uint32_t address) {/* the userland header sits at the start of the userland, after the kernel* (and an optional extra data sector) of either firmware slot */- if (address != 0x90010000 && address != 0x90020000 && address != 0x90410000 && address != 0x90420000) return false;+ if (address != 0x90010000 && address != 0x90020000 && address != 0x90410000 && address != 0x90420000) return 0;const np_userland_t *h = (const np_userland_t *)address;- if (h->magic != USERLAND_MAGIC || h->footer != USERLAND_MAGIC) return false;+ const volatile uint32_t *w = (const volatile uint32_t *)address;+ if (h->magic != USERLAND_MAGIC) return 0;+ int kind = h->footer == USERLAND_MAGIC ? 1 : w[9] == USERLAND_MAGIC && w[10] == 0xEFBEADDEu ? 2 : 0;/* this app must run from the app area it describes */- uint32_t self = (uint32_t)(uintptr_t)&valid_header;- return h->apps_flash_start < h->apps_flash_end && self >= h->apps_flash_start && self < h->apps_flash_end &&- h->apps_flash_start % 0x10000 == 0;+ uint32_t self = (uint32_t)(uintptr_t)&header_kind;+ bool inside = h->apps_flash_start < h->apps_flash_end && self >= h->apps_flash_start && self < h->apps_flash_end &&+ h->apps_flash_start % 0x10000 == 0;+ return inside ? kind : 0;}+static bool upsilon;+const np_userland_t *np_userland(void) {static const np_userland_t *cached;static bool done;@@ -42,24 +49,33 @@ const np_userland_t *np_userland(void) {/* Only external flash is probed: it exists on every model (RAM addresses* differ between models, and reading a missing one faults). */static const uint32_t candidates[] = {0x90010000, 0x90020000, 0x90410000, 0x90420000};- for (unsigned i = 0; i < 4; i++)- if (valid_header(candidates[i])) {- if (cached) { /* two matches: refuse to guess */- cached = 0;- return 0;- }- cached = (const np_userland_t *)candidates[i];+ for (unsigned i = 0; i < 4; i++) {+ int kind = header_kind(candidates[i]);+ if (!kind) continue;+ if (cached) { /* two matches: refuse to guess */+ cached = 0;+ upsilon = false;+ return 0;}+ cached = (const np_userland_t *)candidates[i];+ upsilon = kind == 2;+ }return cached;}+bool np_upsilon(void) { return np_userland() && upsilon; }+bool np_slow_model(void) {+ const np_userland_t *h = np_userland();+ return h && h->storage_ram < 0x24000000u;+}+/* The whole session runs with Home held back (Epsilon's circuit breaker),* and ends with the app's RAM cleared: see games/common/epsilon_app.h. */extern char _data_section_start_ram[], _heap_end[];static bool session_locked;void np_session_begin(void) {- if (!np_userland()) return;+ if (!np_userland() || np_upsilon()) return;SVC2(10, 0, 0);session_locked = true;}@@ -78,8 +94,12 @@ int np_battery_level(void) { return (int)(SVC2(4, 0, 0) & 0xFF); }bool np_battery_charging(void) { return (SVC2(3, 0, 0) & 0xFF) != 0; }bool np_flash_erase_sector(int sector) { return (SVC2(30, sector, 1) & 0xFF) != 0; }bool np_flash_write(void *dst, const void *src, uint32_t len) { return (SVC4(32, dst, src, len, 1) & 0xFF) != 0; }-void np_interrupts_lock(void) { SVC2(10, 0, 0); }-void np_interrupts_unlock(void) { SVC2(13, 0, 0); }+void np_interrupts_lock(void) {+ if (!np_upsilon()) SVC2(10, 0, 0);+}+void np_interrupts_unlock(void) {+ if (!np_upsilon()) SVC2(13, 0, 0);+}#else /* simulator */@@ -106,6 +126,8 @@ void np_interrupts_lock(void) {}void np_interrupts_unlock(void) {}void np_session_begin(void) {}int np_session_end(void) { return 0; }+bool np_upsilon(void) { return false; }+bool np_slow_model(void) { return false; }#endifint np_software_major(void) {diff --git a/launcher/src/sys.h b/launcher/src/sys.hindex 044a10a5..d3985752 100644--- a/launcher/src/sys.h+++ b/launcher/src/sys.h@@ -4,6 +4,7 @@* simulator. */#ifndef NP_SYS_H#define NP_SYS_H+#include <eadk.h>#include "np.h"typedef struct {@@ -12,13 +13,18 @@ typedef struct {uint32_t storage_ram, storage_size;uint32_t apps_flash_start, apps_flash_end;uint32_t apps_ram_start, apps_ram_end;- uint32_t name_flash_start, name_flash_end;+ uint32_t name_flash_start, name_flash_end; /* (Upsilon: the footer, then Omega's magic) */uint32_t footer; /* 0xDEC0EDFE */} np_userland_t;/* The header of the running software, or NULL if it cannot be identified. */const np_userland_t *np_userland(void);int np_software_major(void); /* 0 if unknown */+/* Upsilon, the N0110 and N0115's custom software: its header has no device+ * name, and it has none of the system calls for Home, checksums or flash */+bool np_upsilon(void);+/* an N0110 or N0115 (216 MHz), not the N0120 (550 MHz) */+bool np_slow_model(void);uint32_t np_crc32_bytes(const void *data, uint32_t len);uint32_t np_crc32_words(const uint32_t *data, uint32_t words);@@ -34,4 +40,7 @@ void np_interrupts_unlock(void);void np_session_begin(void);int np_session_end(void);bool np_flash_write(void *dst, const void *src, uint32_t len);+/* eadk_display_draw_string, also on Upsilon (launcher/src/compat.c); the games' calls come here */+void np_display_draw_string(const char *text, eadk_point_t point, bool large_font, eadk_color_t text_color,+ eadk_color_t background_color);#endifdiff --git a/launcher/src/xfont.c b/launcher/src/xfont.cnew file mode 100644index 00000000..82f54aa8--- /dev/null+++ b/launcher/src/xfont.c@@ -0,0 +1,4 @@+/* The 12-pixel font's letters for every text of NumPlay and its games (Chinese), made by+ * tools/lang.py for a language build; none in English. See games/common/np_text.h. */+#include "../../games/common/np_text.h"+#include "np_xfont.h"diff --git a/tools/gen_games.py b/tools/gen_games.pyindex 9b5d06f1..1769c4d4 100644--- a/tools/gen_games.py+++ b/tools/gen_games.py@@ -9,7 +9,10 @@ From games/games.json and the module sizes written by npmodule.py:- numplay.ld: the script of the final `ld -r`, which keeps each game's code,data image, screenshots and marks together as one block.-Usage: gen_games.py games.json MODULE_DIR OUT_DIR [--simulator]+With --only "id id ...", only those games (NumPlay for Upsilon: those that fit its RAM); each keeps+the index of its place in games.json, which its module's sections are named after.++Usage: gen_games.py games.json MODULE_DIR OUT_DIR [--simulator] [--only "id id ..."]"""import argparseimport json@@ -30,8 +33,16 @@ def main():ap.add_argument("modules")ap.add_argument("out")ap.add_argument("--simulator", action="store_true")+ ap.add_argument("--only", help="space separated game ids")a = ap.parse_args()games = json.load(open(a.manifest))+ index = {g["id"]: n for n, g in enumerate(games, 1)}+ if a.only:+ keep = a.only.split()+ missing = [i for i in keep if i not in index]+ if missing:+ raise SystemExit(f"--only: no such games: {missing}")+ games = [g for g in games if g["id"] in keep]np_h = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "launcher", "src", "np.h")).read()limit = int(re.search(r"#define NP_MAX_GAMES (\d+)", np_h).group(1))if len(games) > limit:@@ -112,8 +123,8 @@ def main():# ---- marks.sM = ["@ Generated by tools/gen_games.py: the first and last words of each game's block."]- for n, g in enumerate(games, 1):- i = g["id"]+ for g in games:+ i, n = g["id"], index[g["id"]]M += [f' .section .rodata.np.{n}.{i}.0head,"a"', " .balign 4", f" .word {HEAD:#x}",f' .section .rodata.np.{n}.{i}.zztail,"a"', " .balign 4", f" .word {TAIL:#x}"]open(os.path.join(a.out, "marks.s"), "w").write("\n".join(M) + "\n")@@ -126,8 +137,8 @@ def main():" .rodata.eadk_app_name : { KEEP(*(.rodata.eadk_app_name)) }"," .rodata.eadk_api_level : { KEEP(*(.rodata.eadk_api_level)) }"," .rodata.eadk_app_icon : { KEEP(*(.rodata.eadk_app_icon)) }"]- for n, g in enumerate(games, 1):- i = g["id"]+ for g in games:+ i, n = g["id"], index[g["id"]]p = f".rodata.np.{n}.{i}"D += [f" {p} : {{",f" np_{i}_begin = .;",