Browse Source

Emulator: Set registers for the power-up sequence

master
Riyyi 2 years ago
parent
commit
dcc517c28d
  1. 18
      src/cpu.cpp
  2. 2
      src/cpu.h
  3. 1
      src/main.cpp

18
src/cpu.cpp

@ -14,6 +14,21 @@
CPU::CPU(uint32_t frequency) CPU::CPU(uint32_t frequency)
: ProcessingUnit(frequency) : ProcessingUnit(frequency)
{ {
// CGB registers
// https://gbdev.io/pandocs/Power_Up_Sequence.html#cpu-registers
m_a = 0x11;
m_bc = 0x0; // B = 0x0, C = 0x0
m_de = 0xff56; // D = 0xff, E = 0x56
m_hl = 0x000d; // H = 0x0, L = 0x0d
m_pc = 0x100;
m_sp = 0xffe;
// Flags
m_z = 0x1;
m_n = 0x0;
m_h = 0x0;
m_c = 0x0;
m_shared_registers.emplace("a", &m_a); m_shared_registers.emplace("a", &m_a);
m_shared_registers.emplace("bc", &m_bc); m_shared_registers.emplace("bc", &m_bc);
m_shared_registers.emplace("de", &m_de); m_shared_registers.emplace("de", &m_de);
@ -37,9 +52,6 @@ void CPU::update()
// Read next opcode // Read next opcode
} }
m_a = 6;
m_bc = 732;
// print("This is an update from the CPU\n"); // print("This is an update from the CPU\n");
} }

2
src/cpu.h

@ -42,8 +42,8 @@ private:
uint32_t m_bc { 0 }; // BC uint32_t m_bc { 0 }; // BC
uint32_t m_de { 0 }; // DE uint32_t m_de { 0 }; // DE
uint32_t m_hl { 0 }; // HL uint32_t m_hl { 0 }; // HL
uint32_t m_sp { 0 }; // Stack Pointer
uint32_t m_pc { 0 }; // Program Counter uint32_t m_pc { 0 }; // Program Counter
uint32_t m_sp { 0 }; // Stack Pointer
// Flags // Flags
uint32_t m_z { 0 }; // Zero flag uint32_t m_z { 0 }; // Zero flag

1
src/main.cpp

@ -29,7 +29,6 @@ int main(int argc, char* argv[])
Emu::the().addMemorySpace("CARDROM", 1024); Emu::the().addMemorySpace("CARDROM", 1024);
// Get shared register // Get shared register
Emu::the().processingUnit("cpu")->update();
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("a")); print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("a"));
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("bc")); print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("bc"));

Loading…
Cancel
Save