diff options
author | 2013-10-20 19:43:30 +0000 | |
---|---|---|
committer | 2013-10-20 19:43:30 +0000 | |
commit | 726983263b929a6f1f0a131d7b511242b8bf0437 (patch) | |
tree | d0c91051c8cd9792ed3046180f893edfdefc38f9 /src/emu/bus/comx35 | |
parent | d2236708b3ca7fc0472e9e4915e0ba4dd01c4089 (diff) |
(MESS) comx35: Moved expansion port under emu/bus. (nw)
Diffstat (limited to 'src/emu/bus/comx35')
-rw-r--r-- | src/emu/bus/comx35/clm.c | 283 | ||||
-rw-r--r-- | src/emu/bus/comx35/clm.h | 65 | ||||
-rw-r--r-- | src/emu/bus/comx35/eprom.c | 124 | ||||
-rw-r--r-- | src/emu/bus/comx35/eprom.h | 59 | ||||
-rw-r--r-- | src/emu/bus/comx35/exp.c | 238 | ||||
-rw-r--r-- | src/emu/bus/comx35/exp.h | 176 | ||||
-rw-r--r-- | src/emu/bus/comx35/expbox.c | 368 | ||||
-rw-r--r-- | src/emu/bus/comx35/expbox.h | 77 | ||||
-rw-r--r-- | src/emu/bus/comx35/fdc.c | 301 | ||||
-rw-r--r-- | src/emu/bus/comx35/fdc.h | 73 | ||||
-rw-r--r-- | src/emu/bus/comx35/joycard.c | 117 | ||||
-rw-r--r-- | src/emu/bus/comx35/joycard.h | 56 | ||||
-rw-r--r-- | src/emu/bus/comx35/printer.c | 201 | ||||
-rw-r--r-- | src/emu/bus/comx35/printer.h | 60 | ||||
-rw-r--r-- | src/emu/bus/comx35/ram.c | 106 | ||||
-rw-r--r-- | src/emu/bus/comx35/ram.h | 56 | ||||
-rw-r--r-- | src/emu/bus/comx35/thermal.c | 130 | ||||
-rw-r--r-- | src/emu/bus/comx35/thermal.h | 57 |
18 files changed, 2547 insertions, 0 deletions
diff --git a/src/emu/bus/comx35/clm.c b/src/emu/bus/comx35/clm.c new file mode 100644 index 00000000000..29e016f8c53 --- /dev/null +++ b/src/emu/bus/comx35/clm.c @@ -0,0 +1,283 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 80-Column Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +/* + +(c) 1985 Comx World Operations + +PCB Layout +---------- + +F-003-CLM-REV 1 + + |---------------| + | CN1 | +|---| |---------------------------| +| | +| MC14174 LS86 LS175 LS10 LS161 | +| 14.31818MHz | +| LS245 LS04 | +| ROM1 6845 CN2 | +| LS374 LS165 | +|LD2 LS138 LS157 LS157 | +|LD1 6116 ROM2 SW1 | +| LS126 LS32 LS157 | +|-----------------------------------------------| + +Notes: + All IC's shown. + + 6845 - Motorola MC6845P CRT Controller + 6116 - Motorola MCM6116P15 2Kx8 Asynchronous CMOS Static RAM + ROM1 - Mitsubishi 2Kx8 EPROM "C" + ROM2 - Mitsubishi 2Kx8 EPROM "P" + CN1 - COMX-35 bus PCB edge connector + CN2 - RCA video output connector + LD1 - LED + LD2 - LED + SW1 - switch + +*/ + +#include "clm.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + +#define MC6845_TAG "mc6845" +#define MC6845_SCREEN_TAG "screen80" +#define VIDEORAM_SIZE 0x800 + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_CLM = &device_creator<comx_clm_device>; + + +//------------------------------------------------- +// ROM( comx_clm ) +//------------------------------------------------- + +ROM_START( comx_clm ) + ROM_REGION( 0x2000, "c000", 0 ) + ROM_DEFAULT_BIOS( "v11" ) + ROM_SYSTEM_BIOS( 0, "v10", "v1.0" ) + ROMX_LOAD( "p 1.0.cl1", 0x0000, 0x0800, CRC(b417d30a) SHA1(d428b0467945ecb9aec884211d0f4b1d8d56d738), ROM_BIOS(1) ) + ROM_SYSTEM_BIOS( 1, "v11", "v1.1" ) + ROMX_LOAD( "p 1.1.cl1", 0x0000, 0x0800, CRC(0a2eaf19) SHA1(3f1f640caef964fb47aaa147cab6d215c2b30e9d), ROM_BIOS(2) ) + + ROM_REGION( 0x800, MC6845_TAG, 0 ) + ROMX_LOAD( "c 1.0.cl4", 0x0000, 0x0800, CRC(69dd7b07) SHA1(71d368adbb299103d165eab8359a97769e463e26), ROM_BIOS(1) ) + ROMX_LOAD( "c 1.1.cl4", 0x0000, 0x0800, CRC(dc9b5046) SHA1(4e041cec03dda6dba5e2598d060c49908a4fab2a), ROM_BIOS(2) ) +ROM_END + + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *comx_clm_device::device_rom_region() const +{ + return ROM_NAME( comx_clm ); +} + + +//------------------------------------------------- +// mc6845_interface crtc_intf +//------------------------------------------------- + +void comx_clm_device::crtc_update_row(mc6845_device *device, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param) +{ + for (int column = 0; column < x_count; column++) + { + UINT8 code = m_video_ram[((ma + column) & 0x7ff)]; + UINT16 addr = (code << 3) | (ra & 0x07); + UINT8 data = m_char_rom->base()[addr & 0x7ff]; + + if (BIT(ra, 3) && column == cursor_x) + { + data = 0xff; + } + + for (int bit = 0; bit < 8; bit++) + { + int x = (column * 8) + bit; + int color = BIT(data, 7) ? 7 : 0; + + bitmap.pix32(y, x) = RGB_MONOCHROME_WHITE[color]; + + data <<= 1; + } + } +} + +static MC6845_UPDATE_ROW( comx_clm_update_row ) +{ + comx_clm_device *clm = downcast<comx_clm_device *>(device->owner()); + clm->crtc_update_row(device,bitmap,cliprect,ma,ra,y,x_count,cursor_x,param); +} + +static MC6845_INTERFACE( crtc_intf ) +{ + false, + 8, + NULL, + comx_clm_update_row, + NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + NULL +}; + + +//------------------------------------------------- +// GFXDECODE( comx_clm ) +//------------------------------------------------- + +static GFXDECODE_START( comx_clm ) + GFXDECODE_ENTRY(MC6845_TAG, 0x0000, gfx_8x8x1, 0, 1) +GFXDECODE_END + + +//------------------------------------------------- +// MACHINE_CONFIG_FRAGMENT( comx_clm ) +//------------------------------------------------- + +static MACHINE_CONFIG_FRAGMENT( comx_clm ) + MCFG_SCREEN_ADD(MC6845_SCREEN_TAG, RASTER) + MCFG_SCREEN_UPDATE_DEVICE(MC6845_TAG, mc6845_device, screen_update) + MCFG_SCREEN_SIZE(80*8, 24*8) + MCFG_SCREEN_VISIBLE_AREA(0, 80*8-1, 0, 24*8-1) + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) + MCFG_SCREEN_REFRESH_RATE(50) + + //MCFG_GFXDECODE(comx_clm) + + MCFG_MC6845_ADD(MC6845_TAG, MC6845, MC6845_SCREEN_TAG, XTAL_14_31818MHz/7, crtc_intf) +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor comx_clm_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( comx_clm ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_clm_device - constructor +//------------------------------------------------- + +comx_clm_device::comx_clm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_CLM, "COMX 80 Column Card", tag, owner, clock, "comx_clm", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_crtc(*this, MC6845_TAG), + m_rom(*this, "c000"), + m_char_rom(*this, MC6845_TAG), + m_video_ram(*this, "video_ram") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_clm_device::device_start() +{ + // allocate memory + m_video_ram.allocate(VIDEORAM_SIZE); + + // state saving + save_item(NAME(m_ds)); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_clm_device::device_reset() +{ +} + + +//------------------------------------------------- +// comx_ef4_r - external flag 4 read +//------------------------------------------------- + +int comx_clm_device::comx_ef4_r() +{ + return m_ds ? m_crtc->hsync_r() : CLEAR_LINE; +} + + +//------------------------------------------------- +// comx_mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_clm_device::comx_mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0xff; + + if (offset >= 0xc000 && offset < 0xc800) + { + data = m_rom->base()[offset & 0x7ff]; + } + else if (offset >= 0xd000 && offset < 0xd800) + { + data = m_video_ram[offset & 0x7ff]; + } + else if (offset == 0xd801) + { + data = m_crtc->register_r(space, 0); + } + + return data; +} + + +//------------------------------------------------- +// comx_mwr_w - memory write +//------------------------------------------------- + +void comx_clm_device::comx_mwr_w(address_space &space, offs_t offset, UINT8 data) +{ + if (offset >= 0xd000 && offset < 0xd800) + { + m_video_ram[offset & 0x7ff] = data; + } + else if (offset == 0xd800) + { + m_crtc->address_w(space, 0, data); + } + else if (offset == 0xd801) + { + m_crtc->register_w(space, 0, data); + } +} diff --git a/src/emu/bus/comx35/clm.h b/src/emu/bus/comx35/clm.h new file mode 100644 index 00000000000..401d7f01f0d --- /dev/null +++ b/src/emu/bus/comx35/clm.h @@ -0,0 +1,65 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 80-Column Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_CLM__ +#define __COMX_CLM__ + +#include "emu.h" +#include "exp.h" +#include "video/mc6845.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_clm_device + +class comx_clm_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_clm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; + virtual machine_config_constructor device_mconfig_additions() const; + + // not really public + void crtc_update_row(mc6845_device *device, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual int comx_ef4_r(); + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom); + virtual void comx_mwr_w(address_space &space, offs_t offset, UINT8 data); + +private: + required_device<mc6845_device> m_crtc; + required_memory_region m_rom; + required_memory_region m_char_rom; + optional_shared_ptr<UINT8> m_video_ram; +}; + + +// device type definition +extern const device_type COMX_CLM; + + +#endif diff --git a/src/emu/bus/comx35/eprom.c b/src/emu/bus/comx35/eprom.c new file mode 100644 index 00000000000..1ef8305f78d --- /dev/null +++ b/src/emu/bus/comx35/eprom.c @@ -0,0 +1,124 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 F&M EPROM Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "eprom.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_EPR = &device_creator<comx_epr_device>; + + +//------------------------------------------------- +// ROM( comx_epr ) +//------------------------------------------------- + +ROM_START( comx_epr ) + ROM_REGION( 0x800, "f800", 0 ) + ROM_LOAD( "f&m.eprom.board.1.1.bin", 0x0000, 0x0800, CRC(a042a31a) SHA1(13831a1350aa62a87988bfcc99c4b7db8ef1cf62) ) + + ROM_REGION( 0x10000, "eprom", 0 ) + ROM_LOAD( "f&m.basic.bin", 0x0000, 0x2000, CRC(22ab7b61) SHA1(68b5770bca37b1ba94083f944086884e612b5a1b) ) + ROM_LOAD( "disk.utilities.bin", 0x2000, 0x2000, CRC(2576c945) SHA1(e80481054c6997a5f418d8a5872ac0110ae7b75a) ) + ROM_LOAD( "tennismania.bin", 0x4000, 0x2000, CRC(a956cc74) SHA1(8bc914f52f0dd2cf792da74ec4e9e333365619ef) ) +ROM_END + + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *comx_epr_device::device_rom_region() const +{ + return ROM_NAME( comx_epr ); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_epr_device - constructor +//------------------------------------------------- + +comx_epr_device::comx_epr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_EPR, "COMX-35 F&M EPROM Switchboard", tag, owner, clock, "comx_epr", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_rom(*this, "f800"), + m_eprom(*this, "eprom"), + m_select(0) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_epr_device::device_start() +{ + // state saving + save_item(NAME(m_select)); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_epr_device::device_reset() +{ +} + + +//------------------------------------------------- +// comx_mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_epr_device::comx_mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0; + + if (offset >= 0xc000 && offset < 0xe000) + { + offs_t address = (m_select << 13) | (offset & 0x1fff); + data = m_eprom->base()[address]; + } + else if (offset >= 0xf800) + { + data = m_rom->base()[offset & 0x7ff]; + } + + return data; +} + + +//------------------------------------------------- +// comx_io_w - I/O write +//------------------------------------------------- + +void comx_epr_device::comx_io_w(address_space &space, offs_t offset, UINT8 data) +{ + if (offset == 1) + { + m_select = data >> 5; + } +} diff --git a/src/emu/bus/comx35/eprom.h b/src/emu/bus/comx35/eprom.h new file mode 100644 index 00000000000..d854446bb50 --- /dev/null +++ b/src/emu/bus/comx35/eprom.h @@ -0,0 +1,59 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 F&M EPROM Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_EPR__ +#define __COMX_EPR__ + +#include "emu.h" +#include "exp.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_epr_device + +class comx_epr_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_epr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom); + virtual void comx_io_w(address_space &space, offs_t offset, UINT8 data); + +private: + required_memory_region m_rom; + required_memory_region m_eprom; + + UINT8 m_select; +}; + + +// device type definition +extern const device_type COMX_EPR; + + +#endif diff --git a/src/emu/bus/comx35/exp.c b/src/emu/bus/comx35/exp.c new file mode 100644 index 00000000000..aa117ac8eff --- /dev/null +++ b/src/emu/bus/comx35/exp.c @@ -0,0 +1,238 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Expansion Slot emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "emu.h" +#include "emuopts.h" +#include "exp.h" + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const device_type COMX_EXPANSION_SLOT = &device_creator<comx_expansion_slot_device>; + + +//************************************************************************** +// DEVICE COMX_EXPANSION CARD INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_comx_expansion_card_interface - constructor +//------------------------------------------------- + +device_comx_expansion_card_interface::device_comx_expansion_card_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device), + m_ds(1) +{ + m_slot = dynamic_cast<comx_expansion_slot_device *>(device.owner()); +} + + +//------------------------------------------------- +// ~device_comx_expansion_card_interface - destructor +//------------------------------------------------- + +device_comx_expansion_card_interface::~device_comx_expansion_card_interface() +{ +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_expansion_slot_device - constructor +//------------------------------------------------- + +comx_expansion_slot_device::comx_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_EXPANSION_SLOT, "COMX-35 expansion slot", tag, owner, clock, "comx_expansion_slot", __FILE__), + device_slot_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// comx_expansion_slot_device - destructor +//------------------------------------------------- + +comx_expansion_slot_device::~comx_expansion_slot_device() +{ +} + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void comx_expansion_slot_device::device_config_complete() +{ + // inherit a copy of the static data + const comx_expansion_slot_interface *intf = reinterpret_cast<const comx_expansion_slot_interface *>(static_config()); + if (intf != NULL) + { + *static_cast<comx_expansion_slot_interface *>(this) = *intf; + } + + // or initialize to defaults if none provided + else + { + memset(&m_out_int_cb, 0, sizeof(m_out_int_cb)); + memset(&m_out_wait_cb, 0, sizeof(m_out_wait_cb)); + memset(&m_out_clear_cb, 0, sizeof(m_out_clear_cb)); + } +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_expansion_slot_device::device_start() +{ + m_card = dynamic_cast<device_comx_expansion_card_interface *>(get_card_device()); + + // resolve callbacks + m_out_int_func.resolve(m_out_int_cb, *this); + m_out_wait_func.resolve(m_out_wait_cb, *this); + m_out_clear_func.resolve(m_out_clear_cb, *this); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_expansion_slot_device::device_reset() +{ +} + + +//------------------------------------------------- +// mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_expansion_slot_device::mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0; + + if (m_card != NULL) + { + data = m_card->comx_mrd_r(space, offset, extrom); + } + + return data; +} + + +//------------------------------------------------- +// mwr_w - memory write +//------------------------------------------------- + +void comx_expansion_slot_device::mwr_w(address_space &space, offs_t offset, UINT8 data) +{ + if (m_card != NULL) + { + m_card->comx_mwr_w(space, offset, data); + } +} + + +//------------------------------------------------- +// io_r - I/O read +//------------------------------------------------- + +UINT8 comx_expansion_slot_device::io_r(address_space &space, offs_t offset) +{ + UINT8 data = 0; + + if (m_card != NULL) + { + data = m_card->comx_io_r(space, offset); + } + + return data; +} + + +//------------------------------------------------- +// sout_w - I/O write +//------------------------------------------------- + +void comx_expansion_slot_device::io_w(address_space &space, offs_t offset, UINT8 data) +{ + if (m_card != NULL) + { + m_card->comx_io_w(space, offset, data); + } +} + + +//------------------------------------------------- +// ds_w - device select write +//------------------------------------------------- + +WRITE_LINE_MEMBER( comx_expansion_slot_device::ds_w ) +{ + if (m_card != NULL) + { + m_card->comx_ds_w(state); + } +} + + +//------------------------------------------------- +// q_w - Q write +//------------------------------------------------- + +WRITE_LINE_MEMBER( comx_expansion_slot_device::q_w ) +{ + if (m_card != NULL) + { + m_card->comx_q_w(state); + } +} + +READ_LINE_MEMBER( comx_expansion_slot_device::ef4_r ) +{ + int state = CLEAR_LINE; + + if (m_card != NULL) + { + state = m_card->comx_ef4_r(); + } + + return state; +} + +WRITE_LINE_MEMBER( comx_expansion_slot_device::int_w ) { m_out_int_func(state); } +WRITE_LINE_MEMBER( comx_expansion_slot_device::wait_w ) { m_out_wait_func(state); } +WRITE_LINE_MEMBER( comx_expansion_slot_device::clear_w ) { m_out_clear_func(state); } + + +//------------------------------------------------- +// SLOT_INTERFACE( comx_expansion_cards ) +//------------------------------------------------- + +SLOT_INTERFACE_START( comx_expansion_cards ) + SLOT_INTERFACE("eb", COMX_EB) + SLOT_INTERFACE("fd", COMX_FD) + SLOT_INTERFACE("clm", COMX_CLM) + SLOT_INTERFACE("ram", COMX_RAM) + SLOT_INTERFACE("joy", COMX_JOY) + SLOT_INTERFACE("prn", COMX_PRN) + SLOT_INTERFACE("thm", COMX_THM) + SLOT_INTERFACE("epr", COMX_EPR) +SLOT_INTERFACE_END diff --git a/src/emu/bus/comx35/exp.h b/src/emu/bus/comx35/exp.h new file mode 100644 index 00000000000..66a1122a1b9 --- /dev/null +++ b/src/emu/bus/comx35/exp.h @@ -0,0 +1,176 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Expansion Slot emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +********************************************************************** + + GND 1 A GND + NC 2 B DS + +5V 3 C V+ + D0 4 D D1 + D2 5 E D3 + D4 6 F D5 + D6 7 H D7 + _DP 8 J Q + _CLEAR 9 K _MRD + TPA 10 L N0 + N1 11 M N2 + _RAS 12 N _INT + _WAIT 13 P CLOCK + SC1 14 R SC0 + _EF4 15 S _CASE + TPB 16 T _A15 + _MWR 17 U A14 + MA7 18 V _A14 + MA5 19 W MA6 + MA4 20 X MA3 + MA2 21 Y _EXTROM + MA1 22 Z MA0 + +**********************************************************************/ + +#pragma once + +#ifndef __COMX35_EXPANSION_SLOT__ +#define __COMX35_EXPANSION_SLOT__ + +#include "emu.h" + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +#define COMX_EXPANSION_BUS_TAG "comxexp" + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define COMX_EXPANSION_INTERFACE(_name) \ + const comx_expansion_slot_interface (_name) = + + +#define MCFG_COMX_EXPANSION_SLOT_ADD(_tag, _config, _slot_intf, _def_slot) \ + MCFG_DEVICE_ADD(_tag, COMX_EXPANSION_SLOT, 0) \ + MCFG_DEVICE_CONFIG(_config) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_expansion_slot_interface + +struct comx_expansion_slot_interface +{ + devcb_write_line m_out_int_cb; + devcb_write_line m_out_wait_cb; + devcb_write_line m_out_clear_cb; +}; + + +// ======================> comx_expansion_slot_device + +class device_comx_expansion_card_interface; + +class comx_expansion_slot_device : public device_t, + public comx_expansion_slot_interface, + public device_slot_interface +{ +public: + // construction/destruction + comx_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~comx_expansion_slot_device(); + + UINT8 mrd_r(address_space &space, offs_t offset, int *extrom); + void mwr_w(address_space &space, offs_t offset, UINT8 data); + + UINT8 io_r(address_space &space, offs_t offset); + void io_w(address_space &space, offs_t offset, UINT8 data); + + DECLARE_READ_LINE_MEMBER( ef4_r ); + + DECLARE_WRITE_LINE_MEMBER( ds_w ); + DECLARE_WRITE_LINE_MEMBER( q_w ); + + DECLARE_WRITE_LINE_MEMBER( int_w ); + DECLARE_WRITE_LINE_MEMBER( wait_w ); + DECLARE_WRITE_LINE_MEMBER( clear_w ); + + UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + virtual void device_config_complete(); + + devcb_resolved_write_line m_out_int_func; + devcb_resolved_write_line m_out_wait_func; + devcb_resolved_write_line m_out_clear_func; + + device_comx_expansion_card_interface *m_card; +}; + + +// ======================> device_comx_expansion_card_interface + +// class representing interface-specific live comx_expansion card +class device_comx_expansion_card_interface : public device_slot_card_interface +{ + friend class comx_expansion_slot_device; + +public: + // construction/destruction + device_comx_expansion_card_interface(const machine_config &mconfig, device_t &device); + virtual ~device_comx_expansion_card_interface(); + +protected: + // signals + virtual int comx_ef4_r() { return CLEAR_LINE; } + virtual void comx_ds_w(int state) { m_ds = state; }; + virtual void comx_q_w(int state) { }; + + // memory access + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom) { return 0; }; + virtual void comx_mwr_w(address_space &space, offs_t offset, UINT8 data) { }; + + // I/O access + virtual UINT8 comx_io_r(address_space &space, offs_t offset) { return 0; }; + virtual void comx_io_w(address_space &space, offs_t offset, UINT8 data) { }; + + comx_expansion_slot_device *m_slot; + + int m_ds; +}; + + +// device type definition +extern const device_type COMX_EXPANSION_SLOT; + + +// slot devices +#include "clm.h" +#include "eprom.h" +#include "expbox.h" +#include "fdc.h" +#include "joycard.h" +#include "printer.h" +#include "ram.h" +#include "thermal.h" + +SLOT_INTERFACE_EXTERN( comx_expansion_cards ); + + +#endif diff --git a/src/emu/bus/comx35/expbox.c b/src/emu/bus/comx35/expbox.c new file mode 100644 index 00000000000..a3f2936b8c8 --- /dev/null +++ b/src/emu/bus/comx35/expbox.c @@ -0,0 +1,368 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35E Expansion Box emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +/* + +(c) 1984 Comx World Operations + +PCB Layout +---------- + +F-001-EB-REV0 + + |--------------------------------------| + | 40174 4073 4049 4075 | + | | + | ROM 40175 4073 4075 | + | | +|----| - - - - | +| | | | | 7805 | +| | | | | | +| | | | | | +|C C C C C | +|N N N N N | +|5 1 2 3 4 | +| | | | | | +| | | | | | +| | | | | | +| - - - LD1 - | +|-------------------------------------------| + +Notes: + All IC's shown. + + ROM - NEC D2732D-4 4Kx8 EPROM, unlabeled + CN1 - COMX-35 bus connector slot 1 + CN2 - COMX-35 bus connector slot 2 + CN3 - COMX-35 bus connector slot 3 + CN4 - COMX-35 bus connector slot 4 + CN5 - COMX-35 bus PCB edge connector + LD1 - LED + +*/ + +#include "expbox.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + +#define SLOT1_TAG "slot1" +#define SLOT2_TAG "slot2" +#define SLOT3_TAG "slot3" +#define SLOT4_TAG "slot4" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_EB = &device_creator<comx_eb_device>; + + +//------------------------------------------------- +// ROM( comx_eb ) +//------------------------------------------------- + +ROM_START( comx_eb ) + ROM_REGION( 0x1000, "e000", 0 ) + ROM_SYSTEM_BIOS( 0, "comx", "Original" ) + ROMX_LOAD( "expansion.e5", 0x0000, 0x1000, CRC(52cb44e2) SHA1(3f9a3d9940b36d4fee5eca9f1359c99d7ed545b9), ROM_BIOS(1) ) + ROM_SYSTEM_BIOS( 1, "fm31", "F&M 3.1" ) + ROMX_LOAD( "f&m.expansion.3.1.e5", 0x0000, 0x1000, CRC(818ca2ef) SHA1(ea000097622e7fd472d53e7899e3c83773433045), ROM_BIOS(2) ) + ROM_SYSTEM_BIOS( 2, "fm32", "F&M 3.2" ) + ROMX_LOAD( "f&m.expansion.3.2.e5", 0x0000, 0x1000, CRC(0f0fc960) SHA1(eb6b6e7bc9e761d13554482025d8cb5e260c0619), ROM_BIOS(3) ) +ROM_END + + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *comx_eb_device::device_rom_region() const +{ + return ROM_NAME( comx_eb ); +} + + +//------------------------------------------------- +// COMX_EXPANSION_INTERFACE( expansion_intf ) +//------------------------------------------------- + +WRITE_LINE_DEVICE_HANDLER( int_w ) +{ + comx_eb_device *eb = downcast<comx_eb_device *>(device->owner()); + eb->set_int(device->tag(), state); +} + +WRITE_LINE_DEVICE_HANDLER( wait_w ) +{ + comx_expansion_slot_device *slot = dynamic_cast<comx_expansion_slot_device *>(device->owner()->owner()); + slot->wait_w(state); +} + +WRITE_LINE_DEVICE_HANDLER( clear_w ) +{ + comx_expansion_slot_device *slot = dynamic_cast<comx_expansion_slot_device *>(device->owner()->owner()); + slot->clear_w(state); +} + +static COMX_EXPANSION_INTERFACE( expansion_intf ) +{ + DEVCB_LINE(int_w), + DEVCB_LINE(wait_w), + DEVCB_LINE(clear_w) +}; + + +//------------------------------------------------- +// MACHINE_CONFIG_FRAGMENT( comx_eb ) +//------------------------------------------------- + +static MACHINE_CONFIG_FRAGMENT( comx_eb ) + MCFG_COMX_EXPANSION_SLOT_ADD(SLOT1_TAG, expansion_intf, comx_expansion_cards, "fd") + MCFG_COMX_EXPANSION_SLOT_ADD(SLOT2_TAG, expansion_intf, comx_expansion_cards, "clm") + MCFG_COMX_EXPANSION_SLOT_ADD(SLOT3_TAG, expansion_intf, comx_expansion_cards, "joy") + MCFG_COMX_EXPANSION_SLOT_ADD(SLOT4_TAG, expansion_intf, comx_expansion_cards, "ram") +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor comx_eb_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( comx_eb ); +} + + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// set_int - set INT line state +//------------------------------------------------- + +void comx_eb_device::set_int(const char *tag, int state) +{ + int slot = 0; + + for (slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (!strcmp(tag, m_expansion_slot[slot]->tag())) break; + } + + assert(slot < MAX_EB_SLOTS); + + m_int[slot] = state; + + int irq = CLEAR_LINE; + + for (slot = 0; slot < MAX_EB_SLOTS; slot++) + { + irq |= m_int[slot]; + } + + m_slot->int_w(irq); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_eb_device - constructor +//------------------------------------------------- + +comx_eb_device::comx_eb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_EB, "COMX-35E Expansion Box", tag, owner, clock, "comx_eb", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_rom(*this, "e000"), + m_select(0) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_eb_device::device_start() +{ + m_expansion_slot[0] = dynamic_cast<comx_expansion_slot_device *>(subdevice(SLOT1_TAG)); + m_expansion_slot[1] = dynamic_cast<comx_expansion_slot_device *>(subdevice(SLOT2_TAG)); + m_expansion_slot[2] = dynamic_cast<comx_expansion_slot_device *>(subdevice(SLOT3_TAG)); + m_expansion_slot[3] = dynamic_cast<comx_expansion_slot_device *>(subdevice(SLOT4_TAG)); + + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + m_int[slot] = CLEAR_LINE; + } +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_eb_device::device_reset() +{ + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (m_expansion_slot[slot] != NULL) + { + m_expansion_slot[slot]->device().reset(); + m_expansion_slot[slot]->ds_w(0); + } + } +} + + +//------------------------------------------------- +// comx_ef4_r - external flag 4 read +//------------------------------------------------- + +int comx_eb_device::comx_ef4_r() +{ + int state = CLEAR_LINE; + + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (m_expansion_slot[slot] != NULL) + { + state |= m_expansion_slot[slot]->ef4_r(); + } + } + + return state; +} + + +//------------------------------------------------- +// comx_q_w - Q write +//------------------------------------------------- + +void comx_eb_device::comx_q_w(int state) +{ + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (m_expansion_slot[slot] != NULL) + { + m_expansion_slot[slot]->q_w(state); + } + } +} + + +//------------------------------------------------- +// comx_mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_eb_device::comx_mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0; + + if (offset >= 0x1000 && offset < 0x1800) + { + data = m_rom->base()[offset & 0x7ff]; + *extrom = 0; + } + else if (offset >= 0xe000 && offset < 0xf000) + { + data = m_rom->base()[offset & 0xfff]; + } + else + { + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (BIT(m_select, slot) && m_expansion_slot[slot] != NULL) + { + data |= m_expansion_slot[slot]->mrd_r(space, offset, extrom); + } + } + } + + return data; +} + + +//------------------------------------------------- +// comx_mwr_w - memory write +//------------------------------------------------- + +void comx_eb_device::comx_mwr_w(address_space &space, offs_t offset, UINT8 data) +{ + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (BIT(m_select, slot) && m_expansion_slot[slot] != NULL) + { + m_expansion_slot[slot]->mwr_w(space, offset, data); + } + } +} + + +//------------------------------------------------- +// comx_io_r - I/O read +//------------------------------------------------- + +UINT8 comx_eb_device::comx_io_r(address_space &space, offs_t offset) +{ + UINT8 data = 0; + + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (BIT(m_select, slot) && m_expansion_slot[slot] != NULL) + { + data |= m_expansion_slot[slot]->io_r(space, offset); + } + } + + return data; +} + + +//------------------------------------------------- +// comx_io_w - I/O write +//------------------------------------------------- + +void comx_eb_device::comx_io_w(address_space &space, offs_t offset, UINT8 data) +{ + if (offset == 1 && !(BIT(data, 0))) + { + m_select = data >> 1; + + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (m_expansion_slot[slot] != NULL) + { + m_expansion_slot[slot]->ds_w(BIT(m_select, slot)); + } + } + } + + for (int slot = 0; slot < MAX_EB_SLOTS; slot++) + { + if (BIT(m_select, slot) && m_expansion_slot[slot] != NULL) + { + m_expansion_slot[slot]->io_w(space, offset, data); + } + } +} diff --git a/src/emu/bus/comx35/expbox.h b/src/emu/bus/comx35/expbox.h new file mode 100644 index 00000000000..e3cfcb03e72 --- /dev/null +++ b/src/emu/bus/comx35/expbox.h @@ -0,0 +1,77 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35E Expansion Box emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_EB__ +#define __COMX_EB__ + +#include "emu.h" +#include "exp.h" + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +#define MAX_EB_SLOTS 4 + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_eb_device + +class comx_eb_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_eb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; + virtual machine_config_constructor device_mconfig_additions() const; + + // not really public + void set_int(const char *tag, int state); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual int comx_ef4_r(); + virtual void comx_q_w(int state); + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom); + virtual void comx_mwr_w(address_space &space, offs_t offset, UINT8 data); + virtual UINT8 comx_io_r(address_space &space, offs_t offset); + virtual void comx_io_w(address_space &space, offs_t offset, UINT8 data); + +private: + required_memory_region m_rom; + + comx_expansion_slot_device *m_expansion_slot[MAX_EB_SLOTS]; + int m_int[MAX_EB_SLOTS]; + + UINT8 m_select; +}; + + +// device type definition +extern const device_type COMX_EB; + + +#endif diff --git a/src/emu/bus/comx35/fdc.c b/src/emu/bus/comx35/fdc.c new file mode 100644 index 00000000000..9a9ede9fe7c --- /dev/null +++ b/src/emu/bus/comx35/fdc.c @@ -0,0 +1,301 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Disk Controller Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +/* + +(c) 1984 Comx World Operations + +PCB Layout +---------- + +F-001-FD-REV0 + + |---------------| + | CN1 | +|---| |---------------------------| +| | +| 40174 4068 4072 -| +| ROM || +| LS04 4072 4050 7438 C| +|8MHz N| +| 4049 4075 LS08 2| +|LD1 WD1770 || +| 40174 4503 4075 7438 -| +|LD2 | +|-----------------------------------------------| + +Notes: + All IC's shown. + + ROM - "D.O.S. V1.2" + WD1770 - Western Digital WD1770-xx Floppy Disc Controller @ 8MHz + CN1 - COMX-35 bus PCB edge connector + CN2 - 34 pin floppy connector + LD1 - card selected LED + LD2 - floppy motor on LED + +*/ + +/* + + TODO: + + - floppy broken (wd1770 digital PLL FM mode incomplete) + +*/ + +#include "fdc.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + +#define WD1770_TAG "wd1770" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_FD = &device_creator<comx_fd_device>; + + +//------------------------------------------------- +// ROM( comx_fd ) +//------------------------------------------------- + +ROM_START( comx_fd ) + ROM_REGION( 0x2000, "c000", 0 ) + ROM_LOAD( "d.o.s. v1.2.f4", 0x0000, 0x2000, CRC(cf4ecd2e) SHA1(290e19bdc89e3c8059e63d5ae3cca4daa194e1fe) ) +ROM_END + + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *comx_fd_device::device_rom_region() const +{ + return ROM_NAME( comx_fd ); +} + + +//------------------------------------------------- +// wd17xx_interface fdc_intf +//------------------------------------------------- + +FLOPPY_FORMATS_MEMBER( comx_fd_device::floppy_formats ) + FLOPPY_COMX35_FORMAT +FLOPPY_FORMATS_END + +static SLOT_INTERFACE_START( comx_fd_floppies ) + SLOT_INTERFACE( "525sd35t", FLOPPY_525_SD_35T ) + SLOT_INTERFACE( "525qd", FLOPPY_525_QD ) +SLOT_INTERFACE_END + + +//------------------------------------------------- +// MACHINE_CONFIG_FRAGMENT( comx_fd ) +//------------------------------------------------- + +static MACHINE_CONFIG_FRAGMENT( comx_fd ) + MCFG_WD1770x_ADD(WD1770_TAG, XTAL_8MHz) + + MCFG_FLOPPY_DRIVE_ADD(WD1770_TAG":0", comx_fd_floppies, "525sd35t", comx_fd_device::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD(WD1770_TAG":1", comx_fd_floppies, NULL, comx_fd_device::floppy_formats) +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor comx_fd_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( comx_fd ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_fd_device - constructor +//------------------------------------------------- + +comx_fd_device::comx_fd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_FD, "COMX FD", tag, owner, clock, "comx_fd", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_fdc(*this, WD1770_TAG), + m_floppy0(*this, WD1770_TAG":0"), + m_floppy1(*this, WD1770_TAG":1"), + m_rom(*this, "c000"), + m_q(0), + m_addr(0), + m_disb(1) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_fd_device::device_start() +{ + // state saving + save_item(NAME(m_ds)); + save_item(NAME(m_q)); + save_item(NAME(m_addr)); + save_item(NAME(m_disb)); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_fd_device::device_reset() +{ + m_fdc->reset(); + m_fdc->dden_w(1); + m_fdc->set_floppy(NULL); + + m_addr = 0; + m_disb = 1; +} + + +//------------------------------------------------- +// comx_ef4_r - external flag 4 read +//------------------------------------------------- + +int comx_fd_device::comx_ef4_r() +{ + int state = CLEAR_LINE; + + if (m_ds && !m_disb) + { + state = !m_fdc->drq_r(); + } + + return state; +} + + +//------------------------------------------------- +// comx_q_w - Q write +//------------------------------------------------- + +void comx_fd_device::comx_q_w(int state) +{ + m_q = state; +} + + +//------------------------------------------------- +// comx_mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_fd_device::comx_mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0xff; + + if (offset >= 0x0dd0 && offset < 0x0de0) + { + data = m_rom->base()[offset & 0x1fff]; + *extrom = 0; + } + else if (offset >= 0xc000 && offset < 0xe000) + { + data = m_rom->base()[offset & 0x1fff]; + } + + return data; +} + + +//------------------------------------------------- +// comx_io_r - I/O read +//------------------------------------------------- + +UINT8 comx_fd_device::comx_io_r(address_space &space, offs_t offset) +{ + UINT8 data = 0xff; + + if (offset == 2) + { + if (m_q) + { + data = 0xfe | (m_fdc->intrq_r() ? 1 : 0); + } + else + { + data = m_fdc->gen_r(m_addr); + if (m_addr==3) logerror("%s FDC read %u:%02x\n", machine().describe_context(), m_addr,data); + } + } + + return data; +} + + +//------------------------------------------------- +// comx_io_w - I/O write +//------------------------------------------------- + +void comx_fd_device::comx_io_w(address_space &space, offs_t offset, UINT8 data) +{ + if (offset == 2) + { + if (m_q) + { + /* + + bit description + + 0 FDC A0 + 1 FDC A1 + 2 DRIVE0 + 3 DRIVE1 + 4 F9 DISB + 5 SIDE SELECT + + */ + + // latch data to F3 + m_addr = data & 0x03; + + // drive select + floppy_image_device *floppy = NULL; + + if (BIT(data, 2)) floppy = m_floppy0->get_device(); + if (BIT(data, 3)) floppy = m_floppy1->get_device(); + + m_fdc->set_floppy(floppy); + + if (floppy) floppy->ss_w(BIT(data, 5)); + + m_disb = !BIT(data, 4); + } + else + { + // write data to WD1770 + m_fdc->gen_w(m_addr, data); + } + } +} diff --git a/src/emu/bus/comx35/fdc.h b/src/emu/bus/comx35/fdc.h new file mode 100644 index 00000000000..8fb755eec1c --- /dev/null +++ b/src/emu/bus/comx35/fdc.h @@ -0,0 +1,73 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Disk Controller Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_FD__ +#define __COMX_FD__ + +#include "emu.h" +#include "exp.h" +#include "formats/comx35_dsk.h" +#include "machine/wd_fdc.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_fd_device + +class comx_fd_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_fd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; + virtual machine_config_constructor device_mconfig_additions() const; + + DECLARE_FLOPPY_FORMATS( floppy_formats ); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual int comx_ef4_r(); + virtual void comx_q_w(int state); + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom); + virtual UINT8 comx_io_r(address_space &space, offs_t offset); + virtual void comx_io_w(address_space &space, offs_t offset, UINT8 data); + +private: + // internal state + required_device<wd1770_t> m_fdc; + required_device<floppy_connector> m_floppy0; + required_device<floppy_connector> m_floppy1; + required_memory_region m_rom; + + // floppy state + int m_q; // FDC register select + int m_addr; // FDC address + int m_disb; // data request disable +}; + + +// device type definition +extern const device_type COMX_FD; + + +#endif diff --git a/src/emu/bus/comx35/joycard.c b/src/emu/bus/comx35/joycard.c new file mode 100644 index 00000000000..e001d986481 --- /dev/null +++ b/src/emu/bus/comx35/joycard.c @@ -0,0 +1,117 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 F&M Joycard emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "joycard.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_JOY = &device_creator<comx_joy_device>; + + +//------------------------------------------------- +// INPUT_PORTS( comx_joy ) +//------------------------------------------------- + +static INPUT_PORTS_START( comx_joy ) + PORT_START("JOY1") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) + + PORT_START("JOY2") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_8WAY + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_8WAY + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_8WAY + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_8WAY + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) + PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor comx_joy_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( comx_joy ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_joy_device - constructor +//------------------------------------------------- + +comx_joy_device::comx_joy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_JOY, "COMX JoyCard", tag, owner, clock, "comx_joy", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_joy1(*this, "JOY1"), + m_joy2(*this, "JOY2") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_joy_device::device_start() +{ +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_joy_device::device_reset() +{ +} + + +//------------------------------------------------- +// comx_mrd_r - I/O read +//------------------------------------------------- + +UINT8 comx_joy_device::comx_io_r(address_space &space, offs_t offset) +{ + UINT8 data = 0; + + if (offset == 2) + { + data = m_joy1->read(); + } + else if (offset == 4) + { + data = m_joy2->read(); + } + + return data; +} diff --git a/src/emu/bus/comx35/joycard.h b/src/emu/bus/comx35/joycard.h new file mode 100644 index 00000000000..869df01eb58 --- /dev/null +++ b/src/emu/bus/comx35/joycard.h @@ -0,0 +1,56 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 F&M Joycard emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_JOY__ +#define __COMX_JOY__ + +#include "emu.h" +#include "exp.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_joy_device + +class comx_joy_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_joy_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const; + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual UINT8 comx_io_r(address_space &space, offs_t offset); + +private: + required_ioport m_joy1; + required_ioport m_joy2; +}; + + +// device type definition +extern const device_type COMX_JOY; + + +#endif diff --git a/src/emu/bus/comx35/printer.c b/src/emu/bus/comx35/printer.c new file mode 100644 index 00000000000..64e3b8fdf4c --- /dev/null +++ b/src/emu/bus/comx35/printer.c @@ -0,0 +1,201 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Serial/Parallel Printer Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "printer.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + +#define CENTRONICS_TAG "centronics" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_PRN = &device_creator<comx_prn_device>; + + +//------------------------------------------------- +// ROM( comx_prn ) +//------------------------------------------------- + +ROM_START( comx_prn ) + ROM_REGION( 0x2000, "c000", 0 ) + ROM_SYSTEM_BIOS( 0, "comx", "COMX" ) + ROMX_LOAD( "printer.bin", 0x0000, 0x0800, CRC(3bbc2b2e) SHA1(08bf7ea4174713ab24969c553affd5c1401876b8), ROM_BIOS(1) ) + ROM_SYSTEM_BIOS( 1, "fm12", "F&M v1.2" ) + ROMX_LOAD( "f&m.printer.1.2.bin", 0x0000, 0x1000, CRC(2feb997d) SHA1(ee9cb91042696c88ff5f2f44d2f702dc93369ba0), ROM_BIOS(2) ) + ROM_LOAD( "rs232.bin", 0x1000, 0x0800, CRC(926ff2d1) SHA1(be02bd388bba0211ea72d4868264a63308e4318d) ) +ROM_END + + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *comx_prn_device::device_rom_region() const +{ + return ROM_NAME( comx_prn ); +} + + +//------------------------------------------------- +// SLOT_INTERFACE( comx_centronics_printer ) +//------------------------------------------------- + +SLOT_INTERFACE_START(comx_centronics_printer) + SLOT_INTERFACE("printer", CENTRONICS_PRINTER) + //SLOT_INTERFACE("pl80", COMX_PL80) +SLOT_INTERFACE_END + + +//------------------------------------------------- +// MACHINE_CONFIG_FRAGMENT( comx_prn ) +//------------------------------------------------- + +static MACHINE_CONFIG_FRAGMENT( comx_prn ) + MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics, comx_centronics_printer, "printer") +MACHINE_CONFIG_END + + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor comx_prn_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( comx_prn ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_prn_device - constructor +//------------------------------------------------- + +comx_prn_device::comx_prn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_PRN, "COMX-35 Printer Card", tag, owner, clock, "comx_prn", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_centronics(*this, CENTRONICS_TAG), + m_rom(*this, "c000") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_prn_device::device_start() +{ +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_prn_device::device_reset() +{ +} + + +//------------------------------------------------- +// comx_mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_prn_device::comx_mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0; + + if (offset >= 0xc000 && offset < 0xe000) + { + data = m_rom->base()[offset & 0x1fff]; + } + + return data; +} + + +//------------------------------------------------- +// comx_io_r - I/O read +//------------------------------------------------- + +UINT8 comx_prn_device::comx_io_r(address_space &space, offs_t offset) +{ + /* + Parallel: + + INP 2 for the printer status, where: + b0=1: Acknowledge Fault + b1=0: Device Busy + b2=0: Paper Empty + b3=1: Device Not Selected + + Serial: + + INP 2 for the printer status and to start a new range of bits for the next byte. + */ + + /* + + bit description + + 0 Acknowledge Fault + 1 Device Busy + 2 Paper Empty + 3 Device Not Selected + 4 + 5 + 6 + 7 + + */ + + UINT8 data = 0; + + data |= m_centronics->ack_r(); + data |= m_centronics->not_busy_r() << 1; + data |= m_centronics->pe_r() << 2; + data |= m_centronics->vcc_r() << 3; + + return data; +} + + +//------------------------------------------------- +// comx_io_w - I/O write +//------------------------------------------------- + +void comx_prn_device::comx_io_w(address_space &space, offs_t offset, UINT8 data) +{ + /* + Parallel: + + OUT 2 is used to send a byte to the printer + + Serial: + + OUT 2 is used to send a bit to the printer + */ + + m_centronics->write(data); +} diff --git a/src/emu/bus/comx35/printer.h b/src/emu/bus/comx35/printer.h new file mode 100644 index 00000000000..5f0f4763c2b --- /dev/null +++ b/src/emu/bus/comx35/printer.h @@ -0,0 +1,60 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Serial/Parallel Printer Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_PRN__ +#define __COMX_PRN__ + +#include "emu.h" +#include "exp.h" +#include "machine/ctronics.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_prn_device + +class comx_prn_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_prn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; + virtual machine_config_constructor device_mconfig_additions() const; + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom); + virtual UINT8 comx_io_r(address_space &space, offs_t offset); + virtual void comx_io_w(address_space &space, offs_t offset, UINT8 data); + +private: + required_device<centronics_device> m_centronics; + required_memory_region m_rom; +}; + + +// device type definition +extern const device_type COMX_PRN; + + +#endif diff --git a/src/emu/bus/comx35/ram.c b/src/emu/bus/comx35/ram.c new file mode 100644 index 00000000000..1bec0a5343b --- /dev/null +++ b/src/emu/bus/comx35/ram.c @@ -0,0 +1,106 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 RAM Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "ram.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + +#define RAM_SIZE 0x8000 + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_RAM = &device_creator<comx_ram_device>; + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_ram_device - constructor +//------------------------------------------------- + +comx_ram_device::comx_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_RAM, "COMX-35 RAM Card", tag, owner, clock, "comx_ram", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_ram(*this, "ram") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_ram_device::device_start() +{ + m_ram.allocate(RAM_SIZE); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_ram_device::device_reset() +{ +} + + +//------------------------------------------------- +// comx_mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_ram_device::comx_mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0; + + if (offset >= 0xc000 && offset < 0xd000) + { + data = m_ram[(m_bank << 12) | (offset & 0xfff)]; + } + + return data; +} + + +//------------------------------------------------- +// comx_mwr_w - memory write +//------------------------------------------------- + +void comx_ram_device::comx_mwr_w(address_space &space, offs_t offset, UINT8 data) +{ + if (offset >= 0xc000 && offset < 0xd000) + { + m_ram[(m_bank << 12) | (offset & 0xfff)] = data; + } +} + + +//------------------------------------------------- +// comx_io_w - I/O write +//------------------------------------------------- + +void comx_ram_device::comx_io_w(address_space &space, offs_t offset, UINT8 data) +{ + if (offset == 1) + { + m_bank = (data >> 4) & 0x03; + } +} diff --git a/src/emu/bus/comx35/ram.h b/src/emu/bus/comx35/ram.h new file mode 100644 index 00000000000..532adf95c58 --- /dev/null +++ b/src/emu/bus/comx35/ram.h @@ -0,0 +1,56 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 RAM Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_RAM__ +#define __COMX_RAM__ + +#include "emu.h" +#include "exp.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_ram_device + +class comx_ram_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom); + virtual void comx_mwr_w(address_space &space, offs_t offset, UINT8 data); + virtual void comx_io_w(address_space &space, offs_t offset, UINT8 data); + +private: + optional_shared_ptr<UINT8> m_ram; + + int m_bank; +}; + + +// device type definition +extern const device_type COMX_RAM; + + +#endif diff --git a/src/emu/bus/comx35/thermal.c b/src/emu/bus/comx35/thermal.c new file mode 100644 index 00000000000..9746f294a6a --- /dev/null +++ b/src/emu/bus/comx35/thermal.c @@ -0,0 +1,130 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Thermal Printer Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "thermal.h" + + + +//************************************************************************** +// MACROS/CONSTANTS +//************************************************************************** + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type COMX_THM = &device_creator<comx_thm_device>; + + +//------------------------------------------------- +// ROM( comx_thm ) +//------------------------------------------------- + +ROM_START( comx_thm ) + ROM_REGION( 0x2000, "c000", 0 ) + ROM_LOAD( "thermal.bin", 0x0000, 0x1000, CRC(41a72ba8) SHA1(3a8760c78bd8c7bec2dbf26657b930c9a6814803) ) +ROM_END + + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const rom_entry *comx_thm_device::device_rom_region() const +{ + return ROM_NAME( comx_thm ); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// comx_thm_device - constructor +//------------------------------------------------- + +comx_thm_device::comx_thm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, COMX_THM, "COMX-35 Thermal Printer Card", tag, owner, clock, "comx_thm", __FILE__), + device_comx_expansion_card_interface(mconfig, *this), + m_rom(*this, "c000") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void comx_thm_device::device_start() +{ +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void comx_thm_device::device_reset() +{ +} + + +//------------------------------------------------- +// comx_mrd_r - memory read +//------------------------------------------------- + +UINT8 comx_thm_device::comx_mrd_r(address_space &space, offs_t offset, int *extrom) +{ + UINT8 data = 0; + + if (offset >= 0xc000 && offset < 0xd000) + { + data = m_rom->base()[offset & 0xfff]; + } + + return data; +} + + +//------------------------------------------------- +// comx_io_r - I/O read +//------------------------------------------------- + +UINT8 comx_thm_device::comx_io_r(address_space &space, offs_t offset) +{ + /* + INP 2 is used for the printer status, where: + b0=1: Printer Not Ready + b1=1: Energizing Head + b2=1: Head At Position 0 + */ + + return 0; +} + + +//------------------------------------------------- +// comx_io_w - I/O write +//------------------------------------------------- + +void comx_thm_device::comx_io_w(address_space &space, offs_t offset, UINT8 data) +{ + /* + OUT 2 is used to control the thermal printer where: + Q = 0, b0-7: Pixel 1 to 8 + Q = 1, b7: Pixel 9 (if b0-6=#21) + Q = 1, b3=1: Move head right + Q = 1, b0-7=#12: Move head left + */ +} diff --git a/src/emu/bus/comx35/thermal.h b/src/emu/bus/comx35/thermal.h new file mode 100644 index 00000000000..3a4c39ada97 --- /dev/null +++ b/src/emu/bus/comx35/thermal.h @@ -0,0 +1,57 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/********************************************************************** + + COMX-35 Thermal Printer Card emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __COMX_THM__ +#define __COMX_THM__ + +#include "emu.h" +#include "exp.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> comx_thm_device + +class comx_thm_device : public device_t, + public device_comx_expansion_card_interface +{ +public: + // construction/destruction + comx_thm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_comx_expansion_card_interface overrides + virtual UINT8 comx_mrd_r(address_space &space, offs_t offset, int *extrom); + virtual UINT8 comx_io_r(address_space &space, offs_t offset); + virtual void comx_io_w(address_space &space, offs_t offset, UINT8 data); + +private: + required_memory_region m_rom; +}; + + +// device type definition +extern const device_type COMX_THM; + + +#endif |