/* This is the emulation timing stuff * Should be called at the END of the emulation loop. * Input parameter: microseconds needed for the "real" (emulated) computer to do our loop * This function also does the sleep itself */ static void emu_timekeeping_delay ( int td_em ) { int td, td_pc = get_elapsed_time(et_start, &et_end, NULL); // the time was needed for our emulation loop if (td_pc < 0) { DEBUG("TIMING: negative amount of time spent for an emulation loop?!" NL); td = 0; } else td = td_em - td_pc; // the time difference (+X = PC is faster - real time EP emulation, -X = EP is faster - real time EP emulation is not possible) DEBUG("DELAY: pc=%d em=%d sleep=%d" NL, td_pc, td_em, td); /* for reporting only: BEGIN */ td_em_ALL += td_em; td_pc_ALL += td_pc; if (td_count_ALL == 50) { char buf[256]; //DEBUG("STAT: count = %d, EM = %d, PC = %d, usage = %f%" NL, td_count_ALL, td_em_ALL, td_pc_ALL, 100.0 * (double)td_pc_ALL / (double)td_em_ALL); snprintf(buf, sizeof buf, "%s [%.2fMHz ~ %d%%]%s", WINDOW_TITLE " v" VERSION " ", CPU_CLOCK / 1000000.0, td_em_ALL ? (td_pc_ALL * 100 / td_em_ALL) : -1, paused ? " PAUSED" : "" ); SDL_SetWindowTitle(sdl_win, buf); td_count_ALL = 0; td_pc_ALL = 0; td_em_ALL = 0; } else td_count_ALL++; /* for reporting only: END */ td_balancer += td; /* insane time-diff balancer values ... */ if (td_balancer > 1000000 || td_balancer < -1000000) td_balancer = 0; DEBUG("Balancer = %d" NL, td_balancer); // Should be the last, as with Emscripten, it's not a real sleep, but the settimeout JS stuff ... emu_sleep(td_balancer); }
void enterVariableLink(void) { /* Wait for the GUI to finish whatever it needs to do */ do { emu_sleep(); } while(emu_is_sending || emu_is_recieving); }