int main(int argc, char* argv[]) { int i; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { /* Display help message: */ fprintf(stderr, "\nt4k_test, a test program for the t4k_common library.\n"); fprintf(stderr, "Run program with:\n" "--version, -v - Display version number.\n" "--copyright, -c - Display copyright and license information.\n" "--help, -h - Display this help message.\n" "--silent, -s - (Default) - run without interaction.\n" "--fullscreen, -f - Run additional interactive sound and graphics tests in fullscreen mode.\n" "--windowed, -w - Run additional interactive sound and graphics tests in window.\n" ); fprintf(stderr, "\n"); exit(0); } else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-v") == 0) { fprintf(stderr, "t4k_test program for t4k_common library, Version %s.\n", VERSION); exit(0); } else /* Warn for unknown option, except debug flags */ /* that we deal with separately: */ { fprintf(stderr, "Unknown option: %s\n", argv[i]); } }/* end of command-line args */ fprintf(stderr, "Entering t4k_test (test program for t4k_common).\n"); InitT4KCommon(debug_all); fprintf(stderr, "t4k_test exiting normally.\n"); return 0; }
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"); } }