From d9bcbe5a8c23fc65fc1cf36eae2289464fe454f1 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Wed, 6 Feb 2013 18:57:58 +0000 Subject: [PATCH] (MESS) c64: Added CMD SwiftLink cartridge emulation. [Curt Coder] --- .gitattributes | 2 + hash/c64_flop.xml | 48 +++++++++ src/emu/machine/mos6551.c | 47 ++++++--- src/mess/machine/c64_swiftlink.c | 165 +++++++++++++++++++++++++++++++ src/mess/machine/c64_swiftlink.h | 78 +++++++++++++++ src/mess/machine/cbmipt.c | 1 + src/mess/machine/cbmipt.h | 1 + src/mess/mess.mak | 1 + 8 files changed, 329 insertions(+), 14 deletions(-) create mode 100644 src/mess/machine/c64_swiftlink.c create mode 100644 src/mess/machine/c64_swiftlink.h diff --git a/.gitattributes b/.gitattributes index 101870ee26b..25270020e70 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6969,6 +6969,8 @@ src/mess/machine/c64_supercpu.c svneol=native#text/plain src/mess/machine/c64_supercpu.h svneol=native#text/plain src/mess/machine/c64_sw8k.c svneol=native#text/plain src/mess/machine/c64_sw8k.h svneol=native#text/plain +src/mess/machine/c64_swiftlink.c svneol=native#text/plain +src/mess/machine/c64_swiftlink.h svneol=native#text/plain src/mess/machine/c64_system3.c svneol=native#text/plain src/mess/machine/c64_system3.h svneol=native#text/plain src/mess/machine/c64_tdos.c svneol=native#text/plain diff --git a/hash/c64_flop.xml b/hash/c64_flop.xml index bda3917ac12..ab75d9bc412 100644 --- a/hash/c64_flop.xml +++ b/hash/c64_flop.xml @@ -825,4 +825,52 @@ + + CMD SwiftLink + 1990 + CMD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/emu/machine/mos6551.c b/src/emu/machine/mos6551.c index 9f09ebee54b..06c3927c95a 100644 --- a/src/emu/machine/mos6551.c +++ b/src/emu/machine/mos6551.c @@ -7,6 +7,17 @@ **********************************************************************/ +/* + + TODO: + + - receiver disable + - IRQ on DCD/DSR change + - parity + - framing error + +*/ + #include "mos6551.h" @@ -85,16 +96,16 @@ void mos6551_device::device_reset() void mos6551_device::tra_complete() { - if ((m_cmd & CMD_TC_MASK) == CMD_TC_TIE_RTS_LO) - { - m_st |= ST_IRQ; - m_irq_handler(ASSERT_LINE); - } - if (!(m_st & ST_TDRE)) { transmit_register_setup(m_tdr); m_st |= ST_TDRE; + + if ((m_cmd & CMD_TC_MASK) == CMD_TC_TIE_RTS_LO) + { + m_st |= ST_IRQ; + m_irq_handler(ASSERT_LINE); + } } } @@ -109,15 +120,15 @@ void mos6551_device::rcv_complete() { m_st |= ST_OR; } - else - { - m_st |= ST_RDRF; + + m_st &= ~(ST_FE | ST_PE); - if (!(m_cmd & CMD_RIE)) - { - m_st |= ST_IRQ; - m_irq_handler(ASSERT_LINE); - } + m_st |= ST_RDRF; + + if (!(m_cmd & CMD_RIE)) + { + m_st |= ST_IRQ; + m_irq_handler(ASSERT_LINE); } } @@ -244,6 +255,12 @@ WRITE8_MEMBER( mos6551_device::write ) { transmit_register_setup(m_tdr); m_st |= ST_TDRE; + + if ((m_cmd & CMD_TC_MASK) == CMD_TC_TIE_RTS_LO) + { + m_st |= ST_IRQ; + m_irq_handler(ASSERT_LINE); + } } break; @@ -274,4 +291,6 @@ WRITE8_MEMBER( mos6551_device::write ) void mos6551_device::set_rxc(int clock) { m_ext_rxc = clock; + + update_serial(); } diff --git a/src/mess/machine/c64_swiftlink.c b/src/mess/machine/c64_swiftlink.c new file mode 100644 index 00000000000..b35d11353be --- /dev/null +++ b/src/mess/machine/c64_swiftlink.c @@ -0,0 +1,165 @@ +/********************************************************************** + + CMD SwiftLink RS-232 cartridge emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +/* + + http://mclauchlan.site.net.au/scott/C=Hacking/C-Hacking10/C-Hacking10-swiftlink.html + +*/ + +#include "c64_swiftlink.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + +#define MOS6551_TAG "mos6551" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type C64_SWIFTLINK = &device_creator; + + +//------------------------------------------------- +// MACHINE_CONFIG_FRAGMENT( c64_swiftlink ) +//------------------------------------------------- + +static MACHINE_CONFIG_FRAGMENT( c64_swiftlink ) + MCFG_MOS6551_ADD(MOS6551_TAG, XTAL_3_6864MHz, DEVWRITELINE(DEVICE_SELF, c64_swiftlink_cartridge_device, acia_irq_w)) +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor c64_swiftlink_cartridge_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( c64_swiftlink ); +} + + +//------------------------------------------------- +// INPUT_PORTS( c64_swiftlink ) +//------------------------------------------------- + +static INPUT_PORTS_START( c64_swiftlink ) + PORT_START("CS") + PORT_DIPNAME( 0x03, 0x01, "Base Address" ) + PORT_DIPSETTING( 0x00, "$D700 (C128)" ) + PORT_DIPSETTING( 0x01, "$DE00" ) + PORT_DIPSETTING( 0x02, "$DF00" ) + + PORT_START("IRQ") + PORT_DIPNAME( 0x01, 0x01, "Interrupt" ) + PORT_DIPSETTING( 0x00, "IRQ (C128)" ) + PORT_DIPSETTING( 0x01, "NMI" ) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor c64_swiftlink_cartridge_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( c64_swiftlink ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// c64_swiftlink_cartridge_device - constructor +//------------------------------------------------- + +c64_swiftlink_cartridge_device::c64_swiftlink_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, C64_SWIFTLINK, "C64 SwiftLink cartridge", tag, owner, clock), + device_c64_expansion_card_interface(mconfig, *this), + m_acia(*this, MOS6551_TAG), + m_io_cs(*this, "CS"), + m_io_irq(*this, "IRQ") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void c64_swiftlink_cartridge_device::device_start() +{ +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void c64_swiftlink_cartridge_device::device_reset() +{ + m_acia->reset(); + + m_cs = m_io_cs->read(); + m_irq = m_io_irq->read(); +} + + +//------------------------------------------------- +// c64_cd_r - cartridge data read +//------------------------------------------------- + +UINT8 c64_swiftlink_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) +{ + if (((m_cs == DE00) && !io1) || ((m_cs == DF00) && !io2) || + ((m_cs == D700) && ((offset & 0xff00) == 0xd700))) + { + data = m_acia->read(space, offset & 0x03); + } + + return data; +} + + +//------------------------------------------------- +// c64_cd_w - cartridge data write +//------------------------------------------------- + +void c64_swiftlink_cartridge_device::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) +{ + if (((m_cs == DE00) && !io1) || ((m_cs == DF00) && !io2) || + ((m_cs == D700) && ((offset & 0xff00) == 0xd700))) + { + m_acia->write(space, offset & 0x03, data); + } +} + + +//------------------------------------------------- +// acia_irq_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( c64_swiftlink_cartridge_device::acia_irq_w ) +{ + switch (m_irq) + { + case IRQ: m_slot->irq_w(state); break; + case NMI: m_slot->nmi_w(state); break; + } +} diff --git a/src/mess/machine/c64_swiftlink.h b/src/mess/machine/c64_swiftlink.h new file mode 100644 index 00000000000..b51920e8705 --- /dev/null +++ b/src/mess/machine/c64_swiftlink.h @@ -0,0 +1,78 @@ +/********************************************************************** + + CMD SwiftLink RS-232 cartridge emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __SWIFTLINK__ +#define __SWIFTLINK__ + + +#include "emu.h" +#include "machine/c64exp.h" +#include "machine/mos6551.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> c64_swiftlink_cartridge_device + +class c64_swiftlink_cartridge_device : public device_t, + public device_c64_expansion_card_interface +{ +public: + // construction/destruction + c64_swiftlink_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual machine_config_constructor device_mconfig_additions() const; + virtual ioport_constructor device_input_ports() const; + + DECLARE_WRITE_LINE_MEMBER( acia_irq_w ); + +protected: + // device-level overrides + virtual void device_config_complete() { m_shortname = "c64_swiftlink"; } + virtual void device_start(); + virtual void device_reset(); + + // device_c64_expansion_card_interface overrides + virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); + virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2); + +private: + required_device m_acia; + required_ioport m_io_cs; + required_ioport m_io_irq; + + enum + { + D700 = 0, + DE00, + DF00 + }; + + enum + { + IRQ = 0, + NMI + }; + + int m_cs; + int m_irq; +}; + + +// device type definition +extern const device_type C64_SWIFTLINK; + + +#endif diff --git a/src/mess/machine/cbmipt.c b/src/mess/machine/cbmipt.c index 2a6dbff58fd..a80d69a53c4 100644 --- a/src/mess/machine/cbmipt.c +++ b/src/mess/machine/cbmipt.c @@ -1128,6 +1128,7 @@ SLOT_INTERFACE_START( c64_expansion_cards ) SLOT_INTERFACE("reu1764", C64_REU1764) SLOT_INTERFACE("sfxse", C64_SFX_SOUND_EXPANDER) SLOT_INTERFACE("supercpu", C64_SUPERCPU) + SLOT_INTERFACE("swiftlink", C64_SWIFTLINK) // the following need ROMs from the software list SLOT_INTERFACE_INTERNAL("standard", C64_STD) diff --git a/src/mess/machine/cbmipt.h b/src/mess/machine/cbmipt.h index d2beb62c0fe..dfdb61ba776 100644 --- a/src/mess/machine/cbmipt.h +++ b/src/mess/machine/cbmipt.h @@ -55,6 +55,7 @@ #include "machine/c64_super_games.h" #include "machine/c64_supercpu.h" #include "machine/c64_sw8k.h" +#include "machine/c64_swiftlink.h" #include "machine/c64_system3.h" #include "machine/c64_tdos.h" #include "machine/c64_vw64.h" diff --git a/src/mess/mess.mak b/src/mess/mess.mak index bb3286abd2f..f21717fa75b 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -886,6 +886,7 @@ $(MESSOBJ)/cbm.a: \ $(MESS_MACHINE)/c64_super_games.o \ $(MESS_MACHINE)/c64_supercpu.o \ $(MESS_MACHINE)/c64_sw8k.o \ + $(MESS_MACHINE)/c64_swiftlink.o \ $(MESS_MACHINE)/c64_system3.o \ $(MESS_MACHINE)/c64_tdos.o \ $(MESS_MACHINE)/c64_vw64.o \