void setup_game_close(void) { char err_str[256]; bool display_reset; gui_shutdown(); // is it a restore? if (!setup_close_save_flag) { memmove(&setup,&setup_backup,sizeof(setup_type)); return; } // save // fix control and sound changes setup_to_input(); al_set_volume(setup.sound_volume); al_music_set_volume(setup.music_volume); al_music_set_state(setup.music_on); // need to reset SDL? // can't do it in game (not possible, anyway, but just in case) if (!setup_in_game) { display_reset=(setup_backup.screen_wid!=setup.screen_wid); display_reset=display_reset || (setup_backup.screen_high!=setup.screen_high); display_reset=display_reset || (setup_backup.fsaa_mode!=setup.fsaa_mode); if (display_reset) { if (!view_reset_display(err_str)) { app.loop_quit=TRUE; // fatal error resetting display return; } } } // write setup setup_xml_write(); }
bool view_initialize(char *err_str) { int rate; // clear view structure memset(&view,0x0,sizeof(view_type)); // allocate memory if (!view_memory_allocate()) { view_memory_release(); strcpy(err_str,"Out of Memory"); return(FALSE); } // start SDL if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)==-1) { view_memory_release(); sprintf(err_str,"SDL: Could not init (Error: %s)\n",SDL_GetError()); return(FALSE); } // create screen sizes view_create_screen_size_list(); // gl initialize if (!view_initialize_display(err_str)) return(FALSE); // sound initialize if (!al_initialize(err_str)) { view_shutdown_display(); view_memory_release(); SDL_Quit(); return(FALSE); } al_set_volume(setup.sound_volume); al_music_set_volume(setup.music_volume); al_music_set_state(setup.music_on); // read in the sounds read_settings_sound(); // connect the input read_settings_action(); input_initialize(gl_in_window_mode()); setup_to_input(); // draw timing view.time.input_tick=game_time_get(); view.time.draw_tick=game_time_get(); rate=render_info.monitor_refresh_rate; if (!setup.lock_fps_refresh) rate=max_fps; if (rate>max_fps) rate=max_fps; view.time.draw_time=1000/rate; return(TRUE); }