diff --git a/src/device.c b/src/device.c index ef0b59b2b..a13825307 100644 --- a/src/device.c +++ b/src/device.c @@ -347,6 +347,39 @@ device_available(const device_t *d) return (0); } +const char * +device_get_bios_file(const device_t *d, const char *internal_name, int file_no) +{ + device_config_t *config = NULL; + device_config_bios_t *bios = NULL; + + if (d != NULL) { + config = (device_config_t *) d->config; + if (config != NULL) { + while (config->type != -1) { + if (config->type == CONFIG_BIOS) { + bios = (device_config_bios_t *) config->bios; + + /* Go through the ROM's in the device configuration. */ + while (bios->files_no != 0) { + if (!strcmp(internal_name, bios->internal_name)) { + if (file_no < bios->files_no) + return bios->files[file_no]; + else + return NULL; + } + bios++; + } + } + config++; + } + } + } + + /* A NULL device is never available. */ + return (NULL); +} + int device_has_config(const device_t *d) { diff --git a/src/disk/hdc_xta.c b/src/disk/hdc_xta.c index c6abf9adf..589ec2789 100644 --- a/src/disk/hdc_xta.c +++ b/src/disk/hdc_xta.c @@ -104,7 +104,8 @@ #define HDC_TIME (50 * TIMER_USEC) -#define WD_BIOS_FILE "roms/hdd/xta/idexywd2.bin" +#define WD_REV_1_BIOS_FILE "roms/hdd/xta/idexywd2.bin" +#define WD_REV_2_BIOS_FILE "roms/hdd/xta/infowdbios.rom" enum { STATE_IDLE = 0, @@ -962,16 +963,11 @@ hdc_write(uint16_t port, uint8_t val, void *priv) } } -static int -xta_available(void) -{ - return (rom_present(WD_BIOS_FILE)); -} - static void * xta_init(const device_t *info) { drive_t *drive; + char *bios_rev = NULL; char *fn = NULL; hdc_t *dev; int c, i; @@ -990,7 +986,8 @@ xta_init(const device_t *info) dev->irq = device_get_config_int("irq"); dev->rom_addr = device_get_config_hex20("bios_addr"); dev->dma = 3; - fn = WD_BIOS_FILE; + bios_rev = (char *) device_get_config_bios("bios_rev"); + fn = (char *) device_get_bios_file(info, (const char *) bios_rev, 0); max = 1; break; @@ -1123,6 +1120,22 @@ static const device_config_t wdxt150_config[] = { { .description = "" } }, }, + { + .name = "bios_rev", + .description = "BIOS Revision", + .type = CONFIG_BIOS, + .default_string = "rev_1", + .default_int = 0, + .file_filter = "", + .spinner = { 0 }, /*W1*/ + .bios = { + { .name = "Revision 1.0", .internal_name = "rev_1", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 8192, .files = { WD_REV_1_BIOS_FILE, "" } }, + { .name = "Revision 2.0", .internal_name = "rev_2", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 8192, .files = { WD_REV_2_BIOS_FILE, "" } }, + { .files_no = 0 } + }, + }, { .name = "", .description = "", .type = CONFIG_END } // clang-format off }; @@ -1135,7 +1148,7 @@ const device_t xta_wdxt150_device = { .init = xta_init, .close = xta_close, .reset = NULL, - { .available = xta_available }, + { .available = NULL /*xta_available*/ }, .speed_changed = NULL, .force_redraw = NULL, .config = wdxt150_config diff --git a/src/include/86box/device.h b/src/include/86box/device.h index a8d100acc..ca4e6bdf2 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -90,7 +90,7 @@ typedef struct { int files_no; uint32_t local, size; void *dev1, *dev2; - const char **files; + const char *files[9]; } device_config_bios_t; typedef struct { @@ -108,7 +108,7 @@ typedef struct { const char *file_filter; const device_config_spinner_t spinner; const device_config_selection_t selection[16]; - const device_config_bios_t *bios; + const device_config_bios_t bios[32]; } device_config_t; typedef struct _device_ { @@ -164,6 +164,7 @@ 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 const char *device_get_bios_file(const device_t *d, const char *internal_name, int file_no); extern int device_is_valid(const device_t *, int m); diff --git a/src/win/win_devconf.c b/src/win/win_devconf.c index fee446310..c867dab9f 100644 --- a/src/win/win_devconf.c +++ b/src/win/win_devconf.c @@ -108,7 +108,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) c = 0; q = 0; - while (bios && bios->name && bios->name[0]) { + while (bios && (bios->files_no > 0)) { mbstowcs(lptsTemp, bios->name, strlen(bios->name) + 1); p = 0; for (d = 0; d < bios->files_no; d++) @@ -218,7 +218,6 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if (cid == IDOK) { id = IDC_CONFIG_BASE; config = config_device.dev->config; - bios = config->bios; changed = 0; char s[512]; @@ -251,6 +250,8 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) id += 2; break; case CONFIG_BIOS: + bios = config->bios; + val_str = config_get_string((char *) config_device.name, (char *) config->name, (char *) config->default_string); @@ -375,6 +376,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) id += 2; break; case CONFIG_BIOS: + bios = config->bios; c = combo_to_struct[SendMessage(h, CB_GETCURSEL, 0, 0)]; for (; c > 0; c--) bios++; @@ -551,6 +553,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst) case CONFIG_MIDI_IN: case CONFIG_HEX16: case CONFIG_HEX20: + case CONFIG_BIOS: /*Combo box*/ item = (DLGITEMTEMPLATE *) data; item->x = 70;