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
Five Nights at Freddy's 3: the 8-bit minigames and the good ending
Mason363f6a9d1766246
diff --git a/docs/play.md b/docs/play.mdindex c49bf78d..5a02d196 100644--- a/docs/play.md+++ b/docs/play.md@@ -769,7 +769,7 @@ Five Nights at Freddy's 2 comes as its own app, `FiveNightsAtFreddys2.nwa`. Last| **EXE** | The monitor down, the panel's Exit || **Back** | Pause (Resume, Quit game) |-Last from 12 to 6 AM at Fazbear's Fright. Springtrap comes room by room: play the audio on a camera next to his and he follows it, and seal the vent he crawls into. Reboot the audio, the cameras and the ventilation on the maintenance panel when they fail; with the ventilation down the dark comes in waves and he comes closer. Look away from a phantom on a camera before it jumps out. Night 5 opens the 6th.+Last from 12 to 6 AM at Fazbear's Fright. Springtrap comes room by room: play the audio on a camera next to his and he follows it, and seal the vent he crawls into. Reboot the audio, the cameras and the ventilation on the maintenance panel when they fail; with the ventilation down the dark comes in waves and he comes closer. Look away from a phantom on a camera before it jumps out. After each of the first five nights comes an 8-bit minigame (Left Right walk, OK jump): carry Mangle's cake to the four children for the good ending. Night 5 opens the 6th.<br clear="right">diff --git a/games/fnaf3/README.md b/games/fnaf3/README.mdindex 229f3ca8..1c1a550e 100644--- a/games/fnaf3/README.md+++ b/games/fnaf3/README.md@@ -20,6 +20,7 @@* **Springtrap** walks the attraction's ten cameras and its five vents. He looks in through the window, runs past it, hides by the door and peeks around it. Lure him away with BB's laugh, and seal the vent he's in.* **The maintenance panel:** the audio, the cameras and the ventilation wear out. Reboot one or all. With the ventilation down the office flashes red, the cameras show him where he isn't, and the dark comes in waves.* **The phantoms:** BB, Mangle, Chica, Phantom Freddy, the Puppet and Foxy, when and where the game brings them, each once a night.+* **The 8-bit minigames** after each of the first five nights. Carry the cake from Mangle's Quest to the four children and Happiest Day ends the game well.* **Nights 1 to 5, then the 6th:** the 6th night and the Extras open once the game is beaten, a star for each ending.* **Home** keeps the night as it is, and the next start puts you back in it, paused.@@ -54,6 +55,7 @@ The phantoms don't kill you, but their scare brings the ventilation down and Spr| Backspace | On the monitor: the camera map or the vent map || EXE | The monitor down, the panel's Exit || ↑ ↓, OK | On the panel: a system, reboot it |+| ← →, OK | In a minigame: walk, jump || Back | Pause || Home | Keep the night and quit |@@ -61,7 +63,7 @@ The phantoms don't kill you, but their scare brings the ventilation down and Spr* **Too big to install next to NumPlay.** Your saves in each are kept.* **No sound:** the calculator has no speaker. What you would hear is written at the bottom left: the footsteps, the vents, BB's laugh, the alarm. Springtrap's hum, louder the closer he is, is the two bars at the top left.-* **Left out:** the phone calls and the 8-bit minigames between nights, with the good ending they lead to. The cheats in Extras open with the good ending, so they stay shut.+* **Left out:** the phone calls.* **The pictures are the game's,** at half size: the screen shows 640 of its 800 pixels around where the game looks.## Creditsdiff --git a/games/fnaf3/src/data.bin b/games/fnaf3/src/data.binindex e5134ccf..8d0c5631 100644Binary files a/games/fnaf3/src/data.bin and b/games/fnaf3/src/data.bin differdiff --git a/games/fnaf3/src/data.h b/games/fnaf3/src/data.hindex 6a965fa1..4dd0f6fb 100644--- a/games/fnaf3/src/data.h+++ b/games/fnaf3/src/data.h@@ -9,6 +9,7 @@#define SEC_BANK 4#define SEC_FONTS 5#define SEC_IMGS 6+#define SEC_SPRS 7#define PIC_OFFICE 0#define PIC_OFFICE_RED 1#define PIC_WIN_SPRING 2@@ -239,7 +240,101 @@#define PIC_TITLE14 227#define PIC_TITLE15 228#define PIC_PANEL 229-#define PIC_COUNT 230+#define PIC_MG_BB_0_0 230+#define PIC_MG_BB_1_0 231+#define PIC_MG_BB_2_0 232+#define PIC_MG_BB_0_1 233+#define PIC_MG_BB_1_1 234+#define PIC_MG_BB_2_1 235+#define PIC_MG_MANGLE_0_0 236+#define PIC_MG_MANGLE_1_0 237+#define PIC_MG_MANGLE_2_0 238+#define PIC_MG_MANGLE_3_0 239+#define PIC_MG_MANGLE_0_1 240+#define PIC_MG_MANGLE_1_1 241+#define PIC_MG_MANGLE_3_1 242+#define PIC_MG_MANGLE_0_2 243+#define PIC_MG_MANGLE_1_2 244+#define PIC_MG_MANGLE_2_2 245+#define PIC_MG_MANGLE_3_2 246+#define PIC_MG_MANGLE_0_3 247+#define PIC_MG_MANGLE_1_3 248+#define PIC_MG_MANGLE_2_3 249+#define PIC_MG_MANGLE_3_3 250+#define PIC_MG_MANGLE_0_4 251+#define PIC_MG_MANGLE_2_4 252+#define PIC_MG_MANGLE_3_4 253+#define PIC_MG_CHICA_0_0 254+#define PIC_MG_CHICA_1_0 255+#define PIC_MG_CHICA_2_0 256+#define PIC_MG_CHICA_3_0 257+#define PIC_MG_CHICA_0_1 258+#define PIC_MG_CHICA_1_1 259+#define PIC_MG_CHICA_2_1 260+#define PIC_MG_CHICA_3_1 261+#define PIC_MG_CHICA_0_2 262+#define PIC_MG_CHICA_1_2 263+#define PIC_MG_CHICA_2_2 264+#define PIC_MG_CHICA_3_2 265+#define PIC_MG_CHICA_0_3 266+#define PIC_MG_CHICA_1_3 267+#define PIC_MG_CHICA_2_3 268+#define PIC_MG_CHICA_3_3 269+#define PIC_MG_CHICA_0_4 270+#define PIC_MG_CHICA_1_4 271+#define PIC_MG_CHICA_2_4 272+#define PIC_MG_CHICA_3_4 273+#define PIC_MG_STAGE_0_0 274+#define PIC_MG_STAGE_1_0 275+#define PIC_MG_STAGE_2_0 276+#define PIC_MG_STAGE_3_0 277+#define PIC_MG_STAGE_0_1 278+#define PIC_MG_STAGE_1_1 279+#define PIC_MG_STAGE_2_1 280+#define PIC_MG_STAGE_3_1 281+#define PIC_MG_STAGE_0_2 282+#define PIC_MG_STAGE_1_2 283+#define PIC_MG_STAGE_2_2 284+#define PIC_MG_STAGE_3_2 285+#define PIC_MG_STAGE_0_3 286+#define PIC_MG_STAGE_2_3 287+#define PIC_MG_STAGE_3_3 288+#define PIC_MG_STAGE_0_4 289+#define PIC_MG_STAGE_2_4 290+#define PIC_MG_STAGE_3_4 291+#define PIC_MG_SHADOW_0_0 292+#define PIC_MG_SHADOW_1_0 293+#define PIC_MG_SHADOW_2_0 294+#define PIC_MG_SHADOW_3_0 295+#define PIC_MG_SHADOW_0_1 296+#define PIC_MG_SHADOW_1_1 297+#define PIC_MG_SHADOW_3_1 298+#define PIC_MG_SHADOW_0_2 299+#define PIC_MG_SHADOW_1_2 300+#define PIC_MG_SHADOW_0_3 301+#define PIC_MG_SHADOW_1_3 302+#define PIC_MG_SHADOW_0_4 303+#define PIC_MG_SHADOW_1_4 304+#define PIC_MG_SHADOW_2_4 305+#define PIC_MG_SHADOW_3_4 306+#define PIC_MG_HAPPY_0_0 307+#define PIC_MG_HAPPY_1_0 308+#define PIC_MG_HAPPY_2_0 309+#define PIC_MG_HAPPY_3_0 310+#define PIC_MG_HAPPY_0_1 311+#define PIC_MG_HAPPY_2_1 312+#define PIC_MG_HAPPY_3_1 313+#define PIC_MG_HAPPY_0_2 314+#define PIC_MG_HAPPY_3_2 315+#define PIC_MG_HAPPY_0_3 316+#define PIC_MG_HAPPY_1_3 317+#define PIC_MG_HAPPY_2_3 318+#define PIC_MG_HAPPY_3_3 319+#define PIC_MG_HAPPY_0_4 320+#define PIC_MG_HAPPY_1_4 321+#define PIC_MG_HAPPY_2_4 322+#define PIC_MG_HAPPY_3_4 323+#define PIC_COUNT 324#define FONT_HUD 0#define FONT_BIG 1#define FONT_TEXT 2diff --git a/games/fnaf3/src/game.c b/games/fnaf3/src/game.cindex 79cd6af1..464cd28f 100644--- a/games/fnaf3/src/game.c+++ b/games/fnaf3/src/game.c@@ -9,6 +9,7 @@#include "gfx.h"#include "data.h"#include "plat.h"+#include "mini.h"Game g;@@ -98,36 +99,81 @@ static void title_draw(void) {gfx_text(FONT_HUD, 8, SCREEN_H - 14, "Up Down choose OK start Back quit", WHITE);}+/* ------------------------------------------------------------ the minigames */+/* after a minigame: the night again (BB's, from the camera), the next night, the ending or Extras */+enum { AFTER_NIGHT, AFTER_NEXT, AFTER_END, AFTER_EXTRAS };+static void mini_go(int level, int after) {+ mini_begin(level, after == AFTER_EXTRAS);+ g.mini_after = (uint8_t)after;+ go(SC_MINI);+}++static void mini_over(void) {+ switch (g.mini_after) {+ case AFTER_NIGHT: start_night(g.n.night); break;+ case AFTER_NEXT: start_night(g.n.night + 1); break;+ case AFTER_END: g.ending = g.goodend ? 3 : 1, go(SC_END); break;+ default: go(SC_EXTRAS); break;+ }+}+/* ------------------------------------------------------------ extras */+static const char *const mini_names[MINI_COUNT] = {"BB's Air Adventure", "Mangle's Quest", "Chica's Party",+ "Stage 01", "Shadow Bonnie", "Happiest Day"};+/* Extras: the cheats (after the 6th night and the good ending), the minigames (once the game is beaten), Exit */+static int extras_n(void) { return (g.goodend && g.beat6 ? 4 : 0) + (g.beatgame ? 1 : 0) + 1; }+static void extras_step(void) {+ if (g.extras_sub) { /* the minigames */+ if (pressed(K_UP | K_DIGIT(8))) g.menu = (uint8_t)((g.menu + MINI_COUNT - 1) % MINI_COUNT);+ if (pressed(K_DOWN | K_DIGIT(2))) g.menu = (uint8_t)((g.menu + 1) % MINI_COUNT);+ if (pressed(K_BACK)) g.extras_sub = 0;+ if (pressed(K_OK | K_EXE)) mini_go(g.menu, AFTER_EXTRAS);+ return;+ }bool cheats = g.goodend && g.beat6;- int n = cheats ? 5 : 1;+ int n = extras_n();if (pressed(K_UP | K_DIGIT(8))) g.extras_sel = (uint8_t)((g.extras_sel + n - 1) % n);if (pressed(K_DOWN | K_DIGIT(2))) g.extras_sel = (uint8_t)((g.extras_sel + 1) % n);if (pressed(K_BACK)) go(SC_TITLE);if (pressed(K_OK | K_EXE)) {+ int c = cheats ? 4 : 0;if (g.extras_sel == n - 1) go(SC_TITLE);- else g.cheats ^= (uint8_t)(1 << g.extras_sel), save_progress();+ else if (g.extras_sel < c) g.cheats ^= (uint8_t)(1 << g.extras_sel), save_progress();+ else g.extras_sub = 1, g.menu = 0;}}static void extras_draw(void) {gfx_fill(0, 0, SCREEN_W, SCREEN_H, BLACK);+ if (g.extras_sub) {+ gfx_text_s(FONT_BIG, 14, 12, "Minigames", WHITE);+ for (int i = 0; i < MINI_COUNT; i++) {+ int y = 50 + 22 * i;+ if (i == g.menu) gfx_text(FONT_TEXT, 14, y, ">>", WHITE);+ gfx_text(FONT_TEXT, 34, y, mini_names[i], WHITE);+ }+ gfx_text(FONT_HUD, 8, SCREEN_H - 14, "Up Down choose OK play Back extras", WHITE);+ return;+ }gfx_text_s(FONT_BIG, 14, 12, "Extras", WHITE);bool cheats = g.goodend && g.beat6;static const char *const names[4] = {"Fast Nights", "Radar", "Aggressive", "No Errors"};- int n = 0;+ int i = 0, y = 50;if (cheats)- for (; n < 4; n++) {- int y = 50 + 22 * n;- if (n == g.extras_sel) gfx_text(FONT_TEXT, 14, y, ">>", WHITE);- gfx_text(FONT_TEXT, 34, y, names[n], WHITE);- gfx_text(FONT_TEXT, 160, y, g.cheats >> n & 1 ? "ON" : "OFF", g.cheats >> n & 1 ? GREEN_TEXT : GREY_TEXT);+ for (; i < 4; i++, y += 22) {+ if (i == g.extras_sel) gfx_text(FONT_TEXT, 14, y, ">>", WHITE);+ gfx_text(FONT_TEXT, 34, y, names[i], WHITE);+ gfx_text(FONT_TEXT, 160, y, g.cheats >> i & 1 ? "ON" : "OFF", g.cheats >> i & 1 ? GREEN_TEXT : GREY_TEXT);}else- gfx_text(FONT_TEXT, 14, 50, "The cheats open after the 6th night and the good ending.", GREY_TEXT);- int y = 50 + 22 * (cheats ? 4 : 2);- if (g.extras_sel == n) gfx_text(FONT_TEXT, 14, y, ">>", WHITE);+ gfx_text(FONT_TEXT, 14, y, "The cheats open after the 6th night and the good ending.", GREY_TEXT), y += 22;+ if (g.beatgame) {+ if (i == g.extras_sel) gfx_text(FONT_TEXT, 14, y, ">>", WHITE);+ gfx_text(FONT_TEXT, 34, y, "Minigames", WHITE);+ i++, y += 22;+ }+ if (i == g.extras_sel) gfx_text(FONT_TEXT, 14, y, ">>", WHITE);gfx_text(FONT_TEXT, 34, y, "Exit", WHITE);gfx_text(FONT_HUD, 8, SCREEN_H - 14, "Up Down choose OK pick Back title", WHITE);}@@ -174,14 +220,16 @@ static void pause_draw(void) {gfx_text_c(FONT_TEXT, SCREEN_W / 2, 134, g.pause_item == 1 ? "> Quit game <" : "Quit game", WHITE);}+/* 6 AM: after each of the first five nights its minigame (the phone builds' "cutscenes"), Happiest Day the last */static void six_done(void) {int night = g.n.night;if (night == 5) g.beatgame = 1;if (night == 6) g.beat6 = 1;if (night < 5) g.level = (uint8_t)(night + 1);save_progress();- if (night >= 5) g.ending = night == 6 ? 2 : 1, go(SC_END);- else start_night(night + 1);+ static const uint8_t after_night[6] = {0, MINI_MANGLE, MINI_CHICA, MINI_STAGE, MINI_SHADOW, MINI_HAPPY};+ if (night == 6) g.ending = 2, go(SC_END);+ else mini_go(after_night[night], night == 5 ? AFTER_END : AFTER_NEXT);}void game_step(uint32_t keys) {@@ -210,6 +258,7 @@ void game_step(uint32_t keys) {break;}night_step();+ if (g.mini_next) mini_go(g.mini_next - 1, AFTER_NIGHT), g.mini_next = 0;break;case SC_STATIC:if (g.t > 5) go(SC_OVER);@@ -223,6 +272,10 @@ void game_step(uint32_t keys) {case SC_END:if (g.t > 20 || (g.t > 3 && pressed(K_OK | K_EXE | K_BACK))) go(SC_TITLE);break;+ case SC_MINI:+ mini_step();+ if (mini_done() || pressed(K_BACK)) mini_over();+ break;}g.t += 1.0f / 60;}@@ -263,6 +316,7 @@ static void game_band(void) {gfx_text(FONT_HUGE, 156, 100, "AM", WHITE);break;}- case SC_END: pic_draw(g.ending == 2 ? PIC_THEEND : PIC_BADEND, 0, 0); break;+ case SC_END: pic_draw(g.ending == 3 ? PIC_GOODEND : g.ending == 2 ? PIC_THEEND : PIC_BADEND, 0, 0); break;+ case SC_MINI: mini_draw(); break;}}diff --git a/games/fnaf3/src/game.h b/games/fnaf3/src/game.hindex 3483e795..00f82155 100644--- a/games/fnaf3/src/game.h+++ b/games/fnaf3/src/game.h@@ -20,7 +20,21 @@ enum { L_NONE, L_CAM1, L_CAM10 = 10, L_VENT11, L_VENT15 = 15, L_ST1, L_ST2, L_STenum { PH_NONE, PH_BB, PH_FREDDY, PH_CHICA, PH_FOXY };/* scenes */-enum { SC_TITLE, SC_EXTRAS, SC_DAY, SC_NIGHT, SC_STATIC, SC_OVER, SC_SIX, SC_END };+enum { SC_TITLE, SC_EXTRAS, SC_DAY, SC_NIGHT, SC_STATIC, SC_OVER, SC_SIX, SC_END, SC_MINI };++/* the minigames' saves (the game's Ini keys): BB's balloons, the cake, the four children given one */+enum { MG_BB = 1, MG_CAKE = 2, MG_K1 = 4, MG_K2 = 8, MG_K3 = 16, MG_K4 = 32 };++/* a minigame (mini.c) */+typedef struct {+ uint8_t level, from_extras, win, secret, changed, moving, latch, dir;+ int16_t hx, hy; /* "hitbox" */+ int16_t camx, camy; /* the screen shown ("watch screen", its corner) */+ int8_t jump; /* "Active" A */+ int16_t counter, counter2, cake_t, win_t;+ uint16_t every[10];+ uint32_t frame;+} Mini;/* A night, all of it: kept as it is when Home quits (save.c), so the next start goes on from there. */typedef struct {@@ -125,6 +139,10 @@ typedef struct {bool running;/* the save (Ini "freddy3"): the night reached, the stars, the extras */uint8_t level, beatgame, beat6, goodend, keys_seen;+ uint8_t mg_flags; /* MG_* */+ uint8_t mini_next; /* a minigame to go to after this step, + 1 (0 none) */+ uint8_t mini_after; /* where a minigame leads (game.c) */+ uint8_t extras_sub; /* Extras' list of minigames shown */uint8_t cheats; /* bits: fast nights, radar, aggressive, no errors */uint8_t menu, menu_n;uint8_t paused, confirm, pause_item;@@ -133,6 +151,7 @@ typedef struct {const char *cap[4]; /* what is heard, as captions (the newest last) */float cap_t[4];Night n;+ Mini mg;} Game;enum { CH_FAST = 1, CH_RADAR = 2, CH_AGGRESSIVE = 4, CH_NOERRORS = 8 };@@ -160,6 +179,12 @@ void view_night(void);void view_scare(void);void view_captions(void);+/* mini.c */+void mini_begin(int level, bool from_extras);+void mini_step(void);+void mini_draw(void);+int mini_done(void);+/* save.c */void save_restore_copy(void);void save_progress(void);diff --git a/games/fnaf3/src/gfx.c b/games/fnaf3/src/gfx.cindex 3a516a68..1baf32ec 100644--- a/games/fnaf3/src/gfx.c+++ b/games/fnaf3/src/gfx.c@@ -165,3 +165,32 @@ void gfx_img(int id, int x, int y, uint16_t c) {const uint8_t *p = img_at(id);alpha_rows(p + 8, (int)rd16(p), (int)rd16(p + 2), x, y, c);}++/* ------------------------------------------------------------------ sprites (the minigames) */+static const uint8_t *spr_at(int id) {+ const uint8_t *s = section(SEC_SPRS);+ return s + rd32(s + 4 + 4 * id);+}+int gfx_sprite_w(int id) { return (int)rd16(spr_at(id)); }+int gfx_sprite_h(int id) { return (int)rd16(spr_at(id) + 2); }++/* a sprite with its hot spot at (x, y), mirrored or not: 16 colours, 0 clear */+void gfx_sprite(int id, int x, int y) {+ const uint8_t *p = spr_at(id);+ int w = (int)rd16(p), h = (int)rd16(p + 2);+ x -= rds16(p + 4), y -= rds16(p + 6);+ const uint8_t *pal = p + 8, *px = p + 40;+ int stride = (w + 1) / 2;+ int r0 = gfx_y0 - y, r1 = gfx_y0 + BAND_H - y;+ if (r0 < 0) r0 = 0;+ if (r1 > h) r1 = h;+ int c0 = x < 0 ? -x : 0, c1 = x + w > SCREEN_W ? SCREEN_W - x : w;+ for (int r = r0; r < r1; r++) {+ const uint8_t *row = px + r * stride;+ uint16_t *dst = gfx_band + (y + r - gfx_y0) * SCREEN_W + x;+ for (int c = c0; c < c1; c++) {+ int k = (row[c >> 1] >> ((c & 1) * 4)) & 15;+ if (k) dst[c] = (uint16_t)rd16(pal + 2 * k);+ }+ }+}diff --git a/games/fnaf3/src/gfx.h b/games/fnaf3/src/gfx.hindex 7748354c..15a549e3 100644--- a/games/fnaf3/src/gfx.h+++ b/games/fnaf3/src/gfx.h@@ -45,6 +45,11 @@ void gfx_img(int id, int x, int y, uint16_t c);int gfx_img_w(int id);int gfx_img_h(int id);+/* the minigames' sprites (SPR: tools/minigames.py), their hot spot at (x, y) */+void gfx_sprite(int id, int x, int y);+int gfx_sprite_w(int id);+int gfx_sprite_h(int id);+/* pictures (pic.c): the whole of one at (x, y), or the part (sx, sy, w, h) of it */void pic_draw(int id, int x, int y);void pic_part(int id, int x, int y, int sx, int sy, int w, int h);diff --git a/games/fnaf3/src/mini.c b/games/fnaf3/src/mini.cnew file mode 100644index 00000000..dedf7246--- /dev/null+++ b/games/fnaf3/src/mini.c@@ -0,0 +1,344 @@+/* Five Nights at Freddy's 3: the 8-bit minigames, as their frames' events run them (gamesrc spec: BB, Mangle,+ * Toy Chica, GFreddy, RWQFSFASXC and Marion; the jump, which the phone builds lost, from the PC build's).+ *+ * A level is a few screens of the game's 800 x 480 (here 320 x 192 between black bars), the camera stepping a whole+ * screen when the player leaves one. The player is the game's: a "hitbox" with feelers round it that the solid+ * backdrops stop, gravity 10 pixels every 100 ms for each of two feet off the ground, a jump of 7 steps of 20 pixels+ * every 60 ms. Each level hides a cake: carry the one from Mangle's Quest to the four children (BB's Air Adventure,+ * Chica's Party, Stage 01, Shadow Bonnie) and Happiest Day ends the game well. */+#include <string.h>+#include "game.h"+#include "gfx.h"+#include "plat.h"+#include "data.h"+#include "mini_data.h"++#define M g.mg+#define MAXI 64++typedef struct {+ int16_t x, y;+ uint8_t obj, vis, alive, anim, dir, img, cnt, pad;+ int16_t s0, s1;+} Inst;++static Inst in[MAXI];+static int nin;+static const MgLevel *L;++/* ------------------------------------------------------------ the level's objects */+static const MgObj *obj(int o) { return &mg_objs[L->obj0 + o]; }+static int first(int o) { /* the first instance of an object, -1 none */+ for (int i = 0; i < nin; i++)+ if (in[i].obj == o && in[i].alive) return i;+ return -1;+}+static const MgAnim *anim_of(const Inst *p) {+ const MgObj *ob = obj(p->obj);+ const MgAnim *best = NULL;+ for (int k = 0; k < ob->nanim; k++) {+ const MgAnim *a = &mg_anims[ob->anim0 + k];+ if (a->anim == p->anim && (a->dir == p->dir || !best)) best = a;+ }+ return best ? best : &mg_anims[ob->anim0];+}+static void box(const Inst *p, int *x0, int *y0, int *x1, int *y1) {+ const MgObj *ob = obj(p->obj);+ *x0 = p->x - ob->hx, *y0 = p->y - ob->hy, *x1 = *x0 + ob->w, *y1 = *y0 + ob->h;+}+static bool rect_hit(int ax0, int ay0, int ax1, int ay1, int bx0, int by0, int bx1, int by1) {+ return ax0 < bx1 && bx0 < ax1 && ay0 < by1 && by0 < ay1;+}+/* a feeler (w x h, hot spot hx, hy) at (x, y) on a solid backdrop */+static bool solid_at(int x, int y, int w, int h, int hx, int hy) {+ int x0 = x - hx, y0 = y - hy;+ for (int k = 0; k < L->nsolid; k++) {+ const MgRect *r = &mg_solids[L->solid0 + k];+ if (rect_hit(x0, y0, x0 + w, y0 + h, r->x, r->y, r->x + r->w, r->y + r->h)) return true;+ }+ return false;+}+/* a box on any visible instance of an object: its index, -1 none */+static int touching(int x0, int y0, int x1, int y1, int o) {+ for (int i = 0; i < nin; i++) {+ if (in[i].obj != o || !in[i].alive || !in[i].vis) continue;+ int a, b, c, d;+ box(&in[i], &a, &b, &c, &d);+ if (rect_hit(x0, y0, x1, y1, a, b, c, d)) return i;+ }+ return -1;+}+#define FEEL(n, dx, dy) solid_at(M.hx + (dx), M.hy + (dy), MGF_##n##_W, MGF_##n##_H, MGF_##n##_HX, MGF_##n##_HY)+#define FEEL_ON(n, dx, dy, o) (touching(M.hx + (dx) - MGF_##n##_HX, M.hy + (dy) - MGF_##n##_HY, \+ M.hx + (dx) - MGF_##n##_HX + MGF_##n##_W, M.hy + (dy) - MGF_##n##_HY + MGF_##n##_H, o) >= 0)++static bool every(int id, int ms) {+ uint16_t p = (uint16_t)(ms * 60 / 1000);+ if (!M.every[id]) M.every[id] = p;+ if (--M.every[id]) return false;+ M.every[id] = p;+ return true;+}++/* each level's objects by their names (MGO_*, mini_data.h), -1 where a level has none */+typedef struct {+ int8_t active, collect, exit, exit2, get_this, get_this2, big_cake, child, balloons, win_screen, kid, wall;+ int8_t carry, follower, zip_up, zip_right, zip_left, block[4], parts[4], kids[4], trigger;+ int8_t dy, step;+} Names;+static const Names names[MGL_COUNT] = {+ [MGL_BB] = {MGO_BB_ACTIVE, MGO_BB_COLLECT, MGO_BB_EXIT, -1, MGO_BB_GET_THIS, -1, MGO_BB_BIG_CAKE, MGO_BB_ACTIVE_6,+ MGO_BB_BALLOONS, MGO_BB_ACTIVE_5, -1, -1, -1, -1, -1, -1, -1, {-1, -1, -1, -1}, {-1, -1, -1, -1},+ {-1, -1, -1, -1}, -1, -10, 15},+ [MGL_MANGLE] = {MGO_MANGLE_ACTIVE, MGO_MANGLE_COLLECT, MGO_MANGLE_EXIT, -1, MGO_MANGLE_GET_THIS, -1, -1, -1,+ MGO_MANGLE_BALLOONS, MGO_MANGLE_ACTIVE_5, MGO_MANGLE_KID, MGO_MANGLE_WALL, -1, -1, -1, -1, -1,+ {-1, -1, -1, -1}, {MGO_MANGLE_ACTIVE_6, MGO_MANGLE_ACTIVE_7, MGO_MANGLE_ACTIVE_8, MGO_MANGLE_ACTIVE_9},+ {-1, -1, -1, -1}, -1, -45, 15},+ [MGL_CHICA] = {MGO_CHICA_ACTIVE, MGO_CHICA_COLLECT, MGO_CHICA_EXIT, MGO_CHICA_EXIT_2, MGO_CHICA_GET_THIS,+ MGO_CHICA_GET_THIS_2, -1, MGO_CHICA_ACTIVE_4, MGO_CHICA_BALLOONS, MGO_CHICA_ACTIVE_5, -1, -1,+ MGO_CHICA_COLLECT_4, MGO_CHICA_ACTIVE_9, -1, -1, -1, {-1, -1, -1, -1}, {-1, -1, -1, -1},+ {MGO_CHICA_ACTIVE_8, -1, -1, -1}, -1, -20, 15},+ [MGL_STAGE] = {MGO_STAGE_ACTIVE, MGO_STAGE_COLLECT, MGO_STAGE_EXIT, -1, MGO_STAGE_GET_THIS, -1, MGO_STAGE_BIG_CAKE,+ MGO_STAGE_ACTIVE_6, MGO_STAGE_BALLOONS, MGO_STAGE_ACTIVE_5, -1, -1, -1, -1, MGO_STAGE_ZIP_UP,+ MGO_STAGE_ZIP_RIGHT, MGO_STAGE_ACTIVE_11, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, -1,+ -35, 15},+ [MGL_SHADOW] = {MGO_SHADOW_ACTIVE, -1, MGO_SHADOW_EXIT, -1, MGO_SHADOW_GET_THIS, -1, MGO_SHADOW_BIG_CAKE,+ MGO_SHADOW_ACTIVE_6, MGO_SHADOW_BALLOONS, MGO_SHADOW_ACTIVE_5, MGO_SHADOW_KID, -1, -1, -1,+ MGO_SHADOW_ZIP_UP, MGO_SHADOW_ZIP_RIGHT, MGO_SHADOW_ACTIVE_11,+ {MGO_SHADOW_BLOCK, MGO_SHADOW_BLOCK_2, MGO_SHADOW_BLOCK_3, MGO_SHADOW_BLOCK_4}, {-1, -1, -1, -1},+ {-1, -1, -1, -1}, -1, -35, 15},+ [MGL_HAPPY] = {MGO_HAPPY_ACTIVE, MGO_HAPPY_COLLECT, MGO_HAPPY_EXIT, -1, MGO_HAPPY_GET_THIS, -1, MGO_HAPPY_BIG_CAKE,+ MGO_HAPPY_ACTIVE_6, MGO_HAPPY_BALLOONS, MGO_HAPPY_ACTIVE_5, -1, -1, -1, -1, -1, -1, -1,+ {-1, -1, -1, -1}, {-1, -1, -1, -1},+ {MGO_HAPPY_ACTIVE_8, MGO_HAPPY_ACTIVE_13, MGO_HAPPY_ACTIVE_14, MGO_HAPPY_ACTIVE_15},+ MGO_HAPPY_TRIGGER, -10, 20},+};+#define NM names[M.level]++static void set_vis(int o, bool v) {+ if (o < 0) return;+ for (int i = 0; i < nin; i++)+ if (in[i].obj == o) in[i].vis = v;+}+static bool exists(int o) { return o >= 0 && first(o) >= 0; }+static bool shown(int o) {+ int i = o >= 0 ? first(o) : -1;+ return i >= 0 && in[i].vis;+}+static void kill(int o) {+ if (o < 0) return;+ for (int i = 0; i < nin; i++)+ if (in[i].obj == o) in[i].alive = 0;+}++/* ------------------------------------------------------------ a level */+void mini_begin(int level, bool from_extras) {+ memset(&M, 0, sizeof M);+ M.level = (uint8_t)level, M.from_extras = from_extras;+ L = &mg_levels[level];+ M.hx = L->start_x, M.hy = L->start_y;+ M.camx = (int16_t)(M.hx / 800 * 800), M.camy = (int16_t)(M.hy / 480 * 480);+ nin = 0;+ for (int k = 0; k < L->ninst && nin < MAXI; k++) {+ const MgInst *s = &mg_insts[L->inst0 + k];+ Inst *p = &in[nin++];+ memset(p, 0, sizeof *p);+ p->x = s->x, p->y = s->y, p->obj = s->obj, p->vis = 1, p->alive = 1;+ if (s->obj == NM.collect) M.counter++;+ }+ M.counter++; /* ("Counter": the exit opens at 1) */+ uint8_t f = g.mg_flags;+ /* (what starts hidden: the win's screen, the exits that open, the cakes given, the balloons without BB's) */+ set_vis(NM.win_screen, false);+ set_vis(NM.big_cake, false), set_vis(NM.get_this2, false);+ if (M.level != MGL_CHICA) set_vis(NM.exit, false);+ set_vis(NM.carry, false);+ set_vis(NM.balloons, f & MG_BB);+ if (f & MG_CAKE && M.level == MGL_MANGLE) kill(NM.get_this);+ static const uint8_t given[MGL_COUNT] = {MG_K1, 0, MG_K2, MG_K3, MG_K4, 0};+ if (given[level] && (f & given[level])) kill(NM.child);+ if (level == MGL_HAPPY) {+ static const uint8_t k[4] = {MG_K1, MG_K2, MG_K3, MG_K4};+ for (int i = 0; i < 4; i++) set_vis(NM.kids[i], f & k[i]);+ }+ if (level == MGL_SHADOW && (f & MG_CAKE)) set_vis(NM.big_cake, true), g.mg_flags |= MG_K4, save_progress();+}++static void win(void) {+ if (!M.win) M.win = 1, set_vis(NM.win_screen, true);+}++static void player(void) {+ uint32_t k = g.held;+ bool frozen = M.win || M.cake_t;+ /* gravity: each foot off the ground (and off a balloon) */+ if (!FEEL(FEEL_BOTTOM, 3, 41) && !FEEL_ON(FEEL_BOTTOM, 3, 41, NM.balloons) && !M.jump && !frozen && every(0, 100))+ M.hy += 10;+ if (!FEEL(FEEL_BOTTOM_2, 3, 60) && !FEEL_ON(FEEL_BOTTOM_2, 3, 60, NM.balloons) && !M.jump && !frozen && every(1, 100))+ M.hy += 10;+ bool wall_r = NM.wall >= 0 && FEEL_ON(FEEL_RIGHT, 39, -3, NM.wall), wall_l = NM.wall >= 0 && FEEL_ON(FEEL_LEFT, -33, -3, NM.wall);+ if ((k & (K_RIGHT | K_DIGIT(6))) && !FEEL(FEEL_RIGHT, 39, -3) && !wall_r && !frozen && every(2, 100))+ M.hx += NM.step, M.dir = 0, M.moving = 1;+ if ((k & (K_LEFT | K_DIGIT(4))) && !FEEL(FEEL_LEFT, -33, -3) && !wall_l && !frozen && every(3, 100))+ M.hx -= NM.step, M.dir = 16, M.moving = 1;+ bool jump = g.pressed & (K_OK | K_EXE | K_UP | K_DIGIT(8));+ bool ground = FEEL(FEEL_BOTTOM_2, 3, 60) || FEEL_ON(FEEL_BOTTOM_2, 3, 60, NM.balloons);+ if (jump && !M.jump && ground && !M.latch && !frozen) M.jump = 7, M.latch = 1; /* (the PC build's) */+ if (M.jump > 0 && every(4, 60)) M.jump--, M.hy -= 20;+ if (FEEL(FEEL_TOP, 5, -31)) M.jump = 0;+ if (FEEL(FEEL_BOTTOM_3, 3, 30) && !M.cake_t) M.hy -= 5;+ if (!(g.held & (K_OK | K_EXE | K_UP | K_DIGIT(8)))) M.latch = 0;+ /* the camera: a whole screen when the player leaves one */+ if (M.hy > M.camy + 480) M.camy += 480, M.secret = 1, M.changed = 1;+ if (M.hy < M.camy) M.camy -= 480, M.secret = 1, M.changed = 1;+ if (M.hx > M.camx + 800) M.camx += 800, M.changed = 1, M.secret |= M.level != MGL_MANGLE;+ if (M.hx < M.camx) M.camx -= 800, M.changed = 1, M.secret |= M.level != MGL_MANGLE;+ int a = first(NM.active);+ if (a >= 0) in[a].x = M.hx, in[a].y = (int16_t)(M.hy + NM.dy), in[a].dir = M.dir;+}++/* the player's sprite's box */+static void pbox(int *x0, int *y0, int *x1, int *y1) {+ int a = first(NM.active);+ if (a >= 0) box(&in[a], x0, y0, x1, y1);+ else *x0 = *x1 = M.hx, *y0 = *y1 = M.hy;+}+static bool hitbox_on(int o) {+ return o >= 0 && touching(M.hx - MGF_HITBOX_HX, M.hy - MGF_HITBOX_HY, M.hx - MGF_HITBOX_HX + MGF_HITBOX_W,+ M.hy - MGF_HITBOX_HY + MGF_HITBOX_H, o) >= 0;+}+static int player_on(int o) {+ int x0, y0, x1, y1;+ pbox(&x0, &y0, &x1, &y1);+ return o >= 0 ? touching(x0, y0, x1, y1, o) : -1;+}++static void level_events(void) {+ int i;+ /* the collectables, the cake that wins, the exit */+ if ((i = player_on(NM.collect)) >= 0 && !M.win) in[i].alive = 0, M.counter--, M.counter2 += M.level == MGL_CHICA ? 1 : 100;+ if ((M.level == MGL_MANGLE ? hitbox_on(NM.get_this) : player_on(NM.get_this) >= 0) && !M.win) {+ kill(NM.get_this), win();+ g.mg_flags |= M.level == MGL_MANGLE ? MG_CAKE : MG_BB;+ save_progress();+ }+ if (M.counter == 1 && M.level != MGL_CHICA) set_vis(NM.exit, true);+ if (player_on(NM.exit) >= 0 || player_on(NM.exit2) >= 0) win();+ if (M.changed && !(g.mg_flags & MG_BB)) kill(NM.balloons);+ M.changed = 0;+ /* giving the cake: the child's place (its "big cake" shows) */+ if ((M.level == MGL_BB || M.level == MGL_STAGE) && (g.mg_flags & MG_CAKE) && exists(NM.child) && !shown(NM.big_cake)) {+ int bc = first(NM.big_cake);+ if (bc >= 0) {+ int a, b, c, d;+ box(&in[bc], &a, &b, &c, &d);+ if (rect_hit(M.hx - MGF_HITBOX_HX, M.hy - MGF_HITBOX_HY, M.hx - MGF_HITBOX_HX + MGF_HITBOX_W,+ M.hy - MGF_HITBOX_HY + MGF_HITBOX_H, a, b, c, d)) {+ set_vis(NM.big_cake, true);+ g.mg_flags |= M.level == MGL_BB ? MG_K1 : MG_K3;+ save_progress();+ }+ }+ }+ if (M.level == MGL_CHICA && (g.mg_flags & MG_CAKE) && exists(NM.child) && !shown(NM.get_this2)) {+ int gt = first(NM.get_this2);+ if (gt >= 0) {+ int a, b, c, d;+ box(&in[gt], &a, &b, &c, &d);+ if (rect_hit(M.hx - MGF_HITBOX_HX, M.hy - MGF_HITBOX_HY, M.hx - MGF_HITBOX_HX + MGF_HITBOX_W,+ M.hy - MGF_HITBOX_HY + MGF_HITBOX_H, a, b, c, d))+ set_vis(NM.get_this2, true), g.mg_flags |= MG_K2, save_progress();+ }+ }+ if (shown(NM.big_cake) || shown(NM.get_this2)) { /* the child takes it: 100 frames, it changes, 200: done */+ M.cake_t++;+ if (M.cake_t > 100 && M.level != MGL_HAPPY && (i = first(NM.child)) >= 0) in[i].anim = 12;+ if (M.cake_t > 200 && M.level != MGL_HAPPY) win();+ }+ switch (M.level) {+ case MGL_MANGLE: {+ /* Mangle's parts: each touched once, then carried round him */+ static const int8_t off[4][2] = {{61, 41}, {21, 17}, {25, 29}, {47, 27}};+ int a = first(NM.active), all = 1;+ for (int k = 0; k < 4; k++) {+ int p = first(NM.parts[k]);+ if (p < 0) continue;+ if (!in[p].s0 && hitbox_on(NM.parts[k])) in[p].s0 = 1, M.counter2 += 100;+ if (in[p].s0 && a >= 0 && !M.win)+ in[p].dir = M.dir, in[p].x = (int16_t)(in[a].x + (M.dir ? off[k][0] : -off[k][0])), in[p].y = (int16_t)(in[a].y + off[k][1]);+ all &= in[p].s0;+ }+ if (all || M.secret) set_vis(NM.exit, true);+ if (hitbox_on(NM.kid)) win();+ if (M.counter2 >= 400 && (i = first(NM.wall)) >= 0) in[i].alive = 0;+ break;+ }+ case MGL_CHICA: {+ if ((i = player_on(NM.kids[0])) >= 0 && M.counter2 > 0 && !in[i].s0) in[i].s0 = 1, in[i].anim = 12, M.counter2--;+ int c = first(NM.carry), a = first(NM.active);+ if (c >= 0 && a >= 0) in[c].x = (int16_t)(in[a].x + (M.dir ? -34 : 34)), in[c].y = (int16_t)(in[a].y - 35);+ set_vis(NM.carry, M.counter2 > 0);+ int f = first(NM.follower);+ if (f >= 0 && !M.win && every(5, 100)) {+ if (M.hx > in[f].x) in[f].x += 10, in[f].dir = 0;+ else if (M.hx < in[f].x) in[f].x -= 10, in[f].dir = 16;+ }+ break;+ }+ case MGL_STAGE: case MGL_SHADOW:+ if (player_on(NM.zip_left) >= 0 && every(6, 50)) M.hx -= 10;+ if (player_on(NM.zip_up) >= 0 && every(7, 50)) M.hy -= 10;+ if (player_on(NM.zip_right) >= 0 && every(8, 50)) M.hx += 20;+ if (M.level == MGL_SHADOW) {+ static const int8_t push[4][2] = {{-30, 0}, {30, 0}, {0, -30}, {0, 30}};+ for (int k = 0; k < 4; k++)+ if (hitbox_on(NM.block[k])) M.hx += push[k][0], M.hy += push[k][1];+ if (hitbox_on(NM.kid)) win();+ }+ break;+ case MGL_HAPPY: {+ bool all = true;+ for (int k = 0; k < 4; k++) all &= shown(NM.kids[k]);+ if (hitbox_on(NM.trigger) && exists(NM.child) && all && !shown(NM.big_cake))+ set_vis(NM.big_cake, true), g.goodend = 1, save_progress();+ if (M.cake_t > 1300) win();+ break;+ }+ }+}++void mini_step(void) {+ M.frame++;+ if (!M.win) player();+ level_events();+ if (M.win) M.win_t++;+ /* the sprites' pictures go round */+ for (int i = 0; i < nin; i++)+ if (in[i].alive && ++in[i].cnt >= 6) in[i].cnt = 0, in[i].img++;+}++int mini_done(void) { return M.win_t >= 200; }++void mini_draw(void) {+ gfx_fill(0, 0, SCREEN_W, SCREEN_H, BLACK);+ int sx = M.camx / 800, sy = M.camy / 480;+ if (sx >= 0 && sx < L->sw && sy >= 0 && sy < L->sh) {+ uint16_t id = mg_screens[L->screen0 + sy * L->sw + sx];+ if (id != 0xFFFF) pic_part(id, 0, 24, 0, 0, SCREEN_W, 192);+ }+ for (int i = 0; i < nin; i++) {+ const Inst *p = &in[i];+ if (!p->alive || !p->vis || p->obj == NM.win_screen) continue;+ const MgAnim *a = anim_of(p);+ int x = (p->x - M.camx) * 2 / 5, y = (p->y - M.camy) * 2 / 5 + 24;+ if (x < -160 || x > SCREEN_W + 160 || y < -120 || y > SCREEN_H + 120) continue;+ gfx_sprite(a->first + p->img % a->n, x, y);+ }+ gfx_fill(0, 0, SCREEN_W, 24, BLACK);+ gfx_fill(0, 216, SCREEN_W, 24, BLACK);+ if (M.win) { /* the win: the game's white bars */+ int i = first(NM.win_screen);+ if (i >= 0) gfx_sprite(anim_of(&in[i])->first, 0, 24);+ }+ if (M.frame < 300) gfx_text(FONT_HUD, 6, SCREEN_H - 14, "Left Right walk OK jump Back pause", RGB(0x9A9A9A));+}diff --git a/games/fnaf3/src/mini.h b/games/fnaf3/src/mini.hnew file mode 100644index 00000000..ad2ae48d--- /dev/null+++ b/games/fnaf3/src/mini.h@@ -0,0 +1,5 @@+/* Five Nights at Freddy's 3: the minigames' numbers (as tools/minigames.py lists the levels). */+#ifndef FNAF3_MINI_H+#define FNAF3_MINI_H+enum { MINI_BB, MINI_MANGLE, MINI_CHICA, MINI_STAGE, MINI_SHADOW, MINI_HAPPY, MINI_COUNT };+#endifdiff --git a/games/fnaf3/src/mini_data.h b/games/fnaf3/src/mini_data.hnew file mode 100644index 00000000..60436a2d--- /dev/null+++ b/games/fnaf3/src/mini_data.h@@ -0,0 +1,671 @@+/* Made by tools/pack.py (tools/minigames.py): the minigames' levels. Included once (mini.c). */+#ifndef FNAF3_MINI_DATA_H+#define FNAF3_MINI_DATA_H+#include <stdint.h>++typedef struct { int16_t x, y, w, h; } MgRect;+typedef struct { uint8_t obj, pad; int16_t x, y; } MgInst;+typedef struct { uint8_t anim, dir, n, pad; uint16_t first; } MgAnim; /* sprites first.. */+typedef struct { uint16_t anim0; uint8_t nanim, pad; int16_t w, h, hx, hy; } MgObj; /* box: its first picture's */+typedef struct { int16_t w, h; uint8_t sw, sh; uint16_t screen0; uint16_t solid0, nsolid, inst0, ninst;+ uint8_t obj0, nobj; int16_t start_x, start_y; } MgLevel;++#define MGL_BB 0+#define MGL_MANGLE 1+#define MGL_CHICA 2+#define MGL_STAGE 3+#define MGL_SHADOW 4+#define MGL_HAPPY 5+#define MGO_BB_ACTIVE 0+#define MGO_BB_BALLOONS 1+#define MGO_BB_COLLECT 2+#define MGO_BB_GET_THIS 3+#define MGO_BB_ACTIVE_6 4+#define MGO_BB_BIG_CAKE 5+#define MGO_BB_EXIT 6+#define MGO_BB_ACTIVE_5 7+#define MGO_MANGLE_ACTIVE_4 0+#define MGO_MANGLE_SHADOW 1+#define MGO_MANGLE_EXIT 2+#define MGO_MANGLE_ACTIVE_6 3+#define MGO_MANGLE_ACTIVE_8 4+#define MGO_MANGLE_ACTIVE_7 5+#define MGO_MANGLE_ACTIVE_9 6+#define MGO_MANGLE_ACTIVE 7+#define MGO_MANGLE_COLLECT 8+#define MGO_MANGLE_GET_THIS 9+#define MGO_MANGLE_KID 10+#define MGO_MANGLE_BALLOONS 11+#define MGO_MANGLE_WALL 12+#define MGO_MANGLE_ACTIVE_5 13+#define MGO_CHICA_ACTIVE_9 0+#define MGO_CHICA_ACTIVE_8 1+#define MGO_CHICA_EXIT 2+#define MGO_CHICA_ACTIVE 3+#define MGO_CHICA_BALLOONS 4+#define MGO_CHICA_COLLECT 5+#define MGO_CHICA_COLLECT_4 6+#define MGO_CHICA_GET_THIS 7+#define MGO_CHICA_EXIT_2 8+#define MGO_CHICA_ACTIVE_4 9+#define MGO_CHICA_GET_THIS_2 10+#define MGO_CHICA_ACTIVE_5 11+#define MGO_STAGE_EXIT 0+#define MGO_STAGE_ACTIVE_8 1+#define MGO_STAGE_BALLOONS 2+#define MGO_STAGE_COLLECT 3+#define MGO_STAGE_GET_THIS 4+#define MGO_STAGE_ACTIVE_6 5+#define MGO_STAGE_BIG_CAKE 6+#define MGO_STAGE_ACTIVE_9 7+#define MGO_STAGE_ACTIVE_11 8+#define MGO_STAGE_ZIP_RIGHT 9+#define MGO_STAGE_ZIP_UP 10+#define MGO_STAGE_ACTIVE 11+#define MGO_STAGE_ACTIVE_5 12+#define MGO_SHADOW_EXIT 0+#define MGO_SHADOW_ACTIVE_8 1+#define MGO_SHADOW_BALLOONS 2+#define MGO_SHADOW_GET_THIS 3+#define MGO_SHADOW_ACTIVE_6 4+#define MGO_SHADOW_BIG_CAKE 5+#define MGO_SHADOW_ACTIVE_9 6+#define MGO_SHADOW_ACTIVE_11 7+#define MGO_SHADOW_ZIP_UP 8+#define MGO_SHADOW_BLOCK 9+#define MGO_SHADOW_BLOCK_3 10+#define MGO_SHADOW_BLOCK_4 11+#define MGO_SHADOW_BLOCK_2 12+#define MGO_SHADOW_ZIP_RIGHT 13+#define MGO_SHADOW_ACTIVE_4 14+#define MGO_SHADOW_KID 15+#define MGO_SHADOW_ACTIVE 16+#define MGO_SHADOW_ACTIVE_5 17+#define MGO_HAPPY_BIG_CAKE 0+#define MGO_HAPPY_EXIT 1+#define MGO_HAPPY_ACTIVE 2+#define MGO_HAPPY_BALLOONS 3+#define MGO_HAPPY_COLLECT 4+#define MGO_HAPPY_GET_THIS 5+#define MGO_HAPPY_ACTIVE_6 6+#define MGO_HAPPY_COLLECT_3 7+#define MGO_HAPPY_ACTIVE_8 8+#define MGO_HAPPY_ACTIVE_13 9+#define MGO_HAPPY_ACTIVE_14 10+#define MGO_HAPPY_ACTIVE_15 11+#define MGO_HAPPY_TRIGGER 12+#define MGO_HAPPY_COLLECT_4 13+#define MGO_HAPPY_ACTIVE_5 14+#define MGF_HITBOX_W 46+#define MGF_HITBOX_H 46+#define MGF_HITBOX_HX 23+#define MGF_HITBOX_HY 23+#define MGF_FEEL_RIGHT_W 28+#define MGF_FEEL_RIGHT_H 54+#define MGF_FEEL_RIGHT_HX 14+#define MGF_FEEL_RIGHT_HY 27+#define MGF_FEEL_LEFT_W 28+#define MGF_FEEL_LEFT_H 54+#define MGF_FEEL_LEFT_HX 14+#define MGF_FEEL_LEFT_HY 27+#define MGF_FEEL_TOP_W 40+#define MGF_FEEL_TOP_H 22+#define MGF_FEEL_TOP_HX 20+#define MGF_FEEL_TOP_HY 11+#define MGF_FEEL_BOTTOM_W 50+#define MGF_FEEL_BOTTOM_H 22+#define MGF_FEEL_BOTTOM_HX 25+#define MGF_FEEL_BOTTOM_HY 11+#define MGF_FEEL_BOTTOM_2_W 50+#define MGF_FEEL_BOTTOM_2_H 22+#define MGF_FEEL_BOTTOM_2_HX 25+#define MGF_FEEL_BOTTOM_2_HY 11+#define MGF_FEEL_BOTTOM_3_W 52+#define MGF_FEEL_BOTTOM_3_H 22+#define MGF_FEEL_BOTTOM_3_HX 26+#define MGF_FEEL_BOTTOM_3_HY 11+#define MGL_COUNT 6++static const MgRect mg_solids[] = {+ {0, -6, 32, 2316},+ {105, 396, 798, 30},+ {903, 396, 798, 30},+ {1701, 396, 798, 30},+ {-24, 931, 798, 30},+ {774, 931, 798, 30},+ {1572, 931, 798, 30},+ {106, 132, 798, 30},+ {904, 132, 798, 30},+ {1702, 132, 798, 30},+ {-2, -10, 3054, 30},+ {2370, 132, 32, 294},+ {2370, 426, 32, 294},+ {2370, 720, 32, 294},+ {3044, -2, 32, 2316},+ {0, 2272, 3054, 30},+ {2180, 1662, 32, 328},+ {2180, 2198, 798, 30},+ {2910, 1652, 32, 572},+ {2180, 1652, 798, 30},+ {2334, 2096, 164, 30},+ {2536, 1992, 164, 30},+ {2758, 1904, 164, 30},+ {2466, 1828, 164, 30},+ {1328, 692, 798, 30},+ {2126, 692, 798, 30},+ {0, -6, 32, 2316},+ {105, 415, 1062, 30},+ {1167, 415, 1062, 30},+ {2229, 415, 1062, 30},+ {106, 132, 1062, 30},+ {1168, 132, 1062, 30},+ {2230, 132, 1062, 30},+ {-2, -10, 3054, 30},+ {3044, -2, 32, 2316},+ {-3, 1412, 3054, 30},+ {1211, 1138, 379, 30},+ {1561, 958, 32, 494},+ {0, -6, 32, 2316},+ {107, 420, 1322, 30},+ {-219, 790, 1322, 30},+ {1660, 670, 1276, 30},+ {107, 90, 2830, 30},+ {-2, -10, 3054, 30},+ {107, 89, 32, 400},+ {107, 416, 32, 400},+ {3044, -2, 32, 2316},+ {0, 2274, 3054, 30},+ {2180, 1662, 32, 328},+ {2014, 1534, 32, 772},+ {2180, 2198, 2830, 30},+ {2910, 1652, 32, 572},+ {2180, 1652, 2830, 30},+ {2334, 2096, 164, 30},+ {2536, 1992, 164, 30},+ {2758, 1904, 164, 30},+ {2466, 1828, 164, 30},+ {2367, 284, 32, 400},+ {904, 1358, 1276, 30},+ {1669, 1357, 1276, 30},+ {2237, 960, 32, 400},+ {332, 1066, 32, 322},+ {330, 1066, 164, 30},+ {176, 1066, 164, 30},+ {1070, 792, 32, 322},+ {1070, 1063, 32, 322},+ {0, -6, 32, 2316},+ {124, 58, 566, 30},+ {124, 362, 566, 30},+ {-2, -10, 3054, 30},+ {659, 59, 32, 304},+ {125, 59, 32, 304},+ {134, 298, 358, 92},+ {2382, -32, 32, 2316},+ {-6, 952, 3054, 30},+ {924, 58, 566, 30},+ {924, 362, 566, 30},+ {1459, 59, 32, 304},+ {925, 59, 32, 304},+ {934, 298, 358, 92},+ {128, 523, 566, 30},+ {128, 827, 566, 30},+ {663, 524, 32, 304},+ {129, 524, 32, 304},+ {138, 763, 358, 92},+ {930, 519, 566, 30},+ {930, 823, 566, 30},+ {1465, 520, 32, 304},+ {931, 520, 32, 304},+ {940, 759, 358, 92},+ {1716, 521, 566, 30},+ {1716, 825, 566, 30},+ {2251, 522, 32, 304},+ {1717, 522, 32, 304},+ {1726, 761, 358, 92},+ {1722, 56, 566, 30},+ {1722, 360, 566, 30},+ {2257, 57, 32, 304},+ {1723, 57, 32, 304},+ {78, 48, 32, 330},+ {664, 46, 32, 330},+ {78, 45, 618, 30},+ {78, 348, 618, 30},+ {0, 2272, 3054, 30},+ {2698, 534, 164, 30},+ {2434, 468, 164, 30},+ {2522, 300, 164, 30},+ {2788, 274, 164, 30},+ {2927, 114, 32, 562},+ {103, 1410, 802, 32},+ {295, 822, 164, 30},+ {922, 38, 32, 330},+ {1508, 36, 32, 330},+ {922, 35, 618, 30},+ {922, 338, 618, 30},+ {1680, 52, 32, 330},+ {2266, 50, 32, 330},+ {1680, 49, 618, 30},+ {1680, 352, 618, 30},+ {70, 552, 32, 330},+ {656, 550, 32, 330},+ {70, 549, 618, 30},+ {70, 852, 618, 30},+ {906, 539, 32, 330},+ {1492, 537, 32, 330},+ {906, 536, 618, 30},+ {906, 839, 618, 30},+ {106, 101, 32, 349},+ {0, -6, 32, 2316},+ {106, 422, 1016, 30},+ {1122, 422, 1016, 30},+ {2138, 422, 1016, 30},+ {106, 101, 1016, 30},+ {1122, 101, 1016, 30},+ {2138, 101, 1016, 30},+ {-2, -10, 3054, 30},+ {2388, 101, 32, 349},+ {3044, -2, 32, 2316},+ {0, 2272, 3054, 30},+ {2180, 1452, 32, 349},+ {2180, 2198, 1016, 30},+ {2910, 1652, 32, 572},+ {2180, 1652, 1016, 30},+};+static const MgInst mg_insts[] = {+ {0, 0, 271, 317},+ {1, 0, 227, 721},+ {1, 0, 357, 721},+ {1, 0, 487, 721},+ {1, 0, 617, 721},+ {1, 0, 747, 721},+ {1, 0, 877, 721},+ {1, 0, 1007, 721},+ {1, 0, 1137, 721},+ {1, 0, 1267, 721},+ {2, 0, 1299, 321},+ {2, 0, 681, 283},+ {2, 0, 882, 328},+ {2, 0, 1100, 278},+ {3, 0, 2540, 1754},+ {4, 0, 2164, 639},+ {5, 0, 2006, 608},+ {2, 0, 1523, 275},+ {2, 0, 1747, 322},+ {2, 0, 1941, 272},+ {6, 0, 2206, 329},+ {6, 0, 1890, 1089},+ {3, 0, 2272, 837},+ {7, 0, 0, 0},+ {0, 0, 1184, 1640},+ {0, 0, 1306, 1778},+ {0, 0, 1452, 1688},+ {0, 0, 1604, 1652},+ {0, 0, 1520, 1736},+ {0, 0, 1218, 1016},+ {0, 0, 1517, 1071},+ {0, 0, 1848, 916},+ {0, 0, 1412, 844},+ {0, 0, 1124, 894},+ {0, 0, 1938, 1064},+ {0, 0, 1136, 1094},+ {0, 0, 712, 782},+ {0, 0, 697, 606},+ {0, 0, 587, 849},+ {0, 0, 167, 611},+ {0, 0, 104, 729},+ {0, 0, 938, 878},+ {0, 0, 1790, 866},+ {0, 0, 1984, 836},+ {0, 0, 1864, 1740},+ {0, 0, 1108, 1718},+ {1, 0, 310, 666},+ {2, 0, 2927, 349},+ {3, 0, 694, 358},+ {4, 0, 1095, 334},+ {5, 0, 2153, 384},+ {6, 0, 1999, 375},+ {7, 0, 365, 285},+ {8, 0, -84, 352},+ {9, 0, 3367, 1459},+ {10, 0, 2479, -106},+ {2, 0, 1437, 1347},+ {11, 0, 1320, 2150},+ {11, 0, 1134, 2006},+ {11, 0, 1418, 1932},+ {11, 0, 1716, 1862},+ {11, 0, 1952, 1726},+ {11, 0, 1738, 1624},+ {11, 0, 242, 1167},+ {11, 0, 372, 1167},+ {11, 0, 502, 1167},+ {11, 0, 632, 1167},+ {11, 0, 762, 1167},+ {11, 0, 892, 1167},+ {11, 0, 1022, 1167},+ {11, 0, 1152, 1167},+ {9, 0, 1335, 1054},+ {12, 0, 105, 131},+ {13, 0, 0, 0},+ {0, 0, 1716, 2279},+ {1, 0, 2277, 670},+ {1, 0, 2121, 668},+ {2, 0, 2162, 1289},+ {3, 0, 445, 558},+ {4, 0, 1131, 734},+ {4, 0, 1261, 734},+ {4, 0, 1391, 734},+ {5, 0, 1049, 383},+ {6, 0, 479, 521},+ {7, 0, 2540, 1754},+ {5, 0, 1200, 382},+ {1, 0, 1446, 1356},+ {1, 0, 1224, 1356},+ {5, 0, 1758, 1316},+ {5, 0, 1863, 1316},+ {8, 0, 128, 2206},+ {9, 0, 219, 740},+ {10, 0, 364, 707},+ {11, 0, 0, 0},+ {0, 0, 2328, 873},+ {1, 0, 386, 202},+ {2, 0, -175, 1094},+ {3, 0, -82, 352},+ {4, 0, 3258, 1768},+ {5, 0, 2192, 309},+ {6, 0, 2056, 277},+ {7, 0, 580, 361},+ {8, 0, 307, 326},+ {9, 0, 1725, 201},+ {9, 0, 2259, 255},+ {10, 0, 1544, 276},+ {10, 0, 952, 622},+ {11, 0, 273, 213},+ {1, 0, 1186, 202},+ {7, 0, 1380, 361},+ {1, 0, 390, 667},+ {7, 0, 584, 826},+ {1, 0, 1192, 663},+ {7, 0, 1386, 822},+ {1, 0, 1978, 665},+ {7, 0, 2172, 824},+ {12, 0, 0, 0},+ {0, 0, 172, 281},+ {1, 0, 434, 254},+ {2, 0, -175, 1094},+ {3, 0, 3258, 1768},+ {4, 0, 1540, 897},+ {5, 0, 1425, 865},+ {6, 0, 521, 349},+ {7, 0, 207, -136},+ {8, 0, 1166, -184},+ {9, 0, 801, 227},+ {10, 0, 403, 481},+ {11, 0, 513, 6},+ {12, 0, 8, 236},+ {13, 0, 3164, 466},+ {14, 0, 332, 267},+ {15, 0, 777, 1324},+ {16, 0, 378, 252},+ {10, 0, 404, 961},+ {12, 0, 1597, 244},+ {17, 0, 0, 0},+ {0, 0, 2183, 255},+ {1, 0, 260, 355},+ {2, 0, 445, 573},+ {3, 0, 65, 1130},+ {4, 0, 1088, -246},+ {5, 0, 2540, 1754},+ {3, 0, 340, 1240},+ {3, 0, 656, 1328},+ {3, 0, 860, 1270},+ {3, 0, 1050, 1222},+ {3, 0, 1242, 1168},+ {3, 0, 1464, 1166},+ {3, 0, 1698, 1166},+ {6, 0, 2348, 371},+ {7, 0, 1658, 229},+ {7, 0, 1734, 188},+ {7, 0, 1814, 233},+ {7, 0, 1896, 191},+ {8, 0, 1655, 353},+ {9, 0, 1741, 353},+ {10, 0, 1835, 353},+ {11, 0, 1923, 353},+ {12, 0, 2056, 279},+ {7, 0, 1984, 222},+ {7, 0, 2345, 211},+ {13, 0, 1520, 227},+ {13, 0, 1025, 206},+ {13, 0, 1441, 196},+ {13, 0, 310, 238},+ {13, 0, 395, 205},+ {13, 0, 718, 201},+ {13, 0, 861, 222},+ {13, 0, 935, 191},+ {14, 0, 0, 0},+};+static const MgAnim mg_anims[] = {+ {0, 0, 1, 0, 0},+ {0, 16, 1, 0, 1},+ {0, 0, 1, 0, 2},+ {0, 0, 1, 0, 3},+ {0, 0, 4, 0, 3},+ {0, 0, 1, 0, 7},+ {12, 0, 1, 0, 8},+ {0, 0, 1, 0, 9},+ {0, 0, 1, 0, 10},+ {0, 0, 1, 0, 11},+ {0, 0, 4, 0, 12},+ {0, 0, 1, 0, 16},+ {0, 0, 1, 0, 10},+ {0, 0, 1, 0, 17},+ {0, 16, 1, 0, 18},+ {0, 0, 1, 0, 19},+ {0, 16, 1, 0, 20},+ {0, 0, 1, 0, 21},+ {0, 16, 1, 0, 22},+ {0, 0, 1, 0, 23},+ {0, 16, 1, 0, 24},+ {0, 0, 1, 0, 25},+ {0, 16, 1, 0, 26},+ {0, 0, 1, 0, 3},+ {0, 0, 1, 0, 9},+ {0, 0, 2, 0, 27},+ {0, 16, 2, 0, 29},+ {0, 0, 1, 0, 2},+ {0, 0, 1, 0, 31},+ {0, 0, 1, 0, 11},+ {0, 0, 1, 0, 32},+ {0, 16, 1, 0, 33},+ {0, 0, 1, 0, 34},+ {12, 0, 1, 0, 35},+ {0, 0, 1, 0, 10},+ {0, 0, 1, 0, 36},+ {0, 16, 1, 0, 37},+ {0, 0, 1, 0, 2},+ {0, 0, 1, 0, 38},+ {0, 0, 1, 0, 39},+ {0, 0, 4, 0, 3},+ {0, 0, 1, 0, 10},+ {0, 0, 1, 0, 7},+ {12, 0, 1, 0, 8},+ {0, 0, 1, 0, 9},+ {0, 0, 1, 0, 11},+ {0, 0, 1, 0, 10},+ {0, 0, 8, 0, 44},+ {0, 16, 1, 0, 52},+ {0, 0, 1, 0, 2},+ {0, 0, 1, 0, 3},+ {0, 0, 4, 0, 3},+ {0, 0, 1, 0, 7},+ {12, 0, 1, 0, 8},+ {0, 0, 1, 0, 9},+ {0, 0, 2, 0, 54},+ {12, 0, 1, 0, 35},+ {0, 0, 1, 0, 56},+ {0, 0, 1, 0, 57},+ {0, 0, 1, 0, 58},+ {0, 0, 1, 0, 59},+ {0, 16, 1, 0, 60},+ {0, 0, 1, 0, 11},+ {0, 0, 1, 0, 10},+ {0, 0, 8, 0, 61},+ {0, 16, 1, 0, 52},+ {0, 0, 1, 0, 2},+ {0, 0, 4, 0, 3},+ {0, 0, 1, 0, 69},+ {12, 0, 1, 0, 70},+ {0, 0, 1, 0, 9},+ {0, 0, 2, 0, 71},+ {12, 0, 1, 0, 35},+ {0, 0, 1, 0, 56},+ {0, 0, 1, 0, 73},+ {0, 0, 1, 0, 74},+ {0, 0, 1, 0, 75},+ {0, 0, 1, 0, 76},+ {0, 0, 1, 0, 77},+ {0, 0, 1, 0, 73},+ {0, 0, 2, 0, 78},+ {0, 0, 2, 0, 27},+ {0, 16, 2, 0, 29},+ {0, 0, 1, 0, 80},+ {0, 16, 1, 0, 81},+ {12, 0, 4, 0, 82},+ {12, 16, 4, 0, 86},+ {0, 0, 1, 0, 11},+ {0, 0, 1, 0, 90},+ {0, 0, 1, 0, 10},+ {0, 0, 1, 0, 91},+ {0, 16, 1, 0, 92},+ {12, 0, 1, 0, 93},+ {0, 0, 1, 0, 2},+ {0, 0, 1, 0, 3},+ {0, 0, 4, 0, 3},+ {0, 0, 1, 0, 7},+ {12, 0, 1, 0, 8},+ {13, 0, 1, 0, 94},+ {14, 0, 1, 0, 95},+ {0, 0, 1, 0, 3},+ {12, 0, 1, 0, 96},+ {13, 0, 1, 0, 97},+ {14, 0, 1, 0, 98},+ {15, 0, 1, 0, 99},+ {0, 0, 1, 0, 100},+ {12, 0, 1, 0, 101},+ {0, 0, 1, 0, 102},+ {12, 0, 1, 0, 103},+ {0, 0, 1, 0, 104},+ {12, 0, 1, 0, 105},+ {0, 0, 1, 0, 106},+ {12, 0, 1, 0, 107},+ {0, 0, 1, 0, 108},+ {0, 0, 1, 0, 3},+ {12, 0, 1, 0, 96},+ {13, 0, 1, 0, 97},+ {14, 0, 1, 0, 98},+ {15, 0, 1, 0, 99},+ {0, 0, 1, 0, 11},+};+static const MgObj mg_objs[] = {+ {0, 2, 0, 112, 119, 56, 59},+ {2, 1, 0, 130, 114, 65, 57},+ {3, 1, 0, 68, 114, 34, 57},+ {4, 1, 0, 68, 114, 34, 57},+ {5, 2, 0, 94, 98, 44, 45},+ {7, 1, 0, 159, 168, 79, 84},+ {8, 1, 0, 103, 124, 47, 57},+ {9, 1, 0, 1024, 768, 0, 0},+ {10, 1, 0, 14, 14, 7, 7},+ {11, 1, 0, 69, 8, 34, 4},+ {12, 1, 0, 103, 124, 47, 57},+ {13, 2, 0, 112, 119, 37, 69},+ {15, 2, 0, 112, 119, 46, 51},+ {17, 2, 0, 112, 119, 76, 85},+ {19, 2, 0, 71, 40, 67, 30},+ {21, 2, 0, 112, 119, 37, 69},+ {23, 1, 0, 68, 114, 34, 57},+ {24, 1, 0, 159, 168, 79, 84},+ {25, 2, 0, 168, 168, 82, 84},+ {27, 1, 0, 130, 114, 65, 57},+ {28, 1, 0, 32, 314, 0, 0},+ {29, 1, 0, 1024, 768, 0, 0},+ {30, 2, 0, 142, 142, 70, 141},+ {32, 2, 0, 92, 92, 46, 91},+ {34, 1, 0, 103, 124, 47, 57},+ {35, 2, 0, 112, 147, 56, 73},+ {37, 1, 0, 130, 114, 65, 57},+ {38, 1, 0, 82, 76, 41, 38},+ {39, 1, 0, 36, 33, 18, 16},+ {40, 1, 0, 68, 114, 34, 57},+ {41, 1, 0, 103, 124, 47, 57},+ {42, 2, 0, 94, 98, 44, 45},+ {44, 1, 0, 159, 168, 79, 84},+ {45, 1, 0, 1024, 768, 0, 0},+ {46, 1, 0, 103, 124, 47, 57},+ {47, 2, 0, 130, 187, 65, 91},+ {49, 1, 0, 130, 114, 65, 57},+ {50, 1, 0, 68, 114, 34, 57},+ {51, 1, 0, 68, 114, 34, 57},+ {52, 2, 0, 94, 98, 44, 45},+ {54, 1, 0, 159, 168, 79, 84},+ {55, 2, 0, 92, 92, 46, 91},+ {57, 1, 0, 406, 32, 203, 16},+ {58, 1, 0, 72, 216, 36, 108},+ {59, 1, 0, 106, 224, 53, 112},+ {60, 2, 0, 144, 165, 72, 81},+ {62, 1, 0, 1024, 768, 0, 0},+ {63, 1, 0, 103, 124, 47, 57},+ {64, 2, 0, 130, 187, 65, 91},+ {66, 1, 0, 130, 114, 65, 57},+ {67, 1, 0, 68, 114, 34, 57},+ {68, 2, 0, 94, 98, 44, 45},+ {70, 1, 0, 159, 168, 79, 84},+ {71, 2, 0, 92, 92, 46, 91},+ {73, 1, 0, 406, 32, 203, 16},+ {74, 1, 0, 106, 216, 53, 108},+ {75, 1, 0, 22, 509, 11, 254},+ {76, 1, 0, 816, 24, 408, 12},+ {77, 1, 0, 1028, 24, 514, 12},+ {78, 1, 0, 22, 493, 11, 246},+ {79, 1, 0, 106, 216, 53, 108},+ {80, 1, 0, 144, 165, 71, 81},+ {81, 2, 0, 168, 168, 82, 84},+ {83, 4, 0, 130, 187, 65, 91},+ {87, 1, 0, 1024, 768, 0, 0},+ {88, 1, 0, 159, 168, 77, 105},+ {89, 1, 0, 103, 124, 47, 57},+ {90, 3, 0, 112, 119, 56, 59},+ {93, 1, 0, 130, 114, 65, 57},+ {94, 1, 0, 68, 114, 34, 57},+ {95, 1, 0, 68, 114, 34, 57},+ {96, 4, 0, 94, 98, 44, 45},+ {100, 5, 0, 68, 114, 34, 57},+ {105, 2, 0, 122, 127, 63, 58},+ {107, 2, 0, 122, 127, 63, 58},+ {109, 2, 0, 122, 127, 63, 58},+ {111, 2, 0, 122, 127, 63, 58},+ {113, 1, 0, 64, 272, 30, 127},+ {114, 5, 0, 68, 114, 34, 57},+ {119, 1, 0, 1024, 768, 0, 0},+};+static const uint16_t mg_screens[] = {+ 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,+ 65535, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 65535,+ 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263,+ 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,+ 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 65535,+ 287, 288, 289, 65535, 290, 291, 292, 293, 294, 295, 296, 297,+ 65535, 298, 299, 300, 65535, 65535, 301, 302, 65535, 65535, 303, 304,+ 305, 306, 307, 308, 309, 310, 311, 65535, 312, 313, 314, 65535,+ 65535, 315, 316, 317, 318, 319, 320, 321, 322, 323,+};+static const MgLevel mg_levels[MGL_COUNT] = {+ {2400, 960, 3, 2, 0, 0, 26, 0, 24, 0, 8, 276, 306},+ {3072, 2304, 4, 5, 6, 26, 12, 24, 50, 8, 14, 331, 348},+ {3072, 2304, 4, 5, 26, 38, 28, 74, 20, 22, 12, 331, 285},+ {3072, 2304, 4, 5, 46, 66, 33, 94, 23, 34, 13, 277, 215},+ {3072, 2304, 4, 5, 66, 99, 28, 117, 20, 47, 18, 379, 260},+ {3072, 2304, 4, 5, 86, 127, 16, 137, 34, 65, 15, 561, 331},+};++#endifdiff --git a/games/fnaf3/src/night.c b/games/fnaf3/src/night.cindex 5c16f609..dea7e0ad 100644--- a/games/fnaf3/src/night.c+++ b/games/fnaf3/src/night.c@@ -4,6 +4,7 @@#include <string.h>#include "game.h"#include "data.h"+#include "mini.h"#include "plat.h"#define N g.n@@ -177,6 +178,7 @@ static void input(void) {to = N.vents_map ? (id <= 5 ? 10 + id : 0) : id;}if (to && to != now && !(N.vents_map && N.sealing)) select_cam(to);+ if (pressed(K_DIGIT(8)) && now == 8 && !N.vents_map) g.mini_next = MINI_BB + 1; /* BB on CAM 08 [690] */if (pressed(K_OK)) {if (!N.vents_map) play_audio();else N.sealing = N.vent, N.seal_t = (int16_t)(50 + rnd_n(50)); /* (the double click on a vent camera) */diff --git a/games/fnaf3/src/save.c b/games/fnaf3/src/save.cindex aee4b803..f311bd3c 100644--- a/games/fnaf3/src/save.c+++ b/games/fnaf3/src/save.c@@ -15,7 +15,7 @@typedef struct { /* the game's Ini keys: level, beatgame, beat6, goodend, and the extras' cheats */uint32_t magic;uint8_t version, level, beatgame, beat6;- uint8_t goodend, cheats, keys_seen, pad;+ uint8_t goodend, cheats, keys_seen, mg; /* mg: the minigames' keys (bb, cake, k1 to k4) */} Progress;typedef struct {@@ -114,7 +114,7 @@ void save_progress(void) {memset(&p, 0, sizeof p);p.magic = MAGIC, p.version = VERSION;p.level = g.level, p.beatgame = g.beatgame, p.beat6 = g.beat6, p.goodend = g.goodend;- p.cheats = g.cheats, p.keys_seen = g.keys_seen;+ p.cheats = g.cheats, p.keys_seen = g.keys_seen, p.mg = g.mg_flags;plat_save(SAVE_NAME, &p, sizeof p);copy_write();}@@ -129,7 +129,7 @@ void save_load(void) {if (p.magic != MAGIC || p.version != VERSION) return;g.level = p.level >= 1 && p.level <= 7 ? p.level : 1;g.beatgame = p.beatgame & 1, g.beat6 = p.beat6 & 1, g.goodend = p.goodend & 1;- g.cheats = p.cheats & 15, g.keys_seen = p.keys_seen ? 1 : 0;+ g.cheats = p.cheats & 15, g.keys_seen = p.keys_seen ? 1 : 0, g.mg_flags = p.mg & 63;}void save_resume(void) {diff --git a/games/fnaf3/tests/rules.c b/games/fnaf3/tests/rules.cindex 07214fca..cfc5a90a 100644--- a/games/fnaf3/tests/rules.c+++ b/games/fnaf3/tests/rules.c@@ -8,6 +8,8 @@#include "../src/game.h"#include "../src/gfx.h"#include "../src/plat.h"+#include "../src/mini.h"+#include "../src/mini_data.h"extern const uint8_t fnaf3_data[];const uint8_t *fnaf3_bin;@@ -186,6 +188,75 @@ static void fuzz(int sessions) {}}+/* the minigames: standing, walking, the cake handed round to Happiest Day's good ending */+static int inst_of(int level, int obj, int *x, int *y) {+ const MgLevel *l = &mg_levels[level];+ for (int k = 0; k < l->ninst; k++)+ if (mg_insts[l->inst0 + k].obj == obj) return *x = mg_insts[l->inst0 + k].x, *y = mg_insts[l->inst0 + k].y, 1;+ return 0;+}++static void minis(void) {+ for (int l = 0; l < MINI_COUNT; l++) {+ g.mg_flags = 0;+ mini_begin(l, false);+ g.scene = SC_MINI;+ steps(60 * 3, 0);+ int y0 = g.mg.hy;+ steps(60, 0);+ CHECK(g.mg.hy == y0 && y0 < mg_levels[l].h, "minigame %d: standing (y %d then %d)", l, y0, g.mg.hy);+ int ground = g.mg.hy, top = ground; /* (from where it starts: Stage 01's room is low further on) */+ step(K_OK);+ for (int k = 0; k < 60; k++) step(0), top = g.mg.hy < top ? g.mg.hy : top;+ CHECK(ground - top >= 120 && ground - top <= 160, "minigame %d: a jump of 7 steps (%d px)", l, ground - top);+ steps(60, 0);+ int x0 = g.mg.hx;+ steps(60 * 2, K_RIGHT);+ CHECK(g.mg.hx > x0 + 100, "minigame %d: walks right (%d to %d)", l, x0, g.mg.hx);+ for (int k = 0; k < 60 * 30 && g.scene == SC_MINI; k++) step(k % 25 == 0 ? K_RIGHT | K_OK : K_RIGHT);+ CHECK(g.mg.hy < mg_levels[l].h + 480, "minigame %d: stays in its level", l);+ }+ /* Mangle's Quest's cake, given in BB's Air Adventure, Chica's Party, Stage 01 and Shadow Bonnie */+ g.mg_flags = 0, g.goodend = 0;+ int x, y;+ mini_begin(MINI_MANGLE, false);+ CHECK(inst_of(MINI_MANGLE, MGO_MANGLE_GET_THIS, &x, &y), "Mangle's cake is there");+ g.mg.hx = (int16_t)x, g.mg.hy = (int16_t)y;+ step(0);+ CHECK(g.mg_flags & MG_CAKE && g.mg.win, "the cake taken");+ mini_begin(MINI_BB, false);+ inst_of(MINI_BB, MGO_BB_BIG_CAKE, &x, &y);+ g.mg.hx = (int16_t)x, g.mg.hy = (int16_t)y;+ steps(260, 0);+ CHECK(g.mg_flags & MG_K1 && g.mg.win, "BB's child has it");+ mini_begin(MINI_STAGE, false);+ inst_of(MINI_STAGE, MGO_STAGE_BIG_CAKE, &x, &y);+ g.mg.hx = (int16_t)x, g.mg.hy = (int16_t)y;+ steps(260, 0);+ CHECK(g.mg_flags & MG_K3, "Stage 01's child has it");+ mini_begin(MINI_CHICA, false);+ inst_of(MINI_CHICA, MGO_CHICA_GET_THIS_2, &x, &y);+ g.mg.hx = (int16_t)x, g.mg.hy = (int16_t)y;+ steps(260, 0);+ CHECK(g.mg_flags & MG_K2, "Chica's Party's child has it");+ mini_begin(MINI_SHADOW, false);+ CHECK(g.mg_flags & MG_K4, "Shadow Bonnie's child has it");+ mini_begin(MINI_HAPPY, false);+ inst_of(MINI_HAPPY, MGO_HAPPY_TRIGGER, &x, &y);+ g.mg.hx = (int16_t)x, g.mg.hy = (int16_t)y;+ step(0);+ CHECK(g.goodend, "Happiest Day: the good ending");+ /* after the first night, its minigame; after it, the second night */+ g.mg_flags = 0, g.goodend = 0;+ night(1);+ N.hour = 5, N.frame = 0;+ for (int k = 0; k < 60 * 70 && g.scene != SC_MINI; k++) step(k % 2 ? K_OK : 0);+ CHECK(g.scene == SC_MINI && g.mg.level == MINI_MANGLE, "after night 1: Mangle's Quest (%d)", g.scene);+ tap(K_BACK);+ steps(2, 0);+ CHECK((g.scene == SC_DAY || g.scene == SC_NIGHT) && g.n.night == 2, "then night 2 (%d %d)", g.scene, g.n.night);+}+static void saves(void) {night(3);steps(60 * 30, 0);@@ -208,6 +279,20 @@ static void shot(const char *dir, const char *name) {host_shot(p);}+static void draw_minis(const char *dir) {+ for (int l = 0; l < 6; l++) {+ mini_begin(l, false);+ g.scene = SC_MINI;+ steps(90, 0);+ char n[32];+ snprintf(n, sizeof n, "mini%d", l);+ shot(dir, n);+ for (int k = 0; k < 120; k++) step(k % 40 == 0 ? K_RIGHT | K_OK : K_RIGHT);+ snprintf(n, sizeof n, "mini%db", l);+ shot(dir, n);+ }+}+static void draw_all(const char *dir) {night(5);steps(60, 0);@@ -244,6 +329,10 @@ int main(int argc, char **argv) {fnaf3_bin = fnaf3_data;host_save_dir("build");game_init();+ if (argc > 2 && !strcmp(argv[1], "minis")) {+ draw_minis(argv[2]);+ return 0;+ }if (argc > 2 && !strcmp(argv[1], "shots")) {draw_all(argv[2]);return 0;@@ -251,6 +340,7 @@ int main(int argc, char **argv) {rules();bot_nights();fuzz(60);+ minis();saves();printf("%d checks, %d failed\n", checks, fails);return fails != 0;diff --git a/games/fnaf3/tools/ccn.py b/games/fnaf3/tools/ccn.pyindex c0bf7340..9de75e0a 100644--- a/games/fnaf3/tools/ccn.py+++ b/games/fnaf3/tools/ccn.py@@ -40,7 +40,7 @@ class App:self.pics[h] = (fmt, w, hh, q + 22, size, hx, hy)q += 22 + sizeself.bank = bank- self.objects, self.by_name = {}, {}+ self.objects, self.by_name, self.props, self.dirs = {}, {}, {}, {}b = next(c for i, c in top if i == 0x2229)q = 4for _ in range(struct.unpack_from("<I", b, 0)[0]):@@ -59,7 +59,9 @@ class App:breakanims = self._anims(props) if head[1] == 2 and props else {}self.objects[head[0]] = (head[1], name, anims)- self.frames = {}+ self.props[head[0]] = props+ self.dirs[head[0]] = self._dirs(props) if head[1] == 2 and props else {}+ self.frames, self.frame_size = {}, {}for i, c in top:if i != 0x3333:continue@@ -71,6 +73,7 @@ class App:_, obj, px, py = struct.unpack_from("<HHii", x, 4 + 20 * k)placed.append((obj, px, py))self.frames[name] = placed+ self.frame_size[name] = struct.unpack_from("<ii", sub[0x3334], 0)@staticmethoddef _anims(p):@@ -89,6 +92,31 @@ class App:out[a] = list(struct.unpack_from(f"<{n}H", p, q + 8))return out+ @staticmethod+ def _dirs(p):+ """every animation's directions: {(animation, direction): pictures}"""+ at = struct.unpack_from("<H", p, 6)[0]+ out = {}+ if not at:+ return out+ count = struct.unpack_from("<H", p, at + 2)[0]+ for a, off in enumerate(struct.unpack_from(f"<{count}H", p, at + 4)):+ if not off:+ continue+ for d, doff in enumerate(struct.unpack_from("<32H", p, at + off)):+ if doff:+ q = at + off + doff+ n = struct.unpack_from("<H", p, q + 6)[0]+ out[(a, d)] = list(struct.unpack_from(f"<{n}H", p, q + 8))+ return out++ def backdrop(self, h):+ """a backdrop's obstacle type (1 solid), its size and picture"""+ p = self.props[h]+ obst = struct.unpack_from("<H", p, 4)[0]+ w, hh = struct.unpack_from("<II", p, 8)+ return obst, w, hh, struct.unpack_from("<H", p, 16)[0]+def picture(self, h):"""a picture by its number, RGBA"""fmt, w, hh, at, size = self.pics[h][:5]diff --git a/games/fnaf3/tools/minigames.py b/games/fnaf3/tools/minigames.pynew file mode 100644index 00000000..0ffe0457--- /dev/null+++ b/games/fnaf3/tools/minigames.py@@ -0,0 +1,192 @@+"""Five Nights at Freddy's 3's 8-bit minigames for tools/pack.py: each level's scenery, its sprites and its walls.++A level is one of the game's frames (BB, Mangle, Toy Chica, GFreddy, RWQFSFASXC, Marion), seen a screen of 800 x 480+at a time; here at 0.4, 320 x 192. What never moves (the backdrops and the actives no event touches) is drawn into a+picture for each screen; what does is a sprite (16 colours, one of them clear). The walls are the frame's solid+backdrops, kept in the game's own coordinates (the game is played in them, src/mini.c)."""+import re+import struct++import numpy as np+from PIL import Image++S = 0.4+SW, SH = 800, 480+# key, the game's frame, its events (gamesrc spec, for the objects they touch)+LEVELS = [("BB", "BB"), ("MANGLE", "Mangle"), ("CHICA", "Toy Chica"), ("STAGE", "GFreddy"),+ ("SHADOW", "RWQFSFASXC"), ("HAPPY", "Marion")]+LOGIC = {"hitbox", "feel right", "feel left", "feel top", "feel bottom", "feel bottom 2", "feel bottom 3",+ "watch screen", "right arrow", "right arrow 2", "right arrow 3", "view", "Active 2", "blip flash"}+TOUCHED = {+ "BB": "Active 5,Active 6,Active,balloons,big cake,collect,exit,get this",+ "MANGLE": "Active 4,Active 5,Active 6,Active 7,Active 8,Active 9,Active,balloons,collect,exit,get this,kid,"+ "shadow,wall",+ "CHICA": "Active 4,Active 5,Active 8,Active 9,Active,balloons,collect 4,collect,exit 2,exit,get this 2,get this",+ "STAGE": "Active 11,Active 5,Active 6,Active 8,Active 9,Active,balloons,big cake,collect,exit,get this,"+ "zip right,zip up",+ "SHADOW": "Active 11,Active 4,Active 5,Active 6,Active 8,Active 9,Active,balloons,big cake,block 2,block 3,"+ "block 4,block,exit,get this,kid,zip right,zip up",+ "HAPPY": "Active 13,Active 14,Active 15,Active 5,Active 6,Active 8,Active,balloons,big cake,collect 3,collect 4,"+ "collect,exit,get this,trigger",+}+FEELERS = ["hitbox", "feel right", "feel left", "feel top", "feel bottom", "feel bottom 2", "feel bottom 3"]++SPRITES = []+_SPR = {}+++def c_name(s):+ return re.sub(r"[^A-Z0-9]", "_", s.upper())+++def sprite(app, h):+ """a picture of the game's as a sprite at 0.4: 16 colours, 0 clear (shared when used twice)"""+ if h in _SPR:+ return _SPR[h]+ im = app.picture(h).convert("RGBA")+ hx, hy = app.hotspot(h)+ w, hh = max(1, round(im.width * S)), max(1, round(im.height * S))+ small = im.resize((w, hh), Image.BOX)+ a = np.asarray(small)+ solid = a[..., 3] >= 128+ rgb = Image.fromarray(a[..., :3].astype(np.uint8))+ q = rgb.quantize(colors=15, method=Image.Quantize.MEDIANCUT)+ pal = (q.getpalette() + [0] * 48)[:45]+ idx = np.asarray(q).astype(np.uint8) + 1+ idx[~solid] = 0+ colours = [0] + [((pal[3 * i] >> 3) << 11) | ((pal[3 * i + 1] >> 2) << 5) | (pal[3 * i + 2] >> 3) for i in range(15)]+ rows = bytearray()+ for r in range(hh):+ row = list(idx[r]) + [0]+ for c in range(0, w, 2):+ rows.append(int(row[c]) | int(row[c + 1]) << 4)+ blob = struct.pack("<HHhh", w, hh, round(hx * S), round(hy * S)) + struct.pack("<16H", *colours) + bytes(rows)+ _SPR[h] = len(SPRITES)+ SPRITES.append((blob, im.width, im.height, hx, hy))+ return _SPR[h]+++def pack_sprites():+ out = struct.pack("<I", len(SPRITES))+ p = 4 + 4 * len(SPRITES)+ for b, *_ in SPRITES:+ out += struct.pack("<I", p)+ p += len(b) + (-len(b) % 4)+ return out + b"".join(b + bytes(-len(b) % 4) for b, *_ in SPRITES)+++def build(app, pic, arr):+ """the levels: screen pictures (pic), sprites; returns the lines of src/mini_data.h"""+ h = ["/* Made by tools/pack.py (tools/minigames.py): the minigames' levels. Included once (mini.c). */",+ "#ifndef FNAF3_MINI_DATA_H", "#define FNAF3_MINI_DATA_H", "#include <stdint.h>", "",+ "typedef struct { int16_t x, y, w, h; } MgRect;",+ "typedef struct { uint8_t obj, pad; int16_t x, y; } MgInst;",+ "typedef struct { uint8_t anim, dir, n, pad; uint16_t first; } MgAnim; /* sprites first.. */",+ "typedef struct { uint16_t anim0; uint8_t nanim, pad; int16_t w, h, hx, hy; } MgObj; /* box: its first picture's */",+ "typedef struct { int16_t w, h; uint8_t sw, sh; uint16_t screen0; uint16_t solid0, nsolid, inst0, ninst;",+ " uint8_t obj0, nobj; int16_t start_x, start_y; } MgLevel;", ""]+ rects, insts, anims, objs, levels, screens, enums = [], [], [], [], [], [], []+ feel = None+ for key, frame in LEVELS:+ placed = app.frames[frame]+ W, H = frame_size(app, frame)+ sw, sh = -(-W // SW), -(-H // SH)+ touched = set(TOUCHED[key].split(","))+ # the scenery: backdrops, and actives no event touches, at their places+ canvas = Image.new("RGBA", (sw * SW, sh * SH), (0, 0, 0, 255))+ solid0 = len(rects)+ start = (0, 0)+ for o, x, y in placed:+ kind, name, an = app.objects[o]+ if kind == 1:+ obst, bw, bh, img = app.backdrop(o)+ im = app.picture(img)+ if im.size != (bw, bh):+ im = im.resize((bw, bh))+ paste(canvas, im, x, y)+ if obst == 1:+ rects.append((x, y, bw, bh))+ elif kind == 2 and name == "hitbox":+ start = (x, y)+ elif kind == 2 and name not in LOGIC and name not in touched and (0, 0) in app.dirs[o]:+ im = app.picture(app.dirs[o][(0, 0)][0])+ hx, hy = app.hotspot(app.dirs[o][(0, 0)][0])+ if x == 0 and y == 0 and im.width >= SW:+ continue # (a full-screen overlay of the first screen's: the code draws those)+ paste(canvas, im, x - hx, y - hy)+ screen0 = len(screens)+ for cy in range(sh):+ for cx in range(sw):+ part = canvas.crop((cx * SW, cy * SH, cx * SW + SW, cy * SH + SH)).convert("RGB")+ if not np.asarray(part).any():+ screens.append(0xFFFF)+ continue+ a = arr(part.resize((320, 192), Image.BOX))+ screens.append(pic(f"MG_{key}_{cx}_{cy}", a))+ # what moves: every object the events touch, each placed instance+ obj0 = len(objs)+ local = {}+ inst0 = len(insts)+ for o, x, y in placed:+ kind, name, an = app.objects[o]+ if kind != 2 or name not in touched:+ continue+ if o not in local:+ local[o] = len(objs) - obj0+ a0 = len(anims)+ for (a, d), ps in sorted(app.dirs[o].items()):+ ids = [sprite(app, p) for p in ps] # (an animation's pictures: a run of sprites)+ if ids != list(range(ids[0], ids[0] + len(ids))):+ base = len(SPRITES)+ for p in ps:+ blob = SPRITES[_SPR[p]]+ SPRITES.append(blob)+ ids = list(range(base, base + len(ps)))+ anims.append((a, d, len(ps), ids[0]))+ p0 = app.dirs[o][min(app.dirs[o])][0]+ im = app.picture(p0)+ hx, hy = app.hotspot(p0)+ objs.append((a0, len(anims) - a0, im.width, im.height, hx, hy))+ enums.append(f"#define MGO_{key}_{c_name(name)} {local[o]}")+ insts.append((local[o], x, y))+ if feel is None:+ feel = {}+ for n in FEELERS:+ o = app.obj(n, frame)+ p0 = app.dirs[o][(0, 0)][0]+ im = app.picture(p0)+ feel[n] = (im.width, im.height) + tuple(app.hotspot(p0))+ levels.append((W, H, sw, sh, screen0, solid0, len(rects) - solid0, inst0, len(insts) - inst0, obj0,+ len(objs) - obj0, start[0], start[1]))+ h.append(f"#define MGL_{key} {len(levels) - 1}")+ h += enums+ for n, (w, hh, hx, hy) in feel.items():+ h.append(f"#define MGF_{c_name(n)}_W {w}\n#define MGF_{c_name(n)}_H {hh}\n#define MGF_{c_name(n)}_HX {hx}\n"+ f"#define MGF_{c_name(n)}_HY {hy}")+ h.append(f"#define MGL_COUNT {len(levels)}")+ h.append("")+ h.append("static const MgRect mg_solids[] = {")+ h += [f" {{{x}, {y}, {w}, {hh}}}," for x, y, w, hh in rects]+ h += ["};", "static const MgInst mg_insts[] = {"]+ h += [f" {{{o}, 0, {x}, {y}}}," for o, x, y in insts]+ h += ["};", "static const MgAnim mg_anims[] = {"]+ h += [f" {{{a}, {d}, {n}, 0, {f}}}," for a, d, n, f in anims]+ h += ["};", "static const MgObj mg_objs[] = {"]+ h += [f" {{{a0}, {n}, 0, {w}, {hh}, {hx}, {hy}}}," for a0, n, w, hh, hx, hy in objs]+ h += ["};", "static const uint16_t mg_screens[] = {"]+ for i in range(0, len(screens), 12):+ h.append(" " + ", ".join(str(s if s == 0xFFFF else s) for s in screens[i:i + 12]) + ",")+ h += ["};", "static const MgLevel mg_levels[MGL_COUNT] = {"]+ h += [" {" + ", ".join(str(v) for v in lv) + "}," for lv in levels]+ h += ["};", "", "#endif", ""]+ return h+++def paste(canvas, im, x, y):+ layer = Image.new("RGBA", canvas.size)+ layer.paste(im, (x, y))+ canvas.alpha_composite(layer)+++def frame_size(app, frame):+ return app.frame_size[frame]diff --git a/games/fnaf3/tools/pack.py b/games/fnaf3/tools/pack.pyindex 560d0543..7568ed2b 100644--- a/games/fnaf3/tools/pack.py+++ b/games/fnaf3/tools/pack.py@@ -33,12 +33,13 @@ HERE = os.path.dirname(os.path.abspath(__file__))sys.path.insert(0, HERE)import ccn # noqa: E402import codec as C # noqa: E402+import minigames # noqa: E402OUT_BIN = os.path.join(HERE, "..", "src", "data.bin")OUT_H = os.path.join(HERE, "..", "src", "data.h")ROOT = os.path.join(HERE, "..", "..", "..")CCN = os.path.expanduser("~/Documents/Assets/gamesrc/fnaf3/dl/application.ccn")-SECTIONS = ["HUFF", "QUANT", "PICS", "TABLE", "BANK", "FONTS", "IMGS"]+SECTIONS = ["HUFF", "QUANT", "PICS", "TABLE", "BANK", "FONTS", "IMGS", "SPRS"]QUALITY = {"scene": 80, "scare": 70, "face": 76}FONT_DIRS = [os.environ.get("FONTS", ""), "/usr/share/fonts/truetype/dejavu", "/usr/share/fonts/TTF","/usr/local/share/fonts", "/Library/Fonts", os.path.expanduser("~/Library/Fonts"),@@ -500,6 +501,7 @@ def main():panel_imgs()head_imgs()icon()+ mini_h = minigames.build(APP, lambda n, a: PICS.index(pic(n, a, "face")), arr)huff, quant, pics, table, bank = encode_all()fonts = [ttf_font(font(11, bold=True, mono=True)), # FONT_HUD@@ -508,7 +510,7 @@ def main():ttf_font(font(24, bold=True)), # FONT_CLOCKttf_font(font(24, mono=True)), # FONT_HUGE]- sections = [huff, quant, pics, table, bank, pack_fonts(fonts), pack_imgs()]+ sections = [huff, quant, pics, table, bank, pack_fonts(fonts), pack_imgs(), minigames.pack_sprites()]head = b"FNF3" + struct.pack("<I", len(sections))offs, p = [], len(head) + 4 * len(sections)for s in sections:@@ -526,6 +528,7 @@ def main():h += [f"#define {n} {v}" for n, v in DEFINES]h += ["", "#endif", ""]open(OUT_H, "w").write("\n".join(h))+ open(os.path.join(HERE, "..", "src", "mini_data.h"), "w").write("\n".join(mini_h))print(f"data.bin: {len(out)} bytes")