From f41f26a6e08d026429fd4c59f324a31557db2426 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 10 Feb 2025 02:43:32 -0500 Subject: [PATCH] The xtide (XT) ROM is now optionally writable --- src/disk/hdc_xtide.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/disk/hdc_xtide.c b/src/disk/hdc_xtide.c index fc18d79db..154a28cec 100644 --- a/src/disk/hdc_xtide.c +++ b/src/disk/hdc_xtide.c @@ -41,6 +41,7 @@ #include <86box/mem.h> #include <86box/rom.h> #include <86box/timer.h> +#include <86box/nvr.h> #include <86box/device.h> #include <86box/hdc.h> #include <86box/hdc_ide.h> @@ -58,6 +59,7 @@ typedef struct xtide_t { void *ide_board; uint8_t data_high; rom_t bios_rom; + char nvr_path[64]; } xtide_t; static void @@ -145,6 +147,18 @@ xtide_init(const device_t *info) xtide_read, NULL, NULL, xtide_write, NULL, NULL, xtide); + uint8_t rom_writes_enabled = device_get_config_int("rom_writes_enabled"); + + if (rom_writes_enabled) { + mem_mapping_set_write_handler(&xtide->bios_rom.mapping, rom_write, rom_writew, rom_writel); + sprintf(xtide->nvr_path, "xtide_%i.nvr", device_get_instance()); + FILE *fp = nvr_fopen(xtide->nvr_path, "rb"); + if (fp != NULL) { + fread(xtide->bios_rom.rom, 1, 0x2000, fp); + fclose(fp); + } + } + return xtide; } @@ -193,6 +207,14 @@ xtide_close(void *priv) { xtide_t *xtide = (xtide_t *) priv; + if (xtide->nvr_path[0] != 0x00) { + FILE *fp = nvr_fopen(xtide->nvr_path, "wb"); + if (fp != NULL) { + fwrite(xtide->bios_rom.rom, 1, 0x2000, fp); + fclose(fp); + } + } + free(xtide); ide_xtide_close(); @@ -275,6 +297,17 @@ static const device_config_t xtide_config[] = { }, .bios = { { 0 } } }, + { + .name = "rom_writes_enabled", + .description = "Enable BIOS extension ROM Writes", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, { .name = "bios_addr", .description = "BIOS Address",