From 05e7f8eb96a9f2908e9ea1941ae175035c6be006 Mon Sep 17 00:00:00 2001 From: aerinon Date: Fri, 29 Jan 2021 13:55:13 -0700 Subject: [PATCH 1/5] Ported over pepper's shop code --- LTTP_RND_GeneralBugfixes.asm | 10 +-- bugfixes.asm | 2 +- hooks.asm | 24 +++++- inventory.asm | 10 ++- music.asm | 2 +- shopkeeper.asm | 142 ++++++++++++++++++++++++++--------- tables.asm | 10 +-- 7 files changed, 147 insertions(+), 53 deletions(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 3275a33..a92d2af 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -152,11 +152,6 @@ incsrc clock.asm incsrc accessability.asm incsrc heartbeep.asm incsrc capacityupgrades.asm -incsrc timer.asm -incsrc doorframefixes.asm -incsrc music.asm -incsrc roomloading.asm -incsrc icepalacegraphics.asm warnpc $A18000 org $1C8000 ; text tables for translation @@ -183,6 +178,11 @@ org $A1FF00 ; static mapping area incsrc init.asm 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 hardmode.asm incsrc goalitem.asm diff --git a/bugfixes.asm b/bugfixes.asm index 4b55a67..18cbe2d 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -122,7 +122,7 @@ FixFrogSmith: .loadgfx JSL Tagalong_LoadGfx .done -RTS +RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- diff --git a/hooks.asm b/hooks.asm index 670ec22..9e58cfb 100755 --- a/hooks.asm +++ b/hooks.asm @@ -1171,10 +1171,9 @@ NOP #2 org $05F55F ; <- 2F55F - sprite_potion_shop.asm : 59 JSL.l LoadPowder ;-------------------------------------------------------------------------------- -org $05F681 ; <- 2F681 - sprite_potion_shop.asm : 234 -JSL.l DrawPowder +org $05F67B ; <- 2F67B - sprite_potion_shop.asm : 234 +JSL DrawPowder RTS -NOP #8 ;-------------------------------------------------------------------------------- org $05F65D ; <- 2F65D - sprite_potion_shop.asm : 198 JSL.l CollectPowder @@ -1190,6 +1189,25 @@ JSL.l DrawMushroom org $05EE97 ; <- 2EE97 - sprite_mushroom.asm : 81 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 JSL.l Multiworld_BottleVendor_GiveBottle ;-------------------------------------------------------------------------------- diff --git a/inventory.asm b/inventory.asm index 4214a57..0365528 100644 --- a/inventory.asm +++ b/inventory.asm @@ -924,6 +924,11 @@ LoadPowder: %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) STA $0DA0, Y ; Store item type JSL.l PrepDynamicTile + STA $7F505E + LDA #$00 + STA $7F505F + STA $7F5060 + STA $7F5061 RTL ;-------------------------------------------------------------------------------- @@ -946,6 +951,7 @@ RTL !REDRAW = "$7F5000" ;-------------------------------------------------------------------------------- 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.l !REDRAW : BEQ + LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID @@ -954,8 +960,8 @@ DrawPowder: LDA #$00 : STA.l !REDRAW ; reset redraw flag BRA .defer + - LDA $0DA0, X ; Retrieve stored item type - JSL.l DrawDynamicTile +; LDA $0DA0, X ; Retrieve stored item type +; JSL.l DrawDynamicTile .defer RTL ;-------------------------------------------------------------------------------- diff --git a/music.asm b/music.asm index 7973a49..2375c56 100644 --- a/music.asm +++ b/music.asm @@ -3,7 +3,7 @@ PreOverworld_LoadProperties_ChooseMusic: ; A: scratch space (value never used) ; Y: set to overworld animated tileset ; 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. diff --git a/shopkeeper.asm b/shopkeeper.asm index 620fa8c..77f6dda 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -57,6 +57,7 @@ macro DrawDigit(value,offset) + LDA $0E : 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 LDA.w #$0000 : STA !BIGRAM, X : INX : INX @@ -66,6 +67,7 @@ endmacro !COLUMN_LOW = "$7F5022" !COLUMN_HIGH = "$7F5023" DrawPrice: + STX $07 PHX : PHY : PHP LDY.b #$FF LDX #$00 ; clear bigram pointer @@ -86,7 +88,7 @@ DrawPrice: .len1 %DrawDigit(#1,#0) - + SEP #$20 ; set 8-bit accumulator TXA : LSR #3 : STA $06 ; request 1-4 OAM slots ASL #2 @@ -106,13 +108,16 @@ RTS !FREE_TILE_BUFFER = "#$1180" !SHOP_ID = "$7F5050" !SHOP_TYPE = "$7F5051" -!SHOP_INVENTORY = "$7F5052" ; $7F505E -!SHOP_STATE = "$7F505F" -!SHOP_CAPACITY = "$7F5060" -!SCRATCH_TEMP_X = "$7F5061" -!SHOP_SRAM_INDEX = "$7F5062" -!SHOP_MERCHANT = "$7F5063" -!SHOP_DMA_TIMER = "$7F5064" +!SHOP_INVENTORY = "$7F5052" ; $7F5056 - 5a - 5e +!SHOP_INVENTORY_PLAYER = "$7F5062" +!SHOP_INVENTORY_DISGUISE = "$7F5065" ; was going to remove this, but this lets more than one bee trap exist with its own icon. +!SHOP_STATE = "$7F5069" +!SHOP_CAPACITY = "$7F506A" +!SCRATCH_TEMP_X = "$7F506B" +!SHOP_SRAM_INDEX = "$7F506C" +!SHOP_MERCHANT = "$7F506D" +!SHOP_DMA_TIMER = "$7F506E" +!SHOP_KEEP_REFILL = "$7F506F" ;-------------------------------------------------------------------------------- !NMI_AUX = "$7F5044" ;-------------------------------------------------------------------------------- @@ -126,7 +131,6 @@ SpritePrep_ShopKeeper: PHX : PHY : PHP REP #$30 ; set 16-bit accumulator & index registers - ;LDA $A0 LDX.w #$0000 - 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+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+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 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 PLX - LDA.l ShopContentsTable+4, X : BEQ ++ + LDA.l ShopContentsTable+4, X : BEQ + TYA : CMP.l ShopContentsTable+4, X : !BLT ++ PLY 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+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 +++ + + : PLY : LDA #$40 : PHX : TYX : STA.l !SHOP_INVENTORY+3, X : PLX : BRA +++ ++ PLY : +++ 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 LDA 1,s : TAX : LDA.l .tile_offsets, X : TAX JSR LoadTile @@ -190,7 +206,7 @@ SpritePrep_ShopKeeper: INY #4 .next - INX #8 + INX #9 BRL - .stop @@ -376,6 +392,15 @@ Shopkepeer_CallOriginal: ;!SHOP_TYPE = "$7F5051" ;!SHOP_CAPACITY = "$7F5020" ;!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: LDA.l !SHOP_TYPE : CMP.b #$FF : BNE + : JMP.w Shopkepeer_CallOriginal : + @@ -512,6 +537,7 @@ Shopkeeper_SetupHitboxes: JSR.w Setup_ShopItemInteractionHitbox 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 $10 : CMP.b #$0C : !BGE .no_interaction ; don't interact in other modes besides game action JSR.w Shopkeeper_BuyItem @@ -527,7 +553,7 @@ RTS Shopkeeper_BuyItem: PHX : PHY TYX - + LDA.l !SHOP_INVENTORY, X CMP.b #$0E : BEQ .refill ; Bee Refill CMP.b #$2E : BEQ .refill ; Red Potion Refill @@ -536,6 +562,7 @@ Shopkeeper_BuyItem: BRA + .refill 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 @@ -557,12 +584,15 @@ Shopkeeper_BuyItem: 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 ++ + 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+3, X : INC : STA.l !SHOP_INVENTORY+3, X TXA : LSR #2 : TAX 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 TXA : !ADD !SHOP_SRAM_INDEX : TAX 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 ++ .done + LDA #$0 : STA !SHOP_KEEP_REFILL PLY : PLX RTS Shopkeeper_ItemMasks: -db #$01, #$02, #$04 +db #$01, #$02, #$04, #$08 ;-------------------- ;!SHOP_ID = "$7F5050" ;!SHOP_SRAM_INDEX = "$7F5062" @@ -603,6 +634,7 @@ Setup_ShopItemCollisionHitbox: REP #$20 ; set 16-bit accumulator PHA : PHY 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 PLY : PLA @@ -686,6 +718,7 @@ RTS ;!SHOP_TYPE = "$7F5051" ;!SHOP_INVENTORY = "$7F5052" !SPRITE_OAM = "$7EC025" +!REDRAW = "$7F5000" Shopkeeper_DrawItems: PHB : PHK : PLB PHX : PHY @@ -701,6 +734,14 @@ Shopkeeper_DrawItems: + CMP.b #$01 : BNE + : ++ 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 PLB RTS @@ -713,6 +754,7 @@ Shopkeeper_DrawNextItem: LDA !SHOP_TYPE : AND.b #$03 : DEC : ASL : TAY 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 1,s : ASL #2 : TAY ; set Y to the item index LDA ($00), Y : STA.l !SPRITE_OAM ; load X-coordinate @@ -725,7 +767,9 @@ Shopkeeper_DrawNextItem: SEP #$20 ; set 8-bit accumulator 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 #$2F : BNE + : BRA .potion + CMP.b #$30 : BEQ .potion @@ -741,14 +785,25 @@ Shopkeeper_DrawNextItem: + XBA + AND #$FE 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 + 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.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 .full LDA.b #$02 @@ -764,6 +819,7 @@ Shopkeeper_DrawNextItem: PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSR.w RequestItemOAM : PLX LDA !SHOP_TYPE : AND.b #$80 : BNE + + CPX.b #12 : BEQ + ; don't render potion price JSR.w Shopkeeper_DrawNextPrice + @@ -772,10 +828,14 @@ Shopkeeper_DrawNextItem: INX #4 RTS ;-------------------------------------------------------------------------------- -.item_offsets_idx +.item_offsets_idx ; 112 60 dw #.item_offsets_1 dw #.item_offsets_2 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 dw 8, 40 .item_offsets_2 @@ -785,8 +845,19 @@ dw 32, 40 dw -40, 40 dw 8, 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 -db $C6, $C8, $CA +db $C6, $C8, $CA, $25 ; last bit is for sheet change ;-------------------------------------------------------------------------------- !COLUMN_LOW = "$7F5022" !COLUMN_HIGH = "$7F5023" @@ -797,6 +868,7 @@ Shopkeeper_DrawNextPrice: REP #$20 ; set 16-bit accumulator PHY 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 .price_columns_idx, Y : STA $02 ; get table from the table table PLY : PHY @@ -808,21 +880,19 @@ Shopkeeper_DrawNextPrice: PLY LDA.l !SHOP_INVENTORY+1, X : STA $0C ; set value - BEQ .free - JSR.w DrawPrice - SEP #$20 : STA $06 : STZ $07 ; set 8-bit accumulator & store result - PHA - LDA.b #!BIGRAM : STA $08 - LDA.b #!BIGRAM>>8 : STA $09 - LDA.b #$7E : PHA : PLB ; set data bank to $7E + JSR.w DrawPrice + SEP #$20 : STA $06 : STZ $07 ; set 8-bit accumulator & store result + PHA + LDA.b #!BIGRAM : STA $08 + LDA.b #!BIGRAM>>8 : STA $09 + 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 - - LDA 1,s - ASL #2 : !ADD $90 : STA $90 ; increment oam pointer - PLA - !ADD $92 : STA $92 - .free + PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSL.l Sprite_DrawMultiple_quantity_preset : PLX + + LDA 1,s + ASL #2 : !ADD $90 : STA $90 ; increment oam pointer + PLA + !ADD $92 : STA $92 PLP : PLY : PLX PLB RTS @@ -835,7 +905,7 @@ db #$00, #$FF .price_columns_2 db #$00, #$80, #$80, $FF .price_columns_3 -db #$00, #$60, #$60, #$90, #$90, $FF +db #$00, #$60, #$60, #$90, #$90, $FF, $FF, $FF ;-------------------------------------------------------------------------------- RequestItemOAM: PHX : PHY : PHA diff --git a/tables.asm b/tables.asm index 6f84a33..6c8bf60 100644 --- a/tables.asm +++ b/tables.asm @@ -1602,12 +1602,12 @@ ShopTable: db $01, $15, $01, $5D, $00, $12, $04, $00 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: -;db [id][item][price-low][price-high][max][repl_id][repl_price-low][repl_price-high] -db $01, $51, $64, $00, $07, $FF, $00, $00 -db $01, $53, $64, $00, $07, $FF, $00, $00 -db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF +;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, $00 +db $01, $53, $64, $00, $07, $FF, $00, $00, $00 +db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF ; Fix spawning with more hearts than capacity when less than 3 heart containers LowHeartFix: From 2a0895922993285e75510a2fd07415d71724fbd6 Mon Sep 17 00:00:00 2001 From: aerinon Date: Mon, 1 Feb 2021 10:11:38 -0700 Subject: [PATCH 2/5] Shop counting items --- events.asm | 1 + inventory.asm | 13 +++++++++---- shopkeeper.asm | 23 ++++++++++++++++++++--- tables.asm | 12 ++++++++++-- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/events.asm b/events.asm index dbdafb7..31bfda3 100644 --- a/events.asm +++ b/events.asm @@ -88,6 +88,7 @@ RTL OnFileLoad: REP #$10 ; set 16 bit index registers JSL.l EnableForceBlank ; what we wrote over + REP #$20 : LDA.l $30F010 : STA.l $7EF33E : SEP $#20 LDA.b #$07 : STA $210c ; Restore screen 3 to normal tile area diff --git a/inventory.asm b/inventory.asm index 224e6d4..35c0c5a 100644 --- a/inventory.asm +++ b/inventory.asm @@ -286,8 +286,7 @@ AddInventory: 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 #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 #271 : BNE + : BRL .shop : + ; lake hylia 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 #287 : BNE + : BRL .shop : + ; kakariko shop CMP.w #255 : BNE + : BRL .shop : + ; light world death mountain shop CMP.w #276 : BNE + : BRL .shop : + ; waterfall fairy @@ -295,7 +294,9 @@ AddInventory: CMP.w #278 : BNE + : BRL .shop : + ; pyramid fairy PLP : BRA ++ .shop - PLP : BRL .done + PLP + LDA.l !SHOP_ENABLE_COUNT : BNE ++ + BRL .done ++ .dungeonCounts @@ -1026,9 +1027,13 @@ CollectPowder: ; if for any reason the item value is 0 reload it, just in case %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 JSL.l Link_ReceiveItem + PHA : LDA.b #$00 : STA.l !SHOP_ENABLE_COUNT : PLA ;JSL.l FullInventoryExternal JSL.l ItemSet_Powder RTL diff --git a/shopkeeper.asm b/shopkeeper.asm index 77f6dda..db61bbe 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -106,6 +106,7 @@ RTS ;-------------------------------------------------------------------------------- !TILE_UPLOAD_OFFSET_OVERRIDE = "$7F5042" !FREE_TILE_BUFFER = "#$1180" +!SHOP_ENABLE_COUNT = "$7F504F" !SHOP_ID = "$7F5050" !SHOP_TYPE = "$7F5051" !SHOP_INVENTORY = "$7F5052" ; $7F5056 - 5a - 5e @@ -548,6 +549,9 @@ Shopkeeper_SetupHitboxes: PLP : PLY : PLX RTS + +!LOCK_STATS = "$7EF443" +!ITEM_TOTAL = "$7EF423" ;-------------------- ;!SHOP_STATE Shopkeeper_BuyItem: @@ -584,9 +588,16 @@ Shopkeeper_BuyItem: 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 ++ - PHX : LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_PLAYER, X : STA !MULTIWORLD_ITEM_PLAYER_ID : PLX + 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+3, X : INC : STA.l !SHOP_INVENTORY+3, X + LDA.b #0 : STA.l !SHOP_ENABLE_COUNT TXA : LSR #2 : TAX LDA !SHOP_TYPE : BIT.b #$80 : BNE + @@ -603,11 +614,17 @@ Shopkeeper_BuyItem: BIT.b #$20 : BNE .takeAll .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 : 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 ++ .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 : 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 LDA #$0 : STA !SHOP_KEEP_REFILL diff --git a/tables.asm b/tables.asm index 6c8bf60..2dbd0c0 100644 --- a/tables.asm +++ b/tables.asm @@ -1463,8 +1463,8 @@ dw #9999 ; Rupee Limit ; $7F5042 - Tile Upload Offset Override (Low) ; $7F5043 - Tile Upload Offset Override (High) ; $7F5044 - $7F5046 - NMI Auxiliary Function -; $7F5047 - $7F504F - Unused -; $7F5050 - $7F506F - Shop Block +; $7F5047 - $7F504E - Unused +; $7F504F - $7F506F - Shop Block ; $7F5070 - Reserved for OneMind ; $7F5071 - Reserved for OneMind ; $7F5072 - $7F507D - Unused @@ -1828,6 +1828,14 @@ org $30E37D ; PC 0x18637D Enable_TerrorPin_AI_Fix: 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) ;-------------------------------------------------------------------------------- From a63aa6f5fee8eb65fbf67116503faa35a7a7c256 Mon Sep 17 00:00:00 2001 From: aerinon Date: Mon, 1 Feb 2021 16:29:09 -0700 Subject: [PATCH 3/5] Shop fixes --- events.asm | 2 +- inventory.asm | 8 +++++--- shopkeeper.asm | 26 ++++++++++++++------------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/events.asm b/events.asm index 31bfda3..c9ffa67 100644 --- a/events.asm +++ b/events.asm @@ -88,7 +88,7 @@ RTL OnFileLoad: REP #$10 ; set 16 bit index registers 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.b #$07 : STA $210c ; Restore screen 3 to normal tile area diff --git a/inventory.asm b/inventory.asm index 35c0c5a..bedd126 100644 --- a/inventory.asm +++ b/inventory.asm @@ -260,9 +260,11 @@ AddInventory: ; don't count any of this stuff CPY.b #$20 : BNE + : BRL .itemCounts : + ; Crystal CPY.b #$26 : BNE + : BRL .itemCounts : + ; Heart Piece Completion Heart - CPY.b #$2E : BNE + : BRL .itemCounts : + ; Red Potion (Refill) - CPY.b #$2F : BNE + : BRL .itemCounts : + ; Green Potion (Refill) - CPY.b #$30 : BNE + : BRL .itemCounts : + ; Blue Potion (Refill) + LDA.l !SHOP_ENABLE_COUNT : BNE ++ + CPY.b #$2E : BNE + : BRL .itemCounts : + ; Red Potion (Refill) + CPY.b #$2F : BNE + : BRL .itemCounts : + ; Green Potion (Refill) + CPY.b #$30 : BNE + : BRL .itemCounts : + ; Blue Potion (Refill) + ++ CPY.b #$37 : BNE + : BRL .itemCounts : + ; Pendant CPY.b #$38 : BNE + : BRL .itemCounts : + ; Pendant CPY.b #$39 : BNE + : BRL .itemCounts : + ; Pendant diff --git a/shopkeeper.asm b/shopkeeper.asm index db61bbe..8c95b74 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -896,20 +896,22 @@ Shopkeeper_DrawNextPrice: INY : LDA ($02), Y : STA !COLUMN_HIGH PLY LDA.l !SHOP_INVENTORY+1, X : STA $0C ; set value - - JSR.w DrawPrice - SEP #$20 : STA $06 : STZ $07 ; set 8-bit accumulator & store result - PHA - LDA.b #!BIGRAM : STA $08 - LDA.b #!BIGRAM>>8 : STA $09 - 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 + BEQ .free + JSR.w DrawPrice + SEP #$20 : STA $06 : STZ $07 ; set 8-bit accumulator & store result + PHA + LDA.b #!BIGRAM : STA $08 + LDA.b #!BIGRAM>>8 : STA $09 + LDA.b #$7E : PHA : PLB ; set data bank to $7E - LDA 1,s - ASL #2 : !ADD $90 : STA $90 ; increment oam pointer - PLA - !ADD $92 : STA $92 + PHX : PHA : LDA !SCRATCH_TEMP_X : TAX : PLA : JSL.l Sprite_DrawMultiple_quantity_preset : PLX + + LDA 1,s + ASL #2 : !ADD $90 : STA $90 ; increment oam pointer + PLA + !ADD $92 : STA $92 + .free PLP : PLY : PLX PLB RTS From 4ae59ad1e6cfbbc719170dcfd2c34611219917df Mon Sep 17 00:00:00 2001 From: aerinon Date: Wed, 17 Feb 2021 11:50:51 -0700 Subject: [PATCH 4/5] Double count hera basement cage in keydropshuffle --- stats.asm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stats.asm b/stats.asm index e854827..055ab53 100644 --- a/stats.asm +++ b/stats.asm @@ -244,7 +244,9 @@ IncrementSmallKeysNoPrimary: PHP : REP #$20 ; set 16-bit accumulator LDA $048E : CMP.w #$0087 : BNE ++ ; hera basement PLP : PHY : LDY.b #$24 : JSL.l FullInventoryExternal - JSR CountChestKey : PLY : BRA + + LDA ShuffleKeyDrops : BNE +++ + JSR CountChestKey + +++ PLY : BRA + ++ PLP + From 8b622dd841928464fd7f20eb34068bc250441b6c Mon Sep 17 00:00:00 2001 From: aerinon Date: Thu, 18 Feb 2021 13:37:33 -0700 Subject: [PATCH 5/5] Multiclient flags Multi Sprite Player set to skip progressive limits --- events.asm | 1 + keydropshuffle.asm | 2 +- shopkeeper.asm | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/events.asm b/events.asm index c9ffa67..5cdb884 100644 --- a/events.asm +++ b/events.asm @@ -89,6 +89,7 @@ OnFileLoad: REP #$10 ; set 16 bit index registers JSL.l EnableForceBlank ; what we wrote over 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 diff --git a/keydropshuffle.asm b/keydropshuffle.asm index a150774..70e8004 100644 --- a/keydropshuffle.asm +++ b/keydropshuffle.asm @@ -26,7 +26,7 @@ Sprite_LoadProperties: org $288000 ;140000 ShuffleKeyDrops: db 0 -ShuffleKeyDropsReserved: +MultiClientFlags: ; 140001 -> stored in SRAM at 7ef33d db 0 LootTable: ;PC: 140002 diff --git a/shopkeeper.asm b/shopkeeper.asm index 8c95b74..f789078 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -169,7 +169,7 @@ SpritePrep_ShopKeeper: 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+3, X : PHX : TYX : STA.l !SHOP_INVENTORY+2, X : PLX - LDA.l ShopContentsTable+8, X : PHX : PHA + 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