|
|
| version 1.5, 2003/12/08 00:55:30 | version 1.7, 2004/02/09 20:39:39 |
|---|---|
| Line 5 | Line 5 |
| #include "timing.h" | #include "timing.h" |
| #define MSSHIFT 16 | |
| typedef struct { | typedef struct { |
| UINT32 tick; | UINT32 tick; |
| UINT32 msstep; | |
| UINT cnt; | UINT cnt; |
| UINT32 fraction; | UINT32 fraction; |
| } TIMING; | } TIMING; |
| Line 21 void timing_reset(void) { | Line 24 void timing_reset(void) { |
| timing.fraction = 0; | timing.fraction = 0; |
| } | } |
| void timing_setrate(UINT lines, UINT crthz) { | |
| timing.msstep = (crthz << (MSSHIFT - 3)) / lines / (1000 >> 3); | |
| } | |
| void timing_setcount(UINT value) { | void timing_setcount(UINT value) { |
| timing.cnt = 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; | UINT32 fraction; |
| ticknow = GETTICK(); | ticknow = GETTICK(); |
| span = ticknow - timing.tick; | span = ticknow - timing.tick; |
| if (span) { | if (span) { |
| timing.tick = ticknow; | |
| fddmtr_callback(ticknow); | fddmtr_callback(ticknow); |
| timing.tick = ticknow; | if (span >= 1000) { |
| if (span < 1000) { | span = 1000; |
| timing.fraction += (span * 388); | |
| steps = timing.fraction / 6875; | |
| timing.cnt += steps; | |
| timing.fraction -= (steps * 6875); | |
| } | |
| else { | |
| timing.fraction = 0; | |
| timing.cnt += 56; | |
| } | } |
| fraction = timing.fraction + (span * timing.msstep); | |
| timing.cnt += fraction >> MSSHIFT; | |
| timing.fraction = fraction & ((1 << MSSHIFT) - 1); | |
| } | } |
| return(timing.cnt); | return(timing.cnt); |
| } | } |