From 8f39f074e3e3d242dfdb822a11c77a24a008e781 Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 18 Sep 2024 12:13:07 +0200 Subject: hmcs400: add logerror for unmapped ports --- src/devices/cpu/hmcs400/hmcs400.cpp | 25 ++++++++++++++++++++++--- src/devices/cpu/hmcs400/hmcs400.h | 1 + src/devices/cpu/hmcs400/hmcs400op.cpp | 9 +++++++++ src/mame/ussr/debut.cpp | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/devices/cpu/hmcs400/hmcs400.cpp b/src/devices/cpu/hmcs400/hmcs400.cpp index 0c8cc8d4a9c..06a3270cfd3 100644 --- a/src/devices/cpu/hmcs400/hmcs400.cpp +++ b/src/devices/cpu/hmcs400/hmcs400.cpp @@ -318,8 +318,14 @@ u8 hmcs400_cpu_device::read_r(u8 index) return 0xf; } - u8 inp = m_read_r[index].isunset() ? m_r_mask[index] : m_read_r[index](index); u8 mask = (index == 10) ? 3 : 0xf; // port A is 2-bit + u8 inp = m_read_r[index](index); + + if (m_read_r[index].isunset()) + { + inp = m_r_mask[index]; + logerror("read from unmapped port R%X at $%04X\n", index, m_prev_pc); + } if (m_r_mask[index]) return (inp & m_r[index]) & mask; @@ -329,11 +335,15 @@ u8 hmcs400_cpu_device::read_r(u8 index) void hmcs400_cpu_device::write_r(u8 index, u8 data) { + data &= 0xf; + // ignore writes to read-only or non-existent ports if (index > 8) return; - data &= 0xf; + if (m_write_r[index].isunset()) + logerror("write $%X to unmapped port R%d at $%04X\n", data, index, m_prev_pc); + m_r[index] = data; m_write_r[index](index, data); } @@ -342,7 +352,13 @@ int hmcs400_cpu_device::read_d(u8 index) { index &= 0xf; u16 mask = 1 << index; - u16 inp = m_read_d.isunset() ? m_d_mask : m_read_d(0, mask); + u16 inp = m_read_d(0, mask); + + if (m_read_d.isunset()) + { + inp = m_d_mask; + logerror("read from unmapped port D%d at $%04X\n", index, m_prev_pc); + } if (m_d_mask & mask) return BIT(inp & m_d, index); @@ -355,6 +371,9 @@ void hmcs400_cpu_device::write_d(u8 index, int state) index &= 0xf; u16 mask = 1 << index; + if (m_write_d.isunset()) + logerror("write %d to unmapped port D%d at $%04X\n", state, index, m_prev_pc); + m_d = (m_d & ~mask) | (state ? mask : 0); m_write_d(0, m_d, mask); } diff --git a/src/devices/cpu/hmcs400/hmcs400.h b/src/devices/cpu/hmcs400/hmcs400.h index c8572fe0192..f09c37734c5 100644 --- a/src/devices/cpu/hmcs400/hmcs400.h +++ b/src/devices/cpu/hmcs400/hmcs400.h @@ -117,6 +117,7 @@ protected: // opcode handlers void op_illegal(); + void op_todo(); void op_lai(); void op_lbi(); diff --git a/src/devices/cpu/hmcs400/hmcs400op.cpp b/src/devices/cpu/hmcs400/hmcs400op.cpp index 0fb1ea015c5..676cca73115 100644 --- a/src/devices/cpu/hmcs400/hmcs400op.cpp +++ b/src/devices/cpu/hmcs400/hmcs400op.cpp @@ -58,6 +58,11 @@ void hmcs400_cpu_device::op_illegal() logerror("unknown opcode $%03X at $%04X\n", m_op, m_prev_pc); } +void hmcs400_cpu_device::op_todo() +{ + logerror("unimplemented opcode $%03X at $%04X\n", m_op, m_prev_pc); +} + // immediate instructions @@ -572,6 +577,7 @@ void hmcs400_cpu_device::op_rtni() { // RTNI: Return from Interrupt op_rtn(); + op_todo(); } @@ -664,14 +670,17 @@ void hmcs400_cpu_device::op_p() void hmcs400_cpu_device::op_sts() { // STS: Start Serial + op_todo(); } void hmcs400_cpu_device::op_sby() { // SBY: Standby Mode + op_todo(); } void hmcs400_cpu_device::op_stop() { // STOP: Stop Mode + op_todo(); } diff --git a/src/mame/ussr/debut.cpp b/src/mame/ussr/debut.cpp index 1a42c38362a..cf4f7b80c4d 100644 --- a/src/mame/ussr/debut.cpp +++ b/src/mame/ussr/debut.cpp @@ -211,7 +211,7 @@ static INPUT_PORTS_START( debutm ) PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_1) PORT_NAME(u8"ИНТ (Switch 1P/2P)") PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_P) PORT_NAME(u8"ПОЗ (Position Mode)") PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_S) PORT_NAME(u8"ВФ (Select Piece)") - PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_B) PORT_NAME(u8"ВП (Take Back)") + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_T) PORT_NAME(u8"ВП (Take Back)") PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_L) PORT_NAME(u8"УР (Level)") PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_E) PORT_NAME(u8"ВВ (Enter Position)") -- cgit v1.2.3