File:
[RetroPC.NET] /
np2 /
timing.c
Revision
1.8:
download - view:
text,
annotated -
select for diffs
Thu Feb 19 06:58:41 2004 JST (21 years, 8 months ago) by
yui
Branches:
MAIN
CVS tags:
VER_0_82_x64,
VER_0_82,
VER_0_81A,
VER_0_81,
VER_0_80,
VER_0_79,
VER_0_78,
VER_0_77,
VER_0_76,
VER_0_75,
HEAD
fix fdd motor (T.Yui)
#include "compiler.h"
#include "pccore.h"
#include "diskdrv.h"
#include "fdd_mtr.h"
#include "timing.h"
#define MSSHIFT 16
typedef struct {
UINT32 tick;
UINT32 msstep;
UINT cnt;
UINT32 fraction;
} TIMING;
static TIMING timing;
void timing_reset(void) {
timing.tick = GETTICK();
timing.cnt = 0;
timing.fraction = 0;
}
void timing_setrate(UINT lines, UINT crthz) {
timing.msstep = (crthz << (MSSHIFT - 3)) / lines / (1000 >> 3);
}
void timing_setcount(UINT value) {
timing.cnt = value;
}
UINT timing_getcount(void) {
UINT32 ticknow;
UINT32 span;
UINT32 fraction;
ticknow = GETTICK();
span = ticknow - timing.tick;
if (span) {
timing.tick = ticknow;
fddmtr_callback(ticknow);
if (span >= 1000) {
span = 1000;
}
fraction = timing.fraction + (span * timing.msstep);
timing.cnt += fraction >> MSSHIFT;
timing.fraction = fraction & ((1 << MSSHIFT) - 1);
}
return(timing.cnt);
}
RetroPC.NET-CVS <cvs@retropc.net>