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.

Live backgrounds, home clock, French language and NumDash translation

Gabriel01e5dec15877
diff --git a/games/common/np_lang.h b/games/common/np_lang.h
new file mode 100644
index 00000000..b6e6fc34
--- /dev/null
+++ b/games/common/np_lang.h
@@ -0,0 +1,26 @@
+/* Which language the player chose in NumPlay's Settings (the launcher keeps it
+ * in the file "numplay.set" of Epsilon's file system, bit 2 of the third
+ * content byte). A game gives the file system buffer it already uses for its
+ * saves; nothing is written. Header only, no other dependencies. */
+#ifndef NP_LANG_H
+#define NP_LANG_H
+#include <stdbool.h>
+#include <stdint.h>
+
+__attribute__((unused)) static bool np_lang_french(const uint8_t *buf, uint32_t size) {
+ static const char name[] = "numplay.set";
+ if (!buf) return false;
+ for (uint32_t p = 0; p + 4 <= size;) {
+ uint32_t n = (uint32_t)buf[p] | (uint32_t)buf[p + 1] << 8;
+ if (n < 4 || p + n > size) return false; /* the zero size ends the list */
+ uint32_t i = 0;
+ while (i < sizeof name && p + 2 + i < p + n && buf[p + 2 + i] == (uint8_t)name[i]) i++;
+ if (i == sizeof name) {
+ const uint8_t *c = buf + p + 2 + sizeof name;
+ return p + n - (p + 2 + sizeof name) == 4 && c[0] == 0x4E && c[1] == 1 && (c[2] & 4);
+ }
+ p += n;
+ }
+ return false;
+}
+#endif
diff --git a/games/numdash/Makefile b/games/numdash/Makefile
index 5e1da178..4a809413 100644
--- a/games/numdash/Makefile
+++ b/games/numdash/Makefile
@@ -5,7 +5,7 @@ NWLINK = node node_modules/nwlink/bin/nwlink
WARN = -Wall -Wextra -Werror -Wno-misleading-indentation
# Like the calculator's build: no fused multiply-add, so replays play out the same.
HOST_FP = -ffp-contract=off
-CORE = src/game.c src/trig.c src/level.c src/inflate.c src/leveldata.c src/objdefs.c src/assets.c src/assets_lv.c src/gfx.c src/scene.c src/fx.c src/save.c
+CORE = src/game.c src/trig.c src/level.c src/inflate.c src/leveldata.c src/objdefs.c src/assets.c src/assets_lv.c src/gfx.c src/scene.c src/fx.c src/save.c src/tr.c
COMMON = $(CORE) src/ui.c src/app.c src/menu.c src/play.c src/editor.c
DEVICE_SOURCES = $(COMMON) src/platform_eadk.c src/main.c
DEVICE_OBJECTS = $(patsubst src/%.c,build/arm/%.o,$(DEVICE_SOURCES))
diff --git a/games/numdash/src/gfx.c b/games/numdash/src/gfx.c
index 4ce491ef..b43e6db4 100644
--- a/games/numdash/src/gfx.c
+++ b/games/numdash/src/gfx.c
@@ -550,6 +550,7 @@ static int glyph_of(int font, int ch) {
return g == 255 ? -1 : (int)g;
}
int gfx_text_width(int font, const char *s) {
+ s = gfx_tr(s);
const Font *f = &fonts[font];
int w = 0;
for (; *s && *s != '\n'; s++) {
@@ -670,6 +671,7 @@ static void draw_glyph(const Font *f, int spr, int x, int baseline, color_t top,
void gfx_text(int font, int x, int baseline, const char *s, color_t top, color_t bottom, unsigned alpha) {
const Font *f = &fonts[font];
if (baseline + f->cap < gfx_y0 - 8 || baseline - 2 * f->cap > gfx_y1 + 8 || !alpha) return;
+ s = gfx_tr(s);
x += f->outline;
for (; *s && *s != '\n'; s++) {
int g = glyph_of(font, (unsigned char)*s);
@@ -717,6 +719,7 @@ void gfx_layer_line_color(int line, color_t top, color_t bottom) {
}
void gfx_layer_build(int font, const char *s) {
+ s = gfx_tr(s);
const Font *f = &fonts[font];
int r = f->outline, line_h = f->cap + f->cap / 2 + 2 * r + 2;
int lines = 1, maxw = 0;
diff --git a/games/numdash/src/gfx.h b/games/numdash/src/gfx.h
index 5f446553..19a9c30d 100644
--- a/games/numdash/src/gfx.h
+++ b/games/numdash/src/gfx.h
@@ -73,6 +73,8 @@ static inline const Sprite *sprite_def(int spr) { return spr < SPR_COUNT ? &spri
void gfx_rectf(float x0, float y0, float x1, float y1, color_t c, unsigned alpha256, int mode);
int gfx_sprite_h(int spr, int xform);
+extern bool gfx_french; /* tr.c: the player chose French in NumPlay */
+const char *gfx_tr(const char *s); /* the text in the chosen language */
int gfx_text_width(int font, const char *s);
/* Draws outlined text with its pen at (x, baseline). top/bottom tint a
* vertical gradient over the cap height. */
diff --git a/games/numdash/src/platform_eadk.c b/games/numdash/src/platform_eadk.c
index 8b94b3e7..2a10b9f6 100644
--- a/games/numdash/src/platform_eadk.c
+++ b/games/numdash/src/platform_eadk.c
@@ -1,7 +1,9 @@
#include "platform.h"
+#include "gfx.h"
#include <eadk.h>
#include <string.h>
#include "../../common/epsilon_app.h"
+#include "../../common/np_lang.h"
bool platform_begin(void) {
np_app_begin();
@@ -9,7 +11,12 @@ bool platform_begin(void) {
}
int platform_end(void) { return np_app_end(); }
-bool platform_init(void) { return true; }
+bool platform_init(void) {
+ uint32_t n = 0;
+ const uint8_t *b = epsilon_storage(&n);
+ gfx_french = np_lang_french(b, n); /* NumPlay > Settings > Language */
+ return true;
+}
void platform_close(void) {}
uint32_t platform_millis(void) { return (uint32_t)eadk_timing_millis(); }
void platform_sleep(unsigned ms) { eadk_timing_msleep(ms); }
diff --git a/games/numdash/src/tr.c b/games/numdash/src/tr.c
new file mode 100644
index 00000000..7d20f741
--- /dev/null
+++ b/games/numdash/src/tr.c
@@ -0,0 +1,173 @@
+/* French for NumDash. Texts are drawn through gfx_text and friends, which ask
+ * tr() for the text to show: English as written in the code, or French when the
+ * player chose it in NumPlay's Settings. The pixel font is capitals only and has
+ * no accents, so the French is written without them. Level names (Stereo
+ * Madness, Polargeist...) stay as in the original game. */
+#include <string.h>
+#include "gfx.h"
+
+bool gfx_french;
+
+typedef struct {
+ const char *en, *fr;
+} pair_t;
+
+static const pair_t pairs[] = {
+ {" OBJECTS", " OBJETS"},
+ {"+ - OR TOOLBOX: PICK OBJECT", "+ - OU OUTILS: CHOISIR"},
+ {"0: BUILD / EDIT / DELETE", "0: POSER / EDITER / SUPPR."},
+ {"ALPHA: UNDO BACKSPACE: ERASE", "ALPHA: ANNULER RETOUR: EFFACER"},
+ {"AMAZING!", "FABULEUX!"},
+ {"ARE YOU SURE YOU\nWANT TO QUIT?", "ES-TU SUR DE\nVOULOIR QUITTER?"},
+ {"WANT TO QUIT?", "VOULOIR QUITTER?"},
+ {"ARROWS", "FLECHES"},
+ {"ARROWS: MOVE OK: USE TOOL", "FLECHES: BOUGER OK: UTILISER"},
+ {"ATTEMPT ", "ESSAI "},
+ {"ATTEMPTS: ", "ESSAIS: "},
+ {"Attempt N", "Essai N"},
+ {"AUTO CHECKPOINTS", "POINTS DE CONTROLE AUTO"},
+ {"AWESOME!", "GENIAL!"},
+ {"BACK FOR MORE ARE YA?", "TU EN VEUX ENCORE?"},
+ {"BACK ON TRACK", "REPARTI!"},
+ {"BACK", "RETOUR"},
+ {"BACK: PAUSE HOME: SAVE AND QUIT", "RETOUR: PAUSE ACCUEIL: SAUVER+QUITTER"},
+ {"BACKSPACE REMOVES THE LAST ONE", "RETOUR ENLEVE LE DERNIER"},
+ {"BACKSPACE", "RETOUR"},
+ {"BLUE", "BLEU"},
+ {"BRILLIANT!", "BRILLANT!"},
+ {"BUILD YOUR OWN LEVELS USING THE LEVEL EDITOR", "CREE TES NIVEAUX AVEC L'EDITEUR"},
+ {"BUILD", "CONSTRUIRE"},
+ {"CALCULATING CHANCE OF SUCCESS", "CALCUL DES CHANCES DE REUSSITE"},
+ {"CAN YOU BEAT THEM ALL?", "PEUX-TU TOUS LES BATTRE?"},
+ {"CANCEL", "ANNULER"},
+ {"CHALLENGE BREAKER!", "BRISEUR DE DEFIS!"},
+ {"CHANGE MODE", "CHANGER DE MODE"},
+ {"CLEAR LEVEL", "VIDER LE NIVEAU"},
+ {"CLEAR", "VIDER"},
+ {"COLOR 1", "COULEUR 1"},
+ {"COLOR 2", "COULEUR 2"},
+ {"COLORS", "COULEURS"},
+ {"COMPLETED LEVELS", "NIVEAUX TERMINES"},
+ {"COPY BLOCK", "COPIER LE BLOC"},
+ {"CUSTOMIZE YOUR CHARACTER'S ICON AND COLOR!", "PERSONNALISE TON ICONE ET SA COULEUR!"},
+ {"DELETE", "SUPPRIMER"},
+ {"EDIT", "EDITER"},
+ {"EDITOR KEYS", "TOUCHES"},
+ {"EXE: PLAYTEST BACK: EXIT", "EXE: TESTER RETOUR: SORTIR"},
+ {"EXE: PLAYTEST", "EXE: TESTER"},
+ {"FAKE SPIKES ARE FAKE", "LES FAUX PIQUES SONT FAUX"},
+ {"GOOD JOB!", "BON TRAVAIL!"},
+ {"GREEN", "VERT"},
+ {"HOLD DOWN TO KEEP JUMPING", "MAINTIENS POUR SAUTER EN CONTINU"},
+ {"HOLD TO KEEP JUMPING OR TO FLY", "MAINTIENS POUR SAUTER OU VOLER"},
+ {"HOME", "ACCUEIL"},
+ {"HOW IS THIS POSSIBLE!?", "COMMENT C'EST POSSIBLE!?"},
+ {"HOW TO PLAY", "COMMENT JOUER"},
+ {"I AM SPEECHLESS...", "SANS VOIX..."},
+ {"ICON KIT", "KIT D'ICONES"},
+ {"IF AT FIRST YOU DON'T SUCCEED, TRY, TRY AGAIN...", "SI TU RATES, REESSAIE, REESSAIE..."},
+ {"IMPRESSIVE!", "IMPRESSIONNANT!"},
+ {"INCREDIBLE!", "INCROYABLE!"},
+ {"IT WITHOUT ANY CHECKPOINTS!", "SANS AUCUN POINT DE CONTROLE!"},
+ {"IT'S ALL IN THE TIMING", "TOUT EST DANS LE TIMING"},
+ {"JUMPER", "SAUTEUR"},
+ {"JUMPS: ", "SAUTS: "},
+ {"KEYS", "TOUCHES"},
+ {"LEFT RIGHT: CHANGE BACK: CLOSE", "GAUCHE DROITE: CHANGER RETOUR: FERMER"},
+ {"LEVEL CLEARED", "NIVEAU REUSSI"},
+ {"LEVEL COMPLETE!", "NIVEAU TERMINE!"},
+ {"LEVEL DATA INVALID", "NIVEAU INVALIDE"},
+ {"LEVEL EDITOR", "EDITEUR"},
+ {"LEVEL SAVED", "NIVEAU SAUVE"},
+ {"LEVEL SETTINGS", "OPTIONS NIVEAU"},
+ {"LIME", "CITRON VERT"},
+ {"LISTEN TO THE MUSIC TO HELP TIME YOUR JUMPS", "ECOUTE LA MUSIQUE POUR CALER TES SAUTS"},
+ {"LN: SETTINGS", "LN: REGLAGES"},
+ {"LOADING WILL BE FINISHED... SOON", "LE CHARGEMENT SE TERMINE... BIENTOT"},
+ {"LOW DETAIL", "PEU DE DETAILS"},
+ {"MOVE", "BOUGER"},
+ {"MY LEVEL 1", "MON NIVEAU 1"},
+ {"MY LEVEL 2", "MON NIVEAU 2"},
+ {"MY LEVEL 3", "MON NIVEAU 3"},
+ {"MY LEVELS", "MES NIVEAUX"},
+ {"My levels", "Mes niveaux"},
+ {"NEW BEST!\n", "NOUVEAU RECORD!\n"},
+ {"NEXT BLOCK", "BLOC SUIVANT"},
+ {"NO SHAKE", "SANS SECOUSSES"},
+ {"NORMAL MODE", "MODE NORMAL"},
+ {"NOT BAD!", "PAS MAL!"},
+ {"NOT SAVED - STORAGE FULL", "NON SAUVE - MEMOIRE PLEINE"},
+ {"NOTHING TO UNDO", "RIEN A ANNULER"},
+ {"NUMWORKS EDITION", "EDITION NUMWORKS"},
+ {"OBJECT LIMIT REACHED", "LIMITE D'OBJETS ATTEINTE"},
+ {"OK, EXE OR UP: JUMP", "OK, EXE OU HAUT: SAUTER"},
+ {"OK: GOT IT", "OK: COMPRIS"},
+ {"OK: TOGGLE BACK: SAVE", "OK: CHOIX RETOUR: SAUVER"},
+ {"ONLY ONE BUTTON REQUIRED TO CRASH", "UN SEUL BOUTON POUR SE PLANTER"},
+ {"PINK", "ROSE"},
+ {"PLAY", "JOUER"},
+ {"PLAY, CRASH, RINSE AND REPEAT", "JOUE, PLANTE, RECOMMENCE"},
+ {"PLAYTEST", "TESTER"},
+ {"PLUM", "PRUNE"},
+ {"PRACTICE COMPLETE!", "ENTRAINEMENT TERMINE!"},
+ {"PRACTICE MODE", "ENTRAINEMENT"},
+ {"PRACTICE: 0 PLACES A CHECKPOINT", "ENTRAINEMENT: 0 POSE UN POINT"},
+ {"PREV BLOCK", "BLOC PRECEDENT"},
+ {"PRO TIP: DON'T CRASH", "ASTUCE: NE TE PLANTE PAS"},
+ {"PRO TIP: JUMP", "ASTUCE: SAUTE"},
+ {"PROGRESS BAR", "BARRE DE PROGRES"},
+ {"PURPLE", "POURPRE"},
+ {"QUIT GAME", "QUITTER LE JEU"},
+ {"QUIT", "QUITTER"},
+ {"RED", "ROUGE"},
+ {"REFLEX MASTER!", "MAITRE REFLEXE!"},
+ {"RESTART", "RECOMMENCER"},
+ {"RESUME", "REPRENDRE"},
+ {"ROTATE", "PIVOTER"},
+ {"SAVE DATA UNREADABLE", "SAUVEGARDE ILLISIBLE"},
+ {"SAVE FAILED - STORAGE FULL", "ECHEC - MEMOIRE PLEINE"},
+ {"SAVE", "SAUVER"},
+ {"SAVE, LEAVE", "SAUVER, QUITTER"},
+ {"SECRET COINS", "PIECES SECRETES"},
+ {"SETTINGS", "REGLAGES"},
+ {"SHIFT: ROTATE XNT: COPY", "SHIFT: PIVOTER XNT: COPIER"},
+ {"SHIP", "VAISSEAU"},
+ {"SHOW FPS", "AFFICHER LES FPS"},
+ {"SHOW PERCENT", "AFFICHER %"},
+ {"SKILLFUL!", "HABILE!"},
+ {"SPIKES ARE NOT YOUR FRIENDS. DON'T FORGET TO JUMP", "LES PIQUES NE SONT PAS TES AMIS. SAUTE!"},
+ {"STARS", "ETOILES"},
+ {"START MODE", "MODE DE DEPART"},
+ {"START PRACTICE FROM THE PAUSE MENU", "LANCE L'ENTRAINEMENT DEPUIS LA PAUSE"},
+ {"SURE?", "SUR?"},
+ {"TAP IN MID AIR ON AN ORB", "APPUIE EN L'AIR SUR UN ORBE"},
+ {"THIS LEVEL IS EMPTY", "CE NIVEAU EST VIDE"},
+ {"TIME: ", "TEMPS: "},
+ {"TOOLBOX", "OUTILS"},
+ {"TOTAL ATTEMPTS", "ESSAIS TOTAUX"},
+ {"TOTAL JUMPS", "SAUTS TOTAUX"},
+ {"UNDO", "ANNULER"},
+ {"UNSAVED", "NON SAUVE"},
+ {"UP DOWN: LEVEL LEFT RIGHT: EDIT / PLAY", "HAUT BAS: NIVEAU GAUCHE DROITE: EDITER/JOUER"},
+ {"USE PRACTICE MODE TO LEARN THE LAYOUT OF A LEVEL", "UTILISE L'ENTRAINEMENT POUR APPRENDRE UN NIVEAU"},
+ {"USE THE MODE", "UTILISE LE MODE"},
+ {"VAR: SAVE LN: LEVEL SETTINGS", "VAR: SAUVER LN: REGLAGES DU NIVEAU"},
+ {"WARP SPEED!", "VITESSE LUMIERE!"},
+ {"WELL DONE!", "BIEN JOUE!"},
+ {"WELL DONE... NOW TRY TO COMPLETE", "BRAVO... ESSAIE MAINTENANT DE LE FINIR"},
+ {"WHERE DID I PUT THAT COIN...", "OU AI-JE MIS CETTE PIECE..."},
+ {"YES", "OUI"},
+ {"YOU ARE... THE ONE!", "TU ES... L'ELU!"},
+ {"YOU BEAT ME...", "TU M'AS BATTU..."},
+};
+
+#define NPAIRS ((int)(sizeof pairs / sizeof pairs[0]))
+
+/* s may point into the middle of a longer text (the lines of a message are drawn one by one):
+ the whole rest of the string is what is compared. */
+const char *gfx_tr(const char *s) {
+ if (!gfx_french || !s || !*s) return s;
+ for (int i = 0; i < NPAIRS; i++)
+ if (pairs[i].en[0] == s[0] && !strcmp(pairs[i].en, s)) return pairs[i].fr;
+ return s;
+}
diff --git a/launcher/src/font.h b/launcher/src/font.h
index 1436d19c..ac466201 100644
--- a/launcher/src/font.h
+++ b/launcher/src/font.h
@@ -16,4 +16,6 @@ typedef struct {
} np_font_t;
extern const np_font_t np_font_title, np_font_body, np_font_small;
+/* Latin-1 code points of the glyphs after the 95 ASCII ones (count - 95 of them). */
+extern const unsigned char np_font_extra[];
#endif
diff --git a/launcher/src/font_data.c b/launcher/src/font_data.c
index 85fcfc47..6d51d20f 100644
--- a/launcher/src/font_data.c
+++ b/launcher/src/font_data.c
@@ -1,7 +1,11 @@
-/* Generated by tools/fontgen.py from Nunito (SIL Open Font License 1.1). */
+/* Generated by tools/fontgen.py from Nunito (SIL Open Font License 1.1).
+ * The ASCII glyphs are the original ones; the Latin-1 letters after them (np_font_extra) were
+ * added for French. */
#include "font.h"
-static const uint8_t np_font_title_data[7603] = {
+const unsigned char np_font_extra[29] = {0xb0, 0xab, 0xbb, 0xc0, 0xc2, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xce, 0xcf, 0xd4, 0xd9, 0xdb, 0xdc, 0xe0, 0xe2, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xee, 0xef, 0xf4, 0xf9, 0xfb, 0xfc};
+
+static const uint8_t np_font_title_data[10618] = {
128,222,36,255,207,242,255,29,255,191,224,255,9,252,127,160,255,6,248,79,112,255,2,226,
11,0,0,0,233,61,243,255,58,255,175,144,223,3,231,61,64,238,245,255,10,252,223,255,
159,192,255,220,255,7,250,175,251,95,128,255,136,255,3,246,111,162,8,16,153,1,0,96,
@@ -318,9 +322,135 @@ static const uint8_t np_font_title_data[7603] = {
0,0,248,255,4,0,128,255,79,0,0,247,255,4,0,96,255,143,0,0,209,255,255,5,
0,244,255,159,0,226,255,190,3,112,255,111,0,0,248,255,4,0,128,255,79,0,0,248,
255,4,0,144,255,79,0,248,255,255,2,208,255,255,11,0,180,187,23,0,0,112,238,58,
- 0,100,96,255,255,191,248,63,248,74,249,255,207,0,4,0,146,139,1,
+ 0,100,96,255,255,191,248,63,248,74,249,255,207,0,4,0,146,139,1,32,234,174,2,209,
+ 255,255,29,246,44,194,111,247,8,128,127,244,94,229,95,176,255,255,11,0,182,123,0,0,
+ 136,1,128,24,112,255,7,248,127,243,255,52,255,79,251,207,176,255,12,255,143,240,255,8,
+ 250,223,160,255,13,226,255,37,254,95,96,255,6,246,111,0,118,0,96,7,164,4,64,74,
+ 0,253,30,208,239,1,251,175,176,255,10,244,255,68,255,79,224,255,7,254,127,245,255,83,
+ 255,63,252,143,192,255,8,253,29,208,223,1,131,2,48,40,0,0,0,227,29,0,0,0,
+ 0,0,0,246,175,0,0,0,0,0,0,160,255,5,0,0,0,0,0,0,250,5,0,0,
+ 0,0,0,0,16,0,0,0,0,0,0,0,229,110,0,0,0,0,0,32,255,255,3,0,
+ 0,0,0,144,255,255,10,0,0,0,0,225,255,255,47,0,0,0,0,248,223,253,159,0,
+ 0,0,16,254,127,246,255,1,0,0,112,255,31,225,255,8,0,0,208,255,9,128,255,30,
+ 0,0,246,255,3,32,255,127,0,0,253,255,255,255,255,239,0,80,255,255,255,255,255,255,
+ 6,192,255,255,255,255,255,255,13,244,255,8,0,0,112,255,95,248,255,2,0,0,16,254,
+ 175,245,127,0,0,0,0,246,127,16,1,0,0,0,0,16,1,0,0,0,16,1,0,0,
+ 0,0,0,0,249,159,0,0,0,0,0,112,255,255,7,0,0,0,0,243,175,250,63,0,
+ 0,0,0,244,11,176,79,0,0,0,0,16,0,0,1,0,0,0,0,0,230,110,0,0,
+ 0,0,0,32,255,255,3,0,0,0,0,144,255,255,10,0,0,0,0,242,255,255,47,0,
+ 0,0,0,248,223,253,159,0,0,0,16,254,127,247,239,1,0,0,112,255,30,225,255,8,
+ 0,0,225,255,9,144,255,30,0,0,246,255,3,48,255,127,0,0,253,255,255,255,255,223,
+ 0,80,255,255,255,255,255,255,6,192,255,255,255,255,255,255,12,244,255,7,0,0,112,255,
+ 79,249,239,1,0,0,16,254,175,245,127,0,0,0,0,246,111,16,1,0,0,0,0,16,
+ 1,0,16,183,254,206,57,0,80,254,255,255,255,95,80,255,255,255,255,255,25,254,255,125,
+ 68,215,62,247,255,29,0,0,0,192,255,95,0,0,0,0,254,255,1,0,0,0,240,255,
+ 15,0,0,0,0,254,255,1,0,0,0,192,255,95,0,0,0,0,248,255,28,0,0,0,
+ 32,255,255,109,67,199,61,112,255,255,255,255,255,9,112,255,255,255,255,127,0,32,217,255,
+ 239,91,0,0,0,208,143,2,0,0,0,0,168,223,0,0,0,0,170,250,14,0,0,0,
+ 160,254,76,0,0,0,211,10,0,0,0,128,255,7,0,0,0,209,255,3,0,0,0,209,
+ 95,0,0,0,0,49,0,0,32,185,187,187,187,91,249,255,255,255,255,189,255,255,255,255,
+ 175,251,255,68,68,52,176,255,15,0,0,0,251,255,0,0,0,176,255,255,255,255,45,251,
+ 255,255,255,255,181,255,255,255,255,45,251,255,0,0,0,176,255,15,0,0,0,251,255,0,
+ 0,0,176,255,255,255,255,143,250,255,255,255,255,61,253,255,255,255,143,0,0,0,177,44,
+ 0,0,0,144,255,7,0,0,64,255,27,0,0,0,246,27,0,0,0,0,3,0,32,185,
+ 187,187,187,91,249,255,255,255,255,189,255,255,255,255,175,251,255,68,68,52,176,255,15,0,
+ 0,0,251,255,0,0,0,176,255,255,255,255,45,251,255,255,255,255,181,255,255,255,255,45,
+ 251,255,0,0,0,176,255,15,0,0,0,251,255,0,0,0,176,255,255,255,255,143,250,255,
+ 255,255,255,61,253,255,255,255,143,0,0,232,110,0,0,0,246,255,79,0,0,243,175,252,
+ 30,0,96,207,17,253,4,0,48,1,16,3,32,185,187,187,187,91,249,255,255,255,255,189,
+ 255,255,255,255,175,251,255,68,68,52,176,255,15,0,0,0,251,255,0,0,0,176,255,255,
+ 255,255,45,251,255,255,255,255,181,255,255,255,255,45,251,255,0,0,0,176,255,15,0,0,
+ 0,251,255,0,0,0,176,255,255,255,255,143,250,255,255,255,255,61,253,255,255,255,143,0,
+ 48,1,32,3,0,176,239,65,255,8,0,255,63,247,191,0,128,191,32,237,5,0,0,0,
+ 0,0,32,185,187,187,187,91,249,255,255,255,255,189,255,255,255,255,175,251,255,68,68,52,
+ 176,255,15,0,0,0,251,255,0,0,0,176,255,255,255,255,45,251,255,255,255,255,181,255,
+ 255,255,255,45,251,255,0,0,0,176,255,15,0,0,0,251,255,0,0,0,176,255,255,255,
+ 255,143,250,255,255,255,255,61,253,255,255,255,143,0,16,1,0,0,248,191,1,80,255,255,
+ 9,226,175,247,95,226,27,128,94,0,0,0,0,0,212,126,0,0,250,239,0,0,251,255,
+ 0,0,251,255,0,0,251,255,0,0,251,255,0,0,251,255,0,0,251,255,0,0,251,255,
+ 0,0,251,255,0,0,251,255,0,0,251,255,0,0,251,255,0,0,250,239,0,0,212,126,
+ 0,96,23,32,71,96,255,10,253,47,247,175,224,255,19,169,3,181,8,0,0,0,0,0,
+ 16,252,10,0,0,247,255,3,0,128,255,79,0,0,248,255,4,0,128,255,79,0,0,248,
+ 255,4,0,128,255,79,0,0,248,255,4,0,128,255,79,0,0,248,255,4,0,128,255,79,
+ 0,0,248,255,4,0,128,255,79,0,0,247,255,3,0,16,252,10,0,0,0,32,252,43,
+ 0,0,0,0,16,253,255,12,0,0,0,0,249,143,255,8,0,0,0,208,95,96,207,0,
+ 0,0,0,33,0,48,1,0,0,0,113,236,239,124,1,0,0,229,255,255,255,239,4,0,
+ 245,255,255,255,255,255,4,225,255,223,70,198,255,239,113,255,207,1,0,209,255,127,251,255,
+ 5,0,0,245,255,235,255,31,0,0,16,255,239,255,255,0,0,0,240,255,239,255,31,0,
+ 0,16,255,239,252,255,4,0,0,244,255,140,255,191,0,0,176,255,143,242,255,159,2,162,
+ 255,255,2,247,255,255,255,255,255,7,0,248,255,255,255,255,8,0,0,180,255,255,191,4,
+ 0,0,0,16,67,19,0,0,0,0,96,191,0,0,0,0,0,144,255,7,0,0,0,0,
+ 16,252,46,0,0,0,0,0,193,46,0,0,0,0,0,0,1,0,0,0,212,126,0,0,
+ 0,250,28,250,239,0,0,48,255,127,251,255,0,0,64,255,143,251,255,0,0,64,255,143,
+ 251,255,0,0,64,255,143,251,255,0,0,64,255,143,251,255,0,0,64,255,143,251,255,0,
+ 0,64,255,143,251,255,0,0,64,255,127,251,255,1,0,80,255,127,249,255,5,0,144,255,
+ 95,245,255,94,17,247,255,31,208,255,255,255,255,255,10,48,254,255,255,255,207,1,0,146,
+ 254,255,239,24,0,0,0,32,52,2,0,0,0,0,0,17,0,0,0,0,0,160,255,8,
+ 0,0,0,0,248,255,95,0,0,0,64,255,184,239,2,0,0,96,175,16,252,3,0,0,
+ 0,1,0,16,0,0,212,126,0,0,0,250,28,250,239,0,0,48,255,127,251,255,0,0,
+ 64,255,143,251,255,0,0,64,255,143,251,255,0,0,64,255,143,251,255,0,0,64,255,143,
+ 251,255,0,0,64,255,143,251,255,0,0,64,255,143,251,255,0,0,64,255,127,251,255,1,
+ 0,80,255,127,249,255,5,0,144,255,95,245,255,94,17,247,255,31,208,255,255,255,255,255,
+ 10,48,254,255,255,255,207,1,0,146,254,255,239,24,0,0,0,32,52,2,0,0,0,32,
+ 71,0,118,1,0,0,208,255,98,255,10,0,0,224,255,115,255,10,0,0,80,139,16,169,
+ 3,0,0,0,0,0,0,0,0,212,126,0,0,0,250,28,250,239,0,0,48,255,127,251,
+ 255,0,0,64,255,143,251,255,0,0,64,255,143,251,255,0,0,64,255,143,251,255,0,0,
+ 64,255,143,251,255,0,0,64,255,143,251,255,0,0,64,255,143,251,255,0,0,64,255,127,
+ 251,255,1,0,80,255,127,249,255,5,0,144,255,95,245,255,94,17,247,255,31,208,255,255,
+ 255,255,255,10,48,254,255,255,255,207,1,0,146,254,255,239,24,0,0,0,32,52,2,0,
+ 0,0,48,4,0,0,0,64,255,5,0,0,0,244,207,0,0,0,0,248,95,0,0,0,
+ 0,252,11,0,0,0,32,73,0,0,0,48,118,87,2,0,211,255,255,255,8,128,255,255,
+ 255,255,6,195,106,84,253,207,0,0,0,128,255,14,129,236,255,255,255,208,255,207,219,255,
+ 63,255,111,0,249,255,243,255,74,247,255,15,252,255,255,254,255,16,251,255,75,255,10,0,
+ 65,3,32,3,0,0,64,21,0,0,0,128,255,28,0,0,48,255,255,7,0,0,251,140,
+ 239,1,0,243,63,192,127,0,0,88,0,146,2,0,48,118,87,2,0,211,255,255,255,8,
+ 128,255,255,255,255,6,195,106,84,253,207,0,0,0,128,255,14,129,236,255,255,255,208,255,
+ 207,219,255,63,255,111,0,249,255,243,255,74,247,255,15,252,255,255,254,255,16,251,255,75,
+ 255,10,0,65,3,32,3,0,0,49,35,0,0,179,255,255,76,64,255,255,255,175,225,255,
+ 191,168,110,245,255,10,0,0,247,255,5,0,0,247,255,5,0,0,245,255,9,0,0,225,
+ 255,175,134,92,80,255,255,255,191,0,213,255,255,94,0,0,246,92,1,0,0,212,255,3,
+ 0,48,87,251,7,0,112,255,223,2,0,0,50,3,0,0,48,4,0,0,0,48,255,5,
+ 0,0,0,243,223,0,0,0,0,248,111,0,0,0,0,251,11,0,0,0,32,73,0,0,
+ 0,16,117,71,0,0,96,254,255,223,3,96,255,255,255,239,18,254,191,18,249,159,245,255,
+ 2,16,255,125,255,255,255,255,255,247,255,188,187,187,73,255,111,0,0,0,208,255,175,136,
+ 252,7,227,255,255,255,175,0,162,254,255,191,2,0,0,67,19,0,0,0,0,48,4,0,
+ 0,0,48,255,6,0,0,0,250,111,0,0,0,243,191,0,0,0,128,223,1,0,0,0,
+ 146,3,0,0,16,117,71,0,0,96,254,255,223,3,96,255,255,255,239,18,254,191,18,249,
+ 159,245,255,2,16,255,125,255,255,255,255,255,247,255,188,187,187,73,255,111,0,0,0,208,
+ 255,175,136,252,7,227,255,255,255,175,0,162,254,255,191,2,0,0,67,19,0,0,0,64,
+ 4,0,0,0,160,255,11,0,0,80,255,255,5,0,0,253,170,223,0,0,245,30,225,95,
+ 0,16,73,0,148,1,0,16,117,71,0,0,96,254,255,223,3,96,255,255,255,239,18,254,
+ 191,18,249,159,245,255,2,16,255,125,255,255,255,255,255,247,255,188,187,187,73,255,111,0,
+ 0,0,208,255,175,136,252,7,227,255,255,255,175,0,162,254,255,191,2,0,0,67,19,0,
+ 0,48,2,32,3,0,128,255,68,255,8,0,251,127,247,191,0,80,222,34,237,5,0,0,
+ 0,0,0,0,0,81,119,4,0,0,230,255,255,61,0,246,255,255,255,46,225,255,43,145,
+ 255,89,255,47,0,241,223,247,255,255,255,255,127,255,207,187,187,155,244,255,6,0,0,0,
+ 253,255,138,200,111,48,254,255,255,255,9,32,234,255,255,42,0,0,48,52,1,0,0,48,
+ 2,0,0,251,127,0,96,255,255,2,225,159,252,11,247,29,243,63,163,3,96,25,0,113,
+ 6,0,0,252,143,0,0,255,191,0,0,255,191,0,0,255,191,0,0,255,191,0,0,255,
+ 191,0,0,255,191,0,0,255,191,0,0,255,191,0,0,249,111,0,0,48,2,0,48,2,
+ 16,19,248,79,225,207,251,127,243,255,229,45,176,143,0,0,0,0,0,96,23,0,0,248,
+ 207,0,0,251,255,0,0,251,255,0,0,251,255,0,0,251,255,0,0,251,255,0,0,251,
+ 255,0,0,251,255,0,0,251,255,0,0,246,159,0,0,32,3,0,0,0,48,21,0,0,
+ 0,0,246,223,1,0,0,32,254,255,9,0,0,144,223,247,47,0,0,241,79,176,159,0,
+ 0,128,6,32,57,0,0,0,116,103,2,0,0,230,255,255,191,1,96,255,255,255,255,29,
+ 225,255,110,180,255,143,245,255,7,16,254,223,247,255,4,0,252,255,247,255,5,0,252,239,
+ 244,255,9,32,255,207,208,255,175,216,255,111,64,254,255,255,255,11,0,179,255,255,126,0,
+ 0,0,49,36,0,0,0,82,1,0,0,0,225,159,0,0,0,16,254,47,0,0,0,80,
+ 255,9,0,0,0,144,239,0,0,0,0,128,6,0,0,114,22,0,48,87,192,255,9,16,
+ 255,95,255,191,0,244,255,248,255,11,64,255,143,255,191,0,244,255,248,255,11,64,255,143,
+ 255,191,0,244,255,232,255,12,112,255,143,252,255,153,255,255,120,255,255,255,255,127,144,255,
+ 223,196,255,3,16,51,0,48,2,0,0,83,1,0,0,0,246,223,1,0,0,225,255,159,
+ 0,0,144,223,247,63,0,16,255,4,251,9,0,112,6,16,57,0,114,22,0,48,87,192,
+ 255,9,16,255,95,255,191,0,244,255,248,255,11,64,255,143,255,191,0,244,255,248,255,11,
+ 64,255,143,255,191,0,244,255,232,255,12,112,255,143,252,255,153,255,255,120,255,255,255,255,
+ 127,144,255,223,196,255,3,16,51,0,48,2,0,50,0,49,0,0,244,143,225,207,0,112,
+ 255,59,255,15,0,210,94,176,143,0,0,0,0,0,0,32,103,1,0,115,5,252,159,0,
+ 241,255,245,255,11,64,255,143,255,191,0,244,255,248,255,11,64,255,143,255,191,0,244,255,
+ 248,255,11,64,255,143,254,207,0,247,255,200,255,159,249,255,143,247,255,255,255,255,7,249,
+ 255,77,252,63,0,49,3,0,35,0,
};
-static const np_glyph_t np_font_title_glyphs[95] = {
+static const np_glyph_t np_font_title_glyphs[124] = {
{0, 0, 0, 0, 6, 0},
{5, 15, 0, -15, 6, 0},
{9, 7, 1, -15, 11, 38},
@@ -416,10 +546,39 @@ static const np_glyph_t np_font_title_glyphs[95] = {
{5, 19, 1, -15, 7, 7447},
{9, 19, 0, -15, 9, 7495},
{11, 4, 1, -8, 12, 7581},
+ {8, 7, 0, -15, 8, 7603},
+ {10, 9, 1, -10, 12, 7631},
+ {10, 9, 1, -10, 12, 7676},
+ {16, 21, 0, -20, 16, 7721},
+ {16, 22, 0, -21, 16, 7889},
+ {13, 19, 1, -15, 14, 8065},
+ {11, 20, 1, -20, 13, 8189},
+ {11, 20, 1, -20, 13, 8299},
+ {11, 20, 1, -20, 13, 8409},
+ {11, 20, 1, -20, 13, 8519},
+ {8, 21, -1, -21, 7, 8629},
+ {9, 20, -1, -20, 7, 8713},
+ {15, 21, 1, -20, 17, 8803},
+ {14, 21, 1, -20, 16, 8961},
+ {14, 22, 1, -21, 16, 9108},
+ {14, 21, 1, -20, 16, 9262},
+ {11, 18, 0, -17, 12, 9409},
+ {11, 18, 0, -17, 12, 9508},
+ {10, 16, 0, -11, 10, 9607},
+ {11, 18, 0, -17, 12, 9687},
+ {11, 18, 0, -17, 12, 9786},
+ {11, 18, 0, -17, 12, 9885},
+ {11, 17, 0, -16, 12, 9984},
+ {8, 18, -1, -17, 6, 10078},
+ {8, 17, -1, -16, 6, 10150},
+ {12, 18, 0, -17, 13, 10218},
+ {11, 18, 1, -17, 13, 10326},
+ {11, 18, 1, -17, 13, 10425},
+ {11, 17, 1, -16, 13, 10524},
};
-const np_font_t np_font_title = {32, 95, 18, 5, np_font_title_glyphs, np_font_title_data};
+const np_font_t np_font_title = {32, 124, 21, 5, np_font_title_glyphs, np_font_title_data};
-static const uint8_t np_font_body_data[2788] = {
+static const uint8_t np_font_body_data[3921] = {
113,98,143,245,71,111,243,20,63,96,80,94,229,5,113,49,6,245,167,47,244,149,31,242,
115,14,48,0,2,0,66,96,1,144,25,47,113,189,249,21,248,201,93,48,31,138,0,214,
208,5,246,255,255,6,108,228,0,224,99,11,0,1,16,0,0,208,6,0,80,191,4,193,
@@ -536,9 +695,56 @@ static const uint8_t np_font_body_data[2788] = {
0,244,9,64,143,96,237,3,196,79,0,244,9,64,159,0,244,26,16,254,14,16,36,69,
207,207,207,207,207,207,207,207,207,206,18,117,5,160,254,3,128,95,0,248,5,112,95,0,
226,110,48,207,4,247,5,128,95,16,249,5,252,46,32,20,0,48,55,32,33,207,207,94,
- 48,32,87,0,
+ 48,32,87,0,96,23,200,186,91,225,229,157,32,3,16,6,67,144,30,158,242,136,63,225,
+ 91,95,80,15,171,0,1,0,97,48,4,243,149,30,192,61,143,225,91,95,228,146,11,16,
+ 0,0,0,49,0,0,0,96,47,0,0,0,128,9,0,0,0,114,1,0,0,176,159,0,
+ 0,48,223,47,0,0,233,243,8,0,242,9,235,1,128,111,132,127,16,254,255,255,14,247,
+ 38,34,247,182,13,0,16,174,17,0,0,16,0,0,16,21,0,0,0,235,12,0,0,196,
+ 177,5,0,0,113,1,0,0,160,175,0,0,32,223,47,0,0,248,243,9,0,225,10,250,
+ 1,112,127,116,143,0,254,255,255,30,246,39,34,246,167,30,0,0,189,16,0,0,16,1,
+ 0,81,103,2,64,254,255,95,225,143,84,74,245,9,0,0,247,5,0,0,247,6,0,0,
+ 244,11,0,0,176,207,152,110,16,233,255,60,0,32,126,0,0,96,216,0,0,16,20,0,
+ 0,20,0,0,224,9,0,0,211,1,0,135,136,55,243,222,221,71,159,0,0,244,9,0,
+ 64,255,255,79,244,91,85,65,159,0,0,244,91,85,34,254,255,143,0,0,49,0,0,176,
+ 11,0,48,29,0,135,136,55,243,222,221,71,159,0,0,244,9,0,64,255,255,79,244,91,
+ 85,65,159,0,0,244,91,85,34,254,255,143,0,64,3,0,80,238,3,0,77,167,0,135,
+ 136,55,243,222,221,71,159,0,0,244,9,0,64,255,255,79,244,91,85,65,159,0,0,244,
+ 91,85,34,254,255,143,32,110,218,0,161,116,9,112,136,120,51,239,221,125,244,9,0,64,
+ 159,0,0,244,255,255,68,191,85,21,244,9,0,64,191,85,37,226,255,255,8,0,37,0,
+ 233,29,210,162,7,112,2,64,143,0,244,9,64,159,0,244,9,64,159,0,244,9,64,159,
+ 0,242,7,0,1,0,226,214,26,74,121,0,54,0,241,11,16,191,0,241,11,16,191,0,
+ 241,11,16,191,0,241,11,0,174,0,16,0,0,0,37,0,0,0,234,29,0,0,178,129,
+ 6,0,16,117,38,0,48,254,255,127,16,238,5,194,79,245,8,0,243,122,95,0,0,207,
+ 247,6,0,241,60,191,0,96,143,160,175,134,239,1,145,254,191,2,0,0,18,0,0,0,
+ 66,0,0,0,96,63,0,0,0,112,7,0,0,39,0,48,6,244,8,0,251,65,159,0,
+ 176,31,244,9,0,251,65,159,0,176,31,244,9,0,251,33,191,0,208,14,192,159,182,175,
+ 0,178,255,175,1,0,16,18,0,0,0,16,21,0,0,16,236,11,0,0,149,177,3,0,
+ 39,0,48,6,244,8,0,251,65,159,0,176,31,244,9,0,251,65,159,0,176,31,244,9,
+ 0,251,33,191,0,208,14,192,159,182,175,0,178,255,175,1,0,16,18,0,0,0,229,230,
+ 5,0,48,75,59,0,112,2,0,99,64,143,0,176,31,244,9,0,251,65,159,0,176,31,
+ 244,9,0,251,65,159,0,176,31,242,11,0,237,0,252,105,251,10,32,251,255,26,0,0,
+ 33,1,0,16,3,0,0,230,1,0,0,140,0,0,32,4,0,144,254,77,16,122,230,14,
+ 48,118,253,81,207,216,31,247,89,254,17,252,189,14,0,1,16,0,0,81,0,0,160,143,
+ 0,48,78,46,0,50,64,1,144,254,77,16,122,230,14,48,118,253,81,207,216,31,247,89,
+ 254,17,252,189,14,0,1,16,0,80,252,93,242,109,88,247,6,0,247,6,0,243,93,70,
+ 96,254,110,0,226,7,0,134,13,0,65,1,16,3,0,0,245,2,0,0,155,0,0,32,
+ 5,0,64,252,60,32,223,182,13,247,139,250,115,191,136,23,242,77,132,2,213,255,44,0,
+ 16,1,0,0,0,4,0,0,243,4,0,176,10,0,0,21,0,64,252,60,32,223,182,13,
+ 247,139,250,115,191,136,23,242,77,132,2,213,255,44,0,16,1,0,0,80,1,0,128,175,
+ 0,32,78,62,0,65,48,2,64,252,60,32,223,182,13,247,139,250,115,191,136,23,242,77,
+ 132,2,213,255,44,0,16,1,0,64,58,75,0,230,229,5,0,0,0,0,196,207,3,242,
+ 109,219,112,191,168,63,247,139,120,33,223,68,40,80,253,207,2,0,17,0,0,19,0,246,
+ 11,225,213,20,6,51,32,110,0,244,9,64,159,0,244,9,64,159,0,242,7,0,1,0,
+ 179,163,84,94,110,0,0,0,227,5,80,143,0,245,8,80,143,0,245,8,48,111,0,16,
+ 0,0,80,1,0,112,191,0,16,78,77,0,81,48,2,64,252,125,32,223,182,111,247,6,
+ 242,122,111,32,191,243,76,250,6,230,255,9,0,32,1,0,16,4,0,0,244,3,0,0,
+ 170,0,0,16,5,0,226,6,227,69,159,80,143,244,9,245,72,159,80,143,242,76,251,8,
+ 250,175,111,0,17,16,0,0,80,1,0,112,191,0,16,78,77,0,65,48,2,226,6,227,
+ 69,159,80,143,244,9,245,72,159,80,143,242,76,251,8,250,175,111,0,17,16,0,48,43,
+ 106,0,229,211,9,0,0,0,32,110,48,94,244,9,245,72,159,80,143,244,9,245,40,207,
+ 180,143,160,255,250,6,16,1,1,
};
-static const np_glyph_t np_font_body_glyphs[95] = {
+static const np_glyph_t np_font_body_glyphs[124] = {
{0, 0, 0, 0, 4, 0},
{3, 9, 0, -9, 3, 0},
{6, 5, 0, -9, 6, 14},
@@ -634,10 +840,39 @@ static const np_glyph_t np_font_body_glyphs[95] = {
{2, 12, 1, -9, 4, 2735},
{5, 12, 0, -9, 5, 2747},
{7, 3, 0, -5, 8, 2777},
+ {4, 5, 0, -9, 5, 2788},
+ {6, 6, 0, -6, 7, 2798},
+ {6, 6, 0, -6, 7, 2816},
+ {9, 13, 0, -12, 9, 2834},
+ {9, 13, 0, -12, 9, 2893},
+ {8, 12, 0, -9, 8, 2952},
+ {7, 12, 0, -12, 8, 3000},
+ {7, 12, 0, -12, 8, 3042},
+ {7, 12, 0, -12, 8, 3084},
+ {7, 11, 0, -11, 8, 3126},
+ {5, 13, -1, -12, 4, 3165},
+ {5, 12, -1, -11, 4, 3198},
+ {9, 13, 0, -12, 10, 3228},
+ {9, 13, 0, -12, 9, 3287},
+ {9, 13, 0, -12, 9, 3346},
+ {9, 12, 0, -11, 9, 3405},
+ {7, 11, 0, -10, 7, 3459},
+ {7, 11, 0, -10, 7, 3498},
+ {6, 9, 0, -6, 6, 3537},
+ {7, 11, 0, -10, 7, 3564},
+ {7, 11, 0, -10, 7, 3603},
+ {7, 11, 0, -10, 7, 3642},
+ {7, 10, 0, -9, 7, 3681},
+ {5, 11, -1, -10, 3, 3716},
+ {5, 10, -1, -9, 3, 3744},
+ {7, 11, 0, -10, 7, 3769},
+ {7, 11, 0, -10, 7, 3808},
+ {7, 11, 0, -10, 7, 3847},
+ {7, 10, 0, -9, 7, 3886},
};
-const np_font_t np_font_body = {32, 95, 10, 3, np_font_body_glyphs, np_font_body_data};
+const np_font_t np_font_body = {32, 124, 12, 3, np_font_body_glyphs, np_font_body_data};
-static const uint8_t np_font_small_data[1791] = {
+static const uint8_t np_font_small_data[2508] = {
230,113,31,246,64,13,178,48,26,229,2,214,226,99,63,63,212,241,2,2,2,0,44,59,
129,143,110,161,157,94,112,104,10,213,221,93,209,197,22,208,208,1,0,50,0,0,183,0,
128,254,76,245,37,54,247,39,0,193,255,61,0,99,190,101,51,173,197,255,27,0,183,0,
@@ -712,9 +947,39 @@ static const uint8_t np_font_small_data[1791] = {
6,160,239,0,80,143,0,112,31,0,160,9,0,250,255,18,162,11,96,29,64,94,2,249,
255,6,48,238,1,247,2,128,15,0,249,0,248,9,16,234,0,128,15,0,247,2,64,238,
1,226,67,79,244,68,79,244,68,79,244,68,79,226,3,252,7,193,11,176,12,176,13,80,
- 207,160,29,176,12,193,11,252,7,145,74,37,147,216,45,
+ 207,160,29,176,12,193,11,252,7,145,74,37,147,216,45,48,2,183,61,75,120,196,44,80,
+ 51,37,95,141,246,243,20,109,154,32,17,2,83,113,64,63,94,241,198,90,61,63,33,32,
+ 0,0,53,0,0,0,198,0,0,0,64,0,0,0,209,9,0,0,230,63,0,0,125,171,
+ 0,80,31,245,2,192,190,251,9,245,103,150,47,184,0,16,93,0,128,4,0,0,168,45,
+ 0,0,4,19,0,0,209,8,0,0,232,31,0,16,94,141,0,112,14,230,1,225,190,252,
+ 7,246,102,166,30,154,0,32,78,48,235,190,18,206,85,41,246,3,0,112,31,0,0,246,
+ 3,0,16,222,102,58,48,251,190,1,0,152,0,0,161,10,0,16,5,0,16,77,0,0,
+ 66,0,226,255,143,244,37,18,244,37,2,244,255,111,244,4,0,244,37,18,242,255,143,0,
+ 0,5,0,128,11,0,80,1,226,255,143,244,37,18,244,37,2,244,255,111,244,4,0,244,
+ 37,18,242,255,143,0,114,1,0,188,10,16,5,6,226,255,143,244,37,18,244,37,2,244,
+ 255,111,244,4,0,244,37,18,242,255,143,16,18,2,112,126,14,16,18,2,226,255,143,244,
+ 37,18,244,37,2,244,255,111,244,4,0,244,37,18,242,255,143,146,194,201,4,36,62,244,
+ 68,79,244,68,79,244,36,62,48,48,48,111,63,48,48,0,227,2,64,79,0,244,4,64,
+ 79,0,244,4,64,79,0,227,2,0,96,6,0,0,197,92,0,0,19,49,0,32,234,190,
+ 2,209,92,197,29,246,3,48,111,247,1,16,127,246,3,48,111,209,92,213,29,32,235,174,
+ 2,0,38,0,0,112,11,0,0,64,0,32,62,0,170,244,4,176,76,79,0,203,244,4,
+ 176,60,95,0,188,225,76,247,7,196,239,9,0,128,4,0,128,218,2,0,4,19,32,62,
+ 0,170,244,4,176,76,79,0,203,244,4,176,60,95,0,188,225,76,247,7,196,239,9,0,
+ 18,18,0,224,231,7,0,18,18,32,62,0,170,244,4,176,76,79,0,203,244,4,176,60,
+ 95,0,188,225,76,247,7,196,239,9,112,4,0,213,0,0,22,48,252,110,82,162,94,205,
+ 253,219,179,79,237,217,16,108,0,152,29,80,64,50,252,110,82,162,94,205,253,219,179,79,
+ 237,217,161,238,133,78,36,203,0,128,78,36,161,239,5,144,9,16,170,0,112,5,0,213,
+ 0,0,22,16,250,77,232,132,189,190,187,232,52,22,233,191,0,128,4,32,46,0,67,16,
+ 250,77,232,132,189,190,187,232,52,22,233,191,16,123,0,151,29,80,65,18,250,77,232,132,
+ 189,190,187,232,52,22,233,191,208,214,6,38,38,161,223,132,78,216,235,187,139,78,99,145,
+ 254,11,96,28,209,137,65,80,96,13,128,15,128,15,128,15,96,13,226,229,18,39,23,48,
+ 46,0,244,4,64,79,0,244,4,48,46,0,0,139,0,96,218,2,64,49,3,161,238,8,
+ 232,100,95,203,16,127,232,100,79,161,239,8,96,6,0,64,30,0,0,22,0,214,48,62,
+ 248,64,79,248,64,79,247,148,79,194,175,62,0,139,0,96,218,2,64,49,3,214,48,62,
+ 248,64,79,248,64,79,247,148,79,194,175,62,64,100,2,144,218,6,0,0,0,214,48,62,
+ 248,64,79,248,64,79,247,148,79,194,175,62,
};
-static const np_glyph_t np_font_small_glyphs[95] = {
+static const np_glyph_t np_font_small_glyphs[124] = {
{0, 0, 0, 0, 3, 0},
{3, 7, 0, -7, 3, 0},
{5, 4, 0, -7, 5, 11},
@@ -810,5 +1075,34 @@ static const np_glyph_t np_font_small_glyphs[95] = {
{3, 9, 0, -7, 4, 1753},
{4, 9, 0, -7, 5, 1767},
{6, 2, 0, -4, 6, 1785},
+ {4, 4, 0, -8, 4, 1791},
+ {5, 5, 0, -5, 6, 1799},
+ {5, 5, 0, -5, 6, 1812},
+ {8, 10, 0, -10, 8, 1825},
+ {8, 10, 0, -10, 8, 1865},
+ {7, 9, 0, -7, 7, 1905},
+ {6, 10, 0, -10, 7, 1937},
+ {6, 10, 0, -10, 7, 1967},
+ {6, 10, 0, -10, 7, 1997},
+ {6, 10, 0, -10, 7, 2027},
+ {3, 10, 0, -10, 3, 2057},
+ {5, 10, -1, -10, 3, 2072},
+ {8, 10, 0, -10, 8, 2097},
+ {7, 10, 0, -10, 8, 2137},
+ {7, 10, 0, -10, 8, 2172},
+ {7, 10, 0, -10, 8, 2207},
+ {5, 8, 0, -8, 6, 2242},
+ {5, 8, 0, -8, 6, 2262},
+ {5, 7, 0, -5, 5, 2282},
+ {5, 8, 0, -8, 6, 2300},
+ {5, 8, 0, -8, 6, 2320},
+ {5, 8, 0, -8, 6, 2340},
+ {5, 7, 0, -7, 6, 2360},
+ {4, 8, -1, -8, 3, 2378},
+ {5, 7, -1, -7, 3, 2394},
+ {6, 8, 0, -8, 6, 2412},
+ {6, 8, 0, -8, 6, 2436},
+ {6, 8, 0, -8, 6, 2460},
+ {6, 8, 0, -8, 6, 2484},
};
-const np_font_t np_font_small = {32, 95, 9, 2, np_font_small_glyphs, np_font_small_data};
+const np_font_t np_font_small = {32, 124, 10, 2, np_font_small_glyphs, np_font_small_data};
diff --git a/launcher/src/gfx.c b/launcher/src/gfx.c
index 9f82b4af..1e516d4b 100644
--- a/launcher/src/gfx.c
+++ b/launcher/src/gfx.c
@@ -272,16 +272,27 @@ void gfx_corners(int x, int y, int w, int h, int r, color_t c) {
void gfx_icon(const np_icon_t *icon, int x, int y, color_t c, int a) { gfx_mask(icon->data, icon->w, icon->h, x, y, c, a); }
-static const np_glyph_t *glyph(const np_font_t *f, char ch) {
- unsigned i = (unsigned char)ch - f->first;
- return i < f->count ? &f->glyphs[i] : &f->glyphs['?' - f->first];
+/* Text is UTF-8; only the Latin-1 letters of np_font_extra (two bytes each) are drawn besides ASCII. */
+static unsigned next_cp(const char **ps) {
+ const unsigned char *p = (const unsigned char *)*ps;
+ unsigned c = *p++;
+ if (c >= 0xC2 && c <= 0xC3 && (*p & 0xC0) == 0x80) c = (c & 0x1F) << 6 | (*p++ & 0x3F);
+ *ps = (const char *)p;
+ return c;
+}
+
+static const np_glyph_t *glyph_cp(const np_font_t *f, unsigned cp) {
+ if (cp >= f->first && cp < f->first + 95u) return &f->glyphs[cp - f->first];
+ for (unsigned k = 0; k + 95 < f->count; k++)
+ if (np_font_extra[k] == cp) return &f->glyphs[95 + k];
+ return &f->glyphs['?' - f->first];
}
int gfx_text(const np_font_t *f, int x, int baseline, const char *s, color_t c, int a) {
int top = baseline - f->ascent, bottom = baseline + f->descent;
bool visible = bottom > gfx_y0 && top < gfx_y1;
- for (; *s; s++) {
- const np_glyph_t *g = glyph(f, *s);
+ while (*s) {
+ const np_glyph_t *g = glyph_cp(f, next_cp(&s));
if (visible && g->w) gfx_mask(f->data + g->offset, g->w, g->h, x + g->x, baseline + g->y, c, a);
x += g->advance;
}
@@ -290,7 +301,7 @@ int gfx_text(const np_font_t *f, int x, int baseline, const char *s, color_t c,
int gfx_text_width(const np_font_t *f, const char *s) {
int w = 0;
- for (; *s; s++) w += glyph(f, *s)->advance;
+ while (*s) w += glyph_cp(f, next_cp(&s))->advance;
return w;
}
@@ -303,18 +314,20 @@ void gfx_text_right(const np_font_t *f, int rx, int baseline, const char *s, col
}
int gfx_paragraph(const np_font_t *f, int cx, int baseline, int width, int line, const char *s, color_t c, int a) {
- char buf[96];
+ char buf[160];
while (*s) {
/* take as many words as fit */
int n = 0, last_space = -1, wpx = 0;
- while (s[n] && s[n] != '\n' && n < (int)sizeof(buf) - 1) {
- wpx += glyph(f, s[n])->advance;
- if (s[n] == ' ') last_space = n;
+ while (s[n] && s[n] != '\n' && n < (int)sizeof(buf) - 4) {
+ const char *q = s + n;
+ unsigned cp = next_cp(&q);
+ wpx += glyph_cp(f, cp)->advance;
+ if (cp == ' ') last_space = n;
if (wpx > width && last_space > 0) {
n = last_space;
break;
}
- n++;
+ n += (int)(q - (s + n));
}
memcpy(buf, s, (size_t)n);
buf[n] = 0;
diff --git a/launcher/src/home.c b/launcher/src/home.c
index 8bd9ddc0..90e71293 100644
--- a/launcher/src/home.c
+++ b/launcher/src/home.c
@@ -1,7 +1,9 @@
/* The home screen: a carousel of game cards. The selected card is large,
* its neighbours peek in from the sides, and the card cycles through the
* game's screenshots. The last card opens the settings. */
+#include <string.h>
#include "ui.h"
+#include "live.h"
#define CARD_W 200
#define CARD_H 152
@@ -31,14 +33,93 @@ typedef struct {
static bool first_open = true;
+/* ---- live background and clock. The calculator has no clock to read: the
+ * time is set by hand (Up on the home screen) and then follows the
+ * millisecond counter, so it is lost when the calculator is switched off. */
+static uint32_t clock0; /* seconds of the day when the millisecond counter was 0 */
+static bool clock_set, clock_loaded;
+
+static uint32_t clock_secs(uint32_t now_ms) { return (clock0 + now_ms / 1000) % 86400; }
+static char *two(char *o, unsigned v) {
+ *o++ = (char)('0' + v / 10 % 10);
+ *o++ = (char)('0' + v % 10);
+ return o;
+}
+static void clock_str(char *out) {
+ if (!clock_set) {
+ strcpy(out, "--:--");
+ return;
+ }
+ uint32_t t = clock_secs(np_millis());
+ char *o = two(out, t / 3600);
+ *o++ = ':';
+ o = two(o, t / 60 % 60);
+ *o = 0;
+}
+
+typedef struct {
+ int hh, mm, field;
+} edit_t;
+
+static void edit_scene(void *ctx) {
+ edit_t *e = ctx;
+ if (live_active()) live_strip();
+ else gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, 0x3B4252, 0x171A21);
+ gfx_rrect(36, 48, 248, 144, 14, 0, 150);
+ gfx_text_center(&np_font_title, 160, 78, np_t("Set the time"), 0xFFFF, 256);
+ char h[3], m[3];
+ two(h, (unsigned)e->hh), h[2] = 0;
+ two(m, (unsigned)e->mm), m[2] = 0;
+ int wh = gfx_text_width(&np_font_title, "00"), wc = gfx_text_width(&np_font_title, ":");
+ int x0 = 160 - (2 * wh + wc + 16) / 2, xm = x0 + wh + wc + 16;
+ gfx_text(&np_font_title, x0, 124, h, 0xFFFF, e->field == 0 ? 256 : 150);
+ gfx_text(&np_font_title, x0 + wh + 8, 124, ":", 0xFFFF, 200);
+ gfx_text(&np_font_title, xm, 124, m, 0xFFFF, e->field == 1 ? 256 : 150);
+ gfx_rrect(e->field == 0 ? x0 : xm, 132, wh, 3, 1, 0xFFFF, 256);
+ gfx_text_center(&np_font_small, 160, 160, np_t("Left/Right: hour or minutes Up/Down: change"), 0xFFFF, 190);
+ gfx_text_center(&np_font_small, 160, 178, np_t("OK: save Back: cancel"), 0xFFFF, 190);
+}
+
+static void clock_edit(void) {
+ edit_t e = {12, 0, 0};
+ if (clock_set) {
+ uint32_t t = clock_secs(np_millis());
+ e.hh = (int)(t / 3600);
+ e.mm = (int)(t / 60 % 60);
+ }
+ ui_keys_t keys = {np_keys(), 0, 0}; /* ignore the key that opened this */
+ for (;;) {
+ uint32_t pressed = ui_poll(&keys);
+ if (pressed & (K_BACK | K_HOME)) return;
+ if (pressed & (K_LEFT | K_RIGHT)) e.field ^= 1;
+ if (pressed & K_UP) {
+ if (e.field == 0) e.hh = (e.hh + 1) % 24;
+ else e.mm = (e.mm + 1) % 60;
+ }
+ if (pressed & K_DOWN) {
+ if (e.field == 0) e.hh = (e.hh + 23) % 24;
+ else e.mm = (e.mm + 59) % 60;
+ }
+ if (pressed & K_OK) {
+ uint32_t now = np_millis();
+ clock0 = ((uint32_t)(e.hh * 3600 + e.mm * 60) + 86400 - now / 1000 % 86400) % 86400;
+ clock_set = true;
+ np_clock_save(clock0);
+ return;
+ }
+ live_frame(np_millis());
+ ui_frame(edit_scene, &e);
+ }
+}
+
static uint32_t item_color(int game, int which) {
if (game < 0) return which == 0 ? SETTINGS_TOP : which == 1 ? SETTINGS_BOTTOM : SETTINGS_ACCENT;
const np_game_t *g = &np_games[game];
return which == 0 ? g->top : which == 1 ? g->bottom : g->accent;
}
-static const char *item_title(int game) { return game < 0 ? "Settings" : np_games[game].title; }
-static const char *item_tagline(int game) { return game < 0 ? "Reset, uninstall, more" : np_games[game].tagline; }
+static const char *item_title(int game) { return game < 0 ? np_t("Settings") : np_games[game].title; }
+static const char *item_tagline(int game) { return game < 0 ? np_t("Reset, uninstall, more") : np_t(np_games[game].tagline); }
static float absf(float v) { return v < 0 ? -v : v; }
@@ -119,11 +200,15 @@ static void scene(void *ctx) {
t = NP_CLAMP(t, 0, 256);
uint32_t top = gfx_lerp888(item_color(h->item[a], 0), item_color(h->item[b], 0), t);
uint32_t bottom = gfx_lerp888(item_color(h->item[a], 1), item_color(h->item[b], 1), t);
- gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, top, bottom);
- /* a faint dot grid gives the background some texture */
- for (int y = (gfx_y0 + 15) / 16 * 16 + 8 - 16; y < gfx_y1; y += 16) {
- if (y < gfx_y0) continue;
- for (int x = 8; x < SCREEN_W; x += 16) gfx_fill_alpha(x, y, 2, 1, 0xFFFF, 22);
+ if (live_active()) {
+ live_strip();
+ } else {
+ gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, top, bottom);
+ /* a faint dot grid gives the background some texture */
+ for (int y = (gfx_y0 + 15) / 16 * 16 + 8 - 16; y < gfx_y1; y += 16) {
+ if (y < gfx_y0) continue;
+ for (int x = 8; x < SCREEN_W; x += 16) gfx_fill_alpha(x, y, 2, 1, 0xFFFF, 22);
+ }
}
float z = ui_ease_in_out(h->zoom);
@@ -132,8 +217,18 @@ static void scene(void *ctx) {
if (gfx_y0 < 26 && ui_alpha > 0) {
gfx_icon(&np_icon_logo, 12, 6, 0xFFFF, ui_alpha);
gfx_text(&np_font_body, 40, 18, "NumPlay", 0xFFFF, ui_alpha);
+ char clk[8];
+ clock_str(clk);
+ int cx = 40 + gfx_text_width(&np_font_body, "NumPlay") + 14;
+ cx = gfx_text(&np_font_body, cx, 18, clk, 0xFFFF, ui_alpha * (clock_set ? 210 : 110) / 256);
+ if (clock_set) { /* the seconds, small, so that it is visible that the clock is running */
+ char sec[4] = ":";
+ two(sec + 1, clock_secs(np_millis()) % 60);
+ sec[3] = 0;
+ gfx_text(&np_font_small, cx + 1, 18, sec, 0xFFFF, ui_alpha * 140 / 256);
+ }
/* where we are in the carousel; with many cards the dots get closer */
- int pitch = NP_MIN(10, 190 / (h->n + 1));
+ int pitch = NP_MIN(10, (SCREEN_W - 10 - 172) / (h->n + 1));
int dx = SCREEN_W - 10 - (h->n + 1) * pitch;
for (int i = 0; i < h->n; i++) {
float near = 1 - NP_MIN(absf(i - h->pos), 1.f);
@@ -188,6 +283,12 @@ static int build_items(home_t *h) {
int np_home(int *selected, bool returning) {
ui_init();
+ if (!clock_loaded) { /* once per run: the time set the last time, if the counter is still running */
+ clock_loaded = true;
+ if (np_clock_load(&clock0)) clock_set = true;
+ int m;
+ if (np_bg_load(&m)) live_set(m);
+ }
home_t h = {0};
build_items(&h);
/* the game played last, or else the first game there is: never Settings,
@@ -205,7 +306,7 @@ int np_home(int *selected, bool returning) {
bool unzooming = returning && h.item[h.sel] == *selected && *selected >= 0;
if (unzooming) h.zoom = 1;
ui_keys_t keys = {np_keys(), 0, 0}; /* ignore keys still held from before */
- uint32_t last = np_millis();
+ uint32_t last = np_millis(), shown_min = 0xFFFFFFFF;
bool dirty = true, bar_dirty = false;
int result = -3;
for (;;) {
@@ -225,6 +326,17 @@ int np_home(int *selected, bool returning) {
h.badge = 0;
}
if (pressed & K_OK) result = h.item[h.sel];
+ if (pressed & K_BACKSPACE) { /* next background, then none */
+ live_next();
+ np_bg_save(live_mode());
+ dirty = true;
+ }
+ if (pressed & K_UP) {
+ clock_edit();
+ keys = (ui_keys_t){np_keys(), 0, 0};
+ last = np_millis();
+ dirty = true;
+ }
if (pressed & (K_HOME | K_BACK)) return -2;
}
/* motion */
@@ -277,7 +389,10 @@ int np_home(int *selected, bool returning) {
}
}
}
+ if (live_active()) dirty = true; /* the background moves: every frame */
+ if (clock_set && clock_secs(now) != shown_min) shown_min = clock_secs(now), dirty = true;
if (dirty) {
+ live_frame(now);
ui_frame(scene, &h);
dirty = bar_dirty = false;
} else if (bar_dirty) {
diff --git a/launcher/src/live.c b/launcher/src/live.c
new file mode 100644
index 00000000..430a25d9
--- /dev/null
+++ b/launcher/src/live.c
@@ -0,0 +1,253 @@
+/* The backgrounds are those of NumVisuals (games/numvisuals), with the same
+ * formulas. Time is the millisecond counter. */
+#include "live.h"
+
+#define W SCREEN_W
+#define H SCREEN_H
+#define RGB1(c) (color_t)((((c) >> 8) & 0xF800) | (((c) >> 5) & 0x07E0) | (((c) >> 3) & 0x1F))
+
+enum { AURORA, SUNSET, PLASMA, PASTEL, LAVA, OCEAN };
+
+static int16_t *sn; /* sine, -256..256 */
+static color_t *pal; /* 256 colours */
+static int16_t *scr; /* scratch tables, W * 6 values */
+static bool ready;
+static int mode = PLASMA;
+static int now;
+static int plasma_k, plasma_speed;
+
+#define S(a) sn[(a) & 255]
+#define SCRATCH_VALUES (W * 6)
+
+static int clamp(int v, int a, int b) { return v < a ? a : v > b ? b : v; }
+static int iabs(int v) { return v < 0 ? -v : v; }
+
+/* f over b; a from 0 (all b) to 32 (all f) */
+static color_t mixf(color_t f, color_t b, int a) {
+ uint32_t x = (f | (uint32_t)f << 16) & 0x07E0F81F, y = (b | (uint32_t)b << 16) & 0x07E0F81F;
+ y = (y + ((x - y) * (uint32_t)a >> 5)) & 0x07E0F81F;
+ return (color_t)(y | y >> 16);
+}
+
+typedef struct {
+ const char *name;
+ uint8_t n;
+ uint32_t col[6];
+} bg_t;
+static const bg_t bgs[LIVE_COUNT] = {
+ {"Aurora", 5, {0x02030C, 0x071A33, 0x0E6070, 0x33E8A0, 0xD2FFEA}},
+ {"Sunset Drive", 4, {0x14002E, 0x55106E, 0xC72C79, 0xFF8A5B}},
+ {"Plasma", 6, {0x1B0B3A, 0x6B1FA8, 0xFF3E8A, 0xFFC857, 0x2EC4B6, 0x1B0B3A}},
+ {"Pastel", 6, {0xFFB3C7, 0xB9A2FF, 0x8FD8FF, 0x9EEDB6, 0xFFE08A, 0xFFB3C7}},
+ {"Lava Lamp", 5, {0x12061F, 0x4A0F3F, 0xB8233B, 0xFF7A2E, 0xFFE7A6}},
+ {"Ocean", 4, {0x0E1B45, 0x5A3C8C, 0xE9867A, 0xFFD6A0}},
+};
+
+/* a gradient through the colours of the current background */
+static void palette(void) {
+ if (!pal || mode >= LIVE_COUNT) return;
+ const uint32_t *c = bgs[mode].col;
+ int n = bgs[mode].n;
+ for (int i = 0; i < 256; i++) {
+ int p = i * (n - 1), k = p >> 8, f = p & 255;
+ uint32_t o = 0;
+ for (int s = 0; s < 24; s += 8)
+ o |= (uint32_t)((((c[k] >> s) & 255) * (256 - f) + ((c[k + 1] >> s) & 255) * f) >> 8) << s;
+ pal[i] = RGB1(o);
+ }
+ if (mode == PLASMA) plasma_k = 10, plasma_speed = 16;
+ if (mode == PASTEL) plasma_k = 6, plasma_speed = 8;
+}
+
+void live_init(void) {
+ ready = false;
+ sn = np_alloc(256 * sizeof(int16_t));
+ pal = np_alloc(256 * sizeof(color_t));
+ scr = np_alloc(SCRATCH_VALUES * sizeof(int16_t));
+ if (!sn || !pal || !scr) return;
+ for (int i = 0; i < 128; i++) { /* Bhaskara's sine */
+ float x = i * (3.14159265f / 128), q = x * (3.14159265f - x);
+ sn[i] = (int16_t)(16 * q / (49.348022f - 4 * q) * 256 + 0.5f);
+ sn[i + 128] = (int16_t)-sn[i];
+ }
+ palette();
+ ready = true;
+}
+
+bool live_ready(void) { return ready; }
+bool live_active(void) { return ready && mode < LIVE_COUNT; }
+int live_mode(void) { return mode; }
+void live_set(int m) {
+ mode = (m >= 0 && m <= LIVE_COUNT) ? m : PLASMA;
+ palette();
+}
+void live_next(void) { live_set((mode + 1) % (LIVE_COUNT + 1)); }
+const char *live_name(int m) { return m >= 0 && m < LIVE_COUNT ? bgs[m].name : "None"; }
+
+/* ---------------------------------------------------------------- per frame */
+static void frame_aurora(void) {
+ int16_t *ca = scr, *cb = scr + W, *cc = scr + 2 * W;
+ int t = now;
+ for (int x = 0; x < W; x++) {
+ ca[x] = (int16_t)(104 + (S(x + t / 29) * 22 + S(x * 2 - t / 41 + S(x / 2 + t / 67) / 6) * 12) / 256);
+ cb[x] = (int16_t)(175 + S(x * 3 + t / 13) / 9 + S(x * 9 - t / 9) / 12 + S(x / 2 - t / 23) / 4);
+ cc[x] = (int16_t)(220 + S(x * 2 + 50) / 26 + S(x * 7) / 50);
+ }
+}
+
+static void frame_plasma(void) {
+ int16_t *ca = scr, *cb = scr + W;
+ int t = now * plasma_speed / 16, k = plasma_k;
+ for (int x = 0; x < W; x++) ca[x] = (int16_t)(S(x * k / 8 + t / 7) + S(x * k / 13 - t / 11));
+ for (int y = 0; y < H; y++) cb[y] = (int16_t)(S(y * k / 8 - t / 9) + S(y * k / 17 + t / 13));
+}
+
+static void frame_lava(void) {
+ int16_t *bx = scr, *by = scr + 6;
+ int t = now;
+ for (int i = 0; i < 6; i++) {
+ bx[i] = (int16_t)(160 + S(t / (41 + i * 7) + i * 43) * (110 - i * 9) / 256);
+ by[i] = (int16_t)(120 + S(t / (53 + i * 11) + i * 97 + 64) * (100 - i * 6) / 256);
+ }
+}
+
+static void frame_ocean(void) {
+ static const uint8_t base[6] = {121, 130, 142, 158, 180, 209}, amp[6] = {2, 3, 4, 6, 9, 13};
+ int t = now;
+ for (int k = 0; k < 6; k++)
+ for (int x = 0; x < W; x++)
+ scr[k * W + x] = (int16_t)(base[k] + (S(x * (8 - k) / 4 + t / (70 + k * 25) + k * 50) * 2 +
+ S(x * (11 - k) / 3 - t / (110 + k * 30) + k * 90)) * amp[k] / 768);
+}
+
+void live_frame(uint32_t now_ms) {
+ if (!live_active()) return;
+ now = (int)now_ms;
+ switch (mode) {
+ case AURORA: frame_aurora(); break;
+ case PLASMA:
+ case PASTEL: frame_plasma(); break;
+ case LAVA: frame_lava(); break;
+ case OCEAN: frame_ocean(); break;
+ default: break;
+ }
+}
+
+/* ---------------------------------------------------------------- per strip */
+static void strip_aurora(int top, int sh) {
+ int16_t *ca = scr, *cb = scr + W, *cc = scr + 2 * W;
+ for (int j = 0; j < sh; j++) {
+ int y = top + j, sky = 8 + y * 52 / H;
+ color_t *p = gfx_buf + j * W;
+ for (int x = 0; x < W; x++) {
+ if (y >= cc[x]) {
+ p[x] = RGB1(0x010308);
+ continue;
+ }
+ int d = ca[x] - y, i = d >= 0 ? cb[x] - d * 3 / 2 : cb[x] * 2 / 3 + d * 3;
+ if (i < sky) {
+ uint32_t h = (uint32_t)x * 73856093u ^ (uint32_t)y * 19349663u;
+ i = (h * 0x5BD1E995u) >> 22 ? sky : 190;
+ }
+ p[x] = pal[i > 255 ? 255 : i];
+ }
+ }
+}
+
+static void strip_sunset(int top, int sh) {
+ int t = now;
+ for (int j = 0; j < sh; j++) {
+ int y = top + j;
+ color_t *p = gfx_buf + j * W;
+ if (y < 150) {
+ color_t sky = pal[y * 255 / 150];
+ int dy = y - 102, r2 = 3600 - dy * dy;
+ bool cut = dy > 4 && dy % 11 < (dy - 4) / 9 + 1;
+ color_t sun = mixf(RGB1(0xFF3F81), RGB1(0xFFE45E), clamp((y - 42) * 32 / 108, 0, 32));
+ for (int x = 0; x < W; x++) {
+ int dx = x - 160, d2 = dx * dx + dy * dy;
+ p[x] = dx * dx < r2 && !cut ? sun : d2 < 8100 ? mixf(RGB1(0xFF4F9A), sky, (8100 - d2) / 700) : sky;
+ }
+ } else {
+ int d = y - 146, z0 = 98304 / d, z1 = 98304 / (d + 1), off = t / 2, a = clamp(4 + d / 3, 0, 28);
+ bool row = ((z0 + off) >> 8) != ((z1 + off) >> 8) || d == 4;
+ color_t base = mixf(RGB1(0x0A0018), RGB1(0x2A0A4A), d * 32 / 94), line = mixf(RGB1(0xFF3DDB), base, d == 4 ? 32 : a);
+ int q = (-160 * z0) >> 15;
+ for (int x = 0; x < W; x++) {
+ int nq = ((x - 159) * z0) >> 15;
+ p[x] = row || nq != q ? line : base;
+ q = nq;
+ }
+ }
+ }
+}
+
+static void strip_plasma(int top, int sh) {
+ int16_t *ca = scr, *cb = scr + W;
+ int t = now * plasma_speed / 16, k = plasma_k;
+ for (int j = 0; j < sh; j++) {
+ int y = top + j, r = cb[y];
+ color_t *p = gfx_buf + j * W;
+ for (int x = 0; x < W; x++) p[x] = pal[(uint8_t)(((ca[x] + r + S((x + y) * k / 16 + t / 5)) >> 3) + (t >> 4))];
+ }
+}
+
+static void strip_lava(int top, int sh) {
+ int16_t *bx = scr, *by = scr + 6;
+ for (int j = 0; j < sh; j++) {
+ int y = top + j, dy2[6];
+ color_t *p = gfx_buf + j * W;
+ for (int i = 0; i < 6; i++) dy2[i] = (y - by[i]) * (y - by[i]) + 16;
+ for (int x = 0; x < W; x += 2) {
+ int f = 0;
+ for (int i = 0; i < 6; i++) {
+ int dx = x - bx[i], r = 26 + i * 3;
+ f += (r * r << 7) / (dx * dx + dy2[i]);
+ }
+ p[x] = p[x + 1] = pal[f < 128 ? f * 5 / 8 : 150 + (f - 128 > 315 ? 105 : (f - 128) / 3)];
+ }
+ }
+}
+
+static void strip_ocean(int top, int sh) {
+ static const uint32_t sea_rgb[6] = {0x7FA9CF, 0x5A8CBE, 0x3F72A8, 0x2B5B91, 0x1C4677, 0x11335E};
+ color_t sea[6];
+ for (int i = 0; i < 6; i++) sea[i] = RGB1(sea_rgb[i]);
+ int t = now;
+ for (int j = 0; j < sh; j++) {
+ int y = top + j;
+ color_t *p = gfx_buf + j * W;
+ for (int x = 0; x < W; x++) {
+ int k = 5;
+ while (k >= 0 && y < scr[k * W + x]) k--;
+ color_t c;
+ if (k < 0) {
+ int dx = x - 236, dy = y - 92, d2 = dx * dx + dy * dy;
+ c = d2 < 225 ? RGB1(0xFFF1C9) : pal[clamp(y * 2, 0, 255)];
+ if (d2 >= 225 && d2 < 2500) c = mixf(RGB1(0xFFD9A0), c, (2500 - d2) / 160);
+ } else {
+ int e = y - scr[k * W + x];
+ c = e < 2 ? mixf(0xFFFF, sea[k], 12 - e * 5) : sea[k];
+ if (iabs(x - 236) < 4 + (y - 120) / 4 && S(y * 29 + x * 3 + t / 6) > 170) c = mixf(RGB1(0xFFE2B0), c, 14);
+ }
+ p[x] = c;
+ }
+ }
+}
+
+void live_strip(void) {
+ if (!live_active()) return;
+ int top = gfx_y0, sh = gfx_y1 - gfx_y0;
+ switch (mode) {
+ case AURORA: strip_aurora(top, sh); break;
+ case SUNSET: strip_sunset(top, sh); break;
+ case PLASMA:
+ case PASTEL: strip_plasma(top, sh); break;
+ case LAVA: strip_lava(top, sh); break;
+ case OCEAN: strip_ocean(top, sh); break;
+ default: break;
+ }
+ /* three quarters of the brightness, so that the white text and the cards stay readable */
+ color_t *p = gfx_buf, *e = gfx_buf + sh * W;
+ for (; p < e; p++) *p = (color_t)(((*p & 0xF7DE) >> 1) + ((*p & 0xE79C) >> 2));
+}
diff --git a/launcher/src/live.h b/launcher/src/live.h
new file mode 100644
index 00000000..bf85494b
--- /dev/null
+++ b/launcher/src/live.h
@@ -0,0 +1,20 @@
+/* Live backgrounds for the home screen, ported from NumVisuals: drawn straight
+ * into the strip being rendered, then dimmed a little so the text stays
+ * readable. Their small tables live in the arena; when there is no room for
+ * them the home screen keeps its plain gradient. */
+#ifndef NP_LIVE_H
+#define NP_LIVE_H
+#include "gfx.h"
+
+#define LIVE_COUNT 6 /* Aurora, Sunset Drive, Plasma, Pastel, Lava Lamp, Ocean */
+
+void live_init(void); /* after ui_init has taken its buffers */
+bool live_ready(void); /* the tables could be allocated */
+bool live_active(void); /* ready, and a background is chosen */
+int live_mode(void); /* 0..LIVE_COUNT-1, or LIVE_COUNT for "none" */
+void live_set(int mode);
+void live_next(void); /* the next background, then none, then the first again */
+const char *live_name(int mode);
+void live_frame(uint32_t now_ms); /* once per frame, before rendering */
+void live_strip(void); /* fills the current strip (gfx_y0..gfx_y1) */
+#endif
diff --git a/launcher/src/matrices.c b/launcher/src/matrices.c
index 7bfb3086..3a9e84db 100644
--- a/launcher/src/matrices.c
+++ b/launcher/src/matrices.c
@@ -153,7 +153,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(np_t("MATRICES"), 160, 2, false, C_WHITE, C_BAR);
/* battery */
int level = np_battery_level();
fill(296, 5, 15, 8, C_WHITE);
@@ -168,7 +168,7 @@ static void tabs(void) {
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);
- ctext(names[t], t * 160 + 80, 22, false, fg, bg);
+ ctext(np_t(names[t]), t * 160 + 80, 22, false, fg, bg);
}
}
@@ -181,7 +181,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(np_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,7 +252,7 @@ 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(np_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;
@@ -265,13 +265,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(np_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(np_t("Not invertible"), SCREEN_W - 12 - width(np_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(np_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];
@@ -285,11 +285,11 @@ 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(np_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);
- text(menu_items[i], x + 8, y + 22 + i * 30 + 7, false, C_TEXT, bg);
+ text(np_t(menu_items[i]), x + 8, y + 22 + i * 30 + 7, false, C_TEXT, bg);
fill(x, y + 22 + i * 30 + 29, w, 1, C_LINE);
}
}
@@ -319,7 +319,7 @@ bool np_matrices(const np_config_t *cfg) {
M.n = 3;
M.menu = -1;
for (int i = 0; i < MAXN; i++) M.a[i][i] = 1;
- hint = cfg->hint ? secret_hints[cfg->secret] : NULL;
+ hint = cfg->hint ? np_t(secret_hints[cfg->secret]) : NULL;
status_bar();
redraw();
uint64_t prev = eadk_keyboard_scan();
diff --git a/launcher/src/np.h b/launcher/src/np.h
index 2657dc1e..2f1972c2 100644
--- a/launcher/src/np.h
+++ b/launcher/src/np.h
@@ -82,9 +82,17 @@ typedef struct {
bool disguise; /* start as Matrices, a calculator app; NumPlay opens through the secret */
uint8_t secret; /* NP_SECRET_* */
bool hint; /* Matrices names the secret in light gray, bottom left */
+ bool french; /* the interface is in French (tr.c) */
} np_config_t;
+extern bool np_french;
+const char *np_t(const char *en); /* tr.c: the text in the chosen language */
+char *np_fmt(char *out, unsigned n, const char *en, const char *arg); /* the same, with %s replaced by arg */
void np_config_load(np_config_t *c);
bool np_config_save(const np_config_t *c);
+bool np_clock_load(uint32_t *clock0); /* false when no valid saved time */
+bool np_clock_save(uint32_t clock0);
+bool np_bg_load(int *mode); /* false when none was saved */
+bool np_bg_save(int mode);
/* A copy of every save in numplay_saves.py, a Python script: the only kind of
file the NumWorks installer keeps when NumPlay is updated. */
void np_progress_backup(void);
diff --git a/launcher/src/settings.c b/launcher/src/settings.c
index 6306e04d..0b9a2d2f 100644
--- a/launcher/src/settings.c
+++ b/launcher/src/settings.c
@@ -24,15 +24,15 @@ static char *fmt_kb(char *out, uint32_t bytes) {
while (kb /= 10);
char *o = out;
while (n) *o++ = t[--n];
- strcpy(o, " KB");
+ strcpy(o, np_t(" KB"));
return out;
}
/* ---------------------------------------------------------------- list */
-enum { ROW_GAME, ROW_RESET_ALL, ROW_DISGUISE, ROW_SECRET, ROW_HINT };
+enum { ROW_GAME, ROW_RESET_ALL, ROW_DISGUISE, ROW_SECRET, ROW_HINT, ROW_LANG };
typedef struct {
int n, sel, top, action; /* action: on a game, 0 Reset, 1 Uninstall */
- int8_t kind[NP_MAX_GAMES + 4], game[NP_MAX_GAMES + 4];
+ int8_t kind[NP_MAX_GAMES + 5], game[NP_MAX_GAMES + 5];
int ngames;
np_config_t cfg;
float cursor; /* animated selection */
@@ -43,6 +43,7 @@ static const char *const secret_names[NP_SECRET_COUNT] = {"x,n,t key", "var key"
static void build_rows(list_t *l) {
l->n = l->ngames = 0;
+ l->kind[l->n++] = ROW_LANG; /* first: easy to find above the long list of games */
for (int i = 0; i < np_game_count; i++)
if (np_game_installed(i)) l->kind[l->n] = ROW_GAME, l->game[l->n++] = (int8_t)i, l->ngames++;
l->kind[l->n++] = ROW_RESET_ALL;
@@ -88,12 +89,12 @@ static void list_scene(void *ctx) {
gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, BG_TOP, BG_BOTTOM);
if (gfx_y0 < 44) {
gfx_icon(&np_icon_back, 14, 17, 0xFFFF, 200);
- gfx_text(&np_font_title, 36, 30, "Settings", 0xFFFF, 256);
+ gfx_text(&np_font_title, 36, 30, np_t("Settings"), 0xFFFF, 256);
uint32_t total = 0;
for (int i = 0; i < l->ngames; i++) total += np_game_size(l->game[i]);
char kb[16];
if (l->ngames) {
- gfx_text_right(&np_font_small, SCREEN_W - 14, 20, "INSTALLED GAMES", 0xFFFF, 150);
+ gfx_text_right(&np_font_small, SCREEN_W - 14, 20, np_t("INSTALLED GAMES"), 0xFFFF, 150);
gfx_text_right(&np_font_body, SCREEN_W - 14, 34, fmt_kb(kb, total), 0xFFFF, 230);
}
}
@@ -106,11 +107,11 @@ static void list_scene(void *ctx) {
if (i >= l->n) {
/* credits, under the last row */
if (i != l->n) continue;
- int w = gfx_text_width(&np_font_body, "Made with ") + 12 + gfx_text_width(&np_font_body, " by Mason Chen");
+ int w = gfx_text_width(&np_font_body, np_t("Made with ")) + 12 + gfx_text_width(&np_font_body, np_t(" by Mason Chen"));
int x = 160 - w / 2;
- x = gfx_text(&np_font_body, x, y + 20, "Made with ", 0xFFFF, 230);
+ x = gfx_text(&np_font_body, x, y + 20, np_t("Made with "), 0xFFFF, 230);
gfx_icon(&np_icon_heart, x + 1, y + 12, gfx_rgb(DANGER), 256);
- gfx_text(&np_font_body, x + 12, y + 20, " by Mason Chen", 0xFFFF, 230);
+ gfx_text(&np_font_body, x + 12, y + 20, np_t(" by Mason Chen"), 0xFFFF, 230);
gfx_text_center(&np_font_small, 160, y + 36, "github.com/Mason363/NumPlay", 0xFFFF, 170);
gfx_text_center(&np_font_small, 160, y + 50, "NumPlay " NP_VERSION, 0xFFFF, 120);
continue;
@@ -124,31 +125,42 @@ static void list_scene(void *ctx) {
gfx_text(&np_font_body, 60, y + 15, np_games[game].title, 0xFFFF, 256);
gfx_text(&np_font_small, 60, y + 28, fmt_kb(kb, np_game_size(game)), 0xFFFF, 150);
if (on) {
- pill(SCREEN_W - 170, y + 7, 58, "Reset", l->action == 0, ACCENT);
+ pill(SCREEN_W - 170, y + 7, 58, np_t("Reset"), l->action == 0, ACCENT);
pill(SCREEN_W - 104, y + 7, 86, "", l->action == 1, DANGER);
gfx_icon(&np_icon_trash, SCREEN_W - 96, y + 9, 0xFFFF, l->action == 1 ? 256 : 190);
- gfx_text(&np_font_small, SCREEN_W - 78, y + 21, "Uninstall", 0xFFFF, l->action == 1 ? 256 : 190);
+ gfx_text(&np_font_small, SCREEN_W - 78, y + 21, np_t("Uninstall"), 0xFFFF, l->action == 1 ? 256 : 190);
}
break;
}
case ROW_RESET_ALL:
- row_text(y, "Reset all games", "Deletes the progress of every game", 256);
- if (on) pill(SCREEN_W - 76, y + 7, 58, "Reset", true, ACCENT);
+ row_text(y, np_t("Reset all games"), np_t("Deletes the progress of every game"), 256);
+ if (on) pill(SCREEN_W - 76, y + 7, 58, np_t("Reset"), true, ACCENT);
break;
case ROW_DISGUISE:
- row_text(y, "Start as Matrices", "A math app first; NumPlay opens in secret", 256);
+ row_text(y, np_t("Start as Matrices"), np_t("A math app first; NumPlay opens in secret"), 256);
toggle(y, l->cfg.disguise, 256);
break;
case ROW_HINT: {
int a = l->cfg.disguise ? 256 : 130;
- row_text(y, "Show a hint", "Matrices names the secret, small and gray", a);
+ row_text(y, np_t("Show a hint"), np_t("Matrices names the secret, small and gray"), a);
toggle(y, l->cfg.hint, a);
break;
}
+ case ROW_LANG: {
+ row_text(y, np_t("Language"), np_t("English or French"), 256);
+ const char *v = np_t("English"); /* the language in use, written in itself */
+ int w = gfx_text_width(&np_font_small, v);
+ gfx_text_right(&np_font_small, SCREEN_W - 32, y + 21, v, 0xFFFF, 256);
+ if (on) {
+ gfx_icon(&np_icon_left, SCREEN_W - 44 - w, y + 10, 0xFFFF, 256);
+ gfx_icon(&np_icon_right, SCREEN_W - 26, y + 10, 0xFFFF, 256);
+ }
+ break;
+ }
case ROW_SECRET: {
int a = l->cfg.disguise ? 256 : 130;
- row_text(y, "Secret way in", "Opens NumPlay from Matrices", a);
- const char *v = secret_names[l->cfg.secret];
+ row_text(y, np_t("Secret way in"), np_t("Opens NumPlay from Matrices"), a);
+ const char *v = np_t(secret_names[l->cfg.secret]);
int w = gfx_text_width(&np_font_small, v);
gfx_text_right(&np_font_small, SCREEN_W - 32, y + 21, v, 0xFFFF, a);
if (on) {
@@ -196,7 +208,7 @@ static void hold_button(const dialog_t *d, const char *label) {
gfx_rrect(bx, by, bw, bh, bh / 2, gfx_rgb(DANGER), 256);
int fill = (int)(bw * d->hold);
if (fill > 0) gfx_rrect(bx, by, NP_MAX(fill, bh), bh, bh / 2, 0xFFFF, 110);
- gfx_text_center(&np_font_body, bx + bw / 2, by + 18, d->hinted ? "Hold OK" : label, 0xFFFF, 256);
+ gfx_text_center(&np_font_body, bx + bw / 2, by + 18, d->hinted ? np_t("Hold OK") : label, 0xFFFF, 256);
} else {
gfx_rrect(bx, by, bw, bh, bh / 2, 0xFFFF, 40);
gfx_text_center(&np_font_body, bx + bw / 2, by + 18, label, 0xFFFF, 200);
@@ -206,32 +218,35 @@ static void hold_button(const dialog_t *d, const char *label) {
/* Reset and Reset all: a question (Cancel first, hold OK to reset), then done */
static void reset_scene(dialog_t *d) {
const char *title = d->action == ACT_RESET_ALL ? "every game" : np_games[d->game].title;
- char line[64], body[128];
+ char line[96], body[256];
if (d->stage == 2) {
gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, 0x1F5A3C, 0x0B1A12);
gfx_circle(160, 74, 34, gfx_rgb(OK_GREEN), 256);
gfx_icon(&np_icon_check, 145, 59, 0xFFFF, 256);
- strcpy(line, d->action == ACT_RESET_ALL ? "Every game" : title);
- strcat(line, d->action == ACT_RESET_ALL ? " was reset" : " was reset");
+ if (d->action == ACT_RESET_ALL) strcpy(line, np_t("Every game was reset"));
+ else np_fmt(line, sizeof line, "%s was reset", title);
gfx_text_center(&np_font_title, 160, 142, line, 0xFFFF, 256);
- gfx_text_center(&np_font_body, 160, 166, "Its progress starts over.", 0xFFFF, 200);
+ gfx_text_center(&np_font_body, 160, 166, np_t("Its progress starts over."), 0xFFFF, 200);
ui_button(110, 192, 100, 28, "OK", true, OK_GREEN, 256);
return;
}
gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, DANGER_TOP, DANGER_BOTTOM);
gfx_icon(&np_icon_warning, 137, 14, 0xFFFF, 256);
- strcpy(line, "Reset ");
- strcat(line, title);
- strcat(line, "?");
+ if (d->action == ACT_RESET_ALL) strcpy(line, np_t("Reset every game?"));
+ else np_fmt(line, sizeof line, "Reset %s?", title);
gfx_text_center(&np_font_title, 160, 80, line, 0xFFFF, 256);
- strcpy(body, "This deletes the saved progress of ");
- strcat(body, title);
- strcat(body, ": best scores, unlocked levels and settings. You can't undo this.");
+ if (d->action == ACT_RESET_ALL)
+ strcpy(body, np_t("This deletes the saved progress of every game: best scores, unlocked levels and settings. "
+ "You can't undo this."));
+ else
+ np_fmt(body, sizeof body,
+ "This deletes the saved progress of %s: best scores, unlocked levels and settings. You can't undo this.",
+ title);
int y = gfx_paragraph(&np_font_body, 160, 102, 280, 16, body, 0xFFFF, 240);
- gfx_paragraph(&np_font_small, 160, y + 4, 290, 13, "Games stay installed, and levels you made in an editor are kept.",
+ gfx_paragraph(&np_font_small, 160, y + 4, 290, 13, np_t("Games stay installed, and levels you made in an editor are kept."),
0xFFFF, 170);
- ui_button(38, 198, 110, 28, "Cancel", d->choice == 0, 0x555D70, 256);
- hold_button(d, "Reset");
+ ui_button(38, 198, 110, 28, np_t("Cancel"), d->choice == 0, 0x555D70, 256);
+ hold_button(d, np_t("Reset"));
}
static void dialog_scene(void *ctx) {
@@ -241,17 +256,15 @@ static void dialog_scene(void *ctx) {
return;
}
const np_game_t *g = &np_games[d->game];
- char line[64];
+ char line[96];
if (d->stage == 2) {
gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, 0x1F5A3C, 0x0B1A12);
gfx_circle(160, 74, 34, gfx_rgb(OK_GREEN), 256);
gfx_icon(&np_icon_check, 145, 59, 0xFFFF, 256);
- strcpy(line, g->title);
- strcat(line, " was uninstalled");
+ np_fmt(line, sizeof line, "%s was uninstalled", g->title);
gfx_text_center(&np_font_title, 160, 142, line, 0xFFFF, 256);
char kb[16];
- strcpy(line, fmt_kb(kb, d->freed));
- strcat(line, " of flash memory freed");
+ np_fmt(line, sizeof line, "%s of flash memory freed", fmt_kb(kb, d->freed));
gfx_text_center(&np_font_body, 160, 166, line, 0xFFFF, 200);
ui_button(110, 192, 100, 28, "OK", true, OK_GREEN, 256);
return;
@@ -259,37 +272,31 @@ static void dialog_scene(void *ctx) {
gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, DANGER_TOP, DANGER_BOTTOM);
gfx_icon(&np_icon_warning, 137, 14, 0xFFFF, 256);
if (d->stage == 3) {
- gfx_text_center(&np_font_title, 160, 84, "Couldn't uninstall", 0xFFFF, 256);
- gfx_paragraph(&np_font_body, 160, 112, 280, 17, error_text(d->error), 0xFFFF, 220);
+ gfx_text_center(&np_font_title, 160, 84, np_t("Couldn't uninstall"), 0xFFFF, 256);
+ gfx_paragraph(&np_font_body, 160, 112, 280, 17, np_t(error_text(d->error)), 0xFFFF, 220);
ui_button(110, 196, 100, 28, "OK", true, DANGER, 256);
return;
}
if (d->stage == 1) {
- strcpy(line, "Uninstalling ");
- strcat(line, g->title);
- strcat(line, "...");
+ np_fmt(line, sizeof line, "Uninstalling %s...", g->title);
gfx_text_center(&np_font_title, 160, 96, line, 0xFFFF, 256);
gfx_rrect(40, 118, 240, 10, 5, 0xFFFF, 60);
int w = (int)(240 * d->progress);
if (w >= 10) gfx_rrect(40, 118, w, 10, 5, 0xFFFF, 256);
- gfx_text_center(&np_font_body, 160, 152, "Don't turn off your calculator.", 0xFFFF, 200);
+ gfx_text_center(&np_font_body, 160, 152, np_t("Don't turn off your calculator."), 0xFFFF, 200);
return;
}
- strcpy(line, "Uninstall ");
- strcat(line, g->title);
- strcat(line, "?");
+ np_fmt(line, sizeof line, "Uninstall %s?", g->title);
gfx_text_center(&np_font_title, 160, 80, line, 0xFFFF, 256);
- char body[96];
- strcpy(body, "This deletes ");
- strcat(body, g->title);
- strcat(body, " and all of its saved progress. You can't undo this.");
+ char body[256];
+ np_fmt(body, sizeof body, "This deletes %s and all of its saved progress. You can't undo this.", g->title);
int y = gfx_paragraph(&np_font_body, 160, 102, 280, 16, body, 0xFFFF, 240);
gfx_paragraph(&np_font_small, 160, y + 4, 290, 13,
- "To play it again, reinstall NumPlay from my.numworks.com/apps. Your other games keep their "
- "progress.",
+ np_t("To play it again, reinstall NumPlay from my.numworks.com/apps. Your other games keep their "
+ "progress."),
0xFFFF, 170);
- ui_button(38, 198, 110, 28, "Cancel", d->choice == 0, 0x555D70, 256);
- hold_button(d, "Uninstall");
+ ui_button(38, 198, 110, 28, np_t("Cancel"), d->choice == 0, 0x555D70, 256);
+ hold_button(d, np_t("Uninstall"));
}
static dialog_t *active_dialog;
@@ -398,6 +405,10 @@ void np_settings(void) {
if (p & K_UP) l.sel = NP_MAX(l.sel - 1, 0), l.action = 0;
if (p & K_DOWN) l.sel = NP_MIN(l.sel + 1, l.n - 1), l.action = 0;
if (kind == ROW_GAME && (p & (K_LEFT | K_RIGHT))) l.action = (p & K_RIGHT) != 0;
+ if (kind == ROW_LANG && (p & (K_LEFT | K_RIGHT | K_OK))) {
+ l.cfg.french = !l.cfg.french;
+ np_config_save(&l.cfg);
+ }
if (kind == ROW_SECRET && (p & (K_LEFT | K_RIGHT | K_OK))) {
l.cfg.secret = (uint8_t)((l.cfg.secret + ((p & K_LEFT) ? NP_SECRET_COUNT - 1 : 1)) % NP_SECRET_COUNT);
np_config_save(&l.cfg);
diff --git a/launcher/src/storage.c b/launcher/src/storage.c
index 3935a7e3..5a812655 100644
--- a/launcher/src/storage.c
+++ b/launcher/src/storage.c
@@ -63,19 +63,61 @@ void np_config_load(np_config_t *c) {
c->disguise = false;
c->secret = NP_SECRET_XNT;
c->hint = true;
+ c->french = false;
uint32_t len = 0;
const uint8_t *d = ef_read(CONFIG_NAME, &len);
- if (!d || len != 4 || d[0] != CONFIG_MAGIC || d[1] != 1) return;
- c->disguise = d[2] & 1;
- c->hint = !(d[2] & 2); /* a flag for "no hint": older files keep the hint on */
- if (d[3] < NP_SECRET_COUNT) c->secret = d[3];
+ if (d && len == 4 && d[0] == CONFIG_MAGIC && d[1] == 1) {
+ c->disguise = d[2] & 1;
+ c->hint = !(d[2] & 2); /* a flag for "no hint": older files keep the hint on */
+ c->french = (d[2] & 4) != 0; /* older files: English */
+ if (d[3] < NP_SECRET_COUNT) c->secret = d[3];
+ }
+ np_french = c->french;
}
bool np_config_save(const np_config_t *c) {
- uint8_t d[4] = {CONFIG_MAGIC, 1, (uint8_t)(c->disguise | (c->hint ? 0 : 2)), c->secret};
+ np_french = c->french;
+ uint8_t d[4] = {CONFIG_MAGIC, 1, (uint8_t)(c->disguise | (c->hint ? 0 : 2) | (c->french ? 4 : 0)), c->secret};
return ef_write(CONFIG_NAME, d, sizeof d);
}
+/* The home-screen clock: the seconds of the day at millisecond 0, and the millisecond counter when
+ * it was saved. After a restart the counter starts again from 0, so a saved time is only kept when
+ * the counter has not gone back. */
+#define CLOCK_NAME "npclock.set"
+bool np_clock_load(uint32_t *clock0) {
+ uint32_t len = 0, now = np_millis();
+ const uint8_t *d = ef_read(CLOCK_NAME, &len);
+ if (!d || len != 10 || d[0] != 'C' || d[1] != 1) return false;
+ uint32_t c = (uint32_t)d[2] | (uint32_t)d[3] << 8 | (uint32_t)d[4] << 16 | (uint32_t)d[5] << 24;
+ uint32_t ms = (uint32_t)d[6] | (uint32_t)d[7] << 8 | (uint32_t)d[8] << 16 | (uint32_t)d[9] << 24;
+ if (c >= 86400 || now < ms) return false;
+ *clock0 = c;
+ return true;
+}
+
+bool np_clock_save(uint32_t clock0) {
+ uint32_t now = np_millis();
+ uint8_t d[10] = {'C', 1, (uint8_t)clock0, (uint8_t)(clock0 >> 8), (uint8_t)(clock0 >> 16), (uint8_t)(clock0 >> 24),
+ (uint8_t)now, (uint8_t)(now >> 8), (uint8_t)(now >> 16), (uint8_t)(now >> 24)};
+ return ef_write(CLOCK_NAME, d, sizeof d);
+}
+
+/* Which live background of the home screen was chosen last. */
+#define BG_NAME "npbg.set"
+bool np_bg_load(int *mode) {
+ uint32_t len = 0;
+ const uint8_t *d = ef_read(BG_NAME, &len);
+ if (!d || len != 3 || d[0] != 'B' || d[1] != 1) return false;
+ *mode = d[2];
+ return true;
+}
+
+bool np_bg_save(int mode) {
+ uint8_t d[3] = {'B', 1, (uint8_t)mode};
+ return ef_write(BG_NAME, d, sizeof d);
+}
+
/* ---------------------------------------------------------------- progress copy
* Installing apps restarts the calculator, which empties its file system; the
* NumWorks installer puts back the Python scripts only. So NumPlay keeps every
@@ -110,6 +152,7 @@ static int b64_value(uint8_t c) {
* starts with the rest, like NumBlocks' regions); false when i is past the end */
static bool save_name(int i, char out[64]) {
if (i-- == 0) return strcpy(out, CONFIG_NAME), true;
+ if (i-- == 0) return strcpy(out, BG_NAME), true; /* the home-screen background chosen */
for (int g = 0; g < np_game_count; g++)
for (const char *const *r = np_games[g].records; r && *r; r++) {
bool seen = false;
diff --git a/launcher/src/tr.c b/launcher/src/tr.c
new file mode 100644
index 00000000..36d7bd1f
--- /dev/null
+++ b/launcher/src/tr.c
@@ -0,0 +1,137 @@
+/* Two languages: English, as written in the code, and French. np_t() turns an
+ * English text into its French one when French is chosen (Settings > Language),
+ * and returns it unchanged otherwise or when no translation is listed. Source files are UTF-8; the
+ * accents are drawn by gfx.c. */
+#include <string.h>
+#include "np.h"
+
+bool np_french;
+
+typedef struct {
+ const char *en, *fr;
+} pair_t;
+
+static const pair_t pairs[] = {
+ /* home */
+ {"Settings", "Réglages"},
+ {"Reset, uninstall, more", "Effacer, supprimer, plus"},
+ {"Set the time", "Régler l'heure"},
+ {"Left/Right: hour or minutes Up/Down: change", "Gauche/Droite : h / min Haut/Bas : changer"},
+ {"OK: save Back: cancel", "OK : valider Retour : annuler"},
+ /* the games' taglines */
+ {"Jump to the beat", "Saute en rythme"},
+ {"Hop, dodge, survive", "Saute, esquive, survis"},
+ {"Mine, craft, survive", "Mine, fabrique, survis"},
+ {"Drive, flip, finish", "Conduis, bascule, arrive"},
+ {"Poker hands, wild jokers", "Mains de poker, jokers fous"},
+ {"You, the Dealer, one shotgun", "Toi, le croupier, un fusil"},
+ {"Think with portals", "Pense avec les portails"},
+ {"Stack and clear lines", "Empile et efface les lignes"},
+ {"Bots, puzzles, 2 players", "Bots, problèmes, 2 joueurs"},
+ {"Flap through the pipes", "Vole entre les tuyaux"},
+ {"Eat dots, dodge ghosts", "Mange les points, fuis les fantômes"},
+ {"Eat apples, grow long", "Mange des pommes, grandis"},
+ {"Four in a row wins", "Quatre alignés pour gagner"},
+ {"The classic card game", "Le jeu de cartes classique"},
+ {"Slide, merge, reach 2048", "Glisse, fusionne, atteins 2048"},
+ {"Clear the field, flag the mines", "Déminer le terrain, pose les drapeaux"},
+ {"Break every brick", "Casse chaque brique"},
+ {"Backgrounds, clocks, timers", "Fonds, horloges, minuteurs"},
+ /* settings: list */
+ {"INSTALLED GAMES", "JEUX INSTALLÉS"},
+ {" KB", " Ko"},
+ {"Made with ", "Fait avec "},
+ {" by Mason Chen", " par Mason Chen"},
+ {"Reset", "Effacer"},
+ {"Uninstall", "Supprimer"},
+ {"Reset all games", "Tout effacer"},
+ {"Deletes the progress of every game", "Efface la progression de tous les jeux"},
+ {"Start as Matrices", "Démarrer en Matrices"},
+ {"A math app first; NumPlay opens in secret", "D'abord une app de maths, NumPlay en secret"},
+ {"Show a hint", "Afficher un indice"},
+ {"Matrices names the secret, small and gray", "Matrices indique le secret, en petit et gris"},
+ {"Secret way in", "Accès secret"},
+ {"Opens NumPlay from Matrices", "Ouvre NumPlay depuis Matrices"},
+ {"x,n,t key", "touche x,n,t"},
+ {"var key", "touche var"},
+ {"Toolbox key", "touche Boîte à outils"},
+ {"Pi key", "touche Pi"},
+ {"Square root key", "touche racine carrée"},
+ {"Menu: Examples", "Menu : Exemples"},
+ /* Matrices (the disguise): as the calculator's own app would read in French */
+ {"MATRICES", "MATRICES"},
+ {"Matrix", "Matrice"},
+ {"Results", "Résultats"},
+ {"Dimension", "Dimension"},
+ {"Determinant", "Déterminant"},
+ {"Inverse", "Inverse"},
+ {"Not invertible", "Non inversible"},
+ {"Transpose", "Transposée"},
+ {"Identity matrix", "Matrice identité"},
+ {"Clear", "Effacer"},
+ {"Examples", "Exemples"},
+ {"Toolbox", "Boîte à outils"},
+ {"Matrices", "Matrices"},
+ {"Language", "Langue"},
+ {"English or French", "Anglais ou français"},
+ {"English", "Français"},
+ /* settings: dialogs */
+ {"Hold OK", "Maintiens OK"},
+ {"Cancel", "Annuler"},
+ {"OK", "OK"},
+ {"Reset every game?", "Tout effacer ?"},
+ {"Reset %s?", "Effacer %s ?"},
+ {"This deletes the saved progress of every game: best scores, unlocked levels and settings. You can't undo this.",
+ "Cela supprime la progression enregistrée de tous les jeux : meilleurs scores, niveaux débloqués et réglages. "
+ "C'est irréversible."},
+ {"This deletes the saved progress of %s: best scores, unlocked levels and settings. You can't undo this.",
+ "Cela supprime la progression enregistrée de %s : meilleurs scores, niveaux débloqués et réglages. "
+ "C'est irréversible."},
+ {"Games stay installed, and levels you made in an editor are kept.",
+ "Les jeux restent installés, et les niveaux créés dans un éditeur sont conservés."},
+ {"Every game was reset", "Tout est effacé"},
+ {"%s was reset", "Progression effacée"},
+ {"Its progress starts over.", "Elle repart de zéro."},
+ {"%s was uninstalled", "%s supprimé"},
+ {"%s of flash memory freed", "%s de mémoire flash libérés"},
+ {"Couldn't uninstall", "Suppression impossible"},
+ {"Uninstalling %s...", "Suppression en cours..."},
+ {"Don't turn off your calculator.", "N'éteins pas ta calculatrice."},
+ {"Uninstall %s?", "Supprimer %s ?"},
+ {"This deletes %s and all of its saved progress. You can't undo this.",
+ "Cela supprime %s et toute sa progression enregistrée. C'est irréversible."},
+ {"To play it again, reinstall NumPlay from my.numworks.com/apps. Your other games keep their progress.",
+ "Pour y rejouer, réinstalle NumPlay depuis my.numworks.com/apps. Les autres jeux gardent leur progression."},
+ {"Your calculator's software doesn't allow apps to uninstall parts of themselves. Update it to Epsilon 21 or "
+ "newer at my.numworks.com, then try again.",
+ "Le logiciel de ta calculatrice ne permet pas aux apps de se supprimer en partie. Mets-la à jour vers "
+ "Epsilon 21 ou plus récent sur my.numworks.com, puis réessaie."},
+ {"The battery is too low to safely erase flash memory. Plug in your calculator, then try again.",
+ "La batterie est trop faible pour effacer la mémoire flash en toute sécurité. Branche ta calculatrice, puis "
+ "réessaie."},
+ {"Something went wrong while erasing. To be safe, reinstall NumPlay from my.numworks.com/apps.",
+ "Un problème est survenu pendant l'effacement. Par sécurité, réinstalle NumPlay depuis "
+ "my.numworks.com/apps."},
+};
+
+#define NPAIRS ((int)(sizeof pairs / sizeof pairs[0]))
+const char *np_t(const char *en) {
+ if (!np_french || !en) return en;
+ for (int i = 0; i < NPAIRS; i++)
+ if (!strcmp(pairs[i].en, en)) return pairs[i].fr;
+ return en;
+}
+
+/* The translated text with its first %s replaced by arg. */
+char *np_fmt(char *out, unsigned n, const char *en, const char *arg) {
+ const char *p = np_t(en);
+ unsigned o = 0;
+ for (; *p && o + 1 < n; p++) {
+ if (p[0] == '%' && p[1] == 's') {
+ for (const char *a = arg; *a && o + 1 < n; a++) out[o++] = *a;
+ p++;
+ } else out[o++] = *p;
+ }
+ out[o] = 0;
+ return out;
+}
diff --git a/launcher/src/ui.c b/launcher/src/ui.c
index 9fafc276..98bc1e4c 100644
--- a/launcher/src/ui.c
+++ b/launcher/src/ui.c
@@ -1,5 +1,6 @@
#include "ui.h"
#include "inflate.h"
+#include "live.h"
/* ---- screenshots: decoded on demand into a few slots of the arena */
#define MAX_SLOTS 6
@@ -17,6 +18,7 @@ void ui_init(void) {
np_alloc_reset();
gfx_init();
tables = np_alloc(np_inflate_tables_size());
+ live_init(); /* its small tables first: the screenshot slots below take all that is left */
nslots = 0;
while (nslots < MAX_SLOTS) {
uint8_t *p = np_alloc(SHOT_W * SHOT_H);
diff --git a/tools/fontgen.py b/tools/fontgen.py
index 7ac39c0c..1debbba0 100644
--- a/tools/fontgen.py
+++ b/tools/fontgen.py
@@ -29,6 +29,10 @@ SPECS = [
("np_font_small", 7, 800, 2),
]
FIRST, LAST = 32, 126
+# Latin-1 letters after the ASCII ones (French accents, guillemets, degree sign). Text is UTF-8:
+# gfx.c turns each two-byte sequence back into one of these code points.
+EXTRA = [0xB0, 0xAB, 0xBB, 0xC0, 0xC2, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCE, 0xCF, 0xD4, 0xD9, 0xDB, 0xDC,
+ 0xE0, 0xE2, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEE, 0xEF, 0xF4, 0xF9, 0xFB, 0xFC]
def font_file():
@@ -85,12 +89,14 @@ def main(out):
lines = ["/* Generated by tools/fontgen.py from Nunito (SIL Open Font License 1.1). */",
'#include "font.h"', ""]
total = 0
+ lines.append(f"const unsigned char np_font_extra[{len(EXTRA)}] = {{" + ", ".join(hex(c) for c in EXTRA) + "};")
+ lines.append("")
for name, cap, weight, spacing in SPECS:
f = load(cap, weight)
data = bytearray()
glyphs = []
asc = desc = 0
- for c in range(FIRST, LAST + 1):
+ for c in list(range(FIRST, LAST + 1)) + EXTRA:
g, adv = glyph(f, chr(c), spacing * UP / 4)
if g is None:
glyphs.append((0, 0, 0, 0, adv, len(data)))
@@ -115,7 +121,7 @@ def main(out):
for w, h, ox, oy, adv, off in glyphs:
lines.append(f" {{{w}, {h}, {ox}, {oy}, {adv}, {off}}},")
lines.append("};")
- lines.append(f"const np_font_t {name} = {{{FIRST}, {LAST - FIRST + 1}, {asc}, {desc}, {name}_glyphs, {name}_data}};")
+ lines.append(f"const np_font_t {name} = {{{FIRST}, {LAST - FIRST + 1 + len(EXTRA)}, {asc}, {desc}, {name}_glyphs, {name}_data}};")
lines.append("")
print(f"{name}: cap {cap}px, ascent {asc}, descent {desc}, {len(data)} bytes of glyphs")
Path(out).write_text("\n".join(lines))