summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/h6280/h6280.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/h6280/h6280.cpp')
-rw-r--r--src/devices/cpu/h6280/h6280.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/devices/cpu/h6280/h6280.cpp b/src/devices/cpu/h6280/h6280.cpp
index 4fb069d5390..001305f619b 100644
--- a/src/devices/cpu/h6280/h6280.cpp
+++ b/src/devices/cpu/h6280/h6280.cpp
@@ -150,6 +150,14 @@ enum
#define PCW m_pc.w.l
#define PCD m_pc.d
+void h6280_device::internal_map(address_map &map)
+{
+ map(0x1fe800, 0x1fe80f).mirror(0x3f0).rw(FUNC(h6280_device::io_buffer_r), FUNC(h6280_device::psg_w));
+ map(0x1fec00, 0x1fec01).mirror(0x3fe).rw(FUNC(h6280_device::timer_r), FUNC(h6280_device::timer_w));
+ map(0x1ff000, 0x1ff000).mirror(0x3ff).rw(FUNC(h6280_device::port_r), FUNC(h6280_device::port_w));
+ map(0x1ff400, 0x1ff403).mirror(0x3fc).rw(FUNC(h6280_device::irq_status_r), FUNC(h6280_device::irq_status_w));
+}
+
//**************************************************************************
// DEVICE INTERFACE
//**************************************************************************
@@ -162,8 +170,12 @@ DEFINE_DEVICE_TYPE(H6280, h6280_device, "h6280", "Hudson Soft HuC6280")
h6280_device::h6280_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: cpu_device(mconfig, H6280, tag, owner, clock)
- , m_program_config("program", ENDIANNESS_LITTLE, 8, 21)
+ , device_mixer_interface(mconfig, *this, 2)
+ , m_program_config("program", ENDIANNESS_LITTLE, 8, 21, 0, address_map_constructor(FUNC(h6280_device::internal_map), this))
, m_io_config("io", ENDIANNESS_LITTLE, 8, 2)
+ , m_port_in_cb(*this)
+ , m_port_out_cb(*this)
+ , m_psg(*this, "psg")
{
// build the opcode table
for (int op = 0; op < 256; op++)
@@ -214,8 +226,21 @@ const h6280_device::ophandler h6280_device::s_opcodetable[256] =
&h6280_device::op_f8, &h6280_device::op_f9, &h6280_device::op_fa, &h6280_device::op_fb, &h6280_device::op_fc, &h6280_device::op_fd, &h6280_device::op_fe, &h6280_device::op_ff
};
+//-------------------------------------------------
+// device_add_mconfig - add machine configuration
+//-------------------------------------------------
+void h6280_device::device_add_mconfig(machine_config &config)
+{
+ C6280(config, m_psg, DERIVED_CLOCK(1,2));
+ m_psg->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0);
+ m_psg->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1);
+}
+
void h6280_device::device_start()
{
+ m_port_in_cb.resolve_safe(0xff);
+ m_port_out_cb.resolve_safe();
+
// register our state for the debugger
state_add(STATE_GENPC, "GENPC", m_pc.w.l).noshow();
state_add(STATE_GENPCBASE, "CURPC", m_pc.w.l).noshow();
@@ -2560,6 +2585,33 @@ WRITE8_MEMBER( h6280_device::timer_w )
}
}
+READ8_MEMBER( h6280_device::port_r )
+{
+ if (!m_port_in_cb.isnull())
+ return m_port_in_cb();
+
+ return m_io_buffer;
+}
+
+WRITE8_MEMBER( h6280_device::port_w )
+{
+ m_io_buffer = data;
+
+ if (!m_port_out_cb.isnull())
+ m_port_out_cb(data);
+}
+
+READ8_MEMBER( h6280_device::io_buffer_r )
+{
+ return m_io_buffer;
+}
+
+WRITE8_MEMBER( h6280_device::psg_w )
+{
+ m_io_buffer = data;
+ m_psg->c6280_w(space,offset,data,mem_mask);
+}
+
bool h6280_device::memory_translate(int spacenum, int intention, offs_t &address)
{
if (spacenum == AS_PROGRAM)