static READ8_HANDLER( tp84_sh_timer_r ) { /* main xtal 14.318MHz, divided by 4 to get the CPU clock, further */ /* divided by 2048 to get this timer */ /* (divide by (2048/2), and not 1024, because the CPU cycle counter is */ /* incremented every other state change of the clock) */ return (cpu_get_total_cycles(space->cpu) / (2048/2)) & 0x0f; }
static READ8_HANDLER( cop01_sound_command_r ) { int res; static int pulse; #define TIMER_RATE 12000 /* total guess */ res = (soundlatch_r(space,offset) & 0x7f) << 1; /* bit 0 seems to be a timer */ if ((cpu_get_total_cycles(space->cpu) / TIMER_RATE) & 1) { if (pulse == 0) res |= 1; pulse = 1; } else pulse = 0; return res; }
static WRITE32_HANDLER( speedup_w ) { COMBINE_DATA(speedup_data); /* see if the PC matches */ if ((cpu_get_previouspc(space->cpu) & 0x1fffffff) == speedup_pc) { UINT64 curr_cycles = cpu_get_total_cycles(space->cpu); /* if less than 50 cycles from the last time, count it */ if (curr_cycles - last_cycles < 50) { loop_count++; /* more than 2 in a row and we spin */ if (loop_count > 2) cpu_spinuntil_int(space->cpu); } else loop_count = 0; last_cycles = curr_cycles; } }
static READ8_HANDLER( mikie_sh_timer_r ) { int clock = cpu_get_total_cycles(space->cpu) / MIKIE_TIMER_RATE; return clock; }