diff --git a/src/config.c b/src/config.c index 1b03aca..84fc478 100644 --- a/src/config.c +++ b/src/config.c @@ -8,11 +8,11 @@ * * Configuration file handler. * - * NOTE: Forcing config files to be in Unicode encoding breaks - * it on Windows XP, and possibly also Vista. Use the - * -DANSI_CFG for use on these systems. + * NOTE: Forcing config files to be in Unicode encoding breaks it + * on Windows XP, possibly Vista and several UNIX systems. + * Use the -DANSI_CFG for use on these systems. * - * Version: @(#)config.c 1.0.46 2019/04/29 + * Version: @(#)config.c 1.0.47 2019/05/04 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -87,15 +87,12 @@ typedef struct _list_ { typedef struct { list_t list; - char name[128]; - list_t entry_head; } section_t; typedef struct { list_t list; - char name[128]; char data[256]; wchar_t wdata[512]; @@ -251,136 +248,138 @@ config_free(void) /* Load "General" section. */ static void -load_general(const char *cat) +load_general(config_t *cfg, const char *cat) { char *p; - vid_resize = !!config_get_int(cat, "vid_resize", 0); + cfg->language = config_get_hex16(cat, "language", emu_lang_id); + + cfg->rctrl_is_lalt = config_get_int(cat, "rctrl_is_lalt", 0); + + cfg->vid_resize = !!config_get_int(cat, "vid_resize", 0); p = config_get_string(cat, "vid_renderer", "default"); - vid_api = vidapi_from_internal_name(p); + cfg->vid_api = vidapi_from_internal_name(p); - vid_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0); + cfg->vid_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0); - vid_fullscreen_first = config_get_int(cat, "video_fullscreen_first", 0); + cfg->vid_fullscreen_first = config_get_int(cat, "video_fullscreen_first", 0); - force_43 = !!config_get_int(cat, "force_43", 0); - scale = config_get_int(cat, "scale", 1); - if (scale > 3) - scale = 3; + cfg->force_43 = !!config_get_int(cat, "force_43", 0); + cfg->scale = config_get_int(cat, "scale", 1); + if (cfg->scale > 3) + cfg->scale = 3; - invert_display = !!config_get_int(cat, "invert_display", 0); - enable_overscan = !!config_get_int(cat, "enable_overscan", 0); - vid_cga_contrast = !!config_get_int(cat, "vid_cga_contrast", 0); - vid_grayscale = config_get_int(cat, "video_grayscale", 0); - vid_graytype = config_get_int(cat, "video_graytype", 0); + cfg->invert_display = !!config_get_int(cat, "invert_display", 0); + cfg->enable_overscan = !!config_get_int(cat, "enable_overscan", 0); + cfg->vid_cga_contrast = !!config_get_int(cat, "vid_cga_contrast", 0); + cfg->vid_grayscale = config_get_int(cat, "video_grayscale", 0); + cfg->vid_graytype = config_get_int(cat, "video_graytype", 0); - rctrl_is_lalt = config_get_int(cat, "rctrl_is_lalt", 0); - - window_remember = config_get_int(cat, "window_remember", 0); - if (window_remember) { + cfg->window_remember = config_get_int(cat, "window_remember", 0); + if (cfg->window_remember) { p = config_get_string(cat, "window_coordinates", "0, 0, 0, 0"); - sscanf(p, "%i, %i, %i, %i", &window_w, &window_h, &window_x, &window_y); + sscanf(p, "%i, %i, %i, %i", + &cfg->win_w, &cfg->win_h, &cfg->win_x, &cfg->win_y); } else { config_delete_var(cat, "window_remember"); config_delete_var(cat, "window_coordinates"); - window_w = window_h = window_x = window_y = 0; + cfg->win_w = cfg->win_h = cfg->win_x = cfg->win_y = 0; } - sound_gain = config_get_int(cat, "sound_gain", 0); - - language = config_get_hex16(cat, "language", emu_lang_id); + cfg->sound_gain = config_get_int(cat, "sound_gain", 0); } /* Save "General" section. */ static void -save_general(const char *cat) +save_general(const config_t *cfg, const char *cat) { char temp[512]; const char *str; - config_set_int(cat, "vid_resize", vid_resize); - if (vid_resize == 0) - config_delete_var(cat, "vid_resize"); + if (emu_lang_id == 0x0409) + config_delete_var(cat, "language"); + else + config_set_hex16(cat, "language", emu_lang_id); - str = vidapi_get_internal_name(vid_api); - if (! strcmp(str, "default")) { - config_delete_var(cat, "vid_renderer"); - } else { - config_set_string(cat, "vid_renderer", str); - } - - if (vid_fullscreen_scale == 0) - config_delete_var(cat, "video_fullscreen_scale"); - else - config_set_int(cat, "video_fullscreen_scale", vid_fullscreen_scale); - - if (vid_fullscreen_first == 0) - config_delete_var(cat, "video_fullscreen_first"); - else - config_set_int(cat, "video_fullscreen_first", vid_fullscreen_first); - - if (force_43 == 0) - config_delete_var(cat, "force_43"); - else - config_set_int(cat, "force_43", force_43); - - if (scale == 1) - config_delete_var(cat, "scale"); - else - config_set_int(cat, "scale", scale); - - if (invert_display == 0) - config_delete_var(cat, "invert_display"); - else - config_set_int(cat, "invert_display", invert_display); - - if (enable_overscan == 0) - config_delete_var(cat, "enable_overscan"); - else - config_set_int(cat, "enable_overscan", enable_overscan); - - if (vid_cga_contrast == 0) - config_delete_var(cat, "vid_cga_contrast"); - else - config_set_int(cat, "vid_cga_contrast", vid_cga_contrast); - - if (vid_grayscale == 0) - config_delete_var(cat, "video_grayscale"); - else - config_set_int(cat, "video_grayscale", vid_grayscale); - - if (vid_graytype == 0) - config_delete_var(cat, "video_graytype"); - else - config_set_int(cat, "video_graytype", vid_graytype); - - if (rctrl_is_lalt == 0) + if (cfg->rctrl_is_lalt == 0) config_delete_var(cat, "rctrl_is_lalt"); - else - config_set_int(cat, "rctrl_is_lalt", rctrl_is_lalt); + else + config_set_int(cat, "rctrl_is_lalt", cfg->rctrl_is_lalt); - if (window_remember) { - config_set_int(cat, "window_remember", window_remember); + if (cfg->vid_resize == 0) + config_delete_var(cat, "vid_resize"); + else + config_set_int(cat, "vid_resize", cfg->vid_resize); - sprintf(temp, "%i, %i, %i, %i", window_w, window_h, window_x, window_y); + str = vidapi_get_internal_name(cfg->vid_api); + if (! strcmp(str, "default")) + config_delete_var(cat, "vid_renderer"); + else + config_set_string(cat, "vid_renderer", str); + + if (cfg->vid_fullscreen_scale == 0) + config_delete_var(cat, "video_fullscreen_scale"); + else + config_set_int(cat, "video_fullscreen_scale", cfg->vid_fullscreen_scale); + + if (cfg->vid_fullscreen_first == 0) + config_delete_var(cat, "video_fullscreen_first"); + else + config_set_int(cat, "video_fullscreen_first", cfg->vid_fullscreen_first); + + if (cfg->force_43 == 0) + config_delete_var(cat, "force_43"); + else + config_set_int(cat, "force_43", cfg->force_43); + + if (cfg->scale == 1) + config_delete_var(cat, "scale"); + else + config_set_int(cat, "scale", cfg->scale); + + if (cfg->invert_display == 0) + config_delete_var(cat, "invert_display"); + else + config_set_int(cat, "invert_display", cfg->invert_display); + + if (cfg->enable_overscan == 0) + config_delete_var(cat, "enable_overscan"); + else + config_set_int(cat, "enable_overscan", cfg->enable_overscan); + + if (cfg->vid_cga_contrast == 0) + config_delete_var(cat, "vid_cga_contrast"); + else + config_set_int(cat, "vid_cga_contrast", cfg->vid_cga_contrast); + + if (cfg->vid_grayscale == 0) + config_delete_var(cat, "video_grayscale"); + else + config_set_int(cat, "video_grayscale", cfg->vid_grayscale); + + if (cfg->vid_graytype == 0) + config_delete_var(cat, "video_graytype"); + else + config_set_int(cat, "video_graytype", cfg->vid_graytype); + + if (cfg->window_remember) { + config_set_int(cat, "window_remember", cfg->window_remember); + + sprintf(temp, "%i, %i, %i, %i", + cfg->win_w, cfg->win_h, cfg->win_x, cfg->win_y); config_set_string(cat, "window_coordinates", temp); } else { config_delete_var(cat, "window_remember"); config_delete_var(cat, "window_coordinates"); } - if (sound_gain != 0) - config_set_int(cat, "sound_gain", sound_gain); - else + if (cfg->sound_gain == 0) config_delete_var(cat, "sound_gain"); - - if (emu_lang_id == 0x0409) - config_delete_var(cat, "language"); - else - config_set_hex16(cat, "language", emu_lang_id); + else + config_set_int(cat, "sound_gain", cfg->sound_gain); delete_section_if_empty(cat); } @@ -388,72 +387,70 @@ save_general(const char *cat) /* Load "Machine" section. */ static void -load_machine(const char *cat) +load_machine(config_t *cfg, const char *cat) { char *p; p = config_get_string(cat, "machine", NULL); if (p != NULL) - machine_type = machine_get_from_internal_name(p); - else - machine_type = -1; + cfg->machine_type = machine_get_from_internal_name(p); + else + cfg->machine_type = -1; if (machine_load() == NULL) - machine_type = -1; + cfg->machine_type = -1; - cpu_manufacturer = config_get_int(cat, "cpu_manufacturer", 0); - cpu_type = config_get_int(cat, "cpu", 0); - cpu_waitstates = config_get_int(cat, "cpu_waitstates", 0); + cfg->cpu_manuf = config_get_int(cat, "cpu_manufacturer", 0); + cfg->cpu_type = config_get_int(cat, "cpu", 0); + cfg->cpu_waitstates = config_get_int(cat, "cpu_waitstates", 0); + cfg->cpu_use_dynarec = !!config_get_int(cat, "cpu_use_dynarec", 0); + cfg->enable_ext_fpu = !!config_get_int(cat, "cpu_enable_fpu", 0); - mem_size = config_get_int(cat, "mem_size", 4096); - mem_size = machine_get_memsize(mem_size); + cfg->mem_size = config_get_int(cat, "mem_size", 4096); + cfg->mem_size = machine_get_memsize(cfg->mem_size); - cpu_use_dynarec = !!config_get_int(cat, "cpu_use_dynarec", 0); - - enable_external_fpu = !!config_get_int(cat, "cpu_enable_fpu", 0); - - time_sync = config_get_int(cat, "enable_sync", -1); - if (time_sync != -1) { + cfg->time_sync = config_get_int(cat, "enable_sync", -1); + if (cfg->time_sync != -1) { /* FIXME: remove this after 12/31/2019 --FvK */ config_delete_var(cat, "enable_sync"); } else - time_sync = config_get_int(cat, "time_sync", TIME_SYNC_DISABLED); + cfg->time_sync = config_get_int(cat, "time_sync", TIME_SYNC_DISABLED); } /* Save "Machine" section. */ static void -save_machine(const char *cat) +save_machine(const config_t *cfg, const char *cat) { config_set_string(cat, "machine", machine_get_internal_name()); - if (cpu_manufacturer == 0) + if (cfg->cpu_manuf == 0) config_delete_var(cat, "cpu_manufacturer"); - else - config_set_int(cat, "cpu_manufacturer", cpu_manufacturer); + else + config_set_int(cat, "cpu_manufacturer", cfg->cpu_manuf); - if (cpu_type == 0) + if (cfg->cpu_type == 0) config_delete_var(cat, "cpu"); - else - config_set_int(cat, "cpu", cpu_type); + else + config_set_int(cat, "cpu", cfg->cpu_type); - if (cpu_waitstates == 0) + if (cfg->cpu_waitstates == 0) config_delete_var(cat, "cpu_waitstates"); - else - config_set_int(cat, "cpu_waitstates", cpu_waitstates); + else + config_set_int(cat, "cpu_waitstates", cfg->cpu_waitstates); - config_set_int(cat, "mem_size", mem_size); + config_set_int(cat, "cpu_use_dynarec", cfg->cpu_use_dynarec); - config_set_int(cat, "cpu_use_dynarec", cpu_use_dynarec); - - if (enable_external_fpu == 0) + if (cfg->enable_ext_fpu == 0) config_delete_var(cat, "cpu_enable_fpu"); - else - config_set_int(cat, "cpu_enable_fpu", enable_external_fpu); + else + config_set_int(cat, "cpu_enable_fpu", cfg->enable_ext_fpu); - if (time_sync == TIME_SYNC_DISABLED) + config_set_int(cat, "mem_size", cfg->mem_size); + + if (cfg->time_sync == TIME_SYNC_DISABLED) config_delete_var(cat, "time_sync"); - else - config_set_int(cat, "time_sync", time_sync); + else + config_set_int(cat, "time_sync", cfg->time_sync); delete_section_if_empty(cat); } @@ -461,13 +458,13 @@ save_machine(const char *cat) /* Load "Video" section. */ static void -load_video(const char *cat) +load_video(config_t *cfg, const char *cat) { char *p; if (machine_get_flags_fixed() & MACHINE_VIDEO) { config_delete_var(cat, "video_card"); - video_card = VID_INTERNAL; + cfg->video_card = VID_INTERNAL; } else { p = config_get_string(cat, "video_card", NULL); if (p == NULL) { @@ -476,23 +473,24 @@ load_video(const char *cat) else p = "none"; } - video_card = video_get_video_from_internal_name(p); + cfg->video_card = video_get_video_from_internal_name(p); } - voodoo_enabled = !!config_get_int(cat, "voodoo", 0); + cfg->voodoo_enabled = !!config_get_int(cat, "voodoo", 0); } /* Save "Video" section. */ static void -save_video(const char *cat) +save_video(const config_t *cfg, const char *cat) { - config_set_string(cat, "video_card", video_get_internal_name(video_card)); + config_set_string(cat, "video_card", + video_get_internal_name(cfg->video_card)); - if (voodoo_enabled == 0) + if (cfg->voodoo_enabled == 0) config_delete_var(cat, "voodoo"); - else - config_set_int(cat, "voodoo", voodoo_enabled); + else + config_set_int(cat, "voodoo", cfg->voodoo_enabled); delete_section_if_empty(cat); } @@ -500,32 +498,32 @@ save_video(const char *cat) /* Load "Input Devices" section. */ static void -load_input(const char *cat) +load_input(config_t *cfg, const char *cat) { char temp[512]; int c, d; char *p; p = config_get_string(cat, "mouse_type", "none"); - mouse_type = mouse_get_from_internal_name(p); + cfg->mouse_type = mouse_get_from_internal_name(p); //FIXME: should be an internal_name string!! - joystick_type = config_get_int(cat, "joystick_type", 0); + cfg->joystick_type = config_get_int(cat, "joystick_type", 0); - for (c = 0; c < gamedev_get_max_joysticks(joystick_type); c++) { + for (c = 0; c < gamedev_get_max_joysticks(cfg->joystick_type); c++) { sprintf(temp, "joystick_%i_nr", c); joystick_state[c].plat_joystick_nr = config_get_int(cat, temp, 0); - +//FIXME: state should be in cfg! if (joystick_state[c].plat_joystick_nr) { - for (d = 0; d < gamedev_get_axis_count(joystick_type); d++) { + for (d = 0; d < gamedev_get_axis_count(cfg->joystick_type); d++) { sprintf(temp, "joystick_%i_axis_%i", c, d); joystick_state[c].axis_mapping[d] = config_get_int(cat, temp, d); } - for (d = 0; d < gamedev_get_button_count(joystick_type); d++) { + for (d = 0; d < gamedev_get_button_count(cfg->joystick_type); d++) { sprintf(temp, "joystick_%i_button_%i", c, d); joystick_state[c].button_mapping[d] = config_get_int(cat, temp, d); } - for (d = 0; d < gamedev_get_pov_count(joystick_type); d++) { + for (d = 0; d < gamedev_get_pov_count(cfg->joystick_type); d++) { sprintf(temp, "joystick_%i_pov_%i", c, d); p = config_get_string(cat, temp, "0, 0"); joystick_state[c].pov_mapping[d][0] = joystick_state[c].pov_mapping[d][1] = 0; @@ -538,30 +536,31 @@ load_input(const char *cat) /* Save "Input Devices" section. */ static void -save_input(const char *cat) +save_input(const config_t *cfg, const char *cat) { char temp[512], tmp2[512]; int c, d; - config_set_string(cat, "mouse_type", mouse_get_internal_name(mouse_type)); + config_set_string(cat, "mouse_type", + mouse_get_internal_name(cfg->mouse_type)); - if (joystick_type != 0) { - config_set_int(cat, "joystick_type", joystick_type); + if (cfg->joystick_type != 0) { + config_set_int(cat, "joystick_type", cfg->joystick_type); - for (c = 0; c < gamedev_get_max_joysticks(joystick_type); c++) { + for (c = 0; c < gamedev_get_max_joysticks(cfg->joystick_type); c++) { sprintf(tmp2, "joystick_%i_nr", c); config_set_int(cat, tmp2, joystick_state[c].plat_joystick_nr); if (joystick_state[c].plat_joystick_nr) { - for (d = 0; d < gamedev_get_axis_count(joystick_type); d++) { + for (d = 0; d < gamedev_get_axis_count(cfg->joystick_type); d++) { sprintf(tmp2, "joystick_%i_axis_%i", c, d); config_set_int(cat, tmp2, joystick_state[c].axis_mapping[d]); } - for (d = 0; d < gamedev_get_button_count(joystick_type); d++) { + for (d = 0; d < gamedev_get_button_count(cfg->joystick_type); d++) { sprintf(tmp2, "joystick_%i_button_%i", c, d); config_set_int(cat, tmp2, joystick_state[c].button_mapping[d]); } - for (d = 0; d < gamedev_get_pov_count(joystick_type); d++) { + for (d = 0; d < gamedev_get_pov_count(cfg->joystick_type); d++) { sprintf(tmp2, "joystick_%i_pov_%i", c, d); sprintf(temp, "%i, %i", joystick_state[c].pov_mapping[d][0], joystick_state[c].pov_mapping[d][1]); config_set_string(cat, tmp2, temp); @@ -596,62 +595,73 @@ save_input(const char *cat) /* Load "Sound" section. */ static void -load_sound(const char *cat) +load_sound(config_t *cfg, const char *cat) { char *p; - p = config_get_string(cat, "sound_card", "none"); - sound_card = sound_card_get_from_internal_name(p); + p = config_get_string(cat, "sound_type", "float"); + if (!strcmp(p, "float") || !strcmp(p, "1")) + cfg->sound_is_float = 1; + else + cfg->sound_is_float = 0; + + if (machine_get_flags_fixed() & MACHINE_SOUND) { + config_delete_var(cat, "sound_card"); + cfg->sound_card = SOUND_INTERNAL; + } else { + p = config_get_string(cat, "sound_card", NULL); + if (p == NULL) { + if (machine_get_flags() & MACHINE_SOUND) + p = "internal"; + else + p = "none"; + } + cfg->sound_card = sound_card_get_from_internal_name(p); + } p = config_get_string(cat, "midi_device", "none"); - midi_device = midi_device_get_from_internal_name(p); + cfg->midi_device = midi_device_get_from_internal_name(p); - mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0); + cfg->mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0); p = config_get_string(cat, "opl_type", "dbopl"); if (!strcmp(p, "nukedopl") || !strcmp(p, "1")) - opl_type = 1; - else - opl_type = 0; - - p = config_get_string(cat, "sound_type", "float"); - if (!strcmp(p, "float") || !strcmp(p, "1")) - sound_is_float = 1; - else - sound_is_float = 0; + cfg->opl_type = 1; + else + cfg->opl_type = 0; } /* Save "Sound" section. */ static void -save_sound(const char *cat) +save_sound(const config_t *cfg, const char *cat) { - if (sound_card == 0) - config_delete_var(cat, "sound_card"); - else - config_set_string(cat, "sound_card", - sound_card_get_internal_name(sound_card)); - - if (!strcmp(midi_device_get_internal_name(midi_device), "none")) - config_delete_var(cat, "midi_device"); - else - config_set_string(cat, "midi_device", - midi_device_get_internal_name(midi_device)); - - if (mpu401_standalone_enable == 0) - config_delete_var(cat, "mpu401_standalone"); - else - config_set_int(cat, "mpu401_standalone", mpu401_standalone_enable); - - if (opl_type == 0) - config_delete_var(cat, "opl_type"); - else - config_set_string(cat, "opl_type", (opl_type == 1) ? "nukedopl" : "dbopl"); - - if (sound_is_float == 1) + if (cfg->sound_is_float == 1) config_delete_var(cat, "sound_type"); - else - config_set_string(cat, "sound_type", (sound_is_float == 1) ? "float" : "int16"); + else + config_set_string(cat, "sound_type", (cfg->sound_is_float == 1) ? "float" : "int16"); + + if (cfg->sound_card == SOUND_NONE) + config_delete_var(cat, "sound_card"); + else + config_set_string(cat, "sound_card", + sound_card_get_internal_name(cfg->sound_card)); + + if (!strcmp(midi_device_get_internal_name(cfg->midi_device), "none")) + config_delete_var(cat, "midi_device"); + else + config_set_string(cat, "midi_device", + midi_device_get_internal_name(cfg->midi_device)); + + if (cfg->mpu401_standalone_enable == 0) + config_delete_var(cat, "mpu401_standalone"); + else + config_set_int(cat, "mpu401_standalone", cfg->mpu401_standalone_enable); + + if (cfg->opl_type == 0) + config_delete_var(cat, "opl_type"); + else + config_set_string(cat, "opl_type", (cfg->opl_type == 1) ? "nukedopl" : "dbopl"); delete_section_if_empty(cat); } @@ -659,14 +669,14 @@ save_sound(const char *cat) /* Load "Network" section. */ static void -load_network(const char *cat) +load_network(config_t *cfg, const char *cat) { char *p; p = config_get_string(cat, "net_type", "none"); - network_type = network_get_from_internal_name(p); + cfg->network_type = network_get_from_internal_name(p); - memset(network_host, '\0', sizeof(network_host)); + memset(cfg->network_host, '\0', sizeof(cfg->network_host)); p = config_get_string(cat, "net_host_device", NULL); if (p == NULL) { p = config_get_string(cat, "net_pcap_device", NULL); @@ -675,48 +685,59 @@ load_network(const char *cat) } if (p != NULL) { if ((network_card_to_id(p) == -1) || (network_host_ndev == 1)) { - if ((network_host_ndev == 1) && strcmp(network_host, "none")) { + if ((network_host_ndev == 1) && strcmp(cfg->network_host, "none")) { ui_msgbox(MBX_ERROR, (wchar_t *)IDS_ERR_PCAP_NO); } else if (network_card_to_id(p) == -1) { ui_msgbox(MBX_ERROR, (wchar_t *)IDS_ERR_PCAP_DEV); } - strcpy(network_host, "none"); + strcpy(cfg->network_host, "none"); } else { - strcpy(network_host, p); + strcpy(cfg->network_host, p); } } else - strcpy(network_host, "none"); + strcpy(cfg->network_host, "none"); - p = config_get_string(cat, "net_card", "none"); - network_card = network_card_get_from_internal_name(p); + if (machine_get_flags_fixed() & MACHINE_NETWORK) { + config_delete_var(cat, "net_card"); + cfg->network_card = NET_CARD_INTERNAL; + } else { + p = config_get_string(cat, "net_card", NULL); + if (p == NULL) { + if (machine_get_flags() & MACHINE_NETWORK) + p = "internal"; + else + p = "none"; + } + cfg->network_card = network_card_get_from_internal_name(p); + } } /* Save "Network" section. */ static void -save_network(const char *cat) +save_network(const config_t *cfg, const char *cat) { - if (network_type == 0) + if (cfg->network_type == NET_NONE) config_delete_var(cat, "net_type"); - else + else config_set_string(cat, "net_type", - network_get_internal_name(network_type)); + network_get_internal_name(cfg->network_type)); - if (network_host[0] != '\0') { - if (! strcmp(network_host, "none")) + if (cfg->network_host[0] != '\0') { + if (! strcmp(cfg->network_host, "none")) config_delete_var(cat, "net_host_device"); - else - config_set_string(cat, "net_host_device", network_host); + else + config_set_string(cat, "net_host_device", cfg->network_host); } else { config_delete_var(cat, "net_host_device"); } - if (network_card == 0) + if (cfg->network_card == 0) config_delete_var(cat, "net_card"); - else + else config_set_string(cat, "net_card", - network_card_get_internal_name(network_card)); + network_card_get_internal_name(cfg->network_card)); delete_section_if_empty(cat); } @@ -724,47 +745,47 @@ save_network(const char *cat) /* Load "Ports" section. */ static void -load_ports(const char *cat) +load_ports(config_t *cfg, const char *cat) { char temp[128]; char *p; int i; sprintf(temp, "game_enabled"); - game_enabled = !!config_get_int(cat, temp, 0); + cfg->game_enabled = !!config_get_int(cat, temp, 0); for (i = 0; i < SERIAL_MAX; i++) { sprintf(temp, "serial%i_enabled", i); - serial_enabled[i] = !!config_get_int(cat, temp, 0); + cfg->serial_enabled[i] = !!config_get_int(cat, temp, 0); } for (i = 0; i < PARALLEL_MAX; i++) { sprintf(temp, "parallel%i_enabled", i); - parallel_enabled[i] = !!config_get_int(cat, temp, 0); + cfg->parallel_enabled[i] = !!config_get_int(cat, temp, 0); sprintf(temp, "parallel%i_device", i); p = (char *)config_get_string(cat, temp, "none"); - parallel_device[i] = parallel_device_get_from_internal_name(p); + cfg->parallel_device[i] = parallel_device_get_from_internal_name(p); } } /* Save "Ports" section. */ static void -save_ports(const char *cat) +save_ports(const config_t *cfg, const char *cat) { char temp[128]; int i; sprintf(temp, "game_enabled"); - if (game_enabled) { + if (cfg->game_enabled) { config_set_int(cat, temp, 1); } else config_delete_var(cat, temp); for (i = 0; i < SERIAL_MAX; i++) { sprintf(temp, "serial%i_enabled", i); - if (serial_enabled[i]) { + if (cfg->serial_enabled[i]) { config_set_int(cat, temp, 1); } else config_delete_var(cat, temp); @@ -772,16 +793,16 @@ save_ports(const char *cat) for (i = 0; i < PARALLEL_MAX; i++) { sprintf(temp, "parallel%i_enabled", i); - if (parallel_enabled[i]) + if (cfg->parallel_enabled[i]) config_set_int(cat, temp, 1); - else + else config_delete_var(cat, temp); sprintf(temp, "parallel%i_device", i); - if (parallel_device[i] != 0) + if (cfg->parallel_device[i] != 0) config_set_string(cat, temp, - parallel_device_get_internal_name(parallel_device[i])); - else + parallel_device_get_internal_name(cfg->parallel_device[i])); + else config_delete_var(cat, temp); } @@ -791,96 +812,117 @@ save_ports(const char *cat) /* Load "Other Peripherals" section. */ static void -load_other(const char *cat) +load_other(config_t *cfg, const char *cat) { char temp[128], *p; int c; - p = config_get_string(cat, "scsi_card", "none"); - scsi_card = scsi_card_get_from_internal_name(p); - - p = config_get_string(cat, "hdc", NULL); - if (p == NULL) { - if (machine_get_flags() & MACHINE_HDC) - p = "internal"; - else - p = "none"; + if (machine_get_flags_fixed() & MACHINE_HDC) { + config_delete_var(cat, "hdc"); + cfg->hdc_type = HDC_INTERNAL; + } else { + p = config_get_string(cat, "hdc", NULL); + if (p == NULL) { + if (machine_get_flags() & MACHINE_HDC) + p = "internal"; + else + p = "none"; + } + cfg->hdc_type = hdc_get_from_internal_name(p); } - hdc_type = hdc_get_from_internal_name(p); - ide_ter_enabled = !!config_get_int(cat, "ide_ter", 0); - ide_qua_enabled = !!config_get_int(cat, "ide_qua", 0); + cfg->ide_ter_enabled = !!config_get_int(cat, "ide_ter", 0); + cfg->ide_qua_enabled = !!config_get_int(cat, "ide_qua", 0); - bugger_enabled = !!config_get_int(cat, "bugger_enabled", 0); + if (machine_get_flags_fixed() & MACHINE_SCSI) { + config_delete_var(cat, "scsi_card"); + cfg->scsi_card = SCSI_INTERNAL; + } else { + p = config_get_string(cat, "scsi_card", "none"); + if (p == NULL) { + if (machine_get_flags() & MACHINE_SCSI) + p = "internal"; + else + p = "none"; + } + cfg->scsi_card = scsi_card_get_from_internal_name(p); + } + + cfg->bugger_enabled = !!config_get_int(cat, "bugger_enabled", 0); for (c = 0; c < ISAMEM_MAX; c++) { sprintf(temp, "isamem%i_type", c); p = config_get_string(cat, temp, "none"); - isamem_type[c] = isamem_get_from_internal_name(p); + cfg->isamem_type[c] = isamem_get_from_internal_name(p); } p = config_get_string(cat, "isartc_type", "none"); - isartc_type = isartc_get_from_internal_name(p); + cfg->isartc_type = isartc_get_from_internal_name(p); #ifdef WALTJE - romdos_enabled = !!config_get_int(cat, "romdos_enabled", 0); + cfg->romdos_enabled = !!config_get_int(cat, "romdos_enabled", 0); #endif } /* Save "Other Peripherals" section. */ static void -save_other(const char *cat) +save_other(const config_t *cfg, const char *cat) { char temp[512]; int c; - if (scsi_card == 0) - config_delete_var(cat, "scsi_card"); - else - config_set_string(cat, "scsi_card", - scsi_card_get_internal_name(scsi_card)); + if (cfg->hdc_type == HDC_NONE) + config_delete_var(cat, "hdc"); + else + config_set_string(cat, "hdc", + hdc_get_internal_name(cfg->hdc_type)); - config_set_string(cat, "hdc", hdc_get_internal_name(hdc_type)); - - if (ide_ter_enabled == 0) + if (cfg->ide_ter_enabled == 0) config_delete_var(cat, "ide_ter"); - else - config_set_int(cat, "ide_ter", ide_ter_enabled); + else + config_set_int(cat, "ide_ter", cfg->ide_ter_enabled); - if (ide_qua_enabled == 0) + if (cfg->ide_qua_enabled == 0) config_delete_var(cat, "ide_qua"); - else - config_set_int(cat, "ide_qua", ide_qua_enabled); + else + config_set_int(cat, "ide_qua", cfg->ide_qua_enabled); - if (bugger_enabled == 0) + if (cfg->scsi_card == SCSI_NONE) + config_delete_var(cat, "scsi_card"); + else + config_set_string(cat, "scsi_card", + scsi_card_get_internal_name(cfg->scsi_card)); + + if (cfg->bugger_enabled == 0) config_delete_var(cat, "bugger_enabled"); - else - config_set_int(cat, "bugger_enabled", bugger_enabled); + else + config_set_int(cat, "bugger_enabled", cfg->bugger_enabled); for (c = 0; c < ISAMEM_MAX; c++) { sprintf(temp, "isamem%i_type", c); - if (isamem_type[c] == 0) + if (cfg->isamem_type[c] == 0) config_delete_var(cat, temp); - else + else config_set_string(cat, temp, - isamem_get_internal_name(isamem_type[c])); + isamem_get_internal_name(cfg->isamem_type[c])); } - if (isartc_type == 0) + if (cfg->isartc_type == 0) config_delete_var(cat, "isartc_type"); - else + else config_set_string(cat, "isartc_type", - isartc_get_internal_name(isartc_type)); + isartc_get_internal_name(cfg->isartc_type)); delete_section_if_empty(cat); } /* Load "Hard Disks" section. */ +//FIXME: hdd[] should be loaded into config_t static void -load_disks(const char *cat) +load_disks(config_t *cfg, const char *cat) { char temp[512], tmp2[512], s[512]; uint32_t max_spt, max_hpc, max_tracks; @@ -1013,7 +1055,7 @@ load_disks(const char *cat) /* Save "Hard Disks" section. */ static void -save_disks(const char *cat) +save_disks(const config_t *cfg, const char *cat) { char temp[128], tmp2[128]; const char *str; @@ -1073,52 +1115,56 @@ save_disks(const char *cat) /* Load "Floppy Drives" section. */ +//FIXME: we should load stuff into config_t ! static void -load_floppy(const char *cat) +load_floppy(config_t *cfg, const char *cat) { char temp[512], *p; wchar_t *wp; int c; for (c = 0; c < FDD_NUM; c++) { - sprintf(temp, "fdd_%02i_type", c+1); + sprintf(temp, "fdd_%i_type", c+1); p = config_get_string(cat, temp, (c < 2) ? "525_2dd" : "none"); fdd_set_type(c, fdd_get_from_internal_name(p)); if (fdd_get_type(c) > 13) fdd_set_type(c, 13); - sprintf(temp, "fdd_%02i_fn", c + 1); + /* Try to make paths relative, and copy to destination. */ + sprintf(temp, "fdd_%i_fn", c + 1); wp = config_get_wstring(cat, temp, L""); - - /* Try to make relative, and copy to destination. */ pc_path(floppyfns[c], sizeof_w(floppyfns[c]), wp); - sprintf(temp, "fdd_%02i_writeprot", c+1); + sprintf(temp, "fdd_%i_writeprot", c+1); ui_writeprot[c] = !!config_get_int(cat, temp, 0); - sprintf(temp, "fdd_%02i_turbo", c + 1); + sprintf(temp, "fdd_%i_turbo", c + 1); fdd_set_turbo(c, !!config_get_int(cat, temp, 0)); - sprintf(temp, "fdd_%02i_check_bpb", c+1); + sprintf(temp, "fdd_%i_check_bpb", c+1); fdd_set_check_bpb(c, !!config_get_int(cat, temp, 1)); - /* Check whether each value is default, if yes, delete it so that only non-default values will later be saved. */ + /* + * Check whether or not each value is default, and if yes, + * delete it so that only non-default values will later be + * saved. + */ if (fdd_get_type(c) == ((c < 2) ? 2 : 0)) { - sprintf(temp, "fdd_%02i_type", c+1); + sprintf(temp, "fdd_%i_type", c+1); config_delete_var(cat, temp); } if (wcslen(floppyfns[c]) == 0) { - sprintf(temp, "fdd_%02i_fn", c+1); + sprintf(temp, "fdd_%i_fn", c+1); config_delete_var(cat, temp); } if (! ui_writeprot[c]) { - sprintf(temp, "fdd_%02i_writeprot", c+1); + sprintf(temp, "fdd_%i_writeprot", c+1); config_delete_var(cat, temp); } if (! fdd_get_turbo(c)) { - sprintf(temp, "fdd_%02i_turbo", c+1); + sprintf(temp, "fdd_%i_turbo", c+1); config_delete_var(cat, temp); } if (! fdd_get_check_bpb(c)) { - sprintf(temp, "fdd_%02i_check_bpb", c+1); + sprintf(temp, "fdd_%i_check_bpb", c+1); config_delete_var(cat, temp); } } @@ -1127,47 +1173,46 @@ load_floppy(const char *cat) /* Save "Floppy Drives" section. */ static void -save_floppy(const char *cat) +save_floppy(const config_t *cfg, const char *cat) { char temp[512]; int c; for (c = 0; c < FDD_NUM; c++) { - sprintf(temp, "fdd_%02i_type", c+1); + sprintf(temp, "fdd_%i_type", c+1); if (fdd_get_type(c) == ((c < 2) ? 2 : 0)) config_delete_var(cat, temp); else config_set_string(cat, temp, fdd_get_internal_name(fdd_get_type(c))); - sprintf(temp, "fdd_%02i_fn", c+1); + sprintf(temp, "fdd_%i_fn", c+1); if (wcslen(floppyfns[c]) == 0) { config_delete_var(cat, temp); ui_writeprot[c] = 0; - sprintf(temp, "fdd_%02i_writeprot", c+1); + sprintf(temp, "fdd_%i_writeprot", c+1); config_delete_var(cat, temp); - } else { + } else config_set_wstring(cat, temp, floppyfns[c]); - } - sprintf(temp, "fdd_%02i_writeprot", c+1); + sprintf(temp, "fdd_%i_writeprot", c+1); if (ui_writeprot[c] == 0) config_delete_var(cat, temp); - else + else config_set_int(cat, temp, ui_writeprot[c]); - sprintf(temp, "fdd_%02i_turbo", c+1); + sprintf(temp, "fdd_%i_turbo", c+1); if (fdd_get_turbo(c) == 0) config_delete_var(cat, temp); - else + else config_set_int(cat, temp, fdd_get_turbo(c)); - sprintf(temp, "fdd_%02i_check_bpb", c+1); + sprintf(temp, "fdd_%i_check_bpb", c+1); if (fdd_get_check_bpb(c) == 1) config_delete_var(cat, temp); - else + else config_set_int(cat, temp, fdd_get_check_bpb(c)); } @@ -1176,8 +1221,9 @@ save_floppy(const char *cat) /* Load "Removable Devices" section. */ +//FIXME: stuff should be loaded into config_t ! static void -load_removable(const char *cat) +load_removable(config_t *cfg, const char *cat) { char temp[512], tmp2[512], *p; char s[512]; @@ -1336,7 +1382,7 @@ load_removable(const char *cat) /* Save "Other Removable Devices" section. */ static void -save_removable(const char *cat) +save_removable(const config_t *cfg, const char *cat) { char temp[512], tmp2[512]; int c; @@ -1437,8 +1483,8 @@ save_removable(const char *cat) static const struct { const char *name; - void (*load)(const char *); - void (*save)(const char *); + void (*load)(config_t *, const char *); + void (*save)(const config_t *, const char *); } categories[] = { { "General", load_general, save_general }, { "Machine", load_machine, save_machine }, @@ -1455,36 +1501,6 @@ static const struct { }; -/* Create a usable default configuration. */ -static void -config_default(void) -{ - int i; - - cpu_manufacturer = 0; - cpu_type = 0; - scale = 1; - video_card = VID_CGA; - vid_api = vidapi_from_internal_name("default");; - time_sync = TIME_SYNC_DISABLED; - joystick_type = 0; - hdc_type = 0; - - for (i = 0; i < SERIAL_MAX; i++) - serial_enabled[i] = 0; - - for (i = 0; i < PARALLEL_MAX; i++) - parallel_enabled[i] = 0; - - fdd_set_type(0, 2); - fdd_set_check_bpb(0, 1); - fdd_set_type(1, 2); - fdd_set_check_bpb(1, 1); - - mem_size = 640; -} - - /* Read and parse the configuration file into memory. */ static int config_read(const wchar_t *fn) @@ -1647,26 +1663,110 @@ config_write(const wchar_t *fn) } +/* Create a usable default configuration. */ +void +config_init(config_t *cfg) +{ + int i; + + cfg->language = 0x0000; /* language ID */ + cfg->rctrl_is_lalt = 0; /* set R-CTRL as L-ALT */ + + cfg->window_remember = 0; /* window size and */ + cfg->win_w = 0; cfg->win_h = 0; /* position info */ + cfg->win_x = 0; cfg->win_y = 0; + + cfg->machine_type = -1; /* current machine ID */ + cfg->cpu_manuf = 0; /* cpu manufacturer */ + cfg->cpu_type = 3; /* cpu type */ + cfg->cpu_use_dynarec = 0, /* cpu uses/needs Dyna */ + cfg->enable_ext_fpu = 0; /* enable external FPU */ + cfg->mem_size = 256; /* memory size */ + cfg->time_sync = TIME_SYNC_DISABLED; /* enable time sync */ + + i = vidapi_from_internal_name("default"); /* video renderer */ + cfg->vid_api = i; /* video renderer */ + + cfg->video_card = VID_CGA, /* graphics/video card */ + cfg->voodoo_enabled = 0; /* video option */ + cfg->scale = 1; /* screen scale factor */ + cfg->vid_resize = 0; /* allow resizing */ + cfg->vid_cga_contrast = 0; /* video */ + cfg->vid_fullscreen = 0; /* video */ + cfg->vid_fullscreen_scale = 0; /* video */ + cfg->vid_fullscreen_first = 0; /* video */ + cfg->vid_grayscale = 0; /* video */ + cfg->vid_graytype = 0; /* video */ + cfg->invert_display = 0; /* invert the display */ + cfg->enable_overscan = 0; /* enable overscans */ + cfg->force_43 = 0; /* video */ + + cfg->mouse_type = MOUSE_NONE; /* selected mouse type */ + cfg->joystick_type = 0; /* joystick type */ + + cfg->sound_is_float = 1; /* sound uses FP values */ + cfg->sound_gain = 0; /* sound volume gain */ + cfg->opl_type = 0; /* sound option */ + cfg->sound_card = SOUND_NONE; /* selected sound card */ + cfg->mpu401_standalone_enable = 0; /* sound option */ + cfg->midi_device = 0; /* selected midi device */ + + cfg->game_enabled = 0; /* enable game port */ + + for (i = 0; i < SERIAL_MAX; i++) /* enable serial ports */ + cfg->serial_enabled[i] = 0; + + for (i = 0; i < PARALLEL_MAX; i++) { /* enable LPT ports */ + cfg->parallel_enabled[i] = 0; + cfg->parallel_device[i] = 0; /* set up LPT devices */ + } + + fdd_set_type(0, 2); + fdd_set_check_bpb(0, 1); + fdd_set_type(1, 2); + fdd_set_check_bpb(1, 1); + + cfg->hdc_type = HDC_NONE; /* HDC type */ + + cfg->scsi_card = SCSI_NONE; /* selected SCSI card */ + + cfg->network_type = NET_NONE; /* network provider type */ + cfg->network_card = NET_CARD_NONE; /* network interface num */ + strcpy(cfg->network_host, ""); /* host network intf */ + + cfg->bugger_enabled = 0; /* enable ISAbugger */ + + for (i = 0; i < ISAMEM_MAX; i++) /* enable ISA mem cards */ + cfg->isamem_type[i] = 0; + cfg->isartc_type = 0; /* enable ISA RTC card */ + +#ifdef WALTJE + cfg->romdos_enabled = 0; /* enable ROM DOS */ +#endif + + /* Mark the configuration as clean. */ + config_changed = 0; +} + + /* Load the specified or a default configuration file. */ int -config_load(void) +config_load(config_t *cfg) { int i = 0; + /* Start with a clean, known configuration. */ + config_init(cfg); + if (config_read(cfg_path)) { /* Load all the categories. */ for (i = 0; categories[i].name != NULL; i++) - categories[i].load(categories[i].name); + categories[i].load(cfg, categories[i].name); /* Mark the configuration as changed. */ config_changed = 1; } else { ERRLOG("CONFIG: file not present or invalid, using defaults!\n"); - - config_default(); - - /* Flag this as an invalid configuration. */ - machine_type = -1; } return(i); @@ -1676,11 +1776,12 @@ config_load(void) void config_save(void) { + config_t *cfg = &config; int i; /* Save all the categories. */ for (i = 0; categories[i].name != NULL; i++) - categories[i].save(categories[i].name); + categories[i].save(cfg, categories[i].name); /* Write it back to file if enabled. */ if (! config_ro) @@ -1712,6 +1813,102 @@ config_dump(void) } +/* Compare two configurations. */ +int +config_compare(const config_t *one, const config_t *two) +{ + int i; +#if 0 + int j; +#endif + + i = memcmp(one, two, sizeof(config_t)); + DEBUG("COMPARE: memcmp=%i\n", i); + +#if 0 + /* + * Compare the data old-style, per variable. + * We keep this until the migration is completed. + */ + + /* Machine category */ + i = 0; + i = i || (one->machine_type != two->machine_type); + i = i || (one->cpu_manuf != two->cpu_manuf); + i = i || (one->cpu_waitstates != two->cpu_waitstates); + i = i || (one->cpu_type != two->cpu_type); + i = i || (one->mem_size != two->mem_size); +#ifdef USE_DYNAREC + i = i || (one->cpu_use_dynarec != two->cpu_use_dynarec); +#endif + i = i || (one->enable_ext_fpu != two->enable_ext_fpu); + i = i || (one->time_sync != two->time_sync); + + /* Video category */ + i = i || (one->video_card != two->video_card); + i = i || (one->voodoo_enabled != two->voodoo_enabled); + + /* Input devices category */ + i = i || (one->mouse_type != two->mouse_type); + i = i || (one->joystick_type != two->joystick_type); + + /* Sound category */ + i = i || (one->sound_card != two->sound_card); + i = i || (one->midi_device != two->midi_device); + i = i || (one->mpu401_standalone_enable != two->mpu401_standalone_enable); + i = i || (one->opl_type != two->opl_type); + i = i || (one->sound_is_float != two->sound_is_float); + + /* Network category */ + i = i || (one->network_type != two->network_type); + i = i || strcmp(one->network_host, two->network_host); + i = i || (one->network_card != two->network_card); + + /* Ports category */ + i = i || (one->game_enabled != two->game_enabled); + for (j = 0; j < SERIAL_MAX; j++) + i = i || (one->serial_enabled[j] != two->serial_enabled[j]); + for (j = 0; j < PARALLEL_MAX; j++) { + i = i || (one->parallel_enabled[j] != two->parallel_enabled[j]); + i = i || (one->parallel_device[j] != two->parallel_device[j]); + } + + /* Peripherals category */ + i = i || (one->scsi_card != two->scsi_card); + i = i || (one->hdc_type != two->hdc_type); + i = i || (one->ide_ter_enabled != two->ide_ter_enabled); + i = i || (one->ide_qua_enabled != two->ide_qua_enabled); + i = i || (one->bugger_enabled != two->bugger_enabled); + i = i || (one->isartc_type != two->isartc_type); + + /* ISA memory boards. */ + for (j = 0; j < ISAMEM_MAX; j++) + i = i || (one->isamem_type[j] != two->isamem_type[j]); + +# if 0 + /* Hard disks category */ + i = i || memcmp(hdd, temp_hdd, HDD_NUM * sizeof(hard_disk_t)); + + /* Floppy drives category */ + for (j = 0; j < FDD_NUM; j++) { + i = i || (temp_fdd_types[j] != fdd_get_type(j)); + i = i || (temp_fdd_turbo[j] != fdd_get_turbo(j)); + i = i || (temp_fdd_check_bpb[j] != fdd_get_check_bpb(j)); + } + + /* Other removable devices category */ + i = i || memcmp(cdrom, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_t)); + i = i || memcmp(zip_drives, temp_zip_drives, ZIP_NUM * sizeof(zip_drive_t)); + + i = i || !!temp_deviceconfig; +# endif + DEBUG("COMPARE: vars=%i\n", i); +#endif + + return(i); +} + + void config_delete_var(const char *cat, const char *name) { diff --git a/src/config.h b/src/config.h index ccb53c2..19dfcbe 100644 --- a/src/config.h +++ b/src/config.h @@ -8,13 +8,13 @@ * * Configuration file handler header. * - * Version: @(#)config.h 1.0.3 2018/05/16 + * Version: @(#)config.h 1.0.4 2019/05/04 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -40,14 +40,115 @@ # define EMU_CONFIG_H +/* Maximum units for certain devices. */ +#define SERIAL_MAX 2 /* two ports supported */ +#define PARALLEL_MAX 3 /* three ports supported */ +#define ISAMEM_MAX 4 /* max #cards in system */ +#define FLOPPY_MAX 4 /* max #drives in system */ +#define DISK_MAX 32 /* max #drives in system */ + + #ifdef __cplusplus extern "C" { #endif -extern int config_load(void); +typedef struct { + int language; /* language ID */ + int rctrl_is_lalt; /* set R-CTRL as L-ALT */ + + int window_remember, /* window size and position */ + win_w, win_h, win_x, win_y; + + int machine_type; /* current machine ID */ + int cpu_manuf, /* cpu manufacturer */ + cpu_type, /* cpu type */ + cpu_use_dynarec, /* cpu uses/needs Dyna */ + cpu_waitstates, + enable_ext_fpu; /* enable external FPU */ + + int mem_size; /* memory size */ + + int time_sync; /* enable time sync */ + + int vid_api; /* video renderer */ + + int video_card, /* graphics/video card */ + voodoo_enabled; /* video option */ + + int scale, /* screen scale factor */ + vid_resize, /* allow resizing */ + vid_cga_contrast, /* video */ + vid_fullscreen, /* video */ + vid_fullscreen_scale, /* video */ + vid_fullscreen_first, /* video */ + vid_grayscale, /* video */ + vid_graytype, /* video */ + invert_display, /* invert the display */ + enable_overscan, /* enable overscans */ + force_43; /* video */ + + int mouse_type; /* selected mouse type */ + int joystick_type; /* joystick type */ + + int sound_is_float, /* sound uses FP values */ + sound_gain, /* sound volume gain */ + opl_type, /* sound option */ + sound_card, /* selected sound card */ + mpu401_standalone_enable, /* sound option */ + midi_device; /* selected midi device */ + + int game_enabled, /* enable game port */ + serial_enabled[SERIAL_MAX], /* enable serial ports */ + parallel_enabled[PARALLEL_MAX], /* enable LPT ports */ + parallel_device[PARALLEL_MAX]; /* set up LPT devices */ + + struct { + int type; /* drive type */ + int turbo; /* drive in turbo mode */ + int ckbpb; /* have to check bpb */ + int wp; /* drive is write-protected */ + wchar_t path[512]; /* path of mounted image */ + } floppy[FLOPPY_MAX]; + + // FIXME: HDD + + // FIXME: CDROM + + // FIXME: ZIP + + int hdc_type, /* HDC type */ + ide_ter_enabled, + ide_qua_enabled; + + int scsi_card; /* selected SCSI card */ + + int network_type; /* net provider type */ + int network_card; /* net interface num */ + char network_host[128]; /* host network intf */ + + int bugger_enabled; /* enable ISAbugger */ + + int isamem_type[ISAMEM_MAX]; /* enable ISA mem cards */ + + int isartc_type; /* enable ISA RTC card */ + +#ifdef WALTJE + int romdos_enabled; /* enable ROM DOS */ +#endif +} config_t; + + +/* Global variables. */ +extern config_t config; + + +/* Functions. */ +extern void config_init(config_t *); +extern int config_load(config_t *); extern void config_save(void); extern void config_write(const wchar_t *fn); extern void config_dump(void); +extern int config_compare(const config_t *one, const config_t *two); extern void config_delete_var(const char *cat, const char *name); extern int config_get_int(const char *cat, const char *name, int def); diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 0880849..7210472 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -8,7 +8,7 @@ * * CPU type handler. * - * Version: @(#)cpu.c 1.0.12 2019/04/21 + * Version: @(#)cpu.c 1.0.13 2019/05/03 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -114,6 +114,8 @@ const OpFn *x86_dynarec_opcodes_REPNE; #endif +int cpu_manuf; +int cpu_dynarec; int cpu_busspeed; int cpu_16bitbus; int isa_cycles; @@ -124,7 +126,6 @@ int cpu_cycles_read, cpu_cycles_read_l, cpu_cycles_write, cpu_cycles_write_l; int cpu_prefetch_cycles, cpu_prefetch_width, cpu_mem_prefetch_cycles, cpu_rom_prefetch_cycles; -int cpu_waitstates; int cpu_cache_int_enabled, cpu_cache_ext_enabled; int is186, /* 80186 */ @@ -196,7 +197,9 @@ int timing_misaligned; static const CPU *cpu_list, *cpu = NULL; static int cpu_turbo = -1, - cpu_effective = -1; + cpu_effective = -1, + cpu_waitstates, + cpu_extfpu; #if defined(DEV_BRANCH) && defined(USE_AMD_K) /* Variables for the AMD "K" processors. */ @@ -242,7 +245,7 @@ cpu_activate(void) is_pentium = (cpu->type >= CPU_WINCHIP); hasfpu = (cpu->type >= CPU_i486DX) || (cpu->type == CPU_RAPIDCAD); DEBUG("CPU: manuf=%i model=%i cpuid=%08lx\n", - cpu_manufacturer, cpu_effective, CPUID); + cpu_manuf, cpu_effective, CPUID); DEBUG(" 8086=%i nec=%i 186=%i 286=%i 386=%i rcad=%i cyrix=%i 486=%i pent=%i\n", is8086,is_nec,is186,is286,is386,is_rapidcad,is_cyrix,is486,is_pentium); DEBUG(" hasfpu=%i\n", hasfpu); @@ -261,7 +264,7 @@ cpu_activate(void) if ((cpu->type == CPU_286) || (cpu->type == CPU_386SX) || (cpu->type == CPU_386DX) || (cpu->type == CPU_i486SX)) { - if (enable_external_fpu) + if (cpu_extfpu) hasfpu = 1; } @@ -390,7 +393,7 @@ cpu_activate(void) #else x86_setopcodes(ops_286, ops_286_0f); #endif - if (enable_external_fpu) { + if (cpu_extfpu) { #ifdef USE_DYNAREC x86_dynarec_opcodes_d9_a16 = dynarec_ops_fpu_287_d9_a16; x86_dynarec_opcodes_d9_a32 = dynarec_ops_fpu_287_d9_a32; @@ -1303,13 +1306,16 @@ cpu_activate(void) * In the future, this will be changed. */ void -cpu_set_type(const CPU *list, int type) +cpu_set_type(const CPU *list, int manuf, int type, int fpu, int dyna) { if (list == NULL) { fatal("CPU: invalid CPU list, aborting!\n"); /*NOTREACHED*/ } cpu_list = list; + cpu_manuf = manuf; + cpu_extfpu = fpu; + cpu_dynarec = dyna; /* The 'turbo' speed is the one we got called with. */ cpu_turbo = type; diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 0df5c5e..e5792c3 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -8,7 +8,7 @@ * * Definitions for the CPU module. * - * Version: @(#)cpu.h 1.0.11 2019/04/21 + * Version: @(#)cpu.h 1.0.12 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -330,6 +330,8 @@ COMPILE_TIME_ASSERT(sizeof(cpu_state) <= 128) /* Global variables. */ +extern int cpu_manuf; /* cpu manufacturer */ +extern int cpu_dynarec; /* dynamic recompiler enabled */ extern int cpu_busspeed; extern int cpu_16bitbus; extern int xt_cpu_multi; @@ -405,7 +407,6 @@ extern int cpu_cycles_read, cpu_cycles_read_l, extern int cpu_prefetch_cycles, cpu_prefetch_width, cpu_mem_prefetch_cycles, cpu_rom_prefetch_cycles; extern int cpu_cache_int_enabled, cpu_cache_ext_enabled; -extern int cpu_waitstates; extern int timing_rr; extern int timing_mr, timing_mrl; @@ -427,7 +428,7 @@ extern uint8_t cyrix_read(uint16_t addr, void *priv); extern void loadseg(uint16_t seg, x86seg *s); extern void loadcs(uint16_t seg); -extern void cpu_set_type(const CPU *list, int type); +extern void cpu_set_type(const CPU *list,int manuf,int type,int fpu,int dyna); extern int cpu_get_type(void); extern const char *cpu_get_name(void); extern int cpu_set_speed(int new_speed); diff --git a/src/cpu/x86_ops_bcd.h b/src/cpu/x86_ops_bcd.h index e24a78b..b41213f 100644 --- a/src/cpu/x86_ops_bcd.h +++ b/src/cpu/x86_ops_bcd.h @@ -8,12 +8,12 @@ * * Miscellaneous x86 CPU Instructions. * - * Version: @(#)x86_ops_bcd.h 1.0.1 2018/02/14 + * Version: @(#)x86_ops_bcd.h 1.0.2 2019/05/03 * * Authors: Sarah Walker, * Miran Grca, * - * Copyright 2008-2018 Sarah Walker. + * Copyright 2008-2019 Sarah Walker. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -55,7 +55,7 @@ static int opAAA(uint32_t fetchdat) static int opAAD(uint32_t fetchdat) { int base = getbytef(); - if (cpu_manufacturer != MANU_INTEL) base = 10; + if (cpu_manuf != MANU_INTEL) base = 10; AL = (AH * base) + AL; AH = 0; setznp16(AX); @@ -67,7 +67,7 @@ static int opAAD(uint32_t fetchdat) static int opAAM(uint32_t fetchdat) { int base = getbytef(); - if (!base || cpu_manufacturer != MANU_INTEL) base = 10; + if (!base || cpu_manuf != MANU_INTEL) base = 10; AH = AL / base; AL %= base; setznp16(AX); diff --git a/src/cpu/x86_ops_rep.h b/src/cpu/x86_ops_rep.h index 98e49d3..eb7ec68 100644 --- a/src/cpu/x86_ops_rep.h +++ b/src/cpu/x86_ops_rep.h @@ -8,12 +8,12 @@ * * Miscellaneous x86 CPU Instructions. * - * Version: @(#)x86_ops_rep.h 1.0.2 2018/05/09 + * Version: @(#)x86_ops_rep.h 1.0.3 2019/05/03 * * Authors: Sarah Walker, * Miran Grca, * - * Copyright 2008-2018 Sarah Walker. + * Copyright 2008-2019 Sarah Walker. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -204,7 +204,7 @@ static int opREP_OUTSL_ ## size(uint32_t fetchdat) static int opREP_MOVSB_ ## size(uint32_t fetchdat) \ { \ int reads = 0, writes = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -237,7 +237,7 @@ static int opREP_MOVSB_ ## size(uint32_t fetchdat) static int opREP_MOVSW_ ## size(uint32_t fetchdat) \ { \ int reads = 0, writes = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -270,7 +270,7 @@ static int opREP_MOVSW_ ## size(uint32_t fetchdat) static int opREP_MOVSL_ ## size(uint32_t fetchdat) \ { \ int reads = 0, writes = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -305,7 +305,7 @@ static int opREP_MOVSL_ ## size(uint32_t fetchdat) static int opREP_STOSB_ ## size(uint32_t fetchdat) \ { \ int writes = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -333,7 +333,7 @@ static int opREP_STOSB_ ## size(uint32_t fetchdat) static int opREP_STOSW_ ## size(uint32_t fetchdat) \ { \ int writes = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -361,7 +361,7 @@ static int opREP_STOSW_ ## size(uint32_t fetchdat) static int opREP_STOSL_ ## size(uint32_t fetchdat) \ { \ int writes = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -390,7 +390,7 @@ static int opREP_STOSL_ ## size(uint32_t fetchdat) static int opREP_LODSB_ ## size(uint32_t fetchdat) \ { \ int reads = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -417,7 +417,7 @@ static int opREP_LODSB_ ## size(uint32_t fetchdat) static int opREP_LODSW_ ## size(uint32_t fetchdat) \ { \ int reads = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -444,7 +444,7 @@ static int opREP_LODSW_ ## size(uint32_t fetchdat) static int opREP_LODSL_ ## size(uint32_t fetchdat) \ { \ int reads = 0, total_cycles = 0; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ while (CNT_REG > 0) \ @@ -556,7 +556,7 @@ static int opREP_CMPSL_ ## size(uint32_t fetchdat) static int opREP_SCASB_ ## size(uint32_t fetchdat) \ { \ int reads = 0, total_cycles = 0, tempz; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ tempz = FV; \ @@ -587,7 +587,7 @@ static int opREP_SCASB_ ## size(uint32_t fetchdat) static int opREP_SCASW_ ## size(uint32_t fetchdat) \ { \ int reads = 0, total_cycles = 0, tempz; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ tempz = FV; \ @@ -618,7 +618,7 @@ static int opREP_SCASW_ ## size(uint32_t fetchdat) static int opREP_SCASL_ ## size(uint32_t fetchdat) \ { \ int reads = 0, total_cycles = 0, tempz; \ - int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \ + int cycles_end = cycles - ((is386 && cpu_dynarec) ? 1000 : 100); \ if (trap) \ cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \ tempz = FV; \ diff --git a/src/devices/chipsets/scat.c b/src/devices/chipsets/scat.c index 455e686..4da95c8 100644 --- a/src/devices/chipsets/scat.c +++ b/src/devices/chipsets/scat.c @@ -8,7 +8,7 @@ * * Implementation of the C&T 82C235 ("SCAT") chipset. * - * Version: @(#)scat.c 1.0.16 2019/04/20 + * Version: @(#)scat.c 1.0.17 2019/05/03 * * Authors: Fred N. van Kempen, * Original by GreatPsycho for PCem. @@ -41,6 +41,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../cpu/cpu.h" #include "../../cpu/x86.h" #include "../../io.h" @@ -1087,7 +1088,7 @@ scat_write(uint16_t port, uint8_t val, void *priv) map_update = 1; if ((dev->regs[SCAT_VERSION] & 0xf0) == 0) { - cpu_waitstates = (val & 0x70) == 0 ? 1 : 2; + config.cpu_waitstates = (val & 0x70) == 0 ? 1 : 2; cpu_update_waitstates(); } @@ -1258,7 +1259,7 @@ scat_read(uint16_t port, void *priv) case SCAT_DRAM_CONFIGURATION: if ((dev->regs[SCAT_VERSION] & 0xf0) == 0) - ret = (dev->regs[dev->indx] & 0x8f) | (cpu_waitstates == 1 ? 0 : 0x10); + ret = (dev->regs[dev->indx] & 0x8f) | (config.cpu_waitstates == 1 ? 0 : 0x10); else ret = dev->regs[dev->indx]; break; @@ -1467,7 +1468,7 @@ scat_init(const device_t *info, UNUSED(void *parent)) } dev->regs[SCAT_CLOCK_CONTROL] = 2; dev->regs[SCAT_PERIPHERAL_CONTROL] = 0x80; - dev->regs[SCAT_DRAM_CONFIGURATION] = cpu_waitstates == 1 ? 2 : 0x12; + dev->regs[SCAT_DRAM_CONFIGURATION] = config.cpu_waitstates == 1 ? 2 : 0x12; } dev->regs[SCAT_DMA_WAIT_STATE_CONTROL] = 0; dev->regs[SCAT_MISCELLANEOUS_STATUS] = 0x37; diff --git a/src/devices/disk/hdc.c b/src/devices/disk/hdc.c index b0db80f..d56a7bf 100644 --- a/src/devices/disk/hdc.c +++ b/src/devices/disk/hdc.c @@ -8,7 +8,7 @@ * * Common code to handle all sorts of disk controllers. * - * Version: @(#)hdc.c 1.0.19 2019/04/29 + * Version: @(#)hdc.c 1.0.20 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,7 @@ #define HAVE_STDARG_H #define dbglog hdc_log #include "../../emu.h" +#include "../../config.h" #include "../../machines/machine.h" #include "../../device.h" #include "hdc.h" @@ -57,7 +58,7 @@ int hdc_do_log = ENABLE_HDC_LOG; static const struct { const char *internal_name; const device_t *device; -} controllers[] = { +} devices[] = { { "none", NULL }, { "internal", NULL }, @@ -129,16 +130,17 @@ void hdc_reset(void) { INFO("HDC: reset(current=%d, internal=%d)\n", - hdc_type, !!(machine_get_flags() & MACHINE_HDC)); + config.hdc_type, !!(machine_get_flags() & MACHINE_HDC)); - /* If we have a valid controller, add its device. */ - if (controllers[hdc_type].device != NULL) - device_add(controllers[hdc_type].device); + /* If we have a valid device, add it. */ + if (devices[config.hdc_type].device != NULL) + device_add(devices[config.hdc_type].device); /* Now, add the tertiary and/or quaternary IDE controllers. */ - if (ide_ter_enabled) + if (config.ide_ter_enabled) device_add(&ide_ter_device); - if (ide_qua_enabled) + + if (config.ide_qua_enabled) device_add(&ide_qua_device); } @@ -146,8 +148,8 @@ hdc_reset(void) const char * hdc_get_name(int hdc) { - if (controllers[hdc].device != NULL) - return(controllers[hdc].device->name); + if (devices[hdc].device != NULL) + return(devices[hdc].device->name); return(NULL); } @@ -156,20 +158,18 @@ hdc_get_name(int hdc) const char * hdc_get_internal_name(int hdc) { - return(controllers[hdc].internal_name); + return(devices[hdc].internal_name); } int hdc_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (controllers[c].internal_name != NULL) { - if (! strcmp(controllers[c].internal_name, s)) + for (c = 0; devices[c].internal_name != NULL; c++) + if (! strcmp(devices[c].internal_name, s)) return(c); - c++; - } /* Not found. */ return(0); @@ -179,7 +179,7 @@ hdc_get_from_internal_name(const char *s) const device_t * hdc_get_device(int hdc) { - return(controllers[hdc].device); + return(devices[hdc].device); } @@ -199,8 +199,8 @@ hdc_has_config(int hdc) int hdc_get_flags(int hdc) { - if (controllers[hdc].device != NULL) - return(controllers[hdc].device->flags); + if (devices[hdc].device != NULL) + return(devices[hdc].device->flags); return(0); } @@ -209,5 +209,5 @@ hdc_get_flags(int hdc) int hdc_available(int hdc) { - return(device_available(controllers[hdc].device)); + return(device_available(devices[hdc].device)); } diff --git a/src/devices/disk/hdc_ide.h b/src/devices/disk/hdc_ide.h index e1d346c..fcbf7c1 100644 --- a/src/devices/disk/hdc_ide.h +++ b/src/devices/disk/hdc_ide.h @@ -8,13 +8,13 @@ * * Definitions for the IDE module. * - * Version: @(#)hdc_ide.h 1.0.11 2018/10/14 + * Version: @(#)hdc_ide.h 1.0.12 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -118,7 +118,6 @@ typedef struct { extern int ideboard; -extern int ide_ter_enabled, ide_qua_enabled; extern ide_t *ide_drives[IDE_NUM+XTIDE_NUM]; extern int64_t idecallback[5]; diff --git a/src/devices/floppy/fdd.c b/src/devices/floppy/fdd.c index a38c111..d3980ff 100644 --- a/src/devices/floppy/fdd.c +++ b/src/devices/floppy/fdd.c @@ -8,7 +8,7 @@ * * Implementation of the floppy drive emulation. * - * Version: @(#)fdd.c 1.0.19 2019/04/25 + * Version: @(#)fdd.c 1.0.20 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -58,9 +58,23 @@ #include "fdc.h" +typedef struct { + int8_t drive; + int8_t type; + int8_t turbo; + int8_t check_bpb; + + int track; + int densel; + int head; +} fdd_t; + + /* FIXME: these should be combined. */ DRIVE drives[FDD_NUM]; wchar_t floppyfns[4][512]; +fdd_t fdd[FDD_NUM]; +int ui_writeprot[FDD_NUM] = {0, 0, 0, 0}; int fdd_cur_track[FDD_NUM]; int writeprot[FDD_NUM], fwriteprot[FDD_NUM]; int64_t fdd_poll_time[FDD_NUM] = { 16LL, 16LL, 16LL, 16LL }; @@ -68,6 +82,7 @@ int drive_type[FDD_NUM]; int drive_empty[FDD_NUM] = {1, 1, 1, 1}; int fdd_changed[FDD_NUM]; int64_t motoron[FDD_NUM]; +int oldtrack[FDD_NUM] = {0, 0, 0, 0}; d86f_handler_t d86f_handler[FDD_NUM]; int defaultwriteprot = 0; @@ -75,7 +90,6 @@ int curdrive = 0; int motorspin; int fdc_indexcount = 52; int fdd_notfound = 0; -int oldtrack[FDD_NUM] = {0, 0, 0, 0}; #ifdef ENABLE_FDD_LOG int fdd_do_log = ENABLE_FDD_LOG; #endif @@ -129,20 +143,6 @@ static const struct { static int driveloaders[4]; -typedef struct { - int type; - int track; - int densel; - int head; - int turbo; - int check_bpb; -} fdd_t; - - -fdd_t fdd[FDD_NUM]; -int ui_writeprot[FDD_NUM] = {0, 0, 0, 0}; - - /* Flags: Bit 0: 300 rpm supported; Bit 1: 360 rpm supported; @@ -170,56 +170,78 @@ int ui_writeprot[FDD_NUM] = {0, 0, 0, 0}; static const struct { + const char *internal_name; + const char *name; int max_track; int flags; - const char *name; - const char *internal_name; } drive_types[] = { - { /*None*/ - 0, 0, "None", "none" - }, - { /*5.25" 1DD*/ - 43, FLAG_RPM_300 | FLAG_525 | FLAG_HOLE0, "5.25\" 160/180K", "525_1dd" - }, - { /*5.25" DD*/ - 43, FLAG_RPM_300 | FLAG_525 | FLAG_DS | FLAG_HOLE0, "5.25\" 320/360K", "525_2dd" - }, - { /*5.25" QD*/ - 86, FLAG_RPM_300 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | FLAG_DOUBLE_STEP, "5.25\" 720K", "525_2qd" - }, - { /*5.25" HD PS/2*/ - 86, FLAG_RPM_360 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_DOUBLE_STEP | FLAG_INVERT_DENSEL | FLAG_PS2, "5.25\" 1.2M PS/2", "525_2hd_ps2" - }, - { /*5.25" HD*/ - 86, FLAG_RPM_360 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_DOUBLE_STEP, "5.25\" 1.2M", "525_2hd" - }, - { /*5.25" HD Dual RPM*/ - 86, FLAG_RPM_300 | FLAG_RPM_360 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_DOUBLE_STEP, "5.25\" 1.2M 300/360 RPM", "525_2hd_dualrpm" - }, - { /*3.5" 1DD*/ - 86, FLAG_RPM_300 | FLAG_HOLE0 | FLAG_DOUBLE_STEP, "3.5\" 360K", "35_1dd" - }, - { /*3.5" DD*/ - 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_DOUBLE_STEP, "3.5\" 720K", "35_2dd" - }, - { /*3.5" HD PS/2*/ - 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_DOUBLE_STEP | FLAG_INVERT_DENSEL | FLAG_PS2, "3.5\" 1.44M PS/2", "35_2hd_ps2" - }, - { /*3.5" HD*/ - 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_DOUBLE_STEP, "3.5\" 1.44M", "35_2hd" - }, - { /*3.5" HD PC-98*/ - 86, FLAG_RPM_300 | FLAG_RPM_360 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_DOUBLE_STEP | FLAG_INVERT_DENSEL, "3.5\" 1.25M PC-98", "35_2hd_nec" - }, - { /*3.5" HD 3-Mode*/ - 86, FLAG_RPM_300 | FLAG_RPM_360 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_DOUBLE_STEP, "3.5\" 1.44M 300/360 RPM", "35_2hd_3mode" - }, - { /*3.5" ED*/ - 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | FLAG_HOLE2 | FLAG_DOUBLE_STEP, "3.5\" 2.88M", "35_2ed" - }, - { /*End of list*/ - -1, -1, NULL, NULL - } + { + "none", "None", + 0, 0 + }, + { + "525_1dd", "5.25\" 160/180K", + 43, FLAG_RPM_300 | FLAG_525 | FLAG_HOLE0 + }, + { + "525_2dd", "5.25\" 320/360K", + 43, FLAG_RPM_300 | FLAG_525 | FLAG_DS | FLAG_HOLE0 + }, + { + "525_2qd", "5.25\" 720K", + 86, FLAG_RPM_300 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | FLAG_DOUBLE_STEP + }, + { + "525_2hd_ps2", "5.25\" 1.2M PS/2", + 86, FLAG_RPM_360 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | \ + FLAG_DOUBLE_STEP | FLAG_INVERT_DENSEL | FLAG_PS2 + }, + { + "525_2hd", "5.25\" 1.2M", + 86, FLAG_RPM_360 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | \ + FLAG_DOUBLE_STEP + }, + { + "525_2hd_dualrpm", "5.25\" 1.2M 300/360 RPM", + 86, FLAG_RPM_300 | FLAG_RPM_360 | FLAG_525 | FLAG_DS | FLAG_HOLE0 | \ + FLAG_HOLE1 | FLAG_DOUBLE_STEP + }, + { + "35_1dd", "3.5\" 360K", + 86, FLAG_RPM_300 | FLAG_HOLE0 | FLAG_DOUBLE_STEP + }, + { + "35_2dd", "3.5\" 720K", + 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_DOUBLE_STEP + }, + { + "35_2hd_ps2", "3.5\" 1.44M PS/2", + 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | \ + FLAG_DOUBLE_STEP | FLAG_INVERT_DENSEL | FLAG_PS2 + }, + { + "35_2hd", "3.5\" 1.44M", + 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | \ + FLAG_DOUBLE_STEP + }, + { + "35_2hd_nec", "3.5\" 1.25M PC-98", + 86, FLAG_RPM_300 | FLAG_RPM_360 | FLAG_DS | FLAG_HOLE0 | \ + FLAG_HOLE1 | FLAG_DOUBLE_STEP | FLAG_INVERT_DENSEL + }, + { + "35_2hd_3mode", "3.5\" 1.44M 300/360 RPM", + 86, FLAG_RPM_300 | FLAG_RPM_360 | FLAG_DS | FLAG_HOLE0 | \ + FLAG_HOLE1 | FLAG_DOUBLE_STEP + }, + { + "35_2ed", "3.5\" 2.88M", + 86, FLAG_RPM_300 | FLAG_DS | FLAG_HOLE0 | FLAG_HOLE1 | \ + FLAG_HOLE2 | FLAG_DOUBLE_STEP + }, + { + NULL + } }; @@ -257,13 +279,11 @@ fdd_get_internal_name(int type) int fdd_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (drive_types[c].internal_name != NULL) { + for (c = 0; drive_types[c].internal_name != NULL; c++) if (! strcmp(drive_types[c].internal_name, s)) return c; - c++; - } /* Not found. */ return 0; @@ -508,7 +528,7 @@ fdd_load(int drive, const wchar_t *fn) wchar_t *p; FILE *f; - DEBUG("FDD: loading drive %d with '%ls'\n", drive, fn); + DEBUG("FDD: loading drive %i with '%ls'\n", drive, fn); if (!fn) return(0); p = plat_get_extension(fn); @@ -626,8 +646,10 @@ fdd_real_period(int drive) void fdd_poll(int drive) { - if (drive >= FDD_NUM) - fatal("Attempting to poll floppy drive %i that is not supposed to be there\n", drive); + if (drive >= FDD_NUM) { + ERRLOG("FDD: polling impossible drive %i !\n", drive); + return; + } fdd_poll_time[drive] += (int64_t) fdd_real_period(drive); @@ -670,6 +692,21 @@ fdd_poll_3(void *priv) } +void +fdd_reset(void) +{ + INFO("FDD: reset\n"); + + curdrive = 0; + fdd_period = 32; + + timer_add(fdd_poll_0, NULL, &fdd_poll_time[0], &motoron[0]); + timer_add(fdd_poll_1, NULL, &fdd_poll_time[1], &motoron[1]); + timer_add(fdd_poll_2, NULL, &fdd_poll_time[2], &motoron[2]); + timer_add(fdd_poll_3, NULL, &fdd_poll_time[3], &motoron[3]); +} + + int fdd_get_bitcell_period(int rate) { @@ -732,19 +769,6 @@ fdd_set_rate(int drive, int drvden, int rate) } -void -fdd_reset(void) -{ - curdrive = 0; - fdd_period = 32; - - timer_add(fdd_poll_0, NULL, &fdd_poll_time[0], &motoron[0]); - timer_add(fdd_poll_1, NULL, &fdd_poll_time[1], &motoron[1]); - timer_add(fdd_poll_2, NULL, &fdd_poll_time[2], &motoron[2]); - timer_add(fdd_poll_3, NULL, &fdd_poll_time[3], &motoron[3]); -} - - void fdd_readsector(int drive, int sector, int track, int side, int density, int sector_size) { diff --git a/src/devices/floppy/new/fdd_mfm.c b/src/devices/floppy/new/fdd_mfm.c deleted file mode 100644 index 5886530..0000000 --- a/src/devices/floppy/new/fdd_mfm.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Implementation of the HxC MFM image format. - * - * Version: @(#)fdd_mfm.c 1.0.1 2019/03/02 - * - * Authors: Miran Grca, - * - * Copyright 2018,2019 Miran Grca. - */ -#include -#include -#include -#include -#include -#include -#include -#define HAVE_STDARG_H -#include "../86box.h" -#include "../plat.h" -#include "fdd.h" -#include "fdd_86f.h" -#include "fdd_img.h" -#include "fdd_mfm.h" -#include "fdc.h" - - -#pragma pack(push,1) -typedef struct { - uint8_t hdr_name[7]; - - uint16_t tracks_no; - uint8_t sides_no; - - uint16_t rpm; - uint16_t bit_rate; - uint8_t if_type; - - uint32_t track_list_offset; -} mfm_header_t; - -typedef struct { - uint16_t track_no; - uint8_t side_no; - uint32_t track_size; - uint32_t track_offset; -} mfm_track_t; - -typedef struct { - uint16_t track_no; - uint8_t side_no; - uint16_t rpm; - uint16_t bit_rate; - uint32_t track_size; - uint32_t track_offset; -} mfm_adv_track_t; -#pragma pack(pop) - -typedef struct { - FILE *f; - - mfm_header_t hdr; - mfm_track_t *tracks; - mfm_adv_track_t *adv_tracks; - - uint8_t disk_flags, pad; - uint8_t side_flags[2]; - - int br_rounded, rpm_rounded, - total_tracks, cur_track; - - uint8_t track_data[2][256*1024]; -} mfm_t; - - -static mfm_t *mfm[FDD_NUM]; -static fdc_t *mfm_fdc; - - -#ifdef ENABLE_MFM_LOG -int mfm_do_log = ENABLE_MFM_LOG; - - -static void -mfm_log(const char *fmt, ...) -{ - va_list ap; - - if (mfm_do_log) - { - va_start(ap, fmt); - pclog_ex(fmt, ap); - va_end(ap); - } -} -#else -#define mfm_log(fmt, ...) -#endif - - -static int -get_track_index(int drive, int side, int track) -{ - mfm_t *dev = mfm[drive]; - int i, ret = -1; - - for (i = 0; i < dev->total_tracks; i++) { - if ((dev->tracks[i].track_no == track) && - (dev->tracks[i].side_no == side)) { - ret = i; - break; - } - } - - return ret; -} - - -static int -get_adv_track_index(int drive, int side, int track) -{ - mfm_t *dev = mfm[drive]; - int i, ret = -1; - - for (i = 0; i < dev->total_tracks; i++) { - if ((dev->adv_tracks[i].track_no == track) && - (dev->adv_tracks[i].side_no == side)) { - ret = i; - break; - } - } - - return ret; -} - - -static void -get_adv_track_bitrate(int drive, int side, int track, int *br, int *rpm) -{ - mfm_t *dev = mfm[drive]; - int track_index; - double dbr; - - track_index = get_adv_track_index(drive, side, track); - - if (track_index == -1) { - *br = 250; - *rpm = 300; - } else { - dbr = round(((double) dev->adv_tracks[track_index].bit_rate) / 50.0) * 50.0; - *br = ((int) dbr); - dbr = round(((double) dev->adv_tracks[track_index].rpm) / 60.0) * 60.0; - *rpm = ((int) dbr); - } -} - - -static void -set_disk_flags(int drive) -{ - int br = 250, rpm = 300; - mfm_t *dev = mfm[drive]; - uint16_t temp_disk_flags = 0x1080; /* We ALWAYS claim to have extra bit cells, even if the actual amount is 0; - Bit 12 = 1, bits 6, 5 = 0 - extra bit cells field specifies the entire - amount of bit cells per track. */ - - /* If this is the modified MFM format, get bit rate (and RPM) from track 0 instead. */ - if (dev->hdr.if_type & 0x80) - get_adv_track_bitrate(drive, 0, 0, &br, &rpm); - else { - br = dev->br_rounded; - rpm = dev->rpm_rounded; - } - - switch (br) { - case 500: - temp_disk_flags |= 2; - break; - - case 300: - case 250: - default: - temp_disk_flags |= 0; - break; - - case 1000: - temp_disk_flags |= 4; - break; - } - - if (dev->hdr.sides_no == 2) - temp_disk_flags |= 8; - - dev->disk_flags = temp_disk_flags; -} - - -static uint16_t -disk_flags(int drive) -{ - mfm_t *dev = mfm[drive]; - - return dev->disk_flags; -} - - -static void -set_side_flags(int drive, int side) -{ - mfm_t *dev = mfm[drive]; - uint16_t temp_side_flags = 0; - int br = 250, rpm = 300; - - if (dev->hdr.if_type & 0x80) - get_adv_track_bitrate(drive, side, dev->cur_track, &br, &rpm); - else { - br = dev->br_rounded; - rpm = dev->rpm_rounded; - } - - /* 300 kbps @ 360 rpm = 250 kbps @ 200 rpm */ - if ((br == 300) && (rpm == 360)) { - br = 250; - rpm = 300; - } - - switch (br) { - case 500: - temp_side_flags = 0; - break; - - case 300: - temp_side_flags = 1; - break; - - case 250: - default: - temp_side_flags = 2; - break; - - case 1000: - temp_side_flags = 3; - break; - } - - if (rpm == 360) - temp_side_flags |= 0x20; - - /* - * Set the encoding value to match that provided by the FDC. - * Then if it's wrong, it will sector not found anyway. - */ - temp_side_flags |= 0x08; - - dev->side_flags[side] = temp_side_flags; -} - - -static uint16_t -side_flags(int drive) -{ - mfm_t *dev = mfm[drive]; - int side; - - side = fdd_get_head(drive); - - return dev->side_flags[side]; -} - - -static uint32_t -get_raw_size(int drive, int side) -{ - mfm_t *dev = mfm[drive]; - int track_index, is_300_rpm; - int br = 250, rpm = 300; - - if (dev->hdr.if_type & 0x80) { - track_index = get_adv_track_index(drive, side, dev->cur_track); - get_adv_track_bitrate(drive, 0, 0, &br, &rpm); - } else { - track_index = get_track_index(drive, side, dev->cur_track); - br = dev->br_rounded; - rpm = dev->rpm_rounded; - } - - is_300_rpm = (rpm == 300); - - if (track_index == -1) { - mfm_log("MFM: Unable to find track (%i, %i)\n", dev->cur_track, side); - switch (br) { - case 250: - default: - return is_300_rpm ? 100000 : 83333; - case 300: - return is_300_rpm ? 120000 : 100000; - case 500: - return is_300_rpm ? 200000 : 166666; - case 1000: - return is_300_rpm ? 400000 : 333333; - } - } - - /* Bit 7 on - my extension of the HxC MFM format to output exact bitcell counts - for each track instead of rounded byte counts. */ - if (dev->hdr.if_type & 0x80) - return dev->adv_tracks[track_index].track_size; - else - return dev->tracks[track_index].track_size * 8; -} - - -static int32_t -extra_bit_cells(int drive, int side) -{ - return (int32_t) get_raw_size(drive, side); -} - - -static uint16_t * -encoded_data(int drive, int side) -{ - mfm_t *dev = mfm[drive]; - - return((uint16_t *)dev->track_data[side]); -} - - -void -mfm_read_side(int drive, int side) -{ - mfm_t *dev = mfm[drive]; - int track_index, track_size; - int track_bytes; - - if (dev->hdr.if_type & 0x80) - track_index = get_adv_track_index(drive, side, dev->cur_track); - else - track_index = get_track_index(drive, side, dev->cur_track); - - track_size = get_raw_size(drive, side); - track_bytes = track_size >> 3; - if (track_size & 0x07) - track_bytes++; - - if (track_index == -1) - memset(dev->track_data[side], 0x00, track_bytes); - else { - if (dev->hdr.if_type & 0x80) - fseek(dev->f, dev->adv_tracks[track_index].track_offset, SEEK_SET); - else - fseek(dev->f, dev->tracks[track_index].track_offset, SEEK_SET); - fread(dev->track_data[side], 1, track_size, dev->f); - } - - mfm_log("drive = %i, side = %i, dev->cur_track = %i, track_index = %i, track_size = %i\n", - drive, side, dev->cur_track, track_index, track_size); -} - - -void -mfm_seek(int drive, int track) -{ - mfm_t *dev = mfm[drive]; - - mfm_log("mfm_seek(%i, %i)\n", drive, track); - - if (fdd_doublestep_40(drive)) { - if (dev->hdr.tracks_no <= 43) - track /= 2; - } - - dev->cur_track = track; - d86f_set_cur_track(drive, track); - - if (dev->f == NULL) - return; - - if (track < 0) - track = 0; - - mfm_read_side(drive, 0); - mfm_read_side(drive, 1); - - set_side_flags(drive, 0); - set_side_flags(drive, 1); -} - - -void -mfm_load(int drive, wchar_t *fn) -{ - mfm_t *dev; - double dbr; - int i; - - writeprot[drive] = fwriteprot[drive] = 1; - - /* Allocate a drive block. */ - dev = (mfm_t *)malloc(sizeof(mfm_t)); - memset(dev, 0x00, sizeof(mfm_t)); - - dev->f = plat_fopen(fn, L"rb"); - if (dev->f == NULL) { - free(dev); - memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); - return; - } - - d86f_unregister(drive); - - /* Read the header. */ - fread(&dev->hdr, 1, sizeof(mfm_header_t), dev->f); - - /* Calculate tracks * sides, allocate the tracks array, and read it. */ - dev->total_tracks = dev->hdr.tracks_no * dev->hdr.sides_no; - if (dev->hdr.if_type & 0x80) { - dev->adv_tracks = (mfm_adv_track_t *) malloc(dev->total_tracks * sizeof(mfm_adv_track_t)); - fread(dev->adv_tracks, 1, dev->total_tracks * sizeof(mfm_adv_track_t), dev->f); - } else { - dev->tracks = (mfm_track_t *) malloc(dev->total_tracks * sizeof(mfm_track_t)); - fread(dev->tracks, 1, dev->total_tracks * sizeof(mfm_track_t), dev->f); - } - - /* The chances of finding a HxC MFM image of a single-sided thin track - disk are much smaller than the chances of finding a HxC MFM image - incorrectly converted from a SCP image, erroneously indicating 1 - side and 80+ tracks instead of 2 sides and <= 43 tracks, so if we - have detected such an image, convert the track numbers. */ - if ((dev->hdr.tracks_no > 43) && (dev->hdr.sides_no == 1)) { - dev->hdr.tracks_no >>= 1; - dev->hdr.sides_no <<= 1; - - for (i = 0; i < dev->total_tracks; i++) { - if (dev->hdr.if_type & 0x80) { - dev->adv_tracks[i].side_no <<= 1; - dev->adv_tracks[i].side_no |= (dev->adv_tracks[i].track_no & 1); - dev->adv_tracks[i].track_no >>= 1; - } else { - dev->tracks[i].side_no <<= 1; - dev->tracks[i].side_no |= (dev->tracks[i].track_no & 1); - dev->tracks[i].track_no >>= 1; - } - } - } - - if (!(dev->hdr.if_type & 0x80)) { - dbr = round(((double) dev->hdr.bit_rate) / 50.0) * 50.0; - dev->br_rounded = (int) dbr; - mfm_log("Rounded bit rate: %i kbps\n", dev->br_rounded); - - dbr = round(((double) dev->hdr.rpm) / 60.0) * 60.0; - dev->rpm_rounded = (int) dbr; - mfm_log("Rounded RPM: %i kbps\n", dev->rpm_rounded); - } - - /* Set up the drive unit. */ - mfm[drive] = dev; - - set_disk_flags(drive); - - /* Attach this format to the D86F engine. */ - d86f_handler[drive].disk_flags = disk_flags; - d86f_handler[drive].side_flags = side_flags; - d86f_handler[drive].writeback = null_writeback; - d86f_handler[drive].set_sector = null_set_sector; - d86f_handler[drive].write_data = null_write_data; - d86f_handler[drive].format_conditions = null_format_conditions; - d86f_handler[drive].extra_bit_cells = extra_bit_cells; - d86f_handler[drive].encoded_data = encoded_data; - d86f_handler[drive].read_revolution = common_read_revolution; - d86f_handler[drive].index_hole_pos = null_index_hole_pos; - d86f_handler[drive].get_raw_size = get_raw_size; - d86f_handler[drive].check_crc = 1; - d86f_set_version(drive, D86FVER); - - d86f_common_handlers(drive); - - drives[drive].seek = mfm_seek; - - mfm_log("Loaded as MFM\n"); -} - - -void -mfm_close(int drive) -{ - mfm_t *dev = mfm[drive]; - - if (dev == NULL) return; - - d86f_unregister(drive); - - drives[drive].seek = NULL; - - if (dev->tracks) - free(dev->tracks); - - if (dev->adv_tracks) - free(dev->adv_tracks); - - if (dev->f) - fclose(dev->f); - - /* Release the memory. */ - free(dev); - mfm[drive] = NULL; -} - - -void -mfm_set_fdc(void *fdc) -{ - mfm_fdc = (fdc_t *)fdc; -} diff --git a/src/devices/floppy/new/fdd_mfm.h b/src/devices/floppy/new/fdd_mfm.h deleted file mode 100644 index 2aba3fb..0000000 --- a/src/devices/floppy/new/fdd_mfm.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Implementation of the HxC MFM image format. - * - * Version: @(#)fdd_mfm.h 1.0.0 2018/11/12 - * - * Authors: Miran Grca, - * - * Copyright 2018 Miran Grca. - */ -#ifndef EMU_FLOPPY_MFM_H -# define EMU_FLOPPY_MFM_H - - -extern void mfm_seek(int drive, int track); -extern void mfm_load(int drive, wchar_t *fn); -extern void mfm_close(int drive); - - -#endif /*EMU_FLOPPY_MFM_H*/ diff --git a/src/devices/input/mouse.c b/src/devices/input/mouse.c index 2d05245..5d9b7a3 100644 --- a/src/devices/input/mouse.c +++ b/src/devices/input/mouse.c @@ -10,7 +10,7 @@ * * TODO: Add the Genius bus- and serial mouse. * - * Version: @(#)mouse.c 1.0.18 2019/04/09 + * Version: @(#)mouse.c 1.0.19 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -56,6 +56,7 @@ #define HAVE_STDARG_H #define dbglog mouse_log #include "../../emu.h" +#include "../../config.h" #include "../../device.h" #include "../../plat.h" #include "mouse.h" @@ -70,29 +71,13 @@ int mouse_x, mouse_buttons; -static const device_t mouse_none_device = { - "Disabled", - 0, MOUSE_NONE, NULL, - NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL -}; -static const device_t mouse_internal_device = { - "Internal", - 0, MOUSE_INTERNAL, NULL, - NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL -}; - - static const struct { const char *internal_name; const device_t *device; -} mouse_devices[] = { - { "none", &mouse_none_device }, +} devices[] = { + { "none", NULL }, + { "internal", NULL }, - { "internal", &mouse_internal_device }, { "logibus", &mouse_logibus_device }, { "msbus", &mouse_msinport_device }, #if 0 @@ -108,9 +93,9 @@ static const struct { }; -static void *mouse_priv; static int mouse_nbut; -static device_t mouse_dev; +static void *mouse_priv; +static int (*mouse_func)(int,int,int,int,void *); #ifdef _LOGGING @@ -138,8 +123,6 @@ mouse_init(void) mouse_x = mouse_y = mouse_z = 0; mouse_buttons = 0x00; - mouse_type = MOUSE_NONE; - mouse_close(); } @@ -147,8 +130,9 @@ mouse_init(void) void mouse_close(void) { - mouse_priv = NULL; mouse_nbut = 0; + mouse_priv = NULL; + mouse_func = NULL; } @@ -156,21 +140,18 @@ void mouse_reset(void) { /* Nothing to do if no mouse, or a machine-internal one. */ - if (mouse_type <= MOUSE_INTERNAL) return; + if (config.mouse_type <= MOUSE_INTERNAL) return; - INFO("MOUSE: reset(type=%d, '%s')\n", - mouse_type, mouse_devices[mouse_type].device->name); + INFO("MOUSE: reset(type=%i, '%s')\n", + config.mouse_type, devices[config.mouse_type].device->name); /* Clear local data. */ mouse_x = mouse_y = mouse_z = 0; mouse_buttons = 0x00; - /* Copy the (R/O) mouse info. */ - if (mouse_devices[mouse_type].device != NULL) { - memcpy(&mouse_dev, mouse_devices[mouse_type].device, - sizeof(device_t)); - mouse_priv = device_add(&mouse_dev); - } + /* Initialize the mouse device. */ + if (devices[config.mouse_type].device != NULL) + mouse_priv = device_add(devices[config.mouse_type].device); } @@ -186,18 +167,16 @@ void mouse_process(void) { static int poll_delay = 2; - int (*func)(int, int, int, int, void *); if ((mouse_priv == NULL) || /* no or no active device */ - (mouse_type == MOUSE_NONE)) return; + (config.mouse_type == MOUSE_NONE)) return; if (--poll_delay) return; mouse_poll(); - func = mouse_dev.ms_poll; - if (func != NULL) { - if (! func(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv)) { + if (mouse_func != NULL) { + if (! mouse_func(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv)) { /* Poll failed, maybe port closed? */ mouse_close(); @@ -217,9 +196,9 @@ mouse_process(void) void mouse_set_poll(int (*func)(int,int,int,int,void *), void *arg) { - if (mouse_type != MOUSE_INTERNAL) return; + if (config.mouse_type != MOUSE_INTERNAL) return; - mouse_dev.ms_poll = func; + mouse_func = func; mouse_priv = arg; } @@ -227,8 +206,8 @@ mouse_set_poll(int (*func)(int,int,int,int,void *), void *arg) const char * mouse_get_name(int mouse) { - if (mouse_devices[mouse].device != NULL) - return(mouse_devices[mouse].device->name); + if (devices[mouse].device != NULL) + return(devices[mouse].device->name); return(NULL); } @@ -237,20 +216,18 @@ mouse_get_name(int mouse) const char * mouse_get_internal_name(int mouse) { - return(mouse_devices[mouse].internal_name); + return(devices[mouse].internal_name); } int mouse_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (mouse_devices[c].internal_name != NULL) { - if (! strcmp(mouse_devices[c].internal_name, s)) + for (c = 0; devices[c].internal_name != NULL; c++) + if (! strcmp(devices[c].internal_name, s)) return(c); - c++; - } /* Not found. */ return(0); @@ -260,8 +237,8 @@ mouse_get_from_internal_name(const char *s) int mouse_has_config(int mouse) { - if (mouse_devices[mouse].device != NULL) - return(mouse_devices[mouse].device->config ? 1 : 0); + if (devices[mouse].device != NULL) + return(devices[mouse].device->config ? 1 : 0); return(0); } @@ -270,7 +247,7 @@ mouse_has_config(int mouse) const device_t * mouse_get_device(int mouse) { - return(mouse_devices[mouse].device); + return(devices[mouse].device); } diff --git a/src/devices/misc/isamem.c b/src/devices/misc/isamem.c index 21608d3..c7e8fea 100644 --- a/src/devices/misc/isamem.c +++ b/src/devices/misc/isamem.c @@ -32,7 +32,7 @@ * TODO: The EV159 is supposed to support 16b EMS transfers, but the * EMM.sys driver for it doesn't seem to want to do that.. * - * Version: @(#)isamem.c 1.0.8 2019/04/11 + * Version: @(#)isamem.c 1.0.9 2019/05/03 * * Author: Fred N. van Kempen, * @@ -74,6 +74,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../cpu/cpu.h" #include "../../io.h" #include "../../mem.h" @@ -1018,7 +1019,7 @@ isamem_reset(void) int k, i; for (i = 0; i < ISAMEM_MAX; i++) { - k = isamem_type[i]; + k = config.isamem_type[i]; if (k == 0) continue; /* Clone the device. */ diff --git a/src/devices/misc/isamem.h b/src/devices/misc/isamem.h index a612df5..6f03e42 100644 --- a/src/devices/misc/isamem.h +++ b/src/devices/misc/isamem.h @@ -8,11 +8,11 @@ * * Definitions for the ISAMEM cards. * - * Version: @(#)isamem.h 1.0.1 2018/08/18 + * Version: @(#)isamem.h 1.0.2 2019/05/03 * * Authors: Fred N. van Kempen, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -48,9 +48,6 @@ # define ISAMEM_H -#define ISAMEM_MAX 4 /* max #cards in system */ - - #ifdef __cplusplus extern "C" { #endif diff --git a/src/devices/misc/isartc.c b/src/devices/misc/isartc.c index f9e5410..143559a 100644 --- a/src/devices/misc/isartc.c +++ b/src/devices/misc/isartc.c @@ -28,7 +28,7 @@ * NOTE: The IRQ functionalities have been implemented, but not yet * tested, as I need to write test software for them first :) * - * Version: @(#)isartc.c 1.0.7 2019/04/11 + * Version: @(#)isartc.c 1.0.8 2019/05/03 * * Author: Fred N. van Kempen, * @@ -71,6 +71,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../cpu/cpu.h" #include "../../io.h" #include "../../device.h" @@ -324,7 +325,7 @@ mm67_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (time_sync != TIME_SYNC_DISABLED) { + if (config.time_sync != TIME_SYNC_DISABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); mm67_time_set(nvr, &tm); @@ -527,7 +528,7 @@ isartc_init(const device_t *info, UNUSED(void *parent)) dev->f_rd,NULL,NULL, dev->f_wr,NULL,NULL, dev); /* Hook into the NVR backend. */ - dev->nvr.fn = (const wchar_t *)isartc_get_internal_name(isartc_type); + dev->nvr.fn = (const wchar_t *)isartc_get_internal_name(config.isartc_type); dev->nvr.irq = dev->irq; nvr_init(&dev->nvr); @@ -686,10 +687,10 @@ static const struct { void isartc_reset(void) { - if (isartc_type == 0) return; + if (config.isartc_type == 0) return; /* Add the device to the system. */ - device_add(boards[isartc_type].dev); + device_add(boards[config.isartc_type].dev); } diff --git a/src/devices/network/net_3c503.c b/src/devices/network/net_3c503.c index 4efa34a..344530f 100644 --- a/src/devices/network/net_3c503.c +++ b/src/devices/network/net_3c503.c @@ -8,17 +8,17 @@ * Implementation of the following network controllers: * - 3Com Etherlink II 3c503 (ISA 8-bit). * - * Version: @(#)net_3c503.c 1.0.6 2019/04/11 + * Version: @(#)net_3c503.c 1.0.7 2019/05/02 * * Based on @(#)3c503.cpp Carl (MAME) * - * Authors: TheCollector1995, + * Authors: Fred N. van Kempen, + * TheCollector1995, * Miran Grca, - * Fred N. van Kempen, * Carl, * + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2018 Miran Grca. - * Copyright 2017,2018 Fred N. van Kempen. * Portions Copyright (C) 2018 MAME Project * * This program is free software; you can redistribute it and/or modify @@ -89,15 +89,15 @@ typedef struct { uint8_t rfmsb; uint8_t rflsb; } regs; -} tc503_t; +} el2_t; -static void tc503_rx(void *, uint8_t *, int); -static void tc503_tx(tc503_t *, uint32_t); +static void el2_rx(void *, uint8_t *, int); +static void el2_tx(el2_t *, uint32_t); static void -tc503_interrupt(tc503_t *dev, int set) +el2_interrupt(el2_t *dev, int set) { switch (dev->base_irq) { case 2: @@ -125,9 +125,9 @@ tc503_interrupt(tc503_t *dev, int set) static void -tc503_ram_write(uint32_t addr, uint8_t val, void *priv) +el2_ram_write(uint32_t addr, uint8_t val, void *priv) { - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; if ((addr & 0x3fff) >= 0x2000) return; @@ -137,9 +137,9 @@ tc503_ram_write(uint32_t addr, uint8_t val, void *priv) static uint8_t -tc503_ram_read(uint32_t addr, void *priv) +el2_ram_read(uint32_t addr, void *priv) { - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; if ((addr & 0x3fff) >= 0x2000) return(0xff); @@ -149,7 +149,7 @@ tc503_ram_read(uint32_t addr, void *priv) static void -tc503_set_drq(tc503_t *dev) +el2_set_drq(el2_t *dev) { switch (dev->dma_channel) { case 1: @@ -169,9 +169,9 @@ tc503_set_drq(tc503_t *dev) /* Restore state to power-up, cancelling all I/O. */ static void -tc503_reset(void *priv) +el2_reset(void *priv) { - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; int i; DEBUG("3C503: reset\n"); @@ -232,7 +232,7 @@ tc503_reset(void *priv) dev->regs.ctrl = 0x0a; - tc503_interrupt(dev, 0); + el2_interrupt(dev, 0); } @@ -246,7 +246,7 @@ tc503_reset(void *priv) * and there is 16K of buffer memory starting at 16K. */ static uint32_t -tc503_chipmem_read(tc503_t *dev, uint32_t addr, unsigned int len) +el2_chipmem_read(el2_t *dev, uint32_t addr, unsigned int len) { uint32_t retval = 0; @@ -271,7 +271,7 @@ tc503_chipmem_read(tc503_t *dev, uint32_t addr, unsigned int len) static void -tc503_chipmem_write(tc503_t *dev, uint32_t addr, uint32_t val, unsigned len) +el2_chipmem_write(el2_t *dev, uint32_t addr, uint32_t val, unsigned len) { if ((addr >= DP8390_WORD_MEMSTART) && (addr < DP8390_WORD_MEMEND)) { dev->dp8390.mem[addr-DP8390_WORD_MEMSTART] = val & 0xff; @@ -284,7 +284,7 @@ tc503_chipmem_write(tc503_t *dev, uint32_t addr, uint32_t val, unsigned len) /* Handle reads/writes to the 'zeroth' page of the DS8390 register file. */ static uint32_t -tc503_page0_read(tc503_t *dev, uint32_t off, unsigned int len) +el2_page0_read(el2_t *dev, uint32_t off, unsigned int len) { uint8_t retval = 0; @@ -392,7 +392,7 @@ tc503_page0_read(tc503_t *dev, uint32_t off, unsigned int len) static void -tc503_page0_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) +el2_page0_write(el2_t *dev, uint32_t off, uint32_t val, unsigned len) { uint8_t val2; @@ -400,9 +400,9 @@ tc503_page0_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) /* break up outw into two outb's */ if (len == 2) { - tc503_page0_write(dev, off, (val & 0xff), 1); + el2_page0_write(dev, off, (val & 0xff), 1); if (off < 0x0f) - tc503_page0_write(dev, off+1, ((val>>8)&0xff), 1); + el2_page0_write(dev, off+1, ((val>>8)&0xff), 1); return; } @@ -462,7 +462,7 @@ tc503_page0_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) (dev->dp8390.IMR.tx_inte << 1) | (dev->dp8390.IMR.rx_inte)); if (val == 0x00) - tc503_interrupt(dev, 0); + el2_interrupt(dev, 0); break; case 0x08: /* RSAR0 */ @@ -587,9 +587,9 @@ tc503_page0_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) (dev->dp8390.ISR.pkt_tx << 1) | (dev->dp8390.ISR.pkt_rx)); if (((val & val2) & 0x7f) == 0) - tc503_interrupt(dev, 0); + el2_interrupt(dev, 0); else - tc503_interrupt(dev, 1); + el2_interrupt(dev, 1); break; default: @@ -601,7 +601,7 @@ tc503_page0_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) /* Handle reads/writes to the first page of the DS8390 register file. */ static uint32_t -tc503_page1_read(tc503_t *dev, uint32_t off, unsigned int len) +el2_page1_read(el2_t *dev, uint32_t off, unsigned int len) { DBGLOG(2, "3C503: Page1 read from register 0x%02x, len=%u\n", off, len); @@ -637,7 +637,7 @@ tc503_page1_read(tc503_t *dev, uint32_t off, unsigned int len) static void -tc503_page1_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) +el2_page1_write(el2_t *dev, uint32_t off, uint32_t val, unsigned len) { DBGLOG(2, "3C503: Page1 write to register 0x%02x, len=%u, value=0x%04x\n", off, len, val); @@ -681,7 +681,7 @@ tc503_page1_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) /* Handle reads/writes to the second page of the DS8390 register file. */ static uint32_t -tc503_page2_read(tc503_t *dev, uint32_t off, unsigned int len) +el2_page2_read(el2_t *dev, uint32_t off, unsigned int len) { DBGLOG(2, "3C503: Page2 read from register 0x%02x, len=%u\n", off, len); @@ -758,7 +758,7 @@ tc503_page2_read(tc503_t *dev, uint32_t off, unsigned int len) affect internal operation, but let them through for now and print a warning. */ static void -tc503_page2_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) +el2_page2_write(el2_t *dev, uint32_t off, uint32_t val, unsigned len) { DBGLOG(2, "3C503: Page2 write to register 0x%02x, len=%u, value=0x%04x\n", off, len, val); @@ -819,7 +819,7 @@ tc503_page2_write(tc503_t *dev, uint32_t off, uint32_t val, unsigned len) /* Routines for handling reads/writes to the Command Register. */ static uint32_t -tc503_read_cr(tc503_t *dev) +el2_read_cr(el2_t *dev) { uint32_t retval; @@ -836,7 +836,7 @@ tc503_read_cr(tc503_t *dev) static void -tc503_write_cr(tc503_t *dev, uint32_t val) +el2_write_cr(el2_t *dev, uint32_t val) { DBGLOG(1, "3C503: wrote 0x%02x to CR\n", val); @@ -867,7 +867,7 @@ tc503_write_cr(tc503_t *dev, uint32_t val) if (dev->dp8390.CR.rdma_cmd == 3) { /* Set up DMA read from receive ring */ dev->dp8390.remote_start = dev->dp8390.remote_dma = dev->dp8390.bound_ptr * 256; - dev->dp8390.remote_bytes = (uint16_t) tc503_chipmem_read(dev, dev->dp8390.bound_ptr * 256 + 2, 2); + dev->dp8390.remote_bytes = (uint16_t) el2_chipmem_read(dev, dev->dp8390.bound_ptr * 256 + 2, 2); DEBUG("3C503: sending buffer %x length %d\n", dev->dp8390.remote_start, dev->dp8390.remote_bytes); } @@ -878,7 +878,7 @@ tc503_write_cr(tc503_t *dev, uint32_t val) DEBUG("3C503: loop mode %d not supported\n", dev->dp8390.TCR.loop_cntl); } else { - tc503_rx(dev, + el2_rx(dev, &dev->dp8390.mem[dev->dp8390.tx_page_start*256 - DP8390_WORD_MEMSTART], dev->dp8390.tx_bytes); } @@ -902,7 +902,7 @@ tc503_write_cr(tc503_t *dev, uint32_t val) DEBUG("3C503: CR write, tx timer still active\n"); } - tc503_tx(dev, val); + el2_tx(dev, val); } /* Linux probes for an interrupt by setting up a remote-DMA read @@ -911,17 +911,17 @@ tc503_write_cr(tc503_t *dev, uint32_t val) if (dev->dp8390.CR.rdma_cmd == 0x01 && dev->dp8390.CR.start && dev->dp8390.remote_bytes == 0) { dev->dp8390.ISR.rdma_done = 1; if (dev->dp8390.IMR.rdma_inte) { - tc503_interrupt(dev, 1); - tc503_interrupt(dev, 0); + el2_interrupt(dev, 1); + el2_interrupt(dev, 0); } } } static uint8_t -tc503_lo_read(uint16_t addr, void *priv) +el2_lo_read(uint16_t addr, void *priv) { - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; uint8_t retval = 0; int off = addr - dev->base_address; @@ -929,18 +929,18 @@ tc503_lo_read(uint16_t addr, void *priv) case 0x00: DEBUG(0, "Read offset=%04x\n", off); if (off == 0x00) - retval = tc503_read_cr(dev); + retval = el2_read_cr(dev); else switch(dev->dp8390.CR.pgsel) { case 0x00: - retval = tc503_page0_read(dev, off, 1); + retval = el2_page0_read(dev, off, 1); break; case 0x01: - retval = tc503_page1_read(dev, off, 1); + retval = el2_page1_read(dev, off, 1); break; case 0x02: - retval = tc503_page2_read(dev, off, 1); + retval = el2_page2_read(dev, off, 1); break; case 0x03: @@ -967,9 +967,9 @@ tc503_lo_read(uint16_t addr, void *priv) static void -tc503_lo_write(uint16_t addr, uint8_t val, void *priv) +el2_lo_write(uint16_t addr, uint8_t val, void *priv) { - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; int off = addr - dev->base_address; switch ((dev->regs.ctrl >> 2) & 3) { @@ -979,18 +979,18 @@ tc503_lo_write(uint16_t addr, uint8_t val, void *priv) page being selected by the PS0,PS1 registers in the command register */ if (off == 0x00) - tc503_write_cr(dev, val); + el2_write_cr(dev, val); else switch(dev->dp8390.CR.pgsel) { case 0x00: - tc503_page0_write(dev, off, val, 1); + el2_page0_write(dev, off, val, 1); break; case 0x01: - tc503_page1_write(dev, off, val, 1); + el2_page1_write(dev, off, val, 1); break; case 0x02: - tc503_page2_write(dev, off, val, 1); + el2_page2_write(dev, off, val, 1); break; case 0x03: @@ -1009,9 +1009,9 @@ tc503_lo_write(uint16_t addr, uint8_t val, void *priv) static uint8_t -tc503_hi_read(uint16_t addr, void *priv) +el2_hi_read(uint16_t addr, void *priv) { - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; DEBUG("3C503: Read GA address=%04x\n", addr); @@ -1114,9 +1114,9 @@ tc503_hi_read(uint16_t addr, void *priv) if (!(dev->regs.ctrl & 0x80)) return 0xff; - tc503_set_drq(dev); + el2_set_drq(dev); - return tc503_chipmem_read(dev, dev->regs.da++, 1); + return el2_chipmem_read(dev, dev->regs.da++, 1); } return 0; @@ -1124,9 +1124,9 @@ tc503_hi_read(uint16_t addr, void *priv) static void -tc503_hi_write(uint16_t addr, uint8_t val, void *priv) +el2_hi_write(uint16_t addr, uint8_t val, void *priv) { - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; DEBUG("3C503: Write GA address=%04x, val=%04x\n", addr, val); @@ -1162,16 +1162,16 @@ tc503_hi_write(uint16_t addr, uint8_t val, void *priv) } if (!(val & 0x80)) - tc503_interrupt(dev, 1); + el2_interrupt(dev, 1); else - tc503_interrupt(dev, 0); + el2_interrupt(dev, 0); dev->regs.gacfr = val; break; case 0x06: if (val & 1) { - tc503_reset(dev); + el2_reset(dev); dev->dp8390.ISR.reset = 1; dev->regs.ctrl = 0x0b; return; @@ -1244,42 +1244,42 @@ tc503_hi_write(uint16_t addr, uint8_t val, void *priv) if (!(dev->regs.ctrl & 0x80)) return; - tc503_set_drq(dev); + el2_set_drq(dev); - tc503_chipmem_write(dev, dev->regs.da++, val, 1); + el2_chipmem_write(dev, dev->regs.da++, val, 1); break; } } static void -tc503_ioremove(tc503_t *dev, uint16_t addr) +el2_ioremove(el2_t *dev, uint16_t addr) { io_removehandler(addr, 16, - tc503_lo_read, NULL, NULL, - tc503_lo_write, NULL, NULL, dev); + el2_lo_read, NULL, NULL, + el2_lo_write, NULL, NULL, dev); io_removehandler(addr+0x400, 16, - tc503_hi_read, NULL, NULL, - tc503_hi_write, NULL, NULL, dev); + el2_hi_read, NULL, NULL, + el2_hi_write, NULL, NULL, dev); } static void -tc503_ioset(tc503_t *dev, uint16_t addr) +el2_ioset(el2_t *dev, uint16_t addr) { io_sethandler(addr, 16, - tc503_lo_read, NULL, NULL, - tc503_lo_write, NULL, NULL, dev); + el2_lo_read, NULL, NULL, + el2_lo_write, NULL, NULL, dev); io_sethandler(addr+0x400, 16, - tc503_hi_read, NULL, NULL, - tc503_hi_write, NULL, NULL, dev); + el2_hi_read, NULL, NULL, + el2_hi_write, NULL, NULL, dev); } static void -tc503_tx(tc503_t *dev, uint32_t val) +el2_tx(el2_t *dev, uint32_t val) { dev->dp8390.CR.tx_packet = 0; dev->dp8390.TSR.tx_ok = 1; @@ -1287,7 +1287,7 @@ tc503_tx(tc503_t *dev, uint32_t val) /* Generate an interrupt if not masked */ if (dev->dp8390.IMR.tx_inte) - tc503_interrupt(dev, 1); + el2_interrupt(dev, 1); dev->dp8390.tx_timer_active = 0; } @@ -1300,10 +1300,10 @@ tc503_tx(tc503_t *dev, uint32_t val) * it is copied into it and the receive process is updated. */ static void -tc503_rx(void *priv, uint8_t *buf, int io_len) +el2_rx(void *priv, uint8_t *buf, int io_len) { static uint8_t bcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; - tc503_t *dev = (tc503_t *)priv; + el2_t *dev = (el2_t *)priv; uint8_t pkthdr[4]; uint8_t *startptr; int rx_pages, avail; @@ -1439,21 +1439,37 @@ tc503_rx(void *priv, uint8_t *buf, int io_len) dev->dp8390.ISR.pkt_rx = 1; if (dev->dp8390.IMR.rx_inte) - tc503_interrupt(dev, 1); + el2_interrupt(dev, 1); /* FIXME: move to upper layer */ ui_sb_icon_update(SB_NETWORK, 0); } +static void +el2_close(void *priv) +{ + el2_t *dev = (el2_t *)priv; + + /* Make sure the platform layer is shut down. */ + network_close(); + + el2_ioremove(dev, dev->base_address); + + DEBUG("3C503: closed\n"); + + free(dev); +} + + static void * -tc503_init(const device_t *info, UNUSED(void *parent)) +el2_init(const device_t *info, UNUSED(void *parent)) { uint32_t mac; - tc503_t *dev; + el2_t *dev; - dev = (tc503_t *)mem_alloc(sizeof(tc503_t)); - memset(dev, 0x00, sizeof(tc503_t)); + dev = (el2_t *)mem_alloc(sizeof(el2_t)); + memset(dev, 0x00, sizeof(el2_t)); dev->maclocal[0] = 0x02; /* 02:60:8C (3Com OID) */ dev->maclocal[1] = 0x60; dev->maclocal[2] = 0x8C; @@ -1471,7 +1487,7 @@ tc503_init(const device_t *info, UNUSED(void *parent)) * * PnP and PCI devices start with address spaces inactive. */ - tc503_ioset(dev, dev->base_address); + el2_ioset(dev, dev->base_address); /* Set up our BIA. */ if (mac & 0xff000000) { @@ -1496,15 +1512,19 @@ tc503_init(const device_t *info, UNUSED(void *parent)) dev->dp8390.physaddr[3], dev->dp8390.physaddr[4], dev->dp8390.physaddr[5]); /* Reset the board. */ - tc503_reset(dev); + el2_reset(dev); /* Attach ourselves to the network module. */ - network_attach(dev, dev->dp8390.physaddr, tc503_rx); + if (! network_attach(dev, dev->dp8390.physaddr, el2_rx)) { + el2_close(dev); + + return(NULL); + } /* Map this system into the memory map. */ mem_map_add(&dev->ram_mapping, dev->bios_addr, 0x4000, - tc503_ram_read, NULL, NULL, - tc503_ram_write, NULL, NULL, + el2_ram_read, NULL, NULL, + el2_ram_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, dev); mem_map_disable(&dev->ram_mapping); @@ -1512,23 +1532,7 @@ tc503_init(const device_t *info, UNUSED(void *parent)) } -static void -tc503_close(void *priv) -{ - tc503_t *dev = (tc503_t *)priv; - - /* Make sure the platform layer is shut down. */ - network_close(); - - tc503_ioremove(dev, dev->base_address); - - DEBUG("3C503: closed\n"); - - free(dev); -} - - -static const device_config_t tc503_config[] = { +static const device_config_t el2_config[] = { { "base", "Address", CONFIG_HEX16, "", 0x300, { @@ -1632,12 +1636,12 @@ static const device_config_t tc503_config[] = { }; -const device_t tc503_device = { +const device_t el2_device = { "3Com EtherLink II", DEVICE_ISA, 0, NULL, - tc503_init, tc503_close, NULL, + el2_init, el2_close, NULL, NULL, NULL, NULL, NULL, - tc503_config + el2_config }; diff --git a/src/devices/network/net_3com.h b/src/devices/network/net_3com.h index f06b849..6bf5743 100644 --- a/src/devices/network/net_3com.h +++ b/src/devices/network/net_3com.h @@ -8,11 +8,11 @@ * * Definitions for the 3Com series of ethernet controllers. * - * Version: @(#)net_3com.h 1.0.2 2018/10/12 + * Version: @(#)net_3com.h 1.0.3 2019/05/02 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +36,10 @@ # define NET_3COM_H -extern const device_t tc503_device; +#if 0 +extern const device_t el1_device; +#endif +extern const device_t el2_device; #endif /*NET_3COM_H*/ diff --git a/src/devices/network/net_ne2000.c b/src/devices/network/net_ne2000.c index 929fcf2..ab1e30d 100644 --- a/src/devices/network/net_ne2000.c +++ b/src/devices/network/net_ne2000.c @@ -16,7 +16,7 @@ * * FIXME: move statbar calls to upper layer * - * Version: @(#)net_ne2000.c 1.0.16 2019/04/11 + * Version: @(#)net_ne2000.c 1.0.17 2019/05/02 * * Based on @(#)ne2k.cc v1.56.2.1 2004/02/02 22:37:22 cbothamy * @@ -25,7 +25,7 @@ * Miran Grca, * Peter Grehan, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Portions Copyright (C) 2002 MandrakeSoft S.A. * @@ -2378,6 +2378,22 @@ nic_mca_write(int port, uint8_t val, void *priv) } +static void +nic_close(void *priv) +{ + nic_t *dev = (nic_t *)priv; + + /* Make sure the platform layer is shut down. */ + network_close(); + + nic_ioremove(dev, dev->base_address); + + DEBUG("%s: closed\n", dev->name); + + free(dev); +} + + static void * nic_init(const device_t *info, UNUSED(void *parent)) { @@ -2482,9 +2498,6 @@ nic_init(const device_t *info, UNUSED(void *parent)) if ((dev->board < NE2K_RTL8019AS) && !dev->is_mca) nic_ioset(dev, dev->base_address); - /* Set up our BIOS ROM space, if any. */ - nic_rom_init(dev, fn); - /* See if we have a local MAC address configured. */ mac = device_get_config_mac("mac", -1); @@ -2652,31 +2665,22 @@ nic_init(const device_t *info, UNUSED(void *parent)) nic_reset(dev); /* Attach ourselves to the network module. */ - network_attach(dev, dev->dp8390.physaddr, nic_rx); + if (! network_attach(dev, dev->dp8390.physaddr, nic_rx)) { + nic_close(dev); + + return(NULL); + } INFO("%s: %s attached IO=0x%X IRQ=%d\n", dev->name, dev->is_pci?"PCI":"ISA", dev->base_address, dev->base_irq); + /* Set up our BIOS ROM space, if any. */ + nic_rom_init(dev, fn); + return(dev); } -static void -nic_close(void *priv) -{ - nic_t *dev = (nic_t *)priv; - - /* Make sure the platform layer is shut down. */ - network_close(); - - nic_ioremove(dev, dev->base_address); - - DEBUG("%s: closed\n", dev->name); - - free(dev); -} - - static const device_config_t ne1000_config[] = { { "base", "Address", CONFIG_HEX16, "", 0x300, diff --git a/src/devices/network/net_pcap.c b/src/devices/network/net_pcap.c index 9e2e9a7..936e703 100644 --- a/src/devices/network/net_pcap.c +++ b/src/devices/network/net_pcap.c @@ -8,11 +8,11 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.10 2018/11/12 + * Version: @(#)net_pcap.c 1.0.11 2019/05/03 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -55,6 +55,7 @@ #include #define dbglog network_log #include "../../emu.h" +#include "../../config.h" #include "../../device.h" #include "../../plat.h" #include "../../ui/ui.h" @@ -76,15 +77,16 @@ static event_t *poll_state; /* Pointers to the real functions. */ static char *const (*PCAP_lib_version)(void); -static int (*PCAP_findalldevs)(pcap_if_t **,char *); +static int (*PCAP_findalldevs)(pcap_if_t **, char *); static void (*PCAP_freealldevs)(pcap_if_t *); -static pcap_t *(*PCAP_open_live)(const char *,int,int,int,char *); +static pcap_t *(*PCAP_open_live)(const char *, int, int, int, char *); static int (*PCAP_compile)(pcap_t *,struct bpf_program *, - const char *,int,bpf_u_int32); -static int (*PCAP_setfilter)(pcap_t *,struct bpf_program *); -static u_char *const (*PCAP_next)(pcap_t *,struct pcap_pkthdr *); -static int (*PCAP_sendpacket)(pcap_t *,const u_char *,int); + const char *, int, bpf_u_int32); +static int (*PCAP_setfilter)(pcap_t *, struct bpf_program *); +static uint8_t *const (*PCAP_next)(pcap_t *, struct pcap_pkthdr *); +static int (*PCAP_sendpacket)(pcap_t *, const uint8_t *, int); static void (*PCAP_close)(pcap_t *); + static const dllimp_t pcap_imports[] = { { "pcap_lib_version", &PCAP_lib_version }, { "pcap_findalldevs", &PCAP_findalldevs }, @@ -171,7 +173,7 @@ poll_thread(void *arg) * a list of (usable) intefaces for it. */ static int -net_pcap_init(netdev_t *list) +do_init(netdev_t *list) { char errbuf[PCAP_ERRBUF_SIZE]; pcap_if_t *devlist, *dev; @@ -225,7 +227,7 @@ net_pcap_init(netdev_t *list) /* Close up shop. */ static void -net_pcap_close(void) +do_close(void) { pcap_t *pc; @@ -270,7 +272,7 @@ net_pcap_close(void) * tries to attach to the network module. */ static int -net_pcap_reset(uint8_t *mac) +do_reset(uint8_t *mac) { char errbuf[PCAP_ERRBUF_SIZE]; char filter_exp[255]; @@ -281,21 +283,22 @@ net_pcap_reset(uint8_t *mac) poll_state = NULL; /* Get the value of our capture interface. */ - if ((network_host[0] == '\0') || !strcmp(network_host, "none")) { + if ((config.network_host[0] == '\0') || + !strcmp(config.network_host, "none")) { ERRLOG("PCAP: no interface configured!\n"); return(-1); } /* Open a PCAP live channel. */ - if ((pcap = PCAP_open_live(network_host, /* interface name */ + if ((pcap = PCAP_open_live(config.network_host, /* interface name */ 1518, /* max packet size */ 1, /* promiscuous mode? */ 10, /* timeout in msec */ errbuf)) == NULL) { /* error buffer */ - ERRLOG(" Unable to open device: %s!\n", network_host); + ERRLOG(" Unable to open device: %s!\n", config.network_host); return(-1); } - DEBUG("PCAP: interface: %s\n", network_host); + DEBUG("PCAP: interface: %s\n", config.network_host); /* Create a MAC address based packet filter. */ DEBUG("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", @@ -326,7 +329,7 @@ net_pcap_reset(uint8_t *mac) /* Are we available or not? */ static int -net_pcap_available(void) +do_available(void) { return((pcap_handle != NULL) ? 1 : 0); } @@ -334,7 +337,7 @@ net_pcap_available(void) /* Send a packet to the Pcap interface. */ static void -net_pcap_send(uint8_t *bufp, int len) +do_send(uint8_t *bufp, int len) { if (pcap == NULL) return; @@ -352,9 +355,7 @@ const network_t network_pcap = { #else "PCap", #endif - net_pcap_init, - net_pcap_close, - net_pcap_reset, - net_pcap_available, - net_pcap_send + do_init, do_close, do_reset, + do_available, + do_send }; diff --git a/src/devices/network/net_slirp.c b/src/devices/network/net_slirp.c index ec60db9..11016b9 100644 --- a/src/devices/network/net_slirp.c +++ b/src/devices/network/net_slirp.c @@ -8,11 +8,11 @@ * * Handle SLiRP library processing. * - * Version: @(#)net_slirp.c 1.0.6 2018/11/12 + * Version: @(#)net_slirp.c 1.0.7 2019/05/02 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -85,6 +85,7 @@ static void (*SLIRP_close)(slirp_t *); static void (*SLIRP_poll)(slirp_t *); static int (*SLIRP_recv)(slirp_t *, uint8_t *); static int (*SLIRP_send)(slirp_t *, const uint8_t *, int); + static const dllimp_t slirp_imports[] = { { "slirp_debug", &SLIRP_debug }, { "slirp_version", &SLIRP_version }, @@ -205,7 +206,7 @@ slirp_can_output(void) * be properly initialized. */ static int -net_slirp_init(netdev_t *list) +do_init(netdev_t *list) { char temp[128]; const char *fn = SLIRP_DLL_PATH; @@ -238,7 +239,7 @@ net_slirp_init(netdev_t *list) /* Initialize SLiRP for use. */ static int -net_slirp_reset(uint8_t *mac) +do_reset(uint8_t *mac) { /* Make sure local variables are cleared. */ poll_tid = NULL; @@ -260,7 +261,7 @@ net_slirp_reset(uint8_t *mac) static void -net_slirp_close(void) +do_close(void) { slirp_t *sl; @@ -294,7 +295,7 @@ net_slirp_close(void) /* Are we available or not? */ static int -net_slirp_available(void) +do_available(void) { return((slirp_handle != NULL) ? 1 : 0); } @@ -302,7 +303,7 @@ net_slirp_available(void) /* Send a packet to the SLiRP interface. */ static void -net_slirp_send(uint8_t *pkt, int pkt_len) +do_send(uint8_t *pkt, int pkt_len) { if (slirp != NULL) { network_busy(1); @@ -316,9 +317,9 @@ net_slirp_send(uint8_t *pkt, int pkt_len) const network_t network_slirp = { "SLiRP", - net_slirp_init, - net_slirp_close, - net_slirp_reset, - net_slirp_available, - net_slirp_send + do_init, + do_close, + do_reset, + do_available, + do_send }; diff --git a/src/devices/network/net_wd80x3.c b/src/devices/network/net_wd80x3.c index 49a73e0..b13ea98 100644 --- a/src/devices/network/net_wd80x3.c +++ b/src/devices/network/net_wd80x3.c @@ -11,7 +11,7 @@ * - SMC/WD 8013EBT (ISA 16-bit); * - SMC/WD 8013EP/A (MCA). * - * Version: @(#)net_wd80x3.c 1.0.6 2019/04/11 + * Version: @(#)net_wd80x3.c 1.0.7 2019/05/02 * * Authors: Fred N. van Kempen, * TheCollector1995, @@ -116,23 +116,23 @@ typedef struct { } nic_t; -static void wd_rx(void *, uint8_t *, int); +static void nic_rx(void *, uint8_t *, int); static void nic_tx(nic_t *, uint32_t); static void -wd_interrupt(nic_t *dev, int set) +nic_interrupt(nic_t *dev, int set) { if (set) - picint(1<base_irq); + picint(1 << dev->base_irq); else - picintc(1<base_irq); + picintc(1 << dev->base_irq); } /* reset - restore state to power-up, cancelling all i/o */ static void -wd_reset(void *priv) +nic_reset(void *priv) { nic_t *dev = (nic_t *)priv; @@ -182,12 +182,12 @@ wd_reset(void *priv) dev->dp8390.ISR.reset = 1; dev->dp8390.DCR.longaddr = 1; - wd_interrupt(dev, 0); + nic_interrupt(dev, 0); } static uint32_t -wd_chipmem_read(nic_t *dev, uint32_t addr, unsigned int len) +chipmem_read(nic_t *dev, uint32_t addr, unsigned int len) { uint32_t retval = 0; @@ -210,7 +210,7 @@ wd_chipmem_read(nic_t *dev, uint32_t addr, unsigned int len) static uint32_t -wd_ram_read(uint32_t addr, unsigned len, void *priv) +ram_read(uint32_t addr, unsigned len, void *priv) { nic_t *dev = (nic_t *)priv; uint32_t ret; @@ -239,34 +239,34 @@ wd_ram_read(uint32_t addr, unsigned len, void *priv) static uint8_t -wd_ram_readb(uint32_t addr, void *priv) +ram_readb(uint32_t addr, void *priv) { nic_t *dev = (nic_t *)priv; - return wd_ram_read(addr, 1, dev); + return ram_read(addr, 1, dev); } static uint16_t -wd_ram_readw(uint32_t addr, void *priv) +ram_readw(uint32_t addr, void *priv) { nic_t *dev = (nic_t *)priv; - return wd_ram_read(addr, 2, dev); + return ram_read(addr, 2, dev); } static uint32_t -wd_ram_readl(uint32_t addr, void *priv) +ram_readl(uint32_t addr, void *priv) { nic_t *dev = (nic_t *)priv; - return wd_ram_read(addr, 4, dev); + return ram_read(addr, 4, dev); } static void -wd_ram_write(uint32_t addr, uint32_t val, unsigned len, void *priv) +ram_write(uint32_t addr, uint32_t val, unsigned len, void *priv) { nic_t *dev = (nic_t *)priv; @@ -284,34 +284,34 @@ wd_ram_write(uint32_t addr, uint32_t val, unsigned len, void *priv) static void -wd_ram_writeb(uint32_t addr, uint8_t val, void *priv) +ram_writeb(uint32_t addr, uint8_t val, void *priv) { nic_t *dev = (nic_t *)priv; - wd_ram_write(addr, val, 1, dev); + ram_write(addr, val, 1, dev); } static void -wd_ram_writew(uint32_t addr, uint16_t val, void *priv) +ram_writew(uint32_t addr, uint16_t val, void *priv) { nic_t *dev = (nic_t *)priv; - wd_ram_write(addr, val, 2, dev); + ram_write(addr, val, 2, dev); } static void -wd_ram_writel(uint32_t addr, uint32_t val, void *priv) +ram_writel(uint32_t addr, uint32_t val, void *priv) { nic_t *dev = (nic_t *)priv; - wd_ram_write(addr, val, 4, dev); + ram_write(addr, val, 4, dev); } static uint32_t -wd_smc_read(nic_t *dev, uint32_t off) +smc_read(nic_t *dev, uint32_t off) { uint32_t sum; uint32_t ret = 0; @@ -400,7 +400,7 @@ wd_smc_read(nic_t *dev, uint32_t off) static void -wd_smc_write(nic_t *dev, uint32_t off, uint32_t val) +smc_write(nic_t *dev, uint32_t off, uint32_t val) { DBGLOG(2, "%s: ASIC write addr=0x%02x, value=0x%04x\n", dev->name, (unsigned)off, (unsigned)val); @@ -609,7 +609,7 @@ page0_write(nic_t *dev, uint32_t off, uint8_t val) (dev->dp8390.IMR.tx_inte << 1) | (dev->dp8390.IMR.rx_inte)); if (val == 0x00) - wd_interrupt(dev, 0); + nic_interrupt(dev, 0); break; case 0x08: /* RSAR0 */ @@ -737,9 +737,9 @@ page0_write(nic_t *dev, uint32_t off, uint8_t val) (dev->dp8390.ISR.pkt_tx << 1) | (dev->dp8390.ISR.pkt_rx)); if (((val & val2) & 0x7f) == 0) - wd_interrupt(dev, 0); + nic_interrupt(dev, 0); else - wd_interrupt(dev, 1); + nic_interrupt(dev, 1); break; default: @@ -1028,7 +1028,7 @@ write_cr(nic_t *dev, uint8_t val) if (dev->dp8390.CR.rdma_cmd == 3) { /* Set up DMA read from receive ring */ dev->dp8390.remote_start = dev->dp8390.remote_dma = dev->dp8390.bound_ptr * 256; - dev->dp8390.remote_bytes = (uint16_t) wd_chipmem_read(dev, dev->dp8390.bound_ptr * 256 + 2, 2); + dev->dp8390.remote_bytes = (uint16_t)chipmem_read(dev, dev->dp8390.bound_ptr * 256 + 2, 2); DBGLOG(1, "%s: sending buffer #x%x length %d\n", dev->name, dev->dp8390.remote_start, dev->dp8390.remote_bytes); } @@ -1036,7 +1036,7 @@ write_cr(nic_t *dev, uint8_t val) /* Check for start-tx */ if ((val & 0x04) && dev->dp8390.TCR.loop_cntl) { if (dev->dp8390.TCR.loop_cntl) { - wd_rx(dev, &dev->dp8390.mem[dev->dp8390.tx_page_start*256 - DP8390_WORD_MEMSTART], + nic_rx(dev, &dev->dp8390.mem[dev->dp8390.tx_page_start*256 - DP8390_WORD_MEMSTART], dev->dp8390.tx_bytes); } } else if (val & 0x04) { @@ -1065,15 +1065,15 @@ write_cr(nic_t *dev, uint8_t val) if (dev->dp8390.CR.rdma_cmd == 0x01 && dev->dp8390.CR.start && dev->dp8390.remote_bytes == 0) { dev->dp8390.ISR.rdma_done = 1; if (dev->dp8390.IMR.rdma_inte) { - wd_interrupt(dev, 1); - wd_interrupt(dev, 0); + nic_interrupt(dev, 1); + nic_interrupt(dev, 0); } } } static uint8_t -wd_readb(uint16_t addr, void *priv) +nic_readb(uint16_t addr, void *priv) { nic_t *dev = (nic_t *)priv; int off = addr - dev->base_address; @@ -1084,7 +1084,7 @@ wd_readb(uint16_t addr, void *priv) if (off == 0x10) retval = read_cr(dev); else if (off >= 0x00 && off <= 0x0f) - retval = wd_smc_read(dev, off); + retval = smc_read(dev, off); else switch(dev->dp8390.CR.pgsel) { case 0x00: retval = page0_read(dev, off - 0x10); @@ -1109,7 +1109,7 @@ wd_readb(uint16_t addr, void *priv) static void -wd_writeb(uint16_t addr, uint8_t val, void *priv) +nic_writeb(uint16_t addr, uint8_t val, void *priv) { nic_t *dev = (nic_t *)priv; int off = addr - dev->base_address; @@ -1119,7 +1119,7 @@ wd_writeb(uint16_t addr, uint8_t val, void *priv) if (off == 0x10) write_cr(dev, val); else if (off >= 0x00 && off <= 0x0f) - wd_smc_write(dev, off, val); + smc_write(dev, off, val); else switch(dev->dp8390.CR.pgsel) { case 0x00: page0_write(dev, off - 0x10, val); @@ -1138,18 +1138,18 @@ wd_writeb(uint16_t addr, uint8_t val, void *priv) static void -wd_ioset(nic_t *dev, uint16_t addr) +nic_ioset(nic_t *dev, uint16_t addr) { io_sethandler(addr, 0x20, - wd_readb, NULL, NULL, wd_writeb, NULL, NULL, dev); + nic_readb, NULL, NULL, nic_writeb, NULL, NULL, dev); } static void -wd_ioremove(nic_t *dev, uint16_t addr) +nic_ioremove(nic_t *dev, uint16_t addr) { io_removehandler(addr, 0x20, - wd_readb, NULL, NULL, wd_writeb, NULL, NULL, dev); + nic_readb, NULL, NULL, nic_writeb, NULL, NULL, dev); } @@ -1160,7 +1160,7 @@ wd_ioremove(nic_t *dev, uint16_t addr) * it is copied into it and the receive process is updated. */ static void -wd_rx(void *priv, uint8_t *buf, int io_len) +nic_rx(void *priv, uint8_t *buf, int io_len) { static uint8_t bcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; nic_t *dev = (nic_t *)priv; @@ -1287,7 +1287,7 @@ wd_rx(void *priv, uint8_t *buf, int io_len) dev->dp8390.ISR.pkt_rx = 1; if (dev->dp8390.IMR.rx_inte) - wd_interrupt(dev, 1); + nic_interrupt(dev, 1); ui_sb_icon_update(SB_NETWORK, 0); } @@ -1302,14 +1302,14 @@ nic_tx(nic_t *dev, uint32_t val) /* Generate an interrupt if not masked */ if (dev->dp8390.IMR.tx_inte) - wd_interrupt(dev, 1); + nic_interrupt(dev, 1); dev->dp8390.tx_timer_active = 0; } static uint8_t -wd_mca_read(int port, void *priv) +nic_mca_read(int port, void *priv) { nic_t *dev = (nic_t *)priv; @@ -1318,7 +1318,7 @@ wd_mca_read(int port, void *priv) static void -wd_mca_write(int port, uint8_t val, void *priv) +nic_mca_write(int port, uint8_t val, void *priv) { nic_t *dev = (nic_t *)priv; int8_t irqs[4] = { 3, 4, 10, 15 }; @@ -1330,7 +1330,7 @@ wd_mca_write(int port, uint8_t val, void *priv) /* Save the MCA register value. */ dev->pos_regs[port & 7] = val; - wd_ioremove(dev, dev->base_address); + nic_ioremove(dev, dev->base_address); dev->base_address = 0x800 + (((dev->pos_regs[2] & 0xf0) >> 4) * 0x1000); dev->base_irq = irqs[(dev->pos_regs[5] & 0x0c) >> 2]; @@ -1349,13 +1349,13 @@ wd_mca_write(int port, uint8_t val, void *priv) /* Initialize the device if fully configured. */ if (dev->pos_regs[2] & 0x01) { /* Card enabled; register (new) I/O handler. */ - wd_ioset(dev, dev->base_address); + nic_ioset(dev, dev->base_address); - wd_reset(dev); + nic_reset(dev); mem_map_add(&dev->ram_mapping, dev->ram_addr, ram_size, - wd_ram_readb, wd_ram_readw, wd_ram_readl, - wd_ram_writeb, wd_ram_writew, wd_ram_writel, + ram_readb, ram_readw, ram_readl, + ram_writeb, ram_writew, ram_writel, NULL, MEM_MAPPING_EXTERNAL, dev); mem_map_disable(&dev->ram_mapping); @@ -1366,8 +1366,24 @@ wd_mca_write(int port, uint8_t val, void *priv) } +static void +nic_close(void *priv) +{ + nic_t *dev = (nic_t *)priv; + + /* Make sure the platform layer is shut down. */ + network_close(); + + nic_ioremove(dev, dev->base_address); + + DEBUG("%s: closed\n", dev->name); + + free(dev); +} + + static void * -wd_init(const device_t *info, UNUSED(void *parent)) +nic_init(const device_t *info, UNUSED(void *parent)) { uint32_t mac; nic_t *dev; @@ -1407,7 +1423,7 @@ wd_init(const device_t *info, UNUSED(void *parent)) dev->base_irq = device_get_config_int("irq"); dev->ram_addr = device_get_config_hex20("ram_addr"); } else { - mca_add(wd_mca_read, wd_mca_write, dev); + mca_add(nic_mca_read, nic_mca_write, dev); } /* See if we have a local MAC address configured. */ @@ -1418,7 +1434,7 @@ wd_init(const device_t *info, UNUSED(void *parent)) * PnP and PCI devices start with address spaces inactive. */ if (dev->board != WD8013EPA) - wd_ioset(dev, dev->base_address); + nic_ioset(dev, dev->base_address); /* Set up our BIA. */ if (mac & 0xff000000) { @@ -1445,16 +1461,19 @@ wd_init(const device_t *info, UNUSED(void *parent)) /* Reset the board. */ if (dev->board != WD8013EPA) - wd_reset(dev); + nic_reset(dev); /* Attach ourselves to the network module. */ - network_attach(dev, dev->dp8390.physaddr, wd_rx); + if (! network_attach(dev, dev->dp8390.physaddr, nic_rx)) { + nic_close(dev); + + return(NULL); + } /* Map this system into the memory map. */ if (dev->board != WD8013EPA) { mem_map_add(&dev->ram_mapping, dev->ram_addr, 0x4000, - wd_ram_readb, NULL, NULL, - wd_ram_writeb, NULL, NULL, + ram_readb, NULL, NULL, ram_writeb, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, dev); mem_map_disable(&dev->ram_mapping); @@ -1466,22 +1485,6 @@ wd_init(const device_t *info, UNUSED(void *parent)) } -static void -wd_close(void *priv) -{ - nic_t *dev = (nic_t *)priv; - - /* Make sure the platform layer is shut down. */ - network_close(); - - wd_ioremove(dev, dev->base_address); - - DEBUG("%s: closed\n", dev->name); - - free(dev); -} - - static const device_config_t wd8003_config[] = { { "base", "Address", CONFIG_HEX16, "", 0x300, @@ -1656,7 +1659,7 @@ const device_t wd8003e_device = { DEVICE_ISA, WD8003E, NULL, - wd_init, wd_close, NULL, + nic_init, nic_close, NULL, NULL, NULL, NULL, NULL, wd8003_config }; @@ -1666,7 +1669,7 @@ const device_t wd8013ebt_device = { DEVICE_ISA, WD8013EBT, NULL, - wd_init, wd_close, NULL, + nic_init, nic_close, NULL, NULL, NULL, NULL, NULL, wd8013_config }; @@ -1676,7 +1679,7 @@ const device_t wd8013epa_device = { DEVICE_MCA, WD8013EPA, NULL, - wd_init, wd_close, NULL, + nic_init, nic_close, NULL, NULL, NULL, NULL, NULL, mca_config }; diff --git a/src/devices/network/network.c b/src/devices/network/network.c index 7123c46..9503f80 100644 --- a/src/devices/network/network.c +++ b/src/devices/network/network.c @@ -8,7 +8,7 @@ * * Implementation of the network module. * - * Version: @(#)network.c 1.0.19 2019/03/06 + * Version: @(#)network.c 1.0.20 2019/05/03 * * Author: Fred N. van Kempen, * @@ -53,6 +53,7 @@ #define HAVE_STDARG_H #define dbglog network_log #include "../../emu.h" +#include "../../config.h" #include "../../device.h" #include "../../ui/ui.h" #include "../../plat.h" @@ -88,15 +89,15 @@ static const struct { const char *internal_name; const network_t *net; } networks[] = { - { "none", NULL }, + { "none", NULL }, - { "slirp", &network_slirp }, - { "pcap", &network_pcap }, + { "slirp", &network_slirp }, + { "pcap", &network_pcap }, #ifdef USE_VNS - { "vns", &network_vns }, + { "vns", &network_vns }, #endif - { NULL, NULL } + { NULL, NULL } }; @@ -104,15 +105,13 @@ static const struct { int network_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (networks[c].internal_name != NULL) { + for (c = 0; networks[c].internal_name != NULL; c++) if (! strcmp(networks[c].internal_name, s)) - return(c); - c++; - } + return(c); - /* Not found. */ + /* Not found or not available. */ return(0); } @@ -211,15 +210,14 @@ network_end(void) void network_init(void) { - wchar_t temp[512]; int i, k; /* Clear the local data. */ memset(&netdata, 0x00, sizeof(netdata_t)); /* Initialize to a known state. */ - network_type = 0; - network_card = 0; + config.network_type = NET_NONE; + config.network_card = NET_CARD_NONE; /* Create a first device entry that's always there, as needed by UI. */ strcpy(network_host_devs[0].device, "none"); @@ -232,15 +230,6 @@ network_init(void) /* Try to load network provider module. */ k = networks[i].net->init(&network_host_devs[network_host_ndev]); - if ((k < 0) && (i == network_type)) { - /* Provider not available. */ - swprintf(temp, sizeof_w(temp), - get_string(IDS_ERR_NOLIB), - networks[i].net->name, - network_host_devs[network_host_ndev].description); - ui_msgbox(MBX_ERROR, temp); - continue; - } /* If they have interfaces, add them. */ if (k > 0) @@ -256,38 +245,35 @@ network_init(void) * finished initializing itself, to link itself to the platform support * modules. */ -void +int network_attach(void *dev, uint8_t *mac, NETRXCB rx) { wchar_t temp[256]; - if (network_card == 0) return; + if (config.network_card == NET_CARD_NONE) + return(1); - /* Save the card's info. */ + /* Reset the network provider module. */ + if (networks[config.network_type].net->reset(mac) < 0) { + /* Tell user we can't do this (at the moment.) */ + swprintf(temp, sizeof_w(temp), get_string(IDS_ERR_NONET), + networks[config.network_type].net->name); + + (void)ui_msgbox(MBX_ERROR, temp); + + return(0); + } + + /* All good. Save the card's info. */ netdata.priv = dev; netdata.rx = rx; netdata.mac = mac; - /* Reset the network provider module. */ - if (networks[network_type].net->reset(mac) < 0) { - /* Tell user we can't do this (at the moment.) */ - swprintf(temp, sizeof_w(temp), - get_string(IDS_ERR_NONET), networks[network_type].net->name); - ui_msgbox(MBX_ERROR, temp); - - // FIXME: we should ask in the dialog if they want to - // reconfigure or quit, and throw them into the - // Settings dialog if yes. - - /* Disable network. */ - network_type = 0; - - return; - } - /* Create the network events. */ netdata.poll_wake = thread_create_event(); netdata.poll_complete = thread_create_event(); + + return(1); } @@ -295,16 +281,15 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx) void network_close(void) { - int i = 0; + int i; /* If already closed, do nothing. */ if (netdata.mutex == NULL) return; /* Force-close the network provider modules. */ - while (networks[i].internal_name != NULL) { + for (i = 0; networks[i].internal_name != NULL; i++) { if (networks[i].net) networks[i].net->close(); - i++; } /* Close the network events. */ @@ -339,11 +324,11 @@ network_reset(void) const device_t *dev; #ifdef ENABLE_NETWORK_LOG - INFO("NETWORK: reset (type=%d, card=%d) debug=%d\n", - network_type, network_card, network_do_log); + INFO("NETWORK: reset (type=%i, card=%i) debug=%i\n", + config.network_type, config.network_card, network_do_log); #else - INFO("NETWORK: reset (type=%d, card=%d)\n", - network_type, network_card); + INFO("NETWORK: reset (type=%i, card=%i)\n", + config.network_type, config.network_card); #endif ui_sb_icon_update(SB_NETWORK, 0); @@ -351,15 +336,18 @@ network_reset(void) network_close(); /* If no active card, we're done. */ - if ((network_type == 0) || (network_card == 0)) return; + if ((config.network_type == NET_NONE) || + (config.network_card == NET_CARD_NONE)) return; + + /* All good. */ + INFO("NETWORK: set up for %s, card='%s'\n", + network_getname(config.network_type), + network_card_getname(config.network_card)); netdata.mutex = thread_create_mutex(L"VARCem.NetMutex"); - INFO("NETWORK: set up for %s, card='%s'\n", - network_getname(network_type), network_card_getname(network_card)); - /* Add the selected card to the I/O system. */ - dev = network_card_getdevice(network_card); + dev = network_card_getdevice(config.network_card); if (dev != NULL) device_add(dev); } @@ -379,7 +367,7 @@ network_tx(uint8_t *bufp, int len) } #endif - networks[network_type].net->send(bufp, len); + networks[config.network_type].net->send(bufp, len); ui_sb_icon_update(SB_NETWORK, 0); } @@ -410,7 +398,7 @@ network_rx(uint8_t *bufp, int len) int network_card_to_id(const char *devname) { - int i = 0; + int i; for (i = 0; i < network_host_ndev; i++) { if (! strcmp(network_host_devs[i].device, devname)) { diff --git a/src/devices/network/network.h b/src/devices/network/network.h index 270488c..6ee2ac8 100644 --- a/src/devices/network/network.h +++ b/src/devices/network/network.h @@ -8,11 +8,11 @@ * * Definitions for the network module. * - * Version: @(#)network.h 1.0.8 2018/11/12 + * Version: @(#)network.h 1.0.9 2019/05/02 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -50,10 +50,17 @@ enum { - NET_TYPE_NONE = 0, - NET_TYPE_SLIRP, - NET_TYPE_PCAP, - NET_TYPE_VNS + NET_NONE = 0, + NET_SLIRP, + NET_PCAP +#ifdef USE_VNS + ,NET_VNS +#endif +}; + +enum { + NET_CARD_NONE = 0, + NET_CARD_INTERNAL }; @@ -103,7 +110,7 @@ extern void network_log(int level, const char *fmt, ...); extern void network_init(void); extern void network_close(void); extern void network_reset(void); -extern void network_attach(void *, uint8_t *, NETRXCB); +extern int network_attach(void *, uint8_t *, NETRXCB); extern void network_tx(uint8_t *, int); extern void network_rx(uint8_t *, int); diff --git a/src/devices/network/network_dev.c b/src/devices/network/network_dev.c index 1c08adb..e926ed4 100644 --- a/src/devices/network/network_dev.c +++ b/src/devices/network/network_dev.c @@ -12,11 +12,11 @@ * it should be malloc'ed and then linked to the NETCARD def. * Will be done later. * - * Version: @(#)network_dev.c 1.0.1 2018/11/04 + * Version: @(#)network_dev.c 1.0.2 2019/05/02 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -71,11 +71,15 @@ static const struct { const device_t *device; } net_cards[] = { { "none", NULL }, + { "internal", NULL }, /* ISA cards. */ { "ne1k", &ne1000_device }, { "ne2k", &ne2000_device }, - { "3c503", &tc503_device }, +#if 0 + { "3c501", &el1_device }, +#endif + { "3c503", &el2_device }, { "ne2kpnp", &rtl8019as_device }, { "wd8003e", &wd8003e_device }, { "wd8013ebt", &wd8013ebt_device }, @@ -119,13 +123,11 @@ network_card_log(int level, const char *fmt, ...) int network_card_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (net_cards[c].internal_name != NULL) { + for (c = 0; net_cards[c].internal_name != NULL; c++) if (! strcmp(net_cards[c].internal_name, s)) - return(c); - c++; - } + return(c); /* Not found. */ return(0); diff --git a/src/devices/ports/game.c b/src/devices/ports/game.c index 828b5db..e8b8e1a 100644 --- a/src/devices/ports/game.c +++ b/src/devices/ports/game.c @@ -8,7 +8,7 @@ * * Implementation of a generic Game Port. * - * Version: @(#)game.c 1.0.21 2019/04/25 + * Version: @(#)game.c 1.0.22 2019/05/03 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -43,6 +43,7 @@ #define HAVE_STDARG_H #define dbglog game_log #include "../../emu.h" +#include "../../config.h" #include "../../cpu/cpu.h" #include "../../io.h" #include "../../timer.h" @@ -190,7 +191,7 @@ game_init(const device_t *info, UNUSED(void *parent)) game_t *dev; int i; - INFO("GAME: initializing, type=%d\n", joystick_type); + INFO("GAME: initializing, type=%d\n", config.joystick_type); dev = (game_t *)mem_alloc(sizeof(game_t)); memset(dev, 0x00, sizeof(game_t)); @@ -204,8 +205,8 @@ game_init(const device_t *info, UNUSED(void *parent)) &dev->axis[i].count, &dev->axis[i].count); } - if (joystick_type != 0) { - dev->joystick = gamedev_get_device(joystick_type); + if (config.joystick_type != 0) { + dev->joystick = gamedev_get_device(config.joystick_type); dev->joystick_priv = dev->joystick->init(); } @@ -255,8 +256,8 @@ game_reset(void) dev->joystick = NULL; } - if (joystick_type != JOYSTICK_NONE) { - dev->joystick = gamedev_get_device(joystick_type); + if (config.joystick_type != JOYSTICK_NONE) { + dev->joystick = gamedev_get_device(config.joystick_type); dev->joystick_priv = dev->joystick->init(); } } diff --git a/src/devices/ports/parallel.c b/src/devices/ports/parallel.c index 99d5a00..6e3c14f 100644 --- a/src/devices/ports/parallel.c +++ b/src/devices/ports/parallel.c @@ -8,7 +8,7 @@ * * Implementation of the "LPT" style parallel ports. * - * Version: @(#)parallel.c 1.0.17 2019/04/14 + * Version: @(#)parallel.c 1.0.18 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -44,6 +44,7 @@ #define HAVE_STDARG_H #define dbglog parallel_log #include "../../emu.h" +#include "../../config.h" #include "../../io.h" #include "../../device.h" #include "../../plat.h" @@ -214,14 +215,14 @@ parallel_init(const device_t *info, UNUSED(void *parent)) parallel_write,NULL,NULL, dev); /* If the user configured a device for this port, attach it. */ - if (parallel_device[port] != 0) { - dev->dev_ts = parallel_device_get_device(parallel_device[port]); + if (config.parallel_device[port] != 0) { + dev->dev_ts = parallel_device_get_device(config.parallel_device[port]); if (dev->dev_ts != NULL) dev->dev_ps = dev->dev_ts->init(dev->dev_ts); } INFO("PARALLEL: %s (I/O=%04X, device=%i)\n", - info->name, dev->base, parallel_device[port]); + info->name, dev->base, config.parallel_device[port]); return(dev); } @@ -260,7 +261,7 @@ parallel_reset(void) int i; DEBUG("PARALLEL: reset ([%i] [%i] [%i])\n", - parallel_enabled[0], parallel_enabled[1], parallel_enabled[2]); + config.parallel_enabled[0], config.parallel_enabled[1], config.parallel_enabled[2]); for (i = 0; i < PARALLEL_MAX; i++) { dev = &ports[i]; @@ -279,8 +280,8 @@ parallel_setup(int id, uint16_t port) parallel_t *dev = &ports[id]; DEBUG("PARALLEL: setting up LPT%i as %04X [enabled=%i]\n", - id+1, port, parallel_enabled[id]); - if (! parallel_enabled[id]) return; + id+1, port, config.parallel_enabled[id]); + if (! config.parallel_enabled[id]) return; dev->base = port; } diff --git a/src/devices/ports/parallel.h b/src/devices/ports/parallel.h index 45c21a1..658760d 100644 --- a/src/devices/ports/parallel.h +++ b/src/devices/ports/parallel.h @@ -8,7 +8,7 @@ * * Definitions for the "LPT" parallel port handlerss. * - * Version: @(#)parallel.h 1.0.6 2019/04/14 + * Version: @(#)parallel.h 1.0.7 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -40,8 +40,6 @@ # define EMU_PARALLEL_H -#define PARALLEL_MAX 3 /* three ports supported */ - #define PARALLEL1_ADDR 0x0378 #define PARALLEL2_ADDR 0x0278 #define PARALLEL3_ADDR 0x03BC /* part of the MDA */ diff --git a/src/devices/ports/serial.c b/src/devices/ports/serial.c index 3389164..48468c2 100644 --- a/src/devices/ports/serial.c +++ b/src/devices/ports/serial.c @@ -32,7 +32,7 @@ * The lower half of the driver can interface to the host system * serial ports, or other channels, for real-world access. * - * Version: @(#)serial.c 1.0.16 2019/04/30 + * Version: @(#)serial.c 1.0.17 2019/05/03 * * Author: Fred N. van Kempen, * @@ -77,6 +77,7 @@ #define HAVE_STDARG_H #define dbglog serial_log #include "../../emu.h" +#include "../../config.h" #include "../../io.h" #include "../../mem.h" #include "../../rom.h" @@ -780,7 +781,7 @@ serial_reset(void) int i; DEBUG("SERIAL: reset ([%i] [%i])\n", - serial_enabled[0], serial_enabled[1]); + config.serial_enabled[0], config.serial_enabled[1]); for (i = 0; i < SERIAL_MAX; i++) { /* Get the correct device and clear it. */ @@ -832,9 +833,9 @@ serial_setup(int id, uint16_t port, int8_t irq) serial_t *dev = &ports[id]; INFO("SERIAL: setting up COM%i as %04X,%i [enabled=%i]\n", - id+1, port, irq, serial_enabled[id]); + id+1, port, irq, config.serial_enabled[id]); - if (! serial_enabled[id]) return; + if (! config.serial_enabled[id]) return; dev->base = port; dev->irq = irq; @@ -848,7 +849,7 @@ serial_attach(int port, serial_ops_t *ops, void *arg) serial_t *dev; /* No can do if port not enabled. */ - if (! serial_enabled[port]) return(NULL); + if (! config.serial_enabled[port]) return(NULL); /* Grab the desired port block. */ dev = &ports[port]; @@ -869,7 +870,7 @@ serial_link(int port, const char *arg) serial_t *dev; /* No can do if port not enabled. */ - if (! serial_enabled[port]) return(-1); + if (! config.serial_enabled[port]) return(-1); /* Grab the desired port block. */ dev = &ports[port]; diff --git a/src/devices/ports/serial.h b/src/devices/ports/serial.h index e1f4ccc..42e6cee 100644 --- a/src/devices/ports/serial.h +++ b/src/devices/ports/serial.h @@ -8,11 +8,11 @@ * * Definitions for the SERIAL card. * - * Version: @(#)serial.h 1.0.9 2018/11/23 + * Version: @(#)serial.h 1.0.10 2019/05/03 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -48,7 +48,6 @@ # define EMU_SERIAL_H -#define SERIAL_MAX 2 /* two ports supported */ #define SERIAL_FIFO_MAX 64 /* maximum FIFO size */ /* Default settings for the standard ports. */ diff --git a/src/devices/scsi/scsi.c b/src/devices/scsi/scsi.c index 8e7a2ba..abb57bd 100644 --- a/src/devices/scsi/scsi.c +++ b/src/devices/scsi/scsi.c @@ -8,7 +8,7 @@ * * Handling of the SCSI controllers. * - * Version: @(#)scsi.c 1.0.16 2019/04/23 + * Version: @(#)scsi.c 1.0.17 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -44,6 +44,7 @@ #define HAVE_STDARG_H #define dbglog scsi_card_log #include "../../emu.h" +#include "../../config.h" #include "../../device.h" #include "../../plat.h" #include "../disk/hdc.h" @@ -69,7 +70,7 @@ int scsi_card_do_log = ENABLE_SCSI_DEV_LOG; static const struct { const char *internal_name; const device_t *device; -} scsi_cards[] = { +} devices[] = { { "none", NULL }, { "internal", NULL }, @@ -101,20 +102,18 @@ static const struct { const char * scsi_card_get_internal_name(int card) { - return(scsi_cards[card].internal_name); + return(devices[card].internal_name); } int scsi_card_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (scsi_cards[c].internal_name != NULL) { - if (! strcmp(scsi_cards[c].internal_name, s)) + for (c = 0; devices[c].internal_name != NULL; c++) + if (! strcmp(devices[c].internal_name, s)) return(c); - c++; - } /* Not found. */ return(0); @@ -124,8 +123,8 @@ scsi_card_get_from_internal_name(const char *s) const char * scsi_card_getname(int card) { - if (scsi_cards[card].device != NULL) - return(scsi_cards[card].device->name); + if (devices[card].device != NULL) + return(devices[card].device->name); return(NULL); } @@ -134,15 +133,15 @@ scsi_card_getname(int card) const device_t * scsi_card_getdevice(int card) { - return(scsi_cards[card].device); + return(devices[card].device); } int scsi_card_has_config(int card) { - if (scsi_cards[card].device != NULL) - return(scsi_cards[card].device->config ? 1 : 0); + if (devices[card].device != NULL) + return(devices[card].device->config ? 1 : 0); return(0); } @@ -168,13 +167,14 @@ scsi_card_log(int level, const char *fmt, ...) int scsi_card_available(int card) { - if (scsi_cards[card].device) - return(device_available(scsi_cards[card].device)); + if (devices[card].device) + return(device_available(devices[card].device)); return(1); } +//FIXME: move part of this stuff to scsi_reset() void scsi_card_init(void) { @@ -195,6 +195,6 @@ scsi_card_init(void) } /* If we have one, initialize the configured SCSI controller. */ - if (scsi_cards[scsi_card].device != NULL) - device_add(scsi_cards[scsi_card].device); + if (devices[config.scsi_card].device != NULL) + device_add(devices[config.scsi_card].device); } diff --git a/src/devices/sound/midi.c b/src/devices/sound/midi.c index cf48c53..ffb00d1 100644 --- a/src/devices/sound/midi.c +++ b/src/devices/sound/midi.c @@ -8,13 +8,13 @@ * * MIDI support module, main file. * - * Version: @(#)midi.c 1.0.10 2018/10/20 + * Version: @(#)midi.c 1.0.11 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -45,6 +45,7 @@ #define HAVE_STDARG_H #define dbglog sound_midi_log #include "../../emu.h" +#include "../../config.h" #include "../../device.h" #include "../../plat.h" #include "sound.h" @@ -111,6 +112,7 @@ static const struct { const device_t *device; } devices[] = { {"none", NULL }, + #ifdef USE_FLUIDSYNTH {"fluidsynth", &fluidsynth_device }, #endif @@ -119,6 +121,7 @@ static const struct { {"cm32l", &cm32l_device }, #endif {SYSTEM_MIDI_INT, &system_midi_device }, + {NULL, NULL } }; static midi_t *midi = NULL; @@ -171,13 +174,11 @@ midi_device_get_internal_name(int card) int midi_device_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (devices[c].internal_name != NULL) { + for (c = 0; devices[c].internal_name != NULL; c++) if (! strcmp(devices[c].internal_name, s)) return(c); - c++; - } /* Not found. */ return(0); @@ -204,8 +205,8 @@ sound_midi_log(int level, const char *fmt, ...) void midi_device_init(void) { - if (devices[midi_device].device != NULL) - device_add(devices[midi_device].device); + if (devices[config.midi_device].device != NULL) + device_add(devices[config.midi_device].device); } diff --git a/src/devices/sound/midi_fluidsynth.c b/src/devices/sound/midi_fluidsynth.c index 4ec5f53..a686ec9 100644 --- a/src/devices/sound/midi_fluidsynth.c +++ b/src/devices/sound/midi_fluidsynth.c @@ -17,7 +17,7 @@ * website (for 32bit and 64bit Windows) are working, and * need no additional support files other than sound fonts. * - * Version: @(#)midi_fluidsynth.c 1.0.16 2019/04/11 + * Version: @(#)midi_fluidsynth.c 1.0.17 2019/05/03 * * Code borrowed from scummvm. * @@ -178,7 +178,7 @@ fluidsynth_thread(void *param) thread_wait_event(data->event, -1); thread_reset_event(data->event); - if (sound_is_float) { + if (config.sound_is_float) { float *buf = (float*)((uint8_t*)data->buffer + buf_pos); memset(buf, 0, buf_size); if (data->synth) @@ -324,7 +324,7 @@ fluidsynth_init(const device_t *info, UNUSED(void *parent)) double samplerate; f_fluid_settings_getnum(data->settings, "synth.sample-rate", &samplerate); data->samplerate = (int)samplerate; - if (sound_is_float) { + if (config.sound_is_float) { data->buf_size = (data->samplerate/RENDER_RATE)*2*sizeof(float)*BUFFER_SEGMENTS; data->buffer = (float *)mem_alloc(data->buf_size); data->buffer_int16 = NULL; diff --git a/src/devices/sound/midi_mt32.c b/src/devices/sound/midi_mt32.c index ecbad72..0b35e04 100644 --- a/src/devices/sound/midi_mt32.c +++ b/src/devices/sound/midi_mt32.c @@ -8,7 +8,7 @@ * * Interface to the MuNT32 MIDI synthesizer. * - * Version: @(#)midi_mt32.c 1.0.9 2019/04/11 + * Version: @(#)midi_mt32.c 1.0.10 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -44,6 +44,7 @@ #include "munt/c_interface/c_interface.h" #define dbglog sound_midi_log #include "../../emu.h" +#include "../../config.h" #include "../../mem.h" #include "../../rom.h" #include "../../device.h" @@ -184,7 +185,7 @@ mt32_thread(void *param) thread_wait_event(event, -1); thread_reset_event(event); - if (sound_is_float) { + if (config.sound_is_float) { buf = (float *) ((uint8_t*)buffer + buf_pos); memset(buf, 0, bsize); @@ -245,7 +246,7 @@ mt32emu_init(wchar_t *control_rom, wchar_t *pcm_rom) samplerate = mt32emu_get_actual_stereo_output_samplerate(context); /* buf_size = samplerate/RENDER_RATE*2; */ - if (sound_is_float) { + if (config.sound_is_float) { buf_size = (samplerate/RENDER_RATE)*2*BUFFER_SEGMENTS*sizeof(float); buffer = (float *)mem_alloc(buf_size); buffer_int16 = NULL; diff --git a/src/devices/sound/openal.c b/src/devices/sound/openal.c index e3acca1..0fd645a 100644 --- a/src/devices/sound/openal.c +++ b/src/devices/sound/openal.c @@ -8,13 +8,13 @@ * * Interface to the OpenAL sound processing library. * - * Version: @(#)openal.c 1.0.18 2018/10/24 + * Version: @(#)openal.c 1.0.19 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -53,6 +53,7 @@ #endif #define dbglog sound_log #include "../../emu.h" +#include "../../config.h" #include "../../ui/ui.h" #include "../../plat.h" #include "sound.h" @@ -252,12 +253,12 @@ openal_reset(void) * If the current MIDI device is neither "none", nor system MIDI, * initialize the MIDI buffer and source, otherwise, do not. */ - str = midi_device_get_internal_name(midi_device); + str = midi_device_get_internal_name(config.midi_device); if ((str != NULL) && (!strcmp(str, "none") || !strcmp(str, SYSTEM_MIDI_INT))) init_midi = 1; #ifdef USE_OPENAL - if (sound_is_float) { + if (config.sound_is_float) { buf = (float *)mem_alloc((BUFLEN << 1) * sizeof(float)); cd_buf = (float *)mem_alloc((CD_BUFLEN << 1) * sizeof(float)); if (init_midi) @@ -300,7 +301,7 @@ openal_reset(void) f_alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE ); } - if (sound_is_float) { + if (config.sound_is_float) { memset(buf,0,BUFLEN*2*sizeof(float)); memset(cd_buf,0,BUFLEN*2*sizeof(float)); if (init_midi) @@ -313,7 +314,7 @@ openal_reset(void) } for (c=0; c<4; c++) { - if (sound_is_float) { + if (config.sound_is_float) { f_alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); f_alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); if (init_midi) @@ -335,7 +336,7 @@ openal_reset(void) if (init_midi) f_alSourcePlay(source[2]); - if (sound_is_float) { + if (config.sound_is_float) { if (init_midi) free(midi_buf); free(cd_buf); @@ -369,12 +370,12 @@ openal_buffer_common(void *buf, uint8_t src, int size, int freq) f_alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed); if (processed >= 1) { - gain = pow(10.0, (double)sound_gain / 20.0); + gain = pow(10.0, (double)config.sound_gain / 20.0); f_alListenerf(AL_GAIN, (float)gain); f_alSourceUnqueueBuffers(source[src], 1, &buffer); - if (sound_is_float) { + if (config.sound_is_float) { f_alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, size * sizeof(float), freq); } else { f_alBufferData(buffer, AL_FORMAT_STEREO16, buf, size * sizeof(int16_t), freq); diff --git a/src/devices/sound/snd_dbopl.cpp b/src/devices/sound/snd_dbopl.cpp index 4d814fc..45a0fad 100644 --- a/src/devices/sound/snd_dbopl.cpp +++ b/src/devices/sound/snd_dbopl.cpp @@ -10,14 +10,14 @@ * * NOTE: See MSC_ macros for allocation on stack. --FvK * - * Version: @(#)snd_dbopl.cpp 1.0.8 2018/10/25 + * Version: @(#)snd_dbopl.cpp 1.0.9 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * TheCollector1995, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -39,14 +39,12 @@ * Boston, MA 02111-1307 * USA. */ -#ifdef _MSC_VER - /* for malloc() and printing of the related error message with pclog() */ -# include -# include -# include -# define dbglog sound_log -# include "../../emu.h" -#endif +#include +#include +#include +#define dbglog sound_log +#include "../../emu.h" +#include "../../config.h" #include "dbopl.h" #include "nukedopl.h" #include "sound.h" @@ -89,7 +87,7 @@ void opl_init(void (*timer_callback)(void *param, int timer, int64_t period), vo opl[nr].timer_callback = timer_callback; opl[nr].timer_param = timer_param; opl[nr].is_opl3 = is_opl3; - if (!opl_type) + if (! config.opl_type) { DBOPL::InitTables(); opl[nr].chip.Setup(48000, is_opl3); @@ -129,7 +127,7 @@ void opl_write(int nr, uint16_t addr, uint8_t val) { if (!(addr & 1)) { - if (!opl_type) + if (! config.opl_type) opl[nr].addr = (int)opl[nr].chip.WriteAddr(addr, val) & 0x1ff; else opl[nr].addr = (int)OPL3_WriteAddr(&opl[nr].opl3chip, addr, val) & 0x1ff; @@ -138,7 +136,7 @@ void opl_write(int nr, uint16_t addr, uint8_t val) } else { - if (!opl_type) + if (! config.opl_type) opl[nr].chip.WriteReg(opl[nr].addr, val); else { OPL3_WriteRegBuffered(&opl[nr].opl3chip, (uint16_t) opl[nr].addr, val); @@ -214,7 +212,7 @@ void opl2_update(int nr, int16_t *buffer, int samples) #endif int c; - if (opl_type) + if (config.opl_type) { OPL3_GenerateStream(&opl[nr].opl3chip, buffer, samples); } @@ -248,7 +246,7 @@ void opl3_update(int nr, int16_t *buffer, int samples) #endif int c; - if (opl_type) + if (config.opl_type) { OPL3_GenerateStream(&opl[nr].opl3chip, buffer, samples); } diff --git a/src/devices/sound/snd_dbopl.h b/src/devices/sound/snd_dbopl.h index 098d585..3b2a4b4 100644 --- a/src/devices/sound/snd_dbopl.h +++ b/src/devices/sound/snd_dbopl.h @@ -8,14 +8,14 @@ * * Definitions for the DOSbox OPL emulator. * - * Version: @(#)snd_dbopl.h 1.0.3 2018/09/04 + * Version: @(#)snd_dbopl.h 1.0.4 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * TheCollector1995, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -44,15 +44,15 @@ #ifdef __cplusplus extern "C" { #endif - extern int opl_type; - void opl_init(void (*timer_callback)(void *param, int timer, int64_t period), void *timer_param, int nr, int is_opl3); - void opl_write(int nr, uint16_t addr, uint8_t val); - uint8_t opl_read(int nr, uint16_t addr); - void opl_status_update(int nr); - void opl_timer_over(int nr, int timer); - void opl2_update(int nr, int16_t *buffer, int samples); - void opl3_update(int nr, int16_t *buffer, int samples); +void opl_init(void (*timer_callback)(void *param, int timer, int64_t period), void *timer_param, int nr, int is_opl3); +void opl_write(int nr, uint16_t addr, uint8_t val); +uint8_t opl_read(int nr, uint16_t addr); +void opl_status_update(int nr); +void opl_timer_over(int nr, int timer); +void opl2_update(int nr, int16_t *buffer, int samples); +void opl3_update(int nr, int16_t *buffer, int samples); + #ifdef __cplusplus } #endif diff --git a/src/devices/sound/sound.c b/src/devices/sound/sound.c index 9b3c44b..1854c4a 100644 --- a/src/devices/sound/sound.c +++ b/src/devices/sound/sound.c @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.18 2019/04/25 + * Version: @(#)sound.c 1.0.19 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,6 +45,7 @@ #define HAVE_STDARG_H #define dbglog sound_log #include "../../emu.h" +#include "../../config.h" #include "../../timer.h" #include "../../device.h" #include "../../plat.h" @@ -117,7 +118,7 @@ cd_thread(void *param) if (! cd_audioon) return; for (c = 0; c < CD_BUFLEN*2; c += 2) { - if (sound_is_float) { + if (config.sound_is_float) { cd_out_buffer[c] = 0.0; cd_out_buffer[c+1] = 0.0; } else { @@ -156,7 +157,7 @@ cd_thread(void *param) if (! r) { for (c = 0; c < CD_BUFLEN*2; c += 2) { - if (sound_is_float) { + if (config.sound_is_float) { cd_out_buffer[c] += 0.0; cd_out_buffer[c+1] += 0.0; } else { @@ -196,7 +197,7 @@ cd_thread(void *param) cd_buffer_temp2[1] *= (float)cd_vol_r; cd_buffer_temp2[1] /= 65535.0; - if (sound_is_float) { + if (config.sound_is_float) { cd_out_buffer[c] += (float)(cd_buffer_temp2[0] / 32768.0); cd_out_buffer[c+1] += (float)(cd_buffer_temp2[1] / 32768.0); } else { @@ -216,7 +217,7 @@ cd_thread(void *param) } } - if (sound_is_float) + if (config.sound_is_float) openal_buffer_cd(cd_out_buffer); else openal_buffer_cd(cd_out_buffer_int16); @@ -268,7 +269,7 @@ sound_poll(void *priv) handlers[c].get_buffer(outbuffer, SOUNDBUFLEN, handlers[c].priv); for (c = 0; c < SOUNDBUFLEN * 2; c++) { - if (sound_is_float) { + if (config.sound_is_float) { outbuffer_ex[c] = (float)((outbuffer[c]) / 32768.0); } else { if (outbuffer[c] > 32767) @@ -280,7 +281,7 @@ sound_poll(void *priv) } } - if (sound_is_float) + if (config.sound_is_float) openal_buffer(outbuffer_ex); else openal_buffer(outbuffer_ex_int16); @@ -321,7 +322,7 @@ sound_reset(void) { int i; - INFO("SOUND: reset (current=%i)\n", sound_card); + INFO("SOUND: reset (current=%i)\n", config.sound_card); /* Kill the CD-Audio thread. */ sound_cd_stop(); @@ -331,7 +332,7 @@ sound_reset(void) free(outbuffer_ex); if (outbuffer_ex_int16 != NULL) free(outbuffer_ex_int16); - if (sound_is_float) + if (config.sound_is_float) outbuffer_ex = (float *)mem_alloc(SOUNDBUFLEN * 2 * sizeof(float)); else outbuffer_ex_int16 = (int16_t *)mem_alloc(SOUNDBUFLEN * 2 * sizeof(int16_t)); @@ -361,7 +362,7 @@ sound_reset(void) sound_card_reset(); /* Enable the standlone MPU401 if needed. */ - if (mpu401_standalone_enable) + if (config.mpu401_standalone_enable) mpu401_device_add(); } diff --git a/src/devices/sound/sound_dev.c b/src/devices/sound/sound_dev.c index 7ae3e0e..aeaece7 100644 --- a/src/devices/sound/sound_dev.c +++ b/src/devices/sound/sound_dev.c @@ -8,7 +8,7 @@ * * Sound devices support module. * - * Version: @(#)sound_dev.c 1.0.12 2019/01/13 + * Version: @(#)sound_dev.c 1.0.13 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,6 +45,7 @@ #define HAVE_STDARG_H #define dbglog sound_card_log #include "../../emu.h" +#include "../../config.h" #include "../../device.h" #include "../../plat.h" #include "sound.h" @@ -86,7 +87,7 @@ extern const device_t ncr_business_audio_device; static const struct { const char *internal_name; const device_t *device; -} sound_cards[] = { +} devices[] = { { "none", NULL }, { "internal", NULL }, @@ -141,16 +142,16 @@ sound_card_log(int level, const char *fmt, ...) void sound_card_reset(void) { - if (sound_cards[sound_card].device != NULL) - device_add(sound_cards[sound_card].device); + if (devices[config.sound_card].device != NULL) + device_add(devices[config.sound_card].device); } int sound_card_available(int card) { - if (sound_cards[card].device != NULL) - return(device_available(sound_cards[card].device)); + if (devices[card].device != NULL) + return(device_available(devices[card].device)); return(1); } @@ -159,8 +160,8 @@ sound_card_available(int card) const char * sound_card_getname(int card) { - if (sound_cards[card].device != NULL) - return(sound_cards[card].device->name); + if (devices[card].device != NULL) + return(devices[card].device->name); return(NULL); } @@ -169,36 +170,35 @@ sound_card_getname(int card) const device_t * sound_card_getdevice(int card) { - return(sound_cards[card].device); + return(devices[card].device); } int sound_card_has_config(int card) { - if (sound_cards[card].device == NULL) return(0); + if (devices[card].device != NULL) + return(devices[card].device->config ? 1 : 0); - return(sound_cards[card].device->config ? 1 : 0); + return(0); } const char * sound_card_get_internal_name(int card) { - return(sound_cards[card].internal_name); + return(devices[card].internal_name); } int sound_card_get_from_internal_name(const char *s) { - int c = 0; + int c; - while (sound_cards[c].internal_name != NULL) { - if (! strcmp(sound_cards[c].internal_name, s)) + for (c = 0; devices[c].internal_name != NULL; c++) + if (! strcmp(devices[c].internal_name, s)) return(c); - c++; - } /* Not found. */ return(0); diff --git a/src/devices/system/nvr_at.c b/src/devices/system/nvr_at.c index 8853d77..73f6e76 100644 --- a/src/devices/system/nvr_at.c +++ b/src/devices/system/nvr_at.c @@ -189,7 +189,7 @@ * including the later update (DS12887A) which implemented a * "century" register to be compatible with Y2K. * - * Version: @(#)nvr_at.c 1.0.17 2019/04/29 + * Version: @(#)nvr_at.c 1.0.18 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -226,6 +226,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../cpu/cpu.h" #include "../../machines/machine.h" #include "../../io.h" @@ -553,7 +554,7 @@ nvr_write(uint16_t addr, uint8_t val, void *priv) if ((local->addr < RTC_REGA) || ((local->cent != 0xff) && (local->addr == local->cent))) { if ((local->addr != 1) && (local->addr != 3) && (local->addr != 5)) { - if ((old != val) && (time_sync == TIME_SYNC_DISABLED)) { + if ((old != val) && (config.time_sync == TIME_SYNC_DISABLED)) { /* Update internal clock. */ time_get(nvr, &tm); nvr_time_set(&tm); @@ -629,7 +630,7 @@ nvr_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (time_sync != TIME_SYNC_DISABLED) { + if (config.time_sync != TIME_SYNC_DISABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); time_set(nvr, &tm); diff --git a/src/devices/video/vid_ati_mach64.c b/src/devices/video/vid_ati_mach64.c index b9e3b49..9fd8493 100644 --- a/src/devices/video/vid_ati_mach64.c +++ b/src/devices/video/vid_ati_mach64.c @@ -8,7 +8,7 @@ * * ATi Mach64 graphics card emulation. * - * Version: @(#)vid_ati_mach64.c 1.0.18 2019/04/19 + * Version: @(#)vid_ati_mach64.c 1.0.19 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_bt48x_ramdac.c b/src/devices/video/vid_bt48x_ramdac.c index 3ce319d..462e738 100644 --- a/src/devices/video/vid_bt48x_ramdac.c +++ b/src/devices/video/vid_bt48x_ramdac.c @@ -8,7 +8,7 @@ * * Brooktree Bt48x series true color RAMDAC emulation. * - * Version: @(#)vid_bt48x_ramdac.c 1.0.14 2019/04/12 + * Version: @(#)vid_bt48x_ramdac.c 1.0.15 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_cl54xx.c b/src/devices/video/vid_cl54xx.c index 78355d4..b529465 100644 --- a/src/devices/video/vid_cl54xx.c +++ b/src/devices/video/vid_cl54xx.c @@ -9,7 +9,7 @@ * Emulation of select Cirrus Logic cards (CL-GD 5428, * CL-GD 5429, 5430, 5434 and 5436 are supported). * - * Version: @(#)vid_cl54xx.c 1.0.28 2019/04/19 + * Version: @(#)vid_cl54xx.c 1.0.29 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_colorplus.c b/src/devices/video/vid_colorplus.c index 4c190b9..bf75bbe 100644 --- a/src/devices/video/vid_colorplus.c +++ b/src/devices/video/vid_colorplus.c @@ -8,7 +8,7 @@ * * Plantronics ColorPlus emulation. * - * Version: @(#)vid_colorplus.c 1.0.14 2019/04/25 + * Version: @(#)vid_colorplus.c 1.0.15 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,6 +43,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../cpu/cpu.h" #include "../../io.h" #include "../../mem.h" @@ -404,7 +405,7 @@ colorplus_init(const device_t *info, UNUSED(void *parent)) (const video_timings_t *)info->vid_timing); /* Force the LPT3 port to be enabled. */ - parallel_enabled[2] = 1; + config.parallel_enabled[2] = 1; parallel_setup(2, 0x03bc); return dev; diff --git a/src/devices/video/vid_ega.c b/src/devices/video/vid_ega.c index 6ba8cb3..a612b6d 100644 --- a/src/devices/video/vid_ega.c +++ b/src/devices/video/vid_ega.c @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.16 2019/04/30 + * Version: @(#)vid_ega.c 1.0.17 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_ega_render.c b/src/devices/video/vid_ega_render.c index 9520da9..dd9a19e 100644 --- a/src/devices/video/vid_ega_render.c +++ b/src/devices/video/vid_ega_render.c @@ -9,7 +9,7 @@ * EGA renderers. * NOTE: FIXME: make sure this works (line 99 shadow parameter) * - * Version: @(#)vid_ega_render.c 1.0.4 2019/03/07 + * Version: @(#)vid_ega_render.c 1.0.5 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_et4000w32.c b/src/devices/video/vid_et4000w32.c index 62a974f..1066633 100644 --- a/src/devices/video/vid_et4000w32.c +++ b/src/devices/video/vid_et4000w32.c @@ -12,7 +12,7 @@ * * FIXME: Note the madness on line 1163, fix that somehow? --FvK * - * Version: @(#)vid_et4000w32.c 1.0.19 2019/04/19 + * Version: @(#)vid_et4000w32.c 1.0.20 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_hercules.c b/src/devices/video/vid_hercules.c index fe636cf..c0026b7 100644 --- a/src/devices/video/vid_hercules.c +++ b/src/devices/video/vid_hercules.c @@ -8,7 +8,7 @@ * * Hercules emulation. * - * Version: @(#)vid_hercules.c 1.0.18 2019/04/25 + * Version: @(#)vid_hercules.c 1.0.19 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../io.h" #include "../../cpu/cpu.h" #include "../../mem.h" @@ -488,7 +489,7 @@ hercules_init(const device_t *info, UNUSED(void *parent)) (const video_timings_t *)info->vid_timing); /* Force the LPT3 port to be enabled. */ - parallel_enabled[2] = 1; + config.parallel_enabled[2] = 1; parallel_setup(2, 0x03bc); return(dev); diff --git a/src/devices/video/vid_herculesplus.c b/src/devices/video/vid_herculesplus.c index b9974ad..145163c 100644 --- a/src/devices/video/vid_herculesplus.c +++ b/src/devices/video/vid_herculesplus.c @@ -6,9 +6,9 @@ * * This file is part of the VARCem Project. * - * Hercules InColor emulation. + * Hercules Plus emulation. * - * Version: @(#)vid_hercules_plus.c 1.0.19 2019/04/25 + * Version: @(#)vid_hercules_plus.c 1.0.20 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../io.h" #include "../../mem.h" #include "../../rom.h" @@ -692,7 +693,7 @@ herculesplus_init(const device_t *info, UNUSED(void *parent)) (const video_timings_t *)info->vid_timing); /* Force the LPT3 port to be enabled. */ - parallel_enabled[2] = 1; + config.parallel_enabled[2] = 1; parallel_setup(2, 0x03bc); return dev; diff --git a/src/devices/video/vid_incolor.c b/src/devices/video/vid_incolor.c index db91614..7063edb 100644 --- a/src/devices/video/vid_incolor.c +++ b/src/devices/video/vid_incolor.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_incolor.c 1.0.17 2019/04/25 + * Version: @(#)vid_incolor.c 1.0.18 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../io.h" #include "../../mem.h" #include "../../rom.h" @@ -1016,7 +1017,7 @@ incolor_init(const device_t *info, UNUSED(void *parent)) (const video_timings_t *)info->vid_timing); /* Force the LPT3 port to be enabled. */ - parallel_enabled[2] = 1; + config.parallel_enabled[2] = 1; parallel_setup(2, 0x03bc); return(dev); diff --git a/src/devices/video/vid_mda.c b/src/devices/video/vid_mda.c index f05da57..90fc75c 100644 --- a/src/devices/video/vid_mda.c +++ b/src/devices/video/vid_mda.c @@ -8,7 +8,7 @@ * * MDA emulation. * - * Version: @(#)vid_mda.c 1.0.14 2019/04/25 + * Version: @(#)vid_mda.c 1.0.15 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,7 @@ #include #include #include "../../emu.h" +#include "../../config.h" #include "../../io.h" #include "../../mem.h" #include "../../rom.h" @@ -372,7 +373,7 @@ mda_standalone_init(const device_t *info, UNUSED(void *parent)) (const video_timings_t *)&mda_timings); /* Force the LPT3 port to be enabled. */ - parallel_enabled[2] = 1; + config.parallel_enabled[2] = 1; parallel_setup(2, 0x03bc); return(dev); diff --git a/src/devices/video/vid_svga.c b/src/devices/video/vid_svga.c index 75321c1..da233b9 100644 --- a/src/devices/video/vid_svga.c +++ b/src/devices/video/vid_svga.c @@ -11,7 +11,7 @@ * This is intended to be used by another SVGA driver, * and not as a card in it's own right. * - * Version: @(#)vid_svga.c 1.0.20 2019/04/27 + * Version: @(#)vid_svga.c 1.0.21 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_svga_render.c b/src/devices/video/vid_svga_render.c index 6274eee..f197878 100644 --- a/src/devices/video/vid_svga_render.c +++ b/src/devices/video/vid_svga_render.c @@ -8,7 +8,7 @@ * * SVGA renderers. * - * Version: @(#)vid_svga_render.c 1.0.15 2019/03/07 + * Version: @(#)vid_svga_render.c 1.0.16 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/vid_tgui9440.c b/src/devices/video/vid_tgui9440.c index 330a24b..3ee2f94 100644 --- a/src/devices/video/vid_tgui9440.c +++ b/src/devices/video/vid_tgui9440.c @@ -47,7 +47,7 @@ * access size or host data has any affect, but the Windows 3.1 * driver always reads bytes and write words of 0xffff. * - * Version: @(#)vid_tgui9440.c 1.0.14 2019/04/19 + * Version: @(#)vid_tgui9440.c 1.0.15 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/video/video.c b/src/devices/video/video.c index cb66e4b..e6703a3 100644 --- a/src/devices/video/video.c +++ b/src/devices/video/video.c @@ -8,7 +8,7 @@ * * Main video-rendering module. * - * Version: @(#)video.c 1.0.29 2019/04/29 + * Version: @(#)video.c 1.0.30 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,6 +46,7 @@ #define HAVE_STDARG_H #define dbglog video_log #include "../../emu.h" +#include "../../config.h" #include "../../cpu/cpu.h" #include "../../machines/machine.h" #include "../../io.h" @@ -83,7 +84,9 @@ int changeframecount = 2; int frames = 0; int fullchange = 0; int displine = 0; -int update_overscan = 0; +int enable_overscan, + update_overscan, + suppress_overscan; int overscan_x = 0, overscan_y = 0; @@ -573,7 +576,7 @@ video_palette_rebuild(void) } if ((cga_palette > 1) && (cga_palette < 8)) { - if (vid_cga_contrast != 0) { + if (config.vid_cga_contrast != 0) { for (c = 0; c < 16; c++) { pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], video_6to8[cgapal_mono[cga_palette - 2][c].g], @@ -811,13 +814,18 @@ video_reset(void) const device_t *dev; INFO("VIDEO: reset (video_card=%i, internal=%i)\n", - video_card, (machine_get_flags() & MACHINE_VIDEO) ? 1 : 0); + config.video_card, (machine_get_flags() & MACHINE_VIDEO) ? 1 : 0); /* Initialize the video font tables. */ video_load_font(MDA_FONT_ROM_PATH, FONT_MDA); + enable_overscan = config.enable_overscan; + update_overscan = 0; + suppress_overscan = 0; + /* Do not initialize internal cards here. */ - if ((video_card == VID_NONE) || (video_card == VID_INTERNAL) || \ + if ((config.video_card == VID_NONE) || + (config.video_card == VID_INTERNAL) || \ (machine_get_flags_fixed() & MACHINE_VIDEO)) return; /* Configure default timing parameters for the card. */ @@ -830,12 +838,12 @@ video_reset(void) /* Clear (deallocate) any video font memory. */ video_reset_font(); - dev = video_card_getdevice(video_card); + dev = video_card_getdevice(config.video_card); if (dev != NULL) device_add(dev); /* Enable the Voodoo if configured. */ - if (voodoo_enabled) + if (config.voodoo_enabled) device_add(&voodoo_device); } @@ -870,7 +878,7 @@ video_type(void) if (video_card_type == -1) { /* No video device loaded yet. */ - dev = video_card_getdevice(video_card); + dev = video_card_getdevice(config.video_card); if (dev != NULL) type = DEVICE_VIDEO_GET(dev->flags); } else @@ -983,23 +991,23 @@ video_color_transform(uint32_t color) uint8_t *clr8 = (uint8_t *)&color; #if 0 - if (!vid_grayscale && !invert_display) return color; + if (!config.vid_grayscale && !config.invert_display) return color; #endif - if (vid_grayscale) { - if (vid_graytype) { - if (vid_graytype == 1) + if (config.vid_grayscale) { + if (config.vid_graytype) { + if (config.vid_graytype == 1) color = ((54 * (uint32_t)clr8[2]) + (183 * (uint32_t)clr8[1]) + (18 * (uint32_t)clr8[0])) / 255; else color = ((uint32_t)clr8[2] + (uint32_t)clr8[1] + (uint32_t)clr8[0]) / 3; } else color = ((76 * (uint32_t)clr8[2]) + (150 * (uint32_t)clr8[1]) + (29 * (uint32_t)clr8[0])) / 255; - switch (vid_grayscale) { + switch (config.vid_grayscale) { case 2: case 3: case 4: - color = (uint32_t)shade[vid_grayscale][color]; + color = (uint32_t)shade[config.vid_grayscale][color]; break; default: @@ -1010,7 +1018,7 @@ video_color_transform(uint32_t color) } } - if (invert_display) + if (config.invert_display) color ^= 0x00ffffff; return color; diff --git a/src/devices/video/video.h b/src/devices/video/video.h index 772cde5..80bf50b 100644 --- a/src/devices/video/video.h +++ b/src/devices/video/video.h @@ -8,7 +8,7 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.34 2019/04/30 + * Version: @(#)video.h 1.0.35 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -131,7 +131,9 @@ extern uint32_t *video_6to8, extern uint32_t pal_lookup[256]; extern int fullchange; extern int xsize,ysize; -extern int update_overscan; +extern int enable_overscan, + update_overscan, + suppress_overscan; extern int overscan_x, overscan_y; extern int video_timing_read_b, diff --git a/src/emu.h b/src/emu.h index 7bf6802..616979b 100644 --- a/src/emu.h +++ b/src/emu.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)emu.h 1.0.34 2019/04/11 + * Version: @(#)emu.h 1.0.35 2019/05/03 * * Author: Fred N. van Kempen, * @@ -171,58 +171,6 @@ extern int settings_only; /* (O) only the settings dlg */ extern int log_level; /* (O) global logging level */ extern wchar_t log_path[1024]; /* (O) full path of logfile */ -/* Configuration variables. */ -extern int language; /* (C) language ID */ -extern int window_w, window_h, /* (C) window size and */ - window_x, window_y, /* position info */ - window_remember; -extern int vid_api, /* (C) video renderer */ - vid_resize, /* (C) allow resizing */ - vid_cga_contrast, /* (C) video */ - vid_fullscreen, /* (C) video */ - vid_fullscreen_first, /* (C) video */ - vid_fullscreen_scale, /* (C) video */ - vid_grayscale, /* (C) video */ - vid_graytype, /* (C) video */ - invert_display, /* (C) invert the display */ - suppress_overscan, /* (C) suppress overscans */ - scale, /* (C) screen scale factor */ - enable_overscan, /* (C) video */ - force_43, /* (C) video */ - rctrl_is_lalt; /* (C) set R-CTRL as L-ALT */ -extern int video_card, /* (C) graphics/video card */ - voodoo_enabled; /* (C) video option */ -extern int mouse_type; /* (C) selected mouse type */ -extern int time_sync; /* (C) enable time sync */ -extern int game_enabled, /* (C) enable game port */ - serial_enabled[], /* (C) enable serial ports */ - parallel_enabled[], /* (C) enable LPT ports */ - parallel_device[], /* (C) set up LPT devices */ - bugger_enabled, /* (C) enable ISAbugger */ - isamem_type[], /* (C) enable ISA mem cards */ - isartc_type; /* (C) enable ISA RTC card */ -#ifdef WALTJE -extern int romdos_enabled; /* (C) enable ROM DOS */ -#endif -extern int hdc_type; /* (C) HDC type */ -extern int scsi_card; /* (C) selected SCSI card */ -extern int sound_card, /* (C) selected sound card */ - sound_is_float, /* (C) sound uses FP values */ - sound_gain, /* (C) sound volume gain */ - mpu401_standalone_enable, /* (C) sound option */ - opl_type, /* (C) sound option */ - midi_device; /* (C) selected midi device */ -extern int joystick_type; /* (C) joystick type */ -extern int mem_size; /* (C) memory size */ -extern int machine_type; /* (C) current machine ID */ -extern int cpu_manufacturer, /* (C) cpu manufacturer */ - cpu_type, /* (C) cpu type */ - cpu_use_dynarec, /* (C) cpu uses/needs Dyna */ - enable_external_fpu; /* (C) enable external FPU */ -extern int network_type; /* (C) net provider type */ -extern int network_card; /* (C) net interface num */ -extern char network_host[512]; /* (C) host network intf */ - /* Global variables. */ extern char emu_title[64]; /* full name of application */ extern char emu_version[32]; /* short version ID string */ @@ -231,6 +179,7 @@ extern wchar_t exe_path[1024]; /* emu executable path */ extern wchar_t emu_path[1024]; /* emu installation path */ extern wchar_t usr_path[1024]; /* path (dir) of user data */ extern wchar_t cfg_path[1024]; /* full path of config file */ +extern int mem_size; /* configured memory size */ extern int emu_lang_id; /* current language ID */ extern int scrnsz_x, /* current screen size, X */ scrnsz_y; /* current screen size, Y */ diff --git a/src/machines/m_amstrad.c b/src/machines/m_amstrad.c index cf0d9a6..d202b6b 100644 --- a/src/machines/m_amstrad.c +++ b/src/machines/m_amstrad.c @@ -15,7 +15,7 @@ * 80 columns. To be fixed... * Also, the DDM bits stuff needs to be verified. * - * Version: @(#)m_amstrad.c 1.0.27 2019/04/26 + * Version: @(#)m_amstrad.c 1.0.28 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,6 +50,7 @@ #include #define dbglog kbd_log #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -506,7 +507,7 @@ amstrad_init(const device_t *info, void *arg) device_add_ex(info, dev); /* Force the LPT1 port disabled and add our own. */ - parallel_enabled[0] = 0; + config.parallel_enabled[0] = 0; machine_common_init(); lpt = device_add(¶llel_1_device); @@ -544,7 +545,7 @@ amstrad_init(const device_t *info, void *arg) dev->vidtype = device_get_config_int("video_emulation"); dev->disptype = device_get_config_int("display_type"); - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { /* Initialize the internal video controller. */ dev->vid = m_amstrad_ida_init(dev->type, roms->fontfn, dev->codepage, @@ -565,7 +566,7 @@ amstrad_init(const device_t *info, void *arg) dev->vidtype = device_get_config_int("video_emulation"); dev->disptype = device_get_config_int("display_type"); - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { /* Initialize the internal video controller. */ dev->vid = m_amstrad_ida_init(1, roms->fontfn, dev->codepage, @@ -578,7 +579,7 @@ amstrad_init(const device_t *info, void *arg) break; case 4: /* PC2086 */ - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { device_add(¶dise_pvga1a_pc2086_device); video_inform(VID_TYPE_SPEC, &pvga1a_timing); } @@ -586,7 +587,7 @@ amstrad_init(const device_t *info, void *arg) break; case 5: /* PC3086 */ - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { device_add(¶dise_pvga1a_pc3086_device); video_inform(VID_TYPE_SPEC, &pvga1a_timing); } @@ -594,14 +595,14 @@ amstrad_init(const device_t *info, void *arg) break; case 6: /* MEGAPC */ - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { device_add(¶dise_wd90c11_megapc_device); video_inform(VID_TYPE_SPEC, &wd90c11_timing); } device_add(&fdc_at_actlow_device); break; } - parallel_enabled[0] = 1; + config.parallel_enabled[0] = 1; io_sethandler(0xdead, 1, ams_read,NULL,NULL, ams_write,NULL,NULL, dev); @@ -614,7 +615,7 @@ amstrad_init(const device_t *info, void *arg) keyboard_scan = 1; /* Initialize the (custom) mouse intercace if needed. */ - if (mouse_type == MOUSE_INTERNAL) { + if (config.mouse_type == MOUSE_INTERNAL) { io_sethandler(0x0078, 1, mse_read,NULL,NULL, mse_write,NULL,NULL, dev); io_sethandler(0x007a, 1, mse_read,NULL,NULL, mse_write,NULL,NULL, dev); diff --git a/src/machines/m_bull.c b/src/machines/m_bull.c index 3c759a6..a7d5d7e 100644 --- a/src/machines/m_bull.c +++ b/src/machines/m_bull.c @@ -18,7 +18,7 @@ * * Other than the above, the machine works as expected. * - * Version: @(#)m_bull.c 1.0.1 2019/04/23 + * Version: @(#)m_bull.c 1.0.2 2019/05/03 * * Authors: Fred N. van Kempen, * Idea from a patch for PCem by DNS2KV2, but fully rewritten. @@ -61,6 +61,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -98,20 +99,20 @@ common_init(const device_t *info, void *arg) /* Mainboard switch. */ mem_remap_top(384); - if (hdc_type == HDC_INTERNAL) + if (config.hdc_type == HDC_INTERNAL) device_add(&st506_at_wd1003_device); - if (video_card == VID_INTERNAL && ega) { + if (config.video_card == VID_INTERNAL && ega) { /* Paradise PGA2A, really! */ device_add(&ega_onboard_device); } - if (mouse_type == MOUSE_INTERNAL && mouse) { + if (config.mouse_type == MOUSE_INTERNAL && mouse) { priv = device_add(&mouse_msinport_onboard_device); mouse_bus_set_irq(priv, mouse); } - if (scsi_card == SCSI_INTERNAL && scsi) { + if (config.scsi_card == SCSI_INTERNAL && scsi) { priv = device_add(&scsi_ncr53c80_onboard_device); irq = machine_get_config_int("scsi_irq"); scsi_ncr5380_set_info(priv, scsi, irq); diff --git a/src/machines/m_compaq.c b/src/machines/m_compaq.c index 6e6b6f3..901089e 100644 --- a/src/machines/m_compaq.c +++ b/src/machines/m_compaq.c @@ -14,7 +14,7 @@ * (which is in m_compaq_vid.c), the Portable 3 needs the * Plasma driver, there are some ROM issues, etc. * - * Version: @(#)m_compaq.c 1.0.11 2019/04/14 + * Version: @(#)m_compaq.c 1.0.12 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -49,6 +49,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../mem.h" #include "../rom.h" @@ -177,7 +178,7 @@ cpq_init(const device_t *info, void *arg) device_add(&keyboard_xt_device); parallel_setup(0, 0x03bc); - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&compaq_video_device); device_add(&fdc_xt_device); @@ -191,7 +192,7 @@ cpq_init(const device_t *info, void *arg) write_ram,write_ramw,write_raml, ram + 0xa0000, MEM_MAPPING_INTERNAL, dev); - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&compaq_video_device); device_add(&fdc_at_device); @@ -205,7 +206,7 @@ cpq_init(const device_t *info, void *arg) write_ram,write_ramw,write_raml, ram + 0xa0000, MEM_MAPPING_INTERNAL, dev); - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&compaq_video_device); device_add(&fdc_at_device); @@ -219,7 +220,7 @@ cpq_init(const device_t *info, void *arg) write_ram,write_ramw,write_raml, ram + 0xa0000, MEM_MAPPING_INTERNAL, dev); - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) m_olim24_vid_init(1); device_add(&fdc_at_device); @@ -233,12 +234,12 @@ cpq_init(const device_t *info, void *arg) write_ram,write_ramw,write_raml, ram + 0xa0000, MEM_MAPPING_INTERNAL, dev); - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) m_olim24_vid_init(1); device_add(&fdc_at_device); - if (hdc_type == HDC_INTERNAL) + if (config.hdc_type == HDC_INTERNAL) device_add(&ide_isa_device); break; @@ -248,7 +249,7 @@ cpq_init(const device_t *info, void *arg) device_add(&fdc_at_device); - if (hdc_type == HDC_INTERNAL) + if (config.hdc_type == HDC_INTERNAL) device_add(&ide_isa_device); break; } diff --git a/src/machines/m_europc.c b/src/machines/m_europc.c index e34c0e2..6b8f1ba 100644 --- a/src/machines/m_europc.c +++ b/src/machines/m_europc.c @@ -69,7 +69,7 @@ * FIXME: Find a new way to handle the switching of color/mono on * external cards. New video_get_type(int card) function? * - * Version: @(#)m_europc.c 1.0.23 2019/04/29 + * Version: @(#)m_europc.c 1.0.24 2019/05/03 * * Author: Fred N. van Kempen, * @@ -117,6 +117,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -255,7 +256,7 @@ rtc_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (time_sync != TIME_SYNC_DISABLED) { + if (config.time_sync != TIME_SYNC_DISABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); rtc_time_set(nvr->regs, &tm); @@ -576,7 +577,7 @@ europc_init(const device_t *info, void *arg) * support it. To keep the NVRAM valid, however, we act * like we have it configured. */ - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { INFO("EuroPC: enabling CGA in place of AGA!\n"); device_add(&cga_device); } @@ -593,7 +594,7 @@ europc_init(const device_t *info, void *arg) * with values set by the user. */ b = (dev->nvr.regs[MRTC_CONF_D] & ~0x17); - if (video_card != VID_INTERNAL) { + if (config.video_card != VID_INTERNAL) { /* * OK, this is not exactly correct, either. * @@ -603,7 +604,7 @@ europc_init(const device_t *info, void *arg) * at the configured video card type, and perform an * "educated guess" as to its type.. */ - switch(video_card) { + switch(config.video_card) { case VID_MDA: /* MDA */ case VID_HERCULES: /* Hercules */ b |= 0x03; /* external video, mono */ @@ -657,7 +658,7 @@ europc_init(const device_t *info, void *arg) /* Update CPU speed. */ b = (dev->nvr.regs[MRTC_CONF_D] & 0x3f); - switch(cpu_type) { + switch(config.cpu_type) { case 0: /* 8088, 4.77 MHz */ b |= 0x00; break; @@ -674,21 +675,21 @@ europc_init(const device_t *info, void *arg) /* Set up game port. */ b = (dev->nvr.regs[MRTC_CONF_C] & 0xfc); - if (mouse_type == MOUSE_INTERNAL) { + if (config.mouse_type == MOUSE_INTERNAL) { /* Enable the Logitech Bus Mouse device. */ priv = device_add(&mouse_logibus_onboard_device); mouse_bus_set_irq(priv, 2); /* Configure the port for (Bus Mouse Compatible) Mouse. */ b |= 0x01; - } else if (game_enabled) { + } else if (config.game_enabled) { b |= 0x02; /* enable port as joysticks */ } dev->nvr.regs[MRTC_CONF_C] = b; /* Set up hard disks. */ b = dev->nvr.regs[MRTC_CONF_B] & 0x84; - if (hdc_type != HDC_NONE) + if (config.hdc_type != HDC_NONE) b |= 0x20; /* HD20 #1 */ /* Set up floppy types. */ @@ -747,7 +748,7 @@ europc_init(const device_t *info, void *arg) * * We only do this if we have not configured another one. */ - if (hdc_type == HDC_INTERNAL) + if (config.hdc_type == HDC_INTERNAL) (void)device_add(&xta_hd20_device); return(dev); diff --git a/src/machines/m_headland.c b/src/machines/m_headland.c index 5170c33..69fe44c 100644 --- a/src/machines/m_headland.c +++ b/src/machines/m_headland.c @@ -12,7 +12,7 @@ * so we can add configuration dialog for the onboard video * controller for the AMA machine. * - * Version: @(#)m_headland.c 1.0.12 2019/04/08 + * Version: @(#)m_headland.c 1.0.13 2019/05/03 * * Authors: Fred N. van Kempen, * Original by GreatPsycho for PCem. @@ -46,6 +46,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../cpu/x86.h" #include "../io.h" @@ -109,7 +110,7 @@ headland_init(const device_t *info, void *arg) case 12: /* Arche Technologies AMA-932J-25 */ device_add(&headland_386_device); - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { /* Load the BIOS. */ rom_init(&dev->vid_bios, roms->vidfn, 0xc0000, roms->vidsz, roms->vidsz - 1, 0, 0); diff --git a/src/machines/m_intel4x0.c b/src/machines/m_intel4x0.c index ebfcbb9..96c7a5a 100644 --- a/src/machines/m_intel4x0.c +++ b/src/machines/m_intel4x0.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 430/440-based machines. * - * Version: @(#)m_intel4x0.c 1.0.6 2019/04/08 + * Version: @(#)m_intel4x0.c 1.0.7 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -41,6 +41,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -132,7 +133,7 @@ common_init(const device_t *info, void *arg) device_add(&keyboard_ps2_ami_pci_device); device_add(&pc87306_device); - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { device_add(&s3_phoenix_trio64_onboard_pci_device); video_inform(VID_TYPE_SPEC, &endeavor_timing); } diff --git a/src/machines/m_olim24.c b/src/machines/m_olim24.c index 9aacb8b..e91c4d7 100644 --- a/src/machines/m_olim24.c +++ b/src/machines/m_olim24.c @@ -21,7 +21,7 @@ * data at all, so there seems to not be a way to properly do * that.. The chip's interrupt pin is not connected. * - * Version: @(#)m_olim24.c 1.0.19 2019/04/26 + * Version: @(#)m_olim24.c 1.0.209 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -58,6 +58,7 @@ #include #define dbglog kbd_log #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -472,7 +473,7 @@ rtc_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (time_sync != TIME_SYNC_DISABLED) { + if (config.time_sync != TIME_SYNC_DISABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); rtc_time_set(nvr->regs, &tm); diff --git a/src/machines/m_pbell.c b/src/machines/m_pbell.c index 7c623fe..cba54c3 100644 --- a/src/machines/m_pbell.c +++ b/src/machines/m_pbell.c @@ -8,7 +8,7 @@ * * Implementation of various Packard Bell machines. * - * Version: @(#)m_pbell.c 1.0.1 2019/04/08 + * Version: @(#)m_pbell.c 1.0.2 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -39,6 +39,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -88,7 +89,7 @@ common_init(const device_t *info, void *arg) ide_enable_pio_override(); device_add(&pc87306_device); - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&gd5440_onboard_pci_device); break; } diff --git a/src/machines/m_pcjr.c b/src/machines/m_pcjr.c index 106b054..17c827b 100644 --- a/src/machines/m_pcjr.c +++ b/src/machines/m_pcjr.c @@ -8,7 +8,7 @@ * * Emulation of the IBM PCjr. * - * Version: @(#)m_pcjr.c 1.0.19 2019/04/26 + * Version: @(#)m_pcjr.c 1.0.20 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,6 +43,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -774,7 +775,7 @@ pcjr_init(const device_t *info, UNUSED(void *arg)) nmi_mask = 0x80; - if (serial_enabled[0]) { + if (config.serial_enabled[0]) { serial_setup(1, 0x2f8, 3); device_add(&serial_1_pcjr_device); } diff --git a/src/machines/m_ps1.c b/src/machines/m_ps1.c index 6c2003d..3387133 100644 --- a/src/machines/m_ps1.c +++ b/src/machines/m_ps1.c @@ -22,7 +22,7 @@ * The reserved 384K is remapped to the top of extended memory. * If this is not done then you get an error on startup. * - * Version: @(#)m_ps1.c 1.0.26 2019/04/25 + * Version: @(#)m_ps1.c 1.0.27 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -56,6 +56,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -503,8 +504,8 @@ ps1_init(const device_t *info, void *arg) if (dev->model == 2011) { /* Force some configuration settings. */ - video_card = VID_INTERNAL; - mouse_type = MOUSE_PS2; + config.video_card = VID_INTERNAL; + config.mouse_type = MOUSE_PS2; mem_map_add(&dev->romext_mapping, 0xc8000, 0x08000, ps1_read_romext,ps1_read_romextw,ps1_read_romextl, @@ -528,14 +529,14 @@ ps1_init(const device_t *info, void *arg) device_add(&fdc_at_actlow_device); /* Enable the builtin HDC. */ - if (hdc_type == HDC_INTERNAL) + if (config.hdc_type == HDC_INTERNAL) device_add(&ps1_hdc_device); } if (dev->model == 2121) { /* Force some configuration settings. */ - video_card = VID_INTERNAL; - mouse_type = MOUSE_PS2; + config.video_card = VID_INTERNAL; + config.mouse_type = MOUSE_PS2; io_sethandler(0x00e0, 2, ps1_read,NULL,NULL, ps1_write,NULL,NULL, dev); @@ -563,8 +564,8 @@ ps1_init(const device_t *info, void *arg) if (dev->model == 2133) { /* Force some configuration settings. */ - hdc_type = HDC_INTERNAL; - mouse_type = MOUSE_PS2; + config.hdc_type = HDC_INTERNAL; + config.mouse_type = MOUSE_PS2; /* Enable the builtin FDC. */ device_add(&fdc_at_device); @@ -585,10 +586,10 @@ ps1_init(const device_t *info, void *arg) parallel_setup(0, 0x03bc); /* Hack to prevent Game from being initialized there. */ - i = game_enabled; - game_enabled = 0; + i = config.game_enabled; + config.game_enabled = 0; machine_common_init(); - game_enabled = i; + config.game_enabled = i; mem_remap_top(384); @@ -604,7 +605,7 @@ ps1_init(const device_t *info, void *arg) device_add(&mouse_ps2_device); /* Audio uses ports 200h,202-207h, so only initialize gameport on 201h. */ - if (game_enabled) + if (config.game_enabled) device_add(&game_201_device); return(dev); diff --git a/src/machines/m_ps2_mca.c b/src/machines/m_ps2_mca.c index 61d03b1..5520149 100644 --- a/src/machines/m_ps2_mca.c +++ b/src/machines/m_ps2_mca.c @@ -48,7 +48,7 @@ * * This works around the timing loop mentioned above. * - * Version: @(#)m_ps2_mca.c 1.0.24 2019/04/30 + * Version: @(#)m_ps2_mca.c 1.0.25 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -82,6 +82,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../cpu/x86.h" #include "../io.h" @@ -557,7 +558,7 @@ model_50_init(ps2_t *dev) mem_fffc_init(dev, 2); } - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&vga_ps1_device); } @@ -745,7 +746,7 @@ model_55sx_init(ps2_t *dev) dev->planar_read = model_55sx_read; dev->planar_write = model_55sx_write; - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&vga_ps1_device); } @@ -1071,7 +1072,7 @@ model_70_init(ps2_t *dev) mem_fffc_init(dev, 8); } - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&vga_ps1_device); } @@ -1238,7 +1239,7 @@ model_80_init(ps2_t *dev) mem_fffc_init(dev, 4); } - if (video_card == VID_INTERNAL) + if (config.video_card == VID_INTERNAL) device_add(&vga_ps1_device); } diff --git a/src/machines/m_tosh1x00.c b/src/machines/m_tosh1x00.c index 3fe71c6..6cc22d6 100644 --- a/src/machines/m_tosh1x00.c +++ b/src/machines/m_tosh1x00.c @@ -96,7 +96,7 @@ * * FIXME: The ROM drive should be re-done using the "option file". * - * Version: @(#)m_tosh1x00.c 1.0.19 2019/04/29 + * Version: @(#)m_tosh1x00.c 1.0.20 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -131,6 +131,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -283,7 +284,7 @@ tc8521_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (time_sync != TIME_SYNC_DISABLED) { + if (config.time_sync != TIME_SYNC_DISABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); tc8521_time_set(nvr->regs, &tm); @@ -1032,19 +1033,19 @@ t1000_init(const device_t *info, void *arg) if (dev->is_t1200) { dev->fdc = (fdc_t *)device_add(&fdc_toshiba_device); - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { /* Load the T1200 CGA Font ROM. */ video_load_font(T1200_FONT_PATH, FONT_CGA_THICK); device_add(&t1200_video_device); } - if (hdc_type == HDC_INTERNAL) + if (config.hdc_type == HDC_INTERNAL) (void)device_add(&xta_t1200_device); } else { dev->fdc = (fdc_t *)device_add(&fdc_xt_device); - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { /* Load the T1000 CGA Font ROM. */ video_load_font(T1000_FONT_PATH, FONT_CGA_THICK); diff --git a/src/machines/m_zenith.c b/src/machines/m_zenith.c index c70348d..8b84978 100644 --- a/src/machines/m_zenith.c +++ b/src/machines/m_zenith.c @@ -25,7 +25,7 @@ * to be done on implementing other parts of the Yamaha V6355 * chip that implements the video controller. * - * Version: @(#)m_zenith.c 1.0.5 2019/04/21 + * Version: @(#)m_zenith.c 1.0.6 2019/05/03 * * Authors: Fred N. van Kempen, * Original patch for PCem by 'Tux' @@ -57,6 +57,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" @@ -209,7 +210,7 @@ rtc_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (time_sync != TIME_SYNC_DISABLED) { + if (config.time_sync != TIME_SYNC_DISABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); rtc_time_set(nvr->regs, &tm); @@ -380,7 +381,7 @@ zenith_init(const device_t *info, void *arg) dev->sp_ram, MEM_MAPPING_EXTERNAL, dev); /* Only use the LCD if configured. */ - if (video_card == VID_INTERNAL) { + if (config.video_card == VID_INTERNAL) { vid = device_add_parent(&zenith_ss_video_device, dev); zenith_vid_set_internal(vid, dev->lcd); } diff --git a/src/machines/machine.c b/src/machines/machine.c index 87c0d0f..727b9de 100644 --- a/src/machines/machine.c +++ b/src/machines/machine.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.c 1.0.21 2019/04/29 + * Version: @(#)machine.c 1.0.22 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -41,6 +41,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../cpu/cpu.h" #include "../mem.h" #include "../rom.h" @@ -65,7 +66,7 @@ machine_load(void) { const device_t *dev; - dev = machine_get_device_ex(machine_type); + dev = machine_get_device_ex(config.machine_type); if (dev != NULL) machine = (machine_t *)dev->mach_info; @@ -86,7 +87,9 @@ machine_reset(void) dev = machine_load(); /* Set up the selected CPU at default speed. */ - cpu_set_type(machine->cpu[cpu_manufacturer].cpus, cpu_type); + cpu_set_type(machine->cpu[config.cpu_manuf].cpus, + config.cpu_manuf, config.cpu_type, + config.enable_ext_fpu, config.cpu_use_dynarec); /* Start with (max/turbo) speed. */ pc_set_speed(1); @@ -242,7 +245,7 @@ machine_available(int id) romdef_t r; int i; - dev = machine_get_device_ex(machine_type); + dev = machine_get_device_ex(config.machine_type); wcscpy(temp, MACHINES_PATH); plat_append_slash(temp); @@ -261,18 +264,18 @@ machine_common_init(void) dma_init(); pit_init(); - if (game_enabled) + if (config.game_enabled) device_add(&game_device); - if (parallel_enabled[0]) + if (config.parallel_enabled[0]) device_add(¶llel_1_device); - if (parallel_enabled[1]) + if (config.parallel_enabled[1]) device_add(¶llel_2_device); - if (parallel_enabled[2]) + if (config.parallel_enabled[2]) device_add(¶llel_3_device); - if (serial_enabled[0]) + if (config.serial_enabled[0]) device_add(&serial_1_device); - if (serial_enabled[1]) + if (config.serial_enabled[1]) device_add(&serial_2_device); } diff --git a/src/machines/machine.h b/src/machines/machine.h index a26654e..7327eec 100644 --- a/src/machines/machine.h +++ b/src/machines/machine.h @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.h 1.0.32 2019/04/29 + * Version: @(#)machine.h 1.0.33 2019/05/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -58,6 +58,7 @@ #define MACHINE_SOUND 0x080000 /* sys has int sound */ #define MACHINE_VIDEO 0x100000 /* sys has int video */ #define MACHINE_SCSI 0x200000 /* sys has int SCSI */ +#define MACHINE_NETWORK 0x400000 /* sys has int network */ #define IS_ARCH(a) (machine->flags & (a)) ? 1 : 0; diff --git a/src/machines/machine_table.c b/src/machines/machine_table.c index 83352f6..5662731 100644 --- a/src/machines/machine_table.c +++ b/src/machines/machine_table.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine_table.c 1.0.40 2019/04/23 + * Version: @(#)machine_table.c 1.0.42 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -189,11 +189,11 @@ static const struct { { "[Socket 7 FX] Intel Advanced/ATX", "intel_thor", &m_thor }, { "[Socket 7 FX] MR Intel Advanced/ATX", "intel_thor_mr", &m_thor_mr }, { "[Socket 7 FX] Intel Advanced/EV", "intel_endeavor", &m_endeavor }, + { "[Socket 7 FX] Acer V30", "acer_v30", &m_acer_v30 }, { "[Socket 7 FX] Packard Bell PB640", "pbell_pb640", &m_pb640 }, /* Pentium, Socket7 (HX) */ { "[Socket 7 HX] Acer M3a", "acer_m3a", &m_acer_m3a }, - { "[Socket 7 HX] Acer V30", "acer_v30", &m_acer_v30 }, { "[Socket 7 HX] Acer V35n", "acer_v35n", &m_acer_v35n }, { "[Socket 7 HX] AOpen AP53", "aopen_ap53", &m_ap53 }, { "[Socket 7 HX] ASUS P/I-P55T2P4", "asus_p55t2p4", &m_p55t2p4 }, @@ -240,7 +240,7 @@ machine_get_name_ex(int m) const char * machine_get_name(void) { - return(machine_get_name_ex(machine_type)); + return(machine_get_name_ex(config.machine_type)); } @@ -254,7 +254,7 @@ machine_get_internal_name_ex(int m) const char * machine_get_internal_name(void) { - return(machine_get_internal_name_ex(machine_type)); + return(machine_get_internal_name_ex(config.machine_type)); } @@ -268,7 +268,7 @@ machine_get_device_ex(int m) const device_t * machine_get_device(void) { - return(machine_get_device_ex(machine_type)); + return(machine_get_device_ex(config.machine_type)); } diff --git a/src/mem.c b/src/mem.c index 550ce41..1aa5949 100644 --- a/src/mem.c +++ b/src/mem.c @@ -12,7 +12,7 @@ * The Port92 stuff should be moved to devices/system/memctl.c * as a standard device. * - * Version: @(#)mem.c 1.0.34 2019/04/29 + * Version: @(#)mem.c 1.0.35 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -64,7 +64,8 @@ #endif -uint8_t *ram; /* the virtual RAM */ +int mem_size; /* the virtual RAM */ +uint8_t *ram; uint32_t rammask; mem_map_t base_mapping, @@ -1435,6 +1436,9 @@ mem_reset(void) { uint32_t c, m; + /* Get the configured memory size. */ + mem_size = config.mem_size; + /* * Make sure the configured amount of RAM does not * exceed the physical limit of the machine to avoid diff --git a/src/nvr.c b/src/nvr.c index edeeef7..a9253be 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -8,7 +8,7 @@ * * Implement a generic NVRAM/CMOS/RTC device. * - * Version: @(#)nvr.c 1.0.17 2019/04/26 + * Version: @(#)nvr.c 1.0.18 2019/05/03 * * Author: Fred N. van Kempen, * @@ -51,6 +51,7 @@ #include #include #include "emu.h" +#include "config.h" #include "machines/machine.h" #include "timer.h" #include "plat.h" @@ -198,11 +199,11 @@ nvr_init(nvr_t *nvr) /* Initialize the internal clock as needed. */ memset(&intclk, 0x00, sizeof(intclk)); - if (time_sync != TIME_SYNC_DISABLED) { + if (config.time_sync != TIME_SYNC_DISABLED) { /* Get the current time of day, and convert to local time. */ (void)time(&now); - if (time_sync == TIME_SYNC_ENABLED_UTC) + if (config.time_sync == TIME_SYNC_ENABLED_UTC) tm = gmtime(&now); else tm = localtime(&now); diff --git a/src/pc.c b/src/pc.c index d334a28..e32f6f0 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.73 2019/04/30 + * Version: @(#)pc.c 1.0.74 2019/05/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -88,94 +88,45 @@ #include "plat.h" -#define PCLOG_BUFF_SIZE 8192 /* has to be big enough!! */ +#define PCLOG_BUFF_SIZE 1024 /* buffer for one line */ /* Commandline options. */ -int dump_on_exit = 0; /* (O) dump regs on exit */ -int do_dump_config = 0; /* (O) dump config on load */ -int start_in_fullscreen = 0; /* (O) start in fullscreen */ +int dump_on_exit = 0; /* (O) dump regs on exit */ +int do_dump_config = 0; /* (O) dump config on load */ +int start_in_fullscreen = 0; /* (O) start in fullscreen */ #ifdef _WIN32 -int force_debug = 0; /* (O) force debug output */ +int force_debug = 0; /* (O) force debug output */ #endif #ifdef USE_WX -int video_fps = RENDER_FPS; /* (O) render speed in fps */ +int video_fps = RENDER_FPS; /* (O) render speed in fps */ #endif -int settings_only = 0; /* (O) only the settings dlg */ -int config_ro = 0; /* (O) dont modify cfg file */ -int log_level = LOG_INFO; /* (O) global logging level */ -wchar_t log_path[1024] = { L'\0'}; /* (O) full path of logfile */ +int settings_only = 0; /* (O) only the settings dlg */ +int config_ro = 0; /* (O) dont modify cfg file */ +int log_level = LOG_INFO; /* (O) global logging level */ +wchar_t log_path[1024] = { L'\0'}; /* (O) full path of logfile */ /* Configuration values. */ -int language = 0x0000; /* (C) language ID */ -int window_w, window_h, /* (C) window size and */ - window_x, window_y, /* position info */ - window_remember; -int vid_api = 0, /* (C) video renderer */ - vid_resize, /* (C) allow resizing */ - vid_cga_contrast = 0, /* (C) video */ - vid_fullscreen = 0, /* (C) video */ - vid_fullscreen_scale = 0, /* (C) video */ - vid_fullscreen_first = 0, /* (C) video */ - vid_grayscale = 0, /* (C) video */ - vid_graytype = 0, /* (C) video */ - invert_display = 0, /* (C) invert the display */ - suppress_overscan = 0, /* (C) suppress overscans */ - scale = 0, /* (C) screen scale factor */ - enable_overscan = 0, /* (C) video */ - force_43 = 0, /* (C) video */ - rctrl_is_lalt; /* (C) set R-CTRL as L-ALT */ -int video_card = 0, /* (C) graphics/video card */ - voodoo_enabled = 0; /* (C) video option */ -int mouse_type = 0; /* (C) selected mouse type */ -int time_sync = 0; /* (C) enable time sync */ -int game_enabled = 0, /* (C) enable game port */ - serial_enabled[] = {0,0}, /* (C) enable serial ports */ - parallel_enabled[] = {0,0,0}, /* (C) enable LPT ports */ - parallel_device[] = {0,0,0}, /* (C) set up LPT devices */ - bugger_enabled = 0, /* (C) enable ISAbugger */ - isamem_type[ISAMEM_MAX] = { 0,0,0,0 }, /* (C) enable ISA mem cards */ - isartc_type = 0; /* (C) enable ISA RTC card */ -#ifdef WALTJE -int romdos_enabled = 0; /* (C) enable ROM DOS */ -#endif -int hdc_type = HDC_NONE; /* (C) HDC type */ -int scsi_card = SCSI_NONE; /* (C) selected SCSI card */ -int sound_card = 0, /* (C) selected sound card */ - sound_is_float = 1, /* (C) sound uses FP values */ - sound_gain = 0, /* (C) sound volume gain */ - mpu401_standalone_enable = 0, /* (C) sound option */ - opl_type = 0, /* (C) sound option */ - midi_device; /* (C) selected midi device */ -int joystick_type = 0; /* (C) joystick type */ -int mem_size = 0; /* (C) memory size */ -int machine_type = -1; /* (C) current machine ID */ -int cpu_manufacturer = 0, /* (C) cpu manufacturer */ - cpu_type = 3, /* (C) cpu type */ - cpu_use_dynarec = 0, /* (C) cpu uses/needs Dyna */ - enable_external_fpu = 0; /* (C) enable external FPU */ -int network_type; /* (C) net provider type */ -int network_card; /* (C) net interface num */ -char network_host[512]; /* (C) host network intf */ +config_t config; /* (C) active configuration */ /* Global variables. */ -char emu_title[64]; /* full name of application */ -char emu_version[32]; /* short version ID string */ -char emu_fullversion[128]; /* full version ID string */ -wchar_t exe_path[1024]; /* emu executable path */ -wchar_t emu_path[1024]; /* emu installation path */ -wchar_t usr_path[1024]; /* path (dir) of user data */ -wchar_t cfg_path[1024]; /* full path of config file */ -int emu_lang_id; /* current language ID */ -int scrnsz_x = SCREEN_RES_X, /* current screen size, X */ - scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ -int config_changed, /* config has changed */ - dopause = 0, /* system is paused */ - doresize = 0, /* screen resize requested */ - mouse_capture = 0; /* mouse is captured in app */ -int AT, /* machine is AT class */ - MCA, /* machine has MCA bus */ - PCI; /* machine has PCI bus */ +char emu_title[64]; /* full name of application */ +char emu_version[32]; /* short version ID string */ +char emu_fullversion[128]; /* full version ID string */ +wchar_t exe_path[1024]; /* emu executable path */ +wchar_t emu_path[1024]; /* emu installation path */ +wchar_t usr_path[1024]; /* path (dir) of user data */ +wchar_t cfg_path[1024]; /* full path of config file */ +int emu_lang_id; /* current language ID */ +int scrnsz_x = SCREEN_RES_X, /* current screen size, X */ + scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ +int config_changed, /* config has changed */ + dopause = 0, /* system is paused */ + doresize = 0, /* screen resize requested */ + mouse_capture = 0; /* mouse is captured in app */ +int AT, /* machine is AT class */ + MCA, /* machine has MCA bus */ + PCI; /* machine has PCI bus */ /* Local variables. */ static int fps, /* statistics */ @@ -721,20 +672,18 @@ usage: INFO("# Configuration file: %ls\n#\n\n", cfg_path); /* - * We are about to read the configuration file, which MAY - * put data into global variables (the hard- and floppy - * disks are an example) so we have to initialize those - * modules before we load the config.. + * We are about to read the configuration file, so + * clear all the global configuration data now. */ + config_init(&config); mouse_init(); hdd_init(); cdrom_global_init(); zip_global_init(); - network_init(); /* Load the configuration file. */ - if (! config_load()) return(2); + if (! config_load(&config)) return(2); /* All good. */ return(1); @@ -742,104 +691,13 @@ usage: /* - * Set the active processor speed for this machine. + * Initialize the configured PC - run once, after pc_setup() is done. * - * The argument is either 0 for 'slowest speed', or an - * index into the CPU table to select that model' speed. - * - * This function handles two things: - * - * - it sets up the correct/expected XTAL frequency for - * the desired operating speed; - * - * - it then tells the CPU module to activate that CPU - * and/or speed. - * - * In addition, after the speed change, it updates timings. + * At this point, we have loaded a configuration file (or are running + * with a default one), which may or may not be valid. So, we perform + * a number of sanity checks here, to avoid running into trouble at a + * later time.. */ -void -pc_set_speed(int turbo) -{ - uint32_t speed; - - /* - * Part One - Set up the correct XTAL frequency. - * - * Get the selected processor's desired speed. - * - * For 286+, this is usually 8 (slow) or max speed. - * For PC and XT class, this will return max speed. - */ - speed = machine_get_speed(turbo); - DEBUG("PC: set_speed(%i) -> speed %lu\n", turbo, speed); - - if (cpu_get_type() >= CPU_286) { - /* For 286+, we are done. */ - pit_setclock(speed); - } else { - /* - * Not so easy for PC and XT class machines. - * - * The TURBO setting on these machines (if they had - * one at all) basically is the maximum speed of the - * selected processor. The slow speed is, in pretty - * much all cases, the original 4.77MHz setting. - */ - if (turbo) - pit_setclock(14318184); // speed * xt_multi ? - else - pit_setclock(14318184); - } - - /* - * Part Two - set the correct processor type. - */ - - /* - * Part Three - update several timing constants. - * - * This is necessary because the emulator's entire - * timer system is built around the CPU clock as a - * base unit. So, if we change that, everything does.. - */ -} - - -/* Re-load system configuration and restart. */ -/* FIXME: this has to be reviewed! */ -void -pc_reload(const wchar_t *fn) -{ - config_write(cfg_path); - - floppy_close(); - - cdrom_close(); - - pc_reset_hard_close(); - - // FIXME: set up new config file path 'fn'... --FvK - - config_load(); - - cdrom_hard_reset(); - - zip_hard_reset(); - - scsi_disk_hard_reset(); - - fdd_load(0, floppyfns[0]); - fdd_load(1, floppyfns[1]); - fdd_load(2, floppyfns[2]); - fdd_load(3, floppyfns[3]); - - network_init(); - - pc_reset_hard_init(); -} - - -/* Initialize the configured PC. Run once, after pc_setup() is done. */ int pc_init(void) { @@ -849,25 +707,25 @@ pc_init(void) const char *stransi; /* If no machine selected, force user into Setup Wizard. */ - if (machine_type < 0) { + if (config.machine_type < 0) { str = get_string(IDS_ERR_NOCONF); /* Show the messagebox, and abort if 'No' was selected. */ if (ui_msgbox(MBX_QUESTION, str) != 0) return(0); /* OK, user wants to set up a machine. */ - machine_type = 0; + config.machine_type = 0; return(2); } /* Load the ROMs for the selected machine. */ - if (! machine_available(machine_type)) { + if (! machine_available(config.machine_type)) { /* Whoops, selected machine not available. */ stransi = machine_get_name(); if (stransi == NULL) { /* This happens if configured machine is not even in table.. */ - sprintf(tempA, "machine_%i", machine_type); + sprintf(tempA, "machine_%i", config.machine_type); stransi = (const char *)tempA; } @@ -880,12 +738,12 @@ pc_init(void) return(2); } - if ((video_card < 0) || !video_card_available(video_card)) { + if ((config.video_card < 0) || !video_card_available(config.video_card)) { /* Whoops, selected video not available. */ - stransi = video_card_getname(video_card); + stransi = video_card_getname(config.video_card); if (stransi == NULL) { /* This happens if configured card is not even in table.. */ - sprintf(tempA, "vid_%i", video_card); + sprintf(tempA, "vid_%i", config.video_card); stransi = (const char *)tempA; } @@ -898,6 +756,17 @@ pc_init(void) return(2); } + /* If we have selected a network provider, make sure it is available. */ + if ((config.network_type < 0) || !network_available(config.network_type)) { + swprintf(temp, sizeof_w(temp), get_string(IDS_ERR_NOAVAIL), + get_string(IDS_3314), network_getname(config.network_type)); + + if (ui_msgbox(MBX_CONFIG, temp) == 1) return(0); + + /* OK, user wants to (re-)configure.. */ + return(2); + } + /* * At this point, we know that the selected machine and * video card are available, so we can proceed with the @@ -1068,7 +937,7 @@ pc_reset_hard_init(void) } /* Needs the status bar... */ - if (bugger_enabled) + if (config.bugger_enabled) device_add(&bugger_device); /* Needs the status bar initialized. */ @@ -1122,6 +991,39 @@ pc_reset(int hard) } +/* FIXME: this has to be reviewed! */ +void +pc_reload(const wchar_t *fn) +{ + config_write(cfg_path); + + floppy_close(); + + cdrom_close(); + + pc_reset_hard_close(); + + // FIXME: set up new config file path 'fn'... --FvK + + config_load(&config); + + cdrom_hard_reset(); + + zip_hard_reset(); + + scsi_disk_hard_reset(); + + fdd_load(0, floppyfns[0]); + fdd_load(1, floppyfns[1]); + fdd_load(2, floppyfns[2]); + fdd_load(3, floppyfns[3]); + + network_init(); + + pc_reset_hard_init(); +} + + /* * The main thread runs the actual emulator code. * @@ -1165,7 +1067,7 @@ pc_thread(void *param) if (is386) { #ifdef USE_DYNAREC - if (cpu_use_dynarec) + if (config.cpu_use_dynarec) exec386_dynarec(clockrate/100); else #endif @@ -1211,7 +1113,7 @@ pc_thread(void *param) } /* If needed, handle a screen resize. */ - if (doresize && !vid_fullscreen) { + if (doresize && !config.vid_fullscreen) { ui_resize(scrnsz_x, scrnsz_y); doresize = 0; @@ -1263,6 +1165,71 @@ pc_pause(int p) } +/* + * Set the active processor speed for this machine. + * + * The argument is either 0 for 'slowest speed', or an + * index into the CPU table to select that model' speed. + * + * This function handles two things: + * + * - it sets up the correct/expected XTAL frequency for + * the desired operating speed; + * + * - it then tells the CPU module to activate that CPU + * and/or speed. + * + * In addition, after the speed change, it updates timings. + */ +void +pc_set_speed(int turbo) +{ + uint32_t speed; + + /* + * Part One - Set up the correct XTAL frequency. + * + * Get the selected processor's desired speed. + * + * For 286+, this is usually 8 (slow) or max speed. + * For PC and XT class, this will return max speed. + */ + speed = machine_get_speed(turbo); + DEBUG("PC: set_speed(%i) -> speed %lu\n", turbo, speed); + + if (cpu_get_type() >= CPU_286) { + /* For 286+, we are done. */ + pit_setclock(speed); + } else { + /* + * Not so easy for PC and XT class machines. + * + * The TURBO setting on these machines (if they had + * one at all) basically is the maximum speed of the + * selected processor. The slow speed is, in pretty + * much all cases, the original 4.77MHz setting. + */ + if (turbo) + pit_setclock(14318184); // speed * xt_multi ? + else + pit_setclock(14318184); + } + + /* + * Part Two - set the correct processor type. + */ + + /* + * Part Three - update several timing constants. + * + * This is necessary because the emulator's entire + * timer system is built around the CPU clock as a + * base unit. So, if we change that, everything does.. + */ +} + + +/* Re-load system configuration and restart. */ void set_screen_size(int x, int y) { @@ -1273,7 +1240,7 @@ set_screen_size(int x, int y) double dx, dy, dtx, dty; int vid; - DEBUG("SetScreenSize(%i, %i) resize=%i\n", x, y, vid_resize); + DEBUG("SetScreenSize(%i, %i) resize=%i\n", x, y, config.vid_resize); /* Make sure we keep usable values. */ if (x < 320) x = 320; @@ -1288,7 +1255,7 @@ set_screen_size(int x, int y) if (suppress_overscan) temp_overscan_x = temp_overscan_y = 0; - if (force_43) { + if (config.force_43) { dx = (double)x; dtx = (double)temp_overscan_x; @@ -1305,7 +1272,7 @@ INFO("SetScreenSize(%d,%d) type=%d\n", x, y, vid); /* MDA/Hercules */ dy = (x / 4.0) * 3.0; } else { - if (enable_overscan) { + if (config.enable_overscan) { /* EGA/(S)VGA with overscan */ dy = (((dx - dtx) / 4.0) * 3.0) + dty; } else { @@ -1318,7 +1285,7 @@ INFO("SetScreenSize(%d,%d) type=%d\n", x, y, vid); unscaled_size_y = efscrnsz_y; } - switch(scale) { + switch(config.scale) { case 0: /* 50% */ scrnsz_x = (unscaled_size_x>>1); scrnsz_y = (unscaled_size_y>>1); diff --git a/src/png.c b/src/png.c index 8e6c818..9d14970 100644 --- a/src/png.c +++ b/src/png.c @@ -8,7 +8,7 @@ * * Provide centralized access to the PNG image handler. * - * Version: @(#)png.c 1.0.6 2019/04/27 + * Version: @(#)png.c 1.0.7 2019/05/03 * * Author: Fred N. van Kempen, * @@ -54,6 +54,7 @@ #include #include "./png.h" #include "emu.h" +#include "config.h" #include "plat.h" #include "ui/ui.h" #include "devices/video/video.h" @@ -438,7 +439,7 @@ error: b = &pix[((y * w) + x) * 4]; /* Transform if needed. */ - if (vid_grayscale || invert_display) { + if (config.vid_grayscale || config.invert_display) { rgb = (uint32_t *)b; *rgb = video_color_transform(*rgb); } diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index 4abd519..cfce6ca 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -11,7 +11,7 @@ * This code is called by the UI frontend modules, and, also, * depends on those same modules for lower-level functions. * - * Version: @(#)ui_main.c 1.0.22 2019/03/07 + * Version: @(#)ui_main.c 1.0.23 2019/05/03 * * Author: Fred N. van Kempen, * @@ -291,8 +291,8 @@ main_reset_all(void) wchar_t temp[128]; int i; - menu_set_item(IDM_RESIZE, vid_resize); - menu_set_item(IDM_REMEMBER, window_remember); + menu_set_item(IDM_RESIZE, config.vid_resize); + menu_set_item(IDM_REMEMBER, config.window_remember); /* Add all renderers to the Renderer menu. */ for (i = 0; vidapi_getname(i) != NULL; i++) { @@ -304,26 +304,26 @@ main_reset_all(void) if (! vidapi_available(i)) menu_enable_item(IDM_RENDER_1 + i, 0); } - menu_set_radio_item(IDM_RENDER_1, i, vid_api); + menu_set_radio_item(IDM_RENDER_1, i, config.vid_api); - menu_set_radio_item(IDM_SCALE_1, 4, scale); + menu_set_radio_item(IDM_SCALE_1, 4, config.scale); - menu_set_item(IDM_FULLSCREEN, vid_fullscreen); + menu_set_item(IDM_FULLSCREEN, config.vid_fullscreen); - menu_set_radio_item(IDM_STRETCH, 5, vid_fullscreen_scale); + menu_set_radio_item(IDM_STRETCH, 5, config.vid_fullscreen_scale); - menu_set_item(IDM_RCTRL_IS_LALT, rctrl_is_lalt); + menu_set_item(IDM_RCTRL_IS_LALT, config.rctrl_is_lalt); - menu_set_item(IDM_INVERT, invert_display); - menu_set_item(IDM_OVERSCAN, enable_overscan); + menu_set_item(IDM_INVERT, config.invert_display); + menu_set_item(IDM_OVERSCAN, config.enable_overscan); - menu_set_radio_item(IDM_SCREEN_RGB, 5, vid_grayscale); + menu_set_radio_item(IDM_SCREEN_RGB, 5, config.vid_grayscale); - menu_set_radio_item(IDM_GRAY_601, 3, vid_graytype); + menu_set_radio_item(IDM_GRAY_601, 3, config.vid_graytype); - menu_set_item(IDM_FORCE_43, force_43); + menu_set_item(IDM_FORCE_43, config.force_43); - menu_set_item(IDM_CGA_CONTR, vid_cga_contrast); + menu_set_item(IDM_CGA_CONTR, config.vid_cga_contrast); #ifdef _LOGGING for (i = IDM_LOG_BEGIN; i < IDM_LOG_END; i++) { @@ -333,7 +333,7 @@ main_reset_all(void) } #endif -#ifndef DEV_BRANCH +#ifdef DEV_BRANCH /* FIXME: until we fix these.. --FvK */ menu_enable_item(IDM_LOAD, 0); menu_enable_item(IDM_SAVE, 0); @@ -401,17 +401,17 @@ ui_menu_command(int idm) return(0); case IDM_RESIZE: /* VIEW menu */ - vid_resize ^= 1; - menu_set_item(idm, vid_resize); - if (vid_resize) { + config.vid_resize ^= 1; + menu_set_item(idm, config.vid_resize); + if (config.vid_resize) { /* Force scaling to 1.0. */ - scale = 1; - menu_set_radio_item(IDM_SCALE_1, 4, scale); + config.scale = 1; + menu_set_radio_item(IDM_SCALE_1, 4, config.scale); } /* Disable scaling settings. */ for (i = 0; i < 4; i++) - menu_enable_item(IDM_SCALE_1+i, !vid_resize); + menu_enable_item(IDM_SCALE_1+i, !config.vid_resize); device_force_redraw(); video_force_resize_set(1); @@ -419,8 +419,8 @@ ui_menu_command(int idm) return(0); case IDM_REMEMBER: /* VIEW menu */ - window_remember ^= 1; - menu_set_item(idm, window_remember); + config.window_remember ^= 1; + menu_set_item(idm, config.window_remember); return(0); case IDM_RENDER_1: /* VIEW menu */ @@ -445,8 +445,8 @@ ui_menu_command(int idm) case IDM_STRETCH_SQ: case IDM_STRETCH_INT: case IDM_STRETCH_KEEP: - vid_fullscreen_scale = (idm - IDM_STRETCH); - menu_set_radio_item(IDM_STRETCH, 5, vid_fullscreen_scale); + config.vid_fullscreen_scale = (idm - IDM_STRETCH); + menu_set_radio_item(IDM_STRETCH, 5, config.vid_fullscreen_scale); device_force_redraw(); config_save(); break; @@ -455,32 +455,32 @@ ui_menu_command(int idm) case IDM_SCALE_2: case IDM_SCALE_3: case IDM_SCALE_4: - scale = (idm - IDM_SCALE_1); - menu_set_radio_item(IDM_SCALE_1, 4, scale); + config.scale = (idm - IDM_SCALE_1); + menu_set_radio_item(IDM_SCALE_1, 4, config.scale); device_force_redraw(); video_force_resize_set(1); config_save(); break; case IDM_FORCE_43: /* VIEW menu */ - toggle_video_item(idm, &force_43); + toggle_video_item(idm, &config.force_43); video_force_resize_set(1); config_save(); break; case IDM_RCTRL_IS_LALT: /* VIEW menu */ - rctrl_is_lalt ^= 1; - menu_set_item(idm, rctrl_is_lalt); + config.rctrl_is_lalt ^= 1; + menu_set_item(idm, config.rctrl_is_lalt); config_save(); break; case IDM_INVERT: /* DISPLAY menu */ - toggle_video_item(idm, &invert_display); + toggle_video_item(idm, &config.invert_display); config_save(); break; case IDM_OVERSCAN: /* DISPLAY menu */ - toggle_video_item(idm, &enable_overscan); + toggle_video_item(idm, &config.enable_overscan); video_force_resize_set(1); config_save(); break; @@ -490,8 +490,8 @@ ui_menu_command(int idm) case IDM_SCREEN_AMBER: case IDM_SCREEN_GREEN: case IDM_SCREEN_WHITE: - vid_grayscale = (idm - IDM_SCREEN_RGB); - menu_set_radio_item(IDM_SCREEN_RGB, 5, vid_grayscale); + config.vid_grayscale = (idm - IDM_SCREEN_RGB); + menu_set_radio_item(IDM_SCREEN_RGB, 5, config.vid_grayscale); device_force_redraw(); config_save(); break; @@ -499,15 +499,15 @@ ui_menu_command(int idm) case IDM_GRAY_601: /* DISPLAY menu */ case IDM_GRAY_709: case IDM_GRAY_AVE: - vid_graytype = (idm - IDM_GRAY_601); - menu_set_radio_item(IDM_GRAY_601, 3, vid_graytype); + config.vid_graytype = (idm - IDM_GRAY_601); + menu_set_radio_item(IDM_GRAY_601, 3, config.vid_graytype); device_force_redraw(); config_save(); break; case IDM_CGA_CONTR: /* DISPLAY menu */ - vid_cga_contrast ^= 1; - menu_set_item(idm, vid_cga_contrast); + config.vid_cga_contrast ^= 1; + menu_set_item(idm, config.vid_cga_contrast); video_palette_rebuild(); config_save(); break; @@ -629,13 +629,13 @@ void ui_fullscreen(int on) { /* Want off and already off? */ - if (!on && !vid_fullscreen) return; + if (!on && !config.vid_fullscreen) return; /* Want on and already on? */ - if (on && vid_fullscreen) return; + if (on && config.vid_fullscreen) return; - if (on && vid_fullscreen_first) { - vid_fullscreen_first = 0; + if (on && config.vid_fullscreen_first) { + config.vid_fullscreen_first = 0; ui_msgbox(MBX_INFO, (wchar_t *)IDS_MSG_WINDOW); } @@ -646,9 +646,9 @@ ui_fullscreen(int on) // plat_mouse_close(); /* Close the current mode, and open the new one. */ - plat_vidapis[vid_api]->close(); - vid_fullscreen = on; - plat_vidapis[vid_api]->init(vid_fullscreen); + plat_vidapis[config.vid_api]->close(); + config.vid_fullscreen = on; + plat_vidapis[config.vid_api]->init(config.vid_fullscreen); plat_fullscreen(on); @@ -659,7 +659,7 @@ ui_fullscreen(int on) device_force_redraw(); /* Finally, handle the host's mouse cursor. */ - ui_show_cursor(vid_fullscreen ? 0 : -1); + ui_show_cursor(config.vid_fullscreen ? 0 : -1); /* Update the menu item. */ menu_set_item(IDM_FULLSCREEN, on); @@ -674,7 +674,7 @@ ui_mouse_capture(int on) int state = mouse_capture; /* Do not try to capture the mouse if no mouse configured. */ - if (mouse_type == MOUSE_NONE) return; + if (config.mouse_type == MOUSE_NONE) return; if ((on == 1) && !mouse_capture) { state = 1; diff --git a/src/ui/ui_stbar.c b/src/ui/ui_stbar.c index d3e5d76..ad0dbd5 100644 --- a/src/ui/ui_stbar.c +++ b/src/ui/ui_stbar.c @@ -8,7 +8,7 @@ * * Common UI support functions for the Status Bar module. * - * Version: @(#)ui_stbar.c 1.0.18 2019/04/11 + * Version: @(#)ui_stbar.c 1.0.19 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -289,12 +289,12 @@ ui_sb_tip_update(uint8_t tag) break; case SB_NETWORK: - stransi = network_card_getname(network_card); + stransi = network_card_getname(config.network_card); swprintf(tip, sizeof_w(tip), get_string(IDS_3960), stransi); break; case SB_SOUND: - stransi = sound_card_getname(sound_card); + stransi = sound_card_getname(config.sound_card); swprintf(tip, sizeof_w(tip), get_string(IDS_3970), stransi); break; @@ -487,11 +487,11 @@ ui_sb_reset(void) } hdint = (machine_get_flags() & MACHINE_HDC) ? 1 : 0; - do_net = !!((network_type != 0) && (network_card != 0)); - do_sound = !!(sound_card != 0); + do_net = !!((config.network_type != 0) && (config.network_card != 0)); + do_sound = !!(config.sound_card != 0); /* Get name of current HDC. */ - hdc = hdc_get_internal_name(hdc_type); + hdc = hdc_get_internal_name(config.hdc_type); /* Count all the floppy drives. */ for (drive = 0; drive < FDD_NUM; drive++) { @@ -507,7 +507,7 @@ ui_sb_reset(void) continue; } - if ((hdd[drive].bus == HDD_BUS_SCSI) && (scsi_card == 0)) { + if ((hdd[drive].bus == HDD_BUS_SCSI) && (config.scsi_card == 0)) { /* Disk, but no controller for it. */ continue; } @@ -523,7 +523,7 @@ ui_sb_reset(void) continue; } - if ((cdrom[drive].bus_type == CDROM_BUS_SCSI) && (scsi_card == 0)) { + if ((cdrom[drive].bus_type == CDROM_BUS_SCSI) && (config.scsi_card == 0)) { continue; } @@ -538,7 +538,7 @@ ui_sb_reset(void) continue; } - if ((zip_drives[drive].bus_type == ZIP_BUS_SCSI) && (scsi_card == 0)) + if ((zip_drives[drive].bus_type == ZIP_BUS_SCSI) && (config.scsi_card == 0)) continue; if (zip_drives[drive].bus_type != CDROM_BUS_DISABLED) @@ -557,7 +557,7 @@ ui_sb_reset(void) #endif /* For devices like ISAbugger. */ - if (bugger_enabled) + if (config.bugger_enabled) sb_nparts++; /* General text message field. */ @@ -588,7 +588,7 @@ ui_sb_reset(void) continue; } - if ((hdd[drive].bus == HDD_BUS_SCSI) && (scsi_card == 0)) { + if ((hdd[drive].bus == HDD_BUS_SCSI) && (config.scsi_card == 0)) { /* Disk, but no controller for it. */ continue; } @@ -607,7 +607,7 @@ ui_sb_reset(void) continue; } - if ((cdrom[drive].bus_type == CDROM_BUS_SCSI) && (scsi_card == 0)) + if ((cdrom[drive].bus_type == CDROM_BUS_SCSI) && (config.scsi_card == 0)) continue; if (cdrom[drive].bus_type != CDROM_BUS_DISABLED) { @@ -624,7 +624,7 @@ ui_sb_reset(void) continue; } - if ((zip_drives[drive].bus_type == ZIP_BUS_SCSI) && (scsi_card == 0)) + if ((zip_drives[drive].bus_type == ZIP_BUS_SCSI) && (config.scsi_card == 0)) continue; if (zip_drives[drive].bus_type != 0) { @@ -656,7 +656,7 @@ ui_sb_reset(void) #endif /* Fun! */ - if (bugger_enabled) { + if (config.bugger_enabled) { /* Add a text field for the ISAbugger. */ ptr = &sb_parts[sb_nparts++]; ptr->width = 175; diff --git a/src/ui/ui_vidapi.c b/src/ui/ui_vidapi.c index 887685d..34e4083 100644 --- a/src/ui/ui_vidapi.c +++ b/src/ui/ui_vidapi.c @@ -8,7 +8,7 @@ * * Handle the various video renderer modules. * - * Version: @(#)ui_vidapi.c 1.0.6 2019/04/30 + * Version: @(#)ui_vidapi.c 1.0.7 2019/05/03 * * Author: Fred N. van Kempen, * @@ -51,6 +51,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../device.h" #include "../plat.h" #include "../devices/video/video.h" @@ -128,17 +129,17 @@ vidapi_set(int api) video_blit_wait(); /* Close the (old) API. */ - plat_vidapis[vid_api]->close(); + plat_vidapis[config.vid_api]->close(); /* Initialize the (new) API. */ - vid_api = api; - i = plat_vidapis[vid_api]->init(vid_fullscreen); + config.vid_api = api; + i = plat_vidapis[config.vid_api]->init(config.vid_fullscreen); /* Enable or disable the Render window. */ - ui_show_render(plat_vidapis[vid_api]->local); + ui_show_render(plat_vidapis[config.vid_api]->local); /* Update the menu item. */ - menu_set_radio_item(IDM_RENDER_1, vidapi_count(), vid_api); + menu_set_radio_item(IDM_RENDER_1, vidapi_count(), config.vid_api); /* OK, release the blitter. */ plat_endblit(); @@ -156,7 +157,7 @@ void vidapi_resize(int x, int y) { /* If not defined, not supported or needed. */ - if (plat_vidapis[vid_api]->resize == NULL) return; + if (plat_vidapis[config.vid_api]->resize == NULL) return; /* Lock the blitter. */ plat_startblit(); @@ -164,7 +165,7 @@ vidapi_resize(int x, int y) /* Wait for it to be ours. */ video_blit_wait(); - plat_vidapis[vid_api]->resize(x, y); + plat_vidapis[config.vid_api]->resize(x, y); /* Release the blitter. */ plat_endblit(); @@ -175,9 +176,9 @@ int vidapi_pause(void) { /* If not defined, assume always OK. */ - if (plat_vidapis[vid_api]->pause == NULL) return(0); + if (plat_vidapis[config.vid_api]->pause == NULL) return(0); - return(plat_vidapis[vid_api]->pause()); + return(plat_vidapis[config.vid_api]->pause()); } @@ -185,7 +186,7 @@ void vidapi_enable(int yes) { /* If not defined, assume not needed. */ - if (plat_vidapis[vid_api]->enable == NULL) return; + if (plat_vidapis[config.vid_api]->enable == NULL) return; /* Lock the blitter. */ plat_startblit(); @@ -193,7 +194,7 @@ vidapi_enable(int yes) /* Wait for it to be ours. */ video_blit_wait(); - plat_vidapis[vid_api]->enable(yes); + plat_vidapis[config.vid_api]->enable(yes); /* Release the blitter. */ plat_endblit(); @@ -204,9 +205,9 @@ void vidapi_reset(void) { /* If not defined, assume always OK. */ - if (plat_vidapis[vid_api]->reset == NULL) return; + if (plat_vidapis[config.vid_api]->reset == NULL) return; - plat_vidapis[vid_api]->reset(vid_fullscreen); + plat_vidapis[config.vid_api]->reset(config.vid_fullscreen); } @@ -218,9 +219,10 @@ vidapi_screenshot(void) struct tm *info; time_t now; - DEBUG("VIDAPI: screenshot (api=%i)\n", vid_api); + DEBUG("VIDAPI: screenshot (api=%i)\n", config.vid_api); - if (vid_api < 0) return; + if ((config.vid_api < 0) || + (plat_vidapis[config.vid_api]->screenshot != NULL)) return; (void)time(&now); info = localtime(&now); @@ -236,6 +238,5 @@ vidapi_screenshot(void) wcsftime(fn, sizeof_w(fn), L"%Y%m%d_%H%M%S.png", info); wcscat(path, fn); - if (plat_vidapis[vid_api]->screenshot != NULL) - plat_vidapis[vid_api]->screenshot(path); + plat_vidapis[config.vid_api]->screenshot(path); } diff --git a/src/version.h b/src/version.h index 3e96354..7336c63 100644 --- a/src/version.h +++ b/src/version.h @@ -8,11 +8,11 @@ * * Define application version and build info. * - * Version: @(#)version.h 1.0.20 2018/10/05 + * Version: @(#)version.h 1.0.21 2019/05/02 * * Author: Fred N. van Kempen, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -54,7 +54,7 @@ /* Version info. */ #define EMU_VER_MAJOR 1 #define EMU_VER_MINOR 7 -#define EMU_VER_REV 0 +#define EMU_VER_REV 1 //#define EMU_VER_PATCH 0 diff --git a/src/vnc.c b/src/vnc.c index 3efba85..da0b3e0 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -10,7 +10,7 @@ * * TODO: Implement screenshots, and Audio Redirection. * - * Version: @(#)vnc.c 1.0.11 2019/04/29 + * Version: @(#)vnc.c 1.0.12 2019/05/03 * * Author: Fred N. van Kempen, * Based on raw code by RichardG, @@ -56,6 +56,7 @@ //#define LIBVNCSERVER_HAVE_LIBPTHREAD #include #include "emu.h" +#include "config.h" #include "device.h" #include "devices/video/video.h" #include "devices/input/keyboard.h" @@ -268,7 +269,7 @@ INFO("VNC: blit(%i,%i, %i,%i, %i,%i)\n", x,y, y1,y2, w,h); p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]); if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y) { - if (vid_grayscale || invert_display) + if (config.vid_grayscale || config.invert_display) video_transform_copy(p, &scr->line[y+yy][x], w); else memcpy(p, &scr->line[y+yy][x], w*4); diff --git a/src/win/win.c b/src/win/win.c index 9714c93..dbe02f2 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * Platform main support module for Windows. * - * Version: @(#)win.c 1.0.29 2019/04/30 + * Version: @(#)win.c 1.0.30 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -212,7 +212,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) (void)pc_setup(0, (wchar_t **)stdout); /* Set this to the default value (windowed mode). */ - vid_fullscreen = 0; + config.vid_fullscreen = 0; /* First, set our (default) language. */ lang = (int)GetUserDefaultUILanguage(); @@ -252,7 +252,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) plat_console(0); /* Set the active language for this application. */ - if (! ui_lang_set(language)) { + if (! ui_lang_set(config.language)) { /* That did not work. Revert back to default and try again. */ lang = emu_lang_id; (void)ui_lang_set(lang); diff --git a/src/win/win_d2d.cpp b/src/win/win_d2d.cpp index 2144a00..f4ebccc 100644 --- a/src/win/win_d2d.cpp +++ b/src/win/win_d2d.cpp @@ -8,7 +8,7 @@ * * Rendering module for Microsoft Direct2D. * - * Version: @(#)win_d2d.cpp 1.0.7 2019/04/29 + * Version: @(#)win_d2d.cpp 1.0.8 2019/05/03 * * Authors: Fred N. van Kempen, * David Hrdlicka, @@ -43,6 +43,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../version.h" #include "../device.h" #include "../plat.h" @@ -95,7 +96,7 @@ d2d_stretch(float *w, float *h, float *x, float *y) { double dw, dh, dx, dy, temp, temp2, ratio_w, ratio_h, gsr, hsr; - switch (vid_fullscreen_scale) { + switch (config.vid_fullscreen_scale) { case FULLSCR_SCALE_FULL: *w = (float)d2d_screen_width; *h = (float)d2d_screen_height; @@ -230,7 +231,7 @@ d2d_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) srcdata = mem_alloc(h * w * 4); for (yy = y1; yy < y2; yy++) { if ((y + yy) >= 0 && (y + yy) < scr->h) { - if (vid_grayscale || invert_display) + if (config.vid_grayscale || config.invert_display) video_transform_copy( (uint32_t *)&(((uint8_t *)srcdata)[yy * w * 4]), &scr->line[y + yy][x], w); diff --git a/src/win/win_d3d.cpp b/src/win/win_d3d.cpp index 7d0da53..0ca632c 100644 --- a/src/win/win_d3d.cpp +++ b/src/win/win_d3d.cpp @@ -8,7 +8,7 @@ * * Rendering module for Microsoft Direct3D 9. * - * Version: @(#)win_d3d.cpp 1.0.17 2019/04/29 + * Version: @(#)win_d3d.cpp 1.0.18 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,6 +43,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../version.h" #include "../device.h" #include "../plat.h" @@ -106,7 +107,7 @@ d3d_size(RECT w_rect, double *l, double *t, double *r, double *b, int w, int h) int ratio_w, ratio_h; double hsr, gsr, ra, d; - switch (vid_fullscreen_scale) { + switch (config.vid_fullscreen_scale) { case FULLSCR_SCALE_FULL: d3d_size_default(w_rect, l, t, r, b); break; @@ -216,7 +217,7 @@ d3d_blit_fs(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) if (hr == D3D_OK) { for (yy = y1; yy < y2; yy++) { if (scr) { - if (vid_grayscale || invert_display) + if (config.vid_grayscale || config.invert_display) video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &scr->line[yy + y][x], w); else memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &scr->line[yy + y][x], w * 4); @@ -332,7 +333,7 @@ d3d_blit(bitmap_t *b, int x, int y, int y1, int y2, int w, int h) for (yy = y1; yy < y2; yy++) { if (b) { if ((y + yy) >= 0 && (y + yy) < screen->h) { - if (vid_grayscale || invert_display) + if (config.vid_grayscale || config.invert_display) video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &b->line[yy + y][x], w); else memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &b->line[yy + y][x], w * 4); diff --git a/src/win/win_ddraw.cpp b/src/win/win_ddraw.cpp index 43465c8..8ec2e28 100644 --- a/src/win/win_ddraw.cpp +++ b/src/win/win_ddraw.cpp @@ -8,7 +8,7 @@ * * Rendering module for Microsoft DirectDraw 9. * - * Version: @(#)win_ddraw.cpp 1.0.21 2019/04/29 + * Version: @(#)win_ddraw.cpp 1.0.22 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -42,6 +42,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../device.h" #include "../ui/ui.h" #include "../plat.h" @@ -168,7 +169,7 @@ ddraw_fs_size(RECT w_rect, RECT *r_dest, int w, int h) int ratio_w, ratio_h; double hsr, gsr, ra, d; - switch (vid_fullscreen_scale) { + switch (config.vid_fullscreen_scale) { case FULLSCR_SCALE_FULL: ddraw_fs_size_default(w_rect, r_dest); break; @@ -282,7 +283,7 @@ ddraw_blit_fs(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) for (yy = y1; yy < y2; yy++) { if (scr) { - if (vid_grayscale || invert_display) + if (config.vid_grayscale || config.invert_display) video_transform_copy((uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &scr->line[y + yy][x], w); else memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &scr->line[y + yy][x], w * 4); @@ -363,7 +364,7 @@ ddraw_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) for (yy = y1; yy < y2; yy++) { if (scr) { if ((y + yy) >= 0 && (y + yy) < scr->h) { - if (vid_grayscale || invert_display) + if (config.vid_grayscale || config.invert_display) video_transform_copy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &scr->line[y + yy][x], w); else memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &scr->line[y + yy][x], w * 4); diff --git a/src/win/win_joystick.cpp b/src/win/win_joystick.cpp index d8a8f67..db54e97 100644 --- a/src/win/win_joystick.cpp +++ b/src/win/win_joystick.cpp @@ -13,13 +13,13 @@ * NOTE: Hacks currently needed to compile with MSVC; DX needs to * be updated to 11 or 12 or so. --FvK * - * Version: @(#)win_joystick.cpp 1.0.20 2018/10/24 + * Version: @(#)win_joystick.cpp 1.0.21 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -179,9 +179,9 @@ joystick_init(void) int c; /* Only initialize if the game port is enabled. */ - if (! game_enabled) return; + if (! config.game_enabled) return; - INFO("JOYSTICK: initializing (type=%d)\n", joystick_type); + INFO("JOYSTICK: initializing (type=%i)\n", config.joystick_type); atexit(joystick_close); @@ -305,7 +305,7 @@ joystick_process(void) { int c, d; - if (joystick_type == JOYSTICK_NONE) return; + if (config.joystick_type == JOYSTICK_NONE) return; for (c = 0; c < joysticks_present; c++) { DIJOYSTATE joystate; @@ -334,16 +334,16 @@ joystick_process(void) plat_joystick_state[c].p[b] = joystate.rgdwPOV[b]; } - for (c = 0; c < gamedev_get_max_joysticks(joystick_type); c++) { + for (c = 0; c < gamedev_get_max_joysticks(config.joystick_type); c++) { if (joystick_state[c].plat_joystick_nr) { int joystick_nr = joystick_state[c].plat_joystick_nr - 1; - for (d = 0; d < gamedev_get_axis_count(joystick_type); d++) + for (d = 0; d < gamedev_get_axis_count(config.joystick_type); d++) joystick_state[c].axis[d] = get_axis(joystick_nr, joystick_state[c].axis_mapping[d]); - for (d = 0; d < gamedev_get_button_count(joystick_type); d++) + for (d = 0; d < gamedev_get_button_count(config.joystick_type); d++) joystick_state[c].button[d] = plat_joystick_state[joystick_nr].b[joystick_state[c].button_mapping[d]]; - for (d = 0; d < gamedev_get_pov_count(joystick_type); d++) { + for (d = 0; d < gamedev_get_pov_count(config.joystick_type); d++) { int x, y; double angle, magnitude; @@ -359,11 +359,11 @@ joystick_process(void) joystick_state[c].pov[d] = ((int)angle + 90 + 360) % 360; } } else { - for (d = 0; d < gamedev_get_axis_count(joystick_type); d++) + for (d = 0; d < gamedev_get_axis_count(config.joystick_type); d++) joystick_state[c].axis[d] = 0; - for (d = 0; d < gamedev_get_button_count(joystick_type); d++) + for (d = 0; d < gamedev_get_button_count(config.joystick_type); d++) joystick_state[c].button[d] = 0; - for (d = 0; d < gamedev_get_pov_count(joystick_type); d++) + for (d = 0; d < gamedev_get_pov_count(config.joystick_type); d++) joystick_state[c].pov[d] = -1; } } diff --git a/src/win/win_keyboard.c b/src/win/win_keyboard.c index b18ffda..f013402 100644 --- a/src/win/win_keyboard.c +++ b/src/win/win_keyboard.c @@ -8,12 +8,12 @@ * * Windows raw keyboard input handler. * - * Version: @(#)win_keyboard.c 1.0.8 2018/10/05 + * Version: @(#)win_keyboard.c 1.0.9 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -43,6 +43,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../device.h" #include "../plat.h" #include "../devices/input/keyboard.h" @@ -228,7 +229,7 @@ keyboard_handle(LPARAM lParam, int focus) /* Translate right CTRL to left ALT if the user has so chosen. */ - if ((code == 0x11D) && rctrl_is_lalt) + if ((code == 0x11D) && config.rctrl_is_lalt) code = 0x038; /* Normal scan code pass through, pass it through as is if diff --git a/src/win/win_mouse.cpp b/src/win/win_mouse.cpp index 919f121..82b9500 100644 --- a/src/win/win_mouse.cpp +++ b/src/win/win_mouse.cpp @@ -8,13 +8,13 @@ * * Mouse interface to host device. * - * Version: @(#)win_mouse.cpp 1.0.7 2018/10/05 + * Version: @(#)win_mouse.cpp 1.0.8 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -42,6 +42,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../plat.h" #include "../devices/input/mouse.h" #include "win.h" @@ -77,7 +78,7 @@ win_mouse_init(void) fatal("plat_mouse_init: CreateDevice failed\n"); if (FAILED(lpdi_mouse->SetCooperativeLevel(hwndMain, - DISCL_FOREGROUND | (vid_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE)))) + DISCL_FOREGROUND | (config.vid_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE)))) fatal("plat_mouse_init: SetCooperativeLevel failed\n"); if (FAILED(lpdi_mouse->SetDataFormat(&c_dfDIMouse))) @@ -98,7 +99,7 @@ mouse_poll(void) lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate); } - if (mouse_capture || vid_fullscreen) { + if (mouse_capture || config.vid_fullscreen) { if (x != mousestate.lX || y != mousestate.lY || z != mousestate.lZ) { mouse_x += mousestate.lX; mouse_y += mousestate.lY; diff --git a/src/win/win_sdl.c b/src/win/win_sdl.c index 46918c6..d8a8c22 100644 --- a/src/win/win_sdl.c +++ b/src/win/win_sdl.c @@ -12,7 +12,7 @@ * we will not use that, but, instead, use a new window which * coverrs the entire desktop. * - * Version: @(#)win_sdl.c 1.0.10 2019/04/29 + * Version: @(#)win_sdl.c 1.0.11 2019/05/03 * * Authors: Fred N. van Kempen, * Michael Drüing, @@ -61,6 +61,7 @@ #include #include #include "../emu.h" +#include "../config.h" #include "../version.h" #include "../device.h" #include "../ui/ui.h" @@ -142,7 +143,7 @@ sdl_stretch(int *w, int *h, int *x, int *y) { double dw, dh, dx, dy, temp, temp2, ratio_w, ratio_h, gsr, hsr; - switch (vid_fullscreen_scale) { + switch (config.vid_fullscreen_scale) { case FULLSCR_SCALE_FULL: *w = sdl_w; *h = sdl_h; @@ -275,7 +276,7 @@ sdl_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) for (yy = y1; yy < y2; yy++) { if ((y + yy) >= 0 && (y + yy) < scr->h) { - if (vid_grayscale || invert_display) + if (config.vid_grayscale || config.invert_display) video_transform_copy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &scr->line[y + yy][x], w); else memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &scr->line[y + yy][x], w * 4); diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 776f99d..162792e 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings.c 1.0.40 2019/04/08 + * Version: @(#)win_settings.c 1.0.41 2019/05/04 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -83,52 +83,12 @@ extern const device_t voodoo_device; -/* Machine category. */ -static int temp_machine, - temp_cpu_m, temp_cpu, temp_wait_states, - temp_mem_size, temp_fpu, temp_sync; -#ifdef USE_DYNAREC -static int temp_dynarec; -#endif - -/* Video category. */ -static int temp_video_card, temp_voodoo; - -/* Input devices category. */ -static int temp_mouse, temp_joystick; - -/* Sound category. */ -static int temp_sound_card, temp_midi_device, temp_mpu401, - temp_opl_type, temp_float; - -/* Network category. */ -static int temp_net_type, temp_net_card; -static char temp_host_dev[128]; - -/* Ports category. */ -static int temp_game, - temp_serial[SERIAL_MAX], - temp_parallel[PARALLEL_MAX], - temp_parallel_device[PARALLEL_MAX]; - -/* Other peripherals category. */ -static int temp_hdc_type, - temp_scsi_card, - temp_ide_ter, - temp_ide_qua, - temp_bugger, - temp_isartc, - temp_isamem[ISAMEM_MAX]; - /* Floppy drives category. */ static int temp_fdd_types[FDD_NUM], temp_fdd_turbo[FDD_NUM], temp_fdd_check_bpb[FDD_NUM]; -/* Hard disks category. */ static hard_disk_t temp_hdd[HDD_NUM]; - -/* Other removable devices category. */ static cdrom_t temp_cdrom_drives[CDROM_NUM]; static zip_drive_t temp_zip_drives[ZIP_NUM]; @@ -138,6 +98,7 @@ static HWND hwndParentDialog, static int displayed_category = 0; static int ask_sure = 0; static uint8_t temp_deviceconfig; +static config_t temp_cfg; /* Show a MessageBox dialog. This is nasty, I know. --FvK */ @@ -177,59 +138,8 @@ settings_init(void) { int i; - /* Machine category */ - temp_machine = machine_type; - temp_cpu_m = cpu_manufacturer; - temp_wait_states = cpu_waitstates; - temp_cpu = cpu_type; - temp_mem_size = mem_size; -#ifdef USE_DYNAREC - temp_dynarec = cpu_use_dynarec; -#endif - temp_fpu = enable_external_fpu; - temp_sync = time_sync; - - /* Video category */ - temp_video_card = video_card; - temp_voodoo = voodoo_enabled; - - /* Input devices category */ - temp_mouse = mouse_type; - temp_joystick = joystick_type; - - /* Sound category */ - temp_sound_card = sound_card; - temp_midi_device = midi_device; - temp_mpu401 = mpu401_standalone_enable; - temp_opl_type = opl_type; - temp_float = sound_is_float; - - /* Network category */ - temp_net_type = network_type; - memset(temp_host_dev, 0, sizeof(temp_host_dev)); - strcpy(temp_host_dev, network_host); - temp_net_card = network_card; - - /* Ports category */ - temp_game = game_enabled; - for (i = 0; i < SERIAL_MAX; i++) - temp_serial[i] = serial_enabled[i]; - for (i = 0; i < PARALLEL_MAX; i++) { - temp_parallel[i] = parallel_enabled[i]; - temp_parallel_device[i] = parallel_device[i]; - } - - /* Other peripherals category */ - temp_scsi_card = scsi_card; - temp_hdc_type = hdc_type; - temp_ide_ter = ide_ter_enabled; - temp_ide_qua = ide_qua_enabled; - temp_bugger = bugger_enabled; - temp_isartc = isartc_type; - - /* ISA memory boards. */ - for (i = 0; i < ISAMEM_MAX; i++) - temp_isamem[i] = isamem_type[i]; + /* Copy the current configuration to a temporary one. */ + memcpy(&temp_cfg, &config, sizeof(config_t)); /* Floppy drives category */ for (i = 0; i < FDD_NUM; i++) { @@ -255,58 +165,8 @@ settings_changed(void) { int i = 0, j; - /* Machine category */ - i = i || (machine_type != temp_machine); - i = i || (cpu_manufacturer != temp_cpu_m); - i = i || (cpu_waitstates != temp_wait_states); - i = i || (cpu_type != temp_cpu); - i = i || (mem_size != temp_mem_size); -#ifdef USE_DYNAREC - i = i || (temp_dynarec != cpu_use_dynarec); -#endif - i = i || (temp_fpu != enable_external_fpu); - i = i || (temp_sync != time_sync); - - /* Video category */ - i = i || (video_card != temp_video_card); - i = i || (voodoo_enabled != temp_voodoo); - - /* Input devices category */ - i = i || (mouse_type != temp_mouse); - i = i || (joystick_type != temp_joystick); - - /* Sound category */ - i = i || (sound_card != temp_sound_card); - i = i || (midi_device != temp_midi_device); - i = i || (mpu401_standalone_enable != temp_mpu401); - i = i || (opl_type != temp_opl_type); - i = i || (sound_is_float != temp_float); - - /* Network category */ - i = i || (network_type != temp_net_type); - i = i || strcmp(temp_host_dev, network_host); - i = i || (network_card != temp_net_card); - - /* Ports category */ - i = i || (temp_game != game_enabled); - for (j = 0; j < SERIAL_MAX; j++) - i = i || (temp_serial[j] != serial_enabled[j]); - for (j = 0; j < PARALLEL_MAX; j++) { - i = i || (temp_parallel[j] != parallel_enabled[j]); - i = i || (temp_parallel_device[j] != parallel_device[j]); - } - - /* Peripherals category */ - i = i || (temp_scsi_card != scsi_card); - i = i || (temp_hdc_type != hdc_type); - i = i || (temp_ide_ter != ide_ter_enabled); - i = i || (temp_ide_qua != ide_qua_enabled); - i = i || (temp_bugger != bugger_enabled); - i = i || (temp_isartc != isartc_type); - - /* ISA memory boards. */ - for (j = 0; j < ISAMEM_MAX; j++) - i = i || (temp_isamem[j] != isamem_type[j]); + /* If the main block has changed, done. */ + if (config_compare(&config, &temp_cfg)) return(1); /* Hard disks category */ i = i || memcmp(hdd, temp_hdd, HDD_NUM * sizeof(hard_disk_t)); @@ -356,61 +216,11 @@ settings_save(void) { int i; + /* Shut down the active machine. */ pc_reset_hard_close(); - /* Machine category */ - machine_type = temp_machine; - cpu_manufacturer = temp_cpu_m; - cpu_waitstates = temp_wait_states; - cpu_type = temp_cpu; - mem_size = temp_mem_size; -#ifdef USE_DYNAREC - cpu_use_dynarec = temp_dynarec; -#endif - enable_external_fpu = temp_fpu; - time_sync = temp_sync; - - /* Video category */ - video_card = temp_video_card; - voodoo_enabled = temp_voodoo; - - /* Input devices category */ - mouse_type = temp_mouse; - joystick_type = temp_joystick; - - /* Sound category */ - sound_card = temp_sound_card; - midi_device = temp_midi_device; - mpu401_standalone_enable = temp_mpu401; - opl_type = temp_opl_type; - sound_is_float = temp_float; - - /* Network category */ - network_type = temp_net_type; - memset(network_host, '\0', sizeof(network_host)); - strcpy(network_host, temp_host_dev); - network_card = temp_net_card; - - /* Ports category */ - game_enabled = temp_game; - for (i = 0; i < SERIAL_MAX; i++) - serial_enabled[i] = temp_serial[i]; - for (i = 0; i < PARALLEL_MAX; i++) { - parallel_enabled[i] = temp_parallel[i]; - parallel_device[i] = temp_parallel_device[i]; - } - - /* Peripherals category */ - scsi_card = temp_scsi_card; - hdc_type = temp_hdc_type; - ide_ter_enabled = temp_ide_ter; - ide_qua_enabled = temp_ide_qua; - bugger_enabled = temp_bugger; - isartc_type = temp_isartc; - - /* ISA memory boards. */ - for (i = 0; i < ISAMEM_MAX; i++) - isamem_type[i] = temp_isamem[i]; + /* Save the temporary configuration back to the active one. */ + memcpy(&config, &temp_cfg, sizeof(config_t)); /* Hard disks category */ memcpy(hdd, temp_hdd, HDD_NUM * sizeof(hard_disk_t)); @@ -719,7 +529,7 @@ find_roms(void) int c, d, i; c = d = 0; - while(1) { + for (;;) { /* Get ANSI name of machine. */ str = machine_get_name_ex(c); if (str == NULL) diff --git a/src/win/win_settings_input.h b/src/win/win_settings_input.h index d5cf55e..7f3e417 100644 --- a/src/win/win_settings_input.h +++ b/src/win/win_settings_input.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_input.h 1.0.12 2018/04/08 + * Version: @(#)win_settings_input.h 1.0.13 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -78,7 +78,7 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); @@ -89,7 +89,7 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (stransi == NULL) break; /* Skip devices that are unavailable. */ - if (! mouse_valid(c, temp_machine)) { + if (! mouse_valid(c, temp_cfg.machine_type)) { c++; continue; } @@ -114,10 +114,11 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) c++; d++; } - SendMessage(h, CB_SETCURSEL, mouse_to_list[temp_mouse], 0); + SendMessage(h, CB_SETCURSEL, + mouse_to_list[temp_cfg.mouse_type], 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_MOUSE); - if (mouse_has_config(temp_mouse)) + if (mouse_has_config(temp_cfg.mouse_type)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); @@ -136,17 +137,17 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } c++; } - SendMessage(h, CB_SETCURSEL, temp_joystick, 0); - EnableWindow(h, (temp_game)?TRUE:FALSE); + SendMessage(h, CB_SETCURSEL, temp_cfg.joystick_type, 0); + EnableWindow(h, (temp_cfg.game_enabled)?TRUE:FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY1); - EnableWindow(h, (temp_game && (gamedev_get_max_joysticks(temp_joystick) >= 1)) ? TRUE : FALSE); + EnableWindow(h, (temp_cfg.game_enabled && (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 1)) ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY2); - EnableWindow(h, (temp_game && (gamedev_get_max_joysticks(temp_joystick) >= 2)) ? TRUE : FALSE); + EnableWindow(h, (temp_cfg.game_enabled && (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 2)) ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY3); - EnableWindow(h, (temp_game && (gamedev_get_max_joysticks(temp_joystick) >= 3)) ? TRUE : FALSE); + EnableWindow(h, (temp_cfg.game_enabled && (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 3)) ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY4); - EnableWindow(h, (temp_game && (gamedev_get_max_joysticks(temp_joystick) >= 4)) ? TRUE : FALSE); + EnableWindow(h, (temp_cfg.game_enabled && (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 4)) ? TRUE : FALSE); return TRUE; @@ -154,10 +155,10 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDC_COMBO_MOUSE: h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); - temp_mouse = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.mouse_type = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_MOUSE); - if (mouse_has_config(temp_mouse)) + if (mouse_has_config(temp_cfg.mouse_type)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); @@ -165,56 +166,56 @@ input_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_MOUSE: h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); - temp_mouse = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; - temp_deviceconfig |= dlg_devconf(hdlg, mouse_get_device(temp_mouse)); + temp_cfg.mouse_type = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_deviceconfig |= dlg_devconf(hdlg, mouse_get_device(temp_cfg.mouse_type)); break; case IDC_COMBO_JOYSTICK: h = GetDlgItem(hdlg, IDC_COMBO_JOYSTICK); - temp_joystick = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.joystick_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY1); - EnableWindow(h, (gamedev_get_max_joysticks(temp_joystick) >= 1) ? TRUE : FALSE); + EnableWindow(h, (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 1) ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY2); - EnableWindow(h, (gamedev_get_max_joysticks(temp_joystick) >= 2) ? TRUE : FALSE); + EnableWindow(h, (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 2) ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY3); - EnableWindow(h, (gamedev_get_max_joysticks(temp_joystick) >= 3) ? TRUE : FALSE); + EnableWindow(h, (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 3) ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_JOY4); - EnableWindow(h, (gamedev_get_max_joysticks(temp_joystick) >= 4) ? TRUE : FALSE); + EnableWindow(h, (gamedev_get_max_joysticks(temp_cfg.joystick_type) >= 4) ? TRUE : FALSE); break; case IDC_CONFIGURE_JOY1: h = GetDlgItem(hdlg, IDC_COMBO_JOYSTICK); - temp_joystick = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_deviceconfig |= dlg_jsconf(hdlg, 0, temp_joystick); + temp_cfg.joystick_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_deviceconfig |= dlg_jsconf(hdlg, 0, temp_cfg.joystick_type); break; case IDC_CONFIGURE_JOY2: h = GetDlgItem(hdlg, IDC_COMBO_JOYSTICK); - temp_joystick = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_deviceconfig |= dlg_jsconf(hdlg, 1, temp_joystick); + temp_cfg.joystick_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_deviceconfig |= dlg_jsconf(hdlg, 1, temp_cfg.joystick_type); break; case IDC_CONFIGURE_JOY3: h = GetDlgItem(hdlg, IDC_COMBO_JOYSTICK); - temp_joystick = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_deviceconfig |= dlg_jsconf(hdlg, 2, temp_joystick); + temp_cfg.joystick_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_deviceconfig |= dlg_jsconf(hdlg, 2, temp_cfg.joystick_type); break; case IDC_CONFIGURE_JOY4: h = GetDlgItem(hdlg, IDC_COMBO_JOYSTICK); - temp_joystick = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_deviceconfig |= dlg_jsconf(hdlg, 3, temp_joystick); + temp_cfg.joystick_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_deviceconfig |= dlg_jsconf(hdlg, 3, temp_cfg.joystick_type); break; } return FALSE; case WM_SAVE_CFG: h = GetDlgItem(hdlg, IDC_COMBO_MOUSE); - temp_mouse = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.mouse_type = list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_COMBO_JOYSTICK); - temp_joystick = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.joystick_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); return FALSE; default: diff --git a/src/win/win_settings_machine.h b/src/win/win_settings_machine.h index 093904f..8fd1474 100644 --- a/src/win/win_settings_machine.h +++ b/src/win/win_settings_machine.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_machine.h 1.0.13 2019/04/11 + * Version: @(#)win_settings_machine.h 1.0.14 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -59,12 +59,12 @@ machine_recalc_cpu(HWND hdlg) int cpu_type; /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; - cpu_type = m->cpu[temp_cpu_m].cpus[temp_cpu].type; + cpu_type = m->cpu[temp_cfg.cpu_manuf].cpus[temp_cfg.cpu_type].type; #ifdef USE_DYNAREC - cpu_flags = m->cpu[temp_cpu_m].cpus[temp_cpu].flags; + cpu_flags = m->cpu[temp_cfg.cpu_manuf].cpus[temp_cfg.cpu_type].flags; #endif h = GetDlgItem(hdlg, IDC_COMBO_WS); @@ -76,7 +76,7 @@ machine_recalc_cpu(HWND hdlg) #ifdef USE_DYNAREC h = GetDlgItem(hdlg, IDC_CHECK_DYNAREC); if (cpu_flags & CPU_SUPPORTS_DYNAREC) { - SendMessage(h, BM_SETCHECK, temp_dynarec, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.cpu_use_dynarec, 0); /* * If Dynarec is not enabled, see if the CPU requires @@ -86,7 +86,7 @@ machine_recalc_cpu(HWND hdlg) */ if (cpu_flags & CPU_REQUIRES_DYNAREC) { #if 0 - if (! temp_dynarec) { + if (! temp_cfg.cpu_use_dynarec) { //FIXME: make this a messagebox with a user warning instead! --FvK fatal("Attempting to select a CPU that requires the recompiler and does not support it at the same time\n"); } @@ -102,8 +102,8 @@ machine_recalc_cpu(HWND hdlg) } } else { /* CPU does not support Dynarec, un-check it. */ - temp_dynarec = 0; - SendMessage(h, BM_SETCHECK, temp_dynarec, 0); + temp_cfg.cpu_use_dynarec = 0; + SendMessage(h, BM_SETCHECK, temp_cfg.cpu_use_dynarec, 0); /* Since it is not supported, lock the checkbox. */ EnableWindow(h, FALSE); @@ -114,14 +114,14 @@ machine_recalc_cpu(HWND hdlg) if ((cpu_type < CPU_i486DX) && (cpu_type >= CPU_286)) { EnableWindow(h, TRUE); } else if (cpu_type < CPU_286) { - temp_fpu = 0; + temp_cfg.enable_ext_fpu = 0; EnableWindow(h, FALSE); } else { - temp_fpu = 1; + temp_cfg.enable_ext_fpu = 1; EnableWindow(h, FALSE); } - SendMessage(h, BM_SETCHECK, temp_fpu, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.enable_ext_fpu, 0); } @@ -136,14 +136,14 @@ machine_recalc_cpu_m(HWND hdlg) int c = 0; /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; h = GetDlgItem(hdlg, IDC_COMBO_CPU); SendMessage(h, CB_RESETCONTENT, 0, 0); c = 0; for (;;) { - stransi = m->cpu[temp_cpu_m].cpus[c].name; + stransi = m->cpu[temp_cfg.cpu_manuf].cpus[c].name; if (stransi == NULL) break; @@ -153,9 +153,9 @@ machine_recalc_cpu_m(HWND hdlg) } EnableWindow(h, TRUE); - if (temp_cpu >= c) - temp_cpu = (c - 1); - SendMessage(h, CB_SETCURSEL, temp_cpu, 0); + if (temp_cfg.cpu_type >= c) + temp_cfg.cpu_type = (c - 1); + SendMessage(h, CB_SETCURSEL, temp_cfg.cpu_type, 0); machine_recalc_cpu(hdlg); } @@ -173,7 +173,7 @@ machine_recalc_machine(HWND hdlg) int c; /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; h = GetDlgItem(hdlg, IDC_CONFIGURE_MACHINE); @@ -193,9 +193,9 @@ machine_recalc_machine(HWND hdlg) } EnableWindow(h, TRUE); - if (temp_cpu_m >= c) - temp_cpu_m = (c - 1); - SendMessage(h, CB_SETCURSEL, temp_cpu_m, 0); + if (temp_cfg.cpu_manuf >= c) + temp_cfg.cpu_manuf = (c - 1); + SendMessage(h, CB_SETCURSEL, temp_cfg.cpu_manuf, 0); if (c == 1) EnableWindow(h, FALSE); else @@ -210,11 +210,11 @@ machine_recalc_machine(HWND hdlg) SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel); if (!(m->flags & MACHINE_AT) || (m->ram_granularity >= 128)) { - SendMessage(h, UDM_SETPOS, 0, temp_mem_size); + SendMessage(h, UDM_SETPOS, 0, temp_cfg.mem_size); h = GetDlgItem(hdlg, IDC_TEXT_MB); SendMessage(h, WM_SETTEXT, 0, win_string(IDS_3334)); } else { - SendMessage(h, UDM_SETPOS, 0, temp_mem_size / 1024); + SendMessage(h, UDM_SETPOS, 0, temp_cfg.mem_size / 1024); h = GetDlgItem(hdlg, IDC_TEXT_MB); SendMessage(h, WM_SETTEXT, 0, win_string(IDS_3330)); } @@ -251,8 +251,7 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_ADDSTRING, 0, (LPARAM)str); } - - SendMessage(h, CB_SETCURSEL, mach_to_list[temp_machine], 0); + SendMessage(h, CB_SETCURSEL, mach_to_list[temp_cfg.machine_type], 0); h = GetDlgItem(hdlg, IDC_COMBO_WS); SendMessage(h, CB_ADDSTRING, 0, win_string(IDS_3335)); @@ -260,11 +259,11 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) swprintf(temp, sizeof_w(temp), L"%i", c); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); } - SendMessage(h, CB_SETCURSEL, temp_wait_states, 0); + SendMessage(h, CB_SETCURSEL, temp_cfg.cpu_waitstates, 0); #ifdef USE_DYNAREC h = GetDlgItem(hdlg, IDC_CHECK_DYNAREC); - SendMessage(h, BM_SETCHECK, temp_dynarec, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.cpu_use_dynarec, 0); #endif h = GetDlgItem(hdlg, IDC_MEMSPIN); @@ -277,7 +276,7 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) TIME_SYNC_ENABLED, win_string(IDS_ENABLED)); SendMessage(h, CB_ADDSTRING, TIME_SYNC_ENABLED_UTC, win_string(IDS_3336)); - SendMessage(h, CB_SETCURSEL, temp_sync, 0); + SendMessage(h, CB_SETCURSEL, temp_cfg.time_sync, 0); machine_recalc_machine(hdlg); @@ -289,7 +288,7 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (HIWORD(wParam) == CBN_SELCHANGE) { h = GetDlgItem(hdlg, IDC_COMBO_MACHINE); d = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_machine = list_to_mach[d]; + temp_cfg.machine_type = list_to_mach[d]; machine_recalc_machine(hdlg); } break; @@ -297,9 +296,9 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_COMBO_CPU_TYPE: if (HIWORD(wParam) == CBN_SELCHANGE) { h = GetDlgItem(hdlg, IDC_COMBO_CPU_TYPE); - temp_cpu_m = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.cpu_manuf = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_cpu = 0; + temp_cfg.cpu_type = 0; machine_recalc_cpu_m(hdlg); } break; @@ -307,7 +306,7 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_COMBO_CPU: if (HIWORD(wParam) == CBN_SELCHANGE) { h = GetDlgItem(hdlg, IDC_COMBO_CPU); - temp_cpu = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.cpu_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); machine_recalc_cpu(hdlg); } @@ -316,15 +315,15 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_MACHINE: h = GetDlgItem(hdlg, IDC_COMBO_MACHINE); d = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_machine = list_to_mach[d]; - dev = machine_get_device_ex(temp_machine); + temp_cfg.machine_type = list_to_mach[d]; + dev = machine_get_device_ex(temp_cfg.machine_type); temp_deviceconfig |= dlg_devconf(hdlg, dev); break; case IDC_COMBO_SYNC: if (HIWORD(wParam) == CBN_SELCHANGE) { h = GetDlgItem(hdlg, IDC_COMBO_SYNC); - temp_sync = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.time_sync = (int)SendMessage(h, CB_GETCURSEL, 0, 0); } break; } @@ -333,39 +332,41 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_SAVE_CFG: /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; #ifdef USE_DYNAREC h = GetDlgItem(hdlg, IDC_CHECK_DYNAREC); - temp_dynarec = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.cpu_use_dynarec = (int)SendMessage(h, BM_GETCHECK, 0, 0); #endif h = GetDlgItem(hdlg, IDC_CHECK_FPU); - temp_fpu = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.enable_ext_fpu = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_COMBO_WS); - temp_wait_states = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.cpu_waitstates = (int)SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_MEMTEXT); SendMessage(h, WM_GETTEXT, sizeof_w(temp), (LPARAM)temp); wcstombs(tempA, temp, sizeof(tempA)); - sscanf(tempA, "%i", &temp_mem_size); - temp_mem_size &= ~(m->ram_granularity - 1); - if (temp_mem_size < (int)m->min_ram) - temp_mem_size = m->min_ram; - else if (temp_mem_size > (int)m->max_ram) - temp_mem_size = m->max_ram; + sscanf(tempA, "%i", &temp_cfg.mem_size); + temp_cfg.mem_size &= ~(m->ram_granularity - 1); + if (temp_cfg.mem_size < (int)m->min_ram) + temp_cfg.mem_size = m->min_ram; + else if (temp_cfg.mem_size > (int)m->max_ram) + temp_cfg.mem_size = m->max_ram; if ((m->flags & MACHINE_AT) && (m->ram_granularity < 128)) - temp_mem_size *= 1024; + temp_cfg.mem_size *= 1024; +#if 0 if (m->flags & MACHINE_VIDEO) - video_card = VID_INTERNAL; + temp_cfg.video_card = VID_INTERNAL; if (m->flags & MACHINE_MOUSE) - mouse_type = MOUSE_INTERNAL; + temp_cfg.mouse_type = MOUSE_INTERNAL; if (m->flags & MACHINE_SOUND) - sound_card = SOUND_INTERNAL; + temp_cfg.sound_card = SOUND_INTERNAL; if (m->flags & MACHINE_HDC) - hdc_type = HDC_INTERNAL; + temp_cfg.hdc_type = HDC_INTERNAL; +#endif return FALSE; default: diff --git a/src/win/win_settings_network.h b/src/win/win_settings_network.h index 2490b64..9ea914e 100644 --- a/src/win/win_settings_network.h +++ b/src/win/win_settings_network.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_network.h 1.0.12 2019/04/08 + * Version: @(#)win_settings_network.h 1.0.14 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,6 +43,8 @@ ************************************************************************/ /* Global variables for the Network dialog. */ +static int net_to_list[8], + list_to_net[8]; static int nic_to_list[20], list_to_nic[20]; static int net_ignore_message = 0; @@ -51,33 +53,37 @@ static int net_ignore_message = 0; static void network_recalc_combos(HWND hdlg) { - HWND h; + HWND h, h1, h2; net_ignore_message = 1; h = GetDlgItem(hdlg, IDC_COMBO_PCAP); - if (temp_net_type == NET_TYPE_PCAP) - EnableWindow(h, TRUE); - else - EnableWindow(h, FALSE); + h1 = GetDlgItem(hdlg, IDC_COMBO_NET_CARD); + h2 = GetDlgItem(hdlg, IDC_CONFIGURE_NET_CARD); - h = GetDlgItem(hdlg, IDC_COMBO_NET_CARD); - if (temp_net_type == NET_TYPE_SLIRP) - EnableWindow(h, TRUE); - else if ((temp_net_type == NET_TYPE_PCAP) && (network_card_to_id(temp_host_dev) > 0)) - EnableWindow(h, TRUE); - else - EnableWindow(h, FALSE); + switch(temp_cfg.network_type) { + case NET_SLIRP: + EnableWindow(h, FALSE); + EnableWindow(h1, TRUE); + EnableWindow(h2, TRUE); + break; - h = GetDlgItem(hdlg, IDC_CONFIGURE_NET_CARD); - if (network_card_has_config(temp_net_card) && (temp_net_type == NET_TYPE_SLIRP)) { - EnableWindow(h, TRUE); - } else if (network_card_has_config(temp_net_card) && - (temp_net_type == NET_TYPE_PCAP) && - (network_card_to_id(temp_host_dev) > 0)) { - EnableWindow(h, TRUE); - } else { - EnableWindow(h, FALSE); + case NET_PCAP: + EnableWindow(h, TRUE); + if (network_card_to_id(temp_cfg.network_host) > 0) { + EnableWindow(h1, TRUE); + EnableWindow(h2, TRUE); + } else { + EnableWindow(h1, FALSE); + EnableWindow(h2, FALSE); + } + break; + + default: + EnableWindow(h, FALSE); + EnableWindow(h1, TRUE); + EnableWindow(h2, TRUE); + break; } net_ignore_message = 0; @@ -98,14 +104,16 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; + /* Populate the "network types" box. */ h = GetDlgItem(hdlg, IDC_COMBO_NET_TYPE); c = d = 0; for (;;) { stransi = network_get_internal_name(c); - if (stransi == NULL) break; + if (stransi == NULL) + break; if (! network_available(c)) { c++; @@ -122,17 +130,21 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); } - c++; - d++; + net_to_list[c] = d; + list_to_net[d++] = c++; } - SendMessage(h, CB_SETCURSEL, temp_net_type, 0); + SendMessage(h, CB_SETCURSEL, + net_to_list[temp_cfg.network_type], 0); + + EnableWindow(h, d ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_COMBO_PCAP); - if (temp_net_type == NET_TYPE_PCAP) + if (temp_cfg.network_type == NET_PCAP) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); + /* Populate the "host interfaces" box. */ h = GetDlgItem(hdlg, IDC_COMBO_PCAP); for (c = 0; c < network_host_ndev; c++) { if (c == 0) { @@ -144,17 +156,19 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); } } - SendMessage(h, CB_SETCURSEL, network_card_to_id(temp_host_dev), 0); + SendMessage(h, CB_SETCURSEL, + network_card_to_id(temp_cfg.network_host), 0); - /*NIC config*/ + /* Populate the "network cards" box. */ h = GetDlgItem(hdlg, IDC_COMBO_NET_CARD); c = d = 0; - while (1) { + for (;;) { stransi = network_card_get_internal_name(c); if (stransi == NULL) break; dev = network_card_getdevice(c); - if (!network_card_available(c) || !device_is_valid(dev, m->flags)) { + if (!network_card_available(c) || + !device_is_valid(dev, m->flags)) { c++; continue; } @@ -163,6 +177,15 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) /* Translate "None". */ SendMessage(h, CB_ADDSTRING, 0, win_string(IDS_NONE)); + } else if (c == 1) { + if (! (m->flags & MACHINE_NETWORK)) { + c++; + continue; + } + + /* Translate "Internal". */ + SendMessage(h, CB_ADDSTRING, 0, + win_string(IDS_INTERNAL)); } else { sprintf(tempA, "[%s] %s", device_get_bus_name(dev), @@ -174,7 +197,8 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) nic_to_list[c] = d; list_to_nic[d++] = c++; } - SendMessage(h, CB_SETCURSEL, nic_to_list[temp_net_card], 0); + SendMessage(h, CB_SETCURSEL, + nic_to_list[temp_cfg.network_card], 0); EnableWindow(h, d ? TRUE : FALSE); network_recalc_combos(hdlg); @@ -187,7 +211,7 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; h = GetDlgItem(hdlg, IDC_COMBO_NET_TYPE); - temp_net_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.network_type = list_to_net[SendMessage(h, CB_GETCURSEL, 0, 0)]; network_recalc_combos(hdlg); break; @@ -197,8 +221,9 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; h = GetDlgItem(hdlg, IDC_COMBO_PCAP); - memset(temp_host_dev, '\0', sizeof(temp_host_dev)); - strcpy(temp_host_dev, network_host_devs[SendMessage(h, CB_GETCURSEL, 0, 0)].device); + memset(temp_cfg.network_host, '\0', sizeof(temp_cfg.network_host)); + strcpy(temp_cfg.network_host, + network_host_devs[SendMessage(h, CB_GETCURSEL, 0, 0)].device); network_recalc_combos(hdlg); break; @@ -208,7 +233,7 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; h = GetDlgItem(hdlg, IDC_COMBO_NET_CARD); - temp_net_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.network_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; network_recalc_combos(hdlg); break; @@ -218,23 +243,23 @@ network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; h = GetDlgItem(hdlg, IDC_COMBO_NET_CARD); - temp_net_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.network_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; - temp_deviceconfig |= dlg_devconf(hdlg, network_card_getdevice(temp_net_card)); + temp_deviceconfig |= dlg_devconf(hdlg, network_card_getdevice(temp_cfg.network_card)); break; } return FALSE; case WM_SAVE_CFG: h = GetDlgItem(hdlg, IDC_COMBO_NET_TYPE); - temp_net_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.network_type = list_to_net[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_COMBO_PCAP); - memset(temp_host_dev, '\0', sizeof(temp_host_dev)); - strcpy(temp_host_dev, network_host_devs[SendMessage(h, CB_GETCURSEL, 0, 0)].device); + memset(temp_cfg.network_host, '\0', sizeof(temp_cfg.network_host)); + strcpy(temp_cfg.network_host, network_host_devs[SendMessage(h, CB_GETCURSEL, 0, 0)].device); h = GetDlgItem(hdlg, IDC_COMBO_NET_CARD); - temp_net_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.network_card = list_to_nic[SendMessage(h, CB_GETCURSEL, 0, 0)]; return FALSE; default: diff --git a/src/win/win_settings_periph.h b/src/win/win_settings_periph.h index 1ee1ac0..16ba59b 100644 --- a/src/win/win_settings_periph.h +++ b/src/win/win_settings_periph.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_periph.h 1.0.19 2019/04/23 + * Version: @(#)win_settings_periph.h 1.0.20 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,7 +50,7 @@ static int hdc_to_list[20], /* Populate the HDC combo. */ static void -recalc_scsi_list(const machine_t *m, HWND hdlg) +recalc_scsi_list(const machine_t *m, HWND hdlg, int card) { WCHAR temp[128]; char tempA[128]; @@ -94,15 +94,21 @@ recalc_scsi_list(const machine_t *m, HWND hdlg) scsi_to_list[c] = d; list_to_scsi[d++] = c++; } + SendMessage(h, CB_SETCURSEL, scsi_to_list[card], 0); - SendMessage(h, CB_SETCURSEL, scsi_to_list[temp_scsi_card], 0); EnableWindow(h, d ? TRUE : FALSE); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_SCSI); + if (scsi_card_has_config(card)) + EnableWindow(h, TRUE); + else + EnableWindow(h, FALSE); } /* Populate the HDC combo. */ static void -recalc_hdc_list(const machine_t *m, HWND hdlg) +recalc_hdc_list(const machine_t *m, HWND hdlg, int card) { WCHAR temp[128]; char tempA[128]; @@ -151,9 +157,15 @@ recalc_hdc_list(const machine_t *m, HWND hdlg) list_to_hdc[d] = c; c++; d++; } + SendMessage(h, CB_SETCURSEL, hdc_to_list[card], 0); - SendMessage(h, CB_SETCURSEL, hdc_to_list[temp_hdc_type], 0); EnableWindow(h, d ? TRUE : FALSE); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_HDC); + if (hdc_has_config(card)) + EnableWindow(h, TRUE); + else + EnableWindow(h, FALSE); } @@ -170,35 +182,23 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; - recalc_scsi_list(m, hdlg); + recalc_scsi_list(m, hdlg, temp_cfg.scsi_card); - h = GetDlgItem(hdlg, IDC_CONFIGURE_SCSI); - if (scsi_card_has_config(temp_scsi_card)) - EnableWindow(h, TRUE); - else - EnableWindow(h, FALSE); - - recalc_hdc_list(m, hdlg); - - h = GetDlgItem(hdlg, IDC_CONFIGURE_HDC); - if (hdc_has_config(temp_hdc_type)) - EnableWindow(h, TRUE); - else - EnableWindow(h, FALSE); + recalc_hdc_list(m, hdlg, temp_cfg.hdc_type); if (m->flags & MACHINE_AT) { h = GetDlgItem(hdlg, IDC_CHECK_IDE_TER); EnableWindow(h, TRUE); - SendMessage(h, BM_SETCHECK, temp_ide_ter, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.ide_ter_enabled, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_IDE_TER); EnableWindow(h, TRUE); h = GetDlgItem(hdlg, IDC_CHECK_IDE_QUA); EnableWindow(h, TRUE); - SendMessage(h, BM_SETCHECK, temp_ide_qua, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.ide_qua_enabled, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_IDE_QUA); EnableWindow(h, TRUE); } else { @@ -214,7 +214,7 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } h = GetDlgItem(hdlg, IDC_CHECK_BUGGER); - SendMessage(h, BM_SETCHECK, temp_bugger, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.bugger_enabled, 0); /* Populate the ISA RTC card dropdown. */ h = GetDlgItem(hdlg, IDC_COMBO_ISARTC); @@ -233,9 +233,9 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); } } - SendMessage(h, CB_SETCURSEL, temp_isartc, 0); + SendMessage(h, CB_SETCURSEL, temp_cfg.isartc_type, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_ISARTC); - if (temp_isartc != 0) + if (temp_cfg.isartc_type != 0) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); @@ -258,9 +258,9 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); } } - SendMessage(h, CB_SETCURSEL, temp_isamem[c], 0); + SendMessage(h, CB_SETCURSEL, temp_cfg.isamem_type[c], 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_ISAMEM_1 + c); - if (temp_isamem[c] != 0) + if (temp_cfg.isamem_type[c] != 0) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); @@ -272,10 +272,10 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDC_COMBO_SCSI: h = GetDlgItem(hdlg, IDC_COMBO_SCSI); - temp_scsi_card = list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.scsi_card = list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_SCSI); - if (scsi_card_has_config(temp_scsi_card)) + if (scsi_card_has_config(temp_cfg.scsi_card)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); @@ -283,17 +283,17 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_SCSI: h = GetDlgItem(hdlg, IDC_COMBO_SCSI); - temp_scsi_card = list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.scsi_card = list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; - temp_deviceconfig |= dlg_devconf(hdlg, scsi_card_getdevice(temp_scsi_card)); + temp_deviceconfig |= dlg_devconf(hdlg, scsi_card_getdevice(temp_cfg.scsi_card)); break; case IDC_COMBO_HDC: h = GetDlgItem(hdlg, IDC_COMBO_HDC); - temp_hdc_type = list_to_hdc[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.hdc_type = list_to_hdc[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_HDC); - if (hdc_has_config(temp_hdc_type)) + if (hdc_has_config(temp_cfg.hdc_type)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); @@ -301,16 +301,16 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_HDC: h = GetDlgItem(hdlg, IDC_COMBO_HDC); - temp_hdc_type = list_to_hdc[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.hdc_type = list_to_hdc[SendMessage(h, CB_GETCURSEL, 0, 0)]; - temp_deviceconfig |= dlg_devconf(hdlg, hdc_get_device(temp_hdc_type)); + temp_deviceconfig |= dlg_devconf(hdlg, hdc_get_device(temp_cfg.hdc_type)); break; case IDC_CHECK_IDE_TER: h = GetDlgItem(hdlg, IDC_CHECK_IDE_TER); - temp_ide_ter = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.ide_ter_enabled = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_IDE_TER); - EnableWindow(h, temp_ide_ter ? TRUE : FALSE); + EnableWindow(h, temp_cfg.ide_ter_enabled ? TRUE : FALSE); break; case IDC_CONFIGURE_IDE_TER: @@ -319,9 +319,9 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CHECK_IDE_QUA: h = GetDlgItem(hdlg, IDC_CHECK_IDE_QUA); - temp_ide_qua = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.ide_qua_enabled = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_IDE_QUA); - EnableWindow(h, temp_ide_qua ? TRUE : FALSE); + EnableWindow(h, temp_cfg.ide_qua_enabled ? TRUE : FALSE); break; case IDC_CONFIGURE_IDE_QUA: @@ -330,35 +330,35 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_COMBO_ISARTC: h = GetDlgItem(hdlg, IDC_COMBO_ISARTC); - temp_isartc = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.isartc_type = (int)SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_ISARTC); - if (temp_isartc != 0) + if (temp_cfg.isartc_type != 0) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); break; + case IDC_CONFIGURE_ISARTC: + dev = isartc_get_device(temp_cfg.isartc_type); + if (dev != NULL) + temp_deviceconfig |= dlg_devconf(hdlg, dev); + break; + case IDC_COMBO_ISAMEM_1: case IDC_COMBO_ISAMEM_2: case IDC_COMBO_ISAMEM_3: case IDC_COMBO_ISAMEM_4: c = LOWORD(wParam) - IDC_COMBO_ISAMEM_1; h = GetDlgItem(hdlg, LOWORD(wParam)); - temp_isamem[c] = (int)SendMessage(h, CB_GETCURSEL, 0, 0); + temp_cfg.isamem_type[c] = (int)SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_ISAMEM_1 + c); - if (temp_isamem[c] != 0) + if (temp_cfg.isamem_type[c] != 0) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); break; - case IDC_CONFIGURE_ISARTC: - dev = isartc_get_device(temp_isartc); - if (dev != NULL) - temp_deviceconfig |= dlg_devconf(hdlg, dev); - break; - case IDC_CONFIGURE_ISAMEM_1: case IDC_CONFIGURE_ISAMEM_2: case IDC_CONFIGURE_ISAMEM_3: @@ -376,14 +376,14 @@ peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_SAVE_CFG: h = GetDlgItem(hdlg, IDC_COMBO_HDC); c = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_hdc_type = list_to_hdc[c]; + temp_cfg.hdc_type = list_to_hdc[c]; h = GetDlgItem(hdlg, IDC_COMBO_SCSI); c = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_scsi_card = list_to_scsi[c]; + temp_cfg.scsi_card = list_to_scsi[c]; h = GetDlgItem(hdlg, IDC_CHECK_BUGGER); - temp_bugger = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.bugger_enabled = (int)SendMessage(h, BM_GETCHECK, 0, 0); return FALSE; diff --git a/src/win/win_settings_ports.h b/src/win/win_settings_ports.h index a0728f3..7ecf56a 100644 --- a/src/win/win_settings_ports.h +++ b/src/win/win_settings_ports.h @@ -8,12 +8,12 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_ports.h 1.0.7 2018/10/24 + * Version: @(#)win_settings_ports.h 1.0.8 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -54,7 +54,7 @@ ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* Set up the game port controls. */ h = GetDlgItem(hdlg, IDC_CHECK_GAME); - SendMessage(h, BM_SETCHECK, temp_game, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.game_enabled, 0); /* Set up the parallel port controls. */ for (i = 0; i < PARALLEL_MAX; i++) { @@ -75,15 +75,14 @@ ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } /* Currently selected device? */ - if (temp_parallel_device[i] == c) + if (temp_cfg.parallel_device[i] == c) d = c; c++; } - SendMessage(h, CB_SETCURSEL, d, 0); /* Enable or disable this port. */ - d = parallel_enabled[i]; + d = temp_cfg.parallel_enabled[i]; EnableWindow(h, d ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CHECK_PARALLEL1+i); SendMessage(h, BM_SETCHECK, d, 0); @@ -92,7 +91,7 @@ ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) /* Set up the serial port controls. */ for (i = 0; i < SERIAL_MAX; i++) { h = GetDlgItem(hdlg, IDC_CHECK_SERIAL1+i); - SendMessage(h, BM_SETCHECK, temp_serial[i], 0); + SendMessage(h, BM_SETCHECK, temp_cfg.serial_enabled[i], 0); } return TRUE; @@ -112,20 +111,20 @@ ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_SAVE_CFG: h = GetDlgItem(hdlg, IDC_CHECK_GAME); - temp_game = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.game_enabled = (int)SendMessage(h, BM_GETCHECK, 0, 0); for (i = 0; i < PARALLEL_MAX; i++) { h = GetDlgItem(hdlg, IDC_CHECK_PARALLEL1+i); - temp_parallel[i] = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.parallel_enabled[i] = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_COMBO_PARALLEL1+i); c = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_parallel_device[i] = c; + temp_cfg.parallel_device[i] = c; } for (i = 0; i < SERIAL_MAX; i++) { h = GetDlgItem(hdlg, IDC_CHECK_SERIAL1+i); - temp_serial[i] = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.serial_enabled[i] = (int)SendMessage(h, BM_GETCHECK, 0, 0); } return FALSE; diff --git a/src/win/win_settings_remov.h b/src/win/win_settings_remov.h index 6927eb2..7194392 100644 --- a/src/win/win_settings_remov.h +++ b/src/win/win_settings_remov.h @@ -8,7 +8,7 @@ * * Implementation of the "Removable Devices" dialog. * - * Version: @(#)win_settings_remov.h 1.0.13 2019/03/21 + * Version: @(#)win_settings_remov.h 1.0.14 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/win/win_settings_sound.h b/src/win/win_settings_sound.h index a41ba6f..2f0e7e1 100644 --- a/src/win/win_settings_sound.h +++ b/src/win/win_settings_sound.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_sound.h 1.0.15 2019/04/08 + * Version: @(#)win_settings_sound.h 1.0.16 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -55,7 +55,7 @@ static int midi_to_list[NUM_MIDI], static int mpu401_present(void) { - return temp_mpu401 ? 1 : 0; + return temp_cfg.mpu401_standalone_enable ? 1 : 0; } @@ -64,7 +64,7 @@ mpu401_standalone_allow(void) { const char *md; - md = midi_device_get_internal_name(temp_midi_device); + md = midi_device_get_internal_name(temp_cfg.midi_device); if (md != NULL) { if (! strcmp(md, "none")) return 0; @@ -88,14 +88,15 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; h = GetDlgItem(hdlg, IDC_COMBO_SOUND); c = d = 0; for (;;) { stransi = sound_card_get_internal_name(c); - if (stransi == NULL) break; + if (stransi == NULL) + break; dev = sound_card_getdevice(c); @@ -130,13 +131,13 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) list_to_sound[d] = c; d++; c++; } - - SendMessage(h, CB_SETCURSEL, sound_to_list[temp_sound_card], 0); + SendMessage(h, CB_SETCURSEL, + sound_to_list[temp_cfg.sound_card], 0); EnableWindow(h, d ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_SOUND); - if (sound_card_has_config(temp_sound_card)) + if (sound_card_has_config(temp_cfg.sound_card)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); @@ -167,26 +168,27 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) c++; } - SendMessage(h, CB_SETCURSEL, midi_to_list[temp_midi_device], 0); + SendMessage(h, CB_SETCURSEL, + midi_to_list[temp_cfg.midi_device], 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_MIDI); - if (midi_device_has_config(temp_midi_device)) + if (midi_device_has_config(temp_cfg.midi_device)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); h = GetDlgItem(hdlg, IDC_CHECK_MPU401); - SendMessage(h, BM_SETCHECK, temp_mpu401, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.mpu401_standalone_enable, 0); EnableWindow(h, mpu401_standalone_allow() ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401); - EnableWindow(h, (mpu401_standalone_allow() && temp_mpu401) ? TRUE : FALSE); + EnableWindow(h, (mpu401_standalone_allow() && temp_cfg.mpu401_standalone_enable) ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL); - SendMessage(h, BM_SETCHECK, temp_opl_type, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.opl_type, 0); h = GetDlgItem(hdlg, IDC_CHECK_FLOAT); - SendMessage(h, BM_SETCHECK, temp_float, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.sound_is_float, 0); return TRUE; @@ -194,57 +196,57 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDC_COMBO_SOUND: h = GetDlgItem(hdlg, IDC_COMBO_SOUND); - temp_sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_SOUND); - if (sound_card_has_config(temp_sound_card)) + if (sound_card_has_config(temp_cfg.sound_card)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); h = GetDlgItem(hdlg, IDC_CHECK_MPU401); - SendMessage(h, BM_SETCHECK, temp_mpu401, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.mpu401_standalone_enable, 0); EnableWindow(h, mpu401_standalone_allow() ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401); - EnableWindow(h, (mpu401_standalone_allow() && temp_mpu401) ? TRUE : FALSE); + EnableWindow(h, (mpu401_standalone_allow() && temp_cfg.mpu401_standalone_enable) ? TRUE : FALSE); break; case IDC_CONFIGURE_SOUND: h = GetDlgItem(hdlg, IDC_COMBO_SOUND); - temp_sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; - temp_deviceconfig |= dlg_devconf(hdlg, sound_card_getdevice(temp_sound_card)); + temp_deviceconfig |= dlg_devconf(hdlg, sound_card_getdevice(temp_cfg.sound_card)); break; case IDC_COMBO_MIDI: h = GetDlgItem(hdlg, IDC_COMBO_MIDI); - temp_midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CONFIGURE_MIDI); - if (midi_device_has_config(temp_midi_device)) + if (midi_device_has_config(temp_cfg.midi_device)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); h = GetDlgItem(hdlg, IDC_CHECK_MPU401); - SendMessage(h, BM_SETCHECK, temp_mpu401, 0); + SendMessage(h, BM_SETCHECK, temp_cfg.mpu401_standalone_enable, 0); EnableWindow(h, mpu401_standalone_allow() ? TRUE : FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401); - EnableWindow(h, (mpu401_standalone_allow() && temp_mpu401) ? TRUE : FALSE); + EnableWindow(h, (mpu401_standalone_allow() && temp_cfg.mpu401_standalone_enable) ? TRUE : FALSE); break; case IDC_CONFIGURE_MIDI: h = GetDlgItem(hdlg, IDC_COMBO_MIDI); - temp_midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; - temp_deviceconfig |= dlg_devconf(hdlg, midi_device_getdevice(temp_midi_device)); + temp_deviceconfig |= dlg_devconf(hdlg, midi_device_getdevice(temp_cfg.midi_device)); break; case IDC_CHECK_MPU401: h = GetDlgItem(hdlg, IDC_CHECK_MPU401); - temp_mpu401 = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.mpu401_standalone_enable = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401); EnableWindow(h, mpu401_present() ? TRUE : FALSE); @@ -252,7 +254,7 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_MPU401: /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; temp_deviceconfig |= dlg_devconf(hdlg, (m->flags & MACHINE_MCA) ? &mpu401_mca_device : &mpu401_device); @@ -262,23 +264,23 @@ sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_SAVE_CFG: h = GetDlgItem(hdlg, IDC_COMBO_SOUND); - temp_sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.sound_card = list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_COMBO_MIDI); - temp_midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_cfg.midi_device = list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)]; h = GetDlgItem(hdlg, IDC_CHECK_MPU401); - temp_mpu401 = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.mpu401_standalone_enable = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_CHECK_NUKEDOPL); - temp_opl_type = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.opl_type = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_CHECK_FLOAT); - temp_float = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.sound_is_float = (int)SendMessage(h, BM_GETCHECK, 0, 0); return FALSE; default: - break; + break; } return FALSE; diff --git a/src/win/win_settings_video.h b/src/win/win_settings_video.h index ebc4919..450bd88 100644 --- a/src/win/win_settings_video.h +++ b/src/win/win_settings_video.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_video.h 1.0.11 2019/04/08 + * Version: @(#)win_settings_video.h 1.0.12 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -59,7 +59,7 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) HWND h; /* Get info about the selected machine. */ - dev = machine_get_device_ex(temp_machine); + dev = machine_get_device_ex(temp_cfg.machine_type); m = (machine_t *)dev->mach_info; switch (message) { @@ -111,10 +111,10 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) INFO("A total of %i video cards are available.\n", d); /* Select the current card. */ - vid = vid_to_list[temp_video_card]; + vid = vid_to_list[temp_cfg.video_card]; if (vid < d) { SendMessage(h, CB_SETCURSEL, vid, 0); - if (video_card_has_config(temp_video_card)) { + if (video_card_has_config(temp_cfg.video_card)) { h = GetDlgItem(hdlg, IDC_CONFIGURE_VIDEO); EnableWindow(h, TRUE); } @@ -127,7 +127,7 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) h = GetDlgItem(hdlg, IDC_CHECK_VOODOO); EnableWindow(h, (m->flags & MACHINE_PCI) ? TRUE:FALSE); h = GetDlgItem(hdlg, IDC_CONFIGURE_VOODOO); - EnableWindow(h, ((m->flags & MACHINE_PCI) && temp_voodoo) ? TRUE : FALSE); + EnableWindow(h, ((m->flags & MACHINE_PCI) && temp_cfg.voodoo_enabled) ? TRUE : FALSE); return TRUE; @@ -136,43 +136,43 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_COMBO_VIDEO: h = GetDlgItem(hdlg, IDC_COMBO_VIDEO); c = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_video_card = list_to_vid[c]; + temp_cfg.video_card = list_to_vid[c]; h = GetDlgItem(hdlg, IDC_CONFIGURE_VIDEO); - if (video_card_has_config(temp_video_card)) + if (video_card_has_config(temp_cfg.video_card)) EnableWindow(h, TRUE); else EnableWindow(h, FALSE); break; + case IDC_CONFIGURE_VIDEO: + h = GetDlgItem(hdlg, IDC_COMBO_VIDEO); + temp_cfg.video_card = list_to_vid[SendMessage(h, CB_GETCURSEL, 0, 0)]; + temp_deviceconfig |= dlg_devconf(hdlg, video_card_getdevice(temp_cfg.video_card)); + + break; + case IDC_CHECK_VOODOO: h = GetDlgItem(hdlg, IDC_CHECK_VOODOO); - temp_voodoo = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.voodoo_enabled = (int)SendMessage(h, BM_GETCHECK, 0, 0); h = GetDlgItem(hdlg, IDC_CONFIGURE_VOODOO); - EnableWindow(h, temp_voodoo ? TRUE : FALSE); + EnableWindow(h, temp_cfg.voodoo_enabled ? TRUE : FALSE); break; case IDC_CONFIGURE_VOODOO: temp_deviceconfig |= dlg_devconf(hdlg, &voodoo_device); break; - - case IDC_CONFIGURE_VIDEO: - h = GetDlgItem(hdlg, IDC_COMBO_VIDEO); - c = list_to_vid[SendMessage(h, CB_GETCURSEL, 0, 0)]; - temp_deviceconfig |= dlg_devconf(hdlg, video_card_getdevice(c)); - - break; } return FALSE; case WM_SAVE_CFG: h = GetDlgItem(hdlg, IDC_COMBO_VIDEO); c = (int)SendMessage(h, CB_GETCURSEL, 0, 0); - temp_video_card = list_to_vid[c]; + temp_cfg.video_card = list_to_vid[c]; h = GetDlgItem(hdlg, IDC_CHECK_VOODOO); - temp_voodoo = (int)SendMessage(h, BM_GETCHECK, 0, 0); + temp_cfg.voodoo_enabled = (int)SendMessage(h, BM_GETCHECK, 0, 0); return FALSE; default: diff --git a/src/win/win_snd_gain.c b/src/win/win_snd_gain.c index b3d7936..aaaa964 100644 --- a/src/win/win_snd_gain.c +++ b/src/win/win_snd_gain.c @@ -8,12 +8,12 @@ * * Implementation of the Sound Gain dialog. * - * Version: @(#)win_snd_gain.c 1.0.10 2018/10/25 + * Version: @(#)win_snd_gain.c 1.0.11 2018/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * Copyright 2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -63,10 +63,10 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: dialog_center(hdlg); - old_gain = sound_gain; + old_gain = config.sound_gain; h = GetDlgItem(hdlg, IDC_SLIDER_GAIN); SendMessage(h, TBM_SETRANGE, (WPARAM)1, (LPARAM)MAKELONG(0, 9)); - SendMessage(h, TBM_SETPOS, (WPARAM)1, 9 - (sound_gain >> 1)); + SendMessage(h, TBM_SETPOS, (WPARAM)1, 9 - (config.sound_gain >> 1)); SendMessage(h, TBM_SETTICFREQ, (WPARAM)1, 0); SendMessage(h, TBM_SETLINESIZE, (WPARAM)0, 1); SendMessage(h, TBM_SETPAGESIZE, (WPARAM)0, 2); @@ -74,20 +74,20 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_VSCROLL: h = GetDlgItem(hdlg, IDC_SLIDER_GAIN); - sound_gain = (9 - (int)SendMessage(h, TBM_GETPOS, (WPARAM)0, 0)) << 1; + config.sound_gain = (9 - (int)SendMessage(h, TBM_GETPOS, (WPARAM)0, 0)) << 1; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: h = GetDlgItem(hdlg, IDC_SLIDER_GAIN); - sound_gain = (9 - (int)SendMessage(h, TBM_GETPOS, (WPARAM)0, 0)) << 1; + config.sound_gain = (9 - (int)SendMessage(h, TBM_GETPOS, (WPARAM)0, 0)) << 1; config_save(); EndDialog(hdlg, 0); return TRUE; case IDCANCEL: - sound_gain = old_gain; + config.sound_gain = old_gain; config_save(); EndDialog(hdlg, 0); return TRUE; diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 5cf7d63..fae2e04 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -8,7 +8,7 @@ * * Implement the user Interface module. * - * Version: @(#)win_ui.c 1.0.37 2019/04/30 + * Version: @(#)win_ui.c 1.0.38 2019/05/03 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -278,7 +278,8 @@ LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) BOOL bControlKeyDown; KBDLLHOOKSTRUCT *p; - if (nCode < 0 || nCode != HC_ACTION || (!mouse_capture && !vid_fullscreen)) + if (nCode < 0 || nCode != HC_ACTION || + (!mouse_capture && !config.vid_fullscreen)) return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); p = (KBDLLHOOKSTRUCT*)lParam; @@ -380,7 +381,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_RESIZE: /* Set up for resizing if configured. */ flags = WS_OVERLAPPEDWINDOW; - if (! vid_resize) + if (! config.vid_resize) flags &= ~(WS_SIZEBOX | WS_THICKFRAME | WS_MAXIMIZEBOX); SetWindowLongPtr(hwnd, GWL_STYLE, flags); @@ -396,11 +397,11 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_REMEMBER: GetWindowRect(hwnd, &rect); - if (window_remember) { - window_x = rect.left; - window_y = rect.top; - window_w = rect.right - rect.left; - window_h = rect.bottom - rect.top; + if (config.window_remember) { + config.win_x = rect.left; + config.win_y = rect.top; + config.win_w = rect.right - rect.left; + config.win_h = rect.bottom - rect.top; } config_save(); break; @@ -465,13 +466,13 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ClipCursor(&rect); } - if (window_remember) { + if (config.window_remember) { GetWindowRect(hwndMain, &rect); - window_x = rect.left; - window_y = rect.top; - window_w = rect.right - rect.left; - window_h = rect.bottom - rect.top; + config.win_x = rect.left; + config.win_y = rect.top; + config.win_w = rect.right - rect.left; + config.win_h = rect.bottom - rect.top; save_window_pos = 1; config_save(); @@ -483,16 +484,16 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) * If window is not resizable, then tell the main thread * to resize it, as sometimes, moves can mess up the window * size. */ - if (! vid_resize) + if (! config.vid_resize) doresize = 1; - if (window_remember) { + if (config.window_remember) { GetWindowRect(hwndMain, &rect); - window_x = rect.left; - window_y = rect.top; - window_w = rect.right - rect.left; - window_h = rect.bottom - rect.top; + config.win_x = rect.left; + config.win_y = rect.top; + config.win_w = rect.right - rect.left; + config.win_h = rect.bottom - rect.top; save_window_pos = 1; } break; @@ -619,7 +620,7 @@ input_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_LBUTTONUP: - if (! vid_fullscreen) + if (! config.vid_fullscreen) ui_mouse_capture(1); break; @@ -723,7 +724,7 @@ ui_init(int nCmdShow) /* Set up main window for resizing if configured. */ flags = WS_OVERLAPPEDWINDOW; - if (! vid_resize) + if (! config.vid_resize) flags &= ~(WS_SIZEBOX | WS_THICKFRAME | WS_MAXIMIZEBOX); /* @@ -768,8 +769,8 @@ ui_init(int nCmdShow) ui_reset(); /* Move to the last-saved position if needed. */ - if (window_remember) - MoveWindow(hwndMain, window_x, window_y, window_w, window_h, FALSE); + if (config.window_remember) + MoveWindow(hwndMain, config.win_x, config.win_y, config.win_w, config.win_h, FALSE); /* Load the accelerator table */ haccel = LoadAccelerators(hInstance, ACCEL_NAME); @@ -839,7 +840,7 @@ ui_init(int nCmdShow) /* Initialize the configured Video API. */ again: - if (! vidapi_set(vid_api)) { + if (! vidapi_set(config.vid_api)) { /* * Selected renderer is not available. * @@ -852,14 +853,14 @@ again: */ swprintf(title, sizeof_w(title), get_string(IDS_ERR_NORENDR), - vidapi_get_internal_name(vid_api)); + vidapi_get_internal_name(config.vid_api)); if (ui_msgbox(MBX_CONFIG, title) != 0) { /* Nope, they don't, so just exit. */ return(5); } /* OK, reset to the default one and retry. */ - vid_api = vidapi_from_internal_name("default"); + config.vid_api = vidapi_from_internal_name("default"); goto again; } @@ -920,7 +921,7 @@ again: ui_mouse_capture(0); } - if (vid_fullscreen && keyboard_isfsexit()) { + if (config.vid_fullscreen && keyboard_isfsexit()) { /* Signal "exit fullscreen mode". */ /* INFO("leave full screen though key combination\n"); */ ui_fullscreen(0); @@ -954,7 +955,7 @@ ui_resize(int x, int y) RECT r; /* First, see if we should resize the UI window. */ - if (vid_resize) return; + if (config.vid_resize) return; video_blit_wait(); @@ -969,7 +970,7 @@ ui_resize(int x, int y) wchar_t * ui_window_title(const wchar_t *s) { - if (! vid_fullscreen) { + if (! config.vid_fullscreen) { if (s != NULL) wcscpy(wTitle, s); else