src/mess/drivers/m20.c
| r15185 | r15186 | |
| 42 | 42 | #include "machine/i8251.h" |
| 43 | 43 | #include "machine/i8255.h" |
| 44 | 44 | #include "machine/pit8253.h" |
| 45 | #include "machine/pic8259.h" |
| 45 | 46 | #include "imagedev/flopdrv.h" |
| 46 | 47 | #include "formats/basicdsk.h" |
| 47 | 48 | |
| r15185 | r15186 | |
| 54 | 55 | m_kbdi8251(*this, "i8251_1"), |
| 55 | 56 | m_ttyi8251(*this, "i8251_2"), |
| 56 | 57 | m_i8255(*this, "ppi8255"), |
| 58 | m_i8259(*this, "i8259"), |
| 57 | 59 | m_p_videoram(*this, "p_videoram"){ } |
| 58 | 60 | |
| 59 | 61 | required_device<device_t> m_maincpu; |
| 60 | 62 | required_device<i8251_device> m_kbdi8251; |
| 61 | 63 | required_device<i8251_device> m_ttyi8251; |
| 62 | 64 | required_device<i8255_device> m_i8255; |
| 65 | required_device<device_t> m_i8259; |
| 63 | 66 | required_shared_ptr<UINT16> m_p_videoram; |
| 64 | 67 | |
| 65 | 68 | virtual void machine_reset(); |
| 66 | 69 | |
| 67 | | DECLARE_READ8_MEMBER(ppi_r); |
| 68 | | DECLARE_WRITE8_MEMBER(ppi_w); |
| 70 | DECLARE_READ16_MEMBER(m20_i8259_r); |
| 71 | DECLARE_WRITE16_MEMBER(m20_i8259_w); |
| 72 | DECLARE_WRITE_LINE_MEMBER(pic_irq_line_w); |
| 69 | 73 | }; |
| 70 | 74 | |
| 71 | 75 | |
| r15185 | r15186 | |
| 106 | 110 | return 0; |
| 107 | 111 | } |
| 108 | 112 | |
| 109 | | // translate addresses 81/83/85/87 to PPI offsets 0/1/2/3 |
| 110 | | READ8_MEMBER(m20_state::ppi_r) |
| 113 | READ16_MEMBER(m20_state::m20_i8259_r) |
| 111 | 114 | { |
| 112 | | return m_i8255->read(space, offset/2); |
| 115 | return pic8259_r(m_i8259, offset)<<1; |
| 113 | 116 | } |
| 114 | 117 | |
| 115 | | WRITE8_MEMBER(m20_state::ppi_w) |
| 118 | WRITE16_MEMBER(m20_state::m20_i8259_w) |
| 116 | 119 | { |
| 117 | | m_i8255->write(space, offset/2, data); |
| 120 | pic8259_w(m_i8259, offset, (data>>1)); |
| 118 | 121 | } |
| 119 | 122 | |
| 120 | | // same for pit8253 |
| 121 | | READ8_DEVICE_HANDLER(m20_pit8253_r) |
| 123 | WRITE_LINE_MEMBER( m20_state::pic_irq_line_w ) |
| 122 | 124 | { |
| 123 | | return pit8253_r(device, offset / 2); |
| 125 | if (state) |
| 126 | { |
| 127 | // PIC raised IRQ line |
| 128 | } |
| 129 | else |
| 130 | { |
| 131 | // PIC lowered IRQ line |
| 132 | } |
| 124 | 133 | } |
| 125 | 134 | |
| 126 | | WRITE8_DEVICE_HANDLER(m20_pit8253_w) |
| 127 | | { |
| 128 | | pit8253_w(device, offset / 2, data); |
| 129 | | } |
| 130 | | |
| 131 | 135 | /* from the M20 hardware reference manual: |
| 132 | 136 | M20 memory is configured according to the following scheme: |
| 133 | 137 | Segment Contents |
| r15185 | r15186 | |
| 157 | 161 | // AM_RANGE( 0x20000, 0x2???? ) //work RAM? |
| 158 | 162 | ADDRESS_MAP_END |
| 159 | 163 | |
| 160 | | static ADDRESS_MAP_START(m20_io, AS_IO, 8, m20_state) |
| 164 | static ADDRESS_MAP_START(m20_io, AS_IO, 16, m20_state) |
| 161 | 165 | ADDRESS_MAP_UNMAP_HIGH |
| 162 | 166 | |
| 163 | | AM_RANGE(0x01, 0x01) AM_DEVWRITE_LEGACY("wd177x", wd17xx_command_w) |
| 164 | | AM_RANGE(0x03, 0x03) AM_DEVREADWRITE_LEGACY("wd177x", wd17xx_track_r, wd17xx_track_w) |
| 165 | | AM_RANGE(0x05, 0x05) AM_DEVREADWRITE_LEGACY("wd177x", wd17xx_sector_r, wd17xx_sector_w) |
| 166 | | AM_RANGE(0x07, 0x07) AM_DEVREADWRITE_LEGACY("wd177x", wd17xx_data_r, wd17xx_data_w) |
| 167 | AM_RANGE(0x00, 0x01) AM_DEVWRITE8_LEGACY("wd177x", wd17xx_command_w, 0x00ff) |
| 168 | AM_RANGE(0x02, 0x03) AM_DEVREADWRITE8_LEGACY("wd177x", wd17xx_track_r, wd17xx_track_w, 0x00ff) |
| 169 | AM_RANGE(0x04, 0x05) AM_DEVREADWRITE8_LEGACY("wd177x", wd17xx_sector_r, wd17xx_sector_w, 0x00ff) |
| 170 | AM_RANGE(0x06, 0x07) AM_DEVREADWRITE8_LEGACY("wd177x", wd17xx_data_r, wd17xx_data_w, 0x00ff) |
| 167 | 171 | |
| 168 | | AM_RANGE(0x61, 0x61) AM_DEVWRITE("crtc", mc6845_device, address_w) |
| 169 | | AM_RANGE(0x63, 0x63) AM_DEVREADWRITE("crtc", mc6845_device, register_r, register_w) |
| 170 | | AM_RANGE(0x81, 0x87) AM_READWRITE(ppi_r, ppi_w) |
| 171 | | AM_RANGE(0xa1, 0xa1) AM_DEVREADWRITE("i8251_1", i8251_device, data_r, data_w) |
| 172 | | AM_RANGE(0xa3, 0xa3) AM_DEVREADWRITE("i8251_1", i8251_device, status_r, control_w) |
| 173 | | AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE("i8251_2", i8251_device, data_r, data_w) |
| 174 | | AM_RANGE(0xc3, 0xc3) AM_DEVREADWRITE("i8251_2", i8251_device, status_r, control_w) |
| 172 | AM_RANGE(0x60, 0x61) AM_DEVWRITE8("crtc", mc6845_device, address_w, 0x00ff) |
| 173 | AM_RANGE(0x62, 0x63) AM_DEVREADWRITE8("crtc", mc6845_device, register_r, register_w, 0x00ff) |
| 175 | 174 | |
| 176 | | AM_RANGE(0x121, 0x127) AM_DEVREADWRITE_LEGACY("pit8253", m20_pit8253_r, m20_pit8253_w) |
| 175 | AM_RANGE(0x80, 0x87) AM_DEVREADWRITE8("ppi8255", i8255_device, read, write, 0x00ff) |
| 177 | 176 | |
| 177 | AM_RANGE(0xa0, 0xa1) AM_DEVREADWRITE8("i8251_1", i8251_device, data_r, data_w, 0x00ff) |
| 178 | AM_RANGE(0xa2, 0xa3) AM_DEVREADWRITE8("i8251_1", i8251_device, status_r, control_w, 0x00ff) |
| 179 | AM_RANGE(0xc0, 0xc1) AM_DEVREADWRITE8("i8251_2", i8251_device, data_r, data_w, 0x00ff) |
| 180 | AM_RANGE(0xc2, 0xc3) AM_DEVREADWRITE8("i8251_2", i8251_device, status_r, control_w, 0x00ff) |
| 181 | |
| 182 | AM_RANGE(0x120, 0x127) AM_DEVREADWRITE8_LEGACY("pit8253", pit8253_r, pit8253_w, 0x00ff) |
| 183 | |
| 184 | AM_RANGE(0x140, 0x143) AM_READWRITE(m20_i8259_r, m20_i8259_w) |
| 185 | // AM_RANGE(0x140, 0x143) AM_DEVREADWRITE8_LEGACY("i8259", pic8259_r, pic8259_w, 0xffff) |
| 186 | |
| 178 | 187 | // 0x21?? / 0x21? - fdc ... seems to control the screen colors??? |
| 179 | 188 | ADDRESS_MAP_END |
| 180 | 189 | |
| r15185 | r15186 | |
| 313 | 322 | } |
| 314 | 323 | }; |
| 315 | 324 | |
| 325 | const struct pic8259_interface pic_intf = |
| 326 | { |
| 327 | DEVCB_DRIVER_LINE_MEMBER(m20_state, pic_irq_line_w), |
| 328 | DEVCB_LINE_VCC, // we're the only 8259, so we're the master |
| 329 | DEVCB_NULL |
| 330 | }; |
| 331 | |
| 316 | 332 | static MACHINE_CONFIG_START( m20, m20_state ) |
| 317 | 333 | /* basic machine hardware */ |
| 318 | 334 | MCFG_CPU_ADD("maincpu", Z8001, MAIN_CLOCK) |
| r15185 | r15186 | |
| 343 | 359 | MCFG_I8251_ADD("i8251_1", kbd_i8251_intf) |
| 344 | 360 | MCFG_I8251_ADD("i8251_2", tty_i8251_intf) |
| 345 | 361 | MCFG_PIT8253_ADD("pit8253", pit8253_intf) |
| 362 | MCFG_PIC8259_ADD("i8259", pic_intf) |
| 346 | 363 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(m20_floppy_interface) |
| 347 | 364 | MACHINE_CONFIG_END |
| 348 | 365 | |