OXYGENHUB
◆ main enhanced-x16-emulator / src / timing.h
1.5 KiB · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
1
#ifndef TIMING_H
2
#define TIMING_H
3
4
#include <stdint.h>
5
6
#ifdef __cplusplus
7
extern "C" {
8
#endif
9
10
void timing_init();
11
void timing_update();
12
void timing_update_no_sleep();
13
int64_t timing_lead_us();
14
15
// Emulation speed, as an absolute target clock in kHz rather than a percentage.
16
//
17
// The machine's clock is whatever -mhz selected (default 8, range 1..40), so a
18
// percentage on its own says nothing without knowing what it is a percentage
19
// of: "50%" is a different absolute speed on a machine started with -mhz 1 than
20
// on one started with -mhz 12. kHz is unambiguous, and does not lose precision
21
// at the very low speeds that are useful for watching a routine execute.
22
//
23
// Warp mode bypasses throttling entirely and ignores all of this.
24
#define TIMING_SPEED_MIN_KHZ 25      // 0.025 MHz - slow enough to follow by eye
25
#define TIMING_SPEED_MAX_KHZ 100000  // 100 MHz - well past any real hardware
26
27
int  timing_native_khz(void);        // the machine's own clock, from -mhz
28
int  timing_get_speed_khz(void);
29
void timing_set_speed_khz(int khz);  // clamped to the range above
30
void timing_reset_speed(void);       // back to the machine's own clock
31
32
// Step to the next/previous preset clock (direction > 0 faster, < 0 slower).
33
// The presets are anchored on speeds real hardware runs at, and always include
34
// the machine's own, so normal speed is reachable however it was started.
35
void timing_step_speed(int direction);
36
37
// The target as a percentage of the machine's clock, for display.
38
int  timing_get_speed_percent(void);
39
40
#ifdef __cplusplus
41
}
42
#endif
43
44
#endif