diff --git a/heartpieces.asm b/heartpieces.asm index 26f07d7..6264ca9 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -5,30 +5,16 @@ HeartPieceGet: PHX : PHY LDY.w SpriteItemType, X ; load item value into Y register BNE + - ; if for any reason the item value is 0 reload it, just in case JSL.l LoadHeartPieceRoomValue : TAY + JSL.l MaybeMarkDigSpotCollected - .skipLoad - - - CPY.b #$26 : BNE .notHeart ; don't add a 1/4 heart if it's not a heart piece - LDA.l HeartPieceQuarter : INC A : AND.b #$03 : STA.l HeartPieceQuarter : BNE .unfinished_heart ; add up heart quarters - BRA .giveItem - - .notHeart - .giveItem + CPY.b #$26 : BNE .not_heart ; don't add a 1/4 heart if it's not a heart piece + LDA.l HeartPieceQuarter : INC A : AND.b #$03 : STA.l HeartPieceQuarter + .not_heart JSL.l $8791B3 ; Player_HaltDashAttackLong STZ.w ItemReceiptMethod ; 0 = Receiving item from an NPC or message - JSL.l Link_ReceiveItem - CLC ; return false - JMP .done ; finished - - .unfinished_heart - SEC ; return true - .done JSL MaybeUnlockTabletAnimation PLY : PLX @@ -36,10 +22,8 @@ RTL ;-------------------------------------------------------------------------------- HeartContainerGet: PHX : PHY - JSL.l AddInventory_incrementBossSwordLong - LDY.w SpriteItemType, X ; load item value into Y register - BNE + - ; if for any reason the item value is 0 reload it, just in case + JSL.l IncrementBossSword + LDY.w SpriteItemType, X : BNE + JSL.l LoadHeartContainerRoomValue : TAY + BRA HeartPieceGet_skipLoad diff --git a/hooks.asm b/hooks.asm index 617eb55..460cf50 100755 --- a/hooks.asm +++ b/hooks.asm @@ -1744,7 +1744,7 @@ JSL DialogResetSelectionIndex ;---------------------------------------------------- ;-- Agahnim 1 Defeated org $868475 ; <- 30475 Bank06.asm : 762 - (JSL Sprite_ShowMessageMinimal) -JSL AddInventory_incrementBossSwordLong +JSL IncrementBossSword ;---------------------------------------------------------- ;-- We'll take your sword org $86B4F3 ; <- 334F3 sprite_smithy_bros.asm : 556 (JSL Sprite_ShowMessageUnconditional) diff --git a/inventory.asm b/inventory.asm index b2b7571..8fc3366 100644 --- a/inventory.asm +++ b/inventory.asm @@ -1,28 +1,6 @@ ;================================================================================ ; Inventory Updates ;================================================================================ -; InventoryTracking -; brmpnskf ------oq -; b = blue boomerang | - -; r = red boomerang | - -; m = mushroom current | - -; p = magic powder | - -; n = mushroom past | - -; s = shovel | - -; k = fake flute | o = any bomb acquired from item location -; f = working flute | q = quickswap locked -;-------------------------------------------------------------------------------- -; BowTracking -; Item Tracking Slot #2 -; -------- bsp----- -; b = bow -; s = silver arrow bow -; p = 2nd progressive bow -; - -; - -; - -; - -; - ;-------------------------------------------------------------------------------- ; ProcessMenuButtons: ; out: Carry - 0 = No Button, 1 = Yes Button @@ -129,10 +107,6 @@ ProcessBottleMenu: .no_bottles LDA.b #$00 ; pretend like the controller state was 0 from the overridden load RTL -; .y_not_pressed -; LDA.b Joy1A_New : AND.b #$0C ; thing we wrote over - load controller state -;RTL -;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ;OpenBottleMenu: @@ -162,520 +136,462 @@ RTL ;-------------------------------------------------------------------------------- ; AddInventory: ;-------------------------------------------------------------------------------- -macro TopHalf(address) - LDA.l
: !ADD #$10 : STA.l
-endmacro - -macro BottomHalf(address) - PHA : PHX - LDA.l
: INC : AND.b #$0F : TAX - LDA.l
: AND.b #$F0 : STA.l
- TXA : ORA.l
: STA.l
- PLX : PLA -endmacro -;-------------------------------------------------------------------------------- -FullInventoryExternal: - LDA.l StatsLocked : BEQ + : RTL : + - PHA : PHX : PHP : JMP AddInventory_incrementCounts -;-------------------------------------------------------------------------------- AddInventory: - PHA : PHX : PHP - CPY.b #$0C : BNE + ; Blue Boomerang - LDA.l InventoryTracking : ORA.b #$80 : STA.l InventoryTracking - JMP .incrementCounts - + CPY.b #$2A : BNE + ; Red Boomerang - LDA.l InventoryTracking : ORA.b #$40 : STA.l InventoryTracking - JMP .incrementCounts - + CPY.b #$29 : BNE + ; Mushroom - LDA.l InventoryTracking : ORA.b #$28 : STA.l InventoryTracking - JMP .incrementCounts - + CPY.b #$0D : BNE + ; Magic Powder - LDA.l InventoryTracking : ORA.b #$10 : STA.l InventoryTracking - JMP .incrementCounts - + CPY.b #$13 : BNE + ; Shovel - LDA.l InventoryTracking : ORA.b #$04 : STA.l InventoryTracking - JMP .incrementCounts - + CPY.b #$14 : BNE + ; Flute (Inactive) - LDA.l InventoryTracking : ORA.b #$02 : STA.l InventoryTracking - JMP .incrementCounts - + CPY.b #$4A : BNE + ; Flute (Active) - LDA.l InventoryTracking : ORA.b #$01 : STA.l InventoryTracking - JMP .incrementCounts - + CPY.b #$0B : BNE + ; Bow - LDA.l ArrowMode : BNE +++ - LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking - +++ - JMP .incrementCounts - + CPY.b #$3A : BNE + ; Bow & Arrows - LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking - JMP .incrementCounts - + CPY.b #$3B : BNE + ; Bow & Silver Arrows - LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking - LDA.l ArrowMode : BNE +++ - LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking ; activate wood arrows when not in rupee bow - +++ - JMP .incrementCounts - + CPY.b #$43 : BNE + ; Single arrow - LDA.l ArrowMode : BEQ +++ - LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking ; activate wood arrows in quick-swap - +++ - JMP .incrementCounts - + CPY.b #$58 : BNE + ; Upgrade-Only Silver Arrows - LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking - + +; In: Y - Receipt ID +; Uses $0B-$0D for long absolute addressing + PHA : PHX : PHY : PHP : PHB + PHK : PLB + LDA.l StatsLocked : BNE .done + JSR.w ShopCheck : BCS .done + JSR.w DungeonIncrement : BCS .done + LDA.b #$7E : STA.b Scrap0D + JSR.w StampItem + JSR.w IncrementByOne + SEP #$20 + JSR.w IncrementYAItems + LDA.w InventoryTable_properties,Y : BIT #$01 : BEQ .done + REP #$20 + LDA.l TotalItemCounter : INC : TAY + LDA.l BootsEquipment : BNE + + TYA : STA.l PreBootsLocations + + + LDA.l MirrorEquipment : BNE + + TYA : STA.l PreMirrorLocations + + + LDA.l FluteEquipment : BNE + + TYA : STA.l PreFluteLocations + + + TYA + STA.l TotalItemCounter + .done + PLB : PLP : PLY : PLX : PLA +RTL - .incrementCounts - LDA.l StatsLocked : BEQ + : JMP .done : + +ShopCheck: + LDA.b IndoorsFlag : BEQ .count + LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ .count + LDA.w InventoryTable_properties,Y : BIT.b #$02 : BNE .count + REP #$20 + LDA.b RoomIndex + CMP.w #274 : BEQ .nocount ; dark world death mountain shop, ornamental shield shop + CMP.w #271 : BEQ .nocount ; villiage of outcasts shop, lumberjack shop, lake hylia shop, dark world magic shop + CMP.w #272 : BEQ .nocount ; red shield shop + CMP.w #284 : BEQ .nocount ; bomb shop + CMP.w #287 : BEQ .nocount ; kakariko shop + CMP.w #255 : BEQ .nocount ; light world death mountain shop + CMP.w #276 : BEQ .nocount ; waterfall fairy + CMP.w #277 : BEQ .nocount ; upgrade fairy (shop) + CMP.w #278 : BEQ .nocount ; pyramid fairy + SEP #$20 + .count + CLC +RTS + .nocount + SEP #$21 +RTS - ; don't count any of this stuff - CPY.b #$20 : BNE + : JMP .itemCounts : + ; Crystal - CPY.b #$26 : BNE + : JMP .itemCounts : + ; Heart Piece Completion Heart - CPY.b #$2E : BNE + : JMP .itemCounts : + ; Red Potion (Refill) - CPY.b #$2F : BNE + : JMP .itemCounts : + ; Green Potion (Refill) - CPY.b #$30 : BNE + : JMP .itemCounts : + ; Blue Potion (Refill) - CPY.b #$37 : BNE + : JMP .itemCounts : + ; Pendant - CPY.b #$38 : BNE + : JMP .itemCounts : + ; Pendant - CPY.b #$39 : BNE + : JMP .itemCounts : + ; Pendant - - CPY.b #$04 : !BLT .isSword ; Swords - Skip Shop/Fairy Check for Swords - CPY.b #$49 : BEQ .isSword - CPY.b #$50 : BEQ .isSword - CPY.b #$5E : BEQ .isSword - BRA + - .isSword - JMP .dungeonCounts - + - CPY.b #$3B : BNE + : JMP .dungeonCounts : + ; Silver Arrow Bow - Skip Shop/Fairy Check for Silver Arrow Bow - - LDA.b IndoorsFlag : BEQ ++ ; skip shop check if outdoors - LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ ++ ; skip shop check for chests - PHP : REP #$20 ; set 16-bit accumulator - LDA.b RoomIndex - CMP.w #274 : BNE + : JMP .shop : + ; dark world death mountain shop, ornamental shield shop - CMP.w #271 : BNE + : JMP .shop : + ; villiage of outcasts shop, lumberjack shop, lake hylia shop, dark world magic shop - CMP.w #272 : BNE + : JMP .shop : + ; red shield shop - CMP.w #284 : BNE + : JMP .shop : + ; bomb shop - ;CMP.w #265 : BNE + : JMP .shop : + ; potion shop - commented this out because it's easier to just block potion refills because this one interferes with the powder item being counted - ;CMP.w #271 : BNE + : JMP .shop : + ; lake hylia shop - CMP.w #287 : BNE + : JMP .shop : + ; kakariko shop - CMP.w #255 : BNE + : JMP .shop : + ; light world death mountain shop - CMP.w #276 : BNE + : JMP .shop : + ; waterfall fairy - CMP.w #277 : BNE + : JMP .shop : + ; upgrade fairy (shop) - CMP.w #278 : BNE + : JMP .shop : + ; pyramid fairy - PLP : BRA ++ - .shop - PLP : JMP .done - ++ - - .dungeonCounts - LDA.b IndoorsFlag : BNE + : JMP .fullItemCounts : + - SEP #$20 ; Set 8-bit Accumulator - - LDA.w DungeonID ; get dungeon id - CMP.b #$FF : BEQ .fullItemCounts +DungeonIncrement: + LDA.b IndoorsFlag : BEQ .count + LDA.w DungeonID : CMP.b #$FF : BEQ .count CMP.l BallNChainDungeon : BNE + - CPY.b #$32 : BNE + - JMP .done + CPY.b #$32 : BEQ .ballchain_bigkey + CMP.b #$04 : BCS + - LDA.l SewersLocations : INC : STA.l SewersLocations - LDA.l HCLocations : INC : STA.l HCLocations - BRA .fullItemCounts - + LSR : TAX : LDA.l DungeonLocationsChecked, X : INC : STA.l DungeonLocationsChecked, X - ++ CPX.b #$0D : BNE + - LDA.l BigKeyField : AND.b #$04 : BNE ++ - JSR .incrementGTowerPreBigKey + LDA.l SewersLocations : INC : STA.l SewersLocations : STA.l HCLocations + BRA .count + + + LSR : TAX : LDA.l DungeonLocationsChecked, X : INC : STA.l DungeonLocationsChecked, X + CPX.b #$0D : BNE + + LDA.l BigKeyField : BIT.b #$04 : BNE ++ + LDA.l PreGTBKLocations : INC : STA.l PreGTBKLocations ++ + - ; == END INDOOR-ONLY SECTION - .fullItemCounts - - LDA.l BootsEquipment : BNE + ; Check for Boots - LDA.l PreBootsLocations : INC : STA.l PreBootsLocations ; Increment Pre Boots Counter - + - - LDA.l MirrorEquipment : BNE + ; Check for Mirror - LDA.l PreMirrorLocations : INC : STA.l PreMirrorLocations ; Increment Pre Mirror Counter - + - - LDA.l FluteEquipment : BNE + ; Check for Flute - LDA.l PreFluteLocations : INC : STA.l PreFluteLocations ; Increment Pre Mirror Counter - + - - REP #$20 - LDA.l TotalItemCounter : INC : STA.l TotalItemCounter ; Increment Item Total - SEP #$20 - - .itemCounts - - CPY.b #$00 : BNE + ; Fighter's Sword & Fighter's Shield - LDX.b #$01 - JSR .incrementSword - JSR .incrementShield - JMP .done - + CPY.b #$01 : BNE + ; Master Sword - LDX.b #$02 - JSR .incrementSword - JMP .done - + CPY.b #$02 : BNE + ; Tempered Sword - LDX.b #$03 - JSR .incrementSword - JMP .done - + CPY.b #$03 : BNE + ; Golden Sword - LDX.b #$04 - JSR .incrementSword - JMP .done - + CPY.b #$04 : BNE + ; Fighter's Shield - LDX.b #$01 - JSR .incrementShield - JMP .done - + CPY.b #$05 : BNE + ; Red Shield - LDX.b #$02 - JSR .incrementShield - JMP .done - + CPY.b #$06 : BNE + ; Mirror Shield - LDX.b #$03 - JSR .incrementShield - JMP .done - + CPY.b #$07 : !BLT + ; Items $07 - $0D - CPY.b #$0E : !BGE + - JSR .incrementY - JMP .done - + CPY.b #$14 : BNE + ; Flute (Inactive) - LEAVE THIS ABOVE THE 0F-16 CONDITION - kkat - JSR .stampFlute - JSR .incrementY - JMP .done - + CPY.b #$0F : !BLT + ; Items $0F - $16 - CPY.b #$17 : !BGE + - JSR .incrementY - JMP .done - + CPY.b #$17 : BNE + ; Heart Piece - JSR .incrementHeartPiece - JMP .done - + CPY.b #$18 : !BLT + ; Items $18 - $19 - CPY.b #$1A : !BGE + - JSR .incrementY - JMP .done - + CPY.b #$1A : BNE + ; Magic Mirror - JSR .stampMirror - JSR .incrementY - JMP .done - + CPY.b #$1D : BNE + ; Book of Mudora - LEAVE THIS ABOVE THE 1B-1F CONDITION - kkat - JSR .incrementY - JMP .done - + CPY.b #$1B : !BLT + ; Items IndoorsFlag - $1F - CPY.b #$20 : !BGE + - JSR .incrementA - JMP .done - + CPY.b #$20 : BNE + ; Crystal - JSR .incrementCrystal - JSR .setDungeonCompletion - JMP .done - + CPY.b #$21 : BNE + ; Bug Net - JSR .incrementY - JMP .done - + CPY.b #$22 : BNE + ; Blue Mail - LDX.b #$01 - JSR .incrementMail - + CPY.b #$23 : BNE + ; Red Mail - LDX.b #$02 - JSR .incrementMail - + CPY.b #$24 : BNE + ; Small Key - JSR .incrementKey - JMP .done - + CPY.b #$25 : BNE + ; Compass - JSL MaybeFlagCompassTotalPickup - JSR .incrementCompass - JMP .done - + CPY.b #$26 : BNE + ; Liar Heart (Container) - ;JSR .incrementHeartContainer - JMP .done - + CPY.b #$27 : BNE + ; 1 Bomb - JSR .maybeIncrementBombs - JMP .done - + CPY.b #$28 : BNE + ; 3 Bombs - JSR .maybeIncrementBombs - JMP .done - + CPY.b #$29 : BNE + ; Mushroom - JSR .incrementY - JMP .done - + CPY.b #$2A : !BLT + ; Items $2A - $2D - CPY.b #$2E : !BGE + - JSR .incrementY - JMP .done - + CPY.b #$31 : BNE + ; 10 Bombs - JSR .maybeIncrementBombs - JMP .done - + CPY.b #$32 : BNE + ; Big Key - JSR .incrementBigKey - JMP .done - + CPY.b #$33 : BNE + ; Map - JSR .incrementMap - JMP .done - + CPY.b #$37 : !BLT + ; Items $37 - $39 - Pendants - CPY.b #$3A : !BGE + - JSR .incrementPendant - JSR .setDungeonCompletion - JMP .done - + CPY.b #$3A : !BLT + ; Items $3A - $3B - Bow & Silver Arrows - CPY.b #$3C : !BGE + - JSR .incrementBow - JMP .done - + CPY.b #$3C : BNE + ; Bottle w/Bee - JSR .incrementY - JMP .done - + CPY.b #$3D : BNE + ; Bottle w/Fairy - JSR .incrementY - JMP .done - + CPY.b #$3E : !BLT + ; Items $3E - $3F - Heart Containers - CPY.b #$40 : !BGE + - JSR .incrementHeartContainer - JMP .done - + CPY.b #$48 : BNE + ; Bottle w/Gold Bee - JSR .incrementY - JMP .done - + CPY.b #$49 : BNE + ; Fighter's Sword - LDX.b #$01 - JSR .incrementSword - JMP .done - + CPY.b #$4A : BNE + ; Flute (Active) - JSR .stampFlute - JSR .incrementY - JMP .done - + CPY.b #$4B : BNE + ; Pegasus Boots - JSR .stampBoots - JSR .incrementA - JMP .done - + CPY.b #$4C : BNE + ; 50 Bomb Capacity Upgrade - JSR .incrementCapacity - JSR .maybeIncrementBombs - JMP .done - + CPY.b #$4D : !BLT + ; Items $4D - $4F - Capacity Upgrades - CPY.b #$50 : !BGE + - JSR .incrementCapacity - JMP .done - + CPY.b #$50 : BNE + ; Master Sword (Safe) - LDX.b #$02 - JSR .incrementSword - JMP .done - + CPY.b #$51 : BNE + ; 5 Bomb Capacity Upgrade - LDX.b #$02 - JSR .maybeIncrementBombs - JMP .done - + CPY.b #$52 : BNE + ; 10 Bomb Capacity Upgrade - LDX.b #$02 - JSR .maybeIncrementBombs - JMP .done - + CPY.b #$51 : !BLT + ; Items $51 - $54 - Capacity Upgrades - CPY.b #$55 : !BGE + - JSR .incrementCapacity - JMP .done - + CPY.b #$58 : BNE + ; Upgrade-Only Silver Arrows - JSR .incrementBow - JMP .done - + CPY.b #$5E : BNE + ; Progressive Sword - LDA.l SwordEquipment : INC : TAX - JSR .incrementSword - JMP .done - + CPY.b #$5F : BNE + ; Progressive Shield - LDA.l ShieldEquipment : INC : TAX - JSR .incrementShield - JMP .done - + CPY.b #$60 : BNE + ; Progressive Armor - LDA.l ArmorEquipment : INC : TAX - JSR .incrementMail - JMP .done - + CPY.b #$61 : BNE + ; Progressive Lifting Glove - JSR .incrementA - JMP .done - + CPY.b #$64 : !BLT + ; Items $64 & $65 - Progressive Bow - CPY.b #$66 : !BGE + - JSR .incrementBow - JMP .done - + CPY.b #$70 : !BLT + ; Items $70 - $7F - Free Maps - CPY.b #$80 : !BGE + - JSR .incrementMap - 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 - CPY.b #$A0 : !BGE + - JSR .incrementBigKey - JMP .done - + CPY.b #$A0 : !BLT + ; Items $A0 - $AF - Free Small Keys - CPY.b #$B0 : !BGE + - JSR .incrementKey - JMP .done - + - .done - PLP : PLX : PLA -RTL -; WHICH BEE IS BOTTLED? -; MAKE SURE FAIRY FOUNTAINS DON'T FUCK THE COUNTS UP - -.stampSword - REP #$20 ; set 16-bit accumulator - LDA.l SwordTime : BNE + - LDA.l SwordTime+2 : BNE + - LDA.l NMIFrames : STA.l SwordTime - LDA.l NMIFrames+2 : STA.l SwordTime+2 - + - SEP #$20 ; set 8-bit accumulator + .count + CLC +RTS + .ballchain_bigkey + LDA.l BigKeysBigChests + CLC : ADC.b #$10 + STA.l BigKeysBigChests + SEC RTS -.stampBoots - REP #$20 ; set 16-bit accumulator - LDA.l BootsTime : BNE + - LDA.l BootsTime+2 : BNE + - LDA.l NMIFrames : STA.l BootsTime - LDA.l NMIFrames+2 : STA.l BootsTime+2 - + - SEP #$20 ; set 8-bit accumulator +StampItem: + REP #$30 + TYA : ASL : TAX + LDA.w InventoryTable_stamp,X : BEQ .skip + STA.b Scrap0B + LDA.b [Scrap0B] : BNE .skip + LDA.l NMIFrames : STA.b [Scrap0B] + INC.b Scrap0B : INC.b Scrap0B + LDA.l NMIFrames+2 : STA.b [Scrap0B] + .skip RTS -.stampFlute - REP #$20 ; set 16-bit accumulator - LDA.l FluteTime : BNE + - LDA.l FluteTime+2 : BNE + - LDA.l NMIFrames : STA.l FluteTime - LDA.l NMIFrames+2 : STA.l FluteTime+2 +IncrementYAItems: + LDA.w InventoryTable_properties,Y + BIT.b #$10 : BNE .bomb_check + BIT.b #$20 : BNE .bow_check + BIT.b #$04 : BEQ .not_y + .y_item + LDA.l YAItemCounter : !ADD #$08 : STA.l YAItemCounter + BRA .done + .not_y + BIT.b #$08 : BEQ .done + .a_item + LDA.l YAItemCounter : INC : AND.b #$07 : TAX + LDA.l YAItemCounter : AND.b #$F8 : STA.l YAItemCounter + TXA : ORA.l YAItemCounter : STA.l YAItemCounter + .done +RTS + .bow_check + LDA.l BowEquipment : BNE + + BRA .y_item + + +RTS + .bomb_check + LDA.l InventoryTracking+1 : BIT.b #$02 : BNE + + ORA.b #$02 : STA.l InventoryTracking+1 + BRA .y_item + - SEP #$20 ; set 8-bit accumulator RTS -.stampMirror - REP #$20 ; set 16-bit accumulator - LDA.l MirrorTime : BNE + - LDA.l MirrorTime+2 : BNE + - LDA.l NMIFrames : STA.l MirrorTime - LDA.l NMIFrames+2 : STA.l MirrorTime+2 - + - SEP #$20 ; set 8-bit accumulator +IncrementByOne: + LDA.w InventoryTable_stat,X : BEQ .skip + STA.b Scrap0B + SEP #$20 + LDA.b #$01 : ADC.b [Scrap0B] : STA.b [Scrap0B] + .skip RTS -.incrementSword - JSR .stampSword - LDA.l HighestSword - INC : STA.b Scrap04 : CPX.b Scrap04 : !BLT + ; don't increment unless we're getting a better sword - TXA : STA.l HighestSword +; Properties: - - w o a y s t +; t = Count for total item counter | s = Count for total in shops +; y = Y item | a = A item +; o = Bomb item | w = Bow item +InventoryTable: + .properties : fillbyte $00 : fill 256 ; See above + .stamp : fillword $0000 : fill 256*2 ; Address to stamp with 32-bit time (bank $7E) + .stat : fillword $0000 : fill 256*2 ; Address to increment by one (bank $7E) + +macro InventoryItem(id, props, stamp, stat) + pushpc + org InventoryTable_properties+ : db + org InventoryTable_stamp+(*2) : dw + org InventoryTable_stat+(*2) : dw + pullpc +endmacro + +%InventoryItem($00, $01, SwordTime, $0000) ; 00 - Fighter sword & Shield +%InventoryItem($01, $01, SwordTime, $0000) ; 01 - Master sword +%InventoryItem($02, $01, SwordTime, $0000) ; 02 - Tempered sword +%InventoryItem($03, $01, SwordTime, $0000) ; 03 - Butter sword +%InventoryItem($04, $01, $0000, $0000) ; 04 - Fighter shield +%InventoryItem($05, $01, $0000, $0000) ; 05 - Fire shield +%InventoryItem($06, $01, $0000, $0000) ; 06 - Mirror shield +%InventoryItem($07, $05, $0000, $0000) ; 07 - Fire rod +%InventoryItem($08, $05, $0000, $0000) ; 08 - Ice rod +%InventoryItem($09, $05, $0000, $0000) ; 09 - Hammer +%InventoryItem($0A, $05, $0000, $0000) ; 0A - Hookshot +%InventoryItem($0B, $25, $0000, $0000) ; 0B - Bow +%InventoryItem($0C, $05, $0000, $0000) ; 0C - Blue Boomerang +%InventoryItem($0D, $05, $0000, $0000) ; 0D - Powder +%InventoryItem($0E, $01, $0000, $0000) ; 0E - Bottle refill (bee) +%InventoryItem($0F, $05, $0000, $0000) ; 0F - Bombos +%InventoryItem($10, $05, $0000, $0000) ; 10 - Ether +%InventoryItem($11, $05, $0000, $0000) ; 11 - Quake +%InventoryItem($12, $05, $0000, $0000) ; 12 - Lamp +%InventoryItem($13, $05, $0000, $0000) ; 13 - Shovel +%InventoryItem($14, $05, FluteTime, $0000) ; 14 - Flute (inactive) +%InventoryItem($15, $05, $0000, $0000) ; 15 - Somaria +%InventoryItem($16, $05, $0000, $0000) ; 16 - Bottle +%InventoryItem($17, $01, $0000, HeartPieceCounter) ; 17 - Heart piece +%InventoryItem($18, $05, $0000, $0000) ; 18 - Byrna +%InventoryItem($19, $05, $0000, $0000) ; 19 - Cape +%InventoryItem($1A, $05, MirrorTime, $0000) ; 1A - Mirror +%InventoryItem($1B, $09, $0000, $0000) ; 1B - Glove +%InventoryItem($1C, $09, $0000, $0000) ; 1C - Mitts +%InventoryItem($1D, $05, $0000, $0000) ; 1D - Book +%InventoryItem($1E, $09, $0000, $0000) ; 1E - Flippers +%InventoryItem($1F, $01, $0000, $0000) ; 1F - Pearl +%InventoryItem($20, $00, $0000, CrystalCounter) ; 20 - Crystal +%InventoryItem($21, $05, $0000, $0000) ; 21 - Net +%InventoryItem($22, $01, $0000, $0000) ; 22 - Blue mail +%InventoryItem($23, $01, $0000, $0000) ; 23 - Red mail +%InventoryItem($24, $01, $0000, SmallKeyCounter) ; 24 - Small key +%InventoryItem($25, $01, $0000, $0000) ; 25 - Compass +%InventoryItem($26, $00, $0000, $0000) ; 26 - Heart container from 4/4 +%InventoryItem($27, $15, $0000, $0000) ; 27 - Bomb +%InventoryItem($28, $15, $0000, $0000) ; 28 - 3 bombs +%InventoryItem($29, $05, $0000, $0000) ; 29 - Mushroom +%InventoryItem($2A, $05, $0000, $0000) ; 2A - Red boomerang +%InventoryItem($2B, $05, $0000, $0000) ; 2B - Full bottle (red) +%InventoryItem($2C, $05, $0000, $0000) ; 2C - Full bottle (green) +%InventoryItem($2D, $05, $0000, $0000) ; 2D - Full bottle (blue) +%InventoryItem($2E, $00, $0000, $0000) ; 2E - Potion refill (red) +%InventoryItem($2F, $00, $0000, $0000) ; 2F - Potion refill (green) +%InventoryItem($30, $00, $0000, $0000) ; 30 - Potion refill (blue) +%InventoryItem($31, $11, $0000, $0000) ; 31 - 10 bombs +%InventoryItem($32, $01, $0000, $0000) ; 32 - Big key +%InventoryItem($33, $01, $0000, $0000) ; 33 - Map +%InventoryItem($34, $01, $0000, $0000) ; 34 - 1 rupee +%InventoryItem($35, $01, $0000, $0000) ; 35 - 5 rupees +%InventoryItem($36, $01, $0000, $0000) ; 36 - 20 rupees +%InventoryItem($37, $00, $0000, PendantCounter) ; 37 - Green pendant +%InventoryItem($38, $00, $0000, PendantCounter) ; 38 - Blue pendant +%InventoryItem($39, $00, $0000, PendantCounter) ; 39 - Red pendant +%InventoryItem($3A, $25, $0000, $0000) ; 3A - Bow And Arrows +%InventoryItem($3B, $25, $0000, $0000) ; 3B - Silver Bow +%InventoryItem($3C, $05, $0000, $0000) ; 3C - Full bottle (bee) +%InventoryItem($3D, $05, $0000, $0000) ; 3D - Full bottle (fairy) +%InventoryItem($3E, $01, $0000, HeartContainerCounter) ; 3E - Boss heart +%InventoryItem($3F, $01, $0000, HeartContainerCounter) ; 3F - Sanc heart +%InventoryItem($40, $01, $0000, $0000) ; 40 - 100 rupees +%InventoryItem($41, $01, $0000, $0000) ; 41 - 50 rupees +%InventoryItem($42, $01, $0000, $0000) ; 42 - Heart +%InventoryItem($43, $01, $0000, $0000) ; 43 - Arrow +%InventoryItem($44, $01, $0000, $0000) ; 44 - 10 arrows +%InventoryItem($45, $01, $0000, $0000) ; 45 - Small magic +%InventoryItem($46, $01, $0000, $0000) ; 46 - 300 rupees +%InventoryItem($47, $01, $0000, $0000) ; 47 - 20 rupees green +%InventoryItem($48, $05, $0000, $0000) ; 48 - Full bottle (good bee) +%InventoryItem($49, $01, $0000, $0000) ; 49 - Tossed fighter sword +%InventoryItem($4A, $05, FluteTime, $0000) ; 4A - Active Flute +%InventoryItem($4B, $09, BootsTime, $0000) ; 4B - Boots +%InventoryItem($4C, $15, $0000, CapacityUpgrades) ; 4C - Bomb capacity (50) +%InventoryItem($4D, $01, $0000, CapacityUpgrades) ; 4D - Arrow capacity (70) +%InventoryItem($4E, $01, $0000, CapacityUpgrades) ; 4E - 1/2 magic +%InventoryItem($4F, $01, $0000, CapacityUpgrades) ; 4F - 1/4 magic +%InventoryItem($50, $01, SwordTime, $0000) ; 50 - Master Sword (safe) +%InventoryItem($51, $15, $0000, CapacityUpgrades) ; 51 - Bomb capacity (+5) +%InventoryItem($52, $15, $0000, CapacityUpgrades) ; 52 - Bomb capacity (+10) +%InventoryItem($53, $01, $0000, CapacityUpgrades) ; 53 - Arrow capacity (+5) +%InventoryItem($54, $01, $0000, CapacityUpgrades) ; 54 - Arrow capacity (+10) +%InventoryItem($55, $01, $0000, $0000) ; 55 - Programmable item 1 +%InventoryItem($56, $01, $0000, $0000) ; 56 - Programmable item 2 +%InventoryItem($57, $01, $0000, $0000) ; 57 - Programmable item 3 +%InventoryItem($58, $01, $0000, $0000) ; 58 - Upgrade-only Silver Arrows +%InventoryItem($59, $01, $0000, $0000) ; 59 - Rupoor +%InventoryItem($5A, $01, $0000, $0000) ; 5A - Nothing +%InventoryItem($5B, $01, $0000, $0000) ; 5B - Red clock +%InventoryItem($5C, $01, $0000, $0000) ; 5C - Blue clock +%InventoryItem($5D, $01, $0000, $0000) ; 5D - Green clock +%InventoryItem($5E, $01, $0000, $0000) ; 5E - Progressive sword +%InventoryItem($5F, $01, $0000, $0000) ; 5F - Progressive shield +%InventoryItem($60, $01, $0000, $0000) ; 60 - Progressive armor +%InventoryItem($61, $09, $0000, $0000) ; 61 - Progressive glove +%InventoryItem($62, $01, $0000, $0000) ; 62 - RNG pool item (single) +%InventoryItem($63, $01, $0000, $0000) ; 63 - RNG pool item (multi) +%InventoryItem($64, $25, $0000, $0000) ; 64 - Progressive bow +%InventoryItem($65, $25, $0000, $0000) ; 65 - Progressive bow +%InventoryItem($66, $01, $0000, $0000) ; 66 - +%InventoryItem($67, $01, $0000, $0000) ; 67 - +%InventoryItem($68, $01, $0000, $0000) ; 68 - +%InventoryItem($69, $01, $0000, $0000) ; 69 - +%InventoryItem($6A, $01, $0000, $0000) ; 6A - Triforce +%InventoryItem($6B, $01, $0000, $0000) ; 6B - Power star +%InventoryItem($6C, $01, $0000, $0000) ; 6C - Triforce Piece +%InventoryItem($6D, $01, $0000, $0000) ; 6D - Server request item +%InventoryItem($6E, $01, $0000, $0000) ; 6E - Server request item (dungeon drop) +%InventoryItem($6F, $01, $0000, $0000) ; 6F - +%InventoryItem($70, $01, $0000, $0000) ; 70 - Map of Light World +%InventoryItem($71, $01, $0000, $0000) ; 71 - Map of Dark World +%InventoryItem($72, $01, $0000, $0000) ; 72 - Map of Ganon's Tower +%InventoryItem($73, $01, $0000, $0000) ; 73 - Map of Turtle Rock +%InventoryItem($74, $01, $0000, $0000) ; 74 - Map of Thieves' Town +%InventoryItem($75, $01, $0000, $0000) ; 75 - Map of Tower of Hera +%InventoryItem($76, $01, $0000, $0000) ; 76 - Map of Ice Palace +%InventoryItem($77, $01, $0000, $0000) ; 77 - Map of Skull Woods +%InventoryItem($78, $01, $0000, $0000) ; 78 - Map of Misery Mire +%InventoryItem($79, $01, $0000, $0000) ; 79 - Map of Dark Palace +%InventoryItem($7A, $01, $0000, $0000) ; 7A - Map of Swamp Palace +%InventoryItem($7B, $01, $0000, $0000) ; 7B - Map of Agahnim's Tower +%InventoryItem($7C, $01, $0000, $0000) ; 7C - Map of Desert Palace +%InventoryItem($7D, $01, $0000, $0000) ; 7D - Map of Eastern Palace +%InventoryItem($7E, $01, $0000, $0000) ; 7E - Map of Hyrule Castle +%InventoryItem($7F, $01, $0000, $0000) ; 7F - Map of Sewers +%InventoryItem($80, $01, $0000, $0000) ; 80 - Compass of Light World +%InventoryItem($81, $01, $0000, $0000) ; 81 - Compass of Dark World +%InventoryItem($82, $01, $0000, $0000) ; 82 - Compass of Ganon's Tower +%InventoryItem($83, $01, $0000, $0000) ; 83 - Compass of Turtle Rock +%InventoryItem($84, $01, $0000, $0000) ; 84 - Compass of Thieves' Town +%InventoryItem($85, $01, $0000, $0000) ; 85 - Compass of Tower of Hera +%InventoryItem($86, $01, $0000, $0000) ; 86 - Compass of Ice Palace +%InventoryItem($87, $01, $0000, $0000) ; 87 - Compass of Skull Woods +%InventoryItem($88, $01, $0000, $0000) ; 88 - Compass of Misery Mire +%InventoryItem($89, $01, $0000, $0000) ; 89 - Compass of Dark Palace +%InventoryItem($8A, $01, $0000, $0000) ; 8A - Compass of4Swamp Palace +%InventoryItem($8B, $01, $0000, $0000) ; 8B - Compass of Agahnim's Tower +%InventoryItem($8C, $01, $0000, $0000) ; 8C - Compass of Desert Palace +%InventoryItem($8D, $01, $0000, $0000) ; 8D - Compass of Eastern Palace +%InventoryItem($8E, $01, $0000, $0000) ; 8E - Compass of Hyrule Castle +%InventoryItem($8F, $01, $0000, $0000) ; 8F - Compass of Sewers +%InventoryItem($90, $01, $0000, $0000) ; 90 - Skull key +%InventoryItem($91, $01, $0000, $0000) ; 91 - Reserved +%InventoryItem($92, $01, $0000, $0000) ; 92 - Big key of Ganon's Tower +%InventoryItem($93, $01, $0000, $0000) ; 93 - Big key of Turtle Rock +%InventoryItem($94, $01, $0000, $0000) ; 94 - Big key of Thieves' Town +%InventoryItem($95, $01, $0000, $0000) ; 95 - Big key of Tower of Hera +%InventoryItem($96, $01, $0000, $0000) ; 96 - Big key of Ice Palace +%InventoryItem($97, $01, $0000, $0000) ; 97 - Big key of Skull Woods +%InventoryItem($98, $01, $0000, $0000) ; 98 - Big key of Misery Mire +%InventoryItem($99, $01, $0000, $0000) ; 99 - Big key of Dark Palace +%InventoryItem($9A, $01, $0000, $0000) ; 9A - Big key of Swamp Palace +%InventoryItem($9B, $01, $0000, $0000) ; 9B - Big key of Agahnim's Tower +%InventoryItem($9C, $01, $0000, $0000) ; 9C - Big key of Desert Palace +%InventoryItem($9D, $01, $0000, $0000) ; 9D - Big key of Eastern Palace +%InventoryItem($9E, $01, $0000, $0000) ; 9E - Big key of Hyrule Castle +%InventoryItem($9F, $01, $0000, $0000) ; 9F - Big key of Sewers +%InventoryItem($A0, $01, $0000, SmallKeyCounter) ; A0 - Small key of Sewers +%InventoryItem($A1, $01, $0000, SmallKeyCounter) ; A1 - Small key of Hyrule Castle +%InventoryItem($A2, $01, $0000, SmallKeyCounter) ; A2 - Small key of Eastern Palace +%InventoryItem($A3, $01, $0000, SmallKeyCounter) ; A3 - Small key of Desert Palace +%InventoryItem($A4, $01, $0000, SmallKeyCounter) ; A4 - Small key of Agahnim's Tower +%InventoryItem($A5, $01, $0000, SmallKeyCounter) ; A5 - Small key of Swamp Palace +%InventoryItem($A6, $01, $0000, SmallKeyCounter) ; A6 - Small key of Dark Palace +%InventoryItem($A7, $01, $0000, SmallKeyCounter) ; A7 - Small key of Misery Mire +%InventoryItem($A8, $01, $0000, SmallKeyCounter) ; A8 - Small key of Skull Woods +%InventoryItem($A9, $01, $0000, SmallKeyCounter) ; A9 - Small key of Ice Palace +%InventoryItem($AA, $01, $0000, SmallKeyCounter) ; AA - Small key of Tower of Hera +%InventoryItem($AB, $01, $0000, SmallKeyCounter) ; AB - Small key of Thieves' Town +%InventoryItem($AC, $01, $0000, SmallKeyCounter) ; AC - Small key of Turtle Rock +%InventoryItem($AD, $01, $0000, SmallKeyCounter) ; AD - Small key of Ganon's Tower +%InventoryItem($AE, $01, $0000, $0000) ; AE - Reserved +%InventoryItem($AF, $01, $0000, SmallKeyCounter) ; AF - Generic small key +%InventoryItem($B0, $01, $0000, $0000) ; B0 - +%InventoryItem($B1, $01, $0000, $0000) ; B1 - +%InventoryItem($B2, $01, $0000, $0000) ; B2 - +%InventoryItem($B3, $01, $0000, $0000) ; B3 - +%InventoryItem($B4, $01, $0000, $0000) ; B4 - +%InventoryItem($B5, $01, $0000, $0000) ; B5 - +%InventoryItem($B6, $01, $0000, $0000) ; B6 - +%InventoryItem($B7, $01, $0000, $0000) ; B7 - +%InventoryItem($B8, $01, $0000, $0000) ; B8 - +%InventoryItem($B9, $01, $0000, $0000) ; B9 - +%InventoryItem($BA, $01, $0000, $0000) ; BA - +%InventoryItem($BB, $01, $0000, $0000) ; BB - +%InventoryItem($BC, $01, $0000, $0000) ; BC - +%InventoryItem($BD, $01, $0000, $0000) ; BD - +%InventoryItem($BE, $01, $0000, $0000) ; BE - +%InventoryItem($BF, $01, $0000, $0000) ; BF - +%InventoryItem($C0, $01, $0000, $0000) ; C0 - +%InventoryItem($C1, $01, $0000, $0000) ; C1 - +%InventoryItem($C2, $01, $0000, $0000) ; C2 - +%InventoryItem($C3, $01, $0000, $0000) ; C3 - +%InventoryItem($C4, $01, $0000, $0000) ; C4 - +%InventoryItem($C5, $01, $0000, $0000) ; C5 - +%InventoryItem($C6, $01, $0000, $0000) ; C6 - +%InventoryItem($C7, $01, $0000, $0000) ; C7 - +%InventoryItem($C8, $01, $0000, $0000) ; C8 - +%InventoryItem($C9, $01, $0000, $0000) ; C9 - +%InventoryItem($CA, $01, $0000, $0000) ; CA - +%InventoryItem($CB, $01, $0000, $0000) ; CB - +%InventoryItem($CC, $01, $0000, $0000) ; CC - +%InventoryItem($CD, $01, $0000, $0000) ; CD - +%InventoryItem($CE, $01, $0000, $0000) ; CE - +%InventoryItem($CF, $01, $0000, $0000) ; CF - +%InventoryItem($D0, $01, $0000, $0000) ; D0 - +%InventoryItem($D1, $01, $0000, $0000) ; D1 - +%InventoryItem($D2, $01, $0000, $0000) ; D2 - +%InventoryItem($D3, $01, $0000, $0000) ; D3 - +%InventoryItem($D4, $01, $0000, $0000) ; D4 - +%InventoryItem($D5, $01, $0000, $0000) ; D5 - +%InventoryItem($D6, $01, $0000, $0000) ; D6 - +%InventoryItem($D7, $01, $0000, $0000) ; D7 - +%InventoryItem($D8, $01, $0000, $0000) ; D8 - +%InventoryItem($D9, $01, $0000, $0000) ; D9 - +%InventoryItem($DA, $01, $0000, $0000) ; DA - +%InventoryItem($DB, $01, $0000, $0000) ; DB - +%InventoryItem($DC, $01, $0000, $0000) ; DC - +%InventoryItem($DD, $01, $0000, $0000) ; DD - +%InventoryItem($DE, $01, $0000, $0000) ; DE - +%InventoryItem($DF, $01, $0000, $0000) ; DF - +%InventoryItem($E0, $01, $0000, $0000) ; E0 - +%InventoryItem($E1, $01, $0000, $0000) ; E1 - +%InventoryItem($E2, $01, $0000, $0000) ; E2 - +%InventoryItem($E3, $01, $0000, $0000) ; E3 - +%InventoryItem($E4, $01, $0000, $0000) ; E4 - +%InventoryItem($E5, $01, $0000, $0000) ; E5 - +%InventoryItem($E6, $01, $0000, $0000) ; E6 - +%InventoryItem($E7, $01, $0000, $0000) ; E7 - +%InventoryItem($E8, $01, $0000, $0000) ; E8 - +%InventoryItem($E9, $01, $0000, $0000) ; E9 - +%InventoryItem($EA, $01, $0000, $0000) ; EA - +%InventoryItem($EB, $01, $0000, $0000) ; EB - +%InventoryItem($EC, $01, $0000, $0000) ; EC - +%InventoryItem($ED, $01, $0000, $0000) ; ED - +%InventoryItem($EE, $01, $0000, $0000) ; EE - +%InventoryItem($EF, $01, $0000, $0000) ; EF - +%InventoryItem($F0, $01, $0000, $0000) ; F0 - +%InventoryItem($F1, $01, $0000, $0000) ; F1 - +%InventoryItem($F2, $01, $0000, $0000) ; F2 - +%InventoryItem($F3, $01, $0000, $0000) ; F3 - +%InventoryItem($F4, $01, $0000, $0000) ; F4 - +%InventoryItem($F5, $01, $0000, $0000) ; F5 - +%InventoryItem($F6, $01, $0000, $0000) ; F6 - +%InventoryItem($F7, $01, $0000, $0000) ; F7 - +%InventoryItem($F8, $01, $0000, $0000) ; F8 - +%InventoryItem($F9, $01, $0000, $0000) ; F9 - +%InventoryItem($FA, $01, $0000, $0000) ; FA - +%InventoryItem($FB, $01, $0000, $0000) ; FB - +%InventoryItem($FC, $01, $0000, $0000) ; FC - +%InventoryItem($FD, $01, $0000, $0000) ; FD - +%InventoryItem($FE, $01, $0000, $0000) ; FE - Server request (async) +%InventoryItem($FF, $01, $0000, $0000) ; FF - + +IncrementBossSword: + PHX + LDA.l SwordEquipment : CMP.b #$FF : BNE + + BRA .none + + + ASL : TAX + JMP.w (.vectors,X) + + .vectors + dw .none + dw .fighter + dw .master + dw .tempered + dw .golden + + .none + LDA.l SwordlessBossKills : INC : STA.l SwordlessBossKills + PLX + RTL + .fighter + LDA.l SwordBossKills + CLC : ADC.b #$10 + STA.l SwordBossKills + PLX + RTL + .master + LDA.l SwordBossKills : INC : AND.b #$0F : TAX + LDA.l SwordBossKills : AND.b #$F0 : STA.l SwordBossKills + TXA : ORA.l SwordBossKills : STA.l SwordBossKills + PLX + RTL + .tempered + LDA.l SwordBossKills+1 + CLC : ADC.b #$10 + STA.l SwordBossKills+1 + PLX + RTL + .golden + LDA.l SwordBossKills+1 : INC : AND.b #$0F : TAX + LDA.l SwordBossKills+1 : AND.b #$F0 : STA.l SwordBossKills+1 + TXA : ORA.l SwordBossKills+1 : STA.l SwordBossKills+1 + PLX + RTL + +SetDungeonCompletion: +; TODO: move this + LDX.w DungeonID : BMI + + REP #$20 + LDA.l DungeonMask, X : ORA.l DungeonsCompleted : STA.l DungeonsCompleted + SEP #$20 + RTS -.incrementShield - LDA.l HighestShield - INC : STA.b Scrap04 : CPX.b Scrap04 : !BLT + ; don't increment unless we're getting a better shield - TXA : STA.l HighestShield - + -RTS - -.incrementBow - LDA.l BowEquipment : BNE .dontCount ; Don't increment Y item count for extra bows -.incrementY - LDA.l YAItemCounter : !ADD #$08 : STA.l YAItemCounter -.dontCount -RTS - -.incrementA - LDA.l YAItemCounter : INC : AND.b #$07 : TAX - LDA.l YAItemCounter : AND.b #$F8 : STA.l YAItemCounter - TXA : ORA.l YAItemCounter : STA.l YAItemCounter -RTS - -.incrementPendant - LDA.l PendantCounter : INC : STA.l PendantCounter -RTS - -.incrementCapacity - LDA.l CapacityUpgrades : INC : STA.l CapacityUpgrades -RTS - -.incrementHeartPiece - LDA.l HeartPieceCounter : INC : STA.l HeartPieceCounter -RTS - -.incrementHeartContainer - LDA.l HeartContainerCounter : INC : STA.l HeartContainerCounter -RTS - -.incrementCrystal - LDA.l CrystalCounter : INC : STA.l CrystalCounter -RTS - -.incrementMail - LDA.l HighestMail - INC : STA.b Scrap04 : CPX.b Scrap04 : !BLT + ; don't increment unless we're getting a better mail - TXA : STA.l HighestMail - + -RTS - -.incrementKeyLong - JSR .incrementKey -RTL - -.incrementKey - LDA.l SmallKeyCounter : INC : STA.l SmallKeyCounter -RTS - -.incrementCompass - %BottomHalf(MapsCompasses) -RTS - -.incrementBigKey - %TopHalf(BigKeysBigChests) -RTS - -.incrementGTowerPreBigKey - LDA.l PreGTBKLocations : INC : STA.l PreGTBKLocations -RTS - -.maybeIncrementBombs - LDA.l InventoryTracking+1 : AND.b #$02 : BNE + - LDA.l InventoryTracking+1 : ORA.b #$02 : STA.l InventoryTracking+1 - JSR .incrementY - + -RTS - -.incrementMap - %TopHalf(MapsCompasses) -RTS - -.incrementBossSwordLong - JSR .incrementBossSword -RTL - -.incrementBossSword - LDA.l SwordEquipment - BNE + : - - LDA.l SwordlessBossKills : INC : STA.l SwordlessBossKills - RTS - + CMP.b #$FF : BEQ - - + CMP.b #$01 : BNE + - %TopHalf(SwordBossKills) : RTS - + CMP.b #$02 : BNE + - %BottomHalf(SwordBossKills) : RTS - + CMP.b #$03 : BNE + - %TopHalf(SwordBossKills+1) : RTS - + CMP.b #$04 : BNE + - %BottomHalf(SwordBossKills+1) - + -RTS - -.setDungeonCompletion - LDX.w DungeonID : BMI + - REP #$20 ; 16 bit - LDA.l DungeonMask, X - ORA.l DungeonsCompleted : STA.l DungeonsCompleted - SEP #$20 ; 8 bit - + -RTS -;-------------------------------------------------------------------------------- - -;-------------------------------------------------------------------------------- -; Link_ReceiveItem_HUDRefresh: ;-------------------------------------------------------------------------------- Link_ReceiveItem_HUDRefresh: LDA.l BombsEquipment : BNE + ; skip if we have bombs @@ -936,7 +852,6 @@ CollectPowder: + STZ.w ItemReceiptMethod ; item from NPC JSL.l Link_ReceiveItem - ;JSL.l FullInventoryExternal JSL.l ItemSet_Powder RTL ;-------------------------------------------------------------------------------- diff --git a/newitems.asm b/newitems.asm index 1f5385c..a3a2857 100755 --- a/newitems.asm +++ b/newitems.asm @@ -125,35 +125,6 @@ macro ValueShift() BRA ?start : ?end: endmacro ;-------------------------------------------------------------------------------- -GetDungeonBitByID: - LDA.w #$8000 - CPX.w #$0000 : BEQ .castle - DEX - - - LSR - DEX - BPL - - RTS - - .castle - LSR -RTS -;-------------------------------------------------------------------------------- -GetDungeonBitByOffset: - LDA.w #$0001 - CPX.w #$000E : BEQ .castle - CPX.w #$000F : BEQ .castle - DEX - - - ASL - DEX - BPL - - RTS - - .castle - LDA.w #$00C0 -RTS -;-------------------------------------------------------------------------------- ;carry clear if pass ;carry set if caught ;incsrc eventdata.asm @@ -221,6 +192,126 @@ ItemBehavior: .skip RTS + .blue_boomerang + LDA.l InventoryTracking : ORA.b #$80 + BRA .store_inventory_tracking + + .red_boomerang + LDA.l InventoryTracking : ORA.b #$40 + BRA .store_inventory_tracking + + .mushroom + LDA.l InventoryTracking : ORA.b #$28 + BRA .store_inventory_tracking + + .powder + LDA.l InventoryTracking : ORA.b #$10 + BRA .store_inventory_tracking + + .flute_inactive + LDA.l InventoryTracking : ORA.b #$02 + BRA .store_inventory_tracking + + .flute_active + LDA.l InventoryTracking : ORA.b #$01 + BRA .store_inventory_tracking + + .store_inventory_tracking + STA.l InventoryTracking + RTS + + .fighter_sword_shield + SEP #$10 + LDX.b #$01 + JSR .increment_sword + JSR .increment_shield + REP #$10 + RTS + + .master_sword + SEP #$10 + LDX.b #$02 + JSR .increment_sword + REP #$10 + RTS + + .tempered_sword + SEP #$10 + LDX.b #$03 + JSR .increment_sword + REP #$10 + RTS + + .gold_sword + SEP #$10 + LDX.b #$04 + JSR .increment_sword + REP #$10 + RTS + + .fighter_shield + SEP #$10 + LDX.b #$01 + JSR .increment_shield + REP #$10 + RTS + + .red_shield + SEP #$10 + LDX.b #$02 + JSR .increment_shield + REP #$10 + RTS + + .mirror_shield + SEP #$10 + LDX.b #$03 + JSR .increment_shield + REP #$10 + RTS + + .blue_mail + SEP #$10 + LDX.b #$01 + JSR .increment_mail + REP #$10 + RTS + + .red_mail + SEP #$10 + LDX.b #$02 + JSR .increment_mail + REP #$10 + RTS + + .fighter_sword + SEP #$10 + LDX.b #$01 + JSR .increment_sword + REP #$10 + RTS + + .prog_sword + SEP #$10 + LDA.l SwordEquipment : INC : TAX + JSR .increment_sword + REP #$10 + RTS + + .prog_shield + SEP #$10 + LDA.l ShieldEquipment : INC : TAX + JSR .increment_shield + REP #$10 + RTS + + .prog_mail + SEP #$10 + LDA.l ArmorEquipment : INC : TAX + JSR .increment_mail + REP #$10 + RTS + .bow LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking BIT #$40 : BNE .silversbow @@ -236,27 +327,34 @@ ItemBehavior: .dungeon_compass REP #$20 - LDA.w DungeonID : LSR : TAX - JSR.w GetDungeonBitByID - ORA.l CompassField : STA.l CompassField - SEP #$20 - RTS + LDA.w DungeonID : CMP.w #$0003 : BCC ..hc_sewers + TAX + LDA.l DungeonMask,X : ORA.l CompassField : STA.l CompassField + JMP.w .increment_compass + ..hc_sewers + LDA.w #$C000 : ORA.l CompassField : STA.l CompassField + JMP.w .increment_compass + .dungeon_bigkey REP #$20 - LDA.w DungeonID : LSR : TAX - JSR.w GetDungeonBitByID - ORA.l BigKeyField : STA.l BigKeyField - SEP #$20 - RTS + LDA.w DungeonID : CMP.w #$0003 : BCC ..hc_sewers + TAX + LDA.l DungeonMask,X : ORA.l BigKeyField : STA.l BigKeyField + JMP.w .increment_bigkey + ..hc_sewers + LDA.w #$C000 : ORA.l BigKeyField : STA.l BigKeyField + JMP.w .increment_bigkey .dungeon_map REP #$20 - LDA.w DungeonID : LSR : TAX - JSR.w GetDungeonBitByID - ORA.l MapField : STA.l MapField - SEP #$20 - RTS + LDA.w DungeonID : CMP.w #$0003 : BCC ..hc_sewers + TAX + LDA.l DungeonMask,X : ORA.l MapField : STA.l MapField + JMP.w .increment_map + ..hc_sewers + LDA.w #$C000 : ORA.l MapField : STA.l MapField + JMP.w .increment_map .bow_and_arrows BIT.b #$40 : BEQ + @@ -302,9 +400,12 @@ ItemBehavior: RTS .master_sword_safe + SEP #$10 LDA.l SwordEquipment : CMP.b #$02 : !BGE + ; skip if we have a better sword LDA.b #$02 : STA.l SwordEquipment ; set master sword + + LDX.b #$02 + JSR .increment_sword RTS .bombs_5 @@ -413,50 +514,57 @@ ItemBehavior: .free_map REP #$20 - AND.w #$000F : LSR : TAX - JSR.w GetDungeonBitByOffset - ORA.l MapField : STA.l MapField + AND.w #$000F : ASL : TAX + LDA.w DungeonItemIDMap,X : TAX + LDA.l DungeonMask,X : ORA.l MapField : STA.l MapField SEP #$20 - RTS + JMP.w .increment_map .hc_map LDA.b #$C0 : ORA.l MapField+1 : STA.l MapField+1 - RTS + JMP.w .increment_map .free_compass REP #$20 - AND.w #$000F : LSR : TAX - JSR.w GetDungeonBitByOffset - ORA.l CompassField : STA.l CompassField + AND.w #$000F : ASL : TAX + LDA.w DungeonItemIDMap,X : TAX + LDA.l DungeonMask,X : ORA.l CompassField : STA.l CompassField SEP #$20 - RTS + JMP.w .increment_compass .hc_compass LDA.b #$C0 : ORA.l CompassField+1 : STA.l CompassField+1 - RTS + JMP.w .increment_compass .free_bigkey REP #$20 - AND.w #$000F : LSR : TAX - JSR.w GetDungeonBitByOffset - ORA.l BigKeyField : STA.l BigKeyField + AND.w #$000F : ASL : TAX + LDA.w DungeonItemIDMap,X : TAX + LDA.l DungeonMask,X : ORA.l BigKeyField : STA.l BigKeyField SEP #$20 - RTS + JMP.w .increment_bigkey .hc_bigkey LDA.b #$C0 : ORA.l BigKeyField+1 : STA.l BigKeyField+1 - RTS + JMP.w .increment_bigkey .free_smallkey REP #$20 AND.w #$000F : TAX - LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X ; Increment Key Count + ASL : CMP.w DungeonID : BEQ .same_dungeon + LSR : TAX + LDA.l DungeonKeys,X : INC : STA.l DungeonKeys,X + RTS + .same_dungeon + SEP #$20 + LDA.l CurrentSmallKeys : INC : STA.l CurrentSmallKeys RTS .hc_smallkey - LDA.l HyruleCastleKeys : INC : STA.l HyruleCastleKeys - LDA.l SewerKeys : INC : STA.l SewerKeys - RTS + LDA.w DungeonID : CMP.b #$03 : BCC .same_dungeon + LDA.l HyruleCastleKeys : INC : STA.l HyruleCastleKeys + LDA.l SewerKeys : INC : STA.l SewerKeys + RTS .generic_smallkey LDA.l GenericKeys : BEQ .normal @@ -464,8 +572,50 @@ ItemBehavior: RTS .normal LDA.w DungeonID : CMP.b #$FF : BEQ .done - LSR : TAX - LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X + LDA.l CurrentSmallKeys : INC : STA.l CurrentSmallKeys + + .increment_sword + LDA.l HighestSword + INC : STA.b Scrap04 : CPX.b Scrap04 : !BLT + ; don't increment unless we're getting a better sword + TXA : STA.l HighestSword + + + RTS + + .increment_shield + LDA.l HighestShield + INC : STA.b Scrap04 : CPX.b Scrap04 : !BLT + ; don't increment unless we're getting a better shield + TXA : STA.l HighestShield + + + RTS + + .increment_mail + LDA.l HighestMail + INC : STA.b Scrap04 : CPX.b Scrap04 : !BLT + ; don't increment unless we're getting a better mail + TXA : STA.l HighestMail + + + RTS + + .increment_bigkey + SEP #$30 + LDA.l BigKeysBigChests + CLC : ADC.b #$10 + STA.l BigKeysBigChests + RTS + + .increment_map + SEP #$30 + LDA.l MapsCompasses + CLC : ADC.b #$10 + STA.l MapsCompasses + RTS + + .increment_compass + SEP #$30 + LDA.l MapsCompasses : INC : AND.b #$0F : TAX + LDA.l MapsCompasses : AND.b #$F0 : STA.l MapsCompasses + TXA : ORA.l MapsCompasses : STA.l MapsCompasses + JSL MaybeFlagCompassTotalPickup + .done RTS @@ -520,19 +670,21 @@ ResolveLootID: ..ids db $4E, $4F, $4F - .swords - LDA.l HighestSword : CMP.l ProgressiveSwordLimit : BCC + + .prog_sword + LDA.l HighestSword + CMP.l ProgressiveSwordLimit : BCC + LDA.l ProgressiveSwordReplacement JMP.w .get_item + TAX - LDA.w ResolveLootID_swords_ids,X + LDA.w ResolveLootID_prog_sword_ids,X JMP.w .have_item ..ids - db $49, $01, $02, $03, $03 + db $49, $50, $02, $03, $03 .shields - LDA.l HighestShield : CMP.l ProgressiveShieldLimit : BCC + + LDA.l HighestShield + CMP.l ProgressiveShieldLimit : BCC + LDA.l ProgressiveShieldReplacement JMP.w .get_item + @@ -543,7 +695,8 @@ ResolveLootID: db $04, $05, $06, $06 .armor - LDA.l HighestMail : CMP.l ProgressiveArmorLimit : BCC + + LDA.l HighestMail + CMP.l ProgressiveArmorLimit : BCC + LDA.l ProgressiveArmorReplacement JMP.w .get_item + @@ -552,6 +705,7 @@ ResolveLootID: ..ids db $22, $23, $23 + .gloves LDA.l GloveEquipment : TAX LDA.w ResolveLootID_gloves_ids,X @@ -565,6 +719,7 @@ ResolveLootID: JMP.w .get_item + TAX + LDA.b #$80 : STA.l BowTrackingFlags LDA.w ResolveLootID_bows_ids,X JMP.w .get_item @@ -574,6 +729,7 @@ ResolveLootID: JMP.w .get_item + TAX + LDA.b #$20 : STA.l BowTrackingFlags LDA.w ResolveLootID_bows_ids,X JMP.w .get_item @@ -654,27 +810,27 @@ macro ReceiptProps(id, y, x, gfx, width, pal, sram, value, pal_override, behavio endmacro -%ReceiptProps($00, -5, 0, $06, 2, $02, $F359, $01, $00, skip, skip) ; 00 - Fighter sword & Shield -%ReceiptProps($01, -5, 4, $18, 0, $FF, $F359, $02, $00, skip, skip) ; 01 - Master sword - TODO gfx value? -%ReceiptProps($02, -5, 4, $18, 0, $05, $F359, $03, $00, skip, skip) ; 02 - Tempered sword - TODO gfx value? -%ReceiptProps($03, -5, 4, $18, 0, $05, $F359, $04, $00, skip, skip) ; 03 - Butter sword - TODO gfx value? -%ReceiptProps($04, -5, 4, $2D, 0, $05, $F35A, $01, $01, skip, skip) ; 04 - Fighter shield -%ReceiptProps($05, -4, 0, $20, 2, $05, $F35A, $02, $01, skip, skip) ; 05 - Fire shield -%ReceiptProps($06, -4, 0, $2E, 2, $05, $F35A, $03, $01, skip, skip) ; 06 - Mirror shield +%ReceiptProps($00, -5, 0, $06, 2, $02, $F359, $01, $00, fighter_sword_shield, skip) ; 00 - Fighter sword & Shield +%ReceiptProps($01, -5, 4, $18, 0, $FF, $F359, $02, $00, master_sword, skip) ; 01 - Master sword +%ReceiptProps($02, -5, 4, $18, 0, $05, $F359, $03, $00, tempered_sword, skip) ; 02 - Tempered sword +%ReceiptProps($03, -5, 4, $18, 0, $05, $F359, $04, $00, gold_sword, skip) ; 03 - Golden sword +%ReceiptProps($04, -5, 4, $2D, 0, $05, $F35A, $01, $01, fighter_shield, skip) ; 04 - Fighter shield +%ReceiptProps($05, -4, 0, $20, 2, $05, $F35A, $02, $01, red_shield, skip) ; 05 - Fire shield +%ReceiptProps($06, -4, 0, $2E, 2, $05, $F35A, $03, $01, mirror_shield, skip) ; 06 - Mirror shield %ReceiptProps($07, -5, 4, $09, 0, $01, $F345, $01, $00, skip, skip) ; 07 - Fire rod %ReceiptProps($08, -5, 4, $09, 0, $02, $F346, $01, $00, skip, skip) ; 08 - Ice rod %ReceiptProps($09, -4, 4, $0A, 0, $01, $F34B, $01, $00, skip, skip) ; 09 - Hammer %ReceiptProps($0A, -4, 4, $08, 0, $01, $F342, $01, $00, skip, skip) ; 0A - Hookshot %ReceiptProps($0B, -4, 4, $05, 0, $01, $F340, $01, $00, bow, skip) ; 0B - Bow -%ReceiptProps($0C, -2, 5, $10, 0, $02, $F341, $01, $00, skip, skip) ; 0C - Blue Boomerang -%ReceiptProps($0D, -4, 0, $0B, 2, $02, $F344, $02, $00, skip, skip) ; 0D - Powder +%ReceiptProps($0C, -2, 5, $10, 0, $02, $F341, $01, $00, blue_boomerang, skip) ; 0C - Blue Boomerang +%ReceiptProps($0D, -4, 0, $0B, 2, $02, $F344, $02, $00, powder, skip) ; 0D - Powder %ReceiptProps($0E, -4, 0, $2C, 2, $02, $F35C, $FF, $00, skip, skip) ; 0E - Bottle refill (bee) %ReceiptProps($0F, -4, 0, $1B, 2, $04, $F347, $01, $00, skip, skip) ; 0F - Bombos %ReceiptProps($10, -4, 0, $1A, 2, $04, $F348, $01, $00, skip, skip) ; 10 - Ether %ReceiptProps($11, -4, 0, $1C, 2, $04, $F349, $01, $00, skip, skip) ; 11 - Quake %ReceiptProps($12, -4, 0, $14, 2, $01, $F34A, $01, $00, skip, skip) ; 12 - Lamp %ReceiptProps($13, -4, 4, $19, 0, $01, $F34C, $01, $00, skip, skip) ; 13 - Shovel -%ReceiptProps($14, -4, 0, $0C, 2, $02, $F34C, $02, $00, skip, skip) ; 14 - Flute +%ReceiptProps($14, -4, 0, $0C, 2, $02, $F34C, $02, $00, flute_inactive, skip) ; 14 - Flute %ReceiptProps($15, -4, 4, $07, 0, $01, $F350, $01, $00, skip, skip) ; 15 - Somaria %ReceiptProps($16, -4, 0, $1D, 2, $01, $F35C, $FF, $00, skip, bottles) ; 16 - Bottle %ReceiptProps($17, -4, 0, $2F, 2, $01, $F36B, $FF, $00, skip, skip) ; 17 - Heart piece @@ -688,15 +844,15 @@ endmacro %ReceiptProps($1F, -4, 0, $17, 2, $01, $F357, $01, $00, skip, skip) ; 1F - Pearl %ReceiptProps($20, -4, 0, $28, 2, $06, $F37A, $FF, $01, skip, skip) ; 20 - Crystal %ReceiptProps($21, -4, 0, $27, 2, $01, $F34D, $01, $00, skip, skip) ; 21 - Net -%ReceiptProps($22, -4, 0, $04, 2, $02, $F35B, $FF, $00, skip, skip) ; 22 - Blue mail -%ReceiptProps($23, -5, 0, $04, 2, $01, $F35B, $02, $00, skip, skip) ; 23 - Red mail +%ReceiptProps($22, -4, 0, $04, 2, $02, $F35B, $FF, $00, blue_mail, skip) ; 22 - Blue mail +%ReceiptProps($23, -5, 0, $04, 2, $01, $F35B, $02, $00, red_mail, skip) ; 23 - Red mail %ReceiptProps($24, -4, 4, $0F, 0, $02, $F36F, $FF, $00, skip, skip) ; 24 - Small key %ReceiptProps($25, -4, 0, $16, 2, $02, $F364, $FF, $00, dungeon_compass, skip) ; 25 - Compass %ReceiptProps($26, -4, 0, $03, 2, $01, $F36C, $FF, $00, skip, skip) ; 26 - Heart container from 4/4 %ReceiptProps($27, -4, 0, $13, 2, $02, $F375, $FF, $00, skip, skip) ; 27 - Bomb %ReceiptProps($28, -4, 0, $01, 2, $02, $F375, $FF, $00, skip, skip) ; 28 - 3 bombs -%ReceiptProps($29, -4, 0, $1E, 2, $04, $F344, $FF, $00, skip, skip) ; 29 - Mushroom -%ReceiptProps($2A, -2, 5, $10, 0, $01, $F341, $02, $00, skip, skip) ; 2A - Red boomerang +%ReceiptProps($29, -4, 0, $1E, 2, $04, $F344, $FF, $00, mushroom, skip) ; 29 - Mushroom +%ReceiptProps($2A, -2, 5, $10, 0, $01, $F341, $02, $00, red_boomerang, skip) ; 2A - Red boomerang %ReceiptProps($2B, -4, 0, $00, 2, $01, $F35C, $FF, $00, skip, bottles) ; 2B - Full bottle (red) %ReceiptProps($2C, -4, 0, $00, 2, $04, $F35C, $FF, $00, skip, bottles) ; 2C - Full bottle (green) %ReceiptProps($2D, -4, 0, $00, 2, $02, $F35C, $FF, $00, skip, bottles) ; 2D - Full bottle (blue) @@ -727,14 +883,15 @@ endmacro %ReceiptProps($46, -4, 0, $36, 2, $04, $F360, $FF, $00, skip, skip) ; 46 - 300 rupees %ReceiptProps($47, -4, 0, $37, 2, $04, $F360, $FF, $00, skip, skip) ; 47 - 20 rupees green %ReceiptProps($48, -4, 0, $2C, 2, $02, $F35C, $FF, $00, skip, skip) ; 48 - Full bottle (good bee) -%ReceiptProps($49, -5, 4, $06, 0, $05, $F359, $01, $00, skip, skip) ; 49 - Tossed fighter sword -%ReceiptProps($4A, -4, 0, $0C, 2, $02, $F34C, $03, $00, skip, skip) ; 4A - Active Flute +%ReceiptProps($49, -5, 4, $06, 0, $05, $F359, $01, $00, fighter_sword, skip) ; 49 - Tossed fighter sword +%ReceiptProps($50, -5, 4, $06, 0, $05, $F359, $01, $00, skip, skip) ; 50 - Master Sword (safe) +%ReceiptProps($4A, -4, 0, $0C, 2, $02, $F34C, $03, $00, flute_active, skip) ; 4A - Active Flute %ReceiptProps($4B, -4, 0, $38, 2, $01, $F355, $01, $00, skip, skip) ; 4B - Boots %ReceiptProps($4C, -4, 0, $39, 2, $04, $F375, $32, $00, bombs_50, skip) ; 4C - Bomb capacity (50) %ReceiptProps($4D, -4, 0, $3A, 2, $04, $F376, $46, $00, arrows_70, skip) ; 4D - Arrow capacity (70) %ReceiptProps($4E, -4, 0, $3B, 2, $04, $F373, $80, $00, magic_2, magic) ; 4E - 1/2 magic %ReceiptProps($4F, -4, 0, $3C, 2, $04, $F373, $80, $00, magic_4, magic) ; 4F - 1/4 magic -%ReceiptProps($50, -5, 4, $18, 0, $05, $F359, $02, $00, master_sword_safe, skip) ; 50 - Safe master sword - TODO gfx value +%ReceiptProps($50, -5, 4, $18, 0, $05, $F359, $02, $00, master_sword_safe, skip) ; 50 - Safe master sword %ReceiptProps($51, -4, 0, $42, 2, $04, $F375, $FF, $00, bombs_5, skip) ; 51 - Bomb capacity (+5) %ReceiptProps($52, -4, 0, $3E, 2, $04, $F375, $FF, $00, bombs_10, skip) ; 52 - Bomb capacity (+10) %ReceiptProps($53, -4, 0, $3F, 2, $04, $F376, $FF, $00, arrows_5, skip) ; 53 - Arrow capacity (+5) @@ -748,9 +905,9 @@ endmacro %ReceiptProps($5B, -4, 0, $4B, 2, $01, $F454, $FF, $00, red_clock, skip) ; 5B - Red clock %ReceiptProps($5C, -4, 0, $4B, 2, $02, $F454, $FF, $00, blue_clock, skip) ; 5C - Blue clock %ReceiptProps($5D, -4, 0, $4B, 2, $04, $F454, $FF, $00, green_clock, skip) ; 5D - Green clock -%ReceiptProps($5E, -4, 0, $FE, 2, $FF, $F359, $FF, $00, skip, swords) ; 5E - Progressive sword -%ReceiptProps($5F, -4, 0, $FF, 2, $FF, $F35A, $FF, $01, skip, shields) ; 5F - Progressive shield -%ReceiptProps($60, -4, 0, $FD, 2, $FF, $F35B, $FF, $00, skip, armor) ; 60 - Progressive armor +%ReceiptProps($5E, -4, 0, $FE, 2, $FF, $F359, $FF, $00, prog_sword, prog_sword) ; 5E - Progressive sword +%ReceiptProps($5F, -4, 0, $FF, 2, $FF, $F35A, $FF, $01, prog_shield, shields) ; 5F - Progressive shield +%ReceiptProps($60, -4, 0, $FD, 2, $FF, $F35B, $FF, $00, prog_mail, armor) ; 60 - Progressive armor %ReceiptProps($61, -4, 0, $0D, 2, $FF, $F354, $FF, $00, skip, gloves) ; 61 - Progressive glove %ReceiptProps($62, -4, 0, $FF, 2, $FF, $F36A, $FF, $00, skip, rng_single) ; 62 - RNG pool item (single) %ReceiptProps($63, -4, 0, $FF, 2, $FF, $F36A, $FF, $00, skip, rng_multi) ; 63 - RNG pool item (multi) @@ -792,7 +949,7 @@ endmacro %ReceiptProps($87, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 87 - Compass of Skull Woods %ReceiptProps($88, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 88 - Compass of Misery Mire %ReceiptProps($89, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 89 - Compass of Dark Palace -%ReceiptProps($8A, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 8A - Compass of Swamp Palace +%ReceiptProps($8A, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 8A - Compass of4Swamp Palace %ReceiptProps($8B, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 8B - Compass of Agahnim's Tower %ReceiptProps($8C, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 8C - Compass of Desert Palace %ReceiptProps($8D, -4, 0, $16, 2, $02, $F36A, $FF, $00, free_compass, skip) ; 8D - Compass of Eastern Palace @@ -1221,3 +1378,21 @@ MaybeFlagCompassTotalEntrance: .done RTL ;-------------------------------------------------------------------------------- +DungeonItemIDMap: ; Maps lower four bits of our new dungeon items to DungeonID +db $FFFF +db $FFFF +db $001A ; GT +db $0018 ; TR +db $0016 ; TT +db $0014 ; TH +db $0012 ; IP +db $0010 ; SW +db $000E ; MM +db $000C ; PD +db $000A ; SP +db $0008 ; CT +db $0006 ; DP +db $0004 ; EP +db $0002 ; HC +db $0000 ; SW + diff --git a/pendantcrystalhud.asm b/pendantcrystalhud.asm index 2a3b49e..e0edb7b 100644 --- a/pendantcrystalhud.asm +++ b/pendantcrystalhud.asm @@ -186,7 +186,7 @@ RTL UpdateKeys: PHX : PHP SEP #$30 ; set 8-bit accumulator & index registers - LDA.w DungeonID : CMP.b TSWQ : !BLT .skip + LDA.w DungeonID : CMP.b #$1F : !BLT .skip LSR : TAX ; get dungeon index and store to X @@ -285,7 +285,7 @@ DrawHUDDungeonItems: .dungeon_bitmasks - dw $4000 ; Hyrule Castle + dw $C000 ; Hyrule Castle dw $2000 ; Eastern dw $1000 ; Desert dw $0020 ; Hera diff --git a/ram.asm b/ram.asm index ea376db..b7fa837 100644 --- a/ram.asm +++ b/ram.asm @@ -477,7 +477,7 @@ BossKills: skip 1 ; LagTime: skip 4 ; Computed during stats preparation for display RupeesCollected: skip 2 ; Computed during stats preparation for display NonChestCounter: skip 2 ; Computed during stats preparation for display -skip 2 ; Unused +BowTrackingFlags: skip 2 ; Stores tracking bits for progressive bows before resolution to concrete item. TileUploadOffsetOverride: skip 2 ; Offset override for loading sprite gfx skip 3 ; skip 9 ; diff --git a/save.asm b/save.asm index 5f7204d..15499fc 100644 --- a/save.asm +++ b/save.asm @@ -14,11 +14,13 @@ WriteSaveChecksumAndBackup: STA.l InverseChecksumSRAM PHB - LDA.w #$14FF ; \ - LDX.w #CartridgeSRAM&$FFFF ; | Copies $1500 bytes from beginning of cart SRAM to - LDY.w #SaveBackupSRAM&$FFFF ; | $704000 - MVN !SRAMBank, !SRAMBank ; / + LDA.w #$14FF ; \ + LDX.w #CartridgeSRAM ; | Copies $1500 bytes from beginning of cart SRAM to + LDY.w #SaveBackupSRAM ; | $704000 + MVN !SRAMBank, !SRAMBank ; / PLB + TDC + TAX RTL ;-------------------------------------------------------------------------------- @@ -51,10 +53,10 @@ ValidateSRAM: TDC : STA.l FileValiditySRAM ; Delete save by way of zeroing validity marker BRA .goodchecksum : + PHB - LDA.w #$14FF ; \ - LDX.w #SaveBackupSRAM&$FFFF ; | Copies $1500 bytes from backup on cart SRAM to - LDY.w #CartridgeSRAM&$FFFF ; | main save location at $700000 - MVN !SRAMBank, !SRAMBank ; / + LDA.w #$14FF ; \ + LDX.w #SaveBackupSRAM ; | Copies $1500 bytes from backup on cart SRAM to + LDY.w #CartridgeSRAM ; | main save location at $700000 + MVN !SRAMBank, !SRAMBank ; / PLB .goodchecksum @@ -131,88 +133,23 @@ RTL ;-------------------------------------------------------------------------------- CopyExtendedSaveFileToWRAM: PHA - SEP #$30 - LDA.w DMAP0 : PHA ; preserve DMA parameters - LDA.w BBAD0 : PHA ; preserve DMA parameters - LDA.w A1T0L : PHA ; preserve DMA parameters - LDA.w A1T0H : PHA ; preserve DMA parameters - LDA.w A1B0 : PHA ; preserve DMA parameters - LDA.w DAS0L : PHA ; preserve DMA parameters - LDA.w DAS0H : PHA ; preserve DMA parameters - ;-------------------------------------------------------------------------------- - STZ.w NMITIMEN ; Disable NMI, V/H, joypad - STZ.w HDMAEN ; Disable HDMA - LDA.b #$00 : STA.w DMAP0 ; set DMA transfer direction A -> B, bus A auto increment, single-byte mode - - LDA.b #$80 : STA.w BBAD0 ; set bus B source to WRAM register - - LDA.b #$00 : STA.w WMADDL ; set WRAM register source address - LDA.b #$60 : STA.w WMADDH - LDA.b #$7F : STA.w WMADDB - - STZ.w A1T0L ; set bus A destination address to SRAM - LDA.b #$05 : STA.w A1T0H - LDA.b #$70 : STA.w A1B0 - - LDA.b #$00 : STA.w DAS0L ; set transfer size to 0x1000 - LDA.b #$10 : STA.w DAS0H ; STZ DAS0B - - LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer - LDA.b #$81 : STA.w NMITIMEN ; Re-enable NMI and joypad - ;-------------------------------------------------------------------------------- - PLA : STA.w DAS0H ; restore DMA parameters - PLA : STA.w DAS0L ; restore DMA parameters - PLA : STA.w A1B0 ; restore DMA parameters - PLA : STA.w A1T0H ; restore DMA parameters - PLA : STA.w A1T0L ; restore DMA parameters - PLA : STA.w BBAD0 ; restore DMA parameters - PLA : STA.w DMAP0 ; restore DMA parameters - REP #$30 + PHB + LDA.w #$0FFF + LDX.w #ExtendedSaveDataSRAM + LDY.w #ExtendedSaveDataWRAM + MVN $7F, !SRAMBank + PLB PLA - STA.l $7EC00D ; what we wrote over + STA.l $7EC00D ; What we wrote over. Keep this write last. RTL ;-------------------------------------------------------------------------------- CopyExtendedWRAMSaveFileToSRAM: - PHA PHB - SEP #$30 - LDA.b #$00 : PHA : PLB - LDA.w DMAP0 : PHA ; preserve DMA parameters - LDA.w BBAD0 : PHA ; preserve DMA parameters - LDA.w A1T0L : PHA ; preserve DMA parameters - LDA.w A1T0H : PHA ; preserve DMA parameters - LDA.w A1B0 : PHA ; preserve DMA parameters - LDA.w DAS0L : PHA ; preserve DMA parameters - LDA.w DAS0H : PHA ; preserve DMA parameters - ;-------------------------------------------------------------------------------- - STZ.w NMITIMEN ; Disable NMI, V/H, joypad - STZ.w HDMAEN ; Disable HDMA - LDA.b #$80 : STA.w DMAP0 ; set DMA transfer direction B -> A, bus A auto increment, single-byte mode - - STA.w BBAD0 ; set bus B source to WRAM register - - LDA.b #$00 : STA.w WMADDL ; set WRAM register source address - LDA.b #$60 : STA.w WMADDH - LDA.b #$7F : STA.w WMADDB - - STZ.w A1T0L ; set bus A destination address to SRAM - LDA.b #$05 : STA.w A1T0H - LDA.b #$70 : STA.w A1B0 - - LDA.b #$10 : STA.w DAS0L ; set transfer size to 0xB00 - LDA.b #$0B : STA.w DAS0H ; STZ DAS0B - - LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer - LDA.b #$81 : STA.w NMITIMEN; Re-enable NMI and joypad - ;-------------------------------------------------------------------------------- - PLA : STA.w DAS0H ; restore DMA parameters - PLA : STA.w DAS0L ; restore DMA parameters - PLA : STA.w A1B0 ; restore DMA parameters - PLA : STA.w A1T0H ; restore DMA parameters - PLA : STA.w A1T0L ; restore DMA parameters - PLA : STA.w BBAD0 ; restore DMA parameters - PLA : STA.w DMAP0 ; restore DMA parameters - REP #$30 + LDA.w #$0FFF + LDX.w #ExtendedSaveDataSRAM + LDY.w #ExtendedSaveDataWRAM + MVN !SRAMBank, $7F PLB - PLA + TDC + TAX RTL diff --git a/sram.asm b/sram.asm index ce6c039..c1e3c10 100644 --- a/sram.asm +++ b/sram.asm @@ -381,6 +381,7 @@ InverseChecksumWRAM: skip 2 ; Vanilla Inverse Checksum. Don't write unless c ; beginning at $700500 ;-------------------------------------------------------------------------------- base $7F6000 ; $1000 byte buffer we place beginning at second save file +ExtendedSaveDataWRAM: ; ExtendedFileNameWRAM: skip 24 ; File name, 12 word-length characters. RoomPotData: skip 592 ; Table for expanded pot shuffle. One word per room. SpritePotData: skip 592 ; Table for expanded pot shuffle. One word per room. @@ -413,6 +414,7 @@ FileNameVanillaSRAM: skip 8 ; First four characters of file name FileValiditySRAM: skip 2 ; skip 283 ; InverseChecksumSRAM: skip 2 ; +ExtendedSaveDataSRAM: ; ExtendedFileNameSRAM: skip 24 ; We read and write the file name directly from and to SRAM (24 bytes) skip $1AE4 ; RomVersionSRAM: skip 4 ; ALTTPR ROM version. Low byte is the version, high byte writes @@ -654,6 +656,7 @@ endmacro %assertSRAM(GTCollectedKeys, $7EF4ED) %assertSRAM(FileMarker, $7EF4F0) ;-------------------------------------------------------------------------------- +%assertSRAM(ExtendedSaveDataWRAM, $7F6000) %assertSRAM(ExtendedFileNameWRAM, $7F6000) %assertSRAM(RoomPotData, $7F6018) %assertSRAM(SpritePotData, $7F6268) @@ -676,6 +679,7 @@ endmacro %assertSRAM(FileNameVanillaSRAM, $7003D9) %assertSRAM(FileValiditySRAM, $7003E1) %assertSRAM(InverseChecksumSRAM, $7004FE) +%assertSRAM(ExtendedSaveDataSRAM, $700500) %assertSRAM(ExtendedFileNameSRAM, $700500) %assertSRAM(RomVersionSRAM, $701FFC) %assertSRAM(RomNameSRAM, $702000) diff --git a/stats.asm b/stats.asm index 3eaf2a6..62ab9d6 100644 --- a/stats.asm +++ b/stats.asm @@ -78,31 +78,35 @@ IncrementSmallKeys: STA.l CurrentSmallKeys ; thing we wrote over, write small key count PHX LDA.l StatsLocked : BNE + - JSL AddInventory_incrementKeyLong + LDA.l SmallKeyCounter : INC : STA.l SmallKeyCounter + JSL.l UpdateKeys - PHY : LDY.b #24 : JSL.l FullInventoryExternal : PLY + PHY : LDY.b #24 : JSL.l AddInventory : PLY JSL.l HUD_RebuildLong PLX RTL ;-------------------------------------------------------------------------------- IncrementSmallKeysNoPrimary: - STA.l CurrentSmallKeys ; thing we wrote over, write small key count - PHX - LDA.l StatsLocked : BNE + - JSL AddInventory_incrementKeyLong - + - JSL.l UpdateKeys - LDA.b IndoorsFlag : BEQ + ; skip room check if outdoors - PHP : REP #$20 ; set 16-bit accumulator - LDA.b RoomIndex : CMP.w #$0087 : BNE ++ ; hera basement - PLP : PHY : LDY.b #$24 : JSL.l FullInventoryExternal - JSR CountChestKey : PLY : BRA + - ++ - PLP - + - JSL.l HUD_RebuildLong - PLX + STA.l CurrentSmallKeys ; thing we wrote over, write small key count + PHX + LDA.l StatsLocked : BNE + + LDA.l SmallKeyCounter : INC : STA.l SmallKeyCounter + + + JSL.l UpdateKeys + LDA.b IndoorsFlag : BEQ + ; skip room check if outdoors + PHP : REP #$20 ; set 16-bit accumulator + LDA.b RoomIndex : CMP.w #$0087 : BNE ++ ; hera basement + PLP : PHY + LDY.b #$24 + JSL.l AddInventory + JSR CountChestKey + PLY + BRA + + ++ + PLP + + + JSL.l HUD_RebuildLong + PLX RTL ;-------------------------------------------------------------------------------- DecrementSmallKeys: @@ -150,7 +154,7 @@ RTL IncrementAgahnim2Sword: PHA LDA.l StatsLocked : BNE + - JSL AddInventory_incrementBossSwordLong + JSL.l IncrementBossSword + PLA RTL @@ -209,12 +213,14 @@ DecrementItemCounter: RTL ;-------------------------------------------------------------------------------- IncrementBigChestCounter: - JSL.l Dungeon_SaveRoomQuadrantData ; thing we wrote over - PHA - LDA.l StatsLocked : BNE + - %BottomHalf(BigKeysBigChests) - + - PLA + JSL.l Dungeon_SaveRoomQuadrantData ; thing we wrote over + PHA + LDA.l StatsLocked : BNE + + LDA.l BigKeysBigChests : INC : AND.b #$0F : TAX + LDA.l BigKeysBigChests : AND.b #$F0 : STA.l BigKeysBigChests + TXA : ORA.l BigKeysBigChests : STA.l BigKeysBigChests + + + PLA RTL ;-------------------------------------------------------------------------------- IncrementDamageTakenCounter_Eight: @@ -327,7 +333,7 @@ StatsFinalPrep: LDA.l StatsLocked : BNE .ramPostOnly INC : STA.l StatsLocked - JSL.l AddInventory_incrementBossSwordLong + JSL.l IncrementBossSword LDA.l HighestMail : INC : STA.l HighestMail ; add green mail to mail count diff --git a/tables.asm b/tables.asm index a6bb7bb..0dee045 100644 --- a/tables.asm +++ b/tables.asm @@ -2555,8 +2555,8 @@ db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; 0x186C00 - 186FFE (unused) ;-------------------------------------------------------------------------------- org $B0EFFF ; PC 0x186FFF -BallNChainDungeon: -db $02 +BallNChainDungeon: ; Dungeon ID where ball n chain guard is located. Write +db $02 ; $FF to count ball and chain item for collection stats. org $B0F000 ; PC 0x187000-0x18700F CompassTotalsROM: