2016-06-05 22:10:01 +00:00
|
|
|
auto CPU::io() -> void {
|
2016-06-28 10:43:47 +00:00
|
|
|
cycleEdge();
|
|
|
|
step(4);
|
2010-12-28 06:03:02 +00:00
|
|
|
}
|
|
|
|
|
2016-06-05 22:10:01 +00:00
|
|
|
auto CPU::read(uint16 addr) -> uint8 {
|
2016-06-28 10:43:47 +00:00
|
|
|
cycleEdge();
|
|
|
|
step(4);
|
2013-12-14 06:25:12 +00:00
|
|
|
return bus.read(addr);
|
2010-12-28 06:03:02 +00:00
|
|
|
}
|
|
|
|
|
2016-06-05 22:10:01 +00:00
|
|
|
auto CPU::write(uint16 addr, uint8 data) -> void {
|
2016-06-28 10:43:47 +00:00
|
|
|
cycleEdge();
|
|
|
|
step(4);
|
2013-12-20 11:40:39 +00:00
|
|
|
bus.write(addr, data);
|
2010-12-28 06:03:02 +00:00
|
|
|
}
|
|
|
|
|
2016-06-28 10:43:47 +00:00
|
|
|
auto CPU::cycleEdge() -> void {
|
2012-04-26 10:51:13 +00:00
|
|
|
if(r.ei) {
|
|
|
|
r.ei = false;
|
|
|
|
r.ime = 1;
|
2011-08-13 03:51:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-10 12:12:54 +00:00
|
|
|
//VRAM DMA source can only be ROM or RAM
|
2016-06-28 10:43:47 +00:00
|
|
|
auto CPU::readDMA(uint16 addr) -> uint8 {
|
2013-12-10 12:12:54 +00:00
|
|
|
if(addr < 0x8000) return bus.read(addr); //0000-7fff
|
2016-01-08 09:23:46 +00:00
|
|
|
if(addr < 0xa000) return 0xff; //8000-9fff
|
2013-12-10 12:12:54 +00:00
|
|
|
if(addr < 0xe000) return bus.read(addr); //a000-dfff
|
2016-01-08 09:23:46 +00:00
|
|
|
return 0xff; //e000-ffff
|
2013-12-10 12:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//VRAM DMA target is always VRAM
|
2016-06-28 10:43:47 +00:00
|
|
|
auto CPU::writeDMA(uint16 addr, uint8 data) -> void {
|
2013-12-10 12:12:54 +00:00
|
|
|
addr = 0x8000 | (addr & 0x1fff); //8000-9fff
|
|
|
|
return bus.write(addr, data);
|
|
|
|
}
|
|
|
|
|
2016-06-28 10:43:47 +00:00
|
|
|
auto CPU::readDebugger(uint16 addr) -> uint8 {
|
2012-04-26 10:51:13 +00:00
|
|
|
return bus.read(addr);
|
|
|
|
}
|