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 + ;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------