diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 095ecc4..802931a 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -26,7 +26,7 @@ org $3FFFFF ; <- 1FFFFF db #$00 ; expand file to 2mb org $1FFFF8 ; <- FFFF8 timestamp rom -db #$20, #$18, #$01, #$17 ; year/month/day +db #$20, #$18, #$01, #$18 ; year/month/day ;================================================================================ @@ -65,6 +65,10 @@ db #$20, #$18, #$01, #$17 ; year/month/day !FORCE_HEART_SPAWN = "$7F5033"; !SKIP_HEART_SAVE = "$7F5034"; +!INVENTORY_SWAP = "$7EF38C" +!INVENTORY_SWAP_2 = "$7EF38E" + +!ITEM_LIMIT_COUNTS = "$7EF390" ;================================================================================ incsrc hooks.asm diff --git a/goalitem.asm b/goalitem.asm index 670c5aa..6e6391f 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -2,34 +2,36 @@ ; $7F5010 - Scratch Space (Callee Preserved) ;-------------------------------------------------------------------------------- !GOAL_COUNTER = "$7EF460" +!DRAW_ADDRESS = "$7EC72A" DrawGoalIndicator: LDA.l GoalItemRequirement : AND.w #$00FF : BNE + : RTL : + ; Star Meter PHX LDX.w #$0000 - LDA.l GoalItemIcon : STA $7EC72C, X : INX #2 ; draw star icon and move the cursor + LDA.l GoalItemIcon : STA !DRAW_ADDRESS, X : INX #2 ; draw star icon and move the cursor LDA.l !GOAL_COUNTER AND.w #$00FF JSL.l HexToDec - LDA $7F5005 : AND.w #$00FF : ORA.w #$2400 : STA $7EC72C, X : INX #2 ; draw 10's digit and move the cursor - LDA $7F5006 : AND.w #$00FF : ORA.w #$2400 : STA $7EC72C, X : INX #2 ; draw 10's digit and move the cursor - LDA $7F5007 : AND.w #$00FF : ORA.w #$2400 : STA $7EC72C, X : INX #2 ; draw 1's and move the cursor + LDA $7F5005 : AND.w #$00FF : ORA.w #$2400 : STA !DRAW_ADDRESS, X : INX #2 ; draw 100's digit and move the cursor + LDA $7F5006 : AND.w #$00FF : ORA.w #$2400 : STA !DRAW_ADDRESS, X : INX #2 ; draw 10's digit and move the cursor + LDA $7F5007 : AND.w #$00FF : ORA.w #$2400 : STA !DRAW_ADDRESS, X : INX #2 ; draw 1's and move the cursor LDA.l GoalItemRequirement : AND.w #$00FF : CMP.w #$00FF : BEQ .skip - LDA.w #$2830 : STA $7EC72C, X : INX #2 ; draw slash and move the cursor + LDA.w #$2830 : STA !DRAW_ADDRESS, X : INX #2 ; draw slash and move the cursor LDA.l GoalItemRequirement AND.w #$00FF JSL.l HexToDec - LDA $7F5006 : AND.w #$00FF : ORA.w #$2400 : STA $7EC72C, X : INX #2 ; draw 10's digit and move the cursor - LDA $7F5007 : AND.w #$00FF : ORA.w #$2400 : STA $7EC72C, X : INX #2 ; draw 1's and move the cursor + LDA $7F5005 : AND.w #$00FF : ORA.w #$2400 : STA !DRAW_ADDRESS, X : INX #2 ; draw 100's digit and move the cursor + LDA $7F5006 : AND.w #$00FF : ORA.w #$2400 : STA !DRAW_ADDRESS, X : INX #2 ; draw 10's digit and move the cursor + LDA $7F5007 : AND.w #$00FF : ORA.w #$2400 : STA !DRAW_ADDRESS, X : INX #2 ; draw 1's and move the cursor BRA .done .skip LDA.w #$207F - STA $7EC72C, X : INX # - STA $7EC72C, X : INX # - STA $7EC72C, X : INX # + STA !DRAW_ADDRESS, X : INX # + STA !DRAW_ADDRESS, X : INX # + STA !DRAW_ADDRESS, X : INX # .done PLX RTL diff --git a/hooks.asm b/hooks.asm index 1bf7510..06766c2 100644 --- a/hooks.asm +++ b/hooks.asm @@ -1042,11 +1042,11 @@ JSL.l GetMagicBatItem ;================================================================================ ; Replacement Shopkeeper ;-------------------------------------------------------------------------------- -org $068BEB ; <- 30BEB - Bank07.asm:1125 - (INC $0BA0, X) -JSL.l SpritePrep_ShopKeeper : RTS +;org $068BEB ; <- 30BEB - Bank07.asm:1125 - (INC $0BA0, X) +;JSL.l SpritePrep_ShopKeeper : RTS ;-------------------------------------------------------------------------------- -org $1EEEE3 ; <- F6EE3 - sprite_shopkeeper.asm:7 - (LDA $0E80, X) -JSL.l Sprite_ShopKeeper : RTS +;org $1EEEE3 ; <- F6EE3 - sprite_shopkeeper.asm:7 - (LDA $0E80, X) +;JSL.l Sprite_ShopKeeper : RTS ;-------------------------------------------------------------------------------- ;================================================================================ diff --git a/newitems.asm b/newitems.asm index 472dda1..97f693a 100755 --- a/newitems.asm +++ b/newitems.asm @@ -348,7 +348,14 @@ AddReceivedItemExpanded: { PHA : PHX JSL.l PreItemGet - LDA $02D8 : CMP.b #$16 : BNE ++ ; Bottle + + LDA $02D8 ; Item Value + JSR AttemptItemSubstitution + STA $02D8 + + JSR IncrementItemCounters + + CMP.b #$16 : BNE ++ ; Bottle JSR.w CountBottles : CMP.l BottleLimit : !BLT +++ LDA.l BottleLimitReplacement : STA $02D8 +++ : BRL .done @@ -780,7 +787,7 @@ Link_ReceiveItemAlternatesExpanded: db -1 ; Master Sword (Safe) db -1, -1, -1, -1 ; +5/+10 Bomb Arrows db -1, -1, -1 ; 3x Programmable Item - db -1 ; Upgrade-Only Sivler Arrows + db -1 ; Upgrade-Only Silver Arrows db -1 ; 1 Rupoor db -1 ; Null Item db -1, -1, -1 ; Red, Blue & Green Clocks @@ -801,7 +808,10 @@ Link_ReceiveItemAlternatesExpanded: ;-------------------------------------------------------------------------------- .loadAlternate PHB : PHK : PLB - LDA Link_ReceiveItemAlternatesExpanded, Y : STA $03 + ;TYA : JSR IncrementItemCounters + ;LDA Link_ReceiveItemAlternatesExpanded, Y : STA $03 + TYA : JSR AttemptItemSubstitution : STA $03 + CPY $03 : BNE + : LDA.b #$FF : STA $03 : + PLB RTL ;-------------------------------------------------------------------------------- @@ -915,6 +925,49 @@ GetRNGItemMulti: TAX : XBA : LDA.l RNGMultiItemTable, X RTL ;-------------------------------------------------------------------------------- +IncrementItemCounters: + PHX : PHA + LDX.b #$00 + - + LDA.l ItemSubstitutionRules, X + CMP.b #$FF : BEQ .exit + CMP 1,s : BNE .noMatch + .match + PHX + TXA : LSR #2 : TAX + LDA !ITEM_LIMIT_COUNTS, X : INC : STA !ITEM_LIMIT_COUNTS, X + PLX + BEQ .exit + .noMatch + INX #4 + BRA - + .exit + PLA : PLX +RTS +;-------------------------------------------------------------------------------- +AttemptItemSubstitution: + PHX : PHA + LDX.b #$00 + - + LDA.l ItemSubstitutionRules, X + CMP.b #$FF : BEQ .exit + CMP 1,s : BNE .noMatch + .match + PHX + TXA : LSR #2 : TAX + LDA !ITEM_LIMIT_COUNTS, X + CMP.l ItemSubstitutionRules+1, X : !BLT + + LDA.l ItemSubstitutionRules+2, X : STA 2,s + + + PLX + BEQ .exit + .noMatch + INX #4 + BRA - +.exit + PLA : PLX +RTS +;-------------------------------------------------------------------------------- CountBottles: LDX.b #$00 LDA $7EF35C : BEQ ++ : INX diff --git a/stats.asm b/stats.asm index c9e293b..3dd8784 100644 --- a/stats.asm +++ b/stats.asm @@ -189,8 +189,10 @@ DungeonStairsTransition: JSL Dungeon_SaveRoomQuadrantData BRA StatTransitionCounter DungeonExitTransition: - JSL Player_HaltDashAttackLong - LDA.b #$00 : STA $0301 ; stop item dashing + LDA $7F50C7 : BEQ + ; ice physics + JSL Player_HaltDashAttackLong + LDA.b #$00 : STA $0301 ; stop item dashing + + LDA.b #$0F : STA $10 ; stop running through the transition StatTransitionCounter: PHA : PHP diff --git a/tables.asm b/tables.asm index a6d6e02..3526799 100644 --- a/tables.asm +++ b/tables.asm @@ -691,7 +691,7 @@ StandingKey_Hera: ;================================================================================ org $308165 ; PC 0x180165 GoalItemIcon: -dw #$280E ; #$280D = Star (default) - #$280E = Triforce Piece +dw #$280E ; #$280D = Star - #$280E = Triforce Piece (default) ;================================================================================ org $308167 ; PC 0x180167 GoalItemRequirement: @@ -1347,3 +1347,9 @@ dw $0000, $0000, $0000, $0000, $F800, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000 ;=============================================================================== +org $30C000 ; PC 0x184000 - 0x184007 +ItemSubstitutionRules: +;db [item][quantity][substitution][pad] +db $12, $01, $35, $FF +db $FF, $FF, $FF, $FF +;================================================================================ \ No newline at end of file diff --git a/utilities.asm b/utilities.asm index 0811f8a..3b6a638 100644 --- a/utilities.asm +++ b/utilities.asm @@ -8,7 +8,7 @@ ; out: A - Sprite GFX ID ;-------------------------------------------------------------------------------- GetSpriteID: - + JSR AttemptItemSubstitution CMP.b #$16 : BEQ .bottle ; Bottle CMP.b #$2B : BEQ .bottle ; Red Potion w/bottle CMP.b #$2C : BEQ .bottle ; Green Potion w/bottle @@ -143,7 +143,7 @@ RTL ; out: A - Palette ;-------------------------------------------------------------------------------- GetSpritePalette: - + JSR AttemptItemSubstitution CMP.b #$16 : BEQ .bottle ; Bottle CMP.b #$2B : BEQ .bottle ; Red Potion w/bottle CMP.b #$2C : BEQ .bottle ; Green Potion w/bottle @@ -265,7 +265,7 @@ RTL IsNarrowSprite: PHA : PHX PHB : PHK : PLB - + JSR AttemptItemSubstitution ;-------- CMP.b #$16 : BEQ .bottle ; Bottle CMP.b #$2B : BEQ .bottle ; Red Potion w/bottle