/** @ingroup sdl * @brief Met à jour la fenêtre */ void update() { sdl_handle_events(); double dt = 1 / 60.; if (state->mise_a_jour) state->mise_a_jour(state, dt); set_color(40, 40, 40); draw_rect(window, 0, 0, W, H); state->afficher(state, window); SDL_Flip(window); if (state->quitter) { printf("Quitte!\n"); #ifdef EMSCRIPTEN emscripten_cancel_main_loop(); #endif } }
int main(int argc, char *argv[]) { // Setup SDL if(SDL_setup() != 0) return -1; // Command line arguments char *ram_file = 0; char binary = 0; char little_endian = 0; char debug_mode = 0; char enable_profiling = 0; // Parse the arguments for(int c = 1; c < argc; c++) { if(strcmp(argv[c], "-d") == 0) { debug_mode = 1; } else if(strcmp(argv[c], "-bl") == 0) { binary = 1; little_endian = 1; } else if(strcmp(argv[c], "-bb") == 0) { binary = 1; little_endian = 0; } else if(strcmp(argv[c], "-p") == 0) { enable_profiling = 1; } else { ram_file = argv[c]; } } // Make sure the user specified a RAM file if(ram_file) { // Prepare the emulator if(emulator_setup(ram_file, binary, little_endian, enable_profiling) != 0) return -1; } else { PRINTF("No RAM file specified.\n"); return 0; } // Setup hardware hardware_setup(); // Start the emulator thread pthread_create(&emulator_thread, 0, (void *) &emulator_thread_func, (void *) &debug_mode); // SDL event loop while(running) { sdl_handle_events(); sdl_render(); } // Wait for the emulator thread to finish running = 0; pthread_join(emulator_thread, 0); // Cleanup hardware_release(); // Quit SDL SDL_Quit(); return 0; }