diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 1c4bc96..aa17c3a 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -80,6 +80,7 @@ incsrc treekid.asm incsrc spriteswap.asm incsrc hashalphabethooks.asm incsrc sharedplayerpalettefix.asm +incsrc ram.asm incsrc sram.asm ;org $208000 ; bank #$20 diff --git a/bugfixes.asm b/bugfixes.asm index 1dcaa05..46d9d7b 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -214,3 +214,9 @@ FixJingleGlitch: .exit RTL +;-------------------------------------------------------------------------------- +; Fix spawning with more hearts than capacity when less than 3 heart containers +pushpc + org $09F4AC ; <- module_death.asm:331 + db $08, $08, $10 +pullpc diff --git a/compasses.asm b/compasses.asm index 1da7368..62d24f9 100644 --- a/compasses.asm +++ b/compasses.asm @@ -5,11 +5,11 @@ ; HexToDec when drawing the "??/XX" item counter ; %DrawConstantNumber(1,4) draws 14 ;-------------------------------------------------------------------------------- -macro DrawConstantNumber(digit1,digit2) - LDA.w #$2490+ : STA $7EC79A - LDA.w #$2490+ : STA $7EC79C - SEP #$20 -endmacro +;macro DrawConstantNumber(digit1,digit2) +; LDA.w #$2490+ : STA $7EC79A +; LDA.w #$2490+ : STA $7EC79C +; SEP #$20 +;endmacro ;-------------------------------------------------------------------------------- DrawDungeonCompassCounts: @@ -27,12 +27,23 @@ DrawDungeonCompassCounts: BEQ .done ; skip if we don't have compass ++ - JMP (CompassCountDungeonHandlers, X) : .return_spot - - ; we switch to 8-bit A in the jump before this + LDA $040C : LSR + BNE + + INC + + + TAX : LDA.l CompassTotalsWRAM, X : AND #$00FF + SEP #$20 + JSR HudHexToDec2Digit + REP #$20 + PHX + LDX.b $06 : TXA : ORA #$2400 : STA $7EC79A + LDX.b $07 : TXA : ORA #$2400 : STA $7EC79C + PLX + + LDA DungeonLocationsChecked-1, X : AND #$00FF + SEP #$20 JSR HudHexToDec2Digit REP #$20 - LDX.b $06 : TXA : ORA #$2400 : STA $7EC794 ; Draw the item count LDX.b $07 : TXA : ORA #$2400 : STA $7EC796 @@ -45,76 +56,76 @@ DungeonItemMasks: ; these are dungeon correlations to $7EF364 - $7EF369 so it kn dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 dw $0080, $0040, $0020, $0010, $0008, $0004 -CompassCountDungeonHandlers: ; pointers to functions that handle dungeon-specific code - dw CompassCount_Escape, CompassCount_Escape ; (hyrule castle, sewers) - dw CompassCount_Eastern, CompassCount_Desert, CompassCount_Agah - dw CompassCount_Swamp, CompassCount_PoD, CompassCount_Mire - dw CompassCount_Skull, CompassCount_Ice, CompassCount_Hera - dw CompassCount_Thieves, CompassCount_Trock, CompassCount_Gt -} - -CompassCount_Escape: - %DrawConstantNumber(0,8) - LDA SewersLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Eastern: - %DrawConstantNumber(0,6) - LDA EPLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Desert: - %DrawConstantNumber(0,6) - LDA DPLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Agah: - %DrawConstantNumber(0,2) - LDA CTLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Swamp: - %DrawConstantNumber(1,0) - LDA SPLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_PoD: - %DrawConstantNumber(1,4) - LDA PDLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Mire: - %DrawConstantNumber(0,8) - LDA MMLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Skull: - %DrawConstantNumber(0,8) - LDA SWLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Ice: - %DrawConstantNumber(0,8) - LDA IPLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Hera: - %DrawConstantNumber(0,6) - LDA THLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Thieves: - %DrawConstantNumber(0,8) - LDA TTLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Trock: - %DrawConstantNumber(1,2) - LDA TRLocations - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Gt: - %DrawConstantNumber(2,7) - LDA GTLocations - JMP DrawDungeonCompassCounts_return_spot - +;CompassCountDungeonHandlers: ; pointers to functions that handle dungeon-specific code +; dw CompassCount_Escape, CompassCount_Escape ; (hyrule castle, sewers) +; dw CompassCount_Eastern, CompassCount_Desert, CompassCount_Agah +; dw CompassCount_Swamp, CompassCount_PoD, CompassCount_Mire +; dw CompassCount_Skull, CompassCount_Ice, CompassCount_Hera +; dw CompassCount_Thieves, CompassCount_Trock, CompassCount_Gt +;} +; +;CompassCount_Escape: +; %DrawConstantNumber(0,8) +; LDA SewersLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Eastern: +; %DrawConstantNumber(0,6) +; LDA EPLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Desert: +; %DrawConstantNumber(0,6) +; LDA DPLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Agah: +; %DrawConstantNumber(0,2) +; LDA CTLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Swamp: +; %DrawConstantNumber(1,0) +; LDA SPLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_PoD: +; %DrawConstantNumber(1,4) +; LDA PDLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Mire: +; %DrawConstantNumber(0,8) +; LDA MMLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Skull: +; %DrawConstantNumber(0,8) +; LDA SWLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Ice: +; %DrawConstantNumber(0,8) +; LDA IPLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Hera: +; %DrawConstantNumber(0,6) +; LDA THLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Thieves: +; %DrawConstantNumber(0,8) +; LDA TTLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Trock: +; %DrawConstantNumber(1,2) +; LDA TRLocations +; JMP DrawDungeonCompassCounts_return_spot +; +;CompassCount_Gt: +; %DrawConstantNumber(2,7) +; LDA GTLocations +; JMP DrawDungeonCompassCounts_return_spot +; diff --git a/events.asm b/events.asm index 28afe9e..ec22500 100644 --- a/events.asm +++ b/events.asm @@ -21,9 +21,10 @@ OnDrawHud: JSL.l PollService JML.l ReturnFromOnDrawHud ;-------------------------------------------------------------------------------- -;OnDungeonEntrance: -; STA $7EC172 ; thing we wrote over -;RTL +OnDungeonEntrance: + STA $7EC172 ; thing we wrote over + JSL MaybeFlagCompassTotalEntrance +RTL ;-------------------------------------------------------------------------------- OnPlayerDead: PHA diff --git a/hooks.asm b/hooks.asm index 61caee3..8584242 100755 --- a/hooks.asm +++ b/hooks.asm @@ -41,8 +41,8 @@ ReturnCheckZSNES: ;================================================================================ ; Dungeon Entrance Hook (works, but not needed at the moment) ;-------------------------------------------------------------------------------- -;org $02D8C7 ; <- 158C7 - Bank02.asm : 10981 (STA $7EC172) -;JSL.l OnDungeonEntrance +org $02D8C7 ; <- 158C7 - Bank02.asm : 10981 (STA $7EC172) +JSL.l OnDungeonEntrance ;-------------------------------------------------------------------------------- ;================================================================================ diff --git a/init.asm b/init.asm index b774183..fd7e598 100644 --- a/init.asm +++ b/init.asm @@ -67,5 +67,15 @@ Init_PostRAMClear: JSL MSUInit JSL InitRNGPointerTable + JSR InitCompassTotalsRAM JML $00D463 ; The original target of the jump table that we hijacked + +;-------------------------------------------------------------------------------- +InitCompassTotalsRAM: + LDX #$00 + - + LDA CompassTotalsROM, X : STA CompassTotalsWRAM, X + INX + CPX #$0F : !BLT - +RTS diff --git a/inventory.asm b/inventory.asm index 4851e73..cc62692 100644 --- a/inventory.asm +++ b/inventory.asm @@ -196,7 +196,6 @@ FullInventoryExternal: ;-------------------------------------------------------------------------------- AddInventory: PHA : PHX : PHP - PHA : LDA DummyValue : PLA CPY.b #$0C : BNE + ; Blue Boomerang LDA InventoryTracking : ORA #$80 : STA InventoryTracking JMP .incrementCounts @@ -434,6 +433,7 @@ AddInventory: JSR .incrementKey JMP .done + CPY.b #$25 : BNE + ; Compass + JSL MaybeFlagCompassTotalPickup JSR .incrementCompass JMP .done + CPY.b #$26 : BNE + ; Liar Heart (Container) @@ -546,6 +546,7 @@ AddInventory: JMP .done + CPY.b #$80 : !BLT + ; Items $80 - $8F - Free Compasses CPY.b #$90 : !BGE + + JSL MaybeFlagCompassTotalPickup JSR .incrementCompass JMP .done + CPY.b #$90 : !BLT + ; Items $90 - $9F - Free Big Keys diff --git a/newitems.asm b/newitems.asm index b80f91d..286103e 100755 --- a/newitems.asm +++ b/newitems.asm @@ -1120,3 +1120,49 @@ ChestPrep: SEC RTL ;-------------------------------------------------------------------------------- +; Set a flag in SRAM if we pick up a compass in its own dungeon with HUD compass +; counts on +MaybeFlagCompassTotalPickup: + LDA CompassMode : BEQ .done + LDA $040C : CMP #$FF : BEQ .done + LSR : STA $04 : LDA #$0F : !SUB $04 ; Compute flag "index" + CPY #$25 : BEQ .setFlag ; Set flag if it's a compass for this dungeon + STA $04 + TYA : AND #$0F : CMP $04 : BNE .done ; Check if compass is for this dungeon + .setFlag + CMP #$08 : !BGE ++ + %ValueShift() + ORA CompassCountDisplay : STA CompassCountDisplay + BRA .done + ++ + !SUB #$08 + %ValueShift() + BIT.b #$C0 : BEQ + : LDA.b #$C0 : + ; Make Hyrule Castle / Sewers Count for Both + ORA CompassCountDisplay+1 : STA CompassCountDisplay+1 + .done +RTL +;-------------------------------------------------------------------------------- +; Set the compass count display flag if we're entering a dungeon and alerady have +; that compass +MaybeFlagCompassTotalEntrance: + LDX $040C : CPX #$FF : BEQ .done ; Skip if we're not entering dungeon + LDA CompassMode : BEQ .done ; Skip if we're not showing compass counts + CMP.w #$0002 : BEQ .countShown + LDA CompassField : AND.l DungeonItemMasks, X : BEQ .done ; skip if we don't have compass + .countShown + SEP #$20 + TXA : LSR : STA.b $04 : LDA.b #$0F : !SUB $04 ; Compute flag "index" + CMP #$08 : !BGE ++ + %ValueShift() + ORA CompassCountDisplay : STA CompassCountDisplay + REP #$20 + BRA .done + ++ + !SUB #$08 + %ValueShift() + BIT.b #$C0 : BEQ + : LDA.b #$C0 : + ; Make Hyrule Castle / Sewers Count for Both + ORA CompassCountDisplay+1 : STA CompassCountDisplay+1 + REP #$20 + .done +RTL +;-------------------------------------------------------------------------------- diff --git a/ram.asm b/ram.asm new file mode 100644 index 0000000..3510b8f --- /dev/null +++ b/ram.asm @@ -0,0 +1,18 @@ +;================================================================================ +; RAM Labels & Assertions +;-------------------------------------------------------------------------------- +; Labels for values in WRAM and assertions that ensure they're correct and +; at the expected addresses. All values larger than one byte are little endian. +;-------------------------------------------------------------------------------- +; Placeholder and for compass item max count allocations, still WIP +;-------------------------------------------------------------------------------- +CompassTotalsWRAM = $7F5410 + +;================================================================================ +; RAM Assertions +;-------------------------------------------------------------------------------- +macro assertRAM(label, address) + assert