From 9c6ec45e60aa362ef4796bdf433caec27e85ca4b Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 15 Sep 2018 16:15:39 +0200 Subject: [PATCH] Removed ROM set checking from several files. --- src/keyboard.h | 7 ++++- src/keyboard_at.c | 23 ++++++++++++---- src/keyboard_xt.c | 43 +++++++++++++++++++++-------- src/machine/m_ps1.c | 6 +++- src/machine/m_xt.c | 15 ++++++++++ src/machine/m_xt_laserxt.c | 24 ++++++++++++++++ src/machine/m_xt_t1000.c | 16 +++++++---- src/machine/m_xt_xi8088.c | 4 ++- src/machine/machine.h | 5 +++- src/machine/machine_table.c | 14 +++++----- src/mem.c | 55 +++++++++++++++++++------------------ src/mem.h | 7 ++++- src/nvr.c | 25 ++++++++--------- src/nvr.h | 7 +++-- src/nvr_at.c | 6 ++-- src/nvr_ps2.c | 42 ++++++++++------------------ 16 files changed, 191 insertions(+), 108 deletions(-) diff --git a/src/keyboard.h b/src/keyboard.h index e4c846b7d..8b501dc56 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -8,7 +8,7 @@ * * Definitions for the keyboard interface. * - * Version: @(#)keyboard.h 1.0.15 2018/03/26 + * Version: @(#)keyboard.h 1.0.16 2018/09/15 * * Authors: Sarah Walker, * Miran Grca, @@ -60,12 +60,17 @@ extern int mouse_queue_start, mouse_queue_end; extern int mouse_scan; #ifdef EMU_DEVICE_H +extern const device_t keyboard_pc_device; extern const device_t keyboard_xt_device; extern const device_t keyboard_tandy_device; +#if defined(DEV_BRANCH) && defined(USE_LASERXT) +extern const device_t keyboard_xt_lxt3_device; +#endif extern const device_t keyboard_at_device; extern const device_t keyboard_at_ami_device; extern const device_t keyboard_at_toshiba_device; extern const device_t keyboard_ps2_device; +extern const device_t keyboard_ps2_xi8088_device; extern const device_t keyboard_ps2_ami_device; extern const device_t keyboard_ps2_mca_device; extern const device_t keyboard_ps2_mca_2_device; diff --git a/src/keyboard_at.c b/src/keyboard_at.c index cefe39b0d..8eba9a0d9 100644 --- a/src/keyboard_at.c +++ b/src/keyboard_at.c @@ -8,7 +8,7 @@ * * Intel 8042 (AT keyboard controller) emulation. * - * Version: @(#)keyboard_at.c 1.0.38 2018/09/12 + * Version: @(#)keyboard_at.c 1.0.39 2018/09/15 * * Authors: Sarah Walker, * Miran Grca, @@ -79,6 +79,7 @@ #define KBC_VEN_IBM_MCA 0x08 #define KBC_VEN_QUADTEL 0x0c #define KBC_VEN_TOSHIBA 0x10 +#define KBC_VEN_XI8088 0x14 #define KBC_VEN_MASK 0x1c @@ -785,7 +786,7 @@ kbd_adddata_keyboard(uint16_t val) } /* Test for T3100E 'Fn' key (Right Alt / Right Ctrl) */ - if (romset == ROM_T3100E && (keyboard_recv(0xb8) || keyboard_recv(0x9d))) { + if (CurrentKbd && ((CurrentKbd->flags & KBC_VEN_MASK) == KBC_VEN_TOSHIBA) && (keyboard_recv(0xb8) || keyboard_recv(0x9d))) { switch (val) { case 0x4f: t3100e_notify_set(0x01); break; /* End */ case 0x50: t3100e_notify_set(0x02); break; /* Down */ @@ -1644,7 +1645,7 @@ kbd_write(uint16_t port, uint8_t val, void *priv) int bad = 1; uint8_t mask; - if (romset == ROM_XI8088 && port == 0x63) + if (((kbd->flags & KBC_VEN_MASK) == KBC_VEN_XI8088) && (port == 0x63)) port = 0x61; #ifdef _DEBUG @@ -1952,7 +1953,7 @@ do_command: was_speaker_enable = 1; pit_set_gate(&pit, 2, val & 1); - if (romset == ROM_XI8088) { + if ((kbd->flags & KBC_VEN_MASK) == KBC_VEN_XI8088) { if (val & 0x04) xi8088_turbo_set(1); else @@ -2126,7 +2127,7 @@ kbd_read(uint16_t port, void *priv) atkbd_t *kbd = (atkbd_t *)priv; uint8_t ret = 0xff; - if (romset == ROM_XI8088 && port == 0x63) + if (((kbd->flags & KBC_VEN_MASK) == KBC_VEN_XI8088) && (port == 0x63)) port = 0x61; switch (port) { @@ -2148,7 +2149,7 @@ kbd_read(uint16_t port, void *priv) else ret &= ~0x10; } - if (romset == ROM_XI8088){ + if ((kbd->flags & KBC_VEN_MASK) == KBC_VEN_XI8088) { if (xi8088_turbo_get()) ret |= 0x04; else @@ -2352,6 +2353,16 @@ const device_t keyboard_ps2_device = { NULL, NULL, NULL, NULL }; +const device_t keyboard_ps2_xi8088_device = { + "PS/2 Keyboard (Xi8088)", + 0, + KBC_TYPE_PS2_1 | KBC_VEN_XI8088, + kbd_init, + kbd_close, + kbd_reset, + NULL, NULL, NULL, NULL +}; + const device_t keyboard_ps2_ami_device = { "PS/2 Keyboard (AMI)", 0, diff --git a/src/keyboard_xt.c b/src/keyboard_xt.c index 80405387c..53d61d884 100644 --- a/src/keyboard_xt.c +++ b/src/keyboard_xt.c @@ -8,7 +8,7 @@ * * Implementation of the XT-style keyboard. * - * Version: @(#)keyboard_xt.c 1.0.12 2018/04/26 + * Version: @(#)keyboard_xt.c 1.0.13 2018/09/15 * * Authors: Sarah Walker, * Miran Grca, @@ -56,6 +56,7 @@ typedef struct { uint8_t pb; int tandy; + int type; } xtkbd_t; @@ -460,7 +461,7 @@ kbd_read(uint16_t port, void *priv) switch (port) { case 0x60: - if ((romset == ROM_IBMPC) && (kbd->pb & 0x80)) { + if (!kbd->type && (kbd->pb & 0x80)) { if (video_is_ega_vga()) ret = 0x4d; else if (video_is_mda()) @@ -476,7 +477,7 @@ kbd_read(uint16_t port, void *priv) break; case 0x62: - if (romset == ROM_IBMPC) { + if (!kbd->type) { if (kbd->pb & 0x04) ret = ((mem_size-64) / 32) & 0x0f; else @@ -493,7 +494,7 @@ kbd_read(uint16_t port, void *priv) /* LaserXT = Always 512k RAM; LaserXT/3 = Bit 0: set = 512k, clear = 256k. */ #if defined(DEV_BRANCH) && defined(USE_LASERXT) - if (romset == ROM_LXT3) + if (kbd->type == 3) ret = (mem_size == 512) ? 0x0d : 0x0c; else #endif @@ -502,7 +503,7 @@ kbd_read(uint16_t port, void *priv) } ret |= (ppispeakon ? 0x20 : 0); - if (kbd->tandy) + if (kbd->type == 2) ret |= (tandy1k_eeprom_read() ? 0x10 : 0); break; @@ -539,9 +540,7 @@ kbd_init(const device_t *info) keyboard_set_table(scancode_xt); - if (info->local == 1) { - kbd->tandy = 1; - } + kbd->type = info->local; keyboard_scan = 1; @@ -574,10 +573,20 @@ kbd_close(void *priv) } +const device_t keyboard_pc_device = { + "IBM PC Keyboard", + 0, + 0, + kbd_init, + kbd_close, + kbd_reset, + NULL, NULL, NULL +}; + const device_t keyboard_xt_device = { - "PC/XT Keyboard", - 0, + "XT Keyboard", 0, + 1, kbd_init, kbd_close, kbd_reset, @@ -587,9 +596,21 @@ const device_t keyboard_xt_device = { const device_t keyboard_tandy_device = { "Tandy 1000 Keyboard", 0, - 1, + 2, kbd_init, kbd_close, kbd_reset, NULL, NULL, NULL }; + +#if defined(DEV_BRANCH) && defined(USE_LASERXT) +const device_t keyboard_xt_lxt3_device = { + "VTech Laser XT3 Keyboard", + 0, + 3, + kbd_init, + kbd_close, + kbd_reset, + NULL, NULL, NULL +}; +#endif diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index 1df063517..4e7a555ae 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -28,7 +28,7 @@ * boot. Sometimes, they do, and then it shows an "Incorrect * DOS" error message?? --FvK * - * Version: @(#)m_ps1.c 1.0.10 2018/09/02 + * Version: @(#)m_ps1.c 1.0.11 2018/09/15 * * Authors: Sarah Walker, * Miran Grca, @@ -476,6 +476,10 @@ ps1_setup(int model) ps1_hdc_inform(priv, ps); } + + mem_mapping_add(&romext_mapping, 0xc8000, 0x08000, + mem_read_romext,mem_read_romextw,mem_read_romextl, + NULL,NULL, NULL, romext, 0, NULL); } if (model == 2121) { diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 3878c98b1..4d8261ab7 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -14,6 +14,21 @@ #include "machine.h" +void +machine_pc_init(const machine_t *model) +{ + machine_common_init(model); + + pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + + device_add(&keyboard_pc_device); + device_add(&fdc_xt_device); + nmi_init(); + if (joystick_type != 7) + device_add(&gameport_device); +} + + void machine_xt_init(const machine_t *model) { diff --git a/src/machine/m_xt_laserxt.c b/src/machine/m_xt_laserxt.c index fe5d86606..dc58271be 100644 --- a/src/machine/m_xt_laserxt.c +++ b/src/machine/m_xt_laserxt.c @@ -7,8 +7,15 @@ #include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" +#include "../nmi.h" +#include "../pit.h" #include "../rom.h" #include "machine.h" +#include "../device.h" +#include "../floppy/fdd.h" +#include "../floppy/fdc.h" +#include "../game/gameport.h" +#include "../keyboard.h" static int laserxt_emspage[4]; @@ -138,3 +145,20 @@ machine_xt_laserxt_init(const machine_t *model) laserxt_init(); } + + +void +machine_xt_lxt3_init(const machine_t *model) +{ + machine_common_init(model); + + pit_set_out_func(&pit, 1, pit_refresh_timer_xt); + + device_add(&keyboard_xt_lxt3_device); + device_add(&fdc_xt_device); + nmi_init(); + if (joystick_type != 7) + device_add(&gameport_device); + + laserxt_init(); +} diff --git a/src/machine/m_xt_t1000.c b/src/machine/m_xt_t1000.c index 294ef7c6f..7a21a1c3d 100644 --- a/src/machine/m_xt_t1000.c +++ b/src/machine/m_xt_t1000.c @@ -51,7 +51,7 @@ * NOTE: Still need to figure out a way to load/save ConfigSys and * HardRAM stuff. Needs to be linked in to the NVR code. * - * Version: @(#)m_xt_t1000.c 1.0.9 2018/08/16 + * Version: @(#)m_xt_t1000.c 1.0.10 2018/09/15 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -446,9 +446,9 @@ ems_set_port(t1000_t *sys, uint8_t val) { int n; -#if 0 +#if 0 t1000_log("ems_set_port(%d)", val & 0x0f); -#endif +#endif if (sys->ems_port) { for (n = 0; n <= 0xc000; n += 0x4000) { io_removehandler(sys->ems_port+n, 1, @@ -913,6 +913,9 @@ machine_xt_t1000_init(const machine_t *model) tc8521_init(&t1000.nvr, model->nvrmask + 1); + t1000_nvr_load(); + nvr_set_ven_save(t1000_nvr_save); + if (gfxcard == GFX_INTERNAL) device_add(&t1000_video_device); } @@ -967,8 +970,11 @@ machine_xt_t1200_init(const machine_t *model) tc8521_init(&t1000.nvr, model->nvrmask + 1); - if (gfxcard == GFX_INTERNAL) - device_add(&t1200_video_device); + t1200_nvr_load(); + nvr_set_ven_save(t1200_nvr_save); + + if (gfxcard == GFX_INTERNAL) + device_add(&t1200_video_device); } diff --git a/src/machine/m_xt_xi8088.c b/src/machine/m_xt_xi8088.c index 13d1c20b8..f1ce87919 100644 --- a/src/machine/m_xt_xi8088.c +++ b/src/machine/m_xt_xi8088.c @@ -124,9 +124,11 @@ xi8088_get_device(void) void machine_xt_xi8088_init(const machine_t *model) { /* TODO: set UMBs? See if PCem always sets when we have > 640KB ram and avoids conflicts when a peripheral uses the same memory space */ + if (xi8088_bios_128kb()) + mem_add_upper_bios(); machine_common_init(model); device_add(&fdc_xt_device); - device_add(&keyboard_ps2_device); + device_add(&keyboard_ps2_xi8088_device); nmi_init(); device_add(&at_nvr_device); pic2_init(); diff --git a/src/machine/machine.h b/src/machine/machine.h index 1dfb1577a..68b114a00 100644 --- a/src/machine/machine.h +++ b/src/machine/machine.h @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.h 1.0.28 2018/09/12 + * Version: @(#)machine.h 1.0.29 2018/09/15 * * Authors: Sarah Walker, * Miran Grca, @@ -37,6 +37,7 @@ #define MACHINE_HDC_PS2 0x002000 /* sys has int PS/2 HDC */ #define MACHINE_MOUSE 0x004000 /* sys has int mouse */ #define MACHINE_VIDEO 0x008000 /* sys has int video */ +#define MACHINE_NONMI 0x010000 /* sys does not have NMI's */ #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; @@ -147,6 +148,7 @@ extern void machine_at_r418_init(const machine_t *); extern void machine_at_wd76c10_init(const machine_t *); +extern void machine_pc_init(const machine_t *); extern void machine_pcjr_init(const machine_t *); extern void machine_ps1_m2011_init(const machine_t *); @@ -185,6 +187,7 @@ extern void machine_xt_init(const machine_t *); extern void machine_xt_compaq_init(const machine_t *); #if defined(DEV_BRANCH) && defined(USE_LASERXT) extern void machine_xt_laserxt_init(const machine_t *); +extern void machine_xt_lxt3_init(const machine_t *); #endif extern void machine_xt_t1000_init(const machine_t *); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 2250721cc..a98132026 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -11,7 +11,7 @@ * NOTES: OpenAT wip for 286-class machine with open BIOS. * PS2_M80-486 wip, pending receipt of TRM's for machine. * - * Version: @(#)machine_table.c 1.0.37 2018/09/12 + * Version: @(#)machine_table.c 1.0.38 2018/09/15 * * Authors: Sarah Walker, * Miran Grca, @@ -37,16 +37,16 @@ const machine_t machines[] = { { "[8088] AMI XT clone", ROM_AMIXT, "amixt", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, { "[8088] Compaq Portable", ROM_PORTABLE, "portable", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VIDEO, 128, 640, 128, 0, machine_xt_compaq_init, NULL }, { "[8088] DTK XT clone", ROM_DTKXT, "dtk", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, - { "[8088] IBM PC", ROM_IBMPC, "ibmpc", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 32, 0, machine_xt_init, NULL }, + { "[8088] IBM PC", ROM_IBMPC, "ibmpc", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 32, 0, machine_pc_init, NULL }, { "[8088] IBM PCjr", ROM_IBMPCJR, "ibmpcjr", {{"Intel", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO, 128, 640, 128, 0, machine_pcjr_init, pcjr_get_device }, { "[8088] IBM XT", ROM_IBMXT, "ibmxt", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, { "[8088] Generic XT clone", ROM_GENXT, "genxt", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, { "[8088] Juko XT clone", ROM_JUKOPC, "jukopc", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, { "[8088] Phoenix XT clone", ROM_PXXT, "pxxt", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 64, 640, 64, 0, machine_xt_init, NULL }, - { "[8088] Schneider EuroPC", ROM_EUROPC, "europc", {{"Siemens", cpus_europc}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_HDC | MACHINE_VIDEO | MACHINE_MOUSE, 512, 640, 128, 15, machine_europc_init, NULL }, + { "[8088] Schneider EuroPC", ROM_EUROPC, "europc", {{"Siemens", cpus_europc}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_HDC | MACHINE_VIDEO | MACHINE_MOUSE, 512, 640, 128, 15, machine_europc_init, NULL }, { "[8088] Tandy 1000", ROM_TANDY, "tandy", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 128, 640, 128, 0, machine_tandy1k_init, tandy1k_get_device }, { "[8088] Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 256, 640, 128, 0, machine_tandy1k_init, tandy1k_hx_get_device }, - { "[8088] Toshiba T1000", ROM_T1000, "t1000", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VIDEO, 512, 1280, 768, 63, machine_xt_t1000_init, t1000_get_device }, + { "[8088] Toshiba T1000", ROM_T1000, "t1000", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VIDEO, 512, 1280, 768, 63, machine_xt_t1000_init, t1000_get_device }, #if defined(DEV_BRANCH) && defined(USE_LASERXT) { "[8088] VTech Laser Turbo XT", ROM_LTXT, "ltxt", {{"Intel", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 512, 512, 256, 0, machine_xt_laserxt_init, NULL }, #endif @@ -59,9 +59,9 @@ const machine_t machines[] = { { "[8086] Amstrad PC20(0)", ROM_PC200, "pc200", {{"Intel", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 512, 640, 128, 63, machine_amstrad_init, NULL }, { "[8086] Olivetti M24", ROM_OLIM24, "olivetti_m24", {{"Intel", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_VIDEO | MACHINE_MOUSE, 128, 640, 128, 0, machine_olim24_init, NULL }, { "[8086] Tandy 1000 SL/2", ROM_TANDY1000SL2, "tandy1000sl2", {{"Intel", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA, 512, 768, 128, 0, machine_tandy1k_init, NULL }, - { "[8086] Toshiba T1200", ROM_T1200, "t1200", {{"Intel", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VIDEO, 1024, 2048,1024, 63, machine_xt_t1200_init, t1200_get_device }, + { "[8086] Toshiba T1200", ROM_T1200, "t1200", {{"Intel", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VIDEO, 1024, 2048,1024, 63, machine_xt_t1200_init, t1200_get_device }, #if defined(DEV_BRANCH) && defined(USE_LASERXT) - { "[8086] VTech Laser XT3", ROM_LXT3, "lxt3", {{"Intel", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 256, 512, 256, 0, machine_xt_laserxt_init, NULL }, + { "[8086] VTech Laser XT3", ROM_LXT3, "lxt3", {{"Intel", cpus_8086}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA, 256, 512, 256, 0, machine_xt_lxt3_init, NULL }, #endif { "[286 ISA] AMI 286 clone", ROM_AMI286, "ami286", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 512,8192, 128, 127, machine_at_neat_ami_init, NULL }, @@ -110,7 +110,7 @@ const machine_t machines[] = { { "[486 ISA] AMI WinBIOS 486", ROM_WIN486, "win486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_ali1429_init, NULL }, { "[486 ISA] Award 486 clone", ROM_AWARD486_OPTI495, "award486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_opti495_init, NULL }, { "[486 ISA] DTK PKM-0038S E-2", ROM_DTK486, "dtk486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 128, 1, 127, machine_at_dtk486_init, NULL }, - { "[486 ISA] IBM PS/1 model 2133", ROM_IBMPS1_2133, "ibmps1_2133", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 1, 64, 1, 127, machine_ps1_m2133_init, NULL }, + { "[486 ISA] IBM PS/1 model 2133", ROM_IBMPS1_2133, "ibmps1_2133", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_NONMI, 1, 64, 1, 127, machine_ps1_m2133_init, NULL }, #if defined(DEV_BRANCH) && defined(USE_PS2M70T4) { "[486 MCA] IBM PS/2 model 70 (type 4)", ROM_IBMPS2_M70_TYPE4, "ibmps2_m70_type4", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, 0, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2 | MACHINE_VIDEO, 2, 16, 2, 63, machine_ps2_model_70_type4_init, NULL }, diff --git a/src/mem.c b/src/mem.c index b77a32d17..a85905a28 100644 --- a/src/mem.c +++ b/src/mem.c @@ -12,7 +12,7 @@ * the DYNAMIC_TABLES=1 enables this. Will eventually go * away, either way... * - * Version: @(#)mem.c 1.0.12 2018/09/02 + * Version: @(#)mem.c 1.0.13 2018/09/15 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1568,30 +1568,36 @@ mem_set_mem_state(uint32_t base, uint32_t size, int state) } +void +mem_add_upper_bios(void) +{ + 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|MEM_MAPPING_ROM, 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|MEM_MAPPING_ROM, 0); + mem_mapping_add(&bios_mapping[2], 0xe8000, 0x04000, + mem_read_bios,mem_read_biosw,mem_read_biosl, + mem_write_null,mem_write_nullw,mem_write_nulll, + rom + (0x8000 & biosmask), + MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM, 0); + mem_mapping_add(&bios_mapping[3], 0xec000, 0x04000, + mem_read_bios,mem_read_biosw,mem_read_biosl, + mem_write_null,mem_write_nullw,mem_write_nulll, + rom + (0xc000 & biosmask), + MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM, 0); +} + + void mem_add_bios(void) { - 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|MEM_MAPPING_ROM, 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|MEM_MAPPING_ROM, 0); - mem_mapping_add(&bios_mapping[2], 0xe8000, 0x04000, - mem_read_bios,mem_read_biosw,mem_read_biosl, - mem_write_null,mem_write_nullw,mem_write_nulll, - rom + (0x8000 & biosmask), - MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM, 0); - mem_mapping_add(&bios_mapping[3], 0xec000, 0x04000, - mem_read_bios,mem_read_biosw,mem_read_biosl, - mem_write_null,mem_write_nullw,mem_write_nulll, - rom + (0xc000 & biosmask), - MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM, 0); - } + if (AT) + mem_add_upper_bios(); mem_mapping_add(&bios_mapping[4], 0xf0000, 0x04000, mem_read_bios,mem_read_biosw,mem_read_biosl, @@ -1828,11 +1834,6 @@ mem_log("MEM: reset: new pages=%08lx, pages_sz=%i\n", pages, pages_sz); mem_write_ram,mem_write_ramw,mem_write_raml, ram + 0xc0000, MEM_MAPPING_INTERNAL, NULL); - if (romset == ROM_IBMPS1_2011) - mem_mapping_add(&romext_mapping, 0xc8000, 0x08000, - mem_read_romext,mem_read_romextw,mem_read_romextl, - NULL,NULL, NULL, romext, 0, NULL); - mem_mapping_add(&ram_remapped_mapping, mem_size * 1024, 256 * 1024, mem_read_remapped,mem_read_remappedw,mem_read_remappedl, mem_write_remapped,mem_write_remappedw,mem_write_remappedl, diff --git a/src/mem.h b/src/mem.h index 6139b6dad..afbe52bb4 100644 --- a/src/mem.h +++ b/src/mem.h @@ -8,7 +8,7 @@ * * Definitions for the memory interface. * - * Version: @(#)mem.h 1.0.5 2018/09/02 + * Version: @(#)mem.h 1.0.6 2018/09/15 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -226,6 +226,10 @@ extern uint8_t mem_read_bios(uint32_t addr, void *priv); extern uint16_t mem_read_biosw(uint32_t addr, void *priv); extern uint32_t mem_read_biosl(uint32_t addr, void *priv); +extern uint8_t mem_read_romext(uint32_t addr, void *priv); +extern uint16_t mem_read_romextw(uint32_t addr, void *priv); +extern uint32_t mem_read_romextl(uint32_t addr, void *priv); + extern void mem_write_null(uint32_t addr, uint8_t val, void *p); extern void mem_write_nullw(uint32_t addr, uint16_t val, void *p); extern void mem_write_nulll(uint32_t addr, uint32_t val, void *p); @@ -248,6 +252,7 @@ extern void mmu_invalidate(uint32_t addr); extern void mem_a20_recalc(void); +extern void mem_add_upper_bios(void); extern void mem_add_bios(void); extern void mem_init(void); diff --git a/src/nvr.c b/src/nvr.c index 90ba98661..e76a255e0 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -8,7 +8,7 @@ * * Implement a generic NVRAM/CMOS/RTC device. * - * Version: @(#)nvr.c 1.0.12 2018/08/14 + * Version: @(#)nvr.c 1.0.13 2018/09/15 * * Authors: Fred N. van Kempen, , * David Hrdlička, @@ -257,10 +257,7 @@ nvr_load(void) if (saved_nvr == NULL) return(0); /* Clear out any old data. */ - if (romset == ROM_AWARD286) - memset(saved_nvr->regs, 0xff, sizeof(saved_nvr->regs)); - else - memset(saved_nvr->regs, 0x00, sizeof(saved_nvr->regs)); + memset(saved_nvr->regs, 0x00, sizeof(saved_nvr->regs)); /* Set the defaults. */ if (saved_nvr->reset != NULL) @@ -278,11 +275,6 @@ nvr_load(void) } } - if (romset == ROM_T1000) - t1000_nvr_load(); - else if (romset == ROM_T1200) - t1200_nvr_load(); - /* Get the local RTC running! */ if (saved_nvr->start != NULL) saved_nvr->start(saved_nvr); @@ -291,6 +283,13 @@ nvr_load(void) } +void +nvr_set_ven_save(void (*ven_save)(void)) +{ + saved_nvr->ven_save = ven_save; +} + + /* Save the current NVR to a file. */ int nvr_save(void) @@ -312,10 +311,8 @@ nvr_save(void) } } - if (romset == ROM_T1000) - t1000_nvr_save(); - else if (romset == ROM_T1200) - t1200_nvr_save(); + if (saved_nvr->ven_save) + saved_nvr->ven_save(); /* Device is clean again. */ nvr_dosave = 0; diff --git a/src/nvr.h b/src/nvr.h index fedb652e4..0a7c2d60c 100644 --- a/src/nvr.h +++ b/src/nvr.h @@ -1,4 +1,4 @@ -/* +/* * VARCem Virtual ARchaeological Computer EMulator. * An emulator of (mostly) x86-based PC systems and devices, * using the ISA,EISA,VLB,MCA and PCI system buses, roughly @@ -8,7 +8,7 @@ * * Definitions for the generic NVRAM/CMOS driver. * - * Version: @(#)nvr.h 1.0.8 2018/08/04 + * Version: @(#)nvr.h 1.0.9 2018/09/15 * * Author: Fred N. van Kempen, , * David Hrdlička, @@ -80,6 +80,8 @@ typedef struct _nvr_ { void (*tick)(struct _nvr_ *); void (*recalc)(struct _nvr_ *); + void (*ven_save)(void); + uint8_t regs[NVR_MAXSIZE]; /* these are the registers */ } nvr_t; @@ -99,6 +101,7 @@ extern void nvr_init(nvr_t *); extern wchar_t *nvr_path(wchar_t *str); extern FILE *nvr_fopen(wchar_t *str, wchar_t *mode); extern int nvr_load(void); +extern void nvr_set_ven_save(void (*ven_save)(void)); extern int nvr_save(void); extern int nvr_is_leap(int year); diff --git a/src/nvr_at.c b/src/nvr_at.c index 645f2f4bb..41b79e6a8 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -189,7 +189,7 @@ * including the later update (DS12887A) which implemented a * "century" register to be compatible with Y2K. * - * Version: @(#)nvr_at.c 1.0.11 2018/08/14 + * Version: @(#)nvr_at.c 1.0.12 2018/09/15 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -565,7 +565,7 @@ nvr_write(uint16_t addr, uint8_t val, void *priv) } else { local->addr = (val & (nvr->size - 1)); if (!(machines[machine].flags & MACHINE_MCA) && - (romset != ROM_IBMPS1_2133)) + (machines[machine].flags & MACHINE_NONMI)) nmi_mask = (~val & 0x80); } } @@ -664,7 +664,7 @@ nvr_at_init(const device_t *info) nvr = (nvr_t *)malloc(sizeof(nvr_t)); if (nvr == NULL) return(NULL); /* FIXME: See which is correct, this or 0xFF. */ - if ((info->local == 0) || (romset == ROM_AWARD286)) + if (info->local == 0) memset(nvr, 0xff, sizeof(nvr_t)); else memset(nvr, 0x00, sizeof(nvr_t)); diff --git a/src/nvr_ps2.c b/src/nvr_ps2.c index 665967f48..df1a05430 100644 --- a/src/nvr_ps2.c +++ b/src/nvr_ps2.c @@ -8,7 +8,7 @@ * * Handling of the PS/2 series CMOS devices. * - * Version: @(#)nvr_ps2.c 1.0.8 2018/09/12 + * Version: @(#)nvr_ps2.c 1.0.9 2018/09/15 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -54,6 +54,8 @@ typedef struct { int addr; uint8_t ram[8192]; + + wchar_t *fn; } ps2_nvr_t; @@ -105,28 +107,24 @@ ps2_nvr_write(uint16_t port, uint8_t val, void *priv) static void * ps2_nvr_init(const device_t *info) { + char temp[64]; ps2_nvr_t *nvr; FILE *f = NULL; + int c; nvr = (ps2_nvr_t *)malloc(sizeof(ps2_nvr_t)); memset(nvr, 0x00, sizeof(ps2_nvr_t)); - + + /* Set up the NVR file's name. */ + sprintf(temp, "%s_sec.nvr", machine_get_internal_name()); + c = strlen(temp); + nvr->fn = (wchar_t *)malloc((c + 1) * sizeof(wchar_t)); + mbstowcs(nvr->fn, temp, c + 1); + io_sethandler(0x0074, 3, ps2_nvr_read,NULL,NULL, ps2_nvr_write,NULL,NULL, nvr); - switch (romset) { - case ROM_IBMPS2_M70_TYPE3: - f = nvr_fopen(L"ibmps2_m70_type3_sec.nvr", L"rb"); - break; -#if defined(DEV_BRANCH) && defined(USE_PS2M70T4) - case ROM_IBMPS2_M70_TYPE4: - f = nvr_fopen(L"ibmps2_m70_type4_sec.nvr", L"rb"); - break; -#endif - case ROM_IBMPS2_M80: - f = nvr_fopen(L"ibmps2_m80_sec.nvr", L"rb"); - break; - } + f = nvr_fopen(nvr->fn, L"rb"); memset(nvr->ram, 0xff, 8192); if (f != NULL) { @@ -144,19 +142,7 @@ ps2_nvr_close(void *priv) ps2_nvr_t *nvr = (ps2_nvr_t *)priv; FILE *f = NULL; - switch (romset) { - case ROM_IBMPS2_M70_TYPE3: - f = nvr_fopen(L"ibmps2_m70_type3_sec.nvr", L"wb"); - break; -#if defined(DEV_BRANCH) && defined(USE_PS2M70T4) - case ROM_IBMPS2_M70_TYPE4: - f = nvr_fopen(L"ibmps2_m70_type4_sec.nvr", L"wb"); - break; -#endif - case ROM_IBMPS2_M80: - f = nvr_fopen(L"ibmps2_m80_sec.nvr", L"wb"); - break; - } + f = nvr_fopen(nvr->fn, L"wb"); if (f != NULL) { (void)fwrite(nvr->ram, 8192, 1, f);