2010-12-28 06:03:02 +00:00
|
|
|
#ifdef CPU_CPP
|
|
|
|
|
|
|
|
void CPU::op_io() {
|
2011-08-13 03:51:29 +00:00
|
|
|
cycle_edge();
|
2011-10-28 09:51:43 +00:00
|
|
|
add_clocks(4);
|
2010-12-28 06:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 CPU::op_read(uint16 addr) {
|
2011-08-13 03:51:29 +00:00
|
|
|
cycle_edge();
|
2011-10-28 09:51:43 +00:00
|
|
|
add_clocks(4);
|
2013-12-20 11:40:39 +00:00
|
|
|
if(oamdma.active && (addr < 0xff80 || addr == 0xffff)) return 0x00;
|
2013-12-14 06:25:12 +00:00
|
|
|
return bus.read(addr);
|
2010-12-28 06:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPU::op_write(uint16 addr, uint8 data) {
|
2011-08-13 03:51:29 +00:00
|
|
|
cycle_edge();
|
2011-10-28 09:51:43 +00:00
|
|
|
add_clocks(4);
|
2013-12-20 11:40:39 +00:00
|
|
|
if(oamdma.active && (addr < 0xff80 || addr == 0xffff)) return;
|
|
|
|
bus.write(addr, data);
|
2010-12-28 06:03:02 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 03:51:29 +00:00
|
|
|
void CPU::cycle_edge() {
|
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
|
|
|
|
uint8 CPU::dma_read(uint16 addr) {
|
|
|
|
if(addr < 0x8000) return bus.read(addr); //0000-7fff
|
|
|
|
if(addr < 0xa000) return 0x00; //8000-9fff
|
|
|
|
if(addr < 0xe000) return bus.read(addr); //a000-dfff
|
|
|
|
return 0x00; //e000-ffff
|
|
|
|
}
|
|
|
|
|
|
|
|
//VRAM DMA target is always VRAM
|
|
|
|
void CPU::dma_write(uint16 addr, uint8 data) {
|
|
|
|
addr = 0x8000 | (addr & 0x1fff); //8000-9fff
|
|
|
|
return bus.write(addr, data);
|
|
|
|
}
|
|
|
|
|
2012-04-26 10:51:13 +00:00
|
|
|
uint8 CPU::debugger_read(uint16 addr) {
|
|
|
|
return bus.read(addr);
|
|
|
|
}
|
|
|
|
|
2010-12-28 06:03:02 +00:00
|
|
|
#endif
|