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
Hollow Knight: the inventory's map pane, Greenpath's map, the map's key and markers
Mason Chend0c1980028af
diff --git a/games/hollowknight/src/data.bin b/games/hollowknight/src/data.binindex acdfb44c..c63be122 100644Binary files a/games/hollowknight/src/data.bin and b/games/hollowknight/src/data.bin differdiff --git a/games/hollowknight/src/data.h b/games/hollowknight/src/data.hindex e749390e..a0306c1b 100644--- a/games/hollowknight/src/data.h+++ b/games/hollowknight/src/data.h@@ -667,7 +667,7 @@#define SPRITE_CORPSE_NAIL 2994#define SPRITE_FK_BARREL 2995#define SPRITE_FK_STAFF 2996-#define SPRITE_DIGIT0 3493+#define SPRITE_DIGIT0 3541#define STYLE_DIALOGUE 0#define STYLE_PROMPT 1#define STYLE_TITLE_L 2@@ -1229,27 +1229,52 @@#define TXT_STAG_CTRL_CANCEL 311#define STAG_SCENES_STR {137, 136, 138}#define STAG_SCENES_ROOM {4, 19, 36}-#define MAP_AREAS {{0, 2, -1, 4.0700f, -11.6200f, 381, 0x14u}, {2, 23, 130, -0.0400f, -7.8800f, 384, 0x400020u}}-#define MAP_ROOMS {{0, 1, 3128, 3129, -1.9230f, 7.6490f, 4.0800f, 2.1400f, 0xB6B6B6, 1}, {0, 0, 3135, 3136, -5.4430f, 7.4690f, 2.9600f, 1.4800f, 0x636363, 1}, {1, 12, -1, -1, -1.5030f, 5.1050f, 0.0000f, 0.0000f, 0x000000, 0}, {1, 255, 3138, 3139, 3.3290f, 6.5270f, 0.8900f, 0.3800f, 0xB5DDFB, 1}, {1, 19, 3140, -1, 1.4650f, 4.4640f, 0.6500f, 0.3100f, 0xB5DDFB, 0}, {1, 255, 3141, 3142, 0.9410f, 4.0880f, 1.3600f, 0.3900f, 0xB5DDFB, 1}, {1, 15, 3143, 3144, 1.6660f, 6.5240f, 1.3000f, 0.3400f, 0xB5DDFB, 1}, {1, 9, 3145, -1, -3.0980f, 6.4880f, 1.1110f, 0.4800f, 0xB5DDFB, 0}, {1, 10, 3147, 3148, -2.2270f, 4.6390f, 0.6800f, 0.8600f, 0xB5DDFB, 1}, {1, 25, 3149, -1, -0.6440f, 4.4430f, 0.7000f, 0.3700f, 0xB5DDFB, 0}, {1, 14, 3151, 3152, 0.8660f, 4.8850f, 1.8584f, 0.5000f, 0xB5DDFB, 1}, {1, 20, 3153, 3154, 2.0720f, 3.8620f, 0.9500f, 0.7900f, 0xB5DDFB, 1}, {1, 17, 3155, 3156, 1.6240f, 5.9190f, 1.3800f, 0.5200f, 0xB5DDFB, 1}, {1, 16, 3157, 3158, 2.6280f, 6.1870f, 0.7000f, 1.0300f, 0xB5DDFB, 1}, {1, 255, 3159, 3160, -0.3640f, 4.0580f, 1.2500f, 0.3500f, 0xB5DDFB, 1}, {1, 255, 3161, 3162, -3.1500f, 4.3130f, 1.1700f, 0.3500f, 0xB5DDFB, 1}, {1, 26, 3163, -1, -3.7180f, 5.7650f, 2.3517f, 0.4300f, 0xB5DDFB, 0}, {1, 13, 3165, 3166, -0.5860f, 5.0990f, 1.1900f, 0.8800f, 0xB5DDFB, 1}, {1, 24, 3167, 3168, -1.4530f, 4.2330f, 0.9600f, 0.6900f, 0xB5DDFB, 1}, {1, 8, 3169, 3170, -2.2170f, 5.8440f, 0.6800f, 1.5700f, 0xB5DDFB, 1}, {1, 11, 3171, -1, -1.5030f, 5.1050f, 0.8500f, 0.8900f, 0xB5DDFB, 0}, {1, 21, 3172, -1, 3.7290f, 3.4460f, 2.4100f, 0.6600f, 0xB5DDFB, 0}, {1, 18, 3174, 3175, 2.0240f, 4.9490f, 0.5900f, 1.4673f, 0xB5DDFB, 1}, {1, 6, 3176, 3177, 0.3470f, 6.6100f, 1.3800f, 0.5000f, 0xB5DDFB, 1}, {1, 5, 3178, 3179, -1.1130f, 6.6140f, 1.5800f, 0.7500f, 0xB5DDFB, 1}}-#define MAP_PINS {{0, 0, 3130, -2.0390f, 7.7500f, 133, -1}, {0, 0, 3131, -1.6430f, 7.7500f, 137, -1}, {0, 0, 3132, -2.4700f, 7.7500f, 135, 122}, {0, 0, 3133, -1.2540f, 7.7600f, 135, 123}, {1, 1, 3137, -6.2100f, 7.6800f, 134, -1}, {2, 1, 3137, -1.3150f, 5.0920f, 134, -1}, {4, 0, 3131, 1.2400f, 4.4520f, 137, -1}, {4, 0, 3130, 1.6210f, 4.4490f, 133, -1}, {7, 0, 3146, -3.0697f, 6.4597f, 135, -1}, {9, 0, 3130, -0.3430f, 4.4060f, 133, -1}, {9, 0, 3150, -0.7200f, 4.3930f, 136, -1}, {20, 0, 3130, -1.6940f, 5.0880f, 133, -1}, {21, 0, 3173, 4.5530f, 3.3700f, 135, 124}, {21, 0, 3130, 4.9480f, 3.3820f, 133, -1}}-#define MAP_NEXT {{0, 3134, -1.0730f, 6.4850f, 180.0000f, 380, -1.0730f, 6.1870f, 1, -1}, {16, 3164, -5.2607f, 5.8454f, 90.0000f, 382, -5.5969f, 6.0434f, 2, 16}, {24, 3134, -1.0730f, 7.2500f, 0.0000f, 379, -1.0930f, 7.9120f, 1, -1}}-#define MAP_NAMES {{0, -1, 378, -0.2000f, 8.3901f, 0xFFFFFF, 1, 0}, {0, -1, 379, 3.3200f, 8.4801f, 0xFFFFFF, 1, 1}, {1, -1, 380, 6.7700f, 3.3701f, 0xB5DCFB, 1, 1}, {1, 20, 383, 3.4800f, 5.6971f, 0xB5DCFB, 1, 0}}+#define MAP_AREAS {{0, 2, -1, 4.0700f, -11.6200f, 381, 0x14u}, {2, 23, 130, -0.0400f, -7.8800f, 384, 0x400020u}, {25, 16, 131, 16.3100f, -7.8700f, 385, 0x40u}}+#define MAP_ROOMS {{0, 1, 3128, 3129, -1.9230f, 7.6490f, 4.0800f, 2.1400f, 0xB6B6B6, 1}, {0, 0, 3135, 3136, -5.4430f, 7.4690f, 2.9600f, 1.4800f, 0x636363, 1}, {1, 12, -1, -1, -1.5030f, 5.1050f, 0.0000f, 0.0000f, 0x000000, 0}, {1, 255, 3138, 3139, 3.3290f, 6.5270f, 0.8900f, 0.3800f, 0xB5DDFB, 1}, {1, 19, 3140, -1, 1.4650f, 4.4640f, 0.6500f, 0.3100f, 0xB5DDFB, 0}, {1, 255, 3141, 3142, 0.9410f, 4.0880f, 1.3600f, 0.3900f, 0xB5DDFB, 1}, {1, 15, 3143, 3144, 1.6660f, 6.5240f, 1.3000f, 0.3400f, 0xB5DDFB, 1}, {1, 9, 3145, -1, -3.0980f, 6.4880f, 1.1110f, 0.4800f, 0xB5DDFB, 0}, {1, 10, 3147, 3148, -2.2270f, 4.6390f, 0.6800f, 0.8600f, 0xB5DDFB, 1}, {1, 25, 3149, -1, -0.6440f, 4.4430f, 0.7000f, 0.3700f, 0xB5DDFB, 0}, {1, 14, 3151, 3152, 0.8660f, 4.8850f, 1.8584f, 0.5000f, 0xB5DDFB, 1}, {1, 20, 3153, 3154, 2.0720f, 3.8620f, 0.9500f, 0.7900f, 0xB5DDFB, 1}, {1, 17, 3155, 3156, 1.6240f, 5.9190f, 1.3800f, 0.5200f, 0xB5DDFB, 1}, {1, 16, 3157, 3158, 2.6280f, 6.1870f, 0.7000f, 1.0300f, 0xB5DDFB, 1}, {1, 255, 3159, 3160, -0.3640f, 4.0580f, 1.2500f, 0.3500f, 0xB5DDFB, 1}, {1, 255, 3161, 3162, -3.1500f, 4.3130f, 1.1700f, 0.3500f, 0xB5DDFB, 1}, {1, 26, 3163, -1, -3.7180f, 5.7650f, 2.3517f, 0.4300f, 0xB5DDFB, 0}, {1, 13, 3165, 3166, -0.5860f, 5.0990f, 1.1900f, 0.8800f, 0xB5DDFB, 1}, {1, 24, 3167, 3168, -1.4530f, 4.2330f, 0.9600f, 0.6900f, 0xB5DDFB, 1}, {1, 8, 3169, 3170, -2.2170f, 5.8440f, 0.6800f, 1.5700f, 0xB5DDFB, 1}, {1, 11, 3171, -1, -1.5030f, 5.1050f, 0.8500f, 0.8900f, 0xB5DDFB, 0}, {1, 21, 3172, -1, 3.7290f, 3.4460f, 2.4100f, 0.6600f, 0xB5DDFB, 0}, {1, 18, 3174, 3175, 2.0240f, 4.9490f, 0.5900f, 1.4673f, 0xB5DDFB, 1}, {1, 6, 3176, 3177, 0.3470f, 6.6100f, 1.3800f, 0.5000f, 0xB5DDFB, 1}, {1, 5, 3178, 3179, -1.1130f, 6.6140f, 1.5800f, 0.7500f, 0xB5DDFB, 1}, {2, 255, 3180, 3181, -6.5180f, 4.0350f, 1.0100f, 0.8900f, 0xCFFFC3, 1}, {2, 33, 3182, 3183, -10.8980f, 6.4740f, 1.3600f, 0.7100f, 0xCFFFC3, 1}, {2, 32, 3184, 3185, -11.2830f, 5.0920f, 0.5900f, 2.1300f, 0xCFFFC3, 1}, {2, 255, 3186, 3187, -11.8520f, 3.8320f, 1.6500f, 0.4800f, 0xCFFFC3, 1}, {2, 35, 3188, -1, -12.3910f, 5.0270f, 0.5700f, 1.9700f, 0xCFFFC3, 0}, {2, 34, 3189, 3190, -12.2580f, 6.4100f, 1.3800f, 0.8200f, 0xCFFFC3, 1}, {2, 255, 3191, 3192, -7.6750f, 3.7830f, 1.3400f, 0.4200f, 0xCFFFC3, 1}, {2, 30, 3193, -1, -9.2170f, 5.6940f, 1.2300f, 0.4400f, 0xCFFFC3, 0}, {2, 36, 3194, -1, -12.9760f, 5.8120f, 0.6000f, 0.3000f, 0xCFFFC3, 0}, {2, 255, 3195, 3196, -9.6830f, 3.8190f, 2.6800f, 0.4600f, 0xCFFFC3, 1}, {2, 255, 3197, 3198, -6.8080f, 4.7040f, 2.3200f, 0.5100f, 0xCFFFC3, 1}, {2, 37, 3199, 3200, -13.6530f, 6.1350f, 1.4100f, 1.0200f, 0xCFFFC3, 1}, {2, 31, 3201, -1, -10.4130f, 5.6780f, 1.1700f, 0.5500f, 0xCFFFC3, 0}, {2, 29, 3202, 3203, -8.2930f, 5.2090f, 0.6700f, 1.2200f, 0xCFFFC3, 1}, {2, 28, 3204, 3205, -7.6430f, 5.9550f, 0.6700f, 0.7500f, 0xCFFFC3, 1}, {2, 27, 3206, 3207, -6.1000f, 5.8290f, 2.4400f, 0.6700f, 0xCFFFC3, 1}}+#define MAP_PINS {{0, 0, 3130, -2.0390f, 7.7500f, 133, -1}, {0, 0, 3131, -1.6430f, 7.7500f, 137, -1}, {0, 0, 3132, -2.4700f, 7.7500f, 135, 122}, {0, 0, 3133, -1.2540f, 7.7600f, 135, 123}, {1, 1, 3137, -6.2100f, 7.6800f, 134, -1}, {2, 1, 3137, -1.3150f, 5.0920f, 134, -1}, {4, 0, 3131, 1.2400f, 4.4520f, 137, -1}, {4, 0, 3130, 1.6210f, 4.4490f, 133, -1}, {7, 0, 3146, -3.0697f, 6.4597f, 135, -1}, {9, 0, 3130, -0.3430f, 4.4060f, 133, -1}, {9, 0, 3150, -0.7200f, 4.3930f, 136, -1}, {20, 0, 3130, -1.6940f, 5.0880f, 133, -1}, {21, 0, 3173, 4.5530f, 3.3700f, 135, 124}, {21, 0, 3130, 4.9480f, 3.3820f, 133, -1}, {26, 1, 3137, -10.9970f, 6.6240f, 134, -1}, {27, 0, 3130, -11.2580f, 4.9690f, 133, -1}, {33, 0, 3130, -12.8160f, 5.7890f, 133, -1}, {33, 0, 3131, -13.1960f, 5.7970f, 137, -1}, {39, 0, 3130, -7.6610f, 6.0700f, 133, -1}}+#define MAP_NEXT {{0, 3134, -1.0730f, 6.4850f, 180.0000f, 380, -1.0730f, 6.1870f, 1, -1}, {16, 3164, -5.2607f, 5.8454f, 90.0000f, 382, -5.5969f, 6.0434f, 2, 16}, {24, 3134, -1.0730f, 7.2500f, 0.0000f, 379, -1.0930f, 7.9120f, 1, -1}, {40, 3134, -4.5300f, 5.8450f, -90.0000f, 380, -4.1075f, 6.0470f, 0, 6}}+#define MAP_NAMES {{0, -1, 378, -0.2000f, 8.3901f, 0xFFFFFF, 1, 0}, {0, -1, 379, 3.3200f, 8.4801f, 0xFFFFFF, 1, 1}, {1, -1, 380, 6.7700f, 3.3701f, 0xB5DCFB, 1, 1}, {1, 20, 383, 3.4800f, 5.6971f, 0xB5DCFB, 1, 0}, {2, -1, 382, -5.0993f, 5.4501f, 0xCFFFC3, 0, 1}}#define MAP_QUICK_K 1.5500f-#define MAP_WORLD_K 1.4500f-#define MAP_SHADE {{3180, 0.0055f, -0.0110f, 178}, {3181, 0.0000f, 0.0000f, 255}}-#define MAP_MARKERS {3182, 3183, 3184, 3185}+#define MAP_SHADE {{3208, 0.0055f, -0.0110f, 178}, {3209, 0.0000f, 0.0000f, 255}}+#define MAP_MARKERS {3210, 3211, 3212, 3213}#define MAP_COMPASS_K 0.7000f#define MAP_BG_A 0.4438f#define MAP_TITLE {0.0000f, 7.5363f}-#define MAP_TITLE_BACK {3186, 0.2520f, 7.1073f, 1.0000f, 0.6696f, 246}-#define MAP_NO_MAP {3187, 0.0000f, 0.9400f}-#define MAP_NO_MAP_MSG {385, -0.0600f, -1.2932f}-#define MAP_MSG {-1.2900f, -6.8300f, 0.0000f, 0.0420f, 0.9865f, -0.0210f, 386, 3188, 1.9740f, -0.0840f, 1.0000f, 0.6931f, 179}+#define MAP_TITLE_BACK {3214, 0.2520f, 7.1073f, 1.0000f, 0.6696f, 246}+#define MAP_NO_MAP {3215, 0.0000f, 0.9400f}+#define MAP_NO_MAP_MSG {386, -0.0600f, -1.2932f}+#define MAP_MSG {-1.2900f, -6.8300f, 0.0000f, 0.0420f, 0.9865f, -0.0210f, 387, 3216, 1.9740f, -0.0840f, 1.0000f, 0.6931f, 179}#define MAP_MSG_K 0.7000f#define FIRSTMAP_BG_A 0.6410f-#define FIRSTMAP_TEXTS {{387, 0.0000f, 5.0305f}, {182, 0.0000f, -0.8796f}, {388, 0.0000f, -3.2895f}, {389, 0.0000f, -4.6996f}}-#define FIRSTMAP_PIECES {{3189, 0.0000f, 2.1300f, 1.0000f, 1.0000f}, {3190, 0.0000f, 0.0200f, 1.0000f, 0.0771f}, {3191, 0.0000f, -6.4000f, 1.0000f, 1.0000f}}-#define FIRSTMAP_KEY {390, 0.0900f, -2.3200f}+#define FIRSTMAP_TEXTS {{388, 0.0000f, 5.0305f}, {182, 0.0000f, -0.8796f}, {389, 0.0000f, -3.2895f}, {390, 0.0000f, -4.6996f}}+#define FIRSTMAP_PIECES {{3217, 0.0000f, 2.1300f, 1.0000f, 1.0000f}, {3218, 0.0000f, 0.0200f, 1.0000f, 0.0771f}, {3219, 0.0000f, -6.4000f, 1.0000f, 1.0000f}}+#define FIRSTMAP_KEY {391, 0.0900f, -2.3200f}+#define MAP_WIDE {{{3220, 3.0400f, -6.6800f, 1.0000f, 1.0000f}, 392, {8.7184f, -6.2919f, 11.0476f}, 4.0000f, -8.6420f, 3.3800f, -7.0700f, {1000.0000f, -1000.0000f, 1000.0000f, -1000.0000f}}, {{3221, 4.2300f, -8.2600f, 1.0000f, 1.0000f}, 393, {9.9990f, -7.8578f, 11.7784f}, -0.0400f, -7.5800f, 3.0300f, -8.2300f, {1000.0000f, -1000.0000f, 1000.0000f, -1000.0000f}}, {{3222, -0.6100f, -7.9700f, 1.0000f, 1.0000f}, 394, {5.6452f, -7.7738f, 11.8448f}, 16.4200f, -7.3200f, 0.4000f, -8.5800f, {1000.0000f, 17.2600f, 1000.0000f, -6.2200f}}}+#define MAP_WIDE_GREY 0x5C+#define MAP_WIDE_NAME_GREY 0x5B+#define MAP_WIDE_COMPASS_K 0.8700f+#define MAP_ZOOM {0.2800f, -2.8000f, 0.4360f, 1.3000f}+#define MAP_PAN {-1.4400f, 4.5500f, -8.6420f, -5.5800f}+#define MAP_PAN_SPEED 8.0000f+#define MAP_PAN_ARROWS {{3223, 3.9700f, -2.1900f, 1.0f, 0.0000f}, {3223, 4.0400f, -13.4900f, 1.0f, 180.0000f}, {3223, -9.0000f, -7.1700f, 1.0f, 90.0000f}, {3223, 17.1900f, -7.1700f, 1.0f, -90.0000f}}+#define MAP_ACT_CONFIRM {{3224, 15.3897f, -13.3139f, 1.0000f, 0.8889f}, {16.9008f, -13.2878f}, {16.1269f, -13.0221f, 15.3500f}, {395, 396, 396}}+#define MAP_ACT_MARKER {{3224, -6.9500f, -13.3138f, 1.0000f, 0.8889f}, {-8.5394f, -13.2877f}, {-7.7259f, -13.0223f, 7.6740f}, {397, 398, 399}}+#define MAP_ACT_CANCEL {{3224, 15.3897f, -13.3138f, 1.0000f, 0.8889f}, {16.9008f, -13.2877f}, {16.1259f, -13.0223f, 15.3480f}, {311, 311, 311}}+#define MAP_ACT_CHANGE {{3224, -6.9500f, -12.0238f, 1.0000f, 0.8889f}, {-8.5394f, -11.9977f}, {-7.7259f, -11.7323f, 7.6740f}, {400, 400, 400}}+#define MAP_ACT_KEY {{3224, 15.3897f, -12.2039f, 1.0000f, 0.8889f}, {16.9008f, -12.1778f}, {16.3265f, -11.9122f, 15.3500f}, {401, 402, 403}}+#define MAP_KEY_BB {3225, 13.6200f, 3.4200f, 0.3781f, 1.0000f}+#define MAP_KEY_STEP -0.8250f+#define MAP_KEY_ROWS {{{3226, 11.8600f, -1.7400f, 1.0000f, 1.0000f}, 404, {12.7550f, -1.5413f, 15.3500f}}, {{3227, 11.8600f, -1.7400f, 1.0000f, 1.0000f}, 405, {12.7550f, -1.5413f, 15.3500f}}, {{3228, 11.7720f, -1.7460f, 1.0000f, 1.0000f}, 406, {12.7550f, -1.5413f, 15.3500f}}, {{3229, 11.8600f, -1.7400f, 1.0000f, 1.0000f}, 407, {12.7550f, -1.5413f, 15.3500f}}, {{3230, 11.8600f, -1.7400f, 1.0000f, 1.0000f}, 408, {12.7550f, -1.5413f, 15.3500f}}}+#define MAP_KEY_FLAGS {133, 134, 135, 136, 137}+#define MAP_KEY_N 5+#define MAP_MM_PIECES {{3231, 4.0500f, -12.3700f, 1.0000f, 1.0000f}, {3232, 4.0100f, -12.9500f, 0.7510f, 1.0000f}, {3233, 1.9000f, -12.3700f, 1.0000f, 1.0000f}, {3234, 1.9000f, -12.3700f, 1.0000f, 1.0000f}}+#define MAP_MM_MARKERS {3235, 3236, 3237, 3238}+#define MAP_MM_AMOUNT {0.0000f, -0.6416f, 1.0614f}+#define MAP_MM_ROW {0.0000f, 0.4400f, 1.9000f, 1.4333f, -12.8200f}+#define MAP_MM_PLACE {3239, 4.0500f, -7.9900f, -4.9500f, 13.0500f, -10.5500f, -3.5500f, 7.0000f, 20.0000f}+#define MAP_MM_RADII 0.8900f+#define MAP_MM_UI_PAUSE 0.2000f+#define TXT_KEY_SHIFT 409#define ROOM_ZONES {2, 4, 5, 4, 4, 5, 5, 5, 5, 5, 5, 5, 22, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6}#define MSG_FIREBALL 0#define MSG_DASH 1diff --git a/games/hollowknight/src/game.h b/games/hollowknight/src/game.hindex 51df40ea..b5558a38 100644--- a/games/hollowknight/src/game.h+++ b/games/hollowknight/src/game.h@@ -75,7 +75,8 @@ typedef struct {uint8_t stations_opened; /* (stationsOpened) *//* (scenesVisited, scenesMapped (the quill's), scenesEncounteredCocoon (a lifeblood cocoon broken there): by room) */uint8_t rooms_visited[5], rooms_mapped[5], rooms_cocoon[5];- uint8_t reserved[15];+ uint8_t map_key_pref; /* (mapKeyPref: the map's key and its pins shown 0, the pins only 1, neither 2) */+ uint8_t reserved[14];/* (save version 2 on) the markers placed on the map (placedMarkers_b, _r, _y, _w: their places, 1/100 map units) */uint8_t markers_placed[4];int16_t markers[4][6][2];@@ -462,6 +463,16 @@ uint32_t inv_tick(uint32_t keys); /* -> the keys the game has (none while it ivoid inv_damage(void); /* (HERO DAMAGED: it closes) */bool inv_open(void);void inv_open_map(void); /* (OPEN INVENTORY MAP: the map tapped twice) */+void inv_cursor_arrow(int which); /* (the map pane's: on the left arrow -1, the right -2; else not shown) */+float ui_key(int name, float x, float y, uint8_t white, float a); /* an action's key, by name -> its half width */+/* the inventory's map pane (map.c) */+enum { MAP_PANE_NONE, MAP_PANE_LEFT, MAP_PANE_RIGHT, MAP_PANE_CLOSE };+void map_pane_enter(bool shortcut);+int map_pane_tick(uint32_t keys, uint32_t pressed, uint32_t move, bool repeat); /* -> MAP_PANE_* */+void map_pane_draw(float ox, float oy, float a, uint8_t white, bool current);+bool map_pane_holds(void); /* (Do Not Close: zoomed into) */+float map_pane_nav(void); /* (the pane's arrows' and the side panes' names' alpha: away as it is zoomed into) */+void map_pane_close(void);float text_box(int text, int style, float x, float y, float w, int align, float a);int charm_cost(int id); /* (charmCost_N) */bool charm_equipped(int id);diff --git a/games/hollowknight/src/inv.c b/games/hollowknight/src/inv.cindex 4785a8fe..e345de33 100644--- a/games/hollowknight/src/inv.c+++ b/games/hollowknight/src/inv.c@@ -100,17 +100,22 @@ static struct {uint8_t area, coll, eq; /* (the collection: a backboard 1..40; the equipped row: 1.. its items) */uint8_t tween, tw_charm, oc_attempts;float tw_t, tw_from[2], tw_to[2];- /* Inventory: its items shown (their kinds), the one selected (-1, -2: the arrows) */- uint8_t items[MAX_INV_ITEMS];- float item_xy[MAX_INV_ITEMS][2];- int nitems;+ /* Inventory: the item selected (-1, -2: the arrows; its items: as the Knight has them, made when needed) */int8_t sel;+ bool map_shortcut; /* (opened by the map tapped twice: Map Shortcut, the map zoomed into at once) */} iv;+/* the Inventory pane's items shown: their kinds, their places */+typedef struct {+ uint8_t kind[MAX_INV_ITEMS];+ float xy[MAX_INV_ITEMS][2];+ int n;+} Items;+bool inv_open(void) { return iv.st != IV_CLOSED; }static bool has_pane(int p) {- return p == P_INV || (p == P_CHARMS && pd_flag(PDF_HAS_CHARM));+ return p == P_INV || (p == P_CHARMS && pd_flag(PDF_HAS_CHARM)) || (p == P_MAP && pd_flag(PDF_HAS_MAP));}/* ---------------------------------------------------------------- the Knight's charms */@@ -186,11 +191,11 @@ static void charms_cursor(void) {/* the Inventory pane's items as the Knight has them now */enum { K_HEART_I, K_VESSEL_I, K_NAIL_I, K_FIREBALL_I, K_FOCUS_I, K_GEO_I, K_EQ0 = 16, K_TRINKET0 = 32 };-static void build_items(void) {+static void build_items(Items *l) {int n = 0;for (int k = 0; k < NFIXED; k++) {if (k == IT_FIREBALL && !g_pd.fireball_level) continue;- iv.items[n] = (uint8_t)k, iv.item_xy[n][0] = inv_fixed[k].x, iv.item_xy[n][1] = inv_fixed[k].y, n++;+ l->kind[n] = (uint8_t)k, l->xy[n][0] = inv_fixed[k].x, l->xy[n][1] = inv_fixed[k].y, n++;}int slot = 0;for (int k = 0; k < NEQ; k++) {@@ -198,16 +203,16 @@ static void build_items(void) {: k == EQ_MAP ? (pd_flag(PDF_HAS_MAP) || pd_flag(PDF_HAS_QUILL)) : k == EQ_CITY_KEY ? pd_flag(PDF_HAS_CITY_KEY): k == EQ_SIMPLE_KEY ? g_pd.simple_keys > 0 : g_pd.rancid_eggs > 0;if (!has) continue;- iv.items[n] = (uint8_t)(K_EQ0 + k);- iv.item_xy[n][0] = INV_EQ_X + (slot % 4) * INV_EQ_DX, iv.item_xy[n][1] = INV_EQ_Y + (slot / 4) * INV_EQ_DY;+ l->kind[n] = (uint8_t)(K_EQ0 + k);+ l->xy[n][0] = INV_EQ_X + (slot % 4) * INV_EQ_DX, l->xy[n][1] = INV_EQ_Y + (slot / 4) * INV_EQ_DY;n++, slot++;}for (int k = 0; k < 4; k++)if (g_pd.trinkets[k]) {- iv.items[n] = (uint8_t)(K_TRINKET0 + k), iv.item_xy[n][0] = inv_trinkets[k].x, iv.item_xy[n][1] = inv_trinkets[k].y;+ l->kind[n] = (uint8_t)(K_TRINKET0 + k), l->xy[n][0] = inv_trinkets[k].x, l->xy[n][1] = inv_trinkets[k].y;n++;}- iv.nitems = n;+ l->n = n;}static const Box *item_box(int kind) {@@ -215,9 +220,19 @@ static const Box *item_box(int kind) {}static void inv_cursor(void) {+ Items l;+ build_items(&l);+ if (iv.sel >= l.n) iv.sel = (int8_t)(l.n - 1);if (iv.sel == -1) cursor_to(arrow_l.x, arrow_l.y, &arrow_box, 1, 1);else if (iv.sel == -2) cursor_to(arrow_r.x, arrow_r.y, &arrow_box, 1, 1);- else cursor_to(iv.item_xy[iv.sel][0], iv.item_xy[iv.sel][1], item_box(iv.items[iv.sel]), 1, 1);+ else cursor_to(l.xy[iv.sel][0], l.xy[iv.sel][1], item_box(l.kind[iv.sel]), 1, 1);+}++/* (the map pane's cursor: on an arrow, or not shown (an area chosen)) */+void inv_cursor_arrow(int which) {+ if (which == -1) cursor_to(arrow_l.x, arrow_l.y, &arrow_box, 1, 1);+ else if (which == -2) cursor_to(arrow_r.x, arrow_r.y, &arrow_box, 1, 1);+ else iv.cursor_set = false;}static bool other_panes(void) {@@ -234,8 +249,10 @@ static void pane_enter(int p) {/* (Activate: at the first charm's backboard) */iv.area = CA_COLLECTION, iv.coll = (uint8_t)bb_of_charm(1), iv.eq = 1, iv.oc_attempts = 0, iv.tween = TW_NONE;charms_cursor();+ } else if (p == P_MAP) {+ map_pane_enter(iv.map_shortcut);+ iv.map_shortcut = false;} else {- build_items();iv.sel = 0;inv_cursor();}@@ -272,9 +289,9 @@ static bool can_open(void) {!game_changing_room() && !msg_shown();}-static void open(void) {+static void open(bool map_shortcut) {memset(&iv, 0, sizeof iv);- iv.st = IV_OPEN, iv.slide_t = -1, iv.ct = CURSOR_TIME;+ iv.st = IV_OPEN, iv.slide_t = -1, iv.ct = CURSOR_TIME, iv.map_shortcut = map_shortcut;iv.prev_keys = g_hero.keys;g_pd.disable_pause = true;if (!pd_flag(PDF_AT_BENCH)) hero_relinquish_control_not_velocity();@@ -296,11 +313,16 @@ static void close_now(void) {void inv_open_map(void) {if (iv.st != IV_CLOSED || !can_open()) return;g_pd.current_inv_pane = P_MAP;- open();+ open(true);+}++static void start_close(float t) {+ iv.st = IV_CLOSING, iv.t = t;+ if (iv.pane == P_MAP) map_pane_close();}void inv_damage(void) {- if (iv.st == IV_OPEN) iv.st = IV_CLOSING, iv.t = FADE - 0.05f; /* (Damage Close: down fast) */+ if (iv.st == IV_OPEN) start_close(FADE - 0.05f); /* (Damage Close: down fast) */}void inv_reset(void) {@@ -446,10 +468,12 @@ static void inv_move(uint32_t p) {}if ((left && (p & K_RIGHT)) || (!left && (p & K_LEFT))) {/* (back to the nearest item) */+ Items l;+ build_items(&l);float ax = left ? arrow_l.x : arrow_r.x;int best = 0;- for (int i = 1; i < iv.nitems; i++)- if (fabsf(iv.item_xy[i][0] - ax) < fabsf(iv.item_xy[best][0] - ax)) best = i;+ for (int i = 1; i < l.n; i++)+ if (fabsf(l.xy[i][0] - ax) < fabsf(l.xy[best][0] - ax)) best = i;iv.sel = (int8_t)best;inv_cursor();}@@ -458,12 +482,14 @@ static void inv_move(uint32_t p) {/* the nearest item that way (by how far it is, along more than across) */float dx = (p & K_RIGHT) ? 1 : (p & K_LEFT) ? -1 : 0, dy = (p & K_UP) ? 1 : (p & K_DOWN) ? -1 : 0;if (!dx && !dy) return;- float x0 = iv.item_xy[iv.sel][0], y0 = iv.item_xy[iv.sel][1];+ Items l;+ build_items(&l);+ float x0 = l.xy[iv.sel][0], y0 = l.xy[iv.sel][1];int best = -1;float bd = 1e9f;- for (int i = 0; i < iv.nitems; i++) {+ for (int i = 0; i < l.n; i++) {if (i == iv.sel) continue;- float ex = iv.item_xy[i][0] - x0, ey = iv.item_xy[i][1] - y0;+ float ex = l.xy[i][0] - x0, ey = l.xy[i][1] - y0;float along = ex * dx + ey * dy, across = fabsf(ex * dy - ey * dx);if (along < 0.3f || across > along * 2.5f) continue;float dist = along + across * 2;@@ -483,7 +509,7 @@ uint32_t inv_tick(uint32_t keys) {g_gfx_overlay = NULL, g_gfx_reserve = 0;iv.blocked &= keys;if ((pressed & K_INV) && can_open()) {- open();+ open(false);iv.prev_keys = keys;return 0;}@@ -513,9 +539,9 @@ uint32_t inv_tick(uint32_t keys) {iv.tw_t += DT;if (iv.tw_t >= (iv.tween == TW_FAIL ? 0.5f : TWEEN_TIME)) tween_done();}- /* closing: the inventory key, or back */- if ((pressed & (K_INV | K_BACK)) && iv.tween == TW_NONE) {- iv.st = IV_CLOSING, iv.t = 0;+ /* closing: the inventory key, or back (not as the map is zoomed into: Do Not Close) */+ if ((pressed & (K_INV | K_BACK)) && iv.tween == TW_NONE && !(iv.pane == P_MAP && map_pane_holds())) {+ start_close(0);return 0;}if (iv.slide_t >= 0) return 0;@@ -527,7 +553,11 @@ uint32_t inv_tick(uint32_t keys) {if (iv.held_t >= REPEAT_FIRST) move = dirs, iv.held_t -= REPEAT;} elseiv.held = dirs, iv.held_t = 0;- if (iv.pane == P_CHARMS) {+ if (iv.pane == P_MAP) {+ int r = map_pane_tick(keys, pressed, move, move && !(pressed & dirs));+ if (r == MAP_PANE_LEFT || r == MAP_PANE_RIGHT) move_pane(r == MAP_PANE_LEFT ? -1 : 1);+ else if (r == MAP_PANE_CLOSE) start_close(0);+ } else if (iv.pane == P_CHARMS) {if (move) charms_move(move);if (pressed & K_OK) charms_confirm();} else {@@ -580,6 +610,19 @@ void ui_number_at(int v, int style, float x, float top, int align, float a) {gfx_text(style, px, VIEW_H / 2 - top * HUD_PX + font_asc(st), (const uint8_t *)s, n, (uint32_t)(a * 255 + 0.5f) << 24 | 0xFFFFFF, 0);}+/* an action's key (ActionButtonIcon: the calculator's key, by name, in a box as wide as it) at (x, y) -> its half width */+float ui_key(int name, float x, float y, uint8_t white, float a) {+ const uint8_t *st = font_style(STYLE_MSG), *s = text_get(name);+ int n = (int)strlen((const char *)s);+ float w = text_width(STYLE_MSG, s, n), bw = w / HUD_PX + 0.3f;+ Inst in;+ sprite_inst(SPRITE_MSG_KEY, x, y, 0, bw / 0.95f, 0.75f, white, &in);+ gfx_overlay(&in);+ gfx_text(STYLE_MSG, VIEW_W / 2 + x * HUD_PX - w / 2, VIEW_H / 2 - y * HUD_PX + (font_asc(st) - font_desc(st)) / 2, s, n,+ (uint32_t)(a * 255 + 0.5f) << 24 | 0xFFFFFF, 0);+ return bw / 2;+}+static void cursor_draw(float ox, float oy, uint8_t tint) {/* (its corners, about its box: TL, TR, BL, BR) */static const int8_t sx[4] = {-1, 1, -1, 1}, sy[4] = {1, 1, -1, -1};@@ -677,6 +720,8 @@ static void charms_draw(float ox, float oy, float a, uint8_t white) {}static void items_draw(float ox, float oy, float a, uint8_t white) {+ Items l;+ build_items(&l);for (int i = 0; i < 2; i++) {const TurnedPiece *d = &inv_dividers[i];Inst in;@@ -684,11 +729,11 @@ static void items_draw(float ox, float oy, float a, uint8_t white) {gfx_overlay(&in);}bool any_trinket = false;- for (int i = 0; i < iv.nitems; i++) any_trinket |= iv.items[i] >= K_TRINKET0;+ for (int i = 0; i < l.n; i++) any_trinket |= l.kind[i] >= K_TRINKET0;if (any_trinket) ui_piece(&inv_trinket_bb, ox, oy, 1, white);- for (int i = 0; i < iv.nitems; i++) {- int k = iv.items[i];- float x = ox + iv.item_xy[i][0], y = oy + iv.item_xy[i][1];+ for (int i = 0; i < l.n; i++) {+ int k = l.kind[i];+ float x = ox + l.xy[i][0], y = oy + l.xy[i][1];if (k < NFIXED) {ui_piece(&inv_fixed_bg[k], ox, oy, 1, white);ui_piece(&inv_fixed[k], ox, oy, 1, white);@@ -707,8 +752,8 @@ static void items_draw(float ox, float oy, float a, uint8_t white) {}}/* the selected item's name and description */- if (iv.sel >= 0 && iv.sel < iv.nitems) {- int k = iv.items[iv.sel];+ if (iv.sel >= 0 && iv.sel < l.n) {+ int k = l.kind[iv.sel];NameDesc nd = {-1, -1};if (k == IT_HEART) {int h = g_pd.max_health >= 9 ? 5 : !pd_flag(PDF_HEART_PIECE_COLLECTED) ? 0 : 1 + (g_pd.heart_pieces > 3 ? 3 : g_pd.heart_pieces);@@ -735,7 +780,11 @@ static void items_draw(float ox, float oy, float a, uint8_t white) {static void pane_draw(int p, float a, uint8_t white) {float ox = INV_X + pane_x(p), oy = INV_Y;if (p == P_CHARMS) charms_draw(ox, oy, a, white);- else items_draw(ox, oy, a, white);+ else if (p == P_MAP) {+ map_pane_draw(ox, oy, a, white, p == iv.pane);+ if (iv.cursor_set && p == iv.pane) cursor_draw(ox, oy, white);+ } else+ items_draw(ox, oy, a, white);}void inv_draw(void) {@@ -747,11 +796,14 @@ void inv_draw(void) {ui_piece(&frame, INV_X, INV_Y, 1, bw);for (int i = 0; i < INV_NBORDER; i++) ui_piece(&border[i], INV_X, INV_Y, 1, bw);int l = neighbor_pane(-1), r = neighbor_pane(1);- if (l >= 0) ui_piece(&arrow_l, INV_X, INV_Y, 1, bw), ui_piece(&pane_arrow_l, INV_X, INV_Y, 1, bw);- if (r >= 0) ui_piece(&arrow_r, INV_X, INV_Y, 1, bw), ui_piece(&pane_arrow_r, INV_X, INV_Y, 1, bw);+ /* (the arrows and the side panes' names: away as the map is zoomed into, World Map's FadeGroup) */+ float na = iv.pane == P_MAP && iv.slide_t < 0 ? ba * map_pane_nav() : ba;+ uint8_t nw = gfx_dyn_tint(30, 255, 255, 255, (uint8_t)(na * 255 + 0.5f));+ if (l >= 0) ui_piece(&arrow_l, INV_X, INV_Y, 1, nw), ui_piece(&pane_arrow_l, INV_X, INV_Y, 1, nw);+ if (r >= 0) ui_piece(&arrow_r, INV_X, INV_Y, 1, nw), ui_piece(&pane_arrow_r, INV_X, INV_Y, 1, nw);ui_text_at(pane_names[iv.pane], STYLE_TUTE, &pane_name, INV_X, INV_Y, 1, ba);- if (l >= 0) ui_text_at(pane_names[l], STYLE_TUTE, &pane_name_l, INV_X, INV_Y, 0, ba);- if (r >= 0) ui_text_at(pane_names[r], STYLE_TUTE, &pane_name_r, INV_X, INV_Y, 2, ba);+ if (l >= 0) ui_text_at(pane_names[l], STYLE_TUTE, &pane_name_l, INV_X, INV_Y, 0, na);+ if (r >= 0) ui_text_at(pane_names[r], STYLE_TUTE, &pane_name_r, INV_X, INV_Y, 2, na);/* the panes (the one going too, as they move) */uint8_t pw = gfx_dyn_tint(31, 255, 255, 255, (uint8_t)(pa * 255 + 0.5f));if (iv.slide_t >= 0) pane_draw(iv.prev_pane, pa, pw);diff --git a/games/hollowknight/src/map.c b/games/hollowknight/src/map.cindex 440aca96..d575a45e 100644--- a/games/hollowknight/src/map.c+++ b/games/hollowknight/src/map.c@@ -34,6 +34,7 @@ static struct {bool in_control, walk_right, walking;/* the quick map: shown (and its area), the backdrop's, the name's, the no map message's fades */bool shown;+ bool pins_hidden; /* (the HUD camera's culling mask without the pins' layer: the map's key's None) */int8_t area; /* (-1: no map of it) */float bg_a, name_a, nomap_a, t_open;Anim compass;@@ -51,7 +52,7 @@ static void set_bit(uint8_t *b, int i) {void map_room_entered(void) { set_bit(g_pd.rooms_visited, g_room.id); } /* (SceneManager: scenesVisited) */void map_cocoon_broken(void) { set_bit(g_pd.rooms_cocoon, g_room.id); } /* (AddToCocoonList) */-static bool have_area(int a) { return areas[a].have < 0 || pd_flag(areas[a].have); }+static bool have_area(int a) { return areas[a].have == -1 || (areas[a].have >= 0 && pd_flag(areas[a].have)); }/* UpdateGameMap: with the quill, the rooms visited whose area's map the Knight has, mapped -> any new */bool map_update(void) {@@ -285,18 +286,26 @@ void map_hud_tick(void) {}}-/* the map's colors: a tint each (the menus', the item message's: never up with it), afresh each frame */-static uint32_t tint_used[4];+/* the map's colors: a tint each, afresh each frame: the quick map's on the HUD (the menus', the item message's: never up+ * with it); the inventory's (its overlay: each sprite's colors made as it is drawn) its own, times its pane's alpha */+static uint32_t tint_used[6];static int tint_n;+static bool to_overlay; /* (drawing the inventory's map pane) */+static float pane_a;static uint8_t map_tint(uint32_t rgb, uint8_t a) {- static const uint8_t slots[] = {29, 30, 31, 25};- uint32_t *used = tint_used;- int n = tint_n;+ static const uint8_t hud_slots[] = {29, 30, 31, 25}, pane_slots[] = {15, 22, 23, 24, 25, 26};+ const uint8_t *slots = to_overlay ? pane_slots : hud_slots;+ int max = to_overlay ? (int)sizeof pane_slots : (int)sizeof hud_slots;+ if (to_overlay) a = (uint8_t)(a * pane_a + 0.5f);+ else if (rgb == 0xFFFFFF && a == 255) return gfx_dyn_tint(16, 255, 255, 255, 255); /* (the HUD's white) */uint32_t key = rgb << 8 | a;- for (int i = 0; i < n; i++)- if (used[i] == key) return gfx_dyn_tint(slots[i], (uint8_t)(rgb >> 16), (uint8_t)(rgb >> 8), (uint8_t)rgb, a);- int i = n < 4 ? tint_n++ : 3;- used[i] = key;+ int i = 0;+ while (i < tint_n && tint_used[i] != key) i++;+ if (i == tint_n) {+ if (tint_n < max) tint_n++;+ else i = max - 1;+ tint_used[i] = key;+ }return gfx_dyn_tint(slots[i], (uint8_t)(rgb >> 16), (uint8_t)(rgb >> 8), (uint8_t)rgb, a);}@@ -305,11 +314,13 @@ static void hud_sprite(int sprite, float x, float y, float k, float deg, uint8_tInst in;if (deg != 0) sprite_inst_rot(sprite, x, y, 0, k, k, deg, tint, &in);else sprite_inst(sprite, x, y, 0, k, k, tint, &in);- gfx_hud(&in, 0);+ if (to_overlay) gfx_overlay(&in);+ else gfx_hud(&in, 0);}/* a text: its lines centred on x, from its left or to its right (align 0 left, 1 centred, 2 right), its top at top */static void hud_text(int text, int style, float x, float top, int align, uint32_t rgb, float a) {+ if (to_overlay) a *= pane_a;uint8_t al = (uint8_t)(a * 255 + 0.5f);if (text < 0 || !al) return;const uint8_t *s = text_get(text), *st = font_style(style);@@ -341,7 +352,6 @@ static bool pin_shown(const MapPin *p) {* not */static void draw_area(int a, float ox, float oy, float k, bool quick) {float sk = k / MAP_QUICK_K;- uint8_t white = gfx_dyn_tint(16, 255, 255, 255, 255);for (int i = areas[a].first; i < areas[a].first + areas[a].n; i++) {const MapRoom *r = &rooms[i];if (!room_shown(i)) continue;@@ -349,10 +359,10 @@ static void draw_area(int a, float ox, float oy, float k, bool quick) {hud_sprite(mapped && r->full >= 0 ? r->full : r->sprite, ox + r->x * k, oy + r->y * k, sk, 0, map_tint(r->rgb, 255));}/* (the pins: the HUD camera's layer 30, as Map Key Pref has it) */- for (unsigned i = 0; i < sizeof pins / sizeof pins[0]; i++) {+ for (unsigned i = 0; i < sizeof pins / sizeof pins[0] && !mc.pins_hidden; i++) {const MapPin *p = &pins[i];if (rooms[p->room].area != a || !room_shown(p->room) || !pin_shown(p)) continue;- hud_sprite(p->sprite, ox + p->x * k, oy + p->y * k, sk, 0, white);+ hud_sprite(p->sprite, ox + p->x * k, oy + p->y * k, sk, 0, map_tint(0xFFFFFF, 255));}for (unsigned i = 0; i < sizeof names / sizeof names[0]; i++) {const MapName *n = &names[i];@@ -363,7 +373,7 @@ static void draw_area(int a, float ox, float oy, float k, bool quick) {for (unsigned i = 0; i < sizeof nexts / sizeof nexts[0]; i++) {const MapNext *n = &nexts[i];if (rooms[n->room].area != a || !room_shown(n->room) || (n->visited >= 0 && !pd_flag(n->visited))) continue;- hud_sprite(n->sprite, ox + n->x * k, oy + n->y * k, sk, n->ang, white);+ hud_sprite(n->sprite, ox + n->x * k, oy + n->y * k, sk, n->ang, map_tint(0xFFFFFF, 255));hud_text(n->text, STYLE_MSG, ox + n->tx * k, oy + n->top * k, n->align, 0xFFFFFF, 1);}}@@ -399,7 +409,7 @@ static void draw_marks(float ox, float oy, float k) {if (shade_at(ox, oy, k, &x, &y))for (int i = 0; i < 2; i++)hud_sprite(shade[i].sprite, x + shade[i].dx * k, y + shade[i].dy * k, sk, 0, map_tint(0xFFFFFF, shade[i].a));- uint8_t white = gfx_dyn_tint(16, 255, 255, 255, 255);+ uint8_t white = map_tint(0xFFFFFF, 255);for (int c = 0; c < 4; c++)for (int m = 0; m < g_pd.markers_placed[c] && m < 6; m++)hud_sprite(markers[c], ox + g_pd.markers[c][m][0] * 0.01f * k, oy + g_pd.markers[c][m][1] * 0.01f * k, sk, 0, white);@@ -410,7 +420,7 @@ static void draw_marks(float ox, float oy, float k) {static void map_msg_draw(void);void map_draw(void) {- tint_n = 0;+ tint_n = 0, to_overlay = false;map_msg_draw();if (mc.bg_a <= 0 && mc.name_a <= 0 && mc.nomap_a <= 0) return;float bga = MAP_BG_A * mc.bg_a;@@ -490,3 +500,399 @@ static void map_msg_draw(void) {}(void)k;}++/* ---------------------------------------------------------------- the inventory's map pane */+/* (Inventory/Map/World Map's UI Control: the wide map, the area chosen white, the others grey; Map Zoom into Game_Map+ * (WorldMap: all the areas had, the next areas' arrows not), panned (GameMap's Update, KeepWithinBounds); the map's key+ * (Map Key: the pins had, the key and the pins shown or not); the markers' menu (MapMarkerMenu: placed and taken back,+ * six of each kind). Places: the pane's from the inventory's, Game_Map's from the HUD's middle.) */+typedef struct { UiPiece piece; int16_t text; UiText name; float zx, zy, cx, cy, ext[4]; } WidePiece;+typedef struct { UiPiece back; float key[2]; UiText text; int16_t texts[3]; } MapAction;+typedef struct { UiPiece icon; int16_t text; UiText at; } KeyRow;+static const WidePiece wide[NAREAS] = MAP_WIDE;+static const MapAction act_confirm = MAP_ACT_CONFIRM, act_marker = MAP_ACT_MARKER, act_cancel = MAP_ACT_CANCEL,+ act_change = MAP_ACT_CHANGE, act_key = MAP_ACT_KEY;+static const KeyRow key_rows[MAP_KEY_N] = MAP_KEY_ROWS;+static const int16_t key_flags[MAP_KEY_N] = MAP_KEY_FLAGS;+static const UiPiece key_bb = MAP_KEY_BB;+static const struct { int16_t sprite; float x, y, k, deg; } pan_arrows[4] = MAP_PAN_ARROWS;+static const UiPiece mm_pieces[4] = MAP_MM_PIECES; /* (backboard, its shadow, the cursor's back, the cursor) */+static const int16_t mm_markers[4] = MAP_MM_MARKERS;+static const struct { float x, y, x0, dx, y0; } mm_row = MAP_MM_ROW;+static const UiText mm_amount = MAP_MM_AMOUNT;+static const struct { int16_t sprite; float x, y, minx, maxx, miny, maxy, speed, pull; } mm_place = MAP_MM_PLACE;+static const struct { float x, y, k0, k; } zoom = MAP_ZOOM;+static const float pan_base[4] = MAP_PAN;++enum { A_TOWN, A_CROSSROADS, A_GREENPATH }; /* (MAP_AREAS' order) */+enum { MP_WIDE, MP_ZOOM, MP_ZOOMED, MP_ZOOM_OUT, MP_MARKERS, MP_MARKER_CANCEL };+#define ARROW_L (-1)+#define ARROW_R (-2)+#define ZOOM_TIME 0.4f /* (Map Zoom: iTween 0.4 s easeOutSine; Zoomed In after 0.45) */+#define ZOOM_OUT_TIME 0.25f /* (Zoom Out: 0.25 s linear; Map Up after 0.1, Map Off 0.15 later, Reset 0.1 later) */+#define MAX_MARKERS 6+static struct {+ int8_t sel; /* the area chosen (ARROW_L, ARROW_R: the pane's arrows) */+ int8_t hit; /* the marker under the placement cursor (kind * 8 + its index; -1 none) */+ uint8_t st, marker; /* (marker: the kind chosen, 0..3: b, r, y, w) */+ float t; /* (the state's time) */+ float x, y, k, ox, oy; /* Game_Map's place and scale; zooming out: from where */+ float wide_a, nav_a, key_a, mm_a; /* (the wide map's pieces; World Map's FadeGroup; Map Key's; Map Markers') */+ float px, py, cur_x; /* the placement cursor (from the markers' menu's place); the menu's cursor */+ float confirm_t, place_t; /* (MapMarkerMenu's confirmTimer, placementTimer) */+ bool closed; /* (the inventory closing: Game_Map's areas gone, the map's key down) */+} mp;++static void select_area(int a) {+ mp.sel = (int8_t)a;+ inv_cursor_arrow(a < 0 ? a : 0);+}++/* UI Control's moves (each way: the areas tried in order, their maps had; then where it goes) */+static int wide_move(int from, uint32_t dir) {+ bool cr = have_area(A_CROSSROADS), gp = have_area(A_GREENPATH);+ switch (from) {+ case A_TOWN: /* (T Down, T Left, T Right) */+ if (dir & K_DOWN) return cr ? A_CROSSROADS : gp ? A_GREENPATH : A_TOWN;+ if (dir & K_LEFT) return gp ? A_GREENPATH : ARROW_L;+ return dir & K_RIGHT ? ARROW_R : A_TOWN;+ case A_CROSSROADS: /* (CR Up, CR Left, CR Right, CR Down) */+ if (dir & K_UP) return A_TOWN;+ if (dir & K_LEFT) return gp ? A_GREENPATH : ARROW_L;+ return dir & K_RIGHT ? ARROW_R : A_CROSSROADS;+ case A_GREENPATH: /* (GP Up, GP Right, GP Left, GP Down) */+ if (dir & K_UP) return A_TOWN;+ if (dir & K_RIGHT) return cr ? A_CROSSROADS : A_TOWN;+ return dir & K_LEFT ? ARROW_L : A_GREENPATH;+ case ARROW_L: /* (To Map) */+ return dir & K_RIGHT ? (gp ? A_GREENPATH : A_TOWN) : ARROW_L;+ default: /* (To Map 2) */+ return dir & K_LEFT ? (cr ? A_CROSSROADS : A_TOWN) : ARROW_R;+ }+}++/* (WorldMap's bounds: widened by the areas had, or the one the Knight is in with the compass on) */+static void pan_bounds(float *b) {+ memcpy(b, pan_base, sizeof pan_base);+ int z = area_of_zone();+ for (int a = 0; a < NAREAS; a++) {+ if (!have_area(a) && !(a == z && charm_on(2))) continue;+ const float *e = wide[a].ext;+ b[0] = fminf(b[0], e[0]), b[1] = fmaxf(b[1], e[1]), b[2] = fminf(b[2], e[2]), b[3] = fmaxf(b[3], e[3]);+ }+}++static void keep_within_bounds(void) {+ float b[4];+ pan_bounds(b);+ mp.x = fminf(fmaxf(mp.x, b[0]), b[1]), mp.y = fminf(fmaxf(mp.y, b[2]), b[3]);+}++static bool has_marker(int c) { return pd_flag(PDF_HAS_MARKER_B + c); }+static int spare(int c) { return MAX_MARKERS - g_pd.markers_placed[c]; }+static int marker_kinds(void) { return has_marker(0) + has_marker(1) + has_marker(2) + has_marker(3); }+/* (a kind's place in the menu's row: after the kinds had before it) */+static float marker_x(int c) {+ int n = 0;+ for (int i = 0; i < c; i++) n += has_marker(i);+ return mm_row.x0 + n * mm_row.dx;+}++/* (Activate: the area the Knight is in, its map had; else Dirtmouth. Zoom Shortcut: zoomed into at once) */+static void zoom_in(void);+void map_pane_enter(bool shortcut) {+ memset(&mp, 0, sizeof mp);+ mp.hit = -1, mp.wide_a = mp.nav_a = 1;+ int a = area_of_zone();+ select_area(a >= 0 && have_area(a) ? a : A_TOWN);+ if (mc.compass.sprite < 0) anim_play(&mc.compass, CLIP_MAPUI_IDLE);+ if (shortcut) zoom_in();+}++static void zoom_in(void) {+ /* Map Zoom: the pieces unselected and down, the pane's arrows away; Game_Map from the wide map's place (0.436) */+ mp.st = MP_ZOOM, mp.t = 0;+ mp.x = zoom.x, mp.y = zoom.y, mp.k = zoom.k0;+}++static void zoomed(void) {+ /* Zoomed In: the map's key up, its pins as the key has them; the pan on */+ mp.st = MP_ZOOMED, mp.t = 0;+ mc.pins_hidden = g_pd.map_key_pref == 2;+}++static void markers_open(void) {+ /* Marker Select Menu (OpenMarkerMenu): the first kind with any left chosen (else the first had); the placement cursor+ * at its first place; the map's key down, the pan off */+ mp.st = MP_MARKERS, mp.t = 0;+ mp.marker = 255;+ for (int c = 0; c < 4 && mp.marker == 255; c++)+ if (has_marker(c) && spare(c) > 0) mp.marker = (uint8_t)c;+ for (int c = 0; c < 4 && mp.marker == 255; c++)+ if (has_marker(c)) mp.marker = (uint8_t)c;+ mp.cur_x = mm_row.x0;+ mp.px = mm_place.x, mp.py = mm_place.y;+ mp.confirm_t = MAP_MM_UI_PAUSE, mp.place_t = 0, mp.hit = -1;+}++/* the placement cursor's place on the HUD */+static float place_x(void) { return INV_X + mm_row.x + mp.px; }+static float place_y(void) { return INV_Y + mm_row.y + mp.py; }++/* (PanMap: the cursor moved; at its bounds, the map moved instead (not just after a marker is placed)) */+static bool pan_cursor(uint32_t keys) {+ float ix = (float)((keys & K_RIGHT) != 0) - (float)((keys & K_LEFT) != 0);+ float iy = (float)((keys & K_UP) != 0) - (float)((keys & K_DOWN) != 0);+ if (ix == 0 && iy == 0) return false;+ float vx = ix * mm_place.speed * DT, vy = iy * mm_place.speed * DT;+ float px = mp.px + vx, py = mp.py + vy;+ if (px < mm_place.minx || px > mm_place.maxx) {+ px = px < mm_place.minx ? mm_place.minx : mm_place.maxx;+ if (mp.place_t <= 0) mp.x -= vx;+ }+ if (py < mm_place.miny || py > mm_place.maxy) {+ py = py < mm_place.miny ? mm_place.miny : mm_place.maxy;+ if (mp.place_t <= 0) mp.y -= vy;+ }+ mp.px = px, mp.py = py;+ keep_within_bounds();+ return true;+}++static void marker_at(int c, int i, float *x, float *y) {+ *x = mp.x + g_pd.markers[c][i][0] * 0.01f * mp.k, *y = mp.y + g_pd.markers[c][i][1] * 0.01f * mp.k;+}++/* (InvMarkerCollide: the markers the placement box touches; the one touched last kept while it still is) */+static void find_hit(void) {+ float cx = place_x(), cy = place_y(), x, y;+ int last = -1;+ bool kept = false;+ for (int c = 0; c < 4; c++)+ for (int i = 0; i < g_pd.markers_placed[c] && i < MAX_MARKERS; i++) {+ marker_at(c, i, &x, &y);+ if (hypotf(x - cx, y - cy) > MAP_MM_RADII) continue;+ if (mp.hit == c * 8 + i) kept = true;+ last = c * 8 + i;+ }+ if (!kept) mp.hit = (int8_t)last;+}++static void place_marker(void) {+ int c = mp.marker;+ if (c > 3 || spare(c) <= 0) return; /* (failure: none of that kind left) */+ int i = g_pd.markers_placed[c]++;+ g_pd.markers[c][i][0] = (int16_t)lrintf((place_x() - mp.x) / mp.k * 100);+ g_pd.markers[c][i][1] = (int16_t)lrintf((place_y() - mp.y) / mp.k * 100);+ mp.place_t = 0.3f;+}++static void remove_marker(void) {+ int c = mp.hit >> 3, i = mp.hit & 7, n = g_pd.markers_placed[c];+ for (int j = i; j + 1 < n; j++) g_pd.markers[c][j][0] = g_pd.markers[c][j + 1][0], g_pd.markers[c][j][1] = g_pd.markers[c][j + 1][1];+ g_pd.markers_placed[c] = (uint8_t)(n - 1);+ mp.hit = -1;+}++/* (MarkerSelectRight: the next kind had, round) */+static void marker_next(void) {+ for (int n = 1; n < 4; n++) {+ int c = (mp.marker + n) % 4;+ if (has_marker(c)) {+ mp.marker = (uint8_t)c;+ return;+ }+ }+}++static float fade_to(float a, bool up, float time) { return up ? fminf(1, a + DT / time) : fmaxf(0, a - DT / time); }++bool map_pane_holds(void) { return mp.st != MP_WIDE && !mp.closed; } /* (Do Not Close) */+float map_pane_nav(void) { return mp.nav_a; }+void map_pane_close(void) { mp.closed = true, mp.key_a = mp.mm_a = 0; } /* (Close: CloseQuickMap, MAP KEY DOWN) */++int map_pane_tick(uint32_t keys, uint32_t pressed, uint32_t move, bool repeat) {+ int out = MAP_PANE_NONE;+ mp.t += DT;+ mc.compass.events = 0;+ anim_update(&mc.compass, DT);+ switch (mp.st) {+ case MP_WIDE:+ if (move) {+ int to = wide_move(mp.sel, move);+ if (mp.sel == ARROW_L && (move & K_LEFT)) out = repeat ? MAP_PANE_NONE : MAP_PANE_LEFT; /* (Move Pane L) */+ else if (mp.sel == ARROW_R && (move & K_RIGHT)) out = repeat ? MAP_PANE_NONE : MAP_PANE_RIGHT;+ else select_area(to);+ }+ if (pressed & K_OK) {+ if (mp.sel >= 0) zoom_in();+ else out = mp.sel == ARROW_L ? MAP_PANE_LEFT : MAP_PANE_RIGHT;+ }+ break;+ case MP_ZOOM: {+ float q = fminf(1, mp.t / ZOOM_TIME), e = sinf(q * 1.5707964f);+ const WidePiece *w = &wide[mp.sel];+ mp.k = zoom.k0 + (zoom.k - zoom.k0) * e;+ mp.x = zoom.x + (w->zx - zoom.x) * e, mp.y = zoom.y + (w->zy - zoom.y) * e;+ if (mp.t >= ZOOM_TIME + 0.05f) zoomed();+ break;+ }+ case MP_ZOOMED:+ /* (the pan: the map against the arrows held) */+ mp.x -= ((float)((keys & K_RIGHT) != 0) - (float)((keys & K_LEFT) != 0)) * MAP_PAN_SPEED * DT;+ mp.y -= ((float)((keys & K_UP) != 0) - (float)((keys & K_DOWN) != 0)) * MAP_PAN_SPEED * DT;+ keep_within_bounds();+ if (pressed & (K_INV | K_MAP)) out = MAP_PANE_CLOSE; /* (Inventory Cancel) */+ else if (pressed & K_BACK) mp.st = MP_ZOOM_OUT, mp.t = 0, mp.ox = mp.x, mp.oy = mp.y;+ else if ((pressed & K_OK) && pd_flag(PDF_HAS_MARKER)) markers_open();+ else if ((pressed & K_DASH) && pd_flag(PDF_HAS_PIN)) {+ /* (the map's key's action: the key and the pins, the pins only, neither) */+ g_pd.map_key_pref = (uint8_t)((g_pd.map_key_pref + 1) % 3);+ mc.pins_hidden = g_pd.map_key_pref == 2;+ }+ break;+ case MP_ZOOM_OUT: {+ float q = fminf(1, mp.t / ZOOM_OUT_TIME);+ mp.k = zoom.k + (zoom.k0 - zoom.k) * q;+ mp.x = mp.ox + (zoom.x - mp.ox) * q, mp.y = mp.oy + (zoom.y - mp.oy) * q;+ if (mp.t >= 0.35f) {+ /* Reset: the area chosen again */+ mp.st = MP_WIDE, mp.wide_a = 1;+ select_area(mp.sel);+ }+ break;+ }+ case MP_MARKERS:+ if (!pan_cursor(keys) && mp.hit >= 0) {+ /* (pulled to the marker it is on) */+ float x, y, q = fminf(1, mm_place.pull * DT);+ marker_at(mp.hit >> 3, mp.hit & 7, &x, &y);+ mp.px += (x - place_x()) * q, mp.py += (y - place_y()) * q;+ }+ find_hit();+ if (mp.confirm_t <= 0) {+ if (pressed & K_OK) {+ if (mp.hit >= 0) remove_marker();+ else place_marker();+ } else if (pressed & K_DASH)+ marker_next();+ }+ if (mp.confirm_t > 0) mp.confirm_t -= DT;+ if (mp.place_t > 0) mp.place_t -= DT;+ if (pressed & K_INV) out = MAP_PANE_CLOSE; /* (Marker Inv Cancel) */+ else if (pressed & K_BACK) mp.st = MP_MARKER_CANCEL, mp.t = 0;+ break;+ case MP_MARKER_CANCEL:+ if (mp.t >= 0.05f) zoomed();+ break;+ default:+ break;+ }+ /* the fades: the wide map's pieces (down in 0.15 s; up in 0.4 from the zoom out's 0.1 s), World Map's (0.2 s: up from+ * the zoom out's 0.25), the map's key's (0.2), the markers' menu's (0.1); its cursor to the kind chosen (0.1 s) */+ if (mp.st == MP_ZOOM) mp.wide_a = fade_to(mp.wide_a, false, 0.15f);+ else if (mp.st == MP_ZOOM_OUT && mp.t >= 0.1f) mp.wide_a = fade_to(mp.wide_a, true, 0.4f);+ bool nav = mp.st == MP_WIDE || (mp.st == MP_ZOOM_OUT && mp.t >= 0.25f);+ mp.nav_a = fade_to(mp.nav_a, nav, 0.2f);+ mp.key_a = fade_to(mp.key_a, mp.st == MP_ZOOMED && g_pd.map_key_pref == 0 && pd_flag(PDF_HAS_PIN), 0.2f);+ mp.mm_a = fade_to(mp.mm_a, mp.st == MP_MARKERS, 0.1f);+ if (mp.marker < 4) {+ float to = marker_x(mp.marker), d = mm_row.dx * DT / 0.1f;+ mp.cur_x = fabsf(to - mp.cur_x) <= d ? to : mp.cur_x + (to > mp.cur_x ? d : -d);+ }+ return out;+}++/* an action: its backboard, its key, its text (right aligned: ending before the key; left: from after it) */+static void action_draw(const MapAction *m, int which, int key, float ox, float oy, uint8_t white, float a, bool right) {+ ui_piece(&m->back, ox, oy, 1, white);+ float hw = ui_key(key, ox + m->key[0], oy + m->key[1], white, a);+ UiText t = m->text;+ if (right && t.x > m->key[0] - hw - 0.15f) t.x = m->key[0] - hw - 0.15f;+ if (!right && t.x < m->key[0] + hw + 0.15f) t.x = m->key[0] + hw + 0.15f;+ ui_text_at(m->texts[which], STYLE_MSG, &t, ox, oy, right ? 2 : 0, a);+}++/* the pane at (ox, oy) (its alpha a; its white); current: the pane shown (else going: Pane Reset, nothing chosen) */+void map_pane_draw(float ox, float oy, float a, uint8_t white, bool current) {+ to_overlay = true, pane_a = a, tint_n = 0;+ int st = current ? mp.st : MP_WIDE;+ /* the wide map: the areas had (Dirtmouth always), their names; chosen: white (in the wide map only) */+ float wa = current ? mp.wide_a : 1;+ if (wa > 0) {+ uint8_t wa8 = (uint8_t)(wa * 255 + 0.5f);+ for (int i = 0; i < NAREAS; i++) {+ if (!have_area(i) || wide[i].piece.sprite < 0) continue;+ bool on = current && st == MP_WIDE && mp.sel == i;+ uint8_t g = on ? 255 : MAP_WIDE_GREY, gn = on ? 255 : MAP_WIDE_NAME_GREY;+ ui_piece(&wide[i].piece, ox, oy, 1, map_tint((uint32_t)g * 0x10101u, wa8));+ hud_text(wide[i].text, STYLE_MSG_S, ox + wide[i].name.x, oy + wide[i].name.top, 1, (uint32_t)gn * 0x10101u, wa);+ }+ /* (its compass: where the Knight's area is) */+ int z = area_of_zone();+ if (charm_on(2) && z >= 0 && mc.compass.sprite >= 0)+ hud_sprite(mc.compass.sprite, ox + wide[z].cx, oy + wide[z].cy, MAP_WIDE_COMPASS_K, 0, map_tint(0xFFFFFF, wa8));+ }+ /* Game_Map, zoomed into: its areas had, the marks on it */+ bool map_on = current && !mp.closed && (st == MP_ZOOM || st == MP_ZOOMED || st == MP_MARKERS ||+ st == MP_MARKER_CANCEL || (st == MP_ZOOM_OUT && mp.t < 0.35f));+ if (map_on) {+ for (int i = 0; i < NAREAS; i++)+ if (have_area(i)) draw_area(i, mp.x, mp.y, mp.k, false);+ draw_marks(mp.x, mp.y, mp.k);+ }+ if (current && !mp.closed && st == MP_ZOOMED) {+ /* (the pan's arrows: where there is more of it) */+ float b[4];+ pan_bounds(b);+ bool show[4] = {mp.y > b[2], mp.y < b[3], mp.x < b[1], mp.x > b[0]};+ for (int i = 0; i < 4; i++)+ if (show[i]) hud_sprite(pan_arrows[i].sprite, ox + pan_arrows[i].x, oy + pan_arrows[i].y, pan_arrows[i].k, pan_arrows[i].deg, white);+ }+ /* the map's key: its backboard, its rows (the pins had); its action */+ if (current && pd_flag(PDF_HAS_PIN)) {+ if (mp.key_a > 0) {+ uint8_t kw = map_tint(0xFFFFFF, (uint8_t)(mp.key_a * 255 + 0.5f));+ int n = 0;+ for (int i = 0; i < MAP_KEY_N; i++) n += key_flags[i] >= 0 && pd_flag(key_flags[i]);+ ui_piece(&key_bb, ox, oy + n * MAP_KEY_STEP, 1, kw);+ n = 0;+ for (int i = 0; i < MAP_KEY_N; i++) {+ if (key_flags[i] < 0 || !pd_flag(key_flags[i])) continue;+ ui_piece(&key_rows[i].icon, ox, oy + n * MAP_KEY_STEP, 1, kw);+ ui_text_at(key_rows[i].text, STYLE_MSG, &key_rows[i].at, ox, oy + n * MAP_KEY_STEP, 0, mp.key_a * a);+ n++;+ }+ }+ if (st == MP_ZOOMED && !mp.closed) action_draw(&act_key, g_pd.map_key_pref, TXT_KEY_SHIFT, ox, oy, white, a, true);+ }+ /* the markers' menu: its backboard, its cursor, the kinds had (the chosen bigger; none left: grey), how many are left;+ * the placement cursor; its actions */+ if (current && mp.mm_a > 0) {+ float ma = mp.mm_a;+ uint8_t mw = map_tint(0xFFFFFF, (uint8_t)(ma * 255 + 0.5f)), mg = map_tint(0x808080, (uint8_t)(ma * 255 + 0.5f));+ float bx = ox + mm_row.x, by = oy + mm_row.y;+ ui_piece(&mm_pieces[1], ox, oy, 1, mw);+ ui_piece(&mm_pieces[0], ox, oy, 1, mw);+ ui_piece(&mm_pieces[2], ox + mp.cur_x - mm_row.x0, oy, 1, mw);+ ui_piece(&mm_pieces[3], ox + mp.cur_x - mm_row.x0, oy, 1, mw);+ for (int c = 0; c < 4; c++) {+ if (!has_marker(c)) continue;+ float k = c == mp.marker ? 0.7f : 0.6f, x = bx + marker_x(c), y = by + mm_row.y0;+ bool left = spare(c) > 0;+ hud_sprite(mm_markers[c], x, y, k / 0.7f, 0, left ? mw : mg);+ UiText t = {mm_amount.x * k / 0.6f, mm_amount.top * k / 0.6f, mm_amount.w};+ ui_number_at(spare(c), STYLE_MSG, x + t.x, y + t.top, 1, ma * a);+ }+ if (st == MP_MARKERS || st == MP_MARKER_CANCEL)+ action_draw(&act_cancel, 0, TXT_KEY_BACK, ox, oy, mw, ma * a, true);+ if (marker_kinds() >= 2) action_draw(&act_change, 0, TXT_KEY_SHIFT, ox, oy, mw, ma * a, false);+ }+ if (current && !mp.closed && st == MP_MARKERS) hud_sprite(mm_place.sprite, place_x() - INV_X + ox, place_y() - INV_Y + oy, 1, 0, white);+ /* the confirm action (Zoom In; zoomed: Zoom Out), the markers' (Markers; in their menu: Place, Remove) */+ if (current && (st == MP_WIDE || st == MP_ZOOM)) action_draw(&act_confirm, 0, TXT_KEY_OK, ox, oy, white, a, true);+ if (current && st == MP_ZOOMED) action_draw(&act_confirm, 1, TXT_KEY_BACK, ox, oy, white, a, true);+ if (current && pd_flag(PDF_HAS_MARKER) && (st == MP_ZOOMED || st == MP_MARKERS || st == MP_MARKER_CANCEL))+ action_draw(&act_marker, st == MP_ZOOMED ? 0 : mp.hit >= 0 ? 2 : 1, TXT_KEY_OK, ox, oy, white, a, false);+ to_overlay = false;+}diff --git a/games/hollowknight/src/save.c b/games/hollowknight/src/save.cindex da250224..9231bc64 100644--- a/games/hollowknight/src/save.c+++ b/games/hollowknight/src/save.c@@ -118,6 +118,7 @@ bool save_load(int slot) {/* (counts kept within their arrays whatever the file says) */for (int c = 0; c < 4; c++)if (g_pd.markers_placed[c] > 6) g_pd.markers_placed[c] = 6;+ if (g_pd.map_key_pref > 2) g_pd.map_key_pref = 0;/* (names kept within their bounds whatever the file says) */g_pd.respawn_scene[SCENE_NAME - 1] = g_pd.respawn_marker[SCENE_NAME - 1] = g_pd.shade_scene[SCENE_NAME - 1] = 0;uint32_t nbits;diff --git a/games/hollowknight/src/shop.c b/games/hollowknight/src/shop.cindex 3180f77f..6c7a89c0 100644--- a/games/hollowknight/src/shop.c+++ b/games/hollowknight/src/shop.c@@ -380,16 +380,7 @@ static void anim_piece(const AnimPiece *p, const Anim *an, uint8_t tint) {}/* an action's key (ActionButtonIcon: the calculator's, by name) */-static void key_at(const float *at, int name, float a, uint8_t white) {- const uint8_t *st = font_style(STYLE_MSG);- const uint8_t *s = text_get(name);- float w = text_width(STYLE_MSG, s, 2);- Inst in;- sprite_inst(SPRITE_MSG_KEY, at[0], at[1], 0, (w / HUD_PX + 0.3f) / 0.95f, 0.75f, white, &in);- gfx_overlay(&in);- gfx_text(STYLE_MSG, VIEW_W / 2 + at[0] * HUD_PX - w / 2, VIEW_H / 2 - at[1] * HUD_PX + (font_asc(st) - font_desc(st)) / 2,- s, 2, (uint32_t)(a * 255 + 0.5f) << 24 | 0xFFFFFF, 0);-}+static void key_at(const float *at, int name, float a, uint8_t white) { ui_key(name, at[0], at[1], white, a); }static void shop_draw(void) {float bob = sh.bob_t > 0 ? (sh.bob_t > 0.2f ? (0.4f - sh.bob_t) / 0.2f : sinf(sh.bob_t / 0.2f * 1.5707964f)) * 0.5f : 0;diff --git a/games/hollowknight/src/stag.c b/games/hollowknight/src/stag.cindex afceedc4..f3bbb894 100644--- a/games/hollowknight/src/stag.c+++ b/games/hollowknight/src/stag.c@@ -152,16 +152,8 @@ static float width_of(int text, int style) {/* an action's key (ActionButtonIcon: the calculator's, by name) -> its left (from the menu's place) */static float key_box(const float *k, int name, float a, uint8_t white) {- const uint8_t *st = font_style(STYLE_MSG);- const uint8_t *s = text_get(name);- float w = text_width(STYLE_MSG, s, 2), g = grow();- float x = at[0] + k[0] * g, y = at[1] + k[1] * g;- Inst in;- sprite_inst(SPRITE_MSG_KEY, x, y, 0, (w / HUD_PX + 0.3f) / 0.95f, 0.75f, white, &in);- gfx_overlay(&in);- gfx_text(STYLE_MSG, VIEW_W / 2 + x * HUD_PX - w / 2, VIEW_H / 2 - y * HUD_PX + (font_asc(st) - font_desc(st)) / 2, s, 2,- (uint32_t)(a * 255 + 0.5f) << 24 | 0xFFFFFF, 0);- return k[0] - (w / HUD_PX + 0.3f) / 2;+ float g = grow();+ return k[0] - ui_key(name, at[0] + k[0] * g, at[1] + k[1] * g, white, a);}/* an action's text, ending before its key (the text bigger than the game's: kept clear of it) */diff --git a/games/hollowknight/tests/play.c b/games/hollowknight/tests/play.cindex 560aaaf3..823ad0e9 100644--- a/games/hollowknight/tests/play.c+++ b/games/hollowknight/tests/play.c@@ -167,7 +167,8 @@ int main(int argc, char **argv) {host_shot(shot);}if (getenv("HKGROUPS")) {- printf("fade %d items %u cam %.2f,%.2f groups:", g_screen_fade, g_gfx_items, g_cam_x, g_cam_y);+ extern uint32_t g_gfx_dropped;+ printf("fade %d items %u dropped %u cam %.2f,%.2f groups:", g_screen_fade, g_gfx_items, g_gfx_dropped, g_cam_x, g_cam_y);for (int g = 1; g < MAX_GROUPS; g++)if (g_group_alpha[g] != 255) printf(" %d=%d", g, g_group_alpha[g]);printf("\n");diff --git a/games/hollowknight/tools/gamemap.py b/games/hollowknight/tools/gamemap.pyindex 6a30349e..5a5314ce 100644--- a/games/hollowknight/tools/gamemap.py+++ b/games/hollowknight/tools/gamemap.py@@ -7,11 +7,27 @@ import unity, textGAME_MAP = ("resources.assets", 4808)HUD = ("resources.assets", 5473)QUICK = "_GameCameras/HudCamera/Quick Map/"-# the areas this part of the game has maps of: (Game_Map's child, the PlayerData bool that has its map (None: always),-# the quick map's place for it (Quick Map: SetPosition), its name (Map Zones))-AREAS = (("Town_Tutorial", None, (4.07, -11.62), "TOWN"),- ("Crossroads", "mapCrossroads", (-0.04, -7.88), "CROSSROADS"))-QUICK_K, WORLD_K = 1.55, 1.45 # (the map's scale: the quick map's (Check Area), the world map's (its own))+# the areas of this part of the game: (Game_Map's child, the PlayerData bool that has its map (None: always), the quick+# map's place for it (Quick Map: SetPosition), its name (Map Zones), the inventory's wide map's piece of it, the place the+# map zooms to for it (UI Control: Zoom To Pos), the wide map's compass there (Compass Icon's Position), the pan's bounds+# it widens (WorldMap: min x, max x, min y, max y; None: not that one)). Greenpath's map is never had here: its rooms+# only (where the compass is, in the dark)+AREAS = (("Town_Tutorial", None, (4.07, -11.62), "TOWN", "Town", (4, -8.642), (2.86, -4.49), None),+ ("Crossroads", "mapCrossroads", (-0.04, -7.88), "CROSSROADS", "Crossroads", (-0.04, -7.58), (2.51, -5.65), None),+ ("Green_Path", "mapGreenpath", (16.31, -7.87), "GREEN_PATH", "Greenpath", (16.42, -7.32), (-0.12, -6),+ (None, 17.26, None, -6.22)))+QUICK_K = 1.55 # (the map's scale: the quick map's (Check Area))+# the inventory's map (Inventory/Map/World Map: UI Control): the Wide Map's place (Pos 1: the top areas' maps only),+# the map zoomed into from there (Map Zoom: the wide map's place and these, at 0.436; to 1.3), the pan's bounds+# (WorldMap's, before the areas widen them), its speed (GameMap's panSpeed)+INV = "_GameCameras/HudCamera/Inventory/"+WM = INV + "Map/World Map/"+WIDE_POS = (0.52, -2.58)+ZOOM_FROM, ZOOM_K0, ZOOM_K = (3.81, -7.77), 0.436, 1.3+PAN = (-1.44, 4.55, -8.642, -5.58)+# the map's key (Map Key: Draw Pins): its rows in order, by the pins had (in this part of the game)+KEYS = (("Bench", "pin_bench", "hasPinBench"), ("Cocoon", "Pin Icon", "hasPinCocoon"), ("Vendor", "Pin Icon", "hasPinShop"),+ ("Spa", "Pin Icon", "hasPinSpa"), ("Key Stag", "Pin Icon", "hasPinStag"))MAP_MSG = ("sharedassets7.assets", 539) # (Map Update Msg: what the bench makes as the map is updated)MAP_MSG_AT = (-1.29, -6.83) # (its Map Msg's Position)COCOON = "hasPinCocoon" # (pin_blue_health: SetupMap's, by the rooms a cocoon was broken in)@@ -78,14 +94,19 @@ def build(sprites, texts, res, rooms, pd_flags, room_zone):root = by["Game_Map"]rows, pins, nexts, names, areas = [], [], [], [], []- for ai, (an, have, qpos, title) in enumerate(AREAS):+ for ai, (an, have, qpos, title, _, _, _, _) in enumerate(AREAS):a = by["Game_Map/" + an]first = len(rows)zones = 0+ never = have is not None and flag(have) == -2for r in kids.get(a["id"], []):sr = comp(r, "SpriteRenderer")cls = {(c.get("class") or c["type"]) for c in r["c"]}+ if never and r["name"] not in rooms:+ continue # (a map never had: its rooms here only, for the compass)if "TextMeshPro" in cls:+ if never:+ continue# (the area's name: the world map's only; a sub area's: both)t, mx, top, rgb, al = tx(r, "MSG")world_only = "DisplayOnWorldMapOnly" in cls or fsm(r) is not None@@ -95,7 +116,7 @@ def build(sprites, texts, res, rooms, pd_flags, room_zone):continue # (the Collector's Map's: not here)rm = comp(r, "RoughMapRoom")ri = rooms.index(r["name"]) if r["name"] in rooms else 255- rough = bool(r["self_active"] and rm)+ rough = bool(r["self_active"] and rm) and not neverif ri == 255 and not rough:continue # (never mapped here, never shown)if ri != 255:@@ -106,15 +127,15 @@ def build(sprites, texts, res, rooms, pd_flags, room_zone):col = sr["m_Color"]rgb = sum(int(round(col[c] * 255)) << (16 - 8 * i) for i, c in enumerate("rgb"))s = unity.sprite(d["level"], d["externals"], *sr["m_Sprite"])- sid = spr(sr["m_Sprite"], QUICK_K * k)- full = spr(rm["fullSprite"], QUICK_K * k) if rm else -1+ sid = spr(sr["m_Sprite"], QUICK_K * k) if not never else -1+ full = spr(rm["fullSprite"], QUICK_K * k) if rm and not never else -1w, h = s.w / s.ppu * k, s.h / s.ppu * r["lscale"][1] * k / r["lscale"][0]else:sid, full, w, h, rgb = -1, -1, 0, 0, 0 # (Crossroads_ShamanTemple: its pins only)rows.append("{%d, %d, %d, %d, %s, %s, %s, %s, 0x%06X, %d}" % (ai, ri, sid, full, U(x), U(y), U(w), U(h), rgb,rough))mi = len(rows) - 1- for q in kids.get(r["id"], []):+ for q in ([] if never else kids.get(r["id"], [])):qc = {(c.get("class") or c["type"]) for c in q["c"]}if q["name"].startswith("pin_") and "SpriteRenderer" in qc:f = fsm(q)@@ -158,7 +179,7 @@ def build(sprites, texts, res, rooms, pd_flags, room_zone):out["MAP_PINS"] = "{%s}" % ", ".join(pins)out["MAP_NEXT"] = "{%s}" % ", ".join(nexts)out["MAP_NAMES"] = "{%s}" % ", ".join(names)- out["MAP_QUICK_K"], out["MAP_WORLD_K"] = U(QUICK_K), U(WORLD_K)+ out["MAP_QUICK_K"] = U(QUICK_K)# the shade's mark (Shade Pos: its fader, its head), the markers (Map Markers: B1, R1, Y1, W1)sp = by["Game_Map/Shade Pos"]parts = []@@ -235,4 +256,139 @@ def build(sprites, texts, res, rooms, pd_flags, room_zone):U(q["pos"][0]), U(q["pos"][1]), U(kx / max(kx, ky)), U(ky / max(kx, ky))))out["FIRSTMAP_PIECES"] = "{%s}" % ", ".join(parts)out["FIRSTMAP_KEY"] = "{%d, %s, %s}" % (texts.add("var", "PROMPT"), U(fm("Button")["pos"][0]), U(fm("Button")["pos"][1]))+ out.update(pane(sprites, texts, res, h, hb, sh, flag))+ return out+++def pane(sprites, texts, res, h, hb, sh, flag):+ """The inventory's map pane: places in HUD units from the inventory's (its panes' when shown), the Game_Map's from+ the HUD's middle"""+ U = lambda v: "%.4ff" % v+ inv = hb[INV[:-1]]+ out = {}++ def comp(o, cls):+ return next((c["v"] for c in o["c"] if (c.get("class") or c["type"]) == cls and c.get("v") is not None), None)++ def rel(o, dx=0.0, dy=0.0):+ return o["pos"][0] - inv["pos"][0] + dx, o["pos"][1] - inv["pos"][1] + dy++ def piece(path, dx=0.0, dy=0.0, k=1.0):+ """a sprite at its place: "{sprite, x, y, kx, ky}" (UiPiece)"""+ o = hb[path]+ x, y = rel(o, dx, dy)+ sx, sy = o["m3"][0] * k, o["m3"][4] * k+ m = max(abs(sx), abs(sy))+ sr = comp(o, "SpriteRenderer")+ return "{%d, %s, %s, %s, %s}" % (sprites.id(h, sr["m_Sprite"], m, res), U(x), U(y), U(sx / m), U(sy / m))++ def tx(path, dx=0.0, dy=0.0):+ """a text's place: "{x, top, w}" (UiText: x its rect's left, middle or right, as it is aligned)"""+ o = hb[path]+ x, y = rel(o, dx, dy)+ tc, tm = comp(o, "TextContainer"), comp(o, "TextMeshPro")+ k = o["m3"][0]+ w, ht = tc["m_rect"]["width"] * k, tc["m_rect"]["height"] * k+ al = tm["m_textAlignment"] % 4+ return "{%s, %s, %s}" % (U(x - tc["m_pivot"]["x"] * w + (0, w / 2, w, 0)[al]), U(y + (1 - tc["m_pivot"]["y"]) * ht), U(w))++ def at(path, dx=0.0, dy=0.0):+ return "{%s, %s}" % tuple(U(v) for v in rel(hb[path], dx, dy))++ def txt(key, style, sheet="UI"):+ return texts.add(text.clean(sh[sheet][key]), style)++ # the wide map: each area's piece (none: never had) and its name, where the map zooms to for it, the compass there,+ # the pan's bounds it widens; the pieces' grey (Selection Colour: unselected), their names' grey+ dx, dy = WIDE_POS+ rows = []+ for an, have, _, title, wide, zoom, compass, ext in AREAS:+ never = have is not None and flag(have) == -2+ e = ext or (None,) * 4+ ext_s = ", ".join(U(v if v is not None else (1e3, -1e3)[i % 2]) for i, v in enumerate(e))+ cx, cy = rel(hb[WM + "Wide Map"], dx + compass[0], dy + compass[1])+ if never:+ rows.append("{{-1, 0, 0, 0, 0}, -1, {0, 0, 0}, %s, %s, %s, %s, {%s}}" % (U(zoom[0]), U(zoom[1]), U(cx), U(cy), ext_s))+ continue+ base = WM + "Wide Map/" + wide+ rows.append("{%s, %d, %s, %s, %s, %s, %s, {%s}}" % (piece(base, dx, dy), txt(title, "MSG_S", "Map Zones"),+ tx(base + "/Area Name", dx, dy), U(zoom[0]), U(zoom[1]),+ U(cx), U(cy), ext_s))+ out["MAP_WIDE"] = "{%s}" % ", ".join(rows)+ out["MAP_WIDE_GREY"], out["MAP_WIDE_NAME_GREY"] = "0x5C", "0x5B" # (0.3603, 0.3569)+ ci = hb[WM + "Wide Map/Compass Icon"]+ out["MAP_WIDE_COMPASS_K"] = U(ci["lscale"][0])+ wx, wy = rel(hb[WM + "Wide Map"], dx, dy)+ zx, zy = hb[WM + "Wide Map"]["pos"][0] + dx + ZOOM_FROM[0], hb[WM + "Wide Map"]["pos"][1] + dy + ZOOM_FROM[1]+ out["MAP_ZOOM"] = "{%s, %s, %s, %s}" % (U(zx), U(zy), U(ZOOM_K0), U(ZOOM_K))+ out["MAP_PAN"] = "{%s}" % ", ".join(U(v) for v in PAN)+ gm = unity.prefab(*GAME_MAP)+ gmc = next(c["v"] for c in gm["objects"][0]["c"] if (c.get("class") or c["type"]) == "GameMap")+ out["MAP_PAN_SPEED"] = U(gmc["panSpeed"])+ def turned(path):+ """a sprite turned: "{sprite, x, y, k, degrees}" """+ o = hb[path]+ x, y = rel(o)+ m = o["m3"]+ k = math.hypot(m[0], m[3])+ sr = comp(o, "SpriteRenderer")+ return "{%d, %s, %s, 1.0f, %s}" % (sprites.id(h, sr["m_Sprite"], k, res), U(x), U(y),+ U(math.degrees(math.atan2(m[3], m[0]))))+ out["MAP_PAN_ARROWS"] = "{%s}" % ", ".join(turned(WM + "Pan Arrows/Arrow " + d) for d in "UDLR")+ # the actions: their backboards, their keys' places, their texts (Confirm Action: right; the markers': left)+ def action(base, keys):+ return "{%s, %s, %s, {%s}}" % (piece(base + "/Backboard"), at(base + "/ActionButtonIcon"), tx(base + "/Text"),+ ", ".join(str(txt(k, "MSG")) for k in keys))+ out["MAP_ACT_CONFIRM"] = action(WM + "Confirm Action", ("CTRL_ZOOM_IN", "CTRL_ZOOM_OUT", "CTRL_ZOOM_OUT"))+ out["MAP_ACT_MARKER"] = action(WM + "Map Marker Action", ("CTRL_MARKERS", "CTRL_MARKER_PLACE", "CTRL_MARKER_REMOVE"))+ out["MAP_ACT_CANCEL"] = action(WM + "Map Markers/Marker Cancel Action", ("CTRL_CANCEL",) * 3)+ out["MAP_ACT_CHANGE"] = action(INV + "Map/Marker Change Action", ("CTRL_MARKER_CHANGE",) * 3)+ out["MAP_ACT_KEY"] = action(INV + "Map Key/Action", ("CTRL_HIDE_KEY", "CTRL_HIDE_PINS", "CTRL_SHOW_PINS_KEY"))+ # the map's key: its backboard (its top at Backboard First Y, lower a row's step each), its rows (Pin First Y, then+ # each its step lower): their pins, their names; the pins' flags+ ctl = next(c["fsm"] for c in hb[INV + "Map Key"]["c"] if c.get("fsm") and c["fsm"]["name"] == "Control")+ v = ctl["vars"]+ mk = hb[INV + "Map Key"]+ bb = hb[INV + "Map Key/Backboard Key"]+ out["MAP_KEY_BB"] = piece(INV + "Map Key/Backboard Key", 0, v["Backboard First Y"][1] - bb["lpos"][1])+ out["MAP_KEY_STEP"] = U(v["Pin Y Increment"][1])+ krows, kflags = [], []+ for n, icon, fl in KEYS:+ kb = hb[INV + "Map Key/Keys/" + n]+ ky = v["Pin First Y"][1] - kb["lpos"][1]+ krows.append("{%s, %d, %s}" % (piece(INV + "Map Key/Keys/%s/%s" % (n, icon), 0, ky),+ txt(comp(hb[INV + "Map Key/Keys/%s/Text" % n], "SetTextMeshProGameText")["convName"], "MSG"),+ tx(INV + "Map Key/Keys/%s/Text" % n, 0, ky)))+ kflags.append(str(flag(fl)))+ out["MAP_KEY_ROWS"] = "{%s}" % ", ".join(krows)+ out["MAP_KEY_FLAGS"] = "{%s}" % ", ".join(kflags)+ out["MAP_KEY_N"] = len(KEYS)+ # the markers' menu (MapMarkerMenu): its backboard and shadow, its cursor and its back, the markers (b, r, y, w: the+ # menu's; at 0.6, the chosen at 0.7) and their amounts' place under them, the first's x, the next's step, their y;+ # the placement cursor (its sprite; its first place, its bounds: from the menu's place), its speed, its pull to a+ # marker; the placement box's radius, a marker's (InvMarker)+ mm = hb[WM + "Map Markers"]+ mmc = comp(mm, "MapMarkerMenu")+ ox, oy = rel(mm)+ out["MAP_MM_PIECES"] = "{%s}" % ", ".join(piece(WM + "Map Markers/" + n) for n in (+ "Backboard", "Backboard/Backboard Shadow", "Cursor/Cursor Bg", "Cursor"))+ out["MAP_MM_MARKERS"] = "{%s}" % ", ".join(+ str(sprites.id(h, comp(hb[WM + "Map Markers/Marker_" + c], "SpriteRenderer")["m_Sprite"], 0.7, res)) for c in "bryw")+ # (an amount's text from its marker's place, the marker at 0.6)+ mb_ = hb[WM + "Map Markers/Marker_b"]+ out["MAP_MM_AMOUNT"] = tx(WM + "Map Markers/Marker_b/Amount B", -rel(mb_)[0], -rel(mb_)[1])+ out["MAP_MM_ROW"] = "{%s, %s, %s, %s, %s}" % (U(ox), U(oy), U(mmc["xPos_start"]), U(mmc["xPos_interval"]), U(mmc["markerY"]))+ pc = hb[WM + "Map Markers/Placement Cursor"]+ o = mmc["placementCursorOrigin"]+ out["MAP_MM_PLACE"] = "{%d, %s, %s, %s, %s, %s, %s, %s, %s}" % (+ sprites.id(h, comp(pc, "SpriteRenderer")["m_Sprite"], pc["lscale"][0], res), U(o["x"]), U(o["y"]),+ U(mmc["placementCursorMinX"]), U(mmc["placementCursorMaxX"]), U(mmc["placementCursorMinY"]),+ U(mmc["placementCursorMaxY"]), U(mmc["panSpeed"]), U(mmc["markerPullSpeed"]))+ pb = comp(hb[WM + "Map Markers/Placement Box"], "CircleCollider2D")+ gmb = {q["path"]: q for q in gm["objects"]}+ out["MAP_MM_RADII"] = U(pb["m_Radius"] + comp(gmb["Game_Map/Map Markers/B1/Collider"], "CircleCollider2D")["m_Radius"])+ out["MAP_MM_UI_PAUSE"] = U(mmc["uiPause"])+ # (the wide map's names, the actions' texts: their sizes as the game's MSG)+ texts.add("0123456789", "MSG")+ out["TXT_KEY_SHIFT"] = texts.add("shift", "MSG") # (the dream nail's key here: the calculator's shift)return out