summaryrefslogtreecommitdiffstats
path: root/src/mame/drivers/namcos22.cpp
blob: 65311199019421cacd2237a53c3c09008cb4390a (plain) (blame)
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
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
// license:BSD-3-Clause
// copyright-holders:Phil Stroffolino, hap, R. Belmont
/**
 * This driver describes Namco's System22 and System Super22 hardware.
 *
 * driver provided with thanks to:
 * - hap
 * - pstroffo@yahoo.com (Phil Stroffolino)
 * - R. Belmont
 * - trackmaster@gmx.net (Bjorn Sunder)
 * - team vivanonno
 *
 * TODO:
 * - finish slave DSP emulation
 * - emulate System22 I/O board C74
 * - tokyowar tanks are not shootable, same for timecris helicopter, there's still a very small hitbox but almost impossible to hit.
 * - alpinesa doesn't work, protection related?
 * - C139 for linked cabinets, as well as in RR fullscale
 * - confirm DSP and MCU clocks and their IRQ timing
 * - EEPROM write timing should be around 5ms, it doesn't do any data/rdy polling
 * - texture u/v mapping is often 1 pixel off, resulting in many glitch lines/gaps between textures. The glitch may be in MAME core:
 *       it used to be much worse with the legacy_poly_manager
 * - find out how/where vics num_sprites is determined exactly, currently a workaround is needed for airco22b and dirtdash
 * - improve ss22 lighting:
 *       + mountains in alpinr2b selection screen
 *       + ridgerac waving flag shadowing
 *       + cybrcomm enemies should flash white when you shoot them, probably lighting related
 * - improve ss22 spot:
 *       + dirtdash record time message creates a 'gap' in the spotlight when entering the jungle level
 *       + how is it enabled exactly? the enable bit in spotram is set in tokyowar too(which doesn't use spot)
 *       + what is the high bit in spot_factor for? darkness instead of brightness? not used anywhere
 * - support for text layer video partial updates after posirq, alpinesa does raster effects on it
 * - alpha blended sprite/poly with priority over alpha blended text doesn't work right (see dirtdash countdown when you start at jungle level)
 * - cybrcomm arrows(black part) should be below textlayer when a messagebox pops up
 * - cybrcycc speed dial needle is missing
 * - global offset is wrong in non-super22 servicemode video test, and above that, it flickers in acedrvrw, victlapw
 * - dirtdash polys are broken at the start section of the mountain level, maybe bad rom?
 * - ridgerac fogging isn't applied to the upper/side part of the sky (best seen when driving down a hill), it's fine in ridgera2
 *       czram contents is rather odd here and partly cleared (probably the cause?):
 *        $0000-$0d7f - gradual increase from $00-$7c
 *        $0d80-$0fff - $73, huh, why lower?
 *        $1000-$19ff - $00, huh!? (it's specifically cleared, memsetting czram at boot does not fix the issue)
 *        $1a00-$0dff - $77
 *        $1e00-$1fff - $78
 *
 * - lots of smaller issues
 *
 **********************************************************************************************************
 * Input
 *      - input ports require manual calibration through built-in diagnostics (or canned EEPROM)
 *
 * Output Devices
 *      - Prop Cycle fan (outputs noted at the right MCU port)
 *      - lamps/LEDs on some cabinets
 *      - time crisis has force feedback for the guns
 *
 * Notes:
 *      The "dipswitch" settings are ignored in many games - this isn't a bug.  For example, Prop Cycle software
 *      explicitly clears the chunk of work RAM used to cache the 8 bit dipswitch value immediately after
 *      populating it.  This is apparently done to hide secret debug routines from release versions of games.
 *
 * Self Test Info:
 *    Prop Cycle DSP tests:
 *        MD ROM-PROGRAM      (not-yet-working)
 *        MD-DOWNLOAD       - confirms that main CPU can upload custom code to master DSP
 *        MD-EXTERNAL-RAM   - tests private RAM used by master DSP
 *        C-RAM CHECK BY MD - tests communications RAM, shared by master DSP and main CPU
 *        PDP LOOP TEST     - exercises multi-command DMA transfer
 *        PDP BLOCK MOVE    - exercises DMA block transfer
 *        POINT RAM         - RAM test for "Point RAM" (not directly accessible by any CPU)
 *        CUSTOM IC STATUS  - currently hacked to always report "good"
 *        SD ROM-PRG        - confirms that master DSP can upload custom code to run on slave DSP
 *        SD EXTERNAL-RAM   - tests private RAM used by slave DSP
 *        DATA FLOW TEST 1    (not-yet-working)
 *        DATA FLOW TEST 2    (not-yet-working)
 *        POINT ROM TEST    - checksums the "Point ROMs"
 *
 *    Ridge Racer (Japan) tests:
 *        TEST 1a: MD-EXTERNAL-RAM
 *        TEST 1b: C-RAM CHECK BY MD
 *        TEST 2:  (not-yet-working)
 *        TEST 3:  SD EXTERNAL-RAM
 *        TEST 4:  DATA FLOW TEST 1 (not-yet-working)
 *        TEST 5:  DATA FLOW TEST 2 (not-yet-working)
 *        TEST 6:  POINT RAM
 *
 * IO MCU:
 * - generates sound/music
 * - provides input port management (copying to shared RAM)
 * - coinage handling in most games
 * - manages external physical devices (i.e. lamps, fans, force feedback)
 * - C74 is sound MCU, Mitsubishi M37702 MCU with mask ROM
 * - some external subroutines for C74 are also embedded
 *
 * Master DSP:
 * - S22 has two TI320C25 DSP (printed as C71)
 * - the master DSP provides display list parsing
 *
 * Slave DSP:
 * - serves as a calculation engine for lighting
 *
 * Communications RAM
 * - seen as 32 bit memory by main 68k CPU
 * - seen as 16 bit memory by master DSP (addr 0x8000..0xffff); upper/lower word is selectable
 * - not addressable by slave DSP
 *
 * Point ROMs
 * - encodes 3d model data
 * - not directly addressable by any CPU
 *
 * Point RAM
 * - same address space as Point ROMs
 * - not directly addressable by any CPU
 *
 * Link Feature:
 * - some (typically racing) games may be linked together
 * - serial controller is C139 SCI (same as System21).
 *
 * System Super22
 * - different memory map
 * - different CPU controller register layout
 * - sound CPU uses external ROM (i.e. pr1data.8k) instead of internal BIOS (C74)
 * - additional 2d sprite layer
 * - Point RAM starts at 0xf80000 rather than 0xf00000
 * - "PDP" device, for automated block memory transfers (dsp ram, point ram)
 *
 **********************************************************************************************************
 * SYSTEM22 Known Custom Chips
 *
 * CPU PCB:
 *
 *  C71 TI TMS320C25 DSP
 *  C71 WEYW40116 (TMS320C25 Main/Sub DSP)
 *  C71 D72260FN 980 FE-5CA891W
 *
 *  M5M5178AP-25 (CPU 16R, 17R, 19R, 20R) DSP Work RAM (8K x 8bit x 2 x 2)
 *
 *  C74 Mitsubishi M37702 MCU
 *  C74 159 408600 (OLD SUB)
 *  C74 159 543100 (NEW SUB)
 *  C74 159 414600 (OLD I/O)
 *  C74 159 437600 (NEW I/O)
 *
 * C195 (Shared SRAM Controller)
 * C196 CPP x 6
 * C199 (CPU 18K) x 1
 * C317 IDC (CPU 15E) x 1 (S21B)
 * C337 PFP x 1
 * C342 x 1 (S21B)
 * C352 (32ch PCM)
 * C353 x 1
 *
 *
 * VIDEO PCB:
 *
 * C304 - 4 chips on SS22 Video PCB
 * C305 (Palette)
 * C335
 *  9C, 10C
 *  12D, 12E
 *  14C
 * C300
 *  18B, 18C, 20B, 20C, 22B, 22C
 * Cxxx
 *  34R, 35R
 *
 * TI TBP28L22N (256 x 8bit PROM)
 *  VIDEO 2D, 3D, 4D (RGB Gamma LUT ROM)
 *
 *  RR1.GAM (for Ridge Racer 1/2, Rave Racer)
 **********************************************************************************************************
 *
 *Namco Super System 22 Hardware Overview (last updated 21st
 *December 2012 at 7:15pm)
 *---------------------------------------
 *
 *This document covers all the known Namco Super System 22 games, including....
 *Air Combat 22    (C) Namco, 1995
 *Alpine Racer 1   (C) Namco, 1994
 *Alpine Racer 2   (C) Namco, 1996
 *Alpine Surfer    (C) Namco, 1996
 *Aqua Jet         (C) Namco, 1996
 *Armadillo Racing (C) Namco, 1996 (an undumped prototype/test or early version exists using a different ROM PCB)
 *Cyber Cycles     (C) Namco, 1995
 *Dirt Dash        (C) Namco, 1995
 *Prop Cycle       (C) Namco, 1996
 *Time Crisis      (C) Namco, 1995
 *Tokyo Wars       (C) Namco, 1996
 *
 *The Namco Super System 22 System comprises 4 PCB's plugged into a motherboard. The motherboard contains only
 *some slots and connectors. The 4 PCB's are housed in a metal box with a large fan on the side. The fan mostly cools
 *the video board as these are known to run hot and commonly fail, especially now the system is many years old.
 *
 *CPU PCB   - There are four known revisions of this PCB. Three of them have an extra connector for an
 *            auxiliary PCB. One of the others doesn't have that connector but is are otherwise identical.
 *            All PCBs can be swapped to any game and it will work. However, ALL required IC's must be swapped.
 *            This includes Program ROM PCB, socketed Keycus IC, socketed DATA ROM and socketed WAVE ROM(s).
 *            On most games the EEPROM will re-init itself on bootup. On the others, the EEPROM can re-init itself
 *            to defaults by holding down SERVICE + TEST on power-up. All games are swappable to ANY CPU PCB and will
 *            run ok (all dumped games have been swapped/tested and work fine)
 *DSP PCB   - There is only 1 revision of this PCB. All games use the exact same PCB. The DSP PCB can be swapped to
 *            any other game and works fine (all dumped games tested). Note that some games use different parts of the
 *            DSP PCB and some do more thorough tests on bootup so an old DSP PCB that works fine in one game may come
 *            up as faulty in a different SS22 game.
 *MROM PCB  - These PCB's have many SOP44 ROMs on them and are identical for each game, but the contents of the ROMs
 *            and the number of ROMs vary per game. (a few of the dumped games have had their surface mounted ROMs
 *            swapped to other PCBs and worked fine)
 *FLASH PCB - Flash ROM board used only for a prototype or early version of Armadillo Racing and contains many TSOP56
 *            16M FlashROMs
 *VIDEO PCB - There are three known revisions of this PCB. They're mostly identical apart from some component shuffling
 *            and in the earlier versions (A & B), an Altera FPGA chip is used instead of a Namco custom chip.
 *            All revisions of the Video PCBs are swappable and fully compatible with any SS22 game. The Altera FPGA runs
 *            very hot and almost always fails even if heatsinked! Revision C is the most reliable.
 *MOTHER PCB- There are probably 3 revisions of this PCB, but only the original revision and (C) are documented here.
 *            The differences are very minor, just the amount of connectors on the PCB. The Mother PCB is swappable to
 *            any game as long as the required connectors for that game are present on the PCB. (all dumped games tested
 *            and worked fine using any MOTHER PCB)
 *
 *Each game has a 2 or 3 digit letter code assigned to it. Then a number 1 or 2, Then a Rev. A/B/C/D which denotes the
 *software revision.
 *The 1 denotes a Japanese version. 2 denotes a World version. So far there are no other numbers used other than 1 or 2.
 *For World versions, usually only the main program uses a '2', the rest of the ROM labels use the Japanese region code '1'.
 *There is one exception so far. The World version of Alpine Racer 2, which uses a World version DATA ROM, and also one
 *of the WAVE ROMs is a World version, but one Japanese WAVE ROM is also used.
 *See the CPU PCB, Program ROM Daughterboard and MROM PCB texts below for more details on ROM usage.
 *
 *CPU PCB
 *-------
 *1st Revision
 *SYSTEM SUPER22 CPU PCB 8646960102 (8646970102)
 *
 *2nd Revision
 *SYSTEM SUPER22 CPU(B) PCB 8646962600 (8646972600)
 *
 *3rd Revision
 *SYSTEM SUPER22 CPU(B) PCB 8646962600 (8646972601) <-- very minor?
 *
 *4th Revision
 *SYSTEM SUPER22 CPU(B) PCB 8646962601 (8646972601) <-- very minor?
 *|--------------------------------------------------------------|
 *|      J6                         JC410               3771     |
 *|  N341256(x4)                                           DSW(4)|
 *|                               |-------|                     |--|
 *|                               |MC68EC |                     |  |
 *|                               |020FG25|                     |  |
 *|   *1                          |-------|                     |  |
 *|           DSW(8)        SS22C2         |------|             |  |
 *|                                        | C383 |             |  |
 *|   CAT28C64    KEYCUS    SS22C1         |      |             |  |
 *|                                        |------|             |  |
 *|              |-------|                                      |  |
 *|     N341256  |       |                 |------|             |  |
 *| *3  N341256  | C405  |                 | 139  |             |--|
 *|              |       |       CY7C182   |      |              |
 *| *2           |-------|                 |------|              |
 *|                                                             |--|
 *|        40.000MHz                         137                |  |
 *|                                                             |  |
 *|              DATA.8K         JP1        49.152MHz           |  |
 *|     |------|                 |-------|             4558     |  |
 *|     | C352 |      JP2        |M37710 |                      |  |
 *|     |      |                 |S4BFP  |                      |  |
 *|     |------|                 |-------|                      |  |
 *|LED(x8)                                                      |  |
 *|        J11         SS22C4                MB87078            |  |
 *|      WAVEA.2L                                      4558     |--|
 *| JP3                                                          |
 *|      WAVEB.1L                LC78815M      LC78815M          |
 *|--------------------------------------------------------------|
 *(logic chips omitted from the PCB layout)
 *
 *Notes:
 *      J6           : Custom Namco connector for plug-in program ROM PCB
 *      J11          : Custom Namco connector for optional plug-in WAVE ROM PCB (holds some SOP44 MASKROMs)
 *      JC410        : Custom Namco connector for Optional plug-in Auxiliary PCB (e.g. Gun Control PCB used in Time Crisis
 *                     etc)
 *                     The connector is populated only on the 2nd revision CPU (B) PCB 8646962600 (8646972600)
 *                     and 3rd Revision CPU (B) PCB 8646962600 (8646972601)
 *      JP1          : Jumper for configuration of M37710 (tied to pins 26 & 27 of M37710). Set to 1-2
 *      JP2          : Jumper for configuration of DATA ROM. Set to 1-2 (labelled '4M'), alt. setting 2-3 (labelled '1M/2M')
 *      JP3          : Jumper for configuration of WAVE ROM. Set to 2-3 (labelled '42P32M'), alt. setting 1-2
 *                     (labelled 'OTHER'). 'OTHER' is used when the WAVE ROMs are 16MBit. If the WAVE ROMs are 32MBit
 *                     (i.e. JP3 = 2-3), they're programmed in BYTE mode.
 *      M37710       : Mitsubishi M37710 CPU. Used on SS22 as the sound CPU. Does not have internal ROM (QFP80)
 *      MB87078      : Fujitsu MB87078 electronic volume control IC (SOIC24)
 *      4558         : Op Amp (SOIC8)
 *      LC78815M     : Sanyo LC78815M 2-channel 16-bit D/A converter (x2, SOIC20)
 *      3771         : Fujitsu MB3771 master reset IC (SOIC8)
 *      DSW(4)       : 4 position DIP Switch (1,2,3 are ON, 4 is OFF)
 *      DSW(8)       : 8 position DIP Switch (All OFF)
 *      N341256      : NKK N341256 32k x8 SRAM (x6, SOJ28)
 *      CY7C182      : Cypress 8k x9 SRAM (SOJ28)
 *      MC68EC020FG25: Main CPU, Motorola 68EC020FG25 (QFP100), running at 24.576MHz. Clock source is Namco
 *                     custom clock divider 137. 68EC020 clock = Master Clock of 49.152MHz / 2
 *      C383         : Namco custom C383 (QFP100)
 *      139          : Namco custom 139 Serial Controller Interface IC (QFP64). NOTE! On some PCB's this chip
 *                     has been replaced by a custom C422 chip, though the PCB number is the same. Which means probably
 *                     the function of this chip matches 139
 *      137          : Namco custom clock divider IC (DIP28)
 *      C405         : Namco custom C405 (QFP176)
 *      C352         : Namco custom C352 PCM sound chip (QFP100), clock is 24.576MHz (49.152/2), from pin 6 of C137
 *      SS22C1       : PALCE 22V10H (PLCC28, labelled 'SS22C1')
 *      SS22C2       : PALCE 22V10H (PLCC28, labelled 'SS22C2')
 *      SS22C4       : PALCE 22V10H (PLCC28, labelled 'SS22C4')
 *      CAT28C64     : Catalyst Semiconductor Inc. CAT28C64 8k x8 EEPROM (DIP28)
 *      LEDS         : 8 LEDs of various colors flash (in various pretty patterns) when the CPU PCB is active.
 *      KEYCUS       : Namco custom (DIP32)
 *                                         Air Combat 22    = none
 *                                         Alpine Racer 1   = C391
 *                                         Alpine Racer 2   = C434
 *                                         Alpine Surfer    = C425
 *                                         Aqua Jet         = C429
 *                                         Armadillo Racing = C433
 *                                         Cyber Cycles     = C389
 *                                         Dirt Dash        = C418
 *                                         Prop Cycle       = C428
 *                                         Time Crisis      = C419
 *                                         Tokyo Wars       = C424
 *
 *     *1            : Unpopulated position for PAL16V8 (PLCC20)
 *     *2            : Unpopulated position for Fujitsu MB86601 (QFP100)
 *     *3            : Unpopulated position for 32MHz OSC
 *     DATA.8K       : ST Microelectronics M27C4096 256k x16 EPROM (DIP40, labelled with the gamecode + 'DATA')
 *                     Game                EPROM label
 *                     -------------------------------
 *                     Air Combat 22      'ACS1 DATA'
 *                     Alpine Racer 1     'AR1 DATA B'
 *                     Alpine Racer 2     'ARS2 DATA'
 *                     Alpine Surfer      'AF1 DATA'
 *                     Aqua Jet           'AJ1 DATA'
 *                     Armadillo Racing   'AM1 DATA'
 *                     Cyber Cycles       'CB1 DATA B'
 *                     Dirt Dash          'DT1 DATA A'
 *                     Prop Cycle         'PR1 DATA'
 *                     Time Crisis        'TS1 DATA'
 *                     Tokyo Wars         'TW1 DATA'
 *
 *     WAVEA.2L   \
 *     WAVEB.1L   /  : 16M/32M WAVE MASKROMs. If 32MBit DIP42, they're programmed in BYTE mode (DIP42/SOP44)
 *                     Game                Wave A        Wave B        Type
 *                     ----------------------------------------------------------------------------
 *                     Air Combat 22      'ACS1 WAVE0', 'ACS1 WAVE1' , both SOP44 32M MASKROMs
 *                     Alpine Racer 1     'AR1 WAVEA' ,              , DIP42 16M MASKROM
 *                     Alpine Racer 2     'ARS1 WAVEA', 'ARS2 WAVE B', both DIP42 32M MASKROMs
 *                     Alpine Surfer      'AF1 WAVEA' ,              , DIP42 32M MASKROM
 *                     Aqua Jet           'AJ1 WAVEA' , 'AJ1 WAVEB'  , both DIP42 32M MASKROMs
 *                     Armadillo Racing   'AM1 WAVEA' , 'AM1 WAVEB'  , both DIP42 32M MASKROMs. Prototype version uses TSOP56, mounted on a DIP48 adapter board
 *                     Cyber Cycles       'CB1 WAVEA' , 'CB1 WAVEB'  , WAVE A DIP42 32M MASKROM, WAVE B DIP42 16M MASKROM
 *                     Dirt Dash          'DT1 WAVEA' , 'DT1 WAVEB'  , both DIP42 32M MASKROMs
 *                     Prop Cycle         'PR1 WAVE A', 'PR1 WAVE B' , both DIP42 32M MASKROM
 *                     Time Crisis        'TS1 WAVE A', 'TS1 WAVE B' , WAVE A DIP42 32M MASKROM, WAVE B DIP42 16M MASKROM
 *                     Tokyo Wars         'TW1 WAVE A',              , DIP42 32M MASKROM
 *
 *
 *PROGRAM ROM Daughterboard PCB
 *-----------------------------
 *This PCB holds the main program ROMs. There is a small sticker on each PCB stating the game code and software revision.
 *The actual ROMs are not marked with any codes except the manufacturer's part number.
 *There are 4 known types of program daughterboards used on SS22 games (so far). The most common is the first type.
 *The PCB is very small (approx 2" x 3") containing one custom connector and some FlashROMs, and a PAL (in some cases).
 *The ones that contain a PAL are approx 3" x 3".
 *
 *Type 1
 *SYSTEM SUPER22 MPM(F) PCB 8646961600 (8646971600)
 *|-------------------------|
 *|                         |
 *|                         |
 *| ROM1  ROM2  ROM3  ROM4  |
 *|                         |
 *|                         |
 *|  |-------------------|  |
 *|  |-------------------|  |
 *|-------------------------|
 *Notes:
 *      ROMx: Intel E28F008SA 8MBit FlashROM (x4, TSOP40)
 *
 *      This PCB is used on:
 *                          Game          Software revision
 *                          -------------------------------
 *                          Air Combat 22    'ACS1 Ver.B'
 *                          Alpine Racer     'AR2 Ver.C'
 *                          Alpine Racer     'AR2 Ver.D'
 *                          Aqua Jet         'AJ2 Ver.B'
 *                          Armadillo Racing 'AM1 Ver.A'
 *                          Cyber Cycles     'CB2 Ver.C'
 *                          Prop Cycle       'PR2 Ver.A'
 *                          Time Crisis      'TS2 Ver.B'
 *                          Tokyo Wars       'TW2 Ver.A'
 *
 *Type 2
 *SYSTEM SUPER22 MPM(F16) PCB 8646962500 (8646972500)
 *|-------------------------|
 *|                         |
 *|                         |
 *|      ROM1     ROM2      |
 *|                         |
 *|                         |
 *|                         |
 *|  |-------------------|  |
 *|  |-------------------|  |
 *|-------------------------|
 *Notes:
 *      ROMx: Intel E28F016SA 16MBit FlashROMs (x2, TSOP56)
 *
 *      This PCB is used on:
 *                          Game          Software revision
 *                          -------------------------------
 *                          Time Crisis   'TS2 Ver.A'
 *                          Dirt Dash     'DT2 Ver.A'
 *
 *Type 3
 *SYSTEM SUPER22 MPM(F16X4) PCB 8646962901 (8646972901)
 *|-------------------------|
 *|SS22P1B                  |
 *|                         |
 *|        IC4_LM    IC5_UU |
 *|                         |
 *|                         |
 *|  IC2_LL     IC3_UM      |
 *|                         |
 *|                         |
 *|  |-------------------|  |
 *|  |-------------------|  |
 *|-------------------------|
 *Notes:
 *      ICx*   : Intel E28F016SA 16MBit FlashROMs (x4, TSOP56)
 *      SS22P1B: PALCE16V8H (PLCC20, labelled 'SS22P1B')
 *
 *      This PCB is used on:
 *                          Game           Software revision
 *                          -------------------------------
 *                          Alpine Racer 2 'ARS2 Ver.B'
 *
 *Type 4
 *SYSTEM SUPER22 MPM(F16X4F) PCB 8646963500 (8646973500)
 *SYSTEM SUPER22 MPM(F16X4F) PCB 8646963501 (8646973501) <-- very minor?
 *|-------------------------|
 *|SS22P1B                  |
 *|                         |
 *|                         |
 *| IC2_LL     IC4_UM       |
 *|                         |
 *|      IC3_LM      IC5_UU |
 *|                         |
 *|                         |
 *|  |-------------------|  |
 *|  |-------------------|  |
 *|-------------------------|
 *Notes:
 *      ICx    : Fujitsu 29F016 16MBit FlashROMs (x4, TSOP48)
 *      SS22P1B: PALCE16V8H (PLCC20, labelled 'SS22P1B')
 *               There is a small mod on this PAL as follows....
 *               - Pin 8 is lifted and the pad on the PCB at pin 8
 *                 is tied to pin 16 of the PAL (no other pins are lifted)
 *               - The lifted pin 8 is tied to the MPM PCB connector on pin 1
 *                 That pin traces to pin 6 (OUTPUT Y) of a 74F08 at 15F on the CPU board
 *                 Pins 4 (INPUT A) & 5 (INPUT B) of the 74F08 at 15F trace to Namco custom
 *                 IC C383 pins 53 (A INPUT) & 52 (B INPUT)
 *
 *      This PCB is used on:
 *                          Game           Software revision
 *                          --------------------------------
 *                          Alpine Surfer  'AF2 Ver.A'   note: with PAL modification and using 8646963500 PCB
 *                          Alpine Racer 2 'ARS2 Ver.A'  note: without PAL modification and using 8646963501 PCB
 *
 *
 *Auxillary PCB (connector JC410 on the CPU PCB is used only for Time Crisis)
 *-------------
 *V159 GUN POINT PCB 244790102 (2447970102)
 *|---------------------------------|
 *|                                 |
 *|                      25.175MHz  |
 *|                                 |
 *|                                 |
 *|                                 |
 *|                                 |
 *|                                 |
 *|                                 |
 *|                               J2|
 *|                                 |
 *|                                 |
 *|                                 |
 *|                                 |
 *|                                 |
 *|                                 |
 *|                J1               |
 *|---------------------------------|
 *Notes:
 *      There isn't much on this PCB other than 2 connectors and an oscillator plus a large amount of logic chips.
 *      J1 : Connector joining Gun PCB to a connector on the metal box (which joins to the gun interface PCB in the
 *           cab which supplies 24V for the solenoid in the guns)
 *      J2 : Connector joining to the CPU PCB (to JC410)
 *
 *
 *DSP PCB
 *-------
 *SYSTEM SUPER22 DSP PCB 8646960302 (8646970302)
 *  |--------------------------------------------------------------|
 *  | N341256     |-------|   SS22D1    N341256     |-------|      |
 *  | N341256     |       |             N341256     |       |      |
 *  | |---------| | C71   |                         | C405  |     |--|
 *|--||         | |       |                         |       |     |  |
 *|  ||  C396   | |-------|                         |-------|     |  |
 *|  ||         |                                                 |  |
 *|J ||         |           N341256                 |-------|     |  |
 *|D ||---------|           N341256                 |       |     |  |
 *|3 | |-------|                          N341256   | C405  |     |  |
 *|  | |       |                                    |       |     |  |
 *|  | | C71   |  |---------|                       |-------|     |  |
 *|--| |       |  |         |             |------|                |  |
 *  |  |-------|  |  342    |             | C379 |                |--|
 *  |  |------|   |         |             |      |                 |
 *  |  | C199 |   |         |             |------|  N341256        |
 *  |  |      |   |---------|                       N341256       |--|
 *  |  |------|                                                   |  |
 *  |   |-----|      SS22D5  SS22D4B    40MHz     |---------|     |  |
 *  |   |C353 |                                   |         |     |  |
 *  |   |-----|                                   |  C300   |     |  |
 *  |LED(x8)         SS22D2  SS22D3               |         |     |  |
 *  |   |-----|                                   |         |     |  |
 *  |   | 402 |  |---------|                      |---------|     |  |
 *  |   |-----|  |         |                                      |  |
 *  |            |  C403   |    KM681000   KM681000   KM681000    |  |
 *  |   |-----|  |         |                                      |--|
 *  |   | 402 |  |         |    KM681000   KM681000   KM681000     |
 *  |   |-----|  |---------|                                       |
 *  |--------------------------------------------------------------|
 *(logic chips omitted from the PCB layout)
 *
 *Notes:
 *      JD3          : Custom Namco connector joining this PCB to the MROM PCB with a special flat cable known as a
 *                     'DHD harness'
 *      N341256      : NKK N341256 32k x8 SRAM (x9, SOJ28)
 *      KM681000     : Samsung Electronics KM681000 128k x8 SRAM (x6, SOP32)
 *      342          : Namco custom 342  (QFP160)
 *      402          : Namco custom 402  (x2, TQFP144)
 *      C71          : Namco custom C71, actually a Texas Instruments 320C25 DSP (x2, PLCC68)
 *      C199         : Namco custom C199 (QFP100)
 *      C300         : Namco custom C300 (QFP160)
 *      C353         : Namco custom C353 (QFP120)
 *      C379         : Namco custom C379 (QFP64)
 *      C396         : Namco custom C396 (QFP160)
 *      C403         : Namco custom C403 (QFP136)
 *      C405         : Namco custom C396 (x2, QFP176)
 *      SS22D1       : PALCE 20V8H (PLCC28, labelled 'SS22D1')
 *      SS22D2       : PALCE 16V8H (PLCC20, labelled 'SS22D2')
 *      SS22D3       : PALCE 16V8H (PLCC20, labelled 'SS22D3')
 *      SS22D4B      : PALCE 16V8H (PLCC20, labelled 'SS22D4B')
 *      SS22D5       : PALCE 16V8H (PLCC20, labelled 'SS22D5')
 *      LEDS         : 8 red LEDs flash (in various pretty patterns) when the DSP PCB is active.
 *
 *
 *ROM PCB (type 1)
 *-------
 *SYSTEM SUPER22 MROM PCB 8646960400 (8646970400)
 *  |--------------------------------------------------------------|
 *  | SS22M3      TC551001(x3)                                     |
 *  | JP13                                 CG7.19D    CG5.19B      |
 *  |  PTR-L0.18K  PTR-M0.18J  PTR-U0.18F                          |
 *|--|                                     CG6.18D    CG4.18B      |
 *|  | PTR-L1.16K  PTR-M1.16J  PTR-U1.16F                   CG6.18A|
 *|  |                                     CG5.16D    CG3.16B      |
 *|J | PTR-L2.15K  PTR-M2.15J  PTR-U2.15F                   CG7.15A|
 *|R |                                     CG4.14D    CG2.14B      |
 *|4 | PTR-L3.14K  PTR-M3.14J  PTR-U3.14F                      JP1 |
 *|  |  SCG0.12L              SCG0.12F JP4 CG3.13D    CG1.13B  JP2 |
 *|  |                                 JP5                     JP3 |
 *|--|              SCG7.10J           JP6 CG2.12D    CG0.12B      |
 *  |   SCG1.10L              SCG1.10F                      SS22M1 |
 *  |                                      CG1.10D    SS22M2       |
 *  |                                                              |
 *  |   SCG2.8L     JP10      SCG2.8F      CG0.8D                 |--|
 *|--|              JP11                                          |  |
 *|  |              JP12                                          |  |
 *|  |  SCG3.7L               SCG3.7F      SS22M2     CCR-L.7B    |  |
 *|J |                                                            |  |
 *|R |                                                CCR-H.5B    |  |
 *|3 |  SCG4.5L               SCG4.5F                             |  |
 *|  |              JP7                                           |  |
 *|  |              JP8                                           |  |
 *|--|  SCG5.3L     JP9       SCG5.3F      CCR-L.3D               |  |
 *  |                                                             |--|
 *  |               SCG7.1J                CCR-H.1D                |
 *  |   SCG6.1L               SCG6.1F                              |
 *  |--------------------------------------------------------------|
 *(logic chips omitted from the PCB layout)
 *
 *Notes:
 *      Namco SS22 MROM PCBs have 2 identical sets of CG*, SCG* and CCR-L/CCR-H ROMs on the PCB.
 *      The Japanese region code '1' is appended to all game codes on all MROMs.
 *
 *      JR3, JR4     : Custom Namco connector joining this PCB to the VIDEO & DSP PCBs with a special flat cable known
 *                     as a 'DHD harness'
 *      SS22M1       : PALCE 16V8H (PLCC20, labelled 'SS22M1')
 *      SS22M2       : PALCE 20V8H (x2, PLCC28, labelled 'SS22M2')
 *      SS22M3       : PALCE 16V8H (PLCC20, labelled 'SS22M3')
 *      TC551001     : Toshiba TC551001 128k x8 SRAM (SOP32)
 *      JP1, JP2, JP3: Jumpers to configure CG* ROMs.  Hardwired to '16M' on the PCB. Alt. setting '32M'
 *      JP4, JP5, JP6: Jumpers to configure CG* ROMs.  Hardwired to '16M' on the PCB. Alt. setting '32M'
 *      JP7, JP8, JP9: Jumpers to configure SCG* ROMs. Hardwired to '16M' on the PCB. Alt. setting '32M'
 *   JP10, JP11, JP12: Jumpers to configure SCG* ROMs. Hardwired to '16M' on the PCB. Alt. setting '32M'
 *      JP13         : Jumper  to configure PTR* ROMs. Hardwired to '4M'  on the PCB. Alt. setting '8M'
 *
 *Game               ROMs populated
 *---------------------------------------------------------
 *Air Combat 22      ACS1CCRH.5B, ACS1CCRH.1D    4M SOP32
 *                   ACS1CCRL.7B, ACS1CCRL.3D   16M SOP44
 *                   ACS1CG0.12B, ACS1CG0.8D        "
 *                   ACS1CG1.13B, ACS1CG1.10D       "
 *                   ACS1CG2.14B, ACS1CG2.12D       "
 *                   ACS1CG3.16B, ACS1CG3.13D       "
 *                   ACS1CG4.18B, ACS1CG4.14D       "
 *                   ACS1CG5.19B, ACS1CG5.16D       "
 *                   ACS1CG6.18A, ACS1CG6.18D       "
 *                   ACS1CG7.15A, ACS1CG7.19D       "
 *                   ACS1SCG0.12F,ACS1SCG0.12L      "
 *                   ACS1SCG1.10F,ACS1SCG1.10L      "
 *                   ACS1PTRU0.18F               4M SOP32
 *                   ACS1PTRU1.16F                  "
 *                   ACS1PTRU2.15F                  "
 *                   ACS1PTRU3.14F                  "
 *                   ACS1PTRM0.18J                  "
 *                   ACS1PTRM1.16J                  "
 *                   ACS1PTRM2.15J                  "
 *                   ACS1PTRM3.14J                  "
 *                   ACS1PTRL0.18K                  "
 *                   ACS1PTRL1.16K                  "
 *                   ACS1PTRL2.15K                  "
 *                   ACS1PTRL3.14K                  "
 *
 *Alpine Racer 1     AR1CCRH.5B, AR1CCRH.1D      4M SOP32
 *                   AR1CCRL.7B, AR1CCRL.3D     16M SOP44
 *                   AR1CG0.12B, AR1CG0.8D          "
 *                   AR1CG1.13B, AR1CG1.10D         "
 *                   AR1CG2.14B, AR1CG2.12D         "
 *                   AR1CG3.16B, AR1CG3.13D         "
 *                   AR1CG4.18B, AR1CG4.14D         "
 *                   AR1CG5.19B, AR1CG5.16D         "
 *                   AR1CG6.18A, AR1CG6.18D         "
 *                   AR1CG7.15A, AR1CG7.19D         "
 *                   AR1SCG0.12F,AR1SCG0.12L        "
 *                   AR1SCG1.10F,AR1SCG1.10L        "
 *                   AR1PTRU0.18F                4M SOP32
 *                   AR1PTRU1.16F                   "
 *                   AR1PTRU2.15F                   "
 *                   AR1PTRU3.14F                   "
 *                   AR1PTRM0.18J                   "
 *                   AR1PTRM1.16J                   "
 *                   AR1PTRM2.15J                   "
 *                   AR1PTRM3.14J                   "
 *                   AR1PTRL0.18K                   "
 *                   AR1PTRL1.16K                   "
 *                   AR1PTRL2.15K                   "
 *                   AR1PTRL3.14K                   "
 *
 *Alpine Racer 2     ARS1CCRH.5B, ARS1CCRH.1D    4M SOP32
 *                   ARS1CCRL.7B, ARS1CCRL.3D   16M SOP44
 *                   ARS1CG0.12B, ARS1CG0.8D        "
 *                   ARS1CG1.13B, ARS1CG1.10D       "
 *                   ARS1CG2.14B, ARS1CG2.12D       "
 *                   ARS1CG3.16B, ARS1CG3.13D       "
 *                   ARS1CG4.18B, ARS1CG4.14D       "
 *                   ARS1CG5.19B, ARS1CG5.16D       "
 *                   ARS1SCG0.12F,ARS1SCG0.12L      "
 *                   ARS1PTRU0.18F               4M SOP32
 *                   ARS1PTRU1.16F                  "
 *                   ARS1PTRU2.15F                  "
 *                   ARS1PTRU3.14F                  "
 *                   ARS1PTRM0.18J                  "
 *                   ARS1PTRM1.16J                  "
 *                   ARS1PTRM2.15J                  "
 *                   ARS1PTRM3.14J                  "
 *                   ARS1PTRL0.18K                  "
 *                   ARS1PTRL1.16K                  "
 *                   ARS1PTRL2.15K                  "
 *                   ARS1PTRL3.14K                  "
 *
 *Alpine Surfer      AF1CCRH.5B, AF1CCRH.1D      4M SOP32
 *                   AF1CCRL.7B, AF1CCRL.3D     16M SOP44
 *                   AF1CG0.12B, AF1CG0.8D          "
 *                   AF1CG1.13B, AF1CG1.10D         "
 *                   AF1CG2.14B, AF1CG2.12D         "
 *                   AF1CG3.16B, AF1CG3.13D         "
 *                   AF1CG4.18B, AF1CG4.14D         "
 *                   AF1SCG0B.12F,AF1SCG0B.12L      "
 *                   AF1PTRU0.18F                4M SOP32
 *                   AF1PTRU1.16F                   "
 *                   AF1PTRM0.18J                   "
 *                   AF1PTRM1.16J                   "
 *                   AF1PTRL0.18K                   "
 *                   AF1PTRL1.16K                   "
 *
 *Aqua Jet           AJ1CCRH.5B, AJ1CCRH.1D      4M SOP32
 *                   AJ1CCRL.7B, AJ1CCRL.3D     16M SOP44
 *                   AJ1CG0.12B, AJ1CG0.8D          "
 *                   AJ1CG1.13B, AJ1CG1.10D         "
 *                   AJ1CG2.14B, AJ1CG2.12D         "
 *                   AJ1CG3.16B, AJ1CG3.13D         "
 *                   AJ1CG4.18B, AJ1CG4.14D         "
 *                   AJ1CG5.19B, AJ1CG5.16D         "
 *                   AJ1CG6.18A, AJ1CG6.18D         "
 *                   AJ1CG7.15A, AJ1CG7.19D         "
 *                   AJ1SCG0.12F,AJ1SCG0.12L        "
 *                   AJ1SCG1.10F,AJ1SCG1.10L        "
 *                   AJ1SCG2.8F, AJ1SCG2.8L         "
 *                   AJ1PTRU0.18F                4M SOP32
 *                   AJ1PTRU1.16F                   "
 *                   AJ1PTRU2.15F                   "
 *                   AJ1PTRU3.14F                   "
 *                   AJ1PTRM0.18J                   "
 *                   AJ1PTRM1.16J                   "
 *                   AJ1PTRM2.15J                   "
 *                   AJ1PTRM3.14J                   "
 *                   AJ1PTRL0.18K                   "
 *                   AJ1PTRL1.16K                   "
 *                   AJ1PTRL2.15K                   "
 *                   AJ1PTRL3.14K                   "
 *
 *Armadillo Racing   AM1CCRH.5B, AM1CCRH.1D      4M SOP32
 *                   AM1CCRL.7B, AM1CCRL.3D     16M SOP44
 *                   AM1CG0.12B, AM1CG0.8D          "
 *                   AM1CG1.13B, AM1CG1.10D         "
 *                   AM1CG2.14B, AM1CG2.12D         "
 *                   AM1CG3.16B, AM1CG3.13D         "
 *                   AM1CG4.18B, AM1CG4.14D         "
 *                   AM1CG5.19B, AM1CG5.16D         "
 *                   AM1CG6.18A, AM1CG6.18D         "
 *                   AM1CG7.15A, AM1CG7.19D         "
 *                   AM1SCG0.12F,AM1SCG0.12L        "
 *                   AM1SCG1.10F,AM1SCG1.10L        "
 *                   AM1PTRU0.18F                4M SOP32
 *                   AM1PTRU1.16F                   "
 *                   AM1PTRU2.15F                   "
 *                   AM1PTRU3.14F                   "
 *                   AM1PTRM0.18J                   "
 *                   AM1PTRM1.16J                   "
 *                   AM1PTRM2.15J                   "
 *                   AM1PTRM3.14J                   "
 *                   AM1PTRL0.18K                   "
 *                   AM1PTRL1.16K                   "
 *                   AM1PTRL2.15K                   "
 *                   AM1PTRL3.14K                   "
 *
 *Cyber Cycles       CB1CCRH.5B, CB1CCRH.1D      4M SOP32
 *                   CB1CCRL.7B, CB1CCRL.3D     16M SOP44
 *                   CB1CG0.12B, CB1CG0.8D          "
 *                   CB1CG1.13B, CB1CG1.10D         "
 *                   CB1CG2.14B, CB1CG2.12D         "
 *                   CB1CG3.16B, CB1CG3.13D         "
 *                   CB1CG4.18B, CB1CG4.14D         "
 *                   CB1CG5.19B, CB1CG5.16D         "
 *                   CB1CG6.18A, CB1CG6.18D         "
 *                   CB1SCG0.12F,CB1SCG0.12L        "
 *                   CB1SCG1.10F,CB1SCG1.10L        "
 *                   CB1PTRU0.18F                4M SOP32
 *                   CB1PTRU1.16F                   "
 *                   CB1PTRU2.15F                   "
 *                   CB1PTRU3.14F                   "
 *                   CB1PTRM0.18J                   "
 *                   CB1PTRM1.16J                   "
 *                   CB1PTRM2.15J                   "
 *                   CB1PTRM3.14J                   "
 *                   CB1PTRL0.18K                   "
 *                   CB1PTRL1.16K                   "
 *                   CB1PTRL2.15K                   "
 *                   CB1PTRL3.14K                   "
 *
 *Dirt Dash          DT1CCRH.5B, DT1CCRH.1D      4M SOP32
 *                   DT1CCRL.7B, DT1CCRL.3D     16M SOP44
 *                   DT1CG0.12B, DT1CG0.8D          "
 *                   DT1CG1.13B, DT1CG1.10D         "
 *                   DT1CG2.14B, DT1CG2.12D         "
 *                   DT1CG3.16B, DT1CG3.13D         "
 *                   DT1CG4.18B, DT1CG4.14D         "
 *                   DT1CG5.19B, DT1CG5.16D         "
 *                   DT1CG6.18A, DT1CG6.18D         "
 *                   DT1CG7.15A, DT1CG7.19D         "
 *                   DT1SCG0.12F,DT1SCG0.12L        "
 *                   DT1SCG1.10F,DT1SCG1.10L        "
 *                   DT1PTRU0.18F                4M SOP32
 *                   DT1PTRU1.16F                   "
 *                   DT1PTRU2.15F                   "
 *                   DT1PTRU3.14F                   "
 *                   DT1PTRM0.18J                   "
 *                   DT1PTRM1.16J                   "
 *                   DT1PTRM2.15J                   "
 *                   DT1PTRM3.14J                   "
 *                   DT1PTRL0.18K                   "
 *                   DT1PTRL1.16K                   "
 *                   DT1PTRL2.15K                   "
 *                   DT1PTRL3.14K                   "
 *
 *Prop Cycle         PR1CCRH.5B, PR1CCRH.1D      4M SOP32
 *                   PR1CCRL.7B, PR1CCRL.3D     16M SOP44
 *                   PR1CG0.12B, PR1CG0.8D          "
 *                   PR1CG1.13B, PR1CG1.10D         "
 *                   PR1CG2.14B, PR1CG2.12D         "
 *                   PR1CG3.16B, PR1CG3.13D         "
 *                   PR1CG4.18B, PR1CG4.14D         "
 *                   PR1CG5.19B, PR1CG5.16D         "
 *                   PR1CG6.18A, PR1CG6.18D         "
 *                   PR1CG7.15A, PR1CG7.19D         "
 *                   PR1SCG0.12F,PR1SCG0.12L        "
 *                   PR1SCG1.10F,PR1SCG1.10L        "
 *                   PR1PTRU0.18F                4M SOP32
 *                   PR1PTRU1.16F                   "
 *                   PR1PTRU2.15F                   "
 *                   PR1PTRM0.18J                   "
 *                   PR1PTRM1.16J                   "
 *                   PR1PTRM2.15J                   "
 *                   PR1PTRL0.18K                   "
 *                   PR1PTRL1.16K                   "
 *                   PR1PTRL2.15K                   "
 *
 *Time Crisis        TS1CCRH.5B, TS1CCRH.1D      4M SOP32
 *                   TS1CCRL.7B, TS1CCRL.3D     16M SOP44
 *                   TS1CG0.12B, TS1CG0.8D          "
 *                   TS1CG1.13B, TS1CG1.10D         "
 *                   TS1CG2.14B, TS1CG2.12D         "
 *                   TS1CG3.16B, TS1CG3.13D         "
 *                   TS1CG4.18B, TS1CG4.14D         "
 *                   TS1CG5.19B, TS1CG5.16D         "
 *                   TS1CG6.18A, TS1CG6.18D         "
 *                   TS1CG7.15A, TS1CG7.19D         "
 *                   TS1SCG0.12F,TS1SCG0.12L        "
 *                   TS1SCG1.10F,TS1SCG1.10L        "
 *                   TS1SCG2.8F, TS1SCG2.8L         "
 *                   TS1SCG3.7F, TS1SCG3.7L         "
 *                   TS1SCG4.5F, TS1SCG4.5L         "
 *                   TS1SCG5.3F, TS1SCG5.3L         "
 *                   TS1PTRU0.18F                4M SOP32
 *                   TS1PTRU1.16F                   "
 *                   TS1PTRU2.15F                   "
 *                   TS1PTRM0.18J                   "
 *                   TS1PTRM1.16J                   "
 *                   TS1PTRM2.15J                   "
 *                   TS1PTRL0.18K                   "
 *                   TS1PTRL1.16K                   "
 *                   TS1PTRL2.15K                   "
 *
 *Tokyo Wars         TW1CCRH.5B, TW1CCRH.1D      4M SOP32
 *                   TW1CCRL.7B, TW1CCRL.3D     16M SOP44
 *                   TW1CG0.12B, TW1CG0.8D          "
 *                   TW1CG1.13B, TW1CG1.10D         "
 *                   TW1CG2.14B, TW1CG2.12D         "
 *                   TW1CG3.16B, TW1CG3.13D         "
 *                   TW1CG4.18B, TW1CG4.14D         "
 *                   TW1CG5.19B, TW1CG5.16D         "
 *                   TW1CG6.18A, TW1CG6.18D         "
 *                   TW1CG7.15A, TW1CG7.19D         "
 *                   TW1SCG0.12F,TW1SCG0.12L        "
 *                   TW1SCG1.10F,TW1SCG1.10L        "
 *                   TW1SCG2.8F, TW1SCG2.8L         "
 *                   TW1SCG3.7F, TW1SCG3.7L         "
 *                   TW1PTRU0.18F                4M SOP32
 *                   TW1PTRU1.16F                   "
 *                   TW1PTRU2.15F                   "
 *                   TW1PTRU3.14F                   "
 *                   TW1PTRM0.18J                   "
 *                   TW1PTRM1.16J                   "
 *                   TW1PTRM2.15J                   "
 *                   TW1PTRM3.14J                   "
 *                   TW1PTRL0.18K                   "
 *                   TW1PTRL1.16K                   "
 *                   TW1PTRL2.15K                   "
 *                   TW1PTRL3.14K                   "
 *
 *
 *ROM PCB (type 2)
 *-------
 *SS22DS FLASH PCB 8650961300 (8650971300)
 *  |--------------------------------------------------------------|
 *  |     F13M  F13L                      F12J   F12E    |------|  |
 *  |                                                    |ALTERA|  |
 *  |     F12M  F12L                                     |EPMXXXX  |
 *|--|                                    F11J   F11E    |------|  |
 *|  | HM628128 F11L                                               |
 *|  | HM628128                                             DSF4   |
 *|J | HM628128 F9L                       F9J     F9E              |
 *|R |                                                             |
 *|4 | DSF5A                                                       |
 *|  |                                    F8J     F8E              |
 *|  |                                                             |
 *|--|                                                    SS22DSF3 |
 *  |           F7L   F7M                 F7J     F7E              |
 *  |                                                              |
 *  |                                                              |
 *  |                                     F6J     F6E     SS22DSF3|--|
 *|--|                                                            |  |
 *|  |                                                            |  |
 *|  |          F5L   F5M                 F5J     F5E             |  |
 *|J |                                                            |  |
 *|R |                                                            |  |
 *|3 |                                    F4J     F4E             |  |
 *|  |                                                            |  |
 *|  |          F3L   F3M                                         |  |
 *|--|                                                            |  |
 *  | SS22DSF2                            F2J     F2E             |--|
 *  |                                                              |
 *  | SS22DSF2  F1L   F1M                 F1J     F1E              |
 *  |--------------------------------------------------------------|
 *(logic chips omitted from the PCB layout)
 *
 *Notes:
 *      Namco SS22 FLASH PCBs have 2 identical sets of CG*, SCG* and CCR-L/CCR-H ROMs on the PCB.
 *
 *      JR3, JR4     : Custom Namco connector joining this PCB to the VIDEO & DSP PCBs with a special flat cable known
 *                     as a 'DHD harness'
 *      EPMXXXX      : Altera EPM??? (PLCC84, unknown chip model, possibly EPM7064, sticker on top of it blocking ID markings)
 *      DSF5A        : PALCE 16V8H (PLCC20, labelled 'DSF5A')
 *      DSF4         : PALCE 16V8H (PLCC20, labelled 'DSF4')
 *      SS22DSF3     : EPM7032 (x2, PLCC44, labelled 'SS22DSF3')
 *      SS22DSF2     : EPM7032 (x2, PLCC44, labelled 'SS22DSF2')
 *      HM628128     : Hitachi HM628128 128k x8 SRAM (TSOP32)
 *
 *Game               ROMs populated (All Intel E28F016SA TSOP56 16M FlashROMs)
 *-----------------------------------------------------------------
 *Armadillo Racing   F1E, F1J, F2E, F2J            - CCRL/CCRH
 *ROMs (prototype or
 *early test version)F4E, F4J, F5E, F5J, F6E, F6J, \
 *                   F7E, F7J, F8E, F8J, F9E, F9J, \ CGx ROMs
 *                   F11E, F11J, F12E, F12J        /
 *
 *                   F1L, F1M, F3L, F3M, F5L, F5M, \
 *                   F7L, F7M                      / SCGx ROMs
 *
 *                   F9L, F11L, F12L, F13L,        \
 *                   F12M, F13M                    / PTR ROMs
 *
 *
 *VIDEO PCB
 *---------
 *1st Revision
 *SYSTEM SUPER22 VIDEO 8646960204 (8646970204)
 *
 *2nd Revision
 *SYSTEM SUPER22 VIDEO(B) 8646961200 (8646971200)
 *
 *3rd Revision (PCB layout shown below)
 *SYSTEM SUPER22 VIDEO(C) 8646962700 (8646972700)
 *  |--------------------------------------------------------------|
 *  |                                                              |
 *  |                    HM534251BJ-8(x22)                         |
 *  |                                                   |-----|   |--|
 *  |  |---------| |---------| |---------| |---------|  |C401 |   |  |
 *  |  |         | |         | |         | |         |  |-----|   |  |
 *  |  |   304   | |   304   | |   304   | |   304   |            |  |
 *  |  |         | |         | |         | |         |  |-----|   |  |
 *  |  |         | |         | |         | |         |  |C400 |   |  |
 *  |  |---------| |---------| |---------| |---------|  |-----|   |  |
 *  |  N341256      |-----| |-----| |-----| |-----|               |  |
 *  |  N341256      |C407 | |C401 | |C401 | |C401 |  |---------|  |  |
 *  |               |-----| |-----| |-----| |-----|  |         |  |  |
 *  |   |---------|                                  |  C399   |  |--|
 *  |   |         |         |-----| |-----| |-----|  |         |   |
 *  |   |  C387   |         |C400 | |C400 | |C400 |  |         |   |
 *  |   |         |         |-----| |-----| |-----|  |---------|  |--|
 *|--|  |         |                    |-----|            N341256 |  |
 *|  |  |---------|                    |C406 |  |-----|   N341256 |  |
 *|  |  |-----|                        |-----|  |C381 |           |  |
 *|J |  |C381 |                |---------|      |-----|           |  |
 *|V |  |-----|      N341256   |         |                LC321664|  |
 *|3 |     51.2MHz   N341256   |  C404   |      |---------|       |  |
 *|  | |---------| |---------| |         |      |         |       |  |
 *|  | |         | |         | |         |      |  C361   |       |  |
 *|--| |  C374   | |  C395   | |---------|      |         |       |  |
 *  |  |         | |         | N341256          |         |       |--|
 *  |  |         | |         | N341256          |---------|        |
 *  |  |---------| |---------| N341256                    CXD1178Q |
 *  |--------------------------------------------------------------|
 *(logic chips omitted from the PCB layout)
 *
 *Notes:
 *      JV3          : Custom Namco connector joining this PCB to the MROM PCB with a special flat cable known
 *                     as a 'DHD harness'
 *      N341256      : NKK N341256 32k x8 SRAM (x9, SOJ28)
 *      HM534251BJ-8 : Hitachi HM534251BJ-8 256k x4 FASTPAGE DRAM (x22, SOJ28)
 *      LC321664     : Sanyo LC321664 64k x16 DRAM (SOJ40)
 *      CXD1178Q     : Sony CXD1178Q 8-bit RGB 3-channel D/A converter (QFP48)
 *      304          : Namco custom 304  (x4, QFP120)
 *      C361         : Namco custom C361 (QFP120)
 *      C374         : Namco custom C374 (QFP160)
 *      C381         : Namco custom C381 (x2, QFP144)
 *      C387         : Namco custom C387 (QFP160)
 *      C395         : Namco custom C395 (QFP168)
 *      C399         : Namco custom C399 (QFP160)
 *      C400         : Namco custom C400 (x4, QFP100)
 *                     - x3 on 1st Revision
 *      C401         : Namco custom C401 (x4, QFP64)
 *                     - x5 on 1st Revision
 *      C404         : Namco custom C404 (QFP208)
 *      C406         : Namco custom C406 (TQFP120)
 *      C407         : Namco custom C407 (QFP64) NOTE! On Revision A & B, this position is populated by an
 *                                                     Altera EPM7064 PLCC84 FPGA labelled 'SS22V1B'
 *                                                     The Altera chip runs very hot and fails quite often.
 *                                                     Even if a heatsink is added to the chip it still fails.
 *                                                     The failure of this chip is the primary cause of
 *                                                     video faults on Namco Super System 22 PCBs.
 *                                                     (Second reason for video faults is generally attributed
 *                                                     to failure of RAM on this PCB and/or the DSP PCB)
 *
 *
 *Motherboard PCB
 *---------------
 *1st Revision
 *SYSTEM SUPER22 MOTHER PCB 8646960602 (8646970602)
 *
 *2nd Revision
 *SYSTEM SUPER22 MOTHER(B) PCB (number not known)
 *
 *3rd Revision
 *SYSTEM SUPER22 MOTHER(C) PCB 8646960602 (8646970602)
 *|------------------------------------------------------------------|
 *| J1                  J2           J4           J6           J8    |
 *|           J10                           J5   IC2     J7          |
 *|                     J3          IC3          IC1              J9 |
 *|                                                                  |
 *| JC2 |---------------------|        |---------------------|JC1    |
 *|     |---------------------|        |---------------------|       |
 *|                                                                  |
 *| JD2 |---------------------|        |---------------------|JD1    |
 *|     |---------------------|        |---------------------|       |
 *|                                                                  |
 *|                                    |---------------------|JR1    |
 *|                                    |---------------------|       |
 *|                                                                  |
 *| JV2 |---------------------|        |---------------------|JV1    |
 *|     |---------------------|        |---------------------|       |
 *|------------------------------------------------------------------|
 *Notes:
 *      IC1     : LB1233 (DIP8)
 *      IC2, IC3: LB1235 (DIP8)
 *
 *      JC1, JC2: Connectors to plug in CPU PCB
 *      JD1, JD2: Connectors to plug in DSP PCB
 *      JR1     : Connector  to plug in MROM PCB
 *      JV1, JV2: Connectors to plug in VIDEO PCB
 *
 *      J1 : 9 pin power input socket   Pin  Use
 *                                     -----------
 *                                      1    +5V
 *                                      2    +5V
 *                                      3    +5V
 *                                      4    NC
 *                                      5    Ground
 *                                      6    Ground
 *                                      7    Ground
 *                                      8    NC
 *                                      9    +12V
 *
 *      J2 : 9 pin link connector   Pin  Use
 *                                  --------------
 *                                   1   Ring In+
 *                                   2   Ring In-
 *                                   3   Ring Out2+
 *                                   4   Ground
 *                                   5   /RXD+ (NC)
 *                                   6   /RXD- (NC)
 *                                   7   /TXD  (NC)
 *                                   8   GND   (NC)
 *                                   9   +5V   (NC)
 *
 *      J3 : 9 pin socket   Pin  Use
 *                          -------------------
 *                           1   Service Credit
 *                           2   Test
 *                           3   NC
 *                           4   +12V
 *                           5   Counter
 *                           6   NC
 *                           7   Ground
 *                           8   Coin Sw
 *                           9   NC
 *
 *      J4 : 8 pin connector  Pin  Use
 *                            -------------------------------------
 *                             1   Start
 *                             2   Left Select
 *                             3   Right Select
 *                             4   Safety Free Controls (Ski's etc)
 *                             5   Safety Lock Controls (Ski's etc)
 *                             6   NC
 *                             7   Ground
 *                             8   Ground
 *
 *      J5 : 15 pin socket   Pin  Use
 *                           ---------------
 *                            1   Relay1
 *                            2   Relay1
 *                            3   Mute
 *                            4   Mid Light
 *                            5   Left Light
 *                            6   Right Light
 *                            7   NC
 *                            8   NC
 *                            9   NC
 *                            10  NC
 *                            11  NC
 *                            12  NC
 *                            13  +12V
 *                            14  +5V
 *                            15  NC
 *
 *      J6 : 12 pin audio output connector  Pin  Use
 *                                          ----------
 *                                           1   SPKL+
 *                                           2   SPKL-
 *                                           3   SPKR+
 *                                           4   SPKR-
 *                                           5   NC
 *                                           6   NC
 *                                           7   NC
 *                                           8   NC
 *                                           9   NC
 *                                           10  NC
 *                                           11  NC
 *                                           12  NC
 *
 *      J7 : 12 pin analog controls socket   Pin  Use
 *                                           ---------------------------
 *                                            1   +5V
 *                                            2   5K Ohm Potentiometer 1 (Side Swing on Alpine Racer, Alpine Surfer etc)
 *                                            3   5K Ohm Potentiometer 2 (Tilt on Alpine Racer, Alpine Surfer etc)
 *                                            4   GND                    (Other games may use more/different pots or no pots)
 *                                            5   NC
 *                                            6   NC
 *                                            7   NC
 *                                            8   NC
 *                                            9   NC
 *                                            10  NC
 *                                            11  NC
 *                                            12  NC
 *
 *      J8 : 10 pin connector (not used?)
 *
 *      J9 : 6 pin video output socket   Pin  Use
 *                                       ---------
 *                                        1   Red
 *                                        2   Green
 *                                        3   Blue
 *                                        4   Composite Sync (VSync 15kHz interlaced)
 *                                        5   Ground
 *                                        6   NC
 *
 *      J10: 16 pin flat cable connector (only populated on Mother(C) PCB, use not known)
 *
 *
 *AMP PCB
 *-------
 *SYSTEM SUPER22 AMP(4) PCB 8647960100 (8647970100) (sticker 'AMP(2) PCB 8647961100')
 *|-----------------------------------|
 *|J1  J2   LA4705  J3   *1    *2   J5|
 *|                                   |
 *|-----------------------------------|
 *Notes:
 *      LA4705: 2-channel 15W Power Amp
 *      J1    : 3 pin power input socket   Pin  Use
 *                                         -----------
 *                                          1   +12V
 *                                          2   Ground
 *                                          3   NC
 *
 *      J2    : 4 pin dual speaker output socket   Pin  Use
 *                                                 ---------
 *                                                  1   SP1+
 *                                                  2   SP1-
 *                                                  3   SP2+
 *                                                  4   SP2-
 *
 *      J3    : 8 pin sound data input connector from Mother PCB J6   Pin  Use
 *                                                                    ----------
 *                                                                     1   SPKL+
 *                                                                     2   SPKL-
 *                                                                     3   SPKR+
 *                                                                     4   SPKR-
 *                                                                     5   NC
 *                                                                     6   NC
 *                                                                     7   NC
 *                                                                     8   NC
 *
 *      *1    : Unpopulated position for a 2nd LA4705 Power Amp
 *      *2    : J4 - Unpopulated position for another 4 pin dual speaker output socket
 *      J5    : 2 pin connector used for sound mute  Pin  Use
 *                                                   -----------
 *                                                    1   Mute
 *                                                    2   Ground
 */

#include "emu.h"
#include "includes/namcos22.h"

#include "cpu/m68000/m68000.h"
#include "cpu/tms32025/tms32025.h"
#include "machine/namcomcu.h"
#include "sound/c352.h"
#include "speaker.h"

// 51.2MHz XTAL on video board, pixel clock of 12.8MHz (doubled in MAME because of unemulated interlacing)
// HSync - 15.7248 kHz -> htotal = 814.001
// VSync - 59.9042 Hz  -> vtotal = 524.998 (262+263)
#define PIXEL_CLOCK         (51.2_MHz_XTAL/4*2)

#define HTOTAL              (814)
#define HBEND               (0)
#define HBSTART             (640)

#define VTOTAL              (525)
#define VBEND               (0)
#define VBSTART             (480)


#define MCU_SPEEDUP         1     /* mcu idle skipping */
#define SERIAL_IO_PERIOD    (100) /* lower DSP serial I/O period */
// actual dsp serial freq is unknown, should be much higher than 100Hz of course
// serial comms doesn't work yet anyway

/*********************************************************************************************/

// Main CPU

/* SCI, prelim! */
READ32_MEMBER(namcos22_state::namcos22_sci_r)
{
	switch (offset)
	{
		case 0x0/4:
			return 0x0004 << 16;

		default:
			return 0;
	}
}

WRITE32_MEMBER(namcos22_state::namcos22_sci_w)
{
	/*
	20020000  2 R/W RX Status
	            0x01 : Frame Error
	            0x02 : Frame Received
	            0x04 : ?

	20020002  2 R/W Status/Control Flags
	            0x01 :
	            0x02 : RX flag? (cleared every vsync)
	            0x04 : RX flag? (cleared every vsync)
	            0x08 :

	20020004  2 W   FIFO Control Register
	            0x01 : sync bit enable?
	            0x02 : TX FIFO sync bit (bit-8)

	20020006  2 W   TX Control Register
	            0x01 : TX start/stop
	            0x02 : ?
	            0x10 : ?

	20020008  2 W   -
	2002000a  2 W   TX Frame Size
	2002000c  2 R/W RX FIFO Pointer (0x0000 - 0x0fff)
	2002000e  2 W   TX FIFO Pointer (0x0000 - 0x1fff)
	*/
}


// System Controller

void namcos22_state::syscon_irqlevel(offs_t offset, u8 data)
{
	int line = 1 << offset;
	int oldlevel = m_syscontrol[offset] & 7;
	int newlevel = data & 7;

	m_irq_enabled &= ~line;
	if (m_is_ss22)
		m_irq_enabled |= (newlevel != 0) ? line : 0;
	else
		m_irq_enabled |= (data & 0x10) ? line : 0; // always sets 0x30 to enable

	// change active state
	if (m_irq_state & line)
	{
		if (!(m_irq_enabled & line))
		{
			syscon_irqack(offset, 0);
		}
		else if (oldlevel != newlevel)
		{
			m_maincpu->set_input_line(oldlevel, CLEAR_LINE);
			m_maincpu->set_input_line(newlevel, ASSERT_LINE);
		}
	}
}

void namcos22_state::syscon_irqack(offs_t offset, u8 data)
{
	int line = 1 << offset;
	int level = m_syscontrol[offset] & 7;

	m_irq_state &= ~line;
	m_maincpu->set_input_line(level, CLEAR_LINE);
}

void namcos22_state::syscon_dspcontrol(offs_t offset, u8 data)
{
	if (data == m_syscontrol[offset])
		return;

	if (data == 0)
	{
		// disable DSPs
		master_enable(false);
		slave_enable(false);
		m_dsp_irq_enabled = false;
	}
	else if (data == 1)
	{
		// enable dsp and rendering subsystem
		master_enable(true);
		slave_enable(true);
		m_dsp_irq_enabled = true;
	}
	else if (data == 0xff)
	{
		// used to upload game-specific code to master/slave dsps
		master_enable(true);
		m_dsp_irq_enabled = false;
	}
}

void namcos22_state::syscon_mcucontrol(offs_t offset, u8 data)
{
	// enable/disable mcu
	m_mcu->set_input_line(INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE);
}

READ8_MEMBER(namcos22_state::syscon_r)
{
	return m_syscontrol[offset];
}


/* System Controller (System Super22)

0x00: vblank irq level
0x01: hblank irq level
0x02: sci irq level
0x03: unknown irq level (unused?)

0x04: vblank irq ack
0x05: hblank irq ack
0x06: sci irq ack
0x07: unknown irq ack

0x08: ?
0x09: 0x62 or 0x61
0x0a: 0x62
0x0b: 0x57

0x0c: 0x40
0x0d: 0x12
0x0e: 0x52 or 0x50
0x0f: 0x72 or 0x71

0x10: 0xe0
0x11: 0x2c
0x12: 0x50
0x13: 0xff

0x14: watchdog
0x15: ?
0x16: subcpu enable
0x17: 0x0f

0x18: ?
0x19: ?
0x1a: ?
0x1b: 0x01

0x1c: dsp control
*/
WRITE8_MEMBER(namcos22_state::ss22_syscon_w)
{
	switch (offset)
	{
		// irq level / enable irqs
		case 0x00: // vblank
		case 0x01: // hblank
		case 0x02: // SCI
		case 0x03: // unknown
			syscon_irqlevel(offset, data);
			break;

		// acknowledge irqs
		case 0x04: // vblank
		case 0x05: // hblank
		case 0x06: // SCI
		case 0x07: // unknown
			syscon_irqack(offset-4, data);
			break;

		// watchdog
		case 0x14:
			break;

		// mcu reset
		case 0x16:
			syscon_mcucontrol(offset, data);
			break;

		// dsp control
		case 0x1c:
			syscon_dspcontrol(offset, data);
			break;

		// other regs: unknown
		default:
			break;
	}

	m_syscontrol[offset] = data;
}

/*
000064: 0000 8C9A  (1)
000068: 0000 8CA2  (2)
00006C: 0000 8CAA  (3)
000070: 0000 8CB2  (4)

00008bd8: sys[0x01] := 0x01 // scanline
00008be0: sys[0x02] := 0x02 // sci
00008be8: sys[0x03] := 0x03 // unk
00008bf0: sys[0x00] := 0x04 // vblank
00008bf8: sys[0x08] := 0xff // ?
*/
INTERRUPT_GEN_MEMBER(namcos22_state::namcos22s_interrupt)
{
	// vblank irq
	int line = 1 << 0;
	if (m_irq_enabled & line)
	{
		m_irq_state |= line;
		device.execute().set_input_line(m_syscontrol[0] & 7, ASSERT_LINE);
	}
}


/* System Controller (System22)

0x00: hblank irq level
0x01: ?
0x02: sci irq level
0x03: unknown irq level

0x04: vblank irq level
0x05: hblank irq ack
0x06: ?
0x07: sci irq ack

0x08: unknown irq ack
0x09: vblank irq ack
0x0a: ?
0x0b: ?

0x0c: ?
0x0d: ?
0x0e: ?
0x0f: ?

0x10: ?
0x11: ?
0x12: ?
0x13: ?

0x14: ?
0x15: ? (cyc1)
0x16: Watchdog timer reset
0x17: ?

0x18: 0 or 1 -> mcu reset?
0x19: ?
0x1a: 0 or 1 or 0xff -> DSP control
0x1b: ?
*/
WRITE8_MEMBER(namcos22_state::s22_syscon_w)
{
	switch (offset)
	{
		// irq level / enable irqs
		case 0x00: // hblank
		case 0x01: // ?
		case 0x02: // SCI
		case 0x03: // unknown
		case 0x04: // vblank
			syscon_irqlevel(offset, data);
			break;

		// acknowledge irqs
		case 0x05: // hblank
		case 0x06: // ?
		case 0x07: // SCI
		case 0x08: // unknown
		case 0x09: // vblank
			syscon_irqack(offset-5, data);
			break;

		// watchdog
		case 0x16:
			break;

		// mcu reset
		case 0x18:
			syscon_mcucontrol(offset, data);
			break;

		// dsp control
		case 0x1a:
			syscon_dspcontrol(offset, data);
			break;

		// other regs: unknown
		default:
			break;
	}

	m_syscontrol[offset] = data;
}

/* namcos22_interrupt
Ridge Racer:
    1:0a0b6
    2:09fe8 (rte)
    3:09fe8 (rte)
    4:09f9a (vblank)
    5:14dee (SCI)
    6:09fe8 (rte)
    7:09fe8 (rte)

Ridge Racer 2:
    1:0d10c  40000005
    2:0cfa2 (rte)
    3:0cfa2 (rte)
    4:0cfa2 (rte)
    5:0cef0
    6:1bbcc
    7:0cfa2 (rte)

Ace Driver:
    9f8 (rte)
    9fa (rte)
    9fc (rte)
    9fe (rte)
    a00
    a46
    a4c (rte)

Victory Lap:
    a54 indir to 21c2 (hblank?)
    a5a (rte)
    a5c (rte)
    a5e (rte)
    a60 irq
    abe indirect to 27f1e (SCI)
    ac4 (rte)

Cyber Commando:
    move.b  #$36, $40000002.l
    move.b  # $0, $40000003.l
    move.b  #$35, $40000004.l

    move.b  #$34, $40000004.l
*/
INTERRUPT_GEN_MEMBER(namcos22_state::namcos22_interrupt)
{
	switch (m_gametype)
	{
		case NAMCOS22_RIDGE_RACER:
		case NAMCOS22_RIDGE_RACER2:
		case NAMCOS22_RAVE_RACER:
		case NAMCOS22_ACE_DRIVER:
		case NAMCOS22_VICTORY_LAP:
			handle_driving_io();
			break;

		case NAMCOS22_CYBER_COMMANDO:
			handle_cybrcomm_io();
			break;

		default:
			break;
	}

	// vblank irq
	int line = 1 << 4;
	if (m_irq_enabled & line)
	{
		m_irq_state |= line;
		device.execute().set_input_line(m_syscontrol[4] & 7, ASSERT_LINE);
	}
}


READ16_MEMBER(namcos22_state::namcos22_shared_r)
{
	return m_shareram[offset];
}

WRITE16_MEMBER(namcos22_state::namcos22_shared_w)
{
	COMBINE_DATA(&m_shareram[offset]);
}


READ32_MEMBER(namcos22_state::namcos22_dspram_r)
{
	return m_polygonram[offset] | 0xff000000; // only d0-23 are connected
}

WRITE32_MEMBER(namcos22_state::namcos22_dspram_w)
{
	if (ACCESSING_BITS_16_23)
	{
		// only d0-23 are connected
		mem_mask |= 0xff000000;
		data = signed24(data); // !
	}
	COMBINE_DATA(&m_polygonram[offset]);
}


READ16_MEMBER(namcos22_state::namcos22_keycus_r)
{
	// Like other Namco hardware, this chip is used for protection as well as
	// reading random values in some games for example in timecris to determine
	// where certain enemies will emerge.
	// It works in combination with keycus_w, but not yet understood how.

//  printf("Hit keycus offs %x mask %x PC=%x\n", offset, mem_mask, m_maincpu->pc());

	// protection (not used for all games)
	// note: some games will XOR this register against a magic value, but that doesn't mean
	// that the magic value is the keycus id. For example dirtdash XORs against $2c79, but its
	// keycus id is $01a2 evident from a simple compare.
	switch (m_gametype)
	{
		case NAMCOS22_RIDGE_RACER2:
			if (offset == 0) return 0x0172;
			break;

		case NAMCOS22_ACE_DRIVER:
			if (offset == 3) return 0x0173;
			break;

		case NAMCOS22_CYBER_COMMANDO:
			if (offset == 1) return 0x0185;
			break;

		case NAMCOS22_ALPINE_RACER:
			if (offset == 1) return 0x0187;
			break;

		case NAMCOS22_CYBER_CYCLES:
			if (offset == 0xf) return 0x0387;
			break;

		case NAMCOS22_VICTORY_LAP:
			if (offset == 2) return 0x0188;
			break;

		case NAMCOS22_DIRT_DASH:
			if (offset == 0) return 0x01a2;
			break;

		case NAMCOS22_ALPINE_SURFER:
			if (offset == 1) return 0x01a9;
			break;

		case NAMCOS22_TOKYO_WARS:
			if (offset == 4) return 0x01a8;
			break;

		default:
			break;
	}

	// pick a random number, but don't pick the same twice in a row
	u16 old_rng = m_keycus_rng;
	do
	{
		m_keycus_rng = machine().rand() & 0xffff;
	} while(m_keycus_rng == old_rng);

	return m_keycus_rng;
}

WRITE16_MEMBER(namcos22_state::namcos22_keycus_w)
{
	// for obfuscating keycus and/or random seed?
}

/**
 * Some port values are read serially one bit at a time via word reads at
 * 0x50000008 and 0x5000000a
 *
 * Writes to 0x50000008 and 0x5000000a reset the state of the input buffer.
 *
 * Note that only the values read at 0x50000008 seem to be used in-game.
 *
 * Some of these values are redundant with respects to the work-RAM supplied input port
 * values supplied by the IO CPU.  For example, the position of the stick shift is digital,
 * and may be read through this mechanism or through shared IO RAM at 0x60004030.
 *
 * Other values seem to be digital versions of analog ports, for example "the gas pedal is
 * pressed" as a boolean flag.  IO RAM supplies it as an analog value.
 */
READ16_MEMBER(namcos22_state::namcos22_portbit_r)
{
	u16 ret = m_portbits[offset] & 1;
	m_portbits[offset] = m_portbits[offset] >> 1 | 0x8000;
	return ret;
}

WRITE16_MEMBER(namcos22_state::namcos22_portbit_w)
{
	m_portbits[offset] = ((offset == 0) ? m_p1 : m_p2).read_safe(0xffff);
}

READ16_MEMBER(namcos22_state::namcos22_dipswitch_r)
{
	return ioport("DSW0")->read();
}

WRITE16_MEMBER(namcos22_state::namcos22_cpuleds_w)
{
	// 8 leds on cpu board, 0=on 1=off
	// on System22: two rows of 4 red leds
	// on SS22: GYRGYRGY green/yellow/red
	for (int i = 0; i < 8; i++)
		m_cpuled[i] = (~data << i & 0x80) ? 0 : 1;
}

WRITE32_MEMBER(namcos22_state::namcos22s_chipselect_w)
{
	// assume that this register is for chip enable/disable
	// it's written many times during boot-up, and most games don't touch it afterwards (last value usually 0038 or 0838)
	// 8000: spot related (set in dirtdash night driving)
	// 4000: spot related (set in dirtdash and testmode)
	// 0800: fade related?
	// other bits: no clue
	if (ACCESSING_BITS_16_23)
		m_chipselect = data >> 16;

	// 8-bit access? (see alpinerd)
	else if (ACCESSING_BITS_24_31)
		m_chipselect = data >> 24;
}


// System22
void namcos22_state::namcos22_am(address_map &map)
{
	/**
	 * Program ROM (2M bytes)
	 * Mounted position: LLB: CPU 4D, LMB: CPU 2D, UMB: CPU 8D, UUB: CPU 6D
	 * Known ROM chip type: TI TMS27C040-10, ST M27C4001-10, M27C4001-12Z
	 */
	map(0x00000000, 0x001fffff).rom();

	/**
	 * Main RAM (128K bytes)
	 * Mounted position: CPU 3D, 5D, 7D, 9D
	 * Known DRAM chip type: TC55328P-25, N3441256P-15
	 */
	map(0x10000000, 0x1001ffff).ram().mirror(0x08000000);

	/**
	 * KEYCUS
	 * Mounted position: CPU 13R
	 * Known chip type:
	 *     C370  (Ridge Racer, Ridge Racer 2)
	 *     C388  (Rave Racer)
	 *     C389? (Cyber Cycles)
	 *     C392? (Ace Driver Victory Lap)
	 */
	map(0x20000000, 0x2000000f).rw(FUNC(namcos22_state::namcos22_keycus_r), FUNC(namcos22_state::namcos22_keycus_w));

	/**
	 * C139 SCI Buffer
	 * Mounted position: CPU 4N
	 * Known chip type: M5M5179AP-25 (8k x 9bit SRAM)
	 *
	 * Note: Boot time check: 20010000 - 20011fff / bits=0x000001ff
	 *
	 *     20010000 - 20011fff  TX Buffer
	 *     20012000 - 20013fff  RX FIFO Buffer (also used for TX Buffer)
	 */
	map(0x20010000, 0x20013fff).ram();

	/**
	 * C139 SCI Register
	 * Mounted position: CPU 4R
	 *
	 *     20020000  2  R/W RX Status
	 *         0x01 : Frame Error
	 *         0x02 : Frame Received
	 *         0x04 : ?
	 *
	 *     20020002  2  R/W Status/Control Flags
	 *         0x01 :
	 *         0x02 : RX flag? (cleared every vsync)
	 *         0x04 : RX flag? (cleared every vsync)
	 *         0x08 :
	 *
	 *     20020004  2  W   FIFO Control Register
	 *         0x01 : sync bit enable?
	 *         0x02 : TX FIFO sync bit (bit-8)
	 *
	 *     20020006  2  W   TX Control Register
	 *         0x01 : TX start/stop
	 *         0x02 : ?
	 *         0x10 : ?
	 *
	 *     20020008  2  W   -
	 *     2002000a  2  W   TX Frame Size
	 *     2002000c  2  R/W RX FIFO Pointer (0x0000 - 0x0fff)
	 *     2002000e  2  W   TX FIFO Pointer (0x0000 - 0x1fff)
	 */
	map(0x20020000, 0x2002000f).rw(FUNC(namcos22_state::namcos22_sci_r), FUNC(namcos22_state::namcos22_sci_w));

	/**
	 * System Controller: Interrupt Control, Peripheral Control
	 *
	 */
	map(0x40000000, 0x4000001f).rw(FUNC(namcos22_state::syscon_r), FUNC(namcos22_state::s22_syscon_w));

	/**
	 * Unknown Device (optional for diagnostics?)
	 *
	 * zero means not-connected.
	 * may be related to device at 0x90040000
	 */
	map(0x48000000, 0x4800003f).noprw();

	/**
	 * DIPSW
	 *     0x50000000 - DIPSW3
	 *     0x50000001 - DIPSW2
	 */
	map(0x50000000, 0x50000003).rw(FUNC(namcos22_state::namcos22_dipswitch_r), FUNC(namcos22_state::namcos22_cpuleds_w));
	map(0x50000008, 0x5000000b).rw(FUNC(namcos22_state::namcos22_portbit_r), FUNC(namcos22_state::namcos22_portbit_w));

	/**
	 * EEPROM
	 * Mounted position: CPU 9E
	 * Known chip type: HN58C65P-25 (8k x 8bit EEPROM)
	 */
	map(0x58000000, 0x58001fff).rw(m_eeprom, FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write));

	/**
	 * C74 (Mitsubishi M37702 MCU) Shared RAM (0x60004000 - 0x6000bfff)
	 * Mounted position: CPU 11L, 12L
	 * Known chip type: TC55328P-25, N341256P-15
	 *
	 * DATA ROM for C74 (SEQ data and external code):
	 * Known chip type: NEC D27C4096D-12
	 * Notes: C74(CPU PCB) sends/receives I/O data from C74(I/O PCB) by SIO.
	 *
	 * 0x60004020 b4 = 1 : ???
	 * 0x60004022.w     Volume(R)
	 * 0x60004024.w     Volume(L)
	 * 0x60004026.w     Volume(R) (maybe rear channels, not put on real PCB)
	 * 0x60004028.w     Volume(L) (maybe rear channels, not put on real PCB)
	 * 0x60004030 b0     : system type 0
	 * 0x60004030 b1 = 0 : COIN2
	 * 0x60004030 b2 = 0 : TEST SW
	 * 0x60004030 b3 = 0 : SERVICE SW
	 * 0x60004030 b4 = 0 : COIN1
	 * 0x60004030 b5     : system type 1
	 * (system type on RR2 (00:50inch, 01:two in one, 20:standard, 21:deluxe))
	 * 0x60004031 b0 = 0 : SWITCH1 (for manual transmission)
	 * 0x60004031 b1 = 0 : SWITCH2
	 * 0x60004031 b2 = 0 : SWITCH3
	 * 0x60004031 b3 = 0 : SWITCH4
	 * 0x60004031 b4 = 0 : CLUTCH
	 * 0x60004031 b6 = 0 : VIEW SW
	 * 0x60004032.w     Handle A/D (=steering wheel, default of center value is different in each game)
	 * 0x60004034.w     Gas A/D
	 * 0x60004036.w     Brake A/D
	 * 0x60004038.w     A/D3 (reserved)
	 * (some GOUT (general outputs for lamps, etc) is also mapped this area)
	 * 0x60004080       Data/Code for Sub-CPU
	 * 0x60004200       Data/Code for Sub-CPU
	 * 0x60005000 - 0x6000bfff  Sound Work
	 * +0x0000 - 0x003f Song Request #00 to 31
	 * +0x0100 - 0x02ff Parameter RAM from Main MPU (for SEs)
	 * +0x0300 - 0x03ff?    Song Title (put messages here from Sound CPU)
	 */
	map(0x60000000, 0x60003fff).nopw();
	map(0x60004000, 0x6000bfff).rw(FUNC(namcos22_state::namcos22_shared_r), FUNC(namcos22_state::namcos22_shared_w));

	/**
	 * C71 (TI TMS320C25 DSP) Shared RAM (0x70000000 - 0x70020000)
	 * Mounted position:
	 *     C71: CPU 15R, 21R
	 *     RAM: CPU 15K, 13E, 12E
	 * Known chip type: TC55328P-25, N341256P-15
	 * Notes: connected bits = 0x00ffffff (24bit)
	 */
	map(0x70000000, 0x7001ffff).rw(FUNC(namcos22_state::namcos22_dspram_r), FUNC(namcos22_state::namcos22_dspram_w)).share("polygonram");

	/**
	 * LED on PCB(?)
	 */
	map(0x90000000, 0x90000003).nopw();

	/**
	 * Depth-cueing Look-up Table (fog density between near to far)
	 * Mounted position: VIDEO 8P
	 * Known chip type: TC55328P-25
	 */
	map(0x90010000, 0x90017fff).ram().share("czram");

	/**
	 * C305 (Display Controller)
	 * Mounted position: VIDEO 7D (C305)
	 * Notes: Boot time check: 0x90020100 - 0x9002027f
	 */
	map(0x90020000, 0x90027fff).ram().share("video_mixer");

	/**
	 * Mounted position: VIDEO 6B, 7B, 8B (near C305)
	 * Note: 0xff00-0xffff are for Tilemap (16 x 16)
	 */
	map(0x90028000, 0x9003ffff).ram().w(FUNC(namcos22_state::namcos22_paletteram_w)).share("paletteram");

	/**
	 * unknown (option)
	 * Note: This device may be optional. This may relate to device at 0x48000000
	 */
	map(0x90040000, 0x9007ffff).nopr(); /* diagnostic ROM? */

	/**
	 * Tilemap PCG Memory
	 */
	map(0x90080000, 0x9009dfff).ram().w(FUNC(namcos22_state::namcos22_cgram_w)).share("cgram");

	/**
	 * Tilemap Memory (64 x 64)
	 * Mounted position: VIDEO  2K
	 * Known chip type: HM511664 (64k x 16bit SRAM)
	 * Note: Self test: 90084000 - 9009ffff
	 */
	map(0x9009e000, 0x9009ffff).ram().w(FUNC(namcos22_state::namcos22_textram_w)).share("textram");

	/**
	 * Tilemap Register
	 * Mounted position: unknown
	 */
	map(0x900a0000, 0x900a000f).rw(FUNC(namcos22_state::namcos22_tilemapattr_r), FUNC(namcos22_state::namcos22_tilemapattr_w));
}


// System Super22
void namcos22_state::namcos22s_am(address_map &map)
{
	map(0x000000, 0x3fffff).rom();
	map(0x400000, 0x40001f).rw(FUNC(namcos22_state::namcos22_keycus_r), FUNC(namcos22_state::namcos22_keycus_w));
	map(0x410000, 0x413fff).ram(); // C139 SCI buffer
	map(0x420000, 0x42000f).rw(FUNC(namcos22_state::namcos22_sci_r), FUNC(namcos22_state::namcos22_sci_w)); // C139 SCI registers
	map(0x430000, 0x430003).w(FUNC(namcos22_state::namcos22_cpuleds_w));
	map(0x440000, 0x440003).r(FUNC(namcos22_state::namcos22_dipswitch_r));
	map(0x450008, 0x45000b).rw(FUNC(namcos22_state::namcos22_portbit_r), FUNC(namcos22_state::namcos22_portbit_w));
	map(0x460000, 0x463fff).rw(m_eeprom, FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)).umask32(0xff00ff00);
	map(0x700000, 0x70001f).rw(FUNC(namcos22_state::syscon_r), FUNC(namcos22_state::ss22_syscon_w));
	map(0x800000, 0x800003).w(FUNC(namcos22_state::namcos22s_chipselect_w));
	map(0x810000, 0x81000f).rw(FUNC(namcos22_state::namcos22s_czattr_r), FUNC(namcos22_state::namcos22s_czattr_w));
	map(0x810200, 0x8103ff).rw(FUNC(namcos22_state::namcos22s_czram_r), FUNC(namcos22_state::namcos22s_czram_w));
	map(0x820000, 0x8202ff).nopw(); // leftover of old (non-super) video mixer device
	map(0x824000, 0x8243ff).ram().share("video_mixer");
	map(0x828000, 0x83ffff).ram().w(FUNC(namcos22_state::namcos22_paletteram_w)).share("paletteram");
	map(0x860000, 0x860007).rw(FUNC(namcos22_state::spotram_r), FUNC(namcos22_state::spotram_w));
	map(0x880000, 0x89dfff).ram().w(FUNC(namcos22_state::namcos22_cgram_w)).share("cgram");
	map(0x89e000, 0x89ffff).ram().w(FUNC(namcos22_state::namcos22_textram_w)).share("textram");
	map(0x8a0000, 0x8a000f).rw(FUNC(namcos22_state::namcos22_tilemapattr_r), FUNC(namcos22_state::namcos22_tilemapattr_w));
	map(0x900000, 0x90ffff).ram().share("vics_data");
	map(0x940000, 0x94007f).rw(FUNC(namcos22_state::namcos22s_vics_control_r), FUNC(namcos22_state::namcos22s_vics_control_w)).share("vics_control");
	map(0x980000, 0x9affff).ram().share("spriteram"); // C374
	map(0xa04000, 0xa0bfff).rw(FUNC(namcos22_state::namcos22_shared_r), FUNC(namcos22_state::namcos22_shared_w)); // COM RAM
	map(0xc00000, 0xc1ffff).rw(FUNC(namcos22_state::namcos22_dspram_r), FUNC(namcos22_state::namcos22_dspram_w)).share("polygonram");
	map(0xe00000, 0xe3ffff).ram(); // workram
}


// Time Crisis gun
READ32_MEMBER(namcos22_state::namcos22_gun_r)
{
	int xpos = ioport("LIGHTX")->read();
	int ypos = ioport("LIGHTY")->read();
	// ypos is not completely understood yet, there should be a difference between case 1 and 2
	// game determines real y = 430004 + 430008

	switch (offset)
	{
		case 0: /* 430000 */
			return xpos << 16;

		case 1: /* 430004 */
		case 2: /* 430008 */
			return ypos << 16;

		default:
			return 0;
	}
}

void namcos22_state::timecris_am(address_map &map)
{
	namcos22s_am(map);
	map(0x430000, 0x43000f).r(FUNC(namcos22_state::namcos22_gun_r));
}


// Alpine Surfer protection
READ32_MEMBER(namcos22_state::alpinesa_prot_r)
{
	return m_alpinesa_protection;
}

WRITE32_MEMBER(namcos22_state::alpinesa_prot_w)
{
	switch (data)
	{
		case 0:
			m_alpinesa_protection = 0;
			break;

		case 1:
			m_alpinesa_protection = 1;
			break;

		case 3:
			m_alpinesa_protection = 2;
			break;

		default:
			break;
	}
}

void namcos22_state::alpinesa_am(address_map &map)
{
	namcos22s_am(map);
	map(0x200000, 0x200003).r(FUNC(namcos22_state::alpinesa_prot_r));
	map(0x300000, 0x300003).w(FUNC(namcos22_state::alpinesa_prot_w));
}



/*********************************************************************************************/

// DSPs

void namcos22_state::master_enable(bool enable)
{
	m_master->set_input_line(INPUT_LINE_RESET, enable ? CLEAR_LINE : ASSERT_LINE);
}

void namcos22_state::slave_enable(bool enable)
{
	m_slave->set_input_line(INPUT_LINE_RESET, enable ? CLEAR_LINE : ASSERT_LINE);
	m_slave_simulation_active = enable;
}


READ16_MEMBER(namcos22_state::namcos22_dspram16_r)
{
	u32 value = m_polygonram[offset];

	switch (m_dspram_bank)
	{
		case 0:
			value &= 0xffff;
			break;

		case 1:
			value >>= 16;
			break;

		case 2:
			m_dspram16_latch = value >> 16;
			value &= 0xffff;
			break;

		default:
			break;
	}

	return value;
}

WRITE16_MEMBER(namcos22_state::namcos22_dspram16_w)
{
	u32 value = m_polygonram[offset];
	u16 lo = value & 0xffff;
	u16 hi = value >> 16;

	switch (m_dspram_bank)
	{
		case 0:
			COMBINE_DATA(&lo);
			break;

		case 1:
			COMBINE_DATA(&hi);
			break;

		case 2:
			COMBINE_DATA(&lo);
			hi = m_dspram16_latch;
			break;

		default:
			break;
	}

	m_polygonram[offset] = (hi << 16) | lo;
}

WRITE16_MEMBER(namcos22_state::namcos22_dspram16_bank_w)
{
	COMBINE_DATA(&m_dspram_bank);
}


void namcos22_state::point_write(offs_t offs, u32 data)
{
	offs &= 0x00ffffff; /* 24 bit addressing */
	if (m_is_ss22)
	{
		if (offs >= 0xf80000 && offs < 0xfa0000)
			m_pointram[offs - 0xf80000] = data & 0x00ffffff;
	}
	else
	{
		if (offs >= 0xf00000 && offs < 0xf20000)
			m_pointram[offs - 0xf00000] = data & 0x00ffffff;
	}
}

s32 namcos22_state::pointram_read(offs_t offs) // called from point_read
{
	// point ram, only used in ram test and ridgerac flag?
	s32 result = -1;
	if (m_is_ss22)
	{
		if (offs >= 0xf80000 && offs < 0xfa0000)
			result = m_pointram[offs - 0xf80000];
	}
	else
	{
		if (offs >= 0xf00000 && offs < 0xf20000)
			result = m_pointram[offs - 0xf00000];
	}

	// sign extend or crop
	return signed24(result);
}


WRITE16_MEMBER(namcos22_state::point_address_w)
{
	m_point_address <<= 16;
	m_point_address |= data;
}

WRITE16_MEMBER(namcos22_state::point_loword_iw)
{
	m_point_data |= data;
	point_write(m_point_address++, m_point_data);
}

WRITE16_MEMBER(namcos22_state::point_hiword_w)
{
	m_point_data = data << 16;
}

READ16_MEMBER(namcos22_state::point_loword_r)
{
	return point_read(m_point_address) & 0xffff;
}

READ16_MEMBER(namcos22_state::point_hiword_ir)
{
	// high bit is unknown busy signal (ridgerac, ridgera2, raveracw, cybrcomm)
	return 0x8000 | (point_read(m_point_address++) >> 16 & 0x00ff);
}


READ16_MEMBER(namcos22_state::pdp_status_r)
{
	return m_dsp_master_bioz;
}

READ16_MEMBER(namcos22_state::pdp_begin_r)
{
	if (machine().side_effects_disabled())
		return 0;

	/**
	* This presumably kickstarts the PDP(polygon display parser/processor?)
	* It parses through the displaylist and sends commands to the 3D render device.
	* In MAME, this main task is done in simulate_slavedsp instead. Ideally, we'd make the PDP a device with execute_run
	* SS22 supports more than just "goto" and render commands, they are handled here.
	*/
	m_pdp_frame = m_screen->frame_number();
	if (m_screen->vblank())
		m_pdp_frame++;
	m_pdp_render_done = true;

	m_dsp_master_bioz = 1;
	u16 offs = (m_is_ss22) ? pdp_polygonram_read(0x7fff) : m_pdp_base;

	if (!m_is_ss22)
		return 0;

	for (;;)
	{
		offs &= 0x7fff;
		u16 start = offs;
		u16 cmd = pdp_polygonram_read(offs++);
		u32 srcAddr;
		u32 dstAddr;
		u32 numWords;
		u32 data;
		switch (cmd)
		{
			case 0xfff0:
				// NOP? used in 'PDP LOOP TEST'
				break;

			case 0xfff5:
				// write to point ram
				dstAddr = pdp_polygonram_read(offs++); // 32 bit PointRAM address
				data    = pdp_polygonram_read(offs++); // 24 bit data
				point_write(dstAddr, data);
				break;

			case 0xfff6:
				/* read word from point ram */
				srcAddr = pdp_polygonram_read(offs++); // 32 bit PointRAM address
				dstAddr = pdp_polygonram_read(offs++); // CommRAM address; receives 24 bit PointRAM data
				data    = point_read(srcAddr);
				pdp_polygonram_write(dstAddr, data);
				break;

			case 0xfff7:
				// block move (CommRAM to CommRAM)
				srcAddr  = pdp_polygonram_read(offs++);
				dstAddr  = pdp_polygonram_read(offs++);
				numWords = pdp_polygonram_read(offs++);
				while (numWords--)
				{
					data = pdp_polygonram_read(srcAddr++);
					pdp_polygonram_write(dstAddr++, data);
				}
				break;

			case 0xfffa:
				// read block from point ram
				srcAddr  = pdp_polygonram_read(offs++); // 32 bit PointRAM address
				dstAddr  = pdp_polygonram_read(offs++); // CommRAM address; receives data
				numWords = pdp_polygonram_read(offs++); // block size
				while (numWords--)
				{
					data = point_read(srcAddr++);
					pdp_polygonram_write(dstAddr++, data);
				}
				break;

			case 0xfffb:
				// write block to point ram
				dstAddr  = pdp_polygonram_read(offs++); // 32 bit PointRAM address
				numWords = pdp_polygonram_read(offs++); // block size
				while (numWords--)
				{
					data = pdp_polygonram_read(offs++); // 24 bit source data
					point_write(dstAddr++, data);
				}
				break;

			case 0xfffc:
				// point ram to point ram
				srcAddr  = pdp_polygonram_read(offs++);
				dstAddr  = pdp_polygonram_read(offs++);
				numWords = pdp_polygonram_read(offs++);
				while (numWords--)
				{
					data = point_read(srcAddr++);
					point_write(dstAddr++, data);
				}
				break;

			case 0xfffd:
				// direct command to render device
				// len -> command (eg. BB0003) -> data
				numWords = pdp_polygonram_read(offs++);
				while (numWords--)
				{
					data = pdp_polygonram_read(offs++);
					//namcos22_WriteDataToRenderDevice(data);
				}
				break;

			case 0xfffe:
				// unknown
				data = pdp_polygonram_read(offs++); // ??? (usually 0x400 or 0)
				break;

			case 0xffff:
				// "goto" command
				offs = pdp_polygonram_read(offs) & 0x7fff;
				if (offs == start)
				{
					// MAME will get stuck with a "goto self", so bail out
					// in reality, the cpu can overwrite this address or retrigger pdp_begin
					return 0;
				}
				break;

			default:
				logerror("unknown PDP cmd = 0x%04x!\n", cmd);
				return 0;
		}
	}

	return 0;
}

READ16_MEMBER(namcos22_state::dsp_hold_signal_r)
{
	/* STUB */
	return 0;
}

WRITE16_MEMBER(namcos22_state::dsp_hold_ack_w)
{
	/* STUB */
}

WRITE16_MEMBER(namcos22_state::dsp_xf_output_w)
{
	/* STUB */
}

WRITE16_MEMBER(namcos22_state::dsp_unk2_w)
{
	/**
	* Used by Ridge Racer (Japan) to specify baseaddr
	* for post-processed display-list output.
	*
	* Prop Cycle doesn't use this; instead it writes this
	* addr to the uppermost word of CommRAM.
	*/
	m_pdp_base = data;
}

READ16_MEMBER(namcos22_state::dsp_unk_port3_r)
{
	m_dsp_master_bioz = 0;
	m_dsp_upload_state = NAMCOS22_DSP_UPLOAD_READY;
	return 0;
}

WRITE16_MEMBER(namcos22_state::upload_code_to_slave_dsp_w)
{
	switch (m_dsp_upload_state)
	{
		case NAMCOS22_DSP_UPLOAD_READY:
			logerror("UPLOAD_READY; cmd = 0x%x\n", data);

			switch (data)
			{
				case 0x00:
					slave_enable(false);
					break;

				case 0x01:
					m_dsp_upload_state = NAMCOS22_DSP_UPLOAD_DEST;
					break;

				case 0x02:
					/* custom IC poke */
					break;

				case 0x03:
					slave_enable(true);
					break;

				case 0x04:
					break;

				case 0x10:
					/* serial i/o related? */
					slave_enable(true);
					break;

				default:
					logerror("%08x: master port#7: 0x%04x\n", m_master->pcbase(), data);
					break;
			}
			break;

		case NAMCOS22_DSP_UPLOAD_DEST:
			m_UploadDestIdx = data;
			m_dsp_upload_state = NAMCOS22_DSP_UPLOAD_DATA;
			break;

		case NAMCOS22_DSP_UPLOAD_DATA:
			m_slave_extram[m_UploadDestIdx & 0x1fff] = data;
			m_UploadDestIdx++;
			break;

		default:
			break;
	}
}

READ16_MEMBER(namcos22_state::dsp_unk8_r)
{
	/* bit 0x0001 is busy signal */
	return 0x0000;
}

READ16_MEMBER(namcos22_state::custom_ic_status_r)
{
	/* bit 0x0001 signals completion */
	return 0x0063;
}

READ16_MEMBER(namcos22_state::dsp_upload_status_r)
{
	/* bit 0x0001 is polled to confirm that code/data has been successfully uploaded to the slave dsp via port 0x7. */
	return 0x0000;
}

WRITE16_MEMBER(namcos22_state::slave_serial_io_w)
{
	m_SerialDataSlaveToMasterNext = data;
	logerror("slave_serial_io_w(%04x)\n", data);
}

READ16_MEMBER(namcos22_state::master_serial_io_r)
{
	logerror("master_serial_io_r() == %04x\n", m_SerialDataSlaveToMasterCurrent);
	return m_SerialDataSlaveToMasterCurrent;
}

INTERRUPT_GEN_MEMBER(namcos22_state::dsp_vblank_irq)
{
	if (m_dsp_irq_enabled)
		device.execute().set_input_line(TMS32025_INT0, HOLD_LINE);
}

TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::dsp_serial_pulse)
{
	if (m_dsp_irq_enabled)
	{
		m_SerialDataSlaveToMasterCurrent = m_SerialDataSlaveToMasterNext;

		m_master->set_input_line(TMS32025_RINT, HOLD_LINE);
		m_master->set_input_line(TMS32025_XINT, HOLD_LINE);
		m_slave->set_input_line(TMS32025_RINT, HOLD_LINE);
		m_slave->set_input_line(TMS32025_XINT, HOLD_LINE);
	}
}

WRITE16_MEMBER(namcos22_state::dsp_unk_porta_w)
{
}

WRITE16_MEMBER(namcos22_state::dsp_led_w)
{
	/* I believe this port controls diagnostic LEDs on the DSP PCB. */
}

/**
 * master dsp usage pattern:
 *
 * 4059: out  $10,PA$8
 * 405A: in   $09,PA$8; lac  $09,0h; andk 0001h,0h; bnz  $405A *
 * 4060: out  $11,PA$8
 *
 * 4061: out  $10,PA$F
 * 4062: nop; rpt  *+; out  *+,PA$C // send data to 'render device'
 * 4065: out  $11,PA$F
 *
 * 4066: out  $10,PA$9
 * 4067: nop
 * 4068: out  $11,PA$9
 **************************************************************
 * 0x03a2 // 0x0fff zcode lo
 * 0x0001 // 0x000f zcode hi
 * 0xbd00 // color
 * 0x13a2 // flags
 *
 * 0x0100 0x009c // u,v
 * 0x0072 0xf307 // sx,sy
 * 0x602b 0x9f28 // i,zpos
 *
 * 0x00bf 0x0060 // u,v
 * 0x0040 0xf3ec // sx,sy
 * 0x602b 0xad48 // i,zpos
 *
 * 0x00fb 0x00ca // u,v
 * 0x0075 0xf205 // sx,sy
 * 0x602b 0x93e8 // i,zpos
 *
 * 0x00fb 0x00ca // u,v
 * 0x0075 0xf205 // sx,sy
 * 0x602b 0x93e8 // i,zpos
 */
WRITE16_MEMBER(namcos22_state::dsp_unk8_w)
{
	m_RenderBufSize = 0;
	m_render_refresh = true; // this one is more likely controlled by slavedsp somewhere
}

WRITE16_MEMBER(namcos22_state::master_render_device_w)
{
	if (m_RenderBufSize < NAMCOS22_MAX_RENDER_CMD_SEQ)
	{
		m_RenderBufData[m_RenderBufSize++] = data;
		if (m_RenderBufSize == NAMCOS22_MAX_RENDER_CMD_SEQ)
		{
			draw_direct_poly(m_RenderBufData);
		}
	}
}

void namcos22_state::master_dsp_program(address_map &map)
{
	map(0x0000, 0x0fff).rom(); /* internal ROM (4k words) */
	map(0x4000, 0x7fff).ram().share("masterextram").nopw();
}

void namcos22_state::master_dsp_data(address_map &map)
{
	map(0x1000, 0x3fff).ram();
	map(0x4000, 0x7fff).ram().share("masterextram");
	map(0x8000, 0xffff).rw(FUNC(namcos22_state::namcos22_dspram16_r), FUNC(namcos22_state::namcos22_dspram16_w));
}

void namcos22_state::master_dsp_io(address_map &map)
{
	map(0x0, 0x0).rw(FUNC(namcos22_state::point_loword_r), FUNC(namcos22_state::point_loword_iw));
	map(0x1, 0x1).rw(FUNC(namcos22_state::point_hiword_ir), FUNC(namcos22_state::point_hiword_w));
	map(0x2, 0x2).rw(FUNC(namcos22_state::pdp_begin_r), FUNC(namcos22_state::dsp_unk2_w));
	map(0x3, 0x3).rw(FUNC(namcos22_state::dsp_unk_port3_r), FUNC(namcos22_state::point_address_w));
	map(0x4, 0x4).nopw(); /* unknown */
	map(0x7, 0x7).w(FUNC(namcos22_state::upload_code_to_slave_dsp_w));
	map(0x8, 0x8).rw(FUNC(namcos22_state::dsp_unk8_r), FUNC(namcos22_state::dsp_unk8_w)); /* trigger irq? */
	map(0x9, 0x9).r(FUNC(namcos22_state::custom_ic_status_r)).nopw(); /* trigger irq? */
	map(0xa, 0xa).w(FUNC(namcos22_state::dsp_unk_porta_w));
	map(0xb, 0xb).nopw(); /* RINT-related? */
	map(0xc, 0xc).w(FUNC(namcos22_state::master_render_device_w));
	map(0xd, 0xd).w(FUNC(namcos22_state::namcos22_dspram16_bank_w));
	map(0xe, 0xe).w(FUNC(namcos22_state::dsp_led_w));
	map(0xf, 0xf).r(FUNC(namcos22_state::dsp_upload_status_r)).nopw();
}


READ16_MEMBER(namcos22_state::dsp_slave_bioz_r)
{
	/* STUB */
	return 1;
}

READ16_MEMBER(namcos22_state::dsp_slave_port3_r)
{
	return 0x0010; /* ? */
}

READ16_MEMBER(namcos22_state::dsp_slave_port4_r)
{
	return 0;
//  return ReadDataFromSlaveBuf();
}

READ16_MEMBER(namcos22_state::dsp_slave_port5_r)
{
#if 0
	int numWords = SlaveBufSize();
	int mode = 2;
	return (numWords<<4) | mode;
#endif
	return 0;
}

READ16_MEMBER(namcos22_state::dsp_slave_port6_r)
{
	/* bit 0x9 indicates whether device at port2 is ready to receive data */
	/* bit 0xd indicates whether data is available from port4 */
	return 0;
}

WRITE16_MEMBER(namcos22_state::dsp_slave_portc_w)
{
	/* Unknown; used before transmitting a command sequence. */
}

READ16_MEMBER(namcos22_state::dsp_slave_port8_r)
{
	/* This reports  status of the device mapped at port 0xb. */
	/* The slave dsp waits for bit 0x0001 to be zero before writing a new command sequence. */
	return 0; /* status */
}

READ16_MEMBER(namcos22_state::dsp_slave_portb_r)
{
	/* The slave DSP reads before transmitting a command sequence. */
	return 0;
}

WRITE16_MEMBER(namcos22_state::dsp_slave_portb_w)
{
	/* The slave dsp uses this to transmit a command sequence to an external device. */
}

void namcos22_state::slave_dsp_program(address_map &map)
{
	map(0x0000, 0x0fff).rom(); /* internal ROM */
	map(0x8000, 0x9fff).ram().share("slaveextram").nopw();
}

void namcos22_state::slave_dsp_data(address_map &map)
{
	map(0x8000, 0x9fff).ram().share("slaveextram");
}

void namcos22_state::slave_dsp_io(address_map &map)
{
	/* unknown signal */
	map(0x3, 0x3).r(FUNC(namcos22_state::dsp_slave_port3_r));

	map(0x4, 0x4).r(FUNC(namcos22_state::dsp_slave_port4_r));
	map(0x5, 0x5).r(FUNC(namcos22_state::dsp_slave_port5_r));
	map(0x6, 0x6).r(FUNC(namcos22_state::dsp_slave_port6_r)).nopw();

	/* render device state */
	map(0x8, 0x8).r(FUNC(namcos22_state::dsp_slave_port8_r)).nopw();

	/* render device */
	map(0xb, 0xb).rw(FUNC(namcos22_state::dsp_slave_portb_r), FUNC(namcos22_state::dsp_slave_portb_w));

	map(0xc, 0xc).w(FUNC(namcos22_state::dsp_slave_portc_w));
}


/*********************************************************************************************/

/*
  MCU memory map
  --------------
  000000-00027f: internal MCU registers and RAM
  002000-002fff: C352 PCM chip
  004000-00bfff: shared RAM with host CPU
  00c000-00ffff: BIOS ROM (internal on System22, external on Super)
  200000-27ffff: data ROM
  301000-301001: watchdog?
  308000-308003: unknown (I/O?)

  pin hookups
  -----------
  5 (IRQ0): C383 custom (probably vsync)
  7 (IRQ2): 74F244 at 8c, pin 3

  port assignments
  ----------------
  port 4: "bankswitches" the controls read at port 5, probably other functions too
  port 5: on read, digital controls (buttons, coins, start, service switch)
          on write, various outputs (lamps, the fan in prop cycle, etc)
  ADC   : analog inputs

*/

// System22 37702

READ8_MEMBER(namcos22_state::mcu_port4_s22_r)
{
	// for C74, 0x10 selects sound MCU role, 0x00 selects control-reading role
	return 0x10;
}

READ8_MEMBER(namcos22_state::iomcu_port4_s22_r)
{
	// for C74, 0x10 selects sound MCU role, 0x00 selects control-reading role
	return 0x00;
}

void namcos22_state::mcu_s22_program(address_map &map)
{
	map(0x002000, 0x002fff).rw("c352", FUNC(c352_device::read), FUNC(c352_device::write));
	map(0x004000, 0x00bfff).ram().share("shareram");
	map(0x200000, 0x27ffff).rom().region("mcu", 0);
}

void namcos22_state::iomcu_s22_program(address_map &map)
{
	// is there any external memory or MMIO on this one?
}

void namcos22_state::mcu_s22_io(address_map &map)
{
	map(M37710_PORT4, M37710_PORT4).r(FUNC(namcos22_state::mcu_port4_s22_r));
}

void namcos22_state::iomcu_s22_io(address_map &map)
{
	map(M37710_PORT4, M37710_PORT4).r(FUNC(namcos22_state::iomcu_port4_s22_r));
	map(0x00, 0xff).noprw();
}


// System Super22 M37710

TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::mcu_irq)
{
	int scanline = param;

	/* TODO: real sources of these */
	if (scanline == 480)
		m_mcu->set_input_line(M37710_LINE_IRQ0, HOLD_LINE);
	else if (scanline == 0)
		m_mcu->set_input_line(M37710_LINE_ADC, HOLD_LINE);
	else if (scanline == 240)
		m_mcu->set_input_line(M37710_LINE_IRQ2, HOLD_LINE);
}


WRITE8_MEMBER(namcos22_state::mcu_port4_w)
{
	m_p4 = data;
}

READ8_MEMBER(namcos22_state::mcu_port4_r)
{
	return m_p4;
}

WRITE8_MEMBER(namcos22_state::mcu_port5_w)
{
	;
}

READ8_MEMBER(namcos22_state::mcu_port5_r)
{
	if (m_p4 & 8)
		return m_mcup5a.read_safe(0xff);
	else
		return m_mcup5b.read_safe(0xff);
}

WRITE8_MEMBER(namcos22_state::mcu_port6_w)
{
	;
}

READ8_MEMBER(namcos22_state::mcu_port6_r)
{
	return 0;
}

WRITE8_MEMBER(namcos22_state::mcu_port7_w)
{
	;
}

READ8_MEMBER(namcos22_state::mcu_port7_r)
{
	return 0;
}

READ8_MEMBER(namcos22_state::namcos22s_mcu_adc_r)
{
	u16 adc = m_adc_ports[offset >> 1 & 7].read_safe(0) << 2;
	return (offset & 1) ? adc >> 8 : adc;
}

void namcos22_state::mcu_program(address_map &map)
{
	map(0x002000, 0x002fff).rw("c352", FUNC(c352_device::read), FUNC(c352_device::write));
	map(0x004000, 0x00bfff).ram().share("shareram");
	map(0x00c000, 0x00ffff).rom().region("mcu", 0xc000);
	map(0x200000, 0x27ffff).rom().region("mcu", 0);
	map(0x300000, 0x300001).nopr(); // ? (cybrcycc, alpinesa)
	map(0x301000, 0x301001).nopw(); // watchdog? LEDs?
	map(0x308000, 0x308003).nopw(); // volume control IC?
}

void namcos22_state::mcu_io(address_map &map)
{
	map(M37710_PORT4, M37710_PORT4).rw(FUNC(namcos22_state::mcu_port4_r), FUNC(namcos22_state::mcu_port4_w));
	map(M37710_PORT5, M37710_PORT5).rw(FUNC(namcos22_state::mcu_port5_r), FUNC(namcos22_state::mcu_port5_w));
	map(M37710_PORT6, M37710_PORT6).rw(FUNC(namcos22_state::mcu_port6_r), FUNC(namcos22_state::mcu_port6_w));
	map(M37710_PORT7, M37710_PORT7).rw(FUNC(namcos22_state::mcu_port7_r), FUNC(namcos22_state::mcu_port7_w));
	map(M37710_ADC0_L, M37710_ADC7_H).r(FUNC(namcos22_state::namcos22s_mcu_adc_r));
}

/*********************************************************************************************/

// custom input handling

/* TODO: REMOVE (THIS IS HANDLED BY "IOMCU") */
void namcos22_state::handle_coinage(u16 flags)
{
	int coin_state = (flags & 0x1000) >> 12 | (flags & 0x0200) >> 8;

	if (!(coin_state & 1) && (m_old_coin_state & 1))
		m_credits1++;

	if (!(coin_state & 2) && (m_old_coin_state & 2))
		m_credits2++;

	m_old_coin_state = coin_state;
	m_shareram[0x3a/2] = m_credits1 << 8 | m_credits2;
}

/* TODO: REMOVE (THIS IS HANDLED BY "IOMCU") */
void namcos22_state::handle_driving_io()
{
	if (m_syscontrol[0x18] != 0)
	{
		u16 flags = ioport("INPUTS")->read();
		u16 gas   = ioport("GAS")->read();
		u16 brake = ioport("BRAKE")->read();
		u16 steer = ioport("STEER")->read();

		switch (m_gametype)
		{
			case NAMCOS22_RIDGE_RACER:
			case NAMCOS22_RIDGE_RACER2:
				gas <<= 3;
				gas += 884;
				brake <<= 3;
				brake += 809;
				steer <<= 4;
				steer += 0x160;
				break;

			case NAMCOS22_RAVE_RACER:
				gas <<= 3;
				gas += 992;
				brake <<= 3;
				brake += 3008;
				steer <<= 4;
				steer += 32;
				break;

			case NAMCOS22_VICTORY_LAP:
			case NAMCOS22_ACE_DRIVER:
				gas <<= 3;
				gas += 992;
				brake <<= 3;
				brake += 3008;
				steer <<= 4;
				steer += 2048;
				break;

			default:
				gas <<= 3;
				brake <<= 3;
				steer <<= 4;
				break;
		}

		m_shareram[0x030/2] = flags;
		m_shareram[0x032/2] = steer;
		m_shareram[0x034/2] = gas;
		m_shareram[0x036/2] = brake;
		handle_coinage(flags);
	}
}

/* TODO: REMOVE (THIS IS HANDLED BY "IOMCU") */
void namcos22_state::handle_cybrcomm_io()
{
	if (m_syscontrol[0x18] != 0)
	{
		u16 flags = ioport("INPUTS")->read();
		u16 volume0 = ioport("STICKY1")->read() * 0x10;
		u16 volume1 = ioport("STICKY2")->read() * 0x10;
		u16 volume2 = ioport("STICKX1")->read() * 0x10;
		u16 volume3 = ioport("STICKX2")->read() * 0x10;

		m_shareram[0x030/2] = flags;
		m_shareram[0x032/2] = volume0;
		m_shareram[0x034/2] = volume1;
		m_shareram[0x036/2] = volume2;
		m_shareram[0x038/2] = volume3;
		handle_coinage(flags);
	}
}


// Alpine skiing games

TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::alpine_steplock_callback)
{
	m_motor_status = param;
}

WRITE8_MEMBER(namcos22_state::alpine_mcu_port5_w)
{
	// bits 1+2 are steplock motor outputs
	if ((data & 6) == 6)
	{
		if (m_motor_status == 2)
		{
			// free steps
			m_motor_status = 0;
			m_motor_timer->adjust(attotime::from_msec(500), 1);
		}
	}
	else if (data & 4)
	{
		if (m_motor_status == 1)
		{
			// lock steps
			m_motor_status = 0;
			m_motor_timer->adjust(attotime::from_msec(500), 2);
		}
	}
}

void namcos22_state::alpine_io_map(address_map &map)
{
	mcu_io(map);
	map(M37710_PORT5, M37710_PORT5).w(FUNC(namcos22_state::alpine_mcu_port5_w));
}


// Prop Cycle

WRITE8_MEMBER(namcos22_state::propcycle_mcu_port5_w)
{
	// prop cycle outputs:
	// bit 1 = fan
	// bit 2 = button light
	output().set_value("fan0", data & 1);
	m_led = BIT(data, 1);
}

void namcos22_state::propcycl_io_map(address_map &map)
{
	mcu_io(map);
	map(M37710_PORT5, M37710_PORT5).w(FUNC(namcos22_state::propcycle_mcu_port5_w));
}

TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::propcycl_pedal_interrupt)
{
	m_mcu->pulse_input_line(M37710_LINE_TIMERA3TICK, m_mcu->minimum_quantum_time());
}

TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::propcycl_pedal_update)
{
	// arbitrary timer for reading optical pedal
	u8 i = ioport("PEDAL")->read();

	if (i != 0)
	{
		// the pedal has a simple 1-bit "light interrupted" sensor. the faster you pedal,
		// the faster it pulses.  this is connected to the clock input for timer A3,
		// and timer A3 is configured by the MCU program to cause an interrupt each time
		// it's clocked. by counting the number of interrupts in a frame, we can determine
		// how fast the user is pedaling.

		// these values(in usec) may need tweaking:
		const int base = 750;
		const int range = 100000;

		attotime freq = attotime::from_usec(base + range * (1.0 / (double)i));
		m_pc_pedal_interrupt->adjust(std::min(freq, m_pc_pedal_interrupt->time_left()), 0, freq);
	}
	else
	{
		// not moving
		m_pc_pedal_interrupt->adjust(attotime::never, 0, attotime::never);
	}
}


// Armadillo Racing

TIMER_CALLBACK_MEMBER(namcos22_state::adillor_trackball_interrupt)
{
	m_mcu->pulse_input_line(param ? M37710_LINE_TIMERA2TICK : M37710_LINE_TIMERA3TICK, m_mcu->minimum_quantum_time());
}

TIMER_DEVICE_CALLBACK_MEMBER(namcos22_state::adillor_trackball_update)
{
	// arbitrary timer for reading optical trackball
	u8 ix = ioport("TRACKX")->read();
	u8 iy = ioport("TRACKY")->read();

	if (ix != 0x80 || iy < 0x80)
	{
		if (iy >= 0x80)
			iy = 0x7f;
		double x = (double)(ix - 0x80) / 127.0;
		double y = (double)(0x80 - iy) / 127.0;

		// normalize
		double a = atan(x/y);
		double p = sqrt(x*x + y*y);
		double v = (fabs(a) < (M_PI / 4.0)) ? p*cos(a) : p*sin(a);
		v = fabs(v);

		// note that it is rotated by 45 degrees, so instead of axes like (+), they are like (x)
		a += (M_PI / 4.0);
		if (a < 0)
			a = 0;
		else if (a > (M_PI / 2.0))
			a = M_PI / 2.0;

		// tied to mcu A2/A3 timer (speed determines frequency)
		// these values(in hz) may need tweaking:
		const double base = 20;
		const double range = 1250;

		double t[2];
		t[0] = v*sin(a); // y -> A2
		t[1] = v*cos(a); // x -> A3

		for (int axis = 0; axis < 2; axis++)
		{
			if (t[axis] > (1.0 / range))
			{
				attotime freq = attotime::from_hz(base + range * t[axis]);
				m_ar_tb_interrupt[axis]->adjust(std::min(freq, m_ar_tb_interrupt[axis]->remaining()), axis, freq);
			}
			else
			{
				// not moving
				m_ar_tb_interrupt[axis]->adjust(attotime::never, axis, attotime::never);
			}
		}
	}
	else
	{
		// both axes not moving
		for (int axis = 0; axis < 2; axis++)
		{
			m_ar_tb_interrupt[axis]->adjust(attotime::never, axis, attotime::never);
		}
	}
}



/*********************************************************************************************/

static INPUT_PORTS_START( ridgera )
	PORT_START("INPUTS")
	/*  1 3 5   When the cabinet is set to Deluxe, the stick shift is basically
	    |-|-|   an 8-way joystick that locks into place.
	    2 4 6   Standard (default) setup uses a racing shifter like in Ace Driver. */
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP   ) PORT_NAME("Shift Down")
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_NAME("Shift Up")
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_NAME("Shift Left")    // not used in Standard Cabinet
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_NAME("Shift Right")   // not used in Standard Cabinet
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Clutch Pedal")        // not used in Standard Cabinet
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_CONFNAME( 0x0100, 0x0000, DEF_STR( Cabinet ) ) // @ JAMMA pins
	PORT_CONFSETTING(      0x0000, DEF_STR( Standard ) )
	PORT_CONFSETTING(      0x0100, "Deluxe" )
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_SERVICE3 ) // also service mode?
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("DSW0")
	PORT_SERVICE_DIPLOC( 0x0001, IP_ACTIVE_LOW, "SW2:1")
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW2:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW2:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW2:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW2:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW2:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW2:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW2:8" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0100, 0x0100, "SW3:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0200, 0x0200, "SW3:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0400, 0x0400, "SW3:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0800, 0x0800, "SW3:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x1000, 0x1000, "SW3:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x2000, 0x2000, "SW3:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x4000, 0x4000, "SW3:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x8000, 0x8000, "SW3:8" )

	PORT_START("GAS")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL )  PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Gas Pedal")

	PORT_START("BRAKE")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL2 ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Brake Pedal")

	PORT_START("STEER")
	PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Steering Wheel")
INPUT_PORTS_END

static INPUT_PORTS_START( ridgeracf )
	PORT_INCLUDE( ridgera )

	PORT_MODIFY("INPUTS")
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Ignition Key")
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("AT Switch")
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("MT Switch")
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_SERVICE2 )
	PORT_SERVICE( 0x0400, IP_ACTIVE_LOW )

	// DIP3-1 to DIP3-3 are for setting up the viewing angle (game used one board per screen?)
	// Some of the other dipswitches are for debugging, like with Ridge Racer 2.
	PORT_MODIFY("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0000, "SW2:1" ) // always on?
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0000, "SW2:2" ) // always on?
	PORT_DIPNAME( 0x8000, 0x8000, "Test Mode" ) PORT_DIPLOCATION("SW3:8")
	PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
INPUT_PORTS_END

static INPUT_PORTS_START( ridgera2 )
	PORT_INCLUDE( ridgera )

	PORT_MODIFY("INPUTS")
	PORT_CONFNAME( 0x2100, 0x2000, DEF_STR( Cabinet ) ) // @ JAMMA pins
	PORT_CONFSETTING(      0x0000, "50 Inch" )
	PORT_CONFSETTING(      0x0100, "Twin" )
	PORT_CONFSETTING(      0x2000, DEF_STR( Standard ) )
	PORT_CONFSETTING(      0x2100, "Deluxe" )

	/* Some dipswitches seem to be for debug purposes, for example:
	    2-4 : background drawing related
	    2-5 : background drawing related
	    2-6 : debug link-up
	    2-8 : no game over when time runs out (cheat)
	    3-7 : debug polygons
	*/
	PORT_MODIFY("DSW0")
	PORT_DIPNAME( 0x8000, 0x8000, "Test Mode" ) PORT_DIPLOCATION("SW3:8")
	PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
INPUT_PORTS_END

static INPUT_PORTS_START( raveracw )
	PORT_INCLUDE( ridgera )

	PORT_MODIFY("INPUTS")
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("View Change")

	PORT_CONFNAME( 0x2100, 0x2000, DEF_STR( Cabinet ) ) // @ JAMMA pins
	PORT_CONFSETTING(      0x0000, "50 Inch" )
	PORT_CONFSETTING(      0x0100, "Twin" )
	PORT_CONFSETTING(      0x2000, DEF_STR( Standard ) )
	PORT_CONFSETTING(      0x2100, "Deluxe" )
INPUT_PORTS_END


static INPUT_PORTS_START( cybrcomm )
	PORT_START("INPUTS")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gun Trigger")     // placed on both sticks
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Missile Button")  // placed on both sticks
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("View Change")
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_SERVICE( 0x0400, IP_ACTIVE_LOW )
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )

	/* Note(s)
	    The ranges here are based on the test mode which displays +-224
	    The eeprom is calibrated using these settings.  If the SUBCPU handling changes then these might
	    end up needing to change again too
	    Default key arrangement is based on dual-joystick 'Tank' arrangement found in Assault and CyberSled
	*/
	PORT_START("STICKY1") /* VOLUME 1 */
	PORT_BIT( 0xff, 0x7f, IPT_AD_STICK_Y ) PORT_MINMAX(0x47,0xb7) /* range based on test mode */ PORT_CODE_DEC(KEYCODE_I) PORT_CODE_INC(KEYCODE_K) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(2) /* right joystick: vertical */
	PORT_START("STICKX1") /* VOLUME 2 */
	PORT_BIT( 0xff, 0x7f, IPT_AD_STICK_X ) PORT_MINMAX(0x47,0xb7) /* range based on test mode */ PORT_CODE_DEC(KEYCODE_J) PORT_CODE_INC(KEYCODE_L) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(2) /* right joystick: horizontal */
	PORT_START("STICKY2") /* VOLUME 3 */
	PORT_BIT( 0xff, 0x7f, IPT_AD_STICK_Y ) PORT_MINMAX(0x47,0xb7) /* range based on test mode */ PORT_CODE_DEC(KEYCODE_E) PORT_CODE_INC(KEYCODE_D) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(1) /* left joystick: vertical */
	PORT_START("STICKX2") /* VOLUME 4 */
	PORT_BIT( 0xff, 0x7f, IPT_AD_STICK_X ) PORT_MINMAX(0x47,0xb7) /* range based on test mode */ PORT_CODE_DEC(KEYCODE_S) PORT_CODE_INC(KEYCODE_F) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(1) /* left joystick: horizontal */

	PORT_START("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0001, "SW2:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW2:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW2:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW2:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW2:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW2:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW2:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW2:8" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0100, 0x0100, "SW3:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0200, 0x0200, "SW3:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0400, 0x0400, "SW3:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0800, 0x0800, "SW3:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x1000, 0x1000, "SW3:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x2000, 0x2000, "SW3:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x4000, 0x4000, "SW3:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x8000, 0x8000, "SW3:8" )
INPUT_PORTS_END

static INPUT_PORTS_START( acedrvr )
	PORT_START("INPUTS")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP   ) PORT_NAME("Shift Down")
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_NAME("Shift Up")
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("View Change")
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Motion-Stop")

	PORT_START("P1")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("Dev Service Enter")
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_NAME("Dev Service Up")
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_NAME("Dev Service Down")
	PORT_BIT( 0xff3e, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0001, "SW2:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW2:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW2:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW2:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW2:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW2:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW2:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW2:8" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0100, 0x0100, "SW3:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0200, 0x0200, "SW3:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0400, 0x0400, "SW3:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0800, 0x0800, "SW3:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x1000, 0x1000, "SW3:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x2000, 0x2000, "SW3:6" )
	PORT_DIPNAME( 0x4000, 0x4000, "Test Mode?" ) PORT_DIPLOCATION("SW3:7")
	PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x8000, 0x8000, "Test Mode?" ) PORT_DIPLOCATION("SW3:8")
	PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )

	PORT_START("GAS")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL )  PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Gas Pedal")

	PORT_START("BRAKE")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL2 ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Brake Pedal")

	PORT_START("STEER")
	PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Steering Wheel")
INPUT_PORTS_END

static INPUT_PORTS_START( victlap )
	PORT_INCLUDE( acedrvr )

	PORT_MODIFY("P1")
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_NAME("Dev Service Up")
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_NAME("Dev Service Down")
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("Dev Service Enter")
	PORT_BIT( 0xfe3f, IP_ACTIVE_LOW, IPT_UNKNOWN )
INPUT_PORTS_END

/*********************************************************************************************/

CUSTOM_INPUT_MEMBER(namcos22_state::alpine_motor_read)
{
	return m_motor_status >> (uintptr_t)param & 1;
}

static INPUT_PORTS_START( alpiner )
	PORT_START("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0001, "SW4:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) // Decision / View Change
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_16WAY // L Selection
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_16WAY // R Selection
	PORT_BIT( 0x80, IP_ACTIVE_HIGH,IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, namcos22_state,alpine_motor_read, (void *)0) // steps are free

	PORT_START("MCUP5B")
	PORT_BIT( 0x01, IP_ACTIVE_HIGH,IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, namcos22_state,alpine_motor_read, (void *)1) // steps are locked
	PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("ADC.0")
	PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(4) PORT_NAME("Steps Swing")

	PORT_START("ADC.1")
	PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(4) PORT_PLAYER(2) PORT_NAME("Steps Edge")
INPUT_PORTS_END

static INPUT_PORTS_START( airco22 )
	PORT_START("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0001, "SW4:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Missile Button")
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gun Trigger")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) // also view-change function
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5B")
	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("ADC.0")
	PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0x40, 0xc0) PORT_SENSITIVITY(100) PORT_KEYDELTA(3)

	PORT_START("ADC.1")
	PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x40, 0xc0) PORT_SENSITIVITY(100) PORT_KEYDELTA(3)

	PORT_START("ADC.2") // throttle stick auto-centers
	PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Z ) PORT_MINMAX(0x40, 0xc0) PORT_SENSITIVITY(100) PORT_KEYDELTA(3) PORT_NAME("Throttle Stick")
INPUT_PORTS_END

static INPUT_PORTS_START( cybrcycc )
	PORT_START("DSW0")
	PORT_DIPNAME( 0x0001, 0x0001, "Test Mode?" ) PORT_DIPLOCATION("SW4:1")
	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) // also view-change function
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5B")
	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("ADC.0")
	PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Steering Wheel")

	PORT_START("ADC.1")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL )  PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Gas Pedal")

	PORT_START("ADC.2")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL2 ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Brake Pedal")
INPUT_PORTS_END

static INPUT_PORTS_START( dirtdash )
	PORT_START("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0001, "SW4:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("View Change")
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_NAME("Shift Up")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_NAME("Shift Down")
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Motion-Stop")

	PORT_START("MCUP5B")
	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("ADC.0")
	PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(100) PORT_KEYDELTA(3) PORT_NAME("Steering Wheel")

	PORT_START("ADC.1")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL )  PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Gas Pedal")

	PORT_START("ADC.2")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL2 ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Brake Pedal")
INPUT_PORTS_END

static INPUT_PORTS_START( tokyowar )
	PORT_START("DSW0")
	PORT_DIPNAME( 0x0001, 0x0001, "Test Mode?" ) PORT_DIPLOCATION("SW4:1")
	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) // also view-change function
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Right Trigger")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Left Trigger")
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5B")
	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("ADC.0")
	PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Steering Wheel")

	PORT_START("ADC.2")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL )  PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Gas Pedal")

	PORT_START("ADC.3")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL2 ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_NAME("Brake Pedal")
INPUT_PORTS_END

static INPUT_PORTS_START( aquajet )
	PORT_START("DSW0")
	PORT_DIPNAME( 0x0001, 0x0001, "Test Mode?" ) PORT_DIPLOCATION("SW4:1")
	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5B")
	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("ADC.0")
	PORT_BIT( 0xff, 0x7f, IPT_PADDLE ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE

	PORT_START("ADC.1")
	PORT_BIT( 0xff, 0x00, IPT_PEDAL ) PORT_MINMAX(0x00, 0x80) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE

	PORT_START("ADC.2")
	PORT_BIT( 0xff, 0x7f, IPT_AD_STICK_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE
INPUT_PORTS_END

static INPUT_PORTS_START( adillor )
	PORT_START("DSW0")
	PORT_DIPNAME( 0x0001, 0x0001, "Test Mode?" ) PORT_DIPLOCATION("SW4:1")
	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("P1")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("Dev Service Enter")
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("Dev Service Exit")
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_NAME("Dev Service Left")
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_NAME("Dev Service Right") // when in normal testmode, press this to enter the extra testmode
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_NAME("Dev Service Up")
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_NAME("Dev Service Down")
	PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5B")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
	PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("TRACKX")
	PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0x01, 0xff) PORT_SENSITIVITY(100) PORT_KEYDELTA(20) PORT_NAME("Trackball X")

	PORT_START("TRACKY")
	PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x01, 0xff) PORT_SENSITIVITY(100) PORT_KEYDELTA(20) PORT_NAME("Trackball Y")
INPUT_PORTS_END

static INPUT_PORTS_START( propcycl )
	PORT_START("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0001, "SW4:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0080, 0x0080, "SW4:8" )
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5B")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
	PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("ADC.0")
	PORT_BIT( 0xff, 0x7f, IPT_AD_STICK_X ) PORT_MINMAX(0x00, 0xfe) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE

	PORT_START("ADC.1")
	PORT_BIT( 0xff, 0x7f, IPT_AD_STICK_Y ) PORT_MINMAX(0x00, 0xfe) PORT_SENSITIVITY(100) PORT_KEYDELTA(10)

	PORT_START("PEDAL")
	PORT_BIT( 0x7f, 0x00, IPT_PEDAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10)
INPUT_PORTS_END

static INPUT_PORTS_START( timecris )
	PORT_START("DSW0")
	PORT_DIPUNKNOWN_DIPLOC( 0x0001, 0x0001, "SW4:1" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0002, 0x0002, "SW4:2" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0004, 0x0004, "SW4:3" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0008, 0x0008, "SW4:4" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0010, 0x0010, "SW4:5" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0020, 0x0020, "SW4:6" )
	PORT_DIPUNKNOWN_DIPLOC( 0x0040, 0x0040, "SW4:7" )
	PORT_SERVICE_DIPLOC( 0x0080, IP_ACTIVE_LOW, "SW4:8")
	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("MCUP5A")
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gun Trigger")
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Foot Pedal")
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START("MCUP5B")
	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )

	PORT_START( "LIGHTX" ) // tuned for CRT
	PORT_BIT( 0xfff, 68+626/2, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_MINMAX(68, 68+626) PORT_SENSITIVITY(48) PORT_KEYDELTA(10)

	PORT_START( "LIGHTY" ) // tuned for CRT - can't shoot below the statusbar?
	PORT_BIT( 0xfff, 43+241/2, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_MINMAX(43, 43+241) PORT_SENSITIVITY(64) PORT_KEYDELTA(4)
INPUT_PORTS_END



/*********************************************************************************************/

/* System Super22 supports a sprite layer.
 * Sprites are rendered as part of the polygon draw list, based on a per-sprite Z attribute.
 * Each sprite has explicit placement/color/zoom controls.
 */
static const gfx_layout sprite_layout =
{
	32,32,
	RGN_FRAC(1,1),
	8,
	{ 0,1,2,3,4,5,6,7 },
	{
		0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8,
		8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8,
		16*8,17*8,18*8,19*8,20*8,21*8,22*8,23*8,
		24*8,25*8,26*8,27*8,28*8,29*8,30*8,31*8
	},
	{
		0*32*8,1*32*8,2*32*8,3*32*8,4*32*8,5*32*8,6*32*8,7*32*8,
		8*32*8,9*32*8,10*32*8,11*32*8,12*32*8,13*32*8,14*32*8,15*32*8,
		16*32*8,17*32*8,18*32*8,19*32*8,20*32*8,21*32*8,22*32*8,23*32*8,
		24*32*8,25*32*8,26*32*8,27*32*8,28*32*8,29*32*8,30*32*8,31*32*8
	},
	32*32*8
};

static const gfx_layout texture_tile_layout =
{
	16,16,
	RGN_FRAC(1,1),
	8,
	{ 0,1,2,3,4,5,6,7 },
	{
		0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8,8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8
	},
	{
		0*16*8,1*16*8,2*16*8,3*16*8,4*16*8,5*16*8,6*16*8,7*16*8,
		8*16*8,9*16*8,10*16*8,11*16*8,12*16*8,13*16*8,14*16*8,15*16*8
	},
	16*16*8
};

/* text layer uses a set of 16x16x8bpp tiles defined in RAM */
#define XOR(a) WORD2_XOR_BE(a)
static const gfx_layout namcos22_cg_layout =
{
	16,16,
	0x400, /* 0x3c0 */
	4,
	{ 0,1,2,3 },
	{ XOR(0)*4,  XOR(1)*4,  XOR(2)*4,  XOR(3)*4,  XOR(4)*4,  XOR(5)*4,  XOR(6)*4,  XOR(7)*4,
		XOR(8)*4,  XOR(9)*4, XOR(10)*4, XOR(11)*4, XOR(12)*4, XOR(13)*4, XOR(14)*4, XOR(15)*4 },
	{ 64*0,64*1,64*2,64*3,64*4,64*5,64*6,64*7,64*8,64*9,64*10,64*11,64*12,64*13,64*14,64*15 },
	64*16
};

#undef XOR

static GFXDECODE_START( gfx_namcos22 )
	GFXDECODE_ENTRY( nullptr,   0, namcos22_cg_layout,   0, 0x800 )
	GFXDECODE_ENTRY( "textile", 0, texture_tile_layout,  0, 0x80 )
GFXDECODE_END

static GFXDECODE_START( gfx_super )
	GFXDECODE_ENTRY( nullptr,   0, namcos22_cg_layout,   0, 0x800 )
	GFXDECODE_ENTRY( "textile", 0, texture_tile_layout,  0, 0x80 )
	GFXDECODE_ENTRY( "sprite",  0, sprite_layout,        0, 0x80 )
GFXDECODE_END


void namcos22_state::machine_reset()
{
	master_enable(false);
	slave_enable(false);
	m_dsp_irq_enabled = false;
	if (!m_is_ss22) m_iomcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
	m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
}

void namcos22_state::device_post_load()
{
	m_gfxdecode->gfx(0)->mark_all_dirty();
}

// allow save_item on a non-fundamental type
ALLOW_SAVE_TYPE(namcos22_dsp_upload_state);

void namcos22_state::machine_start()
{
	m_led.resolve();
	m_cpuled.resolve();
	m_portbits[0] = 0xffff;
	m_portbits[1] = 0xffff;

	m_keycus_rng = 0;
	m_su_82 = 0;
	m_irq_state = 0;
	m_p4 = 0;
	m_old_coin_state = 0;
	m_credits1 = m_credits2 = 0;

	// register for savestates, stuff that isn't done in video_start()
	// note: namcos22_renderer class doesn't need saving, it is refreshed every frame
	save_item(NAME(m_poly_translucency));
	save_item(NAME(m_mixer_flags));
	save_item(NAME(m_fog_r));
	save_item(NAME(m_fog_g));
	save_item(NAME(m_fog_b));
	save_item(NAME(m_fog_colormask));
	save_item(NAME(m_screen_fade_r));
	save_item(NAME(m_screen_fade_g));
	save_item(NAME(m_screen_fade_b));
	save_item(NAME(m_screen_fade_factor));
	save_item(NAME(m_poly_fade_r));
	save_item(NAME(m_poly_fade_g));
	save_item(NAME(m_poly_fade_b));
	save_item(NAME(m_poly_fade_enabled));

	save_item(NAME(m_syscontrol));
	save_item(NAME(m_dsp_irq_enabled));
	save_item(NAME(m_dsp_master_bioz));
	save_item(NAME(m_old_coin_state));
	save_item(NAME(m_credits1));
	save_item(NAME(m_credits2));
	save_item(NAME(m_point_address));
	save_item(NAME(m_point_data));
	save_item(NAME(m_SerialDataSlaveToMasterNext));
	save_item(NAME(m_SerialDataSlaveToMasterCurrent));
	save_item(NAME(m_RenderBufSize));
	save_item(NAME(m_RenderBufData));
	save_item(NAME(m_portbits));
	save_item(NAME(m_irq_state));
	save_item(NAME(m_irq_enabled));
	save_item(NAME(m_dsp_upload_state));
	save_item(NAME(m_UploadDestIdx));
	save_item(NAME(m_alpinesa_protection));
	save_item(NAME(m_motor_status));
	save_item(NAME(m_p4));
	save_item(NAME(m_su_82));
	save_item(NAME(m_keycus_id));
	save_item(NAME(m_keycus_rng));
	save_item(NAME(m_chipselect));
	save_item(NAME(m_spotram_enable));
	save_item(NAME(m_spotram_address));
	save_item(NAME(m_cz_adjust));
	save_item(NAME(m_dspram_bank));
	save_item(NAME(m_dspram16_latch));
	save_item(NAME(m_slave_simulation_active));
	save_item(NAME(m_absolute_priority));
	save_item(NAME(m_objectshift));
	save_item(NAME(m_viewmatrix));
	save_item(NAME(m_LitSurfaceInfo));
	save_item(NAME(m_SurfaceNormalFormat));
	save_item(NAME(m_LitSurfaceCount));
	save_item(NAME(m_LitSurfaceIndex));
	save_item(NAME(m_tilemapattr));
	save_item(NAME(m_spot_factor));
	save_item(NAME(m_text_palbase));
	save_item(NAME(m_bg_palbase));
	save_item(NAME(m_camera_zoom));
	save_item(NAME(m_camera_vx));
	save_item(NAME(m_camera_vy));
	save_item(NAME(m_camera_vu));
	save_item(NAME(m_camera_vd));
	save_item(NAME(m_camera_vl));
	save_item(NAME(m_camera_vr));
	save_item(NAME(m_camera_lx));
	save_item(NAME(m_camera_ly));
	save_item(NAME(m_camera_lz));
	save_item(NAME(m_camera_ambient));
	save_item(NAME(m_camera_power));
	save_item(NAME(m_reflection));
	save_item(NAME(m_cullflip));
	save_item(NAME(m_skipped_this_frame));
	save_item(NAME(m_pdp_render_done));
	save_item(NAME(m_render_refresh));
	save_item(NAME(m_pdp_frame));
	save_item(NAME(m_pdp_base));
}

// System22
MACHINE_CONFIG_START(namcos22_state::namcos22)

	/* basic machine hardware */
	MCFG_DEVICE_ADD("maincpu", M68020, 49.152_MHz_XTAL/2) // MC68020RP25E
	MCFG_DEVICE_PROGRAM_MAP(namcos22_am)
	MCFG_DEVICE_VBLANK_INT_DRIVER("screen", namcos22_state, namcos22_interrupt)

	tms32025_device& master(TMS32025(config, m_master, 40_MHz_XTAL));
	master.set_addrmap(AS_PROGRAM, &namcos22_state::master_dsp_program);
	master.set_addrmap(AS_DATA, &namcos22_state::master_dsp_data);
	master.set_addrmap(AS_IO, &namcos22_state::master_dsp_io);
	master.bio_in_cb().set(FUNC(namcos22_state::pdp_status_r));
	master.hold_in_cb().set(FUNC(namcos22_state::dsp_hold_signal_r));
	master.hold_ack_out_cb().set(FUNC(namcos22_state::dsp_hold_ack_w));
	master.xf_out_cb().set(FUNC(namcos22_state::dsp_xf_output_w));
	master.dr_in_cb().set(FUNC(namcos22_state::master_serial_io_r));
	master.set_vblank_int("screen", FUNC(namcos22_state::dsp_vblank_irq));
	MCFG_TIMER_DRIVER_ADD_PERIODIC("dsp_serial", namcos22_state, dsp_serial_pulse, attotime::from_hz(SERIAL_IO_PERIOD))

	tms32025_device& slave(TMS32025(config, m_slave, 40_MHz_XTAL));
	slave.set_addrmap(AS_PROGRAM, &namcos22_state::slave_dsp_program);
	slave.set_addrmap(AS_DATA, &namcos22_state::slave_dsp_data);
	slave.set_addrmap(AS_IO, &namcos22_state::slave_dsp_io);
	slave.bio_in_cb().set(FUNC(namcos22_state::dsp_slave_bioz_r));
	slave.hold_in_cb().set(FUNC(namcos22_state::dsp_hold_signal_r));
	slave.hold_ack_out_cb().set(FUNC(namcos22_state::dsp_hold_ack_w));
	slave.xf_out_cb().set(FUNC(namcos22_state::dsp_xf_output_w));
	slave.dx_out_cb().set(FUNC(namcos22_state::slave_serial_io_w));

	MCFG_DEVICE_ADD("mcu", NAMCO_C74, 49.152_MHz_XTAL/3) // C74 on the CPU board has no periodic interrupts, it runs entirely off Timer A0
	MCFG_DEVICE_PROGRAM_MAP(mcu_s22_program)
	MCFG_DEVICE_IO_MAP(mcu_s22_io)

	MCFG_DEVICE_ADD("iomcu", NAMCO_C74, 6.144_MHz_XTAL)
	MCFG_DEVICE_PROGRAM_MAP(iomcu_s22_program)
	MCFG_DEVICE_IO_MAP(iomcu_s22_io)

	EEPROM_2864(config, "eeprom").write_time(attotime::from_nsec(10));

	/* video hardware */
	MCFG_SCREEN_ADD("screen", RASTER)
	//MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
	MCFG_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART)
	MCFG_SCREEN_UPDATE_DRIVER(namcos22_state, screen_update_namcos22)
	MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, namcos22_state, screen_vblank))

	MCFG_PALETTE_ADD("palette", 0x8000)
	MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_namcos22)

	/* sound hardware */
	SPEAKER(config, "lspeaker").front_left();
	SPEAKER(config, "rspeaker").front_right();

	MCFG_DEVICE_ADD("c352", C352, 49.152_MHz_XTAL/2, 288)
	MCFG_SOUND_ROUTE(0, "lspeaker", 1.00)
	MCFG_SOUND_ROUTE(1, "rspeaker", 1.00)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::cybrcomm)
	namcos22(config);

	SPEAKER(config, "rear_left").rear_left();
	SPEAKER(config, "rear_right").rear_right();

	MCFG_DEVICE_MODIFY("c352")
	MCFG_SOUND_ROUTE(2, "rear_left", 1.00)
	MCFG_SOUND_ROUTE(3, "rear_right", 1.00)
MACHINE_CONFIG_END

// System Super22
MACHINE_CONFIG_START(namcos22_state::namcos22s)
	namcos22(config);

	/* basic machine hardware */
	MCFG_DEVICE_REPLACE("maincpu", M68EC020, 49.152_MHz_XTAL/2) // MC68EC020FG25
	MCFG_DEVICE_PROGRAM_MAP(namcos22s_am)
	MCFG_DEVICE_VBLANK_INT_DRIVER("screen", namcos22_state, namcos22s_interrupt)

	MCFG_DEVICE_REPLACE("mcu", M37710S4, 49.152_MHz_XTAL/3)
	MCFG_DEVICE_PROGRAM_MAP(mcu_program)
	MCFG_DEVICE_IO_MAP(mcu_io)
	MCFG_TIMER_DRIVER_ADD_SCANLINE("mcu_irq", namcos22_state, mcu_irq, "screen", 0, 240)
	MCFG_QUANTUM_TIME(attotime::from_hz(6000)) // erratic inputs otherwise, probably mcu vs maincpu shareram

	MCFG_DEVICE_REMOVE("iomcu")

	/* video hardware */
	MCFG_SCREEN_MODIFY("screen")
	MCFG_SCREEN_UPDATE_DRIVER(namcos22_state, screen_update_namcos22s)

	MCFG_DEVICE_REPLACE("gfxdecode", GFXDECODE, "palette", gfx_super)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::airco22b)
	namcos22s(config);

	SPEAKER(config, "bodysonic").subwoofer();

	MCFG_DEVICE_MODIFY("c352")
	MCFG_SOUND_ROUTE(2, "bodysonic", 0.50) // to subwoofer
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::alpine)
	namcos22s(config);

	MCFG_DEVICE_MODIFY("mcu")
	MCFG_DEVICE_IO_MAP(alpine_io_map)

	MCFG_TIMER_DRIVER_ADD("motor_timer", namcos22_state, alpine_steplock_callback)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::alpinesa)
	alpine(config);

	MCFG_DEVICE_MODIFY("maincpu")
	MCFG_DEVICE_PROGRAM_MAP(alpinesa_am)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::cybrcycc)
	namcos22s(config);

	SPEAKER(config, "tank", 0.0, 0.0, 0.0);

	MCFG_DEVICE_MODIFY("c352")
	MCFG_SOUND_ROUTE(2, "tank", 1.00)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::dirtdash)
	namcos22s(config);

	SPEAKER(config, "road", 0.0, 0.0, 0.0);

	MCFG_DEVICE_MODIFY("c352")
	MCFG_SOUND_ROUTE(3, "road", 1.00)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::timecris)
	namcos22s(config);

	MCFG_DEVICE_MODIFY("maincpu")
	MCFG_DEVICE_PROGRAM_MAP(timecris_am)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::tokyowar)
	namcos22s(config);

	SPEAKER(config, "vibration").subwoofer();
	SPEAKER(config, "seat").rear_center();

	MCFG_DEVICE_MODIFY("c352")
	MCFG_SOUND_ROUTE(2, "vibration", 0.50) // to "bass shaker"
	MCFG_SOUND_ROUTE(3, "seat", 1.00)
MACHINE_CONFIG_END

MACHINE_CONFIG_START(namcos22_state::propcycl)
	namcos22s(config);

	MCFG_DEVICE_MODIFY("mcu")
	MCFG_DEVICE_IO_MAP(propcycl_io_map)

	MCFG_TIMER_DRIVER_ADD_PERIODIC("pc_p_upd", namcos22_state, propcycl_pedal_update, attotime::from_msec(20))
	MCFG_TIMER_DRIVER_ADD("pc_p_int", namcos22_state, propcycl_pedal_interrupt)
MACHINE_CONFIG_END

MACHINE_START_MEMBER(namcos22_state,adillor)
{
	machine_start();

	for (auto & elem : m_ar_tb_interrupt)
		elem = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos22_state::adillor_trackball_interrupt),this));
}

MACHINE_CONFIG_START(namcos22_state::adillor)
	namcos22s(config);

	MCFG_TIMER_DRIVER_ADD_PERIODIC("ar_tb_upd", namcos22_state, adillor_trackball_update, attotime::from_msec(20))
	MCFG_MACHINE_START_OVERRIDE(namcos22_state,adillor)
MACHINE_CONFIG_END



/*********************************************************************************************/

ROM_START( ridgerac )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rr3prgll.4d", 0x00003, 0x80000, CRC(856fe5ec) SHA1(72d95b8bd5da551c3d358b8ab266373a89f8aa6a) )
	ROM_LOAD32_BYTE( "rr3prglm.2d", 0x00002, 0x80000, CRC(1e9ef0a9) SHA1(a4577bcdf13673568793d8a324945fca30b10f43) )
	ROM_LOAD32_BYTE( "rr3prgum.8d", 0x00001, 0x80000, CRC(e160f63f) SHA1(9b4b7a13eb4bc19fcb53daedb87e4945c20a1b8e) )
	ROM_LOAD32_BYTE( "rr3prguu.6d", 0x00000, 0x80000, CRC(f07c78c0) SHA1(dbed76d868b761711faf5b6e11f2c9affb91db5d) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rr1data.6r", 0, 0x080000, CRC(18f5f748) SHA1(e0d149a66de36156edd9b55f604c9a9801aaefa8) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rr1cg0.bin", 0x200000*0x4, 0x200000, CRC(b557a795) SHA1(f345486ffbe797246ad80a55d3c4a332ed6e2888) )
	ROM_LOAD( "rr1cg1.bin", 0x200000*0x5, 0x200000, CRC(0fa212d9) SHA1(a1311de0a504e2d399044fa8ac32ec6c56ec965f) )
	ROM_LOAD( "rr1cg2.bin", 0x200000*0x6, 0x200000, CRC(18e2d2bd) SHA1(69c2ea62eeb255f27d3c69373f6716b0a34683cc) )
	ROM_LOAD( "rr1cg3.bin", 0x200000*0x7, 0x200000, CRC(9564488b) SHA1(6b27d1aea75d6be747c62e165cfa49ecc5d9e767) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rr1ccrl.bin",0x000000, 0x200000, CRC(6092d181) SHA1(52c0e3ac20aa23059a87d1a985d24ae641577310) )
	ROM_LOAD( "rr1ccrh.bin",0x200000, 0x080000, CRC(dd332fd5) SHA1(a7d9c1d6b5a8e3a937b525c1363880e404dcd147) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rr1potl0.5b", 0x80000*0, 0x80000,CRC(3ac193e3) SHA1(ff213766f15e34dc1b25187b57d94e17930090a3) )
	ROM_LOAD( "rr1potl1.4b", 0x80000*1, 0x80000,CRC(ac3ffba5) SHA1(4eb4dda5faeff237e0d35725b56d309948fba900) )
	ROM_LOAD( "rr1potm0.5c", 0x80000*2, 0x80000,CRC(42a3fa08) SHA1(15db0ae7ccf7f5a77b9dd9a9d82a488b67f8aaff) )
	ROM_LOAD( "rr1potm1.4c", 0x80000*3, 0x80000,CRC(1bc1ea7b) SHA1(52c21eef4989c45acc5fa4deda2d0b63214731c8) )
	ROM_LOAD( "rr1potu0.5d", 0x80000*4, 0x80000,CRC(5e367f72) SHA1(5887f011379dce865fef238b402678a3d2033de9) )
	ROM_LOAD( "rr1potu1.4d", 0x80000*5, 0x80000,CRC(31d92475) SHA1(51d3c0baa223e1bc16ea2950f2e085597528f870) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rr1wav0.10r", 0x100000*0, 0x100000,CRC(a8e85bde) SHA1(b56677e9f6c98f7b600043f5dcfef3a482ca7455) )
	ROM_LOAD( "rr1wav1.10p", 0x100000*2, 0x100000,CRC(35f47c8e) SHA1(7c3f9e942f532af8008fbead2a96fee6084bcde6) )
	ROM_LOAD( "rr1wav2.10n", 0x100000*1, 0x100000,CRC(3244cb59) SHA1(b3283b30cfafbfdcbc6d482ecc4ed6a47a527ca4) )
	ROM_LOAD( "rr1wav3.10l", 0x100000*3, 0x100000,CRC(c4cda1a7) SHA1(60bc96880ec79efdff3cc70c09e848692a40bea4) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

ROM_START( ridgeracb )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rr1prll.4d", 0x00003, 0x80000, CRC(4bb7fc86) SHA1(8291375b8ec4d37e0d9e3bf38da2d5907b0f31bd) )
	ROM_LOAD32_BYTE( "rr1prlm.2d", 0x00002, 0x80000, CRC(68e13830) SHA1(ddc447c7afbb5c4238969d7e78bfe9cf8fac6061) )
	ROM_LOAD32_BYTE( "rr1prum.8d", 0x00001, 0x80000, CRC(705ef78a) SHA1(881903413e66d6fd83d46eb18c4e1230531832ae) )
	ROM_LOAD32_BYTE( "rr2pruu.6d", 0x00000, 0x80000, CRC(a79e456f) SHA1(049c596e01e53e3a401c5c4260517f170688d387) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rr1data.6r", 0, 0x080000, CRC(18f5f748) SHA1(e0d149a66de36156edd9b55f604c9a9801aaefa8) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rr1cg0.bin", 0x200000*0x4, 0x200000, CRC(b557a795) SHA1(f345486ffbe797246ad80a55d3c4a332ed6e2888) )
	ROM_LOAD( "rr1cg1.bin", 0x200000*0x5, 0x200000, CRC(0fa212d9) SHA1(a1311de0a504e2d399044fa8ac32ec6c56ec965f) )
	ROM_LOAD( "rr1cg2.bin", 0x200000*0x6, 0x200000, CRC(18e2d2bd) SHA1(69c2ea62eeb255f27d3c69373f6716b0a34683cc) )
	ROM_LOAD( "rr1cg3.bin", 0x200000*0x7, 0x200000, CRC(9564488b) SHA1(6b27d1aea75d6be747c62e165cfa49ecc5d9e767) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rr1ccrl.bin",0x000000, 0x200000, CRC(6092d181) SHA1(52c0e3ac20aa23059a87d1a985d24ae641577310) )
	ROM_LOAD( "rr1ccrh.bin",0x200000, 0x080000, CRC(dd332fd5) SHA1(a7d9c1d6b5a8e3a937b525c1363880e404dcd147) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rr1potl0.5b", 0x80000*0, 0x80000,CRC(3ac193e3) SHA1(ff213766f15e34dc1b25187b57d94e17930090a3) )
	ROM_LOAD( "rr1potl1.4b", 0x80000*1, 0x80000,CRC(ac3ffba5) SHA1(4eb4dda5faeff237e0d35725b56d309948fba900) )
	ROM_LOAD( "rr1potm0.5c", 0x80000*2, 0x80000,CRC(42a3fa08) SHA1(15db0ae7ccf7f5a77b9dd9a9d82a488b67f8aaff) )
	ROM_LOAD( "rr1potm1.4c", 0x80000*3, 0x80000,CRC(1bc1ea7b) SHA1(52c21eef4989c45acc5fa4deda2d0b63214731c8) )
	ROM_LOAD( "rr1potu0.5d", 0x80000*4, 0x80000,CRC(5e367f72) SHA1(5887f011379dce865fef238b402678a3d2033de9) )
	ROM_LOAD( "rr1potu1.4d", 0x80000*5, 0x80000,CRC(31d92475) SHA1(51d3c0baa223e1bc16ea2950f2e085597528f870) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rr1wav0.10r", 0x100000*0, 0x100000,CRC(a8e85bde) SHA1(b56677e9f6c98f7b600043f5dcfef3a482ca7455) )
	ROM_LOAD( "rr1wav1.10p", 0x100000*2, 0x100000,CRC(35f47c8e) SHA1(7c3f9e942f532af8008fbead2a96fee6084bcde6) )
	ROM_LOAD( "rr1wav2.10n", 0x100000*1, 0x100000,CRC(3244cb59) SHA1(b3283b30cfafbfdcbc6d482ecc4ed6a47a527ca4) )
	ROM_LOAD( "rr1wav3.10l", 0x100000*3, 0x100000,CRC(c4cda1a7) SHA1(60bc96880ec79efdff3cc70c09e848692a40bea4) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

ROM_START( ridgeracj )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rr1prll.4d", 0x00003, 0x80000, CRC(4bb7fc86) SHA1(8291375b8ec4d37e0d9e3bf38da2d5907b0f31bd) )
	ROM_LOAD32_BYTE( "rr1prlm.2d", 0x00002, 0x80000, CRC(68e13830) SHA1(ddc447c7afbb5c4238969d7e78bfe9cf8fac6061) )
	ROM_LOAD32_BYTE( "rr1prum.8d", 0x00001, 0x80000, CRC(705ef78a) SHA1(881903413e66d6fd83d46eb18c4e1230531832ae) )
	ROM_LOAD32_BYTE( "rr1pruu.6d", 0x00000, 0x80000, CRC(c1371f96) SHA1(a78e0bf6c147c034487a85efa0a8470f4e8f4bf0) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rr1data.6r", 0, 0x080000, CRC(18f5f748) SHA1(e0d149a66de36156edd9b55f604c9a9801aaefa8) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rr1cg0.bin", 0x200000*0x4, 0x200000, CRC(b557a795) SHA1(f345486ffbe797246ad80a55d3c4a332ed6e2888) )
	ROM_LOAD( "rr1cg1.bin", 0x200000*0x5, 0x200000, CRC(0fa212d9) SHA1(a1311de0a504e2d399044fa8ac32ec6c56ec965f) )
	ROM_LOAD( "rr1cg2.bin", 0x200000*0x6, 0x200000, CRC(18e2d2bd) SHA1(69c2ea62eeb255f27d3c69373f6716b0a34683cc) )
	ROM_LOAD( "rr1cg3.bin", 0x200000*0x7, 0x200000, CRC(9564488b) SHA1(6b27d1aea75d6be747c62e165cfa49ecc5d9e767) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rr1ccrl.bin",0x000000, 0x200000, CRC(6092d181) SHA1(52c0e3ac20aa23059a87d1a985d24ae641577310) )
	ROM_LOAD( "rr1ccrh.bin",0x200000, 0x080000, CRC(dd332fd5) SHA1(a7d9c1d6b5a8e3a937b525c1363880e404dcd147) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rr1potl0.5b", 0x80000*0, 0x80000,CRC(3ac193e3) SHA1(ff213766f15e34dc1b25187b57d94e17930090a3) )
	ROM_LOAD( "rr1potl1.4b", 0x80000*1, 0x80000,CRC(ac3ffba5) SHA1(4eb4dda5faeff237e0d35725b56d309948fba900) )
	ROM_LOAD( "rr1potm0.5c", 0x80000*2, 0x80000,CRC(42a3fa08) SHA1(15db0ae7ccf7f5a77b9dd9a9d82a488b67f8aaff) )
	ROM_LOAD( "rr1potm1.4c", 0x80000*3, 0x80000,CRC(1bc1ea7b) SHA1(52c21eef4989c45acc5fa4deda2d0b63214731c8) )
	ROM_LOAD( "rr1potu0.5d", 0x80000*4, 0x80000,CRC(5e367f72) SHA1(5887f011379dce865fef238b402678a3d2033de9) )
	ROM_LOAD( "rr1potu1.4d", 0x80000*5, 0x80000,CRC(31d92475) SHA1(51d3c0baa223e1bc16ea2950f2e085597528f870) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rr1wav0.10r", 0x100000*0, 0x100000,CRC(a8e85bde) SHA1(b56677e9f6c98f7b600043f5dcfef3a482ca7455) )
	ROM_LOAD( "rr1wav1.10p", 0x100000*2, 0x100000,CRC(35f47c8e) SHA1(7c3f9e942f532af8008fbead2a96fee6084bcde6) )
	ROM_LOAD( "rr1wav2.10n", 0x100000*1, 0x100000,CRC(3244cb59) SHA1(b3283b30cfafbfdcbc6d482ecc4ed6a47a527ca4) )
	ROM_LOAD( "rr1wav3.10l", 0x100000*3, 0x100000,CRC(c4cda1a7) SHA1(60bc96880ec79efdff3cc70c09e848692a40bea4) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

ROM_START( ridgerac3 )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rr3prgll-3s.4d", 0x000003, 0x080000, CRC(2c3d8cb7) SHA1(46a7b62938fe3edde5c52ce3fdfe447000cd6af0) )
	ROM_LOAD32_BYTE( "rr3prglm-3s.2d", 0x000002, 0x080000, CRC(b15343f2) SHA1(3056eb5a3036a74b2ac641a4c3221986c0be1e27) )
	ROM_LOAD32_BYTE( "rr3prgum-3s.8d", 0x000001, 0x080000, CRC(8fda06ac) SHA1(7e9adba198eb0941100cda64ecedac504f6ac696) )
	ROM_LOAD32_BYTE( "rr3prguu-3s.6d", 0x000000, 0x080000, CRC(868398df) SHA1(422e0f9884904b0df93fcacd1468b8da0458eb8e) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rr1data.6r", 0, 0x080000, CRC(18f5f748) SHA1(e0d149a66de36156edd9b55f604c9a9801aaefa8) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rr1cg0.bin", 0x200000*0x4, 0x200000, CRC(b557a795) SHA1(f345486ffbe797246ad80a55d3c4a332ed6e2888) )
	ROM_LOAD( "rr1cg1.bin", 0x200000*0x5, 0x200000, CRC(0fa212d9) SHA1(a1311de0a504e2d399044fa8ac32ec6c56ec965f) )
	ROM_LOAD( "rr1cg2.bin", 0x200000*0x6, 0x200000, CRC(18e2d2bd) SHA1(69c2ea62eeb255f27d3c69373f6716b0a34683cc) )
	ROM_LOAD( "rr1cg3.bin", 0x200000*0x7, 0x200000, CRC(9564488b) SHA1(6b27d1aea75d6be747c62e165cfa49ecc5d9e767) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rr1ccrl.bin",0x000000, 0x200000, CRC(6092d181) SHA1(52c0e3ac20aa23059a87d1a985d24ae641577310) )
	ROM_LOAD( "rr1ccrh.bin",0x200000, 0x080000, CRC(dd332fd5) SHA1(a7d9c1d6b5a8e3a937b525c1363880e404dcd147) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rr1potl0.5b", 0x80000*0, 0x80000,CRC(3ac193e3) SHA1(ff213766f15e34dc1b25187b57d94e17930090a3) )
	ROM_LOAD( "rr1potl1.4b", 0x80000*1, 0x80000,CRC(ac3ffba5) SHA1(4eb4dda5faeff237e0d35725b56d309948fba900) )
	ROM_LOAD( "rr1potm0.5c", 0x80000*2, 0x80000,CRC(42a3fa08) SHA1(15db0ae7ccf7f5a77b9dd9a9d82a488b67f8aaff) )
	ROM_LOAD( "rr1potm1.4c", 0x80000*3, 0x80000,CRC(1bc1ea7b) SHA1(52c21eef4989c45acc5fa4deda2d0b63214731c8) )
	ROM_LOAD( "rr1potu0.5d", 0x80000*4, 0x80000,CRC(5e367f72) SHA1(5887f011379dce865fef238b402678a3d2033de9) )
	ROM_LOAD( "rr1potu1.4d", 0x80000*5, 0x80000,CRC(31d92475) SHA1(51d3c0baa223e1bc16ea2950f2e085597528f870) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rr1wav0.10r", 0x100000*0, 0x100000,CRC(a8e85bde) SHA1(b56677e9f6c98f7b600043f5dcfef3a482ca7455) )
	ROM_LOAD( "rr1wav1.10p", 0x100000*2, 0x100000,CRC(35f47c8e) SHA1(7c3f9e942f532af8008fbead2a96fee6084bcde6) )
	ROM_LOAD( "rr1wav2.10n", 0x100000*1, 0x100000,CRC(3244cb59) SHA1(b3283b30cfafbfdcbc6d482ecc4ed6a47a527ca4) )
	ROM_LOAD( "rr1wav3.10l", 0x100000*3, 0x100000,CRC(c4cda1a7) SHA1(60bc96880ec79efdff3cc70c09e848692a40bea4) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

ROM_START( ridgeracf )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rrf2prgll.4d", 0x00003, 0x80000, CRC(23c6144d) SHA1(99f70e2c60fba7551cafdce12b07da1f8ab8aad6) )
	ROM_LOAD32_BYTE( "rrf2prglm.2d", 0x00002, 0x80000, CRC(1ad638a1) SHA1(505a7f4ba60bbc4e735865fbc5d664311b6045d9) )
	ROM_LOAD32_BYTE( "rrf2prgum.8d", 0x00001, 0x80000, CRC(d7e0aa16) SHA1(cab4578cdd3af84b865114be4105cfdc2e7abf36) )
	ROM_LOAD32_BYTE( "rrf2prguu.6d", 0x00000, 0x80000, CRC(12c808bb) SHA1(64e84686d4ceb8145b9a59b75d0dced830884c9d) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rrf1data.6r", 0, 0x080000, CRC(ce3c6ed6) SHA1(23e033364bc967c10c49fd1d5413dda837670633) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rrf2potl0.l0", 0x80000*0, 0x80000, CRC(9b762e60) SHA1(50b67ff6678bacba140bad3aedda75c30851fa7a) )
	ROM_LOAD( "rrf2potl1.l1", 0x80000*1, 0x80000, CRC(ab4d66b0) SHA1(59020b3dc2efff99cd528752ca7168b64ae96ac4) )
	ROM_LOAD( "rrf2potm0.m0", 0x80000*2, 0x80000, CRC(02d4daa3) SHA1(9b4e48d3234cb91146b5d31ffcf42ad199ccb903) )
	ROM_LOAD( "rrf2potm1.m1", 0x80000*3, 0x80000, CRC(37e005c2) SHA1(036ae1c44aaa6a6904e6d4938572035ccc6854ed) )
	ROM_LOAD( "rrf2potu0.u0", 0x80000*4, 0x80000, CRC(86b3fe98) SHA1(f242d33f7488e233ccdc0b5d309c64510d7a622d) )
	ROM_LOAD( "rrf2potu1.u1", 0x80000*5, 0x80000, CRC(e0c6ce3d) SHA1(cc559a2237ccb753cb1397fecba64733455a8c43) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rrf1wave0.10r", 0x100000*0, 0x100000,CRC(a8e85bde) SHA1(b56677e9f6c98f7b600043f5dcfef3a482ca7455) )
	ROM_LOAD( "rrf1wave1.10p", 0x100000*2, 0x100000,CRC(35f47c8e) SHA1(7c3f9e942f532af8008fbead2a96fee6084bcde6) )
	ROM_LOAD( "rrf1wave2.10n", 0x100000*1, 0x100000,CRC(4ceeae12) SHA1(ae3a6583f8912bc784c7bc63d32448228cf217ba) ) // differs from normal sets
	ROM_LOAD( "rrf1wave3.10l", 0x100000*3, 0x100000,CRC(c4cda1a7) SHA1(60bc96880ec79efdff3cc70c09e848692a40bea4) )

	/* this stuff was missing from this version, and shouldn't be the same (bad textures if we use these roms) */
	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rrf1gam.2d",   0x0000, 0x0100, BAD_DUMP CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rrf1gam.3d",   0x0100, 0x0100, BAD_DUMP CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rrf1gam.4d",   0x0200, 0x0100, BAD_DUMP CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rrf1cg0.bin", 0x200000*0x4, 0x200000, BAD_DUMP CRC(b557a795) SHA1(f345486ffbe797246ad80a55d3c4a332ed6e2888) )
	ROM_LOAD( "rrf1cg1.bin", 0x200000*0x5, 0x200000, BAD_DUMP CRC(0fa212d9) SHA1(a1311de0a504e2d399044fa8ac32ec6c56ec965f) )
	ROM_LOAD( "rrf1cg2.bin", 0x200000*0x6, 0x200000, BAD_DUMP CRC(18e2d2bd) SHA1(69c2ea62eeb255f27d3c69373f6716b0a34683cc) )
	ROM_LOAD( "rrf1cg3.bin", 0x200000*0x7, 0x200000, BAD_DUMP CRC(9564488b) SHA1(6b27d1aea75d6be747c62e165cfa49ecc5d9e767) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rrf1ccrl.bin",0x000000, 0x200000, BAD_DUMP CRC(6092d181) SHA1(52c0e3ac20aa23059a87d1a985d24ae641577310) )
	ROM_LOAD( "rrf1ccrh.bin",0x200000, 0x080000, BAD_DUMP CRC(dd332fd5) SHA1(a7d9c1d6b5a8e3a937b525c1363880e404dcd147) )
ROM_END


ROM_START( ridgera2 )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rrs2prll.4d",  0x00003, 0x80000, CRC(88199c0f) SHA1(5cf5bb714c3d209943a8d815eaea60afd34641ff) )
	ROM_LOAD32_BYTE( "rrs1prlmb.2d", 0x00002, 0x80000, CRC(8e86f199) SHA1(7bd9ec9147ef0380864508f66203ef2c6ad1f7f6) )
	ROM_LOAD32_BYTE( "rrs1prumb.8d", 0x00001, 0x80000, CRC(78c360b6) SHA1(8ee502291359cbc8aef39145c8fe7538311cc58f) )
	ROM_LOAD32_BYTE( "rrs1pruub.6d", 0x00000, 0x80000, CRC(60d6d4a4) SHA1(759762a9b7d7aee7ee1b44b1721e5356898aa7ea) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rrs1data.6r", 0, 0x080000, CRC(b7063aa8) SHA1(08ff689e8dd529b91eee423c93f084945c6de417) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rrs1cg0.1a", 0x200000*0x4, 0x200000,CRC(714c0091) SHA1(df29512bd6e64827660c40304051366d2c4d7977) )
	ROM_LOAD( "rrs1cg1.2a", 0x200000*0x5, 0x200000,CRC(836545c1) SHA1(05e3346463d8d42b5d33216207e855033a65510d) )
	ROM_LOAD( "rrs1cg2.3a", 0x200000*0x6, 0x200000,CRC(00e9799d) SHA1(280184451138420f64080efe13e5e2795f7b61d4) )
	ROM_LOAD( "rrs1cg3.5a", 0x200000*0x7, 0x200000,CRC(3858983f) SHA1(feda270b71f1310ecf4c17823bc8827ca2951b40) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rrs1ccrl.5a", 0x000000, 0x200000,CRC(304a8b57) SHA1(f4f3e7c194697d754375f36a0e41d0941fa5d225) )
	ROM_LOAD( "rrs1ccrh.5c", 0x200000, 0x080000,CRC(bd3c86ab) SHA1(cd3a8774843c5864e651fa8989c80e2d975a13e8) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rrs1pol0.5b", 0x80000*0, 0x80000,CRC(9376c384) SHA1(cde0e36db1beab1523607098a760d81fac2ea90e) )
	ROM_LOAD( "rrs1pol1.4b", 0x80000*1, 0x80000,CRC(094fa832) SHA1(cc59442540b1cdef068c4408b6e048c11042beb8) )
	ROM_LOAD( "rrs1pom0.5c", 0x80000*2, 0x80000,CRC(b47a7f8b) SHA1(0fa0456ad8b4864a7071b5b5ba1a78877c1ac0f0) )
	ROM_LOAD( "rrs1pom1.4c", 0x80000*3, 0x80000,CRC(27260361) SHA1(8775cc779eb8b6a0d79fa84d606c970ec2d6ea8d) )
	ROM_LOAD( "rrs1pou0.5d", 0x80000*4, 0x80000,CRC(74d6ec84) SHA1(63f5beee51443c98100330ec04291f71e10716c4) )
	ROM_LOAD( "rrs1pou1.4d", 0x80000*5, 0x80000,CRC(f527caaa) SHA1(f92bdd15323239d593ddac92a11d23a27e6635ed) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rrs1wav0.10r", 0x100000*0, 0x100000,CRC(99d11a2d) SHA1(1f3db98a99be0f07c03b0a7817561459a58f310e) )
	ROM_LOAD( "rrs1wav1.10p", 0x100000*2, 0x100000,CRC(ad28444a) SHA1(c31bbf3cae5015e5494fe4988b9b01d822224c69) )
	ROM_LOAD( "rrs1wav2.10n", 0x100000*1, 0x100000,CRC(6f0d4619) SHA1(cd3d57f2ea21497f388ffa29ec7d2665647a01c0) )
	ROM_LOAD( "rrs1wav3.10l", 0x100000*3, 0x100000,CRC(106e761f) SHA1(97f47b857bdcbc79b0aface53dd385e67fcc9108) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

ROM_START( ridgera2j )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rrs1prllb.4d", 0x00003, 0x80000, CRC(22f069e5) SHA1(fcaec3aa83853c39d713ed01c511060663027ccd) )
	ROM_LOAD32_BYTE( "rrs1prlmb.2d", 0x00002, 0x80000, CRC(8e86f199) SHA1(7bd9ec9147ef0380864508f66203ef2c6ad1f7f6) )
	ROM_LOAD32_BYTE( "rrs1prumb.8d", 0x00001, 0x80000, CRC(78c360b6) SHA1(8ee502291359cbc8aef39145c8fe7538311cc58f) )
	ROM_LOAD32_BYTE( "rrs1pruub.6d", 0x00000, 0x80000, CRC(60d6d4a4) SHA1(759762a9b7d7aee7ee1b44b1721e5356898aa7ea) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rrs1data.6r", 0, 0x080000, CRC(b7063aa8) SHA1(08ff689e8dd529b91eee423c93f084945c6de417) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rrs1cg0.1a", 0x200000*0x4, 0x200000,CRC(714c0091) SHA1(df29512bd6e64827660c40304051366d2c4d7977) )
	ROM_LOAD( "rrs1cg1.2a", 0x200000*0x5, 0x200000,CRC(836545c1) SHA1(05e3346463d8d42b5d33216207e855033a65510d) )
	ROM_LOAD( "rrs1cg2.3a", 0x200000*0x6, 0x200000,CRC(00e9799d) SHA1(280184451138420f64080efe13e5e2795f7b61d4) )
	ROM_LOAD( "rrs1cg3.5a", 0x200000*0x7, 0x200000,CRC(3858983f) SHA1(feda270b71f1310ecf4c17823bc8827ca2951b40) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rrs1ccrl.5a", 0x000000, 0x200000,CRC(304a8b57) SHA1(f4f3e7c194697d754375f36a0e41d0941fa5d225) )
	ROM_LOAD( "rrs1ccrh.5c", 0x200000, 0x080000,CRC(bd3c86ab) SHA1(cd3a8774843c5864e651fa8989c80e2d975a13e8) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rrs1pol0.5b", 0x80000*0, 0x80000,CRC(9376c384) SHA1(cde0e36db1beab1523607098a760d81fac2ea90e) )
	ROM_LOAD( "rrs1pol1.4b", 0x80000*1, 0x80000,CRC(094fa832) SHA1(cc59442540b1cdef068c4408b6e048c11042beb8) )
	ROM_LOAD( "rrs1pom0.5c", 0x80000*2, 0x80000,CRC(b47a7f8b) SHA1(0fa0456ad8b4864a7071b5b5ba1a78877c1ac0f0) )
	ROM_LOAD( "rrs1pom1.4c", 0x80000*3, 0x80000,CRC(27260361) SHA1(8775cc779eb8b6a0d79fa84d606c970ec2d6ea8d) )
	ROM_LOAD( "rrs1pou0.5d", 0x80000*4, 0x80000,CRC(74d6ec84) SHA1(63f5beee51443c98100330ec04291f71e10716c4) )
	ROM_LOAD( "rrs1pou1.4d", 0x80000*5, 0x80000,CRC(f527caaa) SHA1(f92bdd15323239d593ddac92a11d23a27e6635ed) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rrs1wav0.10r", 0x100000*0, 0x100000,CRC(99d11a2d) SHA1(1f3db98a99be0f07c03b0a7817561459a58f310e) )
	ROM_LOAD( "rrs1wav1.10p", 0x100000*2, 0x100000,CRC(ad28444a) SHA1(c31bbf3cae5015e5494fe4988b9b01d822224c69) )
	ROM_LOAD( "rrs1wav2.10n", 0x100000*1, 0x100000,CRC(6f0d4619) SHA1(cd3d57f2ea21497f388ffa29ec7d2665647a01c0) )
	ROM_LOAD( "rrs1wav3.10l", 0x100000*3, 0x100000,CRC(106e761f) SHA1(97f47b857bdcbc79b0aface53dd385e67fcc9108) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

ROM_START( ridgera2ja )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rrs1prll.4d", 0x00003, 0x80000, CRC(fbf785a2) SHA1(b9333c7623f68f48aa6ae50913a22a527a19576a) )
	ROM_LOAD32_BYTE( "rrs1prlm.2d", 0x00002, 0x80000, CRC(562f747a) SHA1(79d818b87c9a992fc9706fb39e6d560c2b0aa392) )
	ROM_LOAD32_BYTE( "rrs1prum.8d", 0x00001, 0x80000, CRC(93259fb0) SHA1(c29787e873797a003db27adbd20d7b852e26d8c6) )
	ROM_LOAD32_BYTE( "rrs1pruu.6d", 0x00000, 0x80000, CRC(31cdefe8) SHA1(ae836d389bed43dd156eb4cf3e97b6f1ad68181e) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rrs1data.6r", 0, 0x080000, CRC(b7063aa8) SHA1(08ff689e8dd529b91eee423c93f084945c6de417) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rrs1cg0.1a", 0x200000*0x4, 0x200000,CRC(714c0091) SHA1(df29512bd6e64827660c40304051366d2c4d7977) )
	ROM_LOAD( "rrs1cg1.2a", 0x200000*0x5, 0x200000,CRC(836545c1) SHA1(05e3346463d8d42b5d33216207e855033a65510d) )
	ROM_LOAD( "rrs1cg2.3a", 0x200000*0x6, 0x200000,CRC(00e9799d) SHA1(280184451138420f64080efe13e5e2795f7b61d4) )
	ROM_LOAD( "rrs1cg3.5a", 0x200000*0x7, 0x200000,CRC(3858983f) SHA1(feda270b71f1310ecf4c17823bc8827ca2951b40) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rrs1ccrl.5a", 0x000000, 0x200000,CRC(304a8b57) SHA1(f4f3e7c194697d754375f36a0e41d0941fa5d225) )
	ROM_LOAD( "rrs1ccrh.5c", 0x200000, 0x080000,CRC(bd3c86ab) SHA1(cd3a8774843c5864e651fa8989c80e2d975a13e8) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rrs1pol0.5b", 0x80000*0, 0x80000,CRC(9376c384) SHA1(cde0e36db1beab1523607098a760d81fac2ea90e) )
	ROM_LOAD( "rrs1pol1.4b", 0x80000*1, 0x80000,CRC(094fa832) SHA1(cc59442540b1cdef068c4408b6e048c11042beb8) )
	ROM_LOAD( "rrs1pom0.5c", 0x80000*2, 0x80000,CRC(b47a7f8b) SHA1(0fa0456ad8b4864a7071b5b5ba1a78877c1ac0f0) )
	ROM_LOAD( "rrs1pom1.4c", 0x80000*3, 0x80000,CRC(27260361) SHA1(8775cc779eb8b6a0d79fa84d606c970ec2d6ea8d) )
	ROM_LOAD( "rrs1pou0.5d", 0x80000*4, 0x80000,CRC(74d6ec84) SHA1(63f5beee51443c98100330ec04291f71e10716c4) )
	ROM_LOAD( "rrs1pou1.4d", 0x80000*5, 0x80000,CRC(f527caaa) SHA1(f92bdd15323239d593ddac92a11d23a27e6635ed) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rrs1wav0.10r", 0x100000*0, 0x100000,CRC(99d11a2d) SHA1(1f3db98a99be0f07c03b0a7817561459a58f310e) )
	ROM_LOAD( "rrs1wav1.10p", 0x100000*2, 0x100000,CRC(ad28444a) SHA1(c31bbf3cae5015e5494fe4988b9b01d822224c69) )
	ROM_LOAD( "rrs1wav2.10n", 0x100000*1, 0x100000,CRC(6f0d4619) SHA1(cd3d57f2ea21497f388ffa29ec7d2665647a01c0) )
	ROM_LOAD( "rrs1wav3.10l", 0x100000*3, 0x100000,CRC(106e761f) SHA1(97f47b857bdcbc79b0aface53dd385e67fcc9108) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END


ROM_START( raveracw )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rv2prllb.4d", 0x00003, 0x80000, CRC(3017cd1e) SHA1(ccd648b4a5dfc74fd141815af2969f423311042f) )
	ROM_LOAD32_BYTE( "rv2prlmb.2d", 0x00002, 0x80000, CRC(894be0c3) SHA1(4dba93dc3ca1cf502c5f54018b64ad79bb2a632b) )
	ROM_LOAD32_BYTE( "rv2prumb.8d", 0x00001, 0x80000, CRC(6414a800) SHA1(c278ff644909d12a43ba6fc2bf8d2092e469c3e6) )
	ROM_LOAD32_BYTE( "rv2pruub.6d", 0x00000, 0x80000, CRC(a9f18714) SHA1(8e7b17749d151f92020f68d1ac06003cf1f5c573) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rv1data.6r", 0, 0x080000, CRC(d358ec20) SHA1(140c513349240417bb546dd2d151f3666b818e91) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rv1cg0.1a", 0x200000*0x0, 0x200000,CRC(c518f06b) SHA1(4c01d453244192dd13087bdc72a7f7be80b47cbc) ) /* rv1cg0.2a */
	ROM_LOAD( "rv1cg1.1c", 0x200000*0x1, 0x200000,CRC(6628f792) SHA1(7a5405c5fcb2f3f001ae17df393c31e61a834f2b) ) /* rv1cg1.2c */
	ROM_LOAD( "rv1cg2.1d", 0x200000*0x2, 0x200000,CRC(0b707cc5) SHA1(38e1a554b278062edc369565353497ac4b016f78) ) /* rv1cg2.2d */
	ROM_LOAD( "rv1cg3.1e", 0x200000*0x3, 0x200000,CRC(39b62921) SHA1(873287d81338baf10dd85214d82f6c38bfdf199e) ) /* rv1cg3.2e */
	ROM_LOAD( "rv1cg4.1f", 0x200000*0x4, 0x200000,CRC(a9791ea2) SHA1(245b2ebbadd1fbca90dc241f88e9f6f341b2a01a) ) /* rv1cg4.2f */
	ROM_LOAD( "rv1cg5.1j", 0x200000*0x5, 0x200000,CRC(b2c79ec1) SHA1(6f669996863bdf1fe09b0c1a2a876625029d3d43) ) /* rv1cg5.2j */
	ROM_LOAD( "rv1cg6.1k", 0x200000*0x6, 0x200000,CRC(8cddedc2) SHA1(e3993f5505bc7e61bec7be5b48c873572e1220f7) ) /* rv1cg6.2k */
	ROM_LOAD( "rv1cg7.1n", 0x200000*0x7, 0x200000,CRC(b39147ca) SHA1(50ca6691fc809c95e6999dd52e39f2b8c2d22f3b) ) /* rv1cg7.2n */

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rv1ccrl.5a",  0x000000, 0x200000,CRC(bc634f72) SHA1(b5c504ed92bca7682614fc4c51f38cff607e6f2a) ) /* rv1ccrl.5l */
	ROM_LOAD( "rv1ccrh.5c",  0x200000, 0x080000,CRC(a741b262) SHA1(363076220a0eacc67befda05f8253963e8ffbcaa) ) /* rv1ccrh.5j */

	ROM_REGION( 0x80000*12, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rv1potl0.5b", 0x80000*0x0, 0x80000,CRC(de2ce519) SHA1(2fe0dd000571f76d1a4df6a439d40119125170ef) )
	ROM_LOAD( "rv1potl1.4b", 0x80000*0x1, 0x80000,CRC(2215cb5a) SHA1(d48ee692ab3dbcffdc49d22f6f232ca9390da766) )
	ROM_LOAD( "rv1potl2.3b", 0x80000*0x2, 0x80000,CRC(ddb15bf7) SHA1(4c54ec98e0cba10841d43a4ce593cdacfd7f90f8) )
	ROM_LOAD( "rv1potl3.2b", 0x80000*0x3, 0x80000,CRC(fa9361ca) SHA1(35a5c2712bca9c62400b724754de3a931ad21561) )
	ROM_LOAD( "rv1potm0.5c", 0x80000*0x4, 0x80000,CRC(3c024f3a) SHA1(711f0442823797b2d410352796a5cca66af98dce) )
	ROM_LOAD( "rv1potm1.4c", 0x80000*0x5, 0x80000,CRC(b1a32a68) SHA1(e24abb3a7e35d098abae5420bf8ef5c975718987) )
	ROM_LOAD( "rv1potm2.3c", 0x80000*0x6, 0x80000,CRC(a414fe15) SHA1(eb27cdca045ab2ab27dec179043328847fb65e11) )
	ROM_LOAD( "rv1potm3.2c", 0x80000*0x7, 0x80000,CRC(2953bbb4) SHA1(aca1acd87f7130d2522d0c6f8e60beeb7ab7495a) )
	ROM_LOAD( "rv1potu0.5d", 0x80000*0x8, 0x80000,CRC(b9eaf3cc) SHA1(3b2a9041f1fa90706ecf7d4fbff918516f891a07) )
	ROM_LOAD( "rv1potu1.4d", 0x80000*0x9, 0x80000,CRC(a5c55258) SHA1(826d4dde761aec7d848456f7bc4ba6268fe99605) )
	ROM_LOAD( "rv1potu2.3d", 0x80000*0xa, 0x80000,CRC(c18fcb74) SHA1(a4009ae2b014dc89aed4741fd97f84350117c2f4) )
	ROM_LOAD( "rv1potu3.2d", 0x80000*0xb, 0x80000,CRC(79735aaa) SHA1(1cf14274669b916a7641f7a16785da1b72347485) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rv1wav0.10r", 0x000000, 0x100000, CRC(5aef8143) SHA1(a75d31298e3ff9b290f238976a11e8b85cfb72d3) )
	ROM_LOAD( "rv1wav1.10p", 0x200000, 0x100000, CRC(9ed9e6b3) SHA1(dd1da2b08d1b6aa0912daacc77744c9799aabb78) )
	ROM_LOAD( "rv1wav2.10n", 0x100000, 0x100000, CRC(5af9dc83) SHA1(9aeb7f8217b806a6f3ed93056513af9fbcb6b372) )
	ROM_LOAD( "rv1wav3.10l", 0x300000, 0x100000, CRC(ffb9ad75) SHA1(a9a61a597bd3bbe9732f92747d82264fe4d9af48) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )

	ROM_REGION( 0x2000, "eeprom", 0 ) // default eeprom
	ROM_LOAD( "rv1eeprm.9e", 0x0000, 0x2000, CRC(e00dd412) SHA1(f594b31ace5e5e980e904faa8b83a450cc95db17) )
ROM_END

ROM_START( raveracj )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rv1prllb.4d", 0x00003, 0x80000, CRC(71da3eea) SHA1(8a641bb23e0ad89cae5ee1570f8a3627b2434d20) )
	ROM_LOAD32_BYTE( "rv1prlmb.2d", 0x00002, 0x80000, CRC(6ab7e9ce) SHA1(0c6376ca5a63409aeea344bbc201af6c47afe9ab) )
	ROM_LOAD32_BYTE( "rv1prumb.8d", 0x00001, 0x80000, CRC(375fabcf) SHA1(448e3db3e3fab8c7c27e214ab5a5fa84e5f84366) )
	ROM_LOAD32_BYTE( "rv1pruub.6d", 0x00000, 0x80000, CRC(92f834d6) SHA1(028368790f0293fcfea5c7b12f7f315e27a62f77) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rv1data.6r", 0, 0x080000, CRC(d358ec20) SHA1(140c513349240417bb546dd2d151f3666b818e91) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rv1cg0.1a", 0x200000*0x0, 0x200000,CRC(c518f06b) SHA1(4c01d453244192dd13087bdc72a7f7be80b47cbc) ) /* rv1cg0.2a */
	ROM_LOAD( "rv1cg1.1c", 0x200000*0x1, 0x200000,CRC(6628f792) SHA1(7a5405c5fcb2f3f001ae17df393c31e61a834f2b) ) /* rv1cg1.2c */
	ROM_LOAD( "rv1cg2.1d", 0x200000*0x2, 0x200000,CRC(0b707cc5) SHA1(38e1a554b278062edc369565353497ac4b016f78) ) /* rv1cg2.2d */
	ROM_LOAD( "rv1cg3.1e", 0x200000*0x3, 0x200000,CRC(39b62921) SHA1(873287d81338baf10dd85214d82f6c38bfdf199e) ) /* rv1cg3.2e */
	ROM_LOAD( "rv1cg4.1f", 0x200000*0x4, 0x200000,CRC(a9791ea2) SHA1(245b2ebbadd1fbca90dc241f88e9f6f341b2a01a) ) /* rv1cg4.2f */
	ROM_LOAD( "rv1cg5.1j", 0x200000*0x5, 0x200000,CRC(b2c79ec1) SHA1(6f669996863bdf1fe09b0c1a2a876625029d3d43) ) /* rv1cg5.2j */
	ROM_LOAD( "rv1cg6.1k", 0x200000*0x6, 0x200000,CRC(8cddedc2) SHA1(e3993f5505bc7e61bec7be5b48c873572e1220f7) ) /* rv1cg6.2k */
	ROM_LOAD( "rv1cg7.1n", 0x200000*0x7, 0x200000,CRC(b39147ca) SHA1(50ca6691fc809c95e6999dd52e39f2b8c2d22f3b) ) /* rv1cg7.2n */

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rv1ccrl.5a",  0x000000, 0x200000,CRC(bc634f72) SHA1(b5c504ed92bca7682614fc4c51f38cff607e6f2a) ) /* rv1ccrl.5l */
	ROM_LOAD( "rv1ccrh.5c",  0x200000, 0x080000,CRC(a741b262) SHA1(363076220a0eacc67befda05f8253963e8ffbcaa) ) /* rv1ccrh.5j */

	ROM_REGION( 0x80000*12, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rv1potl0.5b", 0x80000*0x0, 0x80000,CRC(de2ce519) SHA1(2fe0dd000571f76d1a4df6a439d40119125170ef) )
	ROM_LOAD( "rv1potl1.4b", 0x80000*0x1, 0x80000,CRC(2215cb5a) SHA1(d48ee692ab3dbcffdc49d22f6f232ca9390da766) )
	ROM_LOAD( "rv1potl2.3b", 0x80000*0x2, 0x80000,CRC(ddb15bf7) SHA1(4c54ec98e0cba10841d43a4ce593cdacfd7f90f8) )
	ROM_LOAD( "rv1potl3.2b", 0x80000*0x3, 0x80000,CRC(fa9361ca) SHA1(35a5c2712bca9c62400b724754de3a931ad21561) )
	ROM_LOAD( "rv1potm0.5c", 0x80000*0x4, 0x80000,CRC(3c024f3a) SHA1(711f0442823797b2d410352796a5cca66af98dce) )
	ROM_LOAD( "rv1potm1.4c", 0x80000*0x5, 0x80000,CRC(b1a32a68) SHA1(e24abb3a7e35d098abae5420bf8ef5c975718987) )
	ROM_LOAD( "rv1potm2.3c", 0x80000*0x6, 0x80000,CRC(a414fe15) SHA1(eb27cdca045ab2ab27dec179043328847fb65e11) )
	ROM_LOAD( "rv1potm3.2c", 0x80000*0x7, 0x80000,CRC(2953bbb4) SHA1(aca1acd87f7130d2522d0c6f8e60beeb7ab7495a) )
	ROM_LOAD( "rv1potu0.5d", 0x80000*0x8, 0x80000,CRC(b9eaf3cc) SHA1(3b2a9041f1fa90706ecf7d4fbff918516f891a07) )
	ROM_LOAD( "rv1potu1.4d", 0x80000*0x9, 0x80000,CRC(a5c55258) SHA1(826d4dde761aec7d848456f7bc4ba6268fe99605) )
	ROM_LOAD( "rv1potu2.3d", 0x80000*0xa, 0x80000,CRC(c18fcb74) SHA1(a4009ae2b014dc89aed4741fd97f84350117c2f4) )
	ROM_LOAD( "rv1potu3.2d", 0x80000*0xb, 0x80000,CRC(79735aaa) SHA1(1cf14274669b916a7641f7a16785da1b72347485) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rv1wav0.10r", 0x000000, 0x100000, CRC(5aef8143) SHA1(a75d31298e3ff9b290f238976a11e8b85cfb72d3) )
	ROM_LOAD( "rv1wav1.10p", 0x200000, 0x100000, CRC(9ed9e6b3) SHA1(dd1da2b08d1b6aa0912daacc77744c9799aabb78) )
	ROM_LOAD( "rv1wav2.10n", 0x100000, 0x100000, CRC(5af9dc83) SHA1(9aeb7f8217b806a6f3ed93056513af9fbcb6b372) )
	ROM_LOAD( "rv1wav3.10l", 0x300000, 0x100000, CRC(ffb9ad75) SHA1(a9a61a597bd3bbe9732f92747d82264fe4d9af48) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )

	ROM_REGION( 0x2000, "eeprom", 0 ) // default eeprom
	ROM_LOAD( "rv1eeprm.9e", 0x0000, 0x2000, CRC(e00dd412) SHA1(f594b31ace5e5e980e904faa8b83a450cc95db17) )
ROM_END

ROM_START( raveracja )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "rv1prll.4d", 0x00003, 0x80000, CRC(5dfce6cd) SHA1(1aeeca1e507ae4cbe3d39ca5efd1cc4fe1ab03a8) )
	ROM_LOAD32_BYTE( "rv1prlm.2d", 0x00002, 0x80000, CRC(0d4d9f74) SHA1(f886b0629cbf5a369af1f44e53c6fd3f51b3fbc9) )
	ROM_LOAD32_BYTE( "rv1prum.8d", 0x00001, 0x80000, CRC(28e503e3) SHA1(a3071461f840f28c65c660de215c73f812f356b3) )
	ROM_LOAD32_BYTE( "rv1pruu.6d", 0x00000, 0x80000, CRC(c47d9ff4) SHA1(4d7c4ac4151a3b306e7277937add8eee26e561a6) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "rv1data.6r", 0, 0x080000, CRC(d358ec20) SHA1(140c513349240417bb546dd2d151f3666b818e91) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "rv1cg0.1a", 0x200000*0x0, 0x200000,CRC(c518f06b) SHA1(4c01d453244192dd13087bdc72a7f7be80b47cbc) ) /* rv1cg0.2a */
	ROM_LOAD( "rv1cg1.1c", 0x200000*0x1, 0x200000,CRC(6628f792) SHA1(7a5405c5fcb2f3f001ae17df393c31e61a834f2b) ) /* rv1cg1.2c */
	ROM_LOAD( "rv1cg2.1d", 0x200000*0x2, 0x200000,CRC(0b707cc5) SHA1(38e1a554b278062edc369565353497ac4b016f78) ) /* rv1cg2.2d */
	ROM_LOAD( "rv1cg3.1e", 0x200000*0x3, 0x200000,CRC(39b62921) SHA1(873287d81338baf10dd85214d82f6c38bfdf199e) ) /* rv1cg3.2e */
	ROM_LOAD( "rv1cg4.1f", 0x200000*0x4, 0x200000,CRC(a9791ea2) SHA1(245b2ebbadd1fbca90dc241f88e9f6f341b2a01a) ) /* rv1cg4.2f */
	ROM_LOAD( "rv1cg5.1j", 0x200000*0x5, 0x200000,CRC(b2c79ec1) SHA1(6f669996863bdf1fe09b0c1a2a876625029d3d43) ) /* rv1cg5.2j */
	ROM_LOAD( "rv1cg6.1k", 0x200000*0x6, 0x200000,CRC(8cddedc2) SHA1(e3993f5505bc7e61bec7be5b48c873572e1220f7) ) /* rv1cg6.2k */
	ROM_LOAD( "rv1cg7.1n", 0x200000*0x7, 0x200000,CRC(b39147ca) SHA1(50ca6691fc809c95e6999dd52e39f2b8c2d22f3b) ) /* rv1cg7.2n */

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "rv1ccrl.5a",  0x000000, 0x200000,CRC(bc634f72) SHA1(b5c504ed92bca7682614fc4c51f38cff607e6f2a) ) /* rv1ccrl.5l */
	ROM_LOAD( "rv1ccrh.5c",  0x200000, 0x080000,CRC(a741b262) SHA1(363076220a0eacc67befda05f8253963e8ffbcaa) ) /* rv1ccrh.5j */

	ROM_REGION( 0x80000*12, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "rv1potl0.5b", 0x80000*0x0, 0x80000,CRC(de2ce519) SHA1(2fe0dd000571f76d1a4df6a439d40119125170ef) )
	ROM_LOAD( "rv1potl1.4b", 0x80000*0x1, 0x80000,CRC(2215cb5a) SHA1(d48ee692ab3dbcffdc49d22f6f232ca9390da766) )
	ROM_LOAD( "rv1potl2.3b", 0x80000*0x2, 0x80000,CRC(ddb15bf7) SHA1(4c54ec98e0cba10841d43a4ce593cdacfd7f90f8) )
	ROM_LOAD( "rv1potl3.2b", 0x80000*0x3, 0x80000,CRC(fa9361ca) SHA1(35a5c2712bca9c62400b724754de3a931ad21561) )
	ROM_LOAD( "rv1potm0.5c", 0x80000*0x4, 0x80000,CRC(3c024f3a) SHA1(711f0442823797b2d410352796a5cca66af98dce) )
	ROM_LOAD( "rv1potm1.4c", 0x80000*0x5, 0x80000,CRC(b1a32a68) SHA1(e24abb3a7e35d098abae5420bf8ef5c975718987) )
	ROM_LOAD( "rv1potm2.3c", 0x80000*0x6, 0x80000,CRC(a414fe15) SHA1(eb27cdca045ab2ab27dec179043328847fb65e11) )
	ROM_LOAD( "rv1potm3.2c", 0x80000*0x7, 0x80000,CRC(2953bbb4) SHA1(aca1acd87f7130d2522d0c6f8e60beeb7ab7495a) )
	ROM_LOAD( "rv1potu0.5d", 0x80000*0x8, 0x80000,CRC(b9eaf3cc) SHA1(3b2a9041f1fa90706ecf7d4fbff918516f891a07) )
	ROM_LOAD( "rv1potu1.4d", 0x80000*0x9, 0x80000,CRC(a5c55258) SHA1(826d4dde761aec7d848456f7bc4ba6268fe99605) )
	ROM_LOAD( "rv1potu2.3d", 0x80000*0xa, 0x80000,CRC(c18fcb74) SHA1(a4009ae2b014dc89aed4741fd97f84350117c2f4) )
	ROM_LOAD( "rv1potu3.2d", 0x80000*0xb, 0x80000,CRC(79735aaa) SHA1(1cf14274669b916a7641f7a16785da1b72347485) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "rv1wav0.10r", 0x000000, 0x100000, CRC(5aef8143) SHA1(a75d31298e3ff9b290f238976a11e8b85cfb72d3) )
	ROM_LOAD( "rv1wav1.10p", 0x200000, 0x100000, CRC(9ed9e6b3) SHA1(dd1da2b08d1b6aa0912daacc77744c9799aabb78) )
	ROM_LOAD( "rv1wav2.10n", 0x100000, 0x100000, CRC(5af9dc83) SHA1(9aeb7f8217b806a6f3ed93056513af9fbcb6b372) )
	ROM_LOAD( "rv1wav3.10l", 0x300000, 0x100000, CRC(ffb9ad75) SHA1(a9a61a597bd3bbe9732f92747d82264fe4d9af48) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )

	ROM_REGION( 0x2000, "eeprom", 0 ) // default eeprom
	ROM_LOAD( "rv1eeprm.9e", 0x0000, 0x2000, CRC(e00dd412) SHA1(f594b31ace5e5e980e904faa8b83a450cc95db17) )
ROM_END


ROM_START( cybrcomm )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "cy1prgll.4d", 0x00003, 0x80000, CRC(b3eab156) SHA1(2a5c4e0360c3b9500687a4d70f7110a0c30da2a5) )
	ROM_LOAD32_BYTE( "cy1prglm.2d", 0x00002, 0x80000, CRC(884a5b0e) SHA1(0e27ae366b8a2695fe112b4740c8c9013bb97e26) )
	ROM_LOAD32_BYTE( "cy1prgum.8d", 0x00001, 0x80000, CRC(c9c4a921) SHA1(76a52461165a8bd8d984a34063fbeb4cb73624af) )
	ROM_LOAD32_BYTE( "cy1prguu.6d", 0x00000, 0x80000, CRC(5f22975b) SHA1(a1a5cb66358d64a3c564b912f2eeafa182786b1e) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "cy1data.6r", 0x00000, 0x20000, CRC(10d0005b) SHA1(10508eeaf74d24a611b44cd3bb12417ceb78904f) )
	ROM_RELOAD(             0x20000, 0x20000)
	ROM_RELOAD(             0x40000, 0x20000)
	ROM_RELOAD(             0x60000, 0x20000)

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "cyc1cg0.1a", 0x200000*0x4, 0x200000,CRC(e839b9bd) SHA1(fee43d37dcca7f1fb952a6bfb886b7ee30b7d75c) ) /* cyc1cg0.6a */
	ROM_LOAD( "cyc1cg1.2a", 0x200000*0x5, 0x200000,CRC(7d13993f) SHA1(96ac82bcc63afe395bae73f005eb66dad7742d48) ) /* cyc1cg1.7a */
	ROM_LOAD( "cyc1cg2.3a", 0x200000*0x6, 0x200000,CRC(7c464566) SHA1(69817ac3a7c6e43b960e8a904962b58b23417163) ) /* cyc1cg2.8a */
	ROM_LOAD( "cyc1cg3.5a", 0x200000*0x7, 0x200000,CRC(2222e16f) SHA1(562bcd4d43b1543303d8fd66d9f0d9a8e3702492) ) /* cyc1cg3.9a */

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */

	//cyc1ccrl.1c FIXED BITS (xxxxxxxx11xxxxxx)
	ROM_LOAD( "cyc1ccrl.1c",     0x000000, 0x100000,CRC(1a0dc5f0) SHA1(bf0093d9cbdcb45a82705e966c48a1f408fa344e) ) /* cyc1ccrl.8c */

	//cyc1ccrh.2c 1xxxxxxxxxxxxxxxxxx = 0xFF
	ROM_LOAD( "cyc1ccrh.2c",     0x200000, 0x080000,CRC(8c4090b8) SHA1(456d548a48833e840c5d39d47b2dcca03f8d6321) ) /* cyc1ccrh.7c */

	ROM_REGION( 0x80000*9, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "cyc1ptl0.5b", 0x80000*0x0, 0x80000,CRC(d91de03d) SHA1(05819d285f6111867c41337bda9c4b9ad5394b6b) )
	ROM_LOAD( "cyc1ptl1.4b", 0x80000*0x1, 0x80000,CRC(e5b98021) SHA1(7416cbf74da969f822e0363ced7a25b967277e28) )
	ROM_LOAD( "cyc1ptl2.3b", 0x80000*0x2, 0x80000,CRC(7ba786c6) SHA1(1a5319dec495453bab9d70ae773a807f0036b355) )
	ROM_LOAD( "cyc1ptm0.5c", 0x80000*0x3, 0x80000,CRC(d454b5c6) SHA1(95ae6f0455e9fd7dff066e74cd4343c94d1bc212) )
	ROM_LOAD( "cyc1ptm1.4c", 0x80000*0x4, 0x80000,CRC(74fdf8cc) SHA1(f2627f400e247b6d4c4157eaf0ec69d57212e566) )
	ROM_LOAD( "cyc1ptm2.3c", 0x80000*0x5, 0x80000,CRC(b9c99a45) SHA1(c86cf594b416776eaf9a32c3cb9d34acc79777e9) )
	ROM_LOAD( "cyc1ptu0.5d", 0x80000*0x6, 0x80000,CRC(4d40897f) SHA1(ffe2a0ab66443553c83512f9a1be94b2e385cf2f) )
	ROM_LOAD( "cyc1ptu1.4d", 0x80000*0x7, 0x80000,CRC(3bdaeeeb) SHA1(826f97e2165af8569cfec03874b16030a9486559) )
	ROM_LOAD( "cyc1ptu2.3d", 0x80000*0x8, 0x80000,CRC(a0e73674) SHA1(1e22142a564e664031c12b250664fc82e3b3d43b) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "cy1wav0.10r", 0x000000, 0x100000, CRC(c6f366a2) SHA1(795dbee09df159d3501c748fb3de16cca81742d6) )
	ROM_LOAD( "cy1wav1.10p", 0x200000, 0x100000, CRC(f30b5e37) SHA1(9f5a94d82741ef9688c6e415ebb9009c906737c9) )
	ROM_LOAD( "cy1wav2.10n", 0x100000, 0x100000, CRC(b98c1ca6) SHA1(4b66aa05f82be5ef3315acc30031872698ff4391) )
	ROM_LOAD( "cy1wav3.10l", 0x300000, 0x100000, CRC(43dbac19) SHA1(83fd4ae4e7ec264fc217ed18caf59bf438af0c3d) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )

	ROM_REGION( 0x2000, "eeprom", 0 ) // default eeprom
	ROM_LOAD( "cy1eeprm.9e", 0x0000, 0x2000, CRC(8432c066) SHA1(99d4bfda3f8aec288dbeaf291bce85fe9009a1de) )
ROM_END


ROM_START( acedrvrw )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "ad2prgll.4d", 0x00003, 0x80000, CRC(808c5ff8) SHA1(119c90ecb5aa099a0e5d1d7944c004beacead367) )
	ROM_LOAD32_BYTE( "ad2prglm.2d", 0x00002, 0x80000, CRC(5f726a10) SHA1(d077312c6a387fbdf906d278c73c6a3730687f32) )
	ROM_LOAD32_BYTE( "ad2prgum.8d", 0x00001, 0x80000, CRC(d5042d6e) SHA1(9ae93e7ea7126302831a879ba0aadcb6e5b842f5) )
	ROM_LOAD32_BYTE( "ad2prguu.6d", 0x00000, 0x80000, CRC(86d4661d) SHA1(2a1529a51ca5466994a2d0d84c7aab13cef95a11) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "ad1data.6r", 0, 0x080000, CRC(82024f74) SHA1(711ab0c4f027716aeab18e3a5d3d06fa82af8007) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "ad1cg0.1a", 0x200000*0x4, 0x200000,CRC(faaa1ee2) SHA1(878f2b74587ed4d06c5110a0eb0020c49ddc5dfa) )
	ROM_LOAD( "ad1cg1.2a", 0x200000*0x5, 0x200000,CRC(1aab1eb7) SHA1(b8f9eeafec7e0de340cf48e38fa55dd14404c867) )
	ROM_LOAD( "ad1cg2.3a", 0x200000*0x6, 0x200000,CRC(cdcd1874) SHA1(5a7a4a0d897cca4956b0a4f178f39f618c921861) )
	ROM_LOAD( "ad1cg3.5a", 0x200000*0x7, 0x200000,CRC(effdd2cd) SHA1(9ff156e7e38c103b8fa6f3c29776dd38482d9cf2) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "ad1ccrl.1c", 0x000000, 0x200000,CRC(bc3c9b12) SHA1(088e861e5c4b37c54b7f72963113a10870bf7927) )
	ROM_LOAD( "ad1ccrh.2c", 0x200000, 0x080000,CRC(71f44526) SHA1(bb4811fc5de626380ce6a17bee73e5e47926d850) )

	ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "ad1potl0.5b", 0x80000*0, 0x80000,CRC(dfc7e729) SHA1(5e3deef66d0a5dd2ff0584b8c8be4bf5e798e4d0) )
	ROM_LOAD( "ad1potl1.4b", 0x80000*1, 0x80000,CRC(5914ef8e) SHA1(f6db9c3061ceda76eef0a9538d9c048366b71124) )
	ROM_LOAD( "ad1potm0.5c", 0x80000*2, 0x80000,CRC(844bcd6b) SHA1(629b8dc0a7e94410c08c8874b69d9f4bc22f3e4f) )
	ROM_LOAD( "ad1potm1.4c", 0x80000*3, 0x80000,CRC(515cf541) SHA1(db1522813ea3e982d479cc1903d18799bf75aea9) )
	ROM_LOAD( "ad1potu0.5d", 0x80000*4, 0x80000,CRC(e0f44949) SHA1(ffdb64d600883974b05edaa9ed3071af355ee17f) )
	ROM_LOAD( "ad1potu1.4d", 0x80000*5, 0x80000,CRC(f2cd2cbb) SHA1(19fe6e3454a1e4353c7fe0a0d7a71742fea946de) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "ad1wave0.10r", 0x100000*0, 0x100000,CRC(c7879a72) SHA1(ae04d664858b0944583590ed0003a9420032d5ca) )
	ROM_LOAD( "ad1wave1.10p", 0x100000*2, 0x100000,CRC(69c1d41e) SHA1(b5cdfe7b75075c585dfd842347f8e4e692bb2781) )
	ROM_LOAD( "ad1wave2.10n", 0x100000*1, 0x100000,CRC(365a6831) SHA1(ddaa44a4436d6de120b64a5d130b1ee18f872e19) )
	ROM_LOAD( "ad1wave3.10l", 0x100000*3, 0x100000,CRC(cd8ecb0b) SHA1(7950b5a3a81f5554f57accabc7a623b8265a21a1) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END


ROM_START( victlapw )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "advprgll.4d", 0x00003, 0x80000, CRC(4dc1b0ab) SHA1(b5913388d16f824af6dbb01b5b0350d510667a87) )
	ROM_LOAD32_BYTE( "advprglm.2d", 0x00002, 0x80000, CRC(7b658bef) SHA1(cf982b49fde0c1897c4c16e77f9eb2a145d8cd42) )
	ROM_LOAD32_BYTE( "advprgum.8d", 0x00001, 0x80000, CRC(af67f2fb) SHA1(f391843ee0d053e33660c60e3718871142d932f2) )
	ROM_LOAD32_BYTE( "advprguu.6d", 0x00000, 0x80000, CRC(b60e5d2b) SHA1(f5740615c2864c5c6433275cf4388bda5122b7a7) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "adv1data.6r", 0, 0x080000, CRC(10eecdb4) SHA1(aaedeed166614e6670e765e0d7e4e9eb5f38ad10) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "adv1cg0.2a",  0x200000*0x0, 0x200000,CRC(13353848) SHA1(c6c7693e3cb086919daf9fcaf6bf602142213073) )
	ROM_LOAD( "adv1cg1.1c",  0x200000*0x1, 0x200000,CRC(1542066c) SHA1(20a053e919b7a81da2a17d31dc7482832a4d4ffe) )
	ROM_LOAD( "adv1cg2.2d",  0x200000*0x2, 0x200000,CRC(111f371c) SHA1(29d8062daae51b3c1712bd30baa9813a2b5b374d) )
	ROM_LOAD( "adv1cg3.1e",  0x200000*0x3, 0x200000,CRC(a077831f) SHA1(71bb95199b368e48bc474123ca84d19213f73137) )
	ROM_LOAD( "adv1cg4.2f",  0x200000*0x4, 0x200000,CRC(71abdacf) SHA1(64409e6aa40dd9e5a6dd1dc306860fbbf6ee7c3e) )
	ROM_LOAD( "adv1cg5.1j",  0x200000*0x5, 0x200000,CRC(cd6cd798) SHA1(51070997a457c0ace078174569cd548ac2226b2d) )
	ROM_LOAD( "adv1cg6.2k",  0x200000*0x6, 0x200000,CRC(94bdafba) SHA1(41e64fa99b342edd8b0ed95ae9869c23e03399e6) )
	ROM_LOAD( "adv1cg7.1n",  0x200000*0x7, 0x200000,CRC(18823475) SHA1(a3244d665b59c352593de21f5cb8d55ddf8cee5c) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "adv1ccrl.5a",     0x000000, 0x200000,CRC(dd2b96ae) SHA1(6337ce17e617234c27ebad578ba82451649aad9c) ) /* ident to adv1ccrl.5l */
	ROM_LOAD( "adv1ccrh.5c",     0x200000, 0x080000,CRC(5719844a) SHA1(a17d7bc239235e9f566931ba4fee1d6ad7964d83) ) /* ident to adv1ccrh.5j */

	ROM_REGION( 0x80000*9, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "adv1pot.l0", 0x80000*0, 0x80000,CRC(3b85b2a4) SHA1(84c92ed0105618d4aa5508af344b4b6cfa772567) )
	ROM_LOAD( "adv1pot.l1", 0x80000*1, 0x80000,CRC(601d6488) SHA1(c7932103ba6070e17deb3cc06060eed7789f938e) )
	ROM_LOAD( "adv1pot.l2", 0x80000*2, 0x80000,CRC(a0323a84) SHA1(deadf9a47461df7b137759d6886e676137b39fd2) )
	ROM_LOAD( "adv1pot.m0", 0x80000*3, 0x80000,CRC(20951aa2) SHA1(3de55bded443a5b78699cec4845470b53b22301a) )
	ROM_LOAD( "adv1pot.m1", 0x80000*4, 0x80000,CRC(5aed6fbf) SHA1(8cee781d8a12e00635b9a1e5cc8d82e64b17e8f1) )
	ROM_LOAD( "adv1pot.m2", 0x80000*5, 0x80000,CRC(00cbff92) SHA1(09a11ba064aafc921a7ca0add5898d91b773f10a) )
	ROM_LOAD( "adv1pot.u0", 0x80000*6, 0x80000,CRC(6b73dd2a) SHA1(e3654ab2b62e4f3314558209e37c5636f871a6c7) )
	ROM_LOAD( "adv1pot.u1", 0x80000*7, 0x80000,CRC(c8788f74) SHA1(606e10b05146e3db824aa608745de80584420d12) )
	ROM_LOAD( "adv1pot.u2", 0x80000*8, 0x80000,CRC(e67f29c5) SHA1(16222afb4f1f494711dd00ebb347c824db333bae) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "adv1wav0.10r", 0x000000, 0x100000, CRC(f07b2d9d) SHA1(fd46c23b336d5e9a748f7f8d825c19737125d2fb) )
	ROM_LOAD( "adv1wav1.10p", 0x200000, 0x100000, CRC(737f3c7a) SHA1(4737994f146c0076e7270785f41f3a85c53c7c5f) )
	ROM_LOAD( "adv1wav2.10n", 0x100000, 0x100000, CRC(c1a5ca5e) SHA1(27e6f9256d5fe5966e91d6be1e6e80900a764af1) )
	ROM_LOAD( "adv1wav3.10l", 0x300000, 0x100000, CRC(fc6b8004) SHA1(5c9e0805895931ec2b6a43376059bdbf5777222f) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

ROM_START( victlapj )
	ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "adv1_prgllc.4d", 0x00003, 0x80000, CRC(1c630018) SHA1(c4cddeb18c6b81c768e25489f1d5af0e9c0bbfa5) )
	ROM_LOAD32_BYTE( "adv1_prglmc.2d", 0x00002, 0x80000, CRC(78413604) SHA1(08245cc1f8d97a166b6c0022fc03c423d92a3653) )
	ROM_LOAD32_BYTE( "adv1_prgumc.8d", 0x00001, 0x80000, CRC(464388d9) SHA1(afad780532aff175b0a547392e80c9f01efbf9d9) )
	ROM_LOAD32_BYTE( "adv1_prguuc.6d", 0x00000, 0x80000, CRC(ad3cb5f9) SHA1(9a62043f60de4d4c82c5bec169ec975add271367) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x80000, "mcu", 0 ) /* sound data */
	ROM_LOAD( "adv1data.6r", 0, 0x080000, CRC(10eecdb4) SHA1(aaedeed166614e6670e765e0d7e4e9eb5f38ad10) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "adv1cg0.2a",  0x200000*0x0, 0x200000,CRC(13353848) SHA1(c6c7693e3cb086919daf9fcaf6bf602142213073) )
	ROM_LOAD( "adv1cg1.1c",  0x200000*0x1, 0x200000,CRC(1542066c) SHA1(20a053e919b7a81da2a17d31dc7482832a4d4ffe) )
	ROM_LOAD( "adv1cg2.2d",  0x200000*0x2, 0x200000,CRC(111f371c) SHA1(29d8062daae51b3c1712bd30baa9813a2b5b374d) )
	ROM_LOAD( "adv1cg3.1e",  0x200000*0x3, 0x200000,CRC(a077831f) SHA1(71bb95199b368e48bc474123ca84d19213f73137) )
	ROM_LOAD( "adv1cg4.2f",  0x200000*0x4, 0x200000,CRC(71abdacf) SHA1(64409e6aa40dd9e5a6dd1dc306860fbbf6ee7c3e) )
	ROM_LOAD( "adv1cg5.1j",  0x200000*0x5, 0x200000,CRC(cd6cd798) SHA1(51070997a457c0ace078174569cd548ac2226b2d) )
	ROM_LOAD( "adv1cg6.2k",  0x200000*0x6, 0x200000,CRC(94bdafba) SHA1(41e64fa99b342edd8b0ed95ae9869c23e03399e6) )
	ROM_LOAD( "adv1cg7.1n",  0x200000*0x7, 0x200000,CRC(18823475) SHA1(a3244d665b59c352593de21f5cb8d55ddf8cee5c) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "adv1ccrl.5a",     0x000000, 0x200000,CRC(dd2b96ae) SHA1(6337ce17e617234c27ebad578ba82451649aad9c) ) /* ident to adv1ccrl.5l */
	ROM_LOAD( "adv1ccrh.5c",     0x200000, 0x080000,CRC(5719844a) SHA1(a17d7bc239235e9f566931ba4fee1d6ad7964d83) ) /* ident to adv1ccrh.5j */

	ROM_REGION( 0x80000*9, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "adv1pot.l0", 0x80000*0, 0x80000,CRC(3b85b2a4) SHA1(84c92ed0105618d4aa5508af344b4b6cfa772567) )
	ROM_LOAD( "adv1pot.l1", 0x80000*1, 0x80000,CRC(601d6488) SHA1(c7932103ba6070e17deb3cc06060eed7789f938e) )
	ROM_LOAD( "adv1pot.l2", 0x80000*2, 0x80000,CRC(a0323a84) SHA1(deadf9a47461df7b137759d6886e676137b39fd2) )
	ROM_LOAD( "adv1pot.m0", 0x80000*3, 0x80000,CRC(20951aa2) SHA1(3de55bded443a5b78699cec4845470b53b22301a) )
	ROM_LOAD( "adv1pot.m1", 0x80000*4, 0x80000,CRC(5aed6fbf) SHA1(8cee781d8a12e00635b9a1e5cc8d82e64b17e8f1) )
	ROM_LOAD( "adv1pot.m2", 0x80000*5, 0x80000,CRC(00cbff92) SHA1(09a11ba064aafc921a7ca0add5898d91b773f10a) )
	ROM_LOAD( "adv1pot.u0", 0x80000*6, 0x80000,CRC(6b73dd2a) SHA1(e3654ab2b62e4f3314558209e37c5636f871a6c7) )
	ROM_LOAD( "adv1pot.u1", 0x80000*7, 0x80000,CRC(c8788f74) SHA1(606e10b05146e3db824aa608745de80584420d12) )
	ROM_LOAD( "adv1pot.u2", 0x80000*8, 0x80000,CRC(e67f29c5) SHA1(16222afb4f1f494711dd00ebb347c824db333bae) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "adv1wav0.10r", 0x000000, 0x100000, CRC(f07b2d9d) SHA1(fd46c23b336d5e9a748f7f8d825c19737125d2fb) )
	ROM_LOAD( "adv1wav1.10p", 0x200000, 0x100000, CRC(737f3c7a) SHA1(4737994f146c0076e7270785f41f3a85c53c7c5f) )
	ROM_LOAD( "adv1wav2.10n", 0x100000, 0x100000, CRC(c1a5ca5e) SHA1(27e6f9256d5fe5966e91d6be1e6e80900a764af1) )
	ROM_LOAD( "adv1wav3.10l", 0x300000, 0x100000, CRC(fc6b8004) SHA1(5c9e0805895931ec2b6a43376059bdbf5777222f) )

	ROM_REGION( 0x300, "gamma_proms", 0 )
	ROM_LOAD( "rr1gam.2d",   0x0000, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.3d",   0x0100, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
	ROM_LOAD( "rr1gam.4d",   0x0200, 0x0100, CRC(b2161bce) SHA1(d2681cc0cf8e68df0d942d392b4eb4458c4bb356) )
ROM_END

/*********************************************************************************************/

ROM_START( propcycl )
	ROM_REGION( 0x400000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "pr2ver-a.1", 0x00003, 0x100000, CRC(3f58594c) SHA1(5fdd8c61b47b51088a201799ce0c2f08c32ef852) )
	ROM_LOAD32_BYTE( "pr2ver-a.2", 0x00002, 0x100000, CRC(c0da354a) SHA1(f27a71a62385b842404fcd8ed6513158e3639b8f) )
	ROM_LOAD32_BYTE( "pr2ver-a.3", 0x00001, 0x100000, CRC(74bf4b74) SHA1(02713aa07238cc9e30163ae24d12c034aa972ff3) )
	ROM_LOAD32_BYTE( "pr2ver-a.4", 0x00000, 0x100000, CRC(cf4d5638) SHA1(2ddd00d6ec3b85c234820507650d201e176c94a2) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x080000, "mcu", 0 ) /* SS22-BIOS ver1.41 */
	ROM_LOAD( "pr1data.8k", 0, 0x080000, CRC(2e5767a4) SHA1(390bf05c90044d841fe2dd4a427177fa1570b9a6) )

	ROM_REGION( 0x200000*8, "sprite", ROMREGION_ERASEFF ) /* 32x32x8bpp sprite tiles */
	ROM_LOAD( "pr1scg0.12f", 0x200000*0, 0x200000,CRC(2d09a869) SHA1(ce8beabaac255e1de29d944c9866022bad713519) ) /* identical to "pr1scg0.12l" */
	ROM_LOAD( "pr1scg1.10f", 0x200000*1, 0x200000,CRC(7433c5bd) SHA1(a8fd4e73de66e3d443c0cb5b5beef8f467014815) ) /* identical to "pr1scg1.10l" */

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "pr1cg0.12b",  0x200000*0x0, 0x200000,CRC(0a041238) SHA1(da5688970432f7fe39337ee9fb46ca25a53fdb11) ) /* identical to "pr1cg0.8d" */
	ROM_LOAD( "pr1cg1.10d",  0x200000*0x1, 0x200000,CRC(7d09e6a7) SHA1(892317ee0bd796fa5c70d64912ef2e696792a2d4) ) /* identical to "pr1cg1.13b" */
	ROM_LOAD( "pr1cg2.12d",  0x200000*0x2, 0x200000,CRC(659f006e) SHA1(23362a922cb1100950181fac4858b953d8fc0794) ) /* identical to "pr1cg2.14b" */
	ROM_LOAD( "pr1cg3.13d",  0x200000*0x3, 0x200000,CRC(d30bffa3) SHA1(2f05227d91d257db9fa8cae114974de602d98729) ) /* identical to "pr1cg3.16b" */
	ROM_LOAD( "pr1cg4.14d",  0x200000*0x4, 0x200000,CRC(f4636cc9) SHA1(4e01a476e418e5790878572e83a8a11536ce30ae) ) /* identical to "pr1cg4.18b" */
	ROM_LOAD( "pr1cg5.16d",  0x200000*0x5, 0x200000,CRC(97d333de) SHA1(e8f8383f49aae834dd8b57231b25899703cef966) ) /* identical to "pr1cg5.19b" */
	ROM_LOAD( "pr1cg6.18a",  0x200000*0x6, 0x200000,CRC(3e081c03) SHA1(6ccb162952f6076359b2785b5d800b39a9a3c5ce) ) /* identical to "pr1cg6.18d" */
	ROM_LOAD( "pr1cg7.15a",  0x200000*0x7, 0x200000,CRC(ec9fc5c8) SHA1(16de614b26f06bbddae3ab56cebba45efd6fe81b) ) /* identical to "pr1cg7.19d" */

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "pr1ccrl.3d",  0x000000, 0x200000,CRC(e01321fd) SHA1(5938c6eff8e1b3642728c3be733f567a97cb5aad) ) /* identical to "pr1ccrl.7b" */
	ROM_LOAD( "pr1ccrh.1d",  0x200000, 0x080000,CRC(1d68bc31) SHA1(d534d0daebe7018e83b57cc7919c294ab89bddc8) ) /* identical to "pr1ccrh.5b" */
	/* These two ROMs define a huge texture tilemap using the tiles from "textile".
	 * The tilemap has 0x100 columns.
	 *
	 * pr1ccrl contains little endian 16 bit words.  Each word references a 16x16 tile.
	 *
	 * pr1ccrh.1d contains packed nibbles.  Each nibble encodes three tile attributes:
	 *  0x8 = swapxy
	 *  0x4 = flipx
	 *  0x2 = flipy
	 *  0x1 = tile bank (used in some sys22 games)
	 */

	ROM_REGION( 0x80000*9, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "pr1ptrl0.18k", 0x80000*0, 0x80000,CRC(fddb27a2) SHA1(6e837b45e3f9ed7ca3d1a457d0f0124de5618d1f) )
	ROM_LOAD( "pr1ptrl1.16k", 0x80000*1, 0x80000,CRC(6964dd06) SHA1(f38a550165504693d20892a7dcfaf01db19b04ef) )
	ROM_LOAD( "pr1ptrl2.15k", 0x80000*2, 0x80000,CRC(4d7ed1d4) SHA1(8f72864a06ff8962e640cb36d062bddf5d110308) )

	ROM_LOAD( "pr1ptrm0.18j", 0x80000*3, 0x80000,CRC(b6f204b7) SHA1(3b34f240b399b6406faaf338ae0ab536247e64a6) )
	ROM_LOAD( "pr1ptrm1.16j", 0x80000*4, 0x80000,CRC(949588b7) SHA1(fdaf50ff2496200b9c981efc18b035f3c0a96ace) )
	ROM_LOAD( "pr1ptrm2.15j", 0x80000*5, 0x80000,CRC(dc1cef0a) SHA1(8cbc02cf73fac3cc110b676d77602ae628385eae) )

	ROM_LOAD( "pr1ptru0.18f", 0x80000*6, 0x80000,CRC(5d66a7c4) SHA1(c9ed1c18724192d45c1f6b40096f15d02baf2401) )
	ROM_LOAD( "pr1ptru1.16f", 0x80000*7, 0x80000,CRC(e9a3f72b) SHA1(f967e1adf8eee4fffdf4288d36a93c5bb4f9a126) )
	ROM_LOAD( "pr1ptru2.15f", 0x80000*8, 0x80000,CRC(c346a842) SHA1(299bc0a30d0e74d8adfa3dc605aebf6439f5bc18) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "pr1wavea.2l", 0x000000, 0x400000, CRC(320f3913) SHA1(3887b7334ca7762794c14198dd24bab47fcd9505) )
	ROM_LOAD( "pr1waveb.1l", 0x800000, 0x400000, CRC(d91acb26) SHA1(c2161e2d70e08aed15cbc875ffee685190611daf) )
ROM_END


ROM_START( airco22b )
	ROM_REGION( 0x400000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "acs1verb.1", 0x00003, 0x100000, CRC(062c4f61) SHA1(98e1c75dd0f493eb6ebb64b46543217c1d40116e) )
	ROM_LOAD32_BYTE( "acs1verb.2", 0x00002, 0x100000, CRC(8ae69711) SHA1(4c5323fa8f0419275e330fec66d1fb2b89bb3795) )
	ROM_LOAD32_BYTE( "acs1verb.3", 0x00001, 0x100000, CRC(71738e67) SHA1(eb8c66dedbeff911b6166ebbda466fb9656ef0fb) )
	ROM_LOAD32_BYTE( "acs1verb.4", 0x00000, 0x100000, CRC(3b193add) SHA1(5e3bca13905bfa3a2947f4f16ca01878b0a14a3a) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x080000, "mcu", 0 ) /* S22-BIOS ver1.20 */
	ROM_LOAD( "acs1data.8k", 0, 0x080000, CRC(33824bc9) SHA1(80ec63883770e5eec1f5f1ddc16a85ef8f22a48b) )

	ROM_REGION( 0x200000*8, "sprite", ROMREGION_ERASEFF ) /* 32x32x8bpp sprite tiles */
	ROM_LOAD( "acs1scg0.12l", 0x200000*0, 0x200000,CRC(e5235404) SHA1(3133b71d1bde3a9815cd02e97382b8078b62b0bb) )
	ROM_LOAD( "acs1scg1.10l", 0x200000*1, 0x200000,CRC(828e91e7) SHA1(8383b029cd29fbad107fd49e866defb50c11c99a) )

	ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "acs1cg0.8d",  0x200000*0x0, 0x200000,CRC(1f31343e) SHA1(25ba730cec74e0ed0b404f5c4430b7c3368c9b52) )
	ROM_LOAD( "acs1cg1.10d", 0x200000*0x1, 0x200000,CRC(ccd5481d) SHA1(050e6fc7d4e0591f8ffc9552d140b6bd4533c06d) )
	ROM_LOAD( "acs1cg2.12d", 0x200000*0x2, 0x200000,CRC(14e5d0d2) SHA1(3147ad11098030e9cfd93fbc0a1b3aafa8b8aba6) )
	ROM_LOAD( "acs1cg3.13d", 0x200000*0x3, 0x200000,CRC(1a7bcc16) SHA1(bbc4ca5b208bea8394d1679e4e2d17d22331e2c8) )
	ROM_LOAD( "acs1cg4.14d", 0x200000*0x4, 0x200000,CRC(1920b7fb) SHA1(56318f2a96c55998bb9a8d791d56be3dfb39867e) )
	ROM_LOAD( "acs1cg5.16d", 0x200000*0x5, 0x200000,CRC(3dd109b7) SHA1(a7f914b9b80f1bca1afb6144698578a29ca74676) )
	ROM_LOAD( "acs1cg6.18d", 0x200000*0x6, 0x200000,CRC(ec71c8a3) SHA1(86892a91883d483ca0d422b78fa36042e02f3ad3) )
	ROM_LOAD( "acs1cg7.19d", 0x200000*0x7, 0x200000,CRC(82271757) SHA1(023c935e78b14da310e4c29da8785b82aa3241ac) )

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "acs1ccrl.3d",     0x000000, 0x200000,CRC(07088ba1) SHA1(a962c0821d5af28ed508cfdbd613675454e306e3) )
	ROM_LOAD( "acs1ccrh.1d",     0x200000, 0x080000,CRC(62936af6) SHA1(ca80b68415aa2cd2ce4e90404f10640d0ae38be9) )

	ROM_REGION( 0x80000*12, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "acs1ptl0.18k", 0x80000*0x0, 0x80000,CRC(bd5896c7) SHA1(58ec7d0f1e0bfdbf4908e1d920bbd7f094993777) )
	ROM_LOAD( "acs1ptl1.16k", 0x80000*0x1, 0x80000,CRC(e583b975) SHA1(beb0cc2b44bc69af057c2bb744cd7e1b95de577a) )
	ROM_LOAD( "acs1ptl2.15k", 0x80000*0x2, 0x80000,CRC(802d737a) SHA1(3d99a369db70d13fb87c2ff26c82b4b39afe94d9) )
	ROM_LOAD( "acs1ptl3.14k", 0x80000*0x3, 0x80000,CRC(fe556ecb) SHA1(9d9dbbb4f1d3688fb763001834640d79d9987d47) )

	ROM_LOAD( "acs1ptm0.18j", 0x80000*0x4, 0x80000,CRC(949b6c58) SHA1(6ea016551b10f5d5764921dcc5a4b81d2b93d701) )
	ROM_LOAD( "acs1ptm1.16j", 0x80000*0x5, 0x80000,CRC(8b2b99d9) SHA1(89c3545c4035509307728a9577018c1100ce3a54) )
	ROM_LOAD( "acs1ptm2.15j", 0x80000*0x6, 0x80000,CRC(f1515080) SHA1(27a87217a140477a6840a610c95ae57abc0d01a6) )
	ROM_LOAD( "acs1ptm3.14j", 0x80000*0x7, 0x80000,CRC(e364f4aa) SHA1(3af6a864765871664cccad82c4795f677be68d51) )

	ROM_LOAD( "acs1ptu0.18f", 0x80000*0x8, 0x80000,CRC(746b3084) SHA1(73397d1f22300fb3a81a0a068da4d0a8cfdc0a36) )
	ROM_LOAD( "acs1ptu1.16f", 0x80000*0x9, 0x80000,CRC(b44f1d3b) SHA1(f3f1a85c082053653e4da7d7f01f1baef1a013c8) )
	ROM_LOAD( "acs1ptu2.15f", 0x80000*0xa, 0x80000,CRC(fdd2d778) SHA1(0269f971d778e908a1efb5a63b08fb3365d98c2a) )
	ROM_LOAD( "acs1ptu3.14f", 0x80000*0xb, 0x80000,CRC(38b425d4) SHA1(8ff6dd6775d42afdff4c9fb2232e4d72b38e515a) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "acs1wav0.1", 0x400000, 0x400000, CRC(52fb9762) SHA1(125c163e62d701c2e17ba0b572ed27c944ca0412) )
	ROM_LOAD( "acs1wav1.2", 0x800000, 0x400000, CRC(b568dca2) SHA1(503deb277691d801acac1380ded2868a5d5ac501) )
ROM_END


ROM_START( cybrcycc )
	ROM_REGION( 0x400000, "maincpu", 0 ) /* main program */
	ROM_LOAD32_BYTE( "cb2ver-c.1", 0x00003, 0x100000, CRC(a8e07a14) SHA1(9bef7068c9bf792960df922ea79e4565d7680433) )
	ROM_LOAD32_BYTE( "cb2ver-c.2", 0x00002, 0x100000, CRC(054c504f) SHA1(9bde803ff09be0402f9b0388e55407362a2508e3) )
	ROM_LOAD32_BYTE( "cb2ver-c.3", 0x00001, 0x100000, CRC(47e6306c) SHA1(39d6fc2c3cb9b4c9d3569cedb79b916a90537115) )
	ROM_LOAD32_BYTE( "cb2ver-c.4", 0x00000, 0x100000, CRC(398426e4) SHA1(f20cd4892420e7b978baa51c9129b362422a3895) )

	ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION( 0x10000*2, "slave", 0 ) /* Slave DSP */
	ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )

	ROM_REGION16_LE( 0x080000, "mcu", 0 ) /* S22-BIOS ver1.30 */
	ROM_LOAD( "cb1datab.8k", 0, 0x080000, CRC(e2404221) SHA1(b88810dd45aee8a5475c30806cdfded25fa14e0e) )

	ROM_REGION( 0x200000*8, "sprite", ROMREGION_ERASEFF ) /* 32x32x8bpp sprite tiles */
	ROM_LOAD( "cb1scg0.12f", 0x200000*0, 0x200000,CRC(7aaca90d) SHA1(9808819db5d86d555a03bb20a2fbedf060d04f0e) ) /* identical to "cb1scg0.12l" */

	ROM_REGION( 0x200000*7, "textile", 0) /* 16x16x8bpp texture tiles */
	ROM_LOAD( "cb1cg0.12b",  0x200000*0x0, 0x200000,CRC(762a47a0) SHA1(8a49c700dca7afec5d8d6a38fedcd3ad4b0e6713) ) /* identical to "cb1cg0.8d" */
	ROM_LOAD( "cb1cg1.10d",  0x200000*0x1, 0x200000,CRC(df92c3e6) SHA1(302d7ee7e073a45e7baa948543bd30251f903a6d) ) /* identical to "cb1cg1.13b" */
	ROM_LOAD( "cb1cg2.12d",  0x200000*0x2, 0x200000,CRC(07bc508e) SHA1(7675694d10b50e57bb10b350559bd321df75d1ea) ) /* identical to "cb1cg2.14b" */
	ROM_LOAD( "cb1cg3.13d",  0x200000*0x3, 0x200000,CRC(50c86dea) SHA1(7837a1d2bd3ade470f7fbc732513dd598badd219) ) /* identical to "cb1cg3.16b" */
	ROM_LOAD( "cb1cg4.14d",  0x200000*0x4, 0x200000,CRC(e93b8894) SHA1(4d28b557b7ed2667e6af9f970f3e99cda785b940) ) /* identical to "cb1cg4.18b" */
	ROM_LOAD( "cb1cg5.16d",  0x200000*0x5, 0x200000,CRC(9ee610a1) SHA1(ebc7892b6a66461ca6b6b912a264da1594340b2d) ) /* identical to "cb1cg5.19b" */
	ROM_LOAD( "cb1cg6.18a",  0x200000*0x6, 0x200000,CRC(ddc3b5cc) SHA1(34edffee9eb6fbf4a00fce0da34d9354b1a1155f) ) /* identical to "cb1cg6.18d" */

	ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
	ROM_LOAD( "cb1ccrl.3d",  0x000000, 0x200000,CRC(2f171c48) SHA1(52b76213e37379b4a5cea7de40cf5396dc2998d8) ) /* identical to "cb1ccrl.7b" */
	ROM_LOAD( "cb1ccrh.1d",  0x200000, 0x080000,CRC(86124b93) SHA1(f2cfd726313cbeff162d402a15de2360377630e7) ) /* identical to "cb1ccrh.5b" */

	ROM_REGION( 0x80000*12, "pointrom", 0 ) /* 3d model data */
	ROM_LOAD( "cb1ptrl0.18k", 0x80000*0x0, 0x80000,CRC(f1393a03) SHA1(c9e808601eef5839e6bff630e5f83380e073c5c0) )
	ROM_LOAD( "cb1ptrl1.16k", 0x80000*0x1, 0x80000,CRC(2ad51de7) SHA1(efd102b960ca10cda70da84661acf61e4bbb9f00) )
	ROM_LOAD( "cb1ptrl2.15k", 0x80000*0x2, 0x80000,CRC(78f77c0d) SHA1(5183a8909c2ac0a3d80e707393bcbb4441d79a3c) )
	ROM_LOAD( "cb1ptrl3.14k", 0x80000*0x3, 0x80000,CRC(804bfb4a) SHA1(74b3fc3931265398e23605d3da7ca84a002da632) )
	ROM_LOAD( "cb1ptrm0.18j", 0x80000*0x4, 0x80000,CRC(f4eece49) SHA1(3f34d1ae5986f0d340563ab0fb637bfdacb8712c) )
	ROM_LOAD( "cb1ptrm1.16j", 0x80000*0x5, 0x80000,CRC(5f3cbd7d) SHA1(d00d0a96b71d6a3b98907c4ba7c702e549dd0adb) )
	ROM_LOAD( "cb1ptrm2.15j", 0x80000*0x6, 0x80000,CRC(02c7e4af) SHA1(6a541a28163b1026a824f6f8aed05d0eb0c8ae93) )
	ROM_LOAD( "cb1ptrm3.14j", 0x80000*0x7, 0x80000,CRC(ace3123b) SHA1(2b590ed967572d77b3cc6b37e341a5bdc55c762f) )
	ROM_LOAD( "cb1ptru0.18f", 0x80000*0x8, 0x80000,CRC(58d35341) SHA1(a5fe00bdcf39521f0465743664ff0dd78be5d6e8) )
	ROM_LOAD( "cb1ptru1.16f", 0x80000*0x9, 0x80000,CRC(f4d005b0) SHA1(0862ed1dd0818bfb765d97f1f9d996c321b0ec83) )
	ROM_LOAD( "cb1ptru2.15f", 0x80000*0xa, 0x80000,CRC(68ffcd50) SHA1(5ca5f71b6b079fde14d76c869d211a815bffae68) )
	ROM_LOAD( "cb1ptru3.14f", 0x80000*0xb, 0x80000,CRC(d89c1c2b) SHA1(9c25df696b2d120ce33d7774381460297740007a) )

	ROM_REGION( 0x1000000, "c352", 0 ) // Samples
	ROM_LOAD( "cb1wavea.2l", 0x000000, 0x400000,