Fix AddInventory/stats tracking with 16 bit item properties

This commit is contained in:
cassidoxa
2023-09-02 22:57:50 -04:00
parent 2cead7ae92
commit 73b2a180ba
5 changed files with 67 additions and 57 deletions

View File

@@ -103,11 +103,11 @@ RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
OnAga2Defeated: OnAga2Defeated:
JSL.l Dungeon_SaveRoomData_justKeys ; thing we wrote over, make sure this is first JSL.l Dungeon_SaveRoomData_justKeys ; thing we wrote over, make sure this is first
LDA.b #$FF : STA.w DungeonID
LDA.b #$01 : STA.l Aga2Duck LDA.b #$01 : STA.l Aga2Duck
LDA.w DungeonID : CMP.b #$1A : BNE + LDA.w DungeonID : CMP.b #$1A : BNE +
LDA.l DungeonsCompleted : ORA.b #$04 : STA.l DungeonsCompleted LDA.l DungeonsCompleted : ORA.b #$04 : STA.l DungeonsCompleted
+ +
LDA.b #$FF : STA.w DungeonID
JML.l IncrementAgahnim2Sword JML.l IncrementAgahnim2Sword
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
OnFileCreation: OnFileCreation:

View File

@@ -147,16 +147,17 @@ AddInventory:
PHA : PHX : PHY : PHP : PHB PHA : PHX : PHY : PHP : PHB
PHK : PLB PHK : PLB
LDA.b #$7E : STA.b Scrap0D LDA.b #$7E : STA.b Scrap0D
LDA.l StatsLocked : BNE .done LDA.l StatsLocked : BNE .done
REP #$30 REP #$30
TYA : AND.w #$00FF : ASL : TAX TYA : AND.w #$00FF : ASL : TAX
SEP #$20 SEP #$20
LDA.w InventoryTable_properties,X : BIT.b #$01 : BEQ .done LDA.w InventoryTable_properties,X : BIT.b #$01 : BEQ .done
JSR.w ShopCheck : BCS .done JSR.w ShopCheck : BCS .done
JSR.w DungeonIncrement : BCS .done JSR.w DungeonIncrement : BCS .done
JSR.w IncrementByOne JSR.w IncrementByOne
JSR.w StampItem JSR.w StampItem
SEP #$20
JSR.w IncrementYAItems JSR.w IncrementYAItems
REP #$20 REP #$20
LDA.l TotalItemCounter : INC : TAY LDA.l TotalItemCounter : INC : TAY
@@ -179,6 +180,7 @@ RTL
ShopCheck: ShopCheck:
; In: X - Receipt ID << 1 ; In: X - Receipt ID << 1
; TODO: If we write all shops, we can use the ShopPurchase flag instead of this ; TODO: If we write all shops, we can use the ShopPurchase flag instead of this
PHX
LDA.b IndoorsFlag : BEQ .count LDA.b IndoorsFlag : BEQ .count
LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ .count LDA.w ItemReceiptMethod : CMP.b #$01 : BEQ .count
LDA.w InventoryTable_properties,X : BIT.b #$02 : BNE .count LDA.w InventoryTable_properties,X : BIT.b #$02 : BNE .count
@@ -196,9 +198,11 @@ ShopCheck:
SEP #$20 SEP #$20
.count .count
CLC CLC
PLX
RTS RTS
.nocount .nocount
SEP #$21 SEP #$21
PLX
RTS RTS
DungeonIncrement: DungeonIncrement:
@@ -207,10 +211,11 @@ DungeonIncrement:
LDA.w InventoryTable_properties,X : BIT.b #$40 : BEQ + LDA.w InventoryTable_properties,X : BIT.b #$40 : BEQ +
JSL.l CountChestKeyLong JSL.l CountChestKeyLong
+ +
SEP #$10
LDA.b IndoorsFlag : BEQ .done LDA.b IndoorsFlag : BEQ .done
LDA.w DungeonID : BMI .done LDA.w DungeonID : BMI .done
CMP.l BallNChainDungeon : BNE + CMP.l BallNChainDungeon : BNE +
CPY.w #$0032 : BEQ .ballchain_bigkey CPY.b #$32 : BEQ .ballchain_bigkey
+ +
CMP.b #$04 : BCS + CMP.b #$04 : BCS +
LDA.l SewersLocations : INC : STA.l SewersLocations : STA.l HCLocations LDA.l SewersLocations : INC : STA.l SewersLocations : STA.l HCLocations
@@ -218,19 +223,17 @@ DungeonIncrement:
+ +
LSR : TAX LSR : TAX
LDA.l DungeonLocationsChecked, X : INC : STA.l DungeonLocationsChecked, X LDA.l DungeonLocationsChecked, X : INC : STA.l DungeonLocationsChecked, X
CPX.w #$000D : BNE + CPX.b #$0D : BNE +
LDA.l BigKeyField : BIT.b #$04 : BNE ++ LDA.l BigKeyField : BIT.b #$04 : BNE ++
LDA.l PreGTBKLocations : INC : STA.l PreGTBKLocations LDA.l PreGTBKLocations : INC : STA.l PreGTBKLocations
++ ++
+ +
.done .done
REP #$11
PLX PLX
CLC
RTS RTS
.ballchain_bigkey .ballchain_bigkey
LDA.l BigKeysBigChests REP #$10
CLC : ADC.b #$10
STA.l BigKeysBigChests
PLX PLX
SEC SEC
RTS RTS
@@ -247,37 +250,40 @@ StampItem:
INC.b Scrap0B : INC.b Scrap0B INC.b Scrap0B : INC.b Scrap0B
LDA.l NMIFrames+2 : STA.b [Scrap0B] LDA.l NMIFrames+2 : STA.b [Scrap0B]
.skip .skip
SEP #$20
RTS RTS
IncrementYAItems: IncrementYAItems:
LDA.w InventoryTable_properties,X PHX
BIT.b #$10 : BNE .bomb_check LDA.w InventoryTable_properties,X
BIT.b #$20 : BNE .bow_check BIT.b #$10 : BNE .bomb_check
BIT.b #$04 : BEQ .not_y BIT.b #$20 : BNE .bow_check
.y_item BIT.b #$04 : BEQ .not_y
LDA.l YAItemCounter : !ADD #$08 : STA.l YAItemCounter .y_item
BRA .done LDA.l YAItemCounter : !ADD #$08 : STA.l YAItemCounter
.not_y BRA .done
BIT.b #$08 : BEQ .done .not_y
.a_item BIT.b #$08 : BEQ .done
LDA.l YAItemCounter : INC : AND.b #$07 : TAX .a_item
LDA.l YAItemCounter : AND.b #$F8 : STA.l YAItemCounter LDA.l YAItemCounter : INC : AND.b #$07 : TAX
TXA : ORA.l YAItemCounter : STA.l YAItemCounter LDA.l YAItemCounter : AND.b #$F8 : STA.l YAItemCounter
TXA : ORA.l YAItemCounter : STA.l YAItemCounter
.done .done
PLX
RTS RTS
.bow_check .bow_check
LDA.l BowEquipment : BNE + LDA.l BowEquipment : BNE +
BRA .y_item BRA .y_item
+
RTS
.bomb_check .bomb_check
LDA.l InventoryTracking+1 : BIT.b #$02 : BNE + LDA.l InventoryTracking+1 : BIT.b #$02 : BNE +
ORA.b #$02 : STA.l InventoryTracking+1 ORA.b #$02 : STA.l InventoryTracking+1
BRA .y_item BRA .y_item
+ +
PLX
RTS RTS
IncrementByOne: IncrementByOne:
PHX
REP #$20 REP #$20
LDA.w InventoryTable_stat,X : BEQ .skip LDA.w InventoryTable_stat,X : BEQ .skip
STA.b Scrap0B STA.b Scrap0B
@@ -285,6 +291,7 @@ IncrementByOne:
LDA.b #$00 : ADC.b [Scrap0B] : STA.b [Scrap0B] LDA.b #$00 : ADC.b [Scrap0B] : STA.b [Scrap0B]
.skip .skip
SEP #$20 SEP #$20
PLX
RTS RTS
IncrementBossSword: IncrementBossSword:

View File

@@ -604,25 +604,31 @@ ItemBehavior:
.increment_bigkey .increment_bigkey
SEP #$20 SEP #$20
LDA.l BigKeysBigChests LDA.l StatsLocked : BNE +
CLC : ADC.b #$10 LDA.l BigKeysBigChests
STA.l BigKeysBigChests CLC : ADC.b #$10
STA.l BigKeysBigChests
+
RTS RTS
.increment_map .increment_map
SEP #$20 SEP #$20
LDA.l MapsCompasses LDA.l StatsLocked : BNE +
CLC : ADC.b #$10 LDA.l MapsCompasses
STA.l MapsCompasses CLC : ADC.b #$10
JSL.l MaybeFlagMapTotalPickup STA.l MapsCompasses
JSL.l MaybeFlagMapTotalPickup
+
RTS RTS
.increment_compass .increment_compass
SEP #$20 SEP #$20
LDA.l MapsCompasses : INC : AND.b #$0F : TAX LDA.l StatsLocked : BNE +
LDA.l MapsCompasses : AND.b #$F0 : STA.l MapsCompasses LDA.l MapsCompasses : INC : AND.b #$0F : TAX
TXA : ORA.l MapsCompasses : STA.l MapsCompasses LDA.l MapsCompasses : AND.b #$F0 : STA.l MapsCompasses
JSL MaybeFlagCompassTotalPickup TXA : ORA.l MapsCompasses : STA.l MapsCompasses
JSL MaybeFlagCompassTotalPickup
+
RTS RTS
.pendant .pendant

View File

@@ -127,23 +127,20 @@ ShowDungeonItems:
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
UpdateKeys: UpdateKeys:
PHX : PHP PHX : PHP
SEP #$30 ; set 8-bit accumulator & index registers SEP #$30
LDA.w DungeonID : CMP.b #$1F : !BLT .skip LDA.l GenericKeys : BNE .skip
LDA.w DungeonID : CMP.b #$1F : BCS .skip
LSR : TAX ; get dungeon index and store to X LSR : TAX
LDA.l CurrentSmallKeys
LDA.l CurrentSmallKeys ; load current key count CPX.b #$02 : BCC .castle_sewers
STA.l DungeonKeys, X ; save to main counts STA.l DungeonKeys, X
BRA .skip
CPX.b #$00 : BNE + .castle_sewers
STA.l HyruleCastleKeys ; copy HC to sewers STA.l HyruleCastleKeys : STA.l SewerKeys
+ : CPX.b #$01 : BNE + .skip
STA.l SewerKeys ; copy sewers to HC JSL.l PostItemGet
+ PLP : PLX
.skip
JSL.l PostItemGet
PLP : PLX
RTL RTL
;$37C = Sewer Passage ;$37C = Sewer Passage
;$37D = Hyrule Castle ;$37D = Hyrule Castle

View File

@@ -117,10 +117,10 @@ DecrementSmallKeys:
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
CountChestKeyLong: CountChestKeyLong:
PHP PHX : PHP
SEP #$30 SEP #$30
JSR.w CountChestKey JSR.w CountChestKey
PLP PLP : PLX
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
CountChestKey: CountChestKey: