Merge remote-tracking branch 'upstream/DRMain' into DRMain

This commit is contained in:
codemann8
2021-02-18 22:45:56 -06:00
10 changed files with 185 additions and 54 deletions

View File

@@ -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

View File

@@ -122,7 +122,7 @@ FixFrogSmith:
.loadgfx .loadgfx
JSL Tagalong_LoadGfx JSL Tagalong_LoadGfx
.done .done
RTS RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------

View File

@@ -89,6 +89,7 @@ OnFileLoad:
REP #$10 ; set 16 bit index registers REP #$10 ; set 16 bit index registers
JSL.l EnableForceBlank ; what we wrote over JSL.l EnableForceBlank ; what we wrote over
REP #$20 : LDA.l $30F010 : STA.l $7EF33E : SEP #$20 REP #$20 : LDA.l $30F010 : STA.l $7EF33E : SEP #$20
LDA MultiClientFlags : STA.l $7EF33D
LDA.b #$07 : STA $210c ; Restore screen 3 to normal tile area LDA.b #$07 : STA $210c ; Restore screen 3 to normal tile area

View File

@@ -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
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------

View File

@@ -260,9 +260,11 @@ AddInventory:
; don't count any of this stuff ; don't count any of this stuff
CPY.b #$20 : BNE + : BRL .itemCounts : + ; Crystal CPY.b #$20 : BNE + : BRL .itemCounts : + ; Crystal
CPY.b #$26 : BNE + : BRL .itemCounts : + ; Heart Piece Completion Heart CPY.b #$26 : BNE + : BRL .itemCounts : + ; Heart Piece Completion Heart
LDA.l !SHOP_ENABLE_COUNT : BNE ++
CPY.b #$2E : BNE + : BRL .itemCounts : + ; Red Potion (Refill) CPY.b #$2E : BNE + : BRL .itemCounts : + ; Red Potion (Refill)
CPY.b #$2F : BNE + : BRL .itemCounts : + ; Green Potion (Refill) CPY.b #$2F : BNE + : BRL .itemCounts : + ; Green Potion (Refill)
CPY.b #$30 : BNE + : BRL .itemCounts : + ; Blue Potion (Refill) CPY.b #$30 : BNE + : BRL .itemCounts : + ; Blue Potion (Refill)
++
CPY.b #$37 : BNE + : BRL .itemCounts : + ; Pendant CPY.b #$37 : BNE + : BRL .itemCounts : + ; Pendant
CPY.b #$38 : BNE + : BRL .itemCounts : + ; Pendant CPY.b #$38 : BNE + : BRL .itemCounts : + ; Pendant
CPY.b #$39 : BNE + : BRL .itemCounts : + ; Pendant CPY.b #$39 : BNE + : BRL .itemCounts : + ; Pendant
@@ -286,8 +288,7 @@ AddInventory:
CMP.w #271 : BNE + : BRL .shop : + ; villiage of outcasts shop, lumberjack shop, lake hylia shop, dark world magic shop CMP.w #271 : BNE + : BRL .shop : + ; villiage of outcasts shop, lumberjack shop, lake hylia shop, dark world magic shop
CMP.w #272 : BNE + : BRL .shop : + ; red shield shop CMP.w #272 : BNE + : BRL .shop : + ; red shield shop
CMP.w #284 : BNE + : BRL .shop : + ; bomb shop CMP.w #284 : BNE + : BRL .shop : + ; bomb shop
;CMP.w #265 : BNE + : BRL .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 #265 : BNE + : BRL .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 + : BRL .shop : + ; lake hylia shop
CMP.w #287 : BNE + : BRL .shop : + ; kakariko shop CMP.w #287 : BNE + : BRL .shop : + ; kakariko shop
CMP.w #255 : BNE + : BRL .shop : + ; light world death mountain shop CMP.w #255 : BNE + : BRL .shop : + ; light world death mountain shop
CMP.w #276 : BNE + : BRL .shop : + ; waterfall fairy CMP.w #276 : BNE + : BRL .shop : + ; waterfall fairy
@@ -295,7 +296,9 @@ AddInventory:
CMP.w #278 : BNE + : BRL .shop : + ; pyramid fairy CMP.w #278 : BNE + : BRL .shop : + ; pyramid fairy
PLP : BRA ++ PLP : BRA ++
.shop .shop
PLP : BRL .done PLP
LDA.l !SHOP_ENABLE_COUNT : BNE ++
BRL .done
++ ++
.dungeonCounts .dungeonCounts
@@ -959,6 +962,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
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
@@ -981,6 +989,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
@@ -989,8 +998,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
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
@@ -1049,9 +1058,13 @@ CollectPowder:
; if for any reason the item value is 0 reload it, just in case ; if for any reason the item value is 0 reload it, just in case
%GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) : TAY %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) : TAY
+ +
PHA : LDA WitchItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID : PLA PHA
LDA WitchItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID
LDA.b #$01 : STA.l !SHOP_ENABLE_COUNT
PLA
STZ $02E9 ; item from NPC STZ $02E9 ; item from NPC
JSL.l Link_ReceiveItem JSL.l Link_ReceiveItem
PHA : LDA.b #$00 : STA.l !SHOP_ENABLE_COUNT : PLA
;JSL.l FullInventoryExternal ;JSL.l FullInventoryExternal
JSL.l ItemSet_Powder JSL.l ItemSet_Powder
RTL RTL

View File

@@ -26,7 +26,7 @@ Sprite_LoadProperties:
org $288000 ;140000 org $288000 ;140000
ShuffleKeyDrops: ShuffleKeyDrops:
db 0 db 0
ShuffleKeyDropsReserved: MultiClientFlags: ; 140001 -> stored in SRAM at 7ef33d
db 0 db 0
LootTable: ;PC: 140002 LootTable: ;PC: 140002

View File

@@ -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.

View File

@@ -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
@@ -104,15 +106,19 @@ RTS
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
!TILE_UPLOAD_OFFSET_OVERRIDE = "$7F5042" !TILE_UPLOAD_OFFSET_OVERRIDE = "$7F5042"
!FREE_TILE_BUFFER = "#$1180" !FREE_TILE_BUFFER = "#$1180"
!SHOP_ENABLE_COUNT = "$7F504F"
!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 +132,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 +169,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 : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID
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 +207,7 @@ SpritePrep_ShopKeeper:
INY #4 INY #4
.next .next
INX #8 INX #9
BRL - BRL -
.stop .stop
@@ -376,6 +393,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 +538,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
@@ -522,6 +549,9 @@ Shopkeeper_SetupHitboxes:
PLP : PLY : PLX PLP : PLY : PLX
RTS RTS
!LOCK_STATS = "$7EF443"
!ITEM_TOTAL = "$7EF423"
;-------------------- ;--------------------
;!SHOP_STATE ;!SHOP_STATE
Shopkeeper_BuyItem: Shopkeeper_BuyItem:
@@ -536,6 +566,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 +588,22 @@ 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
TXA : !ADD !SHOP_SRAM_INDEX : TAX
LDA.l !SHOP_PURCHASE_COUNTS, 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
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
LDA.b #0 : STA.l !SHOP_ENABLE_COUNT
TXA : LSR #2 : TAX TXA : LSR #2 : TAX
LDA !SHOP_TYPE : BIT.b #$80 : BNE + LDA !SHOP_TYPE : BIT.b #$80 : BNE +
LDA !SHOP_KEEP_REFILL : BNE +++
LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE 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 : +++
@@ -573,17 +614,24 @@ Shopkeeper_BuyItem:
BIT.b #$20 : BNE .takeAll BIT.b #$20 : BNE .takeAll
.takeAny .takeAny
LDA.l !SHOP_STATE : ORA.b #$07 : STA.l !SHOP_STATE 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 : PLX PHX
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.b #$01 : STA.l !SHOP_PURCHASE_COUNTS, X
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT
PLX
BRA ++ BRA ++
.takeAll .takeAll
LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE 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 : PLX PHX
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l !SHOP_PURCHASE_COUNTS, X
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT
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 +651,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 +735,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 +751,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 +771,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 +784,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 +802,25 @@ Shopkeeper_DrawNextItem:
+ +
XBA XBA
AND #$FE
STA.l !SPRITE_OAM+4 STA.l !SPRITE_OAM+4
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 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 +836,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 +845,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 +862,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 +885,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
@@ -835,7 +924,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

View File

@@ -244,7 +244,9 @@ IncrementSmallKeysNoPrimary:
PHP : REP #$20 ; set 16-bit accumulator PHP : REP #$20 ; set 16-bit accumulator
LDA $048E : CMP.w #$0087 : BNE ++ ; hera basement LDA $048E : CMP.w #$0087 : BNE ++ ; hera basement
PLP : PHY : LDY.b #$24 : JSL.l FullInventoryExternal PLP : PHY : LDY.b #$24 : JSL.l FullInventoryExternal
JSR CountChestKey : PLY : BRA + LDA ShuffleKeyDrops : BNE +++
JSR CountChestKey
+++ PLY : BRA +
++ ++
PLP PLP
+ +

View File

@@ -1463,8 +1463,8 @@ dw #9999 ; Rupee Limit
; $7F5042 - Tile Upload Offset Override (Low) ; $7F5042 - Tile Upload Offset Override (Low)
; $7F5043 - Tile Upload Offset Override (High) ; $7F5043 - Tile Upload Offset Override (High)
; $7F5044 - $7F5046 - NMI Auxiliary Function ; $7F5044 - $7F5046 - NMI Auxiliary Function
; $7F5047 - $7F504F - Unused ; $7F5047 - $7F504E - Unused
; $7F5050 - $7F506F - Shop Block ; $7F504F - $7F506F - Shop Block
; $7F5070 - Reserved for OneMind ; $7F5070 - Reserved for OneMind
; $7F5071 - Reserved for OneMind ; $7F5071 - Reserved for OneMind
; $7F5072 - $7F507D - Unused ; $7F5072 - $7F507D - Unused
@@ -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:
@@ -1828,6 +1828,14 @@ org $30E37D ; PC 0x18637D
Enable_TerrorPin_AI_Fix: Enable_TerrorPin_AI_Fix:
db #$01 db #$01
;Shop slot count as check
org $30E560 ; PC 0x18650
EnableShopItemCount:
db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; 0x186380 - 187FFF (unused) ; 0x186380 - 187FFF (unused)
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------