Rewrote timer code.
The new code is based on timestamps, rather than delays. This eliminates the need to update every timer in timer_process(), which cost a non-trivial amount of CPU time on low-end machines. This involved changes to every user of the timer code, so this change almost certainly introduces bugs.
This commit is contained in:
parent
ab359ca9c5
commit
a7d006b637
79 changed files with 1050 additions and 1033 deletions
18
src/disc.c
18
src/disc.c
|
|
@ -9,7 +9,7 @@
|
|||
#include "timer.h"
|
||||
|
||||
int disc_drivesel = 0;
|
||||
int disc_poll_time = 16;
|
||||
pc_timer_t disc_poll_timer;
|
||||
|
||||
int disc_track[2];
|
||||
int writeprot[2], fwriteprot[2];
|
||||
|
|
@ -22,9 +22,6 @@ int curdrive = 0;
|
|||
//char discfns[2][260] = {"", ""};
|
||||
int defaultwriteprot = 0;
|
||||
|
||||
int fdc_time;
|
||||
int disc_time;
|
||||
|
||||
int fdc_ready;
|
||||
|
||||
int drive_empty[2] = {1, 1};
|
||||
|
|
@ -137,7 +134,7 @@ int disc_hole(int drive)
|
|||
|
||||
void disc_poll()
|
||||
{
|
||||
disc_poll_time += disc_period * TIMER_USEC;
|
||||
timer_advance_u64(&disc_poll_timer, disc_period * TIMER_USEC);
|
||||
|
||||
if (disc_drivesel < 2 && drives[disc_drivesel].poll)
|
||||
drives[disc_drivesel].poll();
|
||||
|
|
@ -209,7 +206,7 @@ void disc_reset()
|
|||
|
||||
curdrive = 0;
|
||||
disc_period = 32;
|
||||
timer_add(disc_poll, &disc_poll_time, &motoron, NULL);
|
||||
timer_add(&disc_poll_timer, disc_poll, NULL, 0);
|
||||
|
||||
for (drive = 0; drive < 2; drive++)
|
||||
{
|
||||
|
|
@ -295,3 +292,12 @@ void disc_set_drivesel(int drive)
|
|||
|
||||
disc_drivesel = drive;
|
||||
}
|
||||
|
||||
void disc_set_motor_enable(int motor_enable)
|
||||
{
|
||||
if (motor_enable && !motoron)
|
||||
timer_set_delay_u64(&disc_poll_timer, disc_period * TIMER_USEC);
|
||||
else if (!motor_enable)
|
||||
timer_disable(&disc_poll_timer);
|
||||
motoron = motor_enable;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue