From 1a6478aa2797b6cfd95acc1baca80902e001d271 Mon Sep 17 00:00:00 2001 From: sporchia Date: Tue, 25 Sep 2018 22:13:35 -0400 Subject: [PATCH 1/5] initial commit * the cut scene for 1 and 0 crystals is wrong, it always shows minimum of 2 right now * pretty sure the AGA door check will blow up --- LTTP_RND_GeneralBugfixes.asm | 3 +++ entrances.asm | 2 +- goalitem.asm | 23 ++++++++++++++++++++++- hooks.asm | 15 +++++++++++++++ tables.asm | 7 ++++++- utilities.asm | 23 +++++++++++++++++++++++ 6 files changed, 70 insertions(+), 3 deletions(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index dc3cb3a..8158ebc 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -476,6 +476,9 @@ Sprite_CheckIfPlayerPreoccupied: org $08C3AE Ancilla_ReceiveItem: +org $08CF59 +BreakTowerSeal_ExecuteSparkles: + org $08F710 Ancilla_SetOam_XY_Long: diff --git a/entrances.asm b/entrances.asm index b84417d..60f3ca1 100644 --- a/entrances.asm +++ b/entrances.asm @@ -12,7 +12,7 @@ LockAgahnimDoors: JSR.w LockAgahnimDoorsCore : RTL + : CMP.w #$0002 : BNE + JSR.w LockAgahnimDoorsCore : BEQ .unlock - LDA $7EF37A : AND.w #$007F : CMP.w #$007F : BEQ .crystalOrUnlock + JSL.l CheckEnoughCrystals : BEQ .crystalOrUnlock ; I think the registers might be wrong for this LDA #$0001 : RTL .crystalOrUnlock LDA InvertedMode : AND.w #$00FF : BEQ .unlock diff --git a/goalitem.asm b/goalitem.asm index 6f5765f..f177763 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -46,7 +46,28 @@ CheckGanonVulnerability: ;#$05 = Require 100 Goal Items LDA.l !GOAL_COUNTER : CMP.b #100 : !BLT .fail ; require 100 goal items BRA .success + + : CMP #$06 : BNE + + ;#$06 = Require "NumberOfCrystalsRequired" Crystals + JSR CheckEnoughCrystals : BNE .fail + BRA .success + .fail : CLC : RTL .success : SEC : RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- +GetRequriedCrystals: + BEQ + : JSL.l BreakTowerSeal_ExecuteSparkles : + ; thing we wrote over + LDA.l NumberOfCrystalsRequired : DEC #2 : TAX +RTL +;-------------------------------------------------------------------------------- +CheckEnoughCrystals: + LDA InvincibleGanon : CMP #$06 : BNE .normal + .other + PHX : PHY + LDA $7EF37A : JSL CountBits ; the comparison is against 1 less + PLY : PLX + CMP.l NumberOfCrystalsRequired +RTL + + .normal + LDA $7EF37A : AND.b #$7F : CMP.b #$7F ; thing we wrote over +RTL \ No newline at end of file diff --git a/hooks.asm b/hooks.asm index 294b580..2a15520 100755 --- a/hooks.asm +++ b/hooks.asm @@ -284,6 +284,21 @@ org $1BBD77 ; <- bank1B.asm : 308 (SEP #$30) PreventEnterOnBonk_BRANCH_IX: ;-------------------------------------------------------------------------------- +;================================================================================ +; Crystals Mode +;-------------------------------------------------------------------------------- +org $099B7B ; <- ancilla_init.asm : 4136 (LDA $7EF37A : AND.b #$7F : CMP.b #$7F) +JSL.l CheckEnoughCrystals +NOP #4 +db #$90 ; BCC +;-------------------------------------------------------------------------------- +org $08CE0C ; <- 44E0C - ancilla_break_tower_seal.asm : 168 (BEQ #$03 : JSR BreakTowerSeal_ExecuteSparkles : LDX.b #$06) +JSL.l GetRequriedCrystals +NOP #3 +;-------------------------------------------------------------------------------- +org $08CFC9 ; <- 44FC9 - ancilla_break_tower_seal.asm : 414 (RTS) +db #$6B +;-------------------------------------------------------------------------------- ;================================================================================ ; Hash Key Display diff --git a/tables.asm b/tables.asm index 79a20e8..e45b0e3 100644 --- a/tables.asm +++ b/tables.asm @@ -153,6 +153,7 @@ db #$00 ; #$03 = Require Crystals and Aga2 ; #$04 = Require Crystals ; #$05 = Require 100 Goal Items +; #$06 = Require "NumberOfCrystalsRequired" ;-------------------------------------------------------------------------------- org $30803F ; PC 0x18003F HammerableGanon: @@ -255,7 +256,11 @@ CrystalPendantFlags_2: ;Pendant: $00 ;Crystal: $40 ;-------------------------------------------------------------------------------- -; 0x18005E - 0x18005F (unused) +org $30805E ; PC 0x18005E - Number of crystals required to enter GT +NumberOfCrystalsRequired: +db #$07 ; #$07 = 7 Crystals +;-------------------------------------------------------------------------------- +; 0x18005F - 0x18005F (unused) ;-------------------------------------------------------------------------------- org $308060 ; PC 0x180060 - 0x18007E ProgrammableItemLogicJump_1: diff --git a/utilities.asm b/utilities.asm index a806d02..c12da75 100644 --- a/utilities.asm +++ b/utilities.asm @@ -593,6 +593,29 @@ HexToDec: PLA RTL +;-------------------------------------------------------------------------------- +; CountBits +; in: A(b) - Byte to count bits in +; out: A(b) - sum of bits +; caller is responsible for setting 8-bit mode and preserving X and Y +;-------------------------------------------------------------------------------- +CountBits: + PHB : PHK : PLB + TAX ; Save a copy of value + LSR #4 ; Shift down hi nybble, Leave <3> in C + TAY ; And save <7:4> in Y + TXA ; Recover value + AND #$07 ; Put out <2:0> in X + TAX ; And save in X + LDA NybbleBitCounts, Y ; Fetch count for Y + ADC NybbleBitCounts, X ; Add count for X & C + PLB +RTL + +; Look up table of bit counts in the values $00-$0F +NybbleBitCounts: +db #00, #01, #01, #02, #01, #02, #02, #03, #01, #02, #02, #03, #02, #03, #03, #04 + ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- From 8f289c8e0a6a1d45c16ecb1bb03a9308f7e34107 Mon Sep 17 00:00:00 2001 From: sporchia Date: Tue, 25 Sep 2018 22:30:06 -0400 Subject: [PATCH 2/5] per feedback --- entrances.asm | 4 +++- goalitem.asm | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/entrances.asm b/entrances.asm index 60f3ca1..9a82970 100644 --- a/entrances.asm +++ b/entrances.asm @@ -12,8 +12,10 @@ LockAgahnimDoors: JSR.w LockAgahnimDoorsCore : RTL + : CMP.w #$0002 : BNE + JSR.w LockAgahnimDoorsCore : BEQ .unlock + SEP #$30 JSL.l CheckEnoughCrystals : BEQ .crystalOrUnlock ; I think the registers might be wrong for this - LDA #$0001 : RTL + REP #$30 + LDA #$0001 : RTL .crystalOrUnlock LDA InvertedMode : AND.w #$00FF : BEQ .unlock diff --git a/goalitem.asm b/goalitem.asm index f177763..bc4c977 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -48,7 +48,7 @@ CheckGanonVulnerability: BRA .success + : CMP #$06 : BNE + ;#$06 = Require "NumberOfCrystalsRequired" Crystals - JSR CheckEnoughCrystals : BNE .fail + JSR CheckEnoughCrystals : BCC .fail BRA .success + .fail : CLC : RTL From afd69068c3c1bc27cd4a0dd51bb78a5e17afc35a Mon Sep 17 00:00:00 2001 From: sporchia Date: Tue, 25 Sep 2018 22:30:46 -0400 Subject: [PATCH 3/5] remove comment --- entrances.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrances.asm b/entrances.asm index 9a82970..c799a4c 100644 --- a/entrances.asm +++ b/entrances.asm @@ -13,7 +13,7 @@ LockAgahnimDoors: + : CMP.w #$0002 : BNE + JSR.w LockAgahnimDoorsCore : BEQ .unlock SEP #$30 - JSL.l CheckEnoughCrystals : BEQ .crystalOrUnlock ; I think the registers might be wrong for this + JSL.l CheckEnoughCrystals : BEQ .crystalOrUnlock REP #$30 LDA #$0001 : RTL .crystalOrUnlock From 8d864cb94660b8f1ac17956596131913e12d0fda Mon Sep 17 00:00:00 2001 From: sporchia Date: Tue, 25 Sep 2018 22:33:17 -0400 Subject: [PATCH 4/5] more feedback --- entrances.asm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrances.asm b/entrances.asm index c799a4c..96149b0 100644 --- a/entrances.asm +++ b/entrances.asm @@ -13,8 +13,9 @@ LockAgahnimDoors: + : CMP.w #$0002 : BNE + JSR.w LockAgahnimDoorsCore : BEQ .unlock SEP #$30 - JSL.l CheckEnoughCrystals : BEQ .crystalOrUnlock + JSL.l CheckEnoughCrystals REP #$30 + BEQ .crystalOrUnlock LDA #$0001 : RTL .crystalOrUnlock LDA InvertedMode : AND.w #$00FF : BEQ .unlock From 71e1a6a43a3edb7c5c88cd22f2d30afd15955a08 Mon Sep 17 00:00:00 2001 From: sporchia Date: Sat, 6 Oct 2018 11:37:32 -0400 Subject: [PATCH 5/5] Crystals selectable 0 and 1 work 0 is not pretty --- LTTP_RND_GeneralBugfixes.asm | 6 ++++++ goalitem.asm | 15 +++++++++++++++ hooks.asm | 6 +++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 8158ebc..043f276 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -476,6 +476,12 @@ Sprite_CheckIfPlayerPreoccupied: org $08C3AE Ancilla_ReceiveItem: +org $08CE93 +Ancilla_BreakTowerSeal_draw_single_crystal: + +org $08CEC3 +Ancilla_BreakTowerSeal_stop_spawning_sparkles: + org $08CF59 BreakTowerSeal_ExecuteSparkles: diff --git a/goalitem.asm b/goalitem.asm index bc4c977..5259fb2 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -56,7 +56,22 @@ CheckGanonVulnerability: ;-------------------------------------------------------------------------------- GetRequriedCrystals: BEQ + : JSL.l BreakTowerSeal_ExecuteSparkles : + ; thing we wrote over + LDA.l NumberOfCrystalsRequired : CMP.b #$00 : BNE + : JML.l Ancilla_BreakTowerSeal_stop_spawning_sparkles : + + LDA.l NumberOfCrystalsRequired : CMP.b #$01 : BNE + : JML.l Ancilla_BreakTowerSeal_draw_single_crystal : + LDA.l NumberOfCrystalsRequired : DEC #2 : TAX +JML.l GetRequriedCrystals_continue +;-------------------------------------------------------------------------------- +GetRequriedCrystalsInX: + LDA.l NumberOfCrystalsRequired : CMP.b #$00 : BNE + + TAX + RTL + + + + TXA : - : CMP.l NumberOfCrystalsRequired : !BLT + : !SUB.l NumberOfCrystalsRequired : BRA - : + + + INC : CMP.l NumberOfCrystalsRequired : BNE + + LDA.b #$08 + + : DEC : TAX RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystals: diff --git a/hooks.asm b/hooks.asm index 2a15520..4e32ef4 100755 --- a/hooks.asm +++ b/hooks.asm @@ -293,8 +293,12 @@ NOP #4 db #$90 ; BCC ;-------------------------------------------------------------------------------- org $08CE0C ; <- 44E0C - ancilla_break_tower_seal.asm : 168 (BEQ #$03 : JSR BreakTowerSeal_ExecuteSparkles : LDX.b #$06) -JSL.l GetRequriedCrystals +JML.l GetRequriedCrystals NOP #3 +GetRequriedCrystals_continue: +;-------------------------------------------------------------------------------- +org $08CF19 ; <- 44F19 - ancilla_break_tower_seal.asm : 336 (TXA : AND.b #$07 : TAX) +JSL.l GetRequriedCrystalsInX ;-------------------------------------------------------------------------------- org $08CFC9 ; <- 44FC9 - ancilla_break_tower_seal.asm : 414 (RTS) db #$6B