static void MPU401_EOIHandlerDispatch(void) { if (mpu.state.send_now) { mpu.state.eoi_scheduled=true; PIC_AddEvent(EOI_HANDLER,1); // Possible a bit longer } else if (!mpu.state.eoi_scheduled) MPU401_EOIHandler(); }
void MPU401_Event(void) { /* SOFTMPU */ Bit8u i; Bitu new_time; if (mpu.mode==M_UART) return; if (mpu.state.irq_pending) goto next_event; for (i=0;i<8;i++) { /* Decrease counters */ if (mpu.state.amask&(1<<i)) { mpu.playbuf[i].counter--; if (mpu.playbuf[i].counter<=0) UpdateTrack(i); } } if (mpu.state.conductor) { mpu.condbuf.counter--; if (mpu.condbuf.counter<=0) UpdateConductor(); } if (mpu.clock.clock_to_host) { mpu.clock.cth_counter++; if (mpu.clock.cth_counter >= mpu.clock.cth_rate) { mpu.clock.cth_counter=0; mpu.state.req_mask|=(1<<13); } } if (!mpu.state.irq_pending && mpu.state.req_mask) MPU401_EOIHandler(); next_event: PIC_RemoveEvents(MPU_EVENT); if ((new_time=mpu.clock.tempo*mpu.clock.timebase)==0) return; PIC_AddEvent(MPU_EVENT,(Bitu)MPU401_TIMECONSTANT/new_time); }
static void MPU401_EOIHandlerDispatch(void *p) { mpu_t *mpu = (mpu_t *)p; if (mpu->state.send_now) { mpu->state.eoi_scheduled=1; mpu401_eoi_callback = 60 * TIMER_USEC; /* Possible a bit longer */ } else if (!mpu->state.eoi_scheduled) MPU401_EOIHandler(mpu); }
static void MPU401_Event(void *p) { mpu_t *mpu = (mpu_t *)p; uint8_t i; int new_time; pclog("MPU-401 event callback\n"); if (mpu->mode==M_UART) { mpu401_event_callback = 0; return; } if (mpu->state.irq_pending) goto next_event; for (i=0;i<8;i++) { /* Decrease counters */ if (mpu->state.amask&(1<<i)) { mpu->playbuf[i].counter--; if (mpu->playbuf[i].counter<=0) UpdateTrack(mpu, i); } } if (mpu->state.conductor) { mpu->condbuf.counter--; if (mpu->condbuf.counter<=0) UpdateConductor(mpu); } if (mpu->clock.clock_to_host) { mpu->clock.cth_counter++; if (mpu->clock.cth_counter >= mpu->clock.cth_rate) { mpu->clock.cth_counter=0; mpu->state.req_mask|=(1<<13); } } if (!mpu->state.irq_pending && mpu->state.req_mask) MPU401_EOIHandler(mpu); next_event: /* mpu401_event_callback = 0; */ new_time = (mpu->clock.tempo * mpu->clock.timebase); if (new_time == 0) { mpu401_event_callback = 0; return; } else { mpu401_event_callback += (MPU401_TIMECONSTANT/new_time) * 1000 * TIMER_USEC; pclog("Next event after %i us (time constant: %i)\n", (int) ((MPU401_TIMECONSTANT/new_time) * 1000 * TIMER_USEC), (int) MPU401_TIMECONSTANT); } }