diff --git a/src/86box.c b/src/86box.c index 59d47b440..66b9dc88d 100644 --- a/src/86box.c +++ b/src/86box.c @@ -70,6 +70,7 @@ #include <86box/unittester.h> #include <86box/novell_cardkey.h> #include <86box/isamem.h> +#include <86box/isarom.h> #include <86box/isartc.h> #include <86box/lpt.h> #include <86box/serial.h> @@ -181,6 +182,7 @@ int postcard_enabled = 0; /* (C) enable int unittester_enabled = 0; /* (C) enable unit tester device */ int gameport_type[GAMEPORT_MAX] = { 0, 0 }; /* (C) enable gameports */ int isamem_type[ISAMEM_MAX] = { 0, 0, 0, 0 }; /* (C) enable ISA mem cards */ +int isarom_type[ISAROM_MAX] = { 0, 0, 0, 0 }; /* (C) enable ISA ROM cards */ int isartc_type = 0; /* (C) enable ISA RTC card */ int gfxcard[GFXCARD_MAX] = { 0, 0 }; /* (C) graphics/video card */ int show_second_monitors = 1; /* (C) show non-primary monitors */ @@ -1472,6 +1474,10 @@ pc_reset_hard_init(void) zip_hard_reset(); + + /* Reset any ISA ROM cards. */ + isarom_reset(); + /* Reset any ISA RTC cards. */ isartc_reset(); @@ -1901,4 +1907,4 @@ int FindAccelerator(const char *name) { } // No key was found return -1; -} \ No newline at end of file +} diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 44bf2811c..e0fa8b0b6 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -979,28 +979,28 @@ cdrom_toc_dump(cdrom_t *dev) uint8_t b[65536] = { 0 }; int len = cdrom_read_toc(dev, b, CD_TOC_RAW, 0, 0, 65536); const char *fn2 = "d:\\86boxnew\\toc_cue.dmp"; - FILE * f = fopen(fn2, "wb"); - fwrite(b, 1, len, f); - fflush(f); - fclose(f); + FILE * fp = fopen(fn2, "wb"); + fwrite(b, 1, len, fp); + fflush(fp); + fclose(fp); cdrom_log(dev->log, "Written TOC of %i bytes to %s\n", len, fn2); memset(b, 0x00, 65536); len = cdrom_read_toc(dev, b, CD_TOC_NORMAL, 0, 0, 65536); fn2 = "d:\\86boxnew\\toc_cue_cooked.dmp"; - f = fopen(fn2, "wb"); - fwrite(b, 1, len, f); - fflush(f); - fclose(f); + fp = fopen(fn2, "wb"); + fwrite(b, 1, len, fp); + fflush(fp); + fclose(fp); cdrom_log(dev->log, "Written cooked TOC of %i bytes to %s\n", len, fn2); memset(b, 0x00, 65536); len = cdrom_read_toc(dev, b, CD_TOC_SESSION, 0, 0, 65536); fn2 = "d:\\86boxnew\\toc_cue_session.dmp"; - f = fopen(fn2, "wb"); - fwrite(b, 1, len, f); - fflush(f); - fclose(f); + fp = fopen(fn2, "wb"); + fwrite(b, 1, len, fp); + fflush(fp); + fclose(fp); cdrom_log(dev->log, "Written session TOC of %i bytes to %s\n", len, fn2); } #endif diff --git a/src/chipset/neat.c b/src/chipset/neat.c index 0661f89ee..0aa6fe5b6 100644 --- a/src/chipset/neat.c +++ b/src/chipset/neat.c @@ -988,7 +988,7 @@ neat_read(uint16_t port, void *priv) if ((dev->indx >= 0x60) && (dev->indx <= 0x6e)) ret = dev->regs[dev->indx]; else if (dev->indx == 0x6f) - ret = (dev->regs[dev->indx] & 0xfd) | ~(mem_a20_alt & 0x02); + ret = (dev->regs[dev->indx] & 0xfd) | ((~mem_a20_alt) & 0x02); break; default: diff --git a/src/config.c b/src/config.c index dfe0190ac..8039b9887 100644 --- a/src/config.c +++ b/src/config.c @@ -46,6 +46,7 @@ #include <86box/ini.h> #include <86box/config.h> #include <86box/isamem.h> +#include <86box/isarom.h> #include <86box/isartc.h> #include <86box/lpt.h> #include <86box/serial.h> @@ -1699,6 +1700,7 @@ load_other_peripherals(void) if (!novell_keycard_enabled) ini_section_delete_var(cat, "novell_keycard_enabled"); + // ISA RAM Boards for (uint8_t c = 0; c < ISAMEM_MAX; c++) { sprintf(temp, "isamem%d_type", c); @@ -1709,6 +1711,17 @@ load_other_peripherals(void) ini_section_delete_var(cat, temp); } + // ISA ROM Boards + for (uint8_t c = 0; c < ISAROM_MAX; c++) { + sprintf(temp, "isarom%d_type", c); + + p = ini_section_get_string(cat, temp, "none"); + isarom_type[c] = isarom_get_from_internal_name(p); + + if (!strcmp(p, "none")) + ini_section_delete_var(cat, temp); + } + p = ini_section_get_string(cat, "isartc_type", "none"); isartc_type = isartc_get_from_internal_name(p); @@ -1858,6 +1871,8 @@ config_load(void) cdrom[0].sound_on = 1; mem_size = 64; isartc_type = 0; + for (i = 0; i < ISAROM_MAX; i++) + isarom_type[i] = 0; for (i = 0; i < ISAMEM_MAX; i++) isamem_type[i] = 0; @@ -2706,6 +2721,7 @@ save_other_peripherals(void) else ini_section_set_int(cat, "novell_keycard_enabled", novell_keycard_enabled); + // ISA RAM Boards for (uint8_t c = 0; c < ISAMEM_MAX; c++) { sprintf(temp, "isamem%d_type", c); if (isamem_type[c] == 0) @@ -2715,6 +2731,16 @@ save_other_peripherals(void) isamem_get_internal_name(isamem_type[c])); } + // ISA ROM Boards + for (uint8_t c = 0; c < ISAROM_MAX; c++) { + sprintf(temp, "isarom%d_type", c); + if (isarom_type[c] == 0) + ini_section_delete_var(cat, temp); + else + ini_section_set_string(cat, temp, + isarom_get_internal_name(isarom_type[c])); + } + if (isartc_type == 0) ini_section_delete_var(cat, "isartc_type"); else diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index 486d40b07..ea89f5cd9 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -33,6 +33,7 @@ add_library(dev OBJECT i2c_gpio.c ibm_5161.c isamem.c + isarom.c isartc.c isapnp.c kbc_at.c diff --git a/src/device/isamem.c b/src/device/isamem.c index 62fb96f5d..b1095da1f 100644 --- a/src/device/isamem.c +++ b/src/device/isamem.c @@ -2165,12 +2165,12 @@ isamem_get_internal_name(int board) } int -isamem_get_from_internal_name(const char *s) +isamem_get_from_internal_name(const char *str) { int c = 0; while (boards[c].dev != NULL) { - if (!strcmp(boards[c].dev->internal_name, s)) + if (!strcmp(boards[c].dev->internal_name, str)) return c; c++; } diff --git a/src/device/isarom.c b/src/device/isarom.c new file mode 100644 index 000000000..238314c87 --- /dev/null +++ b/src/device/isarom.c @@ -0,0 +1,643 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Implementation of ISA ROM card Expansions. + * + * Authors: Jasmine Iwanek, + * + * Copyright 2025 Jasmine Iwanek. + */ +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include <86box/io.h> +#include <86box/device.h> +#include <86box/mem.h> +#include <86box/rom.h> +#include <86box/nvr.h> +#include <86box/isarom.h> + +#define ISAROM_CARD 0 +#define ISAROM_CARD_DUAL 1 +#define ISAROM_CARD_QUAD 2 + +#ifdef ENABLE_ISAROM_LOG +int isarom_do_log = ENABLE_ISAROM_LOG; + +static void +isarom_log(const char *fmt, ...) +{ + va_list ap; + + if (isarom_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +# define isarom_log(fmt, ...) +#endif + +typedef struct isarom_t { + struct { + rom_t rom; + uint32_t addr; + const char *fn; + uint32_t size; + uint32_t len; + char nvr_path[64]; + uint8_t wp; + } socket[4]; + uint8_t inst; + uint8_t type; +} isarom_t; + +static inline uint8_t +get_limit(uint8_t type) +{ + if (type == ISAROM_CARD_DUAL) + return 2; + if (type == ISAROM_CARD_QUAD) + return 4; + return 1; +} + +static inline void +isarom_save_nvr(char *path, uint8_t *data, size_t size) +{ + if (path[0] == 0x00) + return; + + FILE *fp = nvr_fopen(path, "wb"); + if (fp) { + fwrite(data, 1, size, fp); + fclose(fp); + } +} + +void +isarom_close(void *priv) +{ + isarom_t *dev = (isarom_t *) priv; + if (!priv) + return; + + for (uint8_t i = 0; i < get_limit(dev->type); i++) + if (dev->socket[i].rom.rom) { + isarom_log("isarom[%u]: saving NVR for socket %u -> %s (%u bytes)\n", + dev->inst, i, dev->socket[i].nvr_path, dev->socket[i].size); + isarom_save_nvr(dev->socket[i].nvr_path, dev->socket[i].rom.rom, dev->socket[i].size); + } + + free(dev); +} + +static void * +isarom_init(const device_t *info) +{ + isarom_t *dev = (isarom_t *) calloc(1, sizeof(isarom_t)); + if (!dev) + return NULL; + + dev->inst = device_get_instance(); + dev->type = (uint8_t) info->local; + + isarom_log("isarom[%u]: initializing device (type=%u)\n", dev->inst, dev->type); + + for (uint8_t i = 0; i < get_limit(dev->type); i++) { + char key_fn[12]; + char key_addr[14]; + char key_size[14]; + char key_writes[22]; + char suffix[4] = ""; + if (i > 0) + snprintf(suffix, sizeof(suffix), "%d", i + 1); + + snprintf(key_fn, sizeof(key_fn), "bios_fn%s", suffix); + snprintf(key_addr, sizeof(key_addr), "bios_addr%s", suffix); + snprintf(key_size, sizeof(key_size), "bios_size%s", suffix); + snprintf(key_writes, sizeof(key_writes), "rom_writes_enabled%s", suffix); + + dev->socket[i].fn = device_get_config_string(key_fn); + dev->socket[i].addr = device_get_config_hex20(key_addr); + dev->socket[i].size = device_get_config_int(key_size); + // Note: 2K is the smallest ROM I've found, but 86box's memory granularity is 4k, the number below is fine + // as we'll end up allocating no less than 4k due to the device config limits. + dev->socket[i].len = (dev->socket[i].size > 2048) ? dev->socket[i].size - 1 : 0; + dev->socket[i].wp = (uint8_t) device_get_config_int(key_writes) ? 1 : 0; + + isarom_log("isarom[%u]: socket %u: addr=0x%05X size=%u wp=%u fn=%s\n", + dev->inst, i, dev->socket[i].addr, dev->socket[i].size, + dev->socket[i].wp, dev->socket[i].fn ? dev->socket[i].fn : "(null)"); + + if (dev->socket[i].addr != 0 && dev->socket[i].fn != NULL) { + rom_init(&dev->socket[i].rom, + dev->socket[i].fn, + dev->socket[i].addr, + dev->socket[i].size, + dev->socket[i].len, + 0, + MEM_MAPPING_EXTERNAL); + + isarom_log("isarom[%u]: ROM initialized for socket %u\n", dev->inst, i); + + if (dev->socket[i].wp) { + mem_mapping_set_write_handler(&dev->socket[i].rom.mapping, rom_write, rom_writew, rom_writel); + snprintf(dev->socket[i].nvr_path, sizeof(dev->socket[i].nvr_path), "isarom_%i_%i.nvr", dev->inst, i + 1); + FILE *fp = nvr_fopen(dev->socket[i].nvr_path, "rb"); + if (fp != NULL) { + fread(dev->socket[i].rom.rom, 1, dev->socket[i].size, fp); + fclose(fp); + isarom_log("isarom[%u]: loaded %zu bytes from %s\n", dev->inst, read_bytes, dev->socket[i].nvr_path); + } else + isarom_log("isarom[%u]: NVR not found, skipping load (%s)\n", dev->inst, dev->socket[i].nvr_path); + } + } + } + + return dev; +} + +#define BIOS_FILE_FILTER "ROM files (*.bin *.rom)|*.bin,*.rom" + +#define BIOS_ADDR_SELECTION { \ + { "Disabled", 0x00000 }, \ + { "C000H", 0xc0000 }, \ + { "C200H", 0xc2000 }, \ + { "C400H", 0xc4000 }, \ + { "C600H", 0xc6000 }, \ + { "C800H", 0xc8000 }, \ + { "CA00H", 0xca000 }, \ + { "CC00H", 0xcc000 }, \ + { "CE00H", 0xce000 }, \ + { "D000H", 0xd0000 }, \ + { "D200H", 0xd2000 }, \ + { "D400H", 0xd4000 }, \ + { "D600H", 0xd6000 }, \ + { "D800H", 0xd8000 }, \ + { "DA00H", 0xda000 }, \ + { "DC00H", 0xdc000 }, \ + { "DE00H", 0xde000 }, \ + { "E000H", 0xe0000 }, \ + { "E200H", 0xe2000 }, \ + { "E400H", 0xe4000 }, \ + { "E600H", 0xe6000 }, \ + { "E800H", 0xe8000 }, \ + { "EA00H", 0xea000 }, \ + { "EC00H", 0xec000 }, \ + { "EE00H", 0xee000 }, \ + { "", 0 } \ +} + +#define BIOS_SIZE_SELECTION { \ + { "4K", 4096 }, \ + { "8K", 8192 }, \ + { "16K", 16384 }, \ + { "32K", 32768 }, \ + { "64K", 65536 }, \ + { "", 0 } \ +} + +// clang-format off +static const device_config_t isarom_config[] = { + { + .name = "bios_fn", + .description = "BIOS File", + .type = CONFIG_FNAME, + .default_string = NULL, + .default_int = 0, + .file_filter = BIOS_FILE_FILTER, + .spinner = { 0 }, + .selection = { }, + .bios = { { 0 } } + }, + { + .name = "bios_addr", + .description = "BIOS Address", + .type = CONFIG_HEX20, + .default_string = NULL, + .default_int = 0x00000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_ADDR_SELECTION, + .bios = { { 0 } } + }, + { + .name = "bios_size", + .description = "BIOS Size:", + .type = CONFIG_INT, + .default_string = NULL, + .default_int = 8192, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_SIZE_SELECTION, + .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 = "", .description = "", .type = CONFIG_END } +}; + +static const device_config_t isarom_dual_config[] = { + { + .name = "bios_fn", + .description = "BIOS File (ROM #1)", + .type = CONFIG_FNAME, + .default_string = NULL, + .default_int = 0, + .file_filter = BIOS_FILE_FILTER, + .spinner = { 0 }, + .selection = { }, + .bios = { { 0 } } + }, + { + .name = "bios_addr", + .description = "BIOS Address (ROM #1)", + .type = CONFIG_HEX20, + .default_string = NULL, + .default_int = 0x00000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_ADDR_SELECTION, + .bios = { { 0 } } + }, + { + .name = "bios_size", + .description = "BIOS Size (ROM #1):", + .type = CONFIG_INT, + .default_string = NULL, + .default_int = 8192, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_SIZE_SELECTION, + .bios = { { 0 } } + }, + { + .name = "rom_writes_enabled", + .description = "Enable BIOS extension ROM Writes (ROM #1)", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { + .name = "bios_fn2", + .description = "BIOS File (ROM #2)", + .type = CONFIG_FNAME, + .default_string = NULL, + .default_int = 0, + .file_filter = BIOS_FILE_FILTER, + .spinner = { 0 }, + .selection = { }, + .bios = { { 0 } } + }, + { + .name = "bios_addr2", + .description = "BIOS Address (ROM #2)", + .type = CONFIG_HEX20, + .default_string = NULL, + .default_int = 0x00000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_ADDR_SELECTION, + .bios = { { 0 } } + }, + { + .name = "bios_size2", + .description = "BIOS Size (ROM #2):", + .type = CONFIG_INT, + .default_string = NULL, + .default_int = 8192, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_SIZE_SELECTION, + .bios = { { 0 } } + }, + { + .name = "rom_writes_enabled2", + .description = "Enable BIOS extension ROM Writes (ROM #2)", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { .name = "", .description = "", .type = CONFIG_END } +}; + +static const device_config_t isarom_quad_config[] = { + { + .name = "bios_fn", + .description = "BIOS File (ROM #1)", + .type = CONFIG_FNAME, + .default_string = NULL, + .default_int = 0, + .file_filter = BIOS_FILE_FILTER, + .spinner = { 0 }, + .selection = { }, + .bios = { { 0 } } + }, + { + .name = "bios_addr", + .description = "BIOS Address (ROM #1)", + .type = CONFIG_HEX20, + .default_string = NULL, + .default_int = 0x00000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_ADDR_SELECTION, + .bios = { { 0 } } + }, + { + .name = "bios_size", + .description = "BIOS Size (ROM #1):", + .type = CONFIG_INT, + .default_string = NULL, + .default_int = 8192, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_SIZE_SELECTION, + .bios = { { 0 } } + }, + { + .name = "rom_writes_enabled", + .description = "Enable BIOS extension ROM Writes (ROM #1)", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { + .name = "bios_fn2", + .description = "BIOS File (ROM #2)", + .type = CONFIG_FNAME, + .default_string = NULL, + .default_int = 0, + .file_filter = BIOS_FILE_FILTER, + .spinner = { 0 }, + .selection = { }, + .bios = { { 0 } } + }, + { + .name = "bios_addr2", + .description = "BIOS Address (ROM #2)", + .type = CONFIG_HEX20, + .default_string = NULL, + .default_int = 0x00000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_ADDR_SELECTION, + .bios = { { 0 } } + }, + { + .name = "bios_size2", + .description = "BIOS Size (ROM #2):", + .type = CONFIG_INT, + .default_string = NULL, + .default_int = 8192, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_SIZE_SELECTION, + .bios = { { 0 } } + }, + { + .name = "rom_writes_enabled2", + .description = "Enable BIOS extension ROM Writes (ROM #2)", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { + .name = "bios_fn3", + .description = "BIOS File (ROM #3)", + .type = CONFIG_FNAME, + .default_string = NULL, + .default_int = 0, + .file_filter = "ROM files (*.bin *.rom)|*.bin,*.rom", + .spinner = { 0 }, + .selection = { }, + .bios = { { 0 } } + }, + { + .name = "bios_addr3", + .description = "BIOS Address (ROM #3)", + .type = CONFIG_HEX20, + .default_string = NULL, + .default_int = 0x00000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_ADDR_SELECTION, + .bios = { { 0 } } + }, + { + .name = "bios_size3", + .description = "BIOS Size (ROM #3):", + .type = CONFIG_INT, + .default_string = NULL, + .default_int = 8192, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_SIZE_SELECTION, + .bios = { { 0 } } + }, + { + .name = "rom_writes_enabled3", + .description = "Enable BIOS extension ROM Writes (ROM #3)", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { + .name = "bios_fn4", + .description = "BIOS File (ROM #4)", + .type = CONFIG_FNAME, + .default_string = NULL, + .default_int = 0, + .file_filter = BIOS_FILE_FILTER, + .spinner = { 0 }, + .selection = { }, + .bios = { { 0 } } + }, + { + .name = "bios_addr4", + .description = "BIOS Address (ROM #4)", + .type = CONFIG_HEX20, + .default_string = NULL, + .default_int = 0x00000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_ADDR_SELECTION, + .bios = { { 0 } } + }, + { + .name = "bios_size4", + .description = "BIOS Size (ROM #4):", + .type = CONFIG_INT, + .default_string = NULL, + .default_int = 8192, + .file_filter = NULL, + .spinner = { 0 }, + .selection = BIOS_SIZE_SELECTION, + .bios = { { 0 } } + }, + { + .name = "rom_writes_enabled4", + .description = "Enable BIOS extension ROM Writes (ROM #4)", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { .name = "", .description = "", .type = CONFIG_END } +}; +// clang-format on + +static const device_t isarom_device = { + .name = "Generic ISA ROM Board", + .internal_name = "isarom", + .flags = DEVICE_ISA, + .local = ISAROM_CARD, + .init = isarom_init, + .close = isarom_close, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = isarom_config +}; + +static const device_t isarom_dual_device = { + .name = "Generic Dual ISA ROM Board", + .internal_name = "isarom_dual", + .flags = DEVICE_ISA, + .local = ISAROM_CARD_DUAL, + .init = isarom_init, + .close = isarom_close, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = isarom_dual_config +}; + +static const device_t isarom_quad_device = { + .name = "Generic Quad ISA ROM Board", + .internal_name = "isarom_quad", + .flags = DEVICE_ISA, + .local = ISAROM_CARD_QUAD, + .init = isarom_init, + .close = isarom_close, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = isarom_quad_config +}; + +static const struct { + const device_t *dev; +} boards[] = { + // clang-format off + { &device_none }, + { &isarom_device }, + { &isarom_dual_device }, + { &isarom_quad_device }, + { NULL } + // clang-format on +}; + +void +isarom_reset(void) +{ + for (uint8_t i = 0; i < ISAROM_MAX; i++) { + if (isarom_type[i] == 0) + continue; + + /* Add the device instance to the system. */ + device_add_inst(boards[isarom_type[i]].dev, i + 1); + } +} + +const char * +isarom_get_name(int board) +{ + if (boards[board].dev == NULL) + return NULL; + + return (boards[board].dev->name); +} + +const char * +isarom_get_internal_name(int board) +{ + return device_get_internal_name(boards[board].dev); +} + +int +isarom_get_from_internal_name(const char *str) +{ + int c = 0; + + while (boards[c].dev != NULL) { + if (!strcmp(boards[c].dev->internal_name, str)) + return c; + c++; + } + + /* Not found. */ + return 0; +} + +const device_t * +isarom_get_device(int board) +{ + /* Add the device instance to the system. */ + return boards[board].dev; +} + +int +isarom_has_config(int board) +{ + if (boards[board].dev == NULL) + return 0; + + return (boards[board].dev->config ? 1 : 0); +} diff --git a/src/device/isartc.c b/src/device/isartc.c index 5d6b4aea4..0540dc1f0 100644 --- a/src/device/isartc.c +++ b/src/device/isartc.c @@ -532,8 +532,8 @@ isartc_init(const device_t *info) switch (dev->board) { case ISARTC_MM58167: /* Generic MM58167 RTC */ { - int rom_addr = device_get_config_hex20("bios_addr"); - if (rom_addr != -1) + uint32_t rom_addr = device_get_config_hex20("bios_addr"); + if (rom_addr != 0) rom_init(&dev->rom, ISARTC_ROM_MM58167_1, rom_addr, 0x0800, 0x7ff, 0, MEM_MAPPING_EXTERNAL); @@ -830,7 +830,7 @@ static const device_config_t mm58167_config[] = { .file_filter = NULL, .spinner = { 0 }, .selection = { - { .description = "Disabled", .value = -1 }, + { .description = "Disabled", .value = 0x00000 }, { .description = "C800H", .value = 0xc8000 }, { .description = "CA00H", .value = 0xca000 }, { .description = "CC00H", .value = 0xcc000 }, @@ -919,12 +919,12 @@ isartc_get_internal_name(int board) } int -isartc_get_from_internal_name(char *s) +isartc_get_from_internal_name(const char *str) { int c = 0; while (boards[c].dev != NULL) { - if (!strcmp(boards[c].dev->internal_name, s)) + if (!strcmp(boards[c].dev->internal_name, str)) return c; c++; } diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index ebc16cbfd..0b5391670 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -1653,8 +1653,8 @@ fdc_callback(void *priv) case 0x06: /* Read data */ case 0x0c: /* Read deleted data */ case 0x11: /* Scan equal */ + case 0x16: /* Verify */ case 0x19: /* Scan low or equal */ - case 0x1c: /* Verify */ case 0x1d: /* Scan high or equal */ if ((fdc->interrupt == 0x11) || (fdc->interrupt == 0x19) || (fdc->interrupt == 0x1D)) compare = 1; diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index d3d513b9f..31811069f 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -467,7 +467,7 @@ fdd_load(int drive, char *fn) int c = 0; int size; const char *p; - FILE * fp; + FILE *fp; fdd_log("FDD: loading drive %d with '%s'\n", drive, fn); diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 76f311d17..8bf303961 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -134,6 +134,7 @@ extern int postcard_enabled; /* (C) enable POST card */ extern int unittester_enabled; /* (C) enable unit tester device */ extern int gameport_type[]; /* (C) enable gameports */ extern int isamem_type[]; /* (C) enable ISA mem cards */ +extern int isarom_type[]; /* (C) enable ISA ROM cards */ extern int isartc_type; /* (C) enable ISA RTC card */ extern int sound_is_float; /* (C) sound uses FP values */ extern int voodoo_enabled; /* (C) video option */ diff --git a/src/include/86box/cdrom.h b/src/include/86box/cdrom.h index 5ff4170a2..a962a8635 100644 --- a/src/include/86box/cdrom.h +++ b/src/include/86box/cdrom.h @@ -106,10 +106,10 @@ enum { #define CDV EMU_VERSION_EX static const struct cdrom_drive_types_s { - const char * vendor; - const char * model; - const char * revision; - const char * internal_name; + const char *vendor; + const char *model; + const char *revision; + const char *internal_name; const int bus_type; /* SCSI standard for SCSI (or both) devices, early for IDE. */ const int scsi_std; @@ -296,7 +296,7 @@ typedef struct cdrom { uint8_t speed; uint8_t cur_speed; - void * priv; + void *priv; char image_path[1024]; char prev_image_path[1280]; @@ -322,10 +322,10 @@ typedef struct cdrom { const cdrom_ops_t *ops; - char * image_history[CD_IMAGE_HISTORY]; + char *image_history[CD_IMAGE_HISTORY]; - void * local; - void * log; + void *local; + void *log; void (*insert)(void *priv); void (*close)(void *priv); diff --git a/src/include/86box/cdrom_image.h b/src/include/86box/cdrom_image.h index 84dd66f37..e0760ff7e 100644 --- a/src/include/86box/cdrom_image.h +++ b/src/include/86box/cdrom_image.h @@ -33,6 +33,6 @@ typedef struct track_file_t { int motorola; } track_file_t; -extern void * image_open(cdrom_t *dev, const char *path); +extern void *image_open(cdrom_t *dev, const char *path); #endif /*CDROM_IMAGE_H*/ diff --git a/src/include/86box/config.h b/src/include/86box/config.h index 693f38ab7..34447266b 100644 --- a/src/include/86box/config.h +++ b/src/include/86box/config.h @@ -122,6 +122,7 @@ typedef struct config_t { int ide_qua_enabled; /* Quaternary IDE controller enabled */ int bugger_enabled; /* ISA bugger device enabled */ int isa_rtc_type; /* ISA RTC card */ + int isa_rom_type[ISAROM_MAX]; /* ISA ROM boards */ int isa_mem_type[ISAMEM_MAX]; /* ISA memory boards */ /* Hard disks category */ diff --git a/src/include/86box/hdd.h b/src/include/86box/hdd.h index eda4396ef..53514740d 100644 --- a/src/include/86box/hdd.h +++ b/src/include/86box/hdd.h @@ -159,7 +159,7 @@ typedef struct hard_disk_t { uint8_t pad; uint8_t pad0; - void * priv; + void *priv; char fn[1024]; /* Name of current image file */ /* Differential VHD parent file */ @@ -185,7 +185,7 @@ typedef struct hard_disk_t { uint8_t max_multiple_block; uint8_t pad1[3]; - const char * model; + const char *model; hdd_zone_t zones[HDD_MAX_ZONES]; diff --git a/src/include/86box/isamem.h b/src/include/86box/isamem.h index 51fe50e33..93f417e3e 100644 --- a/src/include/86box/isamem.h +++ b/src/include/86box/isamem.h @@ -42,7 +42,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #ifndef EMU_ISAMEM_H #define EMU_ISAMEM_H @@ -52,17 +51,12 @@ extern "C" { #endif -/* Global variables. */ -extern const device_t isamem_device; -extern const device_t isamem_brat80_device; -extern const device_t isamem_ev159_device; - /* Functions. */ extern void isamem_reset(void); extern const char *isamem_get_name(int t); extern const char *isamem_get_internal_name(int t); -extern int isamem_get_from_internal_name(const char *s); +extern int isamem_get_from_internal_name(const char *str); extern const device_t *isamem_get_device(int t); extern int isamem_has_config(int board); diff --git a/src/include/86box/isarom.h b/src/include/86box/isarom.h new file mode 100644 index 000000000..91cfa15a9 --- /dev/null +++ b/src/include/86box/isarom.h @@ -0,0 +1,37 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Implementation of ISA ROM card Expansions. + * + * Authors: Jasmine Iwanek, + * + * Copyright 2025 Jasmine Iwanek. + */ +#ifndef EMU_ISAROM_H +#define EMU_ISAROM_H + +#define ISAROM_MAX 4 /* max #cards in system */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Functions. */ +extern void isarom_reset(void); + +extern const char *isarom_get_name(int t); +extern const char *isarom_get_internal_name(int t); +extern int isarom_get_from_internal_name(const char *str); +extern const device_t *isarom_get_device(int t); +extern int isarom_has_config(int board); + +#ifdef __cplusplus +} +#endif + +#endif /*EMU_ISAROM_H*/ diff --git a/src/include/86box/isartc.h b/src/include/86box/isartc.h index 0224180b3..815daa5d6 100644 --- a/src/include/86box/isartc.h +++ b/src/include/86box/isartc.h @@ -42,7 +42,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #ifndef EMU_ISARTC_H #define EMU_ISARTC_H @@ -50,13 +49,11 @@ extern "C" { #endif -/* Global variables. */ - /* Functions. */ extern void isartc_reset(void); extern const char *isartc_get_internal_name(int t); -extern int isartc_get_from_internal_name(char *s); +extern int isartc_get_from_internal_name(const char *str); extern const device_t *isartc_get_device(int t); extern int isartc_has_config(int board); diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index c8166a973..112d140f8 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -664,6 +664,7 @@ extern int machine_at_p5sp4_init(const machine_t *); /* m_at_socket5.c */ extern int machine_at_plato_init(const machine_t *); extern int machine_at_dellplato_init(const machine_t *); +extern int machine_at_d842_init(const machine_t *); extern int machine_at_ambradp90_init(const machine_t *); extern int machine_at_p54np4_init(const machine_t *); extern int machine_at_586ip_init(const machine_t *); diff --git a/src/include/86box/mo.h b/src/include/86box/mo.h index f4e7e9809..fc297ffbb 100644 --- a/src/include/86box/mo.h +++ b/src/include/86box/mo.h @@ -110,13 +110,13 @@ typedef struct mo_drive_t { uint8_t pad; uint8_t pad0; - FILE * fp; - void * priv; + FILE *fp; + void *priv; char image_path[1024]; char prev_image_path[1024]; - char * image_history[MO_IMAGE_HISTORY]; + char *image_history[MO_IMAGE_HISTORY]; uint32_t type; uint32_t medium_size; @@ -129,16 +129,16 @@ typedef struct mo_drive_t { typedef struct mo_t { mode_sense_pages_t ms_pages_saved; - mo_drive_t * drv; + mo_drive_t *drv; #ifdef EMU_IDE_H - ide_tf_t * tf; + ide_tf_t *tf; #else - void * tf; + void *tf; #endif void * log; - uint8_t * buffer; + uint8_t *buffer; uint8_t atapi_cdb[16]; uint8_t current_cdb[16]; uint8_t sense[256]; diff --git a/src/include/86box/vid_ega.h b/src/include/86box/vid_ega.h index 0e28820ff..c4c0ea2d7 100644 --- a/src/include/86box/vid_ega.h +++ b/src/include/86box/vid_ega.h @@ -148,6 +148,8 @@ typedef struct ega_t { card should not attempt to display anything. */ void (*render_override)(void *priv); void * priv_parent; + + uint8_t alt_addr; /* 0 for 0x3XX range, 1 for 0x2XX range */ } ega_t; #endif diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 6de73f9f9..6b817f0ee 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -116,6 +116,7 @@ typedef struct svga_t { int lastline_draw; int displine; int fullchange; + int left_overscan; int x_add; int y_add; int pan; diff --git a/src/include/86box/zip.h b/src/include/86box/zip.h index 443ab1327..969ce27f5 100644 --- a/src/include/86box/zip.h +++ b/src/include/86box/zip.h @@ -58,13 +58,13 @@ typedef struct zip_drive_t { uint8_t pad; uint8_t pad0; - FILE * fp; - void * priv; + FILE *fp; + void *priv; char image_path[1024]; char prev_image_path[1024]; - char * image_history[ZIP_IMAGE_HISTORY]; + char *image_history[ZIP_IMAGE_HISTORY]; uint32_t is_250; uint32_t medium_size; @@ -74,16 +74,16 @@ typedef struct zip_drive_t { typedef struct zip_t { mode_sense_pages_t ms_pages_saved; - zip_drive_t * drv; + zip_drive_t *drv; #ifdef EMU_IDE_H - ide_tf_t * tf; + ide_tf_t *tf; #else - void * tf; + void *tf; #endif - void * log; + void *log; - uint8_t * buffer; + uint8_t *buffer; uint8_t atapi_cdb[16]; uint8_t current_cdb[16]; uint8_t sense[256]; diff --git a/src/machine/m_at.c b/src/machine/m_at.c index 13cd831ba..d2c4b99a2 100644 --- a/src/machine/m_at.c +++ b/src/machine/m_at.c @@ -154,32 +154,68 @@ machine_at_ps2_ide_init(const machine_t *model) static const device_config_t ibmat_config[] = { // clang-format off { - .name = "bios", - .description = "BIOS Version", - .type = CONFIG_BIOS, + .name = "bios", + .description = "BIOS Version", + .type = CONFIG_BIOS, .default_string = "ibm5170_111585", - .default_int = 0, - .file_filter = "", - .spinner = { 0 }, - .bios = { - { .name = "62X082x (11/15/85)", .internal_name = "ibm5170_111585", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmat/BIOS_5170_15NOV85_U27.BIN", "roms/machines/ibmat/BIOS_5170_15NOV85_U47.BIN", "" } }, + .default_int = 0, + .file_filter = "", + .spinner = { 0 }, + .bios = { + { + .name = "62X082x (11/15/85)", + .internal_name = "ibm5170_111585", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmat/BIOS_5170_15NOV85_U27.BIN", "roms/machines/ibmat/BIOS_5170_15NOV85_U47.BIN", "" } + }, + { + .name = "61X9266 (11/15/85) (Alt)", + .internal_name = "ibm5170_111585_alt", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmat/BIOS_5170_15NOV85_U27_61X9266.BIN", "roms/machines/ibmat/BIOS_5170_15NOV85_U47_61X9265.BIN", "" } + }, + { + .name = "648009x (06/10/85)", + .internal_name = "ibm5170_061085", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmat/BIOS_5170_10JUN85_U27.BIN", "roms/machines/ibmat/BIOS_5170_10JUN85_U47.BIN", "" } + }, + { + .name = "618102x (01/10/84)", + .internal_name = "ibm5170_011084", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmat/BIOS_5170_10JAN84_U27.BIN", "roms/machines/ibmat/BIOS_5170_10JAN84_U47.BIN", "" } + }, + // The following are Diagnostic ROMs. + { + .name = "Supersoft Diagnostics", + .internal_name = "diag_supersoft", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 2, + .size = 65536, + .files = { "roms/machines/diagnostic/5170_EVEN_LOW_U27_27256.bin", "roms/machines/diagnostic/5170_ODD_HIGH_U47_27256.bin", "" } + }, - { .name = "61X9266 (11/15/85) (Alt)", .internal_name = "ibm5170_111585_alt", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmat/BIOS_5170_15NOV85_U27_61X9266.BIN", "roms/machines/ibmat/BIOS_5170_15NOV85_U47_61X9265.BIN", "" } }, - - { .name = "648009x (06/10/85)", .internal_name = "ibm5170_061085", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmat/BIOS_5170_10JUN85_U27.BIN", "roms/machines/ibmat/BIOS_5170_10JUN85_U47.BIN", "" } }, - - { .name = "618102x (01/10/84)", .internal_name = "ibm5170_011084", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmat/BIOS_5170_10JAN84_U27.BIN", "roms/machines/ibmat/BIOS_5170_10JAN84_U47.BIN", "" } }, { .files_no = 0 } }, }, { - .name = "enable_5161", + .name = "enable_5161", .description = "IBM 5161 Expansion Unit", - .type = CONFIG_BINARY, + .type = CONFIG_BINARY, .default_int = 0 }, { .name = "", .description = "", .type = CONFIG_END } diff --git a/src/machine/m_at_socket5.c b/src/machine/m_at_socket5.c index 0d50fead8..3ed2bd2c7 100644 --- a/src/machine/m_at_socket5.c +++ b/src/machine/m_at_socket5.c @@ -80,6 +80,87 @@ machine_at_dellplato_init(const machine_t *model) return ret; } +int +machine_at_d842_init(const machine_t *model) + +{ + int ret = 0; + const char* fn; + + /* No ROMs available */ + if (!device_available(model->device)) + return ret; + + device_context(model->device); + fn = device_get_bios_file(machine_get_device(machine), device_get_config_bios("bios_versions"), 0); + ret = bios_load_linear(fn, 0x000e0000, 131072, 0); + device_context_restore(); + + machine_at_common_init(model); + + device_add(&ide_pci_2ch_device); + pci_init(PCI_CONFIG_TYPE_2 | PCI_NO_IRQ_STEERING); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x01, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); /* Onboard */ + pci_register_slot(0x03, PCI_CARD_VIDEO, 4, 0, 0, 0); /* Onboard */ + pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 3, 2, 4); /* Slot 01 */ + pci_register_slot(0x0E, PCI_CARD_NORMAL, 2, 1, 3, 4); /* Slot 02 */ + + device_add(&keyboard_ps2_pci_device); + device_add(&i430nx_device); + device_add(&sio_zb_device); + device_add(&fdc37c665_device); + device_add(&intel_flash_bxt_device); + + return ret; +} + +static const device_config_t d842_config[] = { + // clang-format off + { + .name = "bios_versions", + .description = "BIOS Versions", + .type = CONFIG_BIOS, + .default_string = "d842", + .default_int = 0, + .file_filter = "", + .spinner = { 0 }, /*W1*/ + .bios = { + { .name = "Version 1.03 Revision 1.03.842 (11/24/1994)", .internal_name = "d842", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/d842/d842.bin", "" } }, + { .name = "Version 4.04 Revision 1.05.842 (03/15/1996)", .internal_name = "d842_mar96", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/d842/d842_mar96.bin", "" } }, + { .name = "Version 4.04 Revision 1.06.842 (04/03/1998)", .internal_name = "d842_apr98", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/d842/d842_apr98.bin", "" } }, + { .name = "Version 4.04 Revision 1.07.842 (06/02/1998)", .internal_name = "d842_jun98", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/d842/d842_jun98.bin", "" } }, + { .name = "Version 1.03 Revision 1.09.842 (07/08/1996)", .internal_name = "d842_jul96", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/d842/d842_jul96.bin", "" } }, + { .name = "Version 1.03 Revision 1.10.842 (06/04/1998)", .internal_name = "d842_jun98_1", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/d842/d842_jun98_1.bin", "" } }, + + }, + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + + + +const device_t d842_device = { + .name = "Siemens-Nixdorf D842", + .internal_name = "d842", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = &d842_config[0] +}; + int machine_at_ambradp90_init(const machine_t *model) { @@ -394,6 +475,7 @@ machine_at_hawk_init(const machine_t *model) return ret; } + int machine_at_pt2000_init(const machine_t *model) { diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 13f9c52ca..d71d16c15 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -85,7 +85,7 @@ static const device_config_t ibmpc_config[] = { { .name = "Supersoft Diagnostics", .internal_name = "diag_supersoft", .bios_type = BIOS_NORMAL, .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/Supersoft_PCXT_8KB.bin", "" } }, { .name = "Ruud's Diagnostic Rom", .internal_name = "diag_ruuds", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.3_8kb.bin", "" } }, + .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.4_8kb.bin", "" } }, { .name = "XT RAM Test", .internal_name = "diag_xtramtest", .bios_type = BIOS_NORMAL, .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/xtramtest_8k.bin", "" } }, { .files_no = 0 } @@ -195,7 +195,7 @@ static const device_config_t ibmpc82_config[] = { { .name = "Supersoft Diagnostics", .internal_name = "diag_supersoft", .bios_type = BIOS_NORMAL, .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/Supersoft_PCXT_8KB.bin", "" } }, { .name = "Ruud's Diagnostic Rom", .internal_name = "diag_ruuds", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.3_8kb.bin", "" } }, + .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.4_8kb.bin", "" } }, { .name = "XT RAM Test", .internal_name = "diag_xtramtest", .bios_type = BIOS_NORMAL, .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/diagnostic/xtramtest_8k.bin", "" } }, { .files_no = 0 } @@ -282,48 +282,103 @@ machine_pc82_init(const machine_t *model) static const device_config_t ibmxt_config[] = { // clang-format off { - .name = "bios", - .description = "BIOS Version", - .type = CONFIG_BIOS, + .name = "bios", + .description = "BIOS Version", + .type = CONFIG_BIOS, .default_string = "ibm5160_1501512_5000027", - .default_int = 0, - .file_filter = "", - .spinner = { 0 }, - .bios = { - { .name = "1501512 (11/08/82)", .internal_name = "ibm5160_1501512_5000027", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmxt/BIOS_5160_08NOV82_U18_1501512.BIN", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_5000027.BIN", "" } }, - { .name = "1501512 (11/08/82) (Alt)", .internal_name = "ibm5160_1501512_6359116", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmxt/BIOS_5160_08NOV82_U18_1501512.BIN", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_6359116.BIN", "" } }, - { .name = "5000026 (08/16/82)", .internal_name = "ibm5160_5000026_5000027", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmxt/BIOS_5160_16AUG82_U18_5000026.BIN", "roms/machines/ibmxt/BIOS_5160_16AUG82_U19_5000027.BIN", "" } }, -#if 0 + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .bios = { + { + .name = "1501512 (11/08/82)", + .internal_name = "ibm5160_1501512_5000027", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmxt/BIOS_5160_08NOV82_U18_1501512.BIN", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_5000027.BIN", "" } + }, + { + .name = "1501512 (11/08/82) (Alt)", + .internal_name = "ibm5160_1501512_6359116", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmxt/BIOS_5160_08NOV82_U18_1501512.BIN", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_6359116.BIN", "" } + }, + { + .name = "5000026 (08/16/82)", + .internal_name = "ibm5160_5000026_5000027", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmxt/BIOS_5160_16AUG82_U18_5000026.BIN", "roms/machines/ibmxt/BIOS_5160_16AUG82_U19_5000027.BIN", "" } + }, + // GlaBIOS for IBM XT - { .name = "GlaBIOS 0.2.5 (8088)", .internal_name = "glabios_025_8088", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/glabios/GLABIOS_0.2.5_8X.ROM", "" } }, - { .name = "GlaBIOS 0.2.5 (V20)", .internal_name = "glabios_025_v20", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/glabios/GLABIOS_0.2.5_VX.ROM", "" } }, + { + .name = "GlaBIOS 0.2.5 (8088)", + .internal_name = "glabios_025_8088", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 1, + .size = 40960, + .files = { "roms/machines/glabios/GLABIOS_0.2.5_8X.ROM", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_5000027.BIN", "" } + }, + { + .name = "GlaBIOS 0.2.5 (V20)", + .internal_name = "glabios_025_v20", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 1, + .size = 40960, + .files = { "roms/machines/glabios/GLABIOS_0.2.5_VX.ROM", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_5000027.BIN", "" } + }, // The following are Diagnostic ROMs. - { .name = "Supersoft Diagnostics", .internal_name = "diag_supersoft", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 65536, .files = { "roms/machines/diagnostic/Supersoft_PCXT_8KB.bin", "" } }, - { .name = "Ruud's Diagnostic Rom", .internal_name = "diag_ruuds", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 65536, .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.3_8kb.bin", "" } }, - { .name = "XT RAM Test", .internal_name = "diag_xtramtest", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 65536, .files = { "roms/machines/diagnostic/xtramtest_8k.bin", "" } }, -#endif + { + .name = "Supersoft Diagnostics", + .internal_name = "diag_supersoft", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 2, + .size = 65536, + .files = { "roms/machines/diagnostic/Supersoft_PCXT_32KB.bin", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_5000027.BIN", "" } + }, + { + .name = "Ruud's Diagnostic Rom", + .internal_name = "diag_ruuds", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 2, + .size = 65536, + .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.4_32kb.bin", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_5000027.BIN", "" } + }, + { + .name = "XT RAM Test", + .internal_name = "diag_xtramtest", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 2, + .size = 65536, + .files = { "roms/machines/diagnostic/xtramtest_32k.bin", "roms/machines/ibmxt/BIOS_5160_08NOV82_U19_5000027.BIN", "" } + }, { .files_no = 0 } }, }, { - .name = "enable_5161", + .name = "enable_5161", .description = "IBM 5161 Expansion Unit", - .type = CONFIG_BINARY, + .type = CONFIG_BINARY, .default_int = 1 }, { - .name = "enable_basic", + .name = "enable_basic", .description = "IBM Cassette Basic", - .type = CONFIG_BINARY, + .type = CONFIG_BINARY, .default_int = 1 }, { .name = "", .description = "", .type = CONFIG_END } @@ -351,6 +406,8 @@ machine_xt_init(const machine_t *model) uint8_t enable_5161; uint8_t enable_basic; const char *fn; + uint16_t offset = 0; + uint32_t local = 0; /* No ROMs available. */ if (!device_available(model->device)) @@ -360,11 +417,17 @@ machine_xt_init(const machine_t *model) enable_5161 = machine_get_config_int("enable_5161"); enable_basic = machine_get_config_int("enable_basic"); fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 0); - ret = bios_load_linear(fn, 0x000fe000, 65536, 0x6000); + local = device_get_bios_local(model->device, device_get_config_bios("bios")); + + if (local == 0) // Offset for stock roms + offset = 0x6000; + ret = bios_load_linear(fn, 0x000fe000, 65536, offset); if (enable_basic && ret) { - fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 0); - (void) bios_load_aux_linear(fn, 0x000f8000, 24576, 0); + if (local == 0) { // needed for stock roms + fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 0); + (void) bios_load_aux_linear(fn, 0x000f8000, 24576, 0); + } fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 1); /* On the real machine, the BASIC is repeated. */ (void) bios_load_aux_linear(fn, 0x000f0000, 8192, 0); @@ -408,42 +471,98 @@ machine_genxt_init(const machine_t *model) static const device_config_t ibmxt86_config[] = { // clang-format off { - .name = "bios", - .description = "BIOS Version", - .type = CONFIG_BIOS, + .name = "bios", + .description = "BIOS Version", + .type = CONFIG_BIOS, .default_string = "ibm5160_050986", - .default_int = 0, - .file_filter = "", - .spinner = { 0 }, - .bios = { - { .name = "1501512 (05/09/86)", .internal_name = "ibm5160_050986", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmxt86/BIOS_5160_09MAY86_U18_59X7268_62X0890_27256_F800.BIN", "roms/machines/ibmxt86/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", "" } }, - { .name = "5000026 (01/10/86)", .internal_name = "ibm5160_011086", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmxt86/BIOS_5160_10JAN86_U18_62X0851_27256_F800.BIN", "roms/machines/ibmxt86/BIOS_5160_10JAN86_U19_62X0854_27256_F000.BIN", "" } }, - { .name = "1501512 (01/10/86) (Alt)", .internal_name = "ibm5160_011086_alt", .bios_type = BIOS_NORMAL, - .files_no = 2, .local = 0, .size = 65536, .files = { "roms/machines/ibmxt86/BIOS_5160_10JAN86_U18_62X0852_27256_F800.BIN", "roms/machines/ibmxt86/BIOS_5160_10JAN86_U19_62X0853_27256_F000.BIN", "" } }, -#if 0 + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .bios = { + { + .name = "1501512 (05/09/86)", + .internal_name = "ibm5160_050986", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmxt86/BIOS_5160_09MAY86_U18_59X7268_62X0890_27256_F800.BIN", "roms/machines/ibmxt86/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", "" } + }, + { + .name = "5000026 (01/10/86)", + .internal_name = "ibm5160_011086", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmxt86/BIOS_5160_10JAN86_U18_62X0851_27256_F800.BIN", "roms/machines/ibmxt86/BIOS_5160_10JAN86_U19_62X0854_27256_F000.BIN", "" } + }, + { + .name = "1501512 (01/10/86) (Alt)", + .internal_name = "ibm5160_011086_alt", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 0, + .size = 65536, + .files = { "roms/machines/ibmxt86/BIOS_5160_10JAN86_U18_62X0852_27256_F800.BIN", "roms/machines/ibmxt86/BIOS_5160_10JAN86_U19_62X0853_27256_F000.BIN", "" } + }, + // GlaBIOS for IBM XT - { .name = "GlaBIOS 0.2.5 (8088)", .internal_name = "glabios_025_8088", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/glabios/GLABIOS_0.2.5_8X.ROM", "" } }, - { .name = "GlaBIOS 0.2.5 (V20)", .internal_name = "glabios_025_v20", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 40960, .files = { "roms/machines/glabios/GLABIOS_0.2.5_VX.ROM", "" } }, + { + .name = "GlaBIOS 0.2.5 (8088)", + .internal_name = "glabios_025_8088", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 1, + .size = 65536, + .files = { "roms/machines/glabios/GLABIOS_0.2.5_8X.ROM", "roms/machines/ibmxt86/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", "" } + }, + { + .name = "GlaBIOS 0.2.5 (V20)", + .internal_name = "glabios_025_v20", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 1, + .size = 65536, + .files = { "roms/machines/glabios/GLABIOS_0.2.5_VX.ROM", "roms/machines/ibmxt86/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", "" } + }, // The following are Diagnostic ROMs. - { .name = "Supersoft Diagnostics", .internal_name = "diag_supersoft", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 65536, .files = { "roms/machines/diagnostic/Supersoft_PCXT_8KB.bin", "" } }, - { .name = "Ruud's Diagnostic Rom", .internal_name = "diag_ruuds", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 65536, .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.3_8kb.bin", "" } }, - { .name = "XT RAM Test", .internal_name = "diag_xtramtest", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 65536, .files = { "roms/machines/diagnostic/xtramtest_8k.bin", "" } }, -#endif + { + .name = "Supersoft Diagnostics", + .internal_name = "diag_supersoft", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 2, + .size = 65536, + .files = { "roms/machines/diagnostic/Supersoft_PCXT_32KB.bin", "roms/machines/ibmxt86/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", "" } + }, + { + .name = "Ruud's Diagnostic Rom", + .internal_name = "diag_ruuds", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 2, + .size = 65536, + .files = { "roms/machines/diagnostic/ruuds_diagnostic_rom_v5.4_32kb.bin", "roms/machines/ibmxt86/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", "" } + }, + { + .name = "XT RAM Test", + .internal_name = "diag_xtramtest", + .bios_type = BIOS_NORMAL, + .files_no = 2, + .local = 2, + .size = 65536, + .files = { "roms/machines/diagnostic/xtramtest_32k.bin", "roms/machines/ibmxt86/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", "" } + }, + { .files_no = 0 } }, }, { - .name = "enable_5161", + .name = "enable_5161", .description = "IBM 5161 Expansion Unit", - .type = CONFIG_BINARY, + .type = CONFIG_BINARY, .default_int = 1 }, { .name = "", .description = "", .type = CONFIG_END } @@ -470,6 +589,8 @@ machine_xt86_init(const machine_t *model) int ret = 0; uint8_t enable_5161; const char *fn; + uint16_t offset = 0; + uint32_t local = 0; /* No ROMs available. */ if (!device_available(model->device)) @@ -478,11 +599,17 @@ machine_xt86_init(const machine_t *model) device_context(model->device); enable_5161 = machine_get_config_int("enable_5161"); fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 0); - ret = bios_load_linear(fn, 0x000fe000, 65536, 0x6000); + local = device_get_bios_local(model->device, device_get_config_bios("bios")); + + if (local == 0) // Offset for stock roms + offset = 0x6000; + ret = bios_load_linear(fn, 0x000fe000, 65536, offset); if (ret) { - fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 0); - (void) bios_load_aux_linear(fn, 0x000f8000, 24576, 0); + if (local == 0) { // needed for stock roms + fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 0); + (void) bios_load_aux_linear(fn, 0x000f8000, 24576, 0); + } fn = device_get_bios_file(model->device, device_get_config_bios("bios"), 1); (void) bios_load_aux_linear(fn, 0x000f0000, 32768, 0); } diff --git a/src/machine/machine.c b/src/machine/machine.c index 505674000..6a86b785f 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -39,6 +39,7 @@ #include <86box/video.h> #include <86box/machine.h> #include <86box/isamem.h> +#include <86box/isarom.h> #include <86box/pci.h> #include <86box/plat_unused.h> @@ -111,6 +112,11 @@ machine_init_ex(int m) /* Reset any ISA memory cards. */ isamem_reset(); +#if 0 + /* Reset any ISA ROM cards. */ + isarom_reset(); +#endif + /* Reset the fast off stuff. */ cpu_fast_off_reset(); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index a961e9997..611e70c4d 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -66,6 +66,7 @@ extern const device_t vendex_device; extern const device_t c5sbm2_device; extern const device_t sb486pv_device; extern const device_t ap5s_device; +extern const device_t d842_device; extern const device_t d943_device; extern const device_t dells333sl_device; @@ -2377,7 +2378,7 @@ const machine_t machines[] = { .net_device = NULL }, { - .name = "[8086] Olivetti M21/24/24SP", + .name = "[8086] Olivetti M21/24/24SP/AT&T PC 6300", .internal_name = "m24", .type = MACHINE_TYPE_8086, .chipset = MACHINE_CHIPSET_PROPRIETARY, @@ -2417,7 +2418,7 @@ const machine_t machines[] = { }, /* Has Olivetti KBC firmware. */ { - .name = "[8086] Olivetti M240", + .name = "[8086] Olivetti M240/AT&T PC 6300 WGS", .internal_name = "m240", .type = MACHINE_TYPE_8086, .chipset = MACHINE_CHIPSET_PROPRIETARY, @@ -10346,6 +10347,46 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + + { + .name = "[i430NX] Siemens-Nixdorf D842", + .internal_name = "d842", + .type = MACHINE_TYPE_SOCKET5, + .chipset = MACHINE_CHIPSET_INTEL_430NX, + .init = machine_at_d842_init, + .p1_handler = NULL, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET5_7, + .block = CPU_BLOCK_NONE, + .min_bus = 50000000, + .max_bus = 66666667, + .min_voltage = 3380, + .max_voltage = 3520, + .min_multi = 1.5, + .max_multi = 2.0 + }, + .bus_flags = MACHINE_PS2_PCI, + .flags = MACHINE_IDE_DUAL | MACHINE_APM, + .ram = { + .min = 2048, + .max = 131072, + .step = 2048 + }, + .nvrmask = 127, + .kbc_device = NULL, + .kbc_p1 = 0xff, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = &d842_device, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = NULL, + .net_device = NULL + }, /* This has the Phoenix MultiKey KBC firmware. This is basically an Intel Premiere/PCI II with a fancier POST screen. */ { @@ -11814,7 +11855,7 @@ const machine_t machines[] = { .fdc_device = NULL, .sio_device = NULL, .vid_device = &gd5436_onboard_pci_device, - .snd_device = &sb_vibra16s_onboard_device, + .snd_device = &sb_vibra16c_onboard_device, .net_device = NULL }, diff --git a/src/mem/rom.c b/src/mem/rom.c index 666652d53..f7b2b2b0d 100644 --- a/src/mem/rom.c +++ b/src/mem/rom.c @@ -97,7 +97,8 @@ rom_check(const char *fn) else { fp = fopen(fn, "rb"); ret = (fp != NULL); - fclose(fp); + if (fp != NULL) + fclose(fp); } return ret; @@ -134,6 +135,9 @@ rom_fopen(const char *fn, char *mode) char temp[1024]; FILE *fp = NULL; + if ((fn == NULL) || (mode == NULL)) + return NULL; + if (strstr(fn, "roms/") == fn) { /* Relative path */ for (rom_path_t *rom_path = &rom_paths; rom_path != NULL; rom_path = rom_path->next) { @@ -320,11 +324,12 @@ rom_load_linear_oddeven(const char *fn, uint32_t addr, int sz, int off, uint8_t } for (int i = 0; i < (sz >> 1); i++) { if (fread(ptr + (addr + (i << 1) + 1), 1, 1, fp) != 1) - fatal("rom_load_linear(): Error reading od data\n"); + fatal("rom_load_linear(): Error reading odd data\n"); } } - (void) fclose(fp); + if (fp != NULL) + (void) fclose(fp); return 1; } @@ -353,7 +358,8 @@ rom_load_linear(const char *fn, uint32_t addr, int sz, int off, uint8_t *ptr) fatal("rom_load_linear(): Error reading data\n"); } - (void) fclose(fp); + if (fp != NULL) + (void) fclose(fp); return 1; } @@ -397,7 +403,8 @@ rom_load_linear_inverted(const char *fn, uint32_t addr, int sz, int off, uint8_t } } - (void) fclose(fp); + if (fp != NULL) + (void) fclose(fp); return 1; } @@ -438,8 +445,10 @@ rom_load_interleaved(const char *fnl, const char *fnh, uint32_t addr, int sz, in } } - (void) fclose(fph); - (void) fclose(fpl); + if (fph != NULL) + (void) fclose(fph); + if (fpl != NULL) + (void) fclose(fpl); return 1; } diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index 92c4c4ddf..e8cfd6cd7 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -291,8 +291,12 @@ net_slirp_get_revents(int idx, void *opaque) WSA_TO_POLL(FD_WRITE, SLIRP_POLL_OUT); WSA_TO_POLL(FD_CONNECT, SLIRP_POLL_OUT); WSA_TO_POLL(FD_OOB, SLIRP_POLL_PRI); + WSA_TO_POLL(FD_CLOSE, SLIRP_POLL_IN); WSA_TO_POLL(FD_CLOSE, SLIRP_POLL_HUP); + if (ret == 0) + ret |= SLIRP_POLL_IN; + return ret; } #else diff --git a/src/printer/prt_escp.c b/src/printer/prt_escp.c index d0836e5f2..f238341c5 100644 --- a/src/printer/prt_escp.c +++ b/src/printer/prt_escp.c @@ -2053,6 +2053,7 @@ escp_close(void *priv) free(dev->page); } + FT_Done_Face(dev->fontface); free(dev); } diff --git a/src/qt/languages/ca-ES.po b/src/qt/languages/ca-ES.po index 632af979a..c9fc9bd82 100644 --- a/src/qt/languages/ca-ES.po +++ b/src/qt/languages/ca-ES.po @@ -1834,7 +1834,7 @@ msgid "2 MB" msgstr "2 MB" msgid "8 MB" -msgstr " 8 MB" +msgstr "8 MB" msgid "28 MB" msgstr "28 MB" diff --git a/src/qt/languages/cs-CZ.po b/src/qt/languages/cs-CZ.po index 593020962..cd726832d 100644 --- a/src/qt/languages/cs-CZ.po +++ b/src/qt/languages/cs-CZ.po @@ -1834,7 +1834,7 @@ msgid "2 MB" msgstr "2 MB" msgid "8 MB" -msgstr " 8 MB" +msgstr "8 MB" msgid "28 MB" msgstr "28 MB" diff --git a/src/qt/languages/de-DE.po b/src/qt/languages/de-DE.po index 439346608..267e4b13e 100644 --- a/src/qt/languages/de-DE.po +++ b/src/qt/languages/de-DE.po @@ -1834,7 +1834,7 @@ msgid "2 MB" msgstr "2 MB" msgid "8 MB" -msgstr " 8 MB" +msgstr "8 MB" msgid "28 MB" msgstr "28 MB" diff --git a/src/qt/languages/es-ES.po b/src/qt/languages/es-ES.po index 363d56c45..5454ab1de 100644 --- a/src/qt/languages/es-ES.po +++ b/src/qt/languages/es-ES.po @@ -1833,7 +1833,7 @@ msgid "2 MB" msgstr "2 MB" msgid "8 MB" -msgstr " 8 MB" +msgstr "8 MB" msgid "28 MB" msgstr "28 MB" diff --git a/src/qt/languages/hr-HR.po b/src/qt/languages/hr-HR.po index 50dd298c2..0330cd59a 100644 --- a/src/qt/languages/hr-HR.po +++ b/src/qt/languages/hr-HR.po @@ -1834,7 +1834,7 @@ msgid "2 MB" msgstr "2 MB" msgid "8 MB" -msgstr " 8 MB" +msgstr "8 MB" msgid "28 MB" msgstr "28 MB" diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index af427d670..19975c2c9 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -2194,4 +2194,13 @@ msgid "Toggle pause" msgstr "Переключить паузу" msgid "Toggle mute" -msgstr "Переключить беззвучный режим" \ No newline at end of file +msgstr "Переключить беззвучный режим" + +msgid "Text files" +msgstr "Текстовые файлы" + +msgid "ROM files" +msgstr "Файлы ПЗУ" + +msgid "SoundFont files" +msgstr "Файлы SoundFont" diff --git a/src/qt/qt_deviceconfig.cpp b/src/qt/qt_deviceconfig.cpp index cda52e722..255b3c39f 100644 --- a/src/qt/qt_deviceconfig.cpp +++ b/src/qt/qt_deviceconfig.cpp @@ -31,6 +31,7 @@ #include #include #include +#include extern "C" { #include <86box/86box.h> @@ -45,6 +46,7 @@ extern "C" { #include "qt_filefield.hpp" #include "qt_models_common.hpp" +#include "qt_util.hpp" #ifdef Q_OS_LINUX # include # include @@ -276,11 +278,25 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep) } case CONFIG_FNAME: { - auto *fileField = new FileField(); + auto *fileField = new FileField(this); fileField->setObjectName(config->name); fileField->setFileName(selected); - fileField->setFilter(QString(config->file_filter).left(static_cast(strcspn(config->file_filter, - "|")))); + /* Get the actually used part of the filter */ + QString filter = QString(config->file_filter).left(static_cast(strcspn(config->file_filter, "|"))); + /* Extract the description and the extension list */ + QRegularExpressionMatch match = QRegularExpression("(.+) \\((.+)\\)$").match(filter); + QString description = match.captured(1); + QString extensions = match.captured(2); + QStringList extensionList; + /* Split the extension list up and strip the filename globs */ + QRegularExpression re("\\*\\.(.*)"); + int i = 0; + while (extensions.section(' ', i, i) != "") { + QString extension = re.match(extensions.section(' ', i, i)).captured(1); + extensionList.append(extension); + i++; + } + fileField->setFilter(tr(description.toUtf8().constData()) % util::DlgFilter(extensionList) % tr("All files") % util::DlgFilter({ "*" }, true)); this->ui->formLayout->addRow(tr(config->description), fileField); break; } @@ -388,6 +404,7 @@ DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *se } case CONFIG_MIDI_OUT: case CONFIG_MIDI_IN: + case CONFIG_INT: case CONFIG_SELECTION: { auto *cbox = dc.findChild(config->name); diff --git a/src/qt/qt_glsl_parser.cpp b/src/qt/qt_glsl_parser.cpp index 6e107bc19..9efeb430b 100644 --- a/src/qt/qt_glsl_parser.cpp +++ b/src/qt/qt_glsl_parser.cpp @@ -104,22 +104,22 @@ glsl_detect_bom(const char *fn) static char *load_file(const char *fn) { int bom = glsl_detect_bom(fn); - FILE *f = plat_fopen(fn, "rb"); - if (!f) + FILE *fp = plat_fopen(fn, "rb"); + if (!fp) return 0; - fseek(f, 0, SEEK_END); - long fsize = ftell(f); - fseek(f, 0, SEEK_SET); + fseek(fp, 0, SEEK_END); + long fsize = ftell(fp); + fseek(fp, 0, SEEK_SET); if (bom) { fsize -= 3; - fseek(f, 3, SEEK_SET); + fseek(fp, 3, SEEK_SET); } char *data = (char*)malloc(fsize + 1); - fread(data, fsize, 1, f); - fclose(f); + (void) fread(data, fsize, 1, fp); + fclose(fp); data[fsize] = 0; diff --git a/src/qt/qt_settingsdisplay.cpp b/src/qt/qt_settingsdisplay.cpp index fbe6ab5cc..83e19aec7 100644 --- a/src/qt/qt_settingsdisplay.cpp +++ b/src/qt/qt_settingsdisplay.cpp @@ -51,22 +51,29 @@ SettingsDisplay::~SettingsDisplay() void SettingsDisplay::save() { - gfxcard[0] = ui->comboBoxVideo->currentData().toInt(); // TODO +#if 0 + for (uint8_t i = 0; i < GFXCARD_MAX; ++i) { + QComboBox *cbox = findChild(QString("comboBoxVideo%1").arg(i + 1)); + gfxcard[i] = cbox->currentData().toInt(); + } +#else + gfxcard[0] = ui->comboBoxVideo->currentData().toInt(); for (uint8_t i = 1; i < GFXCARD_MAX; i ++) - gfxcard[i] = ui->comboBoxVideoSecondary->currentData().toInt(); + gfxcard[i] = ui->comboBoxVideoSecondary->currentData().toInt(); +#endif voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0; ibm8514_standalone_enabled = ui->checkBox8514->isChecked() ? 1 : 0; xga_standalone_enabled = ui->checkBoxXga->isChecked() ? 1 : 0; - da2_standalone_enabled = ui->checkBoxDa2->isChecked() ? 1 : 0; + da2_standalone_enabled = ui->checkBoxDa2->isChecked() ? 1 : 0; } void SettingsDisplay::onCurrentMachineChanged(int machineId) { // win_settings_video_proc, WM_INITDIALOG - this->machineId = machineId; + this->machineId = machineId; auto curVideoCard = videoCard[0]; auto *model = ui->comboBoxVideo->model(); @@ -98,25 +105,26 @@ SettingsDisplay::onCurrentMachineChanged(int machineId) } model->removeRows(0, removeRows); + // TODO if (machine_has_flags(machineId, MACHINE_VIDEO_ONLY) > 0) { ui->comboBoxVideo->setEnabled(false); ui->comboBoxVideoSecondary->setEnabled(false); - ui->pushButtonConfigureSecondary->setEnabled(false); + ui->pushButtonConfigureVideoSecondary->setEnabled(false); selectedRow = 1; } else { ui->comboBoxVideo->setEnabled(true); ui->comboBoxVideoSecondary->setEnabled(true); - ui->pushButtonConfigureSecondary->setEnabled(true); + ui->pushButtonConfigureVideoSecondary->setEnabled(true); } ui->comboBoxVideo->setCurrentIndex(selectedRow); // TODO for (uint8_t i = 1; i < GFXCARD_MAX; i ++) if (gfxcard[i] == 0) - ui->pushButtonConfigureSecondary->setEnabled(false); + ui->pushButtonConfigureVideoSecondary->setEnabled(false); } void -SettingsDisplay::on_pushButtonConfigure_clicked() +SettingsDisplay::on_pushButtonConfigureVideo_clicked() { int videoCard = ui->comboBoxVideo->currentData().toInt(); auto *device = video_card_getdevice(videoCard); @@ -160,17 +168,17 @@ SettingsDisplay::on_pushButtonConfigureDa2_clicked() void SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } - static QRegularExpression voodooRegex("3dfx|voodoo|banshee", QRegularExpression::CaseInsensitiveOption); + + static QRegularExpression voodooRegex("3dfx|voodoo|banshee|raven", QRegularExpression::CaseInsensitiveOption); auto curVideoCard_2 = videoCard[1]; videoCard[0] = ui->comboBoxVideo->currentData().toInt(); if (videoCard[0] == VID_INTERNAL) - ui->pushButtonConfigure->setEnabled(machine_has_flags(machineId, MACHINE_VIDEO) && - device_has_config(machine_get_vid_device(machineId))); + ui->pushButtonConfigureVideo->setEnabled(machine_has_flags(machineId, MACHINE_VIDEO) && + device_has_config(machine_get_vid_device(machineId))); else - ui->pushButtonConfigure->setEnabled(video_card_has_config(videoCard[0]) > 0); + ui->pushButtonConfigureVideo->setEnabled(video_card_has_config(videoCard[0]) > 0); bool machineHasPci = machine_has_bus(machineId, MACHINE_BUS_PCI) > 0; ui->pushButtonConfigureVoodoo->setEnabled(machineHasPci && ui->checkBoxVoodoo->isChecked()); @@ -233,7 +241,7 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) if ((videoCard[1] == 0) || (machine_has_flags(machineId, MACHINE_VIDEO_ONLY) > 0)) { ui->comboBoxVideoSecondary->setCurrentIndex(0); - ui->pushButtonConfigureSecondary->setEnabled(false); + ui->pushButtonConfigureVideoSecondary->setEnabled(false); } // Is the currently selected video card a voodoo? @@ -287,15 +295,15 @@ void SettingsDisplay::on_comboBoxVideoSecondary_currentIndexChanged(int index) { if (index < 0) { - ui->pushButtonConfigureSecondary->setEnabled(false); + ui->pushButtonConfigureVideoSecondary->setEnabled(false); return; } videoCard[1] = ui->comboBoxVideoSecondary->currentData().toInt(); - ui->pushButtonConfigureSecondary->setEnabled(index != 0 && video_card_has_config(videoCard[1]) > 0); + ui->pushButtonConfigureVideoSecondary->setEnabled(index != 0 && video_card_has_config(videoCard[1]) > 0); } void -SettingsDisplay::on_pushButtonConfigureSecondary_clicked() +SettingsDisplay::on_pushButtonConfigureVideoSecondary_clicked() { auto *device = video_card_getdevice(ui->comboBoxVideoSecondary->currentData().toInt()); DeviceConfig::ConfigureDevice(device); diff --git a/src/qt/qt_settingsdisplay.hpp b/src/qt/qt_settingsdisplay.hpp index 854fce658..7eca7cc60 100644 --- a/src/qt/qt_settingsdisplay.hpp +++ b/src/qt/qt_settingsdisplay.hpp @@ -22,22 +22,23 @@ public slots: void onCurrentMachineChanged(int machineId); private slots: - void on_pushButtonConfigureSecondary_clicked(); - -private slots: - void on_comboBoxVideoSecondary_currentIndexChanged(int index); - -private slots: - void on_checkBoxVoodoo_stateChanged(int state); - void on_checkBox8514_stateChanged(int state); - void on_checkBoxXga_stateChanged(int state); - void on_checkBoxDa2_stateChanged(int state); void on_comboBoxVideo_currentIndexChanged(int index); + void on_pushButtonConfigureVideo_clicked(); + + void on_comboBoxVideoSecondary_currentIndexChanged(int index); + void on_pushButtonConfigureVideoSecondary_clicked(); + + void on_checkBoxVoodoo_stateChanged(int state); void on_pushButtonConfigureVoodoo_clicked(); + + void on_checkBox8514_stateChanged(int state); void on_pushButtonConfigure8514_clicked(); + + void on_checkBoxXga_stateChanged(int state); void on_pushButtonConfigureXga_clicked(); + + void on_checkBoxDa2_stateChanged(int state); void on_pushButtonConfigureDa2_clicked(); - void on_pushButtonConfigure_clicked(); private: Ui::SettingsDisplay *ui; diff --git a/src/qt/qt_settingsdisplay.ui b/src/qt/qt_settingsdisplay.ui index a8799204c..c5eba7adf 100644 --- a/src/qt/qt_settingsdisplay.ui +++ b/src/qt/qt_settingsdisplay.ui @@ -26,28 +26,8 @@ 0 - - - - - 0 - 0 - - - - Configure - - - - - - - XGA Graphics - - - - + 0 @@ -72,15 +52,21 @@ - - + + + + + 0 + 0 + + Configure - + 0 @@ -92,10 +78,23 @@ - - + + + + + 0 + 0 + + + + 30 + + + + + - IBM 8514/A Graphics + Configure @@ -106,6 +105,20 @@ + + + + Configure + + + + + + + IBM 8514/A Graphics + + + @@ -113,6 +126,13 @@ + + + + XGA Graphics + + + @@ -134,26 +154,6 @@ - - - - Configure - - - - - - - - 0 - 0 - - - - 30 - - - diff --git a/src/qt/qt_settingsfloppycdrom.cpp b/src/qt/qt_settingsfloppycdrom.cpp index 5e0ec7bed..bf1499076 100644 --- a/src/qt/qt_settingsfloppycdrom.cpp +++ b/src/qt/qt_settingsfloppycdrom.cpp @@ -359,9 +359,9 @@ SettingsFloppyCDROM::on_comboBoxSpeed_activated(int index) void SettingsFloppyCDROM::on_comboBoxBus_activated(int) { - auto i = ui->tableViewCDROM->selectionModel()->currentIndex().siblingAtColumn(0); + auto i = ui->tableViewCDROM->selectionModel()->currentIndex().siblingAtColumn(0); uint8_t bus_type = ui->comboBoxBus->currentData().toUInt(); - int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt(); + int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt(); Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, @@ -384,9 +384,9 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int) auto *modelType = ui->comboBoxCDROMType->model(); int removeRows = modelType->rowCount(); - uint32_t j = 0; - int selectedTypeRow = 0; - int eligibleRows = 0; + uint32_t j = 0; + int selectedTypeRow = 0; + int eligibleRows = 0; while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) { if (((bus_type == CDROM_BUS_ATAPI) || (bus_type == CDROM_BUS_SCSI)) && ((cdrom_drive_types[j].bus_type == bus_type) || @@ -414,11 +414,10 @@ void SettingsFloppyCDROM::enableCurrentlySelectedChannel() { const auto *item_model = qobject_cast(ui->comboBoxChannel->model()); - const auto index = ui->comboBoxChannel->currentIndex(); - auto *item = item_model->item(index); - if(item) { + const auto index = ui->comboBoxChannel->currentIndex(); + auto *item = item_model->item(index); + if(item) item->setEnabled(true); - } } void @@ -449,9 +448,9 @@ SettingsFloppyCDROM::on_comboBoxCDROMType_activated(int) ui->tableViewCDROM->resizeColumnsToContents(); ui->tableViewCDROM->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); - int speed = cdrom_get_speed(type); + int speed = cdrom_get_speed(type); if (speed == -1) { - speed = ui->comboBoxSpeed->currentData().toUInt(); + speed = ui->comboBoxSpeed->currentData().toUInt(); ui->comboBoxSpeed->setEnabled(true); } else ui->comboBoxSpeed->setEnabled(false); diff --git a/src/qt/qt_settingsfloppycdrom.hpp b/src/qt/qt_settingsfloppycdrom.hpp index 0a3424216..063942201 100644 --- a/src/qt/qt_settingsfloppycdrom.hpp +++ b/src/qt/qt_settingsfloppycdrom.hpp @@ -19,17 +19,20 @@ public: signals: void cdromChannelChanged(); + private slots: - void on_comboBoxCDROMType_activated(int index); - void on_comboBoxChannel_activated(int index); - void on_comboBoxBus_activated(int index); - void on_comboBoxSpeed_activated(int index); - void on_comboBoxBus_currentIndexChanged(int index); - void on_comboBoxFloppyType_activated(int index); - void on_checkBoxCheckBPB_stateChanged(int arg1); - void on_checkBoxTurboTimings_stateChanged(int arg1); void onFloppyRowChanged(const QModelIndex ¤t); + void on_comboBoxFloppyType_activated(int index); + void on_checkBoxTurboTimings_stateChanged(int arg1); + void on_checkBoxCheckBPB_stateChanged(int arg1); + void onCDROMRowChanged(const QModelIndex ¤t); + void on_comboBoxBus_activated(int index); + void on_comboBoxBus_currentIndexChanged(int index); + void on_comboBoxChannel_activated(int index); + void on_comboBoxSpeed_activated(int index); + void on_comboBoxCDROMType_activated(int index); + private: Ui::SettingsFloppyCDROM *ui; diff --git a/src/qt/qt_settingsfloppycdrom.ui b/src/qt/qt_settingsfloppycdrom.ui index b9a937d8d..7dde46631 100644 --- a/src/qt/qt_settingsfloppycdrom.ui +++ b/src/qt/qt_settingsfloppycdrom.ui @@ -27,7 +27,7 @@ 0 - + Floppy drives: @@ -68,7 +68,7 @@ - + Type: @@ -99,7 +99,7 @@ - + CD-ROM drives: @@ -140,33 +140,12 @@ - + Bus: - - - - Channel: - - - - - - - Speed: - - - - - - - Type: - - - @@ -174,6 +153,13 @@ + + + + Channel: + + + @@ -181,6 +167,13 @@ + + + + Speed: + + + @@ -188,6 +181,13 @@ + + + + Type: + + + diff --git a/src/qt/qt_settingsharddisks.cpp b/src/qt/qt_settingsharddisks.cpp index 32b677888..6d82f2b77 100644 --- a/src/qt/qt_settingsharddisks.cpp +++ b/src/qt/qt_settingsharddisks.cpp @@ -49,9 +49,8 @@ static void normalize_hd_list() { hard_disk_t ihdd[HDD_NUM]; - int j; + int j = 0; - j = 0; memset(ihdd, 0x00, HDD_NUM * sizeof(hard_disk_t)); for (uint8_t i = 0; i < HDD_NUM; i++) { @@ -75,8 +74,8 @@ static void addRow(QAbstractItemModel *model, hard_disk_t *hd) { const QString userPath = usr_path; - int row = model->rowCount(); + model->insertRow(row); QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel); @@ -88,11 +87,11 @@ addRow(QAbstractItemModel *model, hard_disk_t *hd) model->setData(model->index(row, ColumnBus), hd->channel, DataBusChannelPrevious); Harddrives::busTrackClass->device_track(1, DEV_HDD, hd->bus_type, hd->channel); QString fileName = hd->fn; - if (fileName.startsWith(userPath, Qt::CaseInsensitive)) { + if (fileName.startsWith(userPath, Qt::CaseInsensitive)) model->setData(model->index(row, ColumnFilename), fileName.mid(userPath.size())); - } else { + else model->setData(model->index(row, ColumnFilename), fileName); - } + model->setData(model->index(row, ColumnFilename), fileName, Qt::UserRole); model->setData(model->index(row, ColumnCylinders), hd->tracks); @@ -120,9 +119,8 @@ SettingsHarddisks::SettingsHarddisks(QWidget *parent) ui->tableView->setModel(model); for (int i = 0; i < HDD_NUM; i++) { - if (hdd[i].bus_type > 0) { + if (hdd[i].bus_type > 0) addRow(model, &hdd[i]); - } } if (model->rowCount() == HDD_NUM) { ui->pushButtonNew->setEnabled(false); @@ -176,9 +174,8 @@ void SettingsHarddisks::reloadBusChannels() { void SettingsHarddisks::on_comboBoxBus_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } buschangeinprogress = true; auto idx = ui->tableView->selectionModel()->currentIndex(); @@ -226,9 +223,8 @@ SettingsHarddisks::on_comboBoxBus_currentIndexChanged(int index) void SettingsHarddisks::on_comboBoxChannel_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } auto idx = ui->tableView->selectionModel()->currentIndex(); if (idx.isValid()) { @@ -250,17 +246,15 @@ SettingsHarddisks::enableCurrentlySelectedChannel() const auto *item_model = qobject_cast(ui->comboBoxChannel->model()); const auto index = ui->comboBoxChannel->currentIndex(); auto *item = item_model->item(index); - if(item) { + if(item) item->setEnabled(true); - } } void SettingsHarddisks::on_comboBoxSpeed_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } auto idx = ui->tableView->selectionModel()->currentIndex(); if (idx.isValid()) { @@ -288,20 +282,19 @@ SettingsHarddisks::onTableRowChanged(const QModelIndex ¤t) auto *model = ui->comboBoxBus->model(); auto match = model->match(model->index(0, 0), Qt::UserRole, bus); - if (!match.isEmpty()) { + if (!match.isEmpty()) ui->comboBoxBus->setCurrentIndex(match.first().row()); - } + model = ui->comboBoxChannel->model(); match = model->match(model->index(0, 0), Qt::UserRole, busChannel); - if (!match.isEmpty()) { + if (!match.isEmpty()) ui->comboBoxChannel->setCurrentIndex(match.first().row()); - } model = ui->comboBoxSpeed->model(); match = model->match(model->index(0, 0), Qt::UserRole, speed); - if (!match.isEmpty()) { + if (!match.isEmpty()) ui->comboBoxSpeed->setCurrentIndex(match.first().row()); - } + reloadBusChannels(); } @@ -358,11 +351,10 @@ void SettingsHarddisks::on_pushButtonRemove_clicked() { auto idx = ui->tableView->selectionModel()->currentIndex(); - if (!idx.isValid()) { + if (!idx.isValid()) return; - } - auto *model = ui->tableView->model(); + auto *model = ui->tableView->model(); const auto col = idx.siblingAtColumn(ColumnBus); Harddrives::busTrackClass->device_track(0, DEV_HDD, model->data(col, DataBus).toInt(), model->data(col, DataBusChannel).toInt()); model->removeRow(idx.row()); diff --git a/src/qt/qt_settingsharddisks.hpp b/src/qt/qt_settingsharddisks.hpp index 4bd287d29..f892a79cd 100644 --- a/src/qt/qt_settingsharddisks.hpp +++ b/src/qt/qt_settingsharddisks.hpp @@ -21,14 +21,13 @@ signals: void driveChannelChanged(); private slots: + void on_comboBoxBus_currentIndexChanged(int index); void on_comboBoxChannel_currentIndexChanged(int index); void on_comboBoxSpeed_currentIndexChanged(int index); -private slots: - void on_pushButtonRemove_clicked(); - void on_pushButtonExisting_clicked(); void on_pushButtonNew_clicked(); - void on_comboBoxBus_currentIndexChanged(int index); + void on_pushButtonExisting_clicked(); + void on_pushButtonRemove_clicked(); void onTableRowChanged(const QModelIndex ¤t); diff --git a/src/qt/qt_settingsharddisks.ui b/src/qt/qt_settingsharddisks.ui index ea69edc5b..f996c76d1 100644 --- a/src/qt/qt_settingsharddisks.ui +++ b/src/qt/qt_settingsharddisks.ui @@ -46,7 +46,7 @@ - + diff --git a/src/qt/qt_settingsinput.cpp b/src/qt/qt_settingsinput.cpp index a7000414c..6d89c511a 100644 --- a/src/qt/qt_settingsinput.cpp +++ b/src/qt/qt_settingsinput.cpp @@ -38,7 +38,7 @@ extern "C" { #include "qt_keybind.hpp" extern MainWindow *main_window; - + // Temporary working copy of key list accelKey acc_keys_t[NUM_ACCELS]; @@ -48,41 +48,40 @@ SettingsInput::SettingsInput(QWidget *parent) { ui->setupUi(this); - QStringList horizontalHeader; - QStringList verticalHeader; - - horizontalHeader.append(tr("Action")); + QStringList horizontalHeader; + QStringList verticalHeader; + + horizontalHeader.append(tr("Action")); horizontalHeader.append(tr("Keybind")); - QTableWidget *keyTable = ui->tableKeys; - keyTable->setRowCount(10); - keyTable->setColumnCount(3); - keyTable->setColumnHidden(2, true); - keyTable->setColumnWidth(0, 200); - keyTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - QStringList headers; - //headers << "Action" << "Bound key"; - keyTable->setHorizontalHeaderLabels(horizontalHeader); - keyTable->verticalHeader()->setVisible(false); - keyTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - keyTable->setSelectionBehavior(QAbstractItemView::SelectRows); - keyTable->setSelectionMode(QAbstractItemView::SingleSelection); - keyTable->setShowGrid(true); - - // Make a working copy of acc_keys so we can check for dupes later without getting - // confused - for(int x=0;xtableKeys; + keyTable->setRowCount(10); + keyTable->setColumnCount(3); + keyTable->setColumnHidden(2, true); + keyTable->setColumnWidth(0, 200); + keyTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + QStringList headers; + //headers << "Action" << "Bound key"; + keyTable->setHorizontalHeaderLabels(horizontalHeader); + keyTable->verticalHeader()->setVisible(false); + keyTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + keyTable->setSelectionBehavior(QAbstractItemView::SelectRows); + keyTable->setSelectionMode(QAbstractItemView::SingleSelection); + keyTable->setShowGrid(true); - refreshInputList(); + // Make a working copy of acc_keys so we can check for dupes later without getting + // confused + for(int x = 0; x < NUM_ACCELS; x++) { + strcpy(acc_keys_t[x].name, acc_keys[x].name); + strcpy(acc_keys_t[x].desc, acc_keys[x].desc); + strcpy(acc_keys_t[x].seq, acc_keys[x].seq); + } + + refreshInputList(); onCurrentMachineChanged(machine); } - SettingsInput::~SettingsInput() { delete ui; @@ -93,16 +92,16 @@ SettingsInput::save() { mouse_type = ui->comboBoxMouse->currentData().toInt(); joystick_type = ui->comboBoxJoystick->currentData().toInt(); - - // Copy accelerators from working set to global set - for(int x=0;xrowCount(); @@ -131,9 +128,8 @@ SettingsInput::onCurrentMachineChanged(int machineId) mouseModel->setData(idx, name, Qt::DisplayRole); mouseModel->setData(idx, i, Qt::UserRole); - if (i == mouse_type) { + if (i == mouse_type) selectedRow = row - removeRows; - } } mouseModel->removeRows(0, removeRows); ui->comboBoxMouse->setCurrentIndex(selectedRow); @@ -141,13 +137,12 @@ SettingsInput::onCurrentMachineChanged(int machineId) int i = 0; const char *joyName = joystick_get_name(i); auto *joystickModel = ui->comboBoxJoystick->model(); - removeRows = joystickModel->rowCount(); - selectedRow = 0; + removeRows = joystickModel->rowCount(); + selectedRow = 0; while (joyName) { int row = Models::AddEntry(joystickModel, tr(joyName).toUtf8().data(), i); - if (i == joystick_type) { + if (i == joystick_type) selectedRow = row - removeRows; - } ++i; joyName = joystick_get_name(i); @@ -159,95 +154,95 @@ SettingsInput::onCurrentMachineChanged(int machineId) void SettingsInput::refreshInputList() { - - for (int x=0;xtableKeys->setItem(x, 0, new QTableWidgetItem(tr(acc_keys_t[x].desc))); - ui->tableKeys->setItem(x, 1, new QTableWidgetItem(QKeySequence(acc_keys_t[x].seq, QKeySequence::PortableText).toString(QKeySequence::NativeText))); - ui->tableKeys->setItem(x, 2, new QTableWidgetItem(acc_keys_t[x].name)); - } + for (int x = 0; x < NUM_ACCELS; x++) { + ui->tableKeys->setItem(x, 0, new QTableWidgetItem(tr(acc_keys_t[x].desc))); + ui->tableKeys->setItem(x, 1, new QTableWidgetItem(QKeySequence(acc_keys_t[x].seq, QKeySequence::PortableText).toString(QKeySequence::NativeText))); + ui->tableKeys->setItem(x, 2, new QTableWidgetItem(acc_keys_t[x].name)); + } } void SettingsInput::on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) { - // Enable/disable bind/clear buttons if user clicked valid row - QTableWidgetItem *cell = ui->tableKeys->item(currentRow,1); - if (!cell) - { - ui->pushButtonBind->setEnabled(false); - ui->pushButtonClearBind->setEnabled(false); - } - else - { - ui->pushButtonBind->setEnabled(true); - ui->pushButtonClearBind->setEnabled(true); - } + // Enable/disable bind/clear buttons if user clicked valid row + QTableWidgetItem *cell = ui->tableKeys->item(currentRow,1); + if (!cell) { + ui->pushButtonBind->setEnabled(false); + ui->pushButtonClearBind->setEnabled(false); + } else { + ui->pushButtonBind->setEnabled(true); + ui->pushButtonClearBind->setEnabled(true); + } } void SettingsInput::on_tableKeys_cellDoubleClicked(int row, int col) { - // Edit bind - QTableWidgetItem *cell = ui->tableKeys->item(row,1); - if (!cell) return; - - QKeySequence keyseq = KeyBinder::BindKey(this, cell->text()); - if (keyseq != false) { - // If no change was made, don't change anything. - if (keyseq.toString(QKeySequence::NativeText) == cell->text()) return; - - // Otherwise, check for conflicts. - // Check against the *working* copy - NOT the one in use by the app, - // so we don't test against shortcuts the user already changed. - for(int x=0;xshowMessage(MBX_ANSI & MBX_INFO, "Bind conflict", "This key combo is already in use", false); - return; - } - } - // If we made it here, there were no conflicts. - // Go ahead and apply the bind. - - // Find the correct accelerator key entry - int accKeyID = FindAccelerator(ui->tableKeys->item(row,2)->text().toUtf8().constData()); - if (accKeyID < 0) return; // this should never happen - - // Make the change - cell->setText(keyseq.toString(QKeySequence::NativeText)); - strcpy(acc_keys_t[accKeyID].seq, keyseq.toString(QKeySequence::PortableText).toUtf8().constData()); - - refreshInputList(); - } + // Edit bind + QTableWidgetItem *cell = ui->tableKeys->item(row,1); + if (!cell) + return; + + QKeySequence keyseq = KeyBinder::BindKey(this, cell->text()); + if (keyseq != false) { + // If no change was made, don't change anything. + if (keyseq.toString(QKeySequence::NativeText) == cell->text()) + return; + + // Otherwise, check for conflicts. + // Check against the *working* copy - NOT the one in use by the app, + // so we don't test against shortcuts the user already changed. + for(int x = 0; x < NUM_ACCELS; x++) { + if(QString::fromStdString(acc_keys_t[x].seq) == keyseq.toString(QKeySequence::PortableText)) { + // That key is already in use + main_window->showMessage(MBX_ANSI & MBX_INFO, "Bind conflict", "This key combo is already in use", false); + return; + } + } + // If we made it here, there were no conflicts. + // Go ahead and apply the bind. + + // Find the correct accelerator key entry + int accKeyID = FindAccelerator(ui->tableKeys->item(row,2)->text().toUtf8().constData()); + if (accKeyID < 0) + return; // this should never happen + + // Make the change + cell->setText(keyseq.toString(QKeySequence::NativeText)); + strcpy(acc_keys_t[accKeyID].seq, keyseq.toString(QKeySequence::PortableText).toUtf8().constData()); + + refreshInputList(); + } } void SettingsInput::on_pushButtonBind_clicked() { - // Edit bind - QTableWidgetItem *cell = ui->tableKeys->currentItem(); - if (!cell) return; - - on_tableKeys_cellDoubleClicked(cell->row(), cell->column()); + // Edit bind + QTableWidgetItem *cell = ui->tableKeys->currentItem(); + if (!cell) + return; + + on_tableKeys_cellDoubleClicked(cell->row(), cell->column()); } void SettingsInput::on_pushButtonClearBind_clicked() { - // Wipe bind - QTableWidgetItem *cell = ui->tableKeys->item(ui->tableKeys->currentRow(), 1); - if (!cell) return; - - cell->setText(""); - // Find the correct accelerator key entry - int accKeyID = FindAccelerator(ui->tableKeys->item(cell->row(),2)->text().toUtf8().constData()); - if (accKeyID < 0) return; // this should never happen - - // Make the change - cell->setText(""); - strcpy(acc_keys_t[accKeyID].seq, ""); + // Wipe bind + QTableWidgetItem *cell = ui->tableKeys->item(ui->tableKeys->currentRow(), 1); + if (!cell) + return; + + cell->setText(""); + // Find the correct accelerator key entry + int accKeyID = FindAccelerator(ui->tableKeys->item(cell->row(),2)->text().toUtf8().constData()); + if (accKeyID < 0) + return; // this should never happen + + // Make the change + cell->setText(""); + strcpy(acc_keys_t[accKeyID].seq, ""); } void @@ -263,9 +258,9 @@ SettingsInput::on_comboBoxJoystick_currentIndexChanged(int index) int joystickId = ui->comboBoxJoystick->currentData().toInt(); for (int i = 0; i < MAX_JOYSTICKS; ++i) { auto *btn = findChild(QString("pushButtonJoystick%1").arg(i + 1)); - if (btn == nullptr) { + if (btn == nullptr) continue; - } + btn->setEnabled(joystick_get_max_joysticks(joystickId) > i); } } @@ -283,9 +278,8 @@ get_axis(JoystickConfiguration &jc, int axis, int joystick_nr) int axis_sel = jc.selectedAxis(axis); int nr_axes = plat_joystick_state[joystick_state[0][joystick_nr].plat_joystick_nr - 1].nr_axes; - if (axis_sel < nr_axes) { + if (axis_sel < nr_axes) return axis_sel; - } axis_sel -= nr_axes; if (axis_sel & 1) diff --git a/src/qt/qt_settingsinput.hpp b/src/qt/qt_settingsinput.hpp index 742421f64..a51ad2564 100644 --- a/src/qt/qt_settingsinput.hpp +++ b/src/qt/qt_settingsinput.hpp @@ -26,17 +26,20 @@ public slots: void onCurrentMachineChanged(int machineId); private slots: - void on_pushButtonConfigureMouse_clicked(); - void on_comboBoxJoystick_currentIndexChanged(int index); void on_comboBoxMouse_currentIndexChanged(int index); + void on_pushButtonConfigureMouse_clicked(); + + void on_comboBoxJoystick_currentIndexChanged(int index); void on_pushButtonJoystick1_clicked(); void on_pushButtonJoystick2_clicked(); void on_pushButtonJoystick3_clicked(); void on_pushButtonJoystick4_clicked(); + void on_tableKeys_cellDoubleClicked(int row, int col); void on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn); - void on_pushButtonBind_clicked(); + void on_pushButtonClearBind_clicked(); + void on_pushButtonBind_clicked(); private: Ui::SettingsInput *ui; diff --git a/src/qt/qt_settingsinput.ui b/src/qt/qt_settingsinput.ui index b7074eeaa..6ac6cf38a 100644 --- a/src/qt/qt_settingsinput.ui +++ b/src/qt/qt_settingsinput.ui @@ -23,6 +23,13 @@ 0 + + + + Mouse: + + + @@ -36,75 +43,6 @@ - - - - Joystick 4... - - - - - - - Joystick 3... - - - - - - - false - - - Bind - - - - - - - Joystick 1... - - - - - - - 30 - - - - - - - Mouse: - - - - - - - false - - - Clear binding - - - - - - - Joystick: - - - - - - - Joystick 2... - - - @@ -118,8 +56,50 @@ + + + + Joystick: + + + + + + + 30 + + + + + + + Joystick 1... + + + + + + + Joystick 2... + + + + + + + Joystick 3... + + + + + + + Joystick 4... + + + - + Key Bindings: @@ -144,6 +124,26 @@ + + + + false + + + Clear binding + + + + + + + false + + + Bind + + + diff --git a/src/qt/qt_settingsmachine.cpp b/src/qt/qt_settingsmachine.cpp index 8548ca8cc..fb5576f69 100644 --- a/src/qt/qt_settingsmachine.cpp +++ b/src/qt/qt_settingsmachine.cpp @@ -358,4 +358,4 @@ void SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state) { ui->softFloatWarningIcon->setVisible(false); ui->softFloatWarningText->setVisible(false); } -} \ No newline at end of file +} diff --git a/src/qt/qt_settingsmachine.hpp b/src/qt/qt_settingsmachine.hpp index 7e89d7fa4..864894447 100644 --- a/src/qt/qt_settingsmachine.hpp +++ b/src/qt/qt_settingsmachine.hpp @@ -18,22 +18,13 @@ public: signals: void currentMachineChanged(int machineId); + private slots: void on_pushButtonConfigure_clicked(); - -private slots: void on_comboBoxFPU_currentIndexChanged(int index); - -private slots: void on_comboBoxSpeed_currentIndexChanged(int index); - -private slots: void on_comboBoxCPU_currentIndexChanged(int index); - -private slots: void on_comboBoxMachine_currentIndexChanged(int index); - -private slots: void on_comboBoxMachineType_currentIndexChanged(int index); void on_checkBoxFPUSoftfloat_stateChanged(int state); diff --git a/src/qt/qt_settingsmachine.ui b/src/qt/qt_settingsmachine.ui index 0c9c2708e..e3b3cdbde 100644 --- a/src/qt/qt_settingsmachine.ui +++ b/src/qt/qt_settingsmachine.ui @@ -41,6 +41,7 @@ 0 + @@ -48,6 +49,7 @@ + @@ -55,6 +57,7 @@ + @@ -62,6 +65,7 @@ + @@ -69,6 +73,7 @@ + @@ -79,6 +84,7 @@ + @@ -86,6 +92,7 @@ + @@ -93,6 +100,7 @@ + @@ -121,6 +129,7 @@ + @@ -131,6 +140,7 @@ + @@ -147,6 +157,7 @@ + @@ -154,6 +165,7 @@ + @@ -161,6 +173,7 @@ + @@ -183,6 +196,7 @@ + @@ -199,6 +213,7 @@ + @@ -253,6 +268,7 @@ + @@ -270,6 +286,7 @@ + @@ -285,6 +302,7 @@ + @@ -292,6 +310,7 @@ + @@ -314,6 +333,7 @@ + diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 1ea48ee6b..2e64175eb 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -36,17 +36,17 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) auto *nic_cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); auto *net_type_cbox = findChild(QString("comboBoxNet%1").arg(i + 1)); - auto *intf_label = findChild(QString("interfaceLabel%1").arg(i + 1)); + auto *intf_label = findChild(QString("labelIntf%1").arg(i + 1)); auto *intf_cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); auto *conf_btn = findChild(QString("pushButtonConf%1").arg(i + 1)); // auto *net_type_conf_btn = findChild(QString("pushButtonNetTypeConf%1").arg(i + 1)); - auto *vde_socket_label = findChild(QString("socketVDELabel%1").arg(i + 1)); + auto *vde_socket_label = findChild(QString("labelSocketVDENIC%1").arg(i + 1)); auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); - auto *option_list_label = findChild(QString("optionListLabel%1").arg(i + 1)); - auto *option_list_line = findChild(QString("optionListLine%1").arg(i + 1)); + auto *option_list_label = findChild(QString("labelOptionList%1").arg(i + 1)); + auto *option_list_line = findChild(QString("lineOptionList%1").arg(i + 1)); intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP); conf_btn->setEnabled(network_card_has_config(nic_cbox->currentData().toInt())); @@ -56,7 +56,6 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) option_list_label->setVisible(false); option_list_line->setVisible(false); - // VDE vde_socket_label->setVisible(false); socket_line->setVisible(false); @@ -70,21 +69,26 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) // Then only enable as needed based on network type switch (net_type_cbox->currentData().toInt()) { case NET_TYPE_VDE: - // option_list_label->setText("VDE Options"); + // option_list_label->setText("VDE Options"); option_list_label->setVisible(true); option_list_line->setVisible(true); vde_socket_label->setVisible(true); socket_line->setVisible(true); break; + case NET_TYPE_PCAP: - // option_list_label->setText("PCAP Options"); + // option_list_label->setText("PCAP Options"); option_list_label->setVisible(true); option_list_line->setVisible(true); intf_cbox->setVisible(true); intf_label->setVisible(true); break; + + case NET_TYPE_SLIRP: + default: + break; } } } @@ -124,11 +128,10 @@ SettingsNetwork::save() net_cards_conf[i].net_type = cbox->currentData().toInt(); cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); memset(net_cards_conf[i].host_dev_name, '\0', sizeof(net_cards_conf[i].host_dev_name)); - if (net_cards_conf[i].net_type == NET_TYPE_PCAP) { + if (net_cards_conf[i].net_type == NET_TYPE_PCAP) strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1); - } else if (net_cards_conf[i].net_type == NET_TYPE_VDE) { + else if (net_cards_conf[i].net_type == NET_TYPE_VDE) strncpy(net_cards_conf[i].host_dev_name, socket_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); - } } } @@ -141,7 +144,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) int selectedRow = 0; // Network Card - QComboBox * cbox_[NET_CARD_MAX] = { 0 }; + QComboBox *cbox_[NET_CARD_MAX] = { 0 }; QAbstractItemModel *models[NET_CARD_MAX] = { 0 }; int removeRows_[NET_CARD_MAX] = { 0 }; int selectedRows[NET_CARD_MAX] = { 0 }; @@ -226,9 +229,8 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) void SettingsNetwork::on_comboIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } enableElements(ui); } @@ -236,8 +238,8 @@ SettingsNetwork::on_comboIndexChanged(int index) void SettingsNetwork::on_pushButtonConf1_clicked() { - int netCard = ui->comboBoxNIC1->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC1->currentData().toInt(); + auto *device = network_card_getdevice(netCard); if (netCard == NET_INTERNAL) device = machine_get_net_device(machineId); DeviceConfig::ConfigureDevice(device, 1); @@ -246,23 +248,23 @@ SettingsNetwork::on_pushButtonConf1_clicked() void SettingsNetwork::on_pushButtonConf2_clicked() { - int netCard = ui->comboBoxNIC2->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC2->currentData().toInt(); + auto *device = network_card_getdevice(netCard); DeviceConfig::ConfigureDevice(device, 2); } void SettingsNetwork::on_pushButtonConf3_clicked() { - int netCard = ui->comboBoxNIC3->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC3->currentData().toInt(); + auto *device = network_card_getdevice(netCard); DeviceConfig::ConfigureDevice(device, 3); } void SettingsNetwork::on_pushButtonConf4_clicked() { - int netCard = ui->comboBoxNIC4->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC4->currentData().toInt(); + auto *device = network_card_getdevice(netCard); DeviceConfig::ConfigureDevice(device, 4); } diff --git a/src/qt/qt_settingsnetwork.ui b/src/qt/qt_settingsnetwork.ui index 8fb048f71..0c0979c46 100644 --- a/src/qt/qt_settingsnetwork.ui +++ b/src/qt/qt_settingsnetwork.ui @@ -27,15 +27,29 @@ 0 - + 0 - + + Network Card #1 - + + + + + + 0 + 0 + + + + Mode: + + + @@ -50,7 +64,7 @@ - + 0 @@ -62,79 +76,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Mode: - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Configure - - - - - - - Options - - - - - - - - 0 - 0 - - - - Interface: - - - - - - - VDE Socket: - - - @@ -151,10 +92,43 @@ - - - - 127 + + + + + 0 + 0 + + + + Configure + + + + + + + Options + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Interface: @@ -168,15 +142,22 @@ - - - - - Network Card #2 - - + + + + VDE Socket: + + + + + + + 127 + + + - + Qt::Vertical @@ -188,28 +169,16 @@ - - - - - 0 - 0 - - - - Interface: - - - - - - - Options - - - + + + + + + Network Card #2 + + - + 0 @@ -234,22 +203,8 @@ - - - - VDE Socket: - - - - - - - Qt::Horizontal - - - - + 0 @@ -261,6 +216,22 @@ + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + 30 + + + @@ -274,25 +245,33 @@ - - - - 30 + + + + Options + + + + + + Qt::Horizontal + + + + + - + 0 0 - - QComboBox::AdjustToContents + + Interface: - - - @@ -303,13 +282,54 @@ + + + + VDE Socket: + + + + + + + 127 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + Network Card #3 - + + + + + + 0 + 0 + + + + Mode: + + + @@ -323,17 +343,16 @@ - - - - VDE Socket: + + + + + 0 + 0 + - - - - - Options + Adapter: @@ -353,39 +372,6 @@ - - - - - 0 - 0 - - - - Interface: - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Mode: - - - @@ -399,8 +385,22 @@ - - + + + + Options + + + + + + + Qt::Horizontal + + + + + 0 @@ -408,13 +408,10 @@ - Adapter: + Interface: - - - @@ -425,8 +422,22 @@ + + + + VDE Socket: + + + + + + + 127 + + + - + Qt::Vertical @@ -440,20 +451,14 @@ - + + Network Card #4 - - - - - Options - - - + - + 0 @@ -465,28 +470,21 @@ - - - - Qt::Vertical + + + + 30 - - - 20 - 40 - - - - - - - - VDE Socket: + + + 0 + 0 + - + 0 @@ -498,26 +496,6 @@ - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Interface: - - - @@ -534,19 +512,6 @@ - - - - 30 - - - - 0 - 0 - - - - @@ -560,8 +525,32 @@ - - + + + + Options + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Interface: + + @@ -573,8 +562,36 @@ + + + + VDE Socket: + + + + + + + 127 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + diff --git a/src/qt/qt_settingsotherperipherals.cpp b/src/qt/qt_settingsotherperipherals.cpp index e1920bf47..0ecdc30d3 100644 --- a/src/qt/qt_settingsotherperipherals.cpp +++ b/src/qt/qt_settingsotherperipherals.cpp @@ -11,8 +11,10 @@ * * * Authors: Joakim L. Gilje + * Jasmine Iwanek * * Copyright 2021 Joakim L. Gilje + * Copyright 2025 Jasmine Iwanek */ #include "qt_settingsotherperipherals.hpp" #include "ui_qt_settingsotherperipherals.h" @@ -22,6 +24,7 @@ extern "C" { #include <86box/device.h> #include <86box/machine.h> #include <86box/isamem.h> +#include <86box/isarom.h> #include <86box/isartc.h> #include <86box/unittester.h> #include <86box/novell_cardkey.h> @@ -44,84 +47,131 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId) this->machineId = machineId; bool machineHasIsa = (machine_has_bus(machineId, MACHINE_BUS_ISA) > 0); + + ui->pushButtonConfigureRTC->setEnabled(machineHasIsa); + ui->comboBoxRTC->setEnabled(machineHasIsa); + ui->checkBoxISABugger->setEnabled(machineHasIsa); + ui->pushButtonConfigureUT->setEnabled(unittester_enabled > 0); + ui->checkBoxKeyCard->setEnabled(machineHasIsa); + ui->pushButtonConfigureKeyCard->setEnabled(novell_keycard_enabled > 0); + ui->checkBoxISABugger->setChecked((machineHasIsa && (bugger_enabled > 0)) ? true : false); ui->checkBoxPOSTCard->setChecked(postcard_enabled > 0 ? true : false); ui->checkBoxUnitTester->setChecked(unittester_enabled > 0 ? true : false); ui->checkBoxKeyCard->setChecked((machineHasIsa && (novell_keycard_enabled > 0)) ? true : false); - ui->checkBoxISABugger->setEnabled(machineHasIsa); - ui->checkBoxKeyCard->setEnabled(machineHasIsa); - ui->pushButtonConfigureKeyCard->setEnabled(novell_keycard_enabled > 0); - ui->pushButtonConfigureUT->setEnabled(unittester_enabled > 0); - ui->comboBoxRTC->setEnabled(machineHasIsa); - ui->pushButtonConfigureRTC->setEnabled(machineHasIsa); - ui->comboBoxCard1->clear(); - ui->comboBoxCard2->clear(); - ui->comboBoxCard3->clear(); - ui->comboBoxCard4->clear(); ui->comboBoxRTC->clear(); - auto *model = ui->comboBoxRTC->model(); - int d = 0; + for (uint8_t i = 0; i < ISAMEM_MAX; ++i) + if (auto *cb = findChild(QString("comboBoxIsaMemCard%1").arg(i + 1))) + cb->clear(); + + for (uint8_t i = 0; i < ISAROM_MAX; ++i) + if (auto *cb = findChild(QString("comboBoxIsaRomCard%1").arg(i + 1))) + cb->clear(); + + int c = 0; int selectedRow = 0; + + // ISA RTC Cards + auto *model = ui->comboBoxRTC->model(); while (true) { - QString name = DeviceConfig::DeviceName(isartc_get_device(d), isartc_get_internal_name(d), 0); - if (name.isEmpty()) { + const QString name = DeviceConfig::DeviceName(isartc_get_device(c), isartc_get_internal_name(c), 0); + if (name.isEmpty()) break; - } - if (!device_is_valid(isartc_get_device(d), machineId)) { + if (!device_is_valid(isartc_get_device(c), machineId)) break; - } - int row = Models::AddEntry(model, name, d); - if (d == isartc_type) { + int row = Models::AddEntry(model, name, c); + if (c == isartc_type) selectedRow = row; - } - ++d; + + ++c; } ui->comboBoxRTC->setCurrentIndex(selectedRow); ui->pushButtonConfigureRTC->setEnabled((isartc_type != 0) && isartc_has_config(isartc_type) && machineHasIsa); - // ISA Memory Expansion Card - QComboBox * cbox[ISAMEM_MAX] = { 0 }; - QAbstractItemModel *models[ISAMEM_MAX] = { 0 }; - int removeRows_[ISAMEM_MAX] = { 0 }; - int selectedRows[ISAMEM_MAX] = { 0 }; + // ISA Memory Expansion Cards + QComboBox *isamem_cbox[ISAMEM_MAX] = { 0 }; + QAbstractItemModel *isamem_models[ISAMEM_MAX] = { 0 }; + int isamem_removeRows_[ISAMEM_MAX] = { 0 }; + int isamem_selectedRows[ISAMEM_MAX] = { 0 }; - for (uint8_t c = 0; c < ISAMEM_MAX; ++c) { - cbox[c] = findChild(QString("comboBoxCard%1").arg(c + 1)); - models[c] = cbox[c]->model(); - removeRows_[c] = models[c]->rowCount(); + for (uint8_t i = 0; i < ISAMEM_MAX; ++i) { + isamem_cbox[i] = findChild(QString("comboBoxIsaMemCard%1").arg(i + 1)); + isamem_models[i] = isamem_cbox[i]->model(); + isamem_removeRows_[i] = isamem_models[i]->rowCount(); } - d = 0; + c = 0; while (true) { - const QString name = DeviceConfig::DeviceName(isamem_get_device(d), - isamem_get_internal_name(d), 0); + const QString name = DeviceConfig::DeviceName(isamem_get_device(c), + isamem_get_internal_name(c), 0); if (name.isEmpty()) break; - if (device_is_valid(isamem_get_device(d), machineId)) { - for (uint8_t c = 0; c < ISAMEM_MAX; ++c) { - int row = Models::AddEntry(models[c], name, d); + if (device_is_valid(isamem_get_device(c), machineId)) { + for (uint8_t i = 0; i < ISAMEM_MAX; ++i) { + int row = Models::AddEntry(isamem_models[i], name, c); - if (d == isamem_type[c]) - selectedRows[c] = row - removeRows_[c]; + if (c == isamem_type[i]) + isamem_selectedRows[i] = row - isamem_removeRows_[i]; } } - d++; + c++; } - for (uint8_t c = 0; c < ISAMEM_MAX; ++c) { - models[c]->removeRows(0, removeRows_[c]); - cbox[c]->setEnabled(models[c]->rowCount() > 1); - cbox[c]->setCurrentIndex(-1); - cbox[c]->setCurrentIndex(selectedRows[c]); - findChild(QString("pushButtonConfigureCard%1").arg(c + 1))->setEnabled((isamem_type[c] != 0) && - isamem_has_config(isamem_type[c]) && machineHasIsa); + for (uint8_t i = 0; i < ISAMEM_MAX; ++i) { + isamem_models[i]->removeRows(0, isamem_removeRows_[i]); + isamem_cbox[i]->setEnabled(isamem_models[i]->rowCount() > 1); + isamem_cbox[i]->setCurrentIndex(-1); + isamem_cbox[i]->setCurrentIndex(isamem_selectedRows[i]); + findChild(QString("pushButtonConfigureIsaMemCard%1").arg(i + 1))->setEnabled((isamem_type[i] != 0) && + isamem_has_config(isamem_type[i]) && machineHasIsa); + } + + // ISA ROM Expansion Cards + QComboBox *isarom_cbox[ISAROM_MAX] = { 0 }; + QAbstractItemModel *isarom_models[ISAROM_MAX] = { 0 }; + int isarom_removeRows_[ISAROM_MAX] = { 0 }; + int isarom_selectedRows[ISAROM_MAX] = { 0 }; + + for (uint8_t i = 0; i < ISAROM_MAX; ++i) { + isarom_cbox[i] = findChild(QString("comboBoxIsaRomCard%1").arg(i + 1)); + isarom_models[i] = isarom_cbox[i]->model(); + isarom_removeRows_[i] = isarom_models[i]->rowCount(); + } + + c = 0; + while (true) { + const QString name = DeviceConfig::DeviceName(isarom_get_device(c), + isarom_get_internal_name(c), 0); + + if (name.isEmpty()) + break; + + if (device_is_valid(isarom_get_device(c), machineId)) { + for (uint8_t i = 0; i < ISAROM_MAX; ++i) { + int row = Models::AddEntry(isarom_models[i], name, c); + + if (c == isarom_type[i]) + isarom_selectedRows[i] = row - isarom_removeRows_[i]; + } + } + + c++; + } + + for (uint8_t i = 0; i < ISAROM_MAX; ++i) { + isarom_models[i]->removeRows(0, isarom_removeRows_[i]); + isarom_cbox[i]->setEnabled(isarom_models[i]->rowCount() > 1); + isarom_cbox[i]->setCurrentIndex(-1); + isarom_cbox[i]->setCurrentIndex(isarom_selectedRows[i]); + findChild(QString("pushButtonConfigureIsaRomCard%1").arg(i + 1))->setEnabled((isarom_type[i] != 0) && + isarom_has_config(isarom_type[i]) && machineHasIsa); } } @@ -134,25 +184,31 @@ void SettingsOtherPeripherals::save() { /* Other peripherals category */ + isartc_type = ui->comboBoxRTC->currentData().toInt(); bugger_enabled = ui->checkBoxISABugger->isChecked() ? 1 : 0; postcard_enabled = ui->checkBoxPOSTCard->isChecked() ? 1 : 0; unittester_enabled = ui->checkBoxUnitTester->isChecked() ? 1 : 0; novell_keycard_enabled = ui->checkBoxKeyCard->isChecked() ? 1 : 0; - isartc_type = ui->comboBoxRTC->currentData().toInt(); /* ISA memory boards. */ for (int i = 0; i < ISAMEM_MAX; i++) { - auto *cbox = findChild(QString("comboBoxCard%1").arg(i + 1)); + auto *cbox = findChild(QString("comboBoxIsaMemCard%1").arg(i + 1)); isamem_type[i] = cbox->currentData().toInt(); } + + /* ISA ROM boards. */ + for (int i = 0; i < ISAROM_MAX; i++) { + auto *cbox = findChild(QString("comboBoxIsaRomCard%1").arg(i + 1)); + isarom_type[i] = cbox->currentData().toInt(); + } } void SettingsOtherPeripherals::on_comboBoxRTC_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } + ui->pushButtonConfigureRTC->setEnabled((index != 0) && isartc_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); } @@ -163,63 +219,123 @@ SettingsOtherPeripherals::on_pushButtonConfigureRTC_clicked() } void -SettingsOtherPeripherals::on_comboBoxCard1_currentIndexChanged(int index) +SettingsOtherPeripherals::on_comboBoxIsaMemCard1_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } - ui->pushButtonConfigureCard1->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); + + ui->pushButtonConfigureIsaMemCard1->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void -SettingsOtherPeripherals::on_pushButtonConfigureCard1_clicked() +SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard1_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard1->currentData().toInt()), 1); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard1->currentData().toInt()), 1); } void -SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index) +SettingsOtherPeripherals::on_comboBoxIsaMemCard2_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } - ui->pushButtonConfigureCard2->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); + + ui->pushButtonConfigureIsaMemCard2->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void -SettingsOtherPeripherals::on_pushButtonConfigureCard2_clicked() +SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard2_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard2->currentData().toInt()), 2); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard2->currentData().toInt()), 2); } void -SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index) +SettingsOtherPeripherals::on_comboBoxIsaMemCard3_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } - ui->pushButtonConfigureCard3->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); + + ui->pushButtonConfigureIsaMemCard3->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void -SettingsOtherPeripherals::on_pushButtonConfigureCard3_clicked() +SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard3_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard3->currentData().toInt()), 3); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard3->currentData().toInt()), 3); } void -SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index) +SettingsOtherPeripherals::on_comboBoxIsaMemCard4_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } - ui->pushButtonConfigureCard4->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); + + ui->pushButtonConfigureIsaMemCard4->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void -SettingsOtherPeripherals::on_pushButtonConfigureCard4_clicked() +SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard4_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()), 4); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard4->currentData().toInt()), 4); +} + +void +SettingsOtherPeripherals::on_comboBoxIsaRomCard1_currentIndexChanged(int index) +{ + if (index < 0) + return; + + ui->pushButtonConfigureIsaRomCard1->setEnabled((index != 0) && isarom_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); +} + +void +SettingsOtherPeripherals::on_pushButtonConfigureIsaRomCard1_clicked() +{ + DeviceConfig::ConfigureDevice(isarom_get_device(ui->comboBoxIsaRomCard1->currentData().toInt()), 1); +} + +void +SettingsOtherPeripherals::on_comboBoxIsaRomCard2_currentIndexChanged(int index) +{ + if (index < 0) + return; + + ui->pushButtonConfigureIsaRomCard2->setEnabled((index != 0) && isarom_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); +} + +void +SettingsOtherPeripherals::on_pushButtonConfigureIsaRomCard2_clicked() +{ + DeviceConfig::ConfigureDevice(isarom_get_device(ui->comboBoxIsaRomCard2->currentData().toInt()), 2); +} + +void +SettingsOtherPeripherals::on_comboBoxIsaRomCard3_currentIndexChanged(int index) +{ + if (index < 0) + return; + + ui->pushButtonConfigureIsaRomCard3->setEnabled((index != 0) && isarom_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); +} + +void +SettingsOtherPeripherals::on_pushButtonConfigureIsaRomCard3_clicked() +{ + DeviceConfig::ConfigureDevice(isarom_get_device(ui->comboBoxIsaRomCard3->currentData().toInt()), 3); +} + +void +SettingsOtherPeripherals::on_comboBoxIsaRomCard4_currentIndexChanged(int index) +{ + if (index < 0) + return; + + ui->pushButtonConfigureIsaRomCard4->setEnabled((index != 0) && isarom_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA)); +} + +void +SettingsOtherPeripherals::on_pushButtonConfigureIsaRomCard4_clicked() +{ + DeviceConfig::ConfigureDevice(isarom_get_device(ui->comboBoxIsaRomCard4->currentData().toInt()), 4); } void @@ -234,13 +350,12 @@ SettingsOtherPeripherals::on_pushButtonConfigureUT_clicked() DeviceConfig::ConfigureDevice(&unittester_device); } -void SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked() -{ - DeviceConfig::ConfigureDevice(&novell_keycard_device); -} - void SettingsOtherPeripherals::on_checkBoxKeyCard_stateChanged(int arg1) { ui->pushButtonConfigureKeyCard->setEnabled(arg1 != 0); } +void SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked() +{ + DeviceConfig::ConfigureDevice(&novell_keycard_device); +} diff --git a/src/qt/qt_settingsotherperipherals.hpp b/src/qt/qt_settingsotherperipherals.hpp index d5804a68b..991759259 100644 --- a/src/qt/qt_settingsotherperipherals.hpp +++ b/src/qt/qt_settingsotherperipherals.hpp @@ -20,22 +20,32 @@ public slots: void onCurrentMachineChanged(int machineId); private slots: - void on_pushButtonConfigureCard4_clicked(); - void on_comboBoxCard4_currentIndexChanged(int index); - void on_pushButtonConfigureCard3_clicked(); - void on_comboBoxCard3_currentIndexChanged(int index); - void on_pushButtonConfigureCard2_clicked(); - void on_comboBoxCard2_currentIndexChanged(int index); - void on_pushButtonConfigureCard1_clicked(); - void on_comboBoxCard1_currentIndexChanged(int index); - void on_pushButtonConfigureRTC_clicked(); void on_comboBoxRTC_currentIndexChanged(int index); + void on_pushButtonConfigureRTC_clicked(); + + void on_comboBoxIsaMemCard1_currentIndexChanged(int index); + void on_pushButtonConfigureIsaMemCard1_clicked(); + void on_comboBoxIsaMemCard2_currentIndexChanged(int index); + void on_pushButtonConfigureIsaMemCard2_clicked(); + void on_comboBoxIsaMemCard3_currentIndexChanged(int index); + void on_pushButtonConfigureIsaMemCard3_clicked(); + void on_comboBoxIsaMemCard4_currentIndexChanged(int index); + void on_pushButtonConfigureIsaMemCard4_clicked(); + + void on_comboBoxIsaRomCard1_currentIndexChanged(int index); + void on_pushButtonConfigureIsaRomCard1_clicked(); + void on_comboBoxIsaRomCard2_currentIndexChanged(int index); + void on_pushButtonConfigureIsaRomCard2_clicked(); + void on_comboBoxIsaRomCard3_currentIndexChanged(int index); + void on_pushButtonConfigureIsaRomCard3_clicked(); + void on_comboBoxIsaRomCard4_currentIndexChanged(int index); + void on_pushButtonConfigureIsaRomCard4_clicked(); + void on_checkBoxUnitTester_stateChanged(int arg1); void on_pushButtonConfigureUT_clicked(); - void on_pushButtonConfigureKeyCard_clicked(); - void on_checkBoxKeyCard_stateChanged(int arg1); + void on_pushButtonConfigureKeyCard_clicked(); private: Ui::SettingsOtherPeripherals *ui; diff --git a/src/qt/qt_settingsotherperipherals.ui b/src/qt/qt_settingsotherperipherals.ui index 41df2deac..5c6b8fbf0 100644 --- a/src/qt/qt_settingsotherperipherals.ui +++ b/src/qt/qt_settingsotherperipherals.ui @@ -27,9 +27,9 @@ 0 - + - + ISA RTC: @@ -58,20 +58,74 @@ - + ISA Memory Expansion - - - + + + + + Card 1: + + + + + + + + 0 + 0 + + + + 30 + + + + + Configure + + + + Card 2: + + + - + + + + 0 + 0 + + + + 30 + + + + + + + Configure + + + + + + + Card 3: + + + + + 0 @@ -84,68 +138,21 @@ - + Configure - - + + - Card 2: - - - - - - - Card 3: - - - - - - - Configure - - - - - - - - 0 - 0 - - - - 30 - - - - - - - Card 1: - - - - - - - - 0 - 0 - - - - 30 + Card 4: - + 0 @@ -158,24 +165,134 @@ - + Configure - - - - Card 4: - - - - + + + ISA ROM Cards + + + + + + Card 1: + + + + + + + + 0 + 0 + + + + 30 + + + + + + + Configure + + + + + + + Card 2: + + + + + + + + 0 + 0 + + + + 30 + + + + + + + Configure + + + + + + + Card 3: + + + + + + + + 0 + 0 + + + + 30 + + + + + + + Configure + + + + + + + Card 4: + + + + + + + + 0 + 0 + + + + 30 + + + + + + + Configure + + + + + + + + @@ -193,7 +310,7 @@ - + @@ -217,7 +334,7 @@ - + 0 diff --git a/src/qt/qt_settingsotherremovable.hpp b/src/qt/qt_settingsotherremovable.hpp index cea1d202b..1459ed043 100644 --- a/src/qt/qt_settingsotherremovable.hpp +++ b/src/qt/qt_settingsotherremovable.hpp @@ -21,33 +21,19 @@ public: signals: void moChannelChanged(); void zipChannelChanged(); -private slots: - void on_checkBoxZIP250_stateChanged(int arg1); - -private slots: - void on_comboBoxZIPChannel_activated(int index); - -private slots: - void on_comboBoxZIPBus_activated(int index); - -private slots: - void on_comboBoxZIPBus_currentIndexChanged(int index); - -private slots: - void on_comboBoxMOType_activated(int index); - -private slots: - void on_comboBoxMOChannel_activated(int index); - -private slots: - void on_comboBoxMOBus_activated(int index); - -private slots: - void on_comboBoxMOBus_currentIndexChanged(int index); private slots: void onMORowChanged(const QModelIndex ¤t); + void on_comboBoxMOBus_currentIndexChanged(int index); + void on_comboBoxMOBus_activated(int index); + void on_comboBoxMOChannel_activated(int index); + void on_comboBoxMOType_activated(int index); + void onZIPRowChanged(const QModelIndex ¤t); + void on_comboBoxZIPBus_currentIndexChanged(int index); + void on_comboBoxZIPBus_activated(int index); + void on_comboBoxZIPChannel_activated(int index); + void on_checkBoxZIP250_stateChanged(int arg1); private: Ui::SettingsOtherRemovable *ui; diff --git a/src/qt/qt_settingsotherremovable.ui b/src/qt/qt_settingsotherremovable.ui index 8962184fc..ae7839e54 100644 --- a/src/qt/qt_settingsotherremovable.ui +++ b/src/qt/qt_settingsotherremovable.ui @@ -27,7 +27,7 @@ 0 - + MO drives: @@ -68,19 +68,12 @@ - + Bus: - - - - Channel: - - - @@ -88,6 +81,13 @@ + + + + Channel: + + + @@ -96,7 +96,7 @@ - + Type: @@ -113,7 +113,7 @@ - + ZIP drives: @@ -154,7 +154,7 @@ - + Bus: @@ -168,7 +168,7 @@ - + Channel: diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index 7e8f2aeda..ddebd28e8 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -51,7 +51,7 @@ SettingsPorts::save() { for (int i = 0; i < PARALLEL_MAX; i++) { auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); - auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); + auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); if (cbox != NULL) lpt_ports[i].device = cbox->currentData().toInt(); if (checkBox != NULL) @@ -73,7 +73,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId) { this->machineId = machineId; - int c = 0; + int c = 0; // LPT Device QComboBox * cbox[PARALLEL_MAX] = { 0 }; @@ -93,7 +93,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId) if (lptName == nullptr) break; - const QString name = tr(lptName); + const QString name = tr(lptName); for (uint8_t i = 0; i < PARALLEL_MAX; ++i) { int row = Models::AddEntry(models[i], name, c); diff --git a/src/qt/qt_settingsports.hpp b/src/qt/qt_settingsports.hpp index 83560914f..8be1f0491 100644 --- a/src/qt/qt_settingsports.hpp +++ b/src/qt/qt_settingsports.hpp @@ -35,22 +35,25 @@ private slots: void on_checkBoxSerial7_stateChanged(int state); #endif void on_checkBoxSerialPassThru1_stateChanged(int state); + void on_pushButtonSerialPassThru1_clicked(); + void on_checkBoxSerialPassThru2_stateChanged(int state); + void on_pushButtonSerialPassThru2_clicked(); + void on_checkBoxSerialPassThru3_stateChanged(int state); + void on_pushButtonSerialPassThru3_clicked(); + void on_checkBoxSerialPassThru4_stateChanged(int state); + void on_pushButtonSerialPassThru4_clicked(); + #if 0 void on_checkBoxSerialPassThru5_stateChanged(int state); - void on_checkBoxSerialPassThru6_stateChanged(int state); - void on_checkBoxSerialPassThru7_stateChanged(int state); -#endif - - void on_pushButtonSerialPassThru1_clicked(); - void on_pushButtonSerialPassThru2_clicked(); - void on_pushButtonSerialPassThru3_clicked(); - void on_pushButtonSerialPassThru4_clicked(); -#if 0 void on_pushButtonSerialPassThru5_clicked(); + + void on_checkBoxSerialPassThru6_stateChanged(int state); void on_pushButtonSerialPassThru6_clicked(); + + void on_checkBoxSerialPassThru7_stateChanged(int state); void on_pushButtonSerialPassThru7_clicked(); #endif diff --git a/src/qt/qt_settingsports.ui b/src/qt/qt_settingsports.ui index bca870e5d..92420f2df 100644 --- a/src/qt/qt_settingsports.ui +++ b/src/qt/qt_settingsports.ui @@ -29,7 +29,7 @@ - + LPT1 Device: @@ -43,7 +43,7 @@ - + LPT2 Device: @@ -57,7 +57,7 @@ - + LPT3 Device: @@ -71,7 +71,7 @@ - + LPT4 Device: @@ -88,27 +88,6 @@ - - - - Parallel port 2 - - - - - - - Parallel port 3 - - - - - - - Serial port 3 - - - @@ -116,20 +95,6 @@ - - - - Parallel port 4 - - - - - - - Serial port 2 - - - @@ -137,6 +102,34 @@ + + + + Serial port 2 + + + + + + + Parallel port 2 + + + + + + + Serial port 3 + + + + + + + Parallel port 3 + + + @@ -144,13 +137,76 @@ + + + + Parallel port 4 + + + - + QLayout::SetDefaultConstraint + + + + Serial port passthrough 1 + + + + + + + Configure + + + + + + + Serial port passthrough 2 + + + + + + + Configure + + + + + + + Serial port passthrough 3 + + + + + + + Configure + + + + + + + Serial port passthrough 4 + + + + + + + Configure + + + @@ -164,13 +220,6 @@ - - - - Serial port passthrough 3 - - - @@ -184,55 +233,6 @@ - - - - Configure - - - - - - - Serial port passthrough 1 - - - - - - - Serial port passthrough 2 - - - - - - - Serial port passthrough 4 - - - - - - - Configure - - - - - - - Configure - - - - - - - Configure - - - diff --git a/src/qt/qt_settingssound.cpp b/src/qt/qt_settingssound.cpp index e49e1ae27..57e278515 100644 --- a/src/qt/qt_settingssound.cpp +++ b/src/qt/qt_settingssound.cpp @@ -14,7 +14,7 @@ * Jasmine Iwanek * * Copyright 2021 Joakim L. Gilje - * Copyright 2022-2023 Jasmine Iwanek + * Copyright 2022-2025 Jasmine Iwanek */ #include "qt_settingssound.hpp" #include "ui_qt_settingssound.h" @@ -76,8 +76,8 @@ SettingsSound::onCurrentMachineChanged(const int machineId) int c; int selectedRow; - // Sound Card - QComboBox * cbox[SOUND_CARD_MAX] = { 0 }; + // Sound Cards + QComboBox *cbox[SOUND_CARD_MAX] = { 0 }; QAbstractItemModel *models[SOUND_CARD_MAX] = { 0 }; int removeRows_[SOUND_CARD_MAX] = { 0 }; int selectedRows[SOUND_CARD_MAX] = { 0 }; @@ -89,7 +89,7 @@ SettingsSound::onCurrentMachineChanged(const int machineId) removeRows_[i] = models[i]->rowCount(); } - c = 0; + c = 0; while (true) { const QString name = DeviceConfig::DeviceName(sound_card_getdevice(c), sound_card_get_internal_name(c), 1); @@ -110,7 +110,7 @@ SettingsSound::onCurrentMachineChanged(const int machineId) } } - c++; + c++; } for (uint8_t i = 0; i < SOUND_CARD_MAX; ++i) { @@ -122,21 +122,19 @@ SettingsSound::onCurrentMachineChanged(const int machineId) // Midi Out c = 0; - auto model = ui->comboBoxMidiOut->model(); + auto *model = ui->comboBoxMidiOut->model(); auto removeRows = model->rowCount(); selectedRow = 0; while (true) { const QString name = DeviceConfig::DeviceName(midi_out_device_getdevice(c), midi_out_device_get_internal_name(c), 0); - if (name.isEmpty()) { + if (name.isEmpty()) break; - } if (midi_out_device_available(c)) { int row = Models::AddEntry(model, name, c); - if (c == midi_output_device_current) { + if (c == midi_output_device_current) selectedRow = row - removeRows; - } } c++; @@ -155,15 +153,13 @@ SettingsSound::onCurrentMachineChanged(const int machineId) while (true) { const QString name = DeviceConfig::DeviceName(midi_in_device_getdevice(c), midi_in_device_get_internal_name(c), 0); - if (name.isEmpty()) { + if (name.isEmpty()) break; - } if (midi_in_device_available(c)) { int row = Models::AddEntry(model, name, c); - if (c == midi_input_device_current) { + if (c == midi_input_device_current) selectedRow = row - removeRows; - } } c++; @@ -198,13 +194,11 @@ allowMpu401(Ui::SettingsSound *ui) QString midiOut = midi_out_device_get_internal_name(ui->comboBoxMidiOut->currentData().toInt()); QString midiIn = midi_in_device_get_internal_name(ui->comboBoxMidiIn->currentData().toInt()); - if (midiOut.isEmpty()) { + if (midiOut.isEmpty()) return false; - } - if (midiOut == QStringLiteral("none") && midiIn == QStringLiteral("none")) { + if (midiOut == QStringLiteral("none") && midiIn == QStringLiteral("none")) return false; - } return true; } @@ -212,9 +206,9 @@ allowMpu401(Ui::SettingsSound *ui) void SettingsSound::on_comboBoxSoundCard1_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } + int sndCard = ui->comboBoxSoundCard1->currentData().toInt(); if (sndCard == SOUND_INTERNAL) @@ -238,9 +232,8 @@ SettingsSound::on_pushButtonConfigureSoundCard1_clicked() void SettingsSound::on_comboBoxSoundCard2_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } int sndCard = ui->comboBoxSoundCard2->currentData().toInt(); @@ -258,9 +251,8 @@ SettingsSound::on_pushButtonConfigureSoundCard2_clicked() void SettingsSound::on_comboBoxSoundCard3_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } int sndCard = ui->comboBoxSoundCard3->currentData().toInt(); @@ -279,9 +271,8 @@ SettingsSound::on_pushButtonConfigureSoundCard3_clicked() void SettingsSound::on_comboBoxSoundCard4_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } int sndCard = ui->comboBoxSoundCard4->currentData().toInt(); @@ -300,9 +291,8 @@ SettingsSound::on_pushButtonConfigureSoundCard4_clicked() void SettingsSound::on_comboBoxMidiOut_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } ui->pushButtonConfigureMidiOut->setEnabled(midi_out_device_has_config(ui->comboBoxMidiOut->currentData().toInt())); ui->checkBoxMPU401->setEnabled(allowMpu401(ui) && (machine_has_bus(machineId, MACHINE_BUS_ISA) || machine_has_bus(machineId, MACHINE_BUS_MCA))); @@ -318,9 +308,8 @@ SettingsSound::on_pushButtonConfigureMidiOut_clicked() void SettingsSound::on_comboBoxMidiIn_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } ui->pushButtonConfigureMidiIn->setEnabled(midi_in_device_has_config(ui->comboBoxMidiIn->currentData().toInt())); ui->checkBoxMPU401->setEnabled(allowMpu401(ui) && (machine_has_bus(machineId, MACHINE_BUS_ISA) || machine_has_bus(machineId, MACHINE_BUS_MCA))); diff --git a/src/qt/qt_settingssound.hpp b/src/qt/qt_settingssound.hpp index 92b700c92..cc2926d5d 100644 --- a/src/qt/qt_settingssound.hpp +++ b/src/qt/qt_settingssound.hpp @@ -20,20 +20,26 @@ public slots: void onCurrentMachineChanged(int machineId); private slots: - void on_pushButtonConfigureMPU401_clicked(); - void on_checkBoxMPU401_stateChanged(int arg1); - void on_pushButtonConfigureMidiIn_clicked(); - void on_pushButtonConfigureMidiOut_clicked(); - void on_comboBoxMidiIn_currentIndexChanged(int index); - void on_comboBoxMidiOut_currentIndexChanged(int index); - void on_pushButtonConfigureSoundCard1_clicked(); void on_comboBoxSoundCard1_currentIndexChanged(int index); - void on_pushButtonConfigureSoundCard2_clicked(); + void on_pushButtonConfigureSoundCard1_clicked(); + void on_comboBoxSoundCard2_currentIndexChanged(int index); - void on_pushButtonConfigureSoundCard3_clicked(); + void on_pushButtonConfigureSoundCard2_clicked(); + void on_comboBoxSoundCard3_currentIndexChanged(int index); - void on_pushButtonConfigureSoundCard4_clicked(); + void on_pushButtonConfigureSoundCard3_clicked(); + void on_comboBoxSoundCard4_currentIndexChanged(int index); + void on_pushButtonConfigureSoundCard4_clicked(); + + void on_comboBoxMidiOut_currentIndexChanged(int index); + void on_pushButtonConfigureMidiOut_clicked(); + + void on_comboBoxMidiIn_currentIndexChanged(int index); + void on_pushButtonConfigureMidiIn_clicked(); + + void on_checkBoxMPU401_stateChanged(int arg1); + void on_pushButtonConfigureMPU401_clicked(); private: Ui::SettingsSound *ui; diff --git a/src/qt/qt_settingssound.ui b/src/qt/qt_settingssound.ui index 1d5ab0050..97ef7c3ff 100644 --- a/src/qt/qt_settingssound.ui +++ b/src/qt/qt_settingssound.ui @@ -26,17 +26,23 @@ 0 - - + + - MIDI In Device: + Sound card #1: - - - - Sound card #1: + + + + 30 + + + + 0 + 0 + @@ -48,12 +54,25 @@ - + Sound card #2: + + + + 30 + + + + 0 + 0 + + + + @@ -62,12 +81,25 @@ - + Sound card #3: + + + + 30 + + + + 0 + 0 + + + + @@ -75,14 +107,26 @@ - - + Sound card #4: + + + + 30 + + + + 0 + 0 + + + + @@ -90,49 +134,13 @@ - - - - - - 30 - - - - 0 - 0 - - - - - + MIDI Out Device: - - - - Standalone MPU-401 - - - - - - - Configure - - - - - - - Configure - - - @@ -153,6 +161,47 @@ + + + + MIDI In Device: + + + + + + + 30 + + + + 0 + 0 + + + + + + + + Configure + + + + + + + Standalone MPU-401 + + + + + + + Configure + + + @@ -171,7 +220,7 @@ FM synth driver - + @@ -202,58 +251,6 @@ - - - - 30 - - - - 0 - 0 - - - - - - - - 30 - - - - 0 - 0 - - - - - - - - 30 - - - - 0 - 0 - - - - - - - - 30 - - - - 0 - 0 - - - - diff --git a/src/qt/qt_settingsstoragecontrollers.cpp b/src/qt/qt_settingsstoragecontrollers.cpp index 48fa04892..b3d827fa2 100644 --- a/src/qt/qt_settingsstoragecontrollers.cpp +++ b/src/qt/qt_settingsstoragecontrollers.cpp @@ -56,8 +56,8 @@ SettingsStorageControllers::save() QComboBox *cbox = findChild(QString("comboBoxSCSI%1").arg(i + 1)); scsi_card_current[i] = cbox->currentData().toInt(); } - hdc_current[0] = ui->comboBoxHD->currentData().toInt(); fdc_current[0] = ui->comboBoxFD->currentData().toInt(); + hdc_current[0] = ui->comboBoxHD->currentData().toInt(); cdrom_interface_current = ui->comboBoxCDInterface->currentData().toInt(); ide_ter_enabled = ui->checkBoxTertiaryIDE->isChecked() ? 1 : 0; ide_qua_enabled = ui->checkBoxQuaternaryIDE->isChecked() ? 1 : 0; @@ -84,18 +84,16 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId) } QString name = DeviceConfig::DeviceName(hdc_get_device(c), hdc_get_internal_name(c), 1); - if (name.isEmpty()) { + if (name.isEmpty()) break; - } if (hdc_available(c)) { const device_t *hdc_dev = hdc_get_device(c); if (device_is_valid(hdc_dev, machineId)) { int row = Models::AddEntry(model, name, c); - if (c == hdc_current[0]) { + if (c == hdc_current[0]) selectedRow = row - removeRows; - } } } c++; @@ -105,7 +103,7 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId) ui->comboBoxHD->setCurrentIndex(-1); ui->comboBoxHD->setCurrentIndex(selectedRow); - /*FD controller config*/ + /* FD controller config */ model = ui->comboBoxFD->model(); removeRows = model->rowCount(); c = 0; @@ -143,11 +141,11 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId) /*CD interface controller config*/ #ifdef USE_CDROM_MITSUMI - ui->label_7->setVisible(true); + ui->labelCDInterface->setVisible(true); ui->comboBoxCDInterface->setVisible(true); ui->pushButtonCDInterface->setVisible(true); #else - ui->label_7->setVisible(false); + ui->labelCDInterface->setVisible(false); ui->comboBoxCDInterface->setVisible(false); ui->pushButtonCDInterface->setVisible(false); #endif @@ -240,29 +238,29 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId) } void -SettingsStorageControllers::on_comboBoxHD_currentIndexChanged(int index) +SettingsStorageControllers::on_comboBoxFD_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } - ui->pushButtonHD->setEnabled(hdc_has_config(ui->comboBoxHD->currentData().toInt()) > 0); + + ui->pushButtonFD->setEnabled(hdc_has_config(ui->comboBoxFD->currentData().toInt()) > 0); } void -SettingsStorageControllers::on_comboBoxFD_currentIndexChanged(int index) +SettingsStorageControllers::on_comboBoxHD_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } - ui->pushButtonFD->setEnabled(hdc_has_config(ui->comboBoxFD->currentData().toInt()) > 0); + + ui->pushButtonHD->setEnabled(hdc_has_config(ui->comboBoxHD->currentData().toInt()) > 0); } void SettingsStorageControllers::on_comboBoxCDInterface_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } + ui->pushButtonCDInterface->setEnabled(cdrom_interface_has_config(ui->comboBoxCDInterface->currentData().toInt()) > 0); } @@ -278,18 +276,18 @@ SettingsStorageControllers::on_checkBoxQuaternaryIDE_stateChanged(int arg1) ui->pushButtonQuaternaryIDE->setEnabled(arg1 == Qt::Checked); } -void -SettingsStorageControllers::on_pushButtonHD_clicked() -{ - DeviceConfig::ConfigureDevice(hdc_get_device(ui->comboBoxHD->currentData().toInt())); -} - void SettingsStorageControllers::on_pushButtonFD_clicked() { DeviceConfig::ConfigureDevice(fdc_card_getdevice(ui->comboBoxFD->currentData().toInt())); } +void +SettingsStorageControllers::on_pushButtonHD_clicked() +{ + DeviceConfig::ConfigureDevice(hdc_get_device(ui->comboBoxHD->currentData().toInt())); +} + void SettingsStorageControllers::on_pushButtonCDInterface_clicked() { @@ -311,36 +309,36 @@ SettingsStorageControllers::on_pushButtonQuaternaryIDE_clicked() void SettingsStorageControllers::on_comboBoxSCSI1_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } + ui->pushButtonSCSI1->setEnabled(scsi_card_has_config(ui->comboBoxSCSI1->currentData().toInt()) > 0); } void SettingsStorageControllers::on_comboBoxSCSI2_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } + ui->pushButtonSCSI2->setEnabled(scsi_card_has_config(ui->comboBoxSCSI2->currentData().toInt()) > 0); } void SettingsStorageControllers::on_comboBoxSCSI3_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } + ui->pushButtonSCSI3->setEnabled(scsi_card_has_config(ui->comboBoxSCSI3->currentData().toInt()) > 0); } void SettingsStorageControllers::on_comboBoxSCSI4_currentIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } + ui->pushButtonSCSI4->setEnabled(scsi_card_has_config(ui->comboBoxSCSI4->currentData().toInt()) > 0); } diff --git a/src/qt/qt_settingsstoragecontrollers.hpp b/src/qt/qt_settingsstoragecontrollers.hpp index c50a94574..7c1c56086 100644 --- a/src/qt/qt_settingsstoragecontrollers.hpp +++ b/src/qt/qt_settingsstoragecontrollers.hpp @@ -20,27 +20,31 @@ public slots: void onCurrentMachineChanged(int machineId); private slots: - void on_pushButtonSCSI4_clicked(); - void on_pushButtonSCSI3_clicked(); - void on_pushButtonSCSI2_clicked(); - void on_pushButtonSCSI1_clicked(); - void on_comboBoxSCSI4_currentIndexChanged(int index); - void on_comboBoxSCSI3_currentIndexChanged(int index); - void on_comboBoxSCSI2_currentIndexChanged(int index); - void on_comboBoxSCSI1_currentIndexChanged(int index); - void on_pushButtonQuaternaryIDE_clicked(); - void on_pushButtonTertiaryIDE_clicked(); - void on_pushButtonFD_clicked(); - void on_pushButtonHD_clicked(); - void on_pushButtonCDInterface_clicked(); - void on_checkBoxQuaternaryIDE_stateChanged(int arg1); - void on_checkBoxTertiaryIDE_stateChanged(int arg1); void on_comboBoxFD_currentIndexChanged(int index); + void on_pushButtonFD_clicked(); + void on_comboBoxHD_currentIndexChanged(int index); + void on_pushButtonHD_clicked(); + void on_comboBoxCDInterface_currentIndexChanged(int index); + void on_pushButtonCDInterface_clicked(); + + void on_checkBoxTertiaryIDE_stateChanged(int arg1); + void on_pushButtonTertiaryIDE_clicked(); + + void on_checkBoxQuaternaryIDE_stateChanged(int arg1); + void on_pushButtonQuaternaryIDE_clicked(); + + void on_comboBoxSCSI1_currentIndexChanged(int index); + void on_pushButtonSCSI1_clicked(); + void on_comboBoxSCSI2_currentIndexChanged(int index); + void on_pushButtonSCSI2_clicked(); + void on_comboBoxSCSI3_currentIndexChanged(int index); + void on_pushButtonSCSI3_clicked(); + void on_comboBoxSCSI4_currentIndexChanged(int index); + void on_pushButtonSCSI4_clicked(); void on_checkBoxLbaEnhancer_stateChanged(int arg1); - void on_pushButtonConfigureLbaEnhancer_clicked(); private: diff --git a/src/qt/qt_settingsstoragecontrollers.ui b/src/qt/qt_settingsstoragecontrollers.ui index a167e5bc1..cd1bf9baf 100644 --- a/src/qt/qt_settingsstoragecontrollers.ui +++ b/src/qt/qt_settingsstoragecontrollers.ui @@ -29,13 +29,20 @@ - + - HD Controller: + FD Controller: - + + + + 30 + + + + Configure @@ -43,14 +50,34 @@ - + - FD Controller: + HD Controller: + + + + + + + + 0 + 0 + + + + 30 + + + + + + + Configure - + CD-ROM Controller: @@ -70,33 +97,6 @@ - - - - - 0 - 0 - - - - 30 - - - - - - - Configure - - - - - - - 30 - - - @@ -104,13 +104,6 @@ - - - - Quaternary IDE Controller - - - @@ -121,6 +114,13 @@ + + + + Quaternary IDE Controller + + + @@ -134,29 +134,15 @@ - + SCSI - - - + + + - Configure - - - - - - - Configure - - - - - - - Controller 3: + Controller 1: @@ -180,6 +166,13 @@ + + + + Controller 2: + + + @@ -193,6 +186,20 @@ + + + + Configure + + + + + + + Controller 3: + + + @@ -206,6 +213,20 @@ + + + + Configure + + + + + + + Controller 4: + + + @@ -219,29 +240,8 @@ - - - - Controller 1: - - - - - - - Controller 2: - - - - - - - Controller 4: - - - - - + + Configure diff --git a/src/qt/qt_util.cpp b/src/qt/qt_util.cpp index 0c78c2f5e..5baaaaacf 100644 --- a/src/qt/qt_util.cpp +++ b/src/qt/qt_util.cpp @@ -92,6 +92,29 @@ DlgFilter(std::initializer_list extensions, bool last) return " (" % temp.join(' ') % ")" % (!last ? ";;" : ""); } +QString +DlgFilter(QStringList extensions, bool last) +{ + QStringList temp; + + for (auto ext : extensions) { +#ifdef Q_OS_UNIX + if (ext == "*") { + temp.append("*"); + continue; + } + temp.append("*." % ext.toUpper()); +#endif + temp.append("*." % ext); + } + +#ifdef Q_OS_UNIX + temp.removeDuplicates(); +#endif + return " (" % temp.join(' ') % ")" % (!last ? ";;" : ""); +} + + QString currentUuid() { auto configPath = QFileInfo(cfg_path).dir().canonicalPath(); diff --git a/src/qt/qt_util.hpp b/src/qt/qt_util.hpp index 9432610b6..e0d2648d0 100644 --- a/src/qt/qt_util.hpp +++ b/src/qt/qt_util.hpp @@ -11,6 +11,7 @@ namespace util { static constexpr auto UUID_MIN_LENGTH = 36; /* Creates extension list for qt filedialog */ QString DlgFilter(std::initializer_list extensions, bool last = false); +QString DlgFilter(QStringList extensions, bool last = false); /* Returns screen the widget is on */ QScreen *screenOfWidget(QWidget *widget); #ifdef Q_OS_WINDOWS diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index 027c85b79..1afefd905 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -161,6 +161,7 @@ fluidsynth_init(UNUSED(const device_t *info)) fluid_settings_setnum(data->settings, "synth.sample-rate", 44100); fluid_settings_setnum(data->settings, "synth.gain", device_get_config_int("output_gain") / 100.0f); + fluid_settings_setint(data->settings, "synth.dynamic-sample-loading", device_get_config_int("dynamic_sample_loading")); data->synth = new_fluid_synth(data->settings); @@ -324,7 +325,7 @@ static const device_config_t fluidsynth_config[] = { .type = CONFIG_FNAME, .default_string = NULL, .default_int = 0, - .file_filter = "SF2 Sound Fonts (*.sf2)|*.sf2", + .file_filter = "SoundFont files (*.sf2 *.sf3)|*.sf2,*.sf3", .spinner = { 0 }, .selection = { { 0 } }, .bios = { { 0 } } @@ -509,6 +510,17 @@ static const device_config_t fluidsynth_config[] = { }, .bios = { { 0 } } }, + { + .name = "dynamic_sample_loading", + .description = "Dynamic Sample Loading", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, { .name = "", .description = "", .type = CONFIG_END } // clang-format on }; diff --git a/src/sound/snd_ad1848.c b/src/sound/snd_ad1848.c index 202fd891a..e9a4390c0 100644 --- a/src/sound/snd_ad1848.c +++ b/src/sound/snd_ad1848.c @@ -731,9 +731,11 @@ ad1848_poll(void *priv) if (!(ad1848->status & 0x01)) { ad1848->status |= 0x01; ad1848->regs[24] |= 0x10; - if (ad1848->regs[10] & 2) - picint(1 << ad1848->irq); } + if (ad1848->regs[10] & 2) + picint(1 << ad1848->irq); + else + picintc(1 << ad1848->irq); } if (!(ad1848->adpcm_pos & 7)) /* ADPCM counts down every 4 bytes */ diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index b828239c0..c21b7c714 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -47,7 +47,7 @@ void ega_doblit(int wx, int wy, ega_t *ega); static video_timings_t timing_ega = { .type = VIDEO_ISA, .write_b = 8, .write_w = 16, .write_l = 32, .read_b = 8, .read_w = 16, .read_l = 32 }; static uint8_t ega_rotate[8][256]; -static int active = 0; +static int active = 0; uint32_t pallook16[256]; uint32_t pallook64[256]; static int ega_type = EGA_TYPE_IBM; @@ -72,7 +72,7 @@ ega_out(uint16_t addr, uint8_t val, void *priv) uint8_t gdcmask = (ega_type == EGA_SUPEREGA) ? 0xff : 0x0f; uint8_t crtcmask = (atype == EGA_SUPEREGA) ? 0xff : 0x1f; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(ega->miscout & 1)) + if (((((addr & 0xfff0) == 0x3d0) || ((addr & 0xfff0) == 0x2d0)) || (((addr & 0xfff0) == 0x3b0) || ((addr & 0xfff0) == 0x2b0))) && !(ega->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -94,7 +94,9 @@ ega_out(uint16_t addr, uint8_t val, void *priv) } break; + case 0x2c0: case 0x3c0: + case 0x2c1: case 0x3c1: if (atype == EGA_SUPEREGA) val &= 0x7f; /* Bit 7 indicates the flipflop status (read only) */ @@ -108,8 +110,9 @@ ega_out(uint16_t addr, uint8_t val, void *priv) } else { if ((ega->attraddr == 0x13) && (ega->attrregs[0x13] != val)) ega->fullchange = changeframecount; - o = ega->attrregs[ega->attraddr & 31]; - ega->attrregs[ega->attraddr & 31] = val; + uint8_t aidx = ega->attraddr & 31; + o = ega->attrregs[aidx]; + ega->attrregs[aidx] = val; if (ega->attraddr < 16) ega->fullchange = changeframecount; int is_attr14 = ega->chipset && (ega->attraddr == 0x14); @@ -139,6 +142,7 @@ ega_out(uint16_t addr, uint8_t val, void *priv) } ega->attrff ^= 1; break; + case 0x2c2: case 0x3c2: o = ega->miscout; egaswitchread = (val & 0xc) >> 2; @@ -148,13 +152,19 @@ ega_out(uint16_t addr, uint8_t val, void *priv) ega->miscout = val; ega->overscan_color = ega->vres ? pallook16[ega->attrregs[0x11] & 0x0f] : pallook64[ega->attrregs[0x11] & 0x3f]; - io_removehandler(0x03a0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); + + uint16_t base_addr = 0x03a0; +#ifdef EGA_ALT_ADDR_SUPPORT + if (ega->alt_addr == 1) + base_addr = 0x02a0; +#endif + io_removehandler(base_addr, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); if (!(val & 1)) - io_sethandler(0x03a0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); + io_sethandler(base_addr, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); ega_recalctimings(ega); if ((type == EGA_TYPE_COMPAQ) && !(val & 0x02)) mem_mapping_disable(&ega->mapping); - else switch (ega->gdcreg[6] & 0xc) { + else switch (ega->gdcreg[6] & 0xc) { case 0x0: /*128k at A0000*/ mem_mapping_set_addr(&ega->mapping, 0xa0000, 0x20000); break; @@ -172,9 +182,11 @@ ega_out(uint16_t addr, uint8_t val, void *priv) break; } break; + case 0x2c4: case 0x3c4: ega->seqaddr = val; break; + case 0x2c5: case 0x3c5: o = ega->seqregs[ega->seqaddr & 0xf]; ega->seqregs[ega->seqaddr & 0xf] = val; @@ -201,16 +213,20 @@ ega_out(uint16_t addr, uint8_t val, void *priv) break; } break; + case 0x2c6: case 0x3c6: if (type == EGA_TYPE_COMPAQ) ega->ctl_mode = val; break; + case 0x2ce: case 0x3ce: ega->gdcaddr = val; break; - case 0x3cf: - ega->gdcreg[ega->gdcaddr & gdcmask] = val; - switch (ega->gdcaddr & gdcmask) { + case 0x2cf: + case 0x3cf: { + uint8_t reg = ega->gdcaddr & gdcmask; + ega->gdcreg[reg] = val; + switch (reg) { case 2: ega->colourcompare = val; break; @@ -225,7 +241,7 @@ ega_out(uint16_t addr, uint8_t val, void *priv) case 6: if ((type == EGA_TYPE_COMPAQ) && !(ega->miscout & 0x02)) mem_mapping_disable(&ega->mapping); - else switch (val & 0xc) { + else switch (val & 0xc) { case 0x0: /*128k at A0000*/ mem_mapping_set_addr(&ega->mapping, 0xa0000, 0x20000); break; @@ -264,32 +280,34 @@ ega_out(uint16_t addr, uint8_t val, void *priv) break; } break; + } + case 0x2d0: case 0x3d0: + case 0x2d4: case 0x3d4: - if (ega->chipset) - ega->crtcreg = val & 0x3f; - else - ega->crtcreg = val; + ega->crtcreg = ega->chipset ? (val & 0x3f) : val; return; + case 0x2d1: case 0x3d1: + case 0x2d5: case 0x3d5: { int idx = ega->crtcreg; if (ega->chipset) { - if ((ega->crtcreg < 7) && (ega->crtc[0x11] & 0x80) && !(ega->regs[0xb4] & 0x80)) + if ((idx < 7) && (ega->crtc[0x11] & 0x80) && !(ega->regs[0xb4] & 0x80)) return; - if ((ega->crtcreg == 7) && (ega->crtc[0x11] & 0x80) && !(ega->regs[0xb4] & 0x80)) + if ((idx == 7) && (ega->crtc[0x11] & 0x80) && !(ega->regs[0xb4] & 0x80)) val = (ega->crtc[7] & ~0x10) | (val & 0x10); } else { idx &= crtcmask; - if ((idx >= 0x19) & (idx <= 0xf6)) + if ((idx >= 0x19) && (idx <= 0xf6)) return; if ((idx < 7) && (ega->crtc[0x11] & 0x80)) return; if ((idx == 7) && (ega->crtc[0x11] & 0x80)) val = (ega->crtc[7] & ~0x10) | (val & 0x10); } - old = ega->crtc[idx]; + old = ega->crtc[idx]; ega->crtc[idx] = val; if (old != val) { if ((idx < 0xe) || (idx > 0x10)) { @@ -305,7 +323,9 @@ ega_out(uint16_t addr, uint8_t val, void *priv) } break; - } default: + } + + default: break; } } @@ -313,14 +333,14 @@ ega_out(uint16_t addr, uint8_t val, void *priv) uint8_t ega_in(uint16_t addr, void *priv) { - ega_t *ega = (ega_t *) priv; + ega_t *ega = (ega_t *) priv; uint8_t ret = 0xff; int type = ega_type; int atype = ega->actual_type; uint8_t gdcmask = (atype == EGA_SUPEREGA) ? 0xff : 0x0f; uint8_t crtcmask = (atype == EGA_SUPEREGA) ? 0xff : 0x1f; - if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(ega->miscout & 1)) + if (((((addr & 0xfff0) == 0x3d0) || ((addr & 0xfff0) == 0x2d0)) || (((addr & 0xfff0) == 0x3b0) || ((addr & 0xfff0) == 0x2b0))) && !(ega->miscout & 1)) addr ^= 0x60; switch (addr) { @@ -341,7 +361,9 @@ ega_in(uint16_t addr, void *priv) } break; + case 0x2c0: case 0x3c0: + case 0x2c1: case 0x3c1: if (type == EGA_TYPE_OTHER) { int data = (atype == EGA_SUPEREGA) ? (ega->attrff & 1) : (addr & 1); @@ -354,9 +376,11 @@ ega_in(uint16_t addr, void *priv) ret = (ret & 0x3f) | (ega->attrff ? 0x80 : 0x00); } break; + case 0x2c2: case 0x3c2: ret = (egaswitches & (8 >> egaswitchread)) ? 0x10 : 0x00; break; + case 0x2c4: case 0x3c4: if (type == EGA_TYPE_OTHER) { if (atype == EGA_SUPEREGA) @@ -365,28 +389,34 @@ ega_in(uint16_t addr, void *priv) ret = ega->seqaddr; } break; + case 0x2c5: case 0x3c5: if (type == EGA_TYPE_OTHER) { - if ((ega->seqaddr & 0x0f) > 0x04) - ret = ega->chipset ? ega->seqregs[ega->seqaddr & 0xf] : 0xff; + uint8_t idx = ega->seqaddr & 0xf; + if (idx > 0x04) + ret = ega->chipset ? ega->seqregs[idx] : 0xff; else - ret = ega->seqregs[ega->seqaddr & 0xf]; + ret = ega->seqregs[idx]; } break; + case 0x2c6: case 0x3c6: if (type == EGA_TYPE_COMPAQ) ret = ega->ctl_mode; break; + case 0x2c8: case 0x3c8: if (type == EGA_TYPE_OTHER) ret = 2; break; + case 0x2cc: case 0x3cc: if (type == EGA_TYPE_OTHER) ret = ega->miscout; break; + case 0x2ce: case 0x3ce: - if (ega_type == EGA_TYPE_OTHER) { + if (type == EGA_TYPE_OTHER) { ret = ega->gdcaddr; if (atype == EGA_SUPEREGA) { ret = (ret & 0x0f) | 0xe0; @@ -395,14 +425,16 @@ ega_in(uint16_t addr, void *priv) } } break; + case 0x2cf: case 0x3cf: if (type == EGA_TYPE_OTHER) { - switch (ega->gdcaddr & gdcmask) { + uint8_t gidx = ega->gdcaddr & gdcmask; + switch (gidx) { default: - ret = ega->gdcreg[ega->gdcaddr & gdcmask]; + ret = ega->gdcreg[gidx]; break; case 0x09 ... 0xf7: - ret = ega->chipset ? ega->gdcreg[ega->gdcaddr & gdcmask] : 0xff; + ret = ega->chipset ? ega->gdcreg[gidx] : 0xff; break; case 0xf8: ret = ega->la; @@ -419,9 +451,11 @@ ega_in(uint16_t addr, void *priv) } } break; + case 0x2d0: case 0x3d0: + case 0x2d4: case 0x3d4: - if (ega_type == EGA_TYPE_OTHER) { + if (type == EGA_TYPE_OTHER) { ret = ega->crtcreg; if (atype == EGA_SUPEREGA) { ret = (ret & 0x1f) | 0xc0; @@ -430,7 +464,9 @@ ega_in(uint16_t addr, void *priv) } } break; + case 0x2d1: case 0x3d1: + case 0x2d5: case 0x3d5: switch (ega->crtcreg & crtcmask) { case 0xc: @@ -465,6 +501,7 @@ ega_in(uint16_t addr, void *priv) break; } break; + case 0x2da: case 0x3da: ega->attrff = 0; if (type == EGA_TYPE_COMPAQ) { @@ -494,7 +531,7 @@ ega_in(uint16_t addr, void *priv) } break; case 0x7c6: - ret = 0xfd; /* EGA mode supported. */ + ret = 0xfd; /* EGA mode supported. */ break; case 0xbc6: /* 0000 = None; @@ -525,6 +562,7 @@ ega_recalctimings(ega_t *ega) double _dispofftime; double disptime; double crtcconst; + double mdiv = (ega->seqregs[1] & 1) ? 8.0 : 9.0; ega->vtotal = ega->crtc[6]; ega->dispend = ega->crtc[0x12]; @@ -578,10 +616,7 @@ ega_recalctimings(ega_t *ega) else crtcconst = (cpuclock / 16872000.0 * (double) (1ULL << 32)); } - if (!(ega->seqregs[1] & 1)) - crtcconst *= 9.0; - else - crtcconst *= 8.0; + crtcconst *= mdiv; } else if (ega->eeprom) { clksel = ((ega->miscout & 0xc) >> 2) | ((ega->regs[0xbe] & 0x10) ? 4 : 0); @@ -603,20 +638,14 @@ ega_recalctimings(ega_t *ega) crtcconst = (cpuclock / 36000000.0 * (double) (1ULL << 32)); break; } - if (!(ega->seqregs[1] & 1)) - crtcconst *= 9.0; - else - crtcconst *= 8.0; + crtcconst *= mdiv; } else { if (ega->vidclock) crtcconst = (ega->seqregs[1] & 1) ? MDACONST : (MDACONST * (9.0 / 8.0)); else crtcconst = (ega->seqregs[1] & 1) ? CGACONST : (CGACONST * (9.0 / 8.0)); } - if (!(ega->seqregs[1] & 1)) - ega->dot_clock = crtcconst / 9.0; - else - ega->dot_clock = crtcconst / 8.0; + ega->dot_clock = crtcconst / mdiv; ega->interlace = 0; @@ -629,17 +658,16 @@ ega_recalctimings(ega_t *ega) ega->hdisp *= (ega->seqregs[1] & 1) ? 16 : 18; else ega->hdisp *= (ega->seqregs[1] & 1) ? 8 : 9; - ega->render = ega_render_text; - ega->hdisp_old = ega->hdisp; + ega->render = ega_render_text; } else { ega->hdisp *= (ega->seqregs[1] & 8) ? 16 : 8; - ega->render = ega_render_graphics; - ega->hdisp_old = ega->hdisp; + ega->render = ega_render_graphics; } + ega->hdisp_old = ega->hdisp; } if (ega->chipset) { - if (ega->hdisp > 640) { + if (ega->hdisp >= 800) { ega->dispend <<= 1; ega->vtotal <<= 1; ega->split <<= 1; @@ -696,7 +724,7 @@ ega_recalctimings(ega_t *ega) timer_disable(&ega->dot_timer); timer_set_delay_u64(&ega->dot_timer, ega->dot_time); ega->cca = 0; - active = 1; + active = 1; ega->dot = 0; } @@ -708,30 +736,30 @@ ega_recalctimings(ega_t *ega) void ega_dot_poll(void *priv) { - ega_t *ega = (ega_t *) priv; - static uint8_t chr; - static uint8_t attr; - const bool doublewidth = ((ega->seqregs[1] & 8) != 0); - const bool attrblink = ((ega->attrregs[0x10] & 8) != 0); - const bool attrlinechars = (ega->attrregs[0x10] & 4); - const bool crtcreset = ((ega->crtc[0x17] & 0x80) == 0); - const bool seq9dot = ((ega->seqregs[1] & 1) == 0); - const bool blinked = ega->blink & 0x10; - const int dwshift = doublewidth ? 1 : 0; - const int dotwidth = 1 << dwshift; - const int charwidth = dotwidth * (seq9dot ? 9 : 8); - const int cursoron = (ega->sc == (ega->crtc[10] & 31)); - const int cursoraddr = (ega->crtc[0xe] << 8) | ega->crtc[0xf]; - uint32_t addr; - int drawcursor; - uint32_t charaddr; - static int fg = 0; - static int bg = 0; - static uint32_t dat = 0x00000000; - static int cclock = 0; - static int disptime; - static int _dispontime; - static int _dispofftime; + ega_t *ega = (ega_t *) priv; + static uint8_t chr; + static uint8_t attr; + const bool doublewidth = ((ega->seqregs[1] & 8) != 0); + const bool attrblink = ((ega->attrregs[0x10] & 8) != 0); + const bool attrlinechars = (ega->attrregs[0x10] & 4); + const bool crtcreset = ((ega->crtc[0x17] & 0x80) == 0); + const bool seq9dot = ((ega->seqregs[1] & 1) == 0); + const bool blinked = ega->blink & 0x10; + const int dwshift = doublewidth ? 1 : 0; + const int dotwidth = 1 << dwshift; + const int charwidth = dotwidth * (seq9dot ? 9 : 8); + const int cursoron = (ega->sc == (ega->crtc[10] & 31)); + const int cursoraddr = (ega->crtc[0xe] << 8) | ega->crtc[0xf]; + uint32_t addr; + int drawcursor; + uint32_t charaddr; + static int fg = 0; + static int bg = 0; + static uint32_t dat = 0x00000000; + static int cclock = 0; + static int disptime; + static int _dispontime; + static int _dispofftime; if (ega->seqregs[1] & 8) { disptime = ((ega->crtc[0] + 2) << 1); @@ -803,11 +831,9 @@ void ega_poll(void *priv) { ega_t *ega = (ega_t *) priv; - int x, y; int old_ma; int wx = 640; int wy = 350; - uint32_t blink_delay; if (!ega->linepos) { timer_advance_u64(&ega->timer, ega->dispofftime); @@ -826,7 +852,7 @@ ega_poll(void *priv) old_ma = ega->ma; ega->displine *= ega->vres + 1; ega->y_add *= ega->vres + 1; - for (y = 0; y <= ega->vres; y++) { + for (int y = 0; y <= ega->vres; y++) { /* Render scanline */ ega->render(ega); @@ -855,7 +881,7 @@ ega_poll(void *priv) ega->stat &= ~8; ega->vslines++; if (ega->chipset) { - if (ega->hdisp > 640) { + if (ega->hdisp >= 800) { if (ega->displine > 2000) ega->displine = 0; } else { @@ -906,7 +932,7 @@ ega_poll(void *priv) !(ega->real_vc & 1)) ega->vc++; if (ega->chipset) { - if (ega->hdisp > 640) + if (ega->hdisp >= 800) ega->vc &= 1023; else ega->vc &= 511; @@ -925,7 +951,7 @@ ega_poll(void *priv) } if (ega->vc == ega->dispend) { ega->dispon = 0; - blink_delay = (ega->crtc[11] & 0x60) >> 5; + uint32_t blink_delay = (ega->crtc[11] & 0x60) >> 5; if (ega->crtc[10] & 0x20) ega->cursoron = 0; else if (blink_delay == 2) @@ -946,14 +972,14 @@ ega_poll(void *priv) #if 0 picint(1 << 2); #endif - x = ega->hdisp; +// x = ega->hdisp; if (ega->interlace && !ega->oddeven) ega->lastline++; if (ega->interlace && ega->oddeven) ega->firstline--; - wx = x; + wx = ega->hdisp; if (ega->vres) { wy = (ega->lastline - ega->firstline) << 1; @@ -1024,9 +1050,6 @@ ega_doblit(int wx, int wy, ega_t *ega) int y_start = enable_overscan ? 0 : (unscaled_overscan_y >> 1); int x_start = enable_overscan ? 0 : (overscan_x >> 1); int bottom = (unscaled_overscan_y >> 1); - uint32_t *p; - int i; - int j; int xs_temp; int ys_temp; @@ -1073,17 +1096,17 @@ ega_doblit(int wx, int wy, ega_t *ega) if ((wx >= 160) && ((wy + 1) >= 120)) { /* Draw (overscan_size - scroll size) lines of overscan on top and bottom. */ - for (i = 0; i < ega->y_add; i++) { - p = &buffer32->line[i & 0x7ff][0]; + for (int i = 0; i < ega->y_add; i++) { + uint32_t *p = &buffer32->line[i & 0x7ff][0]; - for (j = 0; j < (xsize + x_add); j++) + for (int j = 0; j < (xsize + x_add); j++) p[j] = ega->overscan_color; } - for (i = 0; i < bottom; i++) { - p = &buffer32->line[(ysize + ega->y_add + i) & 0x7ff][0]; + for (int i = 0; i < bottom; i++) { + uint32_t *p = &buffer32->line[(ysize + ega->y_add + i) & 0x7ff][0]; - for (j = 0; j < (xsize + x_add); j++) + for (int j = 0; j < (xsize + x_add); j++) p[j] = ega->overscan_color; } } @@ -1107,12 +1130,11 @@ ega_remap_cpu_addr(uint32_t inaddr, ega_t *ega) // bit 2: 1 = 128K mapping, 0 = other mapping (from memory decode PROM) a0mux = 0; - if (ega->gdcreg[6] & 2) { + if (ega->gdcreg[6] & 2) a0mux |= 2; - } - if (ega->vram_limit <= 64 * 1024) { + + if (ega->vram_limit <= 64 * 1024) a0mux |= 1; - } switch (ega->gdcreg[6] & 0xC) { case 0x0: // 128K A000 @@ -1179,9 +1201,8 @@ ega_write(uint32_t addr, uint8_t val, void *priv) cycles -= video_timing_write_b; - if (ega->chain2_write) { + if (ega->chain2_write) writemask2 &= 0x5 << (addr & 1); - } addr = ega_remap_cpu_addr(addr, ega); @@ -1361,9 +1382,8 @@ ega_read(uint32_t addr, void *priv) cycles -= video_timing_read_b; - if (ega->chain2_read) { + if (ega->chain2_read) readplane = (readplane & 2) | (addr & 1); - } addr = ega_remap_cpu_addr(addr, ega); @@ -1401,23 +1421,19 @@ ega_read(uint32_t addr, void *priv) void ega_init(ega_t *ega, int monitor_type, int is_mono) { - int c; - int d; - int e; - ega->vram = malloc(0x40000); ega->vrammask = 0x3ffff; - for (c = 0; c < 256; c++) { - e = c; - for (d = 0; d < 8; d++) { + for (uint16_t c = 0; c < 256; c++) { + int e = c; + for (uint8_t d = 0; d < 8; d++) { ega_rotate[d][c] = e; e = (e >> 1) | ((e & 1) ? 0x80 : 0); } } if (is_mono) { - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { if (((c >> 3) & 3) == 0) pallook64[c] = pallook16[c] = makecol32(0, 0, 0); else @@ -1474,9 +1490,14 @@ ega_init(ega_t *ega, int monitor_type, int is_mono) } } - io_sethandler(0x03a0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); + uint16_t base_addr = 0x03a0; +#ifdef EGA_ALT_ADDR_SUPPORT + if (ega->alt_addr == 1) + base_addr = 0x02a0; +#endif + io_sethandler(base_addr, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); } else { - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { pallook64[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); pallook64[c] += makecol32(((c >> 5) & 1) * 0x55, ((c >> 4) & 1) * 0x55, ((c >> 3) & 1) * 0x55); pallook16[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); @@ -1562,11 +1583,9 @@ ega_set_type(void *priv, uint32_t local) static void * ega_standalone_init(const device_t *info) { - ega_t *ega = malloc(sizeof(ega_t)); + ega_t *ega = calloc(1, sizeof(ega_t)); int monitor_type; - memset(ega, 0x00, sizeof(ega_t)); - video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_ega); overscan_x = 16; @@ -1622,7 +1641,7 @@ ega_standalone_init(const device_t *info) } } - monitor_type = device_get_config_int("monitor_type"); + monitor_type = ega->chipset ? 0x09 : device_get_config_int("monitor_type"); ega_init(ega, monitor_type, (monitor_type & 0x0F) == 0x0B); ega->vram_limit = device_get_config_int("memory") * 1024; @@ -1631,12 +1650,19 @@ ega_standalone_init(const device_t *info) mem_mapping_add(&ega->mapping, 0xa0000, 0x20000, ega_read, NULL, NULL, ega_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, ega); if (ega_type == EGA_TYPE_COMPAQ) mem_mapping_disable(&ega->mapping); - io_sethandler(0x03c0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); + uint16_t addr = 0x03c0; +#ifdef EGA_ALT_ADDR_SUPPORT + if (ega_type == EGA_TYPE_IBM) { + addr = device_get_config_hex16("base"); + if (addr == 0x02c0) + ega->alt_addr = 1; + } +#endif + io_sethandler(addr, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); if (ega->chipset) { io_sethandler(0x01ce, 0x0002, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); - ega->eeprom = malloc(sizeof(ati_eeprom_t)); - memset(ega->eeprom, 0, sizeof(ati_eeprom_t)); + ega->eeprom = calloc(1, sizeof(ati_eeprom_t)); ati_eeprom_load((ati_eeprom_t *) ega->eeprom, "egawonder800p.nvr", 0); } else if (info->local == EGA_COMPAQ) { io_sethandler(0x0084, 0x0001, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); @@ -1712,6 +1738,66 @@ ega_speed_changed(void *priv) 0 = Switch closed (ON); 1 = Switch open (OFF). */ +static const device_config_t ega_ibm_config[] = { + // clang-format off + { + .name = "memory", + .description = "Memory size", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 256, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "32 KB", .value = 32 }, + { .description = "64 KB", .value = 64 }, + { .description = "128 KB", .value = 128 }, + { .description = "256 KB", .value = 256 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "monitor_type", + .description = "Monitor type", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 9, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "Monochrome (5151/MDA) (white)", .value = 0x0B | (DISPLAY_WHITE << 4) }, + { .description = "Monochrome (5151/MDA) (green)", .value = 0x0B | (DISPLAY_GREEN << 4) }, + { .description = "Monochrome (5151/MDA) (amber)", .value = 0x0B | (DISPLAY_AMBER << 4) }, + { .description = "Color 40x25 (5153/CGA)", .value = 0x06 }, + { .description = "Color 80x25 (5153/CGA)", .value = 0x07 }, + { .description = "Enhanced Color - Normal Mode (5154/ECD)", .value = 0x08 }, + { .description = "Enhanced Color - Enhanced Mode (5154/ECD)", .value = 0x09 }, + { .description = "" } + }, + .bios = { { 0 } } + }, +#ifdef EGA_ALT_ADDR_SUPPORT + { + .name = "base", + .description = "Address", + .type = CONFIG_HEX16, + .default_string = NULL, + .default_int = 0x03c0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "0x3C0", .value = 0x03c0 }, + { .description = "0x2C0", .value = 0x02c0 }, + { .description = "" } + }, + .bios = { { 0 } } + }, +#endif + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + static const device_config_t ega_config[] = { // clang-format off { @@ -1755,6 +1841,29 @@ static const device_config_t ega_config[] = { // clang-format on }; +static const device_config_t atiega800p_config[] = { + // clang-format off + { + .name = "memory", + .description = "Memory size", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 256, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "32 KB", .value = 32 }, + { .description = "64 KB", .value = 64 }, + { .description = "128 KB", .value = 128 }, + { .description = "256 KB", .value = 256 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + const device_t ega_device = { .name = "IBM EGA", .internal_name = "ega", @@ -1766,7 +1875,7 @@ const device_t ega_device = { .available = ega_standalone_available, .speed_changed = ega_speed_changed, .force_redraw = NULL, - .config = ega_config + .config = ega_ibm_config }; const device_t cpqega_device = { @@ -1808,7 +1917,7 @@ const device_t atiega800p_device = { .available = atiega800p_standalone_available, .speed_changed = ega_speed_changed, .force_redraw = NULL, - .config = ega_config + .config = atiega800p_config }; const device_t iskra_ega_device = { diff --git a/src/video/vid_ps55da2.c b/src/video/vid_ps55da2.c index 9a95e6ce6..567d60347 100644 --- a/src/video/vid_ps55da2.c +++ b/src/video/vid_ps55da2.c @@ -310,16 +310,16 @@ typedef struct da2_t { uint8_t fctl[32]; uint16_t crtc[32]; uint16_t crtc_vpreg[128]; - uint8_t crtc_vpsel; + uint8_t crtc_vpsel; uint8_t gdcreg[64]; uint8_t reg3ee[16]; int gdcaddr; uint8_t attrc[0x40]; int attraddr, attrff; int attr_palette_enable; - int outflipflop; - int inflipflop; - int iolatch; + int outflipflop; + int inflipflop; + int iolatch; int ioctladdr; int fctladdr; @@ -385,8 +385,7 @@ typedef struct da2_t { card should not attempt to display anything */ int override; - struct - { + struct { int enable; mem_mapping_t mapping; uint8_t ram[DA2_SIZE_GAIJIRAM]; @@ -435,9 +434,9 @@ typedef struct da2_t { uint32_t mmrdbg_vidaddr; #endif - uint8_t pos_regs[8]; - svga_t *mb_vga; - uint8_t monitorid; + uint8_t pos_regs[8]; + svga_t *mb_vga; + uint8_t monitorid; pc_timer_t timer_vidupd; int old_pos2; @@ -520,7 +519,7 @@ da2_WritePlaneDataWithBitmask(uint32_t destaddr, const uint16_t mask, pixel32 *s da2->changedvram[(DA2_MASK_VRAMPLANE & destaddr) >> 9] = changeframecount; destaddr <<= 3; /* read destination data with big endian order */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) writepx[i] = da2_vram_r((destaddr + 24) | i, da2) | (da2_vram_r((destaddr + 16) | i, da2) << 8) | (da2_vram_r((destaddr + 8) | i, da2) << 16) @@ -532,7 +531,7 @@ da2_WritePlaneDataWithBitmask(uint32_t destaddr, const uint16_t mask, pixel32 *s mask32.b[3] = mask32in.b[0]; mask32.b[2] = mask32in.b[1]; mask32.d &= 0xffff0000; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (da2->bitblt.bitshift_destr > 0) srcpx->p8[i] <<= 16 - da2->bitblt.bitshift_destr; // #ifdef ENABLE_DA2_DEBUGBLT @@ -560,7 +559,7 @@ da2_WritePlaneDataWithBitmask(uint32_t destaddr, const uint16_t mask, pixel32 *s break; } } - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { da2_vram_w(destaddr | i, (writepx[i] >> 24) & 0xff, da2); da2_vram_w((destaddr + 8) | i, (writepx[i] >> 16) & 0xff, da2); } @@ -571,7 +570,7 @@ da2_DrawColorWithBitmask(uint32_t destaddr, uint8_t color, uint16_t mask, da2_t { pixel32 srcpx; /* fill data with input color */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) srcpx.p8[i] = (color & (1 << i)) ? 0xffffffff : 0; /* read in word */ da2_WritePlaneDataWithBitmask(destaddr, mask, &srcpx, da2); @@ -582,7 +581,7 @@ da2_CopyPlaneDataWithBitmask(uint32_t srcaddr, uint32_t destaddr, uint16_t mask, pixel32 srcpx; srcaddr &= 0xfffffffe; srcaddr <<= 3; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) srcpx.p8[i] = da2_vram_r((srcaddr + 24) | i, da2) | (da2_vram_r((srcaddr + 16) | i, da2) << 8) | (da2_vram_r((srcaddr + 8) | i, da2) << 16) @@ -592,9 +591,9 @@ da2_CopyPlaneDataWithBitmask(uint32_t srcaddr, uint32_t destaddr, uint16_t mask, } /* get font data for bitblt operation */ static uint32_t -getRAMFont(int32_t code, int line, int x, void *p) +getRAMFont(int32_t code, int line, int x, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t font = 0; #ifdef RESERVED_FOR_FUTURE_USE int fline = line - 2; /* Start line of drawing character (line >= 1 AND line < 24 + 1 ) */ @@ -617,8 +616,7 @@ getRAMFont(int32_t code, int line, int x, void *p) font |= da2->mmio.ram[code + 2]; font <<= 8; font |= da2->mmio.ram[code + 3]; - } - else + } else font = 0; return font; } @@ -641,12 +639,12 @@ da2_PutcharWithBitmask(uint32_t codeIBMJ, int width, uint16_t attr, int line, ui uint32_t fontinv; if (width <= 2) { fontinv = ~font; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font >> 16 : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv >> 16 : 0; } da2_WritePlaneDataWithBitmask(destaddr, maskl, &srcpx, da2); - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv : 0; } @@ -654,12 +652,12 @@ da2_PutcharWithBitmask(uint32_t codeIBMJ, int width, uint16_t attr, int line, ui } else { font = (font & 0xfff80000) | ((font & 0x0000ffff) << 3); fontinv = ~font; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font >> 16 : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv >> 16 : 0; } da2_WritePlaneDataWithBitmask(destaddr, maskl, &srcpx, da2); - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv : 0; } @@ -667,7 +665,7 @@ da2_PutcharWithBitmask(uint32_t codeIBMJ, int width, uint16_t attr, int line, ui da2_WritePlaneDataWithBitmask(destaddr + 2, maskr, &srcpx, da2); } else { da2_WritePlaneDataWithBitmask(destaddr + 2, 0xffff, &srcpx, da2); - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font << 16 : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv << 16 : 0; } @@ -680,8 +678,8 @@ static uint8_t pixel1tohex(uint32_t addr, int index, da2_t *da2) { uint8_t pixeldata = 0; - for (int j = 0; j < 8; j++) { - if (da2_vram_r(((addr << 3) | j) & (1 << (7 - index)), da2)) + for (uint8_t i = 0; i < 8; j++) { + if (da2_vram_r(((addr << 3) | i) & (1 << (7 - index)), da2)) pixeldata++; } return pixeldata; @@ -689,14 +687,14 @@ pixel1tohex(uint32_t addr, int index, da2_t *da2) static void print_pixelbyte(uint32_t addr, da2_t *da2) { - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { pclog("%X", pixel1tohex(addr, i, da2)); } } static void print_bytetobin(uint8_t b) { - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (b & 0x80) pclog("1"); else @@ -723,13 +721,13 @@ IBMJtoSJIS(uint16_t knj) knj -= 0x100; if (knj <= 0x1f7d) ; /* do nothing */ - else if (knj >= 0xb700 && knj <= 0xb75f) { + else if (knj >= 0xb700 && knj <= 0xb75f) knj -= 0x90ec; - } else if (knj >= 0xb3f0 && knj <= 0xb67f) { + else if (knj >= 0xb3f0 && knj <= 0xb67f) knj -= 0x906c; - } else if (knj >= 0x8000 && knj <= 0x8183) { + else if (knj >= 0x8000 && knj <= 0x8183) knj -= 0x5524; - } else + else return 0xffff; uint32_t knj1 = knj / 0xBC; uint32_t knj2 = knj - (knj1 * 0xBC); @@ -850,8 +848,7 @@ da2_bitblt_load(da2_t *da2) DOS/V Extension 1040x725 some DBCS uses 0xB0 others 0x90 */ da2->bitblt.destoption = da2->bitblt.reg[0x2F]; - if (da2->bitblt.destoption & 0x10) /* destaddr -= 2, length += 1; */ - { + if (da2->bitblt.destoption & 0x10) { /* destaddr -= 2, length += 1; */ da2->bitblt.destaddr -= 2; da2->bitblt.size_x += 1; da2->bitblt.destpitch -= 2; @@ -892,9 +889,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); #endif - } + /* Draw a line */ - else if (da2->bitblt.reg[0x5] == 0x43) { + } else if (da2->bitblt.reg[0x5] == 0x43) { da2->bitblt.exec = DA2_BLT_CLINE; da2->bitblt.dest_x = (da2->bitblt.reg[0x32] & 0xffff); da2->bitblt.dest_y = (da2->bitblt.reg[0x34] & 0xffff); @@ -922,17 +919,17 @@ da2_bitblt_load(da2_t *da2) da2_log(" ux1=%d,ux2=%d,uy1=%d,uy2=%d\n", (da2->bitblt.reg[0x32] >> 16) & 0x7ff, (da2->bitblt.reg[0x33] >> 16) & 0x7ff, (da2->bitblt.reg[0x34] >> 16) & 0x7ff, (da2->bitblt.reg[0x35] >> 16) & 0x7ff); - } + /* Fill a rectangle (or draw a horizontal / vertical line) */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x40 && da2->bitblt.reg[0x3D] == 0) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x40 && da2->bitblt.reg[0x3D] == 0) { da2_log("fillrect x=%d, y=%d, w=%d, h=%d, c=%d, 2f=%x, rowcount=%x\n", da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y, da2->bitblt.reg[0x0], da2->bitblt.reg[0x2F], da2->rowoffset * 2); da2->bitblt.exec = DA2_BLT_CFILLRECT; da2->bitblt.destaddr += 2; - } + /* Tiling a rectangle ??(transfer tile data multiple times) os/2 only */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x0040 && da2->bitblt.reg[0x3D] == 0x40) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x0040 && da2->bitblt.reg[0x3D] == 0x40) { da2->bitblt.exec = DA2_BLT_CFILLTILE; da2->bitblt.destaddr += 2; da2->bitblt.srcaddr = da2->bitblt.reg[0x2B]; @@ -942,9 +939,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x2B] % (da2->rowoffset * 2), da2->bitblt.reg[0x2B] / (da2->rowoffset * 2), da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); - } + /* Tiling a rectangle (transfer tile data multiple times) */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x40) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x40) { da2->bitblt.exec = DA2_BLT_CFILLTILE; da2->bitblt.destaddr += 2; da2->bitblt.srcaddr = da2->bitblt.reg[0x2B]; @@ -954,9 +951,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x2B] % (da2->rowoffset * 2), da2->bitblt.reg[0x2B] / (da2->rowoffset * 2), da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); - } + /* Block copy */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x00) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x00) { da2->bitblt.exec = DA2_BLT_CCOPYF; da2->bitblt.srcaddr = da2->bitblt.reg[0x2A]; da2->bitblt.destaddr += 2; @@ -965,9 +962,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x2A] % (da2->rowoffset * 2), da2->bitblt.reg[0x2A] / (da2->rowoffset * 2), da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); - } + /* Block copy but reversed direction */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1140 && da2->bitblt.reg[0x3D] == 0x00) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1140 && da2->bitblt.reg[0x3D] == 0x00) { da2->bitblt.exec = DA2_BLT_CCOPYR; da2->bitblt.srcaddr = da2->bitblt.reg[0x2A]; da2->bitblt.destaddr -= 2; @@ -980,9 +977,9 @@ da2_bitblt_load(da2_t *da2) } } static void -da2_bitblt_exec(void *p) +da2_bitblt_exec(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // timer_set_delay_u64(&da2->bitblt.timer, da2->bitblt.timerspeed); #ifdef ENABLE_DA2_DEBUGBLT_DETAIL if (!(da2->bitblt.debug_exesteps & 0xff)) @@ -1180,9 +1177,9 @@ da2_bitblt_dopayload(void *priv) } } static void -da2_bitblt_addpayload(uint8_t val, void *p) +da2_bitblt_addpayload(uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->bitblt.indata = 1; if (da2->bitblt.payload_addr >= DA2_BLT_MEMSIZE) da2_log("da2_mmio_write payload overflow! addr %x, val %x\n", da2->bitblt.payload_addr, val); @@ -1222,9 +1219,9 @@ da2_bitblt_addpayload(uint8_t val, void *p) } static void -da2_out(uint16_t addr, uint16_t val, void *p) +da2_out(uint16_t addr, uint16_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; int oldval; /* 3E0 3E1 Sequencer Registers (undoc) @@ -1403,7 +1400,7 @@ da2_out(uint16_t addr, uint16_t val, void *p) if (da2->attraddr < 16) da2->fullchange = changeframecount; if (da2->attraddr == LV_MODE_CONTROL || da2->attraddr < 0x10) { - for (int c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { // if (da2->attrc[LV_MODE_CONTROL] & 0x80) da2->egapal[c] = (da2->attrc[c] & 0xf) | ((da2->attrc[0x14] & 0xf) << 4); // else da2->egapal[c] = (da2->attrc[c] & 0x3f) | ((da2->attrc[0x14] & 0xc) << 4); if (da2->attrc[LV_MODE_CONTROL] & 0x80) @@ -1486,9 +1483,9 @@ da2_out(uint16_t addr, uint16_t val, void *p) } static uint16_t -da2_in(uint16_t addr, void *p) +da2_in(uint16_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint16_t temp = 0xff; switch (addr) { @@ -1620,9 +1617,9 @@ da2_in(uint16_t addr, void *p) * out b(idx), in w(data) */ static void -da2_outb(uint16_t addr, uint8_t val, void *p) +da2_outb(uint16_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2_iolog("DA2 Outb addr %03X val %02X %04X:%04X es:di=%x:%x ds:si=%x:%x\n", addr, val, cs >> 4, cpu_state.pc, ES, DI, DS, SI); da2->inflipflop = 0; switch (addr) { @@ -1651,10 +1648,10 @@ da2_outb(uint16_t addr, uint8_t val, void *p) da2_out(addr, da2->iolatch, da2); } void -da2_outw(uint16_t addr, uint16_t val, void *p) +da2_outw(uint16_t addr, uint16_t val, void *priv) { da2_iolog("DA2 Outw addr %03X val %04X\n", addr, val); - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->inflipflop = 0; switch (addr) { case LS_INDEX: @@ -1703,10 +1700,10 @@ da2_outw(uint16_t addr, uint16_t val, void *p) } } static uint8_t -da2_inb(uint16_t addr, void *p) +da2_inb(uint16_t addr, void *priv) { uint8_t temp; - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->outflipflop = 0; switch (addr) { case LC_DATA: @@ -1736,10 +1733,10 @@ da2_inb(uint16_t addr, void *p) return temp; } static uint16_t -da2_inw(uint16_t addr, void *p) +da2_inw(uint16_t addr, void *priv) { uint16_t temp; - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->inflipflop = 0; da2->outflipflop = 0; temp = da2_in(addr, da2); @@ -1748,9 +1745,9 @@ da2_inw(uint16_t addr, void *p) } /* IO 03DAh : Input Status Register 2 for DOSSHELL used by DOS J4.0 */ static uint8_t -da2_in_ISR(uint16_t addr, void *p) +da2_in_ISR(uint16_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint8_t temp = 0; if (addr == 0x3da) { if (da2->cgastat & 0x01) @@ -1764,9 +1761,9 @@ da2_in_ISR(uint16_t addr, void *p) } static void -da2_out_ISR(uint16_t addr, uint8_t val, void *p) +da2_out_ISR(uint16_t addr, uint8_t val, void *priv) { - // da2_t* da2 = (da2_t*)p; + // da2_t* da2 = (da2_t*) priv; da2_iolog("DA2D Out %04X %04X %04X:%04X\n", addr, val, cs >> 4, cpu_state.pc); } @@ -1872,9 +1869,9 @@ The Font ROM can be accessed via 128 KB memory window located at A0000-BFFFFh. /* Get character line pattern from jfont rom or gaiji volatile memory */ static uint32_t -getfont_ps55dbcs(int32_t code, int32_t line, void *p) +getfont_ps55dbcs(int32_t code, int32_t line, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t font = 0; int32_t fline = line - 2; /* Start line of drawing character (line >= 1 AND line < 24 + 1 ) */ if (code >= 0x8000 && code <= 0x8183) @@ -2424,7 +2421,7 @@ da2_mapping_update(da2_t *da2) // da2_recalc_mapping(da2); if (da2->pos_regs[2] & 0x01) { da2_log("DA2 enable registers\n"); - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2_log("DA2 POS[%d]: %x\n", i, da2->pos_regs[i]); io_sethandler(0x03c0, 0x000a, da2_inb, da2_inw, NULL, da2_outb, da2_outw, NULL, da2); io_sethandler(0x03e0, 0x0010, da2_inb, da2_inw, NULL, da2_outb, da2_outw, NULL, da2); @@ -2444,16 +2441,16 @@ da2_mapping_update(da2_t *da2) } static uint8_t -da2_mca_read(int port, void *p) +da2_mca_read(int port, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; return da2->pos_regs[port & 7]; } static void -da2_mca_write(int port, uint8_t val, void *p) +da2_mca_write(int port, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2_log("da2_mca_write: port=%04x val=%02x\n", port, val); @@ -2473,9 +2470,9 @@ da2_mca_feedb(void *priv) } static void -da2_mca_reset(void *p) +da2_mca_reset(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2_log("da2_mca_reset called.\n"); da2_reset(da2); da2_mca_write(0x102, 0, da2); @@ -2485,7 +2482,7 @@ da2_mca_reset(void *p) static void da2_gdcropB(uint32_t addr,uint8_t bitmask, da2_t *da2) { - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (da2->planemask & (1 << i)) { // da2_log("da2_gdcropB o%x a%x d%x p%d m%x\n", da2->gdcreg[LG_COMMAND] & 0x03, addr, da2->gdcinput[i], i, bitmask); switch (da2->gdcreg[LG_COMMAND] & 0x03) { @@ -2518,7 +2515,7 @@ da2_gdcropW(uint32_t addr, uint16_t bitmask, da2_t *da2) // if((addr & 8)) bitmask = da2_rightrotate(bitmask, 8); uint8_t bitmask_l = bitmask & 0xff; uint8_t bitmask_h = bitmask >> 8; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (da2->planemask & (1 << i)) { // da2_log("da2_gdcropW m%x a%x d%x i%d ml%x mh%x\n", da2->gdcreg[LG_COMMAND] & 0x03, addr, da2->gdcinput[i], i, da2->gdcreg[LG_BIT_MASK_LOW], da2->gdcreg[LG_BIT_MASK_HIGH]); switch (da2->gdcreg[LG_COMMAND] & 0x03) { @@ -2556,9 +2553,9 @@ da2_gdcropW(uint32_t addr, uint16_t bitmask, da2_t *da2) } static uint8_t -da2_mmio_read(uint32_t addr, void *p) +da2_mmio_read(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t index = 0; addr &= DA2_MASK_MMIO; if (da2->ioctl[LS_MMIO] & 0x10) { @@ -2604,14 +2601,14 @@ da2_mmio_read(uint32_t addr, void *p) } } else if (!(da2->ioctl[LS_MODE] & 1)) { /* 16 or 256 color mode */ cycles -= video_timing_read_b; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcla[i] = da2->vram[(addr << 3) | i]; /* read in byte */ #ifdef ENABLE_DA2_DEBUGVRAM da2_log("da2_Rb: %05x=%02x\n", addr, da2->gdcla[da2->readplane]); #endif if (da2->gdcreg[LG_MODE] & 0x08) { /* compare data across planes if the read mode bit (3EB 05, bit 3) is 1 */ uint8_t ret = 0; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (~da2->gdcreg[LG_COLOR_DONT_CARE] & (1 << i)) /* color don't care register */ ret |= da2->gdcla[i] ^ ((da2->gdcreg[LG_COLOR_COMPAREJ] & (1 << i)) ? 0xff : 0); } @@ -2624,9 +2621,9 @@ da2_mmio_read(uint32_t addr, void *p) } } static uint16_t -da2_mmio_readw(uint32_t addr, void *p) +da2_mmio_readw(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // da2_log("da2_readW: %x %x %x %x %x\n", da2->ioctl[LS_MMIO], da2->fctl[LF_MMIO_SEL], da2->fctl[LF_MMIO_MODE], da2->fctl[LF_MMIO_ADDR], addr); // da2_log("da2_readW: %x %x %x %x %x CS:PC=%4x:%4x\n", da2->ioctl[LS_MMIO], da2->fctl[LF_MMIO_SEL], da2->fctl[LF_MMIO_MODE], da2->fctl[LF_MMIO_ADDR], addr, CS, cpu_state.pc); @@ -2635,7 +2632,7 @@ da2_mmio_readw(uint32_t addr, void *p) } else if (!(da2->ioctl[LS_MODE] & 1)) {/* 16 color or 256 color mode */ cycles -= video_timing_read_w; addr &= DA2_MASK_MMIO; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcla[i] = (uint16_t) (da2->vram[(addr << 3) | i]) | ((uint16_t) (da2->vram[((addr << 3) + 8) | i]) << 8); /* read vram into latch */ #ifdef ENABLE_DA2_DEBUGVRAM @@ -2643,10 +2640,10 @@ da2_mmio_readw(uint32_t addr, void *p) // if (((int)addr - (int)da2->mmrdbg_vidaddr) > 2 || (((int)da2->mmrdbg_vidaddr - (int)addr) > 2) || da2->mmrdbg_vidaddr == addr) //{ // fprintf(da2->mmrdbg_fp, "\nR %x ", addr); - // for (int i = 0; i <= 0xb; i++) + // for (uint8_t i = 0; i <= 0xb; i++) // fprintf(da2->mmrdbg_fp, "%02x ", da2->gdcreg[i]); // } - // for (int i = 0; i < 16; i++) + // for (uint8_t i = 0; i < 16; i++) //{ // int pixeldata = 0; // if (da2->gdcla[da2->readplane] & (1 << (15 - i))) pixeldata = 1; @@ -2658,7 +2655,7 @@ da2_mmio_readw(uint32_t addr, void *p) if (da2->gdcreg[LG_MODE] & 0x08) { /* compare data across planes if the read mode bit (3EB 05, bit 3) is 1 */ uint16_t ret = 0; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (~da2->gdcreg[LG_COLOR_DONT_CARE] & (1 << i)) /* color don't care register */ ret |= da2->gdcla[i] ^ ((da2->gdcreg[LG_COLOR_COMPAREJ] & (1 << i)) ? 0xffff : 0); } @@ -2674,9 +2671,9 @@ da2_mmio_readw(uint32_t addr, void *p) } } static void -da2_mmio_write(uint32_t addr, uint8_t val, void *p) +da2_mmio_write(uint32_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t index = 0; // da2_log("da2_mmio_write %x %x\n", addr, val); // if ((addr & ~DA2_MASK_MMIO) != 0xA0000) @@ -2735,10 +2732,10 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) //{ if (((int) addr - (int) da2->mmdbg_vidaddr) > 2 || (((int) da2->mmdbg_vidaddr - (int) addr) > 2) || da2->mmdbg_vidaddr == addr) { fprintf(da2->mmdbg_fp, "\nB %x %02x ", addr, val); - for (int i = 0; i <= 0xb; i++) + for (uint8_t i = 0; i <= 0xb; i++) fprintf(da2->mmdbg_fp, "%02x ", da2->gdcreg[i]); } - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { int pixeldata = 0; if (val & (1 << (7 - i))) pixeldata = (da2->planemask & 0xf); @@ -2751,14 +2748,14 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) da2->changedvram[addr >> 9] = changeframecount;/* 0x1FFFF -> 0x1F */ addr <<= 3; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcsrc[i] = da2->gdcla[i]; /* use latch */ // da2_log("da2_Wb m%02x r%02x %05x:%02x %x:%x\n", da2->gdcreg[0x5], da2->gdcreg[LG_COMMAND], addr >> 3, val, cs >> 4, cpu_state.pc); // da2_log("da2_Wb m%02x r%02x %05x:%02x=%02x%02x%02x%02x->", da2->gdcreg[0x5], da2->gdcreg[LG_COMMAND], addr >> 3, val, da2->vram[addr + 0], da2->vram[addr + 1], da2->vram[addr + 2], da2->vram[addr + 3]); if (!(da2->gdcreg[LG_COMMAND] & 0x08)) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xff : 0; else if (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) @@ -2771,7 +2768,7 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) switch (da2->writemode) { case 2: /* equiv to vga write mode 1 */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) da2_vram_w(addr | i, da2->gdcsrc[i], da2); break; @@ -2779,11 +2776,11 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) if (da2->gdcreg[LG_DATA_ROTATION] & 7) val = svga_rotate[da2->gdcreg[LG_DATA_ROTATION] & 7][val]; if (bitmask == 0xff && !(da2->gdcreg[LG_COMMAND] & 0x03) && (!da2->gdcreg[LG_ENABLE_SRJ])) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) da2_vram_w(addr | i, val, da2); } else { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xff : 0; else @@ -2792,7 +2789,7 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) } break; case 1:/* equiv to vga write mode 2 */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = ((val & (1 << i)) ? 0xff : 0); da2_gdcropB(addr, bitmask, da2); break; @@ -2801,7 +2798,7 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) val = svga_rotate[da2->gdcreg[LG_DATA_ROTATION] & 7][val]; bitmask &= val; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xff : 0; da2_gdcropB(addr, bitmask, da2); break; @@ -2818,9 +2815,9 @@ da2_rightrotate(uint16_t data, uint8_t count) return (data >> count) | (data << (sizeof(data) * 8 - count)); } static void -da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) +da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint16_t bitmask; addr &= DA2_MASK_MMIO; bitmask = da2->gdcreg[LG_BIT_MASK_HIGH]; @@ -2832,10 +2829,10 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) if (((int) addr - (int) da2->mmdbg_vidaddr) > 2 || (((int) da2->mmdbg_vidaddr - (int) addr) > 2) || da2->mmdbg_vidaddr == addr) { fprintf(da2->mmdbg_fp, "\nW %x %x ", addr, val); - for (int i = 0; i <= 0xb; i++) + for (uint8_t i = 0; i <= 0xb; i++) fprintf(da2->mmdbg_fp, "%02x ", da2->gdcreg[i]); } - for (int i = 0; i < 16; i++) { + for (uint8_t i = 0; i < 16; i++) { int pixeldata = 0; if (val & (1 << (15 - i))) pixeldata = (da2->planemask & 0xf); @@ -2851,11 +2848,11 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) da2->changedvram[addr >> 9] = changeframecount; addr <<= 3; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcsrc[i] = da2->gdcla[i]; /* use latch */ if (!(da2->gdcreg[LG_COMMAND] & 0x08)) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xffff : 0; else if (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) @@ -2869,7 +2866,7 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) // , da2->vram[addr + 8], da2->vram[addr + 9], da2->vram[addr + 10], da2->vram[addr + 11]); switch (da2->writemode) { case 2: - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) { da2_vram_w(addr | i, da2->gdcsrc[i] & 0xff, da2); da2_vram_w((addr + 8) | i, da2->gdcsrc[i] >> 8, da2); @@ -2879,13 +2876,13 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) if (da2->gdcreg[LG_DATA_ROTATION] & 15) val = da2_rightrotate(val, da2->gdcreg[LG_DATA_ROTATION] & 15); if (bitmask == 0xffff && !(da2->gdcreg[LG_COMMAND] & 0x03) && (!da2->gdcreg[LG_ENABLE_SRJ])) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) { da2_vram_w(addr | i, val & 0xff, da2); da2_vram_w((addr + 8) | i, val >> 8, da2); } } else { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xffff : 0; else @@ -2895,7 +2892,7 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) } break; case 1: - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = ((val & (1 << i)) ? 0xffff : 0); da2_gdcropW(addr, bitmask, da2); break; @@ -2904,7 +2901,7 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) val = da2_rightrotate(val, da2->gdcreg[LG_DATA_ROTATION] & 15); bitmask &= val; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xffff : 0; da2_gdcropW(addr, bitmask, da2); break; @@ -2913,9 +2910,9 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) // , da2->vram[addr + 8], da2->vram[addr + 9], da2->vram[addr + 10], da2->vram[addr + 11]); } static void -da2_mmio_writew(uint32_t addr, uint16_t val, void *p) +da2_mmio_writew(uint32_t addr, uint16_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // if (da2->bitblt.exec != DA2_BLT_CIDLE) /* Bitblt is in operation. */ // return; // if ((addr & ~0x1ffff) != 0xA0000) return; @@ -2941,52 +2938,52 @@ da2_mmio_writew(uint32_t addr, uint16_t val, void *p) } static void -da2_code_write(uint32_t addr, uint8_t val, void *p) +da2_code_write(uint32_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // if ((addr & ~0xfff) != 0xE0000) return; addr &= DA2_MASK_CRAM; da2->cram[addr] = val; da2->fullchange = 2; } static void -da2_code_writeb(uint32_t addr, uint8_t val, void *p) +da2_code_writeb(uint32_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // da2_log("DA2_code_writeb: Write to %x, val %x\n", addr, val); cycles -= video_timing_write_b; da2_code_write(addr, val, da2); } static void -da2_code_writew(uint32_t addr, uint16_t val, void *p) +da2_code_writew(uint32_t addr, uint16_t val, void *priv) { // da2_log("DA2_code_writ ew: Write to %x, val %x\n", addr, val); - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; cycles -= video_timing_write_w; da2_code_write(addr, val & 0xff, da2); da2_code_write(addr + 1, val >> 8, da2); } static uint8_t -da2_code_read(uint32_t addr, void *p) +da2_code_read(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // if ((addr & ~DA2_MASK_CRAM) != 0xE0000) // return DA2_INVALIDACCESS8; addr &= DA2_MASK_CRAM; return da2->cram[addr]; } static uint8_t -da2_code_readb(uint32_t addr, void *p) +da2_code_readb(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; cycles -= video_timing_read_b; return da2_code_read(addr, da2); } static uint16_t -da2_code_readw(uint32_t addr, void *p) +da2_code_readw(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; cycles -= video_timing_read_w; return da2_code_read(addr, da2) | (da2_code_read(addr + 1, da2) << 8); } @@ -3153,9 +3150,9 @@ da2_poll(void *priv) } static void -da2_loadfont(char *fname, void *p) +da2_loadfont(char *fname, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint8_t buf; uint64_t fsize; if (!fname) @@ -3239,7 +3236,7 @@ da2_reset(void *priv) da2->attr_palette_enable = 0; /* disable attribute generator */ /* Set default color palette (Windows 3.1 display driver won't reset palette) */ - for (int i = 0; i < 256; i++) { + for (uint16_t i = 0; i < 256; i++) { da2->vgapal[i].r = ps55_palette_color[i & 0x3F][0]; da2->vgapal[i].g = ps55_palette_color[i & 0x3F][1]; da2->vgapal[i].b = ps55_palette_color[i & 0x3F][2]; @@ -3320,95 +3317,95 @@ da2_available(void) } static void -da2_close(void *p) +da2_close(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; /* dump mem for debug */ #ifdef ENABLE_DA2_LOG - FILE *f; - f = fopen("da2_cram.dmp", "wb"); - if (f != NULL) { - fwrite(da2->cram, DA2_SIZE_CRAM, 1, f); - fclose(f); + FILE *fp; + fp = fopen("da2_cram.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->cram, DA2_SIZE_CRAM, 1, fp); + fclose(fp); } - f = fopen("da2_vram.dmp", "wb"); - if (f != NULL) { - fwrite(da2->vram, DA2_SIZE_VRAM, 1, f); - fclose(f); + fp = fopen("da2_vram.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->vram, DA2_SIZE_VRAM, 1, fp); + fclose(fp); } - f = fopen("da2_gram.dmp", "wb"); - if (f != NULL) { - fwrite(da2->mmio.ram, DA2_SIZE_GAIJIRAM, 1, f); - fclose(f); + fp = fopen("da2_gram.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->mmio.ram, DA2_SIZE_GAIJIRAM, 1, fp); + fclose(fp); } - f = fopen("da2_attrpal.dmp", "wb"); - if (f != NULL) { - fwrite(da2->attrc, 32, 1, f); - fclose(f); + fp = fopen("da2_attrpal.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->attrc, 32, 1, fp); + fclose(fp); } - f = fopen("da2_dacrgb.dmp", "wb"); - if (f != NULL) { - fwrite(da2->vgapal, 3 * 256, 1, f); - fclose(f); + fp = fopen("da2_dacrgb.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->vgapal, 3 * 256, 1, fp); + fclose(fp); } - f = fopen("da2_daregs.txt", "w"); - if (f != NULL) { - for (int i = 0; i < 0x10; i++) - fprintf(f, "3e1(ioctl) %02X: %4X\n", i, da2->ioctl[i]); - for (int i = 0; i < 0x20; i++) - fprintf(f, "3e3(fctl) %02X: %4X\n", i, da2->fctl[i]); - for (int i = 0; i < 0x20; i++) - fprintf(f, "3e5(crtc) %02X: %4X\n", i, da2->crtc[i]); - for (int i = 0; i < 0x40; i++) - fprintf(f, "3e8(attr) %02X: %4X\n", i, da2->attrc[i]); - for (int i = 0; i < 0x10; i++) - fprintf(f, "3eb(gcr) %02X: %4X\n", i, da2->gdcreg[i]); - for (int i = 0; i < 0x10; i++) - fprintf(f, "3ee(?) %02X: %4X\n", i, da2->reg3ee[i]); - for (int i = 0; i < 0x20; i++) { - fprintf(f, "vp %02X: %4X %4X %4X %4X\n", i, + fp = fopen("da2_daregs.txt", "w"); + if (fp != NULL) { + for (uint8_t i = 0; i < 0x10; i++) + fprintf(fp, "3e1(ioctl) %02X: %4X\n", i, da2->ioctl[i]); + for (uint8_t i = 0; i < 0x20; i++) + fprintf(fp, "3e3(fctl) %02X: %4X\n", i, da2->fctl[i]); + for (uint8_t i = 0; i < 0x20; i++) + fprintf(fp, "3e5(crtc) %02X: %4X\n", i, da2->crtc[i]); + for (uint8_t i = 0; i < 0x40; i++) + fprintf(fp, "3e8(attr) %02X: %4X\n", i, da2->attrc[i]); + for (uint8_t i = 0; i < 0x10; i++) + fprintf(fp, "3eb(gcr) %02X: %4X\n", i, da2->gdcreg[i]); + for (uint8_t i = 0; i < 0x10; i++) + fprintf(fp, "3ee(?) %02X: %4X\n", i, da2->reg3ee[i]); + for (uint8_t i = 0; i < 0x20; i++) { + fprintf(fp, "vp %02X: %4X %4X %4X %4X\n", i, da2->crtc_vpreg[0 + i], da2->crtc_vpreg[0x20 + i], da2->crtc_vpreg[0x40 + i], da2->crtc_vpreg[0x60 + i]); } - fclose(f); + fclose(fp); } - f = fopen("ram_low.dmp", "wb"); - if (f != NULL) { - fwrite(&ram[0x0], 0x100000, 1, f); - fclose(f); + fp = fopen("ram_low.dmp", "wb"); + if (fp != NULL) { + fwrite(&ram[0x0], 0x100000, 1, fp); + fclose(fp); } pclog("closed %04X:%04X DS %04X\n", cs >> 4, cpu_state.pc, DS); #endif #ifdef ENABLE_DA2_DEBUGBLT - f = fopen("da2_bltdump.csv", "w"); - if (f != NULL && da2->bitblt.debug_reg_ip > 0) { + fp = fopen("da2_bltdump.csv", "w"); + if (fp != NULL && da2->bitblt.debug_reg_ip > 0) { /* print header */ for (int y = 0; y < DA2_DEBUG_BLTLOG_SIZE; y++) { if (da2->bitblt.debug_reg[(da2->bitblt.debug_reg_ip - 1) * DA2_DEBUG_BLTLOG_SIZE + y] != DA2_DEBUG_BLT_NEVERUSED) - fprintf(f, "\"%02X\"\t", y); + fprintf(fp, "\"%02X\"\t", y); } - fprintf(f, "\n"); + fprintf(fp, "\n"); /* print data */ for (int x = 0; x < da2->bitblt.debug_reg_ip; x++) { for (int y = 0; y < DA2_DEBUG_BLTLOG_SIZE; y++) { if (da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y] == DA2_DEBUG_BLT_NEVERUSED) ; else if (da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y] == DA2_DEBUG_BLT_USEDRESET) - fprintf(f, "\"\"\t"); + fprintf(fp, "\"\"\t"); else { - fprintf(f, "\"%X\"\t", da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y]); + fprintf(fp, "\"%X\"\t", da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y]); if (y == 0x12) { int chr = da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + 0x12]; if ((chr >= 0x20) && (chr < 0x7f)) - fprintf(f, "\"%c\"\t", chr); + fprintf(fp, "\"%c\"\t", chr); else - fprintf(f, "\"\"\t"); + fprintf(fp, "\"\"\t"); } } } - fprintf(f, "\n"); + fprintf(fp, "\n"); } - fclose(f); + fclose(fp); } free(da2->bitblt.debug_reg); #endif @@ -3426,28 +3423,28 @@ da2_close(void *p) } static void -da2_speed_changed(void *p) +da2_speed_changed(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->da2const = (uint64_t) ((cpuclock / DA2_PIXELCLOCK) * (double) (1ull << 32)); da2_recalctimings(da2); } static void -da2_force_redraw(void *p) +da2_force_redraw(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->fullchange = changeframecount; } static const device_config_t da2_configuration[] = { // clang-format off { - .name = "charset", + .name = "charset", .description = "Charset", - .type = CONFIG_SELECTION, + .type = CONFIG_SELECTION, .default_int = DA2_DCONFIG_CHARSET_JPAN, - .selection = { + .selection = { { .description = "932 (Japanese)", .value = DA2_DCONFIG_CHARSET_JPAN @@ -3460,11 +3457,11 @@ static const device_config_t da2_configuration[] = { } }, { - .name = "montype", + .name = "montype", .description = "Monitor type", - .type = CONFIG_SELECTION, + .type = CONFIG_SELECTION, .default_int = DA2_DCONFIG_MONTYPE_COLOR, - .selection = { + .selection = { { .description = "Color", .value = DA2_DCONFIG_MONTYPE_COLOR diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 86a57c00e..0c9c24241 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -691,11 +691,11 @@ svga_recalctimings(svga_t *svga) double _dispontime_xga = 0.0; double _dispofftime_xga = 0.0; double disptime_xga = 0.0; + int vblankend; #ifdef ENABLE_SVGA_LOG int vsyncend; - int vblankend; - int hdispstart; int hdispend; + int hdispstart; int hsyncstart; int hsyncend; #endif @@ -911,7 +911,17 @@ svga_recalctimings(svga_t *svga) if (xga_active && (svga->xga != NULL)) xga_recalctimings(svga); - if (!svga->hoverride) { + vblankend = (svga->vblankstart & 0xffffff80) | (svga->crtc[0x16] & 0x7f); + if (vblankend <= svga->vblankstart) + vblankend += 0x00000080; + + if (svga->hoverride) { + if (svga->hdisp >= 2048) + svga->monitor->mon_overscan_x = 0; + + svga->y_add = (svga->monitor->mon_overscan_y >> 1); + svga->left_overscan = svga->x_add = (svga->monitor->mon_overscan_x >> 1); + } else { uint32_t dot = svga->hblankstart; uint32_t adj_dot = svga->hblankstart; /* Verified with both the Voodoo 3 and the S3 cards: compare 7 bits if bit 7 is set, @@ -919,7 +929,9 @@ svga_recalctimings(svga_t *svga) uint32_t eff_mask = (svga->hblank_end_val & ~0x0000003f) ? svga->hblank_end_mask : 0x0000003f; svga->hblank_sub = 0; - svga_log("HDISP=%d, CRTC1+1=%d, Blank: %04i-%04i, Total: %04i, Mask: %02X, ADJ_DOT=%04i.\n", svga->hdisp, svga->crtc[1] + 1, svga->hblankstart, svga->hblank_end_val, + svga_log("HDISP=%d, CRTC1+1=%d, Blank: %04i-%04i, Total: %04i, " + "Mask: %02X, ADJ_DOT=%04i.\n", svga->hdisp, svga->crtc[1] + 1, + svga->hblankstart, svga->hblank_end_val, svga->htotal, eff_mask, adj_dot); while (adj_dot < (svga->htotal << 1)) { @@ -929,7 +941,10 @@ svga_recalctimings(svga_t *svga) if (adj_dot >= svga->htotal) svga->hblank_sub++; - svga_log("Loop: adjdot=%d, htotal=%d, dotmask=%02x, hblankendvalmask=%02x, blankendval=%02x.\n", adj_dot, svga->htotal, dot & eff_mask, svga->hblank_end_val & eff_mask, svga->hblank_end_val); + svga_log("Loop: adjdot=%d, htotal=%d, dotmask=%02x, " + "hblankendvalmask=%02x, blankendval=%02x.\n", adj_dot, + svga->htotal, dot & eff_mask, svga->hblank_end_val & eff_mask, + svga->hblank_end_val); if ((dot & eff_mask) == (svga->hblank_end_val & eff_mask)) break; @@ -937,7 +952,24 @@ svga_recalctimings(svga_t *svga) adj_dot++; } + uint32_t hd = svga->hdisp; svga->hdisp -= (svga->hblank_sub * svga->dots_per_clock); + + svga->left_overscan = svga->x_add = (svga->htotal - adj_dot - 1) * svga->dots_per_clock; + svga->monitor->mon_overscan_x = svga->x_add + (svga->hblankstart * svga->dots_per_clock) - hd; + + if ((svga->hdisp >= 2048) || (svga->left_overscan < 0)) { + svga->left_overscan = svga->x_add = 0; + svga->monitor->mon_overscan_x = 0; + } + + svga->y_add = svga->vtotal - vblankend + 1; + svga->monitor->mon_overscan_y = svga->y_add + abs(svga->vblankstart - svga->dispend); + + if ((svga->dispend >= 2048) || (svga->y_add < 0)) { + svga->y_add = 0; + svga->monitor->mon_overscan_y = 0; + } } #ifdef TBD @@ -967,12 +999,6 @@ svga_recalctimings(svga_t *svga) } #endif - if (svga->hdisp >= 2048) - svga->monitor->mon_overscan_x = 0; - - svga->y_add = (svga->monitor->mon_overscan_y >> 1); - svga->x_add = (svga->monitor->mon_overscan_x >> 1); - if (svga->vblankstart < svga->dispend) { svga_log("DISPEND > VBLANKSTART.\n"); svga->dispend = svga->vblankstart; @@ -992,12 +1018,9 @@ svga_recalctimings(svga_t *svga) vsyncend = (svga->vsyncstart & 0xfffffff0) | (svga->crtc[0x11] & 0x0f); if (vsyncend <= svga->vsyncstart) vsyncend += 0x00000010; - vblankend = (svga->vblankstart & 0xffffff80) | (svga->crtc[0x16] & 0x7f); - if (vblankend <= svga->vblankstart) - vblankend += 0x00000080; - hdispstart = ((svga->crtc[3] >> 5) & 3); hdispend = svga->crtc[1] + 1; + hdispstart = ((svga->crtc[3] >> 5) & 3); hsyncstart = svga->crtc[4] + ((svga->crtc[5] >> 5) & 3) + 1; hsyncend = (hsyncstart & 0xffffffe0) | (svga->crtc[5] & 0x1f); if (hsyncend <= hsyncstart) @@ -1178,10 +1201,10 @@ svga_do_render(svga_t *svga) if (!svga->override) { svga->render(svga); - svga->x_add = (svga->monitor->mon_overscan_x >> 1); + svga->x_add = svga->left_overscan; svga_render_overscan_left(svga); svga_render_overscan_right(svga); - svga->x_add = (svga->monitor->mon_overscan_x >> 1) - svga->scrollcache; + svga->x_add = svga->left_overscan - svga->scrollcache; } if (svga->overlay_on) { @@ -1360,7 +1383,7 @@ svga_poll(void *priv) svga->sc = 0; if (svga->attrregs[0x10] & 0x20) { svga->scrollcache = 0; - svga->x_add = (svga->monitor->mon_overscan_x >> 1); + svga->x_add = svga->left_overscan; } } } @@ -1466,7 +1489,7 @@ svga_poll(void *priv) if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) svga->scrollcache <<= 1; - svga->x_add = (svga->monitor->mon_overscan_x >> 1) - svga->scrollcache; + svga->x_add = svga->left_overscan - svga->scrollcache; svga->linecountff = 0; @@ -1516,6 +1539,7 @@ svga_init(const device_t *info, svga_t *svga, void *priv, int memsize, svga->attrregs[0x11] = 0; svga->overscan_color = 0x000000; + svga->left_overscan = 8; svga->monitor->mon_overscan_x = 16; svga->monitor->mon_overscan_y = 32; svga->x_add = 8; @@ -1973,9 +1997,15 @@ svga_doblit(int wx, int wy, svga_t *svga) y_add = enable_overscan ? svga->monitor->mon_overscan_y : 0; x_add = enable_overscan ? svga->monitor->mon_overscan_x : 0; +#ifdef USE_OLD_CALCULATION y_start = enable_overscan ? 0 : (svga->monitor->mon_overscan_y >> 1); x_start = enable_overscan ? 0 : (svga->monitor->mon_overscan_x >> 1); bottom = (svga->monitor->mon_overscan_y >> 1); +#else + y_start = enable_overscan ? 0 : svga->y_add; + x_start = enable_overscan ? 0 : svga->left_overscan; + bottom = svga->monitor->mon_overscan_y - svga->y_add; +#endif if (svga->vertical_linedbl) { y_add <<= 1; diff --git a/src/video/video.c b/src/video/video.c index 11edbc3f4..785479e15 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -1017,8 +1017,8 @@ loadfont_common(FILE *fp, int format) for (uint8_t d = 0; d < 8; d++) fontdatm[c][d + 8] = fgetc(fp) & 0xff; (void) fseek(fp, 4096 + 2048, SEEK_SET); - for (uint16_t c = 0; c < 256; c++) - for (uint8_t d = 0; d < 8; d++) /* 8x8 CGA (thick, primary) */ + for (uint16_t c = 0; c < 256; c++) /* 8x8 CGA (thick, primary) */ + for (uint8_t d = 0; d < 8; d++) fontdat[c][d] = fgetc(fp) & 0xff; break;