* Initialize the timer. */
| 228 | * Initialize the timer. |
| 229 | */ |
| 230 | void Timer_Init(void) |
| 231 | { |
| 232 | s_timerLastTime = Timer_GetTime(); |
| 233 | |
| 234 | #if defined(_WIN32) |
| 235 | s_timerTime = s_timerSpeed / 1000; |
| 236 | DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &s_timerMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 237 | #elif defined(TOS) |
| 238 | (void)Cconws("Timer_Init()\r\n"); |
| 239 | /* see http://toshyp.atari.org/en/004009.html#Xbtimer */ |
| 240 | /* s_timerSpeed * 614400 / 10000 */ |
| 241 | #if 0 |
| 242 | Xbtimer(0/* Timer A */, 1/* divider = 4 */, s_timerSpeed * 6144 / 10000, Timer_Handler); |
| 243 | #endif |
| 244 | #elif defined(DOS) |
| 245 | /* */ |
| 246 | #else |
| 247 | s_timerTime.it_value.tv_sec = 0; |
| 248 | s_timerTime.it_value.tv_usec = s_timerSpeed; |
| 249 | s_timerTime.it_interval.tv_sec = 0; |
| 250 | s_timerTime.it_interval.tv_usec = s_timerSpeed; |
| 251 | |
| 252 | { |
| 253 | struct sigaction timerSignal; |
| 254 | |
| 255 | sigemptyset(&timerSignal.sa_mask); |
| 256 | timerSignal.sa_handler = Timer_Handler; |
| 257 | timerSignal.sa_flags = 0; |
| 258 | sigaction(SIGALRM, &timerSignal, NULL); |
| 259 | } |
| 260 | #endif /* _WIN32 */ |
| 261 | #if !defined(TOS) && !defined(DOS) |
| 262 | Timer_InterruptResume(); |
| 263 | #endif /* !defined(TOS) && !defined(DOS) */ |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Uninitialize the timer. |
no test coverage detected