cpu/z80/z80.cpp: Refactor redoable case (#12472)

This commit is contained in:
holub 2024-06-12 15:45:08 -04:00 committed by GitHub
parent fba61e93be
commit 589e521996
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 45 deletions

View File

@ -883,42 +883,14 @@ void nsc800_device::device_reset()
memset(m_nsc800_irq_state, 0, sizeof(m_nsc800_irq_state));
}
bool z80_device::check_icount(u8 to_step, int icount_saved, bool redoable)
{
if ((m_icount < 0) && redoable && access_to_be_redone())
{
m_icount = icount_saved;
m_ref = (m_ref & 0xffff00) | (to_step - 1);
m_redone = true;
return true;
}
if (m_icount <= 0)
{
m_ref = (m_ref & 0xffff00) | to_step;
return true;
}
return false;
}
void z80_device::do_op()
{
const bool is_rop = m_ref >= 0xffff00;
#include "cpu/z80/z80.hxx"
if (!is_rop)
{
m_ref = 0xffff00;
}
}
void nsc800_device::do_op()
{
const bool is_rop = m_ref >= 0xffff00;
#include "cpu/z80/z80_ncs800.hxx"
if (!is_rop)
{
m_ref = 0xffff00;
}
}
/****************************************************************************
@ -926,14 +898,13 @@ void nsc800_device::do_op()
****************************************************************************/
void z80_device::execute_run()
{
if (m_wait_state)
if (m_wait_state || m_busrq_state)
{
m_icount = 0; // stalled
return;
}
m_redone = false;
while (m_icount > 0 && !m_redone)
while (m_icount > 0)
{
do_op();
}

View File

@ -114,7 +114,6 @@ protected:
void block_io_interrupted_flags();
virtual void do_op();
bool check_icount(u8 to_step, int icount_saved, bool redoable);
virtual u8 data_read(u16 addr);
virtual void data_write(u16 addr, u8 value);
@ -174,7 +173,6 @@ protected:
PAIR16 m_shared_data2;
u8 m_rtemp;
bool m_redone;
u32 m_ref;
u8 m_m1_cycles;
u8 m_memrq_cycles;

View File

@ -485,8 +485,10 @@ ffff
{
PC--;
m_ref = 0xffff00;
return;
} else {
m_ref = (0x00 << 16) | (TDAT8 << 8);
return;
}

View File

@ -72,27 +72,34 @@ class Opcode:
il.print("m_icount -= %s;" % (" ".join(tokens[1:])), f)
step += 1
to_step = "0x%s" % (hex(256 + step)[3:])
il.print("if (check_icount(%s, 0, false)) return;" % (to_step), f)
print("\t\t[[fallthrough]];", file=f)
il.print("if (m_icount <= 0) {", f)
il.print(" m_ref = (m_ref & 0xffff00) | %s;" % (to_step), f)
il.print(" return;", f)
il.print("}", f)
il.print("[[fallthrough]];", f)
print("\t\tcase %s:" % (to_step), file=f)
elif (len(tokens) > 2 and tokens[1] == "!!"):
print("\t\t[[fallthrough]];", file=f)
il.print("[[fallthrough]];", f)
step += 1;
print("\t\tcase 0x%s:" % (hex(256 + step)[3:]), file=f)
il.print("{", f)
il.print("\tconst int icount = m_icount;", f)
il.print("\t%s" % " ".join(tokens[2:]), f)
il.print("\tm_icount -= %s;" % (tokens[0]), f)
il.print("%s" % " ".join(tokens[2:]), f)
il.print("m_icount -= %s;" % (tokens[0]), f)
il.print("if (m_icount <= 0) {", f)
il.print(" if (access_to_be_redone()) {", f)
il.print(" m_icount += %s;" % (tokens[0]), f)
il.print(" m_ref = (m_ref & 0xffff00) | 0x%s;" % (hex(256 + step)[3:]), f)
il.print(" } else", f)
step += 1
to_step = "0x%s" % (hex(256 + step)[3:])
il.print("\tif (check_icount(%s, icount, true)) return;" % (to_step), f)
il.print(" m_ref = (m_ref & 0xffff00) | %s;" % (to_step), f)
il.print(" return;", f)
il.print("}", f)
print("\t\t[[fallthrough]];", file=f)
il.print("[[fallthrough]];", f)
print("\t\tcase %s:" % (to_step), file=f)
else:
il.print("%s" % line, f)
if has_steps:
print("\t\tbreak;\n", file=f)
print("\t\t\tbreak;\n", file=f)
print("\t\t}", file=f)
class Macro:
@ -219,7 +226,7 @@ class OpcodeList:
if (opc.code[:2]) != prefix:
if prefix is not None:
print("\n\t}", file=f)
print("\tbreak;", file=f)
print("\t\tbreak;", file=f)
print("", file=f)
print("}", file=f)
print("break; // prefix: 0x%s" % (prefix), file=f)
@ -233,13 +240,15 @@ class OpcodeList:
#print("\t{", file=f)
opc.save_dasm(f)
#print("\t}", file=f)
print("\tbreak;", file=f)
print("\t\tbreak;", file=f)
print("", file=f)
print("\t} // switch opcode", file=f)
print("}", file=f)
print("break; // prefix: 0x%s" % (prefix), file=f)
print("", file=f)
print("} // switch prefix", file=f)
print("", file=f)
print("m_ref = 0xffff00;", file=f)
def main(argv):
if len(argv) != 3 and len(argv) != 4: