src/mess/drivers/x1.c
| r13654 | r13655 | |
| 244 | 244 | |
| 245 | 245 | static VIDEO_START( x1 ) |
| 246 | 246 | { |
| 247 | | // x1_state *state = machine.driver_data<x1_state>(); |
| 248 | | // state->m_avram = auto_alloc_array(machine, UINT8, 0x800); |
| 249 | | // state->m_tvram = auto_alloc_array(machine, UINT8, 0x800); |
| 250 | | // state->m_kvram = auto_alloc_array(machine, UINT8, 0x800); |
| 251 | | // state->m_gfx_bitmap_ram = auto_alloc_array(machine, UINT8, 0xc000*2); |
| 252 | | // state->m_pal_4096 = auto_alloc_array(machine, UINT8, 0x1000*3); |
| 247 | x1_state *state = machine.driver_data<x1_state>(); |
| 248 | |
| 249 | state->m_avram = auto_alloc_array_clear(machine, UINT8, 0x800); |
| 250 | state->m_tvram = auto_alloc_array_clear(machine, UINT8, 0x800); |
| 251 | state->m_kvram = auto_alloc_array_clear(machine, UINT8, 0x800); |
| 252 | state->m_gfx_bitmap_ram = auto_alloc_array_clear(machine, UINT8, 0xc000*2); |
| 253 | state->m_pal_4096 = auto_alloc_array_clear(machine, UINT8, 0x1000*3); |
| 253 | 254 | } |
| 254 | 255 | |
| 255 | 256 | static void x1_draw_pixel(running_machine &machine, bitmap_t *bitmap,int y,int x,UINT16 pen,UINT8 width,UINT8 height) |
| r13654 | r13655 | |
| 563 | 564 | } |
| 564 | 565 | } |
| 565 | 566 | |
| 566 | | static SCREEN_UPDATE( x1 ) |
| 567 | SCREEN_UPDATE( x1 ) |
| 567 | 568 | { |
| 568 | 569 | x1_state *state = screen->machine().driver_data<x1_state>(); |
| 569 | 570 | |
| r13654 | r13655 | |
| 576 | 577 | return 0; |
| 577 | 578 | } |
| 578 | 579 | |
| 579 | | static SCREEN_EOF( x1 ) |
| 580 | | { |
| 581 | | // x1_state *state = screen->machine().driver_data<x1_state>(); |
| 582 | 580 | |
| 583 | | // state->m_old_vpos = -1; |
| 584 | | } |
| 585 | | |
| 586 | 581 | /************************************* |
| 587 | 582 | * |
| 588 | 583 | * Keyboard MCU simulation |
| r13654 | r13655 | |
| 731 | 726 | return ret; |
| 732 | 727 | } |
| 733 | 728 | |
| 734 | | static READ8_HANDLER( sub_io_r ) |
| 729 | READ8_HANDLER( x1_sub_io_r ) |
| 735 | 730 | { |
| 736 | 731 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 737 | 732 | UINT8 ret,bus_res; |
| r13654 | r13655 | |
| 832 | 827 | logerror("CMT: Command 0xe9-0x%02x received.\n",cmd); |
| 833 | 828 | } |
| 834 | 829 | |
| 835 | | static TIMER_DEVICE_CALLBACK( cmt_wind_timer ) |
| 830 | static TIMER_DEVICE_CALLBACK( x1_cmt_wind_timer ) |
| 836 | 831 | { |
| 837 | 832 | x1_state *state = timer.machine().driver_data<x1_state>(); |
| 838 | 833 | cassette_image_device* cmt = timer.machine().device<cassette_image_device>(CASSETTE_TAG); |
| r13654 | r13655 | |
| 857 | 852 | } |
| 858 | 853 | } |
| 859 | 854 | |
| 860 | | static WRITE8_HANDLER( sub_io_w ) |
| 855 | WRITE8_HANDLER( x1_sub_io_w ) |
| 861 | 856 | { |
| 862 | 857 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 863 | 858 | /* sub-routine at $10e sends to these sub-routines when a keyboard input is triggered: |
| r13654 | r13655 | |
| 988 | 983 | *************************************/ |
| 989 | 984 | |
| 990 | 985 | |
| 991 | | static READ8_HANDLER( x1_rom_r ) |
| 986 | READ8_HANDLER( x1_rom_r ) |
| 992 | 987 | { |
| 993 | 988 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 994 | 989 | UINT8 *rom = space->machine().region("cart_img")->base(); |
| r13654 | r13655 | |
| 998 | 993 | return rom[state->m_rom_index[0]<<16|state->m_rom_index[1]<<8|state->m_rom_index[2]<<0]; |
| 999 | 994 | } |
| 1000 | 995 | |
| 1001 | | static WRITE8_HANDLER( x1_rom_w ) |
| 996 | WRITE8_HANDLER( x1_rom_w ) |
| 1002 | 997 | { |
| 1003 | 998 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1004 | 999 | state->m_rom_index[offset] = data; |
| 1005 | 1000 | } |
| 1006 | 1001 | |
| 1007 | | static WRITE8_HANDLER( rom_bank_0_w ) |
| 1002 | WRITE8_HANDLER( x1_rom_bank_0_w ) |
| 1008 | 1003 | { |
| 1009 | 1004 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1010 | 1005 | state->m_ram_bank = 0x10; |
| 1011 | 1006 | } |
| 1012 | 1007 | |
| 1013 | | static WRITE8_HANDLER( rom_bank_1_w ) |
| 1008 | WRITE8_HANDLER( x1_rom_bank_1_w ) |
| 1014 | 1009 | { |
| 1015 | 1010 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1016 | 1011 | state->m_ram_bank = 0x00; |
| r13654 | r13655 | |
| 1027 | 1022 | //static UINT8 fdc_side; |
| 1028 | 1023 | //static UINT8 fdc_drive; |
| 1029 | 1024 | |
| 1030 | | static READ8_HANDLER( x1_fdc_r ) |
| 1025 | READ8_HANDLER( x1_fdc_r ) |
| 1031 | 1026 | { |
| 1032 | 1027 | device_t* dev = space->machine().device("fdc"); |
| 1033 | 1028 | //UINT8 ret = 0; |
| r13654 | r13655 | |
| 1059 | 1054 | return 0x00; |
| 1060 | 1055 | } |
| 1061 | 1056 | |
| 1062 | | static WRITE8_HANDLER( x1_fdc_w ) |
| 1057 | WRITE8_HANDLER( x1_fdc_w ) |
| 1063 | 1058 | { |
| 1064 | 1059 | device_t* dev = space->machine().device("fdc"); |
| 1065 | 1060 | |
| r13654 | r13655 | |
| 1152 | 1147 | return pcg_offset; |
| 1153 | 1148 | } |
| 1154 | 1149 | |
| 1155 | | static READ8_HANDLER( x1_pcg_r ) |
| 1150 | READ8_HANDLER( x1_pcg_r ) |
| 1156 | 1151 | { |
| 1157 | 1152 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1158 | 1153 | int addr; |
| r13654 | r13655 | |
| 1189 | 1184 | return res; |
| 1190 | 1185 | } |
| 1191 | 1186 | |
| 1192 | | static WRITE8_HANDLER( x1_pcg_w ) |
| 1187 | WRITE8_HANDLER( x1_pcg_w ) |
| 1193 | 1188 | { |
| 1194 | 1189 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1195 | 1190 | int addr,pcg_offset; |
| r13654 | r13655 | |
| 1257 | 1252 | } |
| 1258 | 1253 | } |
| 1259 | 1254 | |
| 1260 | | static WRITE8_HANDLER( x1turboz_4096_palette_w ) |
| 1255 | WRITE8_HANDLER( x1turboz_4096_palette_w ) |
| 1261 | 1256 | { |
| 1262 | 1257 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1263 | 1258 | UINT32 pal_entry; |
| r13654 | r13655 | |
| 1276 | 1271 | |
| 1277 | 1272 | /* Note: docs claims that reading the palette ports makes the value to change somehow in X1 mode ... |
| 1278 | 1273 | In 4096 color mode, it's used for reading the value back. */ |
| 1279 | | static WRITE8_HANDLER( x1_pal_r_w ) |
| 1274 | WRITE8_HANDLER( x1_pal_r_w ) |
| 1280 | 1275 | { |
| 1281 | 1276 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1282 | 1277 | |
| r13654 | r13655 | |
| 1297 | 1292 | } |
| 1298 | 1293 | } |
| 1299 | 1294 | |
| 1300 | | static WRITE8_HANDLER( x1_pal_g_w ) |
| 1295 | WRITE8_HANDLER( x1_pal_g_w ) |
| 1301 | 1296 | { |
| 1302 | 1297 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1303 | 1298 | |
| r13654 | r13655 | |
| 1318 | 1313 | } |
| 1319 | 1314 | } |
| 1320 | 1315 | |
| 1321 | | static WRITE8_HANDLER( x1_pal_b_w ) |
| 1316 | WRITE8_HANDLER( x1_pal_b_w ) |
| 1322 | 1317 | { |
| 1323 | 1318 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1324 | 1319 | |
| r13654 | r13655 | |
| 1339 | 1334 | } |
| 1340 | 1335 | } |
| 1341 | 1336 | |
| 1342 | | static WRITE8_HANDLER( x1_ex_gfxram_w ) |
| 1337 | WRITE8_HANDLER( x1_ex_gfxram_w ) |
| 1343 | 1338 | { |
| 1344 | 1339 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1345 | 1340 | UINT8 ex_mask; |
| r13654 | r13655 | |
| 1366 | 1361 | d6(40) = 0:8-raster graphics 1:16-raster graphics |
| 1367 | 1362 | d7(80) = 0:don't display 1:display <- underline (when 1, graphics are not displayed) |
| 1368 | 1363 | */ |
| 1369 | | static WRITE8_HANDLER( x1_scrn_w ) |
| 1364 | WRITE8_HANDLER( x1_scrn_w ) |
| 1370 | 1365 | { |
| 1371 | 1366 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1372 | 1367 | state->m_scrn_reg.pcg_mode = (data & 0x20)>>5; |
| r13654 | r13655 | |
| 1381 | 1376 | printf("SCRN sets true 400 lines mode\n"); |
| 1382 | 1377 | } |
| 1383 | 1378 | |
| 1384 | | static WRITE8_HANDLER( x1_pri_w ) |
| 1379 | WRITE8_HANDLER( x1_pri_w ) |
| 1385 | 1380 | { |
| 1386 | 1381 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1387 | 1382 | state->m_scrn_reg.pri = data; |
| 1388 | 1383 | // printf("PRI = %02x\n",data); |
| 1389 | 1384 | } |
| 1390 | 1385 | |
| 1391 | | static WRITE8_HANDLER( x1_6845_w ) |
| 1386 | WRITE8_HANDLER( x1_6845_w ) |
| 1392 | 1387 | { |
| 1393 | 1388 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1394 | 1389 | if(offset == 0) |
| r13654 | r13655 | |
| 1403 | 1398 | } |
| 1404 | 1399 | } |
| 1405 | 1400 | |
| 1406 | | static READ8_HANDLER( x1_blackclip_r ) |
| 1401 | READ8_HANDLER( x1turboz_blackclip_r ) |
| 1407 | 1402 | { |
| 1408 | 1403 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1409 | 1404 | /* TODO: this returns only on x1turboz */ |
| 1410 | 1405 | return state->m_scrn_reg.blackclip; |
| 1411 | 1406 | } |
| 1412 | 1407 | |
| 1413 | | static WRITE8_HANDLER( x1_blackclip_w ) |
| 1408 | WRITE8_HANDLER( x1turbo_blackclip_w ) |
| 1414 | 1409 | { |
| 1415 | 1410 | /* |
| 1416 | 1411 | -x-- ---- replace blanking duration with black |
| r13654 | r13655 | |
| 1425 | 1420 | printf("Blackclip data access %02x\n",data); |
| 1426 | 1421 | } |
| 1427 | 1422 | |
| 1428 | | static READ8_HANDLER( x1turbo_pal_r ) |
| 1423 | READ8_HANDLER( x1turbo_pal_r ) |
| 1429 | 1424 | { |
| 1430 | 1425 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1431 | 1426 | return state->m_turbo_reg.pal; |
| 1432 | 1427 | } |
| 1433 | 1428 | |
| 1434 | | static READ8_HANDLER( x1turbo_txpal_r ) |
| 1429 | READ8_HANDLER( x1turbo_txpal_r ) |
| 1435 | 1430 | { |
| 1436 | 1431 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1437 | 1432 | return state->m_turbo_reg.txt_pal[offset]; |
| 1438 | 1433 | } |
| 1439 | 1434 | |
| 1440 | | static READ8_HANDLER( x1turbo_txdisp_r ) |
| 1435 | READ8_HANDLER( x1turbo_txdisp_r ) |
| 1441 | 1436 | { |
| 1442 | 1437 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1443 | 1438 | return state->m_turbo_reg.txt_disp; |
| 1444 | 1439 | } |
| 1445 | 1440 | |
| 1446 | | static READ8_HANDLER( x1turbo_gfxpal_r ) |
| 1441 | READ8_HANDLER( x1turbo_gfxpal_r ) |
| 1447 | 1442 | { |
| 1448 | 1443 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1449 | 1444 | return state->m_turbo_reg.gfx_pal; |
| 1450 | 1445 | } |
| 1451 | 1446 | |
| 1452 | | static WRITE8_HANDLER( x1turbo_pal_w ) |
| 1447 | WRITE8_HANDLER( x1turbo_pal_w ) |
| 1453 | 1448 | { |
| 1454 | 1449 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1455 | 1450 | printf("TURBO PAL %02x\n",data); |
| 1456 | 1451 | state->m_turbo_reg.pal = data; |
| 1457 | 1452 | } |
| 1458 | 1453 | |
| 1459 | | static WRITE8_HANDLER( x1turbo_txpal_w ) |
| 1454 | WRITE8_HANDLER( x1turbo_txpal_w ) |
| 1460 | 1455 | { |
| 1461 | 1456 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1462 | 1457 | int r,g,b; |
| r13654 | r13655 | |
| 1474 | 1469 | } |
| 1475 | 1470 | } |
| 1476 | 1471 | |
| 1477 | | static WRITE8_HANDLER( x1turbo_txdisp_w ) |
| 1472 | WRITE8_HANDLER( x1turbo_txdisp_w ) |
| 1478 | 1473 | { |
| 1479 | 1474 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1480 | 1475 | printf("TURBO TEXT DISPLAY %02x\n",data); |
| 1481 | 1476 | state->m_turbo_reg.txt_disp = data; |
| 1482 | 1477 | } |
| 1483 | 1478 | |
| 1484 | | static WRITE8_HANDLER( x1turbo_gfxpal_w ) |
| 1479 | WRITE8_HANDLER( x1turbo_gfxpal_w ) |
| 1485 | 1480 | { |
| 1486 | 1481 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1487 | 1482 | printf("TURBO GFX PAL %02x\n",data); |
| r13654 | r13655 | |
| 1508 | 1503 | return 0x0000; |
| 1509 | 1504 | } |
| 1510 | 1505 | |
| 1511 | | static READ8_HANDLER( x1_kanji_r ) |
| 1506 | READ8_HANDLER( x1_kanji_r ) |
| 1512 | 1507 | { |
| 1513 | 1508 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1514 | 1509 | UINT8 *kanji_rom = space->machine().region("kanji")->base(); |
| r13654 | r13655 | |
| 1522 | 1517 | return res; |
| 1523 | 1518 | } |
| 1524 | 1519 | |
| 1525 | | static WRITE8_HANDLER( x1_kanji_w ) |
| 1520 | WRITE8_HANDLER( x1_kanji_w ) |
| 1526 | 1521 | { |
| 1527 | 1522 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1528 | 1523 | // if(offset < 2) |
| r13654 | r13655 | |
| 1553 | 1548 | } |
| 1554 | 1549 | } |
| 1555 | 1550 | |
| 1556 | | static READ8_HANDLER( x1_emm_r ) |
| 1551 | READ8_HANDLER( x1_emm_r ) |
| 1557 | 1552 | { |
| 1558 | 1553 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1559 | 1554 | UINT8 *emm_ram = space->machine().region("emm")->base(); |
| r13654 | r13655 | |
| 1579 | 1574 | return res; |
| 1580 | 1575 | } |
| 1581 | 1576 | |
| 1582 | | static WRITE8_HANDLER( x1_emm_w ) |
| 1577 | WRITE8_HANDLER( x1_emm_w ) |
| 1583 | 1578 | { |
| 1584 | 1579 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1585 | 1580 | UINT8 *emm_ram = space->machine().region("emm")->base(); |
| r13654 | r13655 | |
| 1605 | 1600 | /* |
| 1606 | 1601 | CZ-141SF, CZ-127MF, X1turboZII, X1turboZ3 boards |
| 1607 | 1602 | */ |
| 1608 | | static READ8_HANDLER( x1turbo_bank_r ) |
| 1603 | READ8_HANDLER( x1turbo_bank_r ) |
| 1609 | 1604 | { |
| 1610 | 1605 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1611 | 1606 | |
| r13654 | r13655 | |
| 1613 | 1608 | return state->m_ex_bank & 0x3f; |
| 1614 | 1609 | } |
| 1615 | 1610 | |
| 1616 | | static WRITE8_HANDLER( x1turbo_bank_w ) |
| 1611 | WRITE8_HANDLER( x1turbo_bank_w ) |
| 1617 | 1612 | { |
| 1618 | 1613 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1619 | 1614 | //UINT8 *RAM = space->machine().region("maincpu")->base(); |
| r13654 | r13655 | |
| 1628 | 1623 | } |
| 1629 | 1624 | |
| 1630 | 1625 | /* TODO: waitstate penalties */ |
| 1631 | | static READ8_HANDLER( x1_mem_r ) |
| 1626 | READ8_HANDLER( x1_mem_r ) |
| 1632 | 1627 | { |
| 1633 | 1628 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1634 | 1629 | UINT8 *wram = space->machine().region("wram")->base(); |
| r13654 | r13655 | |
| 1642 | 1637 | return wram[offset]; //RAM |
| 1643 | 1638 | } |
| 1644 | 1639 | |
| 1645 | | static WRITE8_HANDLER( x1_mem_w ) |
| 1640 | WRITE8_HANDLER( x1_mem_w ) |
| 1646 | 1641 | { |
| 1647 | 1642 | //x1_state *state = space->machine().driver_data<x1_state>(); |
| 1648 | 1643 | UINT8 *wram = space->machine().region("wram")->base(); |
| r13654 | r13655 | |
| 1650 | 1645 | wram[offset] = data; //RAM |
| 1651 | 1646 | } |
| 1652 | 1647 | |
| 1653 | | static READ8_HANDLER( x1turbo_mem_r ) |
| 1648 | READ8_HANDLER( x1turbo_mem_r ) |
| 1654 | 1649 | { |
| 1655 | 1650 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1656 | 1651 | |
| r13654 | r13655 | |
| 1664 | 1659 | return x1_mem_r(space,offset); |
| 1665 | 1660 | } |
| 1666 | 1661 | |
| 1667 | | static WRITE8_HANDLER( x1turbo_mem_w ) |
| 1662 | WRITE8_HANDLER( x1turbo_mem_w ) |
| 1668 | 1663 | { |
| 1669 | 1664 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1670 | 1665 | |
| r13654 | r13655 | |
| 1684 | 1679 | * |
| 1685 | 1680 | *************************************/ |
| 1686 | 1681 | |
| 1687 | | static READ8_HANDLER( x1_io_r ) |
| 1682 | READ8_HANDLER( x1_io_r ) |
| 1688 | 1683 | { |
| 1689 | 1684 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1690 | 1685 | state->m_io_bank_mode = 0; //any read disables the extended mode. |
| r13654 | r13655 | |
| 1695 | 1690 | //if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(space->machine().device("ctc"), offset-0x0704); } |
| 1696 | 1691 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 1697 | 1692 | else if(offset >= 0x1400 && offset <= 0x17ff) { return x1_pcg_r(space, offset-0x1400); } |
| 1698 | | else if(offset >= 0x1900 && offset <= 0x19ff) { return sub_io_r(space, 0); } |
| 1693 | else if(offset >= 0x1900 && offset <= 0x19ff) { return x1_sub_io_r(space, 0); } |
| 1699 | 1694 | else if(offset >= 0x1a00 && offset <= 0x1aff) { return space->machine().device<i8255_device>("ppi8255_0")->read(*space, (offset-0x1a00) & 3); } |
| 1700 | 1695 | else if(offset >= 0x1b00 && offset <= 0x1bff) { return ay8910_r(space->machine().device("ay"), 0); } |
| 1701 | 1696 | // else if(offset >= 0x1f80 && offset <= 0x1f8f) { return z80dma_r(space->machine().device("dma"), 0); } |
| r13654 | r13655 | |
| 1704 | 1699 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(space->machine().device("ctc"), offset-0x1fa0); } |
| 1705 | 1700 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(space->machine().device("ctc"), offset-0x1fa8); } |
| 1706 | 1701 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 1707 | | // else if(offset == 0x1fe0) { return x1_blackclip_r(space,0); } |
| 1702 | // else if(offset == 0x1fe0) { return x1turboz_blackclip_r(space,0); } |
| 1708 | 1703 | else if(offset >= 0x2000 && offset <= 0x2fff) { return state->m_avram[offset & 0x7ff]; } |
| 1709 | 1704 | else if(offset >= 0x3000 && offset <= 0x3fff) { return state->m_tvram[offset & 0x7ff]; } // Ys checks if it's a x1/x1turbo machine by checking if this area is a mirror |
| 1710 | 1705 | else if(offset >= 0x4000 && offset <= 0xffff) { return state->m_gfx_bitmap_ram[offset-0x4000+(state->m_scrn_reg.gfx_bank*0xc000)]; } |
| r13654 | r13655 | |
| 1715 | 1710 | return 0xff; |
| 1716 | 1711 | } |
| 1717 | 1712 | |
| 1718 | | static WRITE8_HANDLER( x1_io_w ) |
| 1713 | WRITE8_HANDLER( x1_io_w ) |
| 1719 | 1714 | { |
| 1720 | 1715 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1721 | 1716 | |
| r13654 | r13655 | |
| 1733 | 1728 | else if(offset >= 0x1300 && offset <= 0x13ff) { x1_pri_w(space, 0,data); } |
| 1734 | 1729 | else if(offset >= 0x1400 && offset <= 0x17ff) { x1_pcg_w(space, offset-0x1400,data); } |
| 1735 | 1730 | else if(offset == 0x1800 || offset == 0x1801) { x1_6845_w(space, offset-0x1800, data); } |
| 1736 | | else if(offset >= 0x1900 && offset <= 0x19ff) { sub_io_w(space, 0,data); } |
| 1731 | else if(offset >= 0x1900 && offset <= 0x19ff) { x1_sub_io_w(space, 0,data); } |
| 1737 | 1732 | else if(offset >= 0x1a00 && offset <= 0x1aff) { space->machine().device<i8255_device>("ppi8255_0")->write(*space, (offset-0x1a00) & 3,data); } |
| 1738 | 1733 | else if(offset >= 0x1b00 && offset <= 0x1bff) { ay8910_data_w(space->machine().device("ay"), 0,data); } |
| 1739 | 1734 | else if(offset >= 0x1c00 && offset <= 0x1cff) { ay8910_address_w(space->machine().device("ay"), 0,data); } |
| 1740 | | else if(offset >= 0x1d00 && offset <= 0x1dff) { rom_bank_1_w(space,0,data); } |
| 1741 | | else if(offset >= 0x1e00 && offset <= 0x1eff) { rom_bank_0_w(space,0,data); } |
| 1735 | else if(offset >= 0x1d00 && offset <= 0x1dff) { x1_rom_bank_1_w(space,0,data); } |
| 1736 | else if(offset >= 0x1e00 && offset <= 0x1eff) { x1_rom_bank_0_w(space,0,data); } |
| 1742 | 1737 | // else if(offset >= 0x1f80 && offset <= 0x1f8f) { z80dma_w(space->machine().device("dma"), 0,data); } |
| 1743 | 1738 | // else if(offset >= 0x1f90 && offset <= 0x1f91) { z80sio_c_w(space->machine().device("sio"), (offset-0x1f90) & 1,data); } |
| 1744 | 1739 | // else if(offset >= 0x1f92 && offset <= 0x1f93) { z80sio_d_w(space->machine().device("sio"), (offset-0x1f92) & 1,data); } |
| r13654 | r13655 | |
| 1749 | 1744 | // else if(offset == 0x1fc0) { x1turbo_txdisp_w(space,0,data); } |
| 1750 | 1745 | // else if(offset == 0x1fc5) { x1turbo_gfxpal_w(space,0,data); } |
| 1751 | 1746 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { x1_scrn_w(space,0,data); } |
| 1752 | | // else if(offset == 0x1fe0) { x1_blackclip_w(space,0,data); } |
| 1747 | // else if(offset == 0x1fe0) { x1turbo_blackclip_w(space,0,data); } |
| 1753 | 1748 | else if(offset >= 0x2000 && offset <= 0x2fff) { state->m_avram[offset & 0x7ff] = data; } |
| 1754 | 1749 | else if(offset >= 0x3000 && offset <= 0x3fff) { state->m_tvram[offset & 0x7ff] = data; } |
| 1755 | 1750 | else if(offset >= 0x4000 && offset <= 0xffff) { state->m_gfx_bitmap_ram[offset-0x4000+(state->m_scrn_reg.gfx_bank*0xc000)] = data; } |
| r13654 | r13655 | |
| 1760 | 1755 | } |
| 1761 | 1756 | |
| 1762 | 1757 | /* TODO: I should actually simplify this, by just overwriting X1 Turbo specifics here, and call plain X1 functions otherwise */ |
| 1763 | | static READ8_HANDLER( x1turbo_io_r ) |
| 1758 | READ8_HANDLER( x1turbo_io_r ) |
| 1764 | 1759 | { |
| 1765 | 1760 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1766 | 1761 | state->m_io_bank_mode = 0; //any read disables the extended mode. |
| r13654 | r13655 | |
| 1782 | 1777 | else if(offset >= 0x0fe8 && offset <= 0x0fef) { printf("8-inch FD read %04x\n",offset); return 0xff; } // * |
| 1783 | 1778 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 1784 | 1779 | else if(offset >= 0x1400 && offset <= 0x17ff) { return x1_pcg_r(space, offset-0x1400); } |
| 1785 | | else if(offset >= 0x1900 && offset <= 0x19ff) { return sub_io_r(space, 0); } |
| 1780 | else if(offset >= 0x1900 && offset <= 0x19ff) { return x1_sub_io_r(space, 0); } |
| 1786 | 1781 | else if(offset >= 0x1a00 && offset <= 0x1aff) { return space->machine().device<i8255_device>("ppi8255_0")->read(*space, (offset-0x1a00) & 3); } |
| 1787 | 1782 | else if(offset >= 0x1b00 && offset <= 0x1bff) { return ay8910_r(space->machine().device("ay"), 0); } |
| 1788 | 1783 | else if(offset >= 0x1f80 && offset <= 0x1f8f) { return z80dma_r(space->machine().device("dma"), 0); } |
| r13654 | r13655 | |
| 1795 | 1790 | else if(offset == 0x1fc0) { return x1turbo_txdisp_r(space,0); } // Z only! |
| 1796 | 1791 | else if(offset == 0x1fc5) { return x1turbo_gfxpal_r(space,0); } // Z only! |
| 1797 | 1792 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } //Z only |
| 1798 | | else if(offset == 0x1fe0) { return x1_blackclip_r(space,0); } |
| 1793 | else if(offset == 0x1fe0) { return x1turboz_blackclip_r(space,0); } |
| 1799 | 1794 | else if(offset == 0x1ff0) { return input_port_read(space->machine(), "X1TURBO_DSW"); } |
| 1800 | 1795 | else if(offset >= 0x2000 && offset <= 0x2fff) { return state->m_avram[offset & 0x7ff]; } |
| 1801 | 1796 | else if(offset >= 0x3000 && offset <= 0x37ff) { return state->m_tvram[offset & 0x7ff]; } |
| r13654 | r13655 | |
| 1808 | 1803 | return 0xff; |
| 1809 | 1804 | } |
| 1810 | 1805 | |
| 1811 | | static WRITE8_HANDLER( x1turbo_io_w ) |
| 1806 | WRITE8_HANDLER( x1turbo_io_w ) |
| 1812 | 1807 | { |
| 1813 | 1808 | x1_state *state = space->machine().driver_data<x1_state>(); |
| 1814 | 1809 | |
| r13654 | r13655 | |
| 1834 | 1829 | else if(offset >= 0x1300 && offset <= 0x13ff) { x1_pri_w(space, 0,data); } |
| 1835 | 1830 | else if(offset >= 0x1400 && offset <= 0x17ff) { x1_pcg_w(space, offset-0x1400,data); } |
| 1836 | 1831 | else if(offset == 0x1800 || offset == 0x1801) { x1_6845_w(space, offset-0x1800, data); } |
| 1837 | | else if(offset >= 0x1900 && offset <= 0x19ff) { sub_io_w(space, 0,data); } |
| 1832 | else if(offset >= 0x1900 && offset <= 0x19ff) { x1_sub_io_w(space, 0,data); } |
| 1838 | 1833 | else if(offset >= 0x1a00 && offset <= 0x1aff) { space->machine().device<i8255_device>("ppi8255_0")->write(*space, (offset-0x1a00) & 3,data); } |
| 1839 | 1834 | else if(offset >= 0x1b00 && offset <= 0x1bff) { ay8910_data_w(space->machine().device("ay"), 0,data); } |
| 1840 | 1835 | else if(offset >= 0x1c00 && offset <= 0x1cff) { ay8910_address_w(space->machine().device("ay"), 0,data); } |
| 1841 | | else if(offset >= 0x1d00 && offset <= 0x1dff) { rom_bank_1_w(space,0,data); } |
| 1842 | | else if(offset >= 0x1e00 && offset <= 0x1eff) { rom_bank_0_w(space,0,data); } |
| 1836 | else if(offset >= 0x1d00 && offset <= 0x1dff) { x1_rom_bank_1_w(space,0,data); } |
| 1837 | else if(offset >= 0x1e00 && offset <= 0x1eff) { x1_rom_bank_0_w(space,0,data); } |
| 1843 | 1838 | else if(offset >= 0x1f80 && offset <= 0x1f8f) { z80dma_w(space->machine().device("dma"), 0,data); } |
| 1844 | 1839 | else if(offset >= 0x1f90 && offset <= 0x1f93) { z80dart_ba_cd_w(space->machine().device("sio"), (offset-0x1f90) & 3,data); } |
| 1845 | 1840 | else if(offset >= 0x1f98 && offset <= 0x1f9f) { printf("Extended SIO/CTC write %04x %02x\n",offset,data); } |
| r13654 | r13655 | |
| 1854 | 1849 | else if(offset == 0x1fc4) { printf("Z Extra scroll config access %02x\n",data); } // Z only! |
| 1855 | 1850 | else if(offset == 0x1fc5) { x1turbo_gfxpal_w(space,0,data); } // Z only! |
| 1856 | 1851 | else if(offset >= 0x1fd0 && offset <= 0x1fdf) { x1_scrn_w(space,0,data); } |
| 1857 | | else if(offset == 0x1fe0) { x1_blackclip_w(space,0,data); } |
| 1852 | else if(offset == 0x1fe0) { x1turbo_blackclip_w(space,0,data); } |
| 1858 | 1853 | else if(offset >= 0x2000 && offset <= 0x2fff) { state->m_avram[offset & 0x7ff] = data; } |
| 1859 | 1854 | else if(offset >= 0x3000 && offset <= 0x37ff) { state->m_tvram[offset & 0x7ff] = data; } |
| 1860 | 1855 | else if(offset >= 0x3800 && offset <= 0x3fff) { state->m_kvram[offset & 0x7ff] = data; } |
| r13654 | r13655 | |
| 1891 | 1886 | * |
| 1892 | 1887 | *************************************/ |
| 1893 | 1888 | |
| 1894 | | static READ8_DEVICE_HANDLER( x1_porta_r ) |
| 1889 | READ8_DEVICE_HANDLER( x1_porta_r ) |
| 1895 | 1890 | { |
| 1896 | 1891 | printf("PPI Port A read\n"); |
| 1897 | 1892 | return 0xff; |
| 1898 | 1893 | } |
| 1899 | 1894 | |
| 1900 | 1895 | /* this port is system related */ |
| 1901 | | static READ8_DEVICE_HANDLER( x1_portb_r ) |
| 1896 | READ8_DEVICE_HANDLER( x1_portb_r ) |
| 1902 | 1897 | { |
| 1903 | 1898 | x1_state *state = device->machine().driver_data<x1_state>(); |
| 1904 | 1899 | //printf("PPI Port B read\n"); |
| r13654 | r13655 | |
| 1942 | 1937 | } |
| 1943 | 1938 | |
| 1944 | 1939 | /* I/O system port */ |
| 1945 | | static READ8_DEVICE_HANDLER( x1_portc_r ) |
| 1940 | READ8_DEVICE_HANDLER( x1_portc_r ) |
| 1946 | 1941 | { |
| 1947 | 1942 | x1_state *state = device->machine().driver_data<x1_state>(); |
| 1948 | 1943 | //printf("PPI Port C read\n"); |
| r13654 | r13655 | |
| 1956 | 1951 | return (state->m_io_sys & 0x9f) | state->m_hres_320 | ~state->m_io_switch; |
| 1957 | 1952 | } |
| 1958 | 1953 | |
| 1959 | | static WRITE8_DEVICE_HANDLER( x1_porta_w ) |
| 1954 | WRITE8_DEVICE_HANDLER( x1_porta_w ) |
| 1960 | 1955 | { |
| 1961 | 1956 | //printf("PPI Port A write %02x\n",data); |
| 1962 | 1957 | } |
| 1963 | 1958 | |
| 1964 | | static WRITE8_DEVICE_HANDLER( x1_portb_w ) |
| 1959 | WRITE8_DEVICE_HANDLER( x1_portb_w ) |
| 1965 | 1960 | { |
| 1966 | 1961 | //printf("PPI Port B write %02x\n",data); |
| 1967 | 1962 | } |
| 1968 | 1963 | |
| 1969 | | static WRITE8_DEVICE_HANDLER( x1_portc_w ) |
| 1964 | WRITE8_DEVICE_HANDLER( x1_portc_w ) |
| 1970 | 1965 | { |
| 1971 | 1966 | x1_state *state = device->machine().driver_data<x1_state>(); |
| 1972 | 1967 | state->m_hres_320 = data & 0x40; |
| r13654 | r13655 | |
| 2045 | 2040 | cputag_set_input_line(field.machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); |
| 2046 | 2041 | } |
| 2047 | 2042 | |
| 2048 | | static INPUT_PORTS_START( x1 ) |
| 2043 | INPUT_PORTS_START( x1 ) |
| 2049 | 2044 | PORT_START("FP_SYS") //front panel buttons, hard-wired with the soft reset/NMI lines |
| 2050 | 2045 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CHANGED(ipl_reset,0) PORT_NAME("IPL reset") |
| 2051 | 2046 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CHANGED(nmi_reset,0) PORT_NAME("NMI reset") |
| r13654 | r13655 | |
| 2494 | 2489 | } |
| 2495 | 2490 | #endif |
| 2496 | 2491 | |
| 2497 | | static TIMER_DEVICE_CALLBACK(keyboard_callback) |
| 2492 | TIMER_DEVICE_CALLBACK(x1_keyboard_callback) |
| 2498 | 2493 | { |
| 2499 | 2494 | x1_state *state = timer.machine().driver_data<x1_state>(); |
| 2500 | 2495 | address_space *space = timer.machine().device("maincpu")->memory().space(AS_PROGRAM); |
| r13654 | r13655 | |
| 2512 | 2507 | if((key1 != state->m_old_key1) || (key2 != state->m_old_key2) || (key3 != state->m_old_key3) || (key4 != state->m_old_key4) || (f_key != state->m_old_fkey)) |
| 2513 | 2508 | { |
| 2514 | 2509 | // generate keyboard IRQ |
| 2515 | | sub_io_w(space,0,0xe6); |
| 2510 | x1_sub_io_w(space,0,0xe6); |
| 2516 | 2511 | state->m_irq_vector = state->m_key_irq_vector; |
| 2517 | 2512 | state->m_key_irq_flag = 1; |
| 2518 | 2513 | cputag_set_input_line(timer.machine(),"maincpu",0,ASSERT_LINE); |
| r13654 | r13655 | |
| 2525 | 2520 | } |
| 2526 | 2521 | } |
| 2527 | 2522 | |
| 2528 | | static TIMER_CALLBACK(x1_rtc_increment) |
| 2523 | TIMER_CALLBACK(x1_rtc_increment) |
| 2529 | 2524 | { |
| 2530 | 2525 | x1_state *state = machine.driver_data<x1_state>(); |
| 2531 | 2526 | static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; |
| r13654 | r13655 | |
| 2553 | 2548 | if((state->m_rtc.year & 0xf0) >= 0xa0) { state->m_rtc.year = 0; } //roll over |
| 2554 | 2549 | } |
| 2555 | 2550 | |
| 2556 | | static MACHINE_RESET( x1 ) |
| 2551 | MACHINE_RESET( x1 ) |
| 2557 | 2552 | { |
| 2558 | 2553 | x1_state *state = machine.driver_data<x1_state>(); |
| 2559 | 2554 | //UINT8 *ROM = machine.region("maincpu")->base(); |
| r13654 | r13655 | |
| 2599 | 2594 | // state->m_old_vpos = -1; |
| 2600 | 2595 | } |
| 2601 | 2596 | |
| 2602 | | static MACHINE_RESET( x1turbo ) |
| 2597 | MACHINE_RESET( x1turbo ) |
| 2603 | 2598 | { |
| 2604 | 2599 | x1_state *state = machine.driver_data<x1_state>(); |
| 2605 | 2600 | MACHINE_RESET_CALL( x1 ); |
| r13654 | r13655 | |
| 2609 | 2604 | state->m_scrn_reg.blackclip = 0; |
| 2610 | 2605 | } |
| 2611 | 2606 | |
| 2612 | | static MACHINE_START( x1 ) |
| 2607 | MACHINE_START( x1 ) |
| 2613 | 2608 | { |
| 2614 | 2609 | x1_state *state = machine.driver_data<x1_state>(); |
| 2615 | 2610 | |
| r13654 | r13655 | |
| 2630 | 2625 | } |
| 2631 | 2626 | } |
| 2632 | 2627 | |
| 2633 | | static PALETTE_INIT(x1) |
| 2628 | PALETTE_INIT(x1) |
| 2634 | 2629 | { |
| 2635 | 2630 | int i; |
| 2636 | 2631 | |
| r13654 | r13655 | |
| 2684 | 2679 | MCFG_SCREEN_SIZE(640, 480) |
| 2685 | 2680 | MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 2686 | 2681 | MCFG_SCREEN_UPDATE(x1) |
| 2687 | | MCFG_SCREEN_EOF(x1) |
| 2688 | 2682 | |
| 2689 | 2683 | MCFG_MC6845_ADD("crtc", H46505, (VDP_CLOCK/48), mc6845_intf) //unknown divider |
| 2690 | 2684 | MCFG_PALETTE_LENGTH(0x10+0x1000) |
| r13654 | r13655 | |
| 2719 | 2713 | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(x1_floppy_interface) |
| 2720 | 2714 | MCFG_SOFTWARE_LIST_ADD("flop_list","x1_flop") |
| 2721 | 2715 | |
| 2722 | | MCFG_TIMER_ADD_PERIODIC("keyboard_timer", keyboard_callback, attotime::from_hz(250)) |
| 2723 | | MCFG_TIMER_ADD_PERIODIC("cmt_wind_timer", cmt_wind_timer, attotime::from_hz(16)) |
| 2716 | MCFG_TIMER_ADD_PERIODIC("keyboard_timer", x1_keyboard_callback, attotime::from_hz(250)) |
| 2717 | MCFG_TIMER_ADD_PERIODIC("x1_cmt_wind_timer", x1_cmt_wind_timer, attotime::from_hz(16)) |
| 2724 | 2718 | MACHINE_CONFIG_END |
| 2725 | 2719 | |
| 2726 | 2720 | static MACHINE_CONFIG_DERIVED( x1turbo, x1 ) |