Fixed a bug where SameBoy freezes for a while after leaving turbo mode
This commit is contained in:
parent
fd2e169dc9
commit
4cf78139a8
@ -61,8 +61,9 @@ void GB_timing_sync(GB_gameboy_t *gb)
|
||||
|
||||
uint64_t target_nanoseconds = gb->cycles_since_last_sync * 1000000000LL / 2 / GB_get_clock_rate(gb); /* / 2 because we use 8MHz units */
|
||||
int64_t nanoseconds = get_nanoseconds();
|
||||
if (labs((signed long)(nanoseconds - gb->last_sync)) < target_nanoseconds ) {
|
||||
nsleep(target_nanoseconds + gb->last_sync - nanoseconds);
|
||||
int64_t time_to_sleep = target_nanoseconds + gb->last_sync - nanoseconds;
|
||||
if (time_to_sleep > 0 && time_to_sleep < LCDC_PERIOD * 1000000000LL / GB_get_clock_rate(gb)) {
|
||||
nsleep(time_to_sleep);
|
||||
gb->last_sync += target_nanoseconds;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user