-
Notifications
You must be signed in to change notification settings - Fork 806
/
map_name_sign.asm
259 lines (235 loc) · 3.87 KB
/
map_name_sign.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
DEF MAP_NAME_SIGN_START EQU $60
InitMapNameSign::
xor a
ldh [hBGMapMode], a
farcall .inefficient_farcall ; this is a waste of 6 ROM bytes and 6 stack bytes
ret
; should have just been a fallthrough
.inefficient_farcall
ld a, [wMapGroup]
ld b, a
ld a, [wMapNumber]
ld c, a
call GetWorldMapLocation
ld [wCurLandmark], a
call .CheckNationalParkGate
jr z, .gate
call GetMapEnvironment
cp GATE
jr nz, .not_gate
.gate
ld a, -1
ld [wCurLandmark], a
.not_gate
ld hl, wEnteredMapFromContinue
bit 1, [hl]
res 1, [hl]
jr nz, .dont_do_map_sign
call .CheckMovingWithinLandmark
jr z, .dont_do_map_sign
ld a, [wCurLandmark]
ld [wPrevLandmark], a
call .CheckSpecialMap
jr z, .dont_do_map_sign
; Display for 60 frames
ld a, 60
ld [wLandmarkSignTimer], a
call LoadMapNameSignGFX
call InitMapNameFrame
farcall HDMATransfer_OnlyTopFourRows
ret
.dont_do_map_sign
ld a, [wCurLandmark]
ld [wPrevLandmark], a
ld a, $90
ldh [rWY], a
ldh [hWY], a
xor a
ldh [hLCDCPointer], a
ret
.CheckMovingWithinLandmark:
ld a, [wCurLandmark]
ld c, a
ld a, [wPrevLandmark]
cp c
ret z
cp LANDMARK_SPECIAL
ret
.CheckSpecialMap:
; These landmarks do not get pop-up signs.
cp -1
ret z
cp LANDMARK_SPECIAL ; redundant check
ret z
cp LANDMARK_RADIO_TOWER
ret z
cp LANDMARK_LAV_RADIO_TOWER
ret z
cp LANDMARK_UNDERGROUND_PATH
ret z
cp LANDMARK_INDIGO_PLATEAU
ret z
cp LANDMARK_POWER_PLANT
ret z
ld a, 1
and a
ret
.CheckNationalParkGate:
ld a, [wMapGroup]
cp GROUP_ROUTE_35_NATIONAL_PARK_GATE
ret nz
ld a, [wMapNumber]
cp MAP_ROUTE_35_NATIONAL_PARK_GATE
ret z
cp MAP_ROUTE_36_NATIONAL_PARK_GATE
ret
PlaceMapNameSign::
ld hl, wLandmarkSignTimer
ld a, [hl]
and a
jr z, .disappear
dec [hl]
cp 60
ret z
cp 59
jr nz, .already_initialized
call InitMapNameFrame
call PlaceMapNameCenterAlign
farcall HDMATransfer_OnlyTopFourRows
.already_initialized
ld a, $80
ld a, $70
ldh [rWY], a
ldh [hWY], a
ret
.disappear
ld a, $90
ldh [rWY], a
ldh [hWY], a
xor a
ldh [hLCDCPointer], a
ret
LoadMapNameSignGFX:
ld de, MapEntryFrameGFX
ld hl, vTiles2 tile MAP_NAME_SIGN_START
lb bc, BANK(MapEntryFrameGFX), 14
call Get2bpp
ret
InitMapNameFrame:
hlcoord 0, 0
ld b, 2
ld c, 18
call InitMapSignAttrmap
call PlaceMapNameFrame
ret
PlaceMapNameCenterAlign:
ld a, [wCurLandmark]
ld e, a
farcall GetLandmarkName
call .GetNameLength
ld a, SCREEN_WIDTH
sub c
srl a
ld b, 0
ld c, a
hlcoord 0, 2
add hl, bc
ld de, wStringBuffer1
call PlaceString
ret
.GetNameLength:
ld c, 0
push hl
ld hl, wStringBuffer1
.loop
ld a, [hli]
cp "@"
jr z, .stop
cp "<WBR>"
jr z, .loop
inc c
jr .loop
.stop
pop hl
ret
InitMapSignAttrmap:
ld de, wAttrmap - wTilemap
add hl, de
inc b
inc b
inc c
inc c
ld a, PAL_BG_TEXT | PRIORITY
.loop
push bc
push hl
.inner_loop
ld [hli], a
dec c
jr nz, .inner_loop
pop hl
ld de, SCREEN_WIDTH
add hl, de
pop bc
dec b
jr nz, .loop
ret
PlaceMapNameFrame:
hlcoord 0, 0
; top left
ld a, MAP_NAME_SIGN_START + 1
ld [hli], a
; top row
ld a, MAP_NAME_SIGN_START + 2
call .FillTopBottom
; top right
ld a, MAP_NAME_SIGN_START + 4
ld [hli], a
; left, first line
ld a, MAP_NAME_SIGN_START + 5
ld [hli], a
; first line
call .FillMiddle
; right, first line
ld a, MAP_NAME_SIGN_START + 11
ld [hli], a
; left, second line
ld a, MAP_NAME_SIGN_START + 6
ld [hli], a
; second line
call .FillMiddle
; right, second line
ld a, MAP_NAME_SIGN_START + 12
ld [hli], a
; bottom left
ld a, MAP_NAME_SIGN_START + 7
ld [hli], a
; bottom
ld a, MAP_NAME_SIGN_START + 8
call .FillTopBottom
; bottom right
ld a, MAP_NAME_SIGN_START + 10
ld [hl], a
ret
.FillMiddle:
ld c, SCREEN_WIDTH - 2
ld a, MAP_NAME_SIGN_START + 13
.loop
ld [hli], a
dec c
jr nz, .loop
ret
.FillTopBottom:
ld c, (SCREEN_WIDTH - 2) / 4 + 1
jr .enterloop
.continueloop
ld [hli], a
ld [hli], a
.enterloop
inc a
ld [hli], a
ld [hli], a
dec a
dec c
jr nz, .continueloop
ret