system - Create a system class for the DMG
This commit is contained in:
parent
1716fe1e98
commit
8d40d491b1
2 changed files with 63 additions and 0 deletions
33
system/dmg.cpp
Normal file
33
system/dmg.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include <system/dmg.h>
|
||||||
|
|
||||||
|
System::System(Cartridge cart)
|
||||||
|
: cart(cart), mbc1(cart), wram1(0x1000), wram2(0x1000),
|
||||||
|
hram(0x100), oam(0x100), bus(), cpu(&bus),
|
||||||
|
ie_mapped(cpu.state.IE), if_mapped(cpu.state.IF)
|
||||||
|
{
|
||||||
|
bus.map_device(0x0000, 0x7FFF, &mbc1);
|
||||||
|
bus.map_device(0xA000, 0xBFFF, &mbc1, 0xA000);
|
||||||
|
bus.map_device(0xC000, 0xCFFF, &wram1);
|
||||||
|
bus.map_device(0xD000, 0xDFFF, &wram2);
|
||||||
|
bus.map_device(0xE000, 0xFDFF, &wram1);
|
||||||
|
bus.map_device(0xFE00, 0xFE9F, &oam);
|
||||||
|
bus.map_device(0xFF80, 0xFFFE, &hram);
|
||||||
|
bus.map_device(0xFFFF, 0xFFFF, &ie_mapped);
|
||||||
|
bus.map_device(0xFF0F, 0xFF0F, &if_mapped);
|
||||||
|
|
||||||
|
cpu.state.A = 0x1;
|
||||||
|
cpu.state.carry = true;
|
||||||
|
cpu.state.halfcarry = true;
|
||||||
|
cpu.state.subtract = false;
|
||||||
|
cpu.state.zero = true;
|
||||||
|
|
||||||
|
cpu.state.B = 0x00;
|
||||||
|
cpu.state.C = 0x13;
|
||||||
|
cpu.state.D = 0x00;
|
||||||
|
cpu.state.E = 0xD8;
|
||||||
|
cpu.state.H = 0x01;
|
||||||
|
cpu.state.L = 0x4D;
|
||||||
|
|
||||||
|
cpu.state.SP = 0xFFFE;
|
||||||
|
cpu.state.PC = 0x100;
|
||||||
|
}
|
30
system/dmg.h
Normal file
30
system/dmg.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cpu/cpu.h>
|
||||||
|
#include <cartridge/cartridge.h>
|
||||||
|
#include <cartridge/mbc/mbc1.h>
|
||||||
|
#include <memory/ram.h>
|
||||||
|
#include <memory/bus.h>
|
||||||
|
#include <memory/register.h>
|
||||||
|
|
||||||
|
class DMG
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
RAM wram1;
|
||||||
|
RAM wram2;
|
||||||
|
RAM hram;
|
||||||
|
RAM oam;
|
||||||
|
|
||||||
|
MBC1 mbc;
|
||||||
|
|
||||||
|
Bus bus;
|
||||||
|
Cpu cpu;
|
||||||
|
|
||||||
|
BoundRegister ie_mapped;
|
||||||
|
BoundRegister if_mapped;
|
||||||
|
|
||||||
|
public:
|
||||||
|
System(Cartridge cart);
|
||||||
|
|
||||||
|
void run();
|
||||||
|
};
|
Loading…
Reference in a new issue