/* * Runs the main Atari emulator loop * * testframes The number of testframes to run (for loading saves) */ void wii_atari_main_loop( int testframes ) { WII_SetRenderCallback( &wii_render_callback ); WII_ChangeSquare( wii_screen_x, wii_screen_y, 0, 0 ); // Track the first fire of the lightgun (so that the catridge can properly // detect joystick versus lightgun.) lightgun_first_fire = true; // Only enable lightgun if the cartridge supports it and we are displaying // at 2x. lightgun_enabled = ( cartridge_controller[0] & CARTRIDGE_CONTROLLER_LIGHTGUN ); float fps_counter; u32 timerCount = 0; u32 start_time = SDL_GetTicks(); timer_Reset(); while( !prosystem_paused ) { if( testframes < 0 ) { wii_atari_update_keys( keyboard_data ); wii_testframe = false; } else { wii_testframe = true; } if( prosystem_active && !prosystem_paused ) { prosystem_ExecuteFrame( keyboard_data ); while( !timer_IsTime() ); fps_counter = (((float)timerCount++/(SDL_GetTicks()-start_time))*1000.0); wii_atari_refresh_screen( true, testframes ); if( testframes < 0 ) { sound_Store(); } wii_fps_counter = fps_counter; if( testframes > 0 ) { --testframes; } else if( testframes == 0 ) { return; } } } // Save the high score SRAM cartridge_SaveHighScoreSram(); }
SdlUi::SdlUi(long width, long height, bool fs_flag) : BaseUi(), zoom_available(true), toggle_fs_available(false), mode_changing(false) { #ifdef GEKKO WPAD_Init(); SYS_SetResetCallback(GekkoResetCallback); #endif uint32_t flags = SDL_INIT_VIDEO; #ifndef EMSCRIPTEN flags |= SDL_INIT_TIMER; #endif #if (!defined(NDEBUG) || defined(_WIN32)) flags |= SDL_INIT_NOPARACHUTE; #endif // Set some SDL environment variables before starting. These are platform // dependent, so every port needs to set them manually #ifndef GEKKO // Set window position to the middle of the screen putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center")); #endif #ifdef __LINUX__ // Set the application class name setenv("SDL_VIDEO_X11_WMCLASS", GAME_TITLE, 0); #elif defined(PSP) putenv(const_cast<char *>("SDL_ASPECT_RATIO=4:3")); #endif if (SDL_Init(flags) < 0) { Output::Error("Couldn't initialize SDL.\n%s\n", SDL_GetError()); } #if SDL_MAJOR_VERSION==1 sdl_surface = NULL; #else sdl_window = NULL; #endif BeginDisplayModeChange(); if (!RequestVideoMode(width, height, fs_flag)) { Output::Error("No suitable video resolution found. Aborting."); } EndDisplayModeChange(); #ifdef GEKKO // Eliminate debug spew in on-screen console Output::WiiSetConsole(); // Eliminate overscan / add 5% borders WII_ChangeSquare(304, 228, 0, 0); #endif SetTitle(GAME_TITLE); #if (defined(USE_JOYSTICK) && defined(SUPPORT_JOYSTICK)) || (defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS)) || (defined(USE_JOYSTICK_HAT) && defined(SUPPORT_JOYSTICK_HAT)) if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { Output::Warning("Couldn't initialize joystick.\n%s", SDL_GetError()); } SDL_JoystickEventState(1); SDL_JoystickOpen(0); #endif #if defined(USE_MOUSE) && defined(SUPPORT_MOUSE) ShowCursor(true); #else ShowCursor(false); #endif #ifdef HAVE_SDL_MIXER audio_.reset(new SdlAudio()); #elif defined(HAVE_OPENAL) audio_.reset(new ALAudio()); #else audio_.reset(new EmptyAudio()); #endif }