summaryrefslogtreecommitdiff
path: root/engine/color.asm
blob: fbbc45144452a879e2b7aa00a92787f08417633a (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
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

INCLUDE "predef/sgb.asm"


CheckShininess: ; 8a68
; Check if a mon is shiny by DVs at bc.
; Return carry if shiny.

	ld l, c
	ld h, b

; Attack
	ld a, [hl]
	and %0010 << 4
	jr z, .NotShiny

; Defense
	ld a, [hli]
	and %1111
	cp  %1010
	jr nz, .NotShiny

; Speed
	ld a, [hl]
	and %1111 << 4
	cp  %1010 << 4
	jr nz, .NotShiny

; Special
	ld a, [hl]
	and %1111
	cp  %1010
	jr nz, .NotShiny

.Shiny
	scf
	ret

.NotShiny
	and a
	ret
; 8a88


CheckContestMon: ; 8a88
; Check a mon's DVs at hl in the bug catching contest.
; Return carry if its DVs are good enough to place in the contest.

; Attack
	ld a, [hl]
	cp 10 << 4
	jr c, .Bad

; Defense
	ld a, [hli]
	and $f
	cp 10
	jr c, .Bad

; Speed
	ld a, [hl]
	cp 10 << 4
	jr c, .Bad

; Special
	ld a, [hl]
	and $f
	cp 10
	jr c, .Bad

.Good
	scf
	ret

.Bad
	and a
	ret
; 8aa4


Function8aa4: ; 8aa4
	push de
	push bc
	ld hl, PalPacket_9ce6
	ld de, $cda9
	ld bc, $0010
	call CopyBytes
	pop bc
	pop de
	ld a, c
	ld [$cdac], a
	ld a, b
	ld [$cdad], a
	ld a, e
	ld [$cdae], a
	ld a, d
	ld [$cdaf], a
	ld hl, $cda9
	call Function9809
	ld hl, BlkPacket_9a86
	call Function9809
	ret
; 8ad1


Function8ad1: ; 8ad1
	ld hl, PalPacket_9c56 + 1
	call Function9610
	call Function971a
	call Function9699
	ret
; 8ade

Function8ade: ; 8ade
	ld hl, $cd9b
	ld a, [$cda9]
	ld e, a
	ld d, $0
	add hl, de
	ld e, l
	ld d, h
	ld a, [de]
	and a
	ld e, $5
	jr z, .asm_8af7
	dec a
	ld e, $a
	jr z, .asm_8af7
	ld e, $f

.asm_8af7
	push de
	ld hl, $cdb3
	ld bc, $0006
	ld a, [$cda9]
	call AddNTimes
	pop de
	ld [hl], e
	ret
; 8b07

Function8b07: ; 8b07
	call CheckCGB
	ret z
	ld hl, Palette8b2f
	ld de, $d000
	ld bc, $0008
	ld a, $5
	call FarCopyWRAM

	ld hl, Palette8b37
	ld de, MartPointer
	ld bc, $0008
	ld a, $5
	call FarCopyWRAM

	call Function96a4
	ld a, $1
	ld [hCGBPalUpdate], a
	ret
; 8b2f

Palette8b2f: ; 8b2f
	RGB 31, 31, 31
	RGB 18, 23, 31
	RGB 15, 20, 31
	RGB 00, 00, 00
; 8b37

Palette8b37: ; 8b37
	RGB 31, 31, 31
	RGB 31, 31, 12
	RGB 08, 16, 28
	RGB 00, 00, 00
; 8b3f

Function8b3f: ; 8b3f
	call CheckCGB
	ret nz
	ld a, [hSGB]
	and a
	ret z
	ld hl, BlkPacket_9a86
	jp Function9809
; 8b4d

Function8b4d: ; 8b4d
	call CheckCGB
	jr nz, .asm_8b5c
	ld a, [hSGB]
	and a
	ret z
	ld hl, $5c26
	jp Function9809

.asm_8b5c
	ld de, Unkn2Pals
	ld a, $3b
	call Function9625
	jp Function9630
; 8b67

Function8b67: ; 8b67
	call CheckCGB
	jr nz, .asm_8b76
	ld a, [hSGB]
	and a
	ret z
	ld hl, $5c36
	jp Function9809

.asm_8b76
	ld de, Unkn2Pals
	ld a, $3c
	call Function9625
	jp Function9630
; 8b81

Function8b81: ; 8b81
	call CheckCGB
	jr nz, .asm_8bb2
	ld a, [hSGB]
	and a
	ret z
	ld a, c
	push af
	ld hl, PalPacket_9ce6
	ld de, $cda9
	ld bc, $0010
	call CopyBytes
	pop af
	call Function9775
	ld a, [hli]
	ld [$cdac], a
	ld a, [hli]
	ld [$cdad], a
	ld a, [hli]
	ld [$cdae], a
	ld a, [hl]
	ld [$cdaf], a
	ld hl, $cda9
	jp Function9809

.asm_8bb2
	ld de, Unkn2Pals
	ld a, c
	call Function9775
	call Function9643
	ret
; 8bbd

Function8bbd: ; 8bbd
	ld a, [TrainerClass]
	call Function976b
	ld a, e
	jr .asm_8bd7

	ld a, [CurPartySpecies]
	call Function97ee
	ld a, e
	bit 7, a
	jr z, .asm_8bd7
	and $7f
	inc hl
	inc hl
	inc hl
	inc hl

.asm_8bd7
	push hl
	ld hl, Unkn1Pals
	ld de, $0008
.asm_8bde
	and a
	jr z, .asm_8be5
	add hl, de
	dec a
	jr .asm_8bde

.asm_8be5
	ld e, l
	ld d, h
	pop hl
	call Function9643
	ret
; 8bec

Function8bec: ; 8bec
	ld a, [hCGB]
	and a
	jr nz, .asm_8bf7
	ld hl, PlayerLightScreenCount
	jp Function9809

.asm_8bf7
	ld a, [EnemyLightScreenCount]
	ld c, a
	ld a, [EnemyReflectCount]
	ld hl, AttrMap
	ld de, $0014
.asm_8c04
	and a
	jr z, .asm_8c0b
	add hl, de
	dec a
	jr .asm_8c04

.asm_8c0b
	ld b, $0
	add hl, bc
	ld bc, $0604
	ld a, [$c705]
	and $3
	call Function9663
	call Function323d
	ret
; 8c1d

Function8c1d: ; 8c1d
	call CheckCGB
	ret z
	ld a, e
	and a
	jr z, .asm_8c2d
	ld a, [CurPartySpecies]
	call Function9775
	jr .asm_8c33

.asm_8c2d
	ld a, [TrainerClass]
	call Function976b

.asm_8c33
	ld de, Unkn1Pals
	call Function9643
	call Function9699
	call Function96b3
	call Function96a4
	ret
; 8c43

Function8c43: ; 8c43
	ld a, [$d10a]
	and a
	jr z, .asm_8c52
	cp $1
	jr z, .asm_8c57
	cp $2
	jr z, .asm_8c70
	ret

.asm_8c52
	ld de, $d092
	jr .asm_8c5a

.asm_8c57
	ld de, $d09a

.asm_8c5a
	ld l, c
	ld h, $0
	add hl, hl
	add hl, hl
	ld bc, Palettes_a8be
	add hl, bc
	ld bc, $0004
	ld a, $5
	call FarCopyWRAM
	ld a, $1
	ld [hCGBPalUpdate], a
	ret

.asm_8c70
	ld e, c
	inc e
	ld hl, $cdf8
	ld bc, $0028
	ld a, [CurPartyMon]
.asm_8c7b
	and a
	jr z, .asm_8c82
	add hl, bc
	dec a
	jr .asm_8c7b

.asm_8c82
	ld bc, $0208
	ld a, e
	call Function9663
	ret
; 8c8a

Function8c8a: ; 8c8a
	call CheckCGB
	ret z
	ld hl, Unknown_8f6a
	ld b, 0
	dec c
	add hl, bc
	add hl, bc
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld a, [hli]
	ld [Unkn1Pals], a
	ld [$d010], a
	ld a, [hl]
	ld [$d001], a
	ld [$d011], a
	pop af
	ld [rSVBK], a
	call Function96a4
	ld a, $1
	ret
; 8cb4

Function8cb4: ; 8cb4
	ld l, e
	ld h, 0
	add hl, hl
	add hl, hl
	add hl, hl
	ld de, Palettes_8d05
	add hl, de
	call CheckCGB
	jr nz, .asm_8cf0
	push hl
	ld hl, PalPacket_9ce6
	ld de, $cda9
	ld bc, $0010
	call CopyBytes
	pop hl
	inc hl
	inc hl
	ld a, [hli]
	ld [$cdac], a
	ld a, [hli]
	ld [$cdad], a
	ld a, [hli]
	ld [$cdae], a
	ld a, [hli]
	ld [$cdaf], a
	ld hl, $cda9
	call Function9809
	ld hl, BlkPacket_9a86
	call Function9809
	ret

.asm_8cf0
	ld de, $d000
	ld bc, $0008
	ld a, $5
	call FarCopyWRAM
	call Function96a4
	call Function9699
	call Function96b3
	ret
; 8d05

Palettes_8d05: ; 8d05
	RGB 20, 31, 11
	RGB 31, 19, 00
	RGB 31, 10, 09
	RGB 00, 00, 00

	RGB 15, 20, 31
	RGB 30, 26, 00
	RGB 31, 12, 00
	RGB 00, 00, 00

	RGB 24, 17, 31
	RGB 30, 26, 00
	RGB 08, 11, 31
	RGB 00, 00, 00

	RGB 31, 25, 17
	RGB 31, 18, 04
	RGB 28, 12, 05
	RGB 00, 00, 00

	RGB 19, 26, 31
	RGB 31, 05, 08
	RGB 31, 09, 31
	RGB 00, 00, 00

	RGB 31, 19, 28
	RGB 31, 21, 00
	RGB 12, 22, 00
	RGB 00, 00, 00

	RGB 19, 17, 23
	RGB 30, 26, 00
	RGB 31, 12, 00
	RGB 00, 00, 00

	RGB 07, 26, 31
	RGB 26, 26, 27
	RGB 31, 11, 11
	RGB 00, 00, 00

	RGB 21, 31, 21
	RGB 30, 26, 00
	RGB 31, 12, 00
	RGB 00, 00, 00

	RGB 07, 26, 31
	RGB 31, 31, 00
	RGB 00, 21, 00
	RGB 00, 00, 00
; 8d55

INCLUDE "predef/cgb.asm"


Function95f0: ; 95f0
	ld hl, Palette_9608
	ld de, Unkn1Pals
	ld bc, $0008
	ld a, $5
	call FarCopyWRAM
	call Function96a4
	call Function9699
	call Function96b3
	ret
; 9608

Palette_9608: ; 9608
	RGB 31, 31, 31
	RGB 09, 31, 31
	RGB 10, 12, 31
	RGB 00, 03, 19
; 9610


Function9610: ; 9610
	ld de, $d000
	ld c, $4

Function9615: ; 9615
	push bc
	ld a, [hli]
	push hl
	call Function9625
	call Function9630
	pop hl
	inc hl
	pop bc
	dec c
	jr nz, Function9615
	ret
; 9625

Function9625: ; 9625
	ld l, a
	ld h, $0
	add hl, hl
	add hl, hl
	add hl, hl
	ld bc, Palettes_9df6
	add hl, bc
	ret
; 9630

Function9630: ; 9630
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld c, $8
.asm_9639
	ld a, [hli]
	ld [de], a
	inc de
	dec c
	jr nz, .asm_9639
	pop af
	ld [rSVBK], a
	ret
; 9643

Function9643: ; 9643
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld a, $ff
	ld [de], a
	inc de
	ld a, $7f
	ld [de], a
	inc de
	ld c, $4
.asm_9654
	ld a, [hli]
	ld [de], a
	inc de
	dec c
	jr nz, .asm_9654
	xor a
	ld [de], a
	inc de
	ld [de], a
	inc de
	pop af
	ld [rSVBK], a
	ret
; 9663

Function9663: ; 9663
.asm_9663
	push bc
	push hl
.asm_9665
	ld [hli], a
	dec c
	jr nz, .asm_9665
	pop hl
	ld bc, $0014
	add hl, bc
	pop bc
	dec b
	jr nz, .asm_9663
	ret
; 9673

Function9673: ; 9673
	push af
	push bc
	push de
	push hl
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld hl, $d000
	ld c, $8
.asm_9683
	ld a, $ff
	ld [hli], a
	ld [hli], a
	ld [hli], a
	ld [hli], a
	xor a
	ld [hli], a
	ld [hli], a
	ld [hli], a
	ld [hli], a
	dec c
	jr nz, .asm_9683
	pop af
	ld [rSVBK], a
	pop hl
	pop de
	pop bc
	pop af
	ret
; 9699


Function9699: ; 9699
	ld hl, AttrMap
	ld bc, $0168
	xor a
	call ByteFill
	ret
; 96a4

Function96a4: ; 96a4
	ld hl, $d000
	ld de, $d080
	ld bc, $0080
	ld a, $5
	call FarCopyWRAM
	ret
; 96b3

Function96b3: ; 96b3
	ld a, [rLCDC]
	bit 7, a
	jr z, .asm_96d0
	ld a, [hBGMapMode]
	push af
	ld a, $2
	ld [hBGMapMode], a
	call DelayFrame
	call DelayFrame
	call DelayFrame
	call DelayFrame
	pop af
	ld [hBGMapMode], a
	ret

.asm_96d0
	ld hl, AttrMap
	ld de, VBGMap0
	ld b, $12
	ld a, $1
	ld [rVBK], a
.asm_96dc
	ld c, $14
.asm_96de
	ld a, [hli]
	ld [de], a
	inc de
	dec c
	jr nz, .asm_96de
	ld a, $c
	add e
	jr nc, .asm_96ea
	inc d

.asm_96ea
	ld e, a
	dec b
	jr nz, .asm_96dc
	ld a, $0
	ld [rVBK], a
	ret
; 96f3

Function96f3: ; 96f3
	ld hl, $cd9b
	ld a, [$cda9]
	ld e, a
	ld d, $0
	add hl, de
	ld e, l
	ld d, h
	ld a, [de]
	inc a
	ld e, a
	ld hl, $ce0c
	ld bc, $0028
	ld a, [$cda9]
.asm_970b
	and a
	jr z, .asm_9712
	add hl, bc
	dec a
	jr .asm_970b

.asm_9712
	ld bc, $0208
	ld a, e
	call Function9663
	ret
; 971a


Function971a: ; 971a
	ld hl, Palettes_b681
	ld de, Unkn2Pals
	ld bc, $0010
	ld a, $5
	call FarCopyWRAM
	ret
; 9729

Function9729: ; 9729
	push de
	callba Function3da85
	ld c, l
	ld b, h
	ld a, [TempBattleMonSpecies]
	call Function974b
	pop de
	ret
; 973a

Function973a: ; 973a
	push de
	callba Function3da97
	ld c, l
	ld b, h
	ld a, [TempEnemyMonSpecies]
	call Function9764
	pop de
	ret
; 974b

Function974b: ; 974b
	and a
	jp nz, Function97f9
	ld a, [$d45b]
	bit 2, a
	jr nz, .asm_9760
	ld a, [PlayerGender]
	and a
	jr z, .asm_9760
	ld hl, KrisPalette
	ret

.asm_9760
	ld hl, PlayerPalette
	ret
; 9764

Function9764: ; 9764
	and a
	jp nz, Function97f9
	ld a, [TrainerClass]

Function976b: ; 976b
	ld l, a
	ld h, 0
	add hl, hl
	add hl, hl
	ld bc, TrainerPalettes
	add hl, bc
	ret
; 9775

Function9775: ; 9775
	call Function97ee
	ret
; 9779

Function9779: ; 9779
	ret
; 977a

Function977a: ; 977a
	call CheckCGB
	ret z
	ld hl, Palettes_979c
	ld a, $90
	ld [rOBPI], a
	ld c, $30
.asm_9787
	ld a, [hli]
	ld [rOBPD], a
	dec c
	jr nz, .asm_9787
	ld hl, Palettes_979c
	ld de, $d050
	ld bc, $0010
	ld a, $5
	call FarCopyWRAM
	ret
; 979c

Palettes_979c: ; 979c
	RGB 31, 31, 31
	RGB 25, 25, 25
	RGB 13, 13, 13
	RGB 00, 00, 00
	RGB 31, 31, 31
	RGB 31, 31, 07
	RGB 31, 16, 01
	RGB 00, 00, 00
	RGB 31, 31, 31
	RGB 31, 19, 24
	RGB 30, 10, 06
	RGB 00, 00, 00
	RGB 31, 31, 31
	RGB 12, 25, 01
	RGB 05, 14, 00
	RGB 00, 00, 00
	RGB 31, 31, 31
	RGB 08, 12, 31
	RGB 01, 04, 31
	RGB 00, 00, 00
	RGB 31, 31, 31
	RGB 24, 18, 07
	RGB 20, 15, 03
	RGB 00, 00, 00
; 97cc

Function97cc: ; 97cc
	call CheckCGB
	ret z
	ld a, $90
	ld [rOBPI], a
	ld a, $1c
	call Function9625
	call Function97e5
	ld a, $21
	call Function9625
	call Function97e5
	ret
; 97e5

Function97e5: ; 97e5
	ld c, $8
.asm_97e7
	ld a, [hli]
	ld [rOBPD], a
	dec c
	jr nz, .asm_97e7
	ret
; 97ee

Function97ee: ; 97ee
	ld l, a
	ld h, $0
	add hl, hl
	add hl, hl
	add hl, hl
	ld bc, $68ce
	add hl, bc
	ret
; 97f9

Function97f9: ; 97f9
	push bc
	call Function97ee
	pop bc
	push hl
	call CheckShininess
	pop hl
	ret nc
	inc hl
	inc hl
	inc hl
	inc hl
	ret
; 9809

Function9809: ; 9809
	ld a, [$cfbe]
	push af
	set 7, a
	ld [$cfbe], a
	call Function981a
	pop af
	ld [$cfbe], a
	ret
; 981a

Function981a: ; 981a
	ld a, [hl]
	and $7
	ret z
	ld b, a
.asm_981f
	push bc
	xor a
	ld [rJOYP], a
	ld a, $30
	ld [rJOYP], a
	ld b, $10
.asm_9829
	ld e, $8
	ld a, [hli]
	ld d, a
.asm_982d
	bit 0, d
	ld a, $10
	jr nz, .asm_9835
	ld a, $20

.asm_9835
	ld [rJOYP], a
	ld a, $30
	ld [rJOYP], a
	rr d
	dec e
	jr nz, .asm_982d
	dec b
	jr nz, .asm_9829
	ld a, $20
	ld [rJOYP], a
	ld a, $30
	ld [rJOYP], a
	call Function9a7a
	pop bc
	dec b
	jr nz, .asm_981f
	ret
; 9853

Function9853: ; 9853
	call CheckCGB
	ret nz
	di
	ld a, [$cfbe]
	push af
	set 7, a
	ld [$cfbe], a
	xor a
	ld [rJOYP], a
	ld [hSGB], a
	call Function994a
	jr nc, .asm_988a
	ld a, $1
	ld [hSGB], a
	call Function98eb
	call Function99b4
	call Function9a7a
	call Function993f
	call Function992c
	call Function9a7a
	call Function993f
	ld hl, PalPacket_9d66
	call Function981a

.asm_988a
	pop af
	ld [$cfbe], a
	ei
	ret
; 9890


Function9890:: ; 9890
	call CheckCGB
	ret z
	ld a, $1
	ld [rVBK], a
	ld hl, VTiles0
	ld bc, $2000
	xor a
	call ByteFill
	ld a, $0
	ld [rVBK], a
	ld a, $80
	ld [rBGPI], a
	ld c, $20
.asm_98ac
	ld a, $ff
	ld [rBGPD], a
	ld a, $7f
	ld [rBGPD], a
	dec c
	jr nz, .asm_98ac
	ld a, $80
	ld [rOBPI], a
	ld c, $20
.asm_98bd
	ld a, $ff
	ld [rOBPD], a
	ld a, $7f
	ld [rOBPD], a
	dec c
	jr nz, .asm_98bd
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld hl, $d000
	call Function98df
	ld hl, $d080
	call Function98df
	pop af
	ld [rSVBK], a
	ret
; 98df

Function98df: ; 98df
	ld c, $40
.asm_98e1
	ld a, $ff
	ld [hli], a
	ld a, $7f
	ld [hli], a
	dec c
	jr nz, .asm_98e1
	ret
; 98eb

Function98eb: ; 98eb
	ld hl, Unknown_98ff
	ld c, $9
.asm_98f0
	push bc
	ld a, [hli]
	push hl
	ld h, [hl]
	ld l, a
	call Function981a
	pop hl
	inc hl
	pop bc
	dec c
	jr nz, .asm_98f0
	ret
; 98ff

Unknown_98ff: ; 98ff
	dw PalPacket_9d56
	dw PalPacket_9d76
	dw PalPacket_9d86
	dw PalPacket_9d96
	dw PalPacket_9da6
	dw PalPacket_9db6
	dw PalPacket_9dc6
	dw PalPacket_9dd6
	dw PalPacket_9de6
; 9911

Function9911: ; 9911
	di
	xor a
	ld [rJOYP], a
	ld hl, PalPacket_9d56
	call Function981a
	call Function992c
	call Function9a7a
	call Function993f
	ld hl, PalPacket_9d66
	call Function981a
	ei
	ret
; 992c

Function992c: ; 992c
	call Function9938
	push de
	call Function9a24
	pop hl
	call Function99d8
	ret
; 9938

Function9938: ; 9938
	ld hl, SGBBorder
	ld de, SGBBorderMap
	ret
; 993f

Function993f: ; 993f
	ld hl, VTiles0
	ld bc, $2000
	xor a
	call ByteFill
	ret
; 994a

Function994a: ; 994a
	ld hl, PalPacket_9d26
	call Function981a
	call Function9a7a
	ld a, [rJOYP]
	and $3
	cp $3
	jr nz, .asm_99a6
	ld a, $20
	ld [rJOYP], a
	ld a, [rJOYP]
	ld a, [rJOYP]
	call Function9a7a
	call Function9a7a
	ld a, $30
	ld [rJOYP], a
	call Function9a7a
	call Function9a7a
	ld a, $10
	ld [rJOYP], a
	ld a, [rJOYP]
	ld a, [rJOYP]
	ld a, [rJOYP]
	ld a, [rJOYP]
	ld a, [rJOYP]
	ld a, [rJOYP]
	call Function9a7a
	call Function9a7a
	ld a, $30
	ld [rJOYP], a
	ld a, [rJOYP]
	ld a, [rJOYP]
	ld a, [rJOYP]
	call Function9a7a
	call Function9a7a
	ld a, [rJOYP]
	and $3
	cp $3
	jr nz, .asm_99a6
	call Function99ab
	and a
	ret

.asm_99a6
	call Function99ab
	scf
	ret
; 99ab

Function99ab: ; 99ab
	ld hl, PalPacket_9d16
	call Function981a
	jp Function9a7a
; 99b4

Function99b4: ; 99b4
	call DisableLCD
	ld a, $e4
	ld [rBGP], a
	ld hl, Palettes_9df6
	ld de, VTiles1
	ld bc, $1000
	call CopyData
	call DrawDefaultTiles
	ld a, $e3
	ld [rLCDC], a
	ld hl, PalPacket_9d06
	call Function981a
	xor a
	ld [rBGP], a
	ret
; 99d8

Function99d8: ; 99d8
	call DisableLCD
	ld a, $e4
	ld [rBGP], a
	ld de, VTiles1
	ld bc, $0140
	call CopyData
	ld b, $12
.asm_99ea
	push bc
	ld bc, $000c
	call CopyData
	ld bc, $0028
	call ClearBytes
	ld bc, $000c
	call CopyData
	pop bc
	dec b
	jr nz, .asm_99ea
	ld bc, $0140
	call CopyData
	ld bc, Start
	call ClearBytes
	ld bc, $0080
	call CopyData
	call DrawDefaultTiles
	ld a, $e3
	ld [rLCDC], a
	ld hl, PalPacket_9d46
	call Function981a
	xor a
	ld [rBGP], a
	ret
; 9a24

Function9a24: ; 9a24
	call DisableLCD
	ld a, $e4
	ld [rBGP], a
	ld de, VTiles1
	ld b, $80
.asm_9a30
	push bc
	ld bc, $0010
	call CopyData
	ld bc, $0010
	call ClearBytes
	pop bc
	dec b
	jr nz, .asm_9a30
	call DrawDefaultTiles
	ld a, $e3
	ld [rLCDC], a
	ld hl, PalPacket_9d36
	call Function981a
	xor a
	ld [rBGP], a
	ret
; 9a52

CopyData: ; 0x9a52
; copy bc bytes of data from hl to de
	ld a, [hli]
	ld [de], a
	inc de
	dec bc
	ld a, c
	or b
	jr nz, CopyData
	ret
; 0x9a5b

ClearBytes: ; 0x9a5b
; clear bc bytes of data starting from de
	xor a
	ld [de], a
	inc de
	dec bc
	ld a, c
	or b
	jr nz, ClearBytes
	ret
; 0x9a64

DrawDefaultTiles: ; 0x9a64
; Draw 240 tiles (2/3 of the screen) from tiles in VRAM
	ld hl, VBGMap0 ; BG Map 0
	ld de, 32 - 20
	ld a, $80 ; starting tile
	ld c, 12 + 1
.line
	ld b, 20
.tile
	ld [hli], a
	inc a
	dec b
	jr nz, .tile
; next line
	add hl, de
	dec c
	jr nz, .line
	ret
; 0x9a7a

Function9a7a: ; 9a7a
	ld de, $1b58
.asm_9a7d
	nop
	nop
	nop
	dec de
	ld a, d
	or e
	jr nz, .asm_9a7d
	ret
; 9a86

BlkPacket_9a86: ; 9a86
	db $21, $01, $03, $00, $00, $00, $13, $11, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9a96: ; 9a96
	db $21, $01, $07, $05, $00, $0a, $13, $0d, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9aa6: ; 9a86
	db $22, $05, $07, $0a, $00, $0c, $13, $11, $03, $05, $01, $00, $0a, $03, $03, $00
	db $0a, $08, $13, $0a, $03, $0a, $00, $04, $08, $0b, $03, $0f, $0b, $00, $13, $07

BlkPacket_9ac6: ; 9a86
	db $21, $01, $07, $05, $00, $01, $07, $07, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9ad6: ; 9a86
	db $21, $01, $07, $05, $0b, $01, $13, $02, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9ae6: ; 9a86
	db $21, $01, $07, $05, $01, $01, $08, $08, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9af6: ; 9a86
	db $21, $01, $07, $05, $07, $05, $0d, $0b, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9b06: ; 9a86
	db $22, $05, $03, $05, $00, $00, $13, $0b, $03, $0a, $00, $04, $13, $09, $02, $0f
	db $00, $06, $13, $07, $03, $00, $04, $04, $0f, $09, $03, $00, $00, $0c, $13, $11

BlkPacket_9b26: ; 9a86
	db $23, $07, $07, $10, $00, $00, $02, $0c, $02, $00, $0c, $00, $12, $01, $02, $00
	db $0c, $02, $12, $03, $02, $00, $0c, $04, $12, $05, $02, $00, $0c, $06, $12, $07
	db $02, $00, $0c, $08, $12, $09, $02, $00, $0c, $0a, $12, $0b, $00, $00, $00, $00

BlkPacket_9b56: ; 9a86
	db $22, $03, $07, $20, $00, $00, $13, $04, $03, $0f, $00, $06, $13, $11, $03, $05
	db $0f, $01, $12, $04, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9b76: ; 9a86
	db $21, $01, $07, $10, $00, $00, $13, $05, $00, $00, $00, $00, $00, $00, $00, $00

BlkPacket_9b86: ; 9a86
	db $21, $02, $07, $0a, $00, $04, $13, $0d, $03, $05, $00, $06, $13, $0b, $00, $00
; 9b96

; 9b96
PalPacket_9b96:	db $51, $48, $00, $49, $00, $4a, $00, $4b, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9ba6:	db $51, $2b, $00, $24, $00, $20, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9bb6:	db $51, $41, $00, $42, $00, $43, $00, $44, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9bc6:	db $51, $4c, $00, $4c, $00, $4c, $00, $4c, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9bd6:	db $51, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9be6:	db $51, $36, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9bf6:	db $51, $37, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c06:	db $51, $38, $00, $39, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c16:	db $51, $3a, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c26:	db $51, $3b, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c36:	db $51, $3c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c46:	db $51, $39, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c56:	db $51, $2e, $00, $2f, $00, $30, $00, $31, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c66:	db $51, $1a, $00, $1a, $00, $1a, $00, $1a, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c76:	db $51, $32, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c86:	db $51, $3c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9c96:	db $51, $3d, $00, $3e, $00, $3f, $00, $40, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9ca6:	db $51, $33, $00, $34, $00, $1b, $00, $1f, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9cb6:	db $51, $1b, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9cc6:	db $51, $1c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9cd6:	db $51, $35, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9ce6:	db $01, $ff, $7f, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9cf6:	db $09, $ff, $7f, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d06:	db $59, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d16:	db $89, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d26:	db $89, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d36:	db $99, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d46:	db $a1, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d56:	db $b9, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d66:	db $b9, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d76:	db $79, $5d, $08, $00, $0b, $8c, $d0, $f4, $60, $00, $00, $00, $00, $00, $00, $00
PalPacket_9d86:	db $79, $52, $08, $00, $0b, $a9, $e7, $9f, $01, $c0, $7e, $e8, $e8, $e8, $e8, $e0
PalPacket_9d96:	db $79, $47, $08, $00, $0b, $c4, $d0, $16, $a5, $cb, $c9, $05, $d0, $10, $a2, $28
PalPacket_9da6:	db $79, $3c, $08, $00, $0b, $f0, $12, $a5, $c9, $c9, $c8, $d0, $1c, $a5, $ca, $c9
PalPacket_9db6:	db $79, $31, $08, $00, $0b, $0c, $a5, $ca, $c9, $7e, $d0, $06, $a5, $cb, $c9, $7e
PalPacket_9dc6:	db $79, $26, $08, $00, $0b, $39, $cd, $48, $0c, $d0, $34, $a5, $c9, $c9, $80, $d0
PalPacket_9dd6:	db $79, $1b, $08, $00, $0b, $ea, $ea, $ea, $ea, $ea, $a9, $01, $cd, $4f, $0c, $d0
PalPacket_9de6:	db $79, $10, $08, $00, $0b, $4c, $20, $08, $ea, $ea, $ea, $ea, $ea, $60, $ea, $ea
; 9df6

Palettes_9df6: ; 9df6
	RGB 31, 31, 31
	RGB 22, 25, 19
	RGB 16, 21, 30
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 27, 28, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 24, 28, 19
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 24, 24, 24
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 21, 23, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 24, 21, 27
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 24, 16
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 25, 30, 26
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 25, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 20, 19
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 26, 19
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 27, 28, 27
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 24, 30, 23
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 29, 24, 29
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 26, 23, 29
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 25, 23, 20
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 29, 26, 18
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 21, 18
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 26, 25, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 22, 21, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 22, 25, 21
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 21, 21, 22
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 20, 20
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 26, 26, 26
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 21, 14, 09
	RGB 15, 20, 20
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 12, 28, 22
	RGB 15, 20, 20
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 07, 07, 07
	RGB 02, 03, 03
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 22, 17
	RGB 16, 14, 19
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 18, 20, 27
	RGB 11, 15, 23
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 20, 10
	RGB 26, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 21, 25, 29
	RGB 14, 19, 25
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 27, 22, 24
	RGB 21, 15, 23
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 28, 20, 15
	RGB 21, 14, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 20, 26, 16
	RGB 09, 20, 11
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 22, 24
	RGB 28, 15, 21
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 28, 14
	RGB 26, 20, 00
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 26, 21, 22
	RGB 15, 15, 18
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 23, 19, 13
	RGB 14, 12, 17
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 16, 18, 21
	RGB 10, 12, 18
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 22, 15, 16
	RGB 17, 02, 05
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 15, 20, 20
	RGB 05, 16, 16
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 23, 15, 19
	RGB 14, 04, 12
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 20, 17, 18
	RGB 18, 13, 11
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 23, 21, 16
	RGB 12, 12, 10
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 21, 25, 29
	RGB 30, 22, 24
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 26, 23, 16
	RGB 29, 14, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 18, 18, 18
	RGB 10, 10, 10
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 26, 15
	RGB 00, 23, 00
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 26, 15
	RGB 31, 23, 00
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 26, 15
	RGB 31, 00, 00
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 29, 26, 19
	RGB 27, 20, 14
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 24, 20, 10
	RGB 21, 00, 04
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 20, 10
	RGB 21, 00, 04
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 26, 16
	RGB 16, 12, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 15, 28, 26
	RGB 12, 22, 26
	RGB 03, 16, 14

	RGB 31, 31, 31
	RGB 15, 28, 26
	RGB 23, 24, 24
	RGB 00, 00, 00

	RGB 31, 31, 24
	RGB 07, 27, 19
	RGB 26, 20, 10
	RGB 19, 12, 08

	RGB 31, 31, 31
	RGB 31, 28, 14
	RGB 31, 13, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 16, 18, 21
	RGB 10, 12, 18
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 23, 21, 16
	RGB 12, 12, 10
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 14, 00
	RGB 07, 11, 15
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 26, 21, 22
	RGB 26, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 27, 04
	RGB 24, 20, 11
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 13, 25
	RGB 24, 20, 11
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 16, 19, 29
	RGB 24, 20, 11
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 22, 24
	RGB 18, 18, 18
	RGB 16, 10, 07

	RGB 31, 31, 31
	RGB 21, 25, 29
	RGB 18, 18, 18
	RGB 16, 10, 07

	RGB 31, 31, 31
	RGB 20, 26, 16
	RGB 18, 18, 18
	RGB 16, 10, 07

	RGB 31, 31, 31
	RGB 31, 28, 14
	RGB 18, 18, 18
	RGB 16, 10, 07

	RGB 31, 31, 31
	RGB 18, 18, 18
	RGB 26, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 22, 24
	RGB 28, 15, 21
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 26, 20, 00
	RGB 16, 19, 29
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 16, 02, 30
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 16, 13, 04
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 28, 04, 02
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 18, 23, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 24, 20, 11
	RGB 18, 13, 11
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 31
	RGB 25, 30, 00
	RGB 25, 30, 00

	RGB 00, 00, 00
	RGB 08, 11, 11
	RGB 21, 21, 21
	RGB 31, 31, 31
; a06e

SGBBorderMap: ; a06e
	db $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $14,$14, $15,$14, $16,$14, $17,$14, $17,$54, $16,$54, $15,$54, $14,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14
	db $01,$14, $02,$14, $03,$14, $03,$54, $02,$54, $01,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $24,$14, $25,$14, $26,$14, $07,$14, $07,$54, $26,$54, $25,$54, $24,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$54, $01,$14, $02,$14, $03,$14, $03,$54, $02,$54, $01,$54
	db $11,$14, $12,$14, $13,$14, $13,$54, $12,$54, $11,$54, $10,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $24,$14, $34,$14, $35,$14, $35,$54, $34,$54, $33,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $10,$14, $11,$14, $12,$14, $13,$14, $13,$54, $12,$54, $11,$54
	db $21,$14, $22,$14, $23,$14, $23,$54, $22,$54, $21,$54, $20,$54, $07,$14, $08,$14, $09,$14, $0a,$14, $0b,$14, $0c,$14, $0d,$14, $07,$14, $07,$14, $18,$14, $09,$14, $1a,$14, $1b,$14, $0d,$14, $0c,$14, $1c,$14, $29,$14, $07,$14, $20,$14, $21,$14, $22,$14, $23,$14, $23,$54, $22,$54, $21,$54
	db $31,$14, $32,$14, $07,$14, $07,$14, $32,$54, $36,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $38,$10, $27,$10, $32,$14, $07,$54, $07,$54, $32,$54, $31,$54
	db $05,$14, $06,$14, $07,$14, $07,$54, $06,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $06,$14, $07,$14, $07,$54, $06,$54, $05,$54
	db $15,$14, $16,$14, $17,$14, $17,$54, $16,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $16,$14, $17,$14, $17,$54, $16,$54, $15,$54
	db $25,$14, $26,$14, $07,$14, $07,$54, $26,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $26,$14, $07,$14, $07,$54, $26,$54, $25,$54
	db $33,$14, $34,$14, $35,$14, $35,$54, $34,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $34,$14, $35,$14, $35,$54, $34,$54, $33,$54
	db $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14
	db $02,$54, $01,$54, $07,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $07,$14, $01,$14, $02,$14
	db $12,$54, $11,$54, $10,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $10,$14, $11,$14, $12,$14
	db $22,$54, $21,$54, $20,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $20,$14, $21,$14, $22,$14
	db $32,$54, $31,$54, $30,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $30,$14, $31,$14, $32,$14
	db $06,$54, $05,$54, $04,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $04,$14, $05,$14, $06,$14
	db $16,$54, $15,$54, $14,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $14,$14, $15,$14, $16,$14
	db $26,$54, $25,$54, $24,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $24,$14, $25,$14, $26,$14
	db $34,$54, $33,$54, $07,$54, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $07,$14, $33,$14, $34,$14
	db $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $1f,$10,                                                                                                                                                                                     $37,$10, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14
	db $01,$14, $02,$14, $03,$14, $03,$54, $02,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $02,$14, $03,$14, $03,$54, $02,$54, $01,$54
	db $11,$14, $12,$14, $13,$14, $13,$54, $12,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $12,$14, $13,$14, $13,$54, $12,$54, $11,$54
	db $21,$14, $22,$14, $23,$14, $23,$54, $22,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $22,$14, $23,$14, $23,$54, $22,$54, $21,$54
	db $31,$14, $32,$14, $07,$14, $07,$14, $32,$54, $1f,$10,                                                                                                                                                                                     $37,$10, $32,$14, $07,$54, $07,$54, $32,$54, $31,$54
	db $05,$14, $06,$14, $07,$14, $07,$54, $06,$54, $2e,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2f,$10, $2d,$10, $06,$14, $07,$14, $07,$54, $06,$54, $05,$54
	db $15,$14, $16,$14, $17,$14, $17,$54, $16,$54, $15,$54, $14,$54, $07,$14, $07,$14, $39,$14, $0e,$14, $09,$14, $0f,$14, $28,$14, $07,$14, $19,$14, $0c,$14, $1c,$14, $29,$14, $2a,$14, $2b,$14, $2c,$14, $39,$14, $07,$14, $07,$14, $14,$14, $15,$14, $16,$14, $17,$14, $17,$54, $16,$54, $15,$54
	db $25,$14, $26,$14, $07,$14, $07,$54, $26,$54, $25,$54, $24,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $01,$14, $02,$14, $03,$14, $03,$54, $02,$54, $01,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $24,$14, $25,$14, $26,$14, $07,$14, $07,$54, $26,$54, $25,$54
	db $33,$14, $34,$14, $35,$14, $35,$54, $34,$54, $24,$54, $07,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $10,$14, $11,$14, $12,$14, $13,$14, $13,$54, $12,$54, $11,$54, $10,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $24,$14, $34,$14, $35,$14, $35,$54, $34,$54, $33,$54
	db $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $20,$14, $21,$14, $22,$14, $23,$14, $23,$54, $22,$54, $21,$54, $20,$54, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14, $07,$14
; a49e

SGBBorderPalettes: ; a49e
	RGB 24, 06, 06
	RGB 24, 24, 26
	RGB 14, 15, 20
	RGB 04, 07, 10

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 18, 24, 18
	RGB 31, 26, 15
	RGB 26, 19, 10
	RGB 12, 07, 05

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 18, 06, 31
	RGB 31, 31, 29
	RGB 31, 12, 00
	RGB 00, 00, 00

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 12, 31, 06
	RGB 22, 26, 30
	RGB 16, 17, 21
	RGB 00, 03, 00

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25

	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
	RGB 31, 31, 25
; a51e

SGBBorder: ; a51e
INCBIN "gfx/misc/sgb_border.2bpp"
; a8be

Palettes_a8be: ; a8be
	RGB 30, 26, 15
	RGB 00, 23, 00

	RGB 30, 26, 15
	RGB 31, 21, 00

	RGB 30, 26, 15
	RGB 31, 00, 00

Palettes_a8ca: ; a8ca
	RGB 30, 26, 15
	RGB 04, 17, 31
; a8ce

; a8ce
INCLUDE "gfx/pics/palette_pointers.asm"
; b0ce

; b0ce
INCLUDE "gfx/trainers/palette_pointers.asm"
; b1de

Functionb1de: ; b1de
	callba Function494ac
	jr c, .asm_b230
	ld a, [$d19a]
	and 7
	ld e, a
	ld d, 0
	ld hl, Unknown_b279
	add hl, de
	add hl, de
	ld a, [hli]
	ld h, [hl]
	ld l, a
	ld a, [TimeOfDayPal]
	and 3
	add a
	add a
	add a
	ld e, a
	ld d, 0
	add hl, de
	ld e, l
	ld d, h
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld hl, Unkn1Pals
	ld b, $8
.asm_b210
	ld a, [de]
	push de
	push hl
	ld l, a
	ld h, 0
	add hl, hl
	add hl, hl
	add hl, hl
	ld de, MornPal
	add hl, de
	ld e, l
	ld d, h
	pop hl
	ld c, 8
.asm_b222
	ld a, [de]
	inc de
	ld [hli], a
	dec c
	jr nz, .asm_b222
	pop de
	inc de
	dec b
	jr nz, .asm_b210
	pop af
	ld [rSVBK], a

.asm_b230
	ld a, [TimeOfDayPal]
	and 3
	ld bc, $40
	ld hl, Palettes_b469
	call AddNTimes
	ld de, Unkn2Pals
	ld bc, $0040
	ld a, $5
	call FarCopyWRAM
	ld a, [$d19a]
	cp 1
	jr z, .asm_b253
	cp 2
	ret nz

.asm_b253
	ld a, [MapGroup]
	ld l, a
	ld h, 0
	add hl, hl
	add hl, hl
	add hl, hl
	ld de, Palettes_b569
	add hl, de
	ld a, [TimeOfDayPal]
	and 3
	cp 2
	jr c, .asm_b26d
	inc hl
	inc hl
	inc hl
	inc hl

.asm_b26d
	ld de, $d032
	ld bc, $0004
	ld a, $5
	call FarCopyWRAM
	ret
; b279

Unknown_b279: ; b279
	dw Unknown_b289
	dw Unknown_b289
	dw Unknown_b289
	dw Unknown_b2a9
	dw Unknown_b2c9
	dw Unknown_b2e9
	dw Unknown_b2a9
	dw Unknown_b2c9
; b289

Unknown_b289: ; b289
	db $00, $01, $02, $28, $04, $05, $06, $07, $08, $09, $0a, $28, $0c, $0d, $0e, $0f
	db $10, $11, $12, $29, $14, $15, $16, $17, $18, $19, $1a, $1b, $1c, $1d, $1e, $1f

Unknown_b2a9: ; b289
	db $20, $21, $22, $23, $24, $25, $26, $07, $20, $21, $22, $23, $24, $25, $26, $07
	db $10, $11, $12, $13, $14, $15, $16, $07, $18, $19, $1a, $1b, $1c, $1d, $1e, $07

Unknown_b2c9: ; b289
	db $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0a, $0b, $0c, $0d, $0e, $0f
	db $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1a, $1b, $1c, $1d, $1e, $1f

Unknown_b2e9: ; b289
	db $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0a, $0b, $0c, $0d, $0e, $0f
	db $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1a, $1b, $1c, $1d, $1e, $1f
; b309

Palette_b309: ; b309
	RGB 31, 31, 31
	RGB 31, 19, 24
	RGB 30, 10, 06
	RGB 00, 00, 00
; b311

Palette_b311: ; b311
	RGB 31, 31, 31
	RGB 17, 19, 31
	RGB 14, 16, 31
	RGB 00, 00, 00
; b319

MornPal: ; 0xb319
INCLUDE "tilesets/morn.pal"
; 0xb359

DayPal: ; 0xb359
INCLUDE "tilesets/day.pal"
; 0xb399

NitePal: ; 0xb399
INCLUDE "tilesets/nite.pal"
; 0xb3d9

DarkPal: ; 0xb3d9
INCLUDE "tilesets/dark.pal"
; 0xb419

; There are actually a lot more of these.

; b419

	RGB 30, 28, 26
	RGB 19, 19, 19
	RGB 13, 13, 13
	RGB 07, 07, 07

	RGB 30, 28, 26
	RGB 31, 19, 24
	RGB 30, 10, 06
	RGB 07, 07, 07

	RGB 18, 24, 09
	RGB 15, 20, 01
	RGB 09, 13, 00
	RGB 07, 07, 07

	RGB 30, 28, 26
	RGB 15, 16, 31
	RGB 09, 09, 31
	RGB 07, 07, 07

	RGB 30, 28, 26
	RGB 31, 31, 07
	RGB 31, 16, 01
	RGB 07, 07, 07

	RGB 26, 24, 17
	RGB 21, 17, 07
	RGB 16, 13, 03
	RGB 07, 07, 07

	RGB 30, 28, 26
	RGB 17, 19, 31
	RGB 14, 16, 31
	RGB 07, 07, 07

	RGB 31, 31, 16
	RGB 31, 31, 16
	RGB 14, 09, 00
	RGB 00, 00, 00

	RGB 23, 23, 31
	RGB 18, 19, 31
	RGB 13, 12, 31
	RGB 07, 07, 07

	RGB 15, 13, 27
	RGB 10, 09, 20
	RGB 04, 03, 18
	RGB 00, 00, 00
; b469

Palettes_b469: ; b469
	RGB 28, 31, 16
	RGB 31, 19, 10
	RGB 31, 07, 01
	RGB 00, 00, 00

	RGB 28, 31, 16
	RGB 31, 19, 10
	RGB 10, 09, 31
	RGB 00, 00, 00

	RGB 28, 31, 16
	RGB 31, 19, 10
	RGB 07, 23, 03
	RGB 00, 00, 00

	RGB 28, 31, 16
	RGB 31, 19, 10
	RGB 15, 10, 03
	RGB 00, 00, 00

	RGB 28, 31, 16
	RGB 31, 19, 10
	RGB 30, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 31
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 22, 31, 10
	RGB 12, 25, 01
	RGB 05, 14, 00
	RGB 07, 07, 07

	RGB 28, 31, 16
	RGB 24, 18, 07
	RGB 20, 15, 03
	RGB 07, 07, 07

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 01
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 10, 09, 31
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 07, 23, 03
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 15, 10, 03
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 30, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 31
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 22, 31, 10
	RGB 12, 25, 01
	RGB 05, 14, 00
	RGB 07, 07, 07

	RGB 27, 31, 27
	RGB 24, 18, 07
	RGB 20, 15, 03
	RGB 07, 07, 07

	RGB 15, 14, 24
	RGB 31, 19, 10
	RGB 31, 07, 01
	RGB 00, 00, 00

	RGB 15, 14, 24
	RGB 31, 19, 10
	RGB 10, 09, 31
	RGB 00, 00, 00

	RGB 15, 14, 24
	RGB 31, 19, 10
	RGB 07, 23, 03
	RGB 00, 00, 00

	RGB 15, 14, 24
	RGB 31, 19, 10
	RGB 15, 10, 03
	RGB 00, 00, 00

	RGB 15, 14, 24
	RGB 31, 19, 10
	RGB 30, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 31
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 15, 14, 24
	RGB 08, 13, 19
	RGB 00, 11, 13
	RGB 00, 00, 00

	RGB 15, 14, 24
	RGB 12, 09, 15
	RGB 08, 04, 05
	RGB 00, 00, 00

	RGB 01, 01, 02
	RGB 31, 19, 10
	RGB 31, 07, 01
	RGB 00, 00, 00

	RGB 01, 01, 02
	RGB 31, 19, 10
	RGB 10, 09, 31
	RGB 00, 00, 00

	RGB 01, 01, 02
	RGB 31, 19, 10
	RGB 07, 23, 03
	RGB 00, 00, 00

	RGB 01, 01, 02
	RGB 31, 19, 10
	RGB 15, 10, 03
	RGB 00, 00, 00

	RGB 01, 01, 02
	RGB 31, 19, 10
	RGB 30, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 31
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 01, 01, 02
	RGB 00, 00, 00
	RGB 00, 00, 00
	RGB 00, 00, 00

	RGB 01, 01, 02
	RGB 00, 00, 00
	RGB 00, 00, 00
	RGB 00, 00, 00
; b569

Palettes_b569: ; b569
	RGB 21, 21, 21
	RGB 11, 11, 11
	RGB 21, 21, 21
	RGB 11, 11, 11

	RGB 14, 17, 31
	RGB 07, 11, 15
	RGB 09, 09, 17
	RGB 05, 07, 13

	RGB 12, 19, 00
	RGB 06, 10, 00
	RGB 06, 09, 07
	RGB 04, 05, 06

	RGB 21, 21, 21
	RGB 11, 11, 11
	RGB 21, 21, 21
	RGB 17, 08, 07

	RGB 31, 19, 00
	RGB 27, 10, 05
	RGB 15, 07, 02
	RGB 11, 04, 02

	RGB 11, 10, 16
	RGB 05, 06, 07
	RGB 03, 04, 08
	RGB 00, 00, 00

	RGB 31, 10, 00
	RGB 18, 06, 00
	RGB 18, 05, 09
	RGB 17, 08, 07

	RGB 17, 27, 31
	RGB 05, 15, 31
	RGB 07, 08, 22
	RGB 07, 07, 16

	RGB 22, 20, 10
	RGB 17, 14, 03
	RGB 11, 11, 05
	RGB 10, 09, 07

	RGB 31, 08, 04
	RGB 09, 09, 08
	RGB 18, 05, 09
	RGB 09, 09, 08

	RGB 24, 14, 31
	RGB 13, 07, 21
	RGB 12, 03, 18
	RGB 09, 03, 15

	RGB 25, 25, 00
	RGB 20, 17, 08
	RGB 12, 12, 00
	RGB 10, 09, 05

	RGB 27, 23, 01
	RGB 23, 11, 00
	RGB 15, 11, 01
	RGB 11, 10, 01

	RGB 27, 28, 31
	RGB 17, 19, 22
	RGB 14, 14, 18
	RGB 10, 09, 13

	RGB 19, 19, 16
	RGB 10, 12, 15
	RGB 09, 09, 11
	RGB 04, 05, 07

	RGB 14, 17, 31
	RGB 07, 11, 15
	RGB 09, 13, 19
	RGB 07, 07, 16

	RGB 21, 21, 21
	RGB 13, 13, 13
	RGB 11, 11, 19
	RGB 07, 07, 12

	RGB 31, 18, 29
	RGB 17, 13, 20
	RGB 14, 06, 12
	RGB 11, 03, 10

	RGB 23, 15, 31
	RGB 16, 05, 31
	RGB 12, 07, 17
	RGB 08, 06, 10

	RGB 21, 21, 25
	RGB 16, 16, 16
	RGB 13, 13, 13
	RGB 07, 07, 07

	RGB 21, 21, 21
	RGB 11, 11, 11
	RGB 21, 21, 21
	RGB 11, 11, 11

	RGB 19, 31, 15
	RGB 31, 22, 02
	RGB 12, 13, 09
	RGB 09, 12, 03

	RGB 15, 10, 31
	RGB 07, 05, 15
	RGB 06, 05, 17
	RGB 02, 02, 08

	RGB 21, 31, 07
	RGB 13, 25, 04
	RGB 09, 14, 08
	RGB 06, 10, 04

	RGB 20, 31, 14
	RGB 11, 23, 05
	RGB 09, 13, 08
	RGB 06, 09, 04

	RGB 31, 26, 00
	RGB 31, 15, 00
	RGB 13, 13, 01
	RGB 08, 08, 01

	RGB 31, 14, 28
	RGB 31, 05, 21
	RGB 14, 07, 17
	RGB 13, 00, 08

Palettes_b641: ; b641
	RGB 27, 31, 27
	RGB 21, 21, 21
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 07, 06
	RGB 20, 02, 03
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 10, 31, 09
	RGB 04, 14, 01
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 08, 12, 31
	RGB 01, 04, 31
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 31, 07
	RGB 31, 16, 01
	RGB 00, 00, 00
; b669

	RGB 27, 31, 27
	RGB 22, 16, 08
	RGB 13, 07, 01
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 15, 31, 31
	RGB 05, 17, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 11, 11, 19
	RGB 07, 07, 12
	RGB 00, 00, 00
; b681

Palettes_b681: ; b681
	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 04
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 10, 14, 20
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 04
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 04
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 04
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 04
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 04
	RGB 00, 00, 00

	RGB 27, 31, 27
	RGB 31, 19, 10
	RGB 31, 07, 04
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 21, 21, 21
	RGB 13, 13, 13
	RGB 07, 07, 07

	RGB 31, 31, 31
	RGB 31, 31, 07
	RGB 31, 16, 01
	RGB 07, 07, 07

	RGB 31, 31, 31
	RGB 31, 19, 24
	RGB 30, 10, 06
	RGB 07, 07, 07

	RGB 31, 31, 31
	RGB 12, 25, 01
	RGB 05, 14, 00
	RGB 07, 07, 07

	RGB 31, 31, 31
	RGB 08, 12, 31
	RGB 01, 04, 31
	RGB 07, 07, 07

	RGB 31, 31, 31
	RGB 24, 18, 07
	RGB 20, 15, 03
	RGB 07, 07, 07

Palettes_b6f1: ; b6f1
	RGB 31, 31, 31
	RGB 18, 23, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 22, 00, 31
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 00, 00
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 25, 22, 00
	RGB 15, 20, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 23, 26, 31
	RGB 18, 23, 31
	RGB 00, 00, 00

Palettes_b719: ; b719
	RGB 31, 31, 31
	RGB 07, 06, 03
	RGB 07, 06, 03
	RGB 07, 06, 03

	RGB 31, 31, 31
	RGB 31, 31, 00
	RGB 26, 22, 00
	RGB 00, 00, 00
; b729

Palettes_b729: ; b729
	RGB 28, 31, 20
	RGB 21, 21, 21
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 00, 00, 31
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 15, 07, 00
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 31, 15, 00
	RGB 15, 07, 00
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 00, 00, 31
	RGB 31, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 15, 07, 00
	RGB 31, 00, 00
; b759

Palettes_b759: ; b759
	RGB 28, 31, 20
	RGB 21, 21, 21
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 00, 00, 31
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 15, 07, 00
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 10, 18, 31
	RGB 13, 06, 31
	RGB 00, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 00, 00, 31
	RGB 31, 00, 00

	RGB 28, 31, 20
	RGB 00, 31, 00
	RGB 15, 07, 00
	RGB 31, 00, 00
; b789

Palettes_b789: ; b789
	RGB 31, 31, 31
	RGB 30, 22, 24
	RGB 18, 18, 18
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 10, 11, 31
	RGB 18, 18, 18
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 12, 31, 11
	RGB 18, 18, 18
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 29, 26, 05
	RGB 18, 18, 18
	RGB 00, 00, 00
; b7a9

Palettes_b7a9: ; b7a9
	RGB 31, 31, 31
	RGB 24, 25, 28
	RGB 24, 24, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 10, 06
	RGB 24, 24, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 15, 31, 00
	RGB 24, 24, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 15, 31
	RGB 24, 24, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 15, 21, 31
	RGB 24, 24, 09
	RGB 00, 00, 00

	RGB 31, 31, 11
	RGB 31, 31, 06
	RGB 24, 24, 09
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 16, 19, 29
	RGB 25, 22, 00
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 21, 21, 21
	RGB 13, 13, 13
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 30, 10, 06
	RGB 31, 00, 00
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 12, 25, 01
	RGB 05, 14, 00
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 12, 25, 01
	RGB 30, 10, 06
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 06
	RGB 20, 15, 03
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 06
	RGB 15, 21, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 06
	RGB 20, 15, 03
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 24, 21
	RGB 31, 13, 31
	RGB 00, 00, 00

	RGB 31, 31, 31
	RGB 31, 31, 31
	RGB 00, 00, 00
	RGB 00, 00, 00
; b829