void SelectSong(int num) { if (num >= number_of_songs) num = 0; current_song = num; // Reset SID SIDReset(0); // Set replay frequency int freq = 50; if (num < 32) freq = speed_flags & (1 << num) ? 60 : 50; SIDSetReplayFreq(freq); SIDAdjustSpeed(100); // Execute init routine CPUExecute(init_adr, current_song, 0, 0, 1000000); }
int main(int argc, char **argv) { // Print banner printf( "SIDPlayer Version 4.4\n\n" "Copyright (C) 1996-2004 Christian Bauer\n" "E-mail: [email protected]\n" "http://www.uni-mainz.de/~bauec002/\n\n" "This is free software with ABSOLUTELY NO WARRANTY.\n" "You are welcome to redistribute it under certain conditions.\n" "For details, see the file COPYING.\n\n" ); // Initialize everything if (SDL_Init(SDL_INIT_AUDIO) < 0) { fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError()); exit(1); } atexit(quit); InitAll(argc, argv); int32 speed = PrefsFindInt32("speed"); // Parse non-option arguments const char *file_name = NULL; int song = 0; int i; for (i=1; i<argc; i++) { if (strcmp(argv[i], "--help") == 0) usage(argv[0]); else if (argv[i][0] == '-') { fprintf(stderr, "Unrecognized option '%s'\n", argv[i]); usage(argv[0]); } else { if (file_name == NULL) file_name = argv[i]; // First non-option argument is file name else song = atoi(argv[i]); // Second non-option argument is song number } } if (file_name == NULL) usage(argv[0]); // Load given PSID file if (!LoadPSIDFile(file_name)) { fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name); exit(1); } // Select song if (song > 0) { if (song > number_of_songs) song = number_of_songs; SelectSong(song - 1); } SIDAdjustSpeed(speed); // SelectSong and LoadPSIDFile() reset this to 100% // Print file information printf("Module Name: %s\n", module_name); printf("Author : %s\n", author_name); printf("Copyright : %s\n\n", copyright_info); printf("Playing song %d/%d\n", current_song + 1, number_of_songs); // Start replay and enter main loop SDL_PauseAudio(false); while (true) { SDL_Event e; if (SDL_WaitEvent(&e)) { if (e.type == SDL_QUIT) break; } } ExitAll(); return 0; }