From 643f9b46ea5ba2e3f2ff6d183de6e5188d262829 Mon Sep 17 00:00:00 2001 From: EngiNerd89 Date: Sat, 19 Dec 2020 12:16:42 +0100 Subject: [PATCH 1/6] Added the following new machines: - Zenith Data Systems Z-151/152/161 - Zenith Data Systems Z-159 - Columbia Data Products MPC-1600 - Eagle PC Spirit Minor tweaks and renamings --- src/device/keyboard_xt.c | 145 +++++++++++++++++++++++++++-------- src/include/86box/keyboard.h | 1 + src/include/86box/machine.h | 14 +++- src/machine/m_xt.c | 45 ++++++++++- src/machine/m_xt_zenith.c | 91 +++++++++++++++++++--- src/machine/machine_table.c | 6 +- 6 files changed, 255 insertions(+), 47 deletions(-) diff --git a/src/device/keyboard_xt.c b/src/device/keyboard_xt.c index 9a234b6eb..9c8a9351b 100644 --- a/src/device/keyboard_xt.c +++ b/src/device/keyboard_xt.c @@ -352,6 +352,34 @@ kbd_log(const char *fmt, ...) #define kbd_log(fmt, ...) #endif +static uint8_t +get_fdd_switch_settings(){ + + int i, fdd_count = 0; + + for (i = 0; i < FDD_NUM; i++) { + if (fdd_get_flags(i)) + fdd_count++; + } + + if (!fdd_count) + return 0x00; + else + return ((fdd_count - 1) << 6) | 0x01; + +} + +static uint8_t +get_videomode_switch_settings(){ + + if (video_is_mda()) + return 0x30; + else if (video_is_cga()) + return 0x20; /* 0x10 would be 40x25 */ + else + return 0x00; + +} static void kbd_poll(void *priv) @@ -530,6 +558,7 @@ kbd_read(uint16_t port, void *priv) { xtkbd_t *kbd = (xtkbd_t *)priv; uint8_t ret = 0xff; + switch (port) { case 0x60: @@ -537,9 +566,28 @@ kbd_read(uint16_t port, void *priv) ret = (kbd->pd & ~0x02) | (hasfpu ? 0x02 : 0x00); else if (((kbd->type == 2) || (kbd->type == 3)) && (kbd->pb & 0x80)) ret = 0xff; /* According to Ruud on the PCem forum, this is supposed to return 0xFF on the XT. */ - else - ret = kbd->pa; - break; + else if ((kbd->type == 9) && (kbd->pb & 0x80)) { + /* Zenith Data Systems Z-151 + * SW1 switch settings: + * bits 6-7: floppy drive number + * bits 4-5: video mode + * bit 2-3: base memory size + * bit 1: fpu enable + * bit 0: fdc enable + */ + ret = get_fdd_switch_settings(); + + ret |= get_videomode_switch_settings(); + + /* base memory size should always be 64k */ + ret |= 0x0c; + + if (hasfpu) + ret |= 0x02; + + } else + ret = kbd->pa; + break; case 0x61: ret = kbd->pb; @@ -548,18 +596,20 @@ kbd_read(uint16_t port, void *priv) case 0x62: if (kbd->type == 0) ret = 0x00; - else if (kbd->type == 1) { + else if (kbd->type == 1) { if (kbd->pb & 0x04) ret = ((mem_size-64) / 32) & 0x0f; else ret = ((mem_size-64) / 32) >> 4; } - else if (kbd->type == 8) { - /* Olivetti M19 */ + else if (kbd->type == 8 || kbd->type == 9) { + /* Olivetti M19 or Zenith Data Systems Z-151*/ if (kbd->pb & 0x04) - ret = kbd->pd; + ret = kbd->pd & 0xbf; + //return 0x00; else ret = kbd->pd >> 4; + //return 0x00; } else { if (kbd->pb & 0x08) @@ -589,6 +639,7 @@ kbd_read(uint16_t port, void *priv) case 0x63: if ((kbd->type == 2) || (kbd->type == 3) || (kbd->type == 4) || (kbd->type == 6)) ret = kbd->pd; + break; } @@ -616,8 +667,6 @@ kbd_reset(void *priv) static void * kbd_init(const device_t *info) { - int i, fdd_count = 0; - xtkbd_t *kbd; kbd = (xtkbd_t *)malloc(sizeof(xtkbd_t)); @@ -634,33 +683,21 @@ kbd_init(const device_t *info) video_reset(gfxcard); if (kbd->type <= 3 || kbd-> type == 8) { - for (i = 0; i < FDD_NUM; i++) { - if (fdd_get_flags(i)) - fdd_count++; - } - + /* DIP switch readout: bit set = OFF, clear = ON. */ if (kbd->type != 8) /* Switches 7, 8 - floppy drives. */ - if (!fdd_count) - kbd->pd = 0x00; - else - kbd->pd = ((fdd_count - 1) << 6) | 0x01; + kbd->pd = get_fdd_switch_settings(); else - /* Jumpers J1, J2 - monitor type. - * 01 - mono (high-res) - * 10 - color (low-res, disables 640x400x2 mode) - * 00 - autoswitching - */ + /* Olivetti M19 + * Jumpers J1, J2 - monitor type. + * 01 - mono (high-res) + * 10 - color (low-res, disables 640x400x2 mode) + * 00 - autoswitching + */ kbd->pd |= 0x00; - /* Switches 5, 6 - video. */ - if (video_is_mda()) - kbd->pd |= 0x30; - else if (video_is_cga()) - kbd->pd |= 0x20; /* 0x10 would be 40x25 */ - else - kbd->pd |= 0x00; + kbd->pd |= get_videomode_switch_settings(); /* Switches 3, 4 - memory size. */ // Note to Compaq/Toshiba keyboard maintainers: type 4 and 6 will never be activated in this block @@ -721,6 +758,44 @@ kbd_init(const device_t *info) /* Switch 1 - always off. */ kbd->pd |= 0x01; + } else if (kbd-> type == 9) { + /* Zenith Data Systems Z-151 + * SW2 switch settings: + * bit 7: monitor frequency + * bits 5-6: autoboot (00-11 resident monitor, 10 hdd, 01 fdd) + * bits 0-4: installed memory + */ + kbd->pd = 0x20; + switch (mem_size) { + case 128: + kbd->pd |= 0x02; + break; + case 192: + kbd->pd |= 0x04; + break; + case 256: + kbd->pd |= 0x02|0x04; + break; + case 320: + kbd->pd |= 0x08; + break; + case 384: + kbd->pd |= 0x02|0x08; + break; + case 448: + kbd->pd |= 0x04|0x08; + break; + case 512: + kbd->pd |= 0x02|0x04|0x08; + break; + case 576: + kbd->pd |= 0x10; + break; + case 640: + default: + kbd->pd |= 0x02|0x10; + break; + } } timer_add(&kbd->send_delay_timer, kbd_poll, kbd, 1); @@ -844,3 +919,13 @@ const device_t keyboard_xt_olivetti_device = { kbd_reset, { NULL }, NULL, NULL }; + +const device_t keyboard_xt_zenith_device = { + "Zenith XT Keyboard", + 0, + 9, + kbd_init, + kbd_close, + kbd_reset, + { NULL }, NULL, NULL +}; diff --git a/src/include/86box/keyboard.h b/src/include/86box/keyboard.h index 3785a8f6d..126e50afc 100644 --- a/src/include/86box/keyboard.h +++ b/src/include/86box/keyboard.h @@ -69,6 +69,7 @@ extern const device_t keyboard_tandy_device; extern const device_t keyboard_xt_lxt3_device; #endif extern const device_t keyboard_xt_olivetti_device; +extern const device_t keyboard_xt_zenith_device; extern const device_t keyboard_at_device; extern const device_t keyboard_at_ami_device; extern const device_t keyboard_at_toshiba_device; diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index d920ef494..25811a9c6 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -511,10 +511,13 @@ extern const device_t europc_device; /* m_xt_olivetti.c */ extern int machine_xt_olim24_init(const machine_t *); +#ifdef EMU_DEVICE_H +extern const device_t *m24_get_device(void); +#endif extern int machine_xt_olim240_init(const machine_t *); extern int machine_xt_olim19_init(const machine_t *); #ifdef EMU_DEVICE_H -extern const device_t *m24_get_device(void); +extern const device_t *m19_get_device(void); #endif /* m_pcjr.c */ @@ -579,6 +582,8 @@ extern int machine_xt_jukopc_init(const machine_t *); extern int machine_xt_open_xt_init(const machine_t *); extern int machine_xt_pxxt_init(const machine_t *); extern int machine_xt_ncrpc4i_init(const machine_t *); +extern int machine_xt_mpc1600_init(const machine_t *); +extern int machine_xt_eaglepcspirit_init(const machine_t *); extern int machine_xt_iskra3104_init(const machine_t *); @@ -606,7 +611,12 @@ extern const device_t *t1200_get_device(void); #endif /* m_xt_zenith.c */ -extern int machine_xt_zenith_init(const machine_t *); +extern int machine_xt_z184_init(const machine_t *); +#ifdef EMU_DEVICE_H +extern const device_t *z184_get_device(void); +#endif +extern int machine_xt_z151_init(const machine_t *); +extern int machine_xt_z159_init(const machine_t *); /* m_xt_xi8088.c */ extern int machine_xt_xi8088_init(const machine_t *); diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index e94c7bc28..c5c1acc1c 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -26,11 +26,11 @@ machine_xt_common_init(const machine_t *model) pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); if (fdc_type == FDC_INTERNAL) - device_add(&fdc_xt_device); + device_add(&fdc_xt_device); nmi_init(); if (joystick_type) - device_add(&gameport_device); + device_add(&gameport_device); } @@ -332,12 +332,51 @@ machine_xt_ncrpc4i_init(const machine_t *model) 0x000fc000, 16384, 0); if (bios_only || !ret) - return ret; + return ret; machine_xt_clone_init(model); return ret; } +int +machine_xt_mpc1600_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/mpc1600/mpc4.34_merged.bin", + 0x000fc000, 16384, 0); + + if (bios_only || !ret) + return ret; + + device_add(&keyboard_pc82_device); + + machine_xt_common_init(model); + + return ret; +} +int +machine_xt_eaglepcspirit_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/eagle_pcspirit/u1101.bin", + 0x000fe000, 16384, 0); + + if (ret) { + bios_load_aux_linear(L"roms/machines/eagle_pcspirit/u1103.bin", + 0x000fc000, 8192, 0); + } + + if (bios_only || !ret) + return ret; + + device_add(&keyboard_pc82_device); + + machine_xt_common_init(model); + + return ret; +} \ No newline at end of file diff --git a/src/machine/m_xt_zenith.c b/src/machine/m_xt_zenith.c index 7b7ea2409..6e5ac1729 100644 --- a/src/machine/m_xt_zenith.c +++ b/src/machine/m_xt_zenith.c @@ -42,6 +42,8 @@ #include <86box/lpt.h> #include <86box/serial.h> #include <86box/machine.h> +#include <86box/io.h> +#include <86box/vid_cga.h> typedef struct { @@ -105,8 +107,36 @@ static const device_t zenith_scratchpad_device = { }; +void +machine_zenith_init(const machine_t *model){ + + machine_common_init(model); + + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); + + device_add(&zenith_scratchpad_device); + + pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); + + device_add(&keyboard_xt_zenith_device); + + nmi_init(); + +} + +const device_t * +z184_get_device(void) +{ + return &cga_device; +} + +/* + * Current bugs and limitations: + * - missing NVRAM implementation + */ int -machine_xt_zenith_init(const machine_t *model) +machine_xt_z184_init(const machine_t *model) { int ret; @@ -114,22 +144,61 @@ machine_xt_zenith_init(const machine_t *model) 0x000f8000, 32768, 0); if (bios_only || !ret) - return ret; + return ret; - machine_common_init(model); - - if (fdc_type == FDC_INTERNAL) - device_add(&fdc_xt_device); + machine_zenith_init(model); lpt1_remove(); /* only one parallel port */ lpt2_remove(); lpt1_init(0x278); device_add(&i8250_device); serial_set_next_inst(2); /* So that serial_standalone_init() won't do anything. */ - device_add(&zenith_scratchpad_device); - pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); - device_add(&keyboard_xt_compaq_device); - nmi_init(); - + + device_add(&cga_device); + return ret; } + +int +machine_xt_z151_init(const machine_t *model) +{ + int ret; + ret = bios_load_linear(L"roms/machines/zdsz151/444-229-18.bin", + 0x000fc000, 32768, 0); + if (ret) { + bios_load_aux_linear(L"roms/machines/zdsz151/444-260-18.bin", + 0x000f8000, 16384, 0); + } + + if (bios_only || !ret) + return ret; + + machine_zenith_init(model); + + return ret; +} + +/* + * Current bugs and limitations: + * - Memory board support for EMS currently missing + */ +int +machine_xt_z159_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/zdsz159/z159m v2.9e.10d", + 0x000f8000, 32768, 0); + + if (bios_only || !ret) + return ret; + + machine_zenith_init(model); + + /* parallel port is on the memory board */ + lpt1_remove(); /* only one parallel port */ + lpt2_remove(); + lpt1_init(0x278); + + return ret; +} \ No newline at end of file diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index c852b0057..5504b69a3 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -56,6 +56,8 @@ const machine_type_t machine_types[] = { const machine_t machines[] = { /* 8088 Machines */ + { "[8088] Columbia Data Products MPC-1600", "mpc1600", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 512, 64, 0, machine_xt_mpc1600_init, NULL }, + { "[8088] Eagle PC Spirit", "eagle_pcspirit", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 640, 64, 0, machine_xt_eaglepcspirit_init, NULL }, { "[8088] IBM PC (1981)", "ibmpc", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 16, 64, 16, 0, machine_pc_init, NULL }, { "[8088] IBM PC (1982)", "ibmpc82", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 256, 256, 256, 0, machine_pc82_init, NULL }, { "[8088] IBM PCjr", "ibmpcjr", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_pcjr_init, pcjr_get_device }, @@ -79,7 +81,9 @@ const machine_t machines[] = { { "[8088] VTech Laser Turbo XT", "ltxt", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 256, 640, 256, 0, machine_xt_laserxt_init, NULL }, #endif { "[8088] Xi8088", "xi8088", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2, 64, 1024, 128, 127, machine_xt_xi8088_init, xi8088_get_device }, - { "[8088] Zenith Data SupersPort", "zdsupers", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 640, 128, 0, machine_xt_zenith_init, NULL }, + { "[8088] Zenith Data Systems Z-151/152/161", "zdsz151", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 640, 64, 0, machine_xt_z151_init, NULL }, + { "[8088] Zenith Data Systems Z-159", "zdsz159", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 640, 64, 0, machine_xt_z159_init, NULL }, + { "[8088] Zenith Data Systems SupersPort (Z-184)", "zdsupers", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC|MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_xt_z184_init, z184_get_device }, /* 8086 Machines */ { "[8086] Amstrad PC1512", "pc1512", MACHINE_TYPE_8086, CPU_PKG_8086, 0, 8000000, 8000000, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO_FIXED | MACHINE_MOUSE, 512, 640, 128, 63, machine_pc1512_init, pc1512_get_device }, From 51009d8e2850b1ffa158f7a648cfc5732361b04a Mon Sep 17 00:00:00 2001 From: EngiNerd89 Date: Sat, 19 Dec 2020 21:17:11 +0100 Subject: [PATCH 2/6] Added the following new machines: - Multitech pc-700 - Philips P3105/NMS9100 - Philips P3120 --- src/include/86box/machine.h | 3 ++ src/machine/m_xt.c | 74 +++++++++++++++++++++++++++++++++++++ src/machine/machine_table.c | 3 ++ 3 files changed, 80 insertions(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 25811a9c6..e2dc4aee6 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -584,6 +584,9 @@ extern int machine_xt_pxxt_init(const machine_t *); extern int machine_xt_ncrpc4i_init(const machine_t *); extern int machine_xt_mpc1600_init(const machine_t *); extern int machine_xt_eaglepcspirit_init(const machine_t *); +extern int machine_xt_multitechpc700_init(const machine_t *); +extern int machine_xt_p3105_init(const machine_t *); +extern int machine_xt_p3120_init(const machine_t *); extern int machine_xt_iskra3104_init(const machine_t *); diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index c5c1acc1c..7640b0932 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -378,5 +378,79 @@ machine_xt_eaglepcspirit_init(const machine_t *model) machine_xt_common_init(model); + return ret; +} + +int +machine_xt_multitechpc700_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/multitech_pc700/multitech pc-700 3.1.bin", + 0x000fe000, 8192, 0); + + if (bios_only || !ret) + return ret; + + device_add(&keyboard_pc_device); + + machine_xt_common_init(model); + + return ret; +} + + +/* + * Current bugs and limitations: + * - 640-768 conventional memory not usable (should be mapped at address d0000-effff) + */ +int +machine_xt_p3105_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/philips_p3105/philipsnms9100.bin", + 0x000fc000, 16384, 0); + + if (bios_only || !ret) + return ret; + + device_add(&keyboard_pc_device); + + machine_xt_common_init(model); + + return ret; +} + +/* + * Current bugs and limitations: + * - 640-768 conventional memory not usable (should be mapped at address d0000-effff) + * - BIOS detects 4 fdds, so hdd letter is E instead of C + */ +int +machine_xt_p3120_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/philips_p3120/philips_p3120.bin", + 0x000f8000, 32768, 0); + + if (bios_only || !ret) + return ret; + + device_add(&keyboard_pc_device); + + machine_common_init(model); + + pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); + + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_at_device); + + nmi_init(); + + if (joystick_type) + device_add(&gameport_device); + return ret; } \ No newline at end of file diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 5504b69a3..1ff1b99ee 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -69,9 +69,12 @@ const machine_t machines[] = { { "[8088] DTK XT clone", "dtk", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 64, 640, 64, 0, machine_xt_dtk_init, NULL }, { "[8088] Generic XT clone", "genxt", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 64, 640, 64, 0, machine_genxt_init, NULL }, { "[8088] Juko XT clone", "jukopc", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 64, 640, 64, 0, machine_xt_jukopc_init, NULL }, + { "[8088] Multitech PC-700", "multitech_pc700", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 128, 640, 64, 0, machine_xt_multitechpc700_init, NULL }, { "[8088] NCR PC4i", "ncr_pc4i", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 256, 640, 256, 0, machine_xt_ncrpc4i_init, NULL }, { "[8088] Olivetti M19", "olivetti_m19", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO_FIXED, 256, 640, 256, 0, machine_xt_olim19_init, NULL }, { "[8088] OpenXT", "open_xt", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 64, 640, 64, 0, machine_xt_open_xt_init, NULL }, + { "[8088] Philips P3105/NMS9100", "philips_p3105", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 256, 768, 256, 0, machine_xt_p3105_init, NULL }, + { "[8088] Philips P3120", "philips_p3120", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 256, 768, 256, 0, machine_xt_p3120_init, NULL }, { "[8088] Phoenix XT clone", "pxxt", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC, 64, 640, 64, 0, machine_xt_pxxt_init, NULL }, { "[8088] Schneider EuroPC", "europc", MACHINE_TYPE_8088, CPU_PKG_8088_EUROPC, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_XTA | MACHINE_MOUSE, 512, 640, 128, 15, machine_europc_init, NULL }, { "[8088] Tandy 1000", "tandy", MACHINE_TYPE_8088, CPU_PKG_8088_EUROPC, 0, 0, 0, 0, 0, 0, 0, MACHINE_PC | MACHINE_VIDEO_FIXED, 128, 640, 128, 0, machine_tandy_init, tandy1k_get_device }, From da1de8aaf57edece4b0ebb1477b46ef78bbc17ed Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 20 Dec 2020 21:14:24 +0100 Subject: [PATCH 3/6] 40x25 text mode and Cardex ET4000/w32p 80x25 text mode now actually fixes. --- src/video/vid_et4000w32.c | 11 +++++++++++ src/video/vid_svga.c | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index b3eb235bd..e856c9675 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -355,6 +355,17 @@ void et4000w32p_recalctimings(svga_t *svga) svga->clock = (cpuclock * (double)(1ull << 32)) / svga->getclock((svga->miscout >> 2) & 3, svga->clock_gen); + if (svga->adv_flags & FLAG_NOSKEW) { + /* On the Cardex ET4000/W32p, adjust text mode clocks by 1. */ + if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /*Text mode*/ + svga->ma_latch--; + if ((svga->seqregs[1] & 8)) /*40 column*/ + svga->hdisp += (svga->seqregs[1] & 1) ? 16 : 18; + else + svga->hdisp += (svga->seqregs[1] & 1) ? 8 : 9; + } + } + switch (svga->bpp) { case 15: case 16: diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 0298c3f36..61dcc6d1f 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -445,7 +445,7 @@ svga_recalctimings(svga_t *svga) svga->interlace = 0; - svga->ma_latch = ((svga->crtc[0xc] << 8) | svga->crtc[0xd]); + svga->ma_latch = ((svga->crtc[0xc] << 8) | svga->crtc[0xd]) + ((svga->crtc[8] & 0x60) >> 5); svga->ca_adj = 0; svga->rowcount = svga->crtc[9] & 31; @@ -457,10 +457,11 @@ svga_recalctimings(svga_t *svga) if (svga->seqregs[1] & 8) /*40 column*/ { svga->render = svga_render_text_40; svga->hdisp *= (svga->seqregs[1] & 1) ? 16 : 18; + /* Character clock is off by 1 now in 40-line modes, on all cards. */ + svga->ma_latch--; + svga->hdisp += (svga->seqregs[1] & 1) ? 16 : 18; } else { svga->render = svga_render_text_80; - if (!(svga->adv_flags & FLAG_NOSKEW)) - svga->ma_latch += ((svga->crtc[8] & 0x60) >> 5); svga->hdisp *= (svga->seqregs[1] & 1) ? 8 : 9; } svga->hdisp_old = svga->hdisp; From 978f02aa99d968a770a45b3737f6304fc997369a Mon Sep 17 00:00:00 2001 From: Winins0 <65453129+Winins0@users.noreply.github.com> Date: Mon, 21 Dec 2020 19:49:08 +0300 Subject: [PATCH 4/6] Gave 1.x/2.0 Sound Blasters port 0x260. (#1185) --- src/sound/snd_sb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 353d25987..303c69ba1 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -1506,8 +1506,11 @@ static const device_config_t sb_config[] = "0x240", 0x240 }, { - "" - } + "0x260", 0x260 + }, + { + "" + } } }, { From b44ba0e69bd5399eec5f15ff783836e1be49cc3d Mon Sep 17 00:00:00 2001 From: TC1995 Date: Mon, 21 Dec 2020 20:53:24 +0100 Subject: [PATCH 5/6] Fixed the previous commit. --- src/sound/snd_ad1848.c | 2 +- src/video/vid_voodoo_banshee.c | 91 ++++++++++++++++++++++++++++++---- 2 files changed, 81 insertions(+), 12 deletions(-) diff --git a/src/sound/snd_ad1848.c b/src/sound/snd_ad1848.c index be11e09ca..fc859f8cc 100644 --- a/src/sound/snd_ad1848.c +++ b/src/sound/snd_ad1848.c @@ -299,6 +299,6 @@ void ad1848_init(ad1848_t *ad1848, int type) timer_add(&ad1848->timer_count, ad1848_poll, ad1848, 0); - if (ad1848->type != AD1848_TYPE_DEFAULT) + if (ad1848->type != AD1848_TYPE_DEFAULT && ad1848->type != AD1848_TYPE_CS4248) sound_set_cd_audio_filter(ad1848_filter_cd_audio, ad1848); } diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 7401df0d0..b749e0cf2 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -116,7 +116,8 @@ typedef struct banshee_t int desktop_y; uint32_t desktop_stride_tiled; - int type; + int type, card; + int vblank_irq; void *i2c, *i2c_ddc, *ddc; } banshee_t; @@ -179,6 +180,7 @@ enum #define VGAINIT0_EXTENDED_SHIFT_OUT (1 << 12) #define VIDPROCCFG_CURSOR_MODE (1 << 1) +#define VIDPROCCFG_INTERLACE (1 << 3) #define VIDPROCCFG_HALF_MODE (1 << 4) #define VIDPROCCFG_OVERLAY_ENABLE (1 << 8) #define VIDPROCCFG_OVERLAY_CLUT_BYPASS (1 << 11) @@ -256,6 +258,32 @@ banshee_log(const char *fmt, ...) static uint32_t banshee_status(banshee_t *banshee); +static int banshee_vga_vsync_enabled(banshee_t *banshee) +{ + if (!(banshee->svga.crtc[0x11] & 0x20) && (banshee->svga.crtc[0x11] & 0x10) && ((banshee->pciInit0 >> 18) & 1) != 0) + return 1; + return 0; +} + +static void banshee_update_irqs(banshee_t *banshee) +{ + if (banshee->vblank_irq > 0 && banshee_vga_vsync_enabled(banshee)) { + pci_set_irq(banshee->card, PCI_INTA); + } else { + pci_clear_irq(banshee->card, PCI_INTA); + } +} + +static void banshee_vblank_start(svga_t* svga) +{ + banshee_t *banshee = (banshee_t*)svga->p; + if (banshee->vblank_irq >= 0) { + banshee->vblank_irq = 1; + banshee_update_irqs(banshee); + } +} + + static void banshee_out(uint16_t addr, uint8_t val, void *p) { banshee_t *banshee = (banshee_t *)p; @@ -281,7 +309,18 @@ static void banshee_out(uint16_t addr, uint8_t val, void *p) svga->crtc[svga->crtcreg] = val; if (old != val) { - if (svga->crtcreg < 0xe || svga->crtcreg > 0x10) + if (svga->crtcreg == 0x11) { + if (!(val & 0x10)) { + if (banshee->vblank_irq > 0) + banshee->vblank_irq = -1; + } else if (banshee->vblank_irq < 0) { + banshee->vblank_irq = 0; + } + banshee_update_irqs(banshee); + if ((val & ~0x30) == (old & ~0x30)) + old = val; + } + if (svga->crtcreg < 0xe || svga->crtcreg > 0x11 || (svga->crtcreg == 0x11 && old != val)) { svga->fullchange = changeframecount; svga_recalctimings(svga); @@ -310,6 +349,8 @@ static uint8_t banshee_in(uint16_t addr, void *p) temp = 0; else temp = 0x10; + if (banshee->vblank_irq > 0) + temp |= 0x80; break; case 0x3D4: temp = svga->crtcreg; @@ -440,6 +481,8 @@ static void banshee_recalctimings(svga_t *svga) if (svga->crtc[0x1b] & 0x40) svga->vsyncstart += 0x400; // banshee_log("svga->hdisp=%i\n", svga->hdisp); + svga->interlace = 0; + if (banshee->vgaInit0 & VGAINIT0_EXTENDED_SHIFT_OUT) { switch (VIDPROCCFG_DESKTOP_PIX_FORMAT) @@ -484,6 +527,8 @@ static void banshee_recalctimings(svga_t *svga) svga->htotal *= 2; } + svga->interlace = !!(banshee->vidProcCfg & VIDPROCCFG_INTERLACE); + svga->overlay.ena = banshee->vidProcCfg & VIDPROCCFG_OVERLAY_ENABLE; svga->overlay.x = voodoo->overlay.start_x; @@ -791,7 +836,6 @@ static uint32_t banshee_status(banshee_t *banshee) voodoo_t *voodoo = banshee->voodoo; svga_t *svga = &banshee->svga; int fifo_entries = FIFO_ENTRIES; - int fifo_size = 0xffff - fifo_entries; int swap_count = voodoo->swap_count; int written = voodoo->cmd_written + voodoo->cmd_written_fifo; int busy = (written - voodoo->cmd_read) || (voodoo->cmdfifo_depth_rd != voodoo->cmdfifo_depth_wr) || @@ -801,11 +845,11 @@ static uint32_t banshee_status(banshee_t *banshee) uint32_t ret; ret = 0; - if (fifo_size < 0x20) - ret |= fifo_size; + if (fifo_entries < 0x20) + ret |= 0x1f - fifo_entries; else ret |= 0x1f; - if (fifo_size) + if (fifo_entries) ret |= 0x20; if (swap_count < 7) ret |= (swap_count << 28); @@ -1041,6 +1085,14 @@ static uint32_t banshee_reg_readl(uint32_t addr, void *p) voodoo_flush(voodoo); switch (addr & 0x1fc) { + case SST_status: + ret = banshee_status(banshee); + break; + + case SST_intrCtrl: + ret = banshee->intrCtrl & 0x0030003f; + break; + case 0x08: ret = voodoo->banshee_blt.clip0Min; break; @@ -1271,7 +1323,11 @@ static void banshee_reg_writel(uint32_t addr, uint32_t val, void *p) break; case 0x0100000: /*2D registers*/ - voodoo_queue_command(voodoo, (addr & 0x1fc) | FIFO_WRITEL_2DREG, val); + if ((addr & 0x3fc) == SST_intrCtrl) { + banshee->intrCtrl = val & 0x0030003f; + } else { + voodoo_queue_command(voodoo, (addr & 0x1fc) | FIFO_WRITEL_2DREG, val); + } break; case 0x0200000: case 0x0300000: case 0x0400000: case 0x0500000: /*3D registers*/ @@ -2365,8 +2421,8 @@ static uint8_t banshee_pci_read(int func, int addr, void *p) case 0x18: ret = 0x01; break; /*ioBaseAddr*/ case 0x19: ret = banshee->ioBaseAddr >> 8; break; - case 0x1a: ret = 0x00; break; - case 0x1b: ret = 0x00; break; + case 0x1a: ret = banshee->ioBaseAddr >> 16; break; + case 0x1b: ret = banshee->ioBaseAddr >> 24; break; /*Subsystem vendor ID*/ case 0x2c: ret = banshee->pci_regs[0x2c]; break; @@ -2445,12 +2501,23 @@ static void banshee_pci_write(int func, int addr, uint8_t val, void *p) case 0x19: if (banshee->pci_regs[PCI_REG_COMMAND] & PCI_COMMAND_IO) io_removehandler(banshee->ioBaseAddr, 0x0100, banshee_ext_in, NULL, banshee_ext_inl, banshee_ext_out, NULL, banshee_ext_outl, banshee); - banshee->ioBaseAddr = val << 8; + banshee->ioBaseAddr &= 0xffff00ff; + banshee->ioBaseAddr |= val << 8; if ((banshee->pci_regs[PCI_REG_COMMAND] & PCI_COMMAND_IO) && banshee->ioBaseAddr) io_sethandler(banshee->ioBaseAddr, 0x0100, banshee_ext_in, NULL, banshee_ext_inl, banshee_ext_out, NULL, banshee_ext_outl, banshee); banshee_log("Banshee ioBaseAddr=%08x\n", banshee->ioBaseAddr); return; + case 0x1a: + banshee->ioBaseAddr &= 0xff00ffff; + banshee->ioBaseAddr |= val << 16; + break; + + case 0x1b: + banshee->ioBaseAddr &= 0x00ffffff; + banshee->ioBaseAddr |= val << 24; + break; + case 0x30: case 0x32: case 0x33: banshee->pci_regs[addr] = val; if (banshee->pci_regs[0x30] & 0x01) @@ -2645,6 +2712,8 @@ static void *banshee_init_common(const device_t *info, wchar_t *fn, int has_sgra MEM_MAPPING_EXTERNAL, banshee); + banshee->svga.vblank_start = banshee_vblank_start; + // io_sethandler(0x03c0, 0x0020, banshee_in, NULL, NULL, banshee_out, NULL, NULL, banshee); banshee->svga.bpp = 8; @@ -2657,7 +2726,7 @@ static void *banshee_init_common(const device_t *info, wchar_t *fn, int has_sgra banshee->dramInit1 = 1 << 30; /*SDRAM*/ banshee->svga.decode_mask = 0x1ffffff; - pci_add_card(PCI_ADD_VIDEO, banshee_pci_read, banshee_pci_write, banshee); + banshee->card = pci_add_card(PCI_ADD_VIDEO, banshee_pci_read, banshee_pci_write, banshee); banshee->voodoo = voodoo_2d3d_card_init(voodoo_type); banshee->voodoo->p = banshee; From 4b42251b846578f1e163a749a92328c88b61b22d Mon Sep 17 00:00:00 2001 From: luisjoseromero Date: Tue, 22 Dec 2020 00:19:45 +0000 Subject: [PATCH 6/6] Fix blit thread related deadlocks Removed unnecessary calls to video_wait_for_blit(), which in addition to not doing much were also in a race with the video_blit_memtoscreen() thread to wait for and reset the blit_data.blit_complete event signalled by blit_thread(), causing several deadlocks. --- src/win/win.c | 4 ---- src/win/win_ui.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/win/win.c b/src/win/win.c index 5322d6c55..74f8d16a4 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -719,7 +719,6 @@ plat_setvid(int api) win_log("Initializing VIDAPI: api=%d\n", api); startblit(); - video_wait_for_blit(); /* Close the (old) API. */ vid_apis[vid_api].close(); @@ -750,7 +749,6 @@ plat_vidsize(int x, int y) if (!vid_api_inited || !vid_apis[vid_api].resize) return; startblit(); - video_wait_for_blit(); vid_apis[vid_api].resize(x, y); endblit(); } @@ -764,7 +762,6 @@ plat_vidapi_enable(int enable) if (!vid_api_inited || !vid_apis[vid_api].enable) return; - video_wait_for_blit(); vid_apis[vid_api].enable(enable != 0); if (! i) @@ -803,7 +800,6 @@ plat_setfullscreen(int on) } /* OK, claim the video. */ - video_wait_for_blit(); win_mouse_close(); /* Close the current mode, and open the new one. */ diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 0cc399117..2b8623ce2 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -166,7 +166,6 @@ static void video_toggle_option(HMENU h, int *val, int id) { startblit(); - video_wait_for_blit(); *val ^= 1; CheckMenuItem(h, id, *val ? MF_CHECKED : MF_UNCHECKED); endblit(); @@ -1467,8 +1466,6 @@ plat_resize(int x, int y) /* First, see if we should resize the UI window. */ if (!vid_resize) { - video_wait_for_blit(); - /* scale the screen base on DPI */ if (dpi_scale) {