Files
86Box/src/config.c

2864 lines
100 KiB
C
Raw Normal View History

/*
2022-07-21 21:44:55 -04:00
* 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.
*
2022-07-21 21:44:55 -04:00
* This file is part of the 86Box distribution.
*
2022-07-21 21:44:55 -04:00
* Configuration file handler.
*
2020-03-25 00:46:02 +02:00
*
*
2022-07-21 21:44:55 -04:00
* Authors: Sarah Walker,
* Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
* Overdoze,
* David Hrdlička, <hrdlickadavid@outlook.com>
*
2022-07-21 21:44:55 -04:00
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
* Copyright 2017-2019 Fred N. van Kempen.
* Copyright 2018,2019 David Hrdlička.
*
2022-07-21 21:44:55 -04:00
* 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.
*/
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include <86box/86box.h>
2020-02-29 19:12:23 +01:00
#include "cpu.h"
#include <86box/device.h>
#include <86box/timer.h>
#include <86box/cassette.h>
2021-07-29 20:34:55 +02:00
#include <86box/cartridge.h>
#include <86box/nvr.h>
2022-09-10 13:32:46 +02:00
#include <86box/ini.h>
#include <86box/config.h>
#include <86box/isamem.h>
#include <86box/isartc.h>
#include <86box/lpt.h>
2022-07-28 16:50:49 -04:00
#include <86box/serial.h>
#include <86box/hdd.h>
#include <86box/hdc.h>
#include <86box/hdc_ide.h>
#include <86box/fdd.h>
#include <86box/fdc.h>
2020-06-16 16:41:35 +02:00
#include <86box/fdc_ext.h>
#include <86box/gameport.h>
#include <86box/machine.h>
#include <86box/mouse.h>
#include <86box/thread.h>
#include <86box/network.h>
#include <86box/scsi.h>
#include <86box/scsi_device.h>
#include <86box/cdrom.h>
#include <86box/zip.h>
#include <86box/mo.h>
#include <86box/sound.h>
#include <86box/midi.h>
#include <86box/snd_mpu401.h>
#include <86box/video.h>
2022-04-19 23:06:39 +02:00
#include <86box/path.h>
#include <86box/plat.h>
#include <86box/plat_dir.h>
#include <86box/ui.h>
#include <86box/snd_opl.h>
static int cx, cy, cw, ch;
2022-09-10 13:32:46 +02:00
static ini_t config;
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
2022-07-21 21:44:55 -04:00
static int backwards_compat = 0;
static int backwards_compat2 = 0;
#ifdef ENABLE_CONFIG_LOG
int config_do_log = ENABLE_CONFIG_LOG;
static void
config_log(const char *fmt, ...)
{
va_list ap;
if (config_do_log) {
2022-07-21 21:44:55 -04:00
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
}
#else
2022-07-21 21:44:55 -04:00
# define config_log(fmt, ...)
#endif
/* Load "General" section. */
static void
load_general(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "General");
2022-07-21 21:44:55 -04:00
char temp[512];
char *p;
2022-09-10 13:32:46 +02:00
vid_resize = ini_section_get_int(cat, "vid_resize", 0);
if (vid_resize & ~3)
2022-07-21 21:44:55 -04:00
vid_resize &= 3;
memset(temp, '\0', sizeof(temp));
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "vid_renderer", "default");
vid_api = plat_vidapi(p);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "vid_api");
2022-09-10 13:32:46 +02:00
video_fullscreen_scale = ini_section_get_int(cat, "video_fullscreen_scale", 0);
2022-09-10 13:32:46 +02:00
video_fullscreen_first = ini_section_get_int(cat, "video_fullscreen_first", 1);
2022-09-10 13:32:46 +02:00
video_filter_method = ini_section_get_int(cat, "video_filter_method", 1);
2022-09-10 13:32:46 +02:00
force_43 = !!ini_section_get_int(cat, "force_43", 0);
scale = ini_section_get_int(cat, "scale", 1);
if (scale > 3)
scale = 3;
2022-09-10 13:32:46 +02:00
dpi_scale = ini_section_get_int(cat, "dpi_scale", 1);
2022-09-10 13:32:46 +02:00
enable_overscan = !!ini_section_get_int(cat, "enable_overscan", 0);
vid_cga_contrast = !!ini_section_get_int(cat, "vid_cga_contrast", 0);
video_grayscale = ini_section_get_int(cat, "video_grayscale", 0);
video_graytype = ini_section_get_int(cat, "video_graytype", 0);
2022-09-10 13:32:46 +02:00
rctrl_is_lalt = ini_section_get_int(cat, "rctrl_is_lalt", 0);
update_icons = ini_section_get_int(cat, "update_icons", 1);
2022-09-10 13:32:46 +02:00
window_remember = ini_section_get_int(cat, "window_remember", 0);
if (window_remember || (vid_resize & 2)) {
2022-07-21 21:44:55 -04:00
if (!window_remember)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_remember");
} else {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_remember");
2022-07-21 21:44:55 -04:00
window_w = window_h = window_x = window_y = 0;
}
if (vid_resize & 2) {
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "window_fixed_res", NULL);
2022-07-21 21:44:55 -04:00
if (p == NULL)
p = "120x120";
sscanf(p, "%ix%i", &fixed_size_x, &fixed_size_y);
if (fixed_size_x < 120)
fixed_size_x = 120;
if (fixed_size_x > 2048)
fixed_size_x = 2048;
if (fixed_size_y < 120)
fixed_size_y = 120;
if (fixed_size_y > 2048)
fixed_size_y = 2048;
} else {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_fixed_res");
2022-07-21 21:44:55 -04:00
fixed_size_x = fixed_size_y = 120;
}
2022-09-10 13:32:46 +02:00
sound_gain = ini_section_get_int(cat, "sound_gain", 0);
2022-09-10 13:32:46 +02:00
kbd_req_capture = ini_section_get_int(cat, "kbd_req_capture", 0);
hide_status_bar = ini_section_get_int(cat, "hide_status_bar", 0);
hide_tool_bar = ini_section_get_int(cat, "hide_tool_bar", 0);
2022-09-10 13:32:46 +02:00
confirm_reset = ini_section_get_int(cat, "confirm_reset", 1);
confirm_exit = ini_section_get_int(cat, "confirm_exit", 1);
confirm_save = ini_section_get_int(cat, "confirm_save", 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "language", NULL);
2022-07-18 02:17:16 +02:00
if (p != NULL)
2022-07-21 21:44:55 -04:00
lang_id = plat_language_code(p);
2022-02-20 02:26:27 -05:00
2022-09-10 13:32:46 +02:00
mouse_sensitivity = ini_section_get_double(cat, "mouse_sensitivity", 1.0);
2022-06-01 15:31:58 +06:00
if (mouse_sensitivity < 0.5)
2022-07-21 21:44:55 -04:00
mouse_sensitivity = 0.5;
2022-06-01 15:31:58 +06:00
else if (mouse_sensitivity > 2.0)
2022-07-21 21:44:55 -04:00
mouse_sensitivity = 2.0;
2022-06-01 15:31:58 +06:00
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "iconset", NULL);
2022-07-18 02:17:16 +02:00
if (p != NULL)
2022-07-21 21:44:55 -04:00
strcpy(icon_set, p);
2022-07-18 02:17:16 +02:00
else
2022-07-21 21:44:55 -04:00
strcpy(icon_set, "");
2022-02-20 02:26:27 -05:00
2022-09-10 13:32:46 +02:00
enable_discord = !!ini_section_get_int(cat, "enable_discord", 0);
2022-09-10 13:32:46 +02:00
open_dir_usr_path = ini_section_get_int(cat, "open_dir_usr_path", 0);
2022-09-10 13:32:46 +02:00
video_framerate = ini_section_get_int(cat, "video_gl_framerate", -1);
video_vsync = ini_section_get_int(cat, "video_gl_vsync", 0);
strncpy(video_shader, ini_section_get_string(cat, "video_gl_shader", ""), sizeof(video_shader));
2022-09-10 13:32:46 +02:00
window_remember = ini_section_get_int(cat, "window_remember", 0);
if (window_remember) {
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "window_coordinates", NULL);
if (p == NULL)
p = "0, 0, 0, 0";
sscanf(p, "%i, %i, %i, %i", &cw, &ch, &cx, &cy);
} else {
cw = ch = cx = cy = 0;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_remember");
}
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_coordinates");
}
/* Load monitor section. */
static void
load_monitor(int monitor_index)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat;
char name[512], temp[512];
char *p = NULL;
2022-09-10 13:32:46 +02:00
sprintf(name, "Monitor #%i", monitor_index + 1);
sprintf(temp, "%i, %i, %i, %i", cx, cy, cw, ch);
2022-09-10 13:32:46 +02:00
cat = ini_find_section(config, name);
p = ini_section_get_string(cat, "window_coordinates", NULL);
if (p == NULL)
p = temp;
if (window_remember) {
sscanf(p, "%i, %i, %i, %i",
&monitor_settings[monitor_index].mon_window_x, &monitor_settings[monitor_index].mon_window_y,
&monitor_settings[monitor_index].mon_window_w, &monitor_settings[monitor_index].mon_window_h);
2022-09-10 13:32:46 +02:00
monitor_settings[monitor_index].mon_window_maximized = !!ini_section_get_int(cat, "window_maximized", 0);
} else {
monitor_settings[monitor_index].mon_window_maximized = 0;
}
}
/* Load "Machine" section. */
static void
load_machine(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Machine");
2022-07-21 21:44:55 -04:00
char *p, *migrate_from = NULL;
int c, i, j, speed, legacy_mfg, legacy_cpu;
2020-11-18 01:09:17 -03:00
double multi;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "machine", NULL);
2020-11-18 01:09:17 -03:00
if (p != NULL) {
2022-07-21 21:44:55 -04:00
migrate_from = p;
if (!strcmp(p, "8500ttc")) /* migrate typo... */
machine = machine_get_machine_from_internal_name("8600ttc");
else if (!strcmp(p, "eagle_pcspirit")) /* ...legacy names... */
machine = machine_get_machine_from_internal_name("pcspirit");
else if (!strcmp(p, "multitech_pc700"))
machine = machine_get_machine_from_internal_name("pc700");
else if (!strcmp(p, "ncr_pc4i"))
machine = machine_get_machine_from_internal_name("pc4i");
else if (!strcmp(p, "olivetti_m19"))
machine = machine_get_machine_from_internal_name("m19");
else if (!strcmp(p, "open_xt"))
machine = machine_get_machine_from_internal_name("openxt");
else if (!strcmp(p, "open_at"))
machine = machine_get_machine_from_internal_name("openat");
else if (!strcmp(p, "philips_p3105"))
machine = machine_get_machine_from_internal_name("p3105");
else if (!strcmp(p, "philips_p3120"))
machine = machine_get_machine_from_internal_name("p3120");
else if (!strcmp(p, "olivetti_m24"))
machine = machine_get_machine_from_internal_name("m24");
else if (!strcmp(p, "olivetti_m240"))
machine = machine_get_machine_from_internal_name("m240");
else if (!strcmp(p, "ncr_pc8"))
machine = machine_get_machine_from_internal_name("pc8");
else if (!strcmp(p, "olivetti_m290"))
machine = machine_get_machine_from_internal_name("m290");
else if (!strcmp(p, "ncr_3302"))
machine = machine_get_machine_from_internal_name("3302");
else if (!strcmp(p, "ncr_pc916sx"))
machine = machine_get_machine_from_internal_name("pc916sx");
else if (!strcmp(p, "cbm_sl386sx16"))
machine = machine_get_machine_from_internal_name("cmdsl386sx16");
else if (!strcmp(p, "cbm_sl386sx25"))
machine = machine_get_machine_from_internal_name("cmdsl386sx25");
else if (!strcmp(p, "mr586"))
machine = machine_get_machine_from_internal_name("p54tp4xe_mr");
else if (!strcmp(p, "pcv240"))
machine = machine_get_machine_from_internal_name("pcv90");
else if (!strcmp(p, "v60n"))
machine = machine_get_machine_from_internal_name("acerv60n");
else if (!strcmp(p, "tsunamiatx"))
machine = machine_get_machine_from_internal_name("s1846");
else if (!strcmp(p, "trinity371"))
machine = machine_get_machine_from_internal_name("s1857");
else if (!strcmp(p, "63a"))
machine = machine_get_machine_from_internal_name("63a1");
else if (!strcmp(p, "4sa2"))
machine = machine_get_machine_from_internal_name("4saw2");
else if (!strcmp(p, "award386dx")) /* ...merged machines... */
machine = machine_get_machine_from_internal_name("award495");
else if (!strcmp(p, "ami386dx"))
machine = machine_get_machine_from_internal_name("ami495");
else if (!strcmp(p, "mr386dx"))
machine = machine_get_machine_from_internal_name("mr495");
else if (!strcmp(p, "award486"))
machine = machine_get_machine_from_internal_name("award495");
else if (!strcmp(p, "ami486"))
machine = machine_get_machine_from_internal_name("ami495");
else if (!strcmp(p, "mr486"))
machine = machine_get_machine_from_internal_name("mr495");
else if (!strcmp(p, "ibmps1_2121_isa"))
machine = machine_get_machine_from_internal_name("ibmps1_2121");
else if (!strcmp(p, "fw6400gx_s1"))
machine = machine_get_machine_from_internal_name("fw6400gx");
else if (!strcmp(p, "p54vl"))
machine = machine_get_machine_from_internal_name("p5vl");
else if (!strcmp(p, "chariot"))
machine = machine_get_machine_from_internal_name("fmb");
else if (!strcmp(p, "president")) { /* ...and removed machines */
machine = machine_get_machine_from_internal_name("mb500n");
migrate_from = NULL;
} else if (!strcmp(p, "j656vxd")) {
machine = machine_get_machine_from_internal_name("p55va");
migrate_from = NULL;
} else {
machine = machine_get_machine_from_internal_name(p);
migrate_from = NULL;
}
2022-02-20 02:26:27 -05:00
} else
2022-07-21 21:44:55 -04:00
machine = 0;
/* This is for backwards compatibility. */
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "model", NULL);
if (p != NULL) {
2022-07-21 21:44:55 -04:00
migrate_from = p;
if (!strcmp(p, "p55r2p4")) /* migrate typo */
machine = machine_get_machine_from_internal_name("p55t2p4");
else {
machine = machine_get_machine_from_internal_name(p);
migrate_from = NULL;
}
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "model");
}
if (machine >= machine_count())
2022-07-21 21:44:55 -04:00
machine = machine_count() - 1;
/* Copy NVR files when migrating a machine to a new internal name. */
if (migrate_from) {
2022-07-21 21:44:55 -04:00
char old_fn[256];
strcpy(old_fn, migrate_from);
strcat(old_fn, ".");
c = strlen(old_fn);
char new_fn[256];
strcpy(new_fn, machines[machine].internal_name);
strcat(new_fn, ".");
i = strlen(new_fn);
/* Iterate through NVR files. */
DIR *dirp = opendir(nvr_path("."));
if (dirp) {
struct dirent *entry;
while ((entry = readdir(dirp))) {
/* Check if this file corresponds to the old name. */
if (strncmp(entry->d_name, old_fn, c))
continue;
/* Add extension to the new name. */
strcpy(&new_fn[i], &entry->d_name[c]);
/* Only copy if a file with the new name doesn't already exist. */
FILE *g = nvr_fopen(new_fn, "rb");
if (!g) {
FILE *f = nvr_fopen(entry->d_name, "rb");
g = nvr_fopen(new_fn, "wb");
uint8_t buf[4096];
while ((j = fread(buf, 1, sizeof(buf), f)))
fwrite(buf, 1, j, g);
fclose(f);
}
fclose(g);
}
}
}
2022-09-10 13:32:46 +02:00
cpu_override = ini_section_get_int(cat, "cpu_override", 0);
2022-07-21 21:44:55 -04:00
cpu_f = NULL;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "cpu_family", NULL);
2020-11-18 15:18:20 -03:00
if (p) {
2022-07-21 21:44:55 -04:00
if (!strcmp(p, "enh_am486dx2")) /* migrate modified names */
cpu_f = cpu_get_family("am486dx2_slenh");
else if (!strcmp(p, "enh_am486dx4"))
cpu_f = cpu_get_family("am486dx4_slenh");
else
cpu_f = cpu_get_family(p);
if (cpu_f && !cpu_family_is_eligible(cpu_f, machine)) /* only honor eligible families */
cpu_f = NULL;
2020-11-18 15:18:20 -03:00
} else {
2022-07-21 21:44:55 -04:00
/* Backwards compatibility with the previous CPU model system. */
2022-09-10 13:32:46 +02:00
legacy_mfg = ini_section_get_int(cat, "cpu_manufacturer", 0);
legacy_cpu = ini_section_get_int(cat, "cpu", 0);
2022-07-21 21:44:55 -04:00
/* Check if either legacy ID is present, and if they are within bounds. */
if (((legacy_mfg > 0) || (legacy_cpu > 0)) && (legacy_mfg >= 0) && (legacy_mfg < 4) && (legacy_cpu >= 0)) {
/* Look for a machine entry on the legacy table. */
p = machine_get_internal_name();
c = 0;
while (cpu_legacy_table[c].machine) {
if (!strcmp(p, cpu_legacy_table[c].machine))
break;
c++;
}
if (cpu_legacy_table[c].machine) {
/* Determine the amount of CPU entries on the table. */
i = -1;
while (cpu_legacy_table[c].tables[legacy_mfg][++i].family)
;
/* If the CPU ID is out of bounds, reset to the last known ID. */
if (legacy_cpu >= i)
legacy_cpu = i - 1;
const cpu_legacy_table_t *legacy_table_entry = &cpu_legacy_table[c].tables[legacy_mfg][legacy_cpu];
/* Check if the referenced family exists. */
cpu_f = cpu_get_family(legacy_table_entry->family);
if (cpu_f) {
/* Save the new values. */
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "cpu_family", (char *) legacy_table_entry->family);
ini_section_set_int(cat, "cpu_speed", legacy_table_entry->rspeed);
ini_section_set_double(cat, "cpu_multi", legacy_table_entry->multi);
2022-07-21 21:44:55 -04:00
}
}
}
}
2020-11-18 01:09:17 -03:00
if (cpu_f) {
2022-09-10 13:32:46 +02:00
speed = ini_section_get_int(cat, "cpu_speed", 0);
multi = ini_section_get_double(cat, "cpu_multi", 0);
2022-07-21 21:44:55 -04:00
/* Find the configured CPU. */
cpu = 0;
c = 0;
i = 256;
while (cpu_f->cpus[cpu].cpu_type) {
if (cpu_is_eligible(cpu_f, cpu, machine)) { /* skip ineligible CPUs */
if ((cpu_f->cpus[cpu].rspeed == speed) && (cpu_f->cpus[cpu].multi == multi)) /* exact speed/multiplier match */
break;
else if ((cpu_f->cpus[cpu].rspeed >= speed) && (i == 256)) /* closest speed match */
i = cpu;
c = cpu; /* store fastest eligible CPU */
}
cpu++;
}
if (!cpu_f->cpus[cpu].cpu_type) /* if no exact match was found, use closest matching faster CPU, or fastest eligible CPU */
cpu = MIN(i, c);
} else { /* default */
2022-07-21 21:44:55 -04:00
/* Find first eligible family. */
c = 0;
while (!cpu_family_is_eligible(&cpu_families[c], machine)) {
if (cpu_families[c++].package == 0) { /* end of list */
fatal("No eligible CPU families for the selected machine\n");
return;
}
}
cpu_f = (cpu_family_t *) &cpu_families[c];
/* Find first eligible CPU in that family. */
cpu = 0;
while (!cpu_is_eligible(cpu_f, cpu, machine)) {
if (cpu_f->cpus[cpu++].cpu_type == 0) { /* end of list */
cpu = 0;
break;
}
}
}
2020-11-18 15:18:20 -03:00
cpu_s = (CPU *) &cpu_f->cpus[cpu];
2022-09-10 13:32:46 +02:00
cpu_waitstates = ini_section_get_int(cat, "cpu_waitstates", 0);
2022-09-10 13:32:46 +02:00
p = (char *) ini_section_get_string(cat, "fpu_type", "none");
2020-11-18 01:09:17 -03:00
fpu_type = fpu_get_type(cpu_f, cpu, p);
2022-09-10 13:32:46 +02:00
mem_size = ini_section_get_int(cat, "mem_size", 64);
#if 0
if (mem_size < ((machine_has_bus(machine, MACHINE_AT) &&
(machines[machine].ram_granularity < 128)) ? machines[machine].min_ram*1024 : machines[machine].min_ram))
2022-07-21 21:44:55 -04:00
mem_size = (((machine_has_bus(machine, MACHINE_AT) && (machines[machine].ram_granularity < 128)) ? machines[machine].min_ram*1024 : machines[machine].min_ram);
#endif
2022-02-20 02:26:27 -05:00
if (mem_size > 2097152)
2022-07-21 21:44:55 -04:00
mem_size = 2097152;
2022-09-10 13:32:46 +02:00
cpu_use_dynarec = !!ini_section_get_int(cat, "cpu_use_dynarec", 0);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "time_sync", NULL);
2022-02-20 02:26:27 -05:00
if (p != NULL) {
2022-07-21 21:44:55 -04:00
if (!strcmp(p, "disabled"))
time_sync = TIME_SYNC_DISABLED;
else if (!strcmp(p, "local"))
time_sync = TIME_SYNC_ENABLED;
else if (!strcmp(p, "utc") || !strcmp(p, "gmt"))
time_sync = TIME_SYNC_ENABLED | TIME_SYNC_UTC;
else
time_sync = TIME_SYNC_ENABLED;
} else
2022-09-10 13:32:46 +02:00
time_sync = !!ini_section_get_int(cat, "enable_sync", 1);
2022-09-10 13:32:46 +02:00
pit_mode = ini_section_get_int(cat, "pit_mode", -1);
/* Remove this after a while.. */
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "nvr_path");
ini_section_delete_var(cat, "enable_sync");
}
/* Load "Video" section. */
static void
load_video(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Video");
char *p;
2022-07-21 21:44:55 -04:00
int free_p = 0;
if (machine_has_flags(machine, MACHINE_VIDEO_ONLY)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "gfxcard");
2022-07-21 21:44:55 -04:00
gfxcard = VID_INTERNAL;
} else {
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "gfxcard", NULL);
2022-07-21 21:44:55 -04:00
if (p == NULL) {
if (machine_has_flags(machine, MACHINE_VIDEO)) {
p = (char *) malloc((strlen("internal") + 1) * sizeof(char));
strcpy(p, "internal");
} else {
p = (char *) malloc((strlen("none") + 1) * sizeof(char));
strcpy(p, "none");
}
free_p = 1;
}
if (!strcmp(p, "virge375_vbe20_pci")) /* migrate renamed cards */
gfxcard = video_get_video_from_internal_name("virge385_pci");
else
gfxcard = video_get_video_from_internal_name(p);
if (free_p)
free(p);
}
2022-09-10 13:32:46 +02:00
voodoo_enabled = !!ini_section_get_int(cat, "voodoo", 0);
ibm8514_enabled = !!ini_section_get_int(cat, "8514a", 0);
xga_enabled = !!ini_section_get_int(cat, "xga", 0);
show_second_monitors = !!ini_section_get_int(cat, "show_second_monitors", 1);
video_fullscreen_scale_maximized = !!ini_section_get_int(cat, "video_fullscreen_scale_maximized", 0);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "gfxcard_2", NULL);
2022-07-21 21:44:55 -04:00
if (!p)
p = "none";
2022-07-07 14:34:59 +06:00
gfxcard_2 = video_get_video_from_internal_name(p);
}
/* Load "Input Devices" section. */
static void
load_input_devices(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Input devices");
2022-07-21 21:44:55 -04:00
char temp[512];
int c, d;
char *p;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "mouse_type", NULL);
if (p != NULL)
2022-07-21 21:44:55 -04:00
mouse_type = mouse_get_from_internal_name(p);
else
mouse_type = 0;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "joystick_type", NULL);
if (p != NULL) {
2022-07-21 21:44:55 -04:00
if (!strcmp(p, "standard_2button")) /* migrate renamed types */
joystick_type = joystick_get_from_internal_name("2axis_2button");
else if (!strcmp(p, "standard_4button"))
joystick_type = joystick_get_from_internal_name("2axis_4button");
else if (!strcmp(p, "standard_6button"))
joystick_type = joystick_get_from_internal_name("2axis_6button");
else if (!strcmp(p, "standard_8button"))
joystick_type = joystick_get_from_internal_name("2axis_8button");
else if (!strcmp(p, "ch_flighstick_pro")) /* fix typo */
joystick_type = joystick_get_from_internal_name("ch_flightstick_pro");
else
joystick_type = joystick_get_from_internal_name(p);
if (!joystick_type) {
/* Try to read an integer for backwards compatibility with old configs */
2022-09-10 13:32:46 +02:00
if (!strcmp(p, "0")) /* workaround for ini_section_get_int returning 0 on non-integer data */
2022-07-21 21:44:55 -04:00
joystick_type = joystick_get_from_internal_name("2axis_2button");
else {
2022-09-10 13:32:46 +02:00
c = ini_section_get_int(cat, "joystick_type", 8);
2022-07-21 21:44:55 -04:00
switch (c) {
case 1:
joystick_type = joystick_get_from_internal_name("2axis_4button");
break;
case 2:
joystick_type = joystick_get_from_internal_name("2axis_6button");
break;
case 3:
joystick_type = joystick_get_from_internal_name("2axis_8button");
break;
case 4:
joystick_type = joystick_get_from_internal_name("4axis_4button");
break;
case 5:
joystick_type = joystick_get_from_internal_name("ch_flightstick_pro");
break;
case 6:
joystick_type = joystick_get_from_internal_name("sidewinder_pad");
break;
case 7:
joystick_type = joystick_get_from_internal_name("thrustmaster_fcs");
break;
default:
joystick_type = 0;
break;
}
}
}
} else
2022-07-21 21:44:55 -04:00
joystick_type = 0;
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) {
sprintf(temp, "joystick_%i_nr", c);
2022-09-10 13:32:46 +02:00
joystick_state[c].plat_joystick_nr = ini_section_get_int(cat, temp, 0);
2022-07-21 21:44:55 -04:00
if (joystick_state[c].plat_joystick_nr) {
for (d = 0; d < joystick_get_axis_count(joystick_type); d++) {
sprintf(temp, "joystick_%i_axis_%i", c, d);
2022-09-10 13:32:46 +02:00
joystick_state[c].axis_mapping[d] = ini_section_get_int(cat, temp, d);
2022-07-21 21:44:55 -04:00
}
for (d = 0; d < joystick_get_button_count(joystick_type); d++) {
sprintf(temp, "joystick_%i_button_%i", c, d);
2022-09-10 13:32:46 +02:00
joystick_state[c].button_mapping[d] = ini_section_get_int(cat, temp, d);
2022-07-21 21:44:55 -04:00
}
for (d = 0; d < joystick_get_pov_count(joystick_type); d++) {
sprintf(temp, "joystick_%i_pov_%i", c, d);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "0, 0");
2022-07-21 21:44:55 -04:00
joystick_state[c].pov_mapping[d][0] = joystick_state[c].pov_mapping[d][1] = 0;
sscanf(p, "%i, %i", &joystick_state[c].pov_mapping[d][0], &joystick_state[c].pov_mapping[d][1]);
}
}
}
}
/* Load "Sound" section. */
static void
load_sound(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Sound");
2022-07-21 21:44:55 -04:00
char temp[512];
char *p;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "sndcard", NULL);
WARNING: CONFIGS MIGHT PARTIALLY BREAK WHERE DEVICE NAMES HAVE CHANGED. Changes to device_t struct to accomodate the upcoming PCI IRQ arbitration rewrite; Added device.c/h API to obtain name from the device_t struct; Significant changes to win/win_settings.c to clean up the code a bit and fix bugs; Ported all the CPU and AudioPCI commits from PCem; Added an API call to allow ACPI soft power off to gracefully stop the emulator; Removed the Siemens PCD-2L from the Dev branch because it now works; Removed the Socket 5 HP Vectra from the Dev branch because it now works; Fixed the Compaq Presario and the Micronics Spitfire; Give the IBM PC330 its own list of 486 CPU so it can have DX2's with CPUID 0x470; SMM fixes; Rewrote the SYSENTER, SYSEXIT, SYSCALL, and SYSRET instructions; Changed IDE reset period to match the specification, fixes #929; The keyboard input and output ports are now forced in front of the queue when read, fixes a number of bugs, including the AMI Apollo hanging on soft reset; Added the Intel AN430TX but Dev branched because it does not work; The network code no longer drops packets if the emulated network card has failed to receive them (eg. when the buffer is full); Changes to PCI card adding and renamed some PCI slot types, also added proper AGP bridge slot types; USB UHCI emulation is no longer a stub (still doesn't fully work, but at least Windows XP chk with Debug no longer ASSERT's on it); Fixed NVR on the the SMC FDC37C932QF and APM variants; A number of fixes to Intel 4x0 chipsets, including fixing every register of the 440LX and 440EX; Some ACPI changes.
2020-11-16 00:01:21 +01:00
/* FIXME: Hack to not break configs with the Sound Blaster 128 PCI set. */
if ((p != NULL) && (!strcmp(p, "sbpci128") || !strcmp(p, "sb128pci")))
2022-07-21 21:44:55 -04:00
p = "es1371";
if (p != NULL)
2022-07-21 21:44:55 -04:00
sound_card_current = sound_card_get_from_internal_name(p);
else
sound_card_current = 0;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "midi_device", NULL);
if (p != NULL)
2022-07-21 21:44:55 -04:00
midi_output_device_current = midi_out_device_get_from_internal_name(p);
else
midi_output_device_current = 0;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "midi_in_device", NULL);
2020-01-01 20:20:16 +01:00
if (p != NULL)
2022-07-21 21:44:55 -04:00
midi_input_device_current = midi_in_device_get_from_internal_name(p);
else
midi_input_device_current = 0;
2020-01-01 20:20:16 +01:00
2022-09-10 13:32:46 +02:00
mpu401_standalone_enable = !!ini_section_get_int(cat, "mpu401_standalone", 0);
2022-09-10 13:32:46 +02:00
SSI2001 = !!ini_section_get_int(cat, "ssi2001", 0);
GAMEBLASTER = !!ini_section_get_int(cat, "gameblaster", 0);
GUS = !!ini_section_get_int(cat, "gus", 0);
2022-02-20 02:26:27 -05:00
memset(temp, '\0', sizeof(temp));
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "sound_type", "float");
2021-04-05 23:30:07 +02:00
if (strlen(p) > 511)
2022-07-21 21:44:55 -04:00
fatal("load_sound(): strlen(p) > 511\n");
2021-04-05 23:30:07 +02:00
else
2022-07-21 21:44:55 -04:00
strncpy(temp, p, strlen(p) + 1);
if (!strcmp(temp, "float") || !strcmp(temp, "1"))
2022-07-21 21:44:55 -04:00
sound_is_float = 1;
else
sound_is_float = 0;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "fm_driver", "nuked");
if (!strcmp(p, "ymfm")) {
fm_driver = FM_DRV_YMFM;
} else {
fm_driver = FM_DRV_NUKED;
}
}
/* Load "Network" section. */
static void
load_network(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Network");
char *p;
char temp[512];
int c = 0, min = 0;
/* Handle legacy configuration which supported only one NIC */
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "net_card", NULL);
if (p != NULL) {
net_cards_conf[c].device_num = network_card_get_from_internal_name(p);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "net_type", NULL);
if (p != NULL) {
if (!strcmp(p, "pcap") || !strcmp(p, "1"))
net_cards_conf[c].net_type = NET_TYPE_PCAP;
else if (!strcmp(p, "slirp") || !strcmp(p, "2"))
net_cards_conf[c].net_type = NET_TYPE_SLIRP;
else
net_cards_conf[c].net_type = NET_TYPE_NONE;
} else {
net_cards_conf[c].net_type = NET_TYPE_NONE;
}
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "net_host_device", NULL);
if (p != NULL) {
if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) {
if (network_ndev == 1) {
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2094, (wchar_t *) IDS_2129);
} else if (network_dev_to_id(p) == -1) {
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2095, (wchar_t *) IDS_2129);
}
strcpy(net_cards_conf[c].host_dev_name, "none");
} else {
strncpy(net_cards_conf[c].host_dev_name, p, sizeof(net_cards_conf[c].host_dev_name) - 1);
2022-07-21 21:44:55 -04:00
}
} else {
strcpy(net_cards_conf[c].host_dev_name, "none");
}
min++;
}
2022-07-21 21:44:55 -04:00
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "net_card");
ini_section_delete_var(cat, "net_type");
ini_section_delete_var(cat, "net_host_device");
for (c = min; c < NET_CARD_MAX; c++) {
sprintf(temp, "net_%02i_card", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL) {
net_cards_conf[c].device_num = network_card_get_from_internal_name(p);
2022-07-21 21:44:55 -04:00
} else {
net_cards_conf[c].device_num = 0;
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "net_%02i_net_type", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL) {
if (!strcmp(p, "pcap") || !strcmp(p, "1")) {
net_cards_conf[c].net_type = NET_TYPE_PCAP;
} else if (!strcmp(p, "slirp") || !strcmp(p, "2")) {
net_cards_conf[c].net_type = NET_TYPE_SLIRP;
} else {
net_cards_conf[c].net_type = NET_TYPE_NONE;
}
} else {
net_cards_conf[c].net_type = NET_TYPE_NONE;
}
sprintf(temp, "net_%02i_host_device", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL) {
if ((network_dev_to_id(p) == -1) || (network_ndev == 1)) {
if (network_ndev == 1) {
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2094, (wchar_t *) IDS_2129);
} else if (network_dev_to_id(p) == -1) {
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2095, (wchar_t *) IDS_2129);
}
strcpy(net_cards_conf[c].host_dev_name, "none");
} else {
strncpy(net_cards_conf[c].host_dev_name, p, sizeof(net_cards_conf[c].host_dev_name) - 1);
}
} else {
strcpy(net_cards_conf[c].host_dev_name, "none");
}
sprintf(temp, "net_%02i_link", c +1);
2022-09-10 13:32:46 +02:00
net_cards_conf[c].link_state = ini_section_get_int(cat, temp,
(NET_LINK_10_HD|NET_LINK_10_FD|NET_LINK_100_HD|NET_LINK_100_FD|NET_LINK_1000_HD|NET_LINK_1000_FD));
}
}
/* Load "Ports" section. */
static void
load_ports(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Ports (COM & LPT)");
char *p;
2022-07-21 21:44:55 -04:00
char temp[512];
int c, d;
for (c = 0; c < SERIAL_MAX; c++) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "serial%d_enabled", c + 1);
2022-09-10 13:32:46 +02:00
com_ports[c].enabled = !!ini_section_get_int(cat, temp, (c >= 2) ? 0 : 1);
2022-01-31 01:43:12 -05:00
2022-07-21 21:44:55 -04:00
/*
sprintf(temp, "serial%d_device", c + 1);
2022-09-10 13:32:46 +02:00
p = (char *) ini_section_get_string(cat, temp, "none");
2022-07-21 21:44:55 -04:00
com_ports[c].device = com_device_get_from_internal_name(p);
*/
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
}
for (c = 0; c < PARALLEL_MAX; c++) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "lpt%d_enabled", c + 1);
2022-09-10 13:32:46 +02:00
lpt_ports[c].enabled = !!ini_section_get_int(cat, temp, (c == 0) ? 1 : 0);
2022-07-21 21:44:55 -04:00
sprintf(temp, "lpt%d_device", c + 1);
2022-09-10 13:32:46 +02:00
p = (char *) ini_section_get_string(cat, temp, "none");
2022-07-21 21:44:55 -04:00
lpt_ports[c].device = lpt_device_get_from_internal_name(p);
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
}
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
/* Legacy config compatibility. */
2022-09-10 13:32:46 +02:00
d = ini_section_get_int(cat, "lpt_enabled", 2);
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
if (d < 2) {
2022-07-21 21:44:55 -04:00
for (c = 0; c < PARALLEL_MAX; c++)
lpt_ports[c].enabled = d;
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
}
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "lpt_enabled");
}
/* Load "Storage Controllers" section. */
static void
load_storage_controllers(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Storage controllers");
char *p, temp[512];
2022-07-21 21:44:55 -04:00
int c, min = 0;
int free_p = 0;
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
2022-09-10 13:32:46 +02:00
backwards_compat2 = (cat == NULL);
2022-02-20 02:26:27 -05:00
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "scsicard", NULL);
if (p != NULL) {
2022-07-21 21:44:55 -04:00
scsi_card_current[0] = scsi_card_get_from_internal_name(p);
min++;
}
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "scsi_card");
for (c = min; c < SCSI_BUS_MAX; c++) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "scsicard_%d", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
2022-07-21 21:44:55 -04:00
if (p != NULL)
scsi_card_current[c] = scsi_card_get_from_internal_name(p);
else
scsi_card_current[c] = 0;
}
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "fdc", NULL);
if (p != NULL)
2022-07-21 21:44:55 -04:00
fdc_type = fdc_card_get_from_internal_name(p);
else
fdc_type = FDC_INTERNAL;
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "hdc", NULL);
if (p == NULL) {
2022-07-21 21:44:55 -04:00
if (machine_has_flags(machine, MACHINE_HDC)) {
p = (char *) malloc((strlen("internal") + 1) * sizeof(char));
strcpy(p, "internal");
} else {
p = (char *) malloc((strlen("none") + 1) * sizeof(char));
strcpy(p, "none");
}
free_p = 1;
}
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
if (!strcmp(p, "mfm_xt"))
2022-07-21 21:44:55 -04:00
hdc_current = hdc_get_from_internal_name("st506_xt");
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
else if (!strcmp(p, "mfm_xt_dtc5150x"))
2022-07-21 21:44:55 -04:00
hdc_current = hdc_get_from_internal_name("st506_xt_dtc5150x");
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
else if (!strcmp(p, "mfm_at"))
2022-07-21 21:44:55 -04:00
hdc_current = hdc_get_from_internal_name("st506_at");
else if (!strcmp(p, "vlb_isa"))
2022-07-21 21:44:55 -04:00
hdc_current = hdc_get_from_internal_name("ide_vlb");
else if (!strcmp(p, "vlb_isa_2ch"))
2022-07-21 21:44:55 -04:00
hdc_current = hdc_get_from_internal_name("ide_vlb_2ch");
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
else
2022-07-21 21:44:55 -04:00
hdc_current = hdc_get_from_internal_name(p);
2020-01-15 03:04:59 +01:00
if (free_p) {
2022-07-21 21:44:55 -04:00
free(p);
p = NULL;
2020-01-15 03:04:59 +01:00
}
2022-09-10 13:32:46 +02:00
ide_ter_enabled = !!ini_section_get_int(cat, "ide_ter", 0);
ide_qua_enabled = !!ini_section_get_int(cat, "ide_qua", 0);
/* TODO: Re-enable by default after we actually have a proper machine flag for this. */
2022-09-10 13:32:46 +02:00
cassette_enable = !!ini_section_get_int(cat, "cassette_enabled", 0);
p = ini_section_get_string(cat, "cassette_file", "");
if (strlen(p) > 511)
2022-07-21 21:44:55 -04:00
fatal("load_storage_controllers(): strlen(p) > 511\n");
else
2022-07-21 21:44:55 -04:00
strncpy(cassette_fname, p, MIN(512, strlen(p) + 1));
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "cassette_mode", "");
2021-07-28 00:58:19 +02:00
if (strlen(p) > 511)
2022-07-21 21:44:55 -04:00
fatal("load_storage_controllers(): strlen(p) > 511\n");
2021-07-28 00:58:19 +02:00
else
2022-07-21 21:44:55 -04:00
strncpy(cassette_mode, p, MIN(512, strlen(p) + 1));
2022-09-10 13:32:46 +02:00
cassette_pos = ini_section_get_int(cat, "cassette_position", 0);
cassette_srate = ini_section_get_int(cat, "cassette_srate", 44100);
cassette_append = !!ini_section_get_int(cat, "cassette_append", 0);
cassette_pcm = ini_section_get_int(cat, "cassette_pcm", 0);
cassette_ui_writeprot = !!ini_section_get_int(cat, "cassette_writeprot", 0);
2021-07-29 20:34:55 +02:00
2022-07-21 21:44:55 -04:00
for (c = 0; c < 2; c++) {
sprintf(temp, "cartridge_%02i_fn", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
2021-07-29 20:34:55 +02:00
#if 0
2022-07-21 21:44:55 -04:00
/*
* NOTE:
* Temporary hack to remove the absolute
* path currently saved in most config
* files. We should remove this before
* finalizing this release! --FvK
*/
if (! wcsnicmp(wp, usr_path, wcslen(usr_path))) {
/*
* Yep, its absolute and prefixed
* with the EXE path. Just strip
* that off for now...
*/
wcsncpy(floppyfns[c], &wp[wcslen(usr_path)], sizeof_w(cart_fns[c]));
} else
2021-07-29 20:34:55 +02:00
#endif
2022-07-21 21:44:55 -04:00
if (strlen(p) > 511)
fatal("load_storage_controllers(): strlen(p) > 511\n");
else
strncpy(cart_fns[c], p, strlen(p) + 1);
2021-07-29 20:34:55 +02:00
}
}
/* Load "Hard Disks" section. */
static void
load_hard_disks(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Hard disks");
2022-07-21 21:44:55 -04:00
char temp[512], tmp2[512];
char s[512];
int c;
char *p;
uint32_t max_spt, max_hpc, max_tracks;
uint32_t board = 0, dev = 0;
memset(temp, '\0', sizeof(temp));
2022-07-21 21:44:55 -04:00
for (c = 0; c < HDD_NUM; c++) {
sprintf(temp, "hdd_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "0, 0, 0, 0, none");
2022-07-21 21:44:55 -04:00
sscanf(p, "%u, %u, %u, %i, %s",
&hdd[c].spt, &hdd[c].hpc, &hdd[c].tracks, (int *) &hdd[c].wp, s);
hdd[c].bus = hdd_string_to_bus(s, 0);
switch (hdd[c].bus) {
case HDD_BUS_DISABLED:
default:
max_spt = max_hpc = max_tracks = 0;
break;
case HDD_BUS_MFM:
max_spt = 26; /* 26 for RLL */
max_hpc = 15;
max_tracks = 2047;
break;
case HDD_BUS_XTA:
max_spt = 63;
max_hpc = 16;
max_tracks = 1023;
break;
case HDD_BUS_ESDI:
max_spt = 99;
max_hpc = 16;
max_tracks = 266305;
break;
case HDD_BUS_IDE:
max_spt = 63;
max_hpc = 16;
max_tracks = 266305;
break;
case HDD_BUS_SCSI:
max_spt = 99;
max_hpc = 255;
max_tracks = 266305;
break;
}
if (hdd[c].spt > max_spt)
hdd[c].spt = max_spt;
if (hdd[c].hpc > max_hpc)
hdd[c].hpc = max_hpc;
if (hdd[c].tracks > max_tracks)
hdd[c].tracks = max_tracks;
sprintf(temp, "hdd_%02i_speed", c + 1);
switch (hdd[c].bus) {
case HDD_BUS_IDE:
2022-07-29 00:47:52 +02:00
case HDD_BUS_ESDI:
2022-07-21 21:44:55 -04:00
sprintf(tmp2, "1997_5400rpm");
break;
default:
sprintf(tmp2, "ramdisk");
break;
}
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
hdd[c].speed_preset = hdd_preset_get_from_internal_name(p);
/* MFM/RLL */
sprintf(temp, "hdd_%02i_mfm_channel", c + 1);
if (hdd[c].bus == HDD_BUS_MFM)
2022-09-10 13:32:46 +02:00
hdd[c].mfm_channel = !!ini_section_get_int(cat, temp, c & 1);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
/* XTA */
sprintf(temp, "hdd_%02i_xta_channel", c + 1);
if (hdd[c].bus == HDD_BUS_XTA)
2022-09-10 13:32:46 +02:00
hdd[c].xta_channel = !!ini_section_get_int(cat, temp, c & 1);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
/* ESDI */
sprintf(temp, "hdd_%02i_esdi_channel", c + 1);
if (hdd[c].bus == HDD_BUS_ESDI)
2022-09-10 13:32:46 +02:00
hdd[c].esdi_channel = !!ini_section_get_int(cat, temp, c & 1);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
/* IDE */
sprintf(temp, "hdd_%02i_ide_channel", c + 1);
if (hdd[c].bus == HDD_BUS_IDE) {
sprintf(tmp2, "%01u:%01u", c >> 1, c & 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
sscanf(p, "%01u:%01u", &board, &dev);
board &= 3;
dev &= 1;
hdd[c].ide_channel = (board << 1) + dev;
if (hdd[c].ide_channel > 7)
hdd[c].ide_channel = 7;
} else {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
}
/* SCSI */
if (hdd[c].bus == HDD_BUS_SCSI) {
sprintf(temp, "hdd_%02i_scsi_location", c + 1);
sprintf(tmp2, "%01u:%02u", SCSI_BUS_MAX, c + 2);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
sscanf(p, "%01u:%02u", &board, &dev);
if (board >= SCSI_BUS_MAX) {
/* Invalid bus - check legacy ID */
sprintf(temp, "hdd_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
hdd[c].scsi_id = ini_section_get_int(cat, temp, c + 2);
2022-07-21 21:44:55 -04:00
if (hdd[c].scsi_id > 15)
hdd[c].scsi_id = 15;
} else {
board %= SCSI_BUS_MAX;
dev &= 15;
hdd[c].scsi_id = (board << 4) + dev;
}
} else {
sprintf(temp, "hdd_%02i_scsi_location", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "hdd_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
memset(hdd[c].fn, 0x00, sizeof(hdd[c].fn));
memset(hdd[c].prev_fn, 0x00, sizeof(hdd[c].prev_fn));
sprintf(temp, "hdd_%02i_fn", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
#if 0
2022-07-21 21:44:55 -04:00
/*
* NOTE:
* Temporary hack to remove the absolute
* path currently saved in most config
* files. We should remove this before
* finalizing this release! --FvK
*/
/*
* ANOTHER NOTE:
* When loading differencing VHDs, the absolute path is required.
* So we should not convert absolute paths to relative. -sards
*/
if (! wcsnicmp(wp, usr_path, wcslen(usr_path))) {
/*
* Yep, its absolute and prefixed
* with the CFG path. Just strip
* that off for now...
*/
wcsncpy(hdd[c].fn, &wp[wcslen(usr_path)], sizeof_w(hdd[c].fn));
} else
#endif
2022-07-21 21:44:55 -04:00
if (path_abs(p)) {
strncpy(hdd[c].fn, p, sizeof(hdd[c].fn) - 1);
} else {
path_append_filename(hdd[c].fn, usr_path, p);
}
path_normalize(hdd[c].fn);
2022-07-21 21:44:55 -04:00
/* If disk is empty or invalid, mark it for deletion. */
if (!hdd_is_valid(c)) {
sprintf(temp, "hdd_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_preide_channels", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_ide_channels", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_fn", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_mfm_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_ide_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
}
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
2018-01-26 22:17:09 +01:00
/* Load "Floppy Drives" section. */
static void
load_floppy_drives(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Floppy drives");
2022-07-21 21:44:55 -04:00
char temp[512], *p;
int c;
2018-01-26 22:17:09 +01:00
if (!backwards_compat)
return;
2022-07-21 21:44:55 -04:00
for (c = 0; c < FDD_NUM; c++) {
sprintf(temp, "fdd_%02i_type", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_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);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
sprintf(temp, "fdd_%02i_fn", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
ini_section_delete_var(cat, temp);
#if 0
/*
* NOTE:
* Temporary hack to remove the absolute
* path currently saved in most config
* files. We should remove this before
* finalizing this release! --FvK
*/
if (! wcsnicmp(wp, usr_path, wcslen(usr_path))) {
/*
* Yep, its absolute and prefixed
* with the EXE path. Just strip
* that off for now...
*/
wcsncpy(floppyfns[c], &wp[wcslen(usr_path)], sizeof_w(floppyfns[c]));
} else
#endif
if (strlen(p) > 511)
fatal("load_floppy_drives(): strlen(p) > 511\n");
else
strncpy(floppyfns[c], p, strlen(p) + 1);
/* if (*wp != L'\0')
config_log("Floppy%d: %ls\n", c, floppyfns[c]); */
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_writeprot", c + 1);
2022-09-10 13:32:46 +02:00
ui_writeprot[c] = !!ini_section_get_int(cat, temp, 0);
ini_section_delete_var(cat, temp);
sprintf(temp, "fdd_%02i_turbo", c + 1);
2022-09-10 13:32:46 +02:00
fdd_set_turbo(c, !!ini_section_get_int(cat, temp, 0));
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_check_bpb", c + 1);
2022-09-10 13:32:46 +02:00
fdd_set_check_bpb(c, !!ini_section_get_int(cat, temp, 1));
ini_section_delete_var(cat, temp);
}
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Load "Floppy and CD-ROM Drives" section. */
static void
load_floppy_and_cdrom_drives(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Floppy and CD-ROM drives");
2022-07-21 21:44:55 -04:00
char temp[512], tmp2[512], *p;
char s[512];
unsigned int board = 0, dev = 0;
2022-07-21 21:44:55 -04:00
int c, d = 0;
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
2022-09-10 13:32:46 +02:00
backwards_compat = (cat == NULL);
memset(temp, 0x00, sizeof(temp));
2022-07-21 21:44:55 -04:00
for (c = 0; c < FDD_NUM; c++) {
sprintf(temp, "fdd_%02i_type", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_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);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
#if 0
/*
* NOTE:
* Temporary hack to remove the absolute
* path currently saved in most config
* files. We should remove this before
* finalizing this release! --FvK
*/
if (! wcsnicmp(wp, usr_path, wcslen(usr_path))) {
/*
* Yep, its absolute and prefixed
* with the EXE path. Just strip
* that off for now...
*/
wcsncpy(floppyfns[c], &wp[wcslen(usr_path)], sizeof_w(floppyfns[c]));
} else
#endif
if (strlen(p) > 511)
fatal("load_floppy_and_cdrom_drives(): strlen(p) > 511\n");
else
strncpy(floppyfns[c], p, strlen(p) + 1);
/* if (*wp != L'\0')
config_log("Floppy%d: %ls\n", c, floppyfns[c]); */
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_writeprot", c + 1);
2022-09-10 13:32:46 +02:00
ui_writeprot[c] = !!ini_section_get_int(cat, temp, 0);
sprintf(temp, "fdd_%02i_turbo", c + 1);
2022-09-10 13:32:46 +02:00
fdd_set_turbo(c, !!ini_section_get_int(cat, temp, 0));
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_check_bpb", c + 1);
2022-09-10 13:32:46 +02:00
fdd_set_check_bpb(c, !!ini_section_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. */
if (fdd_get_type(c) == ((c < 2) ? 2 : 0)) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_type", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
if (strlen(floppyfns[c]) == 0) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_fn", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
if (ui_writeprot[c] == 0) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_writeprot", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
if (fdd_get_turbo(c) == 0) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_turbo", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
if (fdd_get_check_bpb(c) == 1) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_check_bpb", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
}
memset(temp, 0x00, sizeof(temp));
2022-07-21 21:44:55 -04:00
for (c = 0; c < CDROM_NUM; c++) {
sprintf(temp, "cdrom_%02i_host_drive", c + 1);
2022-09-10 13:32:46 +02:00
cdrom[c].host_drive = ini_section_get_int(cat, temp, 0);
cdrom[c].prev_host_drive = cdrom[c].host_drive;
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL)
sscanf(p, "%01u, %s", &d, s);
else if (c == 0)
/* If this is the first drive, unmute the audio. */
sscanf("1, none", "%01u, %s", &d, s);
else
sscanf("0, none", "%01u, %s", &d, s);
cdrom[c].sound_on = d;
cdrom[c].bus_type = hdd_string_to_bus(s, 1);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_speed", c + 1);
2022-09-10 13:32:46 +02:00
cdrom[c].speed = ini_section_get_int(cat, temp, 8);
/* Default values, needed for proper operation of the Settings dialog. */
cdrom[c].ide_channel = cdrom[c].scsi_device_id = c + 2;
if (cdrom[c].bus_type == CDROM_BUS_ATAPI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_ide_channel", c + 1);
sprintf(tmp2, "%01u:%01u", (c + 2) >> 1, (c + 2) & 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%01u", &board, &dev);
board &= 3;
dev &= 1;
2022-07-21 21:44:55 -04:00
cdrom[c].ide_channel = (board << 1) + dev;
if (cdrom[c].ide_channel > 7)
cdrom[c].ide_channel = 7;
} else if (cdrom[c].bus_type == CDROM_BUS_SCSI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_scsi_location", c + 1);
sprintf(tmp2, "%01u:%02u", SCSI_BUS_MAX, c + 2);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%02u", &board, &dev);
if (board >= SCSI_BUS_MAX) {
/* Invalid bus - check legacy ID */
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
cdrom[c].scsi_device_id = ini_section_get_int(cat, temp, c + 2);
if (cdrom[c].scsi_device_id > 15)
cdrom[c].scsi_device_id = 15;
} else {
board %= SCSI_BUS_MAX;
dev &= 15;
2022-07-21 21:44:55 -04:00
cdrom[c].scsi_device_id = (board << 4) + dev;
}
}
if (cdrom[c].bus_type != CDROM_BUS_ATAPI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_ide_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
if (cdrom[c].bus_type != CDROM_BUS_SCSI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_scsi_location", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_image_path", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
#if 0
/*
* NOTE:
* Temporary hack to remove the absolute
* path currently saved in most config
* files. We should remove this before
* finalizing this release! --FvK
*/
if (! wcsnicmp(wp, usr_path, wcslen(usr_path))) {
/*
* Yep, its absolute and prefixed
* with the EXE path. Just strip
* that off for now...
*/
wcsncpy(cdrom[c].image_path, &wp[wcslen(usr_path)], sizeof_w(cdrom[c].image_path));
} else
#endif
2022-07-21 21:44:55 -04:00
strncpy(cdrom[c].image_path, p, sizeof(cdrom[c].image_path) - 1);
if (cdrom[c].host_drive && (cdrom[c].host_drive != 200))
cdrom[c].host_drive = 0;
2022-07-21 21:44:55 -04:00
if ((cdrom[c].host_drive == 0x200) && (strlen(cdrom[c].image_path) == 0))
cdrom[c].host_drive = 0;
/* If the CD-ROM is disabled, delete all its variables. */
if (cdrom[c].bus_type == CDROM_BUS_DISABLED) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_host_drive", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_ide_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_image_path", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_iso_path", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
cdrom[c].image_history[i] = (char *) calloc(MAX_IMAGE_PATH_LEN + 1, sizeof(char));
sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if(p) {
sprintf(cdrom[c].image_history[i], "%s", p);
}
}
}
}
/* Load "Other Removable Devices" section. */
static void
load_other_removable_devices(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Other removable devices");
2022-07-21 21:44:55 -04:00
char temp[512], tmp2[512], *p;
char s[512];
unsigned int board = 0, dev = 0;
2022-07-21 21:44:55 -04:00
int c, d = 0;
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
if (backwards_compat) {
memset(temp, 0x00, sizeof(temp));
2022-07-21 21:44:55 -04:00
for (c = 0; c < CDROM_NUM; c++) {
sprintf(temp, "cdrom_%02i_host_drive", c + 1);
2022-09-10 13:32:46 +02:00
cdrom[c].host_drive = ini_section_get_int(cat, temp, 0);
cdrom[c].prev_host_drive = cdrom[c].host_drive;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL)
sscanf(p, "%01u, %s", &d, s);
else
sscanf("0, none", "%01u, %s", &d, s);
cdrom[c].sound_on = d;
cdrom[c].bus_type = hdd_string_to_bus(s, 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_speed", c + 1);
2022-09-10 13:32:46 +02:00
cdrom[c].speed = ini_section_get_int(cat, temp, 8);
ini_section_delete_var(cat, temp);
/* Default values, needed for proper operation of the Settings dialog. */
cdrom[c].ide_channel = cdrom[c].scsi_device_id = c + 2;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
if (cdrom[c].bus_type == CDROM_BUS_ATAPI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_ide_channel", c + 1);
sprintf(tmp2, "%01u:%01u", (c + 2) >> 1, (c + 2) & 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%01u", &board, &dev);
board &= 3;
dev &= 1;
2022-07-21 21:44:55 -04:00
cdrom[c].ide_channel = (board << 1) + dev;
if (cdrom[c].ide_channel > 7)
cdrom[c].ide_channel = 7;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
} else if (cdrom[c].bus_type == CDROM_BUS_SCSI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
cdrom[c].scsi_device_id = ini_section_get_int(cat, temp, c + 2);
if (cdrom[c].scsi_device_id > 15)
cdrom[c].scsi_device_id = 15;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_image_path", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
ini_section_delete_var(cat, temp);
#if 0
/*
* NOTE:
* Temporary hack to remove the absolute
* path currently saved in most config
* files. We should remove this before
* finalizing this release! --FvK
*/
if (! wcsnicmp(wp, usr_path, wcslen(usr_path))) {
/*
* Yep, its absolute and prefixed
* with the EXE path. Just strip
* that off for now...
*/
wcsncpy(cdrom[c].image_path, &wp[wcslen(usr_path)], sizeof_w(cdrom[c].image_path));
} else
#endif
2022-07-21 21:44:55 -04:00
strncpy(cdrom[c].image_path, p, sizeof(cdrom[c].image_path) - 1);
if (cdrom[c].host_drive && (cdrom[c].host_drive != 200))
cdrom[c].host_drive = 0;
2022-07-21 21:44:55 -04:00
if ((cdrom[c].host_drive == 0x200) && (strlen(cdrom[c].image_path) == 0))
cdrom[c].host_drive = 0;
}
}
backwards_compat = 0;
2018-01-26 22:17:09 +01:00
memset(temp, 0x00, sizeof(temp));
2022-07-21 21:44:55 -04:00
for (c = 0; c < ZIP_NUM; c++) {
sprintf(temp, "zip_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL)
sscanf(p, "%01u, %s", &zip_drives[c].is_250, s);
else
sscanf("0, none", "%01u, %s", &zip_drives[c].is_250, s);
zip_drives[c].bus_type = hdd_string_to_bus(s, 1);
/* Default values, needed for proper operation of the Settings dialog. */
zip_drives[c].ide_channel = zip_drives[c].scsi_device_id = c + 2;
if (zip_drives[c].bus_type == ZIP_BUS_ATAPI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_ide_channel", c + 1);
sprintf(tmp2, "%01u:%01u", (c + 2) >> 1, (c + 2) & 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%01u", &board, &dev);
board &= 3;
dev &= 1;
2022-07-21 21:44:55 -04:00
zip_drives[c].ide_channel = (board << 1) + dev;
if (zip_drives[c].ide_channel > 7)
zip_drives[c].ide_channel = 7;
} else if (zip_drives[c].bus_type == ZIP_BUS_SCSI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_scsi_location", c + 1);
sprintf(tmp2, "%01u:%02u", SCSI_BUS_MAX, c + 2);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%02u", &board, &dev);
if (board >= SCSI_BUS_MAX) {
/* Invalid bus - check legacy ID */
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
zip_drives[c].scsi_device_id = ini_section_get_int(cat, temp, c + 2);
if (zip_drives[c].scsi_device_id > 15)
zip_drives[c].scsi_device_id = 15;
} else {
board %= SCSI_BUS_MAX;
dev &= 15;
2022-07-21 21:44:55 -04:00
zip_drives[c].scsi_device_id = (board << 4) + dev;
}
}
2018-01-26 22:17:09 +01:00
if (zip_drives[c].bus_type != ZIP_BUS_ATAPI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_ide_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
if (zip_drives[c].bus_type != ZIP_BUS_SCSI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_scsi_location", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_image_path", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
2018-01-26 22:17:09 +01:00
#if 0
/*
* NOTE:
* Temporary hack to remove the absolute
* path currently saved in most config
* files. We should remove this before
* finalizing this release! --FvK
*/
if (! wcsnicmp(wp, usr_path, wcslen(usr_path))) {
/*
* Yep, its absolute and prefixed
* with the EXE path. Just strip
* that off for now...
*/
wcsncpy(zip_drives[c].image_path, &wp[wcslen(usr_path)], sizeof_w(zip_drives[c].image_path));
} else
2018-01-26 22:17:09 +01:00
#endif
2022-07-21 21:44:55 -04:00
strncpy(zip_drives[c].image_path, p, sizeof(zip_drives[c].image_path) - 1);
2018-01-26 22:17:09 +01:00
/* If the CD-ROM is disabled, delete all its variables. */
if (zip_drives[c].bus_type == ZIP_BUS_DISABLED) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_host_drive", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2018-01-26 22:17:09 +01:00
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2018-01-26 22:17:09 +01:00
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_ide_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2018-01-26 22:17:09 +01:00
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_image_path", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
2018-01-26 22:17:09 +01:00
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_iso_path", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2018-01-26 22:17:09 +01:00
}
memset(temp, 0x00, sizeof(temp));
2022-07-21 21:44:55 -04:00
for (c = 0; c < MO_NUM; c++) {
sprintf(temp, "mo_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, NULL);
if (p != NULL)
sscanf(p, "%u, %s", &mo_drives[c].type, s);
else
sscanf("00, none", "%u, %s", &mo_drives[c].type, s);
mo_drives[c].bus_type = hdd_string_to_bus(s, 1);
/* Default values, needed for proper operation of the Settings dialog. */
mo_drives[c].ide_channel = mo_drives[c].scsi_device_id = c + 2;
if (mo_drives[c].bus_type == MO_BUS_ATAPI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_ide_channel", c + 1);
sprintf(tmp2, "%01u:%01u", (c + 2) >> 1, (c + 2) & 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%01u", &board, &dev);
board &= 3;
dev &= 1;
2022-07-21 21:44:55 -04:00
mo_drives[c].ide_channel = (board << 1) + dev;
if (mo_drives[c].ide_channel > 7)
mo_drives[c].ide_channel = 7;
} else if (mo_drives[c].bus_type == MO_BUS_SCSI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_scsi_location", c + 1);
sprintf(tmp2, "%01u:%02u", SCSI_BUS_MAX, c + 2);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%02u", &board, &dev);
if (board >= SCSI_BUS_MAX) {
/* Invalid bus - check legacy ID */
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
mo_drives[c].scsi_device_id = ini_section_get_int(cat, temp, c + 2);
if (mo_drives[c].scsi_device_id > 15)
mo_drives[c].scsi_device_id = 15;
} else {
board %= SCSI_BUS_MAX;
dev &= 15;
2022-07-21 21:44:55 -04:00
mo_drives[c].scsi_device_id = (board << 4) + dev;
}
}
if (mo_drives[c].bus_type != MO_BUS_ATAPI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_ide_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
if (mo_drives[c].bus_type != MO_BUS_SCSI) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_scsi_location", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_image_path", c + 1);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "");
strncpy(mo_drives[c].image_path, p, sizeof(mo_drives[c].image_path) - 1);
/* If the CD-ROM is disabled, delete all its variables. */
if (mo_drives[c].bus_type == MO_BUS_DISABLED) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_host_drive", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_parameters", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_ide_channel", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_image_path", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_iso_path", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-02-20 02:26:27 -05:00
}
}
/* Load "Other Peripherals" section. */
static void
load_other_peripherals(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_section(config, "Other peripherals");
char *p;
2022-07-21 21:44:55 -04:00
char temp[512];
int c, free_p = 0;
2022-02-20 02:26:27 -05:00
if (backwards_compat2) {
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "scsicard", NULL);
if (p != NULL)
scsi_card_current[0] = scsi_card_get_from_internal_name(p);
else
scsi_card_current[0] = 0;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "scsicard");
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "fdc", NULL);
if (p != NULL)
fdc_type = fdc_card_get_from_internal_name(p);
else
fdc_type = FDC_INTERNAL;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "fdc");
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "hdc", NULL);
if (p == NULL) {
if (machine_has_flags(machine, MACHINE_HDC)) {
2022-07-21 21:44:55 -04:00
p = (char *) malloc((strlen("internal") + 1) * sizeof(char));
strcpy(p, "internal");
} else {
2022-07-21 21:44:55 -04:00
p = (char *) malloc((strlen("none") + 1) * sizeof(char));
strcpy(p, "none");
}
free_p = 1;
}
if (!strcmp(p, "mfm_xt"))
hdc_current = hdc_get_from_internal_name("st506_xt");
else if (!strcmp(p, "mfm_xt_dtc5150x"))
hdc_current = hdc_get_from_internal_name("st506_xt_dtc5150x");
else if (!strcmp(p, "mfm_at"))
hdc_current = hdc_get_from_internal_name("st506_at");
else if (!strcmp(p, "vlb_isa"))
hdc_current = hdc_get_from_internal_name("ide_vlb");
else if (!strcmp(p, "vlb_isa_2ch"))
hdc_current = hdc_get_from_internal_name("ide_vlb_2ch");
else
hdc_current = hdc_get_from_internal_name(p);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "hdc");
if (free_p) {
free(p);
p = NULL;
}
2022-09-10 13:32:46 +02:00
ide_ter_enabled = !!ini_section_get_int(cat, "ide_ter", 0);
ini_section_delete_var(cat, "ide_ter");
ide_qua_enabled = !!ini_section_get_int(cat, "ide_qua", 0);
ini_section_delete_var(cat, "ide_qua");
}
backwards_compat2 = 0;
2022-09-10 13:32:46 +02:00
bugger_enabled = !!ini_section_get_int(cat, "bugger_enabled", 0);
postcard_enabled = !!ini_section_get_int(cat, "postcard_enabled", 0);
for (c = 0; c < ISAMEM_MAX; c++) {
sprintf(temp, "isamem%d_type", c);
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, temp, "none");
isamem_type[c] = isamem_get_from_internal_name(p);
}
2022-09-10 13:32:46 +02:00
p = ini_section_get_string(cat, "isartc_type", "none");
2022-02-20 02:26:27 -05:00
isartc_type = isartc_get_from_internal_name(p);
}
/* Load the specified or a default configuration file. */
void
config_load(void)
{
int i;
config_log("Loading config file '%s'..\n", cfg_path);
memset(hdd, 0, sizeof(hard_disk_t));
memset(cdrom, 0, sizeof(cdrom_t) * CDROM_NUM);
#ifdef USE_IOCTL
memset(cdrom_ioctl, 0, sizeof(cdrom_ioctl_t) * CDROM_NUM);
#endif
memset(zip_drives, 0, sizeof(zip_drive_t));
2022-09-10 13:32:46 +02:00
config = ini_read(cfg_path);
if (!config) {
config = ini_new();
config_changed = 1;
cpu_f = (cpu_family_t *) &cpu_families[0];
2022-07-21 21:44:55 -04:00
cpu = 0;
kbd_req_capture = 0;
hide_status_bar = 0;
2022-07-21 21:44:55 -04:00
hide_tool_bar = 0;
scale = 1;
machine = machine_get_machine_from_internal_name("ibmpc");
dpi_scale = 1;
fpu_type = fpu_get_type(cpu_f, cpu, "none");
gfxcard = video_get_video_from_internal_name("cga");
vid_api = plat_vidapi("default");
vid_resize = 0;
video_fullscreen_first = 1;
2022-07-21 21:44:55 -04:00
time_sync = TIME_SYNC_ENABLED;
hdc_current = hdc_get_from_internal_name("none");
2022-07-28 16:50:49 -04:00
com_ports[0].enabled = 1;
com_ports[1].enabled = 1;
2022-07-21 21:44:55 -04:00
for (i = 2; i < SERIAL_MAX; i++)
2022-07-28 16:50:49 -04:00
com_ports[i].enabled = 0;
lpt_ports[0].enabled = 1;
2022-07-21 21:44:55 -04:00
for (i = 1; i < PARALLEL_MAX; i++)
lpt_ports[i].enabled = 0;
for (i = 0; i < FDD_NUM; i++) {
if (i < 2)
fdd_set_type(i, 2);
else
fdd_set_type(i, 0);
fdd_set_turbo(i, 0);
fdd_set_check_bpb(i, 1);
}
2020-11-09 04:24:33 +05:00
/* Unmute the CD audio on the first CD-ROM drive. */
cdrom[0].sound_on = 1;
2022-07-21 21:44:55 -04:00
mem_size = 64;
isartc_type = 0;
for (i = 0; i < ISAMEM_MAX; i++)
isamem_type[i] = 0;
/* TODO: Re-enable by default when we have a proper machine flag for this. */
cassette_enable = 0;
memset(cassette_fname, 0x00, sizeof(cassette_fname));
memcpy(cassette_mode, "load", strlen("load") + 1);
2022-07-21 21:44:55 -04:00
cassette_pos = 0;
cassette_srate = 44100;
cassette_append = 0;
cassette_pcm = 0;
cassette_ui_writeprot = 0;
config_log("Config file not present or invalid!\n");
} else {
2022-07-21 21:44:55 -04:00
load_general(); /* General */
for (i = 0; i < MONITORS_NUM; i++)
load_monitor(i);
load_machine(); /* Machine */
load_video(); /* Video */
load_input_devices(); /* Input devices */
load_sound(); /* Sound */
load_network(); /* Network */
load_ports(); /* Ports (COM & LPT) */
load_storage_controllers(); /* Storage controllers */
load_hard_disks(); /* Hard disks */
load_floppy_and_cdrom_drives(); /* Floppy and CD-ROM drives */
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
load_floppy_drives(); /* Floppy drives */
load_other_removable_devices(); /* Other removable devices */
load_other_peripherals(); /* Other peripherals */
/* Mark the configuration as changed. */
config_changed = 1;
config_log("Config loaded.\n\n");
}
video_copy = (video_grayscale || invert_display) ? video_transform_copy : memcpy;
}
/* Save "General" section. */
static void
save_general(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "General");
2022-07-21 21:44:55 -04:00
char temp[512], buffer[512] = { 0 };
char *va_name;
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "vid_resize", vid_resize);
if (vid_resize == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "vid_resize");
va_name = plat_vidapi_name(vid_api);
2022-07-18 02:17:16 +02:00
if (!strcmp(va_name, "default"))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "vid_renderer");
2022-07-18 02:17:16 +02:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "vid_renderer", va_name);
if (video_fullscreen_scale == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_fullscreen_scale");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_fullscreen_scale", video_fullscreen_scale);
if (video_fullscreen_first == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_fullscreen_first");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_fullscreen_first", video_fullscreen_first);
if (video_filter_method == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_filter_method");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_filter_method", video_filter_method);
if (force_43 == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "force_43");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "force_43", force_43);
if (scale == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "scale");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "scale", scale);
if (dpi_scale == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "dpi_scale");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "dpi_scale", dpi_scale);
if (enable_overscan == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "enable_overscan");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "enable_overscan", enable_overscan);
if (vid_cga_contrast == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "vid_cga_contrast");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "vid_cga_contrast", vid_cga_contrast);
if (video_grayscale == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_grayscale");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_grayscale", video_grayscale);
if (video_graytype == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_graytype");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_graytype", video_graytype);
if (rctrl_is_lalt == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "rctrl_is_lalt");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "rctrl_is_lalt", rctrl_is_lalt);
if (update_icons == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "update_icons");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "update_icons", update_icons);
if (window_remember || (vid_resize & 2)) {
if (window_remember)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "window_remember", window_remember);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_remember");
2022-07-18 02:17:16 +02:00
} else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_remember");
if (vid_resize & 2) {
sprintf(temp, "%ix%i", fixed_size_x, fixed_size_y);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "window_fixed_res", temp);
} else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_fixed_res");
if (sound_gain != 0)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "sound_gain", sound_gain);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "sound_gain");
if (kbd_req_capture != 0)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "kbd_req_capture", kbd_req_capture);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "kbd_req_capture");
if (hide_status_bar != 0)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "hide_status_bar", hide_status_bar);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "hide_status_bar");
if (hide_tool_bar != 0)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "hide_tool_bar", hide_tool_bar);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "hide_tool_bar");
if (confirm_reset != 1)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "confirm_reset", confirm_reset);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "confirm_reset");
if (confirm_exit != 1)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "confirm_exit", confirm_exit);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "confirm_exit");
if (confirm_save != 1)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "confirm_save", confirm_save);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "confirm_save");
2022-06-01 15:31:58 +06:00
if (mouse_sensitivity != 1.0)
2022-09-10 13:32:46 +02:00
ini_section_set_double(cat, "mouse_sensitivity", mouse_sensitivity);
2022-06-01 15:31:58 +06:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "mouse_sensitivity");
2022-06-01 15:31:58 +06:00
2021-11-13 21:37:27 +01:00
if (lang_id == DEFAULT_LANGUAGE)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "language");
2022-07-18 02:17:16 +02:00
else {
plat_language_code_r(lang_id, buffer, 511);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "language", buffer);
2022-07-18 02:17:16 +02:00
}
if (!strcmp(icon_set, ""))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "iconset");
2022-07-18 02:17:16 +02:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "iconset", icon_set);
2019-12-04 21:55:35 +01:00
if (enable_discord)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "enable_discord", enable_discord);
2019-12-04 21:55:35 +01:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "enable_discord");
2019-12-04 21:55:35 +01:00
if (open_dir_usr_path)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "open_dir_usr_path", open_dir_usr_path);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "open_dir_usr_path");
if (video_framerate != -1)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_gl_framerate", video_framerate);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_gl_framerate");
if (video_vsync != 0)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_gl_vsync", video_vsync);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_gl_vsync");
if (strlen(video_shader) > 0)
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "video_gl_shader", video_shader);
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_gl_shader");
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save monitor section. */
static void
save_monitor(int monitor_index)
{
char cat[sizeof("Monitor #") + 12] = { [0] = 0 };
char temp[512];
snprintf(cat, sizeof(cat), "Monitor #%i", monitor_index + 1);
if (window_remember) {
sprintf(temp, "%i, %i, %i, %i",
monitor_settings[monitor_index].mon_window_x, monitor_settings[monitor_index].mon_window_y,
monitor_settings[monitor_index].mon_window_w, monitor_settings[monitor_index].mon_window_h);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "window_coordinates", temp);
if (monitor_settings[monitor_index].mon_window_maximized != 0) {
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "window_maximized", monitor_settings[monitor_index].mon_window_maximized);
} else {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_maximized");
}
} else {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "window_coordinates");
ini_section_delete_var(cat, "window_maximized");
}
}
/* Save "Machine" section. */
static void
save_machine(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Machine");
char *p;
2022-07-21 21:44:55 -04:00
int c, i = 0, legacy_mfg, legacy_cpu = -1, closest_legacy_cpu = -1;
p = machine_get_internal_name();
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "machine", p);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "cpu_family", (char *) cpu_f->internal_name);
ini_section_set_int(cat, "cpu_speed", cpu_f->cpus[cpu].rspeed);
ini_section_set_double(cat, "cpu_multi", cpu_f->cpus[cpu].multi);
2020-11-23 14:48:32 -03:00
if (cpu_override)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cpu_override", cpu_override);
2020-11-23 14:48:32 -03:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cpu_override");
/* Forwards compatibility with the previous CPU model system. */
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cpu_manufacturer");
ini_section_delete_var(cat, "cpu");
/* Look for a machine entry on the legacy table. */
c = 0;
while (cpu_legacy_table[c].machine) {
if (!strcmp(p, cpu_legacy_table[c].machine))
break;
c++;
}
if (cpu_legacy_table[c].machine) {
/* Look for a corresponding CPU entry. */
cpu_legacy_table_t *legacy_table_entry;
for (legacy_mfg = 0; legacy_mfg < 4; legacy_mfg++) {
2022-07-21 21:44:55 -04:00
if (!cpu_legacy_table[c].tables[legacy_mfg])
continue;
i = 0;
while (cpu_legacy_table[c].tables[legacy_mfg][i].family) {
legacy_table_entry = (cpu_legacy_table_t *) &cpu_legacy_table[c].tables[legacy_mfg][i];
/* Match the family name, speed and multiplier. */
if (!strcmp(cpu_f->internal_name, legacy_table_entry->family)) {
if ((legacy_table_entry->rspeed == cpu_f->cpus[cpu].rspeed) && (legacy_table_entry->multi == cpu_f->cpus[cpu].multi)) { /* exact speed/multiplier match */
legacy_cpu = i;
break;
} else if ((legacy_table_entry->rspeed >= cpu_f->cpus[cpu].rspeed) && (closest_legacy_cpu == -1)) { /* closest speed match */
closest_legacy_cpu = i;
}
}
2022-07-21 21:44:55 -04:00
i++;
}
2022-07-21 21:44:55 -04:00
/* Use the closest speed match if no exact match was found. */
if ((legacy_cpu == -1) && (closest_legacy_cpu > -1)) {
legacy_cpu = closest_legacy_cpu;
break;
} else if (legacy_cpu > -1) /* exact match found */
break;
}
/* Set legacy values if a match was found. */
if (legacy_cpu > -1) {
if (legacy_mfg)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cpu_manufacturer", legacy_mfg);
if (legacy_cpu)
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cpu", legacy_cpu);
}
}
if (cpu_waitstates == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cpu_waitstates");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cpu_waitstates", cpu_waitstates);
if (fpu_type == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "fpu_type");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "fpu_type", (char *) fpu_get_internal_name(cpu_f, cpu, fpu_type));
2022-07-21 21:44:55 -04:00
// Write the mem_size explicitly to the setttings in order to help managers to display it without having the actual machine table
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "mem_size");
ini_section_set_int(cat, "mem_size", mem_size);
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cpu_use_dynarec", cpu_use_dynarec);
if (time_sync & TIME_SYNC_ENABLED)
if (time_sync & TIME_SYNC_UTC)
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "time_sync", "utc");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "time_sync", "local");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "time_sync", "disabled");
if (pit_mode == -1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "pit_mode");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "pit_mode", pit_mode);
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Video" section. */
static void
save_video(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Video");
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "gfxcard",
2022-07-21 21:44:55 -04:00
video_get_internal_name(gfxcard));
if (voodoo_enabled == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "voodoo");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "voodoo", voodoo_enabled);
if (ibm8514_enabled == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "8514a");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "8514a", ibm8514_enabled);
if (xga_enabled == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "xga");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "xga", xga_enabled);
2022-07-07 14:34:59 +06:00
if (gfxcard_2 == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "gfxcard_2");
2022-07-04 01:50:42 +06:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "gfxcard_2", video_get_internal_name(gfxcard_2));
2022-07-04 01:50:42 +06:00
if (show_second_monitors == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "show_second_monitors");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "show_second_monitors", show_second_monitors);
if (video_fullscreen_scale_maximized == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "video_fullscreen_scale_maximized");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "video_fullscreen_scale_maximized", video_fullscreen_scale_maximized);
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Input Devices" section. */
static void
save_input_devices(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Input devices");
2022-07-21 21:44:55 -04:00
char temp[512], tmp2[512];
int c, d;
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "mouse_type", mouse_get_internal_name(mouse_type));
if (!joystick_type) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "joystick_type");
for (c = 0; c < 16; c++) {
sprintf(tmp2, "joystick_%i_nr", c);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, tmp2);
2022-07-21 21:44:55 -04:00
for (d = 0; d < 16; d++) {
sprintf(tmp2, "joystick_%i_axis_%i", c, d);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, tmp2);
}
2022-07-21 21:44:55 -04:00
for (d = 0; d < 16; d++) {
sprintf(tmp2, "joystick_%i_button_%i", c, d);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, tmp2);
}
2022-07-21 21:44:55 -04:00
for (d = 0; d < 16; d++) {
sprintf(tmp2, "joystick_%i_pov_%i", c, d);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, tmp2);
}
}
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "joystick_type", joystick_get_internal_name(joystick_type));
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) {
sprintf(tmp2, "joystick_%i_nr", c);
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, tmp2, joystick_state[c].plat_joystick_nr);
if (joystick_state[c].plat_joystick_nr) {
2022-07-21 21:44:55 -04:00
for (d = 0; d < joystick_get_axis_count(joystick_type); d++) {
sprintf(tmp2, "joystick_%i_axis_%i", c, d);
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, tmp2, joystick_state[c].axis_mapping[d]);
}
2022-07-21 21:44:55 -04:00
for (d = 0; d < joystick_get_button_count(joystick_type); d++) {
sprintf(tmp2, "joystick_%i_button_%i", c, d);
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, tmp2, joystick_state[c].button_mapping[d]);
}
2022-07-21 21:44:55 -04:00
for (d = 0; d < joystick_get_pov_count(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]);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, tmp2, temp);
}
}
}
}
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Sound" section. */
static void
save_sound(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Sound");
if (sound_card_current == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "sndcard");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "sndcard", sound_card_get_internal_name(sound_card_current));
if (!strcmp(midi_out_device_get_internal_name(midi_output_device_current), "none"))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "midi_device");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "midi_device", midi_out_device_get_internal_name(midi_output_device_current));
2020-01-01 20:20:16 +01:00
if (!strcmp(midi_in_device_get_internal_name(midi_input_device_current), "none"))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "midi_in_device");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "midi_in_device", midi_in_device_get_internal_name(midi_input_device_current));
2020-01-01 20:20:16 +01:00
if (mpu401_standalone_enable == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "mpu401_standalone");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
if (SSI2001 == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "ssi2001");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "ssi2001", SSI2001);
if (GAMEBLASTER == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "gameblaster");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "gameblaster", GAMEBLASTER);
if (GUS == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "gus");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "gus", GUS);
if (sound_is_float == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "sound_type");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "sound_type", (sound_is_float == 1) ? "float" : "int16");
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "fm_driver", (fm_driver == FM_DRV_NUKED) ? "nuked" : "ymfm");
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Network" section. */
static void
save_network(void)
{
int c = 0;
char temp[512];
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Network");
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "net_type");
ini_section_delete_var(cat, "net_host_device");
ini_section_delete_var(cat, "net_card");
for (c = 0; c < NET_CARD_MAX; c++) {
sprintf(temp, "net_%02i_card", c + 1);
if (net_cards_conf[c].device_num == 0) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, network_card_get_internal_name(net_cards_conf[c].device_num));
}
sprintf(temp, "net_%02i_net_type", c + 1);
if (net_cards_conf[c].net_type == NET_TYPE_NONE) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp,
(net_cards_conf[c].net_type == NET_TYPE_SLIRP) ? "slirp" : "pcap");
}
sprintf(temp, "net_%02i_host_device", c + 1);
if (net_cards_conf[c].host_dev_name[0] != '\0') {
if (!strcmp(net_cards_conf[c].host_dev_name, "none"))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, net_cards_conf[c].host_dev_name);
} else {
2022-09-10 13:32:46 +02:00
/* ini_section_set_string(cat, temp, "none"); */
ini_section_delete_var(cat, temp);
}
sprintf(temp, "net_%02i_link", c + 1);
if (net_cards_conf[c].link_state == (NET_LINK_10_HD|NET_LINK_10_FD|NET_LINK_100_HD|NET_LINK_100_FD|NET_LINK_1000_HD|NET_LINK_1000_FD)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, net_cards_conf[c].link_state);
}
}
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Ports" section. */
static void
save_ports(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Ports (COM & LPT)");
2022-07-21 21:44:55 -04:00
char temp[512];
int c, d;
for (c = 0; c < SERIAL_MAX; c++) {
sprintf(temp, "serial%d_enabled", c + 1);
2022-07-28 16:50:49 -04:00
if (((c < 2) && com_ports[c].enabled) || ((c >= 2) && !com_ports[c].enabled))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, com_ports[c].enabled);
2022-01-31 01:43:12 -05:00
2022-07-28 16:50:49 -04:00
/*
2022-07-21 21:44:55 -04:00
sprintf(temp, "serial%d_type", c + 1);
2022-07-28 16:50:49 -04:00
if (!com_ports[c].enabled))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-28 16:50:49 -04:00
// else
2022-09-10 13:32:46 +02:00
// ini_section_set_string(cat, temp, (char *) serial_type[c])
2022-07-21 21:44:55 -04:00
sprintf(temp, "serial%d_device", c + 1);
if (com_ports[c].device == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp,
2022-07-21 21:44:55 -04:00
(char *) com_device_get_internal_name(com_ports[c].device));
*/
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
}
for (c = 0; c < PARALLEL_MAX; c++) {
sprintf(temp, "lpt%d_enabled", c + 1);
d = (c == 0) ? 1 : 0;
if (lpt_ports[c].enabled == d)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, lpt_ports[c].enabled);
sprintf(temp, "lpt%d_device", c + 1);
if (lpt_ports[c].device == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp,
2022-07-21 21:44:55 -04:00
(char *) lpt_device_get_internal_name(lpt_ports[c].device));
Added the IBM 5161 ISA expansion for PC and XT; Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
}
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Storage Controllers" section. */
static void
save_storage_controllers(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Storage controllers");
2022-07-21 21:44:55 -04:00
char temp[512];
int c;
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "scsicard");
for (c = 0; c < SCSI_BUS_MAX; c++) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "scsicard_%d", c + 1);
2022-07-21 21:44:55 -04:00
if (scsi_card_current[c] == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp,
2022-07-21 21:44:55 -04:00
scsi_card_get_internal_name(scsi_card_current[c]));
}
if (fdc_type == FDC_INTERNAL)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "fdc");
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "fdc",
2022-07-21 21:44:55 -04:00
fdc_card_get_internal_name(fdc_type));
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "hdc",
2022-07-21 21:44:55 -04:00
hdc_get_internal_name(hdc_current));
if (ide_ter_enabled == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "ide_ter");
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "ide_ter", ide_ter_enabled);
if (ide_qua_enabled == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "ide_qua");
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "ide_qua", ide_qua_enabled);
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
if (cassette_enable == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_enabled");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cassette_enabled", cassette_enable);
if (strlen(cassette_fname) == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_file");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "cassette_file", cassette_fname);
if (strlen(cassette_mode) == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_mode");
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "cassette_mode", cassette_mode);
if (cassette_pos == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_position");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cassette_position", cassette_pos);
if (cassette_srate == 44100)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_srate");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cassette_srate", cassette_srate);
if (cassette_append == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_append");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cassette_append", cassette_append);
if (cassette_pcm == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_pcm");
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cassette_pcm", cassette_pcm);
2021-07-28 00:58:19 +02:00
if (cassette_ui_writeprot == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "cassette_writeprot");
2021-07-28 00:58:19 +02:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "cassette_writeprot", cassette_ui_writeprot);
2021-07-29 20:34:55 +02:00
2022-07-21 21:44:55 -04:00
for (c = 0; c < 2; c++) {
sprintf(temp, "cartridge_%02i_fn", c + 1);
if (strlen(cart_fns[c]) == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, cart_fns[c]);
2021-07-29 20:34:55 +02:00
}
}
/* Save "Other Peripherals" section. */
static void
save_other_peripherals(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Other peripherals");
2022-07-21 21:44:55 -04:00
char temp[512];
int c;
if (bugger_enabled == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "bugger_enabled");
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "bugger_enabled", bugger_enabled);
2020-03-23 17:03:28 -03:00
if (postcard_enabled == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "postcard_enabled");
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, "postcard_enabled", postcard_enabled);
2020-03-23 17:03:28 -03:00
for (c = 0; c < ISAMEM_MAX; c++) {
2022-07-21 21:44:55 -04:00
sprintf(temp, "isamem%d_type", c);
if (isamem_type[c] == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp,
2022-07-21 21:44:55 -04:00
(char *) isamem_get_internal_name(isamem_type[c]));
}
if (isartc_type == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, "isartc_type");
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, "isartc_type",
2022-07-21 21:44:55 -04:00
isartc_get_internal_name(isartc_type));
2022-02-20 02:26:27 -05:00
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Hard Disks" section. */
static void
save_hard_disks(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Hard disks");
2022-07-21 21:44:55 -04:00
char temp[32], tmp2[512];
char *p;
2022-07-21 21:44:55 -04:00
int c;
memset(temp, 0x00, sizeof(temp));
2022-07-21 21:44:55 -04:00
for (c = 0; c < HDD_NUM; c++) {
sprintf(temp, "hdd_%02i_parameters", c + 1);
if (hdd_is_valid(c)) {
p = hdd_bus_to_string(hdd[c].bus, 0);
sprintf(tmp2, "%u, %u, %u, %i, %s",
hdd[c].spt, hdd[c].hpc, hdd[c].tracks, hdd[c].wp, p);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
} else {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "hdd_%02i_mfm_channel", c + 1);
if (hdd_is_valid(c) && (hdd[c].bus == HDD_BUS_MFM))
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, hdd[c].mfm_channel);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_xta_channel", c + 1);
if (hdd_is_valid(c) && (hdd[c].bus == HDD_BUS_XTA))
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, hdd[c].xta_channel);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_esdi_channel", c + 1);
if (hdd_is_valid(c) && (hdd[c].bus == HDD_BUS_ESDI))
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, hdd[c].esdi_channel);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_ide_channel", c + 1);
if (!hdd_is_valid(c) || (hdd[c].bus != HDD_BUS_IDE)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
sprintf(tmp2, "%01u:%01u", hdd[c].ide_channel >> 1, hdd[c].ide_channel & 1);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "hdd_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_scsi_location", c + 1);
if (hdd[c].bus != HDD_BUS_SCSI)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else {
sprintf(tmp2, "%01u:%02u", hdd[c].scsi_id >> 4,
hdd[c].scsi_id & 15);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_fn", c + 1);
if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0)) {
path_normalize(hdd[c].fn);
if (!strnicmp(hdd[c].fn, usr_path, strlen(usr_path)))
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, &hdd[c].fn[strlen(usr_path)]);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, hdd[c].fn);
2022-07-21 21:44:55 -04:00
} else
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "hdd_%02i_speed", c + 1);
2022-07-29 00:47:52 +02:00
if (!hdd_is_valid(c) || (hdd[c].bus != HDD_BUS_IDE && hdd[c].bus != HDD_BUS_ESDI))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, hdd_preset_get_internal_name(hdd[c].speed_preset));
}
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
2018-01-26 22:17:09 +01:00
/* Save "Floppy Drives" section. */
static void
save_floppy_and_cdrom_drives(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Floppy and CD-ROM drives");
2022-07-21 21:44:55 -04:00
char temp[512], tmp2[512];
int c;
for (c = 0; c < FDD_NUM; c++) {
sprintf(temp, "fdd_%02i_type", c + 1);
if (fdd_get_type(c) == ((c < 2) ? 2 : 0))
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp,
2022-07-21 21:44:55 -04:00
fdd_get_internal_name(fdd_get_type(c)));
sprintf(temp, "fdd_%02i_fn", c + 1);
if (strlen(floppyfns[c]) == 0) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
ui_writeprot[c] = 0;
sprintf(temp, "fdd_%02i_writeprot", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, floppyfns[c]);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "fdd_%02i_writeprot", c + 1);
if (ui_writeprot[c] == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, ui_writeprot[c]);
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_turbo", c + 1);
if (fdd_get_turbo(c) == 0)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, fdd_get_turbo(c));
2022-07-21 21:44:55 -04:00
sprintf(temp, "fdd_%02i_check_bpb", c + 1);
if (fdd_get_check_bpb(c) == 1)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, fdd_get_check_bpb(c));
}
2022-07-21 21:44:55 -04:00
for (c = 0; c < CDROM_NUM; c++) {
sprintf(temp, "cdrom_%02i_host_drive", c + 1);
if ((cdrom[c].bus_type == 0) || (cdrom[c].host_drive != 200)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, cdrom[c].host_drive);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "cdrom_%02i_speed", c + 1);
if ((cdrom[c].bus_type == 0) || (cdrom[c].speed == 8)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_int(cat, temp, cdrom[c].speed);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "cdrom_%02i_parameters", c + 1);
if (cdrom[c].bus_type == 0) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
sprintf(tmp2, "%u, %s", cdrom[c].sound_on,
hdd_bus_to_string(cdrom[c].bus_type, 1));
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "cdrom_%02i_ide_channel", c + 1);
if (cdrom[c].bus_type != CDROM_BUS_ATAPI)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else {
sprintf(tmp2, "%01u:%01u", cdrom[c].ide_channel >> 1,
cdrom[c].ide_channel & 1);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "cdrom_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "cdrom_%02i_scsi_location", c + 1);
if (cdrom[c].bus_type != CDROM_BUS_SCSI)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else {
sprintf(tmp2, "%01u:%02u", cdrom[c].scsi_device_id >> 4,
cdrom[c].scsi_device_id & 15);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "cdrom_%02i_image_path", c + 1);
if ((cdrom[c].bus_type == 0) || (strlen(cdrom[c].image_path) == 0)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, cdrom[c].image_path);
2022-07-21 21:44:55 -04:00
}
for (int i = 0; i < MAX_PREV_IMAGES; i++) {
sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1);
if((cdrom[c].image_history[i] == 0) || strlen(cdrom[c].image_history[i]) == 0) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, cdrom[c].image_history[i]);
}
}
}
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
/* Save "Other Removable Devices" section. */
static void
save_other_removable_devices(void)
{
2022-09-10 13:32:46 +02:00
ini_section_t cat = ini_find_or_create_section(config, "Other removable devices");
2022-07-21 21:44:55 -04:00
char temp[512], tmp2[512];
int c;
for (c = 0; c < ZIP_NUM; c++) {
sprintf(temp, "zip_%02i_parameters", c + 1);
if (zip_drives[c].bus_type == 0) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
sprintf(tmp2, "%u, %s", zip_drives[c].is_250,
hdd_bus_to_string(zip_drives[c].bus_type, 1));
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "zip_%02i_ide_channel", c + 1);
if (zip_drives[c].bus_type != ZIP_BUS_ATAPI)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else {
sprintf(tmp2, "%01u:%01u", zip_drives[c].ide_channel >> 1,
zip_drives[c].ide_channel & 1);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "zip_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "zip_%02i_scsi_location", c + 1);
if (zip_drives[c].bus_type != ZIP_BUS_SCSI)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else {
sprintf(tmp2, "%01u:%02u", zip_drives[c].scsi_device_id >> 4,
zip_drives[c].scsi_device_id & 15);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "zip_%02i_image_path", c + 1);
if ((zip_drives[c].bus_type == 0) || (strlen(zip_drives[c].image_path) == 0)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, zip_drives[c].image_path);
2022-07-21 21:44:55 -04:00
}
2018-01-26 22:17:09 +01:00
}
2022-07-21 21:44:55 -04:00
for (c = 0; c < MO_NUM; c++) {
sprintf(temp, "mo_%02i_parameters", c + 1);
if (mo_drives[c].bus_type == 0) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
sprintf(tmp2, "%u, %s", mo_drives[c].type,
hdd_bus_to_string(mo_drives[c].bus_type, 1));
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "mo_%02i_ide_channel", c + 1);
if (mo_drives[c].bus_type != MO_BUS_ATAPI)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else {
sprintf(tmp2, "%01u:%01u", mo_drives[c].ide_channel >> 1,
mo_drives[c].ide_channel & 1);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "mo_%02i_scsi_id", c + 1);
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
sprintf(temp, "mo_%02i_scsi_location", c + 1);
if (mo_drives[c].bus_type != MO_BUS_SCSI)
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
else {
sprintf(tmp2, "%01u:%02u", mo_drives[c].scsi_device_id >> 4,
mo_drives[c].scsi_device_id & 15);
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, tmp2);
2022-07-21 21:44:55 -04:00
}
sprintf(temp, "mo_%02i_image_path", c + 1);
if ((mo_drives[c].bus_type == 0) || (strlen(mo_drives[c].image_path) == 0)) {
2022-09-10 13:32:46 +02:00
ini_section_delete_var(cat, temp);
2022-07-21 21:44:55 -04:00
} else {
2022-09-10 13:32:46 +02:00
ini_section_set_string(cat, temp, mo_drives[c].image_path);
2022-07-21 21:44:55 -04:00
}
}
2022-09-10 13:32:46 +02:00
ini_delete_section_if_empty(config, cat);
}
void
config_save(void)
2022-02-20 02:26:27 -05:00
{
2022-07-21 21:44:55 -04:00
int i;
save_general(); /* General */
for (i = 0; i < MONITORS_NUM; i++)
save_monitor(i);
save_machine(); /* Machine */
save_video(); /* Video */
save_input_devices(); /* Input devices */
save_sound(); /* Sound */
save_network(); /* Network */
save_ports(); /* Ports (COM & LPT) */
save_storage_controllers(); /* Storage controllers */
save_hard_disks(); /* Hard disks */
save_floppy_and_cdrom_drives(); /* Floppy and CD-ROM drives */
save_other_removable_devices(); /* Other removable devices */
save_other_peripherals(); /* Other peripherals */
2022-09-10 13:32:46 +02:00
ini_write(config, cfg_path);
}
2022-09-10 13:32:46 +02:00
ini_t
config_get_ini(void)
{
2022-09-10 13:32:46 +02:00
return config;
}