diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index b489c08..466b57a 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -478,6 +478,15 @@ Sprite_CheckIfPlayerPreoccupied: org $08C3AE Ancilla_ReceiveItem: +org $08CE93 +Ancilla_BreakTowerSeal_draw_single_crystal: + +org $08CEC3 +Ancilla_BreakTowerSeal_stop_spawning_sparkles: + +org $08CF59 +BreakTowerSeal_ExecuteSparkles: + org $08F710 Ancilla_SetOam_XY_Long: diff --git a/entrances.asm b/entrances.asm index b84417d..96149b0 100644 --- a/entrances.asm +++ b/entrances.asm @@ -12,8 +12,11 @@ LockAgahnimDoors: JSR.w LockAgahnimDoorsCore : RTL + : CMP.w #$0002 : BNE + JSR.w LockAgahnimDoorsCore : BEQ .unlock - LDA $7EF37A : AND.w #$007F : CMP.w #$007F : BEQ .crystalOrUnlock - LDA #$0001 : RTL + SEP #$30 + JSL.l CheckEnoughCrystals + REP #$30 + BEQ .crystalOrUnlock + LDA #$0001 : RTL .crystalOrUnlock LDA InvertedMode : AND.w #$00FF : BEQ .unlock diff --git a/goalitem.asm b/goalitem.asm index 6f5765f..5259fb2 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -46,7 +46,43 @@ 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 : BCC .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 : 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: + 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 e67feeb..8011b52 100755 --- a/hooks.asm +++ b/hooks.asm @@ -323,6 +323,25 @@ 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) +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 +;-------------------------------------------------------------------------------- ;================================================================================ ; Hash Key Display diff --git a/tables.asm b/tables.asm index 1c89fb8..761ac66 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 + ;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------