Merge branch 'sram_rework' into dr_sram

This commit is contained in:
cassidoxa
2022-04-20 00:30:35 -04:00
78 changed files with 2624 additions and 1640 deletions

View File

@@ -188,7 +188,7 @@ SpritePrep_ShopKeeper:
PHY
PHX
LDA.b #$00 : XBA : TYA : LSR #2 : !ADD !SHOP_SRAM_INDEX : TAX
LDA !SHOP_PURCHASE_COUNTS, X : TYX : STA.l !SHOP_INVENTORY+3, X : TAY
LDA PurchaseCounts, X : TYX : STA.l !SHOP_INVENTORY+3, X : TAY
PLX
LDA.l ShopContentsTable+4, X : BEQ +
@@ -244,7 +244,7 @@ SpritePrep_ShopKeeper:
.takeAll
LDA.b #$00 : XBA : LDA !SHOP_SRAM_INDEX : TAX
LDA.l !SHOP_PURCHASE_COUNTS, X
LDA.l PurchaseCounts, X
BRA ++
.notTakeAll
LDA.b #$00
@@ -298,8 +298,6 @@ RTS
;!SHOP_INVENTORY, X
;[id][$lo][$hi][purchase_counter]
;--------------------------------------------------------------------------------
;!SHOP_PURCHASE_COUNTS = "$7EF302"
;--------------------------------------------------------------------------------
Shopkeeper_UploadVRAMTilesLong:
JSR.w Shopkeeper_UploadVRAMTiles
RTL
@@ -457,13 +455,13 @@ Sprite_ShopKeeper:
BIT.b #$20 : BNE + ; Not A Take-All
PHX
LDA !SHOP_SRAM_INDEX : TAX
LDA !SHOP_PURCHASE_COUNTS, X : BEQ ++ : PLX : BRA .done : ++
LDA PurchaseCounts, X : BEQ ++ : PLX : BRA .done : ++
PLX
BRA .normal
+ ; Take-All
;PHX
; LDA !SHOP_SRAM_INDEX : TAX
; LDA.w !SHOP_PURCHASE_COUNTS, X : STA.l !SHOP_STATE
; LDA.w PurchaseCounts, X : STA.l !SHOP_STATE
;PLX
.normal
@@ -591,8 +589,6 @@ Shopkeeper_SetupHitboxes:
PLP : PLY : PLX
RTS
!LOCK_STATS = "$7EF443"
!ITEM_TOTAL = "$7EF423"
;--------------------
;!SHOP_STATE
Shopkeeper_BuyItem:
@@ -611,7 +607,7 @@ Shopkeeper_BuyItem:
+
LDA !SHOP_TYPE : AND.b #$80 : BNE .buy ; don't charge if this is a take-any
REP #$20 : LDA $7EF360 : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy
REP #$20 : LDA CurrentRupees : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy
.cant_afford
LDA.b #$7A
@@ -627,12 +623,12 @@ Shopkeeper_BuyItem:
JMP .done
.buy
LDA !SHOP_TYPE : AND.b #$80 : BNE ++ ; don't charge if this is a take-any
REP #$20 : LDA $7EF360 : !SUB !SHOP_INVENTORY+1, X : STA $7EF360 : SEP #$20 ; Take price away
REP #$20 : LDA CurrentRupees : !SUB !SHOP_INVENTORY+1, X : STA CurrentRupees : SEP #$20 ; Take price away
++
PHX
LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_PLAYER, X : STA !MULTIWORLD_ITEM_PLAYER_ID
TXA : !ADD !SHOP_SRAM_INDEX : TAX
LDA.l !SHOP_PURCHASE_COUNTS, X : BNE +++ ;Is this the first time buying this slot?
LDA.l PurchaseCounts, X : BNE +++ ;Is this the first time buying this slot?
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT ; If so, store the permission to count the item here.
+++
PLX
@@ -647,7 +643,7 @@ Shopkeeper_BuyItem:
+++
PHX
TXA : !ADD !SHOP_SRAM_INDEX : TAX
LDA !SHOP_PURCHASE_COUNTS, X : INC : BEQ +++ : STA !SHOP_PURCHASE_COUNTS, X : +++
LDA PurchaseCounts, X : INC : BEQ +++ : STA PurchaseCounts, X : +++
PLX
BRA ++
+ ; Take-any
@@ -656,14 +652,14 @@ Shopkeeper_BuyItem:
.takeAny
LDA.l !SHOP_STATE : ORA.b #$07 : STA.l !SHOP_STATE
PHX
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.b #$01 : STA.l !SHOP_PURCHASE_COUNTS, X
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.b #$01 : STA.l PurchaseCounts, X
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT
PLX
BRA ++
.takeAll
LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE
PHX
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l !SHOP_PURCHASE_COUNTS, X
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l PurchaseCounts, X
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT
PLX
++
@@ -676,7 +672,6 @@ db #$01, #$02, #$04, #$08
;--------------------
;!SHOP_ID = "$7F5050"
;!SHOP_SRAM_INDEX = "$7F5062"
;!SHOP_PURCHASE_COUNTS = "$7EF302"
;--------------------
Setup_ShopItemCollisionHitbox:
;The complications with XBA are to handle the fact that nintendo likes to store
@@ -797,7 +792,7 @@ Shopkeeper_DrawItems:
LDA $02DA : BNE + ; if not buying item
LDA $7F505E : BEQ + ; if potion slot filled
LDA $0ABF : BEQ + ; haven't left the room
LDA !NPC_FLAGS_2 : AND.b #$20 : BNE +
LDA NpcFlags+1 : AND.b #$20 : BNE +
LDX.b #$0C : LDY.b #$03 : JSR.w Shopkeeper_DrawNextItem
+
PLY : PLX