match cpu registers on reset to hardware, cleanup

This commit is contained in:
scawful
2024-04-25 00:50:39 -04:00
parent b4f2fdc57e
commit d76525201f
6 changed files with 18 additions and 79 deletions

View File

@@ -21,8 +21,8 @@ void Cpu::Reset(bool hard) {
PB = 0;
D = 0;
DB = 0;
E = 0;
status = 0;
E = 1;
status = 0x34;
irq_wanted_ = false;
}
@@ -34,24 +34,6 @@ void Cpu::Reset(bool hard) {
int_delay_ = false;
}
void Cpu::Update(UpdateMode mode, int stepCount) {
int cycles = (mode == UpdateMode::Run) ? clock.GetCycleCount() : stepCount;
// Execute the calculated number of cycles
for (int i = 0; i < cycles; i++) {
if (IsBreakpoint(PC)) {
break;
}
// Fetch and execute an instruction
ExecuteInstruction(ReadByte((PB << 16) + PC));
if (mode == UpdateMode::Step) {
break;
}
}
}
void Cpu::RunOpcode() {
if (reset_wanted_) {
reset_wanted_ = false;

View File

@@ -36,18 +36,12 @@ class InstructionEntry {
std::string instruction; // Human-readable instruction text
};
const int kCpuClockSpeed = 21477272; // 21.477272 MHz
class Cpu : public Loggable, public core::ExperimentFlags {
public:
explicit Cpu(memory::Memory& mem, Clock& vclock,
memory::CpuCallbacks& callbacks)
: memory(mem), clock(vclock), callbacks_(callbacks) {}
enum class UpdateMode { Run, Step, Pause };
void Init(bool verbose = false) { clock.SetFrequency(kCpuClockSpeed); }
void Reset(bool hard = false);
void Update(UpdateMode mode = UpdateMode::Run, int stepCount = 1);
void RunOpcode();