hmcs400: add logerror for unmapped ports

This commit is contained in:
hap 2024-09-18 12:13:07 +02:00
parent 819379be1e
commit 8f39f074e3
4 changed files with 33 additions and 4 deletions

View File

@ -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);
}

View File

@ -117,6 +117,7 @@ protected:
// opcode handlers
void op_illegal();
void op_todo();
void op_lai();
void op_lbi();

View File

@ -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();
}

View File

@ -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)")