From a02ec54132ed002a58f6198053c99481e8004c90 Mon Sep 17 00:00:00 2001 From: Nigel Barnes Date: Wed, 11 Oct 2017 11:33:56 +0100 Subject: [PATCH] bbc: Added Torch Z80 Communicator as Tube slot device. --- scripts/src/bus.lua | 2 + src/devices/bus/bbc/tube/tube.cpp | 4 +- src/devices/bus/bbc/tube/tube_zep100.cpp | 202 +++++++++++++++++++++++ src/devices/bus/bbc/tube/tube_zep100.h | 72 ++++++++ 4 files changed, 278 insertions(+), 2 deletions(-) create mode 100644 src/devices/bus/bbc/tube/tube_zep100.cpp create mode 100644 src/devices/bus/bbc/tube/tube_zep100.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 5b674ee5c32..65bd0e0de03 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -308,6 +308,8 @@ if (BUSES["BBC_TUBE"]~=null) then MAME_DIR .. "src/devices/bus/bbc/tube/tube_casper.h", MAME_DIR .. "src/devices/bus/bbc/tube/tube_z80.cpp", MAME_DIR .. "src/devices/bus/bbc/tube/tube_z80.h", + MAME_DIR .. "src/devices/bus/bbc/tube/tube_zep100.cpp", + MAME_DIR .. "src/devices/bus/bbc/tube/tube_zep100.h", } end diff --git a/src/devices/bus/bbc/tube/tube.cpp b/src/devices/bus/bbc/tube/tube.cpp index ea21071b7c0..13bb4430230 100644 --- a/src/devices/bus/bbc/tube/tube.cpp +++ b/src/devices/bus/bbc/tube/tube.cpp @@ -128,7 +128,7 @@ WRITE8_MEMBER(bbc_tube_slot_device::host_w) #include "tube_casper.h" //#include "tube_x25.h" #include "tube_z80.h" -//#include "tube_zep100.h" +#include "tube_zep100.h" //------------------------------------------------- @@ -144,7 +144,7 @@ SLOT_INTERFACE_START( bbc_extube_devices ) SLOT_INTERFACE("80286", BBC_TUBE_80286) /* Acorn 80286 2nd Processor */ // SLOT_INTERFACE("a500", BBC_TUBE_A500) /* Acorn A500 2nd Processor */ SLOT_INTERFACE("casper", BBC_TUBE_CASPER) /* Casper 68000 2nd Processor */ -// SLOT_INTERFACE("zep100", BBC_TUBE_ZEP100) /* Torch Z80 Communicator (ZEP100) */ + SLOT_INTERFACE("zep100", BBC_TUBE_ZEP100) /* Torch Z80 Communicator (ZEP100) */ /* Acorn ANC21 Universal 2nd Processor Unit */ SLOT_INTERFACE("65c102", BBC_TUBE_65C102) /* Acorn ADC06 65C102 co-processor */ SLOT_INTERFACE("80186", BBC_TUBE_80186) /* Acorn ADC08 80186 co-processor */ diff --git a/src/devices/bus/bbc/tube/tube_zep100.cpp b/src/devices/bus/bbc/tube/tube_zep100.cpp new file mode 100644 index 00000000000..10d98399e08 --- /dev/null +++ b/src/devices/bus/bbc/tube/tube_zep100.cpp @@ -0,0 +1,202 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + Torch Z80 Communicator (ZEP100) + + http://chrisacorns.computinghistory.org.uk/8bit_Upgrades/Torch_Z802ndproc.html + +**********************************************************************/ + + +#include "emu.h" +#include "tube_zep100.h" +#include "softlist_dev.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(BBC_TUBE_ZEP100, bbc_tube_zep100_device, "bbc_tube_zep100", "Torch Z80 Communicator") + + +//------------------------------------------------- +// ADDRESS_MAP( tube_zep100_mem ) +//------------------------------------------------- + +static ADDRESS_MAP_START(tube_zep100_mem, AS_PROGRAM, 8, bbc_tube_zep100_device) + AM_RANGE(0x0000, 0xffff) AM_READWRITE(mem_r, mem_w) +ADDRESS_MAP_END + +//------------------------------------------------- +// ADDRESS_MAP( tube_zep100_io ) +//------------------------------------------------- + +static ADDRESS_MAP_START(tube_zep100_io, AS_IO, 8, bbc_tube_zep100_device) + ADDRESS_MAP_UNMAP_HIGH + AM_RANGE(0x00, 0x07) AM_MIRROR(0xff00) AM_READWRITE(io_r, io_w) +ADDRESS_MAP_END + +//------------------------------------------------- +// ROM( tube_zep100 ) +//------------------------------------------------- + +ROM_START( tube_zep100 ) + ROM_REGION(0x2000, "rom", 0) + ROM_DEFAULT_BIOS("cccp102") + ROM_SYSTEM_BIOS(0, "cccp102", "CCCP 1.02") + ROMX_LOAD("CCCP102.rom", 0x0000, 0x2000, CRC(2eb40a21) SHA1(e6ee738e5f2f8556002b79d18caa8ef21f14e08d), ROM_BIOS(1)) + ROM_SYSTEM_BIOS(1, "cccp094", "CCCP 0.94") + ROMX_LOAD("CCCP094.rom", 0x0000, 0x2000, CRC(49989bd4) SHA1(62b57c858a3baa4ff943c31f77d331c414772a61), ROM_BIOS(2)) +ROM_END + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +MACHINE_CONFIG_MEMBER(bbc_tube_zep100_device::device_add_mconfig ) + MCFG_CPU_ADD("z80", Z80, XTAL_4MHz) + MCFG_CPU_PROGRAM_MAP(tube_zep100_mem) + MCFG_CPU_IO_MAP(tube_zep100_io) + + MCFG_DEVICE_ADD("via", VIA6522, XTAL_4MHz / 2) + MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(bbc_tube_zep100_device, via_pb_w)) + MCFG_VIA6522_CB2_HANDLER(DEVWRITELINE("ppi", i8255_device, pc2_w)) + MCFG_VIA6522_CA2_HANDLER(DEVWRITELINE("ppi", i8255_device, pc6_w)) + MCFG_VIA6522_IRQ_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, bbc_tube_slot_device, irq_w)) + + MCFG_DEVICE_ADD("ppi", I8255A, 0) + MCFG_I8255_OUT_PORTA_CB(DEVWRITE8("via", via6522_device, write_pa)) + MCFG_I8255_IN_PORTB_CB(READ8(bbc_tube_zep100_device, ppi_pb_r)) + MCFG_I8255_OUT_PORTC_CB(WRITE8(bbc_tube_zep100_device, ppi_pc_w)) + + /* internal ram */ + MCFG_RAM_ADD(RAM_TAG) + MCFG_RAM_DEFAULT_SIZE("64K") + MCFG_RAM_DEFAULT_VALUE(0x00) + + /* software lists */ + MCFG_SOFTWARE_LIST_ADD("flop_ls_torch", "bbc_flop_torch") +MACHINE_CONFIG_END + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const tiny_rom_entry *bbc_tube_zep100_device::device_rom_region() const +{ + return ROM_NAME( tube_zep100 ); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// bbc_tube_zep100_device - constructor +//------------------------------------------------- + +bbc_tube_zep100_device::bbc_tube_zep100_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_TUBE_ZEP100, tag, owner, clock), + device_bbc_tube_interface(mconfig, *this), + m_z80(*this, "z80"), + m_via(*this, "via"), + m_ppi(*this, "ppi"), + m_ram(*this, "ram"), + m_rom(*this, "rom"), + m_port_b(0), + m_rom_enabled(true) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void bbc_tube_zep100_device::device_start() +{ + m_slot = dynamic_cast(owner()); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void bbc_tube_zep100_device::device_reset() +{ + m_via->reset(); + + m_rom_enabled = true; +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +READ8_MEMBER(bbc_tube_zep100_device::host_r) +{ + return m_via->read(space, offset & 0x0f); +} + +WRITE8_MEMBER(bbc_tube_zep100_device::host_w) +{ + if (offset & 0x10) + m_z80->reset(); + + m_via->write(space, offset & 0x0f, data); +} + + +READ8_MEMBER(bbc_tube_zep100_device::mem_r) +{ + uint8_t data; + + if (m_rom_enabled) + data = m_rom->base()[offset]; + else + data = m_ram->pointer()[offset]; + + return data; +} + +WRITE8_MEMBER(bbc_tube_zep100_device::mem_w) +{ + m_ram->pointer()[offset] = data; +} + + +READ8_MEMBER(bbc_tube_zep100_device::io_r) +{ + uint8_t data = 0xff; + + if (!machine().side_effect_disabled()) + m_rom_enabled = !BIT(offset, 2); + + data = m_ppi->read(space, offset & 0x03); + + return data; +} + +WRITE8_MEMBER(bbc_tube_zep100_device::io_w) +{ + m_ppi->write(space, offset & 0x03, data); +} + + +WRITE8_MEMBER(bbc_tube_zep100_device::via_pb_w) +{ + m_port_b = data; +} + +READ8_MEMBER(bbc_tube_zep100_device::ppi_pb_r) +{ + return m_port_b; +} + +WRITE8_MEMBER(bbc_tube_zep100_device::ppi_pc_w) +{ + m_via->write_ca1(BIT(data, 7)); + m_via->write_cb1(BIT(data, 1)); +} diff --git a/src/devices/bus/bbc/tube/tube_zep100.h b/src/devices/bus/bbc/tube/tube_zep100.h new file mode 100644 index 00000000000..a24bc533445 --- /dev/null +++ b/src/devices/bus/bbc/tube/tube_zep100.h @@ -0,0 +1,72 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + Torch Z80 Communicator (ZEP100) + + http://chrisacorns.computinghistory.org.uk/8bit_Upgrades/Torch_Z802ndproc.html + +**********************************************************************/ + + +#ifndef MAME_BUS_BBC_TUBE_ZEP100_H +#define MAME_BUS_BBC_TUBE_ZEP100_H + +#include "tube.h" +#include "cpu/z80/z80.h" +#include "machine/6522via.h" +#include "machine/i8255.h" +#include "machine/ram.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> bbc_tube_zep100_device + +class bbc_tube_zep100_device : + public device_t, + public device_bbc_tube_interface +{ +public: + // construction/destruction + bbc_tube_zep100_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + DECLARE_READ8_MEMBER( mem_r ); + DECLARE_WRITE8_MEMBER( mem_w ); + DECLARE_READ8_MEMBER( io_r ); + DECLARE_WRITE8_MEMBER( io_w ); + + DECLARE_WRITE8_MEMBER( via_pb_w ); + DECLARE_READ8_MEMBER( ppi_pb_r ); + DECLARE_WRITE8_MEMBER( ppi_pc_w ); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + // optional information overrides + virtual void device_add_mconfig(machine_config &config) override; + virtual const tiny_rom_entry *device_rom_region() const override; + + virtual DECLARE_READ8_MEMBER( host_r ) override; + virtual DECLARE_WRITE8_MEMBER( host_w ) override; + +private: + required_device m_z80; + required_device m_via; + required_device m_ppi; + required_device m_ram; + required_memory_region m_rom; + + uint8_t m_port_b; + bool m_rom_enabled; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(BBC_TUBE_ZEP100, bbc_tube_zep100_device) + + +#endif /* MAME_BUS_BBC_TUBE_ZEP100_H */