--- np2/timing.c 2003/10/16 17:57:06 1.1 +++ np2/timing.c 2003/12/08 00:55:30 1.5 @@ -1,25 +1,29 @@ #include "compiler.h" #include "pccore.h" -#include "timing.h" #include "diskdrv.h" #include "fdd_mtr.h" +#include "timing.h" + +typedef struct { + UINT32 tick; + UINT cnt; + UINT32 fraction; +} TIMING; -static UINT timercnt = 0; -static UINT32 tick = 0; -static UINT32 cnt = 0; +static TIMING timing; -void timing_init(void) { +void timing_reset(void) { - cnt = 0; - timercnt = 0; - tick = GETTICK(); + timing.tick = GETTICK(); + timing.cnt = 0; + timing.fraction = 0; } void timing_setcount(UINT value) { - timercnt = value; + timing.cnt = value; } UINT timing_getcount(void) { // ver0.12 60.0Hz вк 56.4Hz @@ -29,23 +33,23 @@ UINT timing_getcount(void) { // ver0.1 UINT steps; ticknow = GETTICK(); - span = ticknow - tick; + span = ticknow - timing.tick; if (span) { fddmtr_callback(ticknow); - tick = ticknow; + timing.tick = ticknow; if (span < 1000) { - cnt += (span * 388); - steps = cnt / 6875; - timercnt += steps; - cnt -= (steps * 6875); + timing.fraction += (span * 388); + steps = timing.fraction / 6875; + timing.cnt += steps; + timing.fraction -= (steps * 6875); } else { - cnt = 0; - timercnt += 56; + timing.fraction = 0; + timing.cnt += 56; } } - return(timercnt); + return(timing.cnt); } void timing_term(void) {