From 95fc84a22cce5d4a6570dee9631f99ec17904fba Mon Sep 17 00:00:00 2001 From: wilbertpol Date: Sun, 30 Apr 2023 17:11:18 +0100 Subject: cpu/z80: Fixed incorrect cycle counts when custom cycle tables are used. (#11167) bus/msx/module/skw01.cpp: Removed note about instability in the cx5m128 driver. Software list items promoted to working --------------------------------------- msx1_cart.xml: A Life Planet - M36 - Mother Brain has been aliving (Japan) --- hash/msx1_cart.xml | 3 +-- src/devices/bus/msx/module/skw01.cpp | 5 ----- src/devices/cpu/z80/z80.cpp | 11 +++++++++-- src/devices/cpu/z80/z80.h | 2 ++ src/mame/sega/system1.cpp | 1 + 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hash/msx1_cart.xml b/hash/msx1_cart.xml index 7e3d734161a..aad8da971aa 100644 --- a/hash/msx1_cart.xml +++ b/hash/msx1_cart.xml @@ -1317,8 +1317,7 @@ kept for now until finding out what those bytes affect... - - + A Life Planet - M36 - Mother Brain has been aliving (Japan) 1987 Pixel diff --git a/src/devices/bus/msx/module/skw01.cpp b/src/devices/bus/msx/module/skw01.cpp index 1e683e7eda3..0fef9c1de6b 100644 --- a/src/devices/bus/msx/module/skw01.cpp +++ b/src/devices/bus/msx/module/skw01.cpp @@ -11,11 +11,6 @@ The PCB is labeled YMX-YWP. The software can be started from Basic by entering the command "CALL JWP" or "_JWP". -TODO: -- This module runs unstable on the cx5m128 driver. - The instability is mostly visible when pressing F1, causing the system - to reset, hang, or display a screen with random data. - **************************************************************************/ #include "emu.h" diff --git a/src/devices/cpu/z80/z80.cpp b/src/devices/cpu/z80/z80.cpp index a10754cf0b4..63ddff5d772 100644 --- a/src/devices/cpu/z80/z80.cpp +++ b/src/devices/cpu/z80/z80.cpp @@ -340,7 +340,7 @@ static const uint8_t cc_ex[0x100] = { } while (0) // T Memory Address -#define MTM ((m_cc_op == nullptr ? 4 : m_cc_op[0])-1) +#define MTM (m_mtm_cycles) #define EXEC(prefix,opcode) do { \ unsigned op = opcode; \ @@ -3814,6 +3814,12 @@ void z80_device::z80_set_cycle_tables(const uint8_t *op, const uint8_t *cb, cons } +void z80_device::set_mtm_cycles(uint8_t mtm_cycles) +{ + m_mtm_cycles = mtm_cycles; +} + + z80_device::z80_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : z80_device(mconfig, Z80, tag, owner, clock) { @@ -3828,7 +3834,8 @@ z80_device::z80_device(const machine_config &mconfig, device_type type, const ch m_irqack_cb(*this), m_refresh_cb(*this), m_nomreq_cb(*this), - m_halt_cb(*this) + m_halt_cb(*this), + m_mtm_cycles(3) { } diff --git a/src/devices/cpu/z80/z80.h b/src/devices/cpu/z80/z80.h index 8d3ac158325..64951171860 100644 --- a/src/devices/cpu/z80/z80.h +++ b/src/devices/cpu/z80/z80.h @@ -33,6 +33,7 @@ public: z80_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); void z80_set_cycle_tables(const uint8_t *op, const uint8_t *cb, const uint8_t *ed, const uint8_t *xy, const uint8_t *xycb, const uint8_t *ex); + void set_mtm_cycles(uint8_t mtm_cycles); template void set_memory_map(T &&... args) { set_addrmap(AS_PROGRAM, std::forward(args)...); } template void set_m1_map(T &&... args) { set_addrmap(AS_OPCODES, std::forward(args)...); } template void set_io_map(T &&... args) { set_addrmap(AS_IO, std::forward(args)...); } @@ -291,6 +292,7 @@ protected: const uint8_t * m_cc_xy; const uint8_t * m_cc_xycb; const uint8_t * m_cc_ex; + uint8_t m_mtm_cycles; }; DECLARE_DEVICE_TYPE(Z80, z80_device) diff --git a/src/mame/sega/system1.cpp b/src/mame/sega/system1.cpp index fa623bfdad6..b1462381f9a 100644 --- a/src/mame/sega/system1.cpp +++ b/src/mame/sega/system1.cpp @@ -469,6 +469,7 @@ void system1_state::machine_start() } m_maincpu->z80_set_cycle_tables(cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex); + m_maincpu->set_mtm_cycles(3*5); m_mute_xor = 0x00; m_dakkochn_mux_data = 0x00; -- cgit v1.2.3