-
Notifications
You must be signed in to change notification settings - Fork 53
/
itemdowngrade.asm
76 lines (71 loc) · 2.26 KB
/
itemdowngrade.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
;================================================================================
; Item Downgrade Fix
;--------------------------------------------------------------------------------
ItemDowngradeFix:
JSL.l AddInventory
BMI .dontWrite ; thing we wrote over part 1
CPY.b #$1B : BEQ .isPowerGloves ; Power Gloves
CPY.b #$05 : BEQ .isRedShield ; Red Shield
CPY.b #$04 : BEQ .isBlueShield ; Blue Shield
CPY.b #$0C : BEQ .isBlueBoomerang ; Blue Boomerang
CPY.b #$0B : BEQ .isBow ; Bow
CPY.b #$3A : BEQ .isBowAndArrows ; Bow
CPY.b #$49 : BEQ .isSword ; Fighter's Sword
CPY.b #$01 : BEQ .isSword ; Master Sword
CPY.b #$50 : BEQ .isSword ; Master Sword (Safe)
CPY.b #$02 : BEQ .isSword ; Tempered Sword
CPY.b #$3B : BEQ .isSilverArrowBow ; Silver Arrow Bow
CPY.b #$2A : BEQ .isRedBoomerang ; Red Boomerang
CPY.b #$0D : BEQ .isMagicPowder ; Magic Powder
CPY.b #$14 : BEQ .isFlute ; Flute
CPY.b #$13 : BEQ .isShovel ; Shovel
CPY.b #$29 : BEQ .isMushroom ; Mushroom
CPY.b #$00 : BEQ .isUncleSwordShield ; Fighter's Sword & Shield
.done
STA.b [Scrap00] ; thing we wrote over part 2
.dontWrite
RTL
.isPowerGloves
.isBlueShield
.isRedShield
.isBlueBoomerang
.isBow
.isBowAndArrows
CMP.b [$00] : !BGE .done ; finished if we're upgrading
LDA.b [$00] ; reload old value
RTL
.isSilverArrowBow
.isRedBoomerang
.isMagicPowder
.isFlute
.isShovel
.isMushroom
PHA
LDA.b [Scrap00] : BNE + ; don't upgrade if we already have the toggle for it
PLA
STA.b [Scrap00]
RTL
+
PLA
RTL
.isSword
PHA
LDA.l HighestSword : STA.b Scrap04
TYA ; load sword item
CMP.b #$49 : BNE + : LDA.b #$00 : + ; convert extra fighter's sword to normal one
CMP.b #$50 : BNE + : LDA.b #$01 : + ; convert extra master sword to normal one
INC : CMP.b Scrap04 : !BGE + ; skip if highest is lower (this is an upgrade)
LDA.b Scrap04 : DEC ; convert to item id
TAY : PLA : LDA.b Scrap04 ; put sword id into the thing to write
JMP .done
+
PLA
JMP .done
.isUncleSwordShield
PHA
LDA.l HighestSword : STA.b [Scrap00] ; already set to 1 if we had no sword, always keep highest
INC.b Scrap00
LDA.l HighestShield : STA.b [Scrap00]
PLA
RTL
;================================================================================