2016-08-14 22:07:17 -04:00
|
|
|
/* Copyright holders: Sarah Walker
|
2017-05-31 01:22:52 -04:00
|
|
|
* see COPYING for more details
|
|
|
|
|
*
|
|
|
|
|
* NOTE: Forcing config files to be in Unicode encoding breaks it on
|
|
|
|
|
* Windows XP, and possibly also Vista. Use -DANSI_CFG for use
|
|
|
|
|
* on these systems.
|
|
|
|
|
*/
|
2017-05-17 21:56:31 +02:00
|
|
|
#include <inttypes.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include <stdio.h>
|
2017-05-08 04:54:17 +02:00
|
|
|
#include <stdint.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
2017-05-27 03:53:32 +02:00
|
|
|
|
2017-05-08 04:54:17 +02:00
|
|
|
#include "cdrom.h"
|
2016-06-26 00:34:39 +02:00
|
|
|
#include "config.h"
|
2017-05-08 04:54:17 +02:00
|
|
|
#include "device.h"
|
|
|
|
|
#include "disc.h"
|
|
|
|
|
#include "fdc.h"
|
|
|
|
|
#include "fdd.h"
|
2017-05-05 01:49:42 +02:00
|
|
|
#include "ibm.h"
|
2017-05-08 04:54:17 +02:00
|
|
|
#include "cpu/cpu.h"
|
|
|
|
|
#include "gameport.h"
|
|
|
|
|
#include "ide.h"
|
|
|
|
|
#include "hdd.h"
|
|
|
|
|
#include "model.h"
|
|
|
|
|
#include "mouse.h"
|
|
|
|
|
#include "network.h"
|
|
|
|
|
#include "nvr.h"
|
|
|
|
|
#include "scsi.h"
|
2017-05-27 03:53:32 +02:00
|
|
|
#include "win/plat_joystick.h"
|
|
|
|
|
#include "win/plat_midi.h"
|
2017-05-08 04:54:17 +02:00
|
|
|
#include "sound/snd_dbopl.h"
|
2017-06-03 20:32:58 +02:00
|
|
|
#include "sound/snd_mpu401.h"
|
2017-05-08 04:54:17 +02:00
|
|
|
#include "sound/snd_opl.h"
|
|
|
|
|
#include "sound/sound.h"
|
|
|
|
|
#include "video/video.h"
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
#include "win/win.h"
|
|
|
|
|
#include "win/win_language.h"
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-11 03:25:23 -04:00
|
|
|
|
2017-05-06 04:02:03 +02:00
|
|
|
wchar_t config_file_default[256];
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-05-06 04:02:03 +02:00
|
|
|
static wchar_t config_file[256];
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-05-11 03:25:23 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
typedef struct list_t
|
|
|
|
|
{
|
|
|
|
|
struct list_t *next;
|
|
|
|
|
} list_t;
|
|
|
|
|
|
|
|
|
|
static list_t config_head;
|
|
|
|
|
|
|
|
|
|
typedef struct section_t
|
|
|
|
|
{
|
|
|
|
|
struct list_t list;
|
|
|
|
|
|
|
|
|
|
char name[256];
|
|
|
|
|
|
|
|
|
|
struct list_t entry_head;
|
|
|
|
|
} section_t;
|
|
|
|
|
|
|
|
|
|
typedef struct entry_t
|
|
|
|
|
{
|
|
|
|
|
struct list_t list;
|
|
|
|
|
|
|
|
|
|
char name[256];
|
|
|
|
|
char data[256];
|
2017-05-05 22:36:10 +02:00
|
|
|
wchar_t wdata[256];
|
2016-06-26 00:34:39 +02:00
|
|
|
} entry_t;
|
|
|
|
|
|
|
|
|
|
#define list_add(new, head) \
|
|
|
|
|
{ \
|
|
|
|
|
struct list_t *next = head; \
|
|
|
|
|
\
|
|
|
|
|
while (next->next) \
|
|
|
|
|
next = next->next; \
|
|
|
|
|
\
|
|
|
|
|
(next)->next = new; \
|
|
|
|
|
(new)->next = NULL; \
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-11 03:25:23 -04:00
|
|
|
void config_dump(void)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
|
|
|
|
section_t *current_section;
|
|
|
|
|
|
|
|
|
|
pclog("Config data :\n");
|
|
|
|
|
|
|
|
|
|
current_section = (section_t *)config_head.next;
|
|
|
|
|
|
|
|
|
|
while (current_section)
|
|
|
|
|
{
|
|
|
|
|
entry_t *current_entry;
|
|
|
|
|
|
|
|
|
|
pclog("[%s]\n", current_section->name);
|
|
|
|
|
|
|
|
|
|
current_entry = (entry_t *)current_section->entry_head.next;
|
|
|
|
|
|
|
|
|
|
while (current_entry)
|
|
|
|
|
{
|
|
|
|
|
pclog("%s = %s\n", current_entry->name, current_entry->data);
|
|
|
|
|
|
|
|
|
|
current_entry = (entry_t *)current_entry->list.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_section = (section_t *)current_section->list.next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
static void config_free(void)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
|
|
|
|
section_t *current_section;
|
|
|
|
|
current_section = (section_t *)config_head.next;
|
|
|
|
|
|
|
|
|
|
while (current_section)
|
|
|
|
|
{
|
|
|
|
|
section_t *next_section = (section_t *)current_section->list.next;
|
|
|
|
|
entry_t *current_entry;
|
|
|
|
|
|
|
|
|
|
current_entry = (entry_t *)current_section->entry_head.next;
|
|
|
|
|
|
|
|
|
|
while (current_entry)
|
|
|
|
|
{
|
|
|
|
|
entry_t *next_entry = (entry_t *)current_entry->list.next;
|
|
|
|
|
|
|
|
|
|
free(current_entry);
|
|
|
|
|
current_entry = next_entry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(current_section);
|
|
|
|
|
current_section = next_section;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
static wchar_t cfgbuffer[1024];
|
|
|
|
|
static char sname[256];
|
|
|
|
|
static char ename[256];
|
|
|
|
|
|
2017-06-01 01:47:54 +02:00
|
|
|
int config_load(wchar_t *fn)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2017-05-31 01:22:52 -04:00
|
|
|
section_t *current_section;
|
2017-05-17 21:56:31 +02:00
|
|
|
section_t *new_section;
|
|
|
|
|
entry_t *new_entry;
|
2017-05-31 01:22:52 -04:00
|
|
|
FILE *f;
|
|
|
|
|
int c;
|
2017-05-17 21:56:31 +02:00
|
|
|
int sd = 0, ed = 0, data_pos;
|
|
|
|
|
|
2017-05-31 01:22:52 -04:00
|
|
|
#ifdef ANSI_CFG
|
|
|
|
|
f = _wfopen(fn, L"rt");
|
|
|
|
|
#else
|
|
|
|
|
f = _wfopen(fn, L"rt, ccs=UNICODE");
|
|
|
|
|
#endif
|
|
|
|
|
if (!f)
|
2017-06-01 01:47:54 +02:00
|
|
|
return 0;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
current_section = malloc(sizeof(section_t));
|
2017-05-31 01:22:52 -04:00
|
|
|
memset(current_section, 0x00, sizeof(section_t));
|
|
|
|
|
memset(&config_head, 0x00, sizeof(list_t));
|
2016-06-26 00:34:39 +02:00
|
|
|
list_add(¤t_section->list, &config_head);
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
memset(cfgbuffer, 0, 2048);
|
|
|
|
|
fgetws(cfgbuffer, 255, f);
|
2016-06-26 00:34:39 +02:00
|
|
|
if (feof(f)) break;
|
|
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
while (cfgbuffer[c] == L' ')
|
2016-06-26 00:34:39 +02:00
|
|
|
c++;
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
if (cfgbuffer[c] == L'\0') continue;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
if (cfgbuffer[c] == L'#') /*Comment*/
|
2016-06-26 00:34:39 +02:00
|
|
|
continue;
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
if (cfgbuffer[c] == L'[') /*Section*/
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
sd = 0;
|
2016-06-26 00:34:39 +02:00
|
|
|
c++;
|
2017-05-17 21:56:31 +02:00
|
|
|
while (cfgbuffer[c] != L']' && cfgbuffer[c])
|
|
|
|
|
wctomb(&(sname[sd++]), cfgbuffer[c++]);
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
if (cfgbuffer[c] != L']')
|
2016-06-26 00:34:39 +02:00
|
|
|
continue;
|
2017-05-17 21:56:31 +02:00
|
|
|
sname[sd] = 0;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
new_section = malloc(sizeof(section_t));
|
|
|
|
|
memset(new_section, 0, sizeof(section_t));
|
2017-05-17 21:56:31 +02:00
|
|
|
strncpy(new_section->name, sname, 256);
|
2016-06-26 00:34:39 +02:00
|
|
|
list_add(&new_section->list, &config_head);
|
|
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
current_section = new_section;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
ed = 0;
|
|
|
|
|
while (cfgbuffer[c] != L'=' && cfgbuffer[c] != L' ' && cfgbuffer[c])
|
|
|
|
|
wctomb(&(ename[ed++]), cfgbuffer[c++]);
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
if (cfgbuffer[c] == L'\0') continue;
|
|
|
|
|
ename[ed] = 0;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
while ((cfgbuffer[c] == L'=' || cfgbuffer[c] == L' ') && cfgbuffer[c])
|
2016-06-26 00:34:39 +02:00
|
|
|
c++;
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
if (!cfgbuffer[c]) continue;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
data_pos = c;
|
2017-05-17 21:56:31 +02:00
|
|
|
while (cfgbuffer[c])
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
if (cfgbuffer[c] == L'\n')
|
|
|
|
|
cfgbuffer[c] = L'\0';
|
2016-06-26 00:34:39 +02:00
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new_entry = malloc(sizeof(entry_t));
|
|
|
|
|
memset(new_entry, 0, sizeof(entry_t));
|
2017-05-17 21:56:31 +02:00
|
|
|
strncpy(new_entry->name, ename, 256);
|
|
|
|
|
memcpy(new_entry->wdata, &cfgbuffer[data_pos], 512);
|
2017-05-05 22:36:10 +02:00
|
|
|
new_entry->wdata[255] = L'\0';
|
|
|
|
|
wcstombs(new_entry->data, new_entry->wdata, 512);
|
|
|
|
|
new_entry->data[255] = '\0';
|
2016-06-26 00:34:39 +02:00
|
|
|
list_add(&new_entry->list, ¤t_section->entry_head);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
|
|
config_dump();
|
2017-06-01 01:47:54 +02:00
|
|
|
|
|
|
|
|
return 1;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-05-11 03:25:23 -04:00
|
|
|
void config_new(void)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2017-05-31 01:22:52 -04:00
|
|
|
#ifdef ANSI_CFG
|
|
|
|
|
FILE *f = _wfopen(config_file, L"wt");
|
|
|
|
|
#else
|
2017-05-06 04:02:03 +02:00
|
|
|
FILE *f = _wfopen(config_file, L"wt, ccs=UNICODE");
|
2017-05-31 01:22:52 -04:00
|
|
|
#endif
|
2016-06-26 00:34:39 +02:00
|
|
|
fclose(f);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
static section_t *find_section(char *name)
|
|
|
|
|
{
|
|
|
|
|
section_t *current_section;
|
|
|
|
|
char blank[] = "";
|
|
|
|
|
|
|
|
|
|
current_section = (section_t *)config_head.next;
|
|
|
|
|
if (!name)
|
|
|
|
|
name = blank;
|
|
|
|
|
|
|
|
|
|
while (current_section)
|
|
|
|
|
{
|
|
|
|
|
if (!strncmp(current_section->name, name, 256))
|
|
|
|
|
return current_section;
|
|
|
|
|
|
|
|
|
|
current_section = (section_t *)current_section->list.next;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
static entry_t *find_entry(section_t *section, char *name)
|
|
|
|
|
{
|
|
|
|
|
entry_t *current_entry;
|
|
|
|
|
|
|
|
|
|
current_entry = (entry_t *)section->entry_head.next;
|
|
|
|
|
|
|
|
|
|
while (current_entry)
|
|
|
|
|
{
|
|
|
|
|
if (!strncmp(current_entry->name, name, 256))
|
|
|
|
|
return current_entry;
|
|
|
|
|
|
|
|
|
|
current_entry = (entry_t *)current_entry->list.next;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
static int entries_num(section_t *section)
|
|
|
|
|
{
|
|
|
|
|
entry_t *current_entry;
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
current_entry = (entry_t *)section->entry_head.next;
|
|
|
|
|
|
|
|
|
|
while (current_entry)
|
|
|
|
|
{
|
|
|
|
|
if (strlen(current_entry->name) > 0)
|
|
|
|
|
{
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_entry = (entry_t *)current_entry->list.next;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
static section_t *create_section(char *name)
|
|
|
|
|
{
|
|
|
|
|
section_t *new_section = malloc(sizeof(section_t));
|
|
|
|
|
|
|
|
|
|
memset(new_section, 0, sizeof(section_t));
|
|
|
|
|
strncpy(new_section->name, name, 256);
|
|
|
|
|
list_add(&new_section->list, &config_head);
|
|
|
|
|
|
|
|
|
|
return new_section;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
static entry_t *create_entry(section_t *section, char *name)
|
|
|
|
|
{
|
|
|
|
|
entry_t *new_entry = malloc(sizeof(entry_t));
|
|
|
|
|
memset(new_entry, 0, sizeof(entry_t));
|
|
|
|
|
strncpy(new_entry->name, name, 256);
|
|
|
|
|
list_add(&new_entry->list, §ion->entry_head);
|
|
|
|
|
|
|
|
|
|
return new_entry;
|
|
|
|
|
}
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
int config_get_int(char *head, char *name, int def)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
int value;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
sscanf(entry->data, "%i", &value);
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
int config_get_hex16(char *head, char *name, int def)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
int value;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
sscanf(entry->data, "%04X", &value);
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
int config_get_hex20(char *head, char *name, int def)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
int value;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
sscanf(entry->data, "%05X", &value);
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int config_get_mac(char *head, char *name, int def)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
int val0 = 0, val1 = 0, val2 = 0;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
sscanf(entry->data, "%02x:%02x:%02x", &val0, &val1, &val2);
|
|
|
|
|
|
|
|
|
|
return (val0 << 16) + (val1 << 8) + val2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
char *config_get_string(char *head, char *name, char *def)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
return entry->data;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-05 22:36:10 +02:00
|
|
|
wchar_t *config_get_wstring(char *head, char *name, wchar_t *def)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return def;
|
|
|
|
|
|
|
|
|
|
return entry->wdata;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
void config_delete_var(char *head, char *name)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
memset(entry->name, 0, strlen(entry->name));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void config_delete_section_if_empty(char *head)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (entries_num(section) == 0)
|
|
|
|
|
{
|
|
|
|
|
memset(section->name, 0, strlen(section->name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
void config_set_int(char *head, char *name, int val)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
section = create_section(head);
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
entry = create_entry(section, name);
|
|
|
|
|
|
|
|
|
|
sprintf(entry->data, "%i", val);
|
2017-05-05 22:36:10 +02:00
|
|
|
mbstowcs(entry->wdata, entry->data, 512);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
void config_set_hex16(char *head, char *name, int val)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
section = create_section(head);
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
entry = create_entry(section, name);
|
|
|
|
|
|
|
|
|
|
sprintf(entry->data, "%04X", val);
|
|
|
|
|
mbstowcs(entry->wdata, entry->data, 512);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
void config_set_hex20(char *head, char *name, int val)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
section = create_section(head);
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
entry = create_entry(section, name);
|
|
|
|
|
|
|
|
|
|
sprintf(entry->data, "%05X", val);
|
|
|
|
|
mbstowcs(entry->wdata, entry->data, 512);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void config_set_mac(char *head, char *name, int val)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
section = create_section(head);
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
entry = create_entry(section, name);
|
|
|
|
|
|
|
|
|
|
sprintf(entry->data, "%02x:%02x:%02x", (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff);
|
|
|
|
|
mbstowcs(entry->wdata, entry->data, 512);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
void config_set_string(char *head, char *name, char *val)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
section = create_section(head);
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
entry = create_entry(section, name);
|
|
|
|
|
|
|
|
|
|
strncpy(entry->data, val, 256);
|
2017-05-05 22:36:10 +02:00
|
|
|
mbstowcs(entry->wdata, entry->data, 256);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-05 22:36:10 +02:00
|
|
|
void config_set_wstring(char *head, char *name, wchar_t *val)
|
|
|
|
|
{
|
|
|
|
|
section_t *section;
|
|
|
|
|
entry_t *entry;
|
|
|
|
|
|
|
|
|
|
section = find_section(head);
|
|
|
|
|
|
|
|
|
|
if (!section)
|
|
|
|
|
section = create_section(head);
|
|
|
|
|
|
|
|
|
|
entry = find_entry(section, name);
|
|
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
|
entry = create_entry(section, name);
|
|
|
|
|
|
|
|
|
|
memcpy(entry->wdata, val, 512);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *get_filename(char *s)
|
|
|
|
|
{
|
|
|
|
|
int c = strlen(s) - 1;
|
|
|
|
|
while (c > 0)
|
|
|
|
|
{
|
|
|
|
|
if (s[c] == '/' || s[c] == '\\')
|
|
|
|
|
return &s[c+1];
|
2017-05-05 22:36:10 +02:00
|
|
|
c--;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-06 04:02:03 +02:00
|
|
|
wchar_t *get_filename_w(wchar_t *s)
|
|
|
|
|
{
|
|
|
|
|
int c = wcslen(s) - 1;
|
|
|
|
|
while (c > 0)
|
|
|
|
|
{
|
|
|
|
|
if (s[c] == L'/' || s[c] == L'\\')
|
|
|
|
|
return &s[c+1];
|
|
|
|
|
c--;
|
|
|
|
|
}
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
void append_filename(char *dest, char *s1, char *s2, int size)
|
|
|
|
|
{
|
|
|
|
|
sprintf(dest, "%s%s", s1, s2);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-06 04:02:03 +02:00
|
|
|
void append_filename_w(wchar_t *dest, wchar_t *s1, wchar_t *s2, int size)
|
|
|
|
|
{
|
|
|
|
|
_swprintf(dest, L"%s%s", s1, s2);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
void put_backslash(char *s)
|
|
|
|
|
{
|
|
|
|
|
int c = strlen(s) - 1;
|
|
|
|
|
if (s[c] != '/' && s[c] != '\\')
|
|
|
|
|
s[c] = '/';
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-06 04:02:03 +02:00
|
|
|
void put_backslash_w(wchar_t *s)
|
|
|
|
|
{
|
|
|
|
|
int c = wcslen(s) - 1;
|
|
|
|
|
if (s[c] != L'/' && s[c] != L'\\')
|
|
|
|
|
s[c] = L'/';
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
char *get_extension(char *s)
|
|
|
|
|
{
|
|
|
|
|
int c = strlen(s) - 1;
|
|
|
|
|
|
|
|
|
|
if (c <= 0)
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
|
|
while (c && s[c] != '.')
|
|
|
|
|
c--;
|
|
|
|
|
|
|
|
|
|
if (!c)
|
|
|
|
|
return &s[strlen(s)];
|
|
|
|
|
|
|
|
|
|
return &s[c+1];
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-05 22:36:10 +02:00
|
|
|
wchar_t *get_extension_w(wchar_t *s)
|
|
|
|
|
{
|
|
|
|
|
int c = wcslen(s) - 1;
|
|
|
|
|
|
|
|
|
|
if (c <= 0)
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
|
|
while (c && s[c] != L'.')
|
|
|
|
|
c--;
|
|
|
|
|
|
|
|
|
|
if (!c)
|
|
|
|
|
return &s[wcslen(s)];
|
|
|
|
|
|
|
|
|
|
return &s[c+1];
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-05 22:36:10 +02:00
|
|
|
static wchar_t wname[512];
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-06 04:02:03 +02:00
|
|
|
void config_save(wchar_t *fn)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
|
|
|
|
section_t *current_section;
|
2017-05-31 01:22:52 -04:00
|
|
|
FILE *f;
|
2017-05-17 21:56:31 +02:00
|
|
|
int fl = 0;
|
2017-05-31 01:22:52 -04:00
|
|
|
|
|
|
|
|
#ifdef ANSI_CFG
|
|
|
|
|
f = _wfopen(fn, L"wt");
|
|
|
|
|
#else
|
|
|
|
|
f = _wfopen(fn, L"wt, ccs=UNICODE");
|
|
|
|
|
#endif
|
|
|
|
|
if (f == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
current_section = (section_t *)config_head.next;
|
|
|
|
|
while (current_section)
|
|
|
|
|
{
|
|
|
|
|
entry_t *current_entry;
|
|
|
|
|
|
|
|
|
|
if (current_section->name[0])
|
2017-05-05 22:36:10 +02:00
|
|
|
{
|
|
|
|
|
mbstowcs(wname, current_section->name, strlen(current_section->name) + 1);
|
2017-05-17 21:56:31 +02:00
|
|
|
if (fl)
|
|
|
|
|
{
|
|
|
|
|
fwprintf(f, L"\n[%ws]\n", wname);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fwprintf(f, L"[%ws]\n", wname);
|
|
|
|
|
}
|
|
|
|
|
fl++;
|
2017-05-05 22:36:10 +02:00
|
|
|
}
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
current_entry = (entry_t *)current_section->entry_head.next;
|
|
|
|
|
|
|
|
|
|
while (current_entry)
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
if(strlen(current_entry->name) > 0)
|
2017-05-05 22:36:10 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
mbstowcs(wname, current_entry->name, strlen(current_entry->name) + 1);
|
|
|
|
|
if (current_entry->wdata[0] == L'\0')
|
|
|
|
|
{
|
|
|
|
|
fwprintf(f, L"%ws = \n", wname);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fwprintf(f, L"%ws = %ws\n", wname, current_entry->wdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fl++;
|
2017-05-05 22:36:10 +02:00
|
|
|
}
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
current_entry = (entry_t *)current_entry->list.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_section = (section_t *)current_section->list.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
static wchar_t *read_nvr_path;
|
|
|
|
|
|
2017-05-31 01:22:52 -04:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
/* General */
|
|
|
|
|
static void loadconfig_general(void)
|
2017-05-08 04:54:17 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "General";
|
|
|
|
|
char temps[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
wchar_t *wp;
|
2017-05-08 04:54:17 +02:00
|
|
|
char *p;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
vid_resize = !!config_get_int(cat, "vid_resize", 0);
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(temps, '\0', sizeof(temps));
|
|
|
|
|
p = config_get_string(cat, "vid_renderer", "d3d9");
|
|
|
|
|
if (p != NULL)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
|
|
|
|
strcpy(temps, p);
|
|
|
|
|
}
|
|
|
|
|
if (!strcmp(temps, "ddraw"))
|
|
|
|
|
{
|
|
|
|
|
vid_api = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vid_api = 1;
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
config_delete_var(cat, "vid_api");
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
video_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0);
|
2017-06-01 01:47:54 +02:00
|
|
|
video_fullscreen_first = config_get_int(cat, "video_fullscreen_first", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
force_43 = !!config_get_int(cat, "force_43", 0);
|
2017-05-27 03:53:32 +02:00
|
|
|
scale = config_get_int(cat, "scale", 1);
|
|
|
|
|
if (scale > 3)
|
|
|
|
|
{
|
|
|
|
|
scale = 3;
|
|
|
|
|
}
|
2017-05-18 01:57:16 -04:00
|
|
|
enable_overscan = !!config_get_int(cat, "enable_overscan", 0);
|
2017-06-01 17:52:39 +02:00
|
|
|
vid_cga_contrast = !!config_get_int(cat, "vid_cga_contrast", 0);
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
window_remember = config_get_int(cat, "window_remember", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (window_remember)
|
|
|
|
|
{
|
|
|
|
|
p = config_get_string(cat, "window_coordinates", NULL);
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
p = "0, 0, 0, 0";
|
|
|
|
|
sscanf(p, "%i, %i, %i, %i", &window_w, &window_h, &window_x, &window_y);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "window_remember");
|
|
|
|
|
config_delete_var(cat, "window_coordinates");
|
|
|
|
|
window_w = window_h = window_x = window_y = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (read_nvr_path != NULL)
|
|
|
|
|
{
|
|
|
|
|
free(read_nvr_path);
|
|
|
|
|
read_nvr_path = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(nvr_path, 0x00, sizeof(nvr_path));
|
|
|
|
|
wp = config_get_wstring(cat, "nvr_path", L"");
|
|
|
|
|
if (wp != NULL) {
|
2017-05-27 03:53:32 +02:00
|
|
|
if (wcslen(wp) && (wcslen(wp) <= 992))
|
|
|
|
|
{
|
|
|
|
|
read_nvr_path = (wchar_t *) malloc((wcslen(wp) << 1) + 2);
|
|
|
|
|
wcscpy(read_nvr_path, wp);
|
|
|
|
|
wcscpy(nvr_path, wp);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
else
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
append_filename_w(nvr_path, pcempath, L"nvr\\", 511);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
else append_filename_w(nvr_path, pcempath, L"nvr\\", 511);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
if (nvr_path[wcslen(nvr_path) - 1] != L'/')
|
|
|
|
|
{
|
|
|
|
|
if (nvr_path[wcslen(nvr_path) - 1] != L'\\')
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
nvr_path[wcslen(nvr_path)] = L'\\';
|
2017-05-17 21:56:31 +02:00
|
|
|
nvr_path[wcslen(nvr_path) + 1] = L'\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path_len = wcslen(nvr_path);
|
|
|
|
|
|
|
|
|
|
#ifndef __unix
|
|
|
|
|
/* Currently, 86Box is English (US) only, but in the future (version 1.30 at the earliest) other languages will be added,
|
|
|
|
|
therefore it is better to future-proof the code. */
|
2017-05-18 01:57:16 -04:00
|
|
|
dwLanguage = config_get_hex16(cat, "language", 0x0409);
|
2017-05-17 21:56:31 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Machine */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_machine(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Machine";
|
2017-05-17 21:56:31 +02:00
|
|
|
char *p;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, "model", NULL);
|
|
|
|
|
if (p != NULL)
|
2017-05-08 04:54:17 +02:00
|
|
|
model = model_get_model_from_internal_name(p);
|
|
|
|
|
else
|
|
|
|
|
model = 0;
|
|
|
|
|
if (model >= model_count())
|
|
|
|
|
model = model_count() - 1;
|
|
|
|
|
|
|
|
|
|
romset = model_getromset();
|
2017-05-18 01:57:16 -04:00
|
|
|
cpu_manufacturer = config_get_int(cat, "cpu_manufacturer", 0);
|
|
|
|
|
cpu = config_get_int(cat, "cpu", 0);
|
|
|
|
|
cpu_waitstates = config_get_int(cat, "cpu_waitstates", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
mem_size = config_get_int(cat, "mem_size", 4096);
|
2017-05-17 21:56:31 +02:00
|
|
|
if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram))
|
|
|
|
|
mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram);
|
2017-05-29 01:18:32 +02:00
|
|
|
if (mem_size > 262144)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-29 01:18:32 +02:00
|
|
|
mem_size = 262144;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
cpu_use_dynarec = !!config_get_int(cat, "cpu_use_dynarec", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
enable_external_fpu = !!config_get_int(cat, "cpu_enable_fpu", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
enable_sync = !!config_get_int(cat, "enable_sync", 1);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Video */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_video(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Video";
|
2017-05-17 21:56:31 +02:00
|
|
|
char *p;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, "gfxcard", NULL);
|
|
|
|
|
if (p != NULL)
|
2017-05-08 04:54:17 +02:00
|
|
|
gfxcard = video_get_video_from_internal_name(p);
|
|
|
|
|
else
|
|
|
|
|
gfxcard = 0;
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
video_speed = config_get_int(cat, "video_speed", 3);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
voodoo_enabled = !!config_get_int(cat, "voodoo", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
/* Input devices */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_input_devices(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Input devices";
|
|
|
|
|
char temps[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
int c, d;
|
|
|
|
|
char *p;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, "mouse_type", NULL);
|
|
|
|
|
if (p != NULL)
|
2017-05-17 21:56:31 +02:00
|
|
|
mouse_type = mouse_get_from_internal_name(p);
|
|
|
|
|
else
|
|
|
|
|
mouse_type = 0;
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
joystick_type = config_get_int(cat, "joystick_type", 7);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
sprintf(temps, "joystick_%i_nr", c);
|
|
|
|
|
joystick_state[c].plat_joystick_nr = config_get_int(cat, temps, 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
if (joystick_state[c].plat_joystick_nr)
|
|
|
|
|
{
|
|
|
|
|
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
sprintf(temps, "joystick_%i_axis_%i", c, d);
|
|
|
|
|
joystick_state[c].axis_mapping[d] = config_get_int(cat, temps, d);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
sprintf(temps, "joystick_%i_button_%i", c, d);
|
|
|
|
|
joystick_state[c].button_mapping[d] = config_get_int(cat, temps, d);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
sprintf(temps, "joystick_%i_pov_%i", c, d);
|
|
|
|
|
p = config_get_string(cat, temps, "0, 0");
|
2017-05-17 21:56:31 +02: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]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Sound */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_sound(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Sound";
|
2017-05-27 03:53:32 +02:00
|
|
|
char temps[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
char *p;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, "sndcard", NULL);
|
|
|
|
|
if (p != NULL)
|
2017-05-08 04:54:17 +02:00
|
|
|
sound_card_current = sound_card_get_from_internal_name(p);
|
|
|
|
|
else
|
|
|
|
|
sound_card_current = 0;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
midi_id = config_get_int(cat, "midi_host_device", 0);
|
2017-06-03 20:32:58 +02:00
|
|
|
mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
SSI2001 = !!config_get_int(cat, "ssi2001", 0);
|
|
|
|
|
GAMEBLASTER = !!config_get_int(cat, "gameblaster", 0);
|
|
|
|
|
GUS = !!config_get_int(cat, "gus", 0);
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
memset(temps, '\0', sizeof(temps));
|
|
|
|
|
p = config_get_string(cat, "opl3_type", "dbopl");
|
|
|
|
|
if (p != NULL)
|
|
|
|
|
{
|
|
|
|
|
strcpy(temps, p);
|
|
|
|
|
}
|
2017-05-29 01:18:32 +02:00
|
|
|
if (!strcmp(temps, "nukedopl") || !strcmp(temps, "1"))
|
2017-05-27 03:53:32 +02:00
|
|
|
{
|
|
|
|
|
opl3_type = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
opl3_type = 0;
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Network */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_network(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Network";
|
2017-05-27 03:53:32 +02:00
|
|
|
char temps[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
char *p;
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
memset(temps, '\0', sizeof(temps));
|
|
|
|
|
p = config_get_string(cat, "net_type", "none");
|
|
|
|
|
if (p != NULL)
|
|
|
|
|
{
|
|
|
|
|
strcpy(temps, p);
|
|
|
|
|
}
|
2017-05-29 01:18:32 +02:00
|
|
|
if (!strcmp(temps, "slirp") || !strcmp(temps, "2"))
|
2017-05-27 03:53:32 +02:00
|
|
|
{
|
|
|
|
|
network_type = NET_TYPE_SLIRP;
|
|
|
|
|
}
|
2017-05-29 01:18:32 +02:00
|
|
|
else if (!strcmp(temps, "pcap") || !strcmp(temps, "1"))
|
2017-05-27 03:53:32 +02:00
|
|
|
{
|
|
|
|
|
network_type = NET_TYPE_PCAP;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
network_type = NET_TYPE_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(network_pcap, '\0', sizeof(network_pcap));
|
|
|
|
|
p = config_get_string(cat, "net_pcap_device", "none");
|
|
|
|
|
if (p != NULL)
|
|
|
|
|
if ((network_dev_to_id(p) == -1) || (network_ndev == 1))
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
if ((network_ndev == 1) && strcmp(network_pcap, "none"))
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-29 21:57:31 -04:00
|
|
|
msgbox_error(ghwnd, IDS_2107);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
else if (network_dev_to_id(p) == -1)
|
|
|
|
|
{
|
2017-05-29 21:57:31 -04:00
|
|
|
msgbox_error(ghwnd, IDS_2200);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
strcpy(network_pcap, "none");
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
else
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
strcpy(network_pcap, p);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
else
|
2017-05-18 01:57:16 -04:00
|
|
|
strcpy(network_pcap, "none");
|
|
|
|
|
p = config_get_string(cat, "net_card", NULL);
|
|
|
|
|
if (p != NULL)
|
|
|
|
|
network_card = network_card_get_from_internal_name(p);
|
|
|
|
|
else
|
|
|
|
|
network_card = 0;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Other peripherals */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_other_peripherals(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Other peripherals";
|
|
|
|
|
char temps[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
char *p;
|
2017-05-18 01:57:16 -04:00
|
|
|
int c;
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, "scsicard", NULL);
|
|
|
|
|
if (p != NULL)
|
2017-05-17 21:56:31 +02:00
|
|
|
scsi_card_current = scsi_card_get_from_internal_name(p);
|
|
|
|
|
else
|
|
|
|
|
scsi_card_current = 0;
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(hdd_controller_name, '\0', sizeof(hdd_controller_name));
|
|
|
|
|
p = config_get_string(cat, "hdd_controller", NULL);
|
|
|
|
|
if (p != NULL)
|
2017-05-17 21:56:31 +02:00
|
|
|
strcpy(hdd_controller_name, p);
|
2017-05-08 04:54:17 +02:00
|
|
|
else
|
2017-05-17 21:56:31 +02:00
|
|
|
strcpy(hdd_controller_name, "none");
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(temps, '\0', sizeof(temps));
|
2017-05-08 04:54:17 +02:00
|
|
|
for (c = 2; c < 4; c++)
|
|
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
sprintf(temps, "ide_%02i", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, temps, NULL);
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
p = "0, 00";
|
|
|
|
|
sscanf(p, "%i, %02i", &ide_enable[c], &ide_irq[c]);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
serial_enabled[0] = !!config_get_int(cat, "serial1_enabled", 1);
|
|
|
|
|
serial_enabled[1] = !!config_get_int(cat, "serial2_enabled", 1);
|
|
|
|
|
lpt_enabled = !!config_get_int(cat, "lpt_enabled", 1);
|
|
|
|
|
bugger_enabled = !!config_get_int(cat, "bugger_enabled", 0);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int config_string_to_bus(char *str, int cdrom)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp(str, "none"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_DISABLED;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "mfm"))
|
|
|
|
|
{
|
|
|
|
|
if (cdrom) goto no_mfm_cdrom;
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_MFM;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "rll"))
|
|
|
|
|
{
|
|
|
|
|
if (cdrom) goto no_mfm_cdrom;
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_RLL;
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
if (!strcmp(str, "esdi"))
|
|
|
|
|
{
|
|
|
|
|
if (cdrom) goto no_mfm_cdrom;
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_RLL;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "ide_pio_only"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_IDE_PIO_ONLY;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "ide"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_IDE_PIO_ONLY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "atapi_pio_only"))
|
|
|
|
|
{
|
|
|
|
|
return HDD_BUS_IDE_PIO_ONLY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "atapi"))
|
|
|
|
|
{
|
|
|
|
|
return HDD_BUS_IDE_PIO_ONLY;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "eide"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_IDE_PIO_ONLY;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "xtide"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_XTIDE;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "atide"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_IDE_PIO_ONLY;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "ide_pio_and_dma"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_IDE_PIO_AND_DMA;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "atapi_pio_and_dma"))
|
|
|
|
|
{
|
|
|
|
|
return HDD_BUS_IDE_PIO_AND_DMA;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "scsi"))
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
return HDD_BUS_SCSI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "removable"))
|
|
|
|
|
{
|
|
|
|
|
if (cdrom) goto no_mfm_cdrom;
|
|
|
|
|
|
|
|
|
|
return HDD_BUS_SCSI_REMOVABLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "scsi_removable"))
|
|
|
|
|
{
|
|
|
|
|
if (cdrom) goto no_mfm_cdrom;
|
|
|
|
|
|
|
|
|
|
return HDD_BUS_SCSI_REMOVABLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "removable_scsi"))
|
|
|
|
|
{
|
|
|
|
|
if (cdrom) goto no_mfm_cdrom;
|
|
|
|
|
|
|
|
|
|
return HDD_BUS_SCSI_REMOVABLE;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp(str, "usb"))
|
|
|
|
|
{
|
2017-05-29 21:57:31 -04:00
|
|
|
msgbox_error(ghwnd, IDS_2199);
|
2017-05-17 21:56:31 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
no_mfm_cdrom:
|
2017-05-29 21:57:31 -04:00
|
|
|
msgbox_error(ghwnd, IDS_2095);
|
2017-05-17 21:56:31 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
static int hard_disk_is_valid(int c)
|
|
|
|
|
{
|
|
|
|
|
if (hdc[c].bus == HDD_BUS_DISABLED)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((wcslen(hdc[c].fn) == 0) && (hdc[c].bus != HDD_BUS_SCSI_REMOVABLE))
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((hdc[c].tracks == 0) || (hdc[c].hpc == 0) || (hdc[c].spt == 0))
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-05-29 01:18:32 +02:00
|
|
|
static int tally_char(char *string, char c)
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
int tally = 0;
|
|
|
|
|
|
|
|
|
|
if (string == NULL)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strlen(string) == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < strlen(string); i++)
|
|
|
|
|
{
|
|
|
|
|
if (string[i] == c)
|
|
|
|
|
{
|
|
|
|
|
tally++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tally;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
/* Hard disks */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_hard_disks(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Hard disks";
|
|
|
|
|
char temps[512];
|
|
|
|
|
char temps2[512];
|
|
|
|
|
char s[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
int c;
|
|
|
|
|
char *p;
|
|
|
|
|
wchar_t *wp;
|
2017-05-27 03:53:32 +02:00
|
|
|
int max_spt, max_hpc, max_tracks;
|
|
|
|
|
int board = 0, dev = 0;
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(temps, '\0', sizeof(temps));
|
2017-05-08 04:54:17 +02:00
|
|
|
for (c = 0; c < HDC_NUM; c++)
|
|
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
sprintf(temps, "hdd_%02i_parameters", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, temps, NULL);
|
|
|
|
|
if (p == NULL)
|
2017-05-27 03:53:32 +02:00
|
|
|
p = "0, 0, 0, 0, none";
|
2017-05-29 01:18:32 +02:00
|
|
|
if (tally_char(p, ',') == 3)
|
|
|
|
|
{
|
|
|
|
|
sscanf(p, "%" PRIu64 ", %" PRIu64", %" PRIu64 ", %s", &hdc[c].spt, &hdc[c].hpc, &hdc[c].tracks, s);
|
|
|
|
|
hdc[c].wp = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sscanf(p, "%" PRIu64 ", %" PRIu64", %" PRIu64 ", %i, %s", &hdc[c].spt, &hdc[c].hpc, &hdc[c].tracks, &hdc[c].wp, s);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
hdc[c].bus = config_string_to_bus(s, 0);
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
switch(hdc[c].bus)
|
|
|
|
|
{
|
|
|
|
|
case HDD_BUS_DISABLED:
|
|
|
|
|
default:
|
|
|
|
|
max_spt = max_hpc = max_tracks = 0;
|
|
|
|
|
break;
|
|
|
|
|
case HDD_BUS_MFM:
|
|
|
|
|
max_spt = 17;
|
|
|
|
|
max_hpc = 15;
|
|
|
|
|
max_tracks = 1023;
|
|
|
|
|
break;
|
|
|
|
|
case HDD_BUS_RLL:
|
|
|
|
|
case HDD_BUS_XTIDE:
|
|
|
|
|
max_spt = 63;
|
|
|
|
|
max_hpc = 16;
|
|
|
|
|
max_tracks = 1023;
|
|
|
|
|
break;
|
|
|
|
|
case HDD_BUS_IDE_PIO_ONLY:
|
|
|
|
|
case HDD_BUS_IDE_PIO_AND_DMA:
|
|
|
|
|
max_spt = 63;
|
|
|
|
|
max_hpc = 16;
|
|
|
|
|
max_tracks = 266305;
|
|
|
|
|
break;
|
|
|
|
|
case HDD_BUS_SCSI:
|
|
|
|
|
case HDD_BUS_SCSI_REMOVABLE:
|
|
|
|
|
max_spt = 99;
|
|
|
|
|
max_hpc = 255;
|
|
|
|
|
max_tracks = 266305;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hdc[c].spt > max_spt)
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
hdc[c].spt = max_spt;
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
if (hdc[c].hpc > max_hpc)
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
hdc[c].hpc = max_hpc;
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
if (hdc[c].tracks > max_tracks)
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
hdc[c].tracks = max_tracks;
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
/* MFM */
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "hdd_%02i_mfm_channel", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (hdc[c].bus == HDD_BUS_MFM)
|
|
|
|
|
{
|
|
|
|
|
hdc[c].mfm_channel = !!config_get_int(cat, temps, c & 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XT IDE */
|
|
|
|
|
sprintf(temps, "hdd_%02i_xtide_channel", c + 1);
|
|
|
|
|
if (hdc[c].bus == HDD_BUS_XTIDE)
|
|
|
|
|
{
|
|
|
|
|
hdc[c].xtide_channel = !!config_get_int(cat, temps, c & 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* RLL (ESDI) */
|
|
|
|
|
sprintf(temps, "hdd_%02i_rll_channel", c + 1);
|
|
|
|
|
if (hdc[c].bus == HDD_BUS_RLL)
|
|
|
|
|
{
|
|
|
|
|
hdc[c].rll_channel = !!config_get_int(cat, temps, c & 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
config_delete_var(cat, temps);
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
/* IDE */
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "hdd_%02i_ide_channel", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if ((hdc[c].bus == HDD_BUS_IDE_PIO_ONLY) || (hdc[c].bus == HDD_BUS_IDE_PIO_AND_DMA))
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps2, "%01u:%01u", c >> 1, c & 1);
|
|
|
|
|
p = config_get_string(cat, temps, temps2);
|
|
|
|
|
|
2017-05-29 01:18:32 +02:00
|
|
|
if (strstr(p, ":") == NULL)
|
|
|
|
|
{
|
|
|
|
|
sscanf(p, "%i", &hdc[c].ide_channel);
|
|
|
|
|
hdc[c].ide_channel &= 7;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sscanf(p, "%01u:%01u", &board, &dev);
|
|
|
|
|
|
|
|
|
|
board &= 3;
|
|
|
|
|
dev &= 1;
|
|
|
|
|
hdc[c].ide_channel = (board << 1) + dev;
|
|
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
if (hdc[c].ide_channel > 7)
|
|
|
|
|
{
|
|
|
|
|
hdc[c].ide_channel = 7;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
config_delete_var(cat, temps);
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
/* SCSI */
|
2017-05-17 21:56:31 +02:00
|
|
|
sprintf(temps, "hdd_%02i_scsi_location", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if ((hdc[c].bus == HDD_BUS_SCSI) || (hdc[c].bus == HDD_BUS_SCSI_REMOVABLE))
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
sprintf(temps2, "%02u:%02u", c, 0);
|
|
|
|
|
p = config_get_string(cat, temps, temps2);
|
2017-05-29 01:18:32 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
sscanf(p, "%02u:%02u", &hdc[c].scsi_id, &hdc[c].scsi_lun);
|
|
|
|
|
|
|
|
|
|
if (hdc[c].scsi_id > 15)
|
|
|
|
|
{
|
|
|
|
|
hdc[c].scsi_id = 15;
|
|
|
|
|
}
|
|
|
|
|
if (hdc[c].scsi_lun > 7)
|
|
|
|
|
{
|
|
|
|
|
hdc[c].scsi_lun = 7;
|
|
|
|
|
}
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
else
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
config_delete_var(cat, temps);
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
memset(hdc[c].fn, 0, sizeof(hdc[c].fn));
|
|
|
|
|
memset(hdc[c].prev_fn, 0, sizeof(hdc[c].prev_fn));
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "hdd_%02i_fn", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
wp = config_get_wstring(cat, temps, L"");
|
2017-05-27 03:53:32 +02:00
|
|
|
memcpy(hdc[c].fn, wp, (wcslen(wp) << 1) + 2);
|
|
|
|
|
|
|
|
|
|
/* If the hard disk is in any way empty or invalid, mark the relevant variables for deletion. */
|
|
|
|
|
if (!hard_disk_is_valid(c))
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "hdd_%02i_parameters", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_preide_channels", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_ide_channels", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_scsi_location", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_fn", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_mfm_channel", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_ide_channel", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Removable devices */
|
2017-05-17 21:56:31 +02:00
|
|
|
static void loadconfig_removable_devices(void)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Removable devices";
|
|
|
|
|
char temps[512];
|
|
|
|
|
char temps2[512];
|
|
|
|
|
char s[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
int c;
|
|
|
|
|
char *p;
|
|
|
|
|
wchar_t *wp;
|
2017-05-27 03:53:32 +02:00
|
|
|
unsigned int board = 0, dev = 0;
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
for (c = 0; c < FDD_NUM; c++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "fdd_%02i_type", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, temps, (c < 2) ? "525_2dd" : "none");
|
2017-05-18 21:51:11 +02:00
|
|
|
fdd_set_type(c, fdd_get_from_internal_name(p));
|
2017-05-17 21:56:31 +02:00
|
|
|
if (fdd_get_type(c) > 13)
|
|
|
|
|
{
|
|
|
|
|
fdd_set_type(c, 13);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "fdd_%02i_fn", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
wp = config_get_wstring(cat, temps, L"");
|
2017-05-18 21:51:11 +02:00
|
|
|
memcpy(discfns[c], wp, (wcslen(wp) << 1) + 2);
|
2017-05-17 21:56:31 +02:00
|
|
|
printf("Floppy: %ws\n", discfns[c]);
|
|
|
|
|
sprintf(temps, "fdd_%02i_writeprot", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
ui_writeprot[c] = !!config_get_int(cat, temps, 0);
|
2017-06-04 02:14:27 +02:00
|
|
|
sprintf(temps, "fdd_%02i_turbo", c + 1);
|
|
|
|
|
fdd_set_turbo(c, !!config_get_int(cat, temps, 0));
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
/* 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))
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "fdd_%02i_type", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wcslen(discfns[c]) == 0)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "fdd_%02i_fn", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ui_writeprot[c] == 0)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "fdd_%02i_writeprot", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
2017-06-04 02:14:27 +02:00
|
|
|
|
|
|
|
|
if (fdd_get_turbo(c) == 0)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "fdd_%02i_turbo", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(temps, 0, 512);
|
2017-05-08 04:54:17 +02:00
|
|
|
for (c = 0; c < CDROM_NUM; c++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "cdrom_%02i_host_drive", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
cdrom_drives[c].host_drive = config_get_int(cat, temps, 0);
|
2017-05-08 04:54:17 +02:00
|
|
|
cdrom_drives[c].prev_host_drive = cdrom_drives[c].host_drive;
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_parameters", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
p = config_get_string(cat, temps, NULL);
|
|
|
|
|
if (p != NULL)
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
sscanf(p, "%u, %s", &cdrom_drives[c].sound_on, s);
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sscanf("0, none", "%u, %s", &cdrom_drives[c].sound_on, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cdrom_drives[c].bus_type = config_string_to_bus(s, 1);
|
|
|
|
|
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "cdrom_%02i_ide_channel", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if ((cdrom_drives[c].bus_type == CDROM_BUS_ATAPI_PIO_ONLY) || (cdrom_drives[c].bus_type == CDROM_BUS_ATAPI_PIO_AND_DMA))
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
sprintf(temps2, "%01u:%01u", (c + 2) >> 1, (c + 2) & 1);
|
|
|
|
|
p = config_get_string(cat, temps, temps2);
|
|
|
|
|
|
2017-05-29 01:18:32 +02:00
|
|
|
if (strstr(p, ":") == NULL)
|
|
|
|
|
{
|
|
|
|
|
sscanf(p, "%i", &hdc[c].ide_channel);
|
|
|
|
|
cdrom_drives[c].ide_channel &= 7;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sscanf(p, "%02u:%02u", &board, &dev);
|
|
|
|
|
|
|
|
|
|
board &= 3;
|
|
|
|
|
dev &= 1;
|
|
|
|
|
cdrom_drives[c].ide_channel = (board << 1) + dev;
|
|
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
if (cdrom_drives[c].ide_channel > 7)
|
|
|
|
|
{
|
|
|
|
|
cdrom_drives[c].ide_channel = 7;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_scsi_location", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (cdrom_drives[c].bus_type == CDROM_BUS_SCSI)
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
sprintf(temps2, "%02u:%02u", c + 2, 0);
|
|
|
|
|
p = config_get_string(cat, temps, temps2);
|
|
|
|
|
sscanf(p, "%02u:%02u", &cdrom_drives[c].scsi_device_id, &cdrom_drives[c].scsi_device_lun);
|
|
|
|
|
|
|
|
|
|
if (cdrom_drives[c].scsi_device_id > 15)
|
|
|
|
|
{
|
|
|
|
|
cdrom_drives[c].scsi_device_id = 15;
|
|
|
|
|
}
|
|
|
|
|
if (cdrom_drives[c].scsi_device_lun > 7)
|
|
|
|
|
{
|
|
|
|
|
cdrom_drives[c].scsi_device_lun = 7;
|
|
|
|
|
}
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
else
|
2017-05-10 02:46:01 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
config_delete_var(cat, temps);
|
2017-05-10 02:46:01 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_image_path", c + 1);
|
2017-05-18 01:57:16 -04:00
|
|
|
wp = config_get_wstring(cat, temps, L"");
|
2017-05-18 21:51:11 +02:00
|
|
|
memcpy(cdrom_image[c].image_path, wp, (wcslen(wp) << 1) + 2);
|
2017-05-27 03:53:32 +02:00
|
|
|
|
2017-06-01 01:47:54 +02:00
|
|
|
if (cdrom_drives[c].host_drive < 'A')
|
|
|
|
|
{
|
|
|
|
|
cdrom_drives[c].host_drive = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((cdrom_drives[c].host_drive == 0x200) && (wcslen(cdrom_image[c].image_path) == 0))
|
2017-05-27 03:53:32 +02:00
|
|
|
{
|
|
|
|
|
cdrom_drives[c].host_drive = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the CD-ROM is disabled, delete all its variables. */
|
|
|
|
|
if (cdrom_drives[c].bus_type == CDROM_BUS_DISABLED)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "cdrom_%02i_host_drive", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_parameters", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_ide_channel", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_scsi_location", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_image_path", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_iso_path", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
void loadconfig(wchar_t *fn)
|
|
|
|
|
{
|
2017-06-01 01:47:54 +02:00
|
|
|
int i = 0;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
if (fn == NULL)
|
|
|
|
|
fn = config_file_default;
|
2017-06-01 01:47:54 +02:00
|
|
|
i = config_load(fn);
|
|
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
|
|
|
|
cpu = 0;
|
|
|
|
|
#ifndef __unix
|
|
|
|
|
dwLanguage = 0x0409;
|
|
|
|
|
#endif
|
|
|
|
|
scale = 1;
|
|
|
|
|
vid_api = 1;
|
|
|
|
|
enable_sync = 1;
|
|
|
|
|
joystick_type = 7;
|
|
|
|
|
strcpy(hdd_controller_name, "none");
|
|
|
|
|
serial_enabled[0] = 1;
|
|
|
|
|
serial_enabled[1] = 1;
|
|
|
|
|
lpt_enabled = 1;
|
|
|
|
|
fdd_set_type(0, 2);
|
|
|
|
|
fdd_set_type(1, 2);
|
|
|
|
|
mem_size = 640;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* General */
|
|
|
|
|
loadconfig_general();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Machine */
|
|
|
|
|
loadconfig_machine();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Video */
|
|
|
|
|
loadconfig_video();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Input devices */
|
|
|
|
|
loadconfig_input_devices();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Sound */
|
|
|
|
|
loadconfig_sound();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Network */
|
|
|
|
|
loadconfig_network();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Other peripherals */
|
|
|
|
|
loadconfig_other_peripherals();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Hard disks */
|
|
|
|
|
loadconfig_hard_disks();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Removable devices */
|
|
|
|
|
loadconfig_removable_devices();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wchar_t *nvr_concat(wchar_t *to_concat)
|
|
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
static wchar_t temp_nvr_path[1024];
|
2017-05-08 04:54:17 +02:00
|
|
|
char *p;
|
2017-05-17 21:56:31 +02:00
|
|
|
wchar_t *wp;
|
2017-05-08 04:54:17 +02:00
|
|
|
|
|
|
|
|
memset(temp_nvr_path, 0, 2048);
|
|
|
|
|
wcscpy(temp_nvr_path, nvr_path);
|
|
|
|
|
|
|
|
|
|
p = (char *) temp_nvr_path;
|
|
|
|
|
p += (path_len * 2);
|
2017-05-17 21:56:31 +02:00
|
|
|
wp = (wchar_t *) p;
|
2017-05-08 04:54:17 +02:00
|
|
|
|
|
|
|
|
wcscpy(wp, to_concat);
|
|
|
|
|
return temp_nvr_path;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
static void saveconfig_general(void)
|
2017-05-08 04:54:17 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "General";
|
|
|
|
|
char temps[512];
|
|
|
|
|
|
|
|
|
|
config_set_int(cat, "vid_resize", vid_resize);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (vid_resize == 0)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
config_delete_var(cat, "vid_resize");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vid_api == 1)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "vid_renderer");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch(vid_api)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
config_set_string(cat, "vid_renderer", "ddraw");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
default:
|
|
|
|
|
config_set_string(cat, "vid_renderer", "d3d9");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (video_fullscreen_scale == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "video_fullscreen_scale");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "video_fullscreen_scale", video_fullscreen_scale);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-01 01:47:54 +02:00
|
|
|
if (video_fullscreen_first == 0)
|
2017-05-27 03:53:32 +02:00
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "video_fullscreen_first");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "video_fullscreen_first", video_fullscreen_first);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (force_43 == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "force_43");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "force_43", force_43);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scale == 1)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "scale");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "scale", scale);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (enable_overscan == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "enable_overscan");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "enable_overscan", enable_overscan);
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-06-01 17:52:39 +02:00
|
|
|
if (vid_cga_contrast == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "vid_cga_contrast");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "vid_cga_contrast", vid_cga_contrast);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (window_remember)
|
|
|
|
|
{
|
2017-06-01 17:52:39 +02:00
|
|
|
config_set_int(cat, "window_remember", window_remember);
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
sprintf(temps, "%i, %i, %i, %i", window_w, window_h, window_x, window_y);
|
|
|
|
|
config_set_string(cat, "window_coordinates", temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "window_remember");
|
|
|
|
|
config_delete_var(cat, "window_coordinates");
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (read_nvr_path == NULL)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "nvr_path");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_wstring(cat, "nvr_path", nvr_path);
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
#ifndef __unix
|
2017-05-27 03:53:32 +02:00
|
|
|
if (dwLanguage == 0x0409)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "language");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_hex16(cat, "language", dwLanguage);
|
|
|
|
|
}
|
2017-05-12 05:05:20 -04:00
|
|
|
#endif
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Machine */
|
|
|
|
|
static void saveconfig_machine(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Machine";
|
|
|
|
|
|
|
|
|
|
config_set_string(cat, "model", model_get_internal_name());
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (cpu_manufacturer == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "cpu_manufacturer");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "cpu_manufacturer", cpu_manufacturer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cpu == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "cpu");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "cpu", cpu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cpu_waitstates == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "cpu_waitstates");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "cpu_waitstates", cpu_waitstates);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mem_size == 4096)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "mem_size");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "mem_size", mem_size);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
config_set_int(cat, "cpu_use_dynarec", cpu_use_dynarec);
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
if (enable_external_fpu == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "cpu_enable_fpu");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "cpu_enable_fpu", enable_external_fpu);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-29 01:18:32 +02:00
|
|
|
if (enable_sync == 1)
|
2017-05-27 03:53:32 +02:00
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "enable_sync");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "enable_sync", enable_sync);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Video */
|
|
|
|
|
static void saveconfig_video(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Video";
|
|
|
|
|
|
|
|
|
|
config_set_string(cat, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard)));
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
if (video_speed == 3)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "video_speed");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "video_speed", video_speed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (voodoo_enabled == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "voodoo");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "voodoo", voodoo_enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Input devices */
|
|
|
|
|
static void saveconfig_input_devices(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Input devices";
|
|
|
|
|
char temps[512];
|
|
|
|
|
char s[512];
|
2017-05-17 21:56:31 +02:00
|
|
|
int c, d;
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
config_set_string(cat, "mouse_type", mouse_get_internal_name(mouse_type));
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if ((joystick_type == 0) || (joystick_type == 7))
|
|
|
|
|
{
|
|
|
|
|
if (joystick_type == 7)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "joystick_type");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "joystick_type", joystick_type);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
for (c = 0; c < 16; c++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_nr", c);
|
|
|
|
|
config_delete_var(cat, s);
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
for (d = 0; d < 16; d++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_axis_%i", c, d);
|
|
|
|
|
config_delete_var(cat, s);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
for (d = 0; d < 16; d++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_button_%i", c, d);
|
|
|
|
|
config_delete_var(cat, s);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
for (d = 0; d < 16; d++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_pov_%i", c, d);
|
|
|
|
|
config_delete_var(cat, s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "joystick_type", joystick_type);
|
|
|
|
|
|
|
|
|
|
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_nr", c);
|
|
|
|
|
config_set_int(cat, s, joystick_state[c].plat_joystick_nr);
|
|
|
|
|
|
|
|
|
|
if (joystick_state[c].plat_joystick_nr)
|
|
|
|
|
{
|
|
|
|
|
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_axis_%i", c, d);
|
|
|
|
|
config_set_int(cat, s, joystick_state[c].axis_mapping[d]);
|
|
|
|
|
}
|
|
|
|
|
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_button_%i", c, d);
|
|
|
|
|
config_set_int(cat, s, joystick_state[c].button_mapping[d]);
|
|
|
|
|
}
|
|
|
|
|
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(s, "joystick_%i_pov_%i", c, d);
|
|
|
|
|
sprintf(temps, "%i, %i", joystick_state[c].pov_mapping[d][0], joystick_state[c].pov_mapping[d][1]);
|
|
|
|
|
config_set_string(cat, s, temps);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Sound */
|
|
|
|
|
static void saveconfig_sound(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Sound";
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (sound_card_current == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "sndcard");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_string(cat, "sndcard", sound_card_get_internal_name(sound_card_current));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (midi_id == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "midi_host_device");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "midi_host_device", midi_id);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-03 20:32:58 +02:00
|
|
|
if (mpu401_standalone_enable == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "mpu401_standalone");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (SSI2001 == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "ssi2001");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "ssi2001", SSI2001);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GAMEBLASTER == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "gameblaster");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "gameblaster", GAMEBLASTER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUS == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "gus");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "gus", GUS);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (opl3_type == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "opl3_type");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_string(cat, "opl3_type", (opl3_type == 1) ? "nukedopl" : "dbopl");
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Network */
|
|
|
|
|
static void saveconfig_network(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Network";
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (network_type == NET_TYPE_NONE)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "net_type");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-29 01:18:32 +02:00
|
|
|
config_set_string(cat, "net_type", (network_type == NET_TYPE_SLIRP) ? "slirp" : "pcap");
|
2017-05-27 03:53:32 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
if (network_pcap[0] != '\0')
|
2017-05-08 04:54:17 +02:00
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
if (!strcmp(network_pcap, "none"))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "net_pcap_device");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_string(cat, "net_pcap_device", network_pcap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* config_set_string(cat, "net_pcap_device", "none"); */
|
|
|
|
|
config_delete_var(cat, "net_pcap_device");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (network_card == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "net_card");
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
else
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
config_set_string(cat, "net_card", network_card_get_internal_name(network_card));
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Other peripherals */
|
|
|
|
|
static void saveconfig_other_peripherals(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Other peripherals";
|
|
|
|
|
char temps[512];
|
|
|
|
|
char temps2[512];
|
2017-05-27 03:53:32 +02:00
|
|
|
int c;
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (scsi_card_current == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "scsicard");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_string(cat, "scsicard", scsi_card_get_internal_name(scsi_card_current));
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (!strcmp(hdd_controller_name, "none"))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "hdd_controller");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_string(cat, "hdd_controller", hdd_controller_name);
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(temps, '\0', sizeof(temps));
|
2017-05-08 04:54:17 +02:00
|
|
|
for (c = 2; c < 4; c++)
|
|
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
sprintf(temps, "ide_%02i", c + 1);
|
|
|
|
|
sprintf(temps2, "%i, %02i", !!ide_enable[c], ide_irq[c]);
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
if (ide_enable[c] == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_string(cat, temps, temps2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (serial_enabled[0])
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "serial1_enabled");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "serial1_enabled", serial_enabled[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (serial_enabled[1])
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "serial2_enabled");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "serial2_enabled", serial_enabled[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lpt_enabled)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "lpt_enabled");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "lpt_enabled", lpt_enabled);
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
if (bugger_enabled == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, "bugger_enabled");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, "bugger_enabled", bugger_enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
static char *config_bus_to_string(int bus, int cdrom)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
|
|
|
|
switch (bus)
|
|
|
|
|
{
|
2017-05-27 03:53:32 +02:00
|
|
|
case HDD_BUS_DISABLED:
|
2017-05-17 21:56:31 +02:00
|
|
|
default:
|
|
|
|
|
return "none";
|
|
|
|
|
break;
|
2017-05-27 03:53:32 +02:00
|
|
|
case HDD_BUS_MFM:
|
2017-05-17 21:56:31 +02:00
|
|
|
return "mfm";
|
|
|
|
|
break;
|
2017-05-27 03:53:32 +02:00
|
|
|
case HDD_BUS_XTIDE:
|
|
|
|
|
return "xtide";
|
2017-05-17 21:56:31 +02:00
|
|
|
break;
|
2017-05-27 03:53:32 +02:00
|
|
|
case HDD_BUS_RLL:
|
|
|
|
|
return "rll";
|
2017-05-17 21:56:31 +02:00
|
|
|
break;
|
2017-05-27 03:53:32 +02:00
|
|
|
case HDD_BUS_IDE_PIO_ONLY:
|
|
|
|
|
return cdrom ? "atapi_pio_only" : "ide_pio_only";
|
|
|
|
|
break;
|
|
|
|
|
case HDD_BUS_IDE_PIO_AND_DMA:
|
|
|
|
|
return cdrom ? "atapi_pio_and_dma" : "ide_pio_and_dma";
|
|
|
|
|
break;
|
|
|
|
|
case HDD_BUS_SCSI:
|
2017-05-17 21:56:31 +02:00
|
|
|
return "scsi";
|
|
|
|
|
break;
|
2017-05-27 03:53:32 +02:00
|
|
|
case HDD_BUS_SCSI_REMOVABLE:
|
|
|
|
|
return "scsi_removable";
|
|
|
|
|
break;
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Hard disks */
|
|
|
|
|
static void saveconfig_hard_disks(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Hard disks";
|
2017-05-27 03:53:32 +02:00
|
|
|
char temps[24];
|
|
|
|
|
char temps2[64];
|
2017-05-18 01:57:16 -04:00
|
|
|
char s[512];
|
2017-05-27 03:53:32 +02:00
|
|
|
int c;
|
2017-05-17 21:56:31 +02:00
|
|
|
char *p;
|
|
|
|
|
|
2017-05-27 03:53:32 +02:00
|
|
|
memset(temps, 0, sizeof(temps));
|
2017-05-08 04:54:17 +02:00
|
|
|
for (c = 0; c < HDC_NUM; c++)
|
|
|
|
|
{
|
2017-05-17 21:56:31 +02:00
|
|
|
sprintf(temps, "hdd_%02i_parameters", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
memset(s, 0, sizeof(s));
|
|
|
|
|
if (!hard_disk_is_valid(c))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
p = config_bus_to_string(hdc[c].bus, 0);
|
|
|
|
|
sprintf(temps2, "%" PRIu64 ", %" PRIu64", %" PRIu64 ", %i, %s", hdc[c].spt, hdc[c].hpc, hdc[c].tracks, hdc[c].wp, p);
|
|
|
|
|
config_set_string(cat, temps, temps2);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "hdd_%02i_mfm_channel", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (!hard_disk_is_valid(c) || (hdc[c].bus != HDD_BUS_MFM))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, temps, hdc[c].mfm_channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_xtide_channel", c + 1);
|
|
|
|
|
if (!hard_disk_is_valid(c) || (hdc[c].bus != HDD_BUS_XTIDE))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, temps, hdc[c].xtide_channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_rll_channel", c + 1);
|
|
|
|
|
if (!hard_disk_is_valid(c) || (hdc[c].bus != HDD_BUS_RLL))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, temps, hdc[c].rll_channel);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "hdd_%02i_ide_channel", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (!hard_disk_is_valid(c) || ((hdc[c].bus != HDD_BUS_IDE_PIO_ONLY) && (hdc[c].bus != HDD_BUS_IDE_PIO_AND_DMA)))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps2, "%01u:%01u", hdc[c].ide_channel >> 1, hdc[c].ide_channel & 1);
|
|
|
|
|
config_set_string(cat, temps, temps2);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "hdd_%02i_scsi_location", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (!hard_disk_is_valid(c) || ((hdc[c].bus != HDD_BUS_SCSI) && (hdc[c].bus != HDD_BUS_SCSI_REMOVABLE)))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps2, "%02u:%02u", hdc[c].scsi_id, hdc[c].scsi_lun);
|
|
|
|
|
config_set_string(cat, temps, temps2);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "hdd_%02i_fn", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (!hard_disk_is_valid(c) || (wcslen(hdc[c].fn) == 0))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_wstring(cat, temps, hdc[c].fn);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
|
|
|
|
/* Removable devices */
|
|
|
|
|
static void saveconfig_removable_devices(void)
|
2017-05-17 21:56:31 +02:00
|
|
|
{
|
2017-05-18 01:57:16 -04:00
|
|
|
char *cat = "Removable devices";
|
|
|
|
|
char temps[512];
|
|
|
|
|
char temps2[512];
|
2017-05-27 03:53:32 +02:00
|
|
|
int c;
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(temps, '\0', sizeof(temps));
|
2017-05-17 21:56:31 +02:00
|
|
|
for (c = 0; c < FDD_NUM; c++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "fdd_%02i_type", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (fdd_get_type(c) == ((c < 2) ? 2 : 0))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_string(cat, temps, fdd_get_internal_name(fdd_get_type(c)));
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
sprintf(temps, "fdd_%02i_fn", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (wcslen(discfns[c]) == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
|
|
|
|
|
ui_writeprot[c] = 0;
|
|
|
|
|
|
|
|
|
|
sprintf(temps, "fdd_%02i_writeprot", c + 1);
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_wstring(cat, temps, discfns[c]);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
sprintf(temps, "fdd_%02i_writeprot", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (ui_writeprot[c] == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, temps, ui_writeprot[c]);
|
|
|
|
|
}
|
2017-06-04 02:14:27 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "fdd_%02i_turbo", c + 1);
|
|
|
|
|
if (fdd_get_turbo(c) == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, temps, fdd_get_turbo(c));
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
memset(temps, '\0', sizeof(temps));
|
2017-05-08 04:54:17 +02:00
|
|
|
for (c = 0; c < CDROM_NUM; c++)
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps, "cdrom_%02i_host_drive", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if ((cdrom_drives[c].bus_type == 0) || (cdrom_drives[c].host_drive < 'A') || ((cdrom_drives[c].host_drive > 'Z') && (cdrom_drives[c].host_drive != 200)))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_int(cat, temps, cdrom_drives[c].host_drive);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_parameters", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (cdrom_drives[c].bus_type == 0)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps2, "%u, %s", cdrom_drives[c].sound_on, config_bus_to_string(cdrom_drives[c].bus_type, 1));
|
|
|
|
|
config_set_string(cat, temps, temps2);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-08 04:54:17 +02:00
|
|
|
sprintf(temps, "cdrom_%02i_ide_channel", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if ((cdrom_drives[c].bus_type != CDROM_BUS_ATAPI_PIO_ONLY) && (cdrom_drives[c].bus_type != CDROM_BUS_ATAPI_PIO_AND_DMA))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps2, "%01u:%01u", cdrom_drives[c].ide_channel >> 1, cdrom_drives[c].ide_channel & 1);
|
|
|
|
|
config_set_string(cat, temps, temps2);
|
|
|
|
|
}
|
2017-05-17 21:56:31 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_scsi_location", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if (cdrom_drives[c].bus_type != CDROM_BUS_SCSI)
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf(temps2, "%02u:%02u", cdrom_drives[c].scsi_device_id, cdrom_drives[c].scsi_device_lun);
|
|
|
|
|
config_set_string(cat, temps, temps2);
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
|
|
|
|
sprintf(temps, "cdrom_%02i_image_path", c + 1);
|
2017-05-27 03:53:32 +02:00
|
|
|
if ((cdrom_drives[c].bus_type == 0) || (wcslen(cdrom_image[c].image_path) == 0))
|
|
|
|
|
{
|
|
|
|
|
config_delete_var(cat, temps);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
config_set_wstring(cat, temps, cdrom_image[c].image_path);
|
|
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
}
|
2017-05-27 03:53:32 +02:00
|
|
|
|
|
|
|
|
config_delete_section_if_empty(cat);
|
2017-05-17 21:56:31 +02:00
|
|
|
}
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
void saveconfig(void)
|
|
|
|
|
{
|
|
|
|
|
/* General */
|
|
|
|
|
saveconfig_general();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Machine */
|
|
|
|
|
saveconfig_machine();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Video */
|
|
|
|
|
saveconfig_video();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Input devices */
|
|
|
|
|
saveconfig_input_devices();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Sound */
|
|
|
|
|
saveconfig_sound();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Network */
|
|
|
|
|
saveconfig_network();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Other peripherals */
|
|
|
|
|
saveconfig_other_peripherals();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-17 21:56:31 +02:00
|
|
|
/* Hard disks */
|
|
|
|
|
saveconfig_hard_disks();
|
|
|
|
|
|
|
|
|
|
/* Removable devices */
|
|
|
|
|
saveconfig_removable_devices();
|
2017-05-08 04:54:17 +02:00
|
|
|
|
|
|
|
|
config_save(config_file_default);
|
|
|
|
|
}
|