src/mess/machine/coco.c
| r3692 | r3693 | |
| 208 | 208 | #define GIME_TYPE_1987 0 |
| 209 | 209 | |
| 210 | 210 | #ifdef MAME_DEBUG |
| 211 | | static offs_t coco_dasm_override(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); |
| 211 | static offs_t coco_dasm_override(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); |
| 212 | 212 | #endif /* MAME_DEBUG */ |
| 213 | 213 | |
| 214 | 214 | |
| r3692 | r3693 | |
| 455 | 455 | return 0; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | | static void pak_load_trailer(const pak_decodedtrailer *trailer) |
| 458 | static void pak_load_trailer(running_machine *machine, const pak_decodedtrailer *trailer) |
| 459 | 459 | { |
| 460 | 460 | cpu_set_reg(machine->cpu[0], M6809_PC, trailer->reg_pc); |
| 461 | 461 | cpu_set_reg(machine->cpu[0], M6809_X, trailer->reg_x); |
| r3692 | r3693 | |
| 586 | 586 | memcpy(pakbase, rambase + 0xC000, 0x3F00); |
| 587 | 587 | |
| 588 | 588 | if (trailer_load) |
| 589 | | pak_load_trailer(&trailer); |
| 589 | pak_load_trailer(Machine, &trailer); |
| 590 | 590 | return INIT_PASS; |
| 591 | 591 | } |
| 592 | 592 | |
| r3692 | r3693 | |
| 630 | 630 | if (preamble != 0) |
| 631 | 631 | { |
| 632 | 632 | /* start address - just set the address and return */ |
| 633 | | cpu_set_reg(machine->cpu[0], REG_PC, block_address); |
| 633 | cpu_set_reg(image->machine->cpu[0], REG_PC, block_address); |
| 634 | 634 | done = TRUE; |
| 635 | 635 | } |
| 636 | 636 | else |
| 637 | 637 | { |
| 638 | const address_space *space = cpu_get_address_space( image->machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 639 | |
| 638 | 640 | /* data block - need to cap the maximum length of the block */ |
| 639 | 641 | block_length = MIN(block_length, length - position); |
| 640 | 642 | |
| r3692 | r3693 | |
| 781 | 783 | UINT8 pia0_irq_b = pia_get_irq_b(0); |
| 782 | 784 | |
| 783 | 785 | if (pia0_irq_a || pia0_irq_b) |
| 784 | | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, ASSERT_LINE); |
| 786 | cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, ASSERT_LINE); |
| 785 | 787 | else |
| 786 | | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, CLEAR_LINE); |
| 788 | cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, CLEAR_LINE); |
| 787 | 789 | } |
| 788 | 790 | |
| 789 | 791 | static void d_recalc_firq(running_machine *machine) |
| r3692 | r3693 | |
| 794 | 796 | UINT8 pia2_firq_b = pia_get_irq_b(2); |
| 795 | 797 | |
| 796 | 798 | if (pia1_firq_a || pia1_firq_b || pia2_firq_a || pia2_firq_b) |
| 797 | | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, ASSERT_LINE); |
| 799 | cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, ASSERT_LINE); |
| 798 | 800 | else |
| 799 | | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, CLEAR_LINE); |
| 801 | cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, CLEAR_LINE); |
| 800 | 802 | } |
| 801 | 803 | |
| 802 | 804 | static void coco3_recalc_irq(running_machine *machine) |
| 803 | 805 | { |
| 804 | 806 | if ((coco3_gimereg[0] & 0x20) && gime_irq) |
| 805 | | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, ASSERT_LINE); |
| 807 | cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, ASSERT_LINE); |
| 806 | 808 | else |
| 807 | 809 | d_recalc_irq(machine); |
| 808 | 810 | } |
| r3692 | r3693 | |
| 810 | 812 | static void coco3_recalc_firq(running_machine *machine) |
| 811 | 813 | { |
| 812 | 814 | if ((coco3_gimereg[0] & 0x10) && gime_firq) |
| 813 | | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, ASSERT_LINE); |
| 815 | cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, ASSERT_LINE); |
| 814 | 816 | else |
| 815 | 817 | d_recalc_firq(machine); |
| 816 | 818 | } |
| r3692 | r3693 | |
| 902 | 904 | |
| 903 | 905 | void coco3_horizontal_sync_callback(int data) |
| 904 | 906 | { |
| 905 | | pia_0_ca1_w(Machine, 0, data); |
| 907 | const address_space *space = cpu_get_address_space( Machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 908 | |
| 909 | pia_0_ca1_w(space, 0, data); |
| 906 | 910 | coco3_raise_interrupt(Machine, COCO3_INT_HBORD, data); |
| 907 | 911 | } |
| 908 | 912 | |
| r3692 | r3693 | |
| 910 | 914 | |
| 911 | 915 | void coco3_field_sync_callback(int data) |
| 912 | 916 | { |
| 913 | | pia_0_cb1_w(Machine, 0, data); |
| 917 | const address_space *space = cpu_get_address_space( Machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 918 | |
| 919 | pia_0_cb1_w(space, 0, data); |
| 914 | 920 | } |
| 915 | 921 | |
| 916 | 922 | void coco3_gime_field_sync_callback(running_machine *machine) |
| r3692 | r3693 | |
| 1413 | 1419 | |
| 1414 | 1420 | |
| 1415 | 1421 | /* three functions that update the keyboard in varying ways */ |
| 1416 | | static WRITE8_HANDLER ( d_pia0_pb_w ) { (*update_keyboard)(machine); } |
| 1422 | static WRITE8_HANDLER ( d_pia0_pb_w ) { (*update_keyboard)(space->machine); } |
| 1417 | 1423 | INPUT_CHANGED(coco_keyboard_changed) { (*update_keyboard)(field->port->machine); } |
| 1418 | 1424 | static TIMER_CALLBACK(coco_update_keyboard_timerproc) { (*update_keyboard)(machine); } |
| 1419 | 1425 | |
| 1420 | 1426 | static WRITE8_HANDLER ( d_pia0_pa_w ) |
| 1421 | 1427 | { |
| 1422 | | if (get_input_device(machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE) |
| 1423 | | coco_hiresjoy_w(machine, data & 0x04); |
| 1428 | if (get_input_device(space->machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE) |
| 1429 | coco_hiresjoy_w(space->machine, data & 0x04); |
| 1424 | 1430 | } |
| 1425 | 1431 | |
| 1426 | 1432 | |
| r3692 | r3693 | |
| 1447 | 1453 | |
| 1448 | 1454 | static WRITE8_HANDLER ( d_pia1_cb2_w ) |
| 1449 | 1455 | { |
| 1450 | | soundmux_update(machine); |
| 1456 | soundmux_update(space->machine); |
| 1451 | 1457 | } |
| 1452 | 1458 | |
| 1453 | 1459 | /* Printer output functions used by d_pia1_pa_w */ |
| r3692 | r3693 | |
| 1483 | 1489 | |
| 1484 | 1490 | coco_sound_update(); |
| 1485 | 1491 | |
| 1486 | | if (get_input_device(machine, INPUTPORT_SERIAL) == INPUTDEVICE_DIECOM_LIGHTGUN) |
| 1492 | if (get_input_device(space->machine, INPUTPORT_SERIAL) == INPUTDEVICE_DIECOM_LIGHTGUN) |
| 1487 | 1493 | { |
| 1488 | 1494 | int dclg_this_bit = ((data & 2) >> 1); |
| 1489 | 1495 | |
| r3692 | r3693 | |
| 1526 | 1532 | } |
| 1527 | 1533 | else |
| 1528 | 1534 | { |
| 1529 | | cassette_output(cassette_device_image(machine), ((int) dac - 0x80) / 128.0); |
| 1535 | cassette_output(cassette_device_image(space->machine), ((int) dac - 0x80) / 128.0); |
| 1530 | 1536 | } |
| 1531 | 1537 | |
| 1532 | | (*update_keyboard)(machine); |
| 1538 | (*update_keyboard)(space->machine); |
| 1533 | 1539 | |
| 1534 | | if (get_input_device(machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_INTERFACE) |
| 1535 | | coco_hiresjoy_w(machine, dac >= 0x80); |
| 1540 | if (get_input_device(space->machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_INTERFACE) |
| 1541 | coco_hiresjoy_w(space->machine, dac >= 0x80); |
| 1536 | 1542 | |
| 1537 | 1543 | /* Handle printer output, serial for CoCos, Paralell for Dragons */ |
| 1538 | 1544 | |
| r3692 | r3693 | |
| 1564 | 1570 | { |
| 1565 | 1571 | int ddr; |
| 1566 | 1572 | |
| 1567 | | d_pia1_pb_w(machine, 0, data); |
| 1573 | d_pia1_pb_w(space, 0, data); |
| 1568 | 1574 | |
| 1569 | 1575 | ddr = ~pia_get_port_b_z_mask(1); |
| 1570 | 1576 | |
| r3692 | r3693 | |
| 1574 | 1580 | /* always be high (enabling 32k basic rom) */ |
| 1575 | 1581 | if (ddr & 0x04) |
| 1576 | 1582 | { |
| 1577 | | dragon_page_rom(machine, data & 0x04); |
| 1583 | dragon_page_rom(space->machine, data & 0x04); |
| 1578 | 1584 | } |
| 1579 | 1585 | } |
| 1580 | 1586 | |
| r3692 | r3693 | |
| 1599 | 1605 | /* always be high (enabling boot rom) */ |
| 1600 | 1606 | /* PIA FIXME if (pia_get_ddr_a(2) & 0x04) */ |
| 1601 | 1607 | { |
| 1602 | | dragon_page_rom(machine, data & 0x04); /* bit 2 controls boot or basic rom */ |
| 1608 | dragon_page_rom(space->machine, data & 0x04); /* bit 2 controls boot or basic rom */ |
| 1603 | 1609 | } |
| 1604 | 1610 | |
| 1605 | 1611 | /* Bits 0 and 1 for pia2 port a control the BCDIR and BC1 lines of the */ |
| r3692 | r3693 | |
| 1611 | 1617 | case 0x00 : /* Inactive, do nothing */ |
| 1612 | 1618 | break; |
| 1613 | 1619 | case 0x01 : /* Write to selected port */ |
| 1614 | | ay8910_write_port_0_w(machine, 0, pia_get_output_b(2)); |
| 1620 | ay8910_write_port_0_w(space, 0, pia_get_output_b(2)); |
| 1615 | 1621 | break; |
| 1616 | 1622 | case 0x02 : /* Read from selected port */ |
| 1617 | | pia_set_input_b(2, ay8910_read_port_0_r(machine, 0)); |
| 1623 | pia_set_input_b(2, ay8910_read_port_0_r(space, 0)); |
| 1618 | 1624 | break; |
| 1619 | 1625 | case 0x03 : /* Select port to write to */ |
| 1620 | | ay8910_control_port_0_w(machine, 0, pia_get_output_b(2)); |
| 1626 | ay8910_control_port_0_w(space, 0, pia_get_output_b(2)); |
| 1621 | 1627 | break; |
| 1622 | 1628 | } |
| 1623 | 1629 | } |
| r3692 | r3693 | |
| 1649 | 1655 | /* The NMI line on the alphaAlpha is gated through IC16 (early PLD), and is gated by pia2 CA2 */ |
| 1650 | 1656 | /* The DRQ line goes through pia2 cb1, in exactly the same way as DRQ from DragonDos does */ |
| 1651 | 1657 | /* for pia1 cb1 */ |
| 1658 | |
| 1659 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 1660 | |
| 1652 | 1661 | switch(event) |
| 1653 | 1662 | { |
| 1654 | 1663 | case WD17XX_IRQ_CLR: |
| 1655 | | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, CLEAR_LINE); |
| 1664 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE); |
| 1656 | 1665 | break; |
| 1657 | 1666 | case WD17XX_IRQ_SET: |
| 1658 | 1667 | if(dgnalpha_just_reset) |
| r3692 | r3693 | |
| 1662 | 1671 | else |
| 1663 | 1672 | { |
| 1664 | 1673 | if (pia_get_output_ca2_z(2)) |
| 1665 | | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, ASSERT_LINE); |
| 1674 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, ASSERT_LINE); |
| 1666 | 1675 | } |
| 1667 | 1676 | break; |
| 1668 | 1677 | case WD17XX_DRQ_CLR: |
| 1669 | | pia_2_cb1_w(machine, 0, CARTLINE_CLEAR); |
| 1678 | pia_2_cb1_w(space, 0, CARTLINE_CLEAR); |
| 1670 | 1679 | break; |
| 1671 | 1680 | case WD17XX_DRQ_SET: |
| 1672 | | pia_2_cb1_w(machine, 0, CARTLINE_ASSERTED); |
| 1681 | pia_2_cb1_w(space, 0, CARTLINE_ASSERTED); |
| 1673 | 1682 | break; |
| 1674 | 1683 | } |
| 1675 | 1684 | } |
| r3692 | r3693 | |
| 1682 | 1691 | switch(offset & 0x03) |
| 1683 | 1692 | { |
| 1684 | 1693 | case 0: |
| 1685 | | result = wd17xx_data_r(machine, 0); |
| 1694 | result = wd17xx_data_r(space, 0); |
| 1686 | 1695 | break; |
| 1687 | 1696 | case 1: |
| 1688 | | result = wd17xx_sector_r(machine, 0); |
| 1697 | result = wd17xx_sector_r(space, 0); |
| 1689 | 1698 | break; |
| 1690 | 1699 | case 2: |
| 1691 | | result = wd17xx_track_r(machine, 0); |
| 1700 | result = wd17xx_track_r(space, 0); |
| 1692 | 1701 | break; |
| 1693 | 1702 | case 3: |
| 1694 | | result = wd17xx_status_r(machine, 0); |
| 1703 | result = wd17xx_status_r(space, 0); |
| 1695 | 1704 | break; |
| 1696 | 1705 | default: |
| 1697 | 1706 | break; |
| r3692 | r3693 | |
| 1705 | 1714 | switch(offset & 0x3) |
| 1706 | 1715 | { |
| 1707 | 1716 | case 0: |
| 1708 | | wd17xx_data_w(machine, 0, data); |
| 1717 | wd17xx_data_w(space, 0, data); |
| 1709 | 1718 | break; |
| 1710 | 1719 | case 1: |
| 1711 | | wd17xx_sector_w(machine, 0, data); |
| 1720 | wd17xx_sector_w(space, 0, data); |
| 1712 | 1721 | break; |
| 1713 | 1722 | case 2: |
| 1714 | | wd17xx_track_w(machine, 0, data); |
| 1723 | wd17xx_track_w(space, 0, data); |
| 1715 | 1724 | break; |
| 1716 | 1725 | case 3: |
| 1717 | | wd17xx_command_w(machine, 0, data); |
| 1726 | wd17xx_command_w(space, 0, data); |
| 1718 | 1727 | |
| 1719 | 1728 | /* disk head is encoded in the command byte */ |
| 1720 | 1729 | wd17xx_set_side((data & 0x02) ? 1 : 0); |
| r3692 | r3693 | |
| 1734 | 1743 | static WRITE8_HANDLER ( d_pia1_ca2_w ) |
| 1735 | 1744 | { |
| 1736 | 1745 | cassette_change_state( |
| 1737 | | cassette_device_image(machine), |
| 1746 | cassette_device_image(space->machine), |
| 1738 | 1747 | data ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, |
| 1739 | 1748 | CASSETTE_MASK_MOTOR); |
| 1740 | 1749 | } |
| r3692 | r3693 | |
| 1743 | 1752 | |
| 1744 | 1753 | static READ8_HANDLER ( d_pia1_pa_r ) |
| 1745 | 1754 | { |
| 1746 | | return (cassette_input(cassette_device_image(machine)) >= 0) ? 1 : 0; |
| 1755 | return (cassette_input(cassette_device_image(space->machine)) >= 0) ? 1 : 0; |
| 1747 | 1756 | } |
| 1748 | 1757 | |
| 1749 | 1758 | |
| r3692 | r3693 | |
| 1847 | 1856 | default : bottom_32k=&mess_ram[0x00000]; break; // Just to shut the compiler up ! |
| 1848 | 1857 | } |
| 1849 | 1858 | |
| 1850 | | setup_memory_map(machine); |
| 1859 | setup_memory_map(space->machine); |
| 1851 | 1860 | } |
| 1852 | 1861 | |
| 1853 | 1862 | |
| r3692 | r3693 | |
| 1880 | 1889 | * TODO: Make the overclock more accurate. In dual speed, ROM was a fast |
| 1881 | 1890 | * access but RAM was not. I don't know how to simulate this. |
| 1882 | 1891 | */ |
| 1883 | | cpunum_set_clockscale(Machine, 0, val ? 2 : 1); |
| 1892 | cpu_set_clockscale(Machine->cpu[0], val ? 2 : 1); |
| 1884 | 1893 | } |
| 1885 | 1894 | |
| 1886 | 1895 | READ8_HANDLER(dragon_alpha_mapped_irq_r) |
| r3692 | r3693 | |
| 1940 | 1949 | }; |
| 1941 | 1950 | |
| 1942 | 1951 | /* We need to init these vars from the sam, as this may be called from outside the sam callbacks */ |
| 1952 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 1943 | 1953 | UINT8 memsize = get_sam_memorysize(); |
| 1944 | 1954 | UINT8 maptype = get_sam_maptype(); |
| 1945 | 1955 | // UINT8 pagemode = get_sam_pagemode(); |
| r3692 | r3693 | |
| 1974 | 1984 | { |
| 1975 | 1985 | /* This deals with the bottom 32K page switch and the Dragon Plus paged ram */ |
| 1976 | 1986 | if(block_index<8) |
| 1977 | | memory_set_bankptr(block_index+1,&bottom_32k[memmap[wbank-1].start]); |
| 1987 | memory_set_bankptr(machine, block_index+1,&bottom_32k[memmap[wbank-1].start]); |
| 1978 | 1988 | else |
| 1979 | | memory_set_bankptr(block_index+1,&mess_ram[memmap[wbank-1].start]); |
| 1989 | memory_set_bankptr(machine, block_index+1,&mess_ram[memmap[wbank-1].start]); |
| 1980 | 1990 | |
| 1981 | | memory_install_read_handler(machine, 0, ADDRESS_SPACE_PROGRAM, memmap[block_index].start, memmap[block_index].end, 0, 0, block_index+1); |
| 1982 | | memory_install_write_handler(machine, 0, ADDRESS_SPACE_PROGRAM, memmap[block_index].start, memmap[block_index].end, 0, 0, block_index+1); |
| 1991 | memory_install_read_handler(space, memmap[block_index].start, memmap[block_index].end, 0, 0, block_index+1); |
| 1992 | memory_install_write_handler(space, memmap[block_index].start, memmap[block_index].end, 0, 0, block_index+1); |
| 1983 | 1993 | } |
| 1984 | 1994 | else |
| 1985 | 1995 | { |
| 1986 | | memory_install_read_handler(machine, 0, ADDRESS_SPACE_PROGRAM, memmap[block_index].start, memmap[block_index].end, 0, 0, STATIC_NOP); |
| 1987 | | memory_install_write_handler(machine, 0, ADDRESS_SPACE_PROGRAM, memmap[block_index].start, memmap[block_index].end, 0, 0, STATIC_NOP); |
| 1996 | memory_install_read_handler(space, memmap[block_index].start, memmap[block_index].end, 0, 0, STATIC_NOP); |
| 1997 | memory_install_write_handler(space, memmap[block_index].start, memmap[block_index].end, 0, 0, STATIC_NOP); |
| 1988 | 1998 | } |
| 1989 | 1999 | } |
| 1990 | 2000 | |
| r3692 | r3693 | |
| 2001 | 2011 | else |
| 2002 | 2012 | offset=&coco_rom[0x4000+(0x1000*(block_index-4))]; |
| 2003 | 2013 | |
| 2004 | | memory_set_bankptr(block_index + 9,offset); |
| 2005 | | memory_install_write_handler(machine, 0, ADDRESS_SPACE_PROGRAM, memmap[block_index+8].start, memmap[block_index+8].end, 0, 0, STATIC_NOP); |
| 2014 | memory_set_bankptr(machine, block_index + 9,offset); |
| 2015 | memory_install_write_handler(space, memmap[block_index+8].start, memmap[block_index+8].end, 0, 0, STATIC_NOP); |
| 2006 | 2016 | } |
| 2007 | 2017 | } |
| 2008 | 2018 | } |
| r3692 | r3693 | |
| 2278 | 2288 | { 0xfe00, 0xfeff } |
| 2279 | 2289 | }; |
| 2280 | 2290 | |
| 2291 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 2281 | 2292 | int i, offset, writebank; |
| 2282 | 2293 | UINT8 *readbank; |
| 2283 | 2294 | |
| r3692 | r3693 | |
| 2298 | 2309 | } |
| 2299 | 2310 | |
| 2300 | 2311 | /* set up the banks */ |
| 2301 | | memory_set_bankptr(i + 1, readbank); |
| 2302 | | memory_install_write_handler(machine, 0, ADDRESS_SPACE_PROGRAM, bank_info[i].start, bank_info[i].end, 0, 0, writebank); |
| 2312 | memory_set_bankptr(machine, i + 1, readbank); |
| 2313 | memory_install_write_handler(space, bank_info[i].start, bank_info[i].end, 0, 0, writebank); |
| 2303 | 2314 | |
| 2304 | 2315 | if (LOG_MMU) |
| 2305 | 2316 | { |
| r3692 | r3693 | |
| 2330 | 2341 | if ((offset >> 3) == (coco3_gimereg[1] & 1)) |
| 2331 | 2342 | { |
| 2332 | 2343 | offset &= 7; |
| 2333 | | coco3_mmu_update(machine, offset, (offset == 7) ? 8 : offset); |
| 2344 | coco3_mmu_update(space->machine, offset, (offset == 7) ? 8 : offset); |
| 2334 | 2345 | } |
| 2335 | 2346 | } |
| 2336 | 2347 | |
| r3692 | r3693 | |
| 2349 | 2360 | result = gime_irq; |
| 2350 | 2361 | if (result) { |
| 2351 | 2362 | gime_irq = 0; |
| 2352 | | coco3_recalc_irq(machine); |
| 2363 | coco3_recalc_irq(space->machine); |
| 2353 | 2364 | } |
| 2354 | 2365 | break; |
| 2355 | 2366 | |
| r3692 | r3693 | |
| 2357 | 2368 | result = gime_firq; |
| 2358 | 2369 | if (result) { |
| 2359 | 2370 | gime_firq = 0; |
| 2360 | | coco3_recalc_firq(machine); |
| 2371 | coco3_recalc_firq(space->machine); |
| 2361 | 2372 | } |
| 2362 | 2373 | break; |
| 2363 | 2374 | |
| r3692 | r3693 | |
| 2400 | 2411 | * Bit 1 MC1 ROM map control |
| 2401 | 2412 | * Bit 0 MC0 ROM map control |
| 2402 | 2413 | */ |
| 2403 | | coco3_mmu_update(machine, 0, 8); |
| 2414 | coco3_mmu_update(space->machine, 0, 8); |
| 2404 | 2415 | break; |
| 2405 | 2416 | |
| 2406 | 2417 | case 1: |
| r3692 | r3693 | |
| 2414 | 2425 | * Bit 1 Unused |
| 2415 | 2426 | * Bit 0 TR Task register select |
| 2416 | 2427 | */ |
| 2417 | | coco3_mmu_update(machine, 0, 8); |
| 2428 | coco3_mmu_update(space->machine, 0, 8); |
| 2418 | 2429 | coco3_timer_reset(); |
| 2419 | 2430 | break; |
| 2420 | 2431 | |
| r3692 | r3693 | |
| 2620 | 2631 | READ8_HANDLER(coco3_cartridge_r) |
| 2621 | 2632 | { |
| 2622 | 2633 | /* this behavior is documented in Super Extended Basic Unravelled, page 14 */ |
| 2623 | | return ((coco3_gimereg[0] & 0x04) || (offset >= 0x10)) ? coco_cartridge_r(machine, offset) : 0; |
| 2634 | return ((coco3_gimereg[0] & 0x04) || (offset >= 0x10)) ? coco_cartridge_r(space, offset) : 0; |
| 2624 | 2635 | } |
| 2625 | 2636 | |
| 2626 | 2637 | |
| r3692 | r3693 | |
| 2634 | 2645 | { |
| 2635 | 2646 | /* this behavior is documented in Super Extended Basic Unravelled, page 14 */ |
| 2636 | 2647 | if ((coco3_gimereg[0] & 0x04) || (offset >= 0x10)) |
| 2637 | | coco_cartridge_w(machine, offset, data); |
| 2648 | coco_cartridge_w(space, offset, data); |
| 2638 | 2649 | } |
| 2639 | 2650 | |
| 2640 | 2651 | |
| r3692 | r3693 | |
| 2645 | 2656 | |
| 2646 | 2657 | static void coco_cart_timer_w(running_machine *machine, int data) |
| 2647 | 2658 | { |
| 2648 | | pia_1_cb1_w(machine, 0, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2659 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 2649 | 2660 | |
| 2661 | pia_1_cb1_w(space, 0, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2662 | |
| 2650 | 2663 | /* special code for Q state */ |
| 2651 | 2664 | if ((data == 0x02) || (data == 0x03) || (data == 0x04)) |
| 2652 | 2665 | timer_adjust_oneshot(cart_timer, ATTOTIME_IN_USEC(0), data + 1); |
| r3692 | r3693 | |
| 2687 | 2700 | static TIMER_CALLBACK(halt_timer_proc) |
| 2688 | 2701 | { |
| 2689 | 2702 | int data = param; |
| 2690 | | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2703 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_HALT, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2691 | 2704 | } |
| 2692 | 2705 | |
| 2693 | 2706 | |
| r3692 | r3693 | |
| 2699 | 2712 | static TIMER_CALLBACK(nmi_timer_proc) |
| 2700 | 2713 | { |
| 2701 | 2714 | int data = param; |
| 2702 | | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2715 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2703 | 2716 | } |
| 2704 | 2717 | |
| 2705 | 2718 | |
| r3692 | r3693 | |
| 2795 | 2808 | |
| 2796 | 2809 | WRITE8_HANDLER(coco_pia_1_w) |
| 2797 | 2810 | { |
| 2798 | | pia_1_w(machine, offset, data); |
| 2811 | pia_1_w(space, offset, data); |
| 2799 | 2812 | twiddle_cart_line_if_q(); |
| 2800 | 2813 | } |
| 2801 | 2814 | |
| r3692 | r3693 | |
| 2893 | 2906 | coco_cart = cococart_init(machine, cart_hardware, &cart_config); |
| 2894 | 2907 | |
| 2895 | 2908 | #ifdef MAME_DEBUG |
| 2896 | | cpuintrf_set_dasm_override(0, coco_dasm_override); |
| 2909 | cpu_set_dasm_override(machine->cpu[0], coco_dasm_override); |
| 2897 | 2910 | #endif |
| 2898 | 2911 | |
| 2899 | 2912 | state_save_register_global(mux_sel1); |
| r3692 | r3693 | |
| 3294 | 3307 | }; |
| 3295 | 3308 | |
| 3296 | 3309 | |
| 3297 | | static offs_t coco_dasm_override(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) |
| 3310 | static offs_t coco_dasm_override(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) |
| 3298 | 3311 | { |
| 3299 | 3312 | unsigned call; |
| 3300 | 3313 | unsigned result = 0; |
src/mess/devices/coco_fdc.c
| r3692 | r3693 | |
| 284 | 284 | static UINT8 fdc_coco_r(coco_cartridge *cartridge, UINT16 addr) |
| 285 | 285 | { |
| 286 | 286 | running_machine *machine = Machine; |
| 287 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 287 | 288 | UINT8 result = 0; |
| 288 | 289 | switch(addr & 0xEF) |
| 289 | 290 | { |
| 290 | 291 | case 8: |
| 291 | | result = wd17xx_status_r(machine, 0); |
| 292 | result = wd17xx_status_r(space, 0); |
| 292 | 293 | break; |
| 293 | 294 | case 9: |
| 294 | | result = wd17xx_track_r(machine, 0); |
| 295 | result = wd17xx_track_r(space, 0); |
| 295 | 296 | break; |
| 296 | 297 | case 10: |
| 297 | | result = wd17xx_sector_r(machine, 0); |
| 298 | result = wd17xx_sector_r(space, 0); |
| 298 | 299 | break; |
| 299 | 300 | case 11: |
| 300 | | result = wd17xx_data_r(machine, 0); |
| 301 | result = wd17xx_data_r(space, 0); |
| 301 | 302 | break; |
| 302 | 303 | } |
| 303 | 304 | return result; |
| r3692 | r3693 | |
| 312 | 313 | static void fdc_coco_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 313 | 314 | { |
| 314 | 315 | running_machine *machine = Machine; |
| 316 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 315 | 317 | switch(addr & 0xEF) |
| 316 | 318 | { |
| 317 | 319 | case 0: case 1: case 2: case 3: |
| r3692 | r3693 | |
| 319 | 321 | fdc_coco_dskreg_w(cartridge, data); |
| 320 | 322 | break; |
| 321 | 323 | case 8: |
| 322 | | wd17xx_command_w(machine, 0, data); |
| 324 | wd17xx_command_w(space, 0, data); |
| 323 | 325 | break; |
| 324 | 326 | case 9: |
| 325 | | wd17xx_track_w(machine, 0, data); |
| 327 | wd17xx_track_w(space, 0, data); |
| 326 | 328 | break; |
| 327 | 329 | case 10: |
| 328 | | wd17xx_sector_w(machine, 0, data); |
| 330 | wd17xx_sector_w(space, 0, data); |
| 329 | 331 | break; |
| 330 | 332 | case 11: |
| 331 | | wd17xx_data_w(machine, 0, data); |
| 333 | wd17xx_data_w(space, 0, data); |
| 332 | 334 | break; |
| 333 | 335 | }; |
| 334 | 336 | } |
| r3692 | r3693 | |
| 392 | 394 | { |
| 393 | 395 | const device_config *dev; |
| 394 | 396 | running_machine *machine = Machine; |
| 397 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 395 | 398 | UINT8 result = fdc_coco_r(cartridge, addr); |
| 396 | 399 | |
| 397 | 400 | switch(addr) |
| r3692 | r3693 | |
| 406 | 409 | |
| 407 | 410 | case 0x38: /* FF78 */ |
| 408 | 411 | if (real_time_clock() == RTC_CLOUD9) |
| 409 | | ds1315_r_0(machine, addr); |
| 412 | ds1315_r_0(space, addr); |
| 410 | 413 | break; |
| 411 | 414 | |
| 412 | 415 | case 0x39: /* FF79 */ |
| 413 | 416 | if (real_time_clock() == RTC_CLOUD9) |
| 414 | | ds1315_r_1(machine, addr); |
| 417 | ds1315_r_1(space, addr); |
| 415 | 418 | break; |
| 416 | 419 | |
| 417 | 420 | case 0x3C: /* FF7C */ |
| 418 | 421 | if (real_time_clock() == RTC_CLOUD9) |
| 419 | | result = ds1315_r_data(machine, addr); |
| 422 | result = ds1315_r_data(space, addr); |
| 420 | 423 | break; |
| 421 | 424 | |
| 422 | 425 | case 0x40: |
| r3692 | r3693 | |
| 577 | 580 | static UINT8 fdc_dragon_r(coco_cartridge *cartridge, UINT16 addr) |
| 578 | 581 | { |
| 579 | 582 | running_machine *machine = Machine; |
| 583 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 580 | 584 | UINT8 result = 0; |
| 581 | 585 | switch(addr & 0xEF) |
| 582 | 586 | { |
| 583 | 587 | case 0: |
| 584 | | result = wd17xx_status_r(machine, 0); |
| 588 | result = wd17xx_status_r(space, 0); |
| 585 | 589 | break; |
| 586 | 590 | case 1: |
| 587 | | result = wd17xx_track_r(machine, 0); |
| 591 | result = wd17xx_track_r(space, 0); |
| 588 | 592 | break; |
| 589 | 593 | case 2: |
| 590 | | result = wd17xx_sector_r(machine, 0); |
| 594 | result = wd17xx_sector_r(space, 0); |
| 591 | 595 | break; |
| 592 | 596 | case 3: |
| 593 | | result = wd17xx_data_r(machine, 0); |
| 597 | result = wd17xx_data_r(space, 0); |
| 594 | 598 | break; |
| 595 | 599 | } |
| 596 | 600 | return result; |
| r3692 | r3693 | |
| 605 | 609 | static void fdc_dragon_w(coco_cartridge *cartridge, UINT16 addr, UINT8 data) |
| 606 | 610 | { |
| 607 | 611 | running_machine *machine = Machine; |
| 612 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 608 | 613 | switch(addr & 0xEF) |
| 609 | 614 | { |
| 610 | 615 | case 0: |
| 611 | | wd17xx_command_w(machine, 0, data); |
| 616 | wd17xx_command_w(space, 0, data); |
| 612 | 617 | |
| 613 | 618 | /* disk head is encoded in the command byte */ |
| 614 | 619 | /* Only for type 3 & 4 commands */ |
| r3692 | r3693 | |
| 616 | 621 | wd17xx_set_side((data & 0x02) ? 1 : 0); |
| 617 | 622 | break; |
| 618 | 623 | case 1: |
| 619 | | wd17xx_track_w(machine, 0, data); |
| 624 | wd17xx_track_w(space, 0, data); |
| 620 | 625 | break; |
| 621 | 626 | case 2: |
| 622 | | wd17xx_sector_w(machine, 0, data); |
| 627 | wd17xx_sector_w(space, 0, data); |
| 623 | 628 | break; |
| 624 | 629 | case 3: |
| 625 | | wd17xx_data_w(machine, 0, data); |
| 630 | wd17xx_data_w(space, 0, data); |
| 626 | 631 | break; |
| 627 | 632 | case 8: case 9: case 10: case 11: |
| 628 | 633 | case 12: case 13: case 14: case 15: |