Redid device instantiation, now the ISA memory boards can be configured without having to restart the emulator first.
This commit is contained in:
160
src/device.c
160
src/device.c
@@ -9,7 +9,7 @@
|
||||
* Implementation of the generic device interface to handle
|
||||
* all devices attached to the emulator.
|
||||
*
|
||||
* Version: @(#)device.c 1.0.20 2018/10/17
|
||||
* Version: @(#)device.c 1.0.21 2018/10/23
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -54,17 +54,9 @@
|
||||
#define DEVICE_MAX 256 /* max # of devices */
|
||||
|
||||
|
||||
typedef struct clonedev {
|
||||
const device_t *master;
|
||||
int count;
|
||||
struct clonedev *next;
|
||||
} clonedev_t;
|
||||
|
||||
|
||||
static device_t *devices[DEVICE_MAX];
|
||||
static void *device_priv[DEVICE_MAX];
|
||||
static device_t *device_current;
|
||||
static clonedev_t *clones = NULL;
|
||||
static device_context_t device_current;
|
||||
|
||||
|
||||
#ifdef ENABLE_DEVICE_LOG
|
||||
@@ -86,75 +78,33 @@ device_log(const char *fmt, ...)
|
||||
#define device_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
|
||||
/* Initialize the module for use. */
|
||||
void
|
||||
device_init(void)
|
||||
{
|
||||
clonedev_t *ptr;
|
||||
|
||||
memset(devices, 0x00, sizeof(devices));
|
||||
|
||||
ptr = NULL;
|
||||
while (clones != NULL) {
|
||||
ptr = clones->next;
|
||||
free(clones);
|
||||
clones = ptr;
|
||||
}
|
||||
|
||||
clones = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Clone a master device for multi-instance devices. */
|
||||
const device_t *
|
||||
device_clone(const device_t *master)
|
||||
void
|
||||
device_set_context(device_context_t *c, const device_t *d, int inst)
|
||||
{
|
||||
char temp[1024], *sp;
|
||||
clonedev_t *cl, *ptr;
|
||||
device_t *dev;
|
||||
|
||||
/* Look up the master. */
|
||||
for (ptr = clones; ptr != NULL; ptr = ptr->next)
|
||||
if (ptr->master == master) break;
|
||||
|
||||
/* If not found, add this master to the list. */
|
||||
if (ptr == NULL) {
|
||||
ptr = (clonedev_t *)malloc(sizeof(clonedev_t));
|
||||
memset(ptr, 0x00, sizeof(clonedev_t));
|
||||
if (clones != NULL) {
|
||||
for (cl = clones; cl->next != NULL; cl = cl->next)
|
||||
;
|
||||
cl->next = ptr;
|
||||
} else
|
||||
clones = ptr;
|
||||
ptr->master = master;
|
||||
}
|
||||
|
||||
/* Create a new device. */
|
||||
dev = (device_t *)malloc(sizeof(device_t));
|
||||
|
||||
/* Copy the master info. */
|
||||
memcpy(dev, ptr->master, sizeof(device_t));
|
||||
|
||||
/* Set up a clone. */
|
||||
if (++ptr->count > 1)
|
||||
sprintf(temp, "%s #%i", ptr->master->name, ptr->count);
|
||||
memset(c, 0, sizeof(device_context_t));
|
||||
c->dev = d;
|
||||
if (inst)
|
||||
sprintf(c->name, "%s #%i", d->name, inst);
|
||||
else
|
||||
strcpy(temp, ptr->master->name);
|
||||
sp = (char *)malloc(strlen(temp) + 1);
|
||||
strcpy(sp, temp);
|
||||
dev->name = (const char *)sp;
|
||||
|
||||
return((const device_t *)dev);
|
||||
sprintf(c->name, "%s", d->name);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
device_add(const device_t *d)
|
||||
device_add_common(const device_t *d, void *p, int inst)
|
||||
{
|
||||
void *priv = NULL;
|
||||
int c;
|
||||
device_t *old;
|
||||
device_context_t old;
|
||||
|
||||
for (c = 0; c < 256; c++) {
|
||||
if (devices[c] == (device_t *)d) {
|
||||
@@ -166,10 +116,9 @@ device_add(const device_t *d)
|
||||
if (c >= DEVICE_MAX)
|
||||
fatal("DEVICE: too many devices\n");
|
||||
|
||||
old = device_current;
|
||||
device_current = (device_t *)d;
|
||||
|
||||
devices[c] = (device_t *)d;
|
||||
if (p == NULL) {
|
||||
memcpy(&old, &device_current, sizeof(device_context_t));
|
||||
device_set_context(&device_current, d, inst);
|
||||
|
||||
if (d->init != NULL) {
|
||||
priv = d->init(d);
|
||||
@@ -185,31 +134,44 @@ device_add(const device_t *d)
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&device_current, &old, sizeof(device_context_t));
|
||||
device_priv[c] = priv;
|
||||
device_current = old;
|
||||
} else
|
||||
device_priv[c] = p;
|
||||
|
||||
devices[c] = (device_t *)d;
|
||||
|
||||
return(priv);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
device_add(const device_t *d)
|
||||
{
|
||||
return device_add_common(d, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/* For devices that do not have an init function (internal video etc.) */
|
||||
void
|
||||
device_add_ex(const device_t *d, void *priv)
|
||||
{
|
||||
int c;
|
||||
device_add_common(d, priv, 0);
|
||||
}
|
||||
|
||||
for (c = 0; c < 256; c++) {
|
||||
if (devices[c] == (device_t *)d) {
|
||||
fatal("device_add: device already exists!\n");
|
||||
break;
|
||||
}
|
||||
if (devices[c] == NULL) break;
|
||||
}
|
||||
if (c >= DEVICE_MAX)
|
||||
fatal("device_add: too many devices\n");
|
||||
|
||||
devices[c] = (device_t *)d;
|
||||
device_priv[c] = priv;
|
||||
void *
|
||||
device_add_inst(const device_t *d, int inst)
|
||||
{
|
||||
return device_add_common(d, NULL, inst);
|
||||
}
|
||||
|
||||
|
||||
/* For devices that do not have an init function (internal video etc.) */
|
||||
void
|
||||
device_add_inst_ex(const device_t *d, void *priv, int inst)
|
||||
{
|
||||
device_add_common(d, priv, inst);
|
||||
}
|
||||
|
||||
|
||||
@@ -321,11 +283,11 @@ device_force_redraw(void)
|
||||
const char *
|
||||
device_get_config_string(const char *s)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_string((char *) device_current->name, (char *) s, (char *) c->default_string));
|
||||
return(config_get_string((char *) device_current.name, (char *) s, (char *) c->default_string));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -337,11 +299,11 @@ device_get_config_string(const char *s)
|
||||
int
|
||||
device_get_config_int(const char *s)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_int((char *) device_current->name, (char *) s, c->default_int));
|
||||
return(config_get_int((char *) device_current.name, (char *) s, c->default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -353,11 +315,11 @@ device_get_config_int(const char *s)
|
||||
int
|
||||
device_get_config_int_ex(const char *s, int def)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_int((char *) device_current->name, (char *) s, def));
|
||||
return(config_get_int((char *) device_current.name, (char *) s, def));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -369,11 +331,11 @@ device_get_config_int_ex(const char *s, int def)
|
||||
int
|
||||
device_get_config_hex16(const char *s)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_hex16((char *) device_current->name, (char *) s, c->default_int));
|
||||
return(config_get_hex16((char *) device_current.name, (char *) s, c->default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -385,11 +347,11 @@ device_get_config_hex16(const char *s)
|
||||
int
|
||||
device_get_config_hex20(const char *s)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_hex20((char *) device_current->name, (char *) s, c->default_int));
|
||||
return(config_get_hex20((char *) device_current.name, (char *) s, c->default_int));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -401,11 +363,11 @@ device_get_config_hex20(const char *s)
|
||||
int
|
||||
device_get_config_mac(const char *s, int def)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name))
|
||||
return(config_get_mac((char *) device_current->name, (char *) s, def));
|
||||
return(config_get_mac((char *) device_current.name, (char *) s, def));
|
||||
|
||||
c++;
|
||||
}
|
||||
@@ -417,11 +379,11 @@ device_get_config_mac(const char *s, int def)
|
||||
void
|
||||
device_set_config_int(const char *s, int val)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_int((char *) device_current->name, (char *) s, val);
|
||||
config_set_int((char *) device_current.name, (char *) s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -433,11 +395,11 @@ device_set_config_int(const char *s, int val)
|
||||
void
|
||||
device_set_config_hex16(const char *s, int val)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_hex16((char *) device_current->name, (char *) s, val);
|
||||
config_set_hex16((char *) device_current.name, (char *) s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -449,11 +411,11 @@ device_set_config_hex16(const char *s, int val)
|
||||
void
|
||||
device_set_config_hex20(const char *s, int val)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_hex20((char *) device_current->name, (char *) s, val);
|
||||
config_set_hex20((char *) device_current.name, (char *) s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -465,11 +427,11 @@ device_set_config_hex20(const char *s, int val)
|
||||
void
|
||||
device_set_config_mac(const char *s, int val)
|
||||
{
|
||||
const device_config_t *c = device_current->config;
|
||||
const device_config_t *c = device_current.dev->config;
|
||||
|
||||
while (c && c->type != -1) {
|
||||
if (! strcmp(s, c->name)) {
|
||||
config_set_mac((char *) device_current->name, (char *) s, val);
|
||||
config_set_mac((char *) device_current.name, (char *) s, val);
|
||||
break;
|
||||
}
|
||||
|
||||
|
11
src/device.h
11
src/device.h
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the device handler.
|
||||
*
|
||||
* Version: @(#)device.h 1.0.9 2018/09/06
|
||||
* Version: @(#)device.h 1.0.10 2018/10/23
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -108,15 +108,22 @@ typedef struct _device_ {
|
||||
const device_config_t *config;
|
||||
} device_t;
|
||||
|
||||
typedef struct {
|
||||
const device_t *dev;
|
||||
char name[2048];
|
||||
} device_context_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void device_init(void);
|
||||
extern const device_t * device_clone(const device_t *master);
|
||||
extern void device_set_context(device_context_t *c, const device_t *d, int inst);
|
||||
extern void *device_add(const device_t *);
|
||||
extern void device_add_ex(const device_t *d, void *priv);
|
||||
extern void *device_add_inst(const device_t *, int inst);
|
||||
extern void device_add_inst_ex(const device_t *d, void *priv, int inst);
|
||||
extern void device_close_all(void);
|
||||
extern void device_reset_all(void);
|
||||
extern void device_reset_all_pci(void);
|
||||
|
32
src/isamem.c
32
src/isamem.c
@@ -32,7 +32,7 @@
|
||||
* TODO: The EV159 is supposed to support 16b EMS transfers, but the
|
||||
* EMM.sys driver for it doesn't seem to want to do that..
|
||||
*
|
||||
* Version: @(#)isamem.c 1.0.7 2018/10/17
|
||||
* Version: @(#)isamem.c 1.0.8 2018/10/23
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -106,7 +106,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
const char *name;
|
||||
uint8_t board : 6, /* board type */
|
||||
instance : 2; /* device instance */
|
||||
reserved : 2;
|
||||
|
||||
uint8_t flags;
|
||||
#define FLAG_CONFIG 0x01 /* card is configured */
|
||||
@@ -151,15 +151,6 @@ isamem_log(const char *fmt, ...)
|
||||
#endif
|
||||
|
||||
|
||||
/* Local variables. */
|
||||
static const device_t *instance[ISAMEM_MAX] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/* Read one byte from onboard RAM. */
|
||||
static uint8_t
|
||||
ram_readb(uint32_t addr, void *priv)
|
||||
@@ -412,13 +403,10 @@ isamem_init(const device_t *info)
|
||||
int i;
|
||||
|
||||
/* Find our device and create an instance. */
|
||||
for (i = 0; i < ISAMEM_MAX; i++)
|
||||
if (instance[i] == info) break;
|
||||
dev = (memdev_t *)malloc(sizeof(memdev_t));
|
||||
memset(dev, 0x00, sizeof(memdev_t));
|
||||
dev->name = info->name;
|
||||
dev->board = info->local;
|
||||
dev->instance = i;
|
||||
|
||||
/* Do per-board initialization. */
|
||||
tot = 0;
|
||||
@@ -650,7 +638,7 @@ dev->frame_addr = 0xE0000;
|
||||
}
|
||||
|
||||
/* Let them know our device instance. */
|
||||
return((void *)dev);
|
||||
return((void *) dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -672,8 +660,6 @@ isamem_close(void *priv)
|
||||
if (dev->ram != NULL)
|
||||
free(dev->ram);
|
||||
|
||||
instance[dev->instance] = NULL;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
@@ -1045,21 +1031,14 @@ static const struct {
|
||||
void
|
||||
isamem_reset(void)
|
||||
{
|
||||
const device_t *dev;
|
||||
int k, i;
|
||||
|
||||
for (i = 0; i < ISAMEM_MAX; i++) {
|
||||
k = isamem_type[i];
|
||||
if (k == 0) continue;
|
||||
|
||||
/* Clone the device. */
|
||||
dev = device_clone(boards[k].dev);
|
||||
|
||||
/* Store the device instance. */
|
||||
instance[i] = dev;
|
||||
|
||||
/* Add the instance to the system. */
|
||||
device_add(dev);
|
||||
device_add_inst(boards[k].dev, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1100,5 +1079,6 @@ isamem_get_from_internal_name(const char *s)
|
||||
const device_t *
|
||||
isamem_get_device(int board)
|
||||
{
|
||||
return(instance[board]);
|
||||
/* Add the instance to the system. */
|
||||
return boards[board].dev;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Platform support defintions for Win32.
|
||||
*
|
||||
* Version: @(#)win.h 1.0.23 2018/10/23
|
||||
* Version: @(#)win.h 1.0.24 2018/10/23
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -111,6 +111,7 @@ extern intptr_t fdd_type_to_icon(int type);
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern uint8_t deviceconfig_open(HWND hwnd, const device_t *device);
|
||||
extern uint8_t deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst);
|
||||
#endif
|
||||
extern uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type);
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Windows device configuration dialog implementation.
|
||||
*
|
||||
* Version: @(#)win_devconf.c 1.0.19 2018/10/10
|
||||
* Version: @(#)win_devconf.c 1.0.20 2018/10/23
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <windowsx.h>
|
||||
|
||||
|
||||
static const device_t *config_device;
|
||||
static device_context_t config_device;
|
||||
|
||||
static uint8_t deviceconfig_changed = 0;
|
||||
|
||||
@@ -45,48 +45,45 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND h;
|
||||
|
||||
int val_int;
|
||||
int id;
|
||||
int c;
|
||||
int num;
|
||||
int changed;
|
||||
int cid;
|
||||
int val_int, id, c, d, num;
|
||||
int changed, cid;
|
||||
const device_config_t *config;
|
||||
char s[80];
|
||||
wchar_t ws[512];
|
||||
const device_config_selection_t *selection;
|
||||
char s[512], file_filter[512];
|
||||
char *str;
|
||||
wchar_t ws[512], *wstr;
|
||||
LPTSTR lptsTemp;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
config = config_device.dev->config;
|
||||
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
id = IDC_CONFIG_BASE;
|
||||
config = config_device->config;
|
||||
config = config_device.dev->config;
|
||||
|
||||
lptsTemp = (LPTSTR) malloc(512);
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
const device_config_selection_t *selection = config->selection;
|
||||
while (config->type != -1) {
|
||||
selection = config->selection;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
|
||||
switch (config->type)
|
||||
{
|
||||
switch (config->type) {
|
||||
case CONFIG_BINARY:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
SendMessage(h, BM_SETCHECK, val_int, 0);
|
||||
|
||||
id++;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
c = 0;
|
||||
while (selection->description && selection->description[0])
|
||||
{
|
||||
mbstowcs(lptsTemp, selection->description, strlen(selection->description) + 1);
|
||||
while (selection->description && selection->description[0]) {
|
||||
mbstowcs(lptsTemp, selection->description,
|
||||
strlen(selection->description) + 1);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
|
||||
if (val_int == selection->value)
|
||||
SendMessage(h, CB_SETCURSEL, c, 0);
|
||||
@@ -96,13 +93,12 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_MIDI:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
num = plat_midi_get_num_devs();
|
||||
for (c = 0; c < num; c++)
|
||||
{
|
||||
for (c = 0; c < num; c++) {
|
||||
plat_midi_get_dev_name(c, s);
|
||||
mbstowcs(lptsTemp, s, strlen(s) + 1);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
|
||||
@@ -112,32 +108,30 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_SPINNER:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
_swprintf(ws, L"%i", val_int);
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)ws);
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
wchar_t* str = config_get_wstring((char *) config_device->name, (char *) config->name, 0);
|
||||
if (str)
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)str);
|
||||
wstr = config_get_wstring((char *) config_device.name,
|
||||
(char *) config->name, 0);
|
||||
if (wstr)
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)wstr);
|
||||
id += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_HEX16:
|
||||
val_int = config_get_hex16((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_hex16((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
c = 0;
|
||||
while (selection->description && selection->description[0])
|
||||
{
|
||||
mbstowcs(lptsTemp, selection->description, strlen(selection->description) + 1);
|
||||
while (selection->description && selection->description[0]) {
|
||||
mbstowcs(lptsTemp, selection->description,
|
||||
strlen(selection->description) + 1);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
|
||||
if (val_int == selection->value)
|
||||
SendMessage(h, CB_SETCURSEL, c, 0);
|
||||
@@ -147,14 +141,14 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_HEX20:
|
||||
val_int = config_get_hex20((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_hex20((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
c = 0;
|
||||
while (selection->description && selection->description[0])
|
||||
{
|
||||
mbstowcs(lptsTemp, selection->description, strlen(selection->description) + 1);
|
||||
while (selection->description && selection->description[0]) {
|
||||
mbstowcs(lptsTemp, selection->description,
|
||||
strlen(selection->description) + 1);
|
||||
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
|
||||
if (val_int == selection->value)
|
||||
SendMessage(h, CB_SETCURSEL, c, 0);
|
||||
@@ -167,39 +161,33 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
config++;
|
||||
}
|
||||
|
||||
free(lptsTemp);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
cid = LOWORD(wParam);
|
||||
if (cid == IDOK)
|
||||
{
|
||||
if (cid == IDOK) {
|
||||
id = IDC_CONFIG_BASE;
|
||||
config = config_device->config;
|
||||
config = config_device.dev->config;
|
||||
changed = 0;
|
||||
char s[512];
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
while (config->type != -1) {
|
||||
const device_config_selection_t *selection = config->selection;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
|
||||
switch (config->type)
|
||||
{
|
||||
switch (config->type) {
|
||||
case CONFIG_BINARY:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
if (val_int != SendMessage(h, BM_GETCHECK, 0, 0))
|
||||
changed = 1;
|
||||
|
||||
id++;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
|
||||
@@ -211,9 +199,9 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_MIDI:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
|
||||
@@ -222,20 +210,18 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
char* str = config_get_string((char *) config_device->name, (char *) config->name, (char*)"");
|
||||
str = config_get_string((char *) config_device.name,
|
||||
(char *) config->name, (char*)"");
|
||||
SendMessage(h, WM_GETTEXT, 511, (LPARAM)s);
|
||||
if (strcmp(str, s))
|
||||
changed = 1;
|
||||
|
||||
id += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_SPINNER:
|
||||
val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_int((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
if (val_int > config->spinner.max)
|
||||
val_int = config->spinner.max;
|
||||
else if (val_int < config->spinner.min)
|
||||
@@ -250,9 +236,9 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_HEX16:
|
||||
val_int = config_get_hex16((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_hex16((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
|
||||
@@ -264,9 +250,9 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_HEX20:
|
||||
val_int = config_get_hex20((char *) config_device->name, (char *) config->name, config->default_int);
|
||||
val_int = config_get_hex20((char *) config_device.name,
|
||||
(char *) config->name, config->default_int);
|
||||
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
|
||||
@@ -282,8 +268,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
config++;
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
{
|
||||
if (!changed) {
|
||||
deviceconfig_changed = 0;
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
@@ -292,44 +277,39 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
deviceconfig_changed = 1;
|
||||
|
||||
id = IDC_CONFIG_BASE;
|
||||
config = config_device->config;
|
||||
config = config_device.dev->config;
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
const device_config_selection_t *selection = config->selection;
|
||||
while (config->type != -1) {
|
||||
selection = config->selection;
|
||||
h = GetDlgItem(hdlg, id);
|
||||
|
||||
switch (config->type)
|
||||
{
|
||||
switch (config->type) {
|
||||
case CONFIG_BINARY:
|
||||
config_set_int((char *) config_device->name, (char *) config->name, SendMessage(h, BM_GETCHECK, 0, 0));
|
||||
config_set_int((char *) config_device.name,
|
||||
(char *) config->name, SendMessage(h, BM_GETCHECK, 0, 0));
|
||||
|
||||
id++;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
for (; c > 0; c--)
|
||||
selection++;
|
||||
config_set_int((char *) config_device->name, (char *) config->name, selection->value);
|
||||
config_set_int((char *) config_device.name, (char *) config->name, selection->value);
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_MIDI:
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
config_set_int((char *) config_device->name, (char *) config->name, c);
|
||||
config_set_int((char *) config_device.name, (char *) config->name, c);
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_FNAME:
|
||||
SendMessage(h, WM_GETTEXT, 511, (LPARAM)ws);
|
||||
config_set_wstring((char *) config_device->name, (char *) config->name, ws);
|
||||
config_set_wstring((char *) config_device.name, (char *) config->name, ws);
|
||||
|
||||
id += 3;
|
||||
break;
|
||||
|
||||
case CONFIG_SPINNER:
|
||||
SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws);
|
||||
wcstombs(s, ws, 512);
|
||||
@@ -339,25 +319,23 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
else if (c < config->spinner.min)
|
||||
c = config->spinner.min;
|
||||
|
||||
config_set_int((char *) config_device->name, (char *) config->name, c);
|
||||
config_set_int((char *) config_device.name, (char *) config->name, c);
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_HEX16:
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
for (; c > 0; c--)
|
||||
selection++;
|
||||
config_set_hex16((char *) config_device->name, (char *) config->name, selection->value);
|
||||
config_set_hex16((char *) config_device.name, (char *) config->name, selection->value);
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_HEX20:
|
||||
c = SendMessage(h, CB_GETCURSEL, 0, 0);
|
||||
for (; c > 0; c--)
|
||||
selection++;
|
||||
config_set_hex20((char *) config_device->name, (char *) config->name, selection->value);
|
||||
config_set_hex20((char *) config_device.name, (char *) config->name, selection->value);
|
||||
|
||||
id += 2;
|
||||
break;
|
||||
@@ -367,54 +345,37 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else if (cid == IDCANCEL)
|
||||
{
|
||||
} else if (cid == IDCANCEL) {
|
||||
deviceconfig_changed = 0;
|
||||
EndDialog(hdlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = IDC_CONFIG_BASE;
|
||||
const device_config_t *config = config_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
switch (config->type)
|
||||
{
|
||||
} else {
|
||||
id = IDC_CONFIG_BASE;
|
||||
while (config->type != -1) {
|
||||
switch (config->type) {
|
||||
case CONFIG_BINARY:
|
||||
id++;
|
||||
break;
|
||||
|
||||
case CONFIG_SELECTION:
|
||||
case CONFIG_MIDI:
|
||||
case CONFIG_SPINNER:
|
||||
id += 2;
|
||||
break;
|
||||
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
if (cid == id+1)
|
||||
{
|
||||
char s[512];
|
||||
if (cid == id+1) {
|
||||
s[0] = 0;
|
||||
int c, d;
|
||||
HWND h = GetDlgItem(hdlg, id);
|
||||
h = GetDlgItem(hdlg, id);
|
||||
SendMessage(h, WM_GETTEXT, 511, (LPARAM)s);
|
||||
char file_filter[512];
|
||||
file_filter[0] = 0;
|
||||
|
||||
c = 0;
|
||||
while (config->file_filter[c].description && config->file_filter[c].description[0])
|
||||
{
|
||||
while (config->file_filter[c].description && config->file_filter[c].description[0]) {
|
||||
if (c > 0)
|
||||
strcat(file_filter, "|");
|
||||
strcat(file_filter, config->file_filter[c].description);
|
||||
strcat(file_filter, " (");
|
||||
d = 0;
|
||||
while (config->file_filter[c].extensions[d] && config->file_filter[c].extensions[d][0])
|
||||
{
|
||||
while (config->file_filter[c].extensions[d] && config->file_filter[c].extensions[d][0]) {
|
||||
if (d > 0)
|
||||
strcat(file_filter, ";");
|
||||
strcat(file_filter, "*.");
|
||||
@@ -423,8 +384,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
strcat(file_filter, ")|");
|
||||
d = 0;
|
||||
while (config->file_filter[c].extensions[d] && config->file_filter[c].extensions[d][0])
|
||||
{
|
||||
while (config->file_filter[c].extensions[d] && config->file_filter[c].extensions[d][0]) {
|
||||
if (d > 0)
|
||||
strcat(file_filter, ";");
|
||||
strcat(file_filter, "*.");
|
||||
@@ -438,26 +398,27 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
d = strlen(file_filter);
|
||||
|
||||
/* replace | with \0 */
|
||||
for (c = 0; c < d; ++c)
|
||||
for (c = 0; c < d; ++c) {
|
||||
if (ws[c] == L'|')
|
||||
ws[c] = 0;
|
||||
}
|
||||
|
||||
if (!file_dlg(hdlg, ws, s, 0))
|
||||
SendMessage(h, WM_SETTEXT, 0, (LPARAM)wopenfilestring);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
config++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
uint8_t deviceconfig_open(HWND hwnd, const device_t *device)
|
||||
|
||||
uint8_t
|
||||
deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
|
||||
{
|
||||
const device_config_t *config = device->config;
|
||||
uint16_t *data_block;
|
||||
@@ -492,10 +453,8 @@ uint8_t deviceconfig_open(HWND hwnd, const device_t *device)
|
||||
if (((uintptr_t)data) & 2)
|
||||
data++;
|
||||
|
||||
while (config->type != -1)
|
||||
{
|
||||
switch (config->type)
|
||||
{
|
||||
while (config->type != -1) {
|
||||
switch (config->type) {
|
||||
case CONFIG_BINARY:
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
item->x = 10;
|
||||
@@ -565,7 +524,6 @@ uint8_t deviceconfig_open(HWND hwnd, const device_t *device)
|
||||
|
||||
y += 20;
|
||||
break;
|
||||
|
||||
case CONFIG_SPINNER:
|
||||
/*Spinner*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
@@ -613,7 +571,6 @@ uint8_t deviceconfig_open(HWND hwnd, const device_t *device)
|
||||
|
||||
y += 20;
|
||||
break;
|
||||
|
||||
case CONFIG_FNAME:
|
||||
/*File*/
|
||||
item = (DLGITEMTEMPLATE *)data;
|
||||
@@ -726,7 +683,7 @@ uint8_t deviceconfig_open(HWND hwnd, const device_t *device)
|
||||
|
||||
dlg->cy = y + 20;
|
||||
|
||||
config_device = device;
|
||||
device_set_context(&config_device, device, inst);
|
||||
|
||||
DialogBoxIndirect(hinstance, dlg, hwnd, deviceconfig_dlgproc);
|
||||
|
||||
@@ -734,3 +691,10 @@ uint8_t deviceconfig_open(HWND hwnd, const device_t *device)
|
||||
|
||||
return deviceconfig_changed;
|
||||
}
|
||||
|
||||
|
||||
uint8_t
|
||||
deviceconfig_open(HWND hwnd, const device_t *device)
|
||||
{
|
||||
return deviceconfig_inst_open(hwnd, device, 0);
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Windows 86Box Settings dialog handler.
|
||||
*
|
||||
* Version: @(#)win_settings.c 1.0.67 2018/10/23
|
||||
* Version: @(#)win_settings.c 1.0.68 2018/10/23
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* David Hrdlička, <hrdlickadavid@outlook.com>
|
||||
@@ -1669,11 +1669,8 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa
|
||||
case IDC_CONFIGURE_ISAMEM_3:
|
||||
case IDC_CONFIGURE_ISAMEM_4:
|
||||
c = LOWORD(wParam) - IDC_CONFIGURE_ISAMEM_1;
|
||||
dev = isamem_get_device(c);
|
||||
if (dev != NULL)
|
||||
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)dev);
|
||||
else
|
||||
ui_msgbox(MBX_INFO, (wchar_t *)IDS_2119);
|
||||
dev = isamem_get_device(temp_isamem[c]);
|
||||
temp_deviceconfig |= deviceconfig_inst_open(hdlg, (void *)dev, c + 1);
|
||||
break;
|
||||
|
||||
case IDC_CHECK_IDE_TER:
|
||||
|
Reference in New Issue
Block a user