summaryrefslogtreecommitdiff
path: root/home/text.asm
blob: 73bda459cb412f8f78c081ab9a40b8c24502220f (plain)
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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
ClearBox:: ; fb6
; Fill a c*b box at hl with blank tiles.

	ld a, " "
Functionfb8::
	push bc
	push hl
.x
	ld [hli], a
	dec c
	jr nz, .x
	pop hl
	ld bc, 20 ; screen width
	add hl, bc
	pop bc
	dec b
	jr nz, Functionfb8
	ret
; fc8


ClearTileMap:: ; fc8
; Fill TileMap with blank tiles.

	ld hl, TileMap
	ld a, " "
	ld bc, 360 ; screen dimensions 20*18
	call ByteFill
	
; We aren't done if the LCD is on.
	ld a, [rLCDC]
	bit 7, a
	ret z
	jp WaitBGMap
; fdb


Functionfdb:: ; fdb
	ld a, $7
	ld hl, AttrMap
	ld bc, $0168
	call ByteFill
	jr ClearTileMap
; fe8



TextBox:: ; fe8
; Draw a text box width c height b at hl
; Dimensions do not include the border.
	push bc
	push hl
	call TextBoxBorder
	pop hl
	pop bc
	jr TextBoxPalette
; ff1


TextBoxBorder:: ; ff1

; Top
	push hl
	ld a, "┌"
	ld [hli], a
	inc a ; "─"
	call NPlaceChar
	inc a ; "┐"
	ld [hl], a

; Middle
	pop hl
	ld de, 20 ; screen width
	add hl, de
.PlaceRow
	push hl
	ld a, "│"
	ld [hli], a
	ld a, " "
	call NPlaceChar
	ld [hl], "│"
	pop hl
	ld de, 20 ; screen width
	add hl, de
	dec b
	jr nz, .PlaceRow

; Bottom
	ld a, "└"
	ld [hli], a
	ld a, "─"
	call NPlaceChar
	ld [hl], "┘"

	ret
; 101e


NPlaceChar:: ; 101e
; Place char a c times
	ld d,c
.loop
	ld [hli],a
	dec d
	jr nz, .loop
	ret
; 1024


TextBoxPalette:: ; 1024
; Fill text box width c height b at hl with pal 7
	ld de, AttrMap - TileMap
	add hl, de
	inc b
	inc b
	inc c
	inc c
	ld a, 7 ; pal
.gotoy
	push bc
	push hl
.gotox
	ld [hli], a
	dec c
	jr nz, .gotox
	pop hl
	ld de, 20 ; screen width
	add hl, de
	pop bc
	dec b
	jr nz, .gotoy
	ret
; 103e


SpeechTextBox:: ; 103e
; Standard textbox.
	hlcoord 0, 12
	ld b, 4 ; height
	ld c, 18 ; screen width - 2 (border)
	jp TextBox
; 1048

UnknownText_0x1048:: ; 1048
	db $0, "ゲームフりーク!", $57
; 1052

Function1052:: ; 1052
	ld hl, .text_1056
	ret
.text_1056
	db "@"
; 1057


PrintText:: ; 1057
	call Function106c
Function105a:: ; 105a
	push hl
	hlcoord 1, 14
	ld bc, 18 + 3<<8
	call ClearBox
	pop hl

PrintTextBoxText:: ; 1065
	bccoord 1, 14
	call Function13e5
	ret
; 106c


Function106c:: ; 106c
	push hl
	call SpeechTextBox
	call Function1ad2
	call Function321c
	pop hl
	ret
; 1078



PlaceString:: ; 1078
	push hl

PlaceNextChar:: ; 1079
	ld a, [de]
	cp "@"
	jr nz, CheckDict
	ld b, h
	ld c, l
	pop hl
	ret
	pop de

NextChar:: ; 1083
	inc de
	jp PlaceNextChar

CheckDict:: ; 1087
	cp $15
	jp z, Function117b
	cp $4f
	jp z, Char4F
	cp $4e
	jp z, Function12a7
	cp $16
	jp z, Function12b9
	and a
	jp z, Function1383
	cp $4c
	jp z, Function1337
	cp $4b
	jp z, Char4B
	cp $51 ; Player name
	jp z, Function12f2
	cp $49
	jp z, Function1186
	cp $52 ; Mother name
	jp z, Function118d
	cp $53
	jp z, Function1194
	cp $35
	jp z, Function11e8
	cp $36
	jp z, Function11ef
	cp $37
	jp z, Function11f6
	cp $38
	jp z, Function119b
	cp $39
	jp z, Function11a2
	cp $54
	jp z, Function11c5
	cp $5b
	jp z, Function11b7
	cp $5e
	jp z, Function11be
	cp $5c
	jp z, Function11b0
	cp $5d
	jp z, Function11a9
	cp $23
	jp z, Function11cc
	cp $22
	jp z, Function12b0
	cp $55
	jp z, Char55
	cp $56
	jp z, Function11d3
	cp $57
	jp z, Function137c
	cp $58
	jp z, Function135a
	cp $4a
	jp z, Function11da
	cp $24
	jp z, Function11e1
	cp $25
	jp z, NextChar
	cp $1f
	jr nz, .asm_1122
	ld a, $7f
.asm_1122
	cp $5f
	jp z, Char5F
	cp $59
	jp z, Function11fd
	cp $5a
	jp z, Char5D
	cp $3f
	jp z, Function121b
	cp $14
	jp z, Function1252
	cp $e4
	jr z, .asm_1174 ; 0x113d $35
	cp $e5
	jr z, .asm_1174 ; 0x1141 $31
	jr .asm_114c ; 0x1143 $7
	ld b, a
	call Function13c6
	jp NextChar
.asm_114c
	cp $60
	jr nc, .asm_1174 ; 0x114e $24
	cp $40
	jr nc, .asm_1165 ; 0x1152 $11
	cp $20
	jr nc, .asm_115c ; 0x1156 $4
	add $80
	jr .asm_115e ; 0x115a $2
.asm_115c
	add $90
.asm_115e
	ld b, $e5
	call Function13c6
	jr .asm_1174 ; 0x1163 $f
.asm_1165
	cp $44
	jr nc, .asm_116d ; 0x1167 $4
	add $59
	jr .asm_116f ; 0x116b $2
.asm_116d
	add $86
.asm_116f
	ld b, $e4
	call Function13c6
.asm_1174
	ld [hli], a
	call PrintLetterDelay
	jp NextChar
; 0x117b


Function117b:: ; 117b
	ld c, l
	ld b, h
	callba Function17f036
	jp PlaceNextChar
; 1186

Function1186:: ; 1186
	push de
	ld de, MomsName
	jp Function126a
; 118d

Function118d:: ; 118d
	push de
	ld de, PlayerName
	jp Function126a
; 1194

Function1194:: ; 1194
	push de
	ld de, RivalName
	jp Function126a
; 119b

Function119b:: ; 119b
	push de
	ld de, RedsName
	jp Function126a
; 11a2

Function11a2:: ; 11a2
	push de
	ld de, GreensName
	jp Function126a
; 11a9

Function11a9:: ; 11a9
	push de
	ld de, Char5DText
	jp Function126a
; 11b0

Function11b0:: ; 11b0
	push de
	ld de, Char5CText
	jp Function126a
; 11b7

Function11b7:: ; 11b7
	push de
	ld de, Char5BText
	jp Function126a
; 11be

Function11be:: ; 11be
	push de
	ld de, Char5EText
	jp Function126a
; 11c5

Function11c5:: ; 11c5
	push de
	ld de, Char54Text
	jp Function126a
; 11cc

Function11cc:: ; 11cc
	push de
	ld de, Char23Text
	jp Function126a
; 11d3

Function11d3:: ; 11d3
	push de
	ld de, Char56Text
	jp Function126a
; 11da

Function11da:: ; 11da
	push de
	ld de, Char4AText
	jp Function126a
; 11e1

Function11e1:: ; 11e1
	push de
	ld de, Char24Text
	jp Function126a
; 11e8

Function11e8:: ; 11e8
	push de
	ld de, Char37Text
	jp Function126a
; 11ef

Function11ef:: ; 11ef
	push de
	ld de, Char37Text
	jp Function126a
; 11f6

Function11f6:: ; 11f6
	push de
	ld de, Char37Text
	jp Function126a
; 11fd


Function11fd:: ; 11fd
	ld a, [hBattleTurn]
	xor $1
	jr Function1205
; 1203

Char5D:: ; 1203
	ld a, [hBattleTurn]
; 1205

Function1205:: ; 1205
	push de
	and a
	jr nz, .asm_120e ; 0x1207 $5
	ld de, BattleMonNick
	jr Function126a ; 0x120c $5c
.asm_120e
	ld de, Char5AText ; Enemy
	call PlaceString
	ld h, b
	ld l, c
	ld de, EnemyMonNick
	jr Function126a ; 0x1219 $4f

Function121b:: ; 121b
	push de
	ld a, [InLinkBattle]
	and a
	jr nz, .linkbattle
	ld a, [TrainerClass]
	cp RIVAL1
	jr z, .asm_1248 ; 0x1227 $1f
	cp RIVAL2
	jr z, .asm_1248 ; 0x122b $1b
	ld de, $c656
	call PlaceString
	ld h, b
	ld l, c
	ld de, String12a2
	call PlaceString
	push bc
	callab Function39939
	pop hl
	ld de, StringBuffer1
	jr Function126a ; 0x1246 $22
.asm_1248
	ld de, RivalName
	jr Function126a ; 0x124b $1d
.linkbattle
	ld de, $c656
	jr Function126a ; 0x1250 $18

Function1252:: ; 1252
	push de
	ld de, PlayerName
	call PlaceString
	ld h, b
	ld l, c
	ld a, [PlayerGender]
	bit 0, a
	ld de, String12a5
	jr z, Function126a ; 0x1263 $5
	ld de, String12a6
	jr Function126a ; 0x1268 $0

Function126a:: ; 126a
	call PlaceString
	ld h, b
	ld l, c
	pop de
	jp NextChar
; 0x1273

Char5CText:: ; 1273
	db "TM@"
Char5DText:: ; 1276
	db "TRAINER@"
Char5BText:: ; 127e
	db "PC@"
Char5EText:: ; 1281
	db "ROCKET@"
Char54Text:: ; 1288
	db "POKé@"
Char23Text:: ; 128d
	db "こうげき@"
Char56Text::; 1292
	db "……@"
Char5AText:: ; 1295
	db "Enemy @"
Char4AText:: ; 129c
	db $e1, $e2, "@" ; PK MN
Char24Text:: ; 129f
	db $70, $71, "@" ; PO KE
String12a2:: ; 12a2
	db " @"
Char35Text::
Char36Text::
Char37Text:: ; 12a4
	db "@"
String12a5:: ; 12a5
	db "@"
String12a6:: ; 12a6
	db "@"
; 12a7

Function12a7:: ; 12a7
	pop hl
	ld bc, $0028
	add hl, bc
	push hl
	jp NextChar
; 12b0

Function12b0:: ; 12b0
	pop hl
	ld bc, $0014
	add hl, bc
	push hl
	jp NextChar
; 12b9

Function12b9:: ; 12b9
	pop hl
	push de
	ld bc, $3b60
	add hl, bc
	ld de, $ffec
	ld c, $1
.asm_12c4
	ld a, h
	and a
	jr nz, .asm_12cd
	ld a, l
	cp $14
	jr c, .asm_12d1

.asm_12cd
	add hl, de
	inc c
	jr .asm_12c4

.asm_12d1
	ld hl, TileMap
	ld de, $0014
	ld a, c
.asm_12d8
	and a
	jr z, .asm_12df
	add hl, de
	dec a
	jr .asm_12d8

.asm_12df
	pop de
	inc de
	ld a, [de]
	ld c, a
	ld b, $0
	add hl, bc
	push hl
	jp NextChar
; 12ea


Char4F:: ; 12ea
	pop hl
	hlcoord 1, 16
	push hl
	jp NextChar
; 0x12f2

Function12f2:: ; 12f2
	push de
	ld a, [InLinkBattle]
	cp $3
	jr z, .asm_1301
	cp $4
	jr z, .asm_1301
	call Function13c7

.asm_1301
	call Function13b6
	call Functionaaf
	ld hl, $c5b9
	ld bc, $0312
	call ClearBox
	call Function13cd
	ld c, $14
	call DelayFrames
	ld hl, $c5b9
	pop de
	jp NextChar
; 131f


Char4B:: ; 131f
	ld a, [InLinkBattle]
	or a
	jr nz, .asm_1328
	call Function13c7

.asm_1328
	call Function13b6

	push de
	call Functionaaf
	pop de

	ld a, [InLinkBattle]
	or a
	call z, Function13cd

Function1337:: ; 1337
	push de
	call Function138c
	call Function138c
	hlcoord 1, 16
	pop de
	jp NextChar
; 1345


Char55:: ; 1345
	push de
	ld de, Text_1354
	ld b, h
	ld c, l
	call PlaceString
	ld h, b
	ld l, c
	pop de
	jp NextChar
; 1354

Text_1354:: ; 1354
	db $4b, "@"
; 1356


Char5F:: ; 1356
; ends a Pokédex entry
	ld [hl], "."
	pop hl
	ret
; 135a

Function135a:: ; 135a
	ld a, [InLinkBattle]
	cp $3
	jr z, .asm_1368
	cp $4
	jr z, .asm_1368
	call Function13c7

.asm_1368
	call Function13b6
	call Functionaaf
	ld a, [InLinkBattle]
	cp $3
	jr z, Function137c
	cp $4
	jr z, Function137c
	call Function13cd

Function137c:: ; 137c
	pop hl
	ld de, .string_1382
	dec de
	ret

.string_1382
	db "@"
; 1383

Function1383:: ; 1383
	ld a, $e6
	ld [hli], a
	call PrintLetterDelay
	jp NextChar
; 138c

Function138c:: ; 138c
	ld hl, $c5b9
	ld de, $c5a5
	ld a, $3
.asm_1394
	push af
	ld c, $12
.asm_1397
	ld a, [hli]
	ld [de], a
	inc de
	dec c
	jr nz, .asm_1397
	inc de
	inc de
	inc hl
	inc hl
	pop af
	dec a
	jr nz, .asm_1394
	ld hl, $c5e1
	ld a, $7f
	ld bc, $0012
	call ByteFill
	ld c, $5
	call DelayFrames
	ret
; 13b6

Function13b6:: ; 13b6
	push bc
	ld a, [hOAMUpdate]
	push af
	ld a, $1
	ld [hOAMUpdate], a
	call WaitBGMap
	pop af
	ld [hOAMUpdate], a
	pop bc
	ret
; 13c6

Function13c6:: ; 13c6
	ret
; 13c7

Function13c7:: ; 13c7
	ld a, $ee
	ld [$c606], a
	ret
; 13cd

Function13cd:: ; 13cd
	ld a, [$c605]
	ld [$c606], a
	ret
; 13d4

Function13d4:: ; 13d4
	ld b, a
	ld a, [hROMBank]
	push af
	ld a, b
	rst Bankswitch

	call PlaceString
	pop af
	rst Bankswitch

	ret
; 13e0

Function13e0:: ; 13e0
	ld hl, String_13e4
	ret

String_13e4: ; 13e4
	db "@"
; 13e5


Function13e5:: ; 13e5
	ld a, [$cfcf]
	push af
	set 1, a
	ld [$cfcf], a
	call Function13f6
	pop af
	ld [$cfcf], a
	ret
; 13f6

Function13f6:: ; 13f6
.asm_13f6
	ld a, [hli]
	cp "@"
	ret z
	call Function13ff
	jr .asm_13f6
; 13ff

Function13ff:: ; 13ff
	push hl
	push bc
	ld c, a
	ld b, 0
	ld hl, TextCommands
	add hl, bc
	add hl, bc
	ld e, [hl]
	inc hl
	ld d, [hl]
	pop bc
	pop hl
	
; jp de
	push de
	ret
; 1410

TextCommands:: ; 1410
	dw Text_00
	dw Text_01
	dw Text_02
	dw Text_03
	dw Text_04
	dw Text_05
	dw Text_06
	dw Text_07
	dw Text_08
	dw Text_09
	dw Text_0A
	dw Text_PlaySound ; $0b
	dw Text_0C
	dw Text_0D
	dw Text_PlaySound ; $0e
	dw Text_PlaySound ; $0f
	dw Text_PlaySound ; $10
	dw Text_PlaySound ; $11
	dw Text_PlaySound ; $12
	dw Text_PlaySound ; $13
	dw Text_14
	dw Text_15
	dw Text_16
; 143e

Text_00:: ; 143e
; TX
; write text until "@"
; [$00]["...@"]

	ld d, h
	ld e, l
	ld h, b
	ld l, c
	call PlaceString
	ld h, d
	ld l, e
	inc hl
	ret
; 1449

Text_01:: ; 1449
; TX_RAM
; write text from a ram address
; little endian
; [$01][addr]

	ld a, [hli]
	ld e, a
	ld a, [hli]
	ld d, a
	push hl
	ld h, b
	ld l, c
	call PlaceString
	pop hl
	ret
; 1455

Text_16:: ; 1455
; TX_FAR
; write text from a different bank
; little endian
; [$16][addr][bank]

	ld a, [hROMBank]
	push af

	ld a, [hli]
	ld e, a
	ld a, [hli]
	ld d, a
	ld a, [hli]

	ld [hROMBank], a
	ld [MBC3RomBank], a

	push hl
	ld h, d
	ld l, e
	call Function13f6
	pop hl

	pop af
	ld [hROMBank], a
	ld [MBC3RomBank], a
	ret
; 1470

Text_02:: ; 1470
; TX_NUM
; write bcdnumber from address, typically ram
; little endian
; [$02][addr][flags]
; flags: see PrintBCDNumber

	ld a, [hli]
	ld e, a
	ld a, [hli]
	ld d, a
	ld a, [hli]
	push hl
	ld h, b
	ld l, c
	ld c, a
	call PrintBCDNumber
	ld b, h
	ld c, l
	pop hl
	ret
; 1480

Text_03:: ; 1480
; TX_MOVE
; move to a new tile
; little endian
; [$03][tileaddr]

	ld a, [hli]
	ld [$d0e6], a
	ld c, a
	ld a, [hli]
	ld [$d0e7], a
	ld b, a
	ret
; 148b

Text_04:: ; 148b
; TX_BOX
; draw a box
; little endian
; [$04][tileaddr][height][width]

	ld a, [hli]
	ld e, a
	ld a, [hli]
	ld d, a
	ld a, [hli]
	ld b, a
	ld a, [hli]
	ld c, a
	push hl
	ld h, d
	ld l, e
	call TextBox
	pop hl
	ret
; 149b

Text_05:: ; 149b
; TX_LOW
; write text at (1,16)
; [$05]

	bccoord 1, 16
	ret
; 149f

Text_06:: ; 149f
; TX_WAITBUTTON
; wait for button press
; show arrow
; [06]

	ld a, [InLinkBattle]
	cp $3
	jp z, Text_0D
	cp $4
	jp z, Text_0D
	push hl
	call Function13c7
	push bc
	call Functionaaf
	pop bc
	call Function13cd
	pop hl
	ret
; 14ba

Text_07:: ; 14ba
	push hl
	call Function13cd
	call Function138c
	call Function138c
	pop hl
	bccoord 1, 16
	ret
; 14c9

Text_08:: ; 14c9
; TX_ASM

; rom only?
	bit 7, h
	jr nz, .asm_14ce
	jp [hl]

.asm_14ce
	ld a, "@"
	ld [hl], a
	ret
; 14d2

Text_09:: ; 14d2
	ld a, [hli]
	ld e, a
	ld a, [hli]
	ld d, a
	ld a, [hli]
	push hl
	ld h, b
	ld l, c
	ld b, a
	and $f
	ld c, a
	ld a, b
	and $f0
	swap a
	set 6, a
	ld b, a
	call PrintNum
	ld b, h
	ld c, l
	pop hl
	ret
; 14ed

Text_0A:: ; 14ed
	push hl
	push bc
	call GetJoypad
	ld a, [hJoyDown]
	and A_BUTTON | B_BUTTON
	jr nz, .asm_14fd
	ld c, 30
	call DelayFrames

.asm_14fd
	pop bc
	pop hl
	ret
; 1500

Text_PlaySound:: ; 1500
; chars:
;   $0b, $0e, $0f, $10, $11, $12, $13
; see TextSFX

	push bc
	dec hl
	ld a, [hli]
	ld b, a
	push hl
	ld hl, TextSFX
.asm_1508
	ld a, [hli]
	cp $ff
	jr z, .asm_151f
	cp b
	jr z, .asm_1514
	inc hl
	inc hl
	jr .asm_1508

.asm_1514
	push de
	ld e, [hl]
	inc hl
	ld d, [hl]
	call PlaySFX
	call WaitSFX
	pop de

.asm_151f
	pop hl
	pop bc
	ret
; 1522

Function1522:: ; 1522
	push de
	ld e, [hl]
	inc hl
	ld d, [hl]
	call Function37ce
	pop de
	pop hl
	pop bc
	ret
; 152d

TextSFX:: ; 152d
	dbw $0b, SFX_DEX_FANFARE_50_79
	dbw $12, SFX_FANFARE
	dbw $0e, SFX_DEX_FANFARE_20_49
	dbw $0f, SFX_ITEM
	dbw $10, SFX_CAUGHT_MON
	dbw $11, SFX_DEX_FANFARE_80_109
	dbw $13, SFX_SLOT_MACHINE_START
	db $ff ; end
; 1543

Text_0C:: ; 1543
	ld a, [hli]
	ld d, a
	push hl
	ld h, b
	ld l, c
.asm_1548
	push de
	ld a, "…"
	ld [hli], a
	call GetJoypad
	ld a, [hJoyDown]
	and A_BUTTON | B_BUTTON
	jr nz, .asm_155a
	ld c, 10
	call DelayFrames
.asm_155a
	pop de
	dec d
	jr nz, .asm_1548
	ld b, h
	ld c, l
	pop hl
	ret
; 1562

Text_0D:: ; 1562
; wait for key down
; display arrow
	push hl
	push bc
	call Functionaaf
	pop bc
	pop hl
	ret
; 156a

Text_14:: ; 156a
; Print a string from one of the following:
; 0: StringBuffer3
; 1: StringBuffer4
; 2: StringBuffer5
; 3: StringBuffer2
; 4: StringBuffer1
; 5: EnemyMonNick
; 6: BattleMonNick
; [$14][id]

	ld a, [hli]
	push hl
	ld e, a
	ld d, 0
	ld hl, Unknown_24000
	add hl, de
	add hl, de
	ld a, BANK(Unknown_24000)
	call GetFarHalfword
	ld d, h
	ld e, l
	ld h, b
	ld l, c
	call PlaceString
	pop hl
	ret
; 1582

Text_15:: ; 1582
; TX_DAY

	call GetWeekday
	push hl
	push bc
	ld c, a
	ld b, 0
	ld hl, .Days
	add hl, bc
	add hl, bc
	ld a, [hli]
	ld h, [hl]
	ld l, a
	ld d, h
	ld e, l
	pop hl
	call PlaceString
	ld h, b
	ld l, c
	ld de, .Day
	call PlaceString
	pop hl
	ret
; 15a2

.Days ; 15a2
	dw .Sun
	dw .Mon
	dw .Tues
	dw .Wednes
	dw .Thurs
	dw .Fri
	dw .Satur

.Sun    db "SUN@"
.Mon    db "MON@"
.Tues   db "TUES@"
.Wednes db "WEDNES@"
.Thurs  db "THURS@"
.Fri    db "FRI@"
.Satur  db "SATUR@"
.Day    db "DAY@"
; 15d8