From 4ee376d98959b1da2dcbedc13bffe086f949d499 Mon Sep 17 00:00:00 2001 From: Dirk Best Date: Sun, 29 Oct 2017 20:04:36 +0100 Subject: einstein: Move pipe bus to its own directory --- scripts/src/bus.lua | 10 +- src/devices/bus/einstein/pipe.cpp | 119 ----------------- src/devices/bus/einstein/pipe.h | 135 ------------------- src/devices/bus/einstein/pipe/pipe.cpp | 119 +++++++++++++++++ src/devices/bus/einstein/pipe/pipe.h | 135 +++++++++++++++++++ src/devices/bus/einstein/pipe/tk02.cpp | 231 +++++++++++++++++++++++++++++++++ src/devices/bus/einstein/pipe/tk02.h | 61 +++++++++ src/devices/bus/einstein/tk02.cpp | 231 --------------------------------- src/devices/bus/einstein/tk02.h | 61 --------- src/mame/includes/einstein.h | 2 +- 10 files changed, 552 insertions(+), 552 deletions(-) delete mode 100644 src/devices/bus/einstein/pipe.cpp delete mode 100644 src/devices/bus/einstein/pipe.h create mode 100644 src/devices/bus/einstein/pipe/pipe.cpp create mode 100644 src/devices/bus/einstein/pipe/pipe.h create mode 100644 src/devices/bus/einstein/pipe/tk02.cpp create mode 100644 src/devices/bus/einstein/pipe/tk02.h delete mode 100644 src/devices/bus/einstein/tk02.cpp delete mode 100644 src/devices/bus/einstein/tk02.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 8c49e202ec5..36dc17f43e0 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -3283,14 +3283,14 @@ end --------------------------------------------------- -- ---@src/devices/bus/einstein/pipe.h,BUSES["TATUNG_PIPE"] = true +--@src/devices/bus/einstein/pipe/pipe.h,BUSES["TATUNG_PIPE"] = true --------------------------------------------------- if (BUSES["TATUNG_PIPE"]~=null) then files { - MAME_DIR .. "src/devices/bus/einstein/pipe.cpp", - MAME_DIR .. "src/devices/bus/einstein/pipe.h", - MAME_DIR .. "src/devices/bus/einstein/tk02.cpp", - MAME_DIR .. "src/devices/bus/einstein/tk02.h", + MAME_DIR .. "src/devices/bus/einstein/pipe/pipe.cpp", + MAME_DIR .. "src/devices/bus/einstein/pipe/pipe.h", + MAME_DIR .. "src/devices/bus/einstein/pipe/tk02.cpp", + MAME_DIR .. "src/devices/bus/einstein/pipe/tk02.h", } end diff --git a/src/devices/bus/einstein/pipe.cpp b/src/devices/bus/einstein/pipe.cpp deleted file mode 100644 index 9a44d86dcdf..00000000000 --- a/src/devices/bus/einstein/pipe.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// license: GPL-2.0+ -// copyright-holders: Dirk Best -/*************************************************************************** - - Einstein "Tatung Pipe" - -***************************************************************************/ - -#include "emu.h" -#include "pipe.h" - -// supported devices -#include "tk02.h" - - -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** - -DEFINE_DEVICE_TYPE(TATUNG_PIPE, tatung_pipe_device, "tatung_pipe", "Tatung Pipe Slot") - - -//************************************************************************** -// SLOT DEVICE -//************************************************************************** - -//------------------------------------------------- -// tatung_pipe_device - constructor -//------------------------------------------------- - -tatung_pipe_device::tatung_pipe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, TATUNG_PIPE, tag, owner, clock), - device_slot_interface(mconfig, *this), - m_program(nullptr), - m_io(nullptr), - m_card(nullptr), - m_int_handler(*this), - m_nmi_handler(*this), - m_reset_handler(*this) -{ -} - -//------------------------------------------------- -// tatung_pipe_device - destructor -//------------------------------------------------- - -tatung_pipe_device::~tatung_pipe_device() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void tatung_pipe_device::device_start() -{ - // resolve callbacks - m_int_handler.resolve_safe(); - m_nmi_handler.resolve_safe(); - m_reset_handler.resolve_safe(); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void tatung_pipe_device::device_reset() -{ -} - -//------------------------------------------------- -// set_program_space - set address space we are attached to -//------------------------------------------------- - -void tatung_pipe_device::set_program_space(address_space *program) -{ - m_program = program; -} - -//------------------------------------------------- -// set_io_space - set address space we are attached to -//------------------------------------------------- - -void tatung_pipe_device::set_io_space(address_space *io) -{ - m_io = io; -} - - -//************************************************************************** -// CARD INTERFACE -//************************************************************************** - -//------------------------------------------------- -// device_tatung_pipe_interface - constructor -//------------------------------------------------- - -device_tatung_pipe_interface::device_tatung_pipe_interface(const machine_config &mconfig, device_t &device) : - device_slot_card_interface(mconfig, device) -{ - m_slot = dynamic_cast(device.owner()); -} - -//------------------------------------------------- -// ~device_tatung_pipe_interface - destructor -//------------------------------------------------- - -device_tatung_pipe_interface::~device_tatung_pipe_interface() -{ -} - - -//************************************************************************** -// SLOT INTERFACE -//************************************************************************** - -SLOT_INTERFACE_START( tatung_pipe_cards ) - SLOT_INTERFACE("tk02", TK02_80COL) -SLOT_INTERFACE_END diff --git a/src/devices/bus/einstein/pipe.h b/src/devices/bus/einstein/pipe.h deleted file mode 100644 index d9911ff94d7..00000000000 --- a/src/devices/bus/einstein/pipe.h +++ /dev/null @@ -1,135 +0,0 @@ -// license: GPL-2.0+ -// copyright-holders: Dirk Best -/*************************************************************************** - - Einstein "Tatung Pipe" - - 60-pin slot - - +5V 1 2 D7 - +5V 3 4 D6 - GND 5 6 D5 - GND 7 8 D4 - GND 9 10 D3 - GND 11 12 D2 - GND 13 14 D1 - GND 15 16 D0 - GND 17 18 A15 - A14 19 20 A13 - A12 21 22 A11 - A10 23 24 A9 - A8 25 26 A7 - A6 27 28 A5 - A4 29 30 A3 - A2 31 32 A1 - A0 33 34 /RESET - GND 35 36 /RFSH - GND 37 38 /M1 - GND 39 40 /BUSACK - GND 41 42 /WR - GND 43 44 /RD - GND 45 46 /IORQ - GND 47 48 /MREQ - GND 49 50 /HALT - GND 51 52 /NMI - GND 53 54 /INT - GND 55 56 /WAIT - GND 57 58 /BUSREQ - GND 59 60 SYSCLK - -***************************************************************************/ - -#ifndef MAME_BUS_EINSTEIN_PIPE_H -#define MAME_BUS_EINSTEIN_PIPE_H - -#pragma once - - -//************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_TATUNG_PIPE_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, TATUNG_PIPE, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(tatung_pipe_cards, nullptr, false) - -#define MCFG_TATUNG_PIPE_INT_HANDLER(_devcb) \ - devcb = &tatung_pipe_device::set_int_handler(*device, DEVCB_##_devcb); - -#define MCFG_TATUNG_PIPE_NMI_HANDLER(_devcb) \ - devcb = &tatung_pipe_device::set_nmi_handler(*device, DEVCB_##_devcb); - -#define MCFG_TATUNG_PIPE_RESET_HANDLER(_devcb) \ - devcb = &tatung_pipe_device::set_reset_handler(*device, DEVCB_##_devcb); - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -class device_tatung_pipe_interface; - -class tatung_pipe_device : public device_t, public device_slot_interface -{ - friend class device_tatung_pipe_interface; -public: - // construction/destruction - tatung_pipe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual ~tatung_pipe_device(); - - void set_program_space(address_space *program); - void set_io_space(address_space *io); - - // callbacks - template static devcb_base &set_int_handler(device_t &device, Object &&cb) - { return downcast(device).m_int_handler.set_callback(std::forward(cb)); } - - template static devcb_base &set_nmi_handler(device_t &device, Object &&cb) - { return downcast(device).m_nmi_handler.set_callback(std::forward(cb)); } - - template static devcb_base &set_reset_handler(device_t &device, Object &&cb) - { return downcast(device).m_reset_handler.set_callback(std::forward(cb)); } - - // called from card device - DECLARE_WRITE_LINE_MEMBER( int_w ) { m_int_handler(state); } - DECLARE_WRITE_LINE_MEMBER( nmi_w ) { m_nmi_handler(state); } - DECLARE_WRITE_LINE_MEMBER( reset_w ) { m_reset_handler(state); } - -protected: - // device-level overrides - virtual void device_start() override; - virtual void device_reset() override; - - address_space *m_program; - address_space *m_io; - - device_tatung_pipe_interface *m_card; - -private: - devcb_write_line m_int_handler; - devcb_write_line m_nmi_handler; - devcb_write_line m_reset_handler; -}; - -// class representing interface-specific live pipe device -class device_tatung_pipe_interface : public device_slot_card_interface -{ -public: - // construction/destruction - device_tatung_pipe_interface(const machine_config &mconfig, device_t &device); - virtual ~device_tatung_pipe_interface(); - -protected: - address_space &program_space() { return *m_slot->m_program; } - address_space &io_space() { return *m_slot->m_io; } - - tatung_pipe_device *m_slot; -}; - -// device type definition -DECLARE_DEVICE_TYPE(TATUNG_PIPE, tatung_pipe_device) - -// supported devices -SLOT_INTERFACE_EXTERN(tatung_pipe_cards); - -#endif // MAME_BUS_EINSTEIN_PIPE_H diff --git a/src/devices/bus/einstein/pipe/pipe.cpp b/src/devices/bus/einstein/pipe/pipe.cpp new file mode 100644 index 00000000000..9a44d86dcdf --- /dev/null +++ b/src/devices/bus/einstein/pipe/pipe.cpp @@ -0,0 +1,119 @@ +// license: GPL-2.0+ +// copyright-holders: Dirk Best +/*************************************************************************** + + Einstein "Tatung Pipe" + +***************************************************************************/ + +#include "emu.h" +#include "pipe.h" + +// supported devices +#include "tk02.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(TATUNG_PIPE, tatung_pipe_device, "tatung_pipe", "Tatung Pipe Slot") + + +//************************************************************************** +// SLOT DEVICE +//************************************************************************** + +//------------------------------------------------- +// tatung_pipe_device - constructor +//------------------------------------------------- + +tatung_pipe_device::tatung_pipe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, TATUNG_PIPE, tag, owner, clock), + device_slot_interface(mconfig, *this), + m_program(nullptr), + m_io(nullptr), + m_card(nullptr), + m_int_handler(*this), + m_nmi_handler(*this), + m_reset_handler(*this) +{ +} + +//------------------------------------------------- +// tatung_pipe_device - destructor +//------------------------------------------------- + +tatung_pipe_device::~tatung_pipe_device() +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void tatung_pipe_device::device_start() +{ + // resolve callbacks + m_int_handler.resolve_safe(); + m_nmi_handler.resolve_safe(); + m_reset_handler.resolve_safe(); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void tatung_pipe_device::device_reset() +{ +} + +//------------------------------------------------- +// set_program_space - set address space we are attached to +//------------------------------------------------- + +void tatung_pipe_device::set_program_space(address_space *program) +{ + m_program = program; +} + +//------------------------------------------------- +// set_io_space - set address space we are attached to +//------------------------------------------------- + +void tatung_pipe_device::set_io_space(address_space *io) +{ + m_io = io; +} + + +//************************************************************************** +// CARD INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_tatung_pipe_interface - constructor +//------------------------------------------------- + +device_tatung_pipe_interface::device_tatung_pipe_interface(const machine_config &mconfig, device_t &device) : + device_slot_card_interface(mconfig, device) +{ + m_slot = dynamic_cast(device.owner()); +} + +//------------------------------------------------- +// ~device_tatung_pipe_interface - destructor +//------------------------------------------------- + +device_tatung_pipe_interface::~device_tatung_pipe_interface() +{ +} + + +//************************************************************************** +// SLOT INTERFACE +//************************************************************************** + +SLOT_INTERFACE_START( tatung_pipe_cards ) + SLOT_INTERFACE("tk02", TK02_80COL) +SLOT_INTERFACE_END diff --git a/src/devices/bus/einstein/pipe/pipe.h b/src/devices/bus/einstein/pipe/pipe.h new file mode 100644 index 00000000000..d9911ff94d7 --- /dev/null +++ b/src/devices/bus/einstein/pipe/pipe.h @@ -0,0 +1,135 @@ +// license: GPL-2.0+ +// copyright-holders: Dirk Best +/*************************************************************************** + + Einstein "Tatung Pipe" + + 60-pin slot + + +5V 1 2 D7 + +5V 3 4 D6 + GND 5 6 D5 + GND 7 8 D4 + GND 9 10 D3 + GND 11 12 D2 + GND 13 14 D1 + GND 15 16 D0 + GND 17 18 A15 + A14 19 20 A13 + A12 21 22 A11 + A10 23 24 A9 + A8 25 26 A7 + A6 27 28 A5 + A4 29 30 A3 + A2 31 32 A1 + A0 33 34 /RESET + GND 35 36 /RFSH + GND 37 38 /M1 + GND 39 40 /BUSACK + GND 41 42 /WR + GND 43 44 /RD + GND 45 46 /IORQ + GND 47 48 /MREQ + GND 49 50 /HALT + GND 51 52 /NMI + GND 53 54 /INT + GND 55 56 /WAIT + GND 57 58 /BUSREQ + GND 59 60 SYSCLK + +***************************************************************************/ + +#ifndef MAME_BUS_EINSTEIN_PIPE_H +#define MAME_BUS_EINSTEIN_PIPE_H + +#pragma once + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_TATUNG_PIPE_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, TATUNG_PIPE, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(tatung_pipe_cards, nullptr, false) + +#define MCFG_TATUNG_PIPE_INT_HANDLER(_devcb) \ + devcb = &tatung_pipe_device::set_int_handler(*device, DEVCB_##_devcb); + +#define MCFG_TATUNG_PIPE_NMI_HANDLER(_devcb) \ + devcb = &tatung_pipe_device::set_nmi_handler(*device, DEVCB_##_devcb); + +#define MCFG_TATUNG_PIPE_RESET_HANDLER(_devcb) \ + devcb = &tatung_pipe_device::set_reset_handler(*device, DEVCB_##_devcb); + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class device_tatung_pipe_interface; + +class tatung_pipe_device : public device_t, public device_slot_interface +{ + friend class device_tatung_pipe_interface; +public: + // construction/destruction + tatung_pipe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual ~tatung_pipe_device(); + + void set_program_space(address_space *program); + void set_io_space(address_space *io); + + // callbacks + template static devcb_base &set_int_handler(device_t &device, Object &&cb) + { return downcast(device).m_int_handler.set_callback(std::forward(cb)); } + + template static devcb_base &set_nmi_handler(device_t &device, Object &&cb) + { return downcast(device).m_nmi_handler.set_callback(std::forward(cb)); } + + template static devcb_base &set_reset_handler(device_t &device, Object &&cb) + { return downcast(device).m_reset_handler.set_callback(std::forward(cb)); } + + // called from card device + DECLARE_WRITE_LINE_MEMBER( int_w ) { m_int_handler(state); } + DECLARE_WRITE_LINE_MEMBER( nmi_w ) { m_nmi_handler(state); } + DECLARE_WRITE_LINE_MEMBER( reset_w ) { m_reset_handler(state); } + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + address_space *m_program; + address_space *m_io; + + device_tatung_pipe_interface *m_card; + +private: + devcb_write_line m_int_handler; + devcb_write_line m_nmi_handler; + devcb_write_line m_reset_handler; +}; + +// class representing interface-specific live pipe device +class device_tatung_pipe_interface : public device_slot_card_interface +{ +public: + // construction/destruction + device_tatung_pipe_interface(const machine_config &mconfig, device_t &device); + virtual ~device_tatung_pipe_interface(); + +protected: + address_space &program_space() { return *m_slot->m_program; } + address_space &io_space() { return *m_slot->m_io; } + + tatung_pipe_device *m_slot; +}; + +// device type definition +DECLARE_DEVICE_TYPE(TATUNG_PIPE, tatung_pipe_device) + +// supported devices +SLOT_INTERFACE_EXTERN(tatung_pipe_cards); + +#endif // MAME_BUS_EINSTEIN_PIPE_H diff --git a/src/devices/bus/einstein/pipe/tk02.cpp b/src/devices/bus/einstein/pipe/tk02.cpp new file mode 100644 index 00000000000..02bea85e43f --- /dev/null +++ b/src/devices/bus/einstein/pipe/tk02.cpp @@ -0,0 +1,231 @@ +// license: GPL-2.0+ +// copyright-holders: Dirk Best, Phill Harvey-Smith +/*************************************************************************** + + TK02 80 Column Monochrome Unit + +***************************************************************************/ + +#include "emu.h" +#include "tk02.h" +#include "screen.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(TK02_80COL, tk02_device, "tk02", "TK02 80 Column Monochrome Unit") + +//------------------------------------------------- +// device_address_map +//------------------------------------------------- + +DEVICE_ADDRESS_MAP_START(map, 8, tk02_device) +// AM_RANGE(0x00, 0x07) AM_SELECT(0xff00) AM_READWRITE(ram_r, ram_w) // no AM_SELECT (or AM_MASK) support here + AM_RANGE(0x08, 0x08) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_device, address_w) + AM_RANGE(0x09, 0x09) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_device, register_w) + AM_RANGE(0x0c, 0x0c) AM_MIRROR(0xff00) AM_READ(status_r) +ADDRESS_MAP_END + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +ROM_START( tk02 ) + ROM_REGION(0x2000, "gfx", 0) + ROM_LOAD("tk02-v100.bin", 0x0000, 0x2000, CRC(ad3c4346) SHA1(cd57e630371b4d0314e3f15693753fb195c7257d)) +ROM_END + +const tiny_rom_entry *tk02_device::device_rom_region() const +{ + return ROM_NAME( tk02 ); +} + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +static INPUT_PORTS_START( tk02_links ) + PORT_START("M001") + PORT_DIPUNUSED_DIPLOC(0x01, 0x01, "M001:1") + + PORT_START("M002") + PORT_DIPNAME(0x01, 0x00, "TV Standard") PORT_DIPLOCATION("M002:1") + PORT_DIPSETTING(0x00, "625 lines/50 Hz") + PORT_DIPSETTING(0x01, "525 lines/60 Hz") + + PORT_START("M003") + PORT_DIPNAME(0x01, 0x00, "Startup Mode") PORT_DIPLOCATION("M003:1") + PORT_DIPSETTING(0x00, "Normal") + PORT_DIPSETTING(0x01, "Automatic 80 Column") + + PORT_START("M004") + PORT_DIPNAME(0x01, 0x00, "Character Set") PORT_DIPLOCATION("M004:1") + PORT_DIPSETTING(0x00, "Modified") + PORT_DIPSETTING(0x01, "Normal") +INPUT_PORTS_END + +ioport_constructor tk02_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( tk02_links ); +} + +//------------------------------------------------- +// gfx_layout - only for the char viewer +//------------------------------------------------- + +static const gfx_layout tk02_charlayout = +{ + 8, 10, + 256, + 1, + { 0 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 0x800*8, 0x801*8 }, + 8*8 +}; + +static GFXDECODE_START( tk02 ) + GFXDECODE_ENTRY("gfx", 0x0000, tk02_charlayout, 0, 1) + GFXDECODE_ENTRY("gfx", 0x1000, tk02_charlayout, 0, 1) +GFXDECODE_END + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +MACHINE_CONFIG_MEMBER( tk02_device::device_add_mconfig ) + MCFG_SCREEN_ADD_MONOCHROME("mono", RASTER, rgb_t::green()) + MCFG_SCREEN_RAW_PARAMS(XTAL_8MHz * 2, 1024, 0, 640, 312, 0, 250) + MCFG_SCREEN_UPDATE_DEVICE("crtc", mc6845_device, screen_update) + + MCFG_PALETTE_ADD_MONOCHROME("palette") + + MCFG_GFXDECODE_ADD("gfxdecode", "palette", tk02) + + MCFG_MC6845_ADD("crtc", MC6845, "mono", XTAL_8MHz / 4) + MCFG_MC6845_SHOW_BORDER_AREA(false) + MCFG_MC6845_CHAR_WIDTH(8) + MCFG_MC6845_UPDATE_ROW_CB(tk02_device, crtc_update_row) + MCFG_MC6845_OUT_DE_CB(WRITELINE(tk02_device, de_w)) + + MCFG_TATUNG_PIPE_ADD("pipe") +MACHINE_CONFIG_END + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// tk02_device - constructor +//------------------------------------------------- + +tk02_device::tk02_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, TK02_80COL, tag, owner, clock), + device_tatung_pipe_interface(mconfig, *this), + m_pipe(*this, "pipe"), + m_crtc(*this, "crtc"), + m_palette(*this, "palette"), + m_gfx(*this, "gfx"), + m_links(*this, "M00%u", 1), + m_de(0) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void tk02_device::device_start() +{ + // setup ram + m_ram = std::make_unique(0x800); + memset(m_ram.get(), 0xff, 0x800); + + // register for save states + save_pointer(NAME(m_ram.get()), 0x800); + save_item(NAME(m_de)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void tk02_device::device_reset() +{ + m_pipe->set_io_space(&io_space()); + m_pipe->set_program_space(&program_space()); + + io_space().install_device(0x40, 0x4f, *this, &tk02_device::map); + io_space().install_readwrite_handler(0x40, 0x47, 0, 0, 0xff00, read8_delegate(FUNC(tk02_device::ram_r), this), write8_delegate(FUNC(tk02_device::ram_w), this)); +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +MC6845_UPDATE_ROW( tk02_device::crtc_update_row ) +{ + const pen_t *pen = m_palette->pens(); + + for (int i = 0; i < x_count; i++) + { + uint8_t code = m_ram[(ma + i) & 0x07ff]; + + // 12-------------- link M004 + // --11------------ ra3 + // ----109876543--- data from ram + // -------------210 ra0..2 + uint8_t data = m_gfx->as_u8((m_links[3]->read() << 12) | ((ra & 0x08) << 8) | (code << 3) | (ra & 0x07)); + + if (i == cursor_x) + data ^= 0xff; + + bitmap.pix32(y, i * 8 + 0) = pen[BIT(data, 7)]; + bitmap.pix32(y, i * 8 + 1) = pen[BIT(data, 6)]; + bitmap.pix32(y, i * 8 + 2) = pen[BIT(data, 5)]; + bitmap.pix32(y, i * 8 + 3) = pen[BIT(data, 4)]; + bitmap.pix32(y, i * 8 + 4) = pen[BIT(data, 3)]; + bitmap.pix32(y, i * 8 + 5) = pen[BIT(data, 2)]; + bitmap.pix32(y, i * 8 + 6) = pen[BIT(data, 1)]; + bitmap.pix32(y, i * 8 + 7) = pen[BIT(data, 0)]; + } +} + +WRITE_LINE_MEMBER( tk02_device::de_w ) +{ + m_de = state; +} + +// lower 3 bits of address define a 256-byte "row" +// upper 8 bits define the offset in the row +READ8_MEMBER( tk02_device::ram_r ) +{ + return m_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)]; +} + +WRITE8_MEMBER( tk02_device::ram_w ) +{ + m_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)] = data; +} + +READ8_MEMBER( tk02_device::status_r ) +{ + // 7654---- unused + // ----3--- link M001 + // -----2-- link M002 + // ------1- link M003 + // -------0 mc6845 display enabled + + uint8_t data = 0xf0; + + data |= m_links[0]->read() << 3; + data |= m_links[1]->read() << 2; + data |= m_links[2]->read() << 1; + data |= m_de << 0; + + return data; +} diff --git a/src/devices/bus/einstein/pipe/tk02.h b/src/devices/bus/einstein/pipe/tk02.h new file mode 100644 index 00000000000..8a7d2231de3 --- /dev/null +++ b/src/devices/bus/einstein/pipe/tk02.h @@ -0,0 +1,61 @@ +// license: GPL-2.0+ +// copyright-holders: Dirk Best, Phill Harvey-Smith +/*************************************************************************** + + TK02 80 Column Monochrome Unit + +***************************************************************************/ + +#ifndef MAME_BUS_EINSTEIN_TK02_H +#define MAME_BUS_EINSTEIN_TK02_H + +#pragma once + +#include "pipe.h" +#include "video/mc6845.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> tk02_device + +class tk02_device : public device_t, public device_tatung_pipe_interface +{ +public: + // construction/destruction + tk02_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + virtual const tiny_rom_entry *device_rom_region() const override; + virtual void device_add_mconfig(machine_config &config) override; + virtual ioport_constructor device_input_ports() const override; + virtual void device_start() override; + virtual void device_reset() override; + +private: + DECLARE_ADDRESS_MAP(map, 8); + + DECLARE_WRITE_LINE_MEMBER(de_w); + + DECLARE_READ8_MEMBER(ram_r); + DECLARE_WRITE8_MEMBER(ram_w); + DECLARE_READ8_MEMBER(status_r); + + MC6845_UPDATE_ROW(crtc_update_row); + + required_device m_pipe; + required_device m_crtc; + required_device m_palette; + required_memory_region m_gfx; + required_ioport_array<4> m_links; + + std::unique_ptr m_ram; + int m_de; +}; + +// device type definition +DECLARE_DEVICE_TYPE(TK02_80COL, tk02_device) + +#endif // MAME_BUS_EINSTEIN_TK02_H diff --git a/src/devices/bus/einstein/tk02.cpp b/src/devices/bus/einstein/tk02.cpp deleted file mode 100644 index 02bea85e43f..00000000000 --- a/src/devices/bus/einstein/tk02.cpp +++ /dev/null @@ -1,231 +0,0 @@ -// license: GPL-2.0+ -// copyright-holders: Dirk Best, Phill Harvey-Smith -/*************************************************************************** - - TK02 80 Column Monochrome Unit - -***************************************************************************/ - -#include "emu.h" -#include "tk02.h" -#include "screen.h" - - -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** - -DEFINE_DEVICE_TYPE(TK02_80COL, tk02_device, "tk02", "TK02 80 Column Monochrome Unit") - -//------------------------------------------------- -// device_address_map -//------------------------------------------------- - -DEVICE_ADDRESS_MAP_START(map, 8, tk02_device) -// AM_RANGE(0x00, 0x07) AM_SELECT(0xff00) AM_READWRITE(ram_r, ram_w) // no AM_SELECT (or AM_MASK) support here - AM_RANGE(0x08, 0x08) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_device, address_w) - AM_RANGE(0x09, 0x09) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_device, register_w) - AM_RANGE(0x0c, 0x0c) AM_MIRROR(0xff00) AM_READ(status_r) -ADDRESS_MAP_END - -//------------------------------------------------- -// rom_region - device-specific ROM region -//------------------------------------------------- - -ROM_START( tk02 ) - ROM_REGION(0x2000, "gfx", 0) - ROM_LOAD("tk02-v100.bin", 0x0000, 0x2000, CRC(ad3c4346) SHA1(cd57e630371b4d0314e3f15693753fb195c7257d)) -ROM_END - -const tiny_rom_entry *tk02_device::device_rom_region() const -{ - return ROM_NAME( tk02 ); -} - -//------------------------------------------------- -// input_ports - device-specific input ports -//------------------------------------------------- - -static INPUT_PORTS_START( tk02_links ) - PORT_START("M001") - PORT_DIPUNUSED_DIPLOC(0x01, 0x01, "M001:1") - - PORT_START("M002") - PORT_DIPNAME(0x01, 0x00, "TV Standard") PORT_DIPLOCATION("M002:1") - PORT_DIPSETTING(0x00, "625 lines/50 Hz") - PORT_DIPSETTING(0x01, "525 lines/60 Hz") - - PORT_START("M003") - PORT_DIPNAME(0x01, 0x00, "Startup Mode") PORT_DIPLOCATION("M003:1") - PORT_DIPSETTING(0x00, "Normal") - PORT_DIPSETTING(0x01, "Automatic 80 Column") - - PORT_START("M004") - PORT_DIPNAME(0x01, 0x00, "Character Set") PORT_DIPLOCATION("M004:1") - PORT_DIPSETTING(0x00, "Modified") - PORT_DIPSETTING(0x01, "Normal") -INPUT_PORTS_END - -ioport_constructor tk02_device::device_input_ports() const -{ - return INPUT_PORTS_NAME( tk02_links ); -} - -//------------------------------------------------- -// gfx_layout - only for the char viewer -//------------------------------------------------- - -static const gfx_layout tk02_charlayout = -{ - 8, 10, - 256, - 1, - { 0 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 0x800*8, 0x801*8 }, - 8*8 -}; - -static GFXDECODE_START( tk02 ) - GFXDECODE_ENTRY("gfx", 0x0000, tk02_charlayout, 0, 1) - GFXDECODE_ENTRY("gfx", 0x1000, tk02_charlayout, 0, 1) -GFXDECODE_END - -//------------------------------------------------- -// device_add_mconfig - add device configuration -//------------------------------------------------- - -MACHINE_CONFIG_MEMBER( tk02_device::device_add_mconfig ) - MCFG_SCREEN_ADD_MONOCHROME("mono", RASTER, rgb_t::green()) - MCFG_SCREEN_RAW_PARAMS(XTAL_8MHz * 2, 1024, 0, 640, 312, 0, 250) - MCFG_SCREEN_UPDATE_DEVICE("crtc", mc6845_device, screen_update) - - MCFG_PALETTE_ADD_MONOCHROME("palette") - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", tk02) - - MCFG_MC6845_ADD("crtc", MC6845, "mono", XTAL_8MHz / 4) - MCFG_MC6845_SHOW_BORDER_AREA(false) - MCFG_MC6845_CHAR_WIDTH(8) - MCFG_MC6845_UPDATE_ROW_CB(tk02_device, crtc_update_row) - MCFG_MC6845_OUT_DE_CB(WRITELINE(tk02_device, de_w)) - - MCFG_TATUNG_PIPE_ADD("pipe") -MACHINE_CONFIG_END - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// tk02_device - constructor -//------------------------------------------------- - -tk02_device::tk02_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, TK02_80COL, tag, owner, clock), - device_tatung_pipe_interface(mconfig, *this), - m_pipe(*this, "pipe"), - m_crtc(*this, "crtc"), - m_palette(*this, "palette"), - m_gfx(*this, "gfx"), - m_links(*this, "M00%u", 1), - m_de(0) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void tk02_device::device_start() -{ - // setup ram - m_ram = std::make_unique(0x800); - memset(m_ram.get(), 0xff, 0x800); - - // register for save states - save_pointer(NAME(m_ram.get()), 0x800); - save_item(NAME(m_de)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void tk02_device::device_reset() -{ - m_pipe->set_io_space(&io_space()); - m_pipe->set_program_space(&program_space()); - - io_space().install_device(0x40, 0x4f, *this, &tk02_device::map); - io_space().install_readwrite_handler(0x40, 0x47, 0, 0, 0xff00, read8_delegate(FUNC(tk02_device::ram_r), this), write8_delegate(FUNC(tk02_device::ram_w), this)); -} - - -//************************************************************************** -// IMPLEMENTATION -//************************************************************************** - -MC6845_UPDATE_ROW( tk02_device::crtc_update_row ) -{ - const pen_t *pen = m_palette->pens(); - - for (int i = 0; i < x_count; i++) - { - uint8_t code = m_ram[(ma + i) & 0x07ff]; - - // 12-------------- link M004 - // --11------------ ra3 - // ----109876543--- data from ram - // -------------210 ra0..2 - uint8_t data = m_gfx->as_u8((m_links[3]->read() << 12) | ((ra & 0x08) << 8) | (code << 3) | (ra & 0x07)); - - if (i == cursor_x) - data ^= 0xff; - - bitmap.pix32(y, i * 8 + 0) = pen[BIT(data, 7)]; - bitmap.pix32(y, i * 8 + 1) = pen[BIT(data, 6)]; - bitmap.pix32(y, i * 8 + 2) = pen[BIT(data, 5)]; - bitmap.pix32(y, i * 8 + 3) = pen[BIT(data, 4)]; - bitmap.pix32(y, i * 8 + 4) = pen[BIT(data, 3)]; - bitmap.pix32(y, i * 8 + 5) = pen[BIT(data, 2)]; - bitmap.pix32(y, i * 8 + 6) = pen[BIT(data, 1)]; - bitmap.pix32(y, i * 8 + 7) = pen[BIT(data, 0)]; - } -} - -WRITE_LINE_MEMBER( tk02_device::de_w ) -{ - m_de = state; -} - -// lower 3 bits of address define a 256-byte "row" -// upper 8 bits define the offset in the row -READ8_MEMBER( tk02_device::ram_r ) -{ - return m_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)]; -} - -WRITE8_MEMBER( tk02_device::ram_w ) -{ - m_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)] = data; -} - -READ8_MEMBER( tk02_device::status_r ) -{ - // 7654---- unused - // ----3--- link M001 - // -----2-- link M002 - // ------1- link M003 - // -------0 mc6845 display enabled - - uint8_t data = 0xf0; - - data |= m_links[0]->read() << 3; - data |= m_links[1]->read() << 2; - data |= m_links[2]->read() << 1; - data |= m_de << 0; - - return data; -} diff --git a/src/devices/bus/einstein/tk02.h b/src/devices/bus/einstein/tk02.h deleted file mode 100644 index 8a7d2231de3..00000000000 --- a/src/devices/bus/einstein/tk02.h +++ /dev/null @@ -1,61 +0,0 @@ -// license: GPL-2.0+ -// copyright-holders: Dirk Best, Phill Harvey-Smith -/*************************************************************************** - - TK02 80 Column Monochrome Unit - -***************************************************************************/ - -#ifndef MAME_BUS_EINSTEIN_TK02_H -#define MAME_BUS_EINSTEIN_TK02_H - -#pragma once - -#include "pipe.h" -#include "video/mc6845.h" - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> tk02_device - -class tk02_device : public device_t, public device_tatung_pipe_interface -{ -public: - // construction/destruction - tk02_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - virtual const tiny_rom_entry *device_rom_region() const override; - virtual void device_add_mconfig(machine_config &config) override; - virtual ioport_constructor device_input_ports() const override; - virtual void device_start() override; - virtual void device_reset() override; - -private: - DECLARE_ADDRESS_MAP(map, 8); - - DECLARE_WRITE_LINE_MEMBER(de_w); - - DECLARE_READ8_MEMBER(ram_r); - DECLARE_WRITE8_MEMBER(ram_w); - DECLARE_READ8_MEMBER(status_r); - - MC6845_UPDATE_ROW(crtc_update_row); - - required_device m_pipe; - required_device m_crtc; - required_device m_palette; - required_memory_region m_gfx; - required_ioport_array<4> m_links; - - std::unique_ptr m_ram; - int m_de; -}; - -// device type definition -DECLARE_DEVICE_TYPE(TK02_80COL, tk02_device) - -#endif // MAME_BUS_EINSTEIN_TK02_H diff --git a/src/mame/includes/einstein.h b/src/mame/includes/einstein.h index 7e12b8a4017..5d22b4200ec 100644 --- a/src/mame/includes/einstein.h +++ b/src/mame/includes/einstein.h @@ -12,7 +12,7 @@ #pragma once #include "cpu/z80/z80daisy.h" -#include "bus/einstein/pipe.h" +#include "bus/einstein/pipe/pipe.h" #include "machine/timer.h" #include "machine/wd_fdc.h" #include "machine/z80ctc.h" -- cgit v1.2.3