From 3cec306ecf6ee9c4b2e64f78843d0d9a232de61e Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 4 Apr 2022 18:11:39 +0200 Subject: [PATCH] Device config fix, phase 1. --- src/device.c | 23 +++++++++++++++++++++++ src/include/86box/device.h | 1 + src/video/vid_table.c | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 136c11446..75ea59ff4 100644 --- a/src/device.c +++ b/src/device.c @@ -339,6 +339,29 @@ device_available(const device_t *d) } +int +device_has_config(const device_t *d) +{ + int c = 0; + + if (d == NULL) + return 0; + + if (d->config == NULL) + return 0; + + config = d->config; + + while (config->type != -1) { + if (config->type != CONFIG_MAC) + c++; + config++; + } + + return (c > 0) ? 1 : 0; +} + + int device_poll(const device_t *d, int x, int y, int z, int b) { diff --git a/src/include/86box/device.h b/src/include/86box/device.h index 28e9485ef..afd7c3731 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -147,6 +147,7 @@ extern void device_register_pci_slot(const device_t *d, int device, int type, i extern void device_speed_changed(void); extern void device_force_redraw(void); extern void device_get_name(const device_t *d, int bus, char *name); +extern int device_has_config(const device_t *d); extern int device_is_valid(const device_t *, int m); diff --git a/src/video/vid_table.c b/src/video/vid_table.c index ccd9c4071..02d5ad81c 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -364,7 +364,7 @@ video_card_has_config(int card) { if (video_cards[card].device == NULL) return(0); - return(video_cards[card].device->config ? 1 : 0); + return(device_has_config(video_cards[card].device) ? 1 : 0); }