static void xmodem_next_packet() { int len; int i, sum = 0; xmodem_buf[0] = 0x01; xmodem_buf[1]++; // sequence number xmodem_buf[2] = ~xmodem_buf[1]; // sequence number complement len = fread(&xmodem_buf[3], 1, 0x80, xmodem_file); if (len == 0) { serial_byte_in(0x04); fclose(xmodem_file); xmodem_file = NULL; return; } memset(&xmodem_buf[3 + len], 0x1A, 0x80 - len); for (i = 3; i < 0x83; i++) sum += xmodem_buf[i]; xmodem_buf[0x83] = sum; xmodem_buf_pos = 0; xmodem_next_char(); }
void throttle_interval_event(int index) { event_repeat(index, 27000000 / 100); /* Throttle interval (defined arbitrarily as 100Hz) - used for * keeping the emulator speed down, and other miscellaneous stuff * that needs to be done periodically */ static int intervals = 0, prev_intervals = 0; intervals += 1; usblink_timer(); usblink_queue_do(); int c = gui_getchar(); if(c != -1) serial_byte_in((char) c); gdbstub_recv(); rdebug_recv(); // Calculate speed auto interval_end = std::chrono::high_resolution_clock::now(); static auto prev = interval_end; static double speed = 1.0; auto time = std::chrono::duration_cast<std::chrono::microseconds>(interval_end - prev).count(); if (time >= 500000) { speed = (double)10000 * (intervals - prev_intervals) / time; gui_show_speed(speed); prev_intervals = intervals; prev = interval_end; } gui_do_stuff(true); if (!turbo_mode) throttle_timer_wait(); }
static void xmodem_next_char() { if (xmodem_file && xmodem_buf_pos < 0x84) serial_byte_in(xmodem_buf[xmodem_buf_pos++]); }