From 99da1d31158461364cb783eaca8e7cb378e56be6 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:04:37 +0100 Subject: [PATCH 1/3] Reset boss RNG and other things on new file --- events.asm | 10 ++++++++++ init.asm | 1 + rngfixes.asm | 8 ++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/events.asm b/events.asm index 15912b7..4ff5905 100644 --- a/events.asm +++ b/events.asm @@ -149,6 +149,16 @@ OnNewFile: LDA StartingSword : STA $7EF359 ; set starting sword type LDA !INVENTORY_SWAP : STA $70038C ; copy starting equipment swaps to file select screen LDA !INVENTORY_SWAP_2 : STA $70038E + + ; reset some values on new file that are otherwise only reset on hard reset + STZ $03C4 ; ancilla slot index + STZ $047A ; EG + STZ $0B08 : STZ $0B09 ; arc variable + STZ $0CFB ; enemies killed (pull trees) + STZ $0CFC ; times taken damage (pull trees) + STZ $0FC7 : STZ $0FC8 : STZ $0FC9 : STZ $0FCA : STZ $0FCB : STZ $0FCC : STZ $0FCD ; prize packs + LDA #$00 : STA $7EC011 ; mosaic + JSL InitRNGPointerTable ; boss RNG PLP : PLX RTL ;-------------------------------------------------------------------------------- diff --git a/init.asm b/init.asm index 8da91a0..47a5726 100644 --- a/init.asm +++ b/init.asm @@ -56,5 +56,6 @@ RTL Init_PostRAMClear: JSL MSUInit + JSL InitRNGPointerTable JML $00D463 ; The original target of the jump table that we hijacked \ No newline at end of file diff --git a/rngfixes.asm b/rngfixes.asm index ae1e797..cf2b7b9 100644 --- a/rngfixes.asm +++ b/rngfixes.asm @@ -107,9 +107,9 @@ RTL !RNG_POINTERS = "$7F5200" GetStaticRNG: PHX : PHP - REP #$20 ; set 16-bit accumulator and index registers - AND.w #$007F - ASL : TAX : LDA !RNG_POINTERS, X : INC : AND.w #$03FF : STA !RNG_POINTERS, X : TAX : ASL ; increment pointer and move value to X + REP #$30 ; set 16-bit accumulator and index registers + AND.w #$000F + ASL : TAX : LDA !RNG_POINTERS, X : INC : AND.w #$03FF : STA !RNG_POINTERS, X : TAX ; increment pointer and move value to X LDA Static_RNG, X ; load RNG value PLP : PLX RTL @@ -123,7 +123,7 @@ InitRNGPointerTable: LDA.l .rngDefaults, X : STA !RNG_POINTERS, X : INX #2 LDA.l .rngDefaults, X : STA !RNG_POINTERS, X : INX #2 LDA.l .rngDefaults, X : STA !RNG_POINTERS, X : INX #2 - CPX.w #$007F : !BLT - + CPX.w #$001F : !BLT - PLP : PLX RTL .rngDefaults From 078aebed8dbc2d5c4e05f405a4370ea248ef1749 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:42:40 +0100 Subject: [PATCH 2/3] Restore vanilla prize pack reset behavior --- save.asm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/save.asm b/save.asm index f1add73..1b41061 100644 --- a/save.asm +++ b/save.asm @@ -1,5 +1,13 @@ ;-------------------------------------------------------------------------------- Validate_SRAM: + REP #$30 ; vanilla behavior from $0CCD45, includes prize pack reset after save and quit + LDX #$00FE : - + STZ $0D00, X + STZ $0E00, X + STZ $0F00, X + DEX #2 + BPL - + SEP #$30 RTL ;-------------------------------------------------------------------------------- ClearExtendedSaveFile: From 0c608c1380db82ae7e2d4fa75ee9acc5e2ee04f6 Mon Sep 17 00:00:00 2001 From: Catobat <69204835+Catobat@users.noreply.github.com> Date: Wed, 16 Dec 2020 19:58:33 +0100 Subject: [PATCH 3/3] Fix starting equipment on file select --- events.asm | 8 ++++++-- hooks.asm | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/events.asm b/events.asm index 4ff5905..412f1af 100644 --- a/events.asm +++ b/events.asm @@ -80,6 +80,12 @@ OnAga2Defeated: JSL.l IncrementAgahnim2Sword RTL ;-------------------------------------------------------------------------------- +OnFileCreation: + TAX ; what we wrote over + LDA StartingEquipment+$4C : STA $700340+$4C ; copy starting equipment swaps to file select screen + LDA StartingEquipment+$4E : STA $700340+$4E +RTL +;-------------------------------------------------------------------------------- !RNG_ITEM_LOCK_IN = "$7F5090" OnFileLoad: REP #$10 ; set 16 bit index registers @@ -147,8 +153,6 @@ OnNewFile: + LDA StartingSword : STA $7EF359 ; set starting sword type - LDA !INVENTORY_SWAP : STA $70038C ; copy starting equipment swaps to file select screen - LDA !INVENTORY_SWAP_2 : STA $70038E ; reset some values on new file that are otherwise only reset on hard reset STZ $03C4 ; ancilla slot index diff --git a/hooks.asm b/hooks.asm index e6c37f1..7c5478f 100755 --- a/hooks.asm +++ b/hooks.asm @@ -261,7 +261,9 @@ org $0CCE85 ; <- Bank0C.asm : 1953 (LDA $C8 : ASL A : INC #2 : STA $701FFE) NOP #4 ;-------------------------------------------------------------------------------- org $0CDB4C ; <- Bank0C.asm : 3655 (LDA $C8 : ASL A : INC #2 : STA $701FFE : TAX) -NOP #4 +JSL OnFileCreation +NOP +;Additionally, display inventory swap starting equipment on file select ;-------------------------------------------------------------------------------- org $09F5EA ; <- module_death.asm : 510 (LDA $701FFE : TAX : DEX #2) LDA.w #$0002 : NOP