Item receipt refactor

Inverted maps
Fix shops
This commit is contained in:
cassidoxa
2023-06-30 21:21:59 -04:00
parent 83377b6bea
commit 0a073df728
7 changed files with 711 additions and 844 deletions

View File

@@ -114,7 +114,7 @@ TransferItemReceiptToBuffer_using_ReceiptID:
;===================================================================================================
TransferItemReceiptToVRAM:
TransferItemToVRAM:
REP #$21
SEP #$10
@@ -128,9 +128,9 @@ TransferItemReceiptToVRAM:
LDX.b #ItemReceiptGraphicsROM>>16
.set_address
STA.w $4202
STA.w $4302
ADC.w #$0200
STA.w $4212
STA.w $4312
STX.w $4304
STX.w $4314
@@ -146,7 +146,7 @@ TransferItemReceiptToVRAM:
STA.w $4305
STA.w $4315
LDA.w ItemGFXTgt
LDA.w ItemGFXTarget
STA.w $2116
LDX.b #$01
@@ -159,6 +159,7 @@ TransferItemReceiptToVRAM:
STX.w $420B
STZ.w ItemGFXPtr
STZ.w ItemGFXTarget
.exit
RTL
@@ -888,7 +889,7 @@ StandingItemGraphicsOffsets:
dw BigDecompressionBuffer+$0DA0 ; 46 - 300 rupees
dw BigDecompressionBuffer+$0000 ; 47 - 20 rupees green
dw BigDecompressionBuffer+$09A0 ; 48 - Full bottle (good bee)
dw BigDecompressionBuffer+$1C20 ; 49 - Tossed fighter sword
dw $00A0 ; 49 - Tossed fighter sword
dw BigDecompressionBuffer+$09A0 ; 4A - Bottle refill (good bee)
dw BigDecompressionBuffer+$0040 ; 4B - Boots

View File

@@ -14,7 +14,7 @@
;--------------------------------------------------------------------------------
; BowTracking
; Item Tracking Slot #2
; bsp-----
; -------- bsp-----
; b = bow
; s = silver arrow bow
; p = 2nd progressive bow

View File

@@ -223,6 +223,7 @@ Overworld_LoadNewTiles:
;---------------------------------------------------------------------------------------------------
.stripe
JSR .get_increment
LDX.w $0000,Y
BRA ++ ; to increment at start of loop properly
@@ -256,6 +257,7 @@ Overworld_LoadNewTiles:
;---------------------------------------------------------------------------------------------------
.stripe_rle_inc
JSR .get_increment
JSR .get_rle_size_and_tile
LDX.w $0000,Y
@@ -270,13 +272,11 @@ Overworld_LoadNewTiles:
INC
STA.b OWWriteTile
++ INY
INY
STA.l $7E0000,X
++ STA.l $7E0000,X
DEC.b OWWriteSize
BNE --
INY #2
RTS
;---------------------------------------------------------------------------------------------------
@@ -297,6 +297,7 @@ Overworld_LoadNewTiles:
;---------------------------------------------------------------------------------------------------
.stripe_rle
JSR .get_increment
JSR .get_rle_size_and_tile
LDX.w $0000,Y
@@ -309,13 +310,11 @@ Overworld_LoadNewTiles:
LDA.b OWWriteTile
++ INY
INY
STA.l $7E0000,X
++ STA.l $7E0000,X
DEC.b OWWriteSize
BNE --
INY #2
RTS
;---------------------------------------------------------------------------------------------------
@@ -405,7 +404,7 @@ dw $0000 ; 2C
dw $0000 ; 2D
dw $0000 ; 2E
dw $0000 ; 2F
dw $0000 ; 30
dw .map30 ; 30
dw .map31 ; 31
dw .map32 ; 32
dw .map33 ; 33
@@ -428,7 +427,7 @@ dw $0000 ; 41
dw $0000 ; 42
dw .map43 ; 43
dw .map44 ; 44
dw $0000 ; 45
dw .map45 ; 45
dw $0000 ; 46
dw .map47 ; 47
dw $0000 ; 48
@@ -471,7 +470,7 @@ dw $0000 ; 6C
dw $0000 ; 6D
dw $0000 ; 6E
dw .map6F ; 6F
dw $0000 ; 70
dw .map70 ; 70
dw $0000 ; 71
dw $0000 ; 72
dw .map73 ; 73
@@ -491,6 +490,7 @@ dw $0000 ; 7F
;---------------------------------------------------------------------------------------------------
.map03
dw !OWW_InvertedOnly
; singles
dw $0034, $2BE0
@@ -508,29 +508,23 @@ dw $0000 ; 7F
.map05
dw $0101, $2E18 ; OWG sign
dw !OWW_InvertedOnly
; singles
dw $0034, $21F2
dw $0034, $3D4A
dw $0116, $216E
dw $0126, $21F4
dw $0139, $2970
dw $0139, $2C6C
dw $014B, $2972
dw $014B, $2C6E
dw $016B, $29F0
dw $016B, $2CEC
dw $0182, $29F2
dw $0182, $2CEE
dw $01B3, $236C
dw $01B4, $236E
dw !OWW_Stripe|!OWW_Horizontal
dw $206C ; address
dw $0112, $0111, $0113, $0113, $0112|!OWW_STOP
dw $206E ; address
dw $0112, $0113, $0113, $0112|!OWW_STOP
dw !OWW_StripeRLEINC|!OWW_Horizontal|OWW_RLESize(2)
dw $0111, $20EC ; tile, start
@@ -538,6 +532,10 @@ dw $0000 ; 7F
dw !OWW_StripeRLEINC|!OWW_Horizontal|OWW_RLESize(3)
dw $0116, $20F0 ; tile, start
dw !OWW_Stripe|!OWW_Horizontal
dw $216C ; address
dw $0112, $0116, $011C, $011D, $011E|!OWW_STOP
dw !OWW_StripeRLEINC|!OWW_Horizontal|OWW_RLESize(3)
dw $011C, $2170 ; tile, start
@@ -547,6 +545,13 @@ dw $0000 ; 7F
dw !OWW_StripeRLEINC|!OWW_Horizontal|OWW_RLESize(4)
dw $0144, $2364 ; tile, start
dw !OWW_StripeRLEINC|!OWW_Horizontal|OWW_RLESize(2)
dw $01B3, $236C ; tile, start
dw !OWW_Stripe|!OWW_Horizontal
dw $2970 ; address
dw $0139, $014B|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0130 ; tile
dw $21E2, $21F0, $22E2, $22F0|!OWW_STOP
@@ -565,7 +570,7 @@ dw $0000 ; 7F
dw !OWW_Stripe|!OWW_Horizontal
dw $22E4 ; start
dw $013C, $013C, $013D, $013D, $013C, $013C
dw $013C, $013C, $013D, $013D, $013C, $013C|!OWW_STOP
dw !OWW_END
@@ -580,7 +585,7 @@ dw $0000 ; 7F
dw $0034, $2826
dw !OWW_ArbitraryRLE
dw $0135 ; tile
dw $021B ; tile
dw $259E, $25A2, $25A4, $261C
dw $2626, $269A, $26A8, $271A
dw $2728, $279A, $27A8, $281E
@@ -803,6 +808,201 @@ dw $0000 ; 7F
dw !OWW_END
;---------------------------------------------------------------------------------------------------
.map30
dw !OWW_InvertedOnly
dw $0178, $224E
dw $00D3, $22E2
dw $0302, $22E4
dw $00AA, $2368
dw $00AB, $236C
dw $01C2, $245C
dw $015C, $23E0
dw $0218, $245E
dw $0162, $2460
dw $0105, $255A
dw $01D4, $24DC
dw $0219, $24DE
dw $0171, $25DE
dw $0166, $255E
dw $0766, $2560
dw $06E1, $27D6
dw $00CF, $27DA
dw $0034, $3D94
dw !OWW_ArbitraryRLE
dw $017E
dw $2050, $20CE|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(7)
dw $00D1, $2052
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(6)
dw $00D1, $21E6
dw !OWW_ArbitraryRLE
dw $00D2
dw $2060, $20E2, $2164|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0183
dw $20D0, $214E|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(7)
dw $00C9, $20D2
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(7)
dw $00C9, $2152
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(6)
dw $00C9, $2266
dw $00C9, $22CC
dw !OWW_ArbitraryRLE
dw $00D0
dw $20E0, $2162, $21E4|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(3)
dw $0153, $2150
dw !OWW_ArbitraryRLE
dw $0153
dw $21CE, $22CE|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $00C8
dw $2160, $21E2, $2264, $28DA, $295C|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $00CA
dw $21E0, $2262, $285A, $28DC|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(7)
dw $00DC, $21D2
dw $00DC, $224C
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(2)
dw $00E3, $2252
dw !OWW_ArbitraryRLE
dw $0186
dw $22D0, $234E|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(4)
dw $0034, $22D2
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(7)
dw $0034, $22D4
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(7)
dw $0034, $22D6
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $0034, $2350
dw !OWW_ArbitraryRLE
dw $0034
dw $2458, $2656|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(6)
dw $00CC, $22E6
dw $00CC, $234C
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $00CE, $2362
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(4)
dw $00CE, $25D8
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $00C5, $2364
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(4)
dw $00C5, $25DC
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(4)
dw $06AB, $2366
dw !OWW_ArbitraryRLE
dw $06AB
dw $24E4, $2760|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0384
dw $236A, $236E, $23EC, $246A|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(4)
dw $0384, $24E8
dw !OWW_ArbitraryRLE
dw $0759
dw $23C8, $244A, $24CC, $254E, $26D0, $2752, $27D4|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0757
dw $23CA, $244C, $24CE, $2550, $26D2, $2754|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $01FF
dw $23CC, $244E, $24D0, $2652, $26D4, $2756|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $017C
dw $23CE, $2450, $24D2, $2654, $26D6|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0100
dw $245A, $24D8|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0104
dw $24DA, $2558|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0106
dw $2462, $24E0, $255C|!OWW_STOP
dw !OWW_ArbitraryRLE
dw $0107
dw $2464, $24E2|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $0179, $2552
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(8)
dw $06B4, $2562
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $06E5, $25D0
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(4)
dw $00C4, $25DA
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(7)
dw $0165, $25E4
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $06E4, $27D2
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $06E4, $2854
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(3)
dw $06E4, $2856
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $06E4, $2958
dw $06E4, $29DA
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $02FD, $27D8
dw !OWW_ArbitraryRLE
dw $06E7
dw $28D8, $295A, $29DC|!OWW_STOP
dw !OWW_END
;---------------------------------------------------------------------------------------------------
.map31
dw !OWW_InvertedOnly
@@ -855,150 +1055,6 @@ dw $0000 ; 7F
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(4)
dw $0034, $22D2
; TODO clean up and optimize
dw $00D2, $2060
dw $00D0, $20E0
dw $00D2, $20E2
dw $0153, $2150
dw $00C8, $2160
dw $00D0, $2162
dw $00D2, $2164
dw $0153, $21CE
dw $0153, $21D0
dw $00CA, $21E0
dw $00C8, $21E2
dw $00D0, $21E4
dw $00DC, $224C
dw $0178, $224E
dw $0153, $2250
dw $00E3, $2252
dw $00E3, $2254
dw $00CA, $2262
dw $00C8, $2264
dw $00C9, $22CC
dw $0153, $22CE
dw $0186, $22D0
dw $00D3, $22E2
dw $0302, $22E4
dw $00CC, $234C
dw $0186, $234E
dw $00CE, $2362
dw $00C5, $2364
dw $06AB, $2366
dw $00AA, $2368
dw $0384, $236A
dw $00AB, $236C
dw $0384, $236E
dw $0759, $23C8
dw $0757, $23CA
dw $01FF, $23CC
dw $017C, $23CE
dw $015C, $23E0
dw $00CE, $23E2
dw $00C5, $23E4
dw $06AB, $23E6
dw $0384, $23EC
dw $0759, $244A
dw $0757, $244C
dw $01FF, $244E
dw $017C, $2450
dw $0100, $245A
dw $01C2, $245C
dw $0218, $245E
dw $0162, $2460
dw $0106, $2462
dw $0107, $2464
dw $06AB, $2466
dw $0384, $246A
dw $0759, $24CC
dw $0757, $24CE
dw $01FF, $24D0
dw $017C, $24D2
dw $0034, $24D4
dw $0034, $24D6
dw $0100, $24D8
dw $0104, $24DA
dw $01D4, $24DC
dw $0219, $24DE
dw $0106, $24E0
dw $0107, $24E2
dw $06AB, $24E4
dw $06AB, $24E6
dw $0759, $254E
dw $0757, $2550
dw $0179, $2552
dw $0034, $2554
dw $0034, $2556
dw $0104, $2558
dw $0105, $255A
dw $0106, $255C
dw $0166, $255E
dw $0766, $2560
dw $06E5, $25D0
dw $0179, $25D2
dw $0034, $25D4
dw $0034, $25D6
dw $00CE, $25D8
dw $00C4, $25DA
dw $00C5, $25DC
dw $0171, $25DE
dw $06E5, $2650
dw $01FF, $2652
dw $017C, $2654
dw $0034, $2656
dw $00CE, $2658
dw $00C4, $265A
dw $00C5, $265C
dw $0759, $26D0
dw $0757, $26D2
dw $01FF, $26D4
dw $017C, $26D6
dw $00CE, $26D8
dw $00C4, $26DA
dw $00C5, $26DC
dw $0759, $2752
dw $0757, $2754
dw $01FF, $2756
dw $00CE, $2758
dw $00C4, $275A
dw $00C5, $275C
dw $06AB, $2760
dw $06E4, $27D2
dw $0759, $27D4
dw $06E1, $27D6
dw $02FD, $27D8
dw $00CF, $27DA
dw $06E4, $2852
dw $06E4, $2854
dw $06E4, $2856
dw $02FD, $2858
dw $00CA, $285A
dw $06E4, $28D4
dw $06E4, $28D6
dw $06E7, $28D8
dw $00C8, $28DA
dw $00CA, $28DC
dw $06E4, $2956
dw $06E4, $2958
dw $06E7, $295A
dw $00C8, $295C
dw $06E4, $29D8
dw $06E4, $29DA
dw $06E7, $29DC
dw $0769, $38F8
dw $06E1, $38FA
dw $06E1, $38FC
dw $06E1, $38FE
dw $06E3, $3978
dw $02E5, $397A
dw $02EC, $397C
dw $02E5, $397E
dw $02F0, $39F8
dw $02F3, $39FA
dw $02F3, $39FC
dw $02F3, $39FE
dw $0034, $3D94
dw !OWW_END
;---------------------------------------------------------------------------------------------------
@@ -1065,7 +1121,7 @@ dw $0000 ; 7F
dw !OWW_ArbitraryRLE
dw $0034
dw $270E, $278E, $2790|!OWW_STOP
dw $270E, $278E, $2790, $2918, $291A, $2998, $299A, $291C, $291E, $2920|!OWW_STOP
dw !OWW_StripeRLE|!OWW_Horizontal|OWW_RLESize(8)
dw $0034, $280E
@@ -1268,11 +1324,33 @@ dw $0000 ; 7F
;---------------------------------------------------------------------------------------------------
.map43
dw !OWW_SkipIfInverted, ReliableOWWSentinel
dw !OWW_SkipIfInverted, .map43_inverted
dw $0101, $2550 ; GT sign
dw !OWW_END
.map43_inverted
dw !OWW_InvertedOnly
dw $0212, $2BE0
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(5)
dw $0E96, $235E
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(5)
dw $0E97, $2360
dw !OWW_StripeRLEINC|!OWW_Horizontal|OWW_RLESize(2)
dw $0E94, $25DE ; tile, start
dw !OWW_StripeRLEINC|!OWW_Horizontal|OWW_RLESize(2)
dw $0180, $275E
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $0184, $27DE
dw !OWW_StripeRLE|!OWW_Vertical|OWW_RLESize(2)
dw $0185, $27E0
dw !OWW_END
;---------------------------------------------------------------------------------------------------
@@ -1300,6 +1378,12 @@ dw $0000 ; 7F
dw !OWW_END
;---------------------------------------------------------------------------------------------------
.map45
dw !OWW_InvertedOnly
dw $0239, $3D4A
dw !OWW_END
;---------------------------------------------------------------------------------------------------
.map47
dw !OWW_InvertedOnly
@@ -1474,6 +1558,13 @@ dw $0000 ; 7F
dw !OWW_END
;---------------------------------------------------------------------------------------------------
.map70
dw !OWW_InvertedOnly
dw $0239, $3D94
dw !OWW_END
;---------------------------------------------------------------------------------------------------
.map73
dw !OWW_InvertedOnly

View File

@@ -125,6 +125,35 @@ macro ValueShift()
BRA ?start : ?end:
endmacro
;--------------------------------------------------------------------------------
GetDungeonBitByID:
LDA.w #$8000
CPX.w #$0000 : BEQ .castle
DEX
-
LSR
DEX
BPL -
RTS
.castle
LSR
RTS
;--------------------------------------------------------------------------------
GetDungeonBitByOffset:
LDA.w #$0001
CPX.w #$000E : BEQ .castle
CPX.w #$000F : BEQ .castle
DEX
-
ASL
DEX
BPL -
RTS
.castle
LDA.w #$00C0
RTS
;--------------------------------------------------------------------------------
;carry clear if pass
;carry set if caught
;incsrc eventdata.asm
@@ -167,312 +196,405 @@ ProcessEventItems:
RTS
;--------------------------------------------------------------------------------
AddReceivedItemLong:
JSR ResolveReceipt
JSR.w ResolveReceipt
PHB : PHK
JML AddReceivedItem+2
AddReceivedItemExpandedGetItem:
PHX
PHX : PHB
LDA.w ItemReceiptID ; check inventory
;JSR ResolveReceipt
LDA.w ItemReceiptID
JSL.l FreeDungeonItemNotice
JSR ItemBehavior
SEP #$30
PLX
PLB : PLX
LDA.w ItemReceiptMethod : CMP.b #$01 ; thing we wrote over
RTL
ItemBehavior:
REP #$30
AND #$00FF : ASL : TAX
LDA.l ItemReceipts_behavior, X : STA.w ScratchBufferV
SEP #$30
JMP.w (ScratchBufferV)
SEP #$20
JMP.w (ItemReceipts_behavior,X)
.skip
RTS
.bow
LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking
LDA.l SilverArrowsUseRestriction : BNE ++
LDA.b #03 : STA.l BowEquipment ; set bow to silver
++
RTS
.bow_and_arrows
LDA.l BowTracking : ORA.l ScratchBufferV+6 : STA.l BowTracking
BIT.b #$40 : BEQ +
LDA.l SilverArrowsUseRestriction : BNE +
LDA.b #03 : STA.l BowEquipment ; set bow to silver
+
RTS
.silver_bow
LDA.l BowTracking : ORA.l ScratchBufferV+6 : STA.l BowTracking
LDA.l SilverArrowsUseRestriction : BNE .noequip
LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ .noequip
LDA.l ArrowsFiller : BNE + ; check arrows
LDA.b #$03 : BRA ++ ; bow without arrow
+
LDA.b #$04 ; bow with arrow
++
STA.l BowEquipment
.noequip
LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking ; mark silver bow on y-toggle
RTS
.bombs_50
LDA.b #50 : STA.l BombCapacity ; upgrade bombs
LDA.b #50 : STA.l BombsFiller ; fill bombs
RTS
.arrows_70
LDA.b #70 : STA.l ArrowCapacity ; upgrade arrows
LDA.b #70 : STA.l ArrowsFiller ; fill arrows
RTS
.magic_2
LDA.l MagicConsumption : CMP.b #$02 : !BGE +
INC : STA.l MagicConsumption ; upgrade magic
+
LDA.b #$80 : STA.l MagicFiller ; fill magic
RTS
.magic_4
LDA.b #$02 : STA.l MagicConsumption ; upgrade magic
LDA.b #$80 : STA.l MagicFiller ; fill magic
RTS
.master_sword_safe
LDA.l SwordEquipment : CMP.b #$02 : !BGE + ; skip if we have a better sword
LDA.b #$02 : STA.l SwordEquipment ; set master sword
+
RTS
.bombs_5
LDA.l BombCapacity : !ADD.b #$05 : STA.l BombCapacity ; upgrade bombs +5
LDA.l Upgrade5BombsRefill : STA.l BombsFiller ; fill bombs
RTS
.bombs_10
LDA.l BombCapacity : !ADD.b #$0A : STA.l BombCapacity ; upgrade bombs +10
LDA.l Upgrade10BombsRefill : STA.l BombsFiller ; fill bombs
RTS
.arrows_5
LDA.l ArrowCapacity : !ADD.b #$05 : STA.l ArrowCapacity ; upgrade arrows +5
LDA.l Upgrade5ArrowsRefill : STA.l ArrowsFiller ; fill arrows
RTS
.arrows_10
LDA.l ArrowCapacity : !ADD.b #$0A : STA.l ArrowCapacity ; upgrade arrows +10
LDA.l Upgrade10ArrowsRefill : STA.l ArrowsFiller ; fill arrows
RTS
.programmable_1
%ProgrammableItemLogic(1)
RTS
.programmable_2
%ProgrammableItemLogic(2)
RTS
.programmable_3
%ProgrammableItemLogic(3)
RTS
.silver_arrows
LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking
LDA.l SilverArrowsUseRestriction : BNE ++
LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ ++
LDA.l BowEquipment : BEQ ++ : CMP.b #$03 : !BGE +
!ADD.b #$02 : STA.l BowEquipment ; switch to silver bow
+
++
LDA.l ArrowMode : BEQ +
LDA.b #$01 : STA.l ArrowsFiller
+
RTS
.rupoor
REP #$20 : LDA.l CurrentRupees : !SUB RupoorDeduction : STA.l CurrentRupees : SEP #$20 ; Take 1 rupee
RTS
.null
RTS
.red_clock
REP #$20 ; set 16-bit accumulator
LDA.l ChallengeTimer : !ADD.l RedClockAmount : STA.l ChallengeTimer
LDA.l ChallengeTimer+2 : ADC.l RedClockAmount+2 : STA.l ChallengeTimer+2
SEP #$20 ; set 8-bit accumulator
RTS
.blue_clock
REP #$20 ; set 16-bit accumulator
LDA.l ChallengeTimer : !ADD.l BlueClockAmount : STA.l ChallengeTimer
LDA.l ChallengeTimer+2 : ADC.l BlueClockAmount+2 : STA.l ChallengeTimer+2
SEP #$20 ; set 8-bit accumulator
RTS
.green_clock
REP #$20 ; set 16-bit accumulator
LDA.l ChallengeTimer : !ADD.l GreenClockAmount : STA.l ChallengeTimer
LDA.l ChallengeTimer+2 : ADC.l GreenClockAmount+2 : STA.l ChallengeTimer+2
SEP #$20 ; set 8-bit accumulator
RTS
.triforce
JSL.l ActivateGoal
RTS
.goal_item
REP #$20 ; set 16-bit accumulator
LDA.l GoalItemRequirement : BEQ +
LDA.l GoalCounter : INC : STA.l GoalCounter
CMP.w GoalItemRequirement : !BLT +
LDA.l TurnInGoalItems : AND.w #$00FF : BNE +
JSL.l ActivateGoal
+
SEP #$20 ; set 8-bit accumulator
RTS
.request_F0
JSL.l ItemGetServiceRequest_F0
RTS
.request_F1
JSL.l ItemGetServiceRequest_F1
RTS
.request_F2
JSL.l ItemGetServiceRequest_F2
RTS
.request_async
; JSL.l ItemGetServiceRequest
RTS
.free_map
AND.b #$0F : CMP.b #$08 : !BGE +
%ValueShift()
ORA.l MapField : STA.l MapField ; Map 1
RTS
+
!SUB #$08
%ValueShift()
ORA.l MapField+1 : STA.l MapField+1 ; Map 2
RTS
.hc_map
LDA.b #$C0 : ORA.l MapField+1 : STA.l MapField+1
RTS
.free_compass
AND.b #$0F : CMP.b #$08 : !BGE ++
%ValueShift()
ORA.l CompassField : STA.l CompassField ; Compass 1
RTS
++
!SUB #$08
%ValueShift()
ORA.l CompassField+1 : STA.l CompassField+1 ; Compass 2
RTS
.hc_compass
LDA.b #$C0 : ORA.l CompassField+1 : STA.l CompassField+1
RTS
.free_bigkey
AND.b #$0F : CMP.b #$08 : !BGE ++
%ValueShift()
ORA.l BigKeyField : STA.l BigKeyField ; Big Key 1
RTS
++
!SUB #$08
%ValueShift()
ORA.l BigKeyField+1 : STA.l BigKeyField+1 ; Big Key 2
RTS
.hc_bigkey
LDA.b #$C0 : ORA.l BigKeyField+1 : STA.l BigKeyField+1
RTS
.free_smallkey
AND.b #$0F : TAX
LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X ; Increment Key Count
RTS
.hc_smallkey
LDA.l HyruleCastleKeys : INC : STA.l HyruleCastleKeys
LDA.l SewerKeys : INC : STA.l SewerKeys
RTS
.generic_smallkey
LDA.l GenericKeys : BEQ .normal
LDA.l CurrentSmallKeys : INC : STA.l CurrentSmallKeys
RTS
.normal
LDA.w DungeonID : CMP.b #$FF : BEQ .done
LSR : TAX
LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X
.done
RTS
RTS
.bow
LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking
BIT #$40 : BNE .silversbow
LDA.b #$01 : STA.l BowEquipment
RTS
.silversbow
LDA.l SilverArrowsUseRestriction : BNE +
LDA.b #03 : STA.l BowEquipment ; set bow to silver
+
LDA.b #$01 : STA.l BowEquipment
RTS
.dungeon_compass
REP #$20
LDA.w DungeonID : LSR : TAX
JSR.w GetDungeonBitByID
ORA.l CompassField : STA.l CompassField
SEP #$20
RTS
.dungeon_bigkey
REP #$20
LDA.w DungeonID : LSR : TAX
JSR.w GetDungeonBitByID
ORA.l BigKeyField : STA.l BigKeyField
SEP #$20
RTS
.dungeon_map
REP #$20
LDA.w DungeonID : LSR : TAX
JSR.w GetDungeonBitByID
ORA.l MapField : STA.l MapField
SEP #$20
RTS
.bow_and_arrows
BIT.b #$40 : BEQ +
LDA.l SilverArrowsUseRestriction : BNE +
LDA.b #03 : STA.l BowEquipment ; set bow to silver
+
RTS
.silver_bow
LDA.b #$04 : ORA.l BowTracking : STA.l BowTracking
LDA.l SilverArrowsUseRestriction : BNE .noequip
LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ .noequip
LDA.l ArrowsFiller : BNE + ; check arrows
LDA.b #$03 : BRA ++ ; bow without arrow
+
LDA.b #$04 ; bow with arrow
++
STA.l BowEquipment
.noequip
LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking ; mark silver bow on y-toggle
RTS
.bombs_50
LDA.b #50 : STA.l BombCapacity ; upgrade bombs
LDA.b #50 : STA.l BombsFiller ; fill bombs
RTS
.arrows_70
LDA.b #70 : STA.l ArrowCapacity ; upgrade arrows
LDA.b #70 : STA.l ArrowsFiller ; fill arrows
RTS
.magic_2
LDA.l MagicConsumption : CMP.b #$02 : !BGE +
INC : STA.l MagicConsumption ; upgrade magic
+
LDA.b #$80 : STA.l MagicFiller ; fill magic
RTS
.magic_4
LDA.b #$02 : STA.l MagicConsumption ; upgrade magic
LDA.b #$80 : STA.l MagicFiller ; fill magic
RTS
.master_sword_safe
LDA.l SwordEquipment : CMP.b #$02 : !BGE + ; skip if we have a better sword
LDA.b #$02 : STA.l SwordEquipment ; set master sword
+
RTS
.bombs_5
LDA.l BombCapacity : !ADD.b #$05 : STA.l BombCapacity ; upgrade bombs +5
LDA.l Upgrade5BombsRefill : STA.l BombsFiller ; fill bombs
RTS
.bombs_10
LDA.l BombCapacity : !ADD.b #$0A : STA.l BombCapacity ; upgrade bombs +10
LDA.l Upgrade10BombsRefill : STA.l BombsFiller ; fill bombs
RTS
.arrows_5
LDA.l ArrowCapacity : !ADD.b #$05 : STA.l ArrowCapacity ; upgrade arrows +5
LDA.l Upgrade5ArrowsRefill : STA.l ArrowsFiller ; fill arrows
RTS
.arrows_10
LDA.l ArrowCapacity : !ADD.b #$0A : STA.l ArrowCapacity ; upgrade arrows +10
LDA.l Upgrade10ArrowsRefill : STA.l ArrowsFiller ; fill arrows
RTS
.programmable_1
%ProgrammableItemLogic(1)
RTS
.programmable_2
%ProgrammableItemLogic(2)
RTS
.programmable_3
%ProgrammableItemLogic(3)
RTS
.silver_arrows
LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking
LDA.l SilverArrowsUseRestriction : BNE ++
LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ ++
LDA.l BowEquipment : BEQ ++ : CMP.b #$03 : !BGE +
!ADD.b #$02 : STA.l BowEquipment ; switch to silver bow
+
++
LDA.l ArrowMode : BEQ +
LDA.b #$01 : STA.l ArrowsFiller
+
RTS
.rupoor
REP #$20 : LDA.l CurrentRupees : !SUB RupoorDeduction : STA.l CurrentRupees : SEP #$20 ; Take 1 rupee
RTS
.null
RTS
.red_clock
REP #$20 ; set 16-bit accumulator
LDA.l ChallengeTimer : !ADD.l RedClockAmount : STA.l ChallengeTimer
LDA.l ChallengeTimer+2 : ADC.l RedClockAmount+2 : STA.l ChallengeTimer+2
SEP #$20 ; set 8-bit accumulator
RTS
.blue_clock
REP #$20 ; set 16-bit accumulator
LDA.l ChallengeTimer : !ADD.l BlueClockAmount : STA.l ChallengeTimer
LDA.l ChallengeTimer+2 : ADC.l BlueClockAmount+2 : STA.l ChallengeTimer+2
SEP #$20 ; set 8-bit accumulator
RTS
.green_clock
REP #$20 ; set 16-bit accumulator
LDA.l ChallengeTimer : !ADD.l GreenClockAmount : STA.l ChallengeTimer
LDA.l ChallengeTimer+2 : ADC.l GreenClockAmount+2 : STA.l ChallengeTimer+2
SEP #$20 ; set 8-bit accumulator
RTS
.triforce
JSL.l ActivateGoal
RTS
.goal_item
REP #$20 ; set 16-bit accumulator
LDA.l GoalItemRequirement : BEQ +
LDA.l GoalCounter : INC : STA.l GoalCounter
CMP.w GoalItemRequirement : !BLT +
LDA.l TurnInGoalItems : AND.w #$00FF : BNE +
JSL.l ActivateGoal
+
SEP #$20 ; set 8-bit accumulator
RTS
.request_F0
JSL.l ItemGetServiceRequest_F0
RTS
.request_F1
JSL.l ItemGetServiceRequest_F1
RTS
.request_F2
JSL.l ItemGetServiceRequest_F2
RTS
.request_async
; JSL.l ItemGetServiceRequest
RTS
.free_map
REP #$20
AND.w #$000F : LSR : TAX
JSR.w GetDungeonBitByOffset
ORA.l MapField : STA.l MapField
SEP #$20
RTS
.hc_map
LDA.b #$C0 : ORA.l MapField+1 : STA.l MapField+1
RTS
.free_compass
REP #$20
AND.w #$000F : LSR : TAX
JSR.w GetDungeonBitByOffset
ORA.l CompassField : STA.l CompassField
SEP #$20
RTS
.hc_compass
LDA.b #$C0 : ORA.l CompassField+1 : STA.l CompassField+1
RTS
.free_bigkey
REP #$20
AND.w #$000F : LSR : TAX
JSR.w GetDungeonBitByOffset
ORA.l BigKeyField : STA.l BigKeyField
SEP #$20
RTS
.hc_bigkey
LDA.b #$C0 : ORA.l BigKeyField+1 : STA.l BigKeyField+1
RTS
.free_smallkey
REP #$20
AND.w #$000F : TAX
LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X ; Increment Key Count
RTS
.hc_smallkey
LDA.l HyruleCastleKeys : INC : STA.l HyruleCastleKeys
LDA.l SewerKeys : INC : STA.l SewerKeys
RTS
.generic_smallkey
LDA.l GenericKeys : BEQ .normal
LDA.l CurrentSmallKeys : INC : STA.l CurrentSmallKeys
RTS
.normal
LDA.w DungeonID : CMP.b #$FF : BEQ .done
LSR : TAX
LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X
.done
RTS
;--------------------------------------------------------------------------------
;2B:Bottle Already Filled w/ Red Potion
;2C:Bottle Already Filled w/ Green Potion
;2D:Bottle Already Filled w/ Blue Potion
;3C:Bottle Already Filled w/ Bee
;3D:Bottle Already Filled w/ Fairy
;48:Bottle Already Filled w/ Gold Bee
ResolveReceipt:
PHA : PHX
PHK : PLB
JSL.l PreItemGet
LDA.w ItemReceiptID ; Item Value
.get_item
JSR AttemptItemSubstitution
LDX.b #ItemReceipts>>16 : STX.w ScratchBufferV+2
REP #$30
AND.w #$00FF : ASL : TAX
LDA.w ItemReceipts_resolution, X
STA.w ScratchBufferV
SEP #$30
JMP.w (ScratchBufferV)
JSR.w AttemptItemSubstitution
JSR.w HandleBowTracking ; Progressive bows get resolved to new loot id
JSR.w ResolveLootID
.have_item
JSR IncrementItemCounters
STA.w ItemReceiptID
JSR IncrementItemCounters
PLX : PLA
RTS
;PHB : PHK ; we're skipping the corresponding instructions to grab the data bank
;JML.l AddReceivedItem+2
.items
.skip
LDA.w ItemReceiptID
JMP.w .have_item
.bottles
JSR.w CountBottles : CMP.l BottleLimit : !BLT +
LDA.l BottleLimitReplacement
JMP.w .get_item
+
LDA.w ItemReceiptID
JMP.w .have_item
.magic
LDA.l MagicConsumption : BEQ +
LDA.b #$4F : JMP.w .have_item
+ : LDA.b #$4E
JMP.w .have_item
.swords
LDA.l HighestSword : CMP.l ProgressiveSwordLimit : BCC +
LDA.l ProgressiveSwordReplacement : JMP.w .get_item
+
ADC.b #$43 : JMP.w .have_item
.shields
LDA.l HighestShield : CMP.l ProgressiveShieldLimit : BCC +
LDA.l ProgressiveShieldReplacement : JMP.w .get_item
+
ADC.b #$04 : JMP.w .have_item
.armor
LDA.l HighestMail : CMP.l ProgressiveArmorLimit : BCC +
LDA.l ProgressiveArmorReplacement : JMP.w .get_item
+
ADC.b #$22 : JMP.w .have_item
.gloves
LDA.l GloveEquipment : BNE + ; No Lift
LDA.b #$1B : JMP.w .have_item
+ : LDA.b #$1C : JMP.w .have_item ; Everything Else
.progressive_bow
LDA.b #$80 : STA.l ScratchBufferV+6
BRA .both_bows
.progressive_bow_2
LDA.b #$20 : STA.l ScratchBufferV+6
.both_bows
LDA.l BowEquipment : INC : LSR : CMP.l ProgressiveBowLimit : !BLT +
LDA.l ProgressiveBowReplacement : JMP.w .get_item
+ : CMP.b #$00 : BNE + ; No Bow
LDA.b #$3A : JMP.w .have_item
+ : LDA.b #$3B : JMP.w .have_item ; Any Bow
.null_chest
; JSL ChestItemServiceRequest
JMP.w .have_item
.rng_single
JSL.l GetRNGItemSingle : STA.w ScratchBufferV+6
XBA : JSR.w MarkRNGItemSingle
LDA.b #$FF : STA.l RNGLockIn ; clear lock-in
LDA.w ScratchBufferV+6 : JMP.w .get_item
.rng_multi
JSL.l GetRNGItemMulti : STA.w ScratchBufferV+6
LDA.b #$FF : STA.l RNGLockIn ; clear lock-in
LDA.w ScratchBufferV+6 : JMP.w .get_item
ResolveLootID:
; In: A - Loot ID
; Out: A - Resolved Loot ID
; Caller is responsible for running AttemptItemSubstitution prior if applicable.
PHX : PHB
PHK : PLB
.get_item
TAY
REP #$30
AND.w #$00FF : ASL : TAX
SEP #$30
TYA
JMP.w (ItemReceipts_resolution,X)
.have_item
PLB : PLX
RTS
.skip
JMP.w .have_item
.bottles
JSR.w CountBottles : CMP.l BottleLimit : !BLT +
LDA.l BottleLimitReplacement
JMP.w .get_item
+
LDA.w ItemReceiptID
JMP.w .have_item
.magic
LDA.l MagicConsumption : TAX
LDA.w ResolveLootID_magic_ids,X
JMP.w .have_item
..ids
db $4E, $4F, $4F
.swords
LDA.l HighestSword : CMP.l ProgressiveSwordLimit : BCC +
LDA.l ProgressiveSwordReplacement
JMP.w .get_item
+
TAX
LDA.w ResolveLootID_swords_ids,X
JMP.w .have_item
..ids
db $49, $01, $02, $03, $03
.shields
LDA.l HighestShield : CMP.l ProgressiveShieldLimit : BCC +
LDA.l ProgressiveShieldReplacement
JMP.w .get_item
+
TAX
LDA.w ResolveLootID_shields_ids,X
JMP.w .have_item
..ids
db $04, $05, $06, $06
.armor
LDA.l HighestMail : CMP.l ProgressiveArmorLimit : BCC +
LDA.l ProgressiveArmorReplacement
JMP.w .get_item
+
LDA.w ResolveLootID_armor_ids,X
JMP.w .have_item
..ids
db $22, $23, $23
.gloves
LDA.l GloveEquipment : TAX
LDA.w ResolveLootID_gloves_ids,X
JMP.w .have_item
..ids
db $1B, $1C, $1C
.progressive_bow
LDA.l BowEquipment : INC : LSR : CMP.l ProgressiveBowLimit : BCC +
LDA.l ProgressiveBowReplacement
JMP.w .get_item
+
TAX
LDA.w ResolveLootID_bows_ids,X
JMP.w .get_item
.progressive_bow_2
LDA.l BowEquipment : INC : LSR : CMP.l ProgressiveBowLimit : BCC +
LDA.l ProgressiveBowReplacement
JMP.w .get_item
+
TAX
LDA.w ResolveLootID_bows_ids,X
JMP.w .get_item
.bows
..ids
db $3A, $3B, $3B
.null_chest
; JSL ChestItemServiceRequest
JMP.w .have_item
.rng_single
JSL.l GetRNGItemSingle : STA.w ScratchBufferV+6
XBA : JSR.w MarkRNGItemSingle
LDA.b #$FF : STA.l RNGLockIn ; clear lock-in
LDA.w ScratchBufferV+6 : JMP.w .get_item
.rng_multi
JSL.l GetRNGItemMulti : STA.w ScratchBufferV+6
LDA.b #$FF : STA.l RNGLockIn ; clear lock-in
LDA.w ScratchBufferV+6 : JMP.w .get_item
;--------------------------------------------------------------------------------
;DATA AddReceivedItemExpanded
@@ -526,7 +648,7 @@ macro ReceiptProps(id, y, x, gfx, width, pal, sram, value, pal_override, behavio
org ItemReceipts_value+<id> : db <value>
org ItemReceipts_pal_override+<id> : db <pal_override>
org ItemReceipts_behavior+<id>+<id> : dw ItemBehavior_<behavior>
org ItemReceipts_resolution+<id>+<id> : dw ResolveReceipt_<res>
org ItemReceipts_resolution+<id>+<id> : dw ResolveLootID_<res>
pullpc
@@ -569,7 +691,7 @@ endmacro
%ReceiptProps($22, -4, 0, $04, 2, $02, $F35B, $FF, $00, skip, skip) ; 22 - Blue mail
%ReceiptProps($23, -5, 0, $04, 2, $01, $F35B, $02, $00, skip, skip) ; 23 - Red mail
%ReceiptProps($24, -4, 4, $0F, 0, $02, $F36F, $FF, $00, skip, skip) ; 24 - Small key
%ReceiptProps($25, -4, 0, $16, 2, $02, $F364, $FF, $00, skip, skip) ; 25 - Compass
%ReceiptProps($25, -4, 0, $16, 2, $02, $F364, $FF, $00, dungeon_compass, skip) ; 25 - Compass
%ReceiptProps($26, -4, 0, $03, 2, $01, $F36C, $FF, $00, skip, skip) ; 26 - Heart container from 4/4
%ReceiptProps($27, -4, 0, $13, 2, $02, $F375, $FF, $00, skip, skip) ; 27 - Bomb
%ReceiptProps($28, -4, 0, $01, 2, $02, $F375, $FF, $00, skip, skip) ; 28 - 3 bombs
@@ -582,8 +704,8 @@ endmacro
%ReceiptProps($2F, -4, 0, $00, 2, $04, $F36E, $FF, $00, skip, bottles) ; 2F - Potion refill (green)
%ReceiptProps($30, -4, 0, $00, 2, $02, $F36E, $FF, $00, skip, bottles) ; 30 - Potion refill (blue)
%ReceiptProps($31, -4, 0, $30, 2, $02, $F375, $FF, $00, skip, skip) ; 31 - 10 bombs
%ReceiptProps($32, -4, 0, $22, 2, $04, $F366, $FF, $00, skip, skip) ; 32 - Big key
%ReceiptProps($33, -4, 0, $21, 2, $04, $F368, $FF, $00, skip, skip) ; 33 - Map
%ReceiptProps($32, -4, 0, $22, 2, $04, $F366, $FF, $00, dungeon_bigkey, skip) ; 32 - Big key
%ReceiptProps($33, -4, 0, $21, 2, $04, $F368, $FF, $00, dungeon_map, skip) ; 33 - Map
%ReceiptProps($34, -2, 4, $24, 0, $04, $F360, $FF, $00, skip, skip) ; 34 - 1 rupee
%ReceiptProps($35, -2, 4, $24, 0, $02, $F360, $FB, $00, skip, skip) ; 35 - 5 rupees
%ReceiptProps($36, -2, 4, $24, 0, $01, $F360, $EC, $00, skip, skip) ; 36 - 20 rupees
@@ -613,7 +735,7 @@ endmacro
%ReceiptProps($4E, -4, 0, $3B, 2, $04, $F373, $80, $00, magic_2, magic) ; 4E - 1/2 magic
%ReceiptProps($4F, -4, 0, $3C, 2, $04, $F373, $80, $00, magic_4, magic) ; 4F - 1/4 magic
%ReceiptProps($50, -5, 4, $18, 0, $05, $F359, $02, $00, master_sword_safe, skip) ; 50 - Safe master sword - TODO gfx value
%ReceiptProps($51, -4, 0, $39, 2, $04, $F375, $FF, $00, bombs_5, skip) ; 51 - Bomb capacity (+5)
%ReceiptProps($51, -4, 0, $42, 2, $04, $F375, $FF, $00, bombs_5, skip) ; 51 - Bomb capacity (+5)
%ReceiptProps($52, -4, 0, $3E, 2, $04, $F375, $FF, $00, bombs_10, skip) ; 52 - Bomb capacity (+10)
%ReceiptProps($53, -4, 0, $3F, 2, $04, $F376, $FF, $00, arrows_5, skip) ; 53 - Arrow capacity (+5)
%ReceiptProps($54, -4, 0, $40, 2, $04, $F376, $FF, $00, arrows_10, skip) ; 54 - Arrow capacity (+10)
@@ -845,6 +967,20 @@ Link_ReceiveItemAlternatesExpanded:
PLB
RTL
;--------------------------------------------------------------------------------
HandleBowTracking:
; In: A - Item Receipt ID
CMP.b #$64 : BEQ .prog_one
CMP.b #$65 : BEQ .prog_two
RTS
.prog_one
LDA.b #$80
BRA .done
.prog_two
LDA.b #$20
.done
ORA.l BowTracking : STA.l BowTracking
RTS
;--------------------------------------------------------------------------------
;Return BowEquipment but also draw silver arrows if you have the upgrade even if you don't have the bow
CheckHUDSilverArrows:
LDA.l ArrowMode : BEQ .normal

View File

@@ -273,7 +273,7 @@ ItemGFXPtr = $7E0AFA ; Pointer for item receipt graphics transfers
; $0000 - no transfer, do nothing
; bit 7 reset - offset into ROM table
; bit 7 set - explicit bank7 address
ItemGFXTgt = $7E0AFC ; target VRAM address
ItemGFXTarget = $7E0AFC ; target VRAM address
;
ArcVariable = $7E0B08 ; Arc variable. Word length.
OverlordXLow = $7E0B08 ; $08 bytes.

View File

@@ -3,6 +3,7 @@
; 286 - Northeast Dark Swamp Cave
;--------------------------------------------------------------------------------
!FREE_TILE_BUFFER = $1180
!FREE_TILE = $5A40
; A = Tile ID
macro UploadOAM(dest)
PHA : PHP
@@ -17,7 +18,7 @@ macro UploadOAM(dest)
LDA.b $01,s
JSL.l GetSpritePalette
JSL.l GetSpritePalette_resolved
STA.l SpriteOAM+5 : STA.l SpriteOAM+13
PLA
JSL.l IsNarrowSprite : BCS .narrow
@@ -174,9 +175,9 @@ SpritePrep_ShopKeeper:
JMP -
.stop
LDA.b #Shopkeeper_UploadVRAMTilesLong>>16 : STA.w NMIAux+2
LDA.b #Shopkeeper_UploadVRAMTilesLong>>8 : STA.w NMIAux+1
LDA.b #Shopkeeper_UploadVRAMTilesLong>>0 : STA.w NMIAux
;LDA.b #Shopkeeper_UploadVRAMTilesLong>>16 : STA.w NMIAux+2
;LDA.b #Shopkeeper_UploadVRAMTilesLong>>8 : STA.w NMIAux+1
;LDA.b #Shopkeeper_UploadVRAMTilesLong>>0 : STA.w NMIAux
.done
LDA.l ShopType : BIT.b #$20 : BEQ .notTakeAll ; Take-all
@@ -218,114 +219,21 @@ dw $0100, $0000
; X - Tile Buffer Offset
; Y - Item ID
LoadTile:
TXA : !ADD.w #!FREE_TILE_BUFFER : STA.l TileUploadOffsetOverride ; load offset from X
SEP #$30 ; set 8-bit accumulator & index registers
TYA ; load item ID from Y
JSL.l GetSpriteID ; convert loot id to sprite id
JSL.l GetAnimatedSpriteTile_variable
TXA : LSR #2 : !ADD.w #!FREE_TILE : STA.w ItemGFXTarget ; load offset from X
;SEP #$30
TYA : ASL : TAX
LDA.l StandingItemGraphicsOffsets,X : STA.w ItemGFXPtr
JSL.l TransferItemToVRAM
TDC
;JSL.l GetSpriteID ; convert loot id to sprite id
;JSL.l GetAnimatedSpriteTile_variable
REP #$10 ; set 16-bit index registers
SEP #$20
RTS
;--------------------------------------------------------------------------------
;ShopInventory, X
;[id][$lo][$hi][purchase_counter]
;--------------------------------------------------------------------------------
Shopkeeper_UploadVRAMTilesLong:
JSR.w Shopkeeper_UploadVRAMTiles
RTL
Shopkeeper_UploadVRAMTiles:
LDA.w DMAP0 : PHA ; preserve DMA parameters
LDA.w BBAD0 : PHA ; preserve DMA parameters
LDA.w A1T0L : PHA ; preserve DMA parameters
LDA.w A1T0H : PHA ; preserve DMA parameters
LDA.w A1B0 : PHA ; preserve DMA parameters
LDA.w DAS0L : PHA ; preserve DMA parameters
LDA.w DAS0H : PHA ; preserve DMA parameters
;--------------------------------------------------------------------------------
LDA.b #$01 : STA.w DMAP0 ; set DMA transfer direction A -> B, bus A auto increment, double-byte mode
LDA.b #$18 : STA.w BBAD0 ; set bus B destination to VRAM register
LDA.b #$80 : STA.w VMAIN ; set VRAM to increment by 2 on high register write
LDA.b #$80 : STA.w A1T0L ; set bus A source address to tile buffer
LDA.b #$A1 : STA.w A1T0H
LDA.b #$7E : STA.w A1B0
LDA.l ShopType : AND.b #$10 : BNE .special
JMP .normal
.special
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$40 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5A : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$40 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5B : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$60 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5A : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$60 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5B : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$80 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5A : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$80 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5B : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
JMP .end
.normal
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$60 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5C : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$60 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5D : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$80 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5C : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$80 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5D : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$A0 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5C : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
LDA.b #$40 : STA.w DAS0L : STZ.b DAS0H ; set transfer size to 0x40
LDA.b #$A0 : STA.w VMADDL ; set VRAM register destination address
LDA.b #$5D : STA.w VMADDH
LDA.b #$01 : STA.w MDMAEN ; begin DMA transfer
;--------------------------------------------------------------------------------
.end
PLA : STA.w DAS0H ; restore DMA parameters
PLA : STA.w DAS0L ; restore DMA parameters
PLA : STA.w A1B0 ; restore DMA parameters
PLA : STA.w A1T0H ; restore DMA parameters
PLA : STA.w A1T0L ; restore DMA parameters
PLA : STA.w BBAD0 ; restore DMA parameters
PLA : STA.w DMAP0 ; restore DMA parameters
RTS
;--------------------------------------------------------------------------------
Shopkepeer_CallOriginal:
PLA : PLA : PLA
LDA.b #ShopkeeperJumpTable>>16 : PHA
@@ -686,7 +594,7 @@ Shopkeeper_DrawNextItem:
STA.l SpriteOAM+4
LDA.l ShopInventory, X ; get item palette
JSL.l GetSpritePalette : STA.l SpriteOAM+5
JSL.l GetSpritePalette_resolved : STA.l SpriteOAM+5
LDA.b #$00 : STA.l SpriteOAM+6

View File

@@ -6,7 +6,8 @@
; out: A - Sprite GFX ID
;--------------------------------------------------------------------------------
GetSpriteID:
JSR AttemptItemSubstitution
JSR.w AttemptItemSubstitution
JSR.w ResolveLootID
CMP.b #$16 : BEQ .bottle ; Bottle
CMP.b #$2B : BEQ .bottle ; Red Potion w/bottle
CMP.b #$2C : BEQ .bottle ; Green Potion w/bottle
@@ -37,134 +38,8 @@ GetSpriteID:
PHX
TAX : LDA.l ItemReceipts_graphics, X ; look up item gfx
PLX
CMP.b #$F8 : !BGE .special_handling
RTL
;---------------------------------------------------------------------------------------------------
.special_handling
PHX
AND.b #$07
ASL
TAX
REP #$20
LDA.l .handlers,X
PLX
PHA
SEP #$20
RTS
.handlers
dw .handler_F8-1
dw .handler_F9-1
dw .handler_FA-1
dw .handler_FB-1
dw .handler_FC-1
dw .handler_FD-1
dw .handler_FE-1
dw .handler_FF-1
;---------------------------------------------------------------------------------------------------
.handler_F8
LDA.l BowEquipment
INC
LSR
CMP.l ProgressiveBowLimit
BCC ++
LDA.l ProgressiveBowReplacement
JMP GetSpriteID
++ CMP.b #$00
LDA.b #$29
ADC.b #$00
RTL
;---------------------------------------------------------------------------------------------------
.handler_F9
LDA.l MagicConsumption
CMP.b #$00
LDA.b #$3B
ADC.b #$00
RTL
;---------------------------------------------------------------------------------------------------
.handler_FA
JSL GetRNGItemSingle
JMP GetSpriteID
;---------------------------------------------------------------------------------------------------
.handler_FB
JSL GetRNGItemMulti
JMP GetSpriteID
;---------------------------------------------------------------------------------------------------
.handler_FC
RTL
;---------------------------------------------------------------------------------------------------
.handler_FD
LDA.l ArmorEquipment
CMP.l ProgressiveArmorLimit
BCC ++
LDA.l ProgressiveArmorReplacement
JMP GetSpriteID
++ LDA.b #$04
RTL
;---------------------------------------------------------------------------------------------------
.handler_FE
LDA.l HighestSword
CMP.l ProgressiveSwordLimit
BCC ++
LDA.l ProgressiveSwordReplacement
JMP GetSpriteID
; 00 => 43
; 01 => 44
; 02 => 45
; 03 => 46
++ ADC.b #$43
RTL
;---------------------------------------------------------------------------------------------------
.handler_FF
LDA.l HighestShield
CMP.l ProgressiveShieldLimit
BCC ++
LDA.l ProgressiveShieldReplacement
JMP GetSpriteID
++ CMP.b #$01 ; no shield
BEQ .fighter_shield ; if exactly 1
; if 0 => 2D (carry is clear)
; all others are 2E (carry set for +1)
LDA.b #$2D
ADC.b #$00
RTL
.fighter_shield
LDA.b #$20
RTL
;--------------------------------------------------------------------------------
;--------------------------------------------------------------------------------
; GetSpritePalette
; in: A - Loot ID
@@ -172,6 +47,8 @@ RTL
;--------------------------------------------------------------------------------
GetSpritePalette:
JSR AttemptItemSubstitution
JSR.w ResolveLootID
.resolved
CMP.b #$16 : BEQ .bottle ; Bottle
CMP.b #$2B : BEQ .bottle ; Red Potion w/bottle
CMP.b #$2C : BEQ .bottle ; Green Potion w/bottle
@@ -189,157 +66,10 @@ GetSpritePalette:
PHX
TAX : LDA.l GfxPalettes, X ; look up item gfx
PLX
CMP.b #$F8 : !BGE .special_handling
RTL
;---------------------------------------------------------------------------------------------------
.special_handling
PHX
AND.b #$07
ASL
TAX
REP #$20
LDA.l .handlers,X
PLX
PHA
SEP #$20
RTS
.handlers
dw .handler_F8-1
dw .handler_F9-1
dw .handler_FA-1
dw .handler_FB-1
dw .handler_FC-1
dw .handler_FD-1
dw .handler_FE-1
dw .handler_FF-1
;---------------------------------------------------------------------------------------------------
.handler_F8
LDA.l BowEquipment
INC
LSR
CMP.l ProgressiveBowLimit
BCC ++
LDA.l ProgressiveBowReplacement
JMP GetSpritePalette
++ CMP.b #$00
BNE ++
LDA.b #$08
RTL
++ LDA.b #$02
RTL
LDA.b #$29
ADC.b #$00
RTL
;---------------------------------------------------------------------------------------------------
.handler_F9
RTL
;---------------------------------------------------------------------------------------------------
.handler_FA
JSL GetRNGItemSingle
JMP GetSpritePalette
;---------------------------------------------------------------------------------------------------
.handler_FB
JSL GetRNGItemMulti
JMP GetSpritePalette
;---------------------------------------------------------------------------------------------------
.handler_FC
LDA.l GloveEquipment
BNE ++
LDA.b #$02
RTL
++ LDA.b #$08
RTL
;---------------------------------------------------------------------------------------------------
.handler_FD
LDA.l HighestSword
CMP.l ProgressiveSwordLimit
BCC ++
LDA.l ProgressiveSwordReplacement
JMP GetSpritePalette
; 00 => 04
; 01 => 04
; 02 => 02
; 03 => 08
++ CMP.b #$02
BEQ ++ ; 2 exits with 2
LDA.b #$04
BCC ++ ; 0 or 1 get 4
; everything else is 8
ASL
++ RTL
;---------------------------------------------------------------------------------------------------
.handler_FE
LDA.l HighestShield
CMP.l ProgressiveShieldLimit
BCC ++
LDA.l ProgressiveShieldReplacement
JMP GetSpritePalette
; 0 => 4
; 1 => 2
; 2 => 8
++ CMP.b #$01 ; no shield
BEQ .fighter_shield ; if exactly 1, ASL for 2
LDA.b #$04 ; load 4 for 0
BCC ++ ; exit if < 1, otherwise, ASL for 8
.fighter_shield
ASL
++ RTL
;---------------------------------------------------------------------------------------------------
.handler_FF
LDA.l ArmorEquipment
CMP.l ProgressiveArmorLimit
BCC ++
LDA.l ProgressiveArmorReplacement
JMP GetSpritePalette
++ CMP.b #$01 ; carry set means nonzero
LDA.b #$02
BCS ++ ; nonzero gets 2
ASL ; ASL for 4 if zero
++ RTL
;---------------------------------------------------------------------------------------------------
;DATA - Loot Identifier to Sprite Palette
{
GfxPalettes:
@@ -478,11 +208,12 @@ RTL
; in: A - Loot ID
;-------------------------------------------------------------------------------- 20/8477
PrepDynamicTile:
PHA : PHX : PHY
PHA : PHX : PHY : PHB
JSR.w ResolveLootID
JSR.w LoadDynamicTileOAMTable
JSL TransferItemReceiptToBuffer_using_ReceiptID
SEP #$30
PLY : PLX : PLA
PLB : PLY : PLX : PLA
RTL
;--------------------------------------------------------------------------------
@@ -503,7 +234,7 @@ LoadDynamicTileOAMTable:
LDA.b $01,s
JSL.l GetSpritePalette
JSL.l GetSpritePalette_resolved
STA.l SpriteOAM+5 : STA.l SpriteOAM+13
PLA
JSL.l IsNarrowSprite : BCS .narrow