Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Hollow Knight: Hornet room's breakable floor; camera zones keep their checked limits when one is left for another

Mason Chenbbb0e0953874
diff --git a/games/hollowknight/src/camera.c b/games/hollowknight/src/camera.c
index a7bb987e..f0d00d53 100644
--- a/games/hollowknight/src/camera.c
+++ b/games/hollowknight/src/camera.c
@@ -126,10 +126,12 @@ void cam_init(void) {
}
/* ---------------------------------------------------------------- lock areas */
-static void lock_bounds(const Ent *e, float *x0, float *y0, float *x1, float *y1) {
- /* (CameraLockArea.ValidateBounds) */
- *x0 = e->p0 == -1 ? X_MIN : e->p0, *y0 = e->p1 == -1 ? Y_MIN : e->p1;
- *x1 = e->p2 == -1 ? c.x_limit : e->p2, *y1 = e->p3 == -1 ? c.y_limit : e->p3;
+/* (LockToArea: below 0, the defaults; else, as ReleaseLock has them, CameraLockArea.ValidateBounds's: -1 the defaults) */
+static void lock_bounds(const Ent *e, bool entering, float *x0, float *y0, float *x1, float *y1) {
+ float v[4] = {e->p0, e->p1, e->p2, e->p3}, d[4] = {X_MIN, Y_MIN, c.x_limit, c.y_limit};
+ for (int i = 0; i < 4; i++)
+ if (entering ? v[i] < 0 : v[i] == -1) v[i] = d[i];
+ *x0 = v[0], *y0 = v[1], *x1 = v[2], *y1 = v[3];
}
static void target_enter_lock_zone(float x0, float x1, float y0, float y1) {
@@ -187,7 +189,7 @@ void cam_lock(int ent) {
if (c.cur_lock >= 0 && (es[c.cur_lock].flags & CL_MAX_PRIORITY) && !(e->flags & CL_MAX_PRIORITY)) return;
c.cur_lock = (int16_t)ent;
c.mode = CM_LOCKED;
- lock_bounds(e, &c.x_lock0, &c.y_lock0, &c.x_lock1, &c.y_lock1);
+ lock_bounds(e, true, &c.x_lock0, &c.y_lock0, &c.x_lock1, &c.y_lock1);
if (c.start_locked_timer > 0) {
c.tx = clampf(hx, c.x_lock0, c.x_lock1), c.ty = clampf(hy, c.y_lock0, c.y_lock1);
target_enter_lock_zone_instant(c.x_lock0, c.x_lock1, c.y_lock0, c.y_lock1);
@@ -215,8 +217,7 @@ void cam_release(int ent) {
if (c.nlocks > 0) {
c.cur_lock = c.locks[c.nlocks - 1];
const Ent *l = &es[c.cur_lock];
- /* (as the game: the raw values) */
- c.x_lock0 = l->p0, c.y_lock0 = l->p1, c.x_lock1 = l->p2, c.y_lock1 = l->p3;
+ lock_bounds(l, false, &c.x_lock0, &c.y_lock0, &c.x_lock1, &c.y_lock1);
target_enter_lock_zone(c.x_lock0, c.x_lock1, c.y_lock0, c.y_lock1);
return;
}
@@ -306,7 +307,7 @@ static void controller_late_update(void) {
int n;
const Ent *l = &room_ents(&n)[c.cur_lock];
float x0, y0, x1, y1;
- lock_bounds(l, &x0, &y0, &x1, &y1);
+ lock_bounds(l, false, &x0, &y0, &x1, &y1);
if (c.look_offset > 0 && (l->flags & CL_PREVENT_UP) && dy > y1) dy = c.cy > y1 ? dy - c.look_offset : y1;
if (c.look_offset < 0 && (l->flags & CL_PREVENT_DOWN) && dy < y0) dy = c.cy < y0 ? dy - c.look_offset : y0;
}
diff --git a/games/hollowknight/src/data.bin b/games/hollowknight/src/data.bin
index 40f0f7f2..fbdb667c 100644
Binary files a/games/hollowknight/src/data.bin and b/games/hollowknight/src/data.bin differ
diff --git a/games/hollowknight/src/data.h b/games/hollowknight/src/data.h
index 94cfb7e5..8bfef383 100644
--- a/games/hollowknight/src/data.h
+++ b/games/hollowknight/src/data.h
@@ -673,7 +673,7 @@
#define SPRITE_CORPSE_NAIL 3027
#define SPRITE_FK_BARREL 3028
#define SPRITE_FK_STAFF 3029
-#define SPRITE_DIGIT0 3589
+#define SPRITE_DIGIT0 3594
#define STYLE_DIALOGUE 0
#define STYLE_PROMPT 1
#define STYLE_TITLE_L 2
@@ -924,8 +924,8 @@
#define VMEV_FIRST_MAP_DOWN 45
#define VMEV_FK_RAGE_COMPLETE 46
#define VMSTR_NPC_TITLE 14
-#define VMSTR_VISITED 677
-#define VMSTR_DISPLAY_RIGHT 678
+#define VMSTR_VISITED 678
+#define VMSTR_DISPLAY_RIGHT 679
#define VMSTR_HORNET_SAVER 201
#define VMSTR_ITEM 568
#define STR_ATTACK_RANGE 24
diff --git a/games/hollowknight/src/vm.c b/games/hollowknight/src/vm.c
index 7edcf205..47004ce9 100644
--- a/games/hollowknight/src/vm.c
+++ b/games/hollowknight/src/vm.c
@@ -13,7 +13,7 @@
#define DT 0.02f
#define MAX_VM_OBJS 48
#define MAX_VM_ANIMS 20 /* (its objects that animate: an animator, a wave, a fade) */ /* (tools/vm.py: MAX_OBJS, MAX_FSMS, MAX_VARS) */
-#define MAX_VM_FSMS 26
+#define MAX_VM_FSMS 27
#define MAX_VM_VARS 256
#define MAX_MOVERS 4
#define NONE 0xFFFF
diff --git a/games/hollowknight/tools/vm.py b/games/hollowknight/tools/vm.py
index 459c8be1..a7cb1f5f 100644
--- a/games/hollowknight/tools/vm.py
+++ b/games/hollowknight/tools/vm.py
@@ -21,7 +21,7 @@ ROOMS = {
"Room_ruinhouse": ["Sly Dazed"],
"Crossroads_06": ["Set NPC Leave", "_Scenery/Raising Pillar", "_Props/Gate Switch"],
"Fungus1_04": ["Hornet Infected Knight Encounter", "Hornet Saver", "Cloak Corpse", "Dream Scene Activate",
- "Dreamer Scene 1"],
+ "Dreamer Scene 1", "Break Floor 1"],
"Crossroads_ShamanTemple": ["_Props/Shaman Meeting", "_Props/Shaman Trapped", "_Props/Shaman Killed Blocker",
"_Props/Knight Get Fireball", "Battle Scene/Reminder Cast", "Shiny Item", "Soul Totem 2",
"Bone Gate", "Reminder Cast (1)",
@@ -166,7 +166,7 @@ SKIP_NAMES = {"Dream Dialogue", "Dream Dialogue Flower", "Flower", "Flower Give"
# (the Mender House's door: its inspect region, for a key there is none of, never on; the False Knight's arena wall's
# battle gate: src/obj.c's, which FindChild finds)
SKIP_PATHS = {("Crossroads_04", "_Transition Gates/Mender Door/Inspect"), ("Crossroads_10", "Fk Break Wall/Battle Gate 1")}
-MAX_OBJS, MAX_FSMS, MAX_VARS, MAX_ANIMS = 48, 26, 256, 20 # (src/vm.c)
+MAX_OBJS, MAX_FSMS, MAX_VARS, MAX_ANIMS = 48, 27, 256, 20 # (src/vm.c)
# the grubs in this part of the game (Crossroads_03, Fungus1_21): the Grubfather's rewards past them never come
GRUBS = 2
# the ints ConvertIntToString turns into strings here (the Grubfather's rewards given)