static INTERRUPT_GEN( gcpinbal_interrupt ) { /* Unsure of actual sequence */ timer_set(TIME_IN_CYCLES(500,0),0, gcpinbal_interrupt1); timer_set(TIME_IN_CYCLES(1000,0),0, gcpinbal_interrupt3); cpunum_set_input_line(0, 4, HOLD_LINE); }
static void coco_fdc_callback(int event) { switch(event) { case WD179X_IRQ_CLR: intrq_state = CLEAR_LINE; cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE); break; case WD179X_IRQ_SET: intrq_state = ASSERT_LINE; CLEAR_COCO_HALTENABLE; coco_set_halt_line(CLEAR_LINE); if( COCO_NMIENABLE ) timer_set( TIME_IN_USEC(0), 0, raise_nmi); else cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE); break; case WD179X_DRQ_CLR: drq_state = CLEAR_LINE; if( COCO_HALTENABLE ) timer_set( TIME_IN_CYCLES(7,0), 0, raise_halt); else coco_set_halt_line(CLEAR_LINE); break; case WD179X_DRQ_SET: drq_state = ASSERT_LINE; coco_set_halt_line(CLEAR_LINE); break; } }
static void set_coco_dskreg(int data) { UINT8 drive = 0; UINT8 head = 0; int motor_mask = 0; LOG(("set_coco_dskreg(): %c%c%c%c%c%c%c%c ($%02x)\n", data & 0x80 ? 'H' : 'h', data & 0x40 ? '3' : '.', data & 0x20 ? 'D' : 'S', data & 0x10 ? 'P' : 'p', data & 0x08 ? 'M' : 'm', data & 0x04 ? '2' : '.', data & 0x02 ? '1' : '.', data & 0x01 ? '0' : '.', data )); /* An email from John Kowalski informed me that if the DS3 is * high, and one of the other drive bits is selected (DS0-DS2), then the * second side of DS0, DS1, or DS2 is selected. If multiple bits are * selected in other situations, then both drives are selected, and any * read signals get yucky. */ motor_mask = 0x08; if (data & 0x04) drive = 2; else if (data & 0x02) drive = 1; else if (data & 0x01) drive = 0; else if (data & 0x40) drive = 3; else motor_mask = 0; head = ((data & 0x40) && (drive != 3)) ? 1 : 0; dskreg = data; if( COCO_HALTENABLE && (drq_state == CLEAR_LINE) ) timer_set( TIME_IN_CYCLES(7,0), 0, raise_halt); else coco_set_halt_line(CLEAR_LINE); if( COCO_NMIENABLE && (intrq_state == ASSERT_LINE) ) { CLEAR_COCO_HALTENABLE; coco_set_halt_line(CLEAR_LINE); timer_set( TIME_IN_USEC(0), 0, raise_nmi); } else cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE); wd179x_set_drive(drive); wd179x_set_side(head); wd179x_set_density( (dskreg & 0x20) ? DEN_MFM_LO : DEN_FM_LO ); }
static READ32_HANDLER( kinst_speedup_r ) { if (activecpu_get_pc() == 0x88029890 || /* KI */ activecpu_get_pc() == 0x8802c2d0 /* KI2 */) { UINT32 r3 = activecpu_get_reg(MIPS3_R3); UINT32 r26 = activecpu_get_reg(MIPS3_R26) - *kinst_speedup; if (r26 < r3) { timer_set(TIME_IN_CYCLES((r3 - r26) * 2, 0), 0, end_spin); cpu_spinuntil_int(); } } return *kinst_speedup; }
double cpunum_get_localtime(int cpunum) { double result; VERIFY_CPUNUM(0, cpunum_get_localtime); /* if we're active, add in the time from the current slice */ result = cpu[cpunum].localtime; if (cpunum == cpu_getexecutingcpu()) { int cycles = cycles_currently_ran(); result += TIME_IN_CYCLES(cycles, cpunum); } return result; }
static WRITE8_HANDLER(svision_w) { int value; int delay; svision_reg[offset] = data; switch (offset) { case 2: case 3: break; case 0x26: /* bits 5,6 memory management for a000? */ logerror("%.6f svision write %04x %02x\n",timer_get_time(),offset,data); memory_set_bankptr(1, memory_region(REGION_USER1) + ((svision_reg[0x26] & 0xe0) << 9)); svision_irq(); break; case 0x23: /* delta hero irq routine write */ value = data; if (!data) value = 0x100; if (BANK & 0x10) delay = 16384; else delay = 256; timer_enable(svision.timer1, TRUE); timer_reset(svision.timer1, TIME_IN_CYCLES(value * delay, 0)); break; case 0x10: case 0x11: case 0x12: case 0x13: svision_soundport_w(svision_channel + 0, offset & 3, data); break; case 0x14: case 0x15: case 0x16: case 0x17: svision_soundport_w(svision_channel + 1, offset & 3, data); break; case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: svision_sounddma_w(offset - 0x18, data); break; case 0x28: case 0x29: case 0x2a: svision_noise_w(offset - 0x28, data); break; default: logerror("%.6f svision write %04x %02x\n", timer_get_time(), offset, data); break; } }
static READ8_HANDLER ( combasc_YM2203_status_port_0_r ) { static int boost = 1; int status = YM2203_status_port_0_r(0); if (activecpu_get_pc() == 0x334) { if (boost) { boost = 0; timer_adjust(combasc_interleave_timer, TIME_NOW, 0, TIME_IN_CYCLES(80,1)); } else if (status & 2) { boost = 1; timer_adjust(combasc_interleave_timer, TIME_NOW, 0, TIME_NEVER); } } return(status); }
static WRITE_HANDLER( thunderx_1f98_w ) { // logerror("%04x: 1f98_w %02x\n",activecpu_get_pc(),data); /* bit 0 = enable char ROM reading through the video RAM */ K052109_set_RMRD_line((data & 0x01) ? ASSERT_LINE : CLEAR_LINE); /* bit 1 = PMC-BK */ pmcbank = (data & 0x02) >> 1; /* bit 2 = do collision detection when 0->1 */ if ((data & 4) && !(unknown_enable & 4)) { calculate_collisions(); /* 100 cycle delay is arbitrary */ timer_set(TIME_IN_CYCLES(100,0),0, thunderx_firq_callback); } unknown_enable = data; }
static INTERRUPT_GEN( drill_interrupt ) { timer_set(TIME_IN_CYCLES(5000,0),0,drill_interrupt5); cpunum_set_input_line(0, 4, HOLD_LINE); }
static INTERRUPT_GEN( topspeed_cpub_interrupt ) { /* Unsure how many int6's per frame */ timer_set(TIME_IN_CYCLES(200000-500,0),0, topspeed_cpub_interrupt6); cpunum_set_input_line(2, 5, HOLD_LINE); }
static void cpu_timeslice(void) { double target = timer_time_until_next_timer(); int cpunum, ran; LOG(("------------------\n")); LOG(("cpu_timeslice: target = %.9f\n", target)); /* process any pending suspends */ for (cpunum = 0; Machine->drv->cpu[cpunum].cpu_type != CPU_DUMMY; cpunum++) { if (cpu[cpunum].suspend != cpu[cpunum].nextsuspend) LOG(("--> updated CPU%d suspend from %X to %X\n", cpunum, cpu[cpunum].suspend, cpu[cpunum].nextsuspend)); cpu[cpunum].suspend = cpu[cpunum].nextsuspend; cpu[cpunum].eatcycles = cpu[cpunum].nexteatcycles; } /* loop over CPUs */ for (cpunum = 0; Machine->drv->cpu[cpunum].cpu_type != CPU_DUMMY; cpunum++) { /* only process if we're not suspended */ if (!cpu[cpunum].suspend) { /* compute how long to run */ cycles_running = TIME_TO_CYCLES(cpunum, target - cpu[cpunum].localtime); LOG((" cpu %d: %d cycles\n", cpunum, cycles_running)); /* run for the requested number of cycles */ if (cycles_running > 0) { profiler_mark(PROFILER_CPU1 + cpunum); cycles_stolen = 0; ran = cpunum_execute(cpunum, cycles_running); ran -= cycles_stolen; profiler_mark(PROFILER_END); /* account for these cycles */ cpu[cpunum].totalcycles += ran; cpu[cpunum].localtime += TIME_IN_CYCLES(ran, cpunum); LOG((" %d ran, %d total, time = %.9f\n", ran, (INT32)cpu[cpunum].totalcycles, cpu[cpunum].localtime)); /* if the new local CPU time is less than our target, move the target up */ if (cpu[cpunum].localtime < target && cpu[cpunum].localtime > 0) { target = cpu[cpunum].localtime; LOG((" (new target)\n")); } } } } /* update the local times of all CPUs */ for (cpunum = 0; Machine->drv->cpu[cpunum].cpu_type != CPU_DUMMY; cpunum++) { /* if we're suspended and counting, process */ if (cpu[cpunum].suspend && cpu[cpunum].eatcycles && cpu[cpunum].localtime < target) { /* compute how long to run */ cycles_running = TIME_TO_CYCLES(cpunum, target - cpu[cpunum].localtime); LOG((" cpu %d: %d cycles (suspended)\n", cpunum, cycles_running)); cpu[cpunum].totalcycles += cycles_running; cpu[cpunum].localtime += TIME_IN_CYCLES(cycles_running, cpunum); LOG((" %d skipped, %d total, time = %.9f\n", cycles_running, (INT32)cpu[cpunum].totalcycles, cpu[cpunum].localtime)); } /* update the suspend state */ if (cpu[cpunum].suspend != cpu[cpunum].nextsuspend) LOG(("--> updated CPU%d suspend from %X to %X\n", cpunum, cpu[cpunum].suspend, cpu[cpunum].nextsuspend)); cpu[cpunum].suspend = cpu[cpunum].nextsuspend; cpu[cpunum].eatcycles = cpu[cpunum].nexteatcycles; /* adjust to be relative to the global time */ cpu[cpunum].localtime -= target; } /* update the global time */ timer_adjust_global_time(target); /* huh? something for the debugger */ #ifdef MAME_DEBUG { extern int debug_key_delay; debug_key_delay = 0x7ffe; } #endif }
static INTERRUPT_GEN(s11_irq) { s11_irqline(1); timer_set(TIME_IN_CYCLES(32,0),0,s11_irqline); }