From 1c0c82a510ed97030dc2dbf85e5b19ab93359213 Mon Sep 17 00:00:00 2001 From: Kevin Cathcart Date: Sat, 3 Aug 2019 11:55:40 -0400 Subject: [PATCH] consolidate ganon defeat logic --- goalitem.asm | 25 ++++++++----------------- hooks.asm | 6 +++--- tables.asm | 5 ++--- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/goalitem.asm b/goalitem.asm index 1386ce7..fc80fa8 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -34,34 +34,30 @@ CheckGanonVulnerability: LDA $7EF2DB : AND.b #$20 : CMP #$20 : BNE .fail ; require aga2 defeated (pyramid hole open) BRA .success + : CMP #$04 : BNE + - ;#$04 = Require All Crystals - LDA $7EF37A : AND.b #$7F : CMP #$7F : BNE .fail ; require all crystals + ;#$04 = Require Crystals + JSL CheckEnoughCrystalsForGanon : !BLT .fail ; require specified number of crystals BRA .success + : CMP #$03 : BNE + - ;#$03 = Require All Crystals and Aga 2 - LDA $7EF37A : AND.b #$7F : CMP #$7F : BNE .fail ; require all crystals + ;#$03 = Require Crystals and Aga 2 + JSL CheckEnoughCrystalsForGanon : !BLT .fail ; require specified number of crystals LDA $7EF2DB : AND.b #$20 : CMP #$20 : BNE .fail ; require aga2 defeated (pyramid hole open) BRA .success + : CMP #$05 : BNE + ;#$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 "NumberOfCrystalsRequiredForGanon" Crystals - JSL CheckEnoughCrystalsForGanon : BCC .fail - BRA .success - + + + .fail : CLC : RTL .success : SEC : RTL ;-------------------------------------------------------------------------------- -GetRequriedCrystalsForTower: +GetRequiredCrystalsForTower: BEQ + : JSL.l BreakTowerSeal_ExecuteSparkles : + ; thing we wrote over LDA.l NumberOfCrystalsRequiredForTower : CMP.b #$00 : BNE + : JML.l Ancilla_BreakTowerSeal_stop_spawning_sparkles : + LDA.l NumberOfCrystalsRequiredForTower : CMP.b #$01 : BNE + : JML.l Ancilla_BreakTowerSeal_draw_single_crystal : + LDA.l NumberOfCrystalsRequiredForTower : DEC #2 : TAX -JML.l GetRequriedCrystalsForTower_continue +JML.l GetRequiredCrystalsForTower_continue ;-------------------------------------------------------------------------------- -GetRequriedCrystalsInX: +GetRequiredCrystalsInX: LDA.l NumberOfCrystalsRequiredForTower : CMP.b #$00 : BNE + TAX RTL @@ -75,16 +71,11 @@ GetRequriedCrystalsInX: RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForGanon: - LDA InvincibleGanon : CMP #$06 : BNE .normal PHX : PHY LDA $7EF37A : JSL CountBits ; the comparison is against 1 less PLY : PLX CMP.l NumberOfCrystalsRequiredForGanon RTL - - .normal - LDA $7EF37A : AND.b #$7F : CMP.b #$7F ; thing we wrote over -RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForTower: PHX : PHY diff --git a/hooks.asm b/hooks.asm index c6df31c..e687db7 100755 --- a/hooks.asm +++ b/hooks.asm @@ -380,12 +380,12 @@ NOP #4 db #$90 ; BCC ;-------------------------------------------------------------------------------- org $08CE0C ; <- 44E0C - ancilla_break_tower_seal.asm : 168 (BEQ #$03 : JSR BreakTowerSeal_ExecuteSparkles : LDX.b #$06) -JML.l GetRequriedCrystalsForTower +JML.l GetRequiredCrystalsForTower NOP #3 -GetRequriedCrystalsForTower_continue: +GetRequiredCrystalsForTower_continue: ;-------------------------------------------------------------------------------- org $08CF19 ; <- 44F19 - ancilla_break_tower_seal.asm : 336 (TXA : AND.b #$07 : TAX) -JSL.l GetRequriedCrystalsInX +JSL.l GetRequiredCrystalsInX ;-------------------------------------------------------------------------------- org $08CFC9 ; <- 44FC9 - ancilla_break_tower_seal.asm : 414 (RTS) db #$6B diff --git a/tables.asm b/tables.asm index ea12aac..d9e8d86 100644 --- a/tables.asm +++ b/tables.asm @@ -150,10 +150,9 @@ db #$00 ; #$00 = Off (default) ; #$01 = On ; #$02 = Require All Dungeons -; #$03 = Require Crystals and Aga2 -; #$04 = Require Crystals +; #$03 = Require "NumberOfCrystalsRequiredForGanon" Crystals and Aga2 +; #$04 = Require "NumberOfCrystalsRequiredForGanon" Crystals ; #$05 = Require 100 Goal Items -; #$06 = Require "NumberOfCrystalsRequiredForGanon" ;-------------------------------------------------------------------------------- org $30803F ; PC 0x18003F HammerableGanon: