Code: Select all
1,000,000,000,000,000,000 => the number of attoseconds in one second
18,446,744,073,709,551,615 => 2^64-1
If you're going to use 128-bit counters, then why not up your accuracy to Planck time? :P
...
For what it's worth, I am using this currently:
Code: Select all
auto create(... long double frequency) {
/*uint64*/ scalar = 1.0 / frequency * 1'000'000'000'000'000'000.0 + 0.5; //round to attoseconds
}
auto step(uint clocks) {
clock += clocks * scalar;
}
auto synchronize(Thread& thread) {
if(clock > thread.clock) co_switch(thread.handle);
}
Code: Select all
[FC]
Mega Man 2 = 169fps (stage select) -> 186fps
Zelda = 172fps (in-game) -> 193fps
[SFC]
Zelda 3 = 131fps (save select) -> 140fps
Kirby 3 = 99fps (stage select) -> 106fps
[GB]
Mega Man II = 228fps (stage select) -> 246fps
Zelda DX = 211fps (save select) -> 214fps
[GBA]
Riviera = 180fps (opening) -> 180fps
Minish Cap = 154fps (save select) -> 154fps
[WSC]
Riviera = 177fps (title screen) -> 198fps
Final Fantasy = 158fps (name select) -> 163fps