Emulator: Set registers for the power-up sequence

This commit is contained in:
Riyyi
2022-08-19 21:09:22 +02:00
parent 52cd604eb1
commit dcc517c28d
3 changed files with 16 additions and 5 deletions
+15 -3
View File
@@ -14,6 +14,21 @@
CPU::CPU(uint32_t 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("bc", &m_bc);
m_shared_registers.emplace("de", &m_de);
@@ -37,9 +52,6 @@ void CPU::update()
// Read next opcode
}
m_a = 6;
m_bc = 732;
// print("This is an update from the CPU\n");
}
+1 -1
View File
@@ -42,8 +42,8 @@ private:
uint32_t m_bc { 0 }; // BC
uint32_t m_de { 0 }; // DE
uint32_t m_hl { 0 }; // HL
uint32_t m_sp { 0 }; // Stack Pointer
uint32_t m_pc { 0 }; // Program Counter
uint32_t m_sp { 0 }; // Stack Pointer
// Flags
uint32_t m_z { 0 }; // Zero flag
-1
View File
@@ -29,7 +29,6 @@ int main(int argc, char* argv[])
Emu::the().addMemorySpace("CARDROM", 1024);
// Get shared register
Emu::the().processingUnit("cpu")->update();
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("a"));
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("bc"));