Fix GFX transfer, use stack

Fix HUD arrow icon after buying shop arrow
This commit is contained in:
cassidoxa
2023-08-25 12:29:52 -04:00
parent 3f5455b647
commit 5ac2f8c537
5 changed files with 31 additions and 28 deletions

View File

@@ -44,10 +44,12 @@ TransferItemGFX:
; Only used for shops now but could be used for anything. We should look at how door rando does this
; and try to unify one approach.
REP #$30
LDX.w ItemQueuePtr : BEQ .done
LDX.w ItemStackPtr : BEQ .done
TXA : BIT #$0040 : BNE .fail ; Crash if we have more than 16 queued (should never happen.)
DEX #2
-
LDA.w ItemGFXQueue,X : STA.w ItemGFXPtr
LDA.w ItemTargetQueue,X : STA.w ItemGFXTarget
LDA.l ItemGFXStack,X : STA.w ItemGFXPtr
LDA.l ItemTargetStack,X : STA.w ItemGFXTarget
PHX
JSL.l TransferItemToVRAM
REP #$10
@@ -55,7 +57,9 @@ TransferItemGFX:
DEX #2
BPL -
STZ.w ItemQueuePtr
STZ.w ItemStackPtr
.done
SEP #$30
RTS
.fail
BRK #$00

View File

@@ -1032,7 +1032,7 @@ ItemReceiptGraphicsOffsets:
dw $05A0 ; 4D - Arrow capacity (70)
dw $01A0 ; 4E - 1/2 magic
dw $01E0 ; 4F - 1/4 magic
dw $0 ; 50 - Safe master sword
dw $00E0 ; 50 - Safe master sword
dw $0420 ; 51 - Bomb capacity (+5)
dw $0460 ; 52 - Bomb capacity (+10)
dw $0520 ; 53 - Arrow capacity (+5)

View File

@@ -434,7 +434,10 @@ ItemBehavior:
RTS
.single_arrow
INC.w UpdateHUD
LDA.l ArrowMode : BEQ +
LDA.l CurrentArrows : INC : STA.l CurrentArrows ; Should be sole write to this address
INC.w UpdateHUD ; in retro/rupee bow mode.
+
RTS
.rupoor

12
ram.asm
View File

@@ -190,10 +190,10 @@ MessageJunk = $7E0223 ; Zeroed but never used (?)
;
ShopPurchaseFlag = $7E0224 ; $01 = Shop purchase item receipt.
;CoolScratch = $7E0224 ; 0x5C bytes of free ram
ItemQueuePtr = $7E0226 ; Pointer into Item GFX and VRAM target queues. Word length.
ItemStackPtr = $7E0226 ; Pointer into Item GFX and VRAM target queues. Word length.
; If not zero, pointer should always be left pointing at the
; next available slot in the stack during the frame.
SpriteID = $7E0230 ; 0x0A bytes. Receipt ID for main loop sprite we're handling.
ItemGFXQueue = $7E0230 ; Pointers to decompressed item tiles deferred to NMI loading. $10 bytes
ItemTargetQueue = $7E0240 ; Pointers to VRAM targets for ItemGFXQueue. $10 bytes
AncillaVelocityZ = $7E0294 ; 0x0A bytes
AncillaZCoord = $7E029E ; 0x0A bytes
;
@@ -476,7 +476,10 @@ HUDArrowCount = $7EC760 ;
HUDKeyDigits = $7EC764 ;
;
BigRAM = $7EC900 ; Big buffer of free ram (0x1F00)
TotalItemCountTiles = $7ECB00 ; Cached total item count tiles for HUD. Four words high to low.
ItemGFXStack = $7ECB00 ; Pointers to source of decompressed item tiles deferred to NMI loading.
ItemGFXSBankStack = $7ECB20 ; Source bank byte for above.
ItemTargetStack = $7ECB40 ; Pointers to VRAM targets for ItemGFXStack.
TotalItemCountTiles = $7ECF00 ; Cached total item count tiles for HUD. Four words high to low.
;================================================================================
; Bank 7F
@@ -485,7 +488,6 @@ DecompressionBuffer = $7F0000 ; Decompression Buffer. $2000 bytes.
DecompBuffer2 = $7F4000 ; Another buffer
base $7F5000
RedrawFlag: skip 1 ;
skip 2 ; Unused

View File

@@ -105,8 +105,8 @@ SpritePrep_ShopKeeper:
LDX.w #$0000
LDY.w #$0000
-
TYA : CMP.l ShopCapacity : !BLT ++ : JMP .stop : ++
LDA.l ShopContentsTable+1, X : CMP.b #$FF : BNE ++ : JMP .stop : ++
TYA : CMP.l ShopCapacity : !BLT ++ : JMP .done : ++
LDA.l ShopContentsTable+1, X : CMP.b #$FF : BNE ++ : JMP .done : ++
LDA.l ShopContentsTable, X : CMP.l ShopId : BEQ ++ : JMP .next : ++
LDA.l ShopContentsTable+1, X : PHX : TYX : STA.l ShopInventory, X : PLX
@@ -143,15 +143,9 @@ SpritePrep_ShopKeeper:
.next
INX #8
JMP -
.stop
REP #$20
LDA.w ItemQueuePtr
DEC #2
AND.w #$00E
STA.w ItemQueuePtr
SEP #$20
.done
SEP #$20
LDA.l ShopType : BIT.b #$20 : BEQ .notTakeAll ; Take-all
.takeAll
@@ -199,19 +193,19 @@ SetupTileTransfer:
TXA : LSR #2
CLC : ADC.w #!FREE_TILE_ALT
.store_target
LDX.w ItemQueuePtr
STA.w ItemTargetQueue,X
LDX.w ItemStackPtr
STA.l ItemTargetStack,X
TYA : ASL : TAX
LDA.l StandingItemGraphicsOffsets,X
LDX.w ItemQueuePtr
STA.w ItemGFXQueue,X
LDX.w ItemStackPtr
STA.l ItemGFXStack,X
TXA
INC #2
AND.w #$000E
STA.w ItemQueuePtr
TDC
STA.l ItemStackPtr
LDA.w #$0000
REP #$10 ; set 16-bit index registers
SEP #$20
RTS