From 749849ebcbd2df9caf7b8184403bb61a826d3fe4 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 18 Jun 2022 18:47:18 -0400 Subject: mcs96.cpp, upd78k0.cpp, upd78k2.cpp, upd78k4.cpp: Replace BYTE_XOR_LE with new casting helper --- src/devices/cpu/mcs96/mcs96.cpp | 17 +++++++++-------- src/devices/cpu/upd78k/upd78k0.cpp | 10 +++++----- src/devices/cpu/upd78k/upd78k2.cpp | 10 +++++----- src/devices/cpu/upd78k/upd78k4.cpp | 12 ++++++------ 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/devices/cpu/mcs96/mcs96.cpp b/src/devices/cpu/mcs96/mcs96.cpp index 5759469fcc0..ddf7a7604b5 100644 --- a/src/devices/cpu/mcs96/mcs96.cpp +++ b/src/devices/cpu/mcs96/mcs96.cpp @@ -35,6 +35,7 @@ void mcs96_device::device_start() set_icountptr(icount); + auto register_file_bytes = util::little_endian_cast(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(®ister_file[2])[BYTE_XOR_LE(0)]).noshow(); - state_add(MCS96_AH, "AH", reinterpret_cast(®ister_file[2])[BYTE_XOR_LE(1)]).noshow(); - state_add(MCS96_DL, "DL", reinterpret_cast(®ister_file[3])[BYTE_XOR_LE(0)]).noshow(); - state_add(MCS96_DH, "DH", reinterpret_cast(®ister_file[3])[BYTE_XOR_LE(1)]).noshow(); - state_add(MCS96_BL, "BL", reinterpret_cast(®ister_file[4])[BYTE_XOR_LE(0)]).noshow(); - state_add(MCS96_BH, "BH", reinterpret_cast(®ister_file[4])[BYTE_XOR_LE(1)]).noshow(); - state_add(MCS96_CL, "CL", reinterpret_cast(®ister_file[5])[BYTE_XOR_LE(0)]).noshow(); - state_add(MCS96_CH, "CH", reinterpret_cast(®ister_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)); diff --git a/src/devices/cpu/upd78k/upd78k0.cpp b/src/devices/cpu/upd78k/upd78k0.cpp index 0408b5070b8..f1f48402226 100644 --- a/src/devices/cpu/upd78k/upd78k0.cpp +++ b/src/devices/cpu/upd78k/upd78k0.cpp @@ -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(memshare("iram")->ptr()); for (int n = 0; n < 4; n++) state_add(UPD78K0_AX + n, std::array{{"AX", "BC", "DE", "HL"}}[n], - [this, iram, n]() { return static_cast(iram)[(debug_register_base() >> 1) | n]; }, - [this, iram, n](u16 data) { static_cast(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(UPD78K0_X + n, std::array{{"X", "A", "C", "B", "E", "D", "L", "H"}}[n], - [this, iram, n]() { return static_cast(iram)[BYTE_XOR_LE(debug_register_base() | n)]; }, - [this, iram, n](u8 data) { static_cast(iram)[BYTE_XOR_LE(debug_register_base() | n)] = data; } + [this, iram, n]() { return util::little_endian_cast(iram)[debug_register_base() | n]; }, + [this, iram, n](u8 data) { util::little_endian_cast(iram)[debug_register_base() | n] = data; } ).noshow(); // save state diff --git a/src/devices/cpu/upd78k/upd78k2.cpp b/src/devices/cpu/upd78k/upd78k2.cpp index 403bf7319b7..b8c784e20e8 100644 --- a/src/devices/cpu/upd78k/upd78k2.cpp +++ b/src/devices/cpu/upd78k/upd78k2.cpp @@ -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(memshare("iram")->ptr()); for (int n = 0; n < 4; n++) state_add(UPD78K2_AX + n, std::array{{"AX", "BC", "DE", "HL"}}[n], - [this, iram, n]() { return static_cast(iram)[(register_base() >> 1) | n]; }, - [this, iram, n](u16 data) { static_cast(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(UPD78K2_X + n, std::array{{"X", "A", "C", "B", "E", "D", "L", "H"}}[n], - [this, iram, n]() { return static_cast(iram)[BYTE_XOR_LE(register_base() | n)]; }, - [this, iram, n](u8 data) { static_cast(iram)[BYTE_XOR_LE(register_base() | n)] = data; } + [this, iram, n]() { return util::little_endian_cast(iram)[register_base() | n]; }, + [this, iram, n](u8 data) { util::little_endian_cast(iram)[register_base() | n] = data; } ).noshow(); // save state diff --git a/src/devices/cpu/upd78k/upd78k4.cpp b/src/devices/cpu/upd78k/upd78k4.cpp index 242442746f1..0aad7b0660a 100644 --- a/src/devices/cpu/upd78k/upd78k4.cpp +++ b/src/devices/cpu/upd78k/upd78k4.cpp @@ -137,18 +137,18 @@ void upd78k4_device::device_start() } for (int n = 0; n < 16; n++) state_add(UPD78K4_R0 + n, string_format("R%d", n).c_str(), - [this, n]() { return reinterpret_cast(&m_iram[0])[BYTE_XOR_LE(register_base() | n)]; }, - [this, n](u8 data) { reinterpret_cast(&m_iram[0])[BYTE_XOR_LE(register_base() | n)] = data; } + [this, n]() { return util::little_endian_cast(&m_iram[0])[register_base() | n]; }, + [this, n](u8 data) { util::little_endian_cast(&m_iram[0])[register_base() | n] = data; } ).noshow(); for (int n = 0; n < 4; n++) state_add(UPD78K4_X + n, std::array{{"X", "A", "C", "B"}}[n], - [this, n]() { return reinterpret_cast(&m_iram[0])[BYTE_XOR_LE(register_base() | (m_psw & 0x0020) >> 3 | n)]; }, - [this, n](u8 data) { reinterpret_cast(&m_iram[0])[BYTE_XOR_LE(register_base() | (m_psw & 0x0020) >> 3 | n)] = data; } + [this, n]() { return util::little_endian_cast(&m_iram[0])[register_base() | (m_psw & 0x0020) >> 3 | n]; }, + [this, n](u8 data) { util::little_endian_cast(&m_iram[0])[register_base() | (m_psw & 0x0020) >> 3 | n] = data; } ).noshow(); for (int n = 0; n < 8; n++) state_add(UPD78K4_VPL + n, std::array{{"VPL", "VPH", "UPL", "UPH", "E", "D", "L", "H"}}[n], - [this, n]() { return reinterpret_cast(&m_iram[0])[BYTE_XOR_LE(register_base() | 0x08 | n)]; }, - [this, n](u8 data) { reinterpret_cast(&m_iram[0])[BYTE_XOR_LE(register_base() | 0x08 | n)] = data; } + [this, n]() { return util::little_endian_cast(&m_iram[0])[register_base() | 0x08 | n]; }, + [this, n](u8 data) { util::little_endian_cast(&m_iram[0])[register_base() | 0x08 | n] = data; } ).noshow(); // save state -- cgit v1.2.3