-
Notifications
You must be signed in to change notification settings - Fork 0
/
OverworldMap.asm
468 lines (327 loc) · 8.96 KB
/
OverworldMap.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
; ==============================================================================
; LW OVERWORLD MAP
; ==============================================================================
org $008E54 ;STZ $2115
JSL DMAOwMap
RTS
org $00E399
JSL DMAOwMapGfx
RTL
; ==============================================================================
; DW OVERWORLD MAP
; ==============================================================================
org $008FF3
RTS ; do not do anything during the DW update we'll handle it in the LW routine
org $368000
LWWorldMap_Tiles:
incbin LWMapFinal.bin
LWWorldMap_Gfx:
incbin LWMapGfxFinal.bin
org $378000
DWWorldMap_Tiles:
incbin DWMapFinal.bin
DWWorldMap_Gfx:
incbin DWMapGfxFinal.bin
DMAOwMap:
{
LDA $8A : AND #$40 : BEQ .LWMAP
JMP .DWMAP
.LWMAP
STZ.w $2115
LDA.b #LWWorldMap_Tiles>>16
STA.w $4304
REP #$20
LDA.w #$1800
STA.w $4300
STZ.b $04
STZ.b $02
LDY.b #$01
LDX.b #$00
.next_quadrant
LDA.w #$0020
STA.b $06
LDA.l .vram_offset,X
STA.b $00
.next_row
LDA.b $00
STA.w $2116
CLC
ADC.w #$0080
STA.b $00
LDA.b $02
CLC
ADC.w #LWWorldMap_Tiles
STA.w $4302
LDA.w #$0020
STA.w $4305
STY.w $420B
CLC
ADC.b $02
STA.b $02
DEC.b $06
BNE .next_row
INC.b $04
INC.b $04
LDX.b $04
CPX.b #$08
BNE .next_quadrant
SEP #$20
RTL
.vram_offset
dw $0000, $0020, $1000, $1020
.DWMAP
STZ.w $2115
LDA.b #DWWorldMap_Tiles>>16
STA.w $4304
REP #$20
LDA.w #$1800
STA.w $4300
STZ.b $04
STZ.b $02
LDY.b #$01
LDX.b #$00
.next_quadrant2
LDA.w #$0020
STA.b $06
LDA.l .vram_offset,X
STA.b $00
.next_row2
LDA.b $00
STA.w $2116
CLC
ADC.w #$0080
STA.b $00
LDA.b $02
CLC
ADC.w #DWWorldMap_Tiles
STA.w $4302
LDA.w #$0020
STA.w $4305
STY.w $420B
CLC
ADC.b $02
STA.b $02
DEC.b $06
BNE .next_row2
INC.b $04
INC.b $04
LDX.b $04
CPX.b #$08
BNE .next_quadrant2
SEP #$20
RTL
}
DMAOwMapGfx:
{
LDA $8A : AND #$40 : BNE .DWMAP
LDA.b #LWWorldMap_Gfx>>16 : STA $02
LDA.b #$80 : STA $2115
STZ $2116 : STZ $2117
REP #$10
LDY.w #LWWorldMap_Gfx : STY $00
LDY.w #$0000
.writeChr
LDA [$00], Y : STA $2119 : INY
LDA [$00], Y : STA $2119 : INY
LDA [$00], Y : STA $2119 : INY
LDA [$00], Y : STA $2119 : INY
CPY.w #$4000 : BNE .writeChr
SEP #$10
RTL
.DWMAP
LDA.b #DWWorldMap_Gfx>>16 : STA $02
LDA.b #$80 : STA $2115
STZ $2116 : STZ $2117
REP #$10
LDY.w #DWWorldMap_Gfx : STY $00
LDY.w #$0000
.writeChr2
LDA [$00], Y : STA $2119 : INY
LDA [$00], Y : STA $2119 : INY
LDA [$00], Y : STA $2119 : INY
LDA [$00], Y : STA $2119 : INY
CPY.w #$4000 : BNE .writeChr2
SEP #$10
RTL
}
SpritePalette:
{
REP #$20
; Pendant 1 green -> orange.
LDA.w #hexto555($A9A9A9) : STA.l $7EC696
LDA.w #hexto555($E8E8E8) : STA.l $7EC698
LDA.w #hexto555($FFB345) : STA.l $7EC69C
LDA.w #hexto555($D58200) : STA.l $7EC69E
; Pendant 2 blue -> purple.
LDA.w #hexto555($A9A9A9) : STA.l $7EC656
LDA.w #hexto555($E8E8E8) : STA.l $7EC658
LDA.w #hexto555($AD45FF) : STA.l $7EC65C
LDA.w #hexto555($7C00D5) : STA.l $7EC65E
; Pendant 3 red -> green.
LDA.w #hexto555($A9A9A9) : STA.l $7EC636
LDA.w #hexto555($E8E8E8) : STA.l $7EC638
LDA.w #hexto555($15FF36) : STA.l $7EC63C
LDA.w #hexto555($00B51E) : STA.l $7EC63E
; Pendant 4 crystal -> yellow.
LDA.w #hexto555($F8F8F8) : STA.l $7EC6D2
LDA.w #hexto555($A9A9A9) : STA.l $7EC6D6
LDA.w #hexto555($E8E8E8) : STA.l $7EC6D8
LDA.w #hexto555($282828) : STA.l $7EC6DA
LDA.w #hexto555($FFED23) : STA.l $7EC6DC
LDA.w #hexto555($BFB400) : STA.l $7EC6DE
SEP #$20
;JSL $0ED6C0
RTL
}
org $0ABA67
JSL SpritePalette
org $0ADB27
LWPalettes:
dw $0000, $0CA8, $150A, $10C9, $0CA7, $0886, $110B, $0043, $1D90, $29D2, $112D, $21B1, $1D6F, $25F4, $150B, $194E
dw $29F4, $1D2C, $3A78, $1D4C, $2DD1, $3E99, $0016, $216E, $3613, $14E9, $10C8, $2DF3, $192C, $2190, $531C
org $0ADC27
DWPalettes:
dw $0000, $0CA8, $10C9, $0CA7, $0043, $150A, $0886, $110B, $21B1, $112D, $29F4, $1D2C, $3A78, $46DB, $3A55, $29B0
dw $214C, $150B, $531C, $3613, $216E, $1D90, $29D2, $194E, $1D6F, $25F4, $1D4C, $0016, $14EA
org $0AC589
WorldMapIcon_AdjustCoordinate:
org $0AC51C
WorldMap_HandleSpriteBlink:
org $0ABF90
MapIconDraw:
{
; .dont_draw_link
LDA.l $7EC108
PHA
LDA.l $7EC109
PHA
LDA.l $7EC10A
PHA
LDA.l $7EC10B
PHA
;Removed mirror portal draw code
;Removed pyramid open code?
;---------------------------------------------------------------------------------------------------
.draw_prizes
LDA.b $8A : AND.b #$40 : BEQ .lwprizes
; X position
LDA.b #$00 : STA.l $7EC10B
LDA.b #$89 : STA.l $7EC10A ; Upper nybble control Zoomed low X pos
; Y position
LDA.b #$00 : STA.l $7EC109
LDA.b #$E4 : STA.l $7EC108 ; Upper nybble control Zoomed low Y pos
; Tile GFX
LDA.b #$66 : STA.b $0D
LDA.b #$34 : STA.b $0C
; Tile Size
LDA.b #$02 : STA.b $0B ; 02 = 16x16, 00 = 8x8
LDA.b #$0E : STA.l $7EC025 ; OAM Slot used
JSR HandleMapDrawIcon
JMP restore_coords_and_exit
.lwprizes
; Draw Amulet 1
LDA.l $7EF374 : AND #$04 : BNE .skip_draw_0
; X position
LDA.b #$0E : STA.l $7EC10B
LDA.b #$3E : STA.l $7EC10A
; Y position
LDA.b #$04 : STA.l $7EC109
LDA.b #$68 : STA.l $7EC108
; Tile GFX
LDA.b #$60 : STA.b $0D
LDA.b #$38 : STA.b $0C
; Tile Size
LDA.b #$02 : STA.b $0B ; 02 = 16x16, 00 = 8x8
LDA.b #$0E : STA.l $7EC025 ; OAM Slot used
JSR HandleMapDrawIcon
.skip_draw_0
; Draw Amulet 2
LDA.l $7EF374 : AND #$02 : BNE .skip_draw_1
; X position
LDA.b #$0D : STA.l $7EC10B
LDA.b #$05 : STA.l $7EC10A
; Y position
LDA.b #$0D : STA.l $7EC109
LDA.b #$09 : STA.l $7EC108
LDA.b #$60 : STA.b $0D
LDA.b #$34 : STA.b $0C ; Tile GFX
LDA.b #$02 : STA.b $0B ; 02 = 16x16, 00 = 8x8
LDA.b #$0D : STA.l $7EC025
JSR HandleMapDrawIcon
.skip_draw_1
; Draw Amulet 3
LDA.l $7EF374 : AND #$01 : BNE .skip_draw_2
; X position
LDA.b #$09 : STA.l $7EC10B
LDA.b #$34 : STA.l $7EC10A
; Y position
LDA.b #$00 : STA.l $7EC109
LDA.b #$0E : STA.l $7EC108
LDA.b #$60 : STA.b $0D
LDA.b #$32 : STA.b $0C ; Tile GFX
LDA.b #$02 : STA.b $0B ; 02 = 16x16, 00 = 8x8
LDA.b #$0C : STA.l $7EC025
JSR HandleMapDrawIcon
.skip_draw_2
; Draw Amulet 4
LDA.l $7EF37A : AND #$01 : BNE .skip_draw_3
; X position
LDA.b #$00 : STA.l $7EC10B
LDA.b #$87 : STA.l $7EC10A
; Y position
LDA.b #$06 : STA.l $7EC109
LDA.b #$01 : STA.l $7EC108
LDA.b #$60 : STA.b $0D
LDA.b #$3C : STA.b $0C ; Tile GFX
LDA.b #$02 : STA.b $0B ; 02 = 16x16, 00 = 8x8
LDA.b #$0B : STA.l $7EC025
JSR HandleMapDrawIcon
.skip_draw_3
; Draw Flute X
LDA.l $7EF34C : CMP #$01 : BNE .skip_draw_flute
; X position
LDA.b #$09 : STA.l $7EC10B
LDA.b #$00 : STA.l $7EC10A
; Y position
LDA.b #$02 : STA.l $7EC109
LDA.b #$74 : STA.l $7EC108
LDA.b #$68 : STA.b $0D
LDA.b #$3C : STA.b $0C ; Tile GFX
LDA.b #$00 : STA.b $0B ; 02 = 16x16, 00 = 8x8
LDA.b #$0A : STA.l $7EC025
JSR HandleMapDrawIcon_noflash
.skip_draw_flute
JMP restore_coords_and_exit
}
HandleMapDrawIcon:
{
LDA.b $1A
AND.b #$10
BNE .skip_draw ; Timer to make it flash
.noflash ; ALTERNATE ENTRY POINT
JSR WorldMapIcon_AdjustCoordinate
LDA.l $7EC025 : TAX
JSR WorldMap_CalculateOAMCoordinates
BCC .skip_draw
LDA.l $7EC025 : TAX
LDA.b #$02
JSR WorldMap_HandleSpriteBlink
.skip_draw
RTS
}
warnpc $0AC387
org $0AC38A
{
restore_coords_and_exit:
PLA
STA.l $7EC10B
PLA
STA.l $7EC10A
PLA
STA.l $7EC109
PLA
STA.l $7EC108
RTS
}
WorldMap_CalculateOAMCoordinates:
; ==============================================================================