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
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
|
PokeGear: ; 90b8d (24:4b8d)
ld hl, Options
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [hInMenu]
push af
ld a, $1
ld [hInMenu], a
ld a, [VramState]
push af
xor a
ld [VramState], a
call .InitTilemap
call DelayFrame
.loop
call UpdateTime
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
jr nz, .done
call PokegearJumptable
callba PlaySpriteAnimations
call DelayFrame
jr .loop
.done
ld de, SFX_READ_TEXT_2
call PlaySFX
call WaitSFX
pop af
ld [VramState], a
pop af
ld [hInMenu], a
pop af
ld [Options], a
call ClearBGPalettes
xor a
ld [hBGMapAddress], a
ld a, VBGMap0 / $100
ld [hBGMapAddress + 1], a
ld a, $90
ld [hWY], a
call ExitPokegearRadio_HandleMusic
ret
.InitTilemap: ; 90bea (24:4bea)
call ClearBGPalettes
call ClearTileMap
call ClearSprites
call DisableLCD
xor a
ld [hSCY], a
ld [hSCX], a
ld a, $7
ld [hWX], a
call Pokegear_LoadGFX
callba ClearSpriteAnims
call InitPokegearModeIndicatorArrow
ld a, 8
call SkipMusic
ld a, $e3
ld [rLCDC], a
call TownMap_InitCursorAndPlayerIconPositions
xor a
ld [wJumptableIndex], a
ld [wcf64], a
ld [wcf65], a
ld [wcf66], a
ld [wPokegearPhoneScrollPosition], a
ld [wPokegearPhoneCursorPosition], a
ld [wPokegearPhoneSelectedPerson], a
ld [wPokegearRadioChannelBank], a
ld [wPokegearRadioChannelAddr], a
ld [wPokegearRadioChannelAddr + 1], a
call Pokegear_InitJumptableIndices
call InitPokegearTilemap
ld b, SCGB_POKEGEAR_PALS
call GetSGBLayout
call SetPalettes
ld a, [hCGB]
and a
ret z
ld a, %11100100
call DmgToCgbObjPal0
ret
Pokegear_LoadGFX: ; 90c4e
call ClearVBank1
ld hl, TownMapGFX
ld de, VTiles2
ld a, BANK(TownMapGFX)
call FarDecompress
ld hl, PokegearGFX
ld de, VTiles2 + $30 tiles
ld a, BANK(PokegearGFX)
call FarDecompress
ld hl, PokegearSpritesGFX
ld de, VTiles0
ld a, BANK(PokegearSpritesGFX)
call Decompress
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
call GetWorldMapLocation
cp FAST_SHIP
jr z, .ssaqua
callba GetPlayerIcon
push de
ld h, d
ld l, e
ld a, b
; standing sprite
push af
ld de, VTiles0 tile $10
ld bc, 4 tiles
call FarCopyBytes
pop af
pop hl
; walking sprite
ld de, 12 tiles
add hl, de
ld de, VTiles0 tile $14
ld bc, 4 tiles
call FarCopyBytes
ret
.ssaqua
ld hl, FastShipGFX
ld de, VTiles0 tile $10
ld bc, 8 tiles
call CopyBytes
ret
; 90cb2
FastShipGFX: ; 90cb2
INCBIN "gfx/misc/fast_ship.2bpp"
; 90d32
InitPokegearModeIndicatorArrow: ; 90d32 (24:4d32)
depixel 4, 2, 4, 0
ld a, SPRITE_ANIM_INDEX_0D
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $0
ret
AnimatePokegearModeIndicatorArrow: ; 90d41 (24:4d41)
ld hl, wcf64
ld e, [hl]
ld d, 0
ld hl, .XCoords
add hl, de
ld a, [hl]
ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
; 90d52 (24:4d52)
.XCoords: ; 90d52
db $00, $10, $20, $30
; 90d56
TownMap_GetCurrentLandmark: ; 90d56
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
call GetWorldMapLocation
cp SPECIAL_MAP
ret nz
ld a, [BackupMapGroup]
ld b, a
ld a, [BackupMapNumber]
ld c, a
call GetWorldMapLocation
ret
; 90d70
TownMap_InitCursorAndPlayerIconPositions: ; 90d70 (24:4d70)
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
call GetWorldMapLocation
cp FAST_SHIP
jr z, .FastShip
cp SPECIAL_MAP
jr nz, .LoadLandmark
ld a, [BackupMapGroup]
ld b, a
ld a, [BackupMapNumber]
ld c, a
call GetWorldMapLocation
.LoadLandmark:
ld [wPokegearMapPlayerIconLandmark], a
ld [wPokegearMapCursorLandmark], a
ret
.FastShip:
ld [wPokegearMapPlayerIconLandmark], a
ld a, NEW_BARK_TOWN
ld [wPokegearMapCursorLandmark], a
ret
Pokegear_InitJumptableIndices: ; 90d9e (24:4d9e)
ld a, $0
ld [wJumptableIndex], a
xor a
ld [wcf64], a
ret
InitPokegearTilemap: ; 90da8 (24:4da8)
xor a
ld [hBGMapMode], a
hlcoord 0, 0
ld bc, TileMapEnd - TileMap
ld a, $4f
call ByteFill
ld a, [wcf64]
and $3
add a
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .return_from_jumptable
push de
jp [hl]
.return_from_jumptable
call Pokegear_FinishTilemap
callba TownMapPals
ld a, [wcf65]
and a
jr nz, .kanto_0
xor a
ld [hBGMapAddress], a
ld a, VBGMap0 / $100
ld [hBGMapAddress + 1], a
call .UpdateBGMap
ld a, $90
jr .finish
.kanto_0
xor a
ld [hBGMapAddress], a
ld a, VBGMap1 / $100
ld [hBGMapAddress + 1], a
call .UpdateBGMap
xor a
.finish
ld [hWY], a
ld a, [wcf65]
and 1
xor 1
ld [wcf65], a
ret
.UpdateBGMap: ; 90e00 (24:4e00)
ld a, [hCGB]
and a
jr z, .dmg
ld a, $2
ld [hBGMapMode], a
ld c, 3
call DelayFrames
.dmg
call WaitBGMap
ret
; 90e12 (24:4e12)
.Jumptable: ; 90e12
dw .Clock
dw .Map
dw .Phone
dw .Radio
; 90e1a
.Clock: ; 90e1a
ld de, ClockTilemapRLE
call Pokegear_LoadTilemapRLE
hlcoord 12, 1
ld de, .switch
call PlaceString
hlcoord 0, 12
lb bc, 4, 18
call TextBox
call Pokegear_UpdateClock
ret
; 90e36 (24:4e36)
.switch
db " SWITCH▶@"
; 90e3f
.Map: ; 90e3f
ld a, [wPokegearMapPlayerIconLandmark]
cp FAST_SHIP
jr z, .johto
cp KANTO_LANDMARK
jr nc, .kanto
.johto
ld e, 0
jr .ok
.kanto
ld e, 1
.ok
callba PokegearMap
ld a, $7
ld bc, $12
hlcoord 1, 2
call ByteFill
hlcoord 0, 2
ld [hl], $6
hlcoord 19, 2
ld [hl], $17
ld a, [wPokegearMapCursorLandmark]
call PokegearMap_UpdateLandmarkName
ret
; 90e72
.Radio: ; 90e72
ld de, RadioTilemapRLE
call Pokegear_LoadTilemapRLE
hlcoord 0, 12
lb bc, 4, 18
call TextBox
ret
; 90e82
.Phone: ; 90e82
ld de, PhoneTilemapRLE
call Pokegear_LoadTilemapRLE
hlcoord 0, 12
lb bc, 4, 18
call TextBox
call .PlacePhoneBars
call PokegearPhone_UpdateDisplayList
ret
; 90e98
.PlacePhoneBars: ; 90e98 (24:4e98)
hlcoord 17, 1
ld a, $3c
ld [hli], a
inc a
ld [hl], a
hlcoord 17, 2
inc a
ld [hli], a
call GetMapHeaderPhoneServiceNybble
and a
ret nz
hlcoord 18, 2
ld [hl], $3f
ret
Pokegear_FinishTilemap: ; 90eb0 (24:4eb0)
hlcoord 0, 0
ld bc, $8
ld a, $4f
call ByteFill
hlcoord 0, 1
ld bc, $8
ld a, $4f
call ByteFill
ld de, wPokegearFlags
ld a, [de]
bit 0, a
call nz, .PlaceMapIcon
ld a, [de]
bit 2, a
call nz, .PlacePhoneIcon
ld a, [de]
bit 1, a
call nz, .PlaceRadioIcon
hlcoord 0, 0
ld a, $46
call .PlacePokegearCardIcon
ret
.PlaceMapIcon: ; 90ee4 (24:4ee4)
hlcoord 2, 0
ld a, $40
jr .PlacePokegearCardIcon
.PlacePhoneIcon: ; 90eeb (24:4eeb)
hlcoord 4, 0
ld a, $44
jr .PlacePokegearCardIcon
.PlaceRadioIcon: ; 90ef2 (24:4ef2)
hlcoord 6, 0
ld a, $42
.PlacePokegearCardIcon: ; 90ef7 (24:4ef7)
ld [hli], a
inc a
ld [hld], a
ld bc, $14
add hl, bc
add $f
ld [hli], a
inc a
ld [hld], a
ret
PokegearJumptable: ; 90f04 (24:4f04)
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp [hl]
.Jumptable: ; 90f13 (24:4f13)
dw PokegearClock_Init
dw PokegearClock_Joypad
dw PokegearMap_CheckRegion
dw PokegearMap_Init
dw PokegearMap_JohtoMap
dw PokegearMap_Init
dw PokegearMap_KantoMap
dw PokegearPhone_Init
dw PokegearPhone_Joypad
dw PokegearPhone_MakePhoneCall
dw PokegearPhone_FinishPhoneCall
dw PokegearRadio_Init
dw PokegearRadio_Joypad
PokegearClock_Init: ; 90f2d (24:4f2d)
call InitPokegearTilemap
ld hl, PokegearText_PressAnyButtonToExit
call PrintText
ld hl, wJumptableIndex
inc [hl]
call ExitPokegearRadio_HandleMusic
ret
PokegearClock_Joypad: ; 90f3e (24:4f3e)
call .UpdateClock
ld hl, hJoyLast
ld a, [hl]
and A_BUTTON + B_BUTTON + START + SELECT
jr nz, .quit
ld a, [hl]
and D_RIGHT
ret z
ld a, [wPokegearFlags]
bit 0, a
jr z, .no_map_card
ld c, $2
ld b, $1
jr .done
.no_map_card
ld a, [wPokegearFlags]
bit 2, a
jr z, .no_phone_card
ld c, $7
ld b, $2
jr .done
.no_phone_card
ld a, [wPokegearFlags]
bit 1, a
ret z
ld c, $b
ld b, $3
.done
call Pokegear_SwitchPage
ret
.quit
ld hl, wJumptableIndex
set 7, [hl]
ret
.UpdateClock: ; 90f7b (24:4f7b)
xor a
ld [hBGMapMode], a
call Pokegear_UpdateClock
ld a, $1
ld [hBGMapMode], a
ret
Pokegear_UpdateClock: ; 90f86 (24:4f86)
hlcoord 3, 5
lb bc, 5, 14
call ClearBox
ld a, [hHours]
ld b, a
ld a, [hMinutes]
ld c, a
decoord 6, 8
callba PrintHoursMins
ld hl, .DayText
bccoord 6, 6
call PlaceWholeStringInBoxAtOnce
ret
; 90fa8 (24:4fa8)
db "ごぜん@"
db "ごご@"
.DayText: ; 0x90faf
text_jump UnknownText_0x1c5821
db "@"
; 0x90fb4
PokegearMap_CheckRegion: ; 90fb4 (24:4fb4)
ld a, [wPokegearMapPlayerIconLandmark]
cp FAST_SHIP
jr z, .johto
cp KANTO_LANDMARK
jr nc, .kanto
.johto
ld a, 3
jr .done
ret
.kanto
ld a, 5
.done
ld [wJumptableIndex], a
call ExitPokegearRadio_HandleMusic
ret
PokegearMap_Init: ; 90fcd (24:4fcd)
call InitPokegearTilemap
ld a, [wPokegearMapPlayerIconLandmark]
call PokegearMap_InitPlayerIcon
ld a, [wPokegearMapCursorLandmark]
call PokegearMap_InitCursor
ld a, c
ld [wPokegearMapCursorObjectPointer], a
ld a, b
ld [wPokegearMapCursorObjectPointer + 1], a
ld hl, wJumptableIndex
inc [hl]
ret
PokegearMap_KantoMap: ; 90fe9 (24:4fe9)
call TownMap_GetKantoLandmarkLimits
jr PokegearMap_ContinueMap
PokegearMap_JohtoMap: ; 90fee (24:4fee)
ld d, SILVER_CAVE
ld e, NEW_BARK_TOWN
PokegearMap_ContinueMap: ; 90ff2 (24:4ff2)
ld hl, hJoyLast
ld a, [hl]
and B_BUTTON
jr nz, .cancel
ld a, [hl]
and D_RIGHT
jr nz, .right
ld a, [hl]
and D_LEFT
jr nz, .left
call .DPad
ret
.right
ld a, [wPokegearFlags]
bit 2, a
jr z, .no_phone
ld c, $7
ld b, $2
jr .done
.no_phone
ld a, [wPokegearFlags]
bit 1, a
ret z
ld c, $b
ld b, $3
jr .done
.left
ld c, $0
ld b, $0
.done
call Pokegear_SwitchPage
ret
.cancel
ld hl, wJumptableIndex
set 7, [hl]
ret
.DPad: ; 9102f (24:502f)
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
ret
.up
ld hl, wPokegearMapCursorLandmark
ld a, [hl]
cp d
jr c, .wrap_around_up
ld a, e
dec a
ld [hl], a
.wrap_around_up
inc [hl]
jr .done_dpad
.down
ld hl, wPokegearMapCursorLandmark
ld a, [hl]
cp e
jr nz, .wrap_around_down
ld a, d
inc a
ld [hl], a
.wrap_around_down
dec [hl]
.done_dpad
ld a, [wPokegearMapCursorLandmark]
call PokegearMap_UpdateLandmarkName
ld a, [wPokegearMapCursorObjectPointer]
ld c, a
ld a, [wPokegearMapCursorObjectPointer + 1]
ld b, a
ld a, [wPokegearMapCursorLandmark]
call PokegearMap_UpdateCursorPosition
ret
PokegearMap_InitPlayerIcon: ; 9106a
push af
depixel 0, 0
ld b, SPRITE_ANIM_INDEX_RED_WALK
ld a, [PlayerGender]
bit 0, a
jr z, .got_gender
ld b, SPRITE_ANIM_INDEX_BLUE_WALK
.got_gender
ld a, b
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $10
pop af
ld e, a
push bc
callba GetLandmarkCoords
pop bc
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], e
ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld [hl], d
ret
; 91098
PokegearMap_InitCursor: ; 91098
push af
depixel 0, 0
ld a, SPRITE_ANIM_INDEX_0D
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $4
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL
pop af
push bc
call PokegearMap_UpdateCursorPosition
pop bc
ret
; 910b4
PokegearMap_UpdateLandmarkName: ; 910b4
push af
hlcoord 8, 0
lb bc, 2, 12
call ClearBox
pop af
ld e, a
push de
callba GetLandmarkName
pop de
callba Function1de2c5
hlcoord 8, 0
ld [hl], $34
ret
; 910d4
PokegearMap_UpdateCursorPosition: ; 910d4
push bc
ld e, a
callba GetLandmarkCoords
pop bc
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], e
ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld [hl], d
ret
; 910e8
TownMap_GetKantoLandmarkLimits: ; 910e8
ld a, [StatusFlags]
bit 6, a
jr z, .not_hof
ld d, ROUTE_28
ld e, PALLET_TOWN
ret
.not_hof
ld d, ROUTE_28
ld e, VICTORY_ROAD
ret
; 910f9
PokegearRadio_Init: ; 910f9 (24:50f9)
call InitPokegearTilemap
depixel 4, 10, 4, 4
ld a, SPRITE_ANIM_INDEX_14
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $8
call _UpdateRadioStation
ld hl, wJumptableIndex
inc [hl]
ret
PokegearRadio_Joypad: ; 91112 (24:5112)
ld hl, hJoyLast
ld a, [hl]
and B_BUTTON
jr nz, .cancel
ld a, [hl]
and D_LEFT
jr nz, .left
ld a, [wPokegearRadioChannelAddr]
ld l, a
ld a, [wPokegearRadioChannelAddr + 1]
ld h, a
ld a, [wPokegearRadioChannelBank]
and a
ret z
rst FarCall
ret
.left
ld a, [wPokegearFlags]
bit 2, a
jr z, .no_phone
ld c, $7
ld b, $2
jr .switch_page
.no_phone
ld a, [wPokegearFlags]
bit 0, a
jr z, .no_map
ld c, $2
ld b, $1
jr .switch_page
.no_map
ld c, $0
ld b, $0
.switch_page
call Pokegear_SwitchPage
ret
.cancel
ld hl, wJumptableIndex
set 7, [hl]
ret
PokegearPhone_Init: ; 91156 (24:5156)
ld hl, wJumptableIndex
inc [hl]
xor a
ld [wPokegearPhoneScrollPosition], a
ld [wPokegearPhoneCursorPosition], a
ld [wPokegearPhoneSelectedPerson], a
call InitPokegearTilemap
call ExitPokegearRadio_HandleMusic
ld hl, PokegearText_WhomToCall
call PrintText
ret
PokegearPhone_Joypad: ; 91171 (24:5171)
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .b
ld a, [hl]
and A_BUTTON
jr nz, .a
ld hl, hJoyLast
ld a, [hl]
and D_LEFT
jr nz, .left
ld a, [hl]
and D_RIGHT
jr nz, .right
call PokegearPhone_GetDPad
ret
.left
ld a, [wPokegearFlags]
bit 0, a
jr z, .no_map
ld c, $2
ld b, $1
jr .switch_page
.no_map
ld c, $0
ld b, $0
jr .switch_page
.right
ld a, [wPokegearFlags]
bit 1, a
ret z
ld c, $b
ld b, $3
.switch_page
call Pokegear_SwitchPage
ret
.b
ld hl, wJumptableIndex
set 7, [hl]
ret
.a
ld hl, wPhoneList
ld a, [wPokegearPhoneScrollPosition]
ld e, a
ld d, 0
add hl, de
ld a, [wPokegearPhoneCursorPosition]
ld e, a
ld d, 0
add hl, de
ld a, [hl]
and a
ret z
ld [wPokegearPhoneSelectedPerson], a
hlcoord 1, 4
ld a, [wPokegearPhoneCursorPosition]
ld bc, 20 * 2
call AddNTimes
ld [hl], "▷"
call PokegearPhoneContactSubmenu
jr c, .quit_submenu
ld hl, wJumptableIndex
inc [hl]
ret
.quit_submenu
ld a, $8
ld [wJumptableIndex], a
ret
PokegearPhone_MakePhoneCall: ; 911eb (24:51eb)
call GetMapHeaderPhoneServiceNybble
and a
jr nz, .no_service
ld hl, Options
res NO_TEXT_SCROLL, [hl]
xor a
ld [hInMenu], a
ld de, SFX_CALL
call PlaySFX
ld hl, .dotdotdot
call PrintText
call WaitSFX
ld de, SFX_CALL
call PlaySFX
ld hl, .dotdotdot
call PrintText
call WaitSFX
ld a, [wPokegearPhoneSelectedPerson]
ld b, a
call Function90199
ld c, 10
call DelayFrames
ld hl, Options
set NO_TEXT_SCROLL, [hl]
ld a, $1
ld [hInMenu], a
call PokegearPhone_UpdateCursor
ld hl, wJumptableIndex
inc [hl]
ret
.no_service
callba Phone_NoSignal
ld hl, .OutOfServiceArea
call PrintText
ld a, $8
ld [wJumptableIndex], a
ld hl, PokegearText_WhomToCall
call PrintText
ret
; 9124c (24:524c)
.dotdotdot ; 0x9124c
;
text_jump UnknownText_0x1c5824
db "@"
; 0x91251
.OutOfServiceArea: ; 0x91251
; You're out of the service area.
text_jump UnknownText_0x1c5827
db "@"
; 0x91256
PokegearPhone_FinishPhoneCall: ; 91256 (24:5256)
ld a, [hJoyPressed]
and A_BUTTON | B_BUTTON
ret z
callba HangUp
ld a, $8
ld [wJumptableIndex], a
ld hl, PokegearText_WhomToCall
call PrintText
ret
PokegearPhone_GetDPad: ; 9126d (24:526d)
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
ret
.up
ld hl, wPokegearPhoneCursorPosition
ld a, [hl]
and a
jr z, .scroll_page_up
dec [hl]
jr .done_joypad_same_page
.scroll_page_up
ld hl, wPokegearPhoneScrollPosition
ld a, [hl]
and a
ret z
dec [hl]
jr .done_joypad_update_page
.down
ld hl, wPokegearPhoneCursorPosition
ld a, [hl]
cp $3
jr nc, .scroll_page_down
inc [hl]
jr .done_joypad_same_page
.scroll_page_down
ld hl, wPokegearPhoneScrollPosition
ld a, [hl]
cp $6
ret nc
inc [hl]
jr .done_joypad_update_page
.done_joypad_same_page
xor a
ld [hBGMapMode], a
call PokegearPhone_UpdateCursor
call WaitBGMap
ret
.done_joypad_update_page
xor a
ld [hBGMapMode], a
call PokegearPhone_UpdateDisplayList
call WaitBGMap
ret
PokegearPhone_UpdateCursor: ; 912b7 (24:52b7)
ld a, " "
hlcoord 1, 4
ld [hl], a
hlcoord 1, 6
ld [hl], a
hlcoord 1, 8
ld [hl], a
hlcoord 1, 10
ld [hl], a
hlcoord 1, 4
ld a, [wPokegearPhoneCursorPosition]
ld bc, 2 * SCREEN_WIDTH
call AddNTimes
ld [hl], "▶"
ret
PokegearPhone_UpdateDisplayList: ; 912d8 (24:52d8)
hlcoord 1, 3
ld b, 9
ld a, " "
.row
ld c, 18
.col
ld [hli], a
dec c
jr nz, .col
inc hl
inc hl
dec b
jr nz, .row
ld a, [wPokegearPhoneScrollPosition]
ld e, a
ld d, $0
ld hl, wPhoneList
add hl, de
xor a
ld [wPokegearPhoneLoadNameBuffer], a
.loop
ld a, [hli]
push hl
push af
hlcoord 2, 4
ld a, [wPokegearPhoneLoadNameBuffer]
ld bc, 2 * SCREEN_WIDTH
call AddNTimes
ld d, h
ld e, l
pop af
ld b, a
call Function90380
pop hl
ld a, [wPokegearPhoneLoadNameBuffer]
inc a
ld [wPokegearPhoneLoadNameBuffer], a
cp $4
jr c, .loop
call PokegearPhone_UpdateCursor
ret
; 9131e (24:531e)
PokegearPhone_DeletePhoneNumber: ; 9131e
ld hl, wPhoneList
ld a, [wPokegearPhoneScrollPosition]
ld e, a
ld d, 0
add hl, de
ld a, [wPokegearPhoneCursorPosition]
ld e, a
ld d, 0
add hl, de
ld [hl], 0
ld hl, wPhoneList
ld c, CONTACT_LIST_SIZE
.loop
ld a, [hli]
and a
jr nz, .skip
ld a, [hld]
ld [hli], a
ld [hl], 0
.skip
dec c
jr nz, .loop
ret
; 91342
PokegearPhoneContactSubmenu: ; 91342 (24:5342)
ld hl, wPhoneList
ld a, [wPokegearPhoneScrollPosition]
ld e, a
ld d, 0
add hl, de
ld a, [wPokegearPhoneCursorPosition]
ld e, a
ld d, 0
add hl, de
ld c, [hl]
callba CheckCanDeletePhoneNumber
ld a, c
and a
jr z, .cant_delete
ld hl, .CallDeleteCancelJumptable
ld de, .CallDeleteCancelStrings
jr .got_menu_data
.cant_delete
ld hl, .CallCancelJumptable
ld de, .CallCancelStrings
.got_menu_data
xor a
ld [hBGMapMode], a
push hl
push de
ld a, [de]
ld l, a
inc de
ld a, [de]
ld h, a
inc de
push hl
ld bc, hBGMapAddress + 1
add hl, bc
ld a, [de]
inc de
sla a
ld b, a
ld c, 8
push de
call TextBox
pop de
pop hl
inc hl
call PlaceString
pop de
xor a
ld [wPokegearPhoneSubmenuCursor], a
call .UpdateCursor
call WaitBGMap
.loop
push de
call JoyTextDelay
pop de
ld hl, hJoyPressed
ld a, [hl]
and D_UP
jr nz, .d_up
ld a, [hl]
and D_DOWN
jr nz, .d_down
ld a, [hl]
and A_BUTTON | B_BUTTON
jr nz, .a_b
call DelayFrame
jr .loop
.d_up
ld hl, wPokegearPhoneSubmenuCursor
ld a, [hl]
and a
jr z, .loop
dec [hl]
call .UpdateCursor
jr .loop
.d_down
ld hl, 2
add hl, de
ld a, [wPokegearPhoneSubmenuCursor]
inc a
cp [hl]
jr nc, .loop
ld [wPokegearPhoneSubmenuCursor], a
call .UpdateCursor
jr .loop
.a_b
xor a
ld [hBGMapMode], a
call PokegearPhone_UpdateDisplayList
ld a, $1
ld [hBGMapMode], a
pop hl
ld a, [hJoyPressed]
and B_BUTTON
jr nz, .Cancel
ld a, [wPokegearPhoneSubmenuCursor]
ld e, a
ld d, 0
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp [hl]
.Cancel: ; 913f1
ld hl, PokegearText_WhomToCall
call PrintText
scf
ret
; 913f9 (24:53f9)
.Delete: ; 913f9
ld hl, PokegearText_DeleteStoredNumber
call MenuTextBox
call YesNoBox
call ExitMenu
jr c, .CancelDelete
call PokegearPhone_DeletePhoneNumber
xor a
ld [hBGMapMode], a
call PokegearPhone_UpdateDisplayList
ld hl, PokegearText_WhomToCall
call PrintText
call WaitBGMap
.CancelDelete:
scf
ret
; 9141b
.Call: ; 9141b
and a
ret
; 9141d
.UpdateCursor: ; 9141d (24:541d)
push de
ld a, [de]
inc de
ld l, a
ld a, [de]
inc de
ld h, a
ld a, [de]
ld c, a
push hl
ld a, " "
ld de, SCREEN_WIDTH * 2
.clear_column
ld [hl], a
add hl, de
dec c
jr nz, .clear_column
pop hl
ld a, [wPokegearPhoneSubmenuCursor]
ld bc, SCREEN_WIDTH * 2
call AddNTimes
ld [hl], "▶"
pop de
ret
; 9143f (24:543f)
.CallDeleteCancelStrings: ; 9143f
dwcoord 10, 6
db 3
db "CALL"
next "DELETE"
next "CANCEL"
db "@"
; 91455
.CallDeleteCancelJumptable: ; 91455
dw .Call
dw .Delete
dw .Cancel
; 9145b
.CallCancelStrings: ; 9145b
dwcoord 10, 8
db 2
db "CALL"
next "CANCEL"
db "@"
; 9146a
.CallCancelJumptable: ; 9146a
dw .Call
dw .Cancel
; 9146e
; XXX
ld a, [hHours]
cp 12
jr c, .am
sub 12
ld [wd265], a
scf
ret
.am
ld [wd265], a
and a
ret
; 91480
Pokegear_SwitchPage: ; 91480 (24:5480)
ld de, SFX_READ_TEXT_2
call PlaySFX
ld a, c
ld [wJumptableIndex], a
ld a, b
ld [wcf64], a
call DeleteSpriteAnimStruct2ToEnd
ret
ExitPokegearRadio_HandleMusic: ; 91492
ld a, [wPokegearRadioMusicPlaying]
cp $fe
jr z, .restart_map_music
cp $ff
call z, EnterMapMusic
xor a
ld [wPokegearRadioMusicPlaying], a
ret
.restart_map_music
call RestartMapMusic
xor a
ld [wPokegearRadioMusicPlaying], a
ret
; 914ab
DeleteSpriteAnimStruct2ToEnd: ; 914ab (24:54ab)
ld hl, SpriteAnim2
ld bc, wSpriteAnimationStructsEnd - SpriteAnim2
xor a
call ByteFill
ld a, 2
ld [wSpriteAnimCount], a
ret
Pokegear_LoadTilemapRLE: ; 914bb (24:54bb)
; Format: repeat count, tile ID
; Terminated with $FF
hlcoord 0, 0
.loop
ld a, [de]
cp $ff
ret z
ld b, a
inc de
ld a, [de]
ld c, a
inc de
ld a, b
.load
ld [hli], a
dec c
jr nz, .load
jr .loop
; 914ce (24:54ce)
PokegearText_WhomToCall: ; 0x914ce
; Whom do you want to call?
text_jump UnknownText_0x1c5847
db "@"
; 0x914d3
PokegearText_PressAnyButtonToExit: ; 0x914d3
; Press any button to exit.
text_jump UnknownText_0x1c5862
db "@"
; 0x914d8
PokegearText_DeleteStoredNumber: ; 0x914d8
; Delete this stored phone number?
text_jump UnknownText_0x1c587d
db "@"
; 0x914dd
PokegearSpritesGFX: ; 914dd
INCBIN "gfx/misc/pokegear_sprites.2bpp.lz"
; 9150d
RadioTilemapRLE: ; 9150d
INCBIN "gfx/pokegear/radio.tilemap.rle"
PhoneTilemapRLE: ; 9158a
INCBIN "gfx/pokegear/phone.tilemap.rle"
ClockTilemapRLE: ; 915db
INCBIN "gfx/pokegear/clock.tilemap.rle"
; 9163e
_UpdateRadioStation: ; 9163e (24:563e)
jr UpdateRadioStation
; called from engine/sprite_anims.asm
AnimateTuningKnob: ; 91640 (24:5640)
push bc
call .TuningKnob
pop bc
ld a, [wRadioTuningKnob]
ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
.TuningKnob: ; 9164e (24:564e)
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, .down
ld a, [hl]
and D_UP
jr nz, .up
ret
.down
ld hl, wRadioTuningKnob
ld a, [hl]
and a
ret z
dec [hl]
dec [hl]
jr .update
.up
ld hl, wRadioTuningKnob
ld a, [hl]
cp 80
ret nc
inc [hl]
inc [hl]
.update
UpdateRadioStation: ; 9166f (24:566f)
ld hl, wRadioTuningKnob
ld d, [hl]
ld hl, RadioChannels
.loop
ld a, [hli]
cp -1
jr z, .nostation
cp d
jr z, .foundstation
inc hl
inc hl
jr .loop
.nostation
call NoRadioStation
ret
.foundstation
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .returnafterstation
push de
jp [hl]
.returnafterstation
ld a, [wPokegearRadioChannelBank]
and a
ret z
xor a
ld [hBGMapMode], a
hlcoord 2, 9
call PlaceString
ld a, $1
ld [hBGMapMode], a
ret
; 916a1 (24:56a1)
; XXX
ld [wPokegearRadioChannelBank], a
ld a, [hli]
ld [wPokegearRadioChannelAddr], a
ld a, [hli]
ld [wPokegearRadioChannelAddr + 1], a
ret
; 916ad
RadioChannels:
; frequencies and the shows that play on them.
; frequency value given here = 4 × ingame_frequency − 2
dbw 16, .PkmnTalkAndPokedexShow
dbw 28, .PokemonMusic
dbw 32, .LuckyChannel
dbw 40, .BuenasPassword
dbw 52, .RuinsOfAlphRadio
dbw 64, .PlacesAndPeople
dbw 72, .LetsAllSing
dbw 78, .PokeFluteRadio
dbw 80, .EvolutionRadio
db -1
.PkmnTalkAndPokedexShow:
; Pokédex Show in the morning
; Oak's Pokémon Talk in the afternoon and evening
call .InJohto
jr nc, .NoSignal
ld a, [TimeOfDay]
and a
jp z, LoadStation_PokedexShow
jp LoadStation_OaksPokemonTalk
.PokemonMusic:
call .InJohto
jr nc, .NoSignal
jp LoadStation_PokemonMusic
.LuckyChannel:
call .InJohto
jr nc, .NoSignal
jp LoadStation_LuckyChannel
.BuenasPassword:
call .InJohto
jr nc, .NoSignal
jp LoadStation_BuenasPassword
.RuinsOfAlphRadio:
ld a, [wPokegearMapPlayerIconLandmark]
cp RUINS_OF_ALPH
jr nz, .NoSignal
jp LoadStation_UnownRadio
.PlacesAndPeople:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit 3, a
jr z, .NoSignal
jp LoadStation_PlacesAndPeople
.LetsAllSing:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit 3, a
jr z, .NoSignal
jp LoadStation_LetsAllSing
.PokeFluteRadio:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit 3, a
jr z, .NoSignal
jp LoadStation_PokeFluteRadio
.EvolutionRadio:
; This station airs in the Lake of Rage area when Rocket are still in Mahogany.
ld a, [StatusFlags]
bit 4, a
jr z, .NoSignal
ld a, [wPokegearMapPlayerIconLandmark]
cp MAHOGANY_TOWN
jr z, .ok
cp ROUTE_43
jr z, .ok
cp LAKE_OF_RAGE
jr nz, .NoSignal
.ok
jp LoadStation_EvolutionRadio
.NoSignal:
call NoRadioStation
ret
.InJohto:
; if in Johto or on the S.S. Aqua, set carry
; otherwise clear carry
ld a, [wPokegearMapPlayerIconLandmark]
cp FAST_SHIP
jr z, .johto
cp KANTO_LANDMARK
jr c, .johto
.kanto
and a
ret
.johto
scf
ret
LoadStation_OaksPokemonTalk: ; 91753 (24:5753)
xor a ; OAKS_POKEMON_TALK
ld [wd002], a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, OaksPkmnTalkName
ret
LoadStation_PokedexShow: ; 91766 (24:5766)
ld a, POKEDEX_SHOW
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PokedexShowName
ret
LoadStation_PokemonMusic: ; 9177b (24:577b)
ld a, POKEMON_MUSIC
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PokemonMusicName
ret
LoadStation_LuckyChannel: ; 91790 (24:5790)
ld a, LUCKY_CHANNEL
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, LuckyChannelName
ret
LoadStation_BuenasPassword: ; 917a5 (24:57a5)
ld a, BUENAS_PASSWORD
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, NotBuenasPasswordName
ld a, [StatusFlags2]
bit 0, a
ret z
ld de, BuenasPasswordName
ret
; 917c3 (24:57c3)
BuenasPasswordName: db "BUENA'S PASSWORD@"
NotBuenasPasswordName: db "@"
LoadStation_UnownRadio: ; 917d5 (24:57d5)
ld a, UNOWN_RADIO
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, UnknownStationName
ret
LoadStation_PlacesAndPeople: ; 917ea (24:57ea)
ld a, PLACES_AND_PEOPLE
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PlacesAndPeopleName
ret
LoadStation_LetsAllSing: ; 917ff (24:57ff)
ld a, LETS_ALL_SING
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, LetsAllSingName
ret
; 91814 (24:5814)
LoadStation_RocketRadio: ; 91814
ld a, ROCKET_RADIO
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, LetsAllSingName
ret
; 91829
LoadStation_PokeFluteRadio: ; 91829 (24:5829)
ld a, POKE_FLUTE_RADIO
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, PokeFluteStationName
ret
LoadStation_EvolutionRadio: ; 9183e (24:583e)
ld a, EVOLUTION_RADIO
ld [wd002], a
xor a
ld [wd005], a
ld a, BANK(PlayRadioShow)
ld hl, PlayRadioShow
call Radio_BackUpFarCallParams
ld de, UnknownStationName
ret
; 91853 (24:5853)
LoadStation_Dummy: ; 91853
ret
RadioMusicRestartDE: ; 91854 (24:5854)
push de
ld a, e
ld [wPokegearRadioMusicPlaying], a
ld de, MUSIC_NONE
call PlayMusic
pop de
ld a, e
ld [wMapMusic], a
call PlayMusic
ret
RadioMusicRestartPokemonChannel: ; 91868 (24:5868)
push de
ld a, $fe
ld [wPokegearRadioMusicPlaying], a
ld de, MUSIC_NONE
call PlayMusic
pop de
ld de, MUSIC_POKEMON_CHANNEL
call PlayMusic
ret
Radio_BackUpFarCallParams: ; 9187c (24:587c)
ld [wPokegearRadioChannelBank], a
ld a, l
ld [wPokegearRadioChannelAddr], a
ld a, h
ld [wPokegearRadioChannelAddr + 1], a
ret
NoRadioStation: ; 91888 (24:5888)
call NoRadioMusic
call NoRadioName
xor a
ld [wPokegearRadioChannelBank], a
ld [wPokegearRadioChannelAddr], a
ld [wPokegearRadioChannelAddr + 1], a
ld a, $1
ld [hBGMapMode], a
ret
NoRadioMusic: ; 9189d (24:589d)
ld de, MUSIC_NONE
call PlayMusic
ld a, $ff
ld [wPokegearRadioMusicPlaying], a
ret
NoRadioName: ; 918a9 (24:58a9)
xor a
ld [hBGMapMode], a
hlcoord 1, 8
lb bc, 3, 18
call ClearBox
hlcoord 0, 12
ld bc, $412
call TextBox
ret
; 918bf
OaksPkmnTalkName: db "OAK's <PK><MN> Talk@"
PokedexShowName: db "#DEX Show@"
PokemonMusicName: db "#MON Music@"
LuckyChannelName: db "Lucky Channel@"
UnknownStationName: db "?????@"
PlacesAndPeopleName: db "Places & People@"
LetsAllSingName: db "Let's All Sing!@"
PokeFluteStationName: db "# FLUTE@"
; 9191c
_TownMap: ; 9191c
ld hl, Options
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [hInMenu]
push af
ld a, $1
ld [hInMenu], a
ld a, [VramState]
push af
xor a
ld [VramState], a
call ClearBGPalettes
call ClearTileMap
call ClearSprites
call DisableLCD
call Pokegear_LoadGFX
callba ClearSpriteAnims
ld a, 8
call SkipMusic
ld a, $e3
ld [rLCDC], a
call TownMap_GetCurrentLandmark
ld [wd002], a
ld [wd003], a
xor a
ld [hBGMapMode], a
call .InitTilemap
call WaitBGMap2
ld a, [wd002]
call PokegearMap_InitPlayerIcon
ld a, [wd003]
call PokegearMap_InitCursor
ld a, c
ld [wd004], a
ld a, b
ld [wd005], a
ld b, SCGB_POKEGEAR_PALS
call GetSGBLayout
call SetPalettes
ld a, [hCGB]
and a
jr z, .dmg
ld a, %11100100
call DmgToCgbObjPal0
call DelayFrame
.dmg
ld a, [wd002]
cp KANTO_LANDMARK
jr nc, .kanto
ld d, KANTO_LANDMARK - 1
ld e, 1
call .loop
jr .resume
.kanto
call TownMap_GetKantoLandmarkLimits
call .loop
.resume
pop af
ld [VramState], a
pop af
ld [hInMenu], a
pop af
ld [Options], a
call ClearBGPalettes
ret
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
ret nz
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .pressed_up
ld a, [hl]
and D_DOWN
jr nz, .pressed_down
.loop2
push de
callba PlaySpriteAnimations
pop de
call DelayFrame
jr .loop
.pressed_up
ld hl, wd003
ld a, [hl]
cp d
jr c, .okay
ld a, e
dec a
ld [hl], a
.okay
inc [hl]
jr .next
.pressed_down
ld hl, wd003
ld a, [hl]
cp e
jr nz, .okay2
ld a, d
inc a
ld [hl], a
.okay2
dec [hl]
.next
push de
ld a, [wd003]
call PokegearMap_UpdateLandmarkName
ld a, [wd004]
ld c, a
ld a, [wd005]
ld b, a
ld a, [wd003]
call PokegearMap_UpdateCursorPosition
pop de
jr .loop2
; 91a04
.InitTilemap: ; 91a04
ld a, [wd002]
cp KANTO_LANDMARK
jr nc, .kanto2
ld e, $0
jr .okay_tilemap
.kanto2
ld e, $1
.okay_tilemap
callba PokegearMap
ld a, $7
ld bc, 6
hlcoord 1, 0
call ByteFill
hlcoord 0, 0
ld [hl], $6
hlcoord 7, 0
ld [hl], $17
hlcoord 7, 1
ld [hl], $16
hlcoord 7, 2
ld [hl], $26
ld a, $7
ld bc, NAME_LENGTH
hlcoord 8, 2
call ByteFill
hlcoord 19, 2
ld [hl], $17
ld a, [wd003]
call PokegearMap_UpdateLandmarkName
callba TownMapPals
ret
; 91a53
PlayRadio: ; 91a53
ld hl, Options
ld a, [hl]
push af
set 4, [hl]
call .PlayStation
ld c, 100
call DelayFrames
.loop
call JoyTextDelay
ld a, [hJoyPressed]
and A_BUTTON | B_BUTTON
jr nz, .stop
ld a, [wPokegearRadioChannelAddr]
ld l, a
ld a, [wPokegearRadioChannelAddr + 1]
ld h, a
ld a, [wPokegearRadioChannelBank]
and a
jr z, .zero
rst FarCall
.zero
call DelayFrame
jr .loop
.stop
pop af
ld [Options], a
call ExitPokegearRadio_HandleMusic
ret
; 91a87
.PlayStation: ; 91a87
ld a, -1
ld [EnemyTurnsTaken], a
ld hl, .StationPointers
ld d, $0
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .jump_return
push de
jp [hl]
.jump_return
push de
hlcoord 0, 12
lb bc, 4, 18
call TextBox
hlcoord 1, 14
ld [hl], $72
pop de
hlcoord 2, 14
call PlaceString
ld h, b
ld l, c
ld [hl], $73
call WaitBGMap
ret
; 91ab9
.StationPointers: ; 91ab9
dw .OakOrPnP
dw LoadStation_OaksPokemonTalk
dw LoadStation_PokedexShow
dw LoadStation_PokemonMusic
dw LoadStation_LuckyChannel
dw LoadStation_UnownRadio
dw LoadStation_PlacesAndPeople
dw LoadStation_LetsAllSing
dw LoadStation_RocketRadio
; 91acb
.OakOrPnP: ; 91acb
call IsInJohto
and a
jr nz, .kanto
call UpdateTime
ld a, [TimeOfDay]
and a
jp z, LoadStation_PokedexShow
jp LoadStation_OaksPokemonTalk
.kanto
jp LoadStation_PlacesAndPeople
; 91ae1
PokegearMap: ; 91ae1
ld a, e
and a
jr nz, .kanto
call LoadTownMapGFX
call FillJohtoMap
ret
.kanto
call LoadTownMapGFX
call FillKantoMap
ret
; 91af3
_FlyMap: ; 91af3
call ClearBGPalettes
call ClearTileMap
call ClearSprites
ld hl, hInMenu
ld a, [hl]
push af
ld [hl], $1
xor a
ld [hBGMapMode], a
callba ClearSpriteAnims
call LoadTownMapGFX
ld de, FlyMapLabelBorderGFX
ld hl, VTiles2 tile $30
lb bc, BANK(FlyMapLabelBorderGFX), 6
call Request1bpp
call FlyMap
call ret_91c8f
ld b, SCGB_POKEGEAR_PALS
call GetSGBLayout
call SetPalettes
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .pressedB
ld a, [hl]
and A_BUTTON
jr nz, .pressedA
call FlyMapScroll
call GetMapCursorCoordinates
callba PlaySpriteAnimations
call DelayFrame
jr .loop
.pressedB
ld a, -1
jr .exit
.pressedA
ld a, [wd002]
ld l, a
ld h, 0
add hl, hl
ld de, Flypoints + 1
add hl, de
ld a, [hl]
.exit
ld [wd002], a
pop af
ld [hInMenu], a
call ClearBGPalettes
ld a, $90
ld [hWY], a
xor a
ld [hBGMapAddress], a
ld a, VBGMap0 / $100
ld [hBGMapAddress + 1], a
ld a, [wd002]
ld e, a
ret
; 91b73
FlyMapScroll: ; 91b73
ld a, [StartFlypoint]
ld e, a
ld a, [EndFlypoint]
ld d, a
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .ScrollNext
ld a, [hl]
and D_DOWN
jr nz, .ScrollPrev
ret
.ScrollNext:
ld hl, wd002
ld a, [hl]
cp d
jr nz, .NotAtEndYet
ld a, e
dec a
ld [hl], a
.NotAtEndYet:
inc [hl]
call CheckIfVisitedFlypoint
jr z, .ScrollNext
jr .Finally
.ScrollPrev:
ld hl, wd002
ld a, [hl]
cp e
jr nz, .NotAtStartYet
ld a, d
inc a
ld [hl], a
.NotAtStartYet:
dec [hl]
call CheckIfVisitedFlypoint
jr z, .ScrollPrev
.Finally:
call TownMapBubble
call WaitBGMap
xor a
ld [hBGMapMode], a
ret
; 91bb5
TownMapBubble: ; 91bb5
; Draw the bubble containing the location text in the town map HUD
; Top-left corner
hlcoord 1, 0
ld a, $30
ld [hli], a
; Top row
ld bc, 16
ld a, " "
call ByteFill
; Top-right corner
ld a, $31
ld [hl], a
hlcoord 1, 1
; Middle row
ld bc, 18
ld a, " "
call ByteFill
; Bottom-left corner
hlcoord 1, 2
ld a, $32
ld [hli], a
; Bottom row
ld bc, 16
ld a, " "
call ByteFill
; Bottom-right corner
ld a, $33
ld [hl], a
; Print "Where?"
hlcoord 2, 0
ld de, .Where
call PlaceString
; Print the name of the default flypoint
call .Name
; Up/down arrows
hlcoord 18, 1
ld [hl], $34
ret
.Where:
db "Where?@"
.Name:
; We need the map location of the default flypoint
ld a, [wd002]
ld l, a
ld h, 0
add hl, hl ; two bytes per flypoint
ld de, Flypoints
add hl, de
ld e, [hl]
callba GetLandmarkName
hlcoord 2, 1
ld de, StringBuffer1
call PlaceString
ret
; 91c17
GetMapCursorCoordinates: ; 91c17
ld a, [wd002]
ld l, a
ld h, $0
add hl, hl
ld de, Flypoints
add hl, de
ld e, [hl]
callba GetLandmarkCoords
ld a, [wd003]
ld c, a
ld a, [wd004]
ld b, a
ld hl, $4
add hl, bc
ld [hl], e
ld hl, $5
add hl, bc
ld [hl], d
ret
; 91c3c
CheckIfVisitedFlypoint: ; 91c3c
; Check if the flypoint loaded in [hl] has been visited yet.
push bc
push de
push hl
ld l, [hl]
ld h, 0
add hl, hl
ld de, Flypoints + 1
add hl, de
ld c, [hl]
call HasVisitedSpawn
pop hl
pop de
pop bc
and a
ret
; 91c50
HasVisitedSpawn: ; 91c50
; Check if spawn point c has been visited.
ld hl, VisitedSpawns
ld b, CHECK_FLAG
ld d, 0
predef FlagPredef
ld a, c
ret
; 91c5e
Flypoints: ; 91c5e
; landmark, spawn point
const_def
flypoint: MACRO
const FLY_\1
db \2, SPAWN_\1
ENDM
; Johto
flypoint NEW_BARK, NEW_BARK_TOWN
flypoint CHERRYGROVE, CHERRYGROVE_CITY
flypoint VIOLET, VIOLET_CITY
flypoint AZALEA, AZALEA_TOWN
flypoint GOLDENROD, GOLDENROD_CITY
flypoint ECRUTEAK, ECRUTEAK_CITY
flypoint OLIVINE, OLIVINE_CITY
flypoint CIANWOOD, CIANWOOD_CITY
flypoint MAHOGANY, MAHOGANY_TOWN
flypoint LAKE, LAKE_OF_RAGE
flypoint BLACKTHORN, BLACKTHORN_CITY
flypoint MT_SILVER, SILVER_CAVE
; Kanto
KANTO_FLYPOINT EQU const_value
flypoint PALLET, PALLET_TOWN
flypoint VIRIDIAN, VIRIDIAN_CITY
flypoint PEWTER, PEWTER_CITY
flypoint CERULEAN, CERULEAN_CITY
flypoint VERMILION, VERMILION_CITY
flypoint ROCK_TUNNEL, ROCK_TUNNEL
flypoint LAVENDER, LAVENDER_TOWN
flypoint CELADON, CELADON_CITY
flypoint SAFFRON, SAFFRON_CITY
flypoint FUCHSIA, FUCHSIA_CITY
flypoint CINNABAR, CINNABAR_ISLAND
flypoint INDIGO, INDIGO_PLATEAU
db -1
; 91c8f
ret_91c8f: ; 91c8f
ret
; 91c90
FlyMap: ; 91c90
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
call GetWorldMapLocation
; If we're not in a valid location, i.e. Pokecenter floor 2F,
; the backup map information is used
cp SPECIAL_MAP
jr nz, .CheckRegion
ld a, [BackupMapGroup]
ld b, a
ld a, [BackupMapNumber]
ld c, a
call GetWorldMapLocation
.CheckRegion:
; The first 46 locations are part of Johto. The rest are in Kanto
cp KANTO_LANDMARK
jr nc, .KantoFlyMap
.JohtoFlyMap:
; Note that .NoKanto should be modified in tandem with this branch
push af
; Start from New Bark Town
ld a, FLY_NEW_BARK
ld [wd002], a
; Flypoints begin at New Bark Town...
ld [StartFlypoint], a
; ..and end at Silver Cave
ld a, FLY_MT_SILVER
ld [EndFlypoint], a
; Fill out the map
call FillJohtoMap
call .MapHud
pop af
call TownMapPlayerIcon
ret
.KantoFlyMap:
; The event that there are no flypoints enabled in a map is not
; accounted for. As a result, if you attempt to select a flypoint
; when there are none enabled, the game will crash. Additionally,
; the flypoint selection has a default starting point that
; can be flown to even if none are enabled
; To prevent both of these things from happening when the player
; enters Kanto, fly access is restricted until Indigo Plateau is
; visited and its flypoint enabled
push af
ld c, SPAWN_INDIGO
call HasVisitedSpawn
and a
jr z, .NoKanto
; Kanto's map is only loaded if we've visited Indigo Plateau
; Flypoints begin at Pallet Town...
ld a, FLY_PALLET
ld [StartFlypoint], a
; ...and end at Indigo Plateau
ld a, FLY_INDIGO
ld [EndFlypoint], a
; Because Indigo Plateau is the first flypoint the player
; visits, it's made the default flypoint
ld [wd002], a
; Fill out the map
call FillKantoMap
call .MapHud
pop af
call TownMapPlayerIcon
ret
.NoKanto:
; If Indigo Plateau hasn't been visited, we use Johto's map instead
; Start from New Bark Town
ld a, FLY_NEW_BARK
ld [wd002], a
; Flypoints begin at New Bark Town...
ld [StartFlypoint], a
; ..and end at Silver Cave
ld a, FLY_MT_SILVER
ld [EndFlypoint], a
call FillJohtoMap
pop af
.MapHud:
call TownMapBubble
call TownMapPals
hlbgcoord 0, 0 ; BG Map 0
call TownMapBGUpdate
call TownMapMon
ld a, c
ld [wd003], a
ld a, b
ld [wd004], a
ret
; 91d11
_Area: ; 91d11
; e: Current landmark
ld a, [wd002]
push af
ld a, [wd003]
push af
ld a, e
ld [wd002], a
call ClearSprites
xor a
ld [hBGMapMode], a
ld a, $1
ld [hInMenu], a
ld de, PokedexNestIconGFX
ld hl, VTiles0 tile $7f
lb bc, BANK(PokedexNestIconGFX), 1
call Request2bpp
call .GetPlayerOrFastShipIcon
ld hl, VTiles0 tile $78
ld c, 4
call Request2bpp
call LoadTownMapGFX
call FillKantoMap
call .PlaceString_MonsNest
call TownMapPals
hlbgcoord 0, 0, VBGMap1
call TownMapBGUpdate
call FillJohtoMap
call .PlaceString_MonsNest
call TownMapPals
hlbgcoord 0, 0
call TownMapBGUpdate
ld b, SCGB_POKEGEAR_PALS
call GetSGBLayout
call SetPalettes
xor a
ld [hBGMapMode], a
xor a ; Johto
call .GetAndPlaceNest
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and A_BUTTON | B_BUTTON
jr nz, .a_b
ld a, [hJoypadDown]
and SELECT
jr nz, .select
call .LeftRightInput
call .BlinkNestIcons
jr .next
.select
call .HideNestsShowPlayer
.next
call DelayFrame
jr .loop
.a_b
call ClearSprites
pop af
ld [wd003], a
pop af
ld [wd002], a
ret
; 91d9b
.LeftRightInput: ; 91d9b
ld a, [hl]
and D_LEFT
jr nz, .left
ld a, [hl]
and D_RIGHT
jr nz, .right
ret
.left
ld a, [hWY]
cp $90
ret z
call ClearSprites
ld a, $90
ld [hWY], a
xor a ; Johto
call .GetAndPlaceNest
ret
.right
ld a, [StatusFlags]
bit 6, a ; hall of fame
ret z
ld a, [hWY]
and a
ret z
call ClearSprites
xor a
ld [hWY], a
ld a, 1 ; Kanto
call .GetAndPlaceNest
ret
; 91dcd
.BlinkNestIcons: ; 91dcd
ld a, [hVBlankCounter]
ld e, a
and $f
ret nz
ld a, e
and $10
jr nz, .copy_sprites
call ClearSprites
ret
.copy_sprites
hlcoord 0, 0
ld de, Sprites
ld bc, SpritesEnd - Sprites
call CopyBytes
ret
; 91de9
.PlaceString_MonsNest: ; 91de9
hlcoord 0, 0
ld bc, SCREEN_WIDTH
ld a, " "
call ByteFill
hlcoord 0, 1
ld a, $6
ld [hli], a
ld bc, SCREEN_WIDTH - 2
ld a, $7
call ByteFill
ld [hl], $17
call GetPokemonName
hlcoord 2, 0
call PlaceString
ld h, b
ld l, c
ld de, .String_SNest
call PlaceString
ret
; 91e16
.String_SNest:
db "'S NEST@"
; 91e1e
.GetAndPlaceNest: ; 91e1e
ld [wd003], a
ld e, a
callba FindNest ; load nest landmarks into TileMap[0,0]
decoord 0, 0
ld hl, Sprites
.nestloop
ld a, [de]
and a
jr z, .done_nest
push de
ld e, a
push hl
callba GetLandmarkCoords
pop hl
; load into OAM
ld a, d
sub 4
ld [hli], a
ld a, e
sub 4
ld [hli], a
ld a, $7f ; nest icon in this context
ld [hli], a
xor a
ld [hli], a
; next
pop de
inc de
jr .nestloop
.done_nest
ld hl, Sprites
decoord 0, 0
ld bc, SpritesEnd - Sprites
call CopyBytes
ret
; 91e5a
.HideNestsShowPlayer: ; 91e5a
call .CheckPlayerLocation
ret c
ld a, [wd002]
ld e, a
callba GetLandmarkCoords
ld c, e
ld b, d
ld de, .PlayerOAM
ld hl, Sprites
.ShowPlayerLoop:
ld a, [de]
cp $80
jr z, .clear_oam
add b
ld [hli], a
inc de
ld a, [de]
add c
ld [hli], a
inc de
ld a, [de]
add $78 ; where the player's sprite is loaded
ld [hli], a
inc de
push bc
ld c, 0 ; RED
ld a, [PlayerGender]
bit 0, a
jr z, .got_gender
inc c ; BLUE
.got_gender
ld a, c
ld [hli], a
pop bc
jr .ShowPlayerLoop
.clear_oam
ld hl, Sprites + 4 * 4
ld bc, SpritesEnd - (Sprites + 4 * 4)
xor a
call ByteFill
ret
; 91e9c
.PlayerOAM: ; 91e9c
db -1 * 8, -1 * 8, 0 ; top left
db -1 * 8, 0 * 8, 1 ; top right
db 0 * 8, -1 * 8, 2 ; bottom left
db 0 * 8, 0 * 8, 3 ; bottom right
db $80 ; terminator
; 91ea9
.CheckPlayerLocation: ; 91ea9
; Don't show the player's sprite if you're
; not in the same region as what's currently
; on the screen.
ld a, [wd002]
cp FAST_SHIP
jr z, .johto
cp KANTO_LANDMARK
jr c, .johto
.kanto
ld a, [wd003]
and a
jr z, .clear
jr .ok
.johto
ld a, [wd003]
and a
jr nz, .clear
.ok
and a
ret
.clear
ld hl, Sprites
ld bc, SpritesEnd - Sprites
xor a
call ByteFill
scf
ret
; 91ed0
.GetPlayerOrFastShipIcon: ; 91ed0
ld a, [wd002]
cp FAST_SHIP
jr z, .FastShip
callba GetPlayerIcon
ret
.FastShip:
ld de, FastShipGFX
ld b, BANK(FastShipGFX)
ret
; 91ee4
TownMapBGUpdate: ; 91ee4
; Update BG Map tiles and attributes
; BG Map address
ld a, l
ld [hBGMapAddress], a
ld a, h
ld [hBGMapAddress + 1], a
; Only update palettes on CGB
ld a, [hCGB]
and a
jr z, .tiles
; BG Map mode 2 (palettes)
ld a, 2
ld [hBGMapMode], a
; The BG Map is updated in thirds, so we wait
; 3 frames to update the whole screen's palettes.
ld c, 3
call DelayFrames
.tiles
; Update BG Map tiles
call WaitBGMap
; Turn off BG Map update
xor a
ld [hBGMapMode], a
ret
; 91eff
FillJohtoMap: ; 91eff
ld de, JohtoMap
jr FillTownMap
FillKantoMap: ; 91f04
ld de, KantoMap
FillTownMap: ; 91f07
hlcoord 0, 0
.loop
ld a, [de]
cp -1
ret z
ld a, [de]
ld [hli], a
inc de
jr .loop
; 91f13
TownMapPals: ; 91f13
; Assign palettes based on tile ids
hlcoord 0, 0
decoord 0, 0, AttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
.loop
; Current tile
ld a, [hli]
push hl
; HP/borders use palette 0
cp $60
jr nc, .pal0
; The palette data is condensed to nybbles,
; least-significant first.
ld hl, .PalMap
srl a
jr c, .odd
; Even-numbered tile ids take the bottom nybble...
add l
ld l, a
ld a, h
adc 0
ld h, a
ld a, [hl]
and %111
jr .update
.odd
; ...and odd ids take the top.
add l
ld l, a
ld a, h
adc 0
ld h, a
ld a, [hl]
swap a
and %111
jr .update
.pal0
xor a
.update
pop hl
ld [de], a
inc de
dec bc
ld a, b
or c
jr nz, .loop
ret
.PalMap:
townmappals: MACRO
rept _NARG / 2
dn \2, \1
shift
shift
endr
endm
townmappals 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 3, 1, 4, 5, 4, 5
townmappals 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0
townmappals 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
townmappals 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0
townmappals 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0
townmappals 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0
; 91f7b
TownMapMon: ; 91f7b
; Draw the FlyMon icon at town map location in
; Get FlyMon species
ld a, [CurPartyMon]
ld hl, PartySpecies
ld e, a
ld d, $0
add hl, de
ld a, [hl]
ld [wd265], a
; Get FlyMon icon
ld e, 8 ; starting tile in VRAM
callba GetSpeciesIcon
; Animation/palette
depixel 0, 0
ld a, SPRITE_ANIM_INDEX_00
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $8
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL
ret
; 91fa6
TownMapPlayerIcon: ; 91fa6
; Draw the player icon at town map location in a
push af
callba GetPlayerIcon
; Standing icon
ld hl, VTiles0 tile $10
ld c, 4 ; # tiles
call Request2bpp
; Walking icon
ld hl, $c0
add hl, de
ld d, h
ld e, l
ld hl, VTiles0 tile $14
ld c, 4 ; # tiles
ld a, BANK(ChrisSpriteGFX) ; does nothing
call Request2bpp
; Animation/palette
depixel 0, 0
ld b, SPRITE_ANIM_INDEX_RED_WALK ; Male
ld a, [PlayerGender]
bit 0, a
jr z, .got_gender
ld b, SPRITE_ANIM_INDEX_BLUE_WALK ; Female
.got_gender
ld a, b
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $10
pop af
ld e, a
push bc
callba GetLandmarkCoords
pop bc
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], e
ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld [hl], d
ret
; 0x91ff2
LoadTownMapGFX: ; 91ff2
ld hl, TownMapGFX
ld de, VTiles2
lb bc, BANK(TownMapGFX), $30
call DecompressRequest2bpp
ret
; 91fff
JohtoMap: ; 91fff
INCBIN "gfx/misc/johto.bin"
; 92168
KantoMap: ; 92168
INCBIN "gfx/misc/kanto.bin"
; 922d1
PokedexNestIconGFX: ; 922d1
INCBIN "gfx/pokegear/dexmap_nest_icon.2bpp"
FlyMapLabelBorderGFX: ; 922e1
INCBIN "gfx/pokegear/flymap_label_border.2bpp"
; XXX
xor a
ld [wd002], a
call ClearBGPalettes
call ClearTileMap
call ClearSprites
ld hl, hInMenu
ld a, [hl]
push af
ld [hl], $1
xor a
ld [hBGMapMode], a
callba ClearSpriteAnims
call LoadTownMapGFX
ld de, FlyMapLabelBorderGFX
ld hl, VTiles2 tile $30
lb bc, BANK(FlyMapLabelBorderGFX), 6
call Request1bpp
call FillKantoMap
call TownMapBubble
call TownMapPals
hlbgcoord 0, 0, VBGMap1
call TownMapBGUpdate
call FillJohtoMap
call TownMapBubble
call TownMapPals
hlbgcoord 0, 0
call TownMapBGUpdate
call TownMapMon
ld a, c
ld [wd003], a
ld a, b
ld [wd004], a
ld b, SCGB_POKEGEAR_PALS
call GetSGBLayout
call SetPalettes
.loop
call JoyTextDelay
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .pressedB
ld a, [hl]
and A_BUTTON
jr nz, .pressedA
call .HandleDPad
call GetMapCursorCoordinates
callba PlaySpriteAnimations
call DelayFrame
jr .loop
.pressedB
ld a, -1
jr .finished_a_b
.pressedA
ld a, [wd002]
ld l, a
ld h, 0
add hl, hl
ld de, Flypoints + 1
add hl, de
ld a, [hl]
.finished_a_b
ld [wd002], a
pop af
ld [hInMenu], a
call ClearBGPalettes
ld a, $90
ld [hWY], a
xor a
ld [hBGMapAddress], a
ld a, VBGMap0 / $100
ld [hBGMapAddress + 1], a
ld a, [wd002]
ld e, a
ret
; 923b8
.HandleDPad: ; 923b8
ld hl, hJoyLast
ld a, [hl]
and D_DOWN | D_RIGHT
jr nz, .down_right
ld a, [hl]
and D_UP | D_LEFT
jr nz, .up_left
ret
.down_right
ld hl, wd002
ld a, [hl]
cp FLY_INDIGO
jr c, .okay_dr
ld [hl], -1
.okay_dr
inc [hl]
jr .continue
.up_left
ld hl, wd002
ld a, [hl]
and a
jr nz, .okay_ul
ld [hl], FLY_INDIGO + 1
.okay_ul
dec [hl]
.continue
ld a, [wd002]
cp KANTO_FLYPOINT
jr c, .johto
call FillKantoMap
xor a
ld b, $9c
jr .finish
.johto
call FillJohtoMap
ld a, $90
ld b, $98
.finish
ld [hWY], a
ld a, b
ld [hBGMapAddress + 1], a
call TownMapBubble
call WaitBGMap
xor a
ld [hBGMapMode], a
ret
; 92402
|