int initcmdline_check_psid(void) { /* Check for PSID here since we don't want to allow autodetection in autostart.c. */ if (machine_class == VICE_MACHINE_VSID) { if (autostart_string != NULL && machine_autodetect_psid(autostart_string) == -1) { log_error(LOG_DEFAULT, "`%s' is not a valid PSID file.", autostart_string); return -1; } } return 0; }
static UI_MENU_CALLBACK(load_psid_callback) { char *name = NULL; if (activated) { name = sdl_ui_file_selection_dialog("Choose PSID file", FILEREQ_MODE_CHOOSE_FILE); if (name != NULL) { if (machine_autodetect_psid(name) < 0) { ui_error("Could not load PSID file"); } lib_free(name); psid_init_driver(); machine_play_psid(0); machine_trigger_reset(MACHINE_RESET_MODE_SOFT); return sdl_menu_text_exit_ui; } } return NULL; }
/* Window procedure. All messages are handled here. */ static LRESULT CALLBACK window_proc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) { HDC hdc; PAINTSTRUCT ps; int i; switch (msg) { case WM_CREATE: songs = psid_tunes(&default_song); current_song = default_song; #if 0 if (songs == 0) { log_message(LOG_DEFAULT, "Vsid: no file specified, quitting"); return -1; } #endif DragAcceptFiles(window, TRUE); return 0; case WM_KEYDOWN: switch(wparam) { case 'I': /* infoline on request, just press I */ vsid_disp( 0, VSID_S_LASTLINE, "%s", vsidstrings[VSID_S_LASTLINE]); break; case VK_LEFT: case VK_DOWN: if (current_song > 1) { current_song--; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); InvalidateRect(window, NULL, 0); } break; case VK_RIGHT: case VK_UP: if (current_song < songs) { current_song++; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); InvalidateRect(window, NULL, 0); } break; } return 0; case WM_KEYUP: switch(wparam) { case 'I': /* infoline on request, just press I */ vsid_disp( 0, VSID_S_LASTLINE, "%79s", " "); break; } return 0; case WM_SIZE: return 0; case WM_COMMAND: vsync_suspend_speed_eval(); handle_wm_command(wparam, lparam, window); return 0; case WM_ENTERMENULOOP: vsync_suspend_speed_eval(); update_menus(window); break; case WM_MOVE: break; case WM_CLOSE: vsync_suspend_speed_eval(); vsid_ui_close(); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_DROPFILES: { char dummy[MAX_PATH]; DragQueryFile((HDROP)wparam, 0, dummy, sizeof(dummy) ); if (machine_autodetect_psid(dummy) >= 0) { vsid_disp(0, 0, NULL, NULL); psid_init_driver(); vsid_ui_init(); machine_play_psid(0); for (i = 0; i < VSID_S_LASTLINE; i++) { *vsidstrings[i] = 0; } machine_trigger_reset(MACHINE_RESET_MODE_SOFT); songs = psid_tunes(&default_song); current_song = default_song; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); InvalidateRect(window, NULL, TRUE); } } return 0; case WM_PAINT: { hdc = BeginPaint(window, &ps); if (*vsidstrings[VSID_S_TIMER]) { /* start only when timer string has been filled */ for (i = 0; i < VSID_S_LASTLINE; i++) { vsid_disp(0, i, "%s", vsidstrings[i]); } } EndPaint(window, &ps); return 0; } } return DefWindowProc(window, msg, wparam, lparam); }
static void handle_wm_command(WPARAM wparam, LPARAM lparam, HWND hwnd) { TCHAR *st_name = NULL; char *name = NULL; int i; switch (wparam) { case IDM_LOAD_PSID_FILE: st_name = uilib_select_file(hwnd, translate_text(IDS_PSID_FILE), UILIB_FILTER_ALL, UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_DEFAULT); if (st_name != NULL) { name = system_wcstombs_alloc(st_name); if (machine_autodetect_psid(st_name) >= 0) { vsid_disp(0, 0, NULL, NULL); psid_init_driver(); vsid_ui_init(); machine_play_psid(0); for (i = 0; i < VSID_S_LASTLINE; i++) { *vsidstrings[i] = 0; } machine_trigger_reset(MACHINE_RESET_MODE_SOFT); songs = psid_tunes(&default_song); current_song = default_song; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); } system_wcstombs_free(name); lib_free(st_name); } break; case IDM_SELECT_TUNE: ui_select_vsid_tune(hwnd); break; case IDM_NEXT_TUNE: if (current_song < songs) { current_song++; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); } break; case IDM_PREVIOUS_TUNE: if (current_song > 1) { current_song--; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); } break; case IDM_RESET_HARD: machine_trigger_reset(MACHINE_RESET_MODE_HARD); break; case IDM_RESET_SOFT: machine_trigger_reset(MACHINE_RESET_MODE_SOFT); break; case IDM_MONITOR: monitor_startup_trap(); break; case IDM_EXIT: PostMessage(hwnd, WM_CLOSE, wparam, lparam); break; case IDM_SOUND_RECORD_START: ui_sound_record_settings_dialog(hwnd); break; case IDM_SOUND_RECORD_STOP: resources_set_string("SoundRecordDeviceName", ""); break; case IDM_MAXIMUM_SPEED_CUSTOM: ui_speed_settings_dialog(hwnd); break; case IDM_SOUND_SETTINGS: ui_sound_settings_dialog(hwnd); break; case IDM_SID_SETTINGS: ui_sid_settings_dialog(hwnd, c64_sid_baseaddress); break; case IDM_SETTINGS_SAVE_FILE: if ((st_name = uilib_select_file(hwnd, translate_text(IDS_SAVE_CONFIG_FILE), UILIB_FILTER_ALL, UILIB_SELECTOR_TYPE_FILE_SAVE, UILIB_SELECTOR_STYLE_DEFAULT)) != NULL) { char *name; name = system_wcstombs_alloc(st_name); if (resources_save(st_name) < 0) { ui_error(translate_text(IDS_CANNOT_SAVE_SETTINGS)); } else { ui_message(translate_text(IDS_SETTINGS_SAVED_SUCCESS)); } system_wcstombs_free(name); lib_free(st_name); } break; case IDM_SETTINGS_LOAD_FILE: if ((st_name = uilib_select_file(hwnd, translate_text(IDS_LOAD_CONFIG_FILE), UILIB_FILTER_ALL, UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_DEFAULT)) != NULL) { char *name; name = system_wcstombs_alloc(st_name); if (resources_load(st_name) < 0) { ui_error(translate_text(IDS_CANNOT_LOAD_SETTINGS)); } else { ui_message(translate_text(IDS_SETTINGS_LOADED_SUCCESS)); } system_wcstombs_free(name); lib_free(st_name); } break; case IDM_SETTINGS_SAVE: if (resources_save(NULL) < 0) { ui_error(translate_text(IDS_CANNOT_SAVE_SETTINGS)); } else { ui_message(translate_text(IDS_SETTINGS_SAVED_SUCCESS)); } break; case IDM_SETTINGS_LOAD: if (resources_load(NULL) < 0) { ui_error(translate_text(IDS_CANNOT_LOAD_SETTINGS)); } else { ui_message(translate_text(IDS_SETTINGS_LOADED_SUCCESS)); } break; case IDM_SETTINGS_DEFAULT: resources_set_defaults(); ui_message(translate_text(IDS_DEFAULT_SETTINGS_RESTORED)); break; case IDM_LANG_EN: case IDM_LANG_DA: case IDM_LANG_DE: case IDM_LANG_ES: case IDM_LANG_FR: case IDM_LANG_HU: case IDM_LANG_IT: case IDM_LANG_KO: case IDM_LANG_NL: case IDM_LANG_PL: case IDM_LANG_RU: case IDM_LANG_SV: case IDM_LANG_TR: ui_set_language((unsigned int)wparam); vsid_ui_translate(); break; case IDM_ABOUT: case IDM_HELP: case IDM_CONTRIBUTORS: case IDM_LICENSE: case IDM_WARRANTY: case IDM_CMDLINE: uihelp_dialog(hwnd, wparam); break; default: handle_default_command(wparam, lparam, hwnd); } }
static int vsid_menu_handle(int idm) { char *fname = NULL; char *curlang; int i; switch (idm) { case IDM_NEXT_TUNE: if (current_song < songs) { current_song++; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); } break; case IDM_PREVIOUS_TUNE: if (current_song > 1) { current_song--; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); } break; case IDM_LOAD_PSID_FILE: fname = VSID_BrowseFile(translate_text(IDS_PSID_SELECT), "#?"); if (fname != NULL) { if (machine_autodetect_psid(fname) >= 0) { psid_init_driver(); machine_play_psid(0); for (i = 0; i < VSID_S_LASTLINE; i++) { *vsidstrings[i] = 0; } machine_trigger_reset(MACHINE_RESET_MODE_SOFT); songs = psid_tunes(&default_song); current_song = default_song; psid_ui_set_tune(uint_to_void_ptr(current_song), NULL); vsid_ui_display_tune_nr(current_song); vsid_ui_set_default_tune(default_song); vsid_ui_display_nr_of_tunes(songs); } } break; case IDM_RESET_HARD: machine_trigger_reset(MACHINE_RESET_MODE_HARD); break; case IDM_RESET_SOFT: machine_trigger_reset(MACHINE_RESET_MODE_SOFT); break; case IDM_EXIT: do_quit_vice = 1; break; case IDM_SETTINGS_SAVE_FILE: fname = VSID_BrowseFile(translate_text(IDS_CONFIG_FILENAME_SELECT), "#?"); if (fname != NULL) { if (resources_save(fname) < 0) { ui_error(translate_text(IDMES_CANNOT_SAVE_SETTINGS)); } else { ui_message(translate_text(IDMES_SETTINGS_SAVED_SUCCESS)); } } break; case IDM_SETTINGS_LOAD_FILE: fname = VSID_BrowseFile(translate_text(IDS_CONFIG_FILENAME_SELECT), "#?"); if (fname != NULL) { if (resources_load(fname) < 0) { ui_error(translate_text(IDMES_CANNOT_LOAD_SETTINGS)); } else { ui_message(translate_text(IDMES_SETTINGS_LOAD_SUCCESS)); } } break; case IDM_SETTINGS_SAVE: if (resources_save(NULL) < 0) { ui_error(translate_text(IDMES_CANNOT_SAVE_SETTINGS)); } else { ui_message(translate_text(IDMES_SETTINGS_SAVED_SUCCESS)); } break; case IDM_SETTINGS_LOAD: if (resources_load(NULL) < 0) { ui_error(translate_text(IDMES_CANNOT_LOAD_SETTINGS)); } else { ui_message(translate_text(IDMES_SETTINGS_LOAD_SUCCESS)); } break; case IDM_SETTINGS_DEFAULT: resources_set_defaults(); ui_message(translate_text(IDMES_DFLT_SETTINGS_RESTORED)); break; case IDM_SAMPLE_RATE: i = vsid_requester(translate_text(IDS_SAMPLE_RATE), translate_text(IDS_SAMPLE_RATE), "11025 Hz | 22050 Hz | 44100 Hz | 8000 Hz", 0); resources_set_int("SoundSampleRate", vsid_sample_rates[i]); break; case IDM_BUFFER_SIZE: i = vsid_requester(translate_text(IDS_BUFFER_SIZE), translate_text(IDS_BUFFER_SIZE), "150 msec | 200 msec | 250 msec | 300 msec | 350 msec | 100 msec", 0); resources_set_int("SoundBufferSize", vsid_buffer_sizes[i]); break; case IDM_FRAGMENT_SIZE: fname = util_concat(translate_text(IDS_MEDIUM), " | ", translate_text(IDS_LARGE), " | ", translate_text(IDS_SMALL), NULL); i = vsid_requester(translate_text(IDS_FRAGMENT_SIZE), translate_text(IDS_FRAGMENT_SIZE), fname, 0); resources_set_int("SoundFragmentSize", vsid_fragment_sizes[i]); lib_free(fname); break; case IDM_SPEED_ADJUSTMENT: fname = util_concat(translate_text(IDS_ADJUSTING), " | ", translate_text(IDS_EXACT), " | ", translate_text(IDS_FLEXIBLE), NULL); i = vsid_requester(translate_text(IDS_SPEED_ADJUSTMENT), translate_text(IDS_SPEED_ADJUSTMENT), fname, 0); resources_set_int("SoundSpeedAdjustment", vsid_speed_adjustments[i]); lib_free(fname); break; case IDM_VOLUME: i = vsid_requester(translate_text(IDS_VOLUME), translate_text(IDS_VOLUME), "50% | 25% | 10% | 5% | 0% | 100%", 0); resources_set_int("SoundVolume", vsid_volumes[i]); break; case IDM_SOUND_OUTPUT_MODE: fname = util_concat(translate_text(IDS_MONO), " | ", translate_text(IDS_STEREO), " | ", translate_text(IDS_SYSTEM), NULL); i = vsid_requester(translate_text(IDS_SOUND_OUTPUT_MODE), translate_text(IDS_SOUND_OUTPUT_MODE), fname, 0); resources_set_int("SoundOutput", vsid_output_modes[i]); lib_free(fname); break; case IDM_SID_ENGINE_MODEL: fname = util_concat( #ifdef HAVE_RESID "ReSID | ", #endif #ifdef HAVE_CATWEASELMKIII "Catweasel MK3 | ", #endif #ifdef HAVE_HARDSID "HardSID | ", #endif #ifdef HAVE_RESID_FP "ReSID-fp | ", #endif "Fast SID", NULL); i = vsid_requester(translate_text(IDS_SID_ENGINE), translate_text(IDS_SID_ENGINE), fname, 0); resources_set_int("SidEngine", vsid_sid_engines[i]); lib_free(fname); switch (vsid_sid_engines[i]) { case SID_ENGINE_FASTSID: i = vsid_requester(translate_text(IDS_SID_MODEL), translate_text(IDS_SID_MODEL), "8580 | 6581", 0); resources_set_int("SidModel", vsid_fastsid_models[i]); break; #ifdef HAVE_RESID case SID_ENGINE_RESID: i = vsid_requester(translate_text(IDS_SID_MODEL), translate_text(IDS_SID_MODEL), "8580 | 8580D | 6581", 0); resources_set_int("SidModel", vsid_resid_models[i]); break; #endif #ifdef HAVE_RESID_FP case SID_ENGINE_RESID_FP: i = vsid_requester(translate_text(IDS_SID_MODEL), translate_text(IDS_SID_MODEL), "6581R3 0486S | 6581R3 3984 | 6581R4AR 3789 | 6581R3 4485 | 6581R4 1986S | 8580R5 3691 | 8580R5 3691D | 8580R5 1489 | 8580R5 1489D | 6581R3 4885", 0); resources_set_int("SidModel", vsid_residfp_models[i]); break; #endif } break; case IDM_AMOUNT_OF_EXTRA_SIDS: i = vsid_requester(translate_text(IDS_AMOUNT_OF_EXTRA_SIDS), translate_text(IDS_AMOUNT_OF_EXTRA_SIDS), "1 | 2 | 0", 0); resources_get_int("SidStereo", i); break; #ifdef HAVE_RESID case IDM_SAMPLE_METHOD: fname = util_concat(translate_text(IDS_INTERPOLATING), " | ", translate_text(IDS_RESAMPLING), " | ", translate_text(IDS_FAST_RESAMPLING), " | ", translate_text(IDS_FAST), NULL); i = vsid_requester(translate_text(IDS_SAMPLE_METHOD), translate_text(IDS_SAMPLE_METHOD), fname, 0); resources_set_int("SidResidSampling", i); lib_free(fname); break; #endif case IDM_SOUND_RECORD_START: #ifndef USE_LAMEMP3 i = vsid_requester(translate_text(IDS_SOUND_RECORD_FORMAT), translate_text(IDS_SOUND_RECORD_FORMAT), "AIFF | VOC | WAV | IFF", 0); #else i = vsid_requester(translate_text(IDS_SOUND_RECORD_FORMAT), translate_text(IDS_SOUND_RECORD_FORMAT), "AIFF | VOC | WAV | MP3 | IFF", 0); #endif resources_set_string("SoundRecordDeviceName", ""); resources_set_string("SoundRecordDeviceName", vsid_sound_formats[i]); break; case IDM_SOUND_RECORD_STOP: resources_set_string("SoundRecordDeviceName", ""); break; case IDM_LANGUAGE_ENGLISH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "en")) { resources_set_value("Language", (resource_value_t *)"en"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_DANISH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "da")) { resources_set_value("Language", (resource_value_t *)"da"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_GERMAN: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "de")) { resources_set_value("Language", (resource_value_t *)"de"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_SPANISH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "es")) { resources_set_value("Language", (resource_value_t *)"es"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_FRENCH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "fr")) { resources_set_value("Language", (resource_value_t *)"fr"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_ITALIAN: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "it")) { resources_set_value("Language", (resource_value_t *)"it"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_KOREAN: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "ko")) { resources_set_value("Language", (resource_value_t *)"ko"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_DUTCH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "nl")) { resources_set_value("Language", (resource_value_t *)"nl"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_POLISH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "pl")) { resources_set_value("Language", (resource_value_t *)"pl"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_HUNGARIAN: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "hu")) { resources_set_value("Language", (resource_value_t *)"hu"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_RUSSIAN: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "ru")) { resources_set_value("Language", (resource_value_t *)"ru"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_SWEDISH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "sv")) { resources_set_value("Language", (resource_value_t *)"sv"); vsid_menu_rebuild(); } break; case IDM_LANGUAGE_TURKISH: resources_get_value("Language", (void *)&curlang); if (strcasecmp(curlang, "tr")) { resources_set_value("Language", (resource_value_t *)"tr"); vsid_menu_rebuild(); } break; default: { int i, j, command_found = 0; for (i = 0; toggle_list[i].name != NULL && !command_found; i++) { if (toggle_list[i].idm == idm) { resources_toggle(toggle_list[i].name, NULL); command_found = 1; } } for (i = 0; value_list[i].name != NULL && !command_found; i++) { for (j = 0; value_list[i].vals[j].idm != 0 && !command_found; j++) { if (value_list[i].vals[j].idm == idm) { resources_set_value(value_list[i].name, (resource_value_t) value_list[i].vals[j].value); command_found = 1; } } } } break; } return 0; }