From 0ba8dd4d0d4a8a0b2533ba868c4312a78c682c41 Mon Sep 17 00:00:00 2001 From: EngiNerd89 Date: Thu, 7 Jan 2021 23:30:19 +0100 Subject: [PATCH] Fixed most bugs in Olivetti machines. --- src/device/keyboard_at.c | 1 - src/device/keyboard_xt.c | 4 +- src/device/olivetti_m290_registers.c | 117 +++++++++++++++++++++++++++ src/include/86box/chipset.h | 1 + src/machine/m_at_286_386sx.c | 23 +----- src/machine/m_xt_olivetti.c | 1 + src/machine/machine_table.c | 2 +- src/win/Makefile.mingw | 2 +- 8 files changed, 126 insertions(+), 25 deletions(-) create mode 100644 src/device/olivetti_m290_registers.c diff --git a/src/device/keyboard_at.c b/src/device/keyboard_at.c index 159ca6702..ac59b3036 100644 --- a/src/device/keyboard_at.c +++ b/src/device/keyboard_at.c @@ -2136,7 +2136,6 @@ kbd_read(uint16_t port, void *priv) ret |= 0x2; /* 0x10 would be 40x25 */ else ret |= 0x0; - ret = 0xff; } else { /* bit 2 always on */ ret |= 0x4; diff --git a/src/device/keyboard_xt.c b/src/device/keyboard_xt.c index 69360e00c..57f6788fb 100644 --- a/src/device/keyboard_xt.c +++ b/src/device/keyboard_xt.c @@ -24,6 +24,8 @@ #include #include #include +#include +#define HAVE_STDARG_H #include #include <86box/86box.h> #include <86box/device.h> @@ -598,7 +600,7 @@ kbd_read(uint16_t port, void *priv) ret = ((mem_size-64) / 32) >> 4; } else if (kbd->type == 8 || kbd->type == 9) { - /* Olivetti M19 or Zenith Data Systems Z-151*/ + /* Olivetti M19 or Zenith Data Systems Z-151 */ if (kbd->pb & 0x04) ret = kbd->pd & 0xbf; else diff --git a/src/device/olivetti_m290_registers.c b/src/device/olivetti_m290_registers.c new file mode 100644 index 000000000..abe931c91 --- /dev/null +++ b/src/device/olivetti_m290_registers.c @@ -0,0 +1,117 @@ +/* + * 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 the Olivetti M290 registers Readout + * + * Authors: EngiNerd + * + * Copyright 2020-2021 EngiNerd + */ + + +#include +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include "cpu.h" +#include <86box/timer.h> +#include <86box/io.h> +#include <86box/device.h> +#include <86box/chipset.h> +#include <86box/video.h> + +typedef struct +{ + uint8_t reg_067; + uint8_t reg_069; +} olivetti_m290_registers_t; + +#ifdef ENABLE_OLIVETTI_M290_REGISTERS_LOG +int olivetti_m290_registers_do_log = ENABLE_OLIVETTI_M290_REGISTERS_LOG; +static void +olivetti_m290_registers_log(const char *fmt, ...) +{ + va_list ap; + + if (olivetti_m290_registers_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +#define olivetti_m290_registers_log(fmt, ...) +#endif + +static void +olivetti_m290_registers_write(uint16_t addr, uint8_t val, void *priv) +{ + olivetti_m290_registers_t *dev = (olivetti_m290_registers_t *) priv; + olivetti_m290_registers_log("Olivetti M290 registers: Write %02x at %02x\n", val, addr); + switch (addr) { + case 0x067: + dev->reg_067 = val; + break; + case 0x069: + dev->reg_069 = val; + break; + } +} + +static uint8_t +olivetti_m290_registers_read(uint16_t addr, void *priv) +{ + olivetti_m290_registers_t *dev = (olivetti_m290_registers_t *) priv; + uint8_t ret = 0xff; + switch (addr) { + case 0x067: + ret = dev->reg_067; + break; + case 0x069: + ret = dev->reg_069; + break; + } + olivetti_m290_registers_log("Olivetti M290 registers: Read %02x at %02x\n", ret, addr); + return ret; +} + + +static void +olivetti_m290_registers_close(void *priv) +{ + olivetti_m290_registers_t *dev = (olivetti_m290_registers_t *) priv; + + free(dev); +} + +static void * +olivetti_m290_registers_init(const device_t *info) +{ + olivetti_m290_registers_t *dev = (olivetti_m290_registers_t *) malloc(sizeof(olivetti_m290_registers_t)); + memset(dev, 0, sizeof(olivetti_m290_registers_t)); + + dev->reg_067 = 0x0; + dev->reg_069 = 0x0; + + io_sethandler(0x0067, 0x0003, olivetti_m290_registers_read, NULL, NULL, olivetti_m290_registers_write, NULL, NULL, dev); + + return dev; +} + +const device_t olivetti_m290_registers_device = { + "Olivetti M290 registers Readout", + 0, + 0, + olivetti_m290_registers_init, olivetti_m290_registers_close, NULL, + { NULL }, NULL, NULL, + NULL +}; diff --git a/src/include/86box/chipset.h b/src/include/86box/chipset.h index 3e27c3a8b..e68084678 100644 --- a/src/include/86box/chipset.h +++ b/src/include/86box/chipset.h @@ -137,5 +137,6 @@ extern const device_t wd76c10_device; /* Miscellaneous Hardware */ extern const device_t phoenix_486_jumper_device; extern const device_t vpc2007_device; +extern const device_t olivetti_m290_registers_device; #endif /*EMU_CHIPSET_H*/ diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index b6a40ac4c..a259f1d8a 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -557,25 +557,6 @@ machine_at_pja511m_init(const machine_t *model) #endif - -static uint8_t -m290_read(uint16_t port, void *priv) -{ - uint8_t ret = 0x0; - switch (port) { - /* - * port 69: - * dip-switch bank on mainboard (off=1) - * bit 3 - use OCG/CGA display adapter (off) / other display adapter (on) - */ - case 0x69: - if(video_is_cga()) - ret |= 0x8|0x4; - ret |= 0x1|0x2; - } - return (ret); -} - int machine_at_olim290_init(const machine_t *model) { @@ -588,10 +569,10 @@ machine_at_olim290_init(const machine_t *model) return ret; machine_at_common_init(model); - device_add(&keyboard_at_device); + device_add(&keyboard_at_olivetti_device); device_add(&fdc_at_device); - io_sethandler(0x069, 1, m290_read, NULL, NULL, NULL, NULL, NULL, NULL); + device_add(&olivetti_m290_registers_device); return ret; } diff --git a/src/machine/m_xt_olivetti.c b/src/machine/m_xt_olivetti.c index a2f3d2725..27716cd8c 100644 --- a/src/machine/m_xt_olivetti.c +++ b/src/machine/m_xt_olivetti.c @@ -790,6 +790,7 @@ machine_xt_olim240_init(const machine_t *model) * Current bugs: * - 640x400x2 graphics mode not supported (bit 0 of register 0x3de cannot be set) * - optional mouse emulation missing + * - setting CPU speed at 4.77MHz sometimes throws a timer error. If the machine is hard-resetted, the error disappears. */ int machine_xt_olim19_init(const machine_t *model) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 294c3f2ea..21e0db0f0 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -71,7 +71,7 @@ const machine_t machines[] = { { "[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] Olivetti M19", "olivetti_m19", MACHINE_TYPE_8088, CPU_PKG_8088, 0, 0, 7159092, 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 }, diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 7b7bebd19..0cdbc1621 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -624,7 +624,7 @@ DEVOBJ := bugger.o hwm.o hwm_lm75.o hwm_lm78.o hwm_gl518sm.o hwm_vt82c686.o ibm mouse.o \ mouse_bus.o \ mouse_serial.o mouse_ps2.o \ - phoenix_486_jumper.o + phoenix_486_jumper.o olivetti_m290_registers.o SIOOBJ := sio_acc3221.o \ sio_f82c710.o sio_82091aa.o \