diff --git a/events.asm b/events.asm index 5ed8efc..c23e480 100644 --- a/events.asm +++ b/events.asm @@ -245,7 +245,11 @@ PreItemGet: RTL ;-------------------------------------------------------------------------------- PostItemGet: - + STZ.w ShopPurchaseFlag + LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ + + LDX.w CurrentSpriteSlot + STZ.w SpriteMetaData,X + + RTL ;-------------------------------------------------------------------------------- PostItemAnimation: diff --git a/itemdatatables.asm b/itemdatatables.asm index a7c54a2..a9f7b45 100644 --- a/itemdatatables.asm +++ b/itemdatatables.asm @@ -451,7 +451,7 @@ endmacro %SpriteProps($21, 2, 2, $01, $01, PalettesVanilla_red_melon+$0E) ; 21 - Net %SpriteProps($22, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 22 - Blue mail %SpriteProps($23, 2, 2, $01, $01, PalettesVanilla_red_melon+$0E) ; 23 - Red mail -%SpriteProps($24, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; 24 - Small key +%SpriteProps($24, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; 24 - Small key %SpriteProps($25, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 25 - Compass %SpriteProps($26, 2, 2, $01, $01, PalettesVanilla_red_melon+$0E) ; 26 - Heart container from 4/4 %SpriteProps($27, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 27 - Bomb @@ -575,22 +575,22 @@ endmacro %SpriteProps($9D, 2, 2, $04, $04, PalettesVanilla_green_blue_guard+$0E) ; 9D - Big key of Eastern Palace %SpriteProps($9E, 2, 2, $04, $04, PalettesVanilla_green_blue_guard+$0E) ; 9E - Big key of Hyrule Castle %SpriteProps($9F, 2, 2, $04, $04, PalettesVanilla_green_blue_guard+$0E) ; 9F - Big key of Sewers -%SpriteProps($A0, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A0 - Small key of Sewers -%SpriteProps($A1, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A1 - Small key of Hyrule Castle -%SpriteProps($A2, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A2 - Small key of Eastern Palace -%SpriteProps($A3, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A3 - Small key of Desert Palace -%SpriteProps($A4, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A4 - Small key of Agahnim's Tower -%SpriteProps($A5, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A5 - Small key of Swamp Palace -%SpriteProps($A6, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A6 - Small key of Dark Palace -%SpriteProps($A7, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A7 - Small key of Misery Mire -%SpriteProps($A8, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A8 - Small key of Skull Woods -%SpriteProps($A9, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; A9 - Small key of Ice Palace -%SpriteProps($AA, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AA - Small key of Tower of Hera -%SpriteProps($AB, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AB - Small key of Thieves' Town -%SpriteProps($AC, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AC - Small key of Turtle Rock -%SpriteProps($AD, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AD - Small key of Ganon's Tower +%SpriteProps($A0, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A0 - Small key of Sewers +%SpriteProps($A1, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A1 - Small key of Hyrule Castle +%SpriteProps($A2, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A2 - Small key of Eastern Palace +%SpriteProps($A3, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A3 - Small key of Desert Palace +%SpriteProps($A4, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A4 - Small key of Agahnim's Tower +%SpriteProps($A5, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A5 - Small key of Swamp Palace +%SpriteProps($A6, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A6 - Small key of Dark Palace +%SpriteProps($A7, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A7 - Small key of Misery Mire +%SpriteProps($A8, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A8 - Small key of Skull Woods +%SpriteProps($A9, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; A9 - Small key of Ice Palace +%SpriteProps($AA, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; AA - Small key of Tower of Hera +%SpriteProps($AB, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; AB - Small key of Thieves' Town +%SpriteProps($AC, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; AC - Small key of Turtle Rock +%SpriteProps($AD, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; AD - Small key of Ganon's Tower %SpriteProps($AE, 2, 2, $02, $02, $0000) ; AE - Reserved -%SpriteProps($AF, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AF - Generic small key +%SpriteProps($AF, 0, 0, $02, $04, PalettesVanilla_blue_ice+$0E) ; AF - Generic small key %SpriteProps($B0, 2, 2, $80, $80, PalettesCustom_crystal) ; B0 - Crystal 6 %SpriteProps($B1, 2, 2, $80, $80, PalettesCustom_crystal) ; B1 - Crystal 1 %SpriteProps($B2, 2, 2, $80, $80, PalettesCustom_crystal) ; B2 - Crystal 5 diff --git a/newitems.asm b/newitems.asm index 3158415..5bd3b6b 100644 --- a/newitems.asm +++ b/newitems.asm @@ -131,7 +131,6 @@ AddReceivedItemExpandedGetItem: SEP #$30 PLB : PLX - STZ.w ShopPurchaseFlag LDA.w ItemReceiptMethod : CMP.b #$01 ; thing we wrote over RTL @@ -272,13 +271,11 @@ ItemBehavior: RTS .bow - LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking BIT #$40 : BNE .silversbow LDA.b #$01 : STA.l BowEquipment RTS .silversbow - LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking LDA.l SilverArrowsUseRestriction : BNE + LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking LDA.b #03 : STA.l BowEquipment ; set bow to silver @@ -322,7 +319,6 @@ ItemBehavior: JMP.w .increment_map .bow_and_arrows - LDA.b #$80 : ORA.l BowTracking : STA.l BowTracking LDA.l BowTracking : BIT.b #$40 : BEQ .no_silvers LDA.l SilverArrowsUseRestriction : BNE .no_silvers LDA.l CurrentArrows : BEQ + @@ -342,7 +338,6 @@ ItemBehavior: RTS .silver_bow - LDA.b #$80 : ORA.l BowTracking : STA.l BowTracking LDA.l SilverArrowsUseRestriction : BNE .noequip LDA.b #$40 : ORA.l BowTracking : STA.l BowTracking LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ .noequip @@ -719,7 +714,7 @@ ResolveLootID: .magic SEP #$20 LDA.l MagicConsumption : TAX - LDA.w ResolveLootID_magic_ids,X + LDA.w .magic_ids,X JMP.w .have_item ..ids db $4E, $4F, $4F @@ -732,7 +727,7 @@ ResolveLootID: JMP.w .get_item + TAX - LDA.w ResolveLootID_prog_sword_ids,X + LDA.w .prog_sword_ids,X JMP.w .have_item ..ids db $49, $50, $02, $03, $03 @@ -745,7 +740,7 @@ ResolveLootID: JMP.w .get_item + TAX - LDA.w ResolveLootID_shields_ids,X + LDA.w .shields_ids,X JMP.w .have_item ..ids db $04, $05, $06, $06 @@ -758,7 +753,7 @@ ResolveLootID: JMP.w .get_item + TAX - LDA.w ResolveLootID_armor_ids,X + LDA.w .armor_ids,X JMP.w .have_item ..ids db $22, $23, $23 @@ -767,29 +762,39 @@ ResolveLootID: .gloves SEP #$20 LDA.l GloveEquipment : TAX - LDA.w ResolveLootID_gloves_ids,X + LDA.w .gloves_ids,X JMP.w .have_item ..ids db $1B, $1C, $1C .progressive_bow - SEP #$20 + ; For non-chest progressive bows we assign the tracking bits to SpriteMetaData,X + ; (where X is that sprite's slot) so the bit can be set on pickup. + SEP #$30 LDA.l BowEquipment : INC : LSR : CMP.l ProgressiveBowLimit : BCC + LDA.l ProgressiveBowReplacement JMP.w .get_item + + LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ + + LDX.w CurrentSpriteSlot + LDA.b #$10 : STA.w SpriteMetaData,X + + LDA.l BowEquipment : TAX - LDA.w ResolveLootID_bows_ids,X + LDA.w .bows_ids,X JMP.w .get_item .progressive_bow_2 - SEP #$20 + SEP #$30 LDA.l BowEquipment : INC : LSR : CMP.l ProgressiveBowLimit : BCC + LDA.l ProgressiveBowReplacement JMP.w .get_item + + LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ + + LDX.w CurrentSpriteSlot + LDA.b #$20 : STA.w SpriteMetaData,X + + LDA.l BowEquipment : TAX - LDA.w ResolveLootID_bows_ids,X + LDA.w .bows_ids,X JMP.w .get_item .bows @@ -845,17 +850,33 @@ PotionListExpanded: ;-------------------------------------------------------------------------------- HandleBowTracking: ; In: A - Item Receipt ID + PHA CMP.b #$64 : BEQ .prog_one CMP.b #$65 : BEQ .prog_two + CMP.b #$0B : BEQ .vanilla_bow + CMP.b #$3A : BEQ .vanilla_bow + CMP.b #$3B : BEQ .vanilla_bow + PLA RTS .prog_one - LDA.b #$90 + LDA.b #$10 BRA .done .prog_two - LDA.b #$A0 + LDA.b #$20 + BRA .done + .vanilla_bow + ; A non-chest progressive bow will always have been resolved to a vanilla bow ID + ; at this point. + LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ + + LDX.w CurrentSpriteSlot + LDA.w SpriteMetaData,X : BEQ + + BRA .done + + + LDA.b #$00 .done - ORA.l BowTracking : STA.l BowTracking - LDA.w ItemReceiptID + ORA.b #$80 : ORA.l BowTracking + STA.l BowTracking + PLA RTS ;-------------------------------------------------------------------------------- ;Return BowEquipment but also draw silver arrows if you have the upgrade even if you don't have the bow diff --git a/ram.asm b/ram.asm index bd89cbf..e68c886 100644 --- a/ram.asm +++ b/ram.asm @@ -193,7 +193,8 @@ ShopPurchaseFlag = $7E0224 ; $01 = Shop purchase item receipt. ItemStackPtr = $7E0226 ; Pointer into Item GFX and VRAM target queues. Word length. ; If not zero, pointer should always be left pointing at the ; next available slot in the stack during the frame. -SpriteID = $7E0230 ; 0x0A bytes. Receipt ID for main loop sprite we're handling. +SpriteID = $7E0230 ; 0x10 bytes. Receipt ID for main loop sprite we're handling. +SpriteMetaData = $7E0240 ; 0x10 bytes. Sprite metadata. Used for prog bow tracking. AncillaVelocityZ = $7E0294 ; 0x0A bytes AncillaZCoord = $7E029E ; 0x0A bytes ;