summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2017-02-19 19:38:55 -0500
committer AJR <ajrhacker@users.noreply.github.com>2017-02-19 19:38:55 -0500
commitd31f08ef7721f4be02c964a93662c314150c3c94 (patch)
tree5cb5e84de1ad959c88ca229835ee7a4121d734c1
parent18ead3f434ccd5f39d04a84da2c8f0bbc236024f (diff)
docastle.cpp: Read inputs through TMS1025
tms1024/tms1025: Add input callbacks and read handler; clean up code a little
-rw-r--r--scripts/target/mame/arcade.lua2
-rw-r--r--src/devices/machine/tms1024.cpp34
-rw-r--r--src/devices/machine/tms1024.h42
-rw-r--r--src/mame/drivers/docastle.cpp56
-rw-r--r--src/mame/drivers/hh_tms1k.cpp14
-rw-r--r--src/mame/includes/docastle.h7
-rw-r--r--src/mame/video/docastle.cpp10
7 files changed, 89 insertions, 76 deletions
diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua
index 199d8f95029..2e88c4969f4 100644
--- a/scripts/target/mame/arcade.lua
+++ b/scripts/target/mame/arcade.lua
@@ -592,7 +592,7 @@ MACHINES["STEPPERS"] = true
--MACHINES["WOZFDC"] = true
--MACHINES["DIABLO_HD"] = true
MACHINES["PCI9050"] = true
---MACHINES["TMS1024"] = true
+MACHINES["TMS1024"] = true
MACHINES["GENPC"] = true
MACHINES["GEN_LATCH"] = true
MACHINES["WATCHDOG"] = true
diff --git a/src/devices/machine/tms1024.cpp b/src/devices/machine/tms1024.cpp
index 4dbd8019407..e0f98ef00df 100644
--- a/src/devices/machine/tms1024.cpp
+++ b/src/devices/machine/tms1024.cpp
@@ -25,15 +25,15 @@ const device_type TMS1025 = &device_creator<tms1025_device>;
// constructor
//-------------------------------------------------
-tms1024_device::tms1024_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : device_t(mconfig, TMS1024, "TMS1024 I/O Expander", tag, owner, clock, "tms1024", __FILE__), m_h(0), m_s(0), m_std(0),
- m_write_port1(*this), m_write_port2(*this), m_write_port3(*this), m_write_port4(*this), m_write_port5(*this), m_write_port6(*this), m_write_port7(*this)
+tms1024_device::tms1024_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source), m_h(0), m_s(0), m_std(0),
+ m_read_port{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}},
+ m_write_port{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}}
{
}
-tms1024_device::tms1024_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source)
- : device_t(mconfig, type, name, tag, owner, clock, shortname, source), m_h(0), m_s(0), m_std(0),
- m_write_port1(*this), m_write_port2(*this), m_write_port3(*this), m_write_port4(*this), m_write_port5(*this), m_write_port6(*this), m_write_port7(*this)
+tms1024_device::tms1024_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : tms1024_device(mconfig, TMS1024, "TMS1024 I/O Expander", tag, owner, clock, "tms1024", __FILE__)
{
}
@@ -51,13 +51,10 @@ tms1025_device::tms1025_device(const machine_config &mconfig, const char *tag, d
void tms1024_device::device_start()
{
// resolve callbacks (there is no port 0)
- m_write_port1.resolve_safe(); m_write_port[0] = &m_write_port1;
- m_write_port2.resolve_safe(); m_write_port[1] = &m_write_port2;
- m_write_port3.resolve_safe(); m_write_port[2] = &m_write_port3;
- m_write_port4.resolve_safe(); m_write_port[3] = &m_write_port4;
- m_write_port5.resolve_safe(); m_write_port[4] = &m_write_port5;
- m_write_port6.resolve_safe(); m_write_port[5] = &m_write_port6;
- m_write_port7.resolve_safe(); m_write_port[6] = &m_write_port7;
+ for (devcb_read8 &cb : m_read_port)
+ cb.resolve_safe(0);
+ for (devcb_write8 &cb : m_write_port)
+ cb.resolve_safe();
// zerofill
m_h = 0;
@@ -105,8 +102,17 @@ WRITE_LINE_MEMBER(tms1024_device::write_std)
if (state && !m_std)
{
if (m_s != 0)
- (*m_write_port[m_s-1])((offs_t)(m_s-1), m_h);
+ (m_write_port[m_s-1])((offs_t)(m_s-1), m_h);
}
m_std = state;
}
+
+READ8_MEMBER(tms1024_device::read_h)
+{
+ // TODO: which pin enables read?
+ if (m_s != 0)
+ m_h = (m_read_port[m_s-1])((offs_t)(m_s-1)) & 0xf;
+
+ return m_h;
+}
diff --git a/src/devices/machine/tms1024.h b/src/devices/machine/tms1024.h
index 606098d90fb..a5ccb5bdb78 100644
--- a/src/devices/machine/tms1024.h
+++ b/src/devices/machine/tms1024.h
@@ -15,18 +15,20 @@
// 4-bit ports (3210 = DCBA)
// valid ports: 4-7 for TMS1024, 1-7 for TMS1025
-#define MCFG_TMS1024_WRITE_PORT_CB(X, _devcb) \
- devcb = &tms1024_device::set_write_port##X##_callback(*device, DEVCB_##_devcb);
+#define MCFG_TMS1025_READ_PORT_CB(X, _devcb) \
+ devcb = &tms1024_device::set_read_port_callback(*device, X, DEVCB_##_devcb);
+#define MCFG_TMS1025_WRITE_PORT_CB(X, _devcb) \
+ devcb = &tms1024_device::set_write_port_callback(*device, X, DEVCB_##_devcb);
enum
{
- TMS1024_PORT1 = 0,
- TMS1024_PORT2,
- TMS1024_PORT3,
- TMS1024_PORT4,
- TMS1024_PORT5,
- TMS1024_PORT6,
- TMS1024_PORT7
+ TMS1025_PORT1 = 0,
+ TMS1025_PORT2,
+ TMS1025_PORT3,
+ TMS1025_PORT4,
+ TMS1025_PORT5,
+ TMS1025_PORT6,
+ TMS1025_PORT7
};
@@ -67,17 +69,21 @@ public:
tms1024_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source);
// static configuration helpers
- template<class _Object> static devcb_base &set_write_port1_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port1.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port2_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port2.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port3_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port3.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port4_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port4.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port5_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port5.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port6_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port6.set_callback(object); }
- template<class _Object> static devcb_base &set_write_port7_callback(device_t &device, _Object object) { return downcast<tms1024_device &>(device).m_write_port7.set_callback(object); }
+ template<class _Object> static devcb_base &set_read_port_callback(device_t &device, int port, _Object &&object)
+ {
+ assert(port >= TMS1025_PORT1 && port <= TMS1025_PORT7);
+ return downcast<tms1024_device &>(device).m_read_port[port].set_callback(std::forward<_Object>(object));
+ }
+ template<class _Object> static devcb_base &set_write_port_callback(device_t &device, int port, _Object &&object)
+ {
+ assert(port >= TMS1025_PORT1 && port <= TMS1025_PORT7);
+ return downcast<tms1024_device &>(device).m_write_port[port].set_callback(std::forward<_Object>(object));
+ }
DECLARE_WRITE8_MEMBER(write_h);
DECLARE_WRITE8_MEMBER(write_s);
DECLARE_WRITE_LINE_MEMBER(write_std);
+ DECLARE_READ8_MEMBER(read_h);
protected:
// device-level overrides
@@ -89,8 +95,8 @@ protected:
u8 m_std; // strobe pin
// callbacks
- devcb_write8 m_write_port1, m_write_port2, m_write_port3, m_write_port4, m_write_port5, m_write_port6, m_write_port7;
- devcb_write8 *m_write_port[7];
+ devcb_read8 m_read_port[7];
+ devcb_write8 m_write_port[7];
};
diff --git a/src/mame/drivers/docastle.cpp b/src/mame/drivers/docastle.cpp
index 7af24557142..55d63c40872 100644
--- a/src/mame/drivers/docastle.cpp
+++ b/src/mame/drivers/docastle.cpp
@@ -109,8 +109,11 @@ ac00 sound port 4
Notes:
------
+- All inputs are read through the TMS1025N2LC at D8 (low 4 bits) and F8
+ (high 4 bits). Pins 11-16, 18 and 27-34 of both devices are linked to the
+ edge connector, though several of these input lines are typically unused.
- idsoccer seems to run on a modified version of this board which allows for
- more sprite tiles, it also has a MSM5205 chip for sample playback.
+ more sprite tiles; it also has an extra sound board for ADPCM playback.
TODO:
-----
@@ -229,12 +232,7 @@ static ADDRESS_MAP_START( docastle_map2, AS_PROGRAM, 8, docastle_state )
AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0xa000, 0xa008) AM_READWRITE(docastle_shared1_r, docastle_shared0_w)
- AM_RANGE(0xc001, 0xc001) AM_MIRROR(0x0080) AM_READ_PORT("DSW2")
- AM_RANGE(0xc002, 0xc002) AM_MIRROR(0x0080) AM_READ_PORT("DSW1")
- AM_RANGE(0xc003, 0xc003) AM_MIRROR(0x0080) AM_READ_PORT("JOYS")
- AM_RANGE(0xc004, 0xc004) AM_SELECT(0x0080) AM_READWRITE(flipscreen_r, flipscreen_w)
- AM_RANGE(0xc005, 0xc005) AM_MIRROR(0x0080) AM_READ_PORT("BUTTONS")
- AM_RANGE(0xc007, 0xc007) AM_MIRROR(0x0080) AM_READ_PORT("SYSTEM")
+ AM_RANGE(0xc000, 0xc007) AM_SELECT(0x0080) AM_READWRITE(inputs_flipscreen_r, flipscreen_w)
AM_RANGE(0xe000, 0xe000) AM_DEVWRITE("sn1", sn76489a_device, write)
AM_RANGE(0xe400, 0xe400) AM_DEVWRITE("sn2", sn76489a_device, write)
AM_RANGE(0xe800, 0xe800) AM_DEVWRITE("sn3", sn76489a_device, write)
@@ -275,12 +273,7 @@ static ADDRESS_MAP_START( dorunrun_map2, AS_PROGRAM, 8, docastle_state )
AM_RANGE(0xa400, 0xa400) AM_DEVWRITE("sn2", sn76489a_device, write)
AM_RANGE(0xa800, 0xa800) AM_DEVWRITE("sn3", sn76489a_device, write)
AM_RANGE(0xac00, 0xac00) AM_DEVWRITE("sn4", sn76489a_device, write)
- AM_RANGE(0xc001, 0xc001) AM_MIRROR(0x0080) AM_READ_PORT("DSW2")
- AM_RANGE(0xc002, 0xc002) AM_MIRROR(0x0080) AM_READ_PORT("DSW1")
- AM_RANGE(0xc003, 0xc003) AM_MIRROR(0x0080) AM_READ_PORT("JOYS")
- AM_RANGE(0xc004, 0xc004) AM_SELECT(0x0080) AM_READWRITE(flipscreen_r, flipscreen_w)
- AM_RANGE(0xc005, 0xc005) AM_MIRROR(0x0080) AM_READ_PORT("BUTTONS")
- AM_RANGE(0xc007, 0xc007) AM_MIRROR(0x0080) AM_READ_PORT("SYSTEM")
+ AM_RANGE(0xc000, 0xc007) AM_SELECT(0x0080) AM_READWRITE(inputs_flipscreen_r, flipscreen_w)
AM_RANGE(0xe000, 0xe008) AM_READWRITE(docastle_shared1_r, docastle_shared0_w)
ADDRESS_MAP_END
@@ -298,22 +291,6 @@ static ADDRESS_MAP_START( idsoccer_map, AS_PROGRAM, 8, docastle_state )
AM_RANGE(0xe000, 0xe000) AM_WRITE(docastle_nmitrigger_w)
ADDRESS_MAP_END
-static ADDRESS_MAP_START( idsoccer_map2, AS_PROGRAM, 8, docastle_state )
- AM_RANGE(0x0000, 0x3fff) AM_ROM
- AM_RANGE(0x8000, 0x87ff) AM_RAM
- AM_RANGE(0xa000, 0xa008) AM_READWRITE(docastle_shared1_r, docastle_shared0_w)
- AM_RANGE(0xc001, 0xc001) AM_MIRROR(0x0080) AM_READ_PORT("DSW2")
- AM_RANGE(0xc002, 0xc002) AM_MIRROR(0x0080) AM_READ_PORT("DSW1")
- AM_RANGE(0xc003, 0xc003) AM_MIRROR(0x0080) AM_READ_PORT("JOYS")
- AM_RANGE(0xc004, 0xc004) AM_SELECT(0x0080) AM_READ_PORT("JOYS_RIGHT") AM_WRITE(flipscreen_w)
- AM_RANGE(0xc005, 0xc005) AM_MIRROR(0x0080) AM_READ_PORT("BUTTONS")
- AM_RANGE(0xc007, 0xc007) AM_MIRROR(0x0080) AM_READ_PORT("SYSTEM")
- AM_RANGE(0xe000, 0xe000) AM_DEVWRITE("sn1", sn76489a_device, write)
- AM_RANGE(0xe400, 0xe400) AM_DEVWRITE("sn2", sn76489a_device, write)
- AM_RANGE(0xe800, 0xe800) AM_DEVWRITE("sn3", sn76489a_device, write)
- AM_RANGE(0xec00, 0xec00) AM_DEVWRITE("sn4", sn76489a_device, write)
-ADDRESS_MAP_END
-
/* Input Ports */
static INPUT_PORTS_START( docastle )
@@ -598,6 +575,20 @@ static MACHINE_CONFIG_START( docastle, docastle_state )
MCFG_CPU_PROGRAM_MAP(docastle_map3)
MCFG_CPU_VBLANK_INT_DRIVER("screen", docastle_state, nmi_line_pulse)
+ MCFG_DEVICE_ADD("inp1", TMS1025, 0)
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT1, IOPORT("DSW2"))
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT2, IOPORT("DSW1"))
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT3, IOPORT("JOYS"))
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT5, IOPORT("BUTTONS"))
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT7, IOPORT("SYSTEM"))
+
+ MCFG_DEVICE_ADD("inp2", TMS1025, 0)
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT1, IOPORT("DSW2")) MCFG_DEVCB_RSHIFT(4)
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT2, IOPORT("DSW1")) MCFG_DEVCB_RSHIFT(4)
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT3, IOPORT("JOYS")) MCFG_DEVCB_RSHIFT(4)
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT5, IOPORT("BUTTONS")) MCFG_DEVCB_RSHIFT(4)
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT7, IOPORT("SYSTEM")) MCFG_DEVCB_RSHIFT(4)
+
MCFG_WATCHDOG_ADD("watchdog")
/* video hardware */
@@ -657,8 +648,11 @@ static MACHINE_CONFIG_DERIVED( idsoccer, docastle )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(idsoccer_map)
- MCFG_CPU_MODIFY("slave")
- MCFG_CPU_PROGRAM_MAP(idsoccer_map2)
+ MCFG_DEVICE_MODIFY("inp1")
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT4, IOPORT("JOYS_RIGHT"))
+
+ MCFG_DEVICE_MODIFY("inp2")
+ MCFG_TMS1025_READ_PORT_CB(TMS1025_PORT4, IOPORT("JOYS_RIGHT")) MCFG_DEVCB_RSHIFT(4)
/* video hardware */
MCFG_VIDEO_START_OVERRIDE(docastle_state,dorunrun)
diff --git a/src/mame/drivers/hh_tms1k.cpp b/src/mame/drivers/hh_tms1k.cpp
index 2dddee91c80..bef0ebd74f8 100644
--- a/src/mame/drivers/hh_tms1k.cpp
+++ b/src/mame/drivers/hh_tms1k.cpp
@@ -7822,13 +7822,13 @@ static MACHINE_CONFIG_START( tbreakup, tbreakup_state )
MCFG_TMS1XXX_WRITE_O_CB(WRITE16(tbreakup_state, write_o))
MCFG_DEVICE_ADD("expander", TMS1025, 0)
- MCFG_TMS1024_WRITE_PORT_CB(1, WRITE8(tbreakup_state, expander_w))
- MCFG_TMS1024_WRITE_PORT_CB(2, WRITE8(tbreakup_state, expander_w))
- MCFG_TMS1024_WRITE_PORT_CB(3, WRITE8(tbreakup_state, expander_w))
- MCFG_TMS1024_WRITE_PORT_CB(4, WRITE8(tbreakup_state, expander_w))
- MCFG_TMS1024_WRITE_PORT_CB(5, WRITE8(tbreakup_state, expander_w))
- MCFG_TMS1024_WRITE_PORT_CB(6, WRITE8(tbreakup_state, expander_w))
- MCFG_TMS1024_WRITE_PORT_CB(7, WRITE8(tbreakup_state, expander_w))
+ MCFG_TMS1025_WRITE_PORT_CB(TMS1025_PORT1, WRITE8(tbreakup_state, expander_w))
+ MCFG_TMS1025_WRITE_PORT_CB(TMS1025_PORT2, WRITE8(tbreakup_state, expander_w))
+ MCFG_TMS1025_WRITE_PORT_CB(TMS1025_PORT3, WRITE8(tbreakup_state, expander_w))
+ MCFG_TMS1025_WRITE_PORT_CB(TMS1025_PORT4, WRITE8(tbreakup_state, expander_w))
+ MCFG_TMS1025_WRITE_PORT_CB(TMS1025_PORT5, WRITE8(tbreakup_state, expander_w))
+ MCFG_TMS1025_WRITE_PORT_CB(TMS1025_PORT6, WRITE8(tbreakup_state, expander_w))
+ MCFG_TMS1025_WRITE_PORT_CB(TMS1025_PORT7, WRITE8(tbreakup_state, expander_w))
MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_tms1k_state, display_decay_tick, attotime::from_msec(1))
MCFG_DEFAULT_LAYOUT(layout_tbreakup)
diff --git a/src/mame/includes/docastle.h b/src/mame/includes/docastle.h
index 78afee5b4af..8552ba318fa 100644
--- a/src/mame/includes/docastle.h
+++ b/src/mame/includes/docastle.h
@@ -6,6 +6,7 @@
***************************************************************************/
+#include "machine/tms1024.h"
#include "video/mc6845.h"
#include "sound/msm5205.h"
@@ -19,6 +20,8 @@ public:
m_cpu3(*this, "cpu3"),
m_crtc(*this, "crtc"),
m_msm(*this, "msm"),
+ m_inp1(*this, "inp1"),
+ m_inp2(*this, "inp2"),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram"),
m_spriteram(*this, "spriteram"),
@@ -32,6 +35,8 @@ public:
required_device<cpu_device> m_cpu3;
required_device<h46505_device> m_crtc;
optional_device<msm5205_device> m_msm;
+ required_device<tms1025_device> m_inp1;
+ required_device<tms1025_device> m_inp2;
/* memory pointers */
required_shared_ptr<uint8_t> m_videoram;
@@ -60,7 +65,7 @@ public:
DECLARE_WRITE8_MEMBER(docastle_nmitrigger_w);
DECLARE_WRITE8_MEMBER(docastle_videoram_w);
DECLARE_WRITE8_MEMBER(docastle_colorram_w);
- DECLARE_READ8_MEMBER(flipscreen_r);
+ DECLARE_READ8_MEMBER(inputs_flipscreen_r);
DECLARE_WRITE8_MEMBER(flipscreen_w);
DECLARE_READ8_MEMBER(idsoccer_adpcm_status_r);
DECLARE_WRITE8_MEMBER(idsoccer_adpcm_w);
diff --git a/src/mame/video/docastle.cpp b/src/mame/video/docastle.cpp
index f8a8d26e9b0..1e847d97564 100644
--- a/src/mame/video/docastle.cpp
+++ b/src/mame/video/docastle.cpp
@@ -75,15 +75,17 @@ WRITE8_MEMBER(docastle_state::docastle_colorram_w)
m_do_tilemap->mark_tile_dirty(offset);
}
-READ8_MEMBER(docastle_state::flipscreen_r)
+READ8_MEMBER(docastle_state::inputs_flipscreen_r)
{
- flip_screen_set(offset);
- return (offset ? 1 : 0); // is this really needed?
+ flip_screen_set(BIT(offset, 7));
+ m_inp1->write_s(space, 0, offset & 7);
+ m_inp2->write_s(space, 0, offset & 7);
+ return (m_inp2->read_h(space, 0) << 4) | m_inp1->read_h(space, 0);
}
WRITE8_MEMBER(docastle_state::flipscreen_w)
{
- flip_screen_set(offset);
+ flip_screen_set(BIT(offset, 7));
}
TILE_GET_INFO_MEMBER(docastle_state::get_tile_info)