src/mess/drivers/x1.c
| r5556 | r5557 | |
| 12 | 12 | - Implement the interrupts (uses IM 2), basically used by the keyboard. |
| 13 | 13 | - Implement DMA (X1Turbo only?) |
| 14 | 14 | - clean-ups! |
| 15 | - x1turbo: understand how irq generation works for the ym-2151; |
| 15 | 16 | - There are various unclear video things, these are: |
| 16 | 17 | - Understand why some games still doesn't upload the proper PCG index; |
| 17 | 18 | - Support the alternative PCG upload mode; |
| r5556 | r5557 | |
| 145 | 146 | #include "machine/8255ppi.h" |
| 146 | 147 | #include "sound/ay8910.h" |
| 147 | 148 | #include "video/mc6845.h" |
| 149 | #include "sound/2151intf.h" |
| 150 | |
| 148 | 151 | #include "machine/wd17xx.h" |
| 149 | 152 | #include "devices/basicdsk.h" |
| 150 | 153 | #include "includes/d88.h" |
| r5556 | r5557 | |
| 632 | 635 | return 0xff; |
| 633 | 636 | } |
| 634 | 637 | |
| 635 | | static READ8_HANDLER( x1_io_r ) |
| 636 | | { |
| 637 | | io_bank_mode = 0; //any read disables the extended mode. |
| 638 | | |
| 639 | | if(offset == 0x0000) { return x1_clr_r(space, 0); } |
| 640 | | else if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x0704); } |
| 641 | | else if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| 642 | | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 643 | | else if(offset >= 0x1900 && offset <= 0x19ff) { return sub_io_r(space, 0); } |
| 644 | | else if(offset >= 0x1a00 && offset <= 0x1aff) { return ppi8255_r(devtag_get_device(space->machine, "ppi8255_0"), (offset-0x1a00) & 3); } |
| 645 | | else if(offset >= 0x1b00 && offset <= 0x1bff) { return ay8910_r(devtag_get_device(space->machine, "ay"), 0); } |
| 646 | | // else if(offset >= 0x1f90 && offset <= 0x1f93) { return x1_sio_r(space,(offset-0x1f90) & 3); } |
| 647 | | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa3); } |
| 648 | | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa8); } |
| 649 | | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 650 | | else if(offset >= 0x2000 && offset <= 0x2fff) { return colorram[offset-0x2000]; } |
| 651 | | else if(offset >= 0x3000 && offset <= 0x3fff) { return videoram[offset-0x3000]; } |
| 652 | | else if(offset >= 0x4000 && offset <= 0xffff) { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; } |
| 653 | | else |
| 654 | | { |
| 655 | | logerror("(PC=%06x) Read i/o address %04x\n",cpu_get_pc(space->cpu),offset); |
| 656 | | } |
| 657 | | return 0xff; |
| 658 | | } |
| 659 | | |
| 660 | 638 | static WRITE8_HANDLER( x1_ex_gfxram_w ) |
| 661 | 639 | { |
| 662 | 640 | static UINT8 ex_mask; |
| r5556 | r5557 | |
| 702 | 680 | } |
| 703 | 681 | } |
| 704 | 682 | |
| 683 | static READ8_HANDLER( x1_io_r ) |
| 684 | { |
| 685 | io_bank_mode = 0; //any read disables the extended mode. |
| 686 | |
| 687 | if(offset == 0x0000) { return x1_clr_r(space, 0); } |
| 688 | else if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x0704); } |
| 689 | else if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| 690 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 691 | else if(offset >= 0x1900 && offset <= 0x19ff) { return sub_io_r(space, 0); } |
| 692 | else if(offset >= 0x1a00 && offset <= 0x1aff) { return ppi8255_r(devtag_get_device(space->machine, "ppi8255_0"), (offset-0x1a00) & 3); } |
| 693 | else if(offset >= 0x1b00 && offset <= 0x1bff) { return ay8910_r(devtag_get_device(space->machine, "ay"), 0); } |
| 694 | // else if(offset >= 0x1f90 && offset <= 0x1f93) { return x1_sio_r(space,(offset-0x1f90) & 3); } |
| 695 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa3); } |
| 696 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa8); } |
| 697 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 698 | else if(offset >= 0x2000 && offset <= 0x2fff) { return colorram[offset-0x2000]; } |
| 699 | else if(offset >= 0x3000 && offset <= 0x3fff) { return videoram[offset-0x3000]; } |
| 700 | else if(offset >= 0x4000 && offset <= 0xffff) { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; } |
| 701 | else |
| 702 | { |
| 703 | logerror("(PC=%06x) Read i/o address %04x\n",cpu_get_pc(space->cpu),offset); |
| 704 | } |
| 705 | return 0xff; |
| 706 | } |
| 707 | |
| 705 | 708 | static WRITE8_HANDLER( x1_io_w ) |
| 706 | 709 | { |
| 707 | 710 | if(io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| r5556 | r5557 | |
| 736 | 739 | } |
| 737 | 740 | } |
| 738 | 741 | |
| 742 | static READ8_HANDLER( x1turbo_io_r ) |
| 743 | { |
| 744 | io_bank_mode = 0; //any read disables the extended mode. |
| 745 | |
| 746 | if(offset == 0x0000) { return x1_clr_r(space, 0); } |
| 747 | else if(offset == 0x0700 || offset == 0x0701) { return ym2151_r(devtag_get_device(space->machine, "ym"), offset-0x0700); } |
| 748 | else if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x0704); } |
| 749 | else if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| 750 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { return x1_fdc_r(space, offset-0xff8); } |
| 751 | else if(offset >= 0x1900 && offset <= 0x19ff) { return sub_io_r(space, 0); } |
| 752 | else if(offset >= 0x1a00 && offset <= 0x1aff) { return ppi8255_r(devtag_get_device(space->machine, "ppi8255_0"), (offset-0x1a00) & 3); } |
| 753 | else if(offset >= 0x1b00 && offset <= 0x1bff) { return ay8910_r(devtag_get_device(space->machine, "ay"), 0); } |
| 754 | // else if(offset >= 0x1f90 && offset <= 0x1f93) { return x1_sio_r(space,(offset-0x1f90) & 3); } |
| 755 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa3); } |
| 756 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa8); } |
| 757 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 758 | else if(offset >= 0x2000 && offset <= 0x2fff) { return colorram[offset-0x2000]; } |
| 759 | else if(offset >= 0x3000 && offset <= 0x3fff) { return videoram[offset-0x3000]; } |
| 760 | else if(offset >= 0x4000 && offset <= 0xffff) { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; } |
| 761 | else |
| 762 | { |
| 763 | logerror("(PC=%06x) Read i/o address %04x\n",cpu_get_pc(space->cpu),offset); |
| 764 | } |
| 765 | return 0xff; |
| 766 | } |
| 767 | |
| 768 | static WRITE8_HANDLER( x1turbo_io_w ) |
| 769 | { |
| 770 | if(io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 771 | else if(offset == 0x0700 || offset == 0x0701) { ym2151_w(devtag_get_device(space->machine, "ym"), offset-0x0700,data); } |
| 772 | else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x0704,data); } |
| 773 | // else if(offset >= 0x0c00 && offset <= 0x0cff) { x1_rs232c_w(space->machine, 0, data); } |
| 774 | else if(offset >= 0x0e00 && offset <= 0x0e02) { x1_rom_w(space, offset-0xe00,data); } |
| 775 | // else if(offset >= 0x0e80 && offset <= 0x0e82) { x1_kanji_w(space->machine, offset-0xe80,data); } |
| 776 | else if(offset >= 0x0ff8 && offset <= 0x0fff) { x1_fdc_w(space, offset-0xff8,data); } |
| 777 | else if(offset >= 0x1000 && offset <= 0x10ff) { x1_pal_b_w(space, 0,data); } |
| 778 | else if(offset >= 0x1100 && offset <= 0x11ff) { x1_pal_r_w(space, 0,data); } |
| 779 | else if(offset >= 0x1200 && offset <= 0x12ff) { x1_pal_g_w(space, 0,data); } |
| 780 | else if(offset >= 0x1300 && offset <= 0x13ff) { x1_ply_w(space, 0,data); } |
| 781 | else if(offset >= 0x1400 && offset <= 0x17ff) { x1_pcg_w(space, offset-0x1400,data); } |
| 782 | else if(offset == 0x1800 || offset == 0x1801) { x1_6845_w(space, offset-0x1800, data); } |
| 783 | else if(offset >= 0x1900 && offset <= 0x19ff) { sub_io_w(space, 0,data); } |
| 784 | else if(offset >= 0x1a00 && offset <= 0x1aff) { ppi8255_w(devtag_get_device(space->machine, "ppi8255_0"), (offset-0x1a00) & 3,data); } |
| 785 | else if(offset >= 0x1b00 && offset <= 0x1bff) { ay8910_data_w(devtag_get_device(space->machine, "ay"), 0,data); } |
| 786 | else if(offset >= 0x1c00 && offset <= 0x1cff) { ay8910_address_w(devtag_get_device(space->machine, "ay"), 0,data); } |
| 787 | else if(offset >= 0x1d00 && offset <= 0x1dff) { rom_bank_1_w(space,0,data); } |
| 788 | else if(offset >= 0x1e00 && offset <= 0x1eff) { rom_bank_0_w(space,0,data); } |
| 789 | else if(offset >= 0x1f80 && offset <= 0x1f8f) { x1_dma_w(space,offset-0x1f80,data); } |
| 790 | // else if(offset >= 0x1f90 && offset <= 0x1f93) { x1_sio_w(space->machine,(offset-0x1f90) & 3),data; } |
| 791 | else if(offset >= 0x1fa0 && offset <= 0x1fa3) { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa3,data); } |
| 792 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa8,data); } |
| 793 | else if(offset >= 0x1fd0 && offset <= 0x1fdf) { x1_scrn_w(space,0,data); } |
| 794 | else if(offset >= 0x2000 && offset <= 0x2fff) { colorram[offset-0x2000] = data; } |
| 795 | else if(offset >= 0x3000 && offset <= 0x3fff) { videoram[offset-0x3000] = data; } |
| 796 | else if(offset >= 0x4000 && offset <= 0xffff) { gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)] = data; } |
| 797 | else |
| 798 | { |
| 799 | logerror("(PC=%06x) Write %02x at i/o address %04x\n",cpu_get_pc(space->cpu),data,offset); |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | |
| 739 | 804 | static ADDRESS_MAP_START( x1_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 740 | 805 | ADDRESS_MAP_UNMAP_HIGH |
| 741 | 806 | AM_RANGE(0x0000, 0x7fff) AM_ROMBANK(1) AM_WRITE(rom_data_w) |
| r5556 | r5557 | |
| 747 | 812 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(x1_io_r, x1_io_w) |
| 748 | 813 | ADDRESS_MAP_END |
| 749 | 814 | |
| 815 | static ADDRESS_MAP_START( x1turbo_io , ADDRESS_SPACE_IO, 8 ) |
| 816 | ADDRESS_MAP_UNMAP_HIGH |
| 817 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(x1turbo_io_r, x1turbo_io_w) |
| 818 | ADDRESS_MAP_END |
| 819 | |
| 750 | 820 | static const gfx_layout x1_chars_8x8 = |
| 751 | 821 | { |
| 752 | 822 | 8,8, |
| r5556 | r5557 | |
| 1309 | 1379 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1310 | 1380 | MACHINE_DRIVER_END |
| 1311 | 1381 | |
| 1382 | static MACHINE_DRIVER_START( x1turbo ) |
| 1383 | MDRV_IMPORT_FROM( x1 ) |
| 1384 | |
| 1385 | MDRV_CPU_MODIFY("maincpu") |
| 1386 | MDRV_CPU_IO_MAP(x1turbo_io) |
| 1387 | |
| 1388 | MDRV_SOUND_ADD("ym", YM2151, XTAL_4MHz/4) //unknown clock / divider |
| 1389 | // MDRV_SOUND_CONFIG(ay8910_config) |
| 1390 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1391 | MACHINE_DRIVER_END |
| 1392 | |
| 1312 | 1393 | static DEVICE_IMAGE_LOAD( x1_floppy ) |
| 1313 | 1394 | { |
| 1314 | 1395 | const char *ext; |
| r5556 | r5557 | |
| 1399 | 1480 | ROM_REGION(0x1000, "mcu", ROMREGION_ERASEFF) //MCU for the Keyboard, "sub cpu" |
| 1400 | 1481 | ROM_LOAD( "80c48", 0x0000, 0x1000, NO_DUMP ) |
| 1401 | 1482 | |
| 1402 | | ROM_REGION(0xc00, "pcg", ROMREGION_ERASEFF) |
| 1483 | ROM_REGION(0x1800, "pcg", ROMREGION_ERASEFF) |
| 1403 | 1484 | |
| 1404 | 1485 | ROM_REGION(0x1800, "cgrom", 0) |
| 1405 | 1486 | ROM_LOAD("fnt0808.x1", 0x00000, 0x00800, CRC(e3995a57) SHA1(1c1a0d8c9f4c446ccd7470516b215ddca5052fb2) ) |
| r5556 | r5557 | |
| 1418 | 1499 | ROM_REGION(0x1000, "mcu", ROMREGION_ERASEFF) //MCU for the Keyboard, "sub cpu" |
| 1419 | 1500 | ROM_LOAD( "80c48", 0x0000, 0x1000, NO_DUMP ) |
| 1420 | 1501 | |
| 1421 | | ROM_REGION(0xc00, "pcg", ROMREGION_ERASEFF) |
| 1502 | ROM_REGION(0x1800, "pcg", ROMREGION_ERASEFF) |
| 1422 | 1503 | |
| 1423 | 1504 | ROM_REGION(0x1800, "cgrom", 0) |
| 1424 | 1505 | /* This should be larger... hence, we are missing something (maybe part of the other fnt roms?) */ |
| 1425 | | ROM_LOAD("fnt0808.x1", 0x00000, 0x0800, CRC(84a47530) SHA1(06c0995adc7a6609d4272417fe3570ca43bd0454) ) |
| 1506 | ROM_LOAD("fnt0808.x1", 0x00000, 0x00800, CRC(84a47530) SHA1(06c0995adc7a6609d4272417fe3570ca43bd0454) ) |
| 1426 | 1507 | ROM_RELOAD( 0x00800, 0x00800) |
| 1427 | 1508 | ROM_RELOAD( 0x01000, 0x00800) |
| 1428 | 1509 | |
| r5556 | r5557 | |
| 1441 | 1522 | ROM_REGION(0x1000, "mcu", ROMREGION_ERASEFF) //MCU for the Keyboard, "sub cpu" |
| 1442 | 1523 | ROM_LOAD( "80c48", 0x0000, 0x1000, NO_DUMP ) |
| 1443 | 1524 | |
| 1444 | | ROM_REGION(0xc00, "pcg", ROMREGION_ERASEFF) |
| 1525 | ROM_REGION(0x1800, "pcg", ROMREGION_ERASEFF) |
| 1445 | 1526 | |
| 1446 | | ROM_REGION(0x4c600, "cgrom", 0) |
| 1527 | ROM_REGION(0x4d600, "cgrom", 0) |
| 1447 | 1528 | ROM_LOAD("fnt0808.x1", 0x0000, 0x0800, CRC(84a47530) SHA1(06c0995adc7a6609d4272417fe3570ca43bd0454) ) |
| 1529 | ROM_RELOAD( 0x00800, 0x00800) |
| 1530 | ROM_RELOAD( 0x01000, 0x00800) |
| 1448 | 1531 | ROM_SYSTEM_BIOS( 0, "font1", "Font set 1" ) |
| 1449 | | ROMX_LOAD("fnt0816.x1", 0x0800, 0x1000, BAD_DUMP CRC(34818d54) SHA1(2c5fdd73249421af5509e48a94c52c4e423402bf), ROM_BIOS(1) ) |
| 1532 | ROMX_LOAD("fnt0816.x1", 0x1800, 0x1000, BAD_DUMP CRC(34818d54) SHA1(2c5fdd73249421af5509e48a94c52c4e423402bf), ROM_BIOS(1) ) |
| 1450 | 1533 | /* I strongly suspect this is not genuine */ |
| 1451 | | ROMX_LOAD("fnt1616.x1", 0x01800, 0x4ac00, BAD_DUMP CRC(46826745) SHA1(b9e6c320611f0842df6f45673c47c3e23bc14272), ROM_BIOS(1) ) |
| 1534 | ROMX_LOAD("fnt1616.x1", 0x02800, 0x4ac00, BAD_DUMP CRC(46826745) SHA1(b9e6c320611f0842df6f45673c47c3e23bc14272), ROM_BIOS(1) ) |
| 1452 | 1535 | ROM_SYSTEM_BIOS( 1, "font2", "Font set 2" ) |
| 1453 | | ROMX_LOAD("fnt0816_a.x1", 0x0800, 0x1000, BAD_DUMP CRC(98db5a6b) SHA1(adf1492ef326b0f8820a3caa1915ad5ab8138f49), ROM_BIOS(2) ) |
| 1536 | ROMX_LOAD("fnt0816_a.x1", 0x01800, 0x1000, BAD_DUMP CRC(98db5a6b) SHA1(adf1492ef326b0f8820a3caa1915ad5ab8138f49), ROM_BIOS(2) ) |
| 1454 | 1537 | /* I strongly suspect this is not genuine */ |
| 1455 | | ROMX_LOAD("fnt1616_a.x1", 0x01800, 0x4ac00, BAD_DUMP CRC(bc5689ae) SHA1(a414116e261eb92bbdd407f63c8513257cd5a86f), ROM_BIOS(2) ) |
| 1538 | ROMX_LOAD("fnt1616_a.x1", 0x02800, 0x4ac00, BAD_DUMP CRC(bc5689ae) SHA1(a414116e261eb92bbdd407f63c8513257cd5a86f), ROM_BIOS(2) ) |
| 1456 | 1539 | |
| 1457 | 1540 | ROM_REGION(0x4ac00, "kanji", 0) |
| 1458 | 1541 | /* This is clearly a bad dump: size does not make sense and from 0x28000 on there are only 0xff */ |
| r5556 | r5557 | |
| 1465 | 1548 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 1466 | 1549 | COMP( 1982, x1, 0, 0, x1, x1, 0, x1, "Sharp", "X1 (CZ-800C)", GAME_NOT_WORKING) |
| 1467 | 1550 | COMP( 1984, x1ck, x1, 0, x1, x1, 0, x1, "Sharp", "X1Ck (CZ-804C)", GAME_NOT_WORKING) |
| 1468 | | COMP( 1984, x1turbo, x1, 0, x1, x1, 0, x1, "Sharp", "X1 Turbo (CZ-850C)", GAME_NOT_WORKING) |
| 1469 | | COMP( 1986, x1turboz, x1, 0, x1, x1, 0, x1, "Sharp", "X1 Turbo Z (CZ-880C)", GAME_NOT_WORKING) |
| 1551 | COMP( 1984, x1turbo, x1, 0, x1turbo, x1, 0, x1, "Sharp", "X1 Turbo (CZ-850C)", GAME_NOT_WORKING) |
| 1552 | COMP( 1986, x1turboz, x1, 0, x1turbo, x1, 0, x1, "Sharp", "X1 Turbo Z (CZ-880C)", GAME_NOT_WORKING) |