diff --git a/src/86box.c b/src/86box.c index 246d06b16..3ade3c4e2 100644 --- a/src/86box.c +++ b/src/86box.c @@ -457,7 +457,7 @@ delete_nvr_file(uint8_t flash) int c; /* Set up the NVR file's name. */ - c = strlen(machine_get_internal_name()) + 5; + c = strlen(machine_get_nvr_name()) + 5; fn = (char *) malloc(c + 1); if (fn == NULL) @@ -465,9 +465,9 @@ delete_nvr_file(uint8_t flash) flash ? "BIOS flash" : "CMOS"); if (flash) - sprintf(fn, "%s.bin", machine_get_internal_name()); + sprintf(fn, "%s.bin", machine_get_nvr_name()); else - sprintf(fn, "%s.nvr", machine_get_internal_name()); + sprintf(fn, "%s.nvr", machine_get_nvr_name()); remove(nvr_path(fn)); diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 9e6c57e70..9f3b6e079 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -105,7 +105,7 @@ static const device_t cdrom_interface_none_device = { .init = NULL, .close = NULL, .reset = NULL, - { .available = NULL }, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = NULL diff --git a/src/chipset/sis_5513_p2i.c b/src/chipset/sis_5513_p2i.c index 3655ccc3f..95a890fcf 100644 --- a/src/chipset/sis_5513_p2i.c +++ b/src/chipset/sis_5513_p2i.c @@ -1287,9 +1287,9 @@ sis_5513_pci_to_isa_init(UNUSED(const device_t *info)) acpi_set_nvr(dev->sis->acpi, dev->nvr); /* Set up the NVR file's name. */ - c = strlen(machine_get_internal_name()) + 9; + c = strlen(machine_get_nvr_name()) + 9; dev->fn = (char *) malloc(c + 1); - sprintf(dev->fn, "%s_apc.nvr", machine_get_internal_name()); + sprintf(dev->fn, "%s_apc.nvr", machine_get_nvr_name()); fp = nvr_fopen(dev->fn, "rb"); diff --git a/src/device/hwm_lm78.c b/src/device/hwm_lm78.c index 1e61168ac..909713833 100644 --- a/src/device/hwm_lm78.c +++ b/src/device/hwm_lm78.c @@ -102,9 +102,9 @@ lm78_log(const char *fmt, ...) void lm78_nvram(lm78_t *dev, uint8_t save) { - size_t l = strlen(machine_get_internal_name_ex(machine)) + 14; + size_t l = strlen(machine_get_nvr_name_ex(machine)) + 14; char *nvr_path = (char *) malloc(l); - sprintf(nvr_path, "%s_as99127f.nvr", machine_get_internal_name_ex(machine)); + sprintf(nvr_path, "%s_as99127f.nvr", machine_get_nvr_name_ex(machine)); FILE *fp = nvr_fopen(nvr_path, save ? "wb" : "rb"); if (fp) { diff --git a/src/device/mouse.c b/src/device/mouse.c index 604109668..f0446d781 100644 --- a/src/device/mouse.c +++ b/src/device/mouse.c @@ -61,7 +61,7 @@ static const device_t mouse_none_device = { .init = NULL, .close = NULL, .reset = NULL, - { .poll = NULL }, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = NULL @@ -75,7 +75,7 @@ static const device_t mouse_internal_device = { .init = NULL, .close = NULL, .reset = NULL, - { .poll = NULL }, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = NULL @@ -111,7 +111,6 @@ static atomic_int mouse_buttons; static int mouse_delta_b; static int mouse_old_b; -static const device_t *mouse_curr; static void *mouse_priv; static int mouse_nbut; static int mouse_raw; @@ -537,17 +536,10 @@ mouse_get_abs_coords(double *x_abs, double *y_abs) void mouse_process(void) { - if (mouse_curr == NULL) - return; - if ((mouse_input_mode >= 1) && mouse_poll_ex) mouse_poll_ex(); - else if ((mouse_input_mode == 0) && ((mouse_dev_poll != NULL) || (mouse_curr->poll != NULL))) { - if (mouse_curr->poll != NULL) - mouse_curr->poll(mouse_priv); - else - mouse_dev_poll(mouse_priv); - } + else if ((mouse_input_mode == 0) && (mouse_dev_poll != NULL)) + mouse_dev_poll(mouse_priv); } void @@ -559,9 +551,6 @@ mouse_set_poll_ex(void (*poll_ex)(void)) void mouse_set_poll(int (*func)(void *), void *arg) { - if (mouse_type != MOUSE_TYPE_INTERNAL) - return; - mouse_dev_poll = func; mouse_priv = arg; } @@ -629,7 +618,7 @@ mouse_set_raw(int raw) void mouse_reset(void) { - if (mouse_curr != NULL) + if (mouse_priv != NULL) return; /* Mouse already initialized. */ mouse_log("MOUSE: reset(type=%d, '%s')\n", @@ -651,19 +640,13 @@ mouse_reset(void) sample_rate = 100.0; timer_on_auto(&mouse_timer, 1000000.0 / sample_rate); - mouse_curr = mouse_devices[mouse_type].device; - - if ((mouse_type > 1) && (mouse_curr != NULL)) - mouse_priv = device_add(mouse_curr); + if ((mouse_type > 1) && (mouse_devices[mouse_type].device != NULL)) + mouse_priv = device_add(mouse_devices[mouse_type].device); } void mouse_close(void) { - if (mouse_curr == NULL) - return; - - mouse_curr = NULL; mouse_priv = NULL; mouse_nbut = 0; mouse_dev_poll = NULL; @@ -680,7 +663,6 @@ mouse_init(void) mouse_clear_buttons(); mouse_type = MOUSE_TYPE_NONE; - mouse_curr = NULL; mouse_priv = NULL; mouse_nbut = 0; mouse_dev_poll = NULL; diff --git a/src/device/mouse_bus.c b/src/device/mouse_bus.c index c0f161dbd..7074a71ac 100644 --- a/src/device/mouse_bus.c +++ b/src/device/mouse_bus.c @@ -680,6 +680,8 @@ bm_init(const device_t *info) mouse_set_sample_rate(0.0); + mouse_set_poll(bm_poll, dev); + return dev; } @@ -818,7 +820,7 @@ const device_t mouse_logibus_device = { .init = bm_init, .close = bm_close, .reset = NULL, - .poll = bm_poll, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = lt_config @@ -832,7 +834,7 @@ const device_t mouse_logibus_onboard_device = { .init = bm_init, .close = bm_close, .reset = NULL, - .poll = bm_poll, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = NULL @@ -846,7 +848,7 @@ const device_t mouse_msinport_device = { .init = bm_init, .close = bm_close, .reset = NULL, - .poll = bm_poll, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = ms_config diff --git a/src/device/mouse_microtouch_touchscreen.c b/src/device/mouse_microtouch_touchscreen.c index 15b42bfdd..512fcc0df 100644 --- a/src/device/mouse_microtouch_touchscreen.c +++ b/src/device/mouse_microtouch_touchscreen.c @@ -525,6 +525,7 @@ mtouch_init(UNUSED(const device_t *info)) mouse_input_mode = device_get_config_int("crosshair") + 1; mouse_set_buttons(2); + mouse_set_poll(mtouch_poll, dev); mouse_set_poll_ex(mtouch_poll_global); mtouch_inst = dev; @@ -605,7 +606,7 @@ const device_t mouse_mtouch_device = { .init = mtouch_init, .close = mtouch_close, .reset = NULL, - .poll = mtouch_poll, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = mtouch_config diff --git a/src/device/mouse_ps2.c b/src/device/mouse_ps2.c index 9afc75410..8d98b07ce 100644 --- a/src/device/mouse_ps2.c +++ b/src/device/mouse_ps2.c @@ -352,6 +352,8 @@ mouse_ps2_init(const device_t *info) if (dev->port != NULL) kbc_at_dev_reset(dev, 0); + mouse_set_poll(ps2_poll, dev); + /* Return our private data to the I/O layer. */ return dev; } @@ -397,7 +399,7 @@ const device_t mouse_ps2_device = { .init = mouse_ps2_init, .close = ps2_close, .reset = NULL, - .poll = ps2_poll, + .available = NULL, .speed_changed = NULL, .force_redraw = NULL, .config = ps2_config diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index be9bc62e1..96d3a867c 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -909,6 +909,8 @@ sermouse_init(const device_t *info) /* Tell them how many buttons we have. */ mouse_set_buttons(dev->but); + mouse_set_poll(sermouse_poll, dev); + /* Return our private data to the I/O layer. */ return dev; } @@ -1075,7 +1077,7 @@ const device_t mouse_mssystems_device = { .init = sermouse_init, .close = sermouse_close, .reset = NULL, - .poll = sermouse_poll, + .available = NULL, .speed_changed = sermouse_speed_changed, .force_redraw = NULL, .config = msssermouse_config @@ -1089,7 +1091,7 @@ const device_t mouse_msserial_device = { .init = sermouse_init, .close = sermouse_close, .reset = NULL, - .poll = sermouse_poll, + .available = NULL, .speed_changed = sermouse_speed_changed, .force_redraw = NULL, .config = mssermouse_config @@ -1103,7 +1105,7 @@ const device_t mouse_ltserial_device = { .init = sermouse_init, .close = sermouse_close, .reset = NULL, - .poll = sermouse_poll, + .available = NULL, .speed_changed = sermouse_speed_changed, .force_redraw = NULL, .config = ltsermouse_config diff --git a/src/device/mouse_wacom_tablet.c b/src/device/mouse_wacom_tablet.c index 79b674e07..3b50882ab 100644 --- a/src/device/mouse_wacom_tablet.c +++ b/src/device/mouse_wacom_tablet.c @@ -662,8 +662,10 @@ wacom_init(const device_t *info) if (dev->tablet_type->type == WACOM_TYPE_IV) { wacom_reset_artpad(dev); wacom_process_settings_dword(dev, 0xE2018000); - } - else wacom_reset(dev); + } else + wacom_reset(dev); + + mouse_set_poll(wacom_poll, dev); return dev; } @@ -721,7 +723,7 @@ const device_t mouse_wacom_device = { .init = wacom_init, .close = wacom_close, .reset = NULL, - .poll = wacom_poll, + .available = NULL, .speed_changed = wacom_speed_changed, .force_redraw = NULL, .config = wacom_config @@ -735,7 +737,7 @@ const device_t mouse_wacom_artpad_device = { .init = wacom_init, .close = wacom_close, .reset = NULL, - .poll = wacom_poll, + .available = NULL, .speed_changed = wacom_speed_changed, .force_redraw = NULL, .config = wacom_config diff --git a/src/device/serial_passthrough.c b/src/device/serial_passthrough.c index 256f9eaa9..3ad969006 100644 --- a/src/device/serial_passthrough.c +++ b/src/device/serial_passthrough.c @@ -366,7 +366,7 @@ const device_t serial_passthrough_device = { .init = serial_passthrough_dev_init, .close = serial_passthrough_dev_close, .reset = NULL, - .poll = NULL, + .available = NULL, .speed_changed = serial_passthrough_speed_changed, .force_redraw = NULL, .config = serial_passthrough_config diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index a381f67f1..f0a32df75 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -100,10 +100,10 @@ d86f_handler_t d86f_handler[FDD_NUM]; static const struct { - char *ext; - void (*load)(int drive, char *fn); - void (*close)(int drive); - int size; + const char *ext; + void (*load)(int drive, char *fn); + void (*close)(int drive); + int size; } loaders[] = { { "001", img_load, img_close, -1}, { "002", img_load, img_close, -1}, diff --git a/src/include/86box/device.h b/src/include/86box/device.h index b5a4c1925..479e4cbb6 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -165,10 +165,8 @@ typedef struct _device_ { }; void (*close)(void *priv); void (*reset)(void *priv); - union { - int (*available)(void); - int (*poll)(void *priv); - }; + int (*available)(void); + int (*poll)(void *priv); void (*speed_changed)(void *priv); void (*force_redraw)(void *priv); diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index f39187dd9..1ce46de9b 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -361,6 +361,7 @@ extern int machine_available(int m); extern const char *machine_getname(void); extern const char *machine_getname_ex(int m); extern const char *machine_get_internal_name(void); +extern const char *machine_get_nvr_name(void); extern int machine_get_machine_from_internal_name(const char *s); extern void machine_init(void); #ifdef EMU_DEVICE_H @@ -373,6 +374,7 @@ extern const device_t *machine_get_snd_device(int m); extern const device_t *machine_get_net_device(int m); #endif extern const char *machine_get_internal_name_ex(int m); +extern const char *machine_get_nvr_name_ex(int m); extern int machine_get_nvrmask(int m); extern int machine_has_flags(int m, int flags); extern int machine_has_bus(int m, int bus_flags); diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 3d152065b..19c4b535e 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -696,7 +696,7 @@ static const device_config_t pb450_config[] = { .file_filter = "", .spinner = { 0 }, .bios = { - { .name = "PCI 1.0A", .internal_name = "pci10a", .bios_type = BIOS_NORMAL, + { .name = "PCI 1.0A", .internal_name = "pb450" /*"pci10a"*/, .bios_type = BIOS_NORMAL, .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/pb450/OPTI802.bin", "" } }, { .name = "PNP 1.1A", .internal_name = "pnp11a", .bios_type = BIOS_NORMAL, .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/pb450/PNP11A.bin", "" } }, diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 458b54013..e6198541e 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -16565,3 +16565,26 @@ machine_is_sony(void) { return (!strcmp(machines[machine].internal_name, "pcv90")); } + +const char * +machine_get_nvr_name_ex(int m) +{ + const char *ret = machines[m].internal_name; + const device_t *dev = machine_get_device(m); + + if (dev != NULL) { + device_context(dev); + const char *bios = device_get_config_string("bios"); + if ((bios != NULL) && (strcmp(bios, "") != 0)) + ret = bios; + device_context_restore(); + } + + return ret; +} + +const char * +machine_get_nvr_name(void) +{ + return machine_get_nvr_name_ex(machine); +} diff --git a/src/mem/catalyst_flash.c b/src/mem/catalyst_flash.c index fd2bb739f..00e2422a3 100644 --- a/src/mem/catalyst_flash.c +++ b/src/mem/catalyst_flash.c @@ -194,7 +194,7 @@ catalyst_flash_init(UNUSED(const device_t *info)) dev = calloc(1, sizeof(flash_t)); - sprintf(flash_path, "%s.bin", machine_get_internal_name_ex(machine)); + sprintf(flash_path, "%s.bin", machine_get_nvr_name_ex(machine)); mem_mapping_disable(&bios_mapping); mem_mapping_disable(&bios_high_mapping); diff --git a/src/mem/intel_flash.c b/src/mem/intel_flash.c index 7375b1f42..e193f3545 100644 --- a/src/mem/intel_flash.c +++ b/src/mem/intel_flash.c @@ -353,7 +353,7 @@ intel_flash_init(const device_t *info) dev = calloc(1, sizeof(flash_t)); - sprintf(flash_path, "%s.bin", machine_get_internal_name_ex(machine)); + sprintf(flash_path, "%s.bin", machine_get_nvr_name_ex(machine)); dev->flags = info->local & 0xff; diff --git a/src/mem/sst_flash.c b/src/mem/sst_flash.c index 5a9c9c877..b41e0f2e2 100644 --- a/src/mem/sst_flash.c +++ b/src/mem/sst_flash.c @@ -507,7 +507,7 @@ sst_init(const device_t *info) FILE *fp; sst_t *dev = calloc(1, sizeof(sst_t)); - sprintf(flash_path, "%s.bin", machine_get_internal_name_ex(machine)); + sprintf(flash_path, "%s.bin", machine_get_nvr_name_ex(machine)); mem_mapping_disable(&bios_mapping); mem_mapping_disable(&bios_high_mapping); diff --git a/src/network/net_modem.c b/src/network/net_modem.c index 62621391c..a8eab4290 100644 --- a/src/network/net_modem.c +++ b/src/network/net_modem.c @@ -1621,7 +1621,7 @@ const device_t modem_device = { .init = modem_init, .close = modem_close, .reset = NULL, - .poll = NULL, + .available = NULL, .speed_changed = modem_speed_changed, .force_redraw = NULL, .config = modem_config diff --git a/src/nvr.c b/src/nvr.c index d0b05b93a..7f43a76c1 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -161,9 +161,9 @@ nvr_init(nvr_t *nvr) int c; /* Set up the NVR file's name. */ - c = strlen(machine_get_internal_name()) + 5; + c = strlen(machine_get_nvr_name()) + 5; nvr->fn = (char *) malloc(c + 1); - sprintf(nvr->fn, "%s.nvr", machine_get_internal_name()); + sprintf(nvr->fn, "%s.nvr", machine_get_nvr_name()); /* Initialize the internal clock as needed. */ memset(&intclk, 0x00, sizeof(intclk)); diff --git a/src/nvr_ps2.c b/src/nvr_ps2.c index 3ca0b0ba5..febf6c165 100644 --- a/src/nvr_ps2.c +++ b/src/nvr_ps2.c @@ -122,9 +122,9 @@ ps2_nvr_init(const device_t *info) nvr->size = 8192; /* Set up the NVR file's name. */ - c = strlen(machine_get_internal_name()) + 9; + c = strlen(machine_get_nvr_name()) + 9; nvr->fn = (char *) malloc(c + 1); - sprintf(nvr->fn, "%s_sec.nvr", machine_get_internal_name()); + sprintf(nvr->fn, "%s_sec.nvr", machine_get_nvr_name()); io_sethandler(0x0074, 3, ps2_nvr_read, NULL, NULL, ps2_nvr_write, NULL, NULL, nvr);