summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Wilbert Pol <wilbert@jdg.info>2014-05-14 19:12:09 +0000
committer Wilbert Pol <wilbert@jdg.info>2014-05-14 19:12:09 +0000
commit64ceb60338687edc4bf9587eb7f13581e4374ad6 (patch)
tree302636ce97f5c2263f0f4d9d734eba49a056039d /src
parent7a106be1de1101827e3dfff35594f8fe51a97fd2 (diff)
Whoops, forgot these (nw)
Diffstat (limited to 'src')
-rw-r--r--src/mess/machine/msx_matsushita.c78
-rw-r--r--src/mess/machine/msx_matsushita.h39
-rw-r--r--src/mess/machine/msx_s1985.c65
-rw-r--r--src/mess/machine/msx_s1985.h32
-rw-r--r--src/mess/machine/msx_switched.c21
-rw-r--r--src/mess/machine/msx_switched.h19
6 files changed, 254 insertions, 0 deletions
diff --git a/src/mess/machine/msx_matsushita.c b/src/mess/machine/msx_matsushita.c
new file mode 100644
index 00000000000..a0a70f6bf40
--- /dev/null
+++ b/src/mess/machine/msx_matsushita.c
@@ -0,0 +1,78 @@
+#include "emu.h"
+#include "msx_matsushita.h"
+
+
+const device_type MSX_MATSUSHITA = &device_creator<msx_matsushita_device>;
+
+
+msx_matsushita_device::msx_matsushita_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : msx_switched_device(mconfig, MSX_MATSUSHITA, "Matsushita switched device", tag, owner, clock, "msx_matsushita", __FILE__)
+ , m_io_config(*this, "CONFIG")
+ , m_turbo_out_cb(*this)
+{
+}
+
+
+UINT8 msx_matsushita_device::get_id()
+{
+ return 0x08;
+}
+
+
+static INPUT_PORTS_START( matsushita )
+ PORT_START("CONFIG")
+ PORT_CONFNAME( 0x80, 0x00, "Firmware switch")
+ PORT_CONFSETTING( 0x00, "On" )
+ PORT_CONFSETTING( 0x80, "Off" )
+ PORT_BIT(0x7F, IP_ACTIVE_LOW, IPT_UNUSED)
+INPUT_PORTS_END
+
+
+ioport_constructor msx_matsushita_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME( matsushita );
+}
+
+
+void msx_matsushita_device::device_start()
+{
+ msx_switched_device::device_start();
+ m_turbo_out_cb.resolve_safe();
+}
+
+READ8_MEMBER(msx_matsushita_device::io_read)
+{
+ switch (offset)
+ {
+ case 0:
+ return ~get_id();
+
+ case 1:
+ return m_io_config->read();
+
+ default:
+ printf("msx_matsushita: unhandled read from offset %02x\n", offset);
+ break;
+ }
+
+ return 0xFF;
+}
+
+
+WRITE8_MEMBER(msx_matsushita_device::io_write)
+{
+ switch (offset)
+ {
+ // bit 0: CPU clock select
+ // 0 - 5.369317 MHz
+ // 1 - 3.579545 MHz
+ case 0x01:
+ m_turbo_out_cb((data & 1) ? ASSERT_LINE : CLEAR_LINE);
+ break;
+
+ default:
+ printf("msx_matsushita: unhandled write %02x to offset %02x\n", data, offset);
+ break;
+ }
+}
+
diff --git a/src/mess/machine/msx_matsushita.h b/src/mess/machine/msx_matsushita.h
new file mode 100644
index 00000000000..ae4a823cc1c
--- /dev/null
+++ b/src/mess/machine/msx_matsushita.h
@@ -0,0 +1,39 @@
+#ifndef __MSX_MATSUSHITA_H
+#define __MSX_MATSUSHITA_H
+
+
+#include "msx_switched.h"
+
+
+extern const device_type MSX_MATSUSHITA;
+
+
+#define MCFG_MSX_MATSUSHITA_ADD(_tag) \
+ MCFG_DEVICE_ADD(_tag, MSX_MATSUSHITA, 0)
+
+#define MCFG_MSX_MATSUSHITA_TURBO_CB(_devcb) \
+ devcb = &msx_matsushita_device::set_turbo_callback(*device, DEVCB_##_devcb);
+
+
+class msx_matsushita_device : public msx_switched_device
+{
+public:
+ msx_matsushita_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ template<class _Object> static devcb_base &set_turbo_callback(device_t &device, _Object object) { return downcast<msx_matsushita_device &>(device).m_turbo_out_cb.set_callback(object); }
+
+ virtual void device_start();
+ virtual ioport_constructor device_input_ports() const;
+
+ virtual UINT8 get_id();
+
+ virtual DECLARE_READ8_MEMBER(io_read);
+ virtual DECLARE_WRITE8_MEMBER(io_write);
+
+private:
+ required_ioport m_io_config;
+ devcb_write_line m_turbo_out_cb;
+};
+
+#endif
+
diff --git a/src/mess/machine/msx_s1985.c b/src/mess/machine/msx_s1985.c
new file mode 100644
index 00000000000..588fb668695
--- /dev/null
+++ b/src/mess/machine/msx_s1985.c
@@ -0,0 +1,65 @@
+#include "emu.h"
+#include "msx_s1985.h"
+
+
+const device_type MSX_S1985 = &device_creator<msx_s1985_device>;
+
+
+msx_s1985_device::msx_s1985_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : msx_switched_device(mconfig, MSX_S1985, "MSX-Engine S1985", tag, owner, clock, "msx_s1985", __FILE__)
+ , m_6_1(0)
+ , m_6_2(0)
+ , m_7(0)
+{
+}
+
+
+UINT8 msx_s1985_device::get_id()
+{
+ return 0xFE;
+}
+
+
+READ8_MEMBER(msx_s1985_device::io_read)
+{
+ switch (offset)
+ {
+ case 0:
+ return ~get_id();
+
+ case 7:
+ {
+ UINT8 data = (m_7 & 0x80) ? m_6_2 : m_6_1;
+ m_7 = ( m_7 << 1 ) | ( m_7 >> 7 );
+ return data;
+ }
+ break;
+
+ default:
+ printf("msx_s1985: unhandled read from offset %02x\n", offset);
+ break;
+ }
+
+ return 0xFF;
+}
+
+
+WRITE8_MEMBER(msx_s1985_device::io_write)
+{
+ switch (offset)
+ {
+ case 6:
+ m_6_2 = m_6_1;
+ m_6_1 = data;
+ break;
+
+ case 7:
+ m_7 = data;
+ break;
+
+ default:
+ printf("msx_s1985: unhandled write %02x to offset %02x\n", data, offset);
+ break;
+ }
+}
+
diff --git a/src/mess/machine/msx_s1985.h b/src/mess/machine/msx_s1985.h
new file mode 100644
index 00000000000..dbe00b16f44
--- /dev/null
+++ b/src/mess/machine/msx_s1985.h
@@ -0,0 +1,32 @@
+#ifndef __MSX_S1985_H
+#define __MSX_S1985_H
+
+
+#include "msx_switched.h"
+
+
+extern const device_type MSX_S1985;
+
+
+#define MCFG_MSX_S1985_ADD(_tag) \
+ MCFG_DEVICE_ADD(_tag, MSX_S1985, 0)
+
+
+class msx_s1985_device : public msx_switched_device
+{
+public:
+ msx_s1985_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ virtual UINT8 get_id();
+
+ virtual DECLARE_READ8_MEMBER(io_read);
+ virtual DECLARE_WRITE8_MEMBER(io_write);
+
+private:
+ UINT8 m_6_1;
+ UINT8 m_6_2;
+ UINT8 m_7;
+};
+
+#endif
+
diff --git a/src/mess/machine/msx_switched.c b/src/mess/machine/msx_switched.c
new file mode 100644
index 00000000000..9b416c7df7d
--- /dev/null
+++ b/src/mess/machine/msx_switched.c
@@ -0,0 +1,21 @@
+#include "emu.h"
+#include "msx_switched.h"
+
+
+msx_switched_device::msx_switched_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, source)
+{
+}
+
+
+void msx_switched_device::device_start()
+{
+ address_space &space = dynamic_cast<device_memory_interface*>(owner())->space();
+
+ // Install IO read/write handlers
+ UINT16 start = ( get_id() << 8 ) | 0x00;
+ UINT16 end = ( get_id() << 8 ) | 0x0f;
+ space.install_read_handler(start, end, read8_delegate(FUNC(msx_switched_device::io_read), this));
+ space.install_write_handler(start, end, write8_delegate(FUNC(msx_switched_device::io_write), this));
+}
+
diff --git a/src/mess/machine/msx_switched.h b/src/mess/machine/msx_switched.h
new file mode 100644
index 00000000000..16848c1e3c7
--- /dev/null
+++ b/src/mess/machine/msx_switched.h
@@ -0,0 +1,19 @@
+#ifndef __MSX_SWITCHED_H
+#define __MSX_SWITCHED_H
+
+
+class msx_switched_device : public device_t
+{
+public:
+ msx_switched_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
+
+ virtual UINT8 get_id() = 0;
+
+ virtual DECLARE_READ8_MEMBER(io_read) = 0;
+ virtual DECLARE_WRITE8_MEMBER(io_write) = 0;
+
+protected:
+ virtual void device_start();
+};
+
+#endif