From faeedc757c8e53affa4d94f471e5f75be2bc0f3b Mon Sep 17 00:00:00 2001 From: Dirk Best Date: Mon, 6 Nov 2017 20:45:24 +0100 Subject: [PATCH] einstein: Major cleanup, add a ADC0844 device The analogue joystick is now emulated. Also fixed a few minor issues with the memory map. This also adds a generic Z80 dasisy chain device, for use in drivers with non-Z80 peripherals. --- scripts/src/cpu.lua | 2 + scripts/src/machine.lua | 12 + scripts/target/mame/arcade.lua | 1 + scripts/target/mame/mess.lua | 3 +- src/devices/cpu/z80/z80daisy_generic.cpp | 102 +++++ src/devices/cpu/z80/z80daisy_generic.h | 60 +++ src/devices/machine/adc0844.cpp | 155 ++++++++ src/devices/machine/adc0844.h | 104 +++++ src/mame/drivers/einstein.cpp | 459 ++++++++++++----------- src/mame/includes/einstein.h | 186 --------- src/mame/machine/einstein.cpp | 208 ---------- 11 files changed, 683 insertions(+), 609 deletions(-) create mode 100644 src/devices/cpu/z80/z80daisy_generic.cpp create mode 100644 src/devices/cpu/z80/z80daisy_generic.h create mode 100644 src/devices/machine/adc0844.cpp create mode 100644 src/devices/machine/adc0844.h delete mode 100644 src/mame/includes/einstein.h delete mode 100644 src/mame/machine/einstein.cpp diff --git a/scripts/src/cpu.lua b/scripts/src/cpu.lua index 7230735b835..9ed50cd9db1 100644 --- a/scripts/src/cpu.lua +++ b/scripts/src/cpu.lua @@ -2178,6 +2178,8 @@ if (CPUS["Z80"]~=null) then MAME_DIR .. "src/devices/cpu/z80/z80.h", MAME_DIR .. "src/devices/cpu/z80/z80daisy.cpp", MAME_DIR .. "src/devices/cpu/z80/z80daisy.h", + MAME_DIR .. "src/devices/cpu/z80/z80daisy_generic.cpp", + MAME_DIR .. "src/devices/cpu/z80/z80daisy_generic.h", MAME_DIR .. "src/devices/cpu/z80/tmpz84c011.cpp", MAME_DIR .. "src/devices/cpu/z80/tmpz84c011.h", MAME_DIR .. "src/devices/cpu/z80/tmpz84c015.cpp", diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua index d5a30d27756..d6f08b7c8ce 100644 --- a/scripts/src/machine.lua +++ b/scripts/src/machine.lua @@ -3287,3 +3287,15 @@ if (MACHINES["I82586"]~=null) then MAME_DIR .. "src/devices/machine/i82586.h", } end + +--------------------------------------------------- +-- +--@src/devices/machine/adc0844.h,MACHINES["ADC0844"] = true +--------------------------------------------------- + +if (MACHINES["ADC0844"]~=null) then + files { + MAME_DIR .. "src/devices/machine/adc0844.cpp", + MAME_DIR .. "src/devices/machine/adc0844.h", + } +end diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index 2df9688a977..a7320d9e673 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -608,6 +608,7 @@ MACHINES["GEN_LATCH"] = true MACHINES["WATCHDOG"] = true MACHINES["INPUT_MERGER"] = true MACHINES["K054321"] = true +MACHINES["ADC0844"] = true -------------------------------------------------- -- specify available bus cores diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 6911c73d0b9..de2a0bc5edd 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -618,6 +618,7 @@ MACHINES["FGA002"] = true MACHINES["I82586"] = true MACHINES["INPUT_MERGER"] = true -- MACHINES["K054321"] = true +MACHINES["ADC0844"] = true -------------------------------------------------- -- specify available bus cores @@ -3019,8 +3020,6 @@ files { createMESSProjects(_target, _subtarget, "tatung") files { MAME_DIR .. "src/mame/drivers/einstein.cpp", - MAME_DIR .. "src/mame/includes/einstein.h", - MAME_DIR .. "src/mame/machine/einstein.cpp", } createMESSProjects(_target, _subtarget, "teamconc") diff --git a/src/devices/cpu/z80/z80daisy_generic.cpp b/src/devices/cpu/z80/z80daisy_generic.cpp new file mode 100644 index 00000000000..59168b072a0 --- /dev/null +++ b/src/devices/cpu/z80/z80daisy_generic.cpp @@ -0,0 +1,102 @@ +// license: BSD-3-Clause +// copyright-holders: Dirk Best +/*************************************************************************** + + Generic Z80 daisy chain device + +***************************************************************************/ + +#include "emu.h" +#include "z80daisy_generic.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(Z80DAISY_GENERIC, z80daisy_generic_device, "z80daisy_generic", "Generic Z80 daisy chain device") + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// z80daisy_generic_device - constructor +//------------------------------------------------- + +z80daisy_generic_device::z80daisy_generic_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, Z80DAISY_GENERIC, tag, owner, clock), + device_z80daisy_interface(mconfig, *this), + m_int(0), m_mask(0), m_vector(0xff) +{ +} + +//------------------------------------------------- +// static_set_vector - static configuration +//------------------------------------------------- + +void z80daisy_generic_device::static_set_vector(device_t &device, uint8_t vector) +{ + z80daisy_generic_device &dev = downcast(device); + dev.m_vector = vector; +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void z80daisy_generic_device::device_start() +{ + // register for save states + save_item(NAME(m_int)); + save_item(NAME(m_mask)); + save_item(NAME(m_vector)); +} + +//------------------------------------------------- +// z80daisy_irq_state - return the overall IRQ +// state for this device +//------------------------------------------------- + +int z80daisy_generic_device::z80daisy_irq_state() +{ + if (m_int & ~m_mask) + return Z80_DAISY_INT; + + return 0; +} + +//------------------------------------------------- +// z80daisy_irq_ack - acknowledge an IRQ and +// return the appropriate vector +//------------------------------------------------- + +int z80daisy_generic_device::z80daisy_irq_ack() +{ + return m_vector; +} + +//------------------------------------------------- +// z80daisy_irq_reti - clear the interrupt +// pending state to allow other interrupts through +//------------------------------------------------- + +void z80daisy_generic_device::z80daisy_irq_reti() +{ +} + + +//************************************************************************** +// INTERFACE +//************************************************************************** + +WRITE_LINE_MEMBER( z80daisy_generic_device::int_w ) +{ + m_int = state; +} + +WRITE_LINE_MEMBER( z80daisy_generic_device::mask_w ) +{ + m_mask = state; +} diff --git a/src/devices/cpu/z80/z80daisy_generic.h b/src/devices/cpu/z80/z80daisy_generic.h new file mode 100644 index 00000000000..430f83502fa --- /dev/null +++ b/src/devices/cpu/z80/z80daisy_generic.h @@ -0,0 +1,60 @@ +// license: BSD-3-Clause +// copyright-holders: Dirk Best +/*************************************************************************** + + Generic Z80 daisy chain device + +***************************************************************************/ + +#ifndef MAME_DEVICES_CPU_Z80_Z80DAISY_GENERIC_H +#define MAME_DEVICES_CPU_Z80_Z80DAISY_GENERIC_H + +#pragma once + +#include "z80daisy.h" + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_Z80DAISY_GENERIC_ADD(_tag, _vector) \ + MCFG_DEVICE_ADD(_tag, Z80DAISY_GENERIC, 0) \ + z80daisy_generic_device::static_set_vector(*device, _vector); \ + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class z80daisy_generic_device : public device_t, public device_z80daisy_interface +{ +public: + // construction/destruction + z80daisy_generic_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + // configuration + static void static_set_vector(device_t &device, uint8_t vector); + + DECLARE_WRITE_LINE_MEMBER(int_w); + DECLARE_WRITE_LINE_MEMBER(mask_w); + +protected: + // device-level overrides + virtual void device_start() override; + + // z80daisy_interface overrides + virtual int z80daisy_irq_state() override; + virtual int z80daisy_irq_ack() override; + virtual void z80daisy_irq_reti() override; + +private: + int m_int; + int m_mask; + int m_vector; +}; + +// device type definition +DECLARE_DEVICE_TYPE(Z80DAISY_GENERIC, z80daisy_generic_device) + +#endif // MAME_DEVICES_CPU_Z80_Z80DAISY_GENERIC_H diff --git a/src/devices/machine/adc0844.cpp b/src/devices/machine/adc0844.cpp new file mode 100644 index 00000000000..911a1604866 --- /dev/null +++ b/src/devices/machine/adc0844.cpp @@ -0,0 +1,155 @@ +// license: BSD-3-Clause +// copyright-holders: Dirk Best +/*************************************************************************** + + ADC0844 + + A/D Converter With Multiplexer Options + +***************************************************************************/ + +#include "emu.h" +#include "adc0844.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(ADC0844, adc0844_device, "adc0844", "ADC0844 A/D Converter") + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// adc0844_device - constructor +//------------------------------------------------- + +adc0844_device::adc0844_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ADC0844, tag, owner, clock), + m_intr_cb(*this), + m_channel_cb{ { *this }, { *this }, { *this }, { *this } }, + m_conversion_timer(nullptr), + m_channel(0x0f), + m_result(0xff) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void adc0844_device::device_start() +{ + // resolve callbacks + m_intr_cb.resolve_safe(); + m_channel_cb[0].resolve_safe(0xff); + m_channel_cb[1].resolve_safe(0xff); + m_channel_cb[2].resolve_safe(0xff); + m_channel_cb[3].resolve_safe(0xff); + + // allocate timers + m_conversion_timer = timer_alloc(); + + // register for save states + save_item(NAME(m_channel)); + save_item(NAME(m_result)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void adc0844_device::device_reset() +{ +} + +//------------------------------------------------- +// device_timer - handler timer events +//------------------------------------------------- + +uint8_t adc0844_device::clamp(int value) +{ + if (value > 0) + return 0xff; + else if (value < 0) + return 0x00; + else + return value; +} + +void adc0844_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (m_channel) + { + // differential + case 0x00: + case 0x08: + m_result = clamp(m_channel_cb[0](0) + m_channel_cb[0](0)); + break; + case 0x01: + case 0x09: + m_result = clamp(m_channel_cb[1](0) + m_channel_cb[1](0)); + break; + case 0x02: + case 0x0a: + m_result = clamp(m_channel_cb[2](0) + m_channel_cb[3](0)); + break; + case 0x03: + case 0x0b: + m_result = clamp(m_channel_cb[3](0) + m_channel_cb[2](0)); + break; + // single-ended + case 0x04: + m_result = m_channel_cb[0](0); + break; + case 0x05: + m_result = m_channel_cb[1](0); + break; + case 0x06: + m_result = m_channel_cb[2](0); + break; + case 0x07: + m_result = m_channel_cb[3](0); + break; + // pseudo-differential + case 0x0c: + m_result = clamp(m_channel_cb[0](0) + m_channel_cb[3](0)); + break; + case 0x0d: + m_result = clamp(m_channel_cb[1](0) + m_channel_cb[3](0)); + break; + case 0x0e: + m_result = clamp(m_channel_cb[2](0) + m_channel_cb[3](0)); + break; + // undefined + case 0x0f: + m_result = 0x00; + break; + } + + m_intr_cb(ASSERT_LINE); +} + + +//************************************************************************** +// INTERFACE +//************************************************************************** + +READ8_MEMBER( adc0844_device::read ) +{ + m_intr_cb(CLEAR_LINE); + + return m_result; +} + +WRITE8_MEMBER( adc0844_device::write ) +{ + m_intr_cb(CLEAR_LINE); + + // set channel and start conversion + m_channel = data & 0x0f; + m_conversion_timer->adjust(attotime::from_usec(40)); +} diff --git a/src/devices/machine/adc0844.h b/src/devices/machine/adc0844.h new file mode 100644 index 00000000000..d18ba963172 --- /dev/null +++ b/src/devices/machine/adc0844.h @@ -0,0 +1,104 @@ +// license: BSD-3-Clause +// copyright-holders: Dirk Best +/*************************************************************************** + + ADC0844 + + A/D Converter With Multiplexer Options + + ___ ___ + /RD 1 |* u | 20 VCC + /CS 2 | | 19 /WR + CH1 3 | | 18 /INTR + CH2 4 | | 17 DB0/MA0 + CH3 5 | | 16 DB1/MA1 + CH4 6 | | 15 DB2/MA2 + AGND 7 | | 14 DB3/MA3 + VREF 8 | | 13 DB4 + DB7 9 | | 12 DB5 + DGND 10 |_______| 11 DB6 + +***************************************************************************/ + +#ifndef MAME_DEVICES_MACHINE_ADC0844_H +#define MAME_DEVICES_MACHINE_ADC0844_H + +#pragma once + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_ADC0844_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, ADC0844, 0) + +#define MCFG_ADC0844_INTR_CB(_devcb) \ + devcb = &adc0844_device::set_intr_callback(*device, DEVCB_##_devcb); + +#define MCFG_ADC0844_CH1_CB(_devcb) \ + devcb = &adc0844_device::set_ch1_callback(*device, DEVCB_##_devcb); + +#define MCFG_ADC0844_CH2_CB(_devcb) \ + devcb = &adc0844_device::set_ch2_callback(*device, DEVCB_##_devcb); + +#define MCFG_ADC0844_CH3_CB(_devcb) \ + devcb = &adc0844_device::set_ch3_callback(*device, DEVCB_##_devcb); + +#define MCFG_ADC0844_CH4_CB(_devcb) \ + devcb = &adc0844_device::set_ch4_callback(*device, DEVCB_##_devcb); + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class adc0844_device : public device_t +{ +public: + // construction/destruction + adc0844_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + // configuration + template static devcb_base &set_intr_callback(device_t &device, Object &&cb) + { return downcast(device).m_intr_cb.set_callback(std::forward(cb)); } + + template static devcb_base &set_ch1_callback(device_t &device, Object &&cb) + { return downcast(device).m_channel_cb[0].set_callback(std::forward(cb)); } + + template static devcb_base &set_ch2_callback(device_t &device, Object &&cb) + { return downcast(device).m_channel_cb[1].set_callback(std::forward(cb)); } + + template static devcb_base &set_ch3_callback(device_t &device, Object &&cb) + { return downcast(device).m_channel_cb[2].set_callback(std::forward(cb)); } + + template static devcb_base &set_ch4_callback(device_t &device, Object &&cb) + { return downcast(device).m_channel_cb[3].set_callback(std::forward(cb)); } + + DECLARE_READ8_MEMBER(read); + DECLARE_WRITE8_MEMBER(write); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + +private: + uint8_t clamp(int value); + + // callbacks + devcb_write_line m_intr_cb; + devcb_read8 m_channel_cb[4]; + + emu_timer *m_conversion_timer; + + // state + int m_channel; + uint8_t m_result; +}; + +// device type definition +DECLARE_DEVICE_TYPE(ADC0844, adc0844_device) + +#endif // MAME_DEVICES_MACHINE_ADC0844_H diff --git a/src/mame/drivers/einstein.cpp b/src/mame/drivers/einstein.cpp index 2ca3b932ed4..84bbef0cbc3 100644 --- a/src/mame/drivers/einstein.cpp +++ b/src/mame/drivers/einstein.cpp @@ -1,80 +1,153 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker, Dirk Best, Phill Harvey-Smith +// license: GPL-2.0+ +// copyright-holders: Kevin Thacker, Dirk Best, Phill Harvey-Smith +// thanks-to: Chris Coxall, Andrew Dunipace /****************************************************************************** Tatung Einstein - TMS9129 VDP Graphics - 16k ram - - Z80 CPU (4 MHz) - - Z80 CTC (4 MHz) - channel 0 is serial transmit clock - channel 1 is serial receive clock - trigger for channel 0,1 and 2 is a 2 MHz clock - trigger for channel 3 is the terminal count of channel 2 - - Intel 8251 Serial (2 MHz clock?) - - WD1770 Floppy Disc controller - density is fixed, 4 drives and double sided supported - - AY-3-8910 PSG (2 MHz) - port A and port B are connected to the keyboard. Port A is keyboard - line select, Port B is data. - - printer connected to port A of PIO. /ACK from printer is connected to /ASTB. - D7-D0 of PIO port A is printer data lines. - ARDY of PIO is connected to /STROBE on printer. - - user port is port B of PIO - keyboard connected to port A and port B of PSG - TODO: - - The ADC is not emulated! - - printer emulation needs checking! - - Many thanks to Chris Coxall for the schematics of the TC-01, the dump of the - system rom and a dump of a Xtal boot disc. - - Many thanks to Andrew Dunipace for his help with the 80-column card - and Speculator hardware (Spectrum emulator). - - Kevin Thacker [MESS driver] - - - 2011-Mar-14, Phill Harvey-Smith. - Having traced out the circuit of the TK02 80 coumn card, I have changed the - emulation to match what the hardware does, the emulation was mostly correct, - just some minor issues with the addressing of the VRAM, and bit 0 of the - status register is the latched output of the 6845 DE, and not vblank. - - Also added defines to stop the log being flooded with keyboard messages :) + - Verify centronics printer + - Hook up RS232 port + - Einstein 256 support ******************************************************************************/ #include "emu.h" -#include "includes/einstein.h" - #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" +#include "cpu/z80/z80daisy_generic.h" +#include "bus/centronics/ctronics.h" +#include "bus/einstein/pipe/pipe.h" #include "bus/einstein/userport/userport.h" +#include "machine/adc0844.h" #include "machine/clock.h" +#include "machine/i8251.h" +#include "machine/ram.h" +#include "machine/timer.h" +#include "machine/wd_fdc.h" +#include "machine/z80ctc.h" #include "machine/z80pio.h" +#include "video/tms9928a.h" #include "sound/ay8910.h" +#include "screen.h" #include "softlist.h" #include "speaker.h" +/*************************************************************************** + CONSTANTS +***************************************************************************/ + #define VERBOSE_KEYBOARD 0 #define VERBOSE_DISK 0 +#define XTAL_X001 XTAL_10_738635MHz +#define XTAL_X002 XTAL_8MHz + +#define IC_I001 "i001" /* Z8400A */ +#define IC_I030 "i030" /* AY-3-8910 */ +#define IC_I038 "i038" /* TMM9129 */ +#define IC_I042 "i042" /* WD1770-PH */ +#define IC_I050 "i050" /* ADC0844CCN */ +#define IC_I058 "i058" /* Z8430A */ +#define IC_I060 "i060" /* uPD8251A */ +#define IC_I063 "i063" /* Z8420A */ + + +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +class einstein_state : public driver_device +{ +public: + einstein_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag), + m_maincpu(*this, IC_I001), + m_keyboard_daisy(*this, "keyboard_daisy"), + m_adc_daisy(*this, "adc_daisy"), + m_fire_daisy(*this, "fire_daisy"), + m_pipe(*this, "pipe"), + m_fdc(*this, IC_I042), + m_ram(*this, RAM_TAG), + m_psg(*this, IC_I030), + m_centronics(*this, "centronics"), + m_bios(*this, "bios"), + m_bank1(*this, "bank1"), + m_bank2(*this, "bank2"), + m_bank3(*this, "bank3"), + m_floppy{ { *this, IC_I042 ":0" }, { *this, IC_I042 ":1" }, { *this, IC_I042 ":2" }, { *this, IC_I042 ":3" } }, + m_line(*this, "LINE%u", 0), + m_extra(*this, "EXTRA"), + m_buttons(*this, "BUTTONS"), + m_rom_enabled(0), + m_keyboard_line(0), m_keyboard_data(0xff), + m_centronics_busy(0), m_centronics_perror(0), m_centronics_fault(0) + {} + + DECLARE_INPUT_CHANGED_MEMBER(joystick_button); + TIMER_DEVICE_CALLBACK_MEMBER(keyboard_timer_callback); + DECLARE_WRITE8_MEMBER(keyboard_line_write); + DECLARE_READ8_MEMBER(keyboard_data_read); + DECLARE_READ8_MEMBER(reset_r); + DECLARE_WRITE8_MEMBER(reset_w); + DECLARE_READ8_MEMBER(rom_r); + DECLARE_WRITE8_MEMBER(rom_w); + DECLARE_READ8_MEMBER(kybint_msk_r); + DECLARE_WRITE8_MEMBER(kybint_msk_w); + DECLARE_WRITE8_MEMBER(adcint_msk_w); + DECLARE_WRITE8_MEMBER(fireint_msk_w); + DECLARE_WRITE8_MEMBER(drsel_w); + DECLARE_WRITE_LINE_MEMBER(write_centronics_busy); + DECLARE_WRITE_LINE_MEMBER(write_centronics_perror); + DECLARE_WRITE_LINE_MEMBER(write_centronics_fault); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + +private: + void einstein_scan_keyboard(); + + required_device m_maincpu; + required_device m_keyboard_daisy; + required_device m_adc_daisy; + required_device m_fire_daisy; + required_device m_pipe; + required_device m_fdc; + required_device m_ram; + required_device m_psg; + required_device m_centronics; + required_memory_region m_bios; + required_memory_bank m_bank1; + required_memory_bank m_bank2; + required_memory_bank m_bank3; + required_device m_floppy[4]; + required_ioport_array<8> m_line; + required_ioport m_extra; + required_ioport m_buttons; + + int m_rom_enabled; + + uint8_t m_keyboard_line; + uint8_t m_keyboard_data; + + int m_centronics_busy; + int m_centronics_perror; + int m_centronics_fault; +}; + /*************************************************************************** KEYBOARD ***************************************************************************/ +INPUT_CHANGED_MEMBER( einstein_state::joystick_button ) +{ + int button_down = (m_buttons->read() & 0x03) != 0x03; + m_fire_daisy->int_w(button_down ? ASSERT_LINE : CLEAR_LINE); +} + /* refresh keyboard data. It is refreshed when the keyboard line is written */ void einstein_state::einstein_scan_keyboard() { @@ -92,26 +165,16 @@ void einstein_state::einstein_scan_keyboard() m_keyboard_data = data; } -TIMER_DEVICE_CALLBACK_MEMBER(einstein_state::einstein_keyboard_timer_callback) +TIMER_DEVICE_CALLBACK_MEMBER( einstein_state::keyboard_timer_callback ) { /* re-scan keyboard */ einstein_scan_keyboard(); - /* if /fire1 or /fire2 is 0, signal a fire interrupt */ - if ((m_buttons->read() & 0x03) != 0) - { - m_interrupt |= EINSTEIN_FIRE_INT; - } - - /* keyboard data changed? */ if (m_keyboard_data != 0xff) - { - /* generate interrupt */ - m_interrupt |= EINSTEIN_KEY_INT; - } + m_keyboard_daisy->int_w(ASSERT_LINE); } -WRITE8_MEMBER(einstein_state::einstein_keyboard_line_write) +WRITE8_MEMBER( einstein_state::keyboard_line_write ) { if (VERBOSE_KEYBOARD) logerror("einstein_keyboard_line_write: %02x\n", data); @@ -122,7 +185,7 @@ WRITE8_MEMBER(einstein_state::einstein_keyboard_line_write) einstein_scan_keyboard(); } -READ8_MEMBER(einstein_state::einstein_keyboard_data_read) +READ8_MEMBER( einstein_state::keyboard_data_read ) { /* re-scan the keyboard */ einstein_scan_keyboard(); @@ -138,10 +201,10 @@ READ8_MEMBER(einstein_state::einstein_keyboard_data_read) FLOPPY DRIVES ***************************************************************************/ -WRITE8_MEMBER(einstein_state::einstein_drsel_w) +WRITE8_MEMBER(einstein_state::drsel_w) { if (VERBOSE_DISK) - logerror("%s: einstein_drsel_w %02x\n", machine().describe_context(), data); + logerror("%s: drsel_w %02x\n", machine().describe_context(), data); floppy_image_device *floppy = nullptr; @@ -158,53 +221,9 @@ WRITE8_MEMBER(einstein_state::einstein_drsel_w) /*************************************************************************** - UART + CENTRONICS ***************************************************************************/ -WRITE_LINE_MEMBER(einstein_state::einstein_serial_transmit_clock) -{ - m_uart->write_txc(state); -} - -WRITE_LINE_MEMBER(einstein_state::einstein_serial_receive_clock) -{ - m_uart->write_rxc(state); -} - - -/*************************************************************************** - MEMORY BANKING -***************************************************************************/ - -void einstein_state::einstein_page_rom() -{ - m_bank1->set_base(m_rom_enabled ? m_region_bios->base() : m_ram->pointer()); -} - -/* writing to this port is a simple trigger, and switches between RAM and ROM */ -WRITE8_MEMBER(einstein_state::einstein_rom_w) -{ - m_rom_enabled ^= 1; - einstein_page_rom(); -} - - -/*************************************************************************** - INTERRUPTS -***************************************************************************/ - -/* int priority */ -/* keyboard int->ctc/adc->pio */ -static const z80_daisy_config einstein_daisy_chain[] = -{ - { "keyboard_daisy" }, - { IC_I058 }, - { "adc_daisy" }, - { IC_I063 }, - { "fire_daisy" }, - { nullptr } -}; - WRITE_LINE_MEMBER(einstein_state::write_centronics_busy) { m_centronics_busy = state; @@ -220,15 +239,30 @@ WRITE_LINE_MEMBER(einstein_state::write_centronics_fault) m_centronics_fault = state; } -READ8_MEMBER(einstein_state::einstein_kybintmsk_r) + +/*************************************************************************** + INTERRUPTS +***************************************************************************/ + +static const z80_daisy_config einstein_daisy_chain[] = +{ + { "keyboard_daisy" }, + { IC_I058 }, + { "adc_daisy" }, + { IC_I063 }, + { "fire_daisy" }, + { nullptr } +}; + +READ8_MEMBER( einstein_state::kybint_msk_r ) { uint8_t data = 0; - /* clear key int. a read of this I/O port will do this or a reset */ - m_interrupt &= ~EINSTEIN_KEY_INT; + // reading this port clears the keyboard interrupt + m_keyboard_daisy->int_w(CLEAR_LINE); /* bit 0 and 1: fire buttons on the joysticks */ - data |= m_buttons->read(); + data |= m_buttons->read() & 0x03; /* bit 2 to 4: printer status */ data |= m_centronics_busy << 2; @@ -239,62 +273,27 @@ READ8_MEMBER(einstein_state::einstein_kybintmsk_r) data |= m_extra->read(); if(VERBOSE_KEYBOARD) - logerror("%s: einstein_kybintmsk_r %02x\n", machine().describe_context(), data); + logerror("%s: kybint_msk_r %02x\n", machine().describe_context(), data); return data; } -WRITE8_MEMBER(einstein_state::einstein_kybintmsk_w) +WRITE8_MEMBER( einstein_state::kybint_msk_w ) { - logerror("%s: einstein_kybintmsk_w %02x\n", machine().describe_context(), data); - - /* set mask from bit 0 */ - if (data & 0x01) - { - logerror("key int is disabled\n"); - m_interrupt_mask &= ~EINSTEIN_KEY_INT; - } - else - { - logerror("key int is enabled\n"); - m_interrupt_mask |= EINSTEIN_KEY_INT; - } + logerror("KEY interrupt %s\n", BIT(data, 0) ? "disabled" : "enabled"); + m_keyboard_daisy->mask_w(BIT(data, 0)); } -/* writing to this I/O port sets the state of the mask; D0 is used */ -/* writing 0 enables the /ADC interrupt */ -WRITE8_MEMBER(einstein_state::einstein_adcintmsk_w) +WRITE8_MEMBER( einstein_state::adcint_msk_w ) { - logerror("%s: einstein_adcintmsk_w %02x\n", machine().describe_context(), data); - - if (data & 0x01) - { - logerror("adc int is disabled\n"); - m_interrupt_mask &= ~EINSTEIN_ADC_INT; - } - else - { - logerror("adc int is enabled\n"); - m_interrupt_mask |= EINSTEIN_ADC_INT; - } + logerror("ADC interrupt %s\n", BIT(data, 0) ? "disabled" : "enabled"); + m_adc_daisy->mask_w(BIT(data, 0)); } -/* writing to this I/O port sets the state of the mask; D0 is used */ -/* writing 0 enables the /FIRE interrupt */ -WRITE8_MEMBER(einstein_state::einstein_fire_int_w) +WRITE8_MEMBER( einstein_state::fireint_msk_w ) { - logerror("%s: einstein_fire_int_w %02x\n", machine().describe_context(), data); - - if (data & 0x01) - { - logerror("fire int is disabled\n"); - m_interrupt_mask &= ~EINSTEIN_FIRE_INT; - } - else - { - logerror("fire int is enabled\n"); - m_interrupt_mask |= EINSTEIN_FIRE_INT; - } + logerror("FIRE interrupt %s\n", BIT(data, 0) ? "disabled" : "enabled"); + m_fire_daisy->mask_w(BIT(data, 0)); } @@ -302,8 +301,42 @@ WRITE8_MEMBER(einstein_state::einstein_fire_int_w) MACHINE EMULATION ***************************************************************************/ +READ8_MEMBER( einstein_state::rom_r ) +{ + m_rom_enabled ^= 1; + m_bank1->set_entry(m_rom_enabled); + + return 0xff; +} + +WRITE8_MEMBER( einstein_state::rom_w ) +{ + m_rom_enabled ^= 1; + m_bank1->set_entry(m_rom_enabled); +} + +READ8_MEMBER( einstein_state::reset_r ) +{ + m_psg->reset(); + m_fdc->reset(); + + return 0xff; +} + +WRITE8_MEMBER( einstein_state::reset_w ) +{ + m_psg->reset(); + m_fdc->reset(); +} + void einstein_state::machine_start() { + // initialize memory mapping + m_bank1->configure_entry(0, m_ram->pointer()); + m_bank1->configure_entry(1, m_bios->base()); + m_bank2->set_base(m_ram->pointer()); + m_bank3->set_base(m_ram->pointer() + 0x8000); + // setup expansion slot m_pipe->set_program_space(&m_maincpu->space(AS_PROGRAM)); m_pipe->set_io_space(&m_maincpu->space(AS_IO)); @@ -311,16 +344,14 @@ void einstein_state::machine_start() void einstein_state::machine_reset() { - /* initialize memory mapping */ - m_bank2->set_base(m_ram->pointer()); - m_bank3->set_base(m_ram->pointer() + 0x8000); + // rom enabled on reset m_rom_enabled = 1; - einstein_page_rom(); + m_bank1->set_entry(m_rom_enabled); - /* a reset causes the fire int, adc int, keyboard int mask - to be set to 1, which causes all these to be DISABLED */ - m_interrupt = 0; - m_interrupt_mask = 0; + // interrupt mask enabled + m_keyboard_daisy->mask_w(1); + m_adc_daisy->mask_w(1); + m_fire_daisy->mask_w(1); } @@ -333,34 +364,25 @@ static ADDRESS_MAP_START( einstein_mem, AS_PROGRAM, 8, einstein_state ) AM_RANGE(0x8000, 0x0ffff) AM_RAMBANK("bank3") ADDRESS_MAP_END -/* The I/O ports are decoded into 8 blocks using address lines A3 to A7 */ +// I/O ports are decoded into 8 blocks using address lines A3 to A7 static ADDRESS_MAP_START( einstein_io, AS_IO, 8, einstein_state ) ADDRESS_MAP_UNMAP_HIGH - /* block 0, ay8910 psg */ + AM_RANGE(0x00, 0x00) AM_MIRROR(0xff04) AM_READWRITE(reset_r, reset_w) AM_RANGE(0x02, 0x02) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I030, ay8910_device, data_r, address_w) AM_RANGE(0x03, 0x03) AM_MIRROR(0xff04) AM_DEVWRITE(IC_I030, ay8910_device, data_w) - /* block 1, tms9928a vdp */ - AM_RANGE(0x08, 0x08) AM_MIRROR(0xff06) AM_DEVREADWRITE("tms9929a", tms9929a_device, vram_read, vram_write) - AM_RANGE(0x09, 0x09) AM_MIRROR(0xff06) AM_DEVREADWRITE("tms9929a", tms9929a_device, register_read, register_write) - /* block 2, i8251 uart */ + AM_RANGE(0x08, 0x08) AM_MIRROR(0xff06) AM_DEVREADWRITE("vdp", tms9129_device, vram_read, vram_write) + AM_RANGE(0x09, 0x09) AM_MIRROR(0xff06) AM_DEVREADWRITE("vdp", tms9129_device, register_read, register_write) AM_RANGE(0x10, 0x10) AM_MIRROR(0xff06) AM_DEVREADWRITE(IC_I060, i8251_device, data_r, data_w) AM_RANGE(0x11, 0x11) AM_MIRROR(0xff06) AM_DEVREADWRITE(IC_I060, i8251_device, status_r, control_w) - /* block 3, wd1770 floppy controller */ AM_RANGE(0x18, 0x1b) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I042, wd1770_device, read, write) - /* block 4, internal controls */ - AM_RANGE(0x20, 0x20) AM_MIRROR(0xff00) AM_READWRITE(einstein_kybintmsk_r, einstein_kybintmsk_w) - AM_RANGE(0x21, 0x21) AM_MIRROR(0xff00) AM_WRITE(einstein_adcintmsk_w) - AM_RANGE(0x23, 0x23) AM_MIRROR(0xff00) AM_WRITE(einstein_drsel_w) - AM_RANGE(0x24, 0x24) AM_MIRROR(0xff00) AM_WRITE(einstein_rom_w) - AM_RANGE(0x25, 0x25) AM_MIRROR(0xff00) AM_WRITE(einstein_fire_int_w) - /* block 5, z80ctc */ + AM_RANGE(0x20, 0x20) AM_MIRROR(0xff00) AM_READWRITE(kybint_msk_r, kybint_msk_w) + AM_RANGE(0x21, 0x21) AM_MIRROR(0xff00) AM_WRITE(adcint_msk_w) + AM_RANGE(0x23, 0x23) AM_MIRROR(0xff00) AM_WRITE(drsel_w) + AM_RANGE(0x24, 0x24) AM_MIRROR(0xff00) AM_READWRITE(rom_r, rom_w) + AM_RANGE(0x25, 0x25) AM_MIRROR(0xff00) AM_WRITE(fireint_msk_w) AM_RANGE(0x28, 0x2b) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I058, z80ctc_device, read, write) - /* block 6, z80pio */ AM_RANGE(0x30, 0x33) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I063, z80pio_device, read_alt, write_alt) -#if 0 - /* block 7, adc */ - AM_RANGE(0x38, 0x38) AM_MIRROR(0xff07) AM_DEVREADWRITE_LEGACY(IC_I050, adc0844_r, adc0844_w) -#endif + AM_RANGE(0x38, 0x38) AM_MIRROR(0xff07) AM_DEVREADWRITE("adc", adc0844_device, read, write) ADDRESS_MAP_END @@ -455,27 +477,31 @@ static INPUT_PORTS_START( einstein ) PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CONTROL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) - /* fire buttons for analogue joysticks */ + // fire buttons for analogue joysticks PORT_START("BUTTONS") - PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 1 Button 1") PORT_PLAYER(1) - PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 2 Button 1") PORT_PLAYER(2) + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 1 Button 1") PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, einstein_state, joystick_button, nullptr) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 2 Button 1") PORT_PLAYER(2) PORT_CHANGED_MEMBER(DEVICE_SELF, einstein_state, joystick_button, nullptr) PORT_BIT(0xfc, IP_ACTIVE_HIGH, IPT_UNUSED) - /* analog joystick 1 x axis */ - PORT_START("JOY1_X") - PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_REVERSE + PORT_START("analogue_1_x") + PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(100) PORT_CENTERDELTA(100) PORT_MINMAX(0,0xff) PORT_PLAYER(1) + PORT_CODE_DEC(KEYCODE_4_PAD) PORT_CODE_INC(KEYCODE_6_PAD) + PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) - /* analog joystick 1 y axis */ - PORT_START("JOY1_Y") - PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(1) PORT_REVERSE + PORT_START("analogue_1_y") + PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(100) PORT_CENTERDELTA(100) PORT_MINMAX(0,0xff) PORT_PLAYER(1) + PORT_CODE_DEC(KEYCODE_8_PAD) PORT_CODE_INC(KEYCODE_2_PAD) + PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) + PORT_REVERSE - /* analog joystick 2 x axis */ - PORT_START("JOY2_X") - PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(2) PORT_REVERSE + PORT_START("analogue_2_x") + PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(100) PORT_CENTERDELTA(100) PORT_MINMAX(0,0xff) PORT_PLAYER(2) + PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) - /* analog joystick 2 Y axis */ - PORT_START("JOY2_Y") - PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE + PORT_START("analogue_2_y") + PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(100) PORT_CENTERDELTA(100) PORT_MINMAX(0,0xff) PORT_PLAYER(2) + PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) + PORT_REVERSE INPUT_PORTS_END @@ -501,7 +527,7 @@ static MACHINE_CONFIG_START( einstein ) /* this is actually clocked at the system clock 4 MHz, but this would be too fast for our driver. So we update at 50Hz and hope this is good enough. */ - MCFG_TIMER_DRIVER_ADD_PERIODIC("keyboard", einstein_state, einstein_keyboard_timer_callback, attotime::from_hz(50)) + MCFG_TIMER_DRIVER_ADD_PERIODIC("keyboard", einstein_state, keyboard_timer_callback, attotime::from_hz(50)) MCFG_DEVICE_ADD(IC_I063, Z80PIO, XTAL_X002 / 2) MCFG_Z80PIO_OUT_INT_CB(INPUTLINE(IC_I001, INPUT_LINE_IRQ0)) @@ -513,8 +539,8 @@ static MACHINE_CONFIG_START( einstein ) MCFG_DEVICE_ADD(IC_I058, Z80CTC, XTAL_X002 / 2) MCFG_Z80CTC_INTR_CB(INPUTLINE(IC_I001, INPUT_LINE_IRQ0)) - MCFG_Z80CTC_ZC0_CB(WRITELINE(einstein_state, einstein_serial_transmit_clock)) - MCFG_Z80CTC_ZC1_CB(WRITELINE(einstein_state, einstein_serial_receive_clock)) + MCFG_Z80CTC_ZC0_CB(DEVWRITELINE(IC_I060, i8251_device, write_txc)) + MCFG_Z80CTC_ZC1_CB(DEVWRITELINE(IC_I060, i8251_device, write_rxc)) MCFG_Z80CTC_ZC2_CB(DEVWRITELINE(IC_I058, z80ctc_device, trg3)) MCFG_CLOCK_ADD("ctc_trigger", XTAL_X002 / 4) @@ -523,24 +549,31 @@ static MACHINE_CONFIG_START( einstein ) MCFG_DEVCB_CHAIN_OUTPUT(DEVWRITELINE(IC_I058, z80ctc_device, trg2)) /* Einstein daisy chain support for non-Z80 devices */ - MCFG_DEVICE_ADD("keyboard_daisy", EINSTEIN_KEYBOARD_DAISY, 0) - MCFG_DEVICE_ADD("adc_daisy", EINSTEIN_ADC_DAISY, 0) - MCFG_DEVICE_ADD("fire_daisy", EINSTEIN_FIRE_DAISY, 0) + MCFG_Z80DAISY_GENERIC_ADD("keyboard_daisy", 0xf7) + MCFG_Z80DAISY_GENERIC_ADD("adc_daisy", 0xfb) + MCFG_Z80DAISY_GENERIC_ADD("fire_daisy", 0xfd) /* video hardware */ - MCFG_DEVICE_ADD( "tms9929a", TMS9929A, XTAL_10_738635MHz / 2 ) - MCFG_TMS9928A_VRAM_SIZE(0x4000) /* 16k RAM, provided by IC i040 and i041 */ + MCFG_DEVICE_ADD("vdp", TMS9129, XTAL_10_738635MHz / 2) + MCFG_TMS9928A_VRAM_SIZE(0x4000) // 16k RAM, provided by IC i040 and i041 MCFG_TMS9928A_SET_SCREEN("screen") MCFG_TMS9928A_SCREEN_ADD_PAL("screen") - MCFG_SCREEN_UPDATE_DEVICE("tms9929a", tms9929a_device, screen_update) + MCFG_SCREEN_UPDATE_DEVICE("vdp", tms9129_device, screen_update) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD(IC_I030, AY8910, XTAL_X002 / 4) - MCFG_AY8910_PORT_B_READ_CB(READ8(einstein_state, einstein_keyboard_data_read)) - MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(einstein_state, einstein_keyboard_line_write)) + MCFG_AY8910_PORT_B_READ_CB(READ8(einstein_state, keyboard_data_read)) + MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(einstein_state, keyboard_line_write)) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) + MCFG_ADC0844_ADD("adc") + MCFG_ADC0844_INTR_CB(DEVWRITELINE("adc_daisy", z80daisy_generic_device, int_w)) + MCFG_ADC0844_CH1_CB(IOPORT("analogue_1_x")) + MCFG_ADC0844_CH2_CB(IOPORT("analogue_1_y")) + MCFG_ADC0844_CH3_CB(IOPORT("analogue_2_x")) + MCFG_ADC0844_CH4_CB(IOPORT("analogue_2_y")) + /* printer */ MCFG_CENTRONICS_ADD("centronics", centronics_devices, "printer") MCFG_CENTRONICS_ACK_HANDLER(DEVWRITELINE(IC_I063, z80pio_device, strobe_a)) diff --git a/src/mame/includes/einstein.h b/src/mame/includes/einstein.h deleted file mode 100644 index e446a512c59..00000000000 --- a/src/mame/includes/einstein.h +++ /dev/null @@ -1,186 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker, Dirk Best, Phill Harvey-Smith -/*************************************************************************** - - Tatung Einstein - -***************************************************************************/ - -#ifndef MAME_INCLUDES_EINSTEIN_H -#define MAME_INCLUDES_EINSTEIN_H - -#pragma once - -#include "cpu/z80/z80daisy.h" -#include "bus/einstein/pipe/pipe.h" -#include "machine/timer.h" -#include "machine/wd_fdc.h" -#include "machine/z80ctc.h" -#include "video/tms9928a.h" -#include "machine/ram.h" -#include "machine/i8251.h" -#include "bus/centronics/ctronics.h" -#include "screen.h" - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* xtals */ -#define XTAL_X001 XTAL_10_738635MHz -#define XTAL_X002 XTAL_8MHz - -/* integrated circuits */ -#define IC_I001 "i001" /* Z8400A */ -#define IC_I030 "i030" /* AY-3-8910 */ -#define IC_I038 "i038" /* TMM9129 */ -#define IC_I042 "i042" /* WD1770-PH */ -#define IC_I050 "i050" /* ADC0844CCN */ -#define IC_I058 "i058" /* Z8430A */ -#define IC_I060 "i060" /* uPD8251A */ -#define IC_I063 "i063" /* Z8420A */ - -/* interrupt sources */ -#define EINSTEIN_KEY_INT (1<<0) -#define EINSTEIN_ADC_INT (1<<1) -#define EINSTEIN_FIRE_INT (1<<2) - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -class einstein_state : public driver_device -{ -public: - einstein_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, IC_I001), - m_pipe(*this, "pipe"), - m_fdc(*this, IC_I042), - m_uart(*this, IC_I060), - m_ram(*this, RAM_TAG), - m_centronics(*this, "centronics"), - m_region_bios(*this, "bios"), - m_bank1(*this, "bank1"), - m_bank2(*this, "bank2"), - m_bank3(*this, "bank3"), - m_floppy{ { *this, IC_I042 ":0" }, { *this, IC_I042 ":1" }, { *this, IC_I042 ":2" }, { *this, IC_I042 ":3" } }, - m_line(*this, "LINE%u", 0), - m_extra(*this, "EXTRA"), - m_buttons(*this, "BUTTONS") - { - } - - DECLARE_FLOPPY_FORMATS( floppy_formats ); - DECLARE_WRITE8_MEMBER(einstein_keyboard_line_write); - DECLARE_READ8_MEMBER(einstein_keyboard_data_read); - DECLARE_WRITE8_MEMBER(einstein_rom_w); - DECLARE_READ8_MEMBER(einstein_kybintmsk_r); - DECLARE_WRITE8_MEMBER(einstein_kybintmsk_w); - DECLARE_WRITE8_MEMBER(einstein_adcintmsk_w); - DECLARE_WRITE8_MEMBER(einstein_fire_int_w); - DECLARE_WRITE_LINE_MEMBER(write_centronics_busy); - DECLARE_WRITE_LINE_MEMBER(write_centronics_perror); - DECLARE_WRITE_LINE_MEMBER(write_centronics_fault); - TIMER_DEVICE_CALLBACK_MEMBER(einstein_keyboard_timer_callback); - DECLARE_WRITE8_MEMBER(einstein_drsel_w); - DECLARE_WRITE_LINE_MEMBER(einstein_serial_transmit_clock); - DECLARE_WRITE_LINE_MEMBER(einstein_serial_receive_clock); - - int m_interrupt; - int m_interrupt_mask; - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - -private: - required_device m_maincpu; - required_device m_pipe; - required_device m_fdc; - - int m_rom_enabled; - - /* keyboard */ - uint8_t m_keyboard_line; - uint8_t m_keyboard_data; - - int m_centronics_busy; - int m_centronics_perror; - int m_centronics_fault; - - required_device m_uart; - required_device m_ram; - required_device m_centronics; - required_memory_region m_region_bios; - required_memory_bank m_bank1; - required_memory_bank m_bank2; - required_memory_bank m_bank3; - required_device m_floppy[4]; - required_ioport_array<8> m_line; - required_ioport m_extra; - required_ioport m_buttons; - - void einstein_scan_keyboard(); - void einstein_page_rom(); -}; - - -// ======================> einstein_keyboard_daisy_device - -class einstein_keyboard_daisy_device : public device_t, public device_z80daisy_interface -{ -public: - // construction/destruction - einstein_keyboard_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -private: - virtual void device_start() override; - // z80daisy_interface overrides - virtual int z80daisy_irq_state() override; - virtual int z80daisy_irq_ack() override; - virtual void z80daisy_irq_reti() override; -}; - -DECLARE_DEVICE_TYPE(EINSTEIN_KEYBOARD_DAISY, einstein_keyboard_daisy_device) - - -// ======================> einstein_adc_daisy_device - -class einstein_adc_daisy_device : public device_t, public device_z80daisy_interface -{ -public: - // construction/destruction - einstein_adc_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -private: - virtual void device_start() override; - // z80daisy_interface overrides - virtual int z80daisy_irq_state() override; - virtual int z80daisy_irq_ack() override; - virtual void z80daisy_irq_reti() override; - -}; - -DECLARE_DEVICE_TYPE(EINSTEIN_ADC_DAISY, einstein_adc_daisy_device) - -// ======================> einstein_fire_daisy_device - -class einstein_fire_daisy_device : public device_t, public device_z80daisy_interface -{ -public: - // construction/destruction - einstein_fire_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -private: - virtual void device_start() override; - // z80daisy_interface overrides - virtual int z80daisy_irq_state() override; - virtual int z80daisy_irq_ack() override; - virtual void z80daisy_irq_reti() override; -}; - -DECLARE_DEVICE_TYPE(EINSTEIN_FIRE_DAISY, einstein_fire_daisy_device) - -#endif // MAME_INCLUDES_EINSTEIN_H diff --git a/src/mame/machine/einstein.cpp b/src/mame/machine/einstein.cpp deleted file mode 100644 index 9e2c31d8074..00000000000 --- a/src/mame/machine/einstein.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Kevin Thacker, Dirk Best, Phill Harvey-Smith -/*************************************************************************** - - Tatung Einstein - - -***************************************************************************/ - -#include "emu.h" -#include "includes/einstein.h" - -/**************************************************************** - EINSTEIN NON-Z80 DEVICES DAISY CHAIN SUPPORT -****************************************************************/ - - -DEFINE_DEVICE_TYPE(EINSTEIN_KEYBOARD_DAISY, einstein_keyboard_daisy_device, "einstein_keyboard", "Einstein keyboard daisy chain") - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// z80ctc_device - constructor -//------------------------------------------------- - -einstein_keyboard_daisy_device::einstein_keyboard_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, EINSTEIN_KEYBOARD_DAISY, tag, owner, clock) - , device_z80daisy_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void einstein_keyboard_daisy_device::device_start() -{ -} - -//************************************************************************** -// DAISY CHAIN INTERFACE -//************************************************************************** - -//------------------------------------------------- -// z80daisy_irq_state - return the overall IRQ -// state for this device -//------------------------------------------------- - -int einstein_keyboard_daisy_device::z80daisy_irq_state() -{ - einstein_state *einstein = device().machine().driver_data(); - - if (einstein->m_interrupt & einstein->m_interrupt_mask & EINSTEIN_KEY_INT) - return Z80_DAISY_INT; - - return 0; -} - - -//------------------------------------------------- -// z80daisy_irq_ack - acknowledge an IRQ and -// return the appropriate vector -//------------------------------------------------- - -int einstein_keyboard_daisy_device::z80daisy_irq_ack() -{ - return 0xf7; -} - -//------------------------------------------------- -// z80daisy_irq_reti - clear the interrupt -// pending state to allow other interrupts through -//------------------------------------------------- - -void einstein_keyboard_daisy_device::z80daisy_irq_reti() -{ -} - -DEFINE_DEVICE_TYPE(EINSTEIN_ADC_DAISY, einstein_adc_daisy_device, "einstein_adc", "Einstein ADC daisy chain") - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// z80ctc_device - constructor -//------------------------------------------------- - -einstein_adc_daisy_device::einstein_adc_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, EINSTEIN_ADC_DAISY, tag, owner, clock) - , device_z80daisy_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void einstein_adc_daisy_device::device_start() -{ -} - -//************************************************************************** -// DAISY CHAIN INTERFACE -//************************************************************************** - -//------------------------------------------------- -// z80daisy_irq_state - return the overall IRQ -// state for this device -//------------------------------------------------- - -int einstein_adc_daisy_device::z80daisy_irq_state() -{ - einstein_state *einstein = device().machine().driver_data(); - - if (einstein->m_interrupt & einstein->m_interrupt_mask & EINSTEIN_ADC_INT) - return Z80_DAISY_INT; - - return 0; -} - - -//------------------------------------------------- -// z80daisy_irq_ack - acknowledge an IRQ and -// return the appropriate vector -//------------------------------------------------- - -int einstein_adc_daisy_device::z80daisy_irq_ack() -{ - return 0xfb; -} - -//------------------------------------------------- -// z80daisy_irq_reti - clear the interrupt -// pending state to allow other interrupts through -//------------------------------------------------- - -void einstein_adc_daisy_device::z80daisy_irq_reti() -{ -} - - -DEFINE_DEVICE_TYPE(EINSTEIN_FIRE_DAISY, einstein_fire_daisy_device, "einstein_fire", "Einstein fire button daisy chain") - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// z80ctc_device - constructor -//------------------------------------------------- - -einstein_fire_daisy_device::einstein_fire_daisy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, EINSTEIN_FIRE_DAISY, tag, owner, clock) - , device_z80daisy_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void einstein_fire_daisy_device::device_start() -{ -} - -//************************************************************************** -// DAISY CHAIN INTERFACE -//************************************************************************** - -//------------------------------------------------- -// z80daisy_irq_state - return the overall IRQ -// state for this device -//------------------------------------------------- - -int einstein_fire_daisy_device::z80daisy_irq_state() -{ - einstein_state *einstein = device().machine().driver_data(); - - if (einstein->m_interrupt & einstein->m_interrupt_mask & EINSTEIN_FIRE_INT) - return Z80_DAISY_INT; - - return 0; -} - - -//------------------------------------------------- -// z80daisy_irq_ack - acknowledge an IRQ and -// return the appropriate vector -//------------------------------------------------- - -int einstein_fire_daisy_device::z80daisy_irq_ack() -{ - return 0xfd; -} - -//------------------------------------------------- -// z80daisy_irq_reti - clear the interrupt -// pending state to allow other interrupts through -//------------------------------------------------- - -void einstein_fire_daisy_device::z80daisy_irq_reti() -{ -}