void Opts_SetGlobalOpt(unsigned int index, int val) { if (index < NUM_GLOBAL_OPTS) { //Need to make sure we don't turn on sound options if sound //system couldn't be set up: if(index == USE_SOUND || index == MENU_SOUND || index == MENU_MUSIC) { if(!Opts_SoundHWAvailable()) val = 0; } if (index == USE_TTS) text_to_speech_status = val; global_options->iopts[index] = val; } else DEBUGMSG(debug_options, "Invalid global option index: %d\n", index); }
void initialize_SDL(void) { //NOTE - SDL_Init() and friends now in InitT4KCommon() // Audio parameters int frequency, channels, n_timesopened; Uint16 format; /* Init common library */ if(!InitT4KCommon(debug_status)) { fprintf(stderr, "InitT4KCommon() failed - exiting.\n"); cleanup_on_error(); exit(1); } /* Init SDL Video: */ screen = NULL; /* Init SDL Audio: */ Opts_SetSoundHWAvailable(0); // By default no sound HW #ifndef NOSOUND if (Opts_GetGlobalOpt(USE_SOUND)) { if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16SYS, 2, 2048) < 0) { fprintf(stderr, "\nWarning: I could not set up audio for 44100 Hz " "16-bit stereo.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); } n_timesopened = Mix_QuerySpec(&frequency,&format,&channels); if (n_timesopened > 0) Opts_SetSoundHWAvailable(1); else frequency = format = channels = 0; //more helpful than garbage DEBUGMSG(debug_setup, "Sound mixer: frequency = %d, " "format = %x, " "channels = %d, " "n_timesopened = %d\n", frequency,format,channels,n_timesopened); } #endif /* If couldn't set up sound, deselect sound options: */ if(!Opts_SoundHWAvailable()) { DEBUGMSG(debug_setup, "Sound setup failed - deselecting sound options\n"); Opts_SetGlobalOpt(USE_SOUND, 0); Opts_SetGlobalOpt(MENU_SOUND, 0); Opts_SetGlobalOpt(MENU_MUSIC, 0); } { const SDL_VideoInfo *videoInfo; Uint32 surfaceMode; videoInfo = SDL_GetVideoInfo(); if (videoInfo->hw_available) { surfaceMode = SDL_HWSURFACE; DEBUGMSG(debug_setup, "HW mode\n"); } else { surfaceMode = SDL_SWSURFACE; DEBUGMSG(debug_setup, "SW mode\n"); } // Determine the current resolution: this will be used as the // fullscreen resolution, if the user wants fullscreen. DEBUGMSG(debug_setup, "Current resolution: w %d, h %d.\n",videoInfo->current_w,videoInfo->current_h); if (Opts_GetGlobalOpt(FULLSCREEN) && Opts_CustomRes()) { fs_res_x = Opts_WindowWidth(); fs_res_y = Opts_WindowHeight(); DEBUGMSG(debug_setup, "Full screen mode custom resolution: w %d, h %d.\n",fs_res_x,fs_res_y); } else { fs_res_x = videoInfo->current_w; fs_res_y = videoInfo->current_h; } if (Opts_GetGlobalOpt(FULLSCREEN)) { screen = SDL_SetVideoMode(fs_res_x, fs_res_y, PIXEL_BITS, SDL_FULLSCREEN | surfaceMode); if (screen == NULL) { fprintf(stderr, "\nWarning: I could not open the display in fullscreen mode.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); Opts_SetGlobalOpt(FULLSCREEN, 0); } } if (!Opts_GetGlobalOpt(FULLSCREEN)) { screen = SDL_SetVideoMode(Opts_WindowWidth(), Opts_WindowHeight(), PIXEL_BITS, surfaceMode); } if (screen == NULL) { fprintf(stderr, "\nError: I could not open the display.\n" "The Simple DirectMedia error that occured was:\n" "%s\n\n", SDL_GetError()); cleanup_on_error(); exit(1); } seticon(); SDL_WM_SetCaption("Tux, of Math Command", "TuxMath"); } }