1 #ifdef SCPU_CPP
2 
op_io()3 void sCPU::op_io() {
4   status.clock_count = 6;
5   cycle_edge();
6   add_clocks(6);
7 }
8 
op_read(uint32 addr)9 uint8 sCPU::op_read(uint32 addr) {
10   status.clock_count = speed(addr);
11   cycle_edge();
12   add_clocks(status.clock_count - 4);
13   regs.mdr = bus.read(addr);
14   add_clocks(4);
15   return regs.mdr;
16 }
17 
op_write(uint32 addr,uint8 data)18 void sCPU::op_write(uint32 addr, uint8 data) {
19   status.clock_count = speed(addr);
20   cycle_edge();
21   add_clocks(status.clock_count);
22   bus.write(addr, regs.mdr = data);
23 }
24 
speed(unsigned addr) const25 unsigned sCPU::speed(unsigned addr) const {
26   if(addr & 0x408000) {
27     if(addr & 0x800000) return status.rom_speed;
28     return 8;
29   }
30   if((addr + 0x6000) & 0x4000) return 8;
31   if((addr - 0x4000) & 0x7e00) return 6;
32   return 12;
33 }
34 
35 #endif
36