uint32 sms_z80_run(uint32 cycles) { return CrabZ80_execute(cpuz80, cycles); }
uint32 sms_z80_run(uint32 cycles) { uint32 cyclesdone = 0; uint32 opcode; uint16 pc; int tmp; static char last_str[256]; char str[256]; static uint16 last_pc = 0; uint32 c1, c2; while(cyclesdone < cycles) { debug_crab_ents = debug_mz80_ents = 0; debug_port_reads1 = debug_port_reads2 = 0; debug_mem_reads1 = debug_mem_reads2 = 0; debug_crab_ports = debug_mz80_ports = 0; pc = cpuz80->pc.w; opcode = mread8(cpuz80->pc.w); if(opcode == 0xED || opcode == 0xCB || opcode == 0xDD || opcode == 0xFD) { opcode |= (mread8(cpuz80->pc.w + 1) << 8); } if((opcode & 0xFF00) == 0xCB00) { opcode |= (mread8(cpuz80->pc.w + 2) << 16) | (mread8(cpuz80->pc.w + 3) << 24); } c1 = CrabZ80_execute(cpuz80, 1); c2 = z80_execute(1); cyclesdone += c1; tmp = _compare_registers() + _compare_memory() + _compare_ports(); CrabZ80_disassemble(str, cpuz80, pc); if(tmp) { printf("Cycles done: %d %d\n", (int)c1, (int)c2); printf("%d errors at: PC = 0x%04X, old_pc = 0x%04X Opcode = 0x%02X", tmp, pc, last_pc, opcode & 0xFF); switch(opcode & 0xFF) { case 0xED: case 0xCB: printf("%02X (%s -- %s)\n", (opcode & 0xFF00) >> 8, str, last_str); break; case 0xDD: case 0xFD: if((opcode & 0xFF00) == 0xCB00) printf("%02X%02X%02X (%s -- %s)\n", (opcode & 0xFF00) >> 8, (opcode & 0xFF0000) >> 16, (opcode & 0xFF000000) >> 24, str, last_str); else printf("%02X (%s -- %s)\n", (opcode & 0xFF00) >> 8, str, last_str); break; default: printf("(%s -- %s)\n", str, last_str); } } strcpy(last_str, str); last_pc = pc; }