-
Notifications
You must be signed in to change notification settings - Fork 0
/
reward.asm
272 lines (266 loc) · 5.37 KB
/
reward.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
; Gives reward without printing it.
; Pass reward ID in A and Operand in Y
; Sets carry flag if a sound is played.
GiveReward:
CLC
PHP
SEP #$20
CMP #!Nothing
BNE +
PLP
RTL
+ CMP #!Gems
BNE +
; GEMs
REP #$20
TYA
JSL GiveGems
LDA #$0010 ; UpdateHud
TSB RedrawHudBits
BRK #$8D ; Play Gem get sound
PLP
SEC
RTL
+ CMP #!Exp
BNE +
; EXP
STY ExpToGive
PLP
RTL
+ CMP #!LairRelease
BNE +
; Lair Release
JSL ReleaseLairNpc
PLP
RTL
+ CMP #!Soul
BNE +
; Soul
; Tight loop to compute 1 << Y
LDA #$01
BRA ++
- ASL
++ DEY
BPL -
TSB SoulFlags
BRK #$0E ; Play soul get sound TODO: might be a different sound actually.
PLP
SEC
RTL
+ CMP #!Victory
BNE +
; Victory
JSL WinGame
PLP
RTL
+ ; Catch-all for non-regular items (ID >$40) which don't need special processing.
CMP #!MagicBell+1
BCC +
PLP
RTL
+ ; Give regular item
JSL GiveItem
BRK #$5E ; Play Item Get sound
PLP
SEC
RTL
; Prints reward.
; Pass reward ID in A and Operand in Y
; Retains A/Y register state
PrintReward:
PHP
PHB
PHA
PHY
SEP #$20
CMP #!Nothing
BNE +
LDY #NothingReceived
LDA.B #bank(NothingReceived)
BRA .printAndEnd
+ CMP #!Gems
BNE +
; GEMs
STY TableLookupIndex
LDY #GemsReceived
LDA.B #bank(GemsReceived)
BRA .printAndEnd
+ CMP #!Exp
BNE +
; EXP
STY TableLookupIndex
LDY #ExpReceived
LDA.B #bank(ExpReceived)
BRA .printAndEnd
+ CMP #!Soul
BNE +
; Soul
STY TableLookupIndex
LDY #ReceivedSoul
LDA.B #bank(ReceivedSoul)
BRA .printAndEnd
+ ; Catch-all for remaining non-regular items (ID >$40) which don't need special processing.
CMP #!MagicBell+1
BCS .end
; Give regular item
STA TableLookupIndex
STZ TableLookupIndex+1
LDY #ItemReceived
LDA.B #bank(ItemReceived)
.printAndEnd:
; Change Bank
PHA
PLB
JSL PrintOsdStringFromBankX
.end:
PLY
PLA
PLB
PLP
RTL
; Prints reward using ResumePrintOsdStringFromBankX.
; Pass reward ID in A and Operand in Y
PrintRewardShort:
PHP
PHB
SEP #$20
CMP #!Nothing
BNE +
LDY #PrintNothingShort
LDA.B #bank(PrintNothingShort)
BRA .printAndEnd
+ CMP #!Gems
BNE +
; GEMs
STY TableLookupIndex
LDY #PrintGemsShort
LDA.B #bank(PrintGemsShort)
BRA .printAndEnd
+ CMP #!Exp
BNE +
; EXP
STY TableLookupIndex
LDY #PrintExpShort
LDA.B #bank(PrintExpShort)
BRA .printAndEnd
+ CMP #!LairRelease
BNE +
; Lair Release NPC
REP #$20
TYA ; Lair ID in Y (and A)
ASL #5
TAX ; Lair index in X
SEP #$20
LDA.L $01BA16,X ; Load NPC Name index from lair data field 09
STA TableLookupIndex ; Used by the print routine to load npc name
STZ TableLookupIndex+1 ; Second byte unused
LDY #PrintRevivableNpcNameShort
LDA.B #bank(PrintRevivableNpcNameShort)
BRA .printAndEnd
+ CMP #!RemoteItem
BNE +
; Remote Item
STY TableLookupIndex ; Indexes into the AP icons table.
LDY #RemoteItemShort
LDA.B #bank(RemoteItemShort)
BRA .printAndEnd
+ CMP #!Soul
BNE +
; Soul
STY TableLookupIndex
LDY #PrintSoulNameShort
LDA.B #bank(PrintSoulNameShort)
BRA .printAndEnd
+ CMP #!Victory
BNE +
LDY #PrintVictoryShort
LDA.B #bank(PrintVictoryShort)
BRA .printAndEnd
+ ; Catch-all for remaining non-regular items (ID >$40) which don't need special processing.
CMP #!MagicBell+1
BCS .end
; Give regular item
STA TableLookupIndex
STZ TableLookupIndex+1
LDY #PrintItemNameShort
LDA.B #bank(PrintItemNameShort)
.printAndEnd:
PHA
PLB
JSL ResumePrintOsdStringFromBankX
.end:
PLB
PLP
RTL
; Prints remote reward.
; Pass reward ID in A and Operand in Y
; Retains A/Y register state
PrintRewardFrom:
PHP
PHB
PHA
PHY
SEP #$20
CMP #!Nothing
BNE +
LDY #ReceivedNothingFrom
LDA.B #bank(ReceivedNothingFrom)
BRA .printAndEnd
+ CMP #!Gems
BNE +
; GEMs
STY TableLookupIndex
LDY #ReceivedGemsFrom
LDA.B #bank(ReceivedGemsFrom)
BRA .printAndEnd
+ CMP #!Exp
BNE +
; EXP
STY TableLookupIndex
LDY #ReceivedExpFrom
LDA.B #bank(ReceivedExpFrom)
BRA .printAndEnd
+ CMP #!LairRelease
BNE +
; Lair Release NPC
REP #$20
TYA ; Lair ID in Y (and A)
ASL #5
TAX ; Lair index in X
SEP #$20
LDA.L $01BA16,X ; Load NPC Name index from lair data field 09
STA TableLookupIndex ; Used by the print routine to load npc name
STZ TableLookupIndex+1 ; Second byte unused
LDY #ReceivedRevivableNpcFrom
LDA.B #bank(ReceivedRevivableNpcFrom)
BRA .printAndEnd
+ CMP #!Soul
BNE +
; Soul
STY TableLookupIndex
LDY #ReceivedSoulFrom
LDA.B #bank(ReceivedSoulFrom)
BRA .printAndEnd
+ CMP #!Victory
BNE +
LDY #ReceivedVictoryFrom
LDA.B #bank(ReceivedVictoryFrom)
BRA .printAndEnd
+ ; Catch-all for remaining non-regular items (ID >$40) which don't need special processing.
CMP #!MagicBell+1
BCS .end
; Give regular item
STA TableLookupIndex
STZ TableLookupIndex+1
LDY #ReceivedItemFrom
LDA.B #bank(ReceivedItemFrom)
.printAndEnd:
PHA
PLB
JSL PrintOsdStringFromBankX
.end:
PLY
PLA
PLB
PLP
RTL