|
|
| version 1.3, 2003/10/23 12:58:44 | version 1.6, 2004/02/07 21:23:21 |
|---|---|
| Line 5 | Line 5 |
| #include "timing.h" | #include "timing.h" |
| static UINT timercnt = 0; | typedef struct { |
| static UINT32 tick = 0; | UINT32 tick; |
| static UINT32 cnt = 0; | UINT cnt; |
| UINT32 fraction; | |
| } TIMING; | |
| static TIMING timing; | |
| void timing_reset(void) { | void timing_reset(void) { |
| cnt = 0; | timing.tick = GETTICK(); |
| timercnt = 0; | timing.cnt = 0; |
| tick = GETTICK(); | timing.fraction = 0; |
| } | } |
| void timing_setcount(UINT value) { | void timing_setcount(UINT value) { |
| timercnt = value; | timing.cnt = value; |
| } | } |
| UINT timing_getcount(void) { // ver0.12 60.0Hz вк 56.4Hz | UINT timing_getcount(void) { |
| UINT32 ticknow; | UINT32 ticknow; |
| UINT32 span; | UINT32 span; |
| UINT steps; | UINT steps; |
| ticknow = GETTICK(); | ticknow = GETTICK(); |
| span = ticknow - tick; | span = ticknow - timing.tick; |
| if (span) { | if (span) { |
| fddmtr_callback(ticknow); | fddmtr_callback(ticknow); |
| tick = ticknow; | timing.tick = ticknow; |
| if (span < 1000) { | if (span < 1000) { |
| cnt += (span * 388); | timing.fraction += (span * 388); |
| steps = cnt / 6875; | steps = timing.fraction / 6875; |
| timercnt += steps; | timing.cnt += steps; |
| cnt -= (steps * 6875); | timing.fraction -= (steps * 6875); |
| } | } |
| else { | else { |
| cnt = 0; | timing.fraction = 0; |
| timercnt += 56; | timing.cnt += 56; |
| } | } |
| } | } |
| return(timercnt); | return(timing.cnt); |
| } | } |
| void timing_term(void) { | void timing_term(void) { |