From 4343f5a8a338f7d42082791dee55cc18ed9870ec Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 23 Oct 2018 21:14:41 +0200 Subject: [PATCH] Redid device instantiation, now the ISA memory boards can be configured without having to restart the emulator first. --- src/device.c | 190 +++---- src/device.h | 11 +- src/isamem.c | 32 +- src/win/win.h | 3 +- src/win/win_devconf.c | 1142 +++++++++++++++++++--------------------- src/win/win_settings.c | 9 +- 6 files changed, 649 insertions(+), 738 deletions(-) diff --git a/src/device.c b/src/device.c index 1aed9ef53..68447e644 100644 --- a/src/device.c +++ b/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, * Miran Grca, @@ -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); - 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); + memset(c, 0, sizeof(device_context_t)); + c->dev = d; + if (inst) + sprintf(c->name, "%s #%i", d->name, inst); + else + 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,50 +116,62 @@ device_add(const device_t *d) if (c >= DEVICE_MAX) fatal("DEVICE: too many devices\n"); - old = device_current; - device_current = (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); + if (priv == NULL) { + if (d->name) + device_log("DEVICE: device '%s' init failed\n", d->name); + else + device_log("DEVICE: device init failed\n"); + + device_priv[c] = NULL; + + return(NULL); + } + } + + memcpy(&device_current, &old, sizeof(device_context_t)); + device_priv[c] = priv; + } else + device_priv[c] = p; devices[c] = (device_t *)d; - if (d->init != NULL) { - priv = d->init(d); - if (priv == NULL) { - if (d->name) - device_log("DEVICE: device '%s' init failed\n", d->name); - else - device_log("DEVICE: device init failed\n"); - - device_priv[c] = NULL; - - return(NULL); - } - } - - device_priv[c] = priv; - device_current = old; - 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; } diff --git a/src/device.h b/src/device.h index 387159cbc..896108e49 100644 --- a/src/device.h +++ b/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, * Miran Grca, @@ -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); diff --git a/src/isamem.c b/src/isamem.c index c0d743511..a6f29deb5 100644 --- a/src/isamem.c +++ b/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, * @@ -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; } diff --git a/src/win/win.h b/src/win/win.h index e1fa754b6..69c47b61a 100644 --- a/src/win/win.h +++ b/src/win/win.h @@ -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, * Miran Grca, @@ -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); diff --git a/src/win/win_devconf.c b/src/win/win_devconf.c index ec6c71fe2..b83c35e90 100644 --- a/src/win/win_devconf.c +++ b/src/win/win_devconf.c @@ -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, * Miran Grca, @@ -31,7 +31,7 @@ #include -static const device_t *config_device; +static device_context_t config_device; static uint8_t deviceconfig_changed = 0; @@ -43,694 +43,658 @@ static BOOL CALLBACK #endif deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { - HWND h; + HWND h; - int val_int; - int id; - int c; - int num; - int changed; - int cid; - const device_config_t *config; - char s[80]; - wchar_t ws[512]; - LPTSTR lptsTemp; + int val_int, id, c, d, num; + int changed, cid; + const device_config_t *config; + const device_config_selection_t *selection; + char s[512], file_filter[512]; + char *str; + wchar_t ws[512], *wstr; + LPTSTR lptsTemp; - switch (message) - { - case WM_INITDIALOG: - { - id = IDC_CONFIG_BASE; - config = config_device->config; + config = config_device.dev->config; - lptsTemp = (LPTSTR) malloc(512); + switch (message) { + case WM_INITDIALOG: + id = IDC_CONFIG_BASE; + config = config_device.dev->config; - while (config->type != -1) - { - const device_config_selection_t *selection = config->selection; - h = GetDlgItem(hdlg, id); - - switch (config->type) - { - case CONFIG_BINARY: - val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); - - SendMessage(h, BM_SETCHECK, val_int, 0); - - id++; - break; + lptsTemp = (LPTSTR) malloc(512); - case CONFIG_SELECTION: - 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); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == selection->value) - SendMessage(h, CB_SETCURSEL, c, 0); - selection++; - c++; - } - - id += 2; - break; + while (config->type != -1) { + selection = config->selection; + h = GetDlgItem(hdlg, id); - case CONFIG_MIDI: - 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++) - { - plat_midi_get_dev_name(c, s); + switch (config->type) { + case CONFIG_BINARY: + 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); + + c = 0; + 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); + selection++; + c++; + } + + id += 2; + break; + case CONFIG_MIDI: + 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++) { + plat_midi_get_dev_name(c, s); mbstowcs(lptsTemp, s, strlen(s) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == c) - SendMessage(h, CB_SETCURSEL, c, 0); - } - - id += 2; - break; + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); + if (val_int == c) + SendMessage(h, CB_SETCURSEL, c, 0); + } - case CONFIG_SPINNER: - val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); + id += 2; + break; + case CONFIG_SPINNER: + 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); + _swprintf(ws, L"%i", val_int); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)ws); - id += 2; - break; + id += 2; + break; + case CONFIG_FNAME: + 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); - 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); - id += 3; - } - break; + c = 0; + 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); + selection++; + c++; + } - case CONFIG_HEX16: - 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); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == selection->value) - SendMessage(h, CB_SETCURSEL, c, 0); - selection++; - c++; - } - - id += 2; - break; + id += 2; + break; + case CONFIG_HEX20: + val_int = config_get_hex20((char *) config_device.name, + (char *) config->name, config->default_int); - case CONFIG_HEX20: - 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); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == selection->value) - SendMessage(h, CB_SETCURSEL, c, 0); - selection++; - c++; - } - - id += 2; - break; - } - config++; - } + c = 0; + 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); + selection++; + c++; + } - free(lptsTemp); - } - return TRUE; - - case WM_COMMAND: - { - cid = LOWORD(wParam); - if (cid == IDOK) - { - id = IDC_CONFIG_BASE; - config = config_device->config; - changed = 0; - char s[512]; - - while (config->type != -1) - { - const device_config_selection_t *selection = config->selection; - h = GetDlgItem(hdlg, id); - - switch (config->type) - { - case CONFIG_BINARY: - val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); + id += 2; + break; + } + config++; + } + free(lptsTemp); + return TRUE; + case WM_COMMAND: + cid = LOWORD(wParam); + if (cid == IDOK) { + id = IDC_CONFIG_BASE; + config = config_device.dev->config; + changed = 0; + char s[512]; - if (val_int != SendMessage(h, BM_GETCHECK, 0, 0)) - changed = 1; - - id++; - break; + while (config->type != -1) { + const device_config_selection_t *selection = config->selection; + h = GetDlgItem(hdlg, id); - case CONFIG_SELECTION: - val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); + switch (config->type) { + case CONFIG_BINARY: + val_int = config_get_int((char *) config_device.name, + (char *) config->name, config->default_int); - c = SendMessage(h, CB_GETCURSEL, 0, 0); + if (val_int != SendMessage(h, BM_GETCHECK, 0, 0)) + changed = 1; - for (; c > 0; c--) - selection++; + id++; + break; + case CONFIG_SELECTION: + val_int = config_get_int((char *) config_device.name, + (char *) config->name, config->default_int); - if (val_int != selection->value) - changed = 1; - - id += 2; - break; + c = SendMessage(h, CB_GETCURSEL, 0, 0); - case CONFIG_MIDI: - val_int = config_get_int((char *) config_device->name, (char *) config->name, config->default_int); + for (; c > 0; c--) + selection++; - c = SendMessage(h, CB_GETCURSEL, 0, 0); + if (val_int != selection->value) + changed = 1; - if (val_int != c) - changed = 1; - - id += 2; - break; + id += 2; + break; + case CONFIG_MIDI: + val_int = config_get_int((char *) config_device.name, + (char *) config->name, config->default_int); - case CONFIG_FNAME: - { - 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; + c = SendMessage(h, CB_GETCURSEL, 0, 0); - id += 3; - } - break; + if (val_int != c) + changed = 1; - case CONFIG_SPINNER: - 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) - val_int = config->spinner.min; + id += 2; + break; + case CONFIG_FNAME: + 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; - SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); + id += 3; + break; + case CONFIG_SPINNER: + 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) + val_int = config->spinner.min; + + SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); wcstombs(s, ws, 512); - sscanf(s, "%i", &c); + sscanf(s, "%i", &c); - if (val_int != c) - changed = 1; + if (val_int != c) + changed = 1; - id += 2; - break; + id += 2; + break; + case CONFIG_HEX16: + val_int = config_get_hex16((char *) config_device.name, + (char *) config->name, config->default_int); - case CONFIG_HEX16: - val_int = config_get_hex16((char *) config_device->name, (char *) config->name, config->default_int); + c = SendMessage(h, CB_GETCURSEL, 0, 0); - c = SendMessage(h, CB_GETCURSEL, 0, 0); + for (; c > 0; c--) + selection++; - for (; c > 0; c--) - selection++; + if (val_int != selection->value) + changed = 1; - if (val_int != selection->value) - changed = 1; - - id += 2; - break; + id += 2; + break; + case CONFIG_HEX20: + val_int = config_get_hex20((char *) config_device.name, + (char *) config->name, config->default_int); - case CONFIG_HEX20: - val_int = config_get_hex20((char *) config_device->name, (char *) config->name, config->default_int); + c = SendMessage(h, CB_GETCURSEL, 0, 0); - c = SendMessage(h, CB_GETCURSEL, 0, 0); + for (; c > 0; c--) + selection++; - for (; c > 0; c--) - selection++; + if (val_int != selection->value) + changed = 1; - if (val_int != selection->value) - changed = 1; - - id += 2; - break; - } - config++; - } - - if (!changed) - { - deviceconfig_changed = 0; - EndDialog(hdlg, 0); - return TRUE; - } - - deviceconfig_changed = 1; - - id = IDC_CONFIG_BASE; - config = config_device->config; - - while (config->type != -1) - { - const device_config_selection_t *selection = config->selection; - h = GetDlgItem(hdlg, id); - - switch (config->type) - { - case CONFIG_BINARY: - 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); - - id += 2; - break; - - case CONFIG_MIDI: - c = SendMessage(h, CB_GETCURSEL, 0, 0); - 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); - - id += 3; - break; - - case CONFIG_SPINNER: - SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); - wcstombs(s, ws, 512); - sscanf(s, "%i", &c); - if (c > config->spinner.max) - c = config->spinner.max; - else if (c < config->spinner.min) - c = config->spinner.min; - - 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); - - 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); - - id += 2; - break; - } - config++; - } - - EndDialog(hdlg, 0); - return TRUE; - } - 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) - { - 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]; - s[0] = 0; - int c, d; - HWND 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]) - { - 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]) - { - if (d > 0) - strcat(file_filter, ";"); - strcat(file_filter, "*."); - strcat(file_filter, config->file_filter[c].extensions[d]); - d++; - } - strcat(file_filter, ")|"); - 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, "*."); - strcat(file_filter, config->file_filter[c].extensions[d]); - d++; - } - c++; - } - strcat(file_filter, "|All files (*.*)|*.*|"); - mbstowcs(ws, file_filter, strlen(file_filter) + 1); - d = strlen(file_filter); - - /* replace | with \0 */ - 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++; - } - } + id += 2; + break; } - break; - } - return FALSE; + config++; + } + + if (!changed) { + deviceconfig_changed = 0; + EndDialog(hdlg, 0); + return TRUE; + } + + deviceconfig_changed = 1; + + id = IDC_CONFIG_BASE; + config = config_device.dev->config; + + while (config->type != -1) { + selection = config->selection; + h = GetDlgItem(hdlg, id); + + switch (config->type) { + case CONFIG_BINARY: + 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); + + id += 2; + break; + case CONFIG_MIDI: + c = SendMessage(h, CB_GETCURSEL, 0, 0); + 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); + + id += 3; + break; + case CONFIG_SPINNER: + SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); + wcstombs(s, ws, 512); + sscanf(s, "%i", &c); + if (c > config->spinner.max) + c = config->spinner.max; + else if (c < config->spinner.min) + c = config->spinner.min; + + 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); + + 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); + + id += 2; + break; + } + config++; + } + + EndDialog(hdlg, 0); + return TRUE; + } else if (cid == IDCANCEL) { + deviceconfig_changed = 0; + EndDialog(hdlg, 0); + return TRUE; + } 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) { + s[0] = 0; + h = GetDlgItem(hdlg, id); + SendMessage(h, WM_GETTEXT, 511, (LPARAM)s); + file_filter[0] = 0; + + c = 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]) { + if (d > 0) + strcat(file_filter, ";"); + strcat(file_filter, "*."); + strcat(file_filter, config->file_filter[c].extensions[d]); + d++; + } + strcat(file_filter, ")|"); + 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, "*."); + strcat(file_filter, config->file_filter[c].extensions[d]); + d++; + } + c++; + } + strcat(file_filter, "|All files (*.*)|*.*|"); + mbstowcs(ws, file_filter, strlen(file_filter) + 1); + d = strlen(file_filter); + + /* replace | with \0 */ + 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; - uint16_t *data; - DLGTEMPLATE *dlg; - DLGITEMTEMPLATE *item; + const device_config_t *config = device->config; + uint16_t *data_block; + uint16_t *data; + DLGTEMPLATE *dlg; + DLGITEMTEMPLATE *item; - data_block = malloc(16384); - dlg = (DLGTEMPLATE *)data_block; - int y = 10; - int id = IDC_CONFIG_BASE; + data_block = malloc(16384); + dlg = (DLGTEMPLATE *)data_block; + int y = 10; + int id = IDC_CONFIG_BASE; - deviceconfig_changed = 0; + deviceconfig_changed = 0; - memset(data_block, 0, 16384); - - dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU; - dlg->x = 10; - dlg->y = 10; - dlg->cx = 220; - dlg->cy = 70; - - data = (uint16_t *)(dlg + 1); - - *data++ = 0; /*no menu*/ - *data++ = 0; /*predefined dialog box class*/ - data += MultiByteToWideChar(CP_ACP, 0, "Device Configuration", -1, data, 120); + memset(data_block, 0, 16384); - *data++ = 9; /*Point*/ - data += MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, data, 120); - - if (((uintptr_t)data) & 2) - data++; + dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU; + dlg->x = 10; + dlg->y = 10; + dlg->cx = 220; + dlg->cy = 70; - while (config->type != -1) - { - switch (config->type) - { - case CONFIG_BINARY: - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; - - item->cx = 80; - item->cy = 15; + data = (uint16_t *)(dlg + 1); - item->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX; + *data++ = 0; /*no menu*/ + *data++ = 0; /*predefined dialog box class*/ + data += MultiByteToWideChar(CP_ACP, 0, "Device Configuration", -1, data, 120); - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0080; /* button class */ + *data++ = 9; /*Point*/ + data += MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, data, 120); - data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); - *data++ = 0; /* no creation data */ + if (((uintptr_t)data) & 2) + data++; - y += 20; - break; + while (config->type != -1) { + switch (config->type) { + case CONFIG_BINARY: + item = (DLGITEMTEMPLATE *)data; + item->x = 10; + item->y = y; + item->id = id++; - case CONFIG_SELECTION: - case CONFIG_MIDI: - case CONFIG_HEX16: - case CONFIG_HEX20: - /*Combo box*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 70; - item->y = y; - item->id = id++; - - item->cx = 140; - item->cy = 150; + item->cx = 80; + item->cy = 15; - item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL; + item->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX; - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0085; /* combo box class */ + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0080; /* button class */ - data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); - *data++ = 0; /* no creation data */ - - if (((uintptr_t)data) & 2) - data++; + data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); + *data++ = 0; /* no creation data */ - /*Static text*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; - - item->cx = 60; - item->cy = 15; + y += 20; + break; - item->style = WS_CHILD | WS_VISIBLE; + case CONFIG_SELECTION: + case CONFIG_MIDI: + case CONFIG_HEX16: + case CONFIG_HEX20: + /*Combo box*/ + item = (DLGITEMTEMPLATE *)data; + item->x = 70; + item->y = y; + item->id = id++; - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0082; /* static class */ + item->cx = 140; + item->cy = 150; - data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); - *data++ = 0; /* no creation data */ - - if (((uintptr_t)data) & 2) - data++; + item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL; - y += 20; - break; + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0085; /* combo box class */ - case CONFIG_SPINNER: - /*Spinner*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 70; - item->y = y; - item->id = id++; + data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); + *data++ = 0; /* no creation data */ - item->cx = 140; - item->cy = 14; + if (((uintptr_t)data) & 2) + data++; - item->style = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_NUMBER; - item->dwExtendedStyle = WS_EX_CLIENTEDGE; + /*Static text*/ + item = (DLGITEMTEMPLATE *)data; + item->x = 10; + item->y = y; + item->id = id++; - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0081; /* edit text class */ + item->cx = 60; + item->cy = 15; - data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256); - *data++ = 0; /* no creation data */ + item->style = WS_CHILD | WS_VISIBLE; - if (((uintptr_t)data) & 2) - data++; + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0082; /* static class */ - /* TODO: add up down class */ - /*Static text*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; + data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); + *data++ = 0; /* no creation data */ - item->cx = 60; - item->cy = 15; + if (((uintptr_t)data) & 2) + data++; - item->style = WS_CHILD | WS_VISIBLE; + y += 20; + break; + case CONFIG_SPINNER: + /*Spinner*/ + item = (DLGITEMTEMPLATE *)data; + item->x = 70; + item->y = y; + item->id = id++; - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0082; /* static class */ + item->cx = 140; + item->cy = 14; - data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); - *data++ = 0; /* no creation data */ + item->style = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_NUMBER; + item->dwExtendedStyle = WS_EX_CLIENTEDGE; - if (((uintptr_t)data) & 2) - data++; + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0081; /* edit text class */ - y += 20; - break; + data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256); + *data++ = 0; /* no creation data */ - case CONFIG_FNAME: - /*File*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 70; - item->y = y; - item->id = id++; + if (((uintptr_t)data) & 2) + data++; - item->cx = 100; - item->cy = 14; + /* TODO: add up down class */ + /*Static text*/ + item = (DLGITEMTEMPLATE *)data; + item->x = 10; + item->y = y; + item->id = id++; - item->style = WS_CHILD | WS_VISIBLE | ES_READONLY; - item->dwExtendedStyle = WS_EX_CLIENTEDGE; + item->cx = 60; + item->cy = 15; - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0081; /* edit text class */ + item->style = WS_CHILD | WS_VISIBLE; - data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256); - *data++ = 0; /* no creation data */ + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0082; /* static class */ - if (((uintptr_t)data) & 2) - data++; + data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); + *data++ = 0; /* no creation data */ - /* Button */ - item = (DLGITEMTEMPLATE *)data; - item->x = 175; - item->y = y; - item->id = id++; + if (((uintptr_t)data) & 2) + data++; - item->cx = 35; - item->cy = 14; + y += 20; + break; + case CONFIG_FNAME: + /*File*/ + item = (DLGITEMTEMPLATE *)data; + item->x = 70; + item->y = y; + item->id = id++; - item->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; + item->cx = 100; + item->cy = 14; - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0080; /* button class */ + item->style = WS_CHILD | WS_VISIBLE | ES_READONLY; + item->dwExtendedStyle = WS_EX_CLIENTEDGE; - data += MultiByteToWideChar(CP_ACP, 0, "Browse", -1, data, 256); - *data++ = 0; /* no creation data */ + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0081; /* edit text class */ - if (((uintptr_t)data) & 2) - data++; + data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256); + *data++ = 0; /* no creation data */ - /*Static text*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; + if (((uintptr_t)data) & 2) + data++; - item->cx = 60; - item->cy = 15; + /* Button */ + item = (DLGITEMTEMPLATE *)data; + item->x = 175; + item->y = y; + item->id = id++; - item->style = WS_CHILD | WS_VISIBLE; + item->cx = 35; + item->cy = 14; - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0082; /* static class */ + item->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; - data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); - *data++ = 0; /* no creation data */ + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0080; /* button class */ - if (((uintptr_t)data) & 2) - data++; + data += MultiByteToWideChar(CP_ACP, 0, "Browse", -1, data, 256); + *data++ = 0; /* no creation data */ - y += 20; - break; - } + if (((uintptr_t)data) & 2) + data++; - if (((uintptr_t)data) & 2) - data++; + /*Static text*/ + item = (DLGITEMTEMPLATE *)data; + item->x = 10; + item->y = y; + item->id = id++; - config++; - } + item->cx = 60; + item->cy = 15; - dlg->cdit = (id - IDC_CONFIG_BASE) + 2; + item->style = WS_CHILD | WS_VISIBLE; - item = (DLGITEMTEMPLATE *)data; - item->x = 20; - item->y = y; - item->cx = 50; - item->cy = 14; - item->id = IDOK; /* OK button identifier */ - item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0082; /* static class */ - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0080; /* button class */ + data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256); + *data++ = 0; /* no creation data */ - data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50); - *data++ = 0; /* no creation data */ + if (((uintptr_t)data) & 2) + data++; - if (((uintptr_t)data) & 2) - data++; - - item = (DLGITEMTEMPLATE *)data; - item->x = 80; - item->y = y; - item->cx = 50; - item->cy = 14; - item->id = IDCANCEL; /* OK button identifier */ - item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; + y += 20; + break; + } - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0080; /* button class */ + if (((uintptr_t)data) & 2) + data++; - data += MultiByteToWideChar(CP_ACP, 0, "Cancel", -1, data, 50); - *data++ = 0; /* no creation data */ + config++; + } - dlg->cy = y + 20; - - config_device = device; - - DialogBoxIndirect(hinstance, dlg, hwnd, deviceconfig_dlgproc); + dlg->cdit = (id - IDC_CONFIG_BASE) + 2; - free(data_block); + item = (DLGITEMTEMPLATE *)data; + item->x = 20; + item->y = y; + item->cx = 50; + item->cy = 14; + item->id = IDOK; /* OK button identifier */ + item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; - return deviceconfig_changed; + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0080; /* button class */ + + data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50); + *data++ = 0; /* no creation data */ + + if (((uintptr_t)data) & 2) + data++; + + item = (DLGITEMTEMPLATE *)data; + item->x = 80; + item->y = y; + item->cx = 50; + item->cy = 14; + item->id = IDCANCEL; /* OK button identifier */ + item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; + + data = (uint16_t *)(item + 1); + *data++ = 0xFFFF; + *data++ = 0x0080; /* button class */ + + data += MultiByteToWideChar(CP_ACP, 0, "Cancel", -1, data, 50); + *data++ = 0; /* no creation data */ + + dlg->cy = y + 20; + + device_set_context(&config_device, device, inst); + + DialogBoxIndirect(hinstance, dlg, hwnd, deviceconfig_dlgproc); + + free(data_block); + + return deviceconfig_changed; +} + + +uint8_t +deviceconfig_open(HWND hwnd, const device_t *device) +{ + return deviceconfig_inst_open(hwnd, device, 0); } diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 2e14b84b4..76fe078f8 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -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, * David Hrdlička, @@ -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: