summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/layout/kungfur.lay
blob: a0d6a2206452dafaeebc50ece6008c6f4edf6b6a (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
<?xml version="1.0"?>
<mamelayout version="2">

	<element name="static_black">
		<rect>
			<color red="0.0" green="0.0" blue="0.0" />
		</rect>
	</element>
	<element name="static_green">
		<rect>
			<color red="0.0" green="0.22" blue="0.22" />
		</rect>
	</element>
	<element name="static_yellow">
		<rect>
			<color red="0.85" green="0.85" blue="0.2" />
		</rect>
	</element>

	<element name="digit" defstate="0">
		<led7seg>
			<color red="1.0" green="0.1" blue="0.1" />
		</led7seg>
	</element>


<!-- define level lamps -->

	<element name="level1" defstate="0">
		<disk state="1">
			<color red="1.0" green="0.3" blue="0.3" />
		</disk>
		<disk state="0">
			<color red="0.2" green="0.0" blue="0.0" />
		</disk>
		<text string="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.25" width="1" height="0.5" />
		</text>
	</element>
	<element name="level2" defstate="0">
		<disk state="1">
			<color red="1.0" green="0.3" blue="0.3" />
		</disk>
		<disk state="0">
			<color red="0.2" green="0.0" blue="0.0" />
		</disk>
		<text string="2">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.25" width="1" height="0.5" />
		</text>
	</element>
	<element name="level3" defstate="0">
		<disk state="1">
			<color red="1.0" green="0.3" blue="0.3" />
		</disk>
		<disk state="0">
			<color red="0.2" green="0.0" blue="0.0" />
		</disk>
		<text string="3">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.25" width="1" height="0.5" />
		</text>
	</element>
	<element name="level4" defstate="0">
		<disk state="1">
			<color red="1.0" green="0.3" blue="0.3" />
		</disk>
		<disk state="0">
			<color red="0.2" green="0.0" blue="0.0" />
		</disk>
		<text string="4">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.25" width="1" height="0.5" />
		</text>
	</element>
	<element name="level5" defstate="0">
		<disk state="1">
			<color red="1.0" green="0.3" blue="0.3" />
		</disk>
		<disk state="0">
			<color red="0.2" green="0.0" blue="0.0" />
		</disk>
		<text string="5">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.25" width="1" height="0.5" />
		</text>
	</element>


<!-- define text -->

	<element name="text_score">
		<rect>
			<color red="0.0" green="0.22" blue="0.22" />
		</rect>
		<text string="SCORE">
			<color red="1.0" green="1.0" blue="1.0" />
			<bounds x="0.03" y="0" width="0.94" height="1" />
		</text>
	</element>

	<element name="text_level">
		<rect>
			<color red="0.0" green="0.22" blue="0.22" />
		</rect>
		<text string="LEVEL">
			<color red="1.0" green="1.0" blue="1.0" />
			<bounds x="0.03" y="0" width="0.94" height="1" />
		</text>
	</element>

	<element name="text_reaction">
		<rect>
			<color red="0.0" green="0.22" blue="0.22" />
		</rect>
		<text string="REACTION TIME">
			<color red="1.0" green="1.0" blue="1.0" />
			<bounds x="0.02" y="0" width="0.96" height="1" />
		</text>
	</element>

	<element name="text_average">
		<rect>
			<color red="0.0" green="0.22" blue="0.22" />
		</rect>
		<text string="AVERAGE">
			<color red="1.0" green="1.0" blue="1.0" />
			<bounds x="0.03" y="0" width="0.94" height="1" />
		</text>
	</element>

	<element name="text_today">
		<rect>
			<color red="0.0" green="0.22" blue="0.22" />
		</rect>
		<text string="TODAY'S BEST">
			<bounds x="0.025" y="0" width="0.95" height="1" />
			<color red="1.0" green="1.0" blue="1.0" />
		</text>
	</element>

	<element name="text_1">
		<text string="1ST" align="2">
			<color red="1.0" green="1.0" blue="1.0" />
		</text>
	</element>
	<element name="text_2">
		<text string="2ND" align="2">
			<color red="1.0" green="1.0" blue="1.0" />
		</text>
	</element>
	<element name="text_3">
		<text string="3RD" align="2">
			<color red="1.0" green="1.0" blue="1.0" />
		</text>
	</element>

	<element name="text_gameover" defstate="0">
		<text string="GAME OVER" state="1">
			<color red="1.0" green="0.3" blue="0.3" />
		</text>
		<text string="GAME OVER" state="0">
			<color red="0.2" green="0.0" blue="0.0" />
		</text>
	</element>





	<view name="Internal Layout">
		<bounds left="0" right="147" top="0" bottom="100" />
		<bezel element="static_green">
			<bounds left="0" right="147" top="0" bottom="100" />
		</bezel>


<!-- today's highscores -->

		<bezel element="static_yellow">
			<bounds x="97" y="5" width="45" height="75" />
		</bezel>
		<bezel element="static_green">
			<bounds x="98" y="6" width="43" height="73" />
		</bezel>

		<bezel element="text_today">
			<bounds x="105" y="3" width="29" height="5" />
		</bezel>

		<bezel element="text_1">
			<bounds x="97.5" y="21" width="10" height="5" />
		</bezel>
		<bezel element="static_black">
			<bounds x="109" y="9" width="22" height="17" />
		</bezel>

		<bezel name="digit0" element="digit">
			<bounds x="110" y="10" width="10" height="15" />
		</bezel>
		<bezel name="digit1" element="digit">
			<bounds x="120" y="10" width="10" height="15" />
		</bezel>

		<bezel element="text_2">
			<bounds x="97.5" y="46" width="10" height="5" />
		</bezel>
		<bezel element="static_black">
			<bounds x="109" y="34" width="22" height="17" />
		</bezel>

		<bezel name="digit2" element="digit">
			<bounds x="110" y="35" width="10" height="15" />
		</bezel>
		<bezel name="digit3" element="digit">
			<bounds x="120" y="35" width="10" height="15" />
		</bezel>

		<bezel element="text_3">
			<bounds x="97.5" y="71" width="10" height="5" />
		</bezel>
		<bezel element="static_black">
			<bounds x="109" y="59" width="22" height="17" />
		</bezel>

		<bezel name="digit4" element="digit">
			<bounds x="110" y="60" width="10" height="15" />
		</bezel>
		<bezel name="digit5" element="digit">
			<bounds x="120" y="60" width="10" height="15" />
		</bezel>


<!-- reaction time -->

		<bezel element="static_yellow">
			<bounds x="5" y="70" width="90" height="25" />
		</bezel>
		<bezel element="static_green">
			<bounds x="6" y="71" width="88" height="23" />
		</bezel>

		<bezel element="text_reaction">
			<bounds x="9.5" y="68" width="33" height="5" />
		</bezel>
		<bezel element="text_average">
			<bounds x="56" y="68" width="19.5" height="5" />
		</bezel>

		<bezel element="static_black">
			<bounds x="9" y="74" width="32" height="17" />
		</bezel>

		<bezel name="digit6" element="digit">
			<bounds x="10" y="75" width="10" height="15" />
		</bezel>
		<bezel name="digit7" element="digit">
			<bounds x="20" y="75" width="10" height="15" />
		</bezel>
		<bezel name="digit8" element="digit">
			<bounds x="30" y="75" width="10" height="15" />
		</bezel>

		<bezel element="static_black">
			<bounds x="49" y="74" width="32" height="17" />
		</bezel>

		<bezel name="digit9" element="digit">
			<bounds x="50" y="75" width="10" height="15" />
		</bezel>
		<bezel name="digit10" element="digit">
			<bounds x="60" y="75" width="10" height="15" />
		</bezel>
		<bezel name="digit11" element="digit">
			<bounds x="70" y="75" width="10" height="15" />
		</bezel>


<!-- score -->

		<bezel element="static_yellow">
			<bounds x="5" y="5" width="90" height="40" />
		</bezel>
		<bezel element="static_green">
			<bounds x="6" y="6" width="88" height="38" />
		</bezel>

		<bezel element="text_score">
			<bounds x="43" y="3" width="15" height="5" />
		</bezel>

		<bezel element="static_black">
			<bounds x="29" y="9" width="42" height="32" />
		</bezel>

		<bezel name="digit12" element="digit">
			<bounds x="30" y="10" width="20" height="30" />
		</bezel>
		<bezel name="digit13" element="digit">
			<bounds x="50" y="10" width="20" height="30" />
		</bezel>


<!-- level -->

		<bezel element="static_yellow">
			<bounds x="5" y="47" width="90" height="21" />
		</bezel>
		<bezel element="static_green">
			<bounds x="6" y="48" width="88" height="19" />
		</bezel>

		<bezel element="text_level">
			<bounds x="43" y="45" width="13" height="5" />
		</bezel>

		<bezel name="lamp0" element="level1">
			<bounds x="10" y="52.5" width="10" height="10" />
		</bezel>
		<bezel name="lamp1" element="level2">
			<bounds x="27.5" y="52.5" width="10" height="10" />
		</bezel>
		<bezel name="lamp2" element="level3">
			<bounds x="45" y="52.5" width="10" height="10" />
		</bezel>
		<bezel name="lamp3" element="level4">
			<bounds x="62.5" y="52.5" width="10" height="10" />
		</bezel>
		<bezel name="lamp4" element="level5">
			<bounds x="80" y="52.5" width="10" height="10" />
		</bezel>


<!-- gameover -->

		<bezel element="static_yellow">
			<bounds x="97" y="82" width="45" height="13" />
		</bezel>
		<bezel element="static_green">
			<bounds x="98" y="83" width="43" height="11" />
		</bezel>

		<bezel name="lamp5" element="text_gameover">
			<bounds x="97" y="86" width="45" height="5" />
		</bezel>


	</view>
</mamelayout>
'#n963'>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
// license:BSD-3-Clause
// copyright-holders:Phil Bennett

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

    Konami M2 hardware

    driver by Phil Bennett

    TODO:
    * Fix Heat of Eleven '98 soft-lock when selecting Japan as a team
    * Fix incorrect speed in Tobe! Polystars
    * Fix texture compression
    * Sort out CD images
    * Fix PowerPC 602 Protection Only mode handling.

    DONE
    * Fix Polystars blending
    * Fix missing music in Polystars
    * Fix music playing too early
    * Fix missing music and sound in Hell Night/Evil Night
    * Fix incorrect speed in Heat of 11 and Total Vice (partially)

    // Polystars/Total Vice
    if (pc == 0x40035958)
        gpr[11] = 1;

    // Everything else
    if (pc == 0x400385c8)
        gpr[11] = 0;




Konami M2 Hardware Overview
Konami, 1997-1998

This hardware is 3DO-based with two IBM Power PC CPUs.

There were only 5 known games on this hardware. They include....

Game                                                 Year    CD Codes                                  Konami Part#
-------------------------------------------------------------------------------------------------------------------
Battle Tryst                                         1998    636JAC02
Evil Night                                           1998    810UBA02
Hell Night (alt. Region title, same as Evil Night)   1998    810EAA02
Heat Of Eleven '98                                   1998    703EAA02
Tobe! Polystars                                      1997    623JAA02                                  003894
Total Vice                                           1997    639UAC01, 639EAD01, 639JAD01, 639AAB01


PCB Layouts
-----------

Top Board

[M]DFUP0882ZAM1
FZ-20B1AK 7BKSA03500 (sticker)
|---------------------------------------------------|
|            |--------------------|    |----------| |
|            |--------------------|    |----------| |
|    2902             |---|  |--------|             |
| AK4309 CY2292S|---| |*2 |  |  3DO   |  |-------|  |
|               |*1 | |---|  |        |  |IBM    |  |
|        18MHz  |---|        |        |  |POWERPC|  |
|                            |        |  |602    |  |
|                            |--------|  |-------|  |
|    D4516161  D4516161                             |
|                                 |---|  |-------|  |
|DSW                    |-------| |*3 |  |IBM    |  |
|                       |       | |---|  |POWERPC|  |
|    D4516161  D4516161 |  *4   |        |602    |  |
|                       |       |        |-------|  |
|                       |-------|                   |
|---------------------------------------------------|
Notes:
      AK4309  - Asahi Kasei Microsystems AK4309-VM Digital to Analog Converter (SOIC24)
      2902    - Japan Radio Co. JRC2902 Quad Operational Amplifier (SOIC14)
      CY2292S - Cypress CY2292S Three-PLL General-Purpose EPROM Programmable Clock Generator (SOIC16)
                XTALIN - 18.000MHz, XTALOUT - 18.000MHz, XBUF - 18.000MHz, CPUCLK - 25.2000MHz
                CLKA - , CLKB -  , CLKC - 16.9345MHz, CLKD -
      3DO     - 9701 B861131 VY21118- CDE2 3DO 02473-001-0F (QFP208)
      *1      - [M] JAPAN ASUKA 9651HX001 044 (QFP44)
      *2      - Motorola MC44200FT
      *3      - [M] BIG BODY 2 BU6244KS 704 157 (QFP56)
      *4      - Unknown BGA chip (Graphics Engine, with heatsink attached)
      DSW     - 2 position DIP switch


Bottom Board

PWB403045B (C) 1997 KONAMI CO., LTD.
|----------------------------------------------------------|
|           CN16    |--------------------|    |----------| |
|LA4705             |--------------------|    |----------| |
|       NJM5532D                    9.83MHz                |
|                                   19.66MHz               |
|J                |--------|   93C46.7K                    |-|
|A                | 058232 |                BOOTROM.8Q     | |
|M                |--------|   |------|                    | |
|M       |------|              |003461|                    | |
|A       |056879|              |      |                    | |CN15
|        |      |              |------|                    | |
| TEST   |------|                                          | |
|                                                          | |
|   DSW                                                    | |
|                                                          |-|
|                                                          |
|----------------------------------------------------------|
Notes:
      056879     - Konami custom IC, location 10E (QFP120)
      058232     - Konami custom ceramic flat pack IC, DAC?
      003461     - Konami custom IC, location 11K (QFP100)
      CN16       - 4 pin connector for CD-DA in from CDROM
      CN15       - Standard (PC-compatible) 40 pin IDE CDROM flat cable connector and 4 pin power plug connector,
                   connected to Panasonic CR-583 8-speed CDROM drive.
      LA4705     - LA4705 Power Amplifier
      DSW        - 8 position dip switch
      BOOTROM.8Q - 16MBit MASKROM. Location 8Q (DIP42)
                   Battle Tryst       - 636A01.8Q
                   Evil Night         -       .8Q
                   Heat Of Eleven '98 -       .8Q
                   Polystars          - 623B01.8Q
                   Total Vice         -       .8Q
      93C46.7K   - 128bytes x8bit Serial EEPROM. Location 7K (DIP8)
                   NOTE! There is very mild protection to stop game-swapping. It is based on the information in the EEPROM
                   being the same as the Time Keeper NVRAM.
                   For example, in Evil Night, the first line of the NVRAM in hex is 474E38313000000019984541410002A601FEFE01
                   Looking at it in ascii:  GN810.....EAA.......
                   Hex 474E383130 = GN810
                   1998 = the year of the game
                   Hex 454141 = EAA (the version = europe english)
                   The numbers after this appear to be unimportant (at least with regards to swapping games anyway).
                   All the other data after the first line is used for high scores tables etc.
                   The important part is that the data in the EEPROM should be the same as the NVRAM, but the EEPROM data
                   is byte-swapped! If the two don't match, the check on 7K or the NVRAM will fail and the PCB will reboot
                   forever.

Some lower boards have two connectors underneath for a protection sub-board or sound board. These are detailed below....

GX636-PWB(A) (C) 1997 KONAMI CO., LTD.
|-------------------------|
| CN4 CN3  |---------|    |
|          |---------|CN2 |
|          PAL            |
|                         |
|             NVRAM       |
|                         |
|          |---------|    |
|          |---------|CN1 |
|-------------------------|
Notes:
      NVRAM  - With Heat of Eleven '98, uses Dallas DS1643 NonVolatile TimeKeeping RAM
               With Battle Tryst, uses ST M48T58Y-70PC1 NonVolatile TimeKeeping RAM
               With Poly Stars, a sub board is not used at all
      PAL    - PALCE16V8Q, stamped 'X636A1'
      CN3    - 4-pin sound cable tied to CN16 (CD-DA Input) on main lower board
      CN4    - 4-pin sound cable tied to CDROM analog audio output connector

GQ639 PWB 403327(A)
|-----------------------------------------|
|       639JAA02.xx                       |
|                                         |
|                                         |
|                   |---------|           |
|                   |---------|           |
|                                         |
|                                         |
|               PAL                       |
|                                         |
|                                         |
|                                         |
|                                         |
|                   |---------|           |
|      YMZ280B      |---------|           |
|                                         |
|      16.9344MHz                         |
|                                         |
|                                         |
|-----------------------------------------|
Notes:
      This PCB is used on Total Vice only.
      639JAA02.xx - 8MBit Sound data ROM (DIP42)
      PAL         - PAL16V8H stampd '       '


PWB0000047043 (C) 1998 KONAMI CO., LTD.
|-----------------------------------------|
| CN4     CN3                             |
|                                         |
|                                         |
|                   |---------|           |
|                   |---------|           |
|        16.9344MHz              M48T58Y  |
|                      PAL                |
|          YMZ280B                        |
|                                         |
|                                         |
|                                         |
|                                         |
|                   |---------|           |
|                   |---------|           |
|                                         |
|                                         |
|                                         |
|              810A03.16H                 |
|-----------------------------------------|
Notes:
      This PCB is used on Evil Night/Hell Night only.
      810A03.16H - 16MBit Sound data ROM (DIP42, byte mode)
      PAL        - PAL16V8H stamped 'N810B1'
      M48T58Y    - ST M48T58Y-70PC1 NonVolatile TimeKeeping RAM
      CN3        - 4-pin sound cable tied to CN16 (CD-DA Input) on main lower board
      CN4        - 4-pin sound cable tied to CDROM analog audio output connector

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

#include "emu.h"
#include "cpu/powerpc/ppc.h"
#include "bus/ata/ataintf.h"
#include "bus/ata/cr589.h"
#include "machine/3dom2.h"
#include "machine/eepromser.h"
#include "machine/timekpr.h"
#include "sound/dac.h"
#include "sound/volt_reg.h"
#include "sound/ymz280b.h"
#include "cdrom.h"
#include "debug/debugcon.h"
#include "debug/debugcmd.h"
#include "debugger.h"
#include "romload.h"
#include "screen.h"
#include "speaker.h"

#define M2_CLOCK        XTAL(66'666'700)

#define ENABLE_SDBG     0


/*************************************
 *
 *  ROM definition(s)
 *
 *************************************/

class konamim2_state : public driver_device
{
public:
	konamim2_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_ppc1(*this, "ppc1"),
		m_ppc2(*this, "ppc2"),
		m_bda(*this, "bda"),
		m_cde(*this, "cde"),
		m_eeprom(*this, "eeprom"),
		m_ldac(*this, "ldac"),
		m_rdac(*this, "rdac"),
		m_ata(*this, "ata"),
		m_screen(*this, "screen"),
		m_m48t58(*this, "m48t58"),
		m_ymz280b(*this, "ymz")
	{
	}

	void konamim2(machine_config &config);
	void set_ntsc(machine_config &config);
	void set_ntsc2(machine_config &config);
	void set_arcres(machine_config &config);
	void add_ymz280b(machine_config &config);
	void add_mt48t58(machine_config &config);
	void polystar(machine_config &config);
	void totlvice(machine_config &config);
	void btltryst(machine_config &config);
	void heatof11(machine_config &config);
	void evilngt(machine_config &config);
	void hellngt(machine_config &config);

	static void cr589_config(device_t *device);

	void m2_map(address_map &map);

protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;

	void update_disc();

public:
	DECLARE_WRITE_LINE_MEMBER(ppc1_int);
	DECLARE_WRITE_LINE_MEMBER(ppc2_int);

	DECLARE_WRITE32_MEMBER(cde_sdbg_out);

	DECLARE_WRITE16_MEMBER(ldac_out);
	DECLARE_WRITE16_MEMBER(rdac_out);

	DECLARE_WRITE_LINE_MEMBER(ata_int);

	DECLARE_READ16_MEMBER(konami_io0_r);
	DECLARE_WRITE16_MEMBER(konami_io0_w);
	DECLARE_READ16_MEMBER(konami_sio_r);
	DECLARE_WRITE16_MEMBER(konami_sio_w);
	DECLARE_READ16_MEMBER(konami_io1_r);
	DECLARE_WRITE16_MEMBER(konami_io1_w);
	DECLARE_WRITE16_MEMBER(konami_eeprom_w);

	void init_totlvice();
	void init_btltryst();
	void init_hellngt();

	DECLARE_WRITE16_MEMBER(konami_atapi_unk_w)
	{
		// 8000 = /Reset
		// 4000 = C000 ... DOIO DMA ... 4000
//      m_ata->write_dmack(data & 0x4000 ? ASSERT_LINE : CLEAR_LINE);

		if (!(data & 0x8000))
		{
			logerror("ATAPI RESET!\n");

			// TODO: Do we need any of this?
			update_disc();
		}
	}

	DECLARE_READ16_MEMBER(konami_ide_r)
	{
		return swapendian_int16(m_ata->read_cs0(offset, mem_mask));
	}

	DECLARE_WRITE16_MEMBER(konami_ide_w)
	{
		m_ata->write_cs0(offset, swapendian_int16(data), mem_mask);
	}

private:
	void install_ymz280b();
	void install_m48t58();

	required_device<ppc602_device> m_ppc1;
	optional_device<ppc602_device> m_ppc2;
	required_device<m2_bda_device> m_bda;
	required_device<m2_cde_device> m_cde;
	required_device<eeprom_serial_93cxx_device> m_eeprom;
	required_device<dac_word_interface> m_ldac;
	required_device<dac_word_interface> m_rdac;
	required_device<ata_interface_device> m_ata;
	required_device<screen_device> m_screen;

	optional_device<m48t58_device> m_m48t58;
	optional_device<ymz280b_device> m_ymz280b;

	// ATAPI
	cdrom_file *m_available_cdroms;

	// Konami SIO
	uint16_t    m_sio_data;

	uint32_t    m_ata_int; // TEST
	emu_timer *m_atapi_timer;

	TIMER_CALLBACK_MEMBER( atapi_delay )
	{
		m_atapi_timer->adjust( attotime::never );
		m_ata_int = param;
	}

	void debug_help_command(int ref, const std::vector<std::string> &params);
	void debug_commands(int ref, const std::vector<std::string> &params);

	void dump_task_command(int ref, const std::vector<std::string> &params);
};



/*************************************
 *
 *  Trampolines - Remove ME
 *
 *************************************/

WRITE_LINE_MEMBER(konamim2_state::ppc1_int)
{
	m_ppc1->set_input_line(INPUT_LINE_IRQ0, state ? ASSERT_LINE : CLEAR_LINE);
}

WRITE_LINE_MEMBER(konamim2_state::ppc2_int)
{
	m_ppc2->set_input_line(INPUT_LINE_IRQ0, state ? ASSERT_LINE : CLEAR_LINE);
}

WRITE32_MEMBER(konamim2_state::cde_sdbg_out)
{
	if (data == 0xd)
		putc('\n', stdout);
	else if (data != 0)
		putc(data, stdout);

	fflush(stdout);

#if ENABLE_SDBG
	// Dummy write to enable serial out
	if (data == 0x3c)
		m_cde->sdbg_in(space, 0, 0xffffffff);
#endif
}

WRITE16_MEMBER( konamim2_state::ldac_out )
{
	m_ldac->write(data);
}

WRITE16_MEMBER( konamim2_state::rdac_out )
{
	m_rdac->write(data);
}


/*************************************
 *
 *  ATAPI (Temporary - remove)
 *
 *************************************/

WRITE_LINE_MEMBER( konamim2_state::ata_int )
{
//  m_atapi_timer->adjust( attotime::from_msec(10), state );
	m_ata_int = state;
}


/*************************************
 *
 *  Konami I/O
 *
 *************************************/

READ16_MEMBER( konamim2_state::konami_io0_r )
{
//  printf("IO R: %08X\n", offset);

	switch (offset)
	{
		/*
		    0 =    160
		    1 =     32
		    2 =    -96
		   10 =  -1888
		   FF = -32480

		  100 =    160
		  1FF = -32480

		  200 =    159
		  2FF = -32481

		  300 =    159
		  3FF = -32481

		  400 =    158

		  800 =    156

		  C00 =    154

		  E00
		  F00 =    153

		 1000 =    152
		 2000 =    144
		 4000 =    128
		 8000 =     96

		 E000 =     48
		 F000 =     40
		 FF00 =     33

		 7FFF = -32543
		 FFFF = -32607
		 */
		case 0:
		{
			return swapendian_int16((int16_t)ioport("GUNX1")->read());
		}
		case 1: return 0;
		case 2: return 0; // P3 X?
		case 3: return 0xffff; // ?
		case 4:
		{
			return swapendian_int16((int16_t)ioport("GUNY1")->read());
		}
		case 5: return 0; // P2 Y
		case 6: return 0; // P3 Y?
		case 7: return 0; //??
		case 8: return ioport("P5")->read();
	}

	//return rand();
	return 0;
}

WRITE16_MEMBER( konamim2_state::konami_io0_w )
{
	// 9: 0000, 0xFFF
//  printf("IO W: %08x %08x\n", offset, data);
}

/*
     FEDCBA98 76543210
 0: |........ ........|

 1: |........ ........|

 2: |........ ........|

 3: |........ .......x| Coin 1
    |........ ......x.| Coin 2
    |........ ....x...| Service coin
    |.......x ........| EEPROM D0
    |.....x.. ........| ADC
    |...xx... ........| SIO related? (set to 3 NOTE: Total Vice doesn't like this!)
    |..x..... ........| ATAPI/CD status?

 4: |........ ........| Player 1/2 inputs

 5: |........ ........| Unknown

 6: |........ ........| Unknown

 7: |........ ........| Unknown
*/

READ16_MEMBER( konamim2_state::konami_io1_r )
{
	uint16_t data = 0;

//  printf("%s: PORT R: [%x] MASK:%.8x\n", machine().describe_context(), offset, mem_mask);

	switch (offset)
	{
		case 0:
			data = 0xffff;
			break;

		case 1:
			data = 0xffff;
			break;

		case 2: // DIP switches
			data = ioport("P2")->read();
			break;

		case 3:
		{
			data = ioport("P1")->read();
#if M2_BAD_TIMING
			static uint32_t d = 0;
			data |= d;
			d ^= 0x2000;
#else
			data |= m_ata_int ? 0x2000 : 0;
#endif
			data |= (1 << 10);
			data |= (3 << 11); // TODO: 3 normally
			break;
		}

		case 4: // Buttons
			data = ioport("P4")->read();
			break;

		case 5: // Changing this has a tendency to stop evilngt from booting...
			data = 0xffff;
			break;

		case 6: // Buttons
			data = ioport("P6")->read();
			break;

		case 7:
			data = 0xffff;
			break;

		default:
			logerror("%s: Unknown read: %x\n", machine().describe_context(), offset);
			break;
	}

	return data;
}

WRITE16_MEMBER( konamim2_state::konami_io1_w )
{
	// 0x0200 = ADC?
	// 0x0800 = Coin counter 1
	// 0x1000 = Coin counter 2
	// 0x2000 = CD-MUTE
	// 0x8000 = ?
	logerror("%s: PORT W: [%x] %x, MASK:%.8x\n", machine().describe_context(), offset, data, mem_mask);

//  printf("CDDA is: %s\n", data & 0x2000 ? "ENABLED" : "MUTE");

	machine().bookkeeping().coin_counter_w(0, (data >> 11) & 1);
	machine().bookkeeping().coin_counter_w(1, (data >> 12) & 1);

//  m_cdda->set_output_gain(0, data & 0x2000 ? 1.0 : 0.0);
//  m_cdda->set_output_gain(1, data & 0x2000 ? 1.0 : 0.0);
}



/**************************************
 *
 *  Konami 003461 SIO
 *
 *************************************/

/*
     FEDCBA98 76543210
 0: |xxxxxxxx xxxxxxxx| Data R/W

 1: |........ ........|

 2: |........ ........|

 3: |........ ........|

 4: |........ ........|

 5: |........ ..x.....| Transmit ready

 6: |........ ........|

 7: |xxxxxxxx xxxxxxxx| Register R/W
*/

READ16_MEMBER( konamim2_state::konami_sio_r )
{
	uint16_t data = 0;

	switch (offset)
	{
		case 7:
			data = m_sio_data;
			break;
		//default:
			//logerror("%s: SIO_R: %x %x\n", machine().describe_context(), offset, mem_mask);
	}

	return data;
}

WRITE16_MEMBER( konamim2_state::konami_sio_w )
{
	switch (offset)
	{
		case 7:
			m_sio_data = data;
			break;
		//default:
			//printf("%s: SIO_W: %x %x %x\n", machine().describe_context(), offset, data, mem_mask);
	}
}

// TODO: Use output port
WRITE16_MEMBER( konamim2_state::konami_eeprom_w )
{
	// 3 = CS
	// 2 = CLK
	// 1 = DATA
	// 0 = ? (From Port)
	m_eeprom->cs_write(data & 0x80 ? ASSERT_LINE : CLEAR_LINE);
	m_eeprom->di_write(data & 0x20 ? 1 : 0);
	m_eeprom->clk_write(data & 0x40 ? ASSERT_LINE : CLEAR_LINE);
}



/*************************************
 *
 *  Machine initialization
 *
 *************************************/

void konamim2_state::machine_start()
{
	m_ppc1->ppcdrc_set_options(PPCDRC_COMPATIBLE_OPTIONS);
	m_ppc2->ppcdrc_set_options(PPCDRC_COMPATIBLE_OPTIONS);

	m_ppc1->ppcdrc_add_fastram(m_bda->ram_start(), m_bda->ram_end(), false, m_bda->ram_ptr());
	m_ppc2->ppcdrc_add_fastram(m_bda->ram_start(), m_bda->ram_end(), false, m_bda->ram_ptr());

	m_available_cdroms = cdrom_open(machine().rom_load().get_disk_handle(":cdrom"));

	// TODO: REMOVE
	m_atapi_timer = machine().scheduler().timer_alloc( timer_expired_delegate( FUNC( konamim2_state::atapi_delay ),this ) );
	m_atapi_timer->adjust( attotime::never );

	if (machine().debug_flags & DEBUG_FLAG_ENABLED)
	{
		using namespace std::placeholders;
		machine().debugger().console().register_command("m2", CMDFLAG_NONE, 0, 1, 4, std::bind(&konamim2_state::debug_commands, this, _1, _2));
	}
}

void konamim2_state::machine_reset()
{
	update_disc();
}

void konamim2_state::update_disc()
{
	cdrom_file *new_cdrom = m_available_cdroms;

	atapi_hle_device *image = subdevice<atapi_hle_device>("ata:0:cr589");
	if (image != nullptr)
	{
		void *current_cdrom = nullptr;
		image->GetDevice(&current_cdrom);

		if (current_cdrom != new_cdrom)
		{
			current_cdrom = new_cdrom;

			image->SetDevice(new_cdrom);
		}
	}
	else
	{
		abort();
	}
}

/*************************************
 *
 *  Address map
 *
 *************************************/

void konamim2_state::m2_map(address_map &map)
{
	map(0x20000000, 0x201fffff).rom().region("boot", 0); // BIOBUS Slot 0
	map(0xfff00000, 0xffffffff).rom().region("boot", 0);
	map(0x37400000, 0x37400007).w(FUNC(konamim2_state::konami_eeprom_w)).umask64(0xffff000000000000ULL);
	map(0x37600000, 0x3760000f).w(FUNC(konamim2_state::konami_atapi_unk_w)).umask64(0xffff000000000000ULL);
	map(0x37a00020, 0x37a0003f).rw(FUNC(konamim2_state::konami_io0_r), FUNC(konamim2_state::konami_io0_w));
	map(0x37c00010, 0x37c0001f).rw(FUNC(konamim2_state::konami_sio_r), FUNC(konamim2_state::konami_sio_w));
	map(0x37e00000, 0x37e0000f).rw(FUNC(konamim2_state::konami_io1_r), FUNC(konamim2_state::konami_io1_w));
	map(0x3f000000, 0x3fffffff).rw(FUNC(konamim2_state::konami_ide_r), FUNC(konamim2_state::konami_ide_w));
}



/*************************************
 *
 *  Port definitions
 *
 *************************************/

static INPUT_PORTS_START( konamim2 )
	PORT_START("DSW")
	PORT_DIPNAME( 0x01, 0x00, "Video Res" )
	PORT_DIPSETTING(    0x00, "High Res" )
	PORT_DIPSETTING(    0x01, "Low Res" )

	PORT_START("P1")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SERVICE1 )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read)
	PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_UNUSED ) // ATAPI?
	PORT_BIT( 0xDE00, IP_ACTIVE_HIGH, IPT_UNUSED )
INPUT_PORTS_END

static INPUT_PORTS_START( btltryst )
	PORT_INCLUDE( konamim2 )

	PORT_MODIFY("DSW")
	PORT_DIPNAME( 0x01, 0x01, "Video Res" )
	PORT_DIPSETTING(    0x00, "High Res" )
	PORT_DIPSETTING(    0x01, "Low Res" )

	PORT_START("P2")
	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )

	PORT_START("P4")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )

	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )

	PORT_START("P5")
	PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("P6")
	PORT_SERVICE_NO_TOGGLE( 0x0004, IP_ACTIVE_LOW )
	PORT_BIT( 0xfffb, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END

static INPUT_PORTS_START( polystar )
	PORT_INCLUDE( konamim2 )

	PORT_MODIFY("DSW")
	PORT_DIPNAME( 0x01, 0x01, "Video Res" )
	PORT_DIPSETTING(    0x00, "High Res" )
	PORT_DIPSETTING(    0x01, "Low Res" )

	PORT_START("P2")
	PORT_DIPNAME( 0x01, 0x01, "Sound Output" )
	PORT_DIPSETTING(    0x01, "Mono" )
	PORT_DIPSETTING(    0x00, "Stereo" )
	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )

	PORT_START("P4")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )

	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )

	PORT_START("P5")
	PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("P6")
	PORT_SERVICE_NO_TOGGLE( 0x0004, IP_ACTIVE_LOW )
INPUT_PORTS_END

static INPUT_PORTS_START( totlvice )
	PORT_INCLUDE( konamim2 )

	PORT_START("P2") // TODO: VERIFY
	PORT_DIPNAME( 0x01, 0x00, "Sound Output" )
	PORT_DIPSETTING(    0x01, "Mono" )
	PORT_DIPSETTING(    0x00, "Stereo" )
	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )

	PORT_START("P4")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE2 )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_SERVICE3 )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_START3 )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN3 )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )

	PORT_START("GUNX1")
	PORT_BIT( 0xffff, 0x0000, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_MINMAX(0, 640) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)

	PORT_START("GUNY1")
	PORT_BIT( 0xffff, 0x0000, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_MINMAX(0, 240) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)

	PORT_START("P5") // Gun switches
	PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("P6")
	PORT_SERVICE_NO_TOGGLE( 0x0004, IP_ACTIVE_LOW )
	PORT_BIT( 0xfffb, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END

static INPUT_PORTS_START( heatof11 )
	PORT_INCLUDE( konamim2 )

	PORT_MODIFY("DSW")
	PORT_DIPNAME( 0x01, 0x00, "Video Res" )
	PORT_DIPSETTING(    0x00, "High Res" )
	PORT_DIPSETTING(    0x01, "Low Res" )

	PORT_START("P2")
	PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )

	PORT_START("P4")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )

	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )

	PORT_START("P5")
	PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("P6")
	PORT_SERVICE_NO_TOGGLE( 0x0004, IP_ACTIVE_LOW )
INPUT_PORTS_END

static INPUT_PORTS_START( hellngt )
	PORT_INCLUDE( konamim2 )

	PORT_START("P2")
	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )

	PORT_START("P4")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE2 )
	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_SERVICE3 )
	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_START3 )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN3 )
	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )

	PORT_START("GUNX1")
	PORT_BIT( 0xffff, 0x0000, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_MINMAX( 0, 320*2 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)

	PORT_START("GUNY1")
	PORT_BIT( 0xffff, 0x0000, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_MINMAX( 0, 240 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)

	PORT_START("P5") // Gun switches
	PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START("P6")
	PORT_SERVICE_NO_TOGGLE( 0x0004, IP_ACTIVE_LOW )
	PORT_BIT( 0xfffb, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END



/*************************************
 *
 *  Machine driver
 *
 *************************************/

void konamim2_state::cr589_config(device_t *device)
{
	device->subdevice<cdda_device>("cdda")->add_route(0, ":lspeaker", 1.0);
	device->subdevice<cdda_device>("cdda")->add_route(1, ":rspeaker", 1.0);
	device = device->subdevice("cdda");
}

void konamim2_state::konamim2(machine_config &config)
{
	// Basic machine hardware
	PPC602(config, m_ppc1, M2_CLOCK);
	m_ppc1->set_bus_frequency(M2_CLOCK / 2);
	m_ppc1->set_addrmap(AS_PROGRAM, &konamim2_state::m2_map);

	PPC602(config, m_ppc2, M2_CLOCK);
	m_ppc2->set_bus_frequency(M2_CLOCK / 2);
	m_ppc2->set_addrmap(AS_PROGRAM, &konamim2_state::m2_map);

	// M2 hardware
	M2_BDA(config, m_bda, M2_CLOCK, m_ppc1, m_ppc2);
	m_bda->set_ram_size(m2_bda_device::RAM_8MB, m2_bda_device::RAM_8MB);
	m_bda->subdevice<m2_powerbus_device>("powerbus")->int_handler().set(FUNC(konamim2_state::ppc1_int));
	m_bda->subdevice<m2_memctl_device>("memctl")->gpio_out_handler<3>().set(FUNC(konamim2_state::ppc2_int)).invert();
	m_bda->subdevice<m2_vdu_device>("vdu")->set_screen("screen");
	m_bda->videores_in().set_ioport("DSW");
	m_bda->ldac_handler().set(FUNC(konamim2_state::ldac_out));
	m_bda->rdac_handler().set(FUNC(konamim2_state::rdac_out));

	M2_CDE(config, m_cde, M2_CLOCK, m_ppc1);
	m_cde->int_handler().set(":bda:powerbus", FUNC(m2_powerbus_device::int_line<BDAINT_EXTD4_LINE>));
	m_cde->set_syscfg(SYSCONFIG_ARCADE);
	m_cde->sdbg_out().set(FUNC(konamim2_state::cde_sdbg_out));

	// Common devices
	EEPROM_93C46_16BIT(config, m_eeprom);

	ATA_INTERFACE(config, m_ata, 0);
	m_ata->irq_handler().set(FUNC(konamim2_state::ata_int));

	m_ata->slot(0).option_add("cr589", CR589);
	m_ata->slot(0).set_option_machine_config("cr589", cr589_config);
	m_ata->slot(0).set_default_option("cr589");

	// Video hardware
	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	m_screen->set_screen_update("bda:vdu", FUNC(m2_vdu_device::screen_update));

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

	// TODO!
	DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0);
	DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0);

	voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref", 0));
	vref.add_route(0, "ldac", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "ldac", -1.0, DAC_VREF_NEG_INPUT);
	vref.add_route(0, "rdac", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "rdac", -1.0, DAC_VREF_NEG_INPUT);
}



/*************************************
 *
 *  Machine fragments
 *
 *************************************/

void konamim2_state::set_ntsc(machine_config &config)
{
//  m_screen->set_raw(11750000, 766, 126, 126+640, 260, 20, 20+240); // TODO
	m_screen->set_refresh_hz(59.360001);
	m_screen->set_size(768, 262);
	m_screen->set_visarea(126, 126+640-1, 20, 20+240-1);
}

void konamim2_state::set_ntsc2(machine_config &config)
{
	//m_screen->set_raw(11750000, 766, 126, 126+640, 260, 20, 20+240); // TODO
	m_screen->set_refresh_hz(59.360001);
	m_screen->set_size(768, 262*2); // TOTAL VICE ONLY WORKS WITH THIS!
	m_screen->set_visarea(126, 126+640-1, 20, 20+240-1);
}

void konamim2_state::set_arcres(machine_config &config)
{
	m_screen->set_raw(16934500, 684, 104, 104+512, 416, 26, 26+384);
}

void konamim2_state::add_ymz280b(machine_config &config)
{
	// TODO: The YMZ280B outputs are actually routed to a speaker in each gun
	YMZ280B(config, m_ymz280b, XTAL(16'934'400));
	m_ymz280b->add_route(0, "lspeaker", 0.5);
	m_ymz280b->add_route(1, "rspeaker", 0.5);
}

void konamim2_state::add_mt48t58(machine_config &config)
{
	M48T58(config, m_m48t58);
}



/*************************************
 *
 *  Machine drivers
 *
 *************************************/

void konamim2_state::polystar(machine_config &config)
{
	konamim2(config);
	m_bda->set_ram_size(m2_bda_device::RAM_4MB, m2_bda_device::RAM_4MB);
	set_ntsc(config);
}

void konamim2_state::totlvice(machine_config &config)
{
	konamim2(config);
	add_ymz280b(config);
//  set_arcres(config);
	set_ntsc2(config);
}

void konamim2_state::btltryst(machine_config &config)
{
	konamim2(config);
	add_mt48t58(config);
	set_ntsc(config);
}

void konamim2_state::heatof11(machine_config &config)
{
	konamim2(config);
	add_mt48t58(config);
	set_arcres(config);
}

void konamim2_state::evilngt(machine_config &config)
{
	konamim2(config);
	add_mt48t58(config);
	add_ymz280b(config);
	set_ntsc(config);
}

void konamim2_state::hellngt(machine_config &config)
{
	konamim2(config);
	add_mt48t58(config);
	add_ymz280b(config);
	set_arcres(config);
}



/*************************************
 *
 *  ROM definition(s)
 *
 *************************************/

ROM_START( polystar )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "623b01.8q", 0x000000, 0x200000, CRC(bd879f93) SHA1(e2d63bfbd2b15260a2664082652442eadea3eab6) )

	ROM_REGION16_BE( 0x80, "eeprom", 0 ) /* EEPROM default contents */
	ROM_LOAD( "93c46.7k", 0x000000, 0x000080, CRC(fab5a203) SHA1(153e22aa8cfce80b77ba200957685f796fc99b1c) )

	DISK_REGION( "cdrom" ) // Has 1s of silence near the start of the first audio track
	DISK_IMAGE_READONLY( "623jaa02", 0, BAD_DUMP SHA1(e7d9e628a3e0e085e084e4e3630fa5e3a7345547) )
ROM_END

ROM_START( btltryst )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "636a01.8q", 0x000000, 0x200000, CRC(7b1dc738) SHA1(32ae8e7ddd38fcc70b4410275a2cc5e9a0d7d33b) )

	ROM_REGION16_BE( 0x80, "eeprom", 0 )
	ROM_LOAD( "93c46.7k",  0x000000, 0x000080, CRC(cc2c5640) SHA1(694cf2b3700f52ed80252b013052c90020e58ce6) )

	ROM_REGION( 0x2000, "m48t58", 0 ) /* timekeeper SRAM */
	ROM_LOAD( "m48t58", 0x000000, 0x002000, CRC(71ee073b) SHA1(cc8002d7ee8d1695aebbbb2a3a1e97a7e16948c1) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "636jac02", 0, SHA1(d36556a3a4b91058100924a9e9f1a58983399c6e) )
ROM_END

#if 0
ROM_START( btltrysta )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "636a01.8q", 0x000000, 0x200000, CRC(7b1dc738) SHA1(32ae8e7ddd38fcc70b4410275a2cc5e9a0d7d33b) )

	ROM_REGION( 0x2000, "m48t58", 0 ) /* timekeeper SRAM */
	ROM_LOAD( "m48t58y", 0x000000, 0x002000, CRC(8611ff09) SHA1(6410236947d99c552c4a1f7dd5fd8c7a5ae4cba1) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "636jaa02", 0, SHA1(d36556a3a4b91058100924a9e9f1a58983399c6e) )
ROM_END
#endif

ROM_START( heatof11 )
	ROM_REGION64_BE( 0x200000, "boot", 0 )  /* boot rom */
	ROM_LOAD16_WORD( "636a01.8q", 0x000000, 0x200000, CRC(7b1dc738) SHA1(32ae8e7ddd38fcc70b4410275a2cc5e9a0d7d33b) )

	ROM_REGION16_BE( 0x80, "eeprom", 0 ) /* EEPROM default contents */
	ROM_LOAD( "93c46.7k",  0x000000, 0x000080, CRC(e7029938) SHA1(ae41340dbcb600debe246629dc36fb371d1a5b05) )

	ROM_REGION( 0x2000, "m48t58", 0 ) /* timekeeper SRAM */
	ROM_LOAD( "dallas.5e",  0x000000, 0x002000, CRC(5b74eafd) SHA1(afbf5f1f5a27407fd6f17c764bbb7fae4ab779f5) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "heatof11", 0, BAD_DUMP SHA1(5a0a2782cd8676d3f6dfad4e0f805b309e230d8b) )
ROM_END

ROM_START( evilngt )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "636a01.8q", 0x000000, 0x200000, CRC(7b1dc738) SHA1(32ae8e7ddd38fcc70b4410275a2cc5e9a0d7d33b) )

	ROM_REGION16_BE( 0x80, "eeprom", 0 ) /* EEPROM default contents */
	ROM_LOAD( "93c46.7k", 0x000000, 0x000080, CRC(60ae825e) SHA1(fd61db9667c53dd12700a0fe202fcd1e3d35d206) )

	ROM_REGION( 0x2000, "m48t58", 0 ) /* timekeeper SRAM */
	ROM_LOAD( "m48t58y.9n", 0x000000, 0x002000, CRC(e887ca1f) SHA1(54205f01b1ceba1d5f4d979fc30be1add8116e90) )

	ROM_REGION( 0x400000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "810a03.16h", 0x000000, 0x400000, CRC(05112d3a) SHA1(0df2a167b7bc08a32d983b71614d59834efbfb59) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "810uba02", 0, SHA1(e570470c1cbfe187d5bba8125616412f386264ba) )
ROM_END

ROM_START( evilngte )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "636a01.8q", 0x000000, 0x200000, CRC(7b1dc738) SHA1(32ae8e7ddd38fcc70b4410275a2cc5e9a0d7d33b) )

	ROM_REGION( 0x2000, "m48t58", 0 ) /* timekeeper SRAM */
	ROM_LOAD( "m48t58y.u1", 0x000000, 0x001000, CRC(169bb8f4) SHA1(55c0bafab5d309fe69156489186e232aa87ca0dd) )

	ROM_REGION( 0x400000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "810a03.16h", 0x000000, 0x400000, CRC(05112d3a) SHA1(0df2a167b7bc08a32d983b71614d59834efbfb59) )

	// TODO: Add CHD
ROM_END

ROM_START( hellngt )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "636a01.8q", 0x000000, 0x200000, CRC(7b1dc738) SHA1(32ae8e7ddd38fcc70b4410275a2cc5e9a0d7d33b) )

	ROM_REGION16_BE( 0x80, "eeprom", 0 ) /* EEPROM default contents */
	ROM_LOAD( "93c46.7k",    0x000000, 0x000080, CRC(53b41f68) SHA1(f75f59808a5b04b1e49f2cca0592a2466b82f019) )

	ROM_REGION( 0x2000, "m48t58", 0 )
	ROM_LOAD( "m48t58y.9n",  0x000000, 0x002000, CRC(ff8e78a1) SHA1(02e56f55264dd0bf3a08808726a6366e9cb6031e) )

	ROM_REGION( 0x400000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "810a03.16h",  0x000000, 0x400000, CRC(05112d3a) SHA1(0df2a167b7bc08a32d983b71614d59834efbfb59) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "810eaa02", 0, SHA1(d701b900eddc7674015823b2cb33e887bf107fa8) )
ROM_END

ROM_START( totlvice )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "623b01.8q", 0x000000, 0x200000, CRC(bd879f93) SHA1(e2d63bfbd2b15260a2664082652442eadea3eab6) )

	ROM_REGION16_BE( 0x80, "eeprom", 0 )
	ROM_LOAD( "93c46.7k", 0x000000, 0x000080, CRC(25aa0bd1) SHA1(cc461e0629ff71c3a868882f1f67af0e19135c1a) )

	ROM_REGION( 0x100000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "639jaa02.bin",  0x000000, 0x100000, CRC(c6163818) SHA1(b6f8f2d808b98610becc0a5be5443ece3908df0b) )

	// was converted from the following cue/bin pair, is this sufficient / good for this platform? - there are a lot of audio tracks that need verifying as non-corrupt
	//ROM_LOAD( "TotalVice-GQ639-EBA01.cue",  0, 0x00000555, CRC(55ef2f62) SHA1(8e31b3e62244e6090a93228dae377552340dcdeb) )
	//ROM_LOAD( "TotalVice-GQ639-EBA01.bin",  0, 0x1ec4db10, CRC(5882f8ba) SHA1(e589d500d99d2f4cff4506cd5ac9a5bfc8d30675) )
	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "639eba01", 0, BAD_DUMP SHA1(d95c13575e015169b126f7e8492d150bd7e5ebda) )
ROM_END

#if 0
// NB: Dumped by Phil, hasn't been converted to CHD yet
ROM_START( totlvicd )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "623b01.8q", 0x000000, 0x200000, CRC(bd879f93) SHA1(e2d63bfbd2b15260a2664082652442eadea3eab6) )

	ROM_REGION( 0x100000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "639jaa02.bin",  0x000000, 0x100000, CRC(c6163818) SHA1(b6f8f2d808b98610becc0a5be5443ece3908df0b) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "639ead01", 0, SHA1(9d1085281aeb14185e2e78f3f21e7004a591039c) )
ROM_END
#endif

ROM_START( totlvicu )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "623b01.8q", 0x000000, 0x200000, CRC(bd879f93) SHA1(e2d63bfbd2b15260a2664082652442eadea3eab6) )

	ROM_REGION( 0x100000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "639jaa02.bin",  0x000000, 0x100000, CRC(c6163818) SHA1(b6f8f2d808b98610becc0a5be5443ece3908df0b) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "639uac01", 0, BAD_DUMP SHA1(88431b8a0ce83c156c8b19efbba1af901b859404) )
ROM_END

ROM_START( totlvica )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "623b01.8q", 0x000000, 0x200000, CRC(bd879f93) SHA1(e2d63bfbd2b15260a2664082652442eadea3eab6) )

	ROM_REGION( 0x100000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "639jaa02.bin",  0x000000, 0x100000, CRC(c6163818) SHA1(b6f8f2d808b98610becc0a5be5443ece3908df0b) )

	DISK_REGION( "cdrom" )
	DISK_IMAGE_READONLY( "639aab01", 0, SHA1(34f34b26399cc04ffb0207df69f52eba42892eb6) )
ROM_END

ROM_START( totlvicj )
	ROM_REGION64_BE( 0x200000, "boot", 0 )
	ROM_LOAD16_WORD( "623b01.8q", 0x000000, 0x200000, CRC(bd879f93) SHA1(e2d63bfbd2b15260a2664082652442eadea3eab6) )

	ROM_REGION( 0x100000, "ymz", 0 ) /* YMZ280B sound rom on sub board */
	ROM_LOAD( "639jaa02.bin",  0x000000, 0x100000, CRC(c6163818) SHA1(b6f8f2d808b98610becc0a5be5443ece3908df0b) )

	DISK_REGION( "cdrom" ) // Need a re-image
	DISK_IMAGE_READONLY( "639jad01", 0, BAD_DUMP SHA1(39d41d5a9d1c40636d174c8bb8172b1121e313f8) )
ROM_END

#if 0 // FIXME
ROM_START( 3do_m2 )
	ROM_REGION64_BE( 0x100000, "boot", 0 )
	ROM_SYSTEM_BIOS( 0, "panafz35", "Panasonic FZ-35S (3DO M2)" )
	ROMX_LOAD( "fz35_jpn.bin", 0x000000, 0x100000, CRC(e1c5bfd3) SHA1(0a3e27d672be79eeee1d2dc2da60d82f6eba7934), ROM_BIOS(1) )
ROM_END
#endif

/*************************************
 *
 *  Driver initialization
 *
 *************************************/

void konamim2_state::install_m48t58()
{
	read8sm_delegate read_delegate(*m_m48t58, FUNC(m48t58_device::read));
	write8sm_delegate write_delegate(*m_m48t58, FUNC(m48t58_device::write));

	m_ppc1->space(AS_PROGRAM).install_readwrite_handler(0x36c00000, 0x36c03fff, read_delegate, write_delegate, 0xff00ff00ff00ff00ULL);
	m_ppc2->space(AS_PROGRAM).install_readwrite_handler(0x36c00000, 0x36c03fff, read_delegate, write_delegate, 0xff00ff00ff00ff00ULL);
}

void konamim2_state::install_ymz280b()
{
	read8sm_delegate read_delegate(*m_ymz280b, FUNC(ymz280b_device::read));
	write8sm_delegate write_delegate(*m_ymz280b, FUNC(ymz280b_device::write));

	m_ppc1->space(AS_PROGRAM).install_readwrite_handler(0x3e800000, 0x3e80000f, read_delegate, write_delegate, 0xff00ff0000000000ULL);
	m_ppc2->space(AS_PROGRAM).install_readwrite_handler(0x3e800000, 0x3e80000f, read_delegate, write_delegate, 0xff00ff0000000000ULL);
}

void konamim2_state::init_totlvice()
{
	install_ymz280b();
}

void konamim2_state::init_btltryst()
{
	install_m48t58();
}

void konamim2_state::init_hellngt()
{
	install_m48t58();
	install_ymz280b();
}



/*************************************
 *
 *  Game driver(s)
 *
 *************************************/

GAME( 1997, polystar,  0,        polystar, polystar, konamim2_state, empty_init,    ROT0, "Konami", "Tobe! Polystars (ver JAA)",    MACHINE_IMPERFECT_TIMING | MACHINE_IMPERFECT_SOUND )
GAME( 1997, totlvice,  0,        totlvice, totlvice, konamim2_state, init_totlvice, ROT0, "Konami", "Total Vice (ver EBA)",         MACHINE_IMPERFECT_TIMING )
//GAME( 1997, totlvicd, totlvice, totlvice, totlvice, konamim2_state, init_totlvice, ROT0, "Konami", "Total Vice (ver EAD)",         MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING )
GAME( 1997, totlvicj,  totlvice, totlvice, totlvice, konamim2_state, init_totlvice, ROT0, "Konami", "Total Vice (ver JAD)",         MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING )
GAME( 1997, totlvica,  totlvice, totlvice, totlvice, konamim2_state, init_totlvice, ROT0, "Konami", "Total Vice (ver AAB)",         MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING )
GAME( 1997, totlvicu,  totlvice, totlvice, totlvice, konamim2_state, init_totlvice, ROT0, "Konami", "Total Vice (ver UAC)",         MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING )
GAME( 1998, btltryst,  0,        btltryst, btltryst, konamim2_state, init_btltryst, ROT0, "Konami", "Battle Tryst (ver JAC)",       MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING | MACHINE_IMPERFECT_GRAPHICS )
//GAME( 1998, btltrysta, btltryst, btltryst, btltryst, konamim2_state, init_btltryst, ROT0, "Konami", "Battle Tryst (ver JAA)",       MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING | MACHINE_IMPERFECT_GRAPHICS )
GAME( 1998, heatof11,  0,        heatof11, heatof11, konamim2_state, init_btltryst, ROT0, "Konami", "Heat of Eleven '98 (ver EAA)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING | MACHINE_IMPERFECT_GRAPHICS)
GAME( 1998, evilngt,   0,        evilngt,  hellngt,  konamim2_state, init_hellngt,  ROT0, "Konami", "Evil Night (ver UBA)",         MACHINE_IMPERFECT_TIMING )
GAME( 1998, evilngte,  evilngt,  evilngt,  hellngt,  konamim2_state, init_hellngt,  ROT0, "Konami", "Evil Night (ver EAA)",         MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING )
GAME( 1998, hellngt,   evilngt,  hellngt,  hellngt,  konamim2_state, init_hellngt,  ROT0, "Konami", "Hell Night (ver EAA)",         MACHINE_IMPERFECT_TIMING )

//CONS( 199?, 3do_m2,     0,      0,    3do_m2,    m2,    driver_device, 0,      "3DO",  "3DO M2",    MACHINE_NOT_WORKING | MACHINE_IMPERFECT_TIMING | MACHINE_NO_SOUND )


/*************************************
 *
 *  Debugging Aids
 *
 *************************************/

void konamim2_state::debug_help_command(int ref, const std::vector<std::string> &params)
{
	debugger_console &con = machine().debugger().console();

	con.printf("Available M2 commands:\n");
	con.printf("  konm2 dump_task,<address> -- Dump task object at <address>\n");
	con.printf("  konm2 dump_dspp,<address> -- Dump DSPP object at <address>\n");
}

void konamim2_state::debug_commands(int ref, const std::vector<std::string> &params)
{
	if (params.size() < 1)
		return;

	if (params[0] == "help")
		debug_help_command(ref, params);
	else if (params[0] == "dump_task")
		dump_task_command(ref, params);
	else if (params[0] == "dump_dspp")
		subdevice<dspp_device>("bda:dspp")->dump_state();
}

void konamim2_state::dump_task_command(int ref, const std::vector<std::string> &params)
{
	typedef uint32_t   Item;
	typedef uint32_t   m2ptr;

	typedef struct TimerTicks
	{
		uint32_t tt_Hi;
		uint32_t tt_Lo;
	} TimerTicks;

	struct ItemNode
	{
		m2ptr pn_Next;    /* pointer to next in list              */ // 0
		m2ptr pn_Prev;    /* pointer to previous in list          */ // 4
		uint8_t     n_SubsysType;     /* what component manages this node     */ // 8
		uint8_t     n_Type;           /* what type of node for the component  */ // 9
		uint8_t     n_Priority;       /* queueing priority                    */ // A
		uint8_t     n_Flags;          /* misc flags, see below                */ // B
		int32_t     n_Size;           /* total size of node including hdr     */ // C
		m2ptr    pn_Name;           /* name of item, or NULL                */ // 10
		uint8_t     n_Version;        /* version of of this Item              */ // 14
		uint8_t     n_Revision;       /* revision of this Item                */ // 15
		uint8_t     n_Reserved0;      /* reserved for future use              */ // 16
		uint8_t     n_ItemFlags;      /* additional system item flags         */ // 17
		Item      n_Item;           /* Item number representing this struct */ //18
		Item      n_Owner;          /* creator, present owner, disposer     */ // 1C
		m2ptr     pn_Reserved1;      /* reserved for future use              */ // 20
	};

	struct Task
	{
		ItemNode     t;
		m2ptr       pt_ThreadTask;      /* I am a thread of what task?  */
		uint32_t     t_WaitBits;        /* signals being waited for     */
		uint32_t     t_SigBits;         /* signals received             */
		uint32_t     t_AllocatedSigs;   /* signals allocated            */
		m2ptr        pt_StackBase;       /* base of stack                */
		int32_t      t_StackSize;       /* size of stack                */
		uint32_t     t_MaxUSecs;        /* quantum length in usecs      */
		TimerTicks   t_ElapsedTime;     /* time spent running this task */
		uint32_t     t_NumTaskLaunch;   /* # times launched this task   */
		uint32_t     t_Flags;           /* task flags                   */
		Item         t_Module;          /* the module we live within    */
		Item         t_DefaultMsgPort;  /* default task msgport         */
		m2ptr         pt_UserData;        /* user-private data            */
	};

	debugger_cpu &cpu = machine().debugger().cpu();
	debugger_console &con = machine().debugger().console();
	address_space &space = m_ppc1->space();
	uint64_t addr;
	offs_t address;

	if (params.size() < 1)
		return;

	if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
		return;

	address = (offs_t)addr;
	address = 0x40FB54E8;
	if (!m_ppc1->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address))
	{
		con.printf("Address is unmapped.\n");
		return;
	}

	Task task;

	task.t.pn_Next = cpu.read_dword(space, address + offsetof(ItemNode, pn_Next), true);
	task.t.pn_Prev = cpu.read_dword(space, address + offsetof(ItemNode, pn_Prev), true);
	task.t.n_SubsysType = cpu.read_byte(space, address + offsetof(ItemNode, n_SubsysType), true);
	task.t.n_Type = cpu.read_byte(space, address + offsetof(ItemNode, n_Type), true);
	task.t.n_Priority = cpu.read_byte(space, address + offsetof(ItemNode, n_Priority), true);
	task.t.n_Flags = cpu.read_byte(space, address + offsetof(ItemNode, n_Flags), true);
	task.t.n_Size = cpu.read_dword(space, address + offsetof(ItemNode, n_Size), true);
	task.t.pn_Name = cpu.read_dword(space, address + offsetof(ItemNode, pn_Name), true);

	char name[128];
	char *ptr = name;
	uint32_t nameptr = task.t.pn_Name;

	do
	{
		*ptr = cpu.read_byte(space, nameptr++, true);
	} while (*ptr++ != 0);

	task.t.n_Version = cpu.read_byte(space, address + offsetof(ItemNode, n_Version), true);
	task.t.n_Revision = cpu.read_byte(space, address + offsetof(ItemNode, n_Revision), true);
	task.t.n_Reserved0 = cpu.read_byte(space, address + offsetof(ItemNode, n_Reserved0), true);
	task.t.n_ItemFlags = cpu.read_byte(space, address + offsetof(ItemNode, n_ItemFlags), true);
	task.t.n_Item = cpu.read_dword(space, address + offsetof(ItemNode, n_Item), true);
	task.t.n_Owner = cpu.read_dword(space, address + offsetof(ItemNode, n_Owner), true);
	task.t.pn_Reserved1 = cpu.read_dword(space, address + offsetof(ItemNode, pn_Reserved1), true);

	task.pt_ThreadTask = cpu.read_dword(space, address + offsetof(Task, pt_ThreadTask), true);
	task.t_WaitBits = cpu.read_dword(space, address + offsetof(Task, t_WaitBits), true);
	task.t_SigBits = cpu.read_dword(space, address + offsetof(Task, t_SigBits), true);
	task.t_AllocatedSigs = cpu.read_dword(space, address + offsetof(Task, t_AllocatedSigs), true);
	task.pt_StackBase = cpu.read_dword(space, address + offsetof(Task, pt_StackBase), true);
	task.t_StackSize = cpu.read_dword(space, address + offsetof(Task, t_StackSize), true);
	task.t_MaxUSecs = cpu.read_dword(space, address + offsetof(Task, t_MaxUSecs), true);
	task.t_ElapsedTime.tt_Hi = cpu.read_dword(space, address + offsetof(Task, t_ElapsedTime)+0, true);
	task.t_ElapsedTime.tt_Lo = cpu.read_dword(space, address + offsetof(Task, t_ElapsedTime)+4, true);
	task.t_NumTaskLaunch = cpu.read_dword(space, address + offsetof(Task, t_NumTaskLaunch), true);
	task.t_Flags = cpu.read_dword(space, address + offsetof(Task, t_Flags), true);
	task.t_Module = cpu.read_dword(space, address + offsetof(Task, t_Module), true);
	task.t_DefaultMsgPort = cpu.read_dword(space, address + offsetof(Task, t_DefaultMsgPort), true);
	task.pt_UserData = cpu.read_dword(space, address + offsetof(Task, pt_UserData), true);

//  m2ptr       pt_ThreadTask;      /* I am a thread of what task?  */
//  uint32_t     t_WaitBits;        /* signals being waited for     */
//  uint32_t     t_SigBits;         /* signals received             */
//  uint32_t     t_AllocatedSigs;   /* signals allocated            */
//  m2ptr        pt_StackBase;       /* base of stack                */
//  int32_t      t_StackSize;       /* size of stack                */
//  uint32_t     t_MaxUSecs;        /* quantum length in usecs      */
//  TimerTicks   t_ElapsedTime;     /* time spent running this task */
//  uint32_t     t_NumTaskLaunch;   /* # times launched this task   */
//  uint32_t     t_Flags;           /* task flags                   */
//  Item         t_Module;          /* the module we live within    */
//  Item         t_DefaultMsgPort;  /* default task msgport         */
//  m2ptr         pt_UserData;        /* user-private data            */

	con.printf("**** Task Info @ %08X ****\n", address);
	con.printf("Next:        %08X\n", task.t.pn_Next);
	con.printf("Prev:        %08X\n", task.t.pn_Prev);
	con.printf("SubsysType:  %X\n", task.t.n_SubsysType);
	con.printf("Type:        %X\n", task.t.n_Type);
	con.printf("Priority:    %X\n", task.t.n_Priority);
	con.printf("Flags:       %X\n", task.t.n_Flags);
	con.printf("Size:        %08X\n", task.t.n_Size);
	con.printf("Name:        %s\n", name);
	con.printf("Version:     %X\n", task.t.n_Version);
	con.printf("Revision:    %X\n", task.t.n_Revision);
	con.printf("Reserved0:   %X\n", task.t.n_Reserved0);
	con.printf("ItemFlags:   %X\n", task.t.n_ItemFlags);
	con.printf("Item:        %08X\n", task.t.n_Item);
	con.printf("Owner:       %08X\n", task.t.n_Owner);
	con.printf("Reserved1:   %08X\n", task.t.pn_Reserved1);
	con.printf("ThreadTask:  %08X\n", task.pt_ThreadTask);
	con.printf("WaitBits:    %08X\n", task.t_WaitBits);
	con.printf("SigBits:     %08X\n", task.t_SigBits);
	con.printf("AllocSigs:   %08X\n", task.t_AllocatedSigs);
	con.printf("StackBase:   %08X\n", task.pt_StackBase);
	con.printf("StackSize:   %08X\n", task.t_StackSize);
	con.printf("MaxUSecs:    %08X\n", task.t_MaxUSecs);
	con.printf("ElapsedTime: %016llu\n", (uint64_t)task.t_ElapsedTime.tt_Lo + ((uint64_t)task.t_ElapsedTime.tt_Hi << 32ull));
	con.printf("NumTaskLaunch:  %u\n", task.t_NumTaskLaunch);
	con.printf("Flags:          %08X\n", task.t_Flags);
	con.printf("Module:         %08X\n", task.t_Module);
	con.printf("DefaultMsgPort: %08X\n", task.t_DefaultMsgPort);
	con.printf("UserData:       %08X\n", task.pt_UserData);
	con.printf("\n");
}