From 39759575905084916d78ffc1612a7ef67f5da037 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 23 Dec 2021 17:38:58 +0100 Subject: [PATCH] Added Kingston MC64 memory expansion card (adf 71d0) which allows up to 64MB of RAM in the MCA-based 386DX-based models as well as a IBM CPU planar upgrade which allows 486DX cpu's to be used on the 386DX-based 80 models. Fixed missing part of the width in the Compaq CGA cards. --- src/machine/m_ps2_mca.c | 67 +++++++++++++++++++++++++++++-------- src/machine/machine_table.c | 6 ++-- src/video/vid_compaq_cga.c | 4 +-- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index e6e659176..549168ffb 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -862,13 +862,8 @@ static void ps2_mca_mem_fffc_init(int start_mb) { uint32_t planar_size, expansion_start; - if (start_mb == 2) { - planar_size = 0x160000; - expansion_start = 0x260000; - } else { - planar_size = (start_mb - 1) << 20; - expansion_start = start_mb << 20; - } + planar_size = (start_mb - 1) << 20; + expansion_start = start_mb << 20; mem_mapping_set_addr(&ram_high_mapping, 0x100000, planar_size); @@ -919,6 +914,36 @@ static void ps2_mca_mem_fffc_init(int start_mb) mem_mapping_disable(&ps2.expansion_mapping); } +static void ps2_mca_mem_d071_init(int start_mb) +{ + uint32_t planar_size, expansion_start; + + planar_size = (start_mb - 1) << 20; + expansion_start = start_mb << 20; + + mem_mapping_set_addr(&ram_high_mapping, 0x100000, planar_size); + + ps2.mem_pos_regs[0] = 0xd0; + ps2.mem_pos_regs[1] = 0x71; + ps2.mem_pos_regs[4] = (mem_size / 1024) - start_mb; + + mca_add(ps2_mem_expansion_read, ps2_mem_expansion_write, ps2_mem_expansion_feedb, NULL, NULL); + mem_mapping_add(&ps2.expansion_mapping, + expansion_start, + (mem_size - (start_mb << 10)) << 10, + mem_read_ram, + mem_read_ramw, + mem_read_raml, + mem_write_ram, + mem_write_ramw, + mem_write_raml, + &ram[expansion_start], + MEM_MAPPING_INTERNAL, + NULL); + mem_mapping_disable(&ps2.expansion_mapping); +} + + static void ps2_mca_board_model_50_init() { ps2_mca_board_common_init(); @@ -995,7 +1020,7 @@ static void ps2_mca_board_model_55sx_init() model_55sx_mem_recalc(); } -static void mem_encoding_update() +static void mem_encoding_update(void) { mem_mapping_disable(&ps2.split_mapping); @@ -1005,6 +1030,8 @@ static void mem_encoding_update() mem_set_mem_state(1 << 20, (mem_size << 10) - (1 << 20), MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); ps2.split_addr = ((uint32_t) (ps2.mem_regs[0] & 0xf)) << 20; + if (!ps2.split_addr) + ps2.split_addr = 1 << 20; if (ps2.mem_regs[1] & 2) { mem_set_mem_state(0xe0000, 0x20000, MEM_READ_EXTANY | MEM_WRITE_INTERNAL); @@ -1210,14 +1237,22 @@ static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) if (ps2.planar_id == 0xfff9) { if (mem_size > 4096) { - /* Only 4 MB supported on planar, create a memory expansion card for the rest */ - ps2_mca_mem_fffc_init(4); + /* Only 4 MB supported on planar, create a memory expansion card for the rest */ + if (mem_size > 12288) { + ps2_mca_mem_d071_init(4); + } else { + ps2_mca_mem_fffc_init(4); + } } } else { if (mem_size > 8192) { - /* Only 8 MB supported on planar, create a memory expansion card for the rest */ - ps2_mca_mem_fffc_init(8); + /* Only 8 MB supported on planar, create a memory expansion card for the rest */ + if (mem_size > 16384) + ps2_mca_mem_d071_init(8); + else { + ps2_mca_mem_fffc_init(8); + } } } @@ -1288,8 +1323,12 @@ static void ps2_mca_board_model_80_type2_init(int is486) if ((mem_size > 4096) && !is486) { - /* Only 4 MB supported on planar, create a memory expansion card for the rest */ - ps2_mca_mem_fffc_init(4); + /* Only 4 MB supported on planar, create a memory expansion card for the rest */ + if (mem_size > 12288) + ps2_mca_mem_d071_init(4); + else { + ps2_mca_mem_fffc_init(4); + } } if (gfxcard == VID_INTERNAL) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 74260d668..17a3dc335 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -309,11 +309,11 @@ const machine_t machines[] = { /* 386DX machines which utilize the MCA bus */ /* Has IBM PS/2 Type 1 KBC firmware. */ - { "[MCA] IBM PS/2 model 70 (type 3)", "ibmps2_m70_type3", MACHINE_TYPE_386DX, CPU_PKG_386DX | CPU_PKG_486BL, 0, 0, 0, 0, 0, 0, 0, MACHINE_MCA | MACHINE_BUS_PS2 | MACHINE_VIDEO, 2048, 16384, 2048, 63, machine_ps2_model_70_type3_init, NULL }, + { "[MCA] IBM PS/2 model 70 (type 3)", "ibmps2_m70_type3", MACHINE_TYPE_386DX, CPU_PKG_386DX | CPU_PKG_486BL, 0, 0, 0, 0, 0, 0, 0, MACHINE_MCA | MACHINE_BUS_PS2 | MACHINE_VIDEO, 2048, 65536, 2048, 63, machine_ps2_model_70_type3_init, NULL }, /* Has IBM PS/2 Type 1 KBC firmware. */ - { "[MCA] IBM PS/2 model 80", "ibmps2_m80", MACHINE_TYPE_386DX, CPU_PKG_386DX | CPU_PKG_486BL, 0, 0, 0, 0, 0, 0, 0, MACHINE_MCA | MACHINE_BUS_PS2 | MACHINE_VIDEO, 1024, 12288, 1024, 63, machine_ps2_model_80_init, NULL }, + { "[MCA] IBM PS/2 model 80 (type 2)", "ibmps2_m80", MACHINE_TYPE_386DX, CPU_PKG_386DX | CPU_PKG_486BL | CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_MCA | MACHINE_BUS_PS2 | MACHINE_VIDEO, 1024, 65536, 1024, 63, machine_ps2_model_80_init, NULL }, /* Has IBM PS/2 Type 1 KBC firmware. */ - { "[MCA] IBM PS/2 model 80 (type 3)", "ibmps2_m80_type3", MACHINE_TYPE_386DX, CPU_PKG_386DX | CPU_PKG_486BL, 0, 0, 0, 0, 0, 0, 0, MACHINE_MCA | MACHINE_BUS_PS2 | MACHINE_VIDEO, 2048, 12288, 2048, 63, machine_ps2_model_80_axx_init, NULL }, + { "[MCA] IBM PS/2 model 80 (type 3)", "ibmps2_m80_type3", MACHINE_TYPE_386DX, CPU_PKG_386DX | CPU_PKG_486BL | CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_MCA | MACHINE_BUS_PS2 | MACHINE_VIDEO, 2048, 65536, 2048, 63, machine_ps2_model_80_axx_init, NULL }, /* 386DX/486 machines */ /* The BIOS sends commands C9 without a parameter and D5, both of which are diff --git a/src/video/vid_compaq_cga.c b/src/video/vid_compaq_cga.c index d971a6af4..99655b551 100644 --- a/src/video/vid_compaq_cga.c +++ b/src/video/vid_compaq_cga.c @@ -315,8 +315,8 @@ compaq_cga_poll(void *p) compaq_cga_log("Lastline %i Firstline %i %i\n", self->cga.lastline, self->cga.firstline ,self->cga.lastline - self->cga.firstline); - if (self->cga.cgamode & 1) x = (self->cga.crtc[1] << 3); - else x = (self->cga.crtc[1] << 4); + if (self->cga.cgamode & 1) x = (self->cga.crtc[1] << 3) + 16; + else x = (self->cga.crtc[1] << 4) + 16; self->cga.lastline++;