void fs_uae_init_path_resolver() { int k; // current working directory should always come first (index 0) k = 0; g_paths[FS_UAE_DIR_PATHS].path[k++] = g_strdup("."); if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_DIR_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } // current working directory should always come first (index 0) k = 0; g_paths[FS_UAE_FLOPPY_PATHS].path[k++] = g_strdup("."); if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_FLOPPY_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } // then add the default floppies dir if (fs_uae_floppies_dir()) { g_paths[FS_UAE_FLOPPY_PATHS].path[k++] = g_strdup( fs_uae_floppies_dir()); } // similarly for other path types k = 0; g_paths[FS_UAE_CD_PATHS].path[k++] = g_strdup("."); if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_CD_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } if (fs_uae_cdroms_dir()) { g_paths[FS_UAE_CD_PATHS].path[k++] = g_strdup( fs_uae_cdroms_dir()); } k = 0; g_paths[FS_UAE_HD_PATHS].path[k++] = g_strdup("."); if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_HD_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } if (fs_uae_hard_drives_dir()) { g_paths[FS_UAE_HD_PATHS].path[k++] = g_strdup( fs_uae_hard_drives_dir()); } k = 0; g_paths[FS_UAE_ROM_PATHS].path[k++] = g_strdup("."); if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_ROM_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } if (fs_uae_kickstarts_dir()) { g_paths[FS_UAE_ROM_PATHS].path[k++] = g_strdup( fs_uae_kickstarts_dir()); } }
void fs_uae_init_path_resolver(void) { bool relative_paths = true; if (fs_config_is_false(OPTION_RELATIVE_PATHS)) { relative_paths = false; } int k; k = 0; if (relative_paths) { /* Current working directory should always come first (index 0) */ g_paths[FS_UAE_DIR_PATHS].path[k++] = g_strdup("."); } if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_DIR_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } k = 0; if (relative_paths) { g_paths[FS_UAE_FLOPPY_PATHS].path[k++] = g_strdup("."); } if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_FLOPPY_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } if (fs_uae_floppies_dir()) { g_paths[FS_UAE_FLOPPY_PATHS].path[k++] = g_strdup( fs_uae_floppies_dir()); } k = 0; if (relative_paths) { g_paths[FS_UAE_CD_PATHS].path[k++] = g_strdup("."); } if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_CD_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } if (fs_uae_cdroms_dir()) { g_paths[FS_UAE_CD_PATHS].path[k++] = g_strdup( fs_uae_cdroms_dir()); } k = 0; if (relative_paths) { g_paths[FS_UAE_HD_PATHS].path[k++] = g_strdup("."); } if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_HD_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } if (fs_uae_hard_drives_dir()) { g_paths[FS_UAE_HD_PATHS].path[k++] = g_strdup( fs_uae_hard_drives_dir()); } k = 0; if (relative_paths) { g_paths[FS_UAE_ROM_PATHS].path[k++] = g_strdup("."); } if (g_fs_uae_config_dir_path) { g_paths[FS_UAE_ROM_PATHS].path[k++] = g_strdup( g_fs_uae_config_dir_path); } if (fs_uae_kickstarts_dir()) { g_paths[FS_UAE_ROM_PATHS].path[k++] = g_strdup( fs_uae_kickstarts_dir()); } }
int main(int argc, char *argv[]) { fs_uae_argc = argc; fs_uae_argv = argv; fs_set_argv(argc, argv); #ifdef WITH_CEF cef_init(argc, argv); #endif char **arg; arg = argv + 1; while (arg && *arg) { if (strcmp(*arg, "--list-joysticks") == 0) { list_joysticks(); exit(0); } else if (strcmp(*arg, "--list-devices") == 0) { list_joysticks(); exit(0); } else if (strcmp(*arg, "--version") == 0) { printf("%s\n", PACKAGE_VERSION); exit(0); } else if (strcmp(*arg, "--help") == 0) { printf(COPYRIGHT_NOTICE, PACKAGE_VERSION, OS_NAME_2, ARCH_NAME_2); printf(EXTRA_HELP_TEXT); exit(0); } arg++; } fs_init(); int error = fs_data_init("fs-uae", "fs-uae.dat"); if (error) { printf("WARNING: error (%d) loading fs-uae.dat\n", error); } fs_set_prgname("fs-uae"); fs_set_application_name("Amiga Emulator"); amiga_set_log_function(log_to_libfsemu); //result = parse_options(argc, argv); printf(COPYRIGHT_NOTICE, PACKAGE_VERSION, OS_NAME_2, ARCH_NAME_2); fs_log(COPYRIGHT_NOTICE, PACKAGE_VERSION, OS_NAME_2, ARCH_NAME_2); char *current_dir = g_get_current_dir(); fs_log("current directory is %s\n", current_dir); g_free(current_dir); amiga_init(); #if 0 // FIXME: disabling fullscreen spaces must be done before // SDL_INIT_VIDEO, but we need to check config to see if this should // be done, and we initialize SDL early to check for config file // (catch 22)... // FIXME: check fullscreen_spaces option SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0"); #endif #ifdef MACOSX SDL_Init(SDL_INIT_EVERYTHING); SDL_PumpEvents(); SDL_Event event; fs_log("OS X: Check for pending SDL_DROPFILE event\n"); while (SDL_PollEvent(&event)) { fs_log("Got SDL event 0x%x\n", event.type); if (event.type == SDL_DROPFILE) { if (event.drop.file != NULL) { g_fs_uae_config_file_path = strdup(event.drop.file); } SDL_free(event.drop.file); } } #endif // skip first entry arg = argv + 1; if (g_fs_uae_config_file_path == NULL) { while (arg && *arg) { const gchar *test_path = *arg; if (test_path && fs_path_exists(test_path)) { if (check_extension(test_path, ".fs-uae")) { g_fs_uae_config_file_path = g_strdup(test_path); } else if (check_extension(test_path, ".conf")) { g_fs_uae_config_file_path = g_strdup(test_path); } else if (check_extension(test_path, ".adf")) { g_fs_uae_disk_file_path = g_strdup(test_path); } else if (check_extension(test_path, ".ipf")) { g_fs_uae_disk_file_path = g_strdup(test_path); } else if (check_extension(test_path, ".dms")) { g_fs_uae_disk_file_path = g_strdup(test_path); } } arg++; } } /* Parse options first, in case base_dir, logging options etc is * specified on the command line. */ fs_config_parse_options(argc - 1, argv + 1); fs_log("\n"); fs_log(LOG_LINE); fs_log("libfsemu init\n"); fs_log(LOG_LINE); fs_log("\n"); fs_emu_path_set_expand_function(fs_uae_expand_path); fs_emu_init_overlays(overlay_names); fs_emu_init(); // then load the config file load_config_file(); init_i18n(); if (g_fs_uae_disk_file_path) { fs_config_set_string(OPTION_FLOPPY_DRIVE_0, g_fs_uae_disk_file_path); g_warn_about_missing_config_file = 0; } if (g_warn_about_missing_config_file) { fs_emu_warning(_("No configuration file was found")); } fs_log("\n"); fs_log(LOG_LINE); fs_log("fs-uae init\n"); fs_log(LOG_LINE); fs_log("\n"); configure_logging(fs_config_get_const_string("log")); fs_emu_set_state_check_function(amiga_get_state_checksum); fs_emu_set_rand_check_function(amiga_get_rand_checksum); // force creation of some recommended default directories fs_uae_kickstarts_dir(); fs_uae_configurations_dir(); fs_uae_init_path_resolver(); fs_uae_plugins_init(); // must be called early, before fs_emu_init -affects video output fs_uae_configure_amiga_model(); // force creation of state directories //fs_uae_flash_memory_dir(); //fs_uae_save_states_dir(); //fs_uae_floppy_overlays_dir(); fs_uae_state_dir(); const char *controllers_dir = fs_uae_controllers_dir(); if (controllers_dir) { fs_emu_set_controllers_dir(controllers_dir); } const char *logs_dir = fs_uae_logs_dir(); if (logs_dir) { char *log_file; log_file = g_build_filename(logs_dir, "FS-UAE.log", NULL); if (fs_path_exists(log_file)) { g_unlink(log_file); } g_free(log_file); log_file = g_build_filename(logs_dir, "FS-UAE.log.txt", NULL); if (fs_path_exists(log_file)) { g_unlink(log_file); } g_free(log_file); log_file = g_build_filename(logs_dir, "Emulator.log.txt", NULL); if (fs_path_exists(log_file)) { g_unlink(log_file); } g_free(log_file); log_file = g_build_filename(logs_dir, "fs-uae.log.txt", NULL); fs_config_set_log_file(log_file); g_free(log_file); } fs_config_set_string_if_unset("themes_dir", fs_uae_themes_dir()); fs_emu_set_pause_function(pause_function); //fs_uae_init_input(); fs_emu_init_2(FS_EMU_INIT_EVERYTHING); // we initialize the recording module either it is used or not, so it // can delete state-specific recordings (if necessary) when states are // saved fs_uae_init_recording(); int deterministic_mode = 0; const char* record_file = fs_config_get_const_string("record"); if (record_file) { fs_log("record file specified: %s, forcing deterministic mode\n", record_file); deterministic_mode = 1; fs_uae_enable_recording(record_file); } else { fs_log("not running in record mode\n"); } if (fs_emu_netplay_enabled() || fs_config_get_boolean(OPTION_DETERMINISTIC) == 1) { deterministic_mode = 1; } if (deterministic_mode) { amiga_set_deterministic_mode(); } if (logs_dir) { if (fs_emu_netplay_enabled()) { char *sync_log_file = g_build_filename(logs_dir, "Synchronization.log", NULL); amiga_set_synchronization_log_file(sync_log_file); free(sync_log_file); } } #ifdef FS_EMU_DRIVERS fs_emu_audio_stream_options **options = fs_emu_audio_alloc_stream_options(2); options[0]->frequency = fs_emu_audio_output_frequency(); /* 12 * 2352 is CDDA_BUFFERS * 2352 (blkdev_cdimage.cpp) */ options[1]->buffer_size = 12 * 2352; // begin playing with only one buffer queued options[1]->min_buffers = 1; fs_emu_audio_configure(options); amiga_set_audio_buffer_size(options[0]->buffer_size); fs_emu_audio_free_stream_options(options); #else // this stream is for paula output and drive clicks // FIXME: could mix drive clicks in its own stream instead, -might // give higher quality mixing fs_emu_audio_stream_options options; options.struct_size = sizeof(fs_emu_audio_stream_options); fs_emu_init_audio_stream_options(&options); options.frequency = fs_emu_audio_output_frequency(); fs_emu_init_audio_stream(0, &options); amiga_set_audio_buffer_size(options.buffer_size); // this stream is for CD audio output (CDTV/CD32) fs_emu_init_audio_stream_options(&options); // 12 * 2352 is CDDA_BUFFERS * 2352 (blkdev_cdimage.cpp) options.buffer_size = 12 * 2352; // begin playing with only one buffer queued options.min_buffers = 1; fs_emu_init_audio_stream(1, &options); #endif amiga_set_audio_callback(audio_callback_function); amiga_set_cd_audio_callback(audio_callback_function); amiga_set_event_function(event_handler); amiga_set_led_function(led_function); amiga_on_update_leds(on_update_leds); amiga_set_media_function(media_function); amiga_set_init_function(on_init); if (fs_config_get_boolean(OPTION_JIT_COMPILER) == 1) { amiga_init_jit_compiler(); } #ifdef WITH_LUA amiga_init_lua(fs_emu_acquire_lua, fs_emu_release_lua); amiga_init_lua_state(fs_emu_get_lua_state()); fs_uae_init_lua_state(fs_emu_get_lua_state()); #endif if (fs_emu_get_video_format() == FS_EMU_VIDEO_FORMAT_RGBA) { amiga_set_video_format(AMIGA_VIDEO_FORMAT_RGBA); } else if (fs_emu_get_video_format() == FS_EMU_VIDEO_FORMAT_BGRA) { amiga_set_video_format(AMIGA_VIDEO_FORMAT_BGRA); } else if (fs_emu_get_video_format() == FS_EMU_VIDEO_FORMAT_R5G6B5) { amiga_set_video_format(AMIGA_VIDEO_FORMAT_R5G6B5); } else if (fs_emu_get_video_format() == FS_EMU_VIDEO_FORMAT_R5G5B5A1) { amiga_set_video_format(AMIGA_VIDEO_FORMAT_R5G5B5A1); } else { fs_emu_warning("Unsupported video format requested"); } amiga_add_rtg_resolution(672, 540); amiga_add_rtg_resolution(960, 540); amiga_add_rtg_resolution(672 * 2, 540 * 2); amiga_add_rtg_resolution(fs_emu_get_windowed_width(), fs_emu_get_windowed_height()); amiga_add_rtg_resolution(fs_emu_get_fullscreen_width(), fs_emu_get_fullscreen_height()); fs_uae_init_video(); //fs_uae_init_keyboard(); fs_uae_init_mouse(); fs_uae_configure_menu(); fs_emu_run(main_function); fs_log("fs-uae shutting down, fs_emu_run returned\n"); if (g_rmdir(fs_uae_state_dir()) == 0) { fs_log("state dir %s was removed because it was empty\n", fs_uae_state_dir()); } else { fs_log("state dir %s was not removed (non-empty)\n", fs_uae_state_dir()); } fs_log("end of main function\n"); cleanup_old_files(); #ifdef WITH_CEF cef_destroy(); #endif return 0; }
void fs_uae_configure_amiga_hardware() { amiga_config *c = g_fs_uae_amiga_configs + g_fs_uae_amiga_config; char *path; fs_emu_log("fs_uae_configure_amiga_hardware\n"); fs_uae_load_rom_files(fs_uae_kickstarts_dir()); #ifdef NEW_ACCURACY_SYSTEM g_accuracy = 1; #endif fs_emu_log("configuring \"%s\", accuracy=%d\n", c->name, g_accuracy); amiga_quickstart(c->quickstart_model, c->quickstart_config, g_accuracy); amiga_set_option("cachesize", "0"); if (c->cpu_model) { amiga_set_option("cpu_model", c->cpu_model); } if (c->z3mem_size) { amiga_set_int_option("z3mem_size", c->z3mem_size); } if (c->cpu_32bit_addressing) { amiga_set_option("cpu_24bit_addressing", "false"); } if (c->fast) { amiga_set_option("cpu_speed", "max"); amiga_set_option("blitter_cycle_exact", "false"); amiga_set_option("cpu_cycle_exact", "false"); amiga_set_option("cpu_compatible", "false"); amiga_set_option("immediate_blits", "true"); } //if (g_fs_uae_fastest_possible) { amiga_set_cpu_idle(2); //} if (g_fs_uae_ntsc_mode) { // FIXME: ciiatod on some Amiga models? amiga_set_option("ntsc", "true"); } path = fs_config_get_string("kickstart_file"); if (path) { path = fs_uae_expand_path_and_free(path); path = fs_uae_resolve_path_and_free(path, FS_UAE_ROM_PATHS); amiga_set_option("kickstart_rom_file", path); free(path); } path = fs_config_get_string("kickstart_ext_file"); if (path) { path = fs_uae_expand_path_and_free(path); path = fs_uae_resolve_path_and_free(path, FS_UAE_ROM_PATHS); amiga_set_option("kickstart_ext_rom_file", path); free(path); } configure_memory(c); if (fs_config_get_boolean("bsdsocket_library") == 1) { amiga_set_option("bsdsocket_emu", "yes"); } amiga_enable_serial_port(); configure_accuracy(c); /* if (g_fs_uae_amiga_model == MODEL_A500) { if (slow_memory || fast_memory || chip_memory > 512) { fs_log("using A500 and memory expansions, " "enabling real-time clock"); amiga_set_option("rtc", "MSM6242B"); } } */ /* char **keys = g_key_file_get_keys(g_fs_uae_config, "uae", NULL, NULL); if (keys) { for (char **key = keys; *key; key++) { char *value = g_key_file_get_string(g_fs_uae_config, "uae", *key, NULL); if (value != NULL) { amiga_set_option(*key, value); free(value); } } g_strfreev(keys); } */ }