mcs96.cpp, upd78k0.cpp, upd78k2.cpp, upd78k4.cpp: Replace BYTE_XOR_LE with new casting helper

This commit is contained in:
AJR 2022-06-18 18:47:18 -04:00
parent 2811706ae0
commit 749849ebcb
4 changed files with 25 additions and 24 deletions

View File

@ -35,6 +35,7 @@ void mcs96_device::device_start()
set_icountptr(icount);
auto register_file_bytes = util::little_endian_cast<u8>(register_file.target());
state_add(STATE_GENPC, "GENPC", PC).noshow();
state_add(STATE_GENPCBASE, "CURPC", PPC).noshow();
state_add(STATE_GENFLAGS, "GENFLAGS", PSW).formatstr("%16s").noshow();
@ -46,14 +47,14 @@ void mcs96_device::device_start()
state_add(MCS96_DX, "DX", register_file[3]);
state_add(MCS96_BX, "BX", register_file[4]);
state_add(MCS96_CX, "CX", register_file[5]);
state_add(MCS96_AL, "AL", reinterpret_cast<u8 *>(&register_file[2])[BYTE_XOR_LE(0)]).noshow();
state_add(MCS96_AH, "AH", reinterpret_cast<u8 *>(&register_file[2])[BYTE_XOR_LE(1)]).noshow();
state_add(MCS96_DL, "DL", reinterpret_cast<u8 *>(&register_file[3])[BYTE_XOR_LE(0)]).noshow();
state_add(MCS96_DH, "DH", reinterpret_cast<u8 *>(&register_file[3])[BYTE_XOR_LE(1)]).noshow();
state_add(MCS96_BL, "BL", reinterpret_cast<u8 *>(&register_file[4])[BYTE_XOR_LE(0)]).noshow();
state_add(MCS96_BH, "BH", reinterpret_cast<u8 *>(&register_file[4])[BYTE_XOR_LE(1)]).noshow();
state_add(MCS96_CL, "CL", reinterpret_cast<u8 *>(&register_file[5])[BYTE_XOR_LE(0)]).noshow();
state_add(MCS96_CH, "CH", reinterpret_cast<u8 *>(&register_file[5])[BYTE_XOR_LE(1)]).noshow();
state_add(MCS96_AL, "AL", register_file_bytes[4]).noshow();
state_add(MCS96_AH, "AH", register_file_bytes[5]).noshow();
state_add(MCS96_DL, "DL", register_file_bytes[6]).noshow();
state_add(MCS96_DH, "DH", register_file_bytes[7]).noshow();
state_add(MCS96_BL, "BL", register_file_bytes[8]).noshow();
state_add(MCS96_BH, "BH", register_file_bytes[9]).noshow();
state_add(MCS96_CL, "CL", register_file_bytes[10]).noshow();
state_add(MCS96_CH, "CH", register_file_bytes[11]).noshow();
save_item(NAME(inst_state));
save_item(NAME(pending_irq));

View File

@ -117,16 +117,16 @@ void upd78k0_device::device_start()
[this](u8 data) { m_psw = (m_psw & 0xd7) | (data & 2) << 4 | (data & 1) << 3; }
).mask(3).noshow();
state_add(UPD78K0_SP, "SP", m_sp);
void *iram = memshare("iram")->ptr();
u16 *iram = static_cast<u16 *>(memshare("iram")->ptr());
for (int n = 0; n < 4; n++)
state_add<u16>(UPD78K0_AX + n, std::array<const char *, 4>{{"AX", "BC", "DE", "HL"}}[n],
[this, iram, n]() { return static_cast<u16 *>(iram)[(debug_register_base() >> 1) | n]; },
[this, iram, n](u16 data) { static_cast<u16 *>(iram)[(debug_register_base() >> 1) | n] = data; }
[this, iram, n]() { return iram[(debug_register_base() >> 1) | n]; },
[this, iram, n](u16 data) { iram[(debug_register_base() >> 1) | n] = data; }
);
for (int n = 0; n < 8; n++)
state_add<u8>(UPD78K0_X + n, std::array<const char *, 8>{{"X", "A", "C", "B", "E", "D", "L", "H"}}[n],
[this, iram, n]() { return static_cast<u8 *>(iram)[BYTE_XOR_LE(debug_register_base() | n)]; },
[this, iram, n](u8 data) { static_cast<u8 *>(iram)[BYTE_XOR_LE(debug_register_base() | n)] = data; }
[this, iram, n]() { return util::little_endian_cast<const u8>(iram)[debug_register_base() | n]; },
[this, iram, n](u8 data) { util::little_endian_cast<u8>(iram)[debug_register_base() | n] = data; }
).noshow();
// save state

View File

@ -100,16 +100,16 @@ void upd78k2_device::device_start()
[this](u8 data) { m_psw = (m_psw & 0xd7) | (data & 2) << 4 | (data & 1) << 3; }
).mask(3).noshow();
state_add(UPD78K2_SP, "SP", m_sp);
void *iram = memshare("iram")->ptr();
u16 *iram = static_cast<u16 *>(memshare("iram")->ptr());
for (int n = 0; n < 4; n++)
state_add<u16>(UPD78K2_AX + n, std::array<const char *, 4>{{"AX", "BC", "DE", "HL"}}[n],
[this, iram, n]() { return static_cast<u16 *>(iram)[(register_base() >> 1) | n]; },
[this, iram, n](u16 data) { static_cast<u16 *>(iram)[(register_base() >> 1) | n] = data; }
[this, iram, n]() { return iram[(register_base() >> 1) | n]; },
[this, iram, n](u16 data) { iram[(register_base() >> 1) | n] = data; }
);
for (int n = 0; n < 8; n++)
state_add<u8>(UPD78K2_X + n, std::array<const char *, 8>{{"X", "A", "C", "B", "E", "D", "L", "H"}}[n],
[this, iram, n]() { return static_cast<u8 *>(iram)[BYTE_XOR_LE(register_base() | n)]; },
[this, iram, n](u8 data) { static_cast<u8 *>(iram)[BYTE_XOR_LE(register_base() | n)] = data; }
[this, iram, n]() { return util::little_endian_cast<const u8>(iram)[register_base() | n]; },
[this, iram, n](u8 data) { util::little_endian_cast<u8>(iram)[register_base() | n] = data; }
).noshow();
// save state

View File

@ -137,18 +137,18 @@ void upd78k4_device::device_start()
}
for (int n = 0; n < 16; n++)
state_add<u8>(UPD78K4_R0 + n, string_format("R%d", n).c_str(),
[this, n]() { return reinterpret_cast<u8 *>(&m_iram[0])[BYTE_XOR_LE(register_base() | n)]; },
[this, n](u8 data) { reinterpret_cast<u8 *>(&m_iram[0])[BYTE_XOR_LE(register_base() | n)] = data; }
[this, n]() { return util::little_endian_cast<const u8>(&m_iram[0])[register_base() | n]; },
[this, n](u8 data) { util::little_endian_cast<u8>(&m_iram[0])[register_base() | n] = data; }
).noshow();
for (int n = 0; n < 4; n++)
state_add<u8>(UPD78K4_X + n, std::array<const char *, 4>{{"X", "A", "C", "B"}}[n],
[this, n]() { return reinterpret_cast<u8 *>(&m_iram[0])[BYTE_XOR_LE(register_base() | (m_psw & 0x0020) >> 3 | n)]; },
[this, n](u8 data) { reinterpret_cast<u8 *>(&m_iram[0])[BYTE_XOR_LE(register_base() | (m_psw & 0x0020) >> 3 | n)] = data; }
[this, n]() { return util::little_endian_cast<const u8>(&m_iram[0])[register_base() | (m_psw & 0x0020) >> 3 | n]; },
[this, n](u8 data) { util::little_endian_cast<u8>(&m_iram[0])[register_base() | (m_psw & 0x0020) >> 3 | n] = data; }
).noshow();
for (int n = 0; n < 8; n++)
state_add<u8>(UPD78K4_VPL + n, std::array<const char *, 8>{{"VPL", "VPH", "UPL", "UPH", "E", "D", "L", "H"}}[n],
[this, n]() { return reinterpret_cast<u8 *>(&m_iram[0])[BYTE_XOR_LE(register_base() | 0x08 | n)]; },
[this, n](u8 data) { reinterpret_cast<u8 *>(&m_iram[0])[BYTE_XOR_LE(register_base() | 0x08 | n)] = data; }
[this, n]() { return util::little_endian_cast<const u8>(&m_iram[0])[register_base() | 0x08 | n]; },
[this, n](u8 data) { util::little_endian_cast<u8>(&m_iram[0])[register_base() | 0x08 | n] = data; }
).noshow();
// save state