mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2024-07-15 01:29:08 +00:00
a9a03d946a
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
namespace Fuse
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using EightBit;
|
|
|
|
public class RegisterState
|
|
{
|
|
public enum Register
|
|
{
|
|
AF, BC, DE, HL, SP, PC
|
|
};
|
|
|
|
public List<Register16> Registers { get; } = new List<Register16>();
|
|
public bool Halted { get; private set; } = false;
|
|
public int TStates { get; private set; } = -1;
|
|
|
|
public void Parse(Lines lines)
|
|
{
|
|
this.ParseExternalState(lines);
|
|
this.ParseInternalState(lines);
|
|
}
|
|
|
|
private void ParseInternalState(Lines lines) => this.ParseInternalState(lines.ReadLine());
|
|
|
|
private void ParseInternalState(string line)
|
|
{
|
|
var tokens = line.Split(new char[] { ' ', '\t' });
|
|
this.ParseInternalState(tokens);
|
|
}
|
|
|
|
private void ParseInternalState(string[] tokens)
|
|
{
|
|
this.Halted = Convert.ToInt32(tokens[0]) == 1;
|
|
this.TStates = Convert.ToInt32(tokens[1]);
|
|
}
|
|
|
|
private void ParseExternalState(Lines lines)
|
|
{
|
|
var line = lines.ReadLine();
|
|
foreach (var token in line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries))
|
|
{
|
|
this.Registers.Add(new Register16(Convert.ToUInt16(token, 16)));
|
|
}
|
|
}
|
|
}
|
|
}
|