From c298e706a4765ea0e211bc20a3132e5c5095e14a Mon Sep 17 00:00:00 2001 From: SarahW Date: Wed, 28 Feb 2018 21:36:15 +0000 Subject: [PATCH] Added flash size and turbo switches to Xi8088. Patch from EluanCM. --- src/mem.c | 19 +++++++++--- src/model.c | 3 +- src/xi8088.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++--- src/xi8088.h | 6 +++- 4 files changed, 101 insertions(+), 13 deletions(-) diff --git a/src/mem.c b/src/mem.c index 7b4de06..18bc37b 100644 --- a/src/mem.c +++ b/src/mem.c @@ -17,6 +17,7 @@ #include "rom.h" #include "x86_ops.h" #include "codegen.h" +#include "xi8088.h" page_t *pages; page_t **page_lookup; @@ -901,11 +902,19 @@ int loadbios() case ROM_XI8088: f = romfopen("xi8088/bios-xi8088.bin", "rb"); /* use the bios without xt-ide because it's configurable in pcem */ if (!f) break; - /* high bit is flipped in xi8088 */ - romfread(rom + 0x10000, 0x10000, 1, f); - romfread(rom, 0x10000, 1, f); + if (xi8088_bios_128kb()) + { + /* high bit is flipped in xi8088 */ + romfread(rom + 0x10000, 0x10000, 1, f); + romfread(rom, 0x10000, 1, f); + biosmask = 0x1ffff; + } + else + { + /* smaller bios, more UMBs */ + romfread(rom, 0x10000, 1, f); + } fclose(f); - biosmask = 0x1ffff; return 1; } printf("Failed to load ROM!\n"); @@ -2189,7 +2198,7 @@ void mem_set_mem_state(uint32_t base, uint32_t size, int state) void mem_add_bios() { - if (AT) + if (AT || (romset == ROM_XI8088 && xi8088_bios_128kb())) { mem_mapping_add(&bios_mapping[0], 0xe0000, 0x04000, mem_read_bios, mem_read_biosw, mem_read_biosl, mem_write_null, mem_write_nullw, mem_write_nulll, rom, MEM_MAPPING_EXTERNAL, 0); mem_mapping_add(&bios_mapping[1], 0xe4000, 0x04000, mem_read_bios, mem_read_biosw, mem_read_biosl, mem_write_null, mem_write_nullw, mem_write_nulll, rom + (0x4000 & biosmask), MEM_MAPPING_EXTERNAL, 0); diff --git a/src/model.c b/src/model.c index df90f94..630387b 100644 --- a/src/model.c +++ b/src/model.c @@ -128,7 +128,7 @@ MODEL models[] = {"[8088] Thomson TO16 PC", ROM_TO16_PC, "to16_pc", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, MODEL_GFX_NONE, 512, 640, 128, xt_init, NULL}, {"[8088] Toshiba 1000", ROM_T1000, "t1000", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, MODEL_GFX_FIXED, 512, 1280, 768, xt_t1000_init, &t1000_device}, {"[8088] VTech Laser Turbo XT", ROM_LTXT, "ltxt", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, MODEL_GFX_NONE, 64, 1152, 64, xt_laserxt_init, NULL}, - {"[8088] Xi8088", ROM_XI8088, "xi8088", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, MODEL_GFX_NONE|MODEL_AT|MODEL_PS2, 64, 1024, 128, xt_xi8088_init, NULL}, + {"[8088] Xi8088", ROM_XI8088, "xi8088", { {"", cpus_8088}, {"", NULL}, {"", NULL}}, MODEL_GFX_NONE|MODEL_AT|MODEL_PS2, 64, 1024, 128, xt_xi8088_init, &xi8088_device}, {"[8086] Amstrad PC1512", ROM_PC1512, "pc1512", { {"", cpus_pc1512}, {"", NULL}, {"", NULL}}, MODEL_GFX_FIXED|MODEL_AMSTRAD, 512, 640, 128, ams_init, NULL}, {"[8086] Amstrad PC1640", ROM_PC1640, "pc1640", { {"", cpus_8086}, {"", NULL}, {"", NULL}}, MODEL_GFX_DISABLE_HW|MODEL_AMSTRAD, 640, 640, 0, ams_init, NULL}, @@ -378,7 +378,6 @@ void xt_xi8088_init() nvr_init(); pic2_init(); device_add(&gameport_device); - xi8088_init(); } void at_init() diff --git a/src/xi8088.c b/src/xi8088.c index ad04e7e..d4b7930 100644 --- a/src/xi8088.c +++ b/src/xi8088.c @@ -5,16 +5,27 @@ #include "xi8088.h" -static uint8_t xi8088_turbo; +typedef struct xi8088_t +{ + uint8_t turbo; + + int turbo_setting; + int bios_128kb; +} xi8088_t; + +static xi8088_t xi8088; uint8_t xi8088_turbo_get() { - return xi8088_turbo; + return xi8088.turbo; } void xi8088_turbo_set(uint8_t value) { - xi8088_turbo = value; + if (!xi8088.turbo_setting) + return; + + xi8088.turbo = value; if (!value) { pclog("Xi8088 turbo off\n"); @@ -30,7 +41,72 @@ void xi8088_turbo_set(uint8_t value) } } -void xi8088_init() +int xi8088_bios_128kb() { - xi8088_turbo = 1; + return xi8088.bios_128kb; } + +static void *xi8088_init() +{ + /* even though the bios by default turns the turbo off when controlling by hotkeys, pcem always starts at full speed */ + xi8088.turbo = 1; + xi8088.turbo_setting = device_get_config_int("turbo_setting"); + xi8088.bios_128kb = device_get_config_int("bios_128kb"); + + return &xi8088; +} + +static device_config_t xi8088_config[] = +{ + { + .name = "turbo_setting", + .description = "Turbo", + .type = CONFIG_SELECTION, + .selection = + { + { + .description = "Always at selected speed", + .value = 0 + }, + { + .description = "Hotkeys (starts off)", + .value = 1 + } + }, + .default_int = 0 + }, + { + .name = "bios_128kb", + .description = "BIOS size", + .type = CONFIG_SELECTION, + .selection = + { + { + .description = "64KB", + .value = 0 + }, + { + .description = "128KB", + .value = 1 + } + }, + .default_int = 1 + }, + { + .type = -1 + } +}; + + +device_t xi8088_device = +{ + "Xi8088", + 0, + xi8088_init, + NULL, + NULL, + NULL, + NULL, + NULL, + xi8088_config +}; diff --git a/src/xi8088.h b/src/xi8088.h index ef40e19..54178da 100644 --- a/src/xi8088.h +++ b/src/xi8088.h @@ -1,3 +1,7 @@ +#include "device.h" + +extern device_t xi8088_device; + uint8_t xi8088_turbo_get(); void xi8088_turbo_set(uint8_t value); -void xi8088_init(); +int xi8088_bios_128kb();