src/mess/drivers/x1.c
| r5789 | r5790 | |
| 142 | 142 | |
| 143 | 143 | #include "driver.h" |
| 144 | 144 | #include "cpu/z80/z80.h" |
| 145 | #include "cpu/z80/z80daisy.h" |
| 145 | 146 | #include "machine/z80ctc.h" |
| 146 | 147 | #include "machine/z80sio.h" |
| 147 | 148 | #include "machine/8255ppi.h" |
| r5789 | r5790 | |
| 166 | 167 | static UINT8 pcg_reset; |
| 167 | 168 | static UINT16 crtc_start_addr; |
| 168 | 169 | static UINT8 sub_obf; |
| 170 | static UINT8 key_irq_flag; |
| 171 | static UINT8 ctc_irq_flag; |
| 169 | 172 | static struct |
| 170 | 173 | { |
| 171 | 174 | UINT8 gfx_bank; |
| r5789 | r5790 | |
| 187 | 190 | |
| 188 | 191 | static UINT8 pcg_write_addr; |
| 189 | 192 | |
| 193 | static DEVICE_START(x1_daisy){} |
| 190 | 194 | |
| 191 | 195 | /************************************* |
| 192 | 196 | * |
| r5789 | r5790 | |
| 682 | 686 | logerror("SUB: Command byte 0x%02x\n",data); |
| 683 | 687 | } |
| 684 | 688 | |
| 689 | static int x1_keyboard_irq_state(const device_config* device) |
| 690 | { |
| 691 | if(key_irq_flag != 0) |
| 692 | return Z80_DAISY_INT; |
| 693 | |
| 694 | return 0; |
| 695 | } |
| 696 | |
| 697 | static int x1_keyboard_irq_ack(const device_config* device) |
| 698 | { |
| 699 | key_irq_flag = 0; |
| 700 | cputag_set_input_line(device->machine,"maincpu",INPUT_LINE_IRQ0,CLEAR_LINE); |
| 701 | return key_irq_vector; |
| 702 | } |
| 703 | |
| 704 | static DEVICE_GET_INFO( x1_keyboard_getinfo ) |
| 705 | { |
| 706 | switch (state) |
| 707 | { |
| 708 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 709 | case DEVINFO_INT_TOKEN_BYTES: info->i = 4; break; |
| 710 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 711 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 712 | |
| 713 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 714 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(x1_daisy); break; |
| 715 | case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)x1_keyboard_irq_state; break; |
| 716 | case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)x1_keyboard_irq_ack; break; |
| 717 | |
| 718 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 719 | case DEVINFO_STR_NAME: strcpy(info->s, "X1 keyboard"); break; |
| 720 | case DEVINFO_STR_FAMILY: strcpy(info->s, "X1 daisy chain"); break; |
| 721 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 722 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 723 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 724 | } |
| 725 | } |
| 726 | |
| 685 | 727 | /************************************* |
| 686 | 728 | * |
| 687 | 729 | * ROM Image / Banking Handling |
| r5789 | r5790 | |
| 1740 | 1782 | |
| 1741 | 1783 | static void ctc0_interrupt(const device_config *device, int state) |
| 1742 | 1784 | { |
| 1743 | | //x1_irq_vector = 0x5e; |
| 1744 | | //cputag_set_input_line(device->machine, "maincpu", 0, state); |
| 1785 | cputag_set_input_line(device->machine,"maincpu",INPUT_LINE_IRQ0,state); |
| 1745 | 1786 | } |
| 1746 | 1787 | |
| 1747 | 1788 | |
| r5789 | r5790 | |
| 1749 | 1790 | { |
| 1750 | 1791 | 0, // timer disables |
| 1751 | 1792 | ctc0_interrupt, // interrupt handler |
| 1752 | | z80ctc_trg0_w, // ZC/TO0 callback |
| 1793 | z80ctc_trg3_w, // ZC/TO0 callback |
| 1753 | 1794 | z80ctc_trg1_w, // ZC/TO1 callback |
| 1754 | 1795 | z80ctc_trg2_w, // ZC/TO2 callback |
| 1755 | 1796 | }; |
| r5789 | r5790 | |
| 1764 | 1805 | 0 /* receive handler */ |
| 1765 | 1806 | }; |
| 1766 | 1807 | |
| 1808 | static const z80_daisy_chain x1_daisy[] = |
| 1809 | { |
| 1810 | { "x1kb" }, |
| 1811 | { "ctc" }, |
| 1812 | // { "dma" }, |
| 1813 | // { "sio" }, |
| 1814 | { NULL } |
| 1815 | }; |
| 1767 | 1816 | |
| 1768 | 1817 | /************************************* |
| 1769 | 1818 | * |
| r5789 | r5790 | |
| 1808 | 1857 | //... |
| 1809 | 1858 | } |
| 1810 | 1859 | |
| 1811 | | static IRQ_CALLBACK(x1_irq_callback) |
| 1860 | /*static IRQ_CALLBACK(x1_irq_callback) |
| 1812 | 1861 | { |
| 1813 | | cpu_set_input_line(device, 0, CLEAR_LINE); |
| 1862 | if(ctc_irq_flag != 0) |
| 1863 | { |
| 1864 | ctc_irq_flag = 0; |
| 1865 | if(key_irq_flag == 0) // if no other devices are pulling the IRQ line high |
| 1866 | cpu_set_input_line(device, 0, CLEAR_LINE); |
| 1867 | return x1_irq_vector; |
| 1868 | } |
| 1869 | if(key_irq_flag != 0) |
| 1870 | { |
| 1871 | key_irq_flag = 0; |
| 1872 | if(ctc_irq_flag == 0) // if no other devices are pulling the IRQ line high |
| 1873 | cpu_set_input_line(device, 0, CLEAR_LINE); |
| 1874 | return key_irq_vector; |
| 1875 | } |
| 1814 | 1876 | return x1_irq_vector; |
| 1815 | 1877 | } |
| 1816 | | |
| 1878 | */ |
| 1817 | 1879 | static TIMER_CALLBACK(keyboard_callback) |
| 1818 | 1880 | { |
| 1819 | 1881 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| r5789 | r5790 | |
| 1830 | 1892 | // generate keyboard IRQ |
| 1831 | 1893 | sub_io_w(space,0,0xe6); |
| 1832 | 1894 | x1_irq_vector = key_irq_vector; |
| 1895 | key_irq_flag = 1; |
| 1833 | 1896 | cputag_set_input_line(machine,"maincpu",0,ASSERT_LINE); |
| 1834 | 1897 | old_key1 = key1; |
| 1835 | 1898 | old_key2 = key2; |
| r5789 | r5790 | |
| 1865 | 1928 | io_bank_mode = 0; |
| 1866 | 1929 | pcg_index[0] = pcg_index[1] = pcg_index[2] = 0; |
| 1867 | 1930 | |
| 1868 | | cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), x1_irq_callback); |
| 1931 | //cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), x1_irq_callback); |
| 1869 | 1932 | timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback); |
| 1870 | 1933 | |
| 1871 | 1934 | cmt_current_cmd = 0; |
| 1872 | 1935 | cmt_test = 0; |
| 1873 | 1936 | cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 1937 | |
| 1938 | key_irq_flag = ctc_irq_flag = 0; |
| 1874 | 1939 | } |
| 1875 | 1940 | |
| 1876 | 1941 | static PALETTE_INIT(x1) |
| r5789 | r5790 | |
| 1927 | 1992 | MDRV_CPU_PROGRAM_MAP(x1_mem) |
| 1928 | 1993 | MDRV_CPU_IO_MAP(x1_io) |
| 1929 | 1994 | MDRV_CPU_VBLANK_INT("screen", x1_vbl) |
| 1995 | MDRV_CPU_CONFIG(x1_daisy) |
| 1930 | 1996 | |
| 1931 | 1997 | MDRV_Z80CTC_ADD( "ctc", XTAL_4MHz , ctc_intf ) |
| 1932 | 1998 | MDRV_Z80SIO_ADD( "sio", XTAL_4MHz , sio_intf ) |
| 1933 | 1999 | MDRV_Z80DMA_ADD( "dma", XTAL_4MHz , x1_dma ) |
| 1934 | 2000 | |
| 2001 | MDRV_DEVICE_ADD("x1kb", DEVICE_GET_INFO_NAME(x1_keyboard_getinfo), 0) |
| 2002 | |
| 1935 | 2003 | MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf ) |
| 1936 | 2004 | |
| 1937 | 2005 | MDRV_MACHINE_RESET(x1) |