Ported over pepper's shop code
This commit is contained in:
@@ -152,11 +152,6 @@ incsrc clock.asm
|
|||||||
incsrc accessability.asm
|
incsrc accessability.asm
|
||||||
incsrc heartbeep.asm
|
incsrc heartbeep.asm
|
||||||
incsrc capacityupgrades.asm
|
incsrc capacityupgrades.asm
|
||||||
incsrc timer.asm
|
|
||||||
incsrc doorframefixes.asm
|
|
||||||
incsrc music.asm
|
|
||||||
incsrc roomloading.asm
|
|
||||||
incsrc icepalacegraphics.asm
|
|
||||||
warnpc $A18000
|
warnpc $A18000
|
||||||
|
|
||||||
org $1C8000 ; text tables for translation
|
org $1C8000 ; text tables for translation
|
||||||
@@ -183,6 +178,11 @@ org $A1FF00 ; static mapping area
|
|||||||
incsrc init.asm
|
incsrc init.asm
|
||||||
|
|
||||||
org $A48000 ; code bank - PUT NEW CODE HERE
|
org $A48000 ; code bank - PUT NEW CODE HERE
|
||||||
|
incsrc timer.asm
|
||||||
|
incsrc doorframefixes.asm
|
||||||
|
incsrc music.asm
|
||||||
|
incsrc roomloading.asm
|
||||||
|
incsrc icepalacegraphics.asm
|
||||||
incsrc glitched.asm
|
incsrc glitched.asm
|
||||||
incsrc hardmode.asm
|
incsrc hardmode.asm
|
||||||
incsrc goalitem.asm
|
incsrc goalitem.asm
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ FixFrogSmith:
|
|||||||
.loadgfx
|
.loadgfx
|
||||||
JSL Tagalong_LoadGfx
|
JSL Tagalong_LoadGfx
|
||||||
.done
|
.done
|
||||||
RTS
|
RTL
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
|
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
|
|||||||
24
hooks.asm
24
hooks.asm
@@ -1171,10 +1171,9 @@ NOP #2
|
|||||||
org $05F55F ; <- 2F55F - sprite_potion_shop.asm : 59
|
org $05F55F ; <- 2F55F - sprite_potion_shop.asm : 59
|
||||||
JSL.l LoadPowder
|
JSL.l LoadPowder
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
org $05F681 ; <- 2F681 - sprite_potion_shop.asm : 234
|
org $05F67B ; <- 2F67B - sprite_potion_shop.asm : 234
|
||||||
JSL.l DrawPowder
|
JSL DrawPowder
|
||||||
RTS
|
RTS
|
||||||
NOP #8
|
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
org $05F65D ; <- 2F65D - sprite_potion_shop.asm : 198
|
org $05F65D ; <- 2F65D - sprite_potion_shop.asm : 198
|
||||||
JSL.l CollectPowder
|
JSL.l CollectPowder
|
||||||
@@ -1190,6 +1189,25 @@ JSL.l DrawMushroom
|
|||||||
org $05EE97 ; <- 2EE97 - sprite_mushroom.asm : 81
|
org $05EE97 ; <- 2EE97 - sprite_mushroom.asm : 81
|
||||||
NOP #14
|
NOP #14
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
|
org $05F529 ; <- 2F52C - sprite_potion_shop.asm
|
||||||
|
JSL SpritePrep_ShopKeeper
|
||||||
|
LDX #$0
|
||||||
|
JSR $F539 ; <- powder spawn here
|
||||||
|
RTS
|
||||||
|
;--------------------------------------------------------------------------------
|
||||||
|
org $05F568 ; <- 2F568 - sprite_potion_shop.asm
|
||||||
|
LDA #$b0 : STA $0D00, Y : LDA #$90 : STA $0D10, Y ; manually set position of powder item
|
||||||
|
LDA #$21 : STA $0D20, Y : LDA #$12 : STA $0D30, Y
|
||||||
|
JMP $F61D
|
||||||
|
;--------------------------------------------------------------------------------
|
||||||
|
org $05F633 ; <- 2F633 - sprite_potion_shop.asm
|
||||||
|
LDA $0E80, X : BNE +
|
||||||
|
JSL Sprite_ShopKeeperPotion ;; TODO: i don't remember prices being set on top of the player
|
||||||
|
JSR $F893 ; <- witch behavior here
|
||||||
|
RTS : +
|
||||||
|
JSR $F644 ; <- powder behavior here
|
||||||
|
RTS
|
||||||
|
;--------------------------------------------------------------------------------
|
||||||
org $05EB1D ; <- 2EB1D - sprite_bottle_vendor.asm : 158
|
org $05EB1D ; <- 2EB1D - sprite_bottle_vendor.asm : 158
|
||||||
JSL.l Multiworld_BottleVendor_GiveBottle
|
JSL.l Multiworld_BottleVendor_GiveBottle
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -924,6 +924,11 @@ LoadPowder:
|
|||||||
%GetPossiblyEncryptedItem(WitchItem, SpriteItemValues)
|
%GetPossiblyEncryptedItem(WitchItem, SpriteItemValues)
|
||||||
STA $0DA0, Y ; Store item type
|
STA $0DA0, Y ; Store item type
|
||||||
JSL.l PrepDynamicTile
|
JSL.l PrepDynamicTile
|
||||||
|
STA $7F505E
|
||||||
|
LDA #$00
|
||||||
|
STA $7F505F
|
||||||
|
STA $7F5060
|
||||||
|
STA $7F5061
|
||||||
RTL
|
RTL
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -946,6 +951,7 @@ RTL
|
|||||||
!REDRAW = "$7F5000"
|
!REDRAW = "$7F5000"
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
DrawPowder:
|
DrawPowder:
|
||||||
|
; this fights with the shopkeep code, so had to move the powder draw there
|
||||||
LDA $02DA : BNE .defer ; defer if link is buying a potion
|
LDA $02DA : BNE .defer ; defer if link is buying a potion
|
||||||
LDA.l !REDRAW : BEQ +
|
LDA.l !REDRAW : BEQ +
|
||||||
LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID
|
LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID
|
||||||
@@ -954,8 +960,8 @@ DrawPowder:
|
|||||||
LDA #$00 : STA.l !REDRAW ; reset redraw flag
|
LDA #$00 : STA.l !REDRAW ; reset redraw flag
|
||||||
BRA .defer
|
BRA .defer
|
||||||
+
|
+
|
||||||
LDA $0DA0, X ; Retrieve stored item type
|
; LDA $0DA0, X ; Retrieve stored item type
|
||||||
JSL.l DrawDynamicTile
|
; JSL.l DrawDynamicTile
|
||||||
.defer
|
.defer
|
||||||
RTL
|
RTL
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ PreOverworld_LoadProperties_ChooseMusic:
|
|||||||
; A: scratch space (value never used)
|
; A: scratch space (value never used)
|
||||||
; Y: set to overworld animated tileset
|
; Y: set to overworld animated tileset
|
||||||
; X: set to music track/command id
|
; X: set to music track/command id
|
||||||
JSR.w FixFrogSmith ; Just a convenient spot to install this hook
|
JSL.l FixFrogSmith ; Just a convenient spot to install this hook
|
||||||
|
|
||||||
LDY.b #$58 ; death mountain animated tileset.
|
LDY.b #$58 ; death mountain animated tileset.
|
||||||
|
|
||||||
|
|||||||
142
shopkeeper.asm
142
shopkeeper.asm
@@ -57,6 +57,7 @@ macro DrawDigit(value,offset)
|
|||||||
+
|
+
|
||||||
LDA $0E : STA !BIGRAM, X : INX : INX
|
LDA $0E : STA !BIGRAM, X : INX : INX
|
||||||
LDA.w #56 : STA !BIGRAM, X : INX : INX
|
LDA.w #56 : STA !BIGRAM, X : INX : INX
|
||||||
|
LDA $A0 : CMP.l #$109 : BNE + : LDA.w #$FFCA : STA !BIGRAM-2, X : +
|
||||||
LDY $0A : TYA : ASL : TAY : LDA.w .digit_properties, Y : STA !BIGRAM, X : INX : INX
|
LDY $0A : TYA : ASL : TAY : LDA.w .digit_properties, Y : STA !BIGRAM, X : INX : INX
|
||||||
LDA.w #$0000 : STA !BIGRAM, X : INX : INX
|
LDA.w #$0000 : STA !BIGRAM, X : INX : INX
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ endmacro
|
|||||||
!COLUMN_LOW = "$7F5022"
|
!COLUMN_LOW = "$7F5022"
|
||||||
!COLUMN_HIGH = "$7F5023"
|
!COLUMN_HIGH = "$7F5023"
|
||||||
DrawPrice:
|
DrawPrice:
|
||||||
|
STX $07
|
||||||
PHX : PHY : PHP
|
PHX : PHY : PHP
|
||||||
LDY.b #$FF
|
LDY.b #$FF
|
||||||
LDX #$00 ; clear bigram pointer
|
LDX #$00 ; clear bigram pointer
|
||||||
@@ -86,7 +88,7 @@ DrawPrice:
|
|||||||
|
|
||||||
.len1
|
.len1
|
||||||
%DrawDigit(#1,#0)
|
%DrawDigit(#1,#0)
|
||||||
|
|
||||||
SEP #$20 ; set 8-bit accumulator
|
SEP #$20 ; set 8-bit accumulator
|
||||||
TXA : LSR #3 : STA $06 ; request 1-4 OAM slots
|
TXA : LSR #3 : STA $06 ; request 1-4 OAM slots
|
||||||
ASL #2
|
ASL #2
|
||||||
@@ -106,13 +108,16 @@ RTS
|
|||||||
!FREE_TILE_BUFFER = "#$1180"
|
!FREE_TILE_BUFFER = "#$1180"
|
||||||
!SHOP_ID = "$7F5050"
|
!SHOP_ID = "$7F5050"
|
||||||
!SHOP_TYPE = "$7F5051"
|
!SHOP_TYPE = "$7F5051"
|
||||||
!SHOP_INVENTORY = "$7F5052" ; $7F505E
|
!SHOP_INVENTORY = "$7F5052" ; $7F5056 - 5a - 5e
|
||||||
!SHOP_STATE = "$7F505F"
|
!SHOP_INVENTORY_PLAYER = "$7F5062"
|
||||||
!SHOP_CAPACITY = "$7F5060"
|
!SHOP_INVENTORY_DISGUISE = "$7F5065" ; was going to remove this, but this lets more than one bee trap exist with its own icon.
|
||||||
!SCRATCH_TEMP_X = "$7F5061"
|
!SHOP_STATE = "$7F5069"
|
||||||
!SHOP_SRAM_INDEX = "$7F5062"
|
!SHOP_CAPACITY = "$7F506A"
|
||||||
!SHOP_MERCHANT = "$7F5063"
|
!SCRATCH_TEMP_X = "$7F506B"
|
||||||
!SHOP_DMA_TIMER = "$7F5064"
|
!SHOP_SRAM_INDEX = "$7F506C"
|
||||||
|
!SHOP_MERCHANT = "$7F506D"
|
||||||
|
!SHOP_DMA_TIMER = "$7F506E"
|
||||||
|
!SHOP_KEEP_REFILL = "$7F506F"
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
!NMI_AUX = "$7F5044"
|
!NMI_AUX = "$7F5044"
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
@@ -126,7 +131,6 @@ SpritePrep_ShopKeeper:
|
|||||||
PHX : PHY : PHP
|
PHX : PHY : PHP
|
||||||
|
|
||||||
REP #$30 ; set 16-bit accumulator & index registers
|
REP #$30 ; set 16-bit accumulator & index registers
|
||||||
;LDA $A0
|
|
||||||
LDX.w #$0000
|
LDX.w #$0000
|
||||||
-
|
-
|
||||||
LDA ShopTable+1, X : CMP $A0 : BNE +
|
LDA ShopTable+1, X : CMP $A0 : BNE +
|
||||||
@@ -164,25 +168,37 @@ SpritePrep_ShopKeeper:
|
|||||||
LDA.l ShopContentsTable+1, X : PHX : TYX : STA.l !SHOP_INVENTORY, X : PLX
|
LDA.l ShopContentsTable+1, X : PHX : TYX : STA.l !SHOP_INVENTORY, X : PLX
|
||||||
LDA.l ShopContentsTable+2, X : PHX : TYX : STA.l !SHOP_INVENTORY+1, X : PLX
|
LDA.l ShopContentsTable+2, X : PHX : TYX : STA.l !SHOP_INVENTORY+1, X : PLX
|
||||||
LDA.l ShopContentsTable+3, X : PHX : TYX : STA.l !SHOP_INVENTORY+2, X : PLX
|
LDA.l ShopContentsTable+3, X : PHX : TYX : STA.l !SHOP_INVENTORY+2, X : PLX
|
||||||
|
LDA.l ShopContentsTable+8, X : PHX : PHA
|
||||||
|
LDA #0 : XBA : TYA : LSR #2 : TAX ; This will convert the value back to the slot number (in 8-bit accumulator mode)
|
||||||
|
PLA : STA.l !SHOP_INVENTORY_PLAYER, X : LDA #0 : STA.l !SHOP_INVENTORY_DISGUISE, X : PLX
|
||||||
PHY
|
PHY
|
||||||
PHX
|
PHX
|
||||||
LDA.b #$00 : XBA : TYA : LSR #2 : !ADD !SHOP_SRAM_INDEX : TAX
|
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 !SHOP_PURCHASE_COUNTS, X : TYX : STA.l !SHOP_INVENTORY+3, X : TAY
|
||||||
PLX
|
PLX
|
||||||
|
|
||||||
LDA.l ShopContentsTable+4, X : BEQ ++
|
LDA.l ShopContentsTable+4, X : BEQ +
|
||||||
TYA : CMP.l ShopContentsTable+4, X : !BLT ++
|
TYA : CMP.l ShopContentsTable+4, X : !BLT ++
|
||||||
PLY
|
PLY
|
||||||
LDA.l ShopContentsTable+5, X : PHX : TYX : STA.l !SHOP_INVENTORY, X : PLX
|
LDA.l ShopContentsTable+5, X : PHX : TYX : STA.l !SHOP_INVENTORY, X : PLX
|
||||||
LDA.l ShopContentsTable+6, X : PHX : TYX : STA.l !SHOP_INVENTORY+1, X : PLX
|
LDA.l ShopContentsTable+6, X : PHX : TYX : STA.l !SHOP_INVENTORY+1, X : PLX
|
||||||
LDA.l ShopContentsTable+7, X : PHX : TYX : STA.l !SHOP_INVENTORY+2, X : PLX
|
LDA.l ShopContentsTable+7, X : PHX : TYX : STA.l !SHOP_INVENTORY+2, X : PLX
|
||||||
|
LDA #$40 : PHX : TYX : STA.l !SHOP_INVENTORY+3, X : PLX
|
||||||
|
PHX : LDA #0 : XBA : TYA : LSR #2 : TAX ; This will convert the value back to the slot number (in 8-bit accumulator mode)
|
||||||
|
LDA #0 : STA.l !SHOP_INVENTORY_PLAYER, X : PLX
|
||||||
BRA +++
|
BRA +++
|
||||||
|
+ : PLY : LDA #$40 : PHX : TYX : STA.l !SHOP_INVENTORY+3, X : PLX : BRA +++
|
||||||
++
|
++
|
||||||
PLY : +++
|
PLY : +++
|
||||||
|
|
||||||
PHX : PHY
|
PHX : PHY
|
||||||
PHX : TYX : LDA.l !SHOP_INVENTORY, X : PLX : TAY
|
PHX : TYX : LDA.l !SHOP_INVENTORY, X : PLX
|
||||||
|
CMP #$B0 : BNE +
|
||||||
|
PHX : LDA #0 : XBA : TYA : LSR #2 : TAX ; This will convert the value back to the slot number (in 8-bit accumulator mode)
|
||||||
|
JSL GetRandomInt : AND #$3F
|
||||||
|
BNE ++ : LDA #$49 : ++ : CMP #$26 : BNE ++ : LDA #$6A : ++ ; if 0 (fighter's sword + shield), set to just sword, if filled container (bugged palette), switch to triforce piece
|
||||||
|
STA.l !SHOP_INVENTORY_DISGUISE, X : PLX
|
||||||
|
+ : TAY
|
||||||
REP #$20 ; set 16-bit accumulator
|
REP #$20 ; set 16-bit accumulator
|
||||||
LDA 1,s : TAX : LDA.l .tile_offsets, X : TAX
|
LDA 1,s : TAX : LDA.l .tile_offsets, X : TAX
|
||||||
JSR LoadTile
|
JSR LoadTile
|
||||||
@@ -190,7 +206,7 @@ SpritePrep_ShopKeeper:
|
|||||||
INY #4
|
INY #4
|
||||||
|
|
||||||
.next
|
.next
|
||||||
INX #8
|
INX #9
|
||||||
BRL -
|
BRL -
|
||||||
.stop
|
.stop
|
||||||
|
|
||||||
@@ -376,6 +392,15 @@ Shopkepeer_CallOriginal:
|
|||||||
;!SHOP_TYPE = "$7F5051"
|
;!SHOP_TYPE = "$7F5051"
|
||||||
;!SHOP_CAPACITY = "$7F5020"
|
;!SHOP_CAPACITY = "$7F5020"
|
||||||
;!SCRATCH_TEMP_X = "$7F5021"
|
;!SCRATCH_TEMP_X = "$7F5021"
|
||||||
|
Sprite_ShopKeeperPotion:
|
||||||
|
PHB : PHK : PLB ;; we can just call the default shopkeeper but the potion shopkeeper refills your health
|
||||||
|
LDA $A0 : CMP.b #$09 : BNE +
|
||||||
|
JSR.w Shopkeeper_DrawItems
|
||||||
|
JSR.w Shopkeeper_SetupHitboxes
|
||||||
|
+
|
||||||
|
PLB
|
||||||
|
RTL
|
||||||
|
|
||||||
Sprite_ShopKeeper:
|
Sprite_ShopKeeper:
|
||||||
|
|
||||||
LDA.l !SHOP_TYPE : CMP.b #$FF : BNE + : JMP.w Shopkepeer_CallOriginal : +
|
LDA.l !SHOP_TYPE : CMP.b #$FF : BNE + : JMP.w Shopkepeer_CallOriginal : +
|
||||||
@@ -512,6 +537,7 @@ Shopkeeper_SetupHitboxes:
|
|||||||
|
|
||||||
JSR.w Setup_ShopItemInteractionHitbox
|
JSR.w Setup_ShopItemInteractionHitbox
|
||||||
JSL.l Utility_CheckIfHitBoxesOverlapLong : BCC .no_interaction
|
JSL.l Utility_CheckIfHitBoxesOverlapLong : BCC .no_interaction
|
||||||
|
LDA $02DA : BNE .no_interaction ; defer if link is buying a potion (this is faster than the potion buying speed before potion shop shuffle)
|
||||||
LDA $F6 : AND.b #$80 : BEQ .no_interaction ; check for A-press
|
LDA $F6 : AND.b #$80 : BEQ .no_interaction ; check for A-press
|
||||||
LDA $10 : CMP.b #$0C : !BGE .no_interaction ; don't interact in other modes besides game action
|
LDA $10 : CMP.b #$0C : !BGE .no_interaction ; don't interact in other modes besides game action
|
||||||
JSR.w Shopkeeper_BuyItem
|
JSR.w Shopkeeper_BuyItem
|
||||||
@@ -527,7 +553,7 @@ RTS
|
|||||||
Shopkeeper_BuyItem:
|
Shopkeeper_BuyItem:
|
||||||
PHX : PHY
|
PHX : PHY
|
||||||
TYX
|
TYX
|
||||||
|
|
||||||
LDA.l !SHOP_INVENTORY, X
|
LDA.l !SHOP_INVENTORY, X
|
||||||
CMP.b #$0E : BEQ .refill ; Bee Refill
|
CMP.b #$0E : BEQ .refill ; Bee Refill
|
||||||
CMP.b #$2E : BEQ .refill ; Red Potion Refill
|
CMP.b #$2E : BEQ .refill ; Red Potion Refill
|
||||||
@@ -536,6 +562,7 @@ Shopkeeper_BuyItem:
|
|||||||
BRA +
|
BRA +
|
||||||
.refill
|
.refill
|
||||||
JSL.l Sprite_GetEmptyBottleIndex : BMI .full_bottles
|
JSL.l Sprite_GetEmptyBottleIndex : BMI .full_bottles
|
||||||
|
LDA #$1 : STA !SHOP_KEEP_REFILL ; If this is on, don't toggle bit to remove from shop
|
||||||
+
|
+
|
||||||
|
|
||||||
LDA !SHOP_TYPE : AND.b #$80 : BNE .buy ; don't charge if this is a take-any
|
LDA !SHOP_TYPE : AND.b #$80 : BNE .buy ; don't charge if this is a take-any
|
||||||
@@ -557,12 +584,15 @@ Shopkeeper_BuyItem:
|
|||||||
LDA !SHOP_TYPE : AND.b #$80 : BNE ++ ; don't charge if this is a take-any
|
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 $7EF360 : !SUB !SHOP_INVENTORY+1, X : STA $7EF360 : SEP #$20 ; Take price away
|
||||||
++
|
++
|
||||||
|
PHX : LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_PLAYER, X : STA !MULTIWORLD_ITEM_PLAYER_ID : PLX
|
||||||
LDA.l !SHOP_INVENTORY, X : TAY : JSL.l Link_ReceiveItem
|
LDA.l !SHOP_INVENTORY, X : TAY : JSL.l Link_ReceiveItem
|
||||||
LDA.l !SHOP_INVENTORY+3, X : INC : STA.l !SHOP_INVENTORY+3, X
|
LDA.l !SHOP_INVENTORY+3, X : INC : STA.l !SHOP_INVENTORY+3, X
|
||||||
|
|
||||||
TXA : LSR #2 : TAX
|
TXA : LSR #2 : TAX
|
||||||
LDA !SHOP_TYPE : BIT.b #$80 : BNE +
|
LDA !SHOP_TYPE : BIT.b #$80 : BNE +
|
||||||
LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE
|
LDA !SHOP_KEEP_REFILL : BNE +++
|
||||||
|
LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE
|
||||||
|
+++
|
||||||
PHX
|
PHX
|
||||||
TXA : !ADD !SHOP_SRAM_INDEX : TAX
|
TXA : !ADD !SHOP_SRAM_INDEX : TAX
|
||||||
LDA !SHOP_PURCHASE_COUNTS, X : INC : BEQ +++ : STA !SHOP_PURCHASE_COUNTS, X : +++
|
LDA !SHOP_PURCHASE_COUNTS, X : INC : BEQ +++ : STA !SHOP_PURCHASE_COUNTS, X : +++
|
||||||
@@ -580,10 +610,11 @@ Shopkeeper_BuyItem:
|
|||||||
PHX : LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l !SHOP_PURCHASE_COUNTS, X : PLX
|
PHX : LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l !SHOP_PURCHASE_COUNTS, X : PLX
|
||||||
++
|
++
|
||||||
.done
|
.done
|
||||||
|
LDA #$0 : STA !SHOP_KEEP_REFILL
|
||||||
PLY : PLX
|
PLY : PLX
|
||||||
RTS
|
RTS
|
||||||
Shopkeeper_ItemMasks:
|
Shopkeeper_ItemMasks:
|
||||||
db #$01, #$02, #$04
|
db #$01, #$02, #$04, #$08
|
||||||
;--------------------
|
;--------------------
|
||||||
;!SHOP_ID = "$7F5050"
|
;!SHOP_ID = "$7F5050"
|
||||||
;!SHOP_SRAM_INDEX = "$7F5062"
|
;!SHOP_SRAM_INDEX = "$7F5062"
|
||||||
@@ -603,6 +634,7 @@ Setup_ShopItemCollisionHitbox:
|
|||||||
REP #$20 ; set 16-bit accumulator
|
REP #$20 ; set 16-bit accumulator
|
||||||
PHA : PHY
|
PHA : PHY
|
||||||
LDA !SHOP_TYPE : AND.w #$0003 : DEC : ASL : TAY
|
LDA !SHOP_TYPE : AND.w #$0003 : DEC : ASL : TAY
|
||||||
|
LDA $A0 : CMP.l #$109 : BNE + : INY #6 : +
|
||||||
LDA.w Shopkeeper_DrawNextItem_item_offsets_idx, Y : STA $00 ; get table from the table table
|
LDA.w Shopkeeper_DrawNextItem_item_offsets_idx, Y : STA $00 ; get table from the table table
|
||||||
PLY : PLA
|
PLY : PLA
|
||||||
|
|
||||||
@@ -686,6 +718,7 @@ RTS
|
|||||||
;!SHOP_TYPE = "$7F5051"
|
;!SHOP_TYPE = "$7F5051"
|
||||||
;!SHOP_INVENTORY = "$7F5052"
|
;!SHOP_INVENTORY = "$7F5052"
|
||||||
!SPRITE_OAM = "$7EC025"
|
!SPRITE_OAM = "$7EC025"
|
||||||
|
!REDRAW = "$7F5000"
|
||||||
Shopkeeper_DrawItems:
|
Shopkeeper_DrawItems:
|
||||||
PHB : PHK : PLB
|
PHB : PHK : PLB
|
||||||
PHX : PHY
|
PHX : PHY
|
||||||
@@ -701,6 +734,14 @@ Shopkeeper_DrawItems:
|
|||||||
+ CMP.b #$01 : BNE + : ++
|
+ CMP.b #$01 : BNE + : ++
|
||||||
JSR.w Shopkeeper_DrawNextItem
|
JSR.w Shopkeeper_DrawNextItem
|
||||||
+
|
+
|
||||||
|
LDA $A0 : CMP.b #$09 : BNE + ; render powder slot if potion shop
|
||||||
|
LDA !REDRAW : BNE + ; if not redrawing
|
||||||
|
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 +
|
||||||
|
LDX.b #$0C : LDY.b #$03 : JSR.w Shopkeeper_DrawNextItem
|
||||||
|
+
|
||||||
PLY : PLX
|
PLY : PLX
|
||||||
PLB
|
PLB
|
||||||
RTS
|
RTS
|
||||||
@@ -713,6 +754,7 @@ Shopkeeper_DrawNextItem:
|
|||||||
|
|
||||||
LDA !SHOP_TYPE : AND.b #$03 : DEC : ASL : TAY
|
LDA !SHOP_TYPE : AND.b #$03 : DEC : ASL : TAY
|
||||||
REP #$20 ; set 16-bit accumulator
|
REP #$20 ; set 16-bit accumulator
|
||||||
|
LDA $A0 : CMP.l #$109 : BNE + : INY #6 : +
|
||||||
LDA.w .item_offsets_idx, Y : STA $00 ; get table from the table table
|
LDA.w .item_offsets_idx, Y : STA $00 ; get table from the table table
|
||||||
LDA 1,s : ASL #2 : TAY ; set Y to the item index
|
LDA 1,s : ASL #2 : TAY ; set Y to the item index
|
||||||
LDA ($00), Y : STA.l !SPRITE_OAM ; load X-coordinate
|
LDA ($00), Y : STA.l !SPRITE_OAM ; load X-coordinate
|
||||||
@@ -725,7 +767,9 @@ Shopkeeper_DrawNextItem:
|
|||||||
SEP #$20 ; set 8-bit accumulator
|
SEP #$20 ; set 8-bit accumulator
|
||||||
PLY
|
PLY
|
||||||
|
|
||||||
LDA.l !SHOP_INVENTORY, X ; get item id
|
PHX : LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_DISGUISE, X : PLX : CMP #$0 : BNE ++
|
||||||
|
LDA.l !SHOP_INVENTORY, X ; get item palette
|
||||||
|
++
|
||||||
CMP.b #$2E : BNE + : BRA .potion
|
CMP.b #$2E : BNE + : BRA .potion
|
||||||
+ CMP.b #$2F : BNE + : BRA .potion
|
+ CMP.b #$2F : BNE + : BRA .potion
|
||||||
+ CMP.b #$30 : BEQ .potion
|
+ CMP.b #$30 : BEQ .potion
|
||||||
@@ -741,14 +785,25 @@ Shopkeeper_DrawNextItem:
|
|||||||
+
|
+
|
||||||
XBA
|
XBA
|
||||||
|
|
||||||
|
AND #$FE
|
||||||
STA.l !SPRITE_OAM+4
|
STA.l !SPRITE_OAM+4
|
||||||
|
|
||||||
LDA.l !SHOP_INVENTORY, X ; get item palette
|
PHX : LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_DISGUISE, X : PLX : CMP #$0 : BNE ++
|
||||||
|
LDA.l !SHOP_INVENTORY, X ; get item palette
|
||||||
|
++
|
||||||
JSL.l GetSpritePalette : STA.l !SPRITE_OAM+5
|
JSL.l GetSpritePalette : STA.l !SPRITE_OAM+5
|
||||||
|
|
||||||
|
LDA.w .tile_indices, Y : AND.b #$01 : BEQ +; get tile index sheet
|
||||||
|
LDA.l !SPRITE_OAM+5
|
||||||
|
ORA.b #$1
|
||||||
|
STA.l !SPRITE_OAM+5
|
||||||
|
+
|
||||||
|
|
||||||
LDA.b #$00 : STA.l !SPRITE_OAM+6
|
LDA.b #$00 : STA.l !SPRITE_OAM+6
|
||||||
|
|
||||||
LDA.l !SHOP_INVENTORY, X ; get item palette
|
PHX : LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_DISGUISE, X : PLX : CMP #$0 : BNE ++
|
||||||
|
LDA.l !SHOP_INVENTORY, X ; get item id for narrowness
|
||||||
|
++
|
||||||
JSL.l IsNarrowSprite : BCS .narrow
|
JSL.l IsNarrowSprite : BCS .narrow
|
||||||
.full
|
.full
|
||||||
LDA.b #$02
|
LDA.b #$02
|
||||||
@@ -764,6 +819,7 @@ Shopkeeper_DrawNextItem:
|
|||||||
PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSR.w RequestItemOAM : PLX
|
PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSR.w RequestItemOAM : PLX
|
||||||
|
|
||||||
LDA !SHOP_TYPE : AND.b #$80 : BNE +
|
LDA !SHOP_TYPE : AND.b #$80 : BNE +
|
||||||
|
CPX.b #12 : BEQ + ; don't render potion price
|
||||||
JSR.w Shopkeeper_DrawNextPrice
|
JSR.w Shopkeeper_DrawNextPrice
|
||||||
+
|
+
|
||||||
|
|
||||||
@@ -772,10 +828,14 @@ Shopkeeper_DrawNextItem:
|
|||||||
INX #4
|
INX #4
|
||||||
RTS
|
RTS
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
.item_offsets_idx
|
.item_offsets_idx ; 112 60
|
||||||
dw #.item_offsets_1
|
dw #.item_offsets_1
|
||||||
dw #.item_offsets_2
|
dw #.item_offsets_2
|
||||||
dw #.item_offsets_3
|
dw #.item_offsets_3
|
||||||
|
.item_offsets_idx_Potion ; 160 176 - (112 64) = (48 112)
|
||||||
|
dw #.item_offsets_1p
|
||||||
|
dw #.item_offsets_2p
|
||||||
|
dw #.item_offsets_3p
|
||||||
.item_offsets_1
|
.item_offsets_1
|
||||||
dw 8, 40
|
dw 8, 40
|
||||||
.item_offsets_2
|
.item_offsets_2
|
||||||
@@ -785,8 +845,19 @@ dw 32, 40
|
|||||||
dw -40, 40
|
dw -40, 40
|
||||||
dw 8, 40
|
dw 8, 40
|
||||||
dw 56, 40
|
dw 56, 40
|
||||||
|
.item_offsets_1p
|
||||||
|
dw -40, -72
|
||||||
|
.item_offsets_2p
|
||||||
|
dw -64, -72
|
||||||
|
dw -16, -72
|
||||||
|
.item_offsets_3p
|
||||||
|
dw -88, -72
|
||||||
|
dw -40, -72
|
||||||
|
dw 8, -72
|
||||||
|
.potion_offset
|
||||||
|
dw -16, 0
|
||||||
.tile_indices
|
.tile_indices
|
||||||
db $C6, $C8, $CA
|
db $C6, $C8, $CA, $25 ; last bit is for sheet change
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
!COLUMN_LOW = "$7F5022"
|
!COLUMN_LOW = "$7F5022"
|
||||||
!COLUMN_HIGH = "$7F5023"
|
!COLUMN_HIGH = "$7F5023"
|
||||||
@@ -797,6 +868,7 @@ Shopkeeper_DrawNextPrice:
|
|||||||
REP #$20 ; set 16-bit accumulator
|
REP #$20 ; set 16-bit accumulator
|
||||||
PHY
|
PHY
|
||||||
LDA !SHOP_TYPE : AND.w #$0003 : DEC : ASL : TAY
|
LDA !SHOP_TYPE : AND.w #$0003 : DEC : ASL : TAY
|
||||||
|
LDA $A0 : CMP.l #$109 : BNE + : INY #6 : +
|
||||||
LDA.w Shopkeeper_DrawNextItem_item_offsets_idx, Y : STA $00 ; get table from the table table
|
LDA.w Shopkeeper_DrawNextItem_item_offsets_idx, Y : STA $00 ; get table from the table table
|
||||||
LDA.w .price_columns_idx, Y : STA $02 ; get table from the table table
|
LDA.w .price_columns_idx, Y : STA $02 ; get table from the table table
|
||||||
PLY : PHY
|
PLY : PHY
|
||||||
@@ -808,21 +880,19 @@ Shopkeeper_DrawNextPrice:
|
|||||||
PLY
|
PLY
|
||||||
LDA.l !SHOP_INVENTORY+1, X : STA $0C ; set value
|
LDA.l !SHOP_INVENTORY+1, X : STA $0C ; set value
|
||||||
|
|
||||||
BEQ .free
|
JSR.w DrawPrice
|
||||||
JSR.w DrawPrice
|
SEP #$20 : STA $06 : STZ $07 ; set 8-bit accumulator & store result
|
||||||
SEP #$20 : STA $06 : STZ $07 ; set 8-bit accumulator & store result
|
PHA
|
||||||
PHA
|
LDA.b #!BIGRAM : STA $08
|
||||||
LDA.b #!BIGRAM : STA $08
|
LDA.b #!BIGRAM>>8 : STA $09
|
||||||
LDA.b #!BIGRAM>>8 : STA $09
|
LDA.b #$7E : PHA : PLB ; set data bank to $7E
|
||||||
LDA.b #$7E : PHA : PLB ; set data bank to $7E
|
|
||||||
|
|
||||||
PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSL.l Sprite_DrawMultiple_quantity_preset : PLX
|
PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSL.l Sprite_DrawMultiple_quantity_preset : PLX
|
||||||
|
|
||||||
LDA 1,s
|
LDA 1,s
|
||||||
ASL #2 : !ADD $90 : STA $90 ; increment oam pointer
|
ASL #2 : !ADD $90 : STA $90 ; increment oam pointer
|
||||||
PLA
|
PLA
|
||||||
!ADD $92 : STA $92
|
!ADD $92 : STA $92
|
||||||
.free
|
|
||||||
PLP : PLY : PLX
|
PLP : PLY : PLX
|
||||||
PLB
|
PLB
|
||||||
RTS
|
RTS
|
||||||
@@ -835,7 +905,7 @@ db #$00, #$FF
|
|||||||
.price_columns_2
|
.price_columns_2
|
||||||
db #$00, #$80, #$80, $FF
|
db #$00, #$80, #$80, $FF
|
||||||
.price_columns_3
|
.price_columns_3
|
||||||
db #$00, #$60, #$60, #$90, #$90, $FF
|
db #$00, #$60, #$60, #$90, #$90, $FF, $FF, $FF
|
||||||
;--------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------
|
||||||
RequestItemOAM:
|
RequestItemOAM:
|
||||||
PHX : PHY : PHA
|
PHX : PHY : PHA
|
||||||
|
|||||||
10
tables.asm
10
tables.asm
@@ -1602,12 +1602,12 @@ ShopTable:
|
|||||||
db $01, $15, $01, $5D, $00, $12, $04, $00
|
db $01, $15, $01, $5D, $00, $12, $04, $00
|
||||||
db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
|
db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
|
||||||
|
|
||||||
org $30C900 ; PC 0x184900 - 0x184FFF - max 224 entries
|
org $30C900 ; PC 0x184900 - 0x184FFF - max 198 entries (9 bytes * C6 (198) = 6f6 ~ 184FF6)
|
||||||
ShopContentsTable:
|
ShopContentsTable:
|
||||||
;db [id][item][price-low][price-high][max][repl_id][repl_price-low][repl_price-high]
|
;db [id][item][price-low][price-high][max][repl_id][repl_price-low][repl_price-high][player]
|
||||||
db $01, $51, $64, $00, $07, $FF, $00, $00
|
db $01, $51, $64, $00, $07, $FF, $00, $00, $00
|
||||||
db $01, $53, $64, $00, $07, $FF, $00, $00
|
db $01, $53, $64, $00, $07, $FF, $00, $00, $00
|
||||||
db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
|
db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
|
||||||
|
|
||||||
; Fix spawning with more hearts than capacity when less than 3 heart containers
|
; Fix spawning with more hearts than capacity when less than 3 heart containers
|
||||||
LowHeartFix:
|
LowHeartFix:
|
||||||
|
|||||||
Reference in New Issue
Block a user