From a892ff39b22ca2ae8810b52ba987102e7dd0dd2a Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Wed, 5 Aug 2020 08:48:25 -0700 Subject: [PATCH] Backport terrorpin ai fix from enemizer. (and fix a bug with it.) --- LTTP_RND_GeneralBugfixes.asm | 1 + hooks.asm | 9 +++++++++ tables.asm | 4 ++++ terrorpin.asm | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 terrorpin.asm diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index c52b101..a43c171 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -213,6 +213,7 @@ incsrc elder.asm incsrc toast.asm incsrc darkroomitems.asm incsrc multiworld.asm +incsrc terrorpin.asm warnpc $A58000 ;org $228000 ; contrib area diff --git a/hooks.asm b/hooks.asm index 6227b18..586ce64 100755 --- a/hooks.asm +++ b/hooks.asm @@ -2560,3 +2560,12 @@ CheckIfReading: CPX #$04 RTS ;================================================================================ + +;================================================================================ +; Terrorpin AI fix +;-------------------------------------------------------------------------------- +org $1EB2B1 ; sprite_terrorpin.asm(57) : AND.b #$03 : STA $0DE0, X ; 5 bytes +JSL FixTerrorpin ; 4 bytes +NOP ; 1 byte +;-------------------------------------------------------------------------------- + diff --git a/tables.asm b/tables.asm index 4707bea..0ef8c1c 100644 --- a/tables.asm +++ b/tables.asm @@ -1824,6 +1824,10 @@ org $30E36D ; PC 0x18636D ;BerserkerMulti.world Seed GUID db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00 +org $30E37D ; PC 0x18637D +Enable_TerrorPin_AI_Fix: +db #$01 + ;-------------------------------------------------------------------------------- ; 0x186380 - 187FFF (unused) ;-------------------------------------------------------------------------------- diff --git a/terrorpin.asm b/terrorpin.asm new file mode 100644 index 0000000..9be8def --- /dev/null +++ b/terrorpin.asm @@ -0,0 +1,19 @@ +;================================================================================ +; Terrorpin AI Fixes +;================================================================================ +FixTerrorpin: +{ + PHA ;save A so that checking the option doesn't smoke A + LDA.b Enable_TerrorPin_AI_Fix : BNE .new ; check if option is on + PLA ;restore A + ; do the old code that smokes A + AND.b #$03 : STA $0DE0, X + RTL + + .new + PLA ; Restore A + PHA ; save A so the orignal code doesn't kill it + AND.b #$03 : STA $0DE0, X ; restore what we overwrote + PLA ; restore A so the AND/BNE in the original code actually does something + RTL +}