-
Notifications
You must be signed in to change notification settings - Fork 53
/
potions.asm
90 lines (86 loc) · 2.57 KB
/
potions.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
;--------------------------------------------------------------------------------
; $7F5092 - Potion Animation Busy Flags (Health)
; $7F5093 - Potion Animation Busy Flags (Magic)
;--------------------------------------------------------------------------------
RefillHealth:
REP #$20 ; set 16-bit accumulator
LDA.b RoomIndex ; these are all decimal because i got them that way
CMP.w #279 : BNE + ; Spike Cave bottles work normally
SEP #$20 ; set 8-bit accumulator
LDA.b #$A0
BRA .done
+
SEP #$20 ; set 8-bit accumulator
LDA.l PotionHealthRefill : CMP.b #$A0 : !BGE .done
LDA.l BusyHealth : BNE ++
LDA.l PotionHealthRefill ; load refill amount
!ADD CurrentHealth ; add to current health
CMP.l MaximumHealth : !BLT +++ : LDA.l MaximumHealth : +++
STA.l BusyHealth
++
LDA.l CurrentHealth : CMP.l BusyHealth : !BLT ++
LDA.b #$00 : STA.l HeartsFiller
LDA.w $020A : BNE .notDone
LDA.b #$00 : STA.l BusyHealth
SEC
RTL
++
LDA.b #$08 : STA.l HeartsFiller ; refill some health
.notDone
CLC
RTL
.done
; Check goal health versus actual health.
; if(actual < goal) then branch.
LDA.l CurrentHealth : CMP.l MaximumHealth : BCC .refillAllHealth
LDA.l MaximumHealth : STA.l CurrentHealth
LDA.b #$00 : STA.l HeartsFiller
; ??? not sure what purpose this branch serves.
LDA.w $020A : BNE .beta
SEC
RTL
.refillAllHealth
; Fill up ze health.
LDA.b #$A0 : STA.l HeartsFiller
.beta
CLC
RTL
;--------------------------------------------------------------------------------
RefillMagic:
REP #$20 ; set 16-bit accumulator
LDA.b RoomIndex ; these are all decimal because i got them that way
CMP.w #279 : BNE + ; Spike Cave bottles work normally
SEP #$20 ; set 8-bit accumulator
LDA.b #$80
BRA .done
+
SEP #$20 ; set 8-bit accumulator
LDA.l PotionMagicRefill : CMP.b #$80 : !BGE .done
LDA.l BusyMagic : BNE ++
LDA.l PotionMagicRefill ; load refill amount
!ADD CurrentMagic ; add to current magic
CMP.b #$80 : !BLT +++ : LDA.b #$80 : +++
STA.l BusyMagic
++
LDA.l CurrentMagic : CMP.l BusyMagic : !BLT ++
LDA.b #$00 : STA.l BusyMagic
SEC
RTL
++
LDA.b #$01 : STA.l MagicFiller ; refill some magic
CLC
RTL
.done
SEP #$30
; Check if Link's magic meter is full
LDA.l CurrentMagic : CMP.b #$80
BCS .itsFull
; Tell the magic meter to fill up until it's full.
LDA.b #$80 : STA.l MagicFiller
SEP #$30
RTL
.itsFull
; Set the carry, signifying we're done filling it.
SEP #$31
RTL
;--------------------------------------------------------------------------------