vgbc/system/dmg.cpp

33 lines
923 B
C++

#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;
}