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
|
MobileAPI::
; Mobile
cp $2
ld [wMobileAPIIndex], a
ld a, l
ld [wc986], a
ld a, h
ld [wc987], a
jr nz, .okay
ld [wc982], a
ld a, l
ld [wc981], a
ld hl, wc983
ld a, c
ld [hli], a
ld a, b
ld [hl], a
.okay
ld hl, wc822
set 6, [hl]
ldh a, [hROMBank]
push af
ld a, BANK(_MobileAPI)
ld [wc981], a
rst Bankswitch
jp _MobileAPI
ReturnMobileAPI::
; Return from _MobileAPI
ld [wc986], a
ld a, l
ld [wc987], a
ld a, h
ld [wMobileAPIIndex], a
pop bc
ld a, b
ld [wc981], a
rst Bankswitch
ld hl, wc822
res 6, [hl]
ld hl, wc987
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wc986]
ret
MobileReceive::
ldh a, [hROMBank]
push af
ld a, BANK(_MobileReceive)
ld [wc981], a
rst Bankswitch
call _MobileReceive
pop bc
ld a, b
ld [wc981], a
rst Bankswitch
ret
MobileTimer::
push af
push bc
push de
push hl
ldh a, [hMobile]
and a
jr z, .pop_ret
xor a
ldh [rTAC], a
; Turn off timer interrupt
ldh a, [rIF]
and 1 << VBLANK | 1 << LCD_STAT | 1 << SERIAL | 1 << JOYPAD
ldh [rIF], a
ld a, [wc86a]
or a
jr z, .pop_ret
ld a, [wc822]
bit 1, a
jr nz, .skip_timer
ldh a, [rSC]
and 1 << rSC_ON
jr nz, .skip_timer
ldh a, [hROMBank]
push af
ld a, BANK(_Timer)
ld [wc981], a
rst Bankswitch
call _Timer
pop bc
ld a, b
ld [wc981], a
rst Bankswitch
.skip_timer
ldh a, [rTMA]
ldh [rTIMA], a
ld a, 1 << rTAC_ON | rTAC_65536_HZ
ldh [rTAC], a
.pop_ret
pop hl
pop de
pop bc
pop af
reti
Function3ed7:: ; unreferenced
ld [$dc02], a
ldh a, [hROMBank]
push af
ld a, BANK(Function114243)
rst Bankswitch
call Function114243
pop bc
ld a, b
rst Bankswitch
ld a, [$dc02]
ret
Function3eea::
push hl
push bc
ld de, wAttrmap - wTilemap
add hl, de
inc b
inc b
inc c
inc c
call Function3f35
pop bc
pop hl
call MobileHome_PlaceBox
ret
Function3efd:: ; unreferenced
push hl
hlcoord 0, 12
ld b, 4
ld c, 18
call .fill_attr
pop hl
call PrintTextboxText
ret
.fill_attr
push hl
push bc
ld de, wAttrmap - wTilemap
add hl, de
inc b
inc b
inc c
inc c
call Function3f35
pop bc
pop hl
call TextboxBorder
ret
Function3f20::
hlcoord 0, 0, wAttrmap
ld b, 6
ld c, 20
call Function3f35
hlcoord 0, 0
ld b, 4
ld c, 18
call MobileHome_PlaceBox
ret
Function3f35::
ld a, 6
ld de, SCREEN_WIDTH
.row
push bc
push hl
.col
ld [hli], a
dec c
jr nz, .col
pop hl
add hl, de
pop bc
dec b
jr nz, .row
ret
MobileHome_PlaceBox:
push bc
call .FillTop
pop bc
.RowLoop:
push bc
call .FillMiddle
pop bc
dec b
jr nz, .RowLoop
call .FillBottom
ret
.FillTop:
ld a, $63
ld d, $62
ld e, $64
jr .FillRow
.FillBottom:
ld a, $68
ld d, $67
ld e, $69
jr .FillRow
.FillMiddle:
ld a, $7f
ld d, $65
ld e, $66
.FillRow:
push hl
ld [hl], d
inc hl
.FillLoop:
ld [hli], a
dec c
jr nz, .FillLoop
ld [hl], e
pop hl
ld de, SCREEN_WIDTH
add hl, de
ret
Function3f7c::
call MenuBoxCoord2Tile
call GetMenuBoxDims
dec b
dec c
call Function3eea
ret
Function3f88::
ld hl, wDecompressScratch
ld b, 0
.row
push bc
ld c, 1 tiles / 2
.col
ld a, [de]
inc de
cpl
ld [hl], 0
inc hl
ld [hli], a
dec c
jr nz, .col
pop bc
dec c
jr nz, .row
ret
Function3f9f::
ld hl, wDecompressScratch
.row
push bc
ld c, 1 tiles / 2
.col
ld a, [de]
inc de
inc de
cpl
ld [hl], $0
inc hl
ld [hli], a
dec c
jr nz, .col
pop bc
dec c
jr nz, .row
ret
|