diff options
author | cracyc <cracyc@users.noreply.github.com> | 2017-10-09 15:21:48 -0500 |
---|---|---|
committer | cracyc <cracyc@users.noreply.github.com> | 2017-10-09 15:21:48 -0500 |
commit | 358f17ad4c9754694a1b5ea2dafdee2c95522717 (patch) | |
tree | 443a62636451a6fa05a25c8f280a9270c5eacfef | |
parent | 026d45a939a63b57098d8fd281c993577f7b8f0a (diff) |
z8000: the z8000 daisy chain is different enough from the z80 that it'll probably need it's own implementation if anything uses it (nw)
p8k: the p8k_16 uses glue logic to make z80 daisy chain devices work (nw)
-rw-r--r-- | src/devices/cpu/z8000/z8000.cpp | 1 | ||||
-rw-r--r-- | src/devices/cpu/z8000/z8000.h | 4 | ||||
-rw-r--r-- | src/mame/drivers/p8k.cpp | 102 |
3 files changed, 36 insertions, 71 deletions
diff --git a/src/devices/cpu/z8000/z8000.cpp b/src/devices/cpu/z8000/z8000.cpp index ef2326ee80c..ab42e44539e 100644 --- a/src/devices/cpu/z8000/z8000.cpp +++ b/src/devices/cpu/z8000/z8000.cpp @@ -38,7 +38,6 @@ z8002_device::z8002_device(const machine_config &mconfig, const char *tag, devic z8002_device::z8002_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int addrbits, int iobits, int vecmult) : cpu_device(mconfig, type, tag, owner, clock) - , z80_daisy_chain_interface(mconfig, *this) , m_program_config("program", ENDIANNESS_BIG, 16, addrbits, 0) , m_io_config("io", ENDIANNESS_BIG, iobits, 16, 0) , m_mo_out(*this) diff --git a/src/devices/cpu/z8000/z8000.h b/src/devices/cpu/z8000/z8000.h index aa9382e75d7..a782efbaf18 100644 --- a/src/devices/cpu/z8000/z8000.h +++ b/src/devices/cpu/z8000/z8000.h @@ -5,8 +5,6 @@ #pragma once -#include "cpu/z80/z80daisy.h" - enum { @@ -33,7 +31,7 @@ enum #define MCFG_Z8000_MO(_devcb) \ devcb = &z8002_device::set_mo_callback(*device, DEVCB_##_devcb); -class z8002_device : public cpu_device, public z80_daisy_chain_interface +class z8002_device : public cpu_device { public: // construction/destruction diff --git a/src/mame/drivers/p8k.cpp b/src/mame/drivers/p8k.cpp index 5995e1d103a..6d2d78b2c4f 100644 --- a/src/mame/drivers/p8k.cpp +++ b/src/mame/drivers/p8k.cpp @@ -42,8 +42,6 @@ TODO: * properly implement Z80 daisy chain in 16 bit board * Find out how to enter hardware check on 16 bit board - * Vectored interrupts use Z8000_VI, but this results in a crash. Once - that is fixed and working, then the use of sio0 can be attempted. ****************************************************************************/ @@ -51,7 +49,6 @@ #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" #include "cpu/z8000/z8000.h" -#include "machine/terminal.h" #include "machine/upd765.h" #include "machine/z80ctc.h" #include "machine/z80dart.h" @@ -62,6 +59,26 @@ #include "machine/clock.h" #include "bus/rs232/rs232.h" +class p8k_16_daisy_device : public device_t, public z80_daisy_chain_interface +{ +public: + p8k_16_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + IRQ_CALLBACK_MEMBER(irq_callback) { + if(!irqline) return 0; + device_z80daisy_interface *intf = daisy_get_irq_device(); + return intf ? intf->z80daisy_irq_ack() >> 1 : 0; + } + DECLARE_WRITE8_MEMBER(reti_w) { if(data == 0x4d) daisy_call_reti_device(); } +protected: + void device_start() override {} +}; + +DEFINE_DEVICE_TYPE(P8K_16_DAISY, p8k_16_daisy_device, "p8k_16_daisy", "p8k_16_daisy") + +p8k_16_daisy_device::p8k_16_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, P8K_16_DAISY, tag, owner, clock) + , z80_daisy_chain_interface(mconfig, *this) {} + class p8k_state : public driver_device { @@ -69,16 +86,13 @@ public: p8k_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") - , m_terminal(*this, "terminal") + , m_daisy(*this, "p8k_16_daisy") { } DECLARE_READ8_MEMBER(p8k_port0_r); DECLARE_WRITE8_MEMBER(p8k_port0_w); - DECLARE_READ16_MEMBER(portff82_r); - DECLARE_WRITE16_MEMBER(portff82_w); DECLARE_DRIVER_INIT(p8k); DECLARE_MACHINE_RESET(p8k); - DECLARE_MACHINE_RESET(p8k_16); DECLARE_WRITE_LINE_MEMBER(fdc_irq); DECLARE_WRITE_LINE_MEMBER(p8k_daisy_interrupt); @@ -88,13 +102,10 @@ public: DECLARE_WRITE8_MEMBER(memory_write_byte); DECLARE_READ8_MEMBER(io_read_byte); DECLARE_WRITE8_MEMBER(io_write_byte); - void kbd_put_16(u8 data); private: - uint8_t m_term_data; - virtual void machine_start() override; required_device<cpu_device> m_maincpu; - optional_device<generic_terminal_device> m_terminal; + optional_device<p8k_16_daisy_device> m_daisy; }; /*************************************************************************** @@ -238,10 +249,6 @@ DECLARE_WRITE_LINE_MEMBER( p8k_state::fdc_irq ) z80pio->port_b_write(state ? 0x10 : 0x00); } -void p8k_state::machine_start() -{ -} - static SLOT_INTERFACE_START( p8k_floppies ) SLOT_INTERFACE( "525hd", FLOPPY_525_HD ) SLOT_INTERFACE_END @@ -304,41 +311,6 @@ DRIVER_INIT_MEMBER(p8k_state,p8k) ****************************************************************************/ -void p8k_state::kbd_put_16(u8 data) -{ - address_space &mem = m_maincpu->space(AS_DATA); - // keyboard int handler is at 0x0700 - m_term_data = data; - // This is another dire hack.. - uint8_t offs = mem.read_byte(0x43a5); - uint16_t addr = 0x41b0 + (uint16_t) offs; - mem.write_byte(addr, data); - mem.write_byte(0x43a0, 1); -} - -MACHINE_RESET_MEMBER(p8k_state,p8k_16) -{ -} - -READ16_MEMBER( p8k_state::portff82_r ) -{ - if (offset == 3) // FF87 - return 0xff; - else - if (offset == 1) // FF83 - return m_term_data; - return 0; -} - -WRITE16_MEMBER( p8k_state::portff82_w ) -{ - if (offset == 1) // FF83 - { - address_space &mem = m_maincpu->space(AS_PROGRAM); - m_terminal->write(mem, 0, data); - } -} - static ADDRESS_MAP_START(p8k_16_memmap, AS_PROGRAM, 16, p8k_state) AM_RANGE(0x00000, 0x03fff) AM_ROM AM_SHARE("share0") AM_RANGE(0x04000, 0x07fff) AM_RAM AM_SHARE("share1") @@ -354,8 +326,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START(p8k_16_iomap, AS_IO, 16, p8k_state) // AM_RANGE(0x0fef0, 0x0feff) // clock - //AM_RANGE(0x0ff80, 0x0ff87) AM_DEVREADWRITE8("sio0", z80sio0_device, cd_ba_r, cd_ba_w, 0xff) - AM_RANGE(0x0ff80, 0x0ff87) AM_READWRITE(portff82_r,portff82_w) + AM_RANGE(0x0ff80, 0x0ff87) AM_DEVREADWRITE8("sio0", z80sio0_device, cd_ba_r, cd_ba_w, 0xff) AM_RANGE(0x0ff88, 0x0ff8f) AM_DEVREADWRITE8("sio1", z80sio0_device, cd_ba_r, cd_ba_w, 0xff) AM_RANGE(0x0ff90, 0x0ff97) AM_DEVREADWRITE8("pio0", z80pio_device, read_alt, write_alt, 0xff) AM_RANGE(0x0ff98, 0x0ff9f) AM_DEVREADWRITE8("pio1", z80pio_device, read_alt, write_alt, 0xff) @@ -366,7 +337,7 @@ static ADDRESS_MAP_START(p8k_16_iomap, AS_IO, 16, p8k_state) // AM_RANGE(0x0ffc8, 0x0ffc9) // SBR // AM_RANGE(0x0ffd0, 0x0ffd1) // NBR // AM_RANGE(0x0ffd8, 0x0ffd9) // SNVR -// AM_RANGE(0x0ffe0, 0x0ffe1) // RETI + AM_RANGE(0x0ffe0, 0x0ffe1) AM_DEVWRITE8("p8k_16_daisy", p8k_16_daisy_device, reti_w, 0xff) // AM_RANGE(0x0fff0, 0x0fff1) // TRPL // AM_RANGE(0x0fff8, 0x0fff9) // IF1L ADDRESS_MAP_END @@ -380,8 +351,7 @@ ADDRESS_MAP_END WRITE_LINE_MEMBER( p8k_state::p8k_16_daisy_interrupt ) { - // this must be studied a little bit more :-) - //m_maincpu->set_input_line(Z8000_VI, ASSERT_LINE); // This I believe should signal the cpu about a IM2 event, but MAME crashes. + m_maincpu->set_input_line(INPUT_LINE_IRQ1, state ? ASSERT_LINE : CLEAR_LINE); } @@ -499,11 +469,13 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_START( p8k_16 ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z8001, XTAL_4MHz ) - MCFG_Z80_DAISY_CHAIN(p8k_16_daisy_chain) MCFG_CPU_PROGRAM_MAP(p8k_16_memmap) MCFG_CPU_DATA_MAP(p8k_16_datamap) MCFG_CPU_IO_MAP(p8k_16_iomap) - MCFG_MACHINE_RESET_OVERRIDE(p8k_state,p8k_16) + MCFG_CPU_IRQ_ACKNOWLEDGE_DEVICE("p8k_16_daisy", p8k_16_daisy_device, irq_callback) + + MCFG_DEVICE_ADD("p8k_16_daisy", P8K_16_DAISY, 0) + MCFG_Z80_DAISY_CHAIN(p8k_16_daisy_chain) MCFG_DEVICE_ADD("uart_clock", CLOCK, 307200) MCFG_CLOCK_SIGNAL_HANDLER(DEVWRITELINE("sio0", z80sio0_device, txcb_w)) @@ -517,14 +489,14 @@ static MACHINE_CONFIG_START( p8k_16 ) MCFG_Z80CTC_INTR_CB(WRITELINE(p8k_state, p8k_16_daisy_interrupt)) MCFG_DEVICE_ADD("sio0", Z80SIO0, XTAL_4MHz) - //MCFG_Z80DART_OUT_TXDB_CB(DEVWRITELINE("rs232", rs232_port_device, write_txd)) - //MCFG_Z80DART_OUT_DTRB_CB(DEVWRITELINE("rs232", rs232_port_device, write_dtr)) - //MCFG_Z80DART_OUT_RTSB_CB(DEVWRITELINE("rs232", rs232_port_device, write_rts)) + MCFG_Z80DART_OUT_TXDB_CB(DEVWRITELINE("rs232", rs232_port_device, write_txd)) + MCFG_Z80DART_OUT_DTRB_CB(DEVWRITELINE("rs232", rs232_port_device, write_dtr)) + MCFG_Z80DART_OUT_RTSB_CB(DEVWRITELINE("rs232", rs232_port_device, write_rts)) MCFG_Z80DART_OUT_INT_CB(WRITELINE(p8k_state, p8k_16_daisy_interrupt)) - //MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, "terminal") - //MCFG_RS232_RXD_HANDLER(DEVWRITELINE("sio0", z80sio0_device, rxb_w)) - //MCFG_RS232_CTS_HANDLER(DEVWRITELINE("sio0", z80sio0_device, ctsb_w)) + MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, "terminal") + MCFG_RS232_RXD_HANDLER(DEVWRITELINE("sio0", z80sio0_device, rxb_w)) + MCFG_RS232_CTS_HANDLER(DEVWRITELINE("sio0", z80sio0_device, ctsb_w)) MCFG_DEVICE_ADD("sio1", Z80SIO0, XTAL_4MHz) MCFG_Z80DART_OUT_INT_CB(WRITELINE(p8k_state, p8k_16_daisy_interrupt)) @@ -542,10 +514,6 @@ static MACHINE_CONFIG_START( p8k_16 ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("beeper", BEEP, 3250) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) - - /* video hardware */ - MCFG_DEVICE_ADD("terminal", GENERIC_TERMINAL, 0) - MCFG_GENERIC_TERMINAL_KEYBOARD_CB(PUT(p8k_state, kbd_put_16)) MACHINE_CONFIG_END /* ROM definition */ |