From ecca099d81f0617aa88f06fa5f2cb8995f9f1ea0 Mon Sep 17 00:00:00 2001 From: PalindromicBreadLoaf Date: Mon, 28 Jul 2025 12:16:50 -0400 Subject: [PATCH] Minor innacuracy updates --- src/cpu.cpp | 20 ++++++++++---------- src/cpu.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cpu.cpp b/src/cpu.cpp index 3955115..9348f20 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -8,12 +8,11 @@ // CPU Implementation void CPU::Reset() { - A = X = Y = 0; - SP = 0x01FF; - PC = 0x8000; // Will be loaded from reset vector + A = D = X = Y = 0; + SP = 0x01FF; // Start of page 1 + PC = ReadWord(0x00FFFC); P = 0x34; // Start in emulation mode DB = PB = 0; - D = 0; cycles = 0; } @@ -5112,15 +5111,16 @@ void CPU::XBA() { } void CPU::XCE() { - const bool old_carry = (P & FLAG_C) != 0; - const bool old_emulation = emulation_mode; + + if (emulation_mode) P |= FLAG_C; + else P &= ~FLAG_C; emulation_mode = old_carry; - if (old_emulation) { - P |= FLAG_C; + if (emulation_mode) { + // Force 8-bit modes, constrain stack to page 1 + P |= (FLAG_M | FLAG_X); + SP = (SP & 0x00FF) | 0x0100; } - - cycles += 2; } \ No newline at end of file diff --git a/src/cpu.h b/src/cpu.h index 24523bc..c0d2a1d 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -20,7 +20,7 @@ class CPU { Bus* bus; uint64_t cycles; - bool emulation_mode = false; + bool emulation_mode = true; bool stopped = false; bool waiting_for_interrupt = false;