From 836b4f7f92db01414a243c7fc80f76792cc1a85a Mon Sep 17 00:00:00 2001 From: jeboo Date: Mon, 30 Mar 2026 10:35:38 -0400 Subject: [PATCH] fix OOB bug when leaving Kraid fight from right door --- patches/ips/fix_kraid_door.ips | Bin 0 -> 34 bytes patches/rom_map/Bank A7.txt | 3 ++- patches/rom_map/vanilla_hooks.txt | 1 + patches/src/fix_kraid_door.asm | 27 +++++++++++++++++++++++++++ rust/maprando/src/patch.rs | 1 + 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 patches/ips/fix_kraid_door.ips create mode 100644 patches/src/fix_kraid_door.asm diff --git a/patches/ips/fix_kraid_door.ips b/patches/ips/fix_kraid_door.ips new file mode 100644 index 0000000000000000000000000000000000000000..c4a29d327bbea90eb46dc87f6777e9892932af59 GIT binary patch literal 34 qcmWG=3~}}l-te1&+2_E2;r|C1c-Ky4|G=2A_8XUk&;Jds{%!#A91c(b literal 0 HcmV?d00001 diff --git a/patches/rom_map/Bank A7.txt b/patches/rom_map/Bank A7.txt index 0fb852e6fa..b0dcfbb358 100644 --- a/patches/rom_map/Bank A7.txt +++ b/patches/rom_map/Bank A7.txt @@ -1,4 +1,5 @@ 0000 - FF82: used by vanilla game FF82 - FFC0: escape.asm (for dachora) -FFC0 - FFDF: map_area (for kraid) +FFC0 - FFD0: fix_kraid_door.asm +FFD0 - FFE0: [FREE] FFE0 - FFFF: flashing_placebo (for phantoon) diff --git a/patches/rom_map/vanilla_hooks.txt b/patches/rom_map/vanilla_hooks.txt index 33ab55fbee..ab422032b9 100644 --- a/patches/rom_map/vanilla_hooks.txt +++ b/patches/rom_map/vanilla_hooks.txt @@ -1096,6 +1096,7 @@ $a6b2ba - gray_doors.asm $a6b297 - gray_doors.asm [BANK A7] +$a7b0fb - fix_kraid_door.asm $a7c81e - escape.asm $a7f892 - escape.asm $a7dd7f - flashing_placebo.asm diff --git a/patches/src/fix_kraid_door.asm b/patches/src/fix_kraid_door.asm new file mode 100644 index 0000000000..45dc6c5096 --- /dev/null +++ b/patches/src/fix_kraid_door.asm @@ -0,0 +1,27 @@ +; Fix bug when entering Kraid from right door and leaving just as he +; finishes ascending. The boss AI checks that Samus is left of Kraid, +; and will adjust her X coordinate if needed. This can lead to a bugged +; Samus position or OOB error if it occurs during the door transition. +; +; Reported by P.JBoy, fix by Stag Shot + +lorom + +!bank_a7_free_space_start = $a7ffc0 +!bank_a7_free_space_end = $a7ffd0 + +org $a7b0fb + jmp fix_kraid_door + +org !bank_a7_free_space_start +fix_kraid_door: + lda $795 ; door transition flag + beq .resume + rts ; skip rest of func + +.resume + lda $af6 ; replaced code + clc ; + jmp $b0ff ; resume func + +assert pc() < !bank_a7_free_space_end diff --git a/rust/maprando/src/patch.rs b/rust/maprando/src/patch.rs index e67dc74307..04ccc13e9c 100644 --- a/rust/maprando/src/patch.rs +++ b/rust/maprando/src/patch.rs @@ -492,6 +492,7 @@ impl Patcher<'_> { "fast_big_boy_cutscene", "fix_kraid_vomit", "fix_kraid_hud", + "fix_kraid_door", "escape_autosave", "boss_exit", "load_plms_early",