Added Debugger

This commit is contained in:
2026-04-08 22:36:26 +01:00
parent d857c88d12
commit 5550eb8c91
5 changed files with 563 additions and 4 deletions

View File

@@ -5,6 +5,9 @@ namespace Core.Cpu
{
public partial class Z80
{
//T-State counter
public long TotalTStates { get; set; }
// Main Register Set
public RegisterPair AF;
public RegisterPair BC;
@@ -52,9 +55,24 @@ namespace Core.Cpu
{
// Fetch the next opcode and increment the Program Counter
byte opcode = _memory.Read(PC++);
int tStates = ExecuteOpcode(opcode);
TotalTStates += tStates;
// Decode and execute
return ExecuteOpcode(opcode);
return tStates;
}
public string GetFlagsString()
{
byte f = AF.Low;
return $"S:{(f >> 7) & 1} " +
$"Z:{(f >> 6) & 1} " +
$"Y:{(f >> 5) & 1} " + // Undocumented flag
$"H:{(f >> 4) & 1} " +
$"X:{(f >> 3) & 1} " + // Undocumented flag
$"P/V:{(f >> 2) & 1} " +
$"N:{(f >> 1) & 1} " +
$"C:{f & 1}";
}
private int ExecuteOpcode(byte opcode)