From 45bcbc75fd2ae1eec31154edf4bebaff5d726823 Mon Sep 17 00:00:00 2001 From: Doug Johnson Date: Sun, 6 Aug 2023 20:11:36 -0600 Subject: [PATCH 001/103] networking: add Linux-specific TAP mode to network interface This addition was motivated by my lack of knowledge of VDE and my familiarity with the Linux networking stack. The driver automatically manages the creation of TAP devices and their association with bridges, such that configurations which specify the same bridge will be connected together. It also automatically handles the creation of bridge devices for convenience's sake. --- src/config.c | 9 +- src/include/86box/network.h | 5 +- src/network/CMakeLists.txt | 9 + src/network/net_tap.c | 353 ++++++++++++++++++++++++++++++++++ src/network/network.c | 6 + src/qt/qt_mediamenu.cpp | 3 + src/qt/qt_settingsnetwork.cpp | 18 +- src/qt/qt_settingsnetwork.ui | 78 ++++++-- 8 files changed, 463 insertions(+), 18 deletions(-) create mode 100644 src/network/net_tap.c diff --git a/src/config.c b/src/config.c index 2f1561f18..8284fec6d 100644 --- a/src/config.c +++ b/src/config.c @@ -660,6 +660,8 @@ load_network(void) nc->net_type = NET_TYPE_SLIRP; else if (!strcmp(p, "vde") || !strcmp(p, "2")) nc->net_type = NET_TYPE_VDE; + else if (!strcmp(p, "tap") || !strcmp(p, "3")) + nc->net_type = NET_TYPE_TAP; else nc->net_type = NET_TYPE_NONE; } else @@ -706,11 +708,12 @@ load_network(void) nc->net_type = NET_TYPE_SLIRP; else if (!strcmp(p, "vde") || !strcmp(p, "2")) nc->net_type = NET_TYPE_VDE; + else if (!strcmp(p, "tap") || !strcmp(p, "3")) + nc->net_type = NET_TYPE_TAP; else nc->net_type = NET_TYPE_NONE; } else nc->net_type = NET_TYPE_NONE; - sprintf(temp, "net_%02i_host_device", c + 1); p = ini_section_get_string(cat, temp, NULL); if (p != NULL) { @@ -2309,7 +2312,9 @@ save_network(void) case NET_TYPE_VDE: ini_section_set_string(cat, temp, "vde"); break; - + case NET_TYPE_TAP: + ini_section_set_string(cat, temp, "tap"); + break; default: break; } diff --git a/src/include/86box/network.h b/src/include/86box/network.h index fa6408790..ec8c70abb 100644 --- a/src/include/86box/network.h +++ b/src/include/86box/network.h @@ -52,6 +52,7 @@ #define NET_TYPE_SLIRP 1 /* use the SLiRP port forwarder */ #define NET_TYPE_PCAP 2 /* use the (Win)Pcap API */ #define NET_TYPE_VDE 3 /* use the VDE plug API */ +#define NET_TYPE_TAP 4 /* use a linux TAP device */ #define NET_MAX_FRAME 1518 /* Queue size must be a power of 2 */ @@ -125,6 +126,7 @@ typedef struct netdrv_t { extern const netdrv_t net_pcap_drv; extern const netdrv_t net_slirp_drv; extern const netdrv_t net_vde_drv; +extern const netdrv_t net_tap_drv; extern const netdrv_t net_null_drv; struct _netcard_t { @@ -154,10 +156,11 @@ typedef struct { int has_slirp; int has_pcap; int has_vde; + int has_tap; } network_devmap_t; -#define HAS_NOSLIRP_NET(x) (x.has_pcap || x.has_vde) +#define HAS_NOSLIRP_NET(x) (x.has_pcap || x.has_vde || x.has_tap) #ifdef __cplusplus extern "C" { diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 0d42cbd8d..cbdff7b1d 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -67,5 +67,14 @@ if (UNIX) endif() endif() endif() +if (UNIX AND NOT APPLE) # Support for TAP on Linux and BSD, supposedly. + find_path(HAS_TAP "linux/if_tun.h" PATHS ${TAP_INCLUDE_DIR} "/usr/include /usr/local/include" "/opt/homebrew/include" ) + if(HAS_TAP) + add_compile_definitions(HAS_TAP) + list(APPEND net_sources net_tap.c) + else() + message(WARNING "TAP support not available. Are you on some BSD?") + endif() +endif() add_library(net OBJECT ${net_sources}) diff --git a/src/network/net_tap.c b/src/network/net_tap.c new file mode 100644 index 000000000..762f68b60 --- /dev/null +++ b/src/network/net_tap.c @@ -0,0 +1,353 @@ +/* + * 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. + * + * Linux TAP network interface for 86box. + * + * This file was created by looking at the VDE network backend + * as a reference, credit to jguillaumes. + * + * Authors: Doug Johnson + * + * + * Copyright 2023 Doug Johnson + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the entire + * above notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names + * of its contributors may be used to endorse or promote + * products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef _WIN32 +# error TAP networking is only supported on Linux +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define HAVE_STDARG_H + +#include <86box/86box.h> +#include <86box/device.h> +#include <86box/plat.h> +#include <86box/plat_dynld.h> +#include <86box/thread.h> +#include <86box/timer.h> +#include <86box/network.h> +#include <86box/net_event.h> + +typedef struct net_tap_t { + int fd; // tap device file descriptor + netcard_t *card; + thread_t *poll_tid; + net_evt_t tx_event; + net_evt_t stop_event; + netpkt_t pkt_rx; + netpkt_t pkts_tx[NET_QUEUE_LEN]; +} net_tap_t; + +#ifdef ENABLE_TAP_LOG +int tap_do_log = ENABLE_TAP_LOG; + + +static void tap_logv(const char *fmt, va_list ap) +{ + if (tap_do_log) { + pclog_ex(fmt, ap); + } +} + +static void tap_log(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + if (tap_do_log) { + va_start(ap, fmt); + tap_logv(fmt, ap); + va_end(ap); + } + va_end(ap); +} + +#else +# define tap_log(...) \ + do { \ + } while (0) +# define tap_logv(...) \ + do { \ + } while (0) +#endif + +static void net_tap_thread(void *priv) { + enum { + NET_EVENT_STOP = 0, + NET_EVENT_TX, + NET_EVENT_RX, + NET_EVENT_TAP, + NET_EVENT_MAX, + }; + net_tap_t *tap = priv; + tap_log("TAP: poll thread started.\n"); + struct pollfd pfd[NET_EVENT_MAX]; + pfd[NET_EVENT_STOP].fd = net_event_get_fd(&tap->stop_event); + pfd[NET_EVENT_STOP].events = POLLIN | POLLPRI; + + pfd[NET_EVENT_TX].fd = net_event_get_fd(&tap->tx_event); + pfd[NET_EVENT_TX].events = POLLIN | POLLPRI; + + pfd[NET_EVENT_RX].fd = tap->fd; + pfd[NET_EVENT_RX].events = POLLIN | POLLPRI; + + pfd[NET_EVENT_TAP].fd = tap->fd; + pfd[NET_EVENT_TAP].events = POLLERR | POLLHUP | POLLPRI; + fcntl(tap->fd, F_SETFL, O_NONBLOCK); + while(1) { + ssize_t ret = poll(pfd, NET_EVENT_MAX, -1); + if (ret < 0) { + tap_log("TAP: poll error: %s\n", strerror(errno)); + net_event_set(&tap->stop_event); + break; + } + if (pfd[NET_EVENT_TAP].revents) { + tap_log("TAP: tap close/error event received.\n"); + net_event_set(&tap->stop_event); + } + if (pfd[NET_EVENT_TX].revents & POLLIN) { + net_event_clear(&tap->tx_event); + int packets = network_tx_popv(tap->card, tap->pkts_tx, + NET_QUEUE_LEN); + for(int i = 0; i < packets; i++) { + netpkt_t *pkt = &tap->pkts_tx[i]; + ssize_t ret = write(tap->fd, pkt->data, pkt->len); + if (ret < 0) { + tap_log("TAP: write error: %s\n", strerror(errno)); + } + } + } + if (pfd[NET_EVENT_RX].revents & POLLIN) { + ssize_t len = read(tap->fd, tap->pkt_rx.data, NET_MAX_FRAME); + if (len < 0) { + tap_log("TAP: read error: %s\n", strerror(errno)); + continue; + } + tap->pkt_rx.len = len; + network_rx_put_pkt(tap->card, &tap->pkt_rx); + } + if (pfd[NET_EVENT_STOP].revents & POLLIN) { + net_event_clear(&tap->stop_event); + break; + } + } +} + +void net_tap_close(void *priv) +{ + if (!priv) { + return; + } + net_tap_t *tap = priv; + tap_log("TAP: closing.\n"); + net_event_set(&tap->stop_event); + tap_log("TAP: waiting for poll thread to exit.\n"); + thread_wait(tap->poll_tid); + tap_log("TAP: poll thread exited.\n"); + for(int i = 0; i < NET_QUEUE_LEN; i++) { + free(tap->pkts_tx[i].data); + } + free(tap->pkt_rx.data); + if (tap->fd >= 0) { + close(tap->fd); + } + free(tap); +} + +void net_tap_error(char *errbuf, const char* format, ...) +{ + va_list ap; + va_start(ap, format); + vsnprintf(errbuf, NET_DRV_ERRBUF_SIZE, format, ap); + tap_log("TAP: %s", errbuf); + va_end(ap); +} + +// Error handling macro for the many ioctl calls we use in net_tap_alloc +#define ioctl_or_fail(fd, request, argp) \ + do { \ + if ((err = ioctl(fd, request, argp)) < 0) { \ + tap_log("TAP: ioctl " #request " error: %s\n", strerror(errno)); \ + goto fail; \ + } \ + } while (0) + +// Returns -ERRNO so we can get an idea what's wrong +int net_tap_alloc(const uint8_t *mac_addr, const char* bridge_dev) +{ + int fd; + struct ifreq ifr = {0}; + if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { + tap_log("TAP: open error: %s\n", strerror(errno)); + return -errno; + } + ifr.ifr_flags = IFF_TAP | IFF_NO_PI; + int err; + if ((err = ioctl(fd, TUNSETIFF, &ifr)) < 0) { + tap_log("TAP: ioctl TUNSETIFF error: %s\n", strerror(errno)); + close(fd); + return -errno; + } + // Create a socket for ioctl operations + int sock; + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + tap_log("TAP: socket error: %s\n", strerror(errno)); + close(fd); + return -errno; + } + // Bring the interface up + tap_log("TAP: Bringing interface '%s' up.\n", ifr.ifr_name); + ifr.ifr_flags = IFF_UP; + ioctl_or_fail(sock, SIOCSIFFLAGS, &ifr); + // Add interface to bridge, if specified + if (bridge_dev && bridge_dev[0] != '\0') { + // First see if the bridge exists + struct ifreq ifr_bridge; + //NOTE strncpy does not null terminate if the string is too long, I use + // snprintf or strlcpy instead + //strncpy(ifr_bridge.ifr_name, bridge_dev, IFNAMSIZ); + snprintf(ifr_bridge.ifr_name, IFNAMSIZ, "%s", bridge_dev); + if ((err = ioctl(sock, SIOCGIFINDEX, &ifr_bridge)) < 0) { + if (errno != ENODEV) { + tap_log("TAP: ioctl SIOCGIFINDEX error: %s\n", strerror(errno)); + goto fail; + } else { + // Create the bridge + ioctl_or_fail(sock, SIOCBRADDBR, &ifr_bridge); + // Set the bridge up + ifr_bridge.ifr_flags = IFF_UP; + ioctl_or_fail(sock, SIOCSIFFLAGS, &ifr_bridge); + } + } + // Get TAP index + ioctl_or_fail(sock, SIOCGIFINDEX, &ifr); + // Add the tap device to the bridge + ifr_bridge.ifr_ifindex = ifr.ifr_ifindex; + ioctl_or_fail(sock, SIOCBRADDIF, &ifr_bridge); + } + // close the socket we used for ioctl operations + close(sock); + tap_log("Allocated tap device %s\n", ifr.ifr_name); + return fd; + // cleanup point used by ioctl_or_fail macro +fail: + close(sock); + close(fd); + return -errno; +} + +void net_tap_in_available(void *priv) +{ + net_tap_t *tap = priv; + net_event_set(&tap->tx_event); +} + +void * +net_tap_init( + const netcard_t *card, + const uint8_t *mac_addr, + void *priv, + char *netdrv_errbuf) +{ + const char *bridge_dev = (void *) priv; + int tap_fd = net_tap_alloc(mac_addr, bridge_dev); + if (tap_fd < 0) { + if (tap_fd == -EPERM) { + net_tap_error( + netdrv_errbuf, + "No permissions to allocate tap device. " + "Try adding NET_CAP_ADMIN,NET_CAP_RAW to 86box (" + "sudo setcap 'CAP_NET_RAW,CAP_NET_ADMIN=eip')"); + } else { + net_tap_error( + netdrv_errbuf, + "Unable to allocate TAP device: %s", + strerror(-tap_fd)); + } + return NULL; + } + if (bridge_dev && bridge_dev[0] != '\0') { + } + net_tap_t *tap = calloc(1, sizeof(net_tap_t)); + if (!tap) { + goto alloc_fail; + } + tap->pkt_rx.data = calloc(1, NET_MAX_FRAME); + if (!tap->pkt_rx.data) { + goto alloc_fail; + } + for(int i = 0; i < NET_QUEUE_LEN; i++) { + tap->pkts_tx[i].data = calloc(1, NET_MAX_FRAME); + if (!tap->pkts_tx[i].data) { + goto alloc_fail; + } + } + tap->fd = tap_fd; + tap->card = (netcard_t *) card; + net_event_init(&tap->tx_event); + net_event_init(&tap->stop_event); + tap->poll_tid = thread_create(net_tap_thread, tap); + return tap; +alloc_fail: + net_tap_error(netdrv_errbuf, "Failed to allocate memory"); + close(tap_fd); + free(tap); + return NULL; +} + +const netdrv_t net_tap_drv = { + &net_tap_in_available, + &net_tap_init, + &net_tap_close, + NULL +}; diff --git a/src/network/network.c b/src/network/network.c index 7c02609ae..9ad502cfb 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -480,6 +480,12 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin card->host_drv = net_vde_drv; card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name, net_drv_error); break; +#endif +#ifdef HAS_TAP + case NET_TYPE_TAP: + card->host_drv = net_tap_drv; + card->host_drv.priv = card->host_drv.init(card, mac, net_cards_conf[net_card_current].host_dev_name, net_drv_error); + break; #endif default: card->host_drv.priv = NULL; diff --git a/src/qt/qt_mediamenu.cpp b/src/qt/qt_mediamenu.cpp index 1fa5283d2..41687c925 100644 --- a/src/qt/qt_mediamenu.cpp +++ b/src/qt/qt_mediamenu.cpp @@ -1061,6 +1061,9 @@ MediaMenu::nicUpdateMenu(int i) case NET_TYPE_VDE: netType = "VDE"; break; + case NET_TYPE_TAP: + netType = "TAP"; + break; } QString devName = DeviceConfig::DeviceName(network_card_getdevice(net_cards_conf[i].device_num), network_card_get_internal_name(net_cards_conf[i].device_num), 1); diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 2aa3705fd..4411d4d4c 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -38,12 +38,13 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) auto *intf_cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); auto *conf_btn = findChild(QString("pushButtonConf%1").arg(i + 1)); auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); - + auto *bridge_line = findChild(QString("bridgeTAPNIC%1").arg(i + 1)); int netType = net_type_cbox->currentData().toInt(); bool adaptersEnabled = netType == NET_TYPE_NONE || netType == NET_TYPE_SLIRP || netType == NET_TYPE_VDE - || (netType == NET_TYPE_PCAP && intf_cbox->currentData().toInt() > 0); + || (netType == NET_TYPE_PCAP && intf_cbox->currentData().toInt() > 0) + || netType == NET_TYPE_TAP; intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP); nic_cbox->setEnabled(adaptersEnabled); @@ -54,6 +55,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) else conf_btn->setEnabled(adaptersEnabled && network_card_has_config(nic_cbox->currentData().toInt())); socket_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_VDE); + bridge_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_TAP); } } @@ -86,6 +88,7 @@ SettingsNetwork::save() for (int i = 0; i < NET_CARD_MAX; ++i) { auto *cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); + auto *bridge_line = findChild(QString("bridgeTAPNIC%1").arg(i + 1)); net_cards_conf[i].device_num = cbox->currentData().toInt(); cbox = findChild(QString("comboBoxNet%1").arg(i + 1)); net_cards_conf[i].net_type = cbox->currentData().toInt(); @@ -95,6 +98,8 @@ SettingsNetwork::save() strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1); } else if (net_cards_conf[i].net_type == NET_TYPE_VDE) { strncpy(net_cards_conf[i].host_dev_name, socket_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); + } else if (net_cards_conf[i].net_type == NET_TYPE_TAP) { + strncpy(net_cards_conf[i].host_dev_name, bridge_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); } } } @@ -152,7 +157,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) if (network_devmap.has_vde) { Models::AddEntry(model, "VDE", NET_TYPE_VDE); } - + Models::AddEntry(model, "TAP", NET_TYPE_TAP); model->removeRows(0, removeRows); cbox->setCurrentIndex(net_cards_conf[i].net_type); @@ -171,12 +176,17 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) } model->removeRows(0, removeRows); cbox->setCurrentIndex(selectedRow); - } + } if (net_cards_conf[i].net_type == NET_TYPE_VDE) { QString currentVdeSocket = net_cards_conf[i].host_dev_name; auto editline = findChild(QString("socketVDENIC%1").arg(i+1)); editline->setText(currentVdeSocket); } + else if (net_cards_conf[i].net_type == NET_TYPE_TAP) { + QString currentTapDevice = net_cards_conf[i].host_dev_name; + auto editline = findChild(QString("bridgeTAPNIC%1").arg(i+1)); + editline->setText(currentTapDevice); + } } } diff --git a/src/qt/qt_settingsnetwork.ui b/src/qt/qt_settingsnetwork.ui index 8f1eb5a79..efb25a16a 100644 --- a/src/qt/qt_settingsnetwork.ui +++ b/src/qt/qt_settingsnetwork.ui @@ -144,7 +144,21 @@ - + + + + TAP Bridge Device + + + + + + + 127 + + + + Qt::Vertical @@ -259,6 +273,13 @@ + + + + 127 + + + @@ -266,7 +287,14 @@ - + + + + TAP Bridge Device + + + + Qt::Vertical @@ -394,7 +422,21 @@ - + + + + TAP Bridge Device + + + + + + + 127 + + + + Qt::Vertical @@ -508,13 +550,6 @@ - - - - 127 - - - @@ -522,7 +557,28 @@ - + + + + 127 + + + + + + + TAP Bridge Device + + + + + + + 127 + + + + Qt::Vertical From f4485b595731d307e4f28deb50288e7cc36b1abf Mon Sep 17 00:00:00 2001 From: Doug Johnson Date: Wed, 3 Jan 2024 20:39:15 -0700 Subject: [PATCH 002/103] Add address sanitizer support for debugging double free --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d7b3f6f0..f9f39a8d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,7 @@ option(GDBSTUB "Enable GDB stub server for debugging" option(DEV_BRANCH "Development branch" OFF) option(DISCORD "Discord Rich Presence support" ON) option(DEBUGREGS486 "Enable debug register opeartion on 486+ CPUs" OFF) +option(LIBASAN "Enable compilation with the addresss sanitizer" OFF) if(WIN32) set(QT ON) @@ -212,4 +213,10 @@ if(NOT EMU_COPYRIGHT_YEAR) set(EMU_COPYRIGHT_YEAR 2024) endif() +# Libasan +if(LIBASAN) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) +endif() + add_subdirectory(src) From bba8f4d499633915d7f6bbe56de049d10cead607 Mon Sep 17 00:00:00 2001 From: starfrost013 Date: Sat, 21 Jun 2025 00:39:50 +0100 Subject: [PATCH 003/103] Remove various unused ega_t fields and lots of unused 8514 stuff --- src/include/86box/vid_8514a.h | 39 ++--------- src/include/86box/vid_ega.h | 127 ++++++++++++++++------------------ src/include/86box/vid_svga.h | 1 - src/video/vid_8514a.c | 13 ++-- src/video/vid_ati_mach64.c | 8 --- src/video/vid_ati_mach8.c | 60 ++++++++-------- src/video/vid_ega.c | 5 -- src/video/vid_mga.c | 7 -- src/video/vid_ps55da2.c | 3 - src/video/vid_s3.c | 8 --- src/video/vid_svga.c | 29 -------- 11 files changed, 101 insertions(+), 199 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 9d19d916c..4b81e56c0 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -18,6 +18,8 @@ #ifndef VIDEO_8514A_H #define VIDEO_8514A_H +#include + #define INT_VSY (1 << 0) #define INT_GE_BSY (1 << 1) #define INT_FIFO_OVR (1 << 2) @@ -92,18 +94,14 @@ typedef struct ibm8514_t { int dac_r; int dac_g; int dac_b; - int internal_pitch; int hwcursor_on; - int modechange; uint64_t dispontime; uint64_t dispofftime; struct { uint16_t subsys_cntl; - uint16_t setup_md; uint16_t advfunc_cntl; - uint16_t advfunc_cntl_old; uint16_t cur_y; uint16_t cur_x; int16_t destx; @@ -132,35 +130,24 @@ typedef struct ibm8514_t { int16_t clip_left; int16_t clip_top; uint8_t pix_trans[2]; - int poly_draw; int ssv_state; - int x1; - int x2; - int x3; - int y1; - int y2; + int temp_cnt; - int16_t dx_ibm; - int16_t dy_ibm; int16_t cx; - int16_t cx_back; int16_t cy; - int16_t oldcx; + /* oldcx was not used! */ int16_t oldcy; int16_t sx; int16_t sy; int16_t dx; int16_t dy; - int16_t err; uint32_t src; uint32_t dest; int x_count; - int xx_count; int y_count; int input; int input2; int output; - int output2; int ssv_len; int ssv_len_back; @@ -179,20 +166,12 @@ typedef struct ibm8514_t { uint32_t dst_ge_offset; uint16_t src_pitch; uint16_t dst_pitch; - int64_t cur_x_24bpp; - int64_t cur_y_24bpp; - int64_t dest_x_24bpp; - int64_t dest_y_24bpp; } accel; - uint16_t test; int h_blankstart; - int h_blank_end_val; int hblankstart; - int hblank_end_val; int hblankend; int hblank_ext; - int hblank_sub; int v_total_reg; int v_total; @@ -202,12 +181,10 @@ typedef struct ibm8514_t { int split; int h_disp; int h_total; - int h_sync_width; int h_disp_time; int rowoffset; int dispon; - int hdisp_on; - int linecountff; + int hdispon; int vc; int linepos; int oddeven; @@ -241,9 +218,7 @@ typedef struct ibm8514_t { int vsyncwidth; int vtotal; int v_disp; - int v_disp2; int vdisp; - int vdisp2; int disp_cntl; int interlace; uint16_t subsys_cntl; @@ -255,15 +230,15 @@ typedef struct ibm8514_t { int blitter_busy; uint64_t blitter_time; - uint64_t status_time; int pitch; int ext_pitch; int ext_crt_pitch; ibm8514_extensions_t extensions; int onboard; int linear; + bool vram_is_512k; + uint32_t vram_amount; - int vram_512k_8514; int vendor_mode; int _8514on; int _8514crt; diff --git a/src/include/86box/vid_ega.h b/src/include/86box/vid_ega.h index beef6f98d..caa8a63d5 100644 --- a/src/include/86box/vid_ega.h +++ b/src/include/86box/vid_ega.h @@ -13,14 +13,18 @@ * * Authors: Sarah Walker, * Miran Grca, + * Connor Hyde / starfrost, * * Copyright 2008-2020 Sarah Walker. * Copyright 2016-2020 Miran Grca. + * Copyright 2025 Connor Hyde. */ #ifndef VIDEO_EGA_H #define VIDEO_EGA_H +#include + #if defined(EMU_MEM_H) && defined(EMU_ROM_H) typedef struct ega_t { mem_mapping_t mapping; @@ -57,65 +61,52 @@ typedef struct ega_t { uint16_t light_pen; - int vidclock; - int fast; - int extvram; - int vres; - int readmode; - int writemode; - int readplane; - int vrammask; - int chain4; - int chain2_read; - int chain2_write; - int cursorvisible; - int oddeven_page; - int oddeven_chain; - int vc; - int real_vc; - int scanline; - int dispon; - int hdisp_on; - int cursoron; - int blink; - int fullchange; - int linepos; - int vslines; - int linecountff; - int oddeven; - int lowres; - int interlace; - int linedbl; - int lindebl; - int rowcount; - int vtotal; - int dispend; - int vsyncstart; - int split; - int hdisp; - int hdisp_old; - int htotal; - int hdisp_time; - int rowoffset; - int vblankstart; - int scrollcache; - int firstline; - int lastline; - int firstline_draw; - int lastline_draw; - int x_add; - int y_add; - int displine; - int res_x; - int res_y; - int bpp; - int index; - int remap_required; - int actual_type; - int chipset; - int mono_display; + int32_t vidclock; + int32_t vres; + int32_t readmode; + int32_t writemode; + int32_t readplane; + int32_t vrammask; + int32_t chain4; + int32_t chain2_read; + int32_t chain2_write; + int32_t cursorvisible; + int32_t vc; + int32_t real_vc; + int32_t scanline; + int32_t dispon; + int32_t cursoron; + int32_t blink; + int32_t fullchange; + int32_t linepos; + int32_t vslines; + int32_t linecountff; + int32_t oddeven; + int32_t interlace; + int32_t linedbl; + int32_t rowcount; + int32_t vtotal; + int32_t dispend; + int32_t vsyncstart; + int32_t split; + int32_t hdisp; + int32_t htotal; + int32_t rowoffset; + int32_t vblankstart; + int32_t scrollcache; + int32_t firstline; + int32_t lastline; + int32_t firstline_draw; + int32_t lastline_draw; + int32_t x_add; + int32_t y_add; + int32_t displine; + int32_t index; + bool remap_required; + int32_t actual_type; + int32_t chipset; - int mda_attr_to_color_table[256][2][2]; + int32_t mda_attr_to_color_table[256][2][2]; uint32_t charseta; uint32_t charsetb; @@ -164,7 +155,7 @@ extern const device_t jega_device; extern const device_t jvga_device; #endif -extern int update_overscan; +extern int32_t update_overscan; #define DISPLAY_RGB 0 #define DISPLAY_COMPOSITE 1 @@ -174,7 +165,7 @@ extern int update_overscan; #define DISPLAY_WHITE 5 #if defined(EMU_MEM_H) && defined(EMU_ROM_H) -extern void ega_init(ega_t *ega, int monitor_type, int is_mono); +extern void ega_init(ega_t *ega, int32_t monitor_type, int32_t is_mono); extern void ega_recalctimings(struct ega_t *ega); extern void ega_recalc_remap_func(struct ega_t *ega); #endif @@ -186,18 +177,18 @@ extern void ega_write(uint32_t addr, uint8_t val, void *priv); extern uint8_t ega_read(uint32_t addr, void *priv); extern void ega_set_type(void *priv, uint32_t local); -extern int firstline_draw; -extern int lastline_draw; -extern int displine; -extern int scanline; +extern int32_t firstline_draw; +extern int32_t lastline_draw; +extern int32_t displine; +extern int32_t scanline; extern uint32_t memaddr; extern uint32_t cursoraddr; -extern int cursorvisible; -extern int cursoron; -extern int cgablink; +extern int32_t cursorvisible; +extern int32_t cursoron; +extern int32_t cgablink; -extern int scrollcache; +extern int32_t scrollcache; extern uint8_t edatlookup[4][4]; extern uint8_t egaremap2bpp[256]; diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index ad9170ad3..77e41273d 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -98,7 +98,6 @@ typedef struct svga_t { int hdisp_time; int rowoffset; int dispon; - int hdisp_on; int vc; int scanline; int linepos; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index 97202340d..d8dc369e2 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -520,7 +520,6 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x92e8: if (len == 2) { - dev->test = val; dev->accel.err_term = val & 0x3fff; if (val & 0x2000) dev->accel.err_term |= ~0x1fff; @@ -790,7 +789,7 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) case 0x92e8: if (len == 2) - temp = dev->test; + temp = dev->accel.err_term; break; case 0x96e8: @@ -968,7 +967,7 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) dev->data_available2 = 0; temp |= INT_FIFO_EMP; } - temp |= (dev->subsys_stat | (dev->vram_512k_8514 ? 0x00 : 0x80)); + temp |= (dev->subsys_stat | (dev->vram_is_512k ? 0x00 : 0x80)); temp |= 0x20; } break; @@ -2430,7 +2429,7 @@ skip_nibble_rect_write: ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { - ibm8514_log("Results c(%d,%d):rdmask=%02x, wrtmask=%02x, mix=%02x, destdat=%02x, nowrite=%d.\n", dev->accel.cx, dev->accel.cy, rd_mask_polygon, wrt_mask, mix_dat, dest_dat, dev->accel.cx_back); + ibm8514_log("Results c(%d,%d):rdmask=%02x, wrtmask=%02x, mix=%02x, destdat=%02x\n", dev->accel.cx, dev->accel.cy, rd_mask_polygon, wrt_mask, mix_dat, dest_dat); WRITE(dev->accel.dest + dev->accel.cx, dest_dat); } } else @@ -3679,7 +3678,6 @@ ibm8514_poll(void *priv) dev->linepos = 1; if (dev->dispon) { - dev->hdisp_on = 1; dev->memaddr &= dev->vram_mask; @@ -3722,7 +3720,6 @@ ibm8514_poll(void *priv) timer_advance_u64(&svga->timer, dev->dispontime); if (dev->dispon) svga->cgastat &= ~1; - dev->hdisp_on = 0; dev->linepos = 0; if (dev->dispon) { @@ -3862,7 +3859,7 @@ ibm8514_recalctimings(svga_t *svga) dev->pitch = 1024; dev->rowoffset = 0x80; - if (dev->vram_512k_8514) { + if (dev->vram_is_512k) { if (dev->h_disp == 640) dev->pitch = 640; } @@ -3947,7 +3944,7 @@ ibm8514_init(const device_t *info) svga->ext8514 = NULL; dev->vram_amount = device_get_config_int("memory"); - dev->vram_512k_8514 = dev->vram_amount == 512; + dev->vram_is_512k = dev->vram_amount == 512; dev->vram_size = dev->vram_amount << 10; dev->vram = calloc(dev->vram_size, 1); dev->changedvram = calloc((dev->vram_size >> 12) + 1, 1); diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 74086dab1..471dacb19 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -255,9 +255,6 @@ typedef struct mach64_t { event_t *wake_fifo_thread; event_t *fifo_not_full_event; - uint64_t blitter_time; - uint64_t status_time; - uint16_t pci_id; uint32_t config_chip_id; uint32_t block_decoded_io; @@ -1189,8 +1186,6 @@ fifo_thread(void *param) thread_reset_event(mach64->wake_fifo_thread); mach64->blitter_busy = 1; while (!FIFO_EMPTY) { - uint64_t start_time = plat_timer_read(); - uint64_t end_time; fifo_entry_t *fifo = &mach64->fifo[mach64->fifo_read_idx & FIFO_MASK]; switch (fifo->addr_type & FIFO_TYPE) { @@ -1213,9 +1208,6 @@ fifo_thread(void *param) if (FIFO_ENTRIES > 0xe000) thread_set_event(mach64->fifo_not_full_event); - - end_time = plat_timer_read(); - mach64->blitter_time += end_time - start_time; } mach64->blitter_busy = 0; } diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 4133b730e..5a767e3fc 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2835,7 +2835,7 @@ ati8514_recalctimings(svga_t *svga) mach_log("cntl=%d, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d.\n", dev->accel.advfunc_cntl & 0x04, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace); - if (dev->vram_512k_8514) { + if (dev->vram_is_512k) { if (dev->h_disp == 640) dev->pitch = 640; else @@ -2917,7 +2917,7 @@ mach_recalctimings(svga_t *svga) mach->accel.crt_offset <<= 2; } - if (ATI_MACH32 && !dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (ATI_MACH32 && !dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { dev->accel.ge_offset <<= 1; mach->accel.crt_offset <<= 1; } @@ -2960,7 +2960,7 @@ mach_recalctimings(svga_t *svga) mach->accel.src_ge_offset <<= 2; mach->accel.dst_ge_offset <<= 2; } - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { mach->accel.src_ge_offset <<= 1; mach->accel.dst_ge_offset <<= 1; } @@ -2979,7 +2979,7 @@ mach_recalctimings(svga_t *svga) else mach->accel.dst_ge_offset <<= 2; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) mach->accel.dst_ge_offset <<= 1; mach->accel.dst_ge_offset -= mach->accel.crt_offset; @@ -2994,7 +2994,7 @@ mach_recalctimings(svga_t *svga) else mach->accel.src_ge_offset <<= 2; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) mach->accel.src_ge_offset <<= 1; mach->accel.src_ge_offset -= mach->accel.crt_offset; @@ -3015,7 +3015,7 @@ mach_recalctimings(svga_t *svga) switch (dev->accel_bpp) { case 8: if ((mach->accel.ext_ge_config & 0x30) == 0x00) { - if (dev->vram_512k_8514) { + if (dev->vram_is_512k) { if (dev->h_disp == 640) dev->pitch = 640; else @@ -3056,7 +3056,7 @@ mach_recalctimings(svga_t *svga) mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 0x03, dev->interlace, svga->hdisp); - if (dev->vram_512k_8514) { + if (dev->vram_is_512k) { if (dev->h_disp == 640) dev->pitch = 640; else @@ -3236,7 +3236,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u dev->v_disp &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d, vdisp2=%d.\n", dev->v_disp, dev->v_disp2); + mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->v_disp); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ @@ -3256,7 +3256,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u dev->v_disp &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d, vdisp2=%d.\n", dev->v_disp, dev->v_disp2); + mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->v_disp); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3594,7 +3594,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } mach->cursor_offset_lo = mach->cursor_offset_lo_reg; dev->hwcursor.addr = ((mach->cursor_offset_lo | (mach->cursor_offset_hi << 16)) << 2); - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) dev->hwcursor.addr <<= 1; break; @@ -3607,7 +3607,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u dev->hwcursor.ena = !!(mach->cursor_offset_hi_reg & 0x8000); mach->cursor_offset_hi = mach->cursor_offset_hi_reg & 0x0f; dev->hwcursor.addr = ((mach->cursor_offset_lo | (mach->cursor_offset_hi << 16)) << 2); - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) dev->hwcursor.addr <<= 1; break; @@ -4794,7 +4794,7 @@ mach_accel_in_call(uint16_t port, mach_t *mach, svga_t *svga, ibm8514_t *dev) temp |= INT_FIFO_EMP; mach_log("Fifo Empty.\n"); } - temp |= (dev->subsys_stat | (dev->vram_512k_8514 ? 0x00 : 0x80)); + temp |= (dev->subsys_stat | (dev->vram_is_512k ? 0x00 : 0x80)); if (mach->accel.ext_ge_config & 0x08) temp |= ((mach->accel.ext_ge_config & 0x07) << 4); else @@ -5231,12 +5231,12 @@ mach32_write_common(uint32_t addr, uint8_t val, int linear, mach_t *mach, svga_t cycles -= svga->monitor->mon_video_timing_write_b; if (linear) { - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; dev->changedvram[addr >> 12] = svga->monitor->mon_changeframecount; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { switch (addr & 0x06) { case 0x00: case 0x06: @@ -5387,7 +5387,7 @@ mach32_write(uint32_t addr, uint8_t val, void *priv) return; } - if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; switch (addr & 0x06) { case 0x00: @@ -5427,7 +5427,7 @@ mach32_writew(uint32_t addr, uint16_t val, void *priv) return; } - if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; if (addr & 0x04) { mach32_write_common(addr - 2, val & 0x0f, 0, mach, svga); @@ -5462,7 +5462,7 @@ mach32_writel(uint32_t addr, uint32_t val, void *priv) return; } - if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; mach32_write_common(addr, val & 0x0f, 0, mach, svga); mach32_write_common(addr + 1, (val >> 4) & 0x0f, 0, mach, svga); @@ -5705,12 +5705,12 @@ mach32_writew_linear(uint32_t addr, uint16_t val, mach_t *mach) ibm8514_t *dev = (ibm8514_t *) svga->dev8514; cycles -= svga->monitor->mon_video_timing_write_w; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; dev->changedvram[addr >> 12] = svga->monitor->mon_changeframecount; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { if (addr & 0x04) { dev->vram[addr - 2] = val & 0x0f; dev->vram[addr - 1] = (val >> 4) & 0x0f; @@ -5734,12 +5734,12 @@ mach32_writel_linear(uint32_t addr, uint32_t val, mach_t *mach) cycles -= svga->monitor->mon_video_timing_write_l; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; dev->changedvram[addr >> 12] = svga->monitor->mon_changeframecount; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { dev->vram[addr] = val & 0x0f; dev->vram[addr + 1] = (val >> 4) & 0x0f; dev->vram[addr + 4] = (val >> 8) & 0x0f; @@ -5765,11 +5765,11 @@ mach32_read_common(uint32_t addr, int linear, mach_t *mach, svga_t *svga) cycles -= svga->monitor->mon_video_timing_read_b; if (linear) { - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { switch ((addr & 0x06) >> 1) { case 0x00: case 0x03: @@ -5879,7 +5879,7 @@ mach32_read(uint32_t addr, void *priv) (void) xga_read_test(addr, svga); addr = (addr & svga->banked_mask) + svga->read_bank; - if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; switch ((addr & 0x06) >> 1) { case 0x00: @@ -5916,7 +5916,7 @@ mach32_readw(uint32_t addr, void *priv) (void) xga_read_test(addr, svga); addr = (addr & svga->banked_mask) + svga->read_bank; - if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; if (addr & 0x04) { ret = mach32_read_common(addr - 2, 0, mach, svga) & 0x0f; @@ -5948,7 +5948,7 @@ mach32_readl(uint32_t addr, void *priv) (void) xga_read_test(addr, svga); addr = (addr & svga->banked_mask) + svga->read_bank; - if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; ret = mach32_read_common(addr, 0, mach, svga) & 0x0f; ret |= (mach32_read_common(addr + 1, 0, mach, svga) << 4); @@ -5976,7 +5976,7 @@ mach32_readw_linear(uint32_t addr, mach_t *mach) uint16_t ret; cycles -= svga->monitor->mon_video_timing_read_w; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; addr &= dev->vram_mask; if (addr & 0x04) { @@ -6004,7 +6004,7 @@ mach32_readl_linear(uint32_t addr, mach_t *mach) uint32_t ret; cycles -= svga->monitor->mon_video_timing_read_l; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; addr &= dev->vram_mask; ret = dev->vram[addr] & 0x0f; @@ -6301,7 +6301,7 @@ mach32_hwcursor_draw(svga_t *svga, int displine) int shift = 0; offset = dev->hwcursor_latch.x - dev->hwcursor_latch.xoff; - if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) shift = 1; mach_log("BPP=%d, displine=%d.\n", dev->accel_bpp, displine); @@ -7070,7 +7070,7 @@ mach8_init(const device_t *info) mach->has_bios = !(info->local & 0xff00); mach->ramdac_type = mach->pci_bus ? device_get_config_int("ramdac") : 1; dev->vram_amount = device_get_config_int("memory"); - dev->vram_512k_8514 = dev->vram_amount == 512; + dev->vram_is_512k = dev->vram_amount == 512; if (ATI_MACH32) { if (mach->pci_bus) { diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 1cfea782c..fba4ce7a8 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -663,7 +663,6 @@ ega_recalctimings(ega_t *ega) ega->hdisp *= (ega->seqregs[1] & 8) ? 16 : 8; ega->render = ega_render_graphics; } - ega->hdisp_old = ega->hdisp; } if (ega->chipset) { @@ -841,7 +840,6 @@ ega_poll(void *priv) ega->linepos = 1; if (ega->dispon) { - ega->hdisp_on = 1; ega->memaddr &= ega->vrammask; if (ega->firstline == 2000) { @@ -897,7 +895,6 @@ ega_poll(void *priv) if (ega->dispon) ega->status &= ~1; - ega->hdisp_on = 0; ega->linepos = 0; if ((ega->scanline == (ega->crtc[11] & 31)) || (ega->scanline == ega->rowcount)) @@ -1539,10 +1536,8 @@ ega_init(ega_t *ega, int monitor_type, int is_mono) old_overscan_color = 0; ega->miscout |= 0x22; - ega->oddeven_page = 0; ega->seqregs[4] |= 2; - ega->extvram = 1; update_overscan = 0; diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index 294e6ce75..e08ee1724 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -474,8 +474,6 @@ typedef struct mystique_t { atomic_uint status; atomic_bool softrap_status_read; - uint64_t blitter_time, status_time; - pc_timer_t softrap_pending_timer, wake_timer; fifo_entry_t fifo[FIFO_SIZE]; @@ -6048,8 +6046,6 @@ static void mystique_start_blit(mystique_t *mystique) { svga_t *svga = &mystique->svga; - uint64_t start_time = plat_timer_read(); - uint64_t end_time; /*Make sure we don't get any artifacts.*/ svga->chain2_write = 0; @@ -6119,9 +6115,6 @@ mystique_start_blit(mystique_t *mystique) fatal("mystique_start_blit: unknown blit %08x\n", mystique->dwgreg.dwgctrl_running & DWGCTRL_OPCODE_MASK); break; } - - end_time = plat_timer_read(); - mystique->blitter_time += end_time - start_time; } static void diff --git a/src/video/vid_ps55da2.c b/src/video/vid_ps55da2.c index 938e4bf6b..29eefabbf 100644 --- a/src/video/vid_ps55da2.c +++ b/src/video/vid_ps55da2.c @@ -356,7 +356,6 @@ typedef struct da2_t { uint64_t da2const; int dispon; - int hdisp_on; uint32_t memaddr, memaddr_backup, cursoraddr; int vc; @@ -3020,7 +3019,6 @@ da2_poll(void *priv) da2->linepos = 1; if (da2->dispon) { - da2->hdisp_on = 1; da2->memaddr &= da2->vram_display_mask; if (da2->firstline == 2000) { @@ -3052,7 +3050,6 @@ da2_poll(void *priv) if (da2->dispon) da2->cgastat &= ~1; - da2->hdisp_on = 0; da2->linepos = 0; if (da2->scanline == (da2->crtc[LC_CURSOR_ROW_END] & 31)) diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index d0495dca0..b222957eb 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -375,8 +375,6 @@ typedef struct s3_t { event_t *fifo_not_full_event; atomic_int blitter_busy; - uint64_t blitter_time; - uint64_t status_time; uint8_t subsys_cntl, subsys_stat; @@ -9698,8 +9696,6 @@ static void fifo_thread(void *param) { s3_t *s3 = (s3_t *) param; - uint64_t start_time; - uint64_t end_time; while (s3->fifo_thread_run) { thread_set_event(s3->fifo_not_full_event); @@ -9707,7 +9703,6 @@ fifo_thread(void *param) thread_reset_event(s3->wake_fifo_thread); s3->blitter_busy = 1; while (!FIFO_EMPTY) { - start_time = plat_timer_read(); fifo_entry_t *fifo = &s3->fifo[s3->fifo_read_idx & FIFO_MASK]; switch (fifo->addr_type & FIFO_TYPE) { @@ -9739,9 +9734,6 @@ fifo_thread(void *param) if (FIFO_ENTRIES > 0xe000) thread_set_event(s3->fifo_not_full_event); - - end_time = plat_timer_read(); - s3->blitter_time += (end_time - start_time); } s3->blitter_busy = 0; s3->subsys_stat |= INT_FIFO_EMP; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index cf3a22c5c..2fed471f9 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -972,33 +972,6 @@ svga_recalctimings(svga_t *svga) } } -#ifdef TBD - if (ibm8514_active && (svga->dev8514 != NULL)) { - if (dev->on) { - uint32_t dot8514 = dev->h_blankstart; - uint32_t adj_dot8514 = dev->h_blankstart; - uint32_t eff_mask8514 = 0x0000001f; - dev->hblank_sub = 0; - - while (adj_dot8514 < (dev->h_total << 1)) { - if (dot8514 == dev->h_total) - dot8514 = 0; - - if (adj_dot8514 >= dev->h_total) - dev->hblank_sub++; - - if ((dot8514 & eff_mask8514) == (dev->h_blank_end_val & eff_mask8514)) - break; - - dot8514++; - adj_dot8514++; - } - - dev->h_disp -= dev->hblank_sub; - } - } -#endif - if (svga->vblankstart < svga->dispend) { svga_log("DISPEND > VBLANKSTART.\n"); svga->dispend = svga->vblankstart; @@ -1281,7 +1254,6 @@ svga_poll(void *priv) svga->linepos = 1; if (svga->dispon) { - svga->hdisp_on = 1; svga->memaddr &= svga->vram_display_mask; if (svga->firstline == 2000) { @@ -1328,7 +1300,6 @@ svga_poll(void *priv) if (svga->dispon) svga->cgastat &= ~1; - svga->hdisp_on = 0; svga->linepos = 0; if ((svga->scanline == (svga->crtc[11] & 31)) || (svga->scanline == svga->rowcount)) From adb8b388a8dd848a5692350b39c11bfb7ff1e8c4 Mon Sep 17 00:00:00 2001 From: starfrost013 Date: Sat, 21 Jun 2025 00:55:39 +0100 Subject: [PATCH 004/103] v_disp -> vdisp_latch; get rid of even more unused shit --- src/include/86box/vid_8514a.h | 15 +++---------- src/include/86box/vid_ati_eeprom.h | 2 +- src/include/86box/vid_svga.h | 2 +- src/include/86box/vid_xga.h | 2 +- src/video/ramdac/vid_ramdac_bt48x.c | 2 +- src/video/ramdac/vid_ramdac_ibm_rgb528.c | 2 +- src/video/ramdac/vid_ramdac_tvp3026.c | 6 ++--- src/video/vid_8514a.c | 20 ++++++++--------- src/video/vid_ati_eeprom.c | 12 +++++----- src/video/vid_ati_mach64.c | 6 ++--- src/video/vid_ati_mach8.c | 28 ++++++++++++------------ src/video/vid_chips_69000.c | 2 +- src/video/vid_cl54xx.c | 4 ++-- src/video/vid_et4000w32.c | 2 +- src/video/vid_ht216.c | 2 +- src/video/vid_mga.c | 2 +- src/video/vid_s3.c | 8 +++---- src/video/vid_s3_virge.c | 12 +++++----- src/video/vid_svga.c | 12 +++++----- src/video/vid_tgui9440.c | 2 +- src/video/vid_voodoo_banshee.c | 8 +++---- src/video/vid_xga.c | 6 ++--- 22 files changed, 74 insertions(+), 83 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 4b81e56c0..5d4b262c4 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -40,15 +40,13 @@ typedef enum { } ibm8514_extensions_t; typedef struct hwcursor8514_t { - int ena; + int enable; int x; int y; int xoff; int yoff; int cur_xsize; int cur_ysize; - int v_acc; - int h_acc; uint32_t addr; uint32_t pitch; } hwcursor8514_t; @@ -129,7 +127,6 @@ typedef struct ibm8514_t { uint16_t clip_bottom; int16_t clip_left; int16_t clip_top; - uint8_t pix_trans[2]; int ssv_state; int temp_cnt; @@ -144,7 +141,7 @@ typedef struct ibm8514_t { uint32_t src; uint32_t dest; int x_count; - int y_count; + /* y_count not used */ int input; int input2; int output; @@ -154,13 +151,8 @@ typedef struct ibm8514_t { uint8_t ssv_dir; uint8_t ssv_draw; int odd_in; - int odd_out; - uint16_t scratch; int fill_state; - int xdir; - int ydir; - int linedraw; uint32_t ge_offset; uint32_t src_ge_offset; uint32_t dst_ge_offset; @@ -214,10 +206,9 @@ typedef struct ibm8514_t { int hdisp2; int hdisped; int scanline; - int vsyncstart; int vsyncwidth; int vtotal; - int v_disp; + int vdisp_latch; int vdisp; int disp_cntl; int interlace; diff --git a/src/include/86box/vid_ati_eeprom.h b/src/include/86box/vid_ati_eeprom.h index c52b5bd4b..84e09f946 100644 --- a/src/include/86box/vid_ati_eeprom.h +++ b/src/include/86box/vid_ati_eeprom.h @@ -49,7 +49,7 @@ typedef struct ati_eeprom_t { void ati_eeprom_load(ati_eeprom_t *eeprom, char *fn, int type); void ati_eeprom_load_mach8(ati_eeprom_t *eeprom, char *fn, int mca); void ati_eeprom_load_mach8_vga(ati_eeprom_t *eeprom, char *fn); -void ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat); +void ati_eeprom_write(ati_eeprom_t *eeprom, int enable, int clk, int dat); int ati_eeprom_read(ati_eeprom_t *eeprom); #endif /*VIDEO_ATI_EEPROM_H*/ diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 77e41273d..b6eae1c8a 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -33,7 +33,7 @@ struct monitor_t; typedef struct hwcursor_t { - int ena; + int enable; int x; int y; int xoff; diff --git a/src/include/86box/vid_xga.h b/src/include/86box/vid_xga.h index e72c7af40..a2ef1a530 100644 --- a/src/include/86box/vid_xga.h +++ b/src/include/86box/vid_xga.h @@ -20,7 +20,7 @@ #include <86box/rom.h> typedef struct xga_hwcursor_t { - int ena; + int enable; int x; int y; int xoff; diff --git a/src/video/ramdac/vid_ramdac_bt48x.c b/src/video/ramdac/vid_ramdac_bt48x.c index d608750e3..0a70afdbd 100644 --- a/src/video/ramdac/vid_ramdac_bt48x.c +++ b/src/video/ramdac/vid_ramdac_bt48x.c @@ -161,7 +161,7 @@ bt48x_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svga_ break; case 0x09: /* Command Register 2 (RS value = 1001) */ ramdac->cmd_r2 = val; - svga->dac_hwcursor.ena = !!(val & 0x03); + svga->dac_hwcursor.enable = !!(val & 0x03); bt48x_set_bpp(ramdac, svga); break; case 0x0a: diff --git a/src/video/ramdac/vid_ramdac_ibm_rgb528.c b/src/video/ramdac/vid_ramdac_ibm_rgb528.c index cd7d5c1b6..947c251e9 100644 --- a/src/video/ramdac/vid_ramdac_ibm_rgb528.c +++ b/src/video/ramdac/vid_ramdac_ibm_rgb528.c @@ -631,7 +631,7 @@ ibm_rgb528_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *s } svga->dac_hwcursor.addr = ramdac->smlc_part; svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = (val & 0x04) ? 64 : 32; - svga->dac_hwcursor.ena = ((val & 0x03) != 0x00); + svga->dac_hwcursor.enable = ((val & 0x03) != 0x00); break; case 0x031: if (!updt_cntl) diff --git a/src/video/ramdac/vid_ramdac_tvp3026.c b/src/video/ramdac/vid_ramdac_tvp3026.c index bd5a83fd0..e80aeedab 100644 --- a/src/video/ramdac/vid_ramdac_tvp3026.c +++ b/src/video/ramdac/vid_ramdac_tvp3026.c @@ -170,7 +170,7 @@ tvp3026_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svg svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = 64; svga->dac_hwcursor.x = ramdac->hwc_x - svga->dac_hwcursor.cur_xsize; svga->dac_hwcursor.y = ramdac->hwc_y - svga->dac_hwcursor.cur_ysize; - svga->dac_hwcursor.ena = !!(val & 0x03); + svga->dac_hwcursor.enable = !!(val & 0x03); ramdac->mode = val & 0x03; } break; @@ -182,13 +182,13 @@ tvp3026_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svg svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = 64; svga->dac_hwcursor.x = ramdac->hwc_x - svga->dac_hwcursor.cur_xsize; svga->dac_hwcursor.y = ramdac->hwc_y - svga->dac_hwcursor.cur_ysize; - svga->dac_hwcursor.ena = !!(val & 0x03); + svga->dac_hwcursor.enable = !!(val & 0x03); ramdac->mode = val & 0x03; } else { svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = 64; svga->dac_hwcursor.x = ramdac->hwc_x - svga->dac_hwcursor.cur_xsize; svga->dac_hwcursor.y = ramdac->hwc_y - svga->dac_hwcursor.cur_ysize; - svga->dac_hwcursor.ena = !!(ramdac->dcc & 0x03); + svga->dac_hwcursor.enable = !!(ramdac->dcc & 0x03); ramdac->mode = ramdac->dcc & 0x03; } break; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index d8dc369e2..f911da6be 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -397,21 +397,21 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x16e8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->v_disp = val; - dev->v_disp &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->v_disp); + dev->vdisp_latch = val; + dev->vdisp_latch &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_latch); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->v_disp, val); + WRITE8(port, dev->vdisp_latch, val); } break; case 0x16e9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->v_disp, val >> 8); - dev->v_disp &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->v_disp); + WRITE8(port, dev->vdisp_latch, val >> 8); + dev->vdisp_latch &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_latch); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -3663,12 +3663,12 @@ ibm8514_poll(void *priv) if (dev->on) { ibm8514_log("ON!\n"); if (!dev->linepos) { - if ((dev->displine == ((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y)) && dev->hwcursor_latch.ena) { + if ((dev->displine == ((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y)) && dev->hwcursor_latch.enable) { dev->hwcursor_on = dev->hwcursor_latch.cur_ysize - dev->hwcursor_latch.yoff; dev->hwcursor_oddeven = 0; } - if ((dev->displine == (((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y) + 1)) && dev->hwcursor_latch.ena && dev->interlace) { + if ((dev->displine == (((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y) + 1)) && dev->hwcursor_latch.enable && dev->interlace) { dev->hwcursor_on = dev->hwcursor_latch.cur_ysize - (dev->hwcursor_latch.yoff + 1); dev->hwcursor_oddeven = 1; } @@ -3819,7 +3819,7 @@ ibm8514_recalctimings(svga_t *svga) if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ dev->h_total = 0x9e; - dev->vdisp = (dev->v_disp + 1) >> 1; + dev->vdisp = (dev->vdisp_latch + 1) >> 1; if ((dev->vdisp == 478) || (dev->vdisp == 766)) dev->vdisp += 2; diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index a057f1f39..1efb506d1 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -107,18 +107,18 @@ ati_eeprom_save(ati_eeprom_t *eeprom) } void -ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) +ati_eeprom_write(ati_eeprom_t *eeprom, int enable, int clk, int dat) { - if (!ena) + if (!enable) eeprom->out = 1; if (clk && !eeprom->oldclk) { - if (ena && !eeprom->oldena) { + if (enable && !eeprom->oldena) { eeprom->state = EEPROM_WAIT; eeprom->opcode = 0; eeprom->count = 3; eeprom->out = 1; - } else if (ena) { + } else if (enable) { switch (eeprom->state) { case EEPROM_WAIT: if (!dat) @@ -231,9 +231,9 @@ ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) break; } } - eeprom->oldena = ena; + eeprom->oldena = enable; } else if (!clk && eeprom->oldclk) { - if (ena) { + if (enable) { switch (eeprom->state) { case EEPROM_OUTPUT: eeprom->out = (eeprom->dat & 0x10000) ? 1 : 0; diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 471dacb19..fadf1115f 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -2297,7 +2297,7 @@ mach64_vblank_start(svga_t *svga) svga->overlay.addr = mach64->buf_offset[0] & 0x3ffff8; svga->overlay.pitch = mach64->buf_pitch[0] & 0xfff; - svga->overlay.ena = (mach64->overlay_scale_cntl & OVERLAY_EN) && (overlay_cmp_mix != 1); + svga->overlay.enable = (mach64->overlay_scale_cntl & OVERLAY_EN) && (overlay_cmp_mix != 1); mach64->overlay_v_acc = 0; mach64->scaler_update = 1; @@ -3344,9 +3344,9 @@ mach64_ext_writeb(uint32_t addr, uint8_t val, void *priv) ati_eeprom_write(&mach64->eeprom, mach64->gen_test_cntl & 0x10, mach64->gen_test_cntl & 2, mach64->gen_test_cntl & 1); mach64->gen_test_cntl = (mach64->gen_test_cntl & ~8) | (ati_eeprom_read(&mach64->eeprom) ? 8 : 0); if (mach64->type == MACH64_GX) - svga->dac_hwcursor.ena = !!(mach64->gen_test_cntl & 0x80); + svga->dac_hwcursor.enable = !!(mach64->gen_test_cntl & 0x80); else - svga->hwcursor.ena = !!(mach64->gen_test_cntl & 0x80); + svga->hwcursor.enable = !!(mach64->gen_test_cntl & 0x80); break; case 0xdc: diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 5a767e3fc..4a73d6a8e 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2715,7 +2715,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) dev->hdisp = (dev->hdisped + 1) << 3; - dev->vdisp = (dev->v_disp + 1) >> 1; + dev->vdisp = (dev->vdisp_latch + 1) >> 1; if ((dev->vdisp == 478) || (dev->vdisp == 598) || (dev->vdisp == 766) || (dev->vdisp == 1022)) dev->vdisp += 2; @@ -3232,17 +3232,17 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20) && val) { - dev->v_disp = val; - dev->v_disp &= 0x1fff; + dev->vdisp_latch = val; + dev->vdisp_latch &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->v_disp); + mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->vdisp_latch); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->v_disp, val); - dev->v_disp &= 0x1fff; + WRITE8(port, dev->vdisp_latch, val); + dev->vdisp_latch &= 0x1fff; } } } @@ -3252,11 +3252,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->v_disp, val >> 8); - dev->v_disp &= 0x1fff; + WRITE8(port, dev->vdisp_latch, val >> 8); + dev->vdisp_latch &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->v_disp); + mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->vdisp_latch); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3604,7 +3604,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { WRITE8(port + 1, mach->cursor_offset_hi_reg, val >> 8); } - dev->hwcursor.ena = !!(mach->cursor_offset_hi_reg & 0x8000); + dev->hwcursor.enable = !!(mach->cursor_offset_hi_reg & 0x8000); mach->cursor_offset_hi = mach->cursor_offset_hi_reg & 0x0f; dev->hwcursor.addr = ((mach->cursor_offset_lo | (mach->cursor_offset_hi << 16)) << 2); if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) @@ -4606,13 +4606,13 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in case 0xc6ee: if (len == 2) - temp = dev->v_disp; + temp = dev->vdisp_latch; else - temp = dev->v_disp & 0xff; + temp = dev->vdisp_latch & 0xff; break; case 0xc6ef: if (len == 1) - temp = dev->v_disp >> 8; + temp = dev->vdisp_latch >> 8; break; case 0xcaee: @@ -7246,7 +7246,7 @@ ati8514_init(svga_t *svga, void *ext8514, void *dev8514) dev->accel_bpp = 8; dev->rowoffset = 0x80; dev->hdisped = 0x7f; - dev->v_disp = 0x05ff; + dev->vdisp_latch = 0x05ff; dev->htotal = 0x9d; dev->v_total_reg = 0x0668; dev->v_sync_start = 0x0600; diff --git a/src/video/vid_chips_69000.c b/src/video/vid_chips_69000.c index 70b2b9e16..c63886b04 100644 --- a/src/video/vid_chips_69000.c +++ b/src/video/vid_chips_69000.c @@ -1906,7 +1906,7 @@ chips_69000_write_ext_reg(chips_69000_t* chips, uint8_t val) break; case 0xA0: chips->ext_regs[chips->ext_index] = val; - chips->svga.hwcursor.ena = ((val & 7) == 0b101) || ((val & 7) == 0b1); + chips->svga.hwcursor.enable = ((val & 7) == 0b101) || ((val & 7) == 0b1); chips->svga.hwcursor.cur_xsize = chips->svga.hwcursor.cur_ysize = ((val & 7) == 0b1) ? 32 : 64; break; case 0xA2: diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index e1c02f5a9..a896108d6 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -813,7 +813,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *priv) else svga->overscan_color = svga->pallook[svga->attrregs[0x11]]; svga_recalctimings(svga); - svga->hwcursor.ena = val & CIRRUS_CURSOR_SHOW; + svga->hwcursor.enable = val & CIRRUS_CURSOR_SHOW; if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5422) svga->hwcursor.cur_xsize = svga->hwcursor.cur_ysize = ((svga->crtc[0x27] >= CIRRUS_ID_CLGD5422) && @@ -1244,7 +1244,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *priv) break; case 0x3e: gd54xx->overlay.mode = (val >> 1) & 7; - svga->overlay.ena = (val & 1) != 0; + svga->overlay.enable = (val & 1) != 0; gd54xx_update_overlay(gd54xx); break; diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index 533bd1f28..ca2ee8434 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -277,7 +277,7 @@ et4000w32p_out(uint16_t addr, uint8_t val, void *priv) et4000->regs[et4000->index] = val; svga->hwcursor.x = et4000->regs[0xE0] | ((et4000->regs[0xE1] & 7) << 8); svga->hwcursor.y = et4000->regs[0xE4] | ((et4000->regs[0xE5] & 7) << 8); - svga->hwcursor.ena = !!(et4000->regs[0xF7] & 0x80); + svga->hwcursor.enable = !!(et4000->regs[0xF7] & 0x80); svga->hwcursor.xoff = et4000->regs[0xE2]; svga->hwcursor.yoff = et4000->regs[0xE6]; svga->hwcursor.cur_xsize = svga->hwcursor.cur_ysize = ((et4000->regs[0xEF] & 4) || ((et4000->type == ET4000W32) && (et4000->regs[0xe2] >= 0x1f) && (et4000->regs[0xe6] >= 0x1f))) ? 128 : 64; diff --git a/src/video/vid_ht216.c b/src/video/vid_ht216.c index 3089ae26d..061b70246 100644 --- a/src/video/vid_ht216.c +++ b/src/video/vid_ht216.c @@ -299,7 +299,7 @@ ht216_out(uint16_t addr, uint8_t val, void *priv) break; case 0xa5: - svga->hwcursor.ena = !!(val & 0x80); + svga->hwcursor.enable = !!(val & 0x80); break; case 0xc0: diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index e08ee1724..e5ac55648 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -1380,7 +1380,7 @@ mystique_write_xreg(mystique_t *mystique, int reg, uint8_t val) case XREG_XCURCTRL: mystique->xcurctrl = val; - svga->hwcursor.ena = (val & 3) ? 1 : 0; + svga->hwcursor.enable = (val & 3) ? 1 : 0; break; case XREG_XCURCOL0R: diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index b222957eb..4f890dcdf 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -3037,7 +3037,7 @@ s3_out(uint16_t addr, uint8_t val, void *priv) case 0x45: if ((s3->chip == S3_VISION964) || (s3->chip == S3_VISION968)) break; - svga->hwcursor.ena = val & 1; + svga->hwcursor.enable = val & 1; break; case 0x46: case 0x47: @@ -4442,13 +4442,13 @@ s3_trio64v_recalctimings(svga_t *svga) else svga->overlay.addr = s3->streams.sec_fb0; - svga->overlay.ena = (svga->overlay.x >= 0); + svga->overlay.enable = (svga->overlay.x >= 0); svga->overlay.h_acc = s3->streams.dda_horiz_accumulator; svga->overlay.v_acc = s3->streams.dda_vert_accumulator; svga->rowoffset = s3->streams.pri_stride >> 3; - if (svga->overlay.ena) { - svga->overlay.ena = (((s3->streams.blend_ctrl >> 24) & 7) == 0b000) || + if (svga->overlay.enable) { + svga->overlay.enable = (((s3->streams.blend_ctrl >> 24) & 7) == 0b000) || (((s3->streams.blend_ctrl >> 24) & 7) == 0b101); } switch ((s3->streams.pri_ctrl >> 24) & 0x7) { diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index 9422f69bf..387d5faec 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -584,7 +584,7 @@ s3_virge_out(uint16_t addr, uint8_t val, void *priv) break; case 0x45: - svga->hwcursor.ena = val & 1; + svga->hwcursor.enable = val & 1; break; case 0x46: case 0x47: @@ -965,19 +965,19 @@ s3_virge_recalctimings(svga_t *svga) else svga->overlay.addr = virge->streams.sec_fb0; - svga->overlay.ena = (svga->overlay.x >= 0); + svga->overlay.enable = (svga->overlay.x >= 0); svga->overlay.h_acc = virge->streams.dda_horiz_accumulator; svga->overlay.v_acc = virge->streams.dda_vert_accumulator; if (virge->chip < S3_VIRGEGX2) svga->rowoffset = virge->streams.pri_stride >> 3; - if (virge->chip <= S3_VIRGEDX && svga->overlay.ena) { - svga->overlay.ena = (((virge->streams.blend_ctrl >> 24) & 7) == 0b000) || (((virge->streams.blend_ctrl >> 24) & 7) == 0b101); - } else if (virge->chip >= S3_VIRGEGX2 && svga->overlay.ena) { + if (virge->chip <= S3_VIRGEDX && svga->overlay.enable) { + svga->overlay.enable = (((virge->streams.blend_ctrl >> 24) & 7) == 0b000) || (((virge->streams.blend_ctrl >> 24) & 7) == 0b101); + } else if (virge->chip >= S3_VIRGEGX2 && svga->overlay.enable) { /* 0x20 = Secondary Stream enabled */ /* 0x2000 = Primary Stream enabled */ - svga->overlay.ena = !!(virge->streams.blend_ctrl & 0x20); + svga->overlay.enable = !!(virge->streams.blend_ctrl & 0x20); } if (virge->chip >= S3_VIRGEGX2) { diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 4b80a0eed..54856d9e0 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1223,32 +1223,32 @@ svga_poll(void *priv) svga_log("SVGA Poll.\n"); if (!svga->linepos) { - if (svga->displine == ((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) && svga->hwcursor_latch.ena) { + if (svga->displine == ((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) && svga->hwcursor_latch.enable) { svga->hwcursor_on = svga->hwcursor_latch.cur_ysize - svga->hwcursor_latch.yoff; svga->hwcursor_oddeven = 0; } - if (svga->displine == (((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) + 1) && svga->hwcursor_latch.ena && svga->interlace) { + if (svga->displine == (((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) + 1) && svga->hwcursor_latch.enable && svga->interlace) { svga->hwcursor_on = svga->hwcursor_latch.cur_ysize - (svga->hwcursor_latch.yoff + 1); svga->hwcursor_oddeven = 1; } - if (svga->displine == ((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) && svga->dac_hwcursor_latch.ena) { + if (svga->displine == ((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) && svga->dac_hwcursor_latch.enable) { svga->dac_hwcursor_on = svga->dac_hwcursor_latch.cur_ysize - svga->dac_hwcursor_latch.yoff; svga->dac_hwcursor_oddeven = 0; } - if (svga->displine == (((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) + 1) && svga->dac_hwcursor_latch.ena && svga->interlace) { + if (svga->displine == (((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) + 1) && svga->dac_hwcursor_latch.enable && svga->interlace) { svga->dac_hwcursor_on = svga->dac_hwcursor_latch.cur_ysize - (svga->dac_hwcursor_latch.yoff + 1); svga->dac_hwcursor_oddeven = 1; } - if (svga->displine == svga->overlay_latch.y && svga->overlay_latch.ena) { + if (svga->displine == svga->overlay_latch.y && svga->overlay_latch.enable) { svga->overlay_on = svga->overlay_latch.cur_ysize - svga->overlay_latch.yoff; svga->overlay_oddeven = 0; } - if (svga->displine == svga->overlay_latch.y + 1 && svga->overlay_latch.ena && svga->interlace) { + if (svga->displine == svga->overlay_latch.y + 1 && svga->overlay_latch.enable && svga->interlace) { svga->overlay_on = svga->overlay_latch.cur_ysize - svga->overlay_latch.yoff; svga->overlay_oddeven = 1; } diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index 5cc3a8a78..c0ba06a07 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -530,7 +530,7 @@ tgui_out(uint16_t addr, uint8_t val, void *priv) case 0x50: if (tgui->type >= TGUI_9440) { - svga->hwcursor.ena = !!(val & 0x80); + svga->hwcursor.enable = !!(val & 0x80); svga->hwcursor.cur_xsize = svga->hwcursor.cur_ysize = ((val & 1) ? 64 : 32); } break; diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 4bcf8a479..12cccdccb 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -679,7 +679,7 @@ banshee_recalctimings(svga_t *svga) svga->interlace = !!(banshee->vidProcCfg & VIDPROCCFG_INTERLACE); - svga->overlay.ena = banshee->vidProcCfg & VIDPROCCFG_OVERLAY_ENABLE; + svga->overlay.enable = banshee->vidProcCfg & VIDPROCCFG_OVERLAY_ENABLE; svga->overlay.x = voodoo->overlay.start_x; svga->overlay.y = voodoo->overlay.start_y; @@ -689,8 +689,8 @@ banshee_recalctimings(svga_t *svga) if (banshee->vidProcCfg & VIDPROCCFG_OVERLAY_TILE) svga->overlay.pitch *= 128 * 32; if (svga->overlay.cur_xsize <= 0 || svga->overlay.cur_ysize <= 0) - svga->overlay.ena = 0; - if (svga->overlay.ena) { + svga->overlay.enable = 0; + if (svga->overlay.enable) { #if 0 banshee_log("Overlay enabled : start=%i,%i end=%i,%i size=%i,%i pitch=%x\n", voodoo->overlay.start_x, voodoo->overlay.start_y, @@ -894,7 +894,7 @@ banshee_ext_outl(uint16_t addr, uint32_t val, void *priv) banshee_log("vidProcCfg=%08x\n", val); #endif banshee->overlay_pix_fmt = (val & VIDPROCCFG_OVERLAY_PIX_FORMAT_MASK) >> VIDPROCCFG_OVERLAY_PIX_FORMAT_SHIFT; - svga->hwcursor.ena = val & VIDPROCCFG_HWCURSOR_ENA; + svga->hwcursor.enable = val & VIDPROCCFG_HWCURSOR_ENA; svga->fullchange = changeframecount; svga->lut_map = !(val & VIDPROCCFG_DESKTOP_CLUT_BYPASS) && (svga->bpp < 24); svga_recalctimings(svga); diff --git a/src/video/vid_xga.c b/src/video/vid_xga.c index 8f4dc0d0e..51f842cc5 100644 --- a/src/video/vid_xga.c +++ b/src/video/vid_xga.c @@ -424,7 +424,7 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val) case 0x36: xga->hwc_control = val; - xga->hwcursor.ena = xga->hwc_control & 1; + xga->hwcursor.enable = xga->hwc_control & 1; break; case 0x38: @@ -3092,12 +3092,12 @@ xga_poll(void *priv) xga_log("XGA Poll=%d.\n", xga->on); if (xga->on) { if (!xga->linepos) { - if (xga->displine == xga->hwcursor_latch.y && xga->hwcursor_latch.ena) { + if (xga->displine == xga->hwcursor_latch.y && xga->hwcursor_latch.enable) { xga->hwcursor_on = xga->hwcursor_latch.cur_ysize - ((xga->hwcursor_latch.yoff & 0x20) ? 32 : 0); xga->hwcursor_oddeven = 0; } - if (xga->displine == (xga->hwcursor_latch.y + 1) && xga->hwcursor_latch.ena && xga->interlace) { + if (xga->displine == (xga->hwcursor_latch.y + 1) && xga->hwcursor_latch.enable && xga->interlace) { xga->hwcursor_on = xga->hwcursor_latch.cur_ysize - ((xga->hwcursor_latch.yoff & 0x20) ? 33 : 1); xga->hwcursor_oddeven = 1; } From 7abb8170126ca784cb5acfcf72debe7c08323a72 Mon Sep 17 00:00:00 2001 From: starfrost013 Date: Sat, 21 Jun 2025 01:32:59 +0100 Subject: [PATCH 005/103] clarify vga/8514 separation --- src/include/86box/vid_8514a.h | 34 +++--- src/include/86box/vid_xga.h | 14 +-- src/video/vid_8514a.c | 161 +++++++++++--------------- src/video/vid_ati_mach8.c | 206 ++++++++++++++-------------------- src/video/vid_svga.c | 10 +- src/video/vid_xga.c | 52 ++++----- 6 files changed, 200 insertions(+), 277 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 5d4b262c4..cecacc507 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -39,7 +39,7 @@ typedef enum { EXTENSIONS_MAX } ibm8514_extensions_t; -typedef struct hwcursor8514_t { +typedef struct ibm8514_hwcursor_s { int enable; int x; int y; @@ -49,14 +49,14 @@ typedef struct hwcursor8514_t { int cur_ysize; uint32_t addr; uint32_t pitch; -} hwcursor8514_t; +} ibm8514_hwcursor_t; typedef union { uint64_t q; uint32_t d[2]; uint16_t w[4]; uint8_t b[8]; -} latch8514_t; +} ibm8514_latch_t; typedef struct ibm8514_t { rom_t bios_rom; @@ -64,8 +64,8 @@ typedef struct ibm8514_t { mem_mapping_t bios_mapping; uint8_t *rom1; uint8_t *rom2; - hwcursor8514_t hwcursor; - hwcursor8514_t hwcursor_latch; + ibm8514_hwcursor_t hwcursor; + ibm8514_hwcursor_t hwcursor_latch; uint8_t pos_regs[8]; char *rom_path; @@ -160,20 +160,17 @@ typedef struct ibm8514_t { uint16_t dst_pitch; } accel; - int h_blankstart; int hblankstart; int hblankend; int hblank_ext; - int v_total_reg; - int v_total; + int vtotal_reg; + int vtotal_8514; int dispend; - int v_sync_start; - int v_syncstart; + int vsyncstart; int split; - int h_disp; - int h_total; - int h_disp_time; + int hdisp_8514; + int htotal_8514; int rowoffset; int dispon; int hdispon; @@ -197,26 +194,23 @@ typedef struct ibm8514_t { uint8_t linedbl; uint8_t data_available; - uint8_t data_available2; uint8_t rowcount; int hsync_start; int hsync_width; int htotal; - int hdisp; - int hdisp2; + int hdisp_vga; int hdisped; int scanline; int vsyncwidth; int vtotal; - int vdisp_latch; - int vdisp; + int vdisp_8514; + int vdisp_vga; int disp_cntl; int interlace; uint16_t subsys_cntl; uint8_t subsys_stat; atomic_int force_busy; - atomic_int force_busy2; atomic_int fifo_idx; int blitter_busy; @@ -235,7 +229,7 @@ typedef struct ibm8514_t { int _8514crt; PALETTE _8514pal; - latch8514_t latch; + ibm8514_latch_t latch; void (*vblank_start)(void *priv); void (*accel_out_fifo)(void *priv, uint16_t port, uint16_t val, int len); diff --git a/src/include/86box/vid_xga.h b/src/include/86box/vid_xga.h index a2ef1a530..a8c7e09cd 100644 --- a/src/include/86box/vid_xga.h +++ b/src/include/86box/vid_xga.h @@ -114,18 +114,16 @@ typedef struct xga_t { int dac_pos; int dac_r; int dac_g; - int v_total; + int vtotal_xga; int dispend; - int v_syncstart; int split; - int v_blankstart; - int h_disp; - int h_disp_old; - int h_total; - int h_disp_time; + int vblankstart_xga; + int hdisp_xga; + int hdispold_xga; + int htotal_xga; int rowoffset; int dispon; - int h_disp_on; + int hdispon_xga; int vc; int scanline; int linepos; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index f911da6be..d8a9576b5 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -376,19 +376,19 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x12e8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->v_total_reg = val; - dev->v_total_reg &= 0x1fff; + dev->vtotal_reg = val; + dev->vtotal_reg &= 0x1fff; ibm8514_log("IBM 8514/A compatible: (0x%04x): vtotal=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->v_total_reg, val); + WRITE8(port, dev->vtotal_reg, val); } break; case 0x12e9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->v_total_reg, val >> 8); - dev->v_total_reg &= 0x1fff; + WRITE8(port, dev->vtotal_reg, val >> 8); + dev->vtotal_reg &= 0x1fff; ibm8514_log("IBM 8514/A compatible: (0x%04x): vtotal=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -397,21 +397,21 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x16e8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->vdisp_latch = val; - dev->vdisp_latch &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_latch); + dev->vdisp_8514 = val; + dev->vdisp_8514 &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_8514); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->vdisp_latch, val); + WRITE8(port, dev->vdisp_8514, val); } break; case 0x16e9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->vdisp_latch, val >> 8); - dev->vdisp_latch &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_latch); + WRITE8(port, dev->vdisp_8514, val >> 8); + dev->vdisp_8514 &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_8514); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -420,25 +420,26 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x1ae8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->v_sync_start = val; - dev->v_sync_start &= 0x1fff; - ibm8514_log("IBM 8514/A compatible: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + dev->vsyncstart = val; + dev->vsyncstart &= 0x1fff; + ibm8514_log("IBM 8514/A compatible: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); ibm8514_log("IBM 8514/A compatible: (0x%04x): vsyncstart=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->v_sync_start, val); + WRITE8(port, dev->vsyncstart, val); } break; case 0x1ae9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->v_sync_start, val >> 8); - dev->v_sync_start &= 0x1fff; - dev->v_syncstart = dev->v_sync_start + 1; + WRITE8(port, dev->vsyncstart, val >> 8); + dev->vsyncstart &= 0x1fff; + dev->vsyncstart++; + // change this if it breaks if (dev->interlace) - dev->v_syncstart >>= 1; + dev->vsyncstart >>= 1; - ibm8514_log("IBM 8514/A compatible: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + ibm8514_log("IBM 8514/A compatible: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); ibm8514_log("IBM 8514/A compatible: (0x%04x): vsyncstart=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -465,7 +466,6 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) dev->subsys_stat &= ~val; if ((val & 0xc000) == 0x8000) { dev->force_busy = 0; - dev->force_busy2 = 0; } } else { WRITE8(port, dev->subsys_cntl, val); @@ -477,7 +477,6 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) WRITE8(port, dev->subsys_cntl, val); if ((val & 0xc0) == 0x80) { dev->force_busy = 0; - dev->force_busy2 = 0; } } break; @@ -485,7 +484,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x4ae8: WRITE8(port, dev->accel.advfunc_cntl, val); dev->on = dev->accel.advfunc_cntl & 0x01; - ibm8514_log("[%04X:%08X]: IBM 8514/A: (0x%04x): ON=%d, shadow crt=%x, hdisp=%d, vdisp=%d.\n", CS, cpu_state.pc, port, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp, dev->vdisp); + ibm8514_log("[%04X:%08X]: IBM 8514/A: (0x%04x): ON=%d, shadow crt=%x, hdisp=%d, vdisp=%d.\n", CS, cpu_state.pc, port, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp_vga, dev->vdisp_vga); ibm8514_log("IBM mode set %s resolution.\n", (dev->accel.advfunc_cntl & 0x04) ? "2: 1024x768" : "1: 640x480"); svga_recalctimings(svga); break; @@ -537,7 +536,6 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) dev->accel.ssv_state = 0; if (len == 2) { dev->data_available = 0; - dev->data_available2 = 0; dev->accel.cmd = val; dev->accel.cmd_back = 1; if (dev->accel.cmd & 0x100) @@ -847,12 +845,12 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) if (len == 1) { dev->fifo_idx = 0; - if (dev->force_busy2) + if (dev->force_busy) temp |= 0x02; /*Hardware busy*/ - dev->force_busy2 = 0; + dev->force_busy = 0; - if (dev->data_available2) { + if (dev->data_available) { temp |= 0x01; /*Read Data available*/ switch (dev->accel.cmd >> 13) { case 2: @@ -860,11 +858,11 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) case 4: case 6: if (dev->accel.sy < 0) - dev->data_available2 = 0; + dev->data_available = 0; break; default: if (!dev->accel.sy) - dev->data_available2 = 0; + dev->data_available = 0; break; } } @@ -910,7 +908,7 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) switch (port) { case 0x2e8: - if (dev->vc == dev->v_syncstart) + if (dev->vc == dev->vsyncstart) temp |= 0x02; ibm8514_log("Read: Display Status1=%02x.\n", temp); @@ -962,9 +960,7 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) if (!dev->fifo_idx && !dev->on) { dev->force_busy = 0; - dev->force_busy2 = 0; dev->data_available = 0; - dev->data_available2 = 0; temp |= INT_FIFO_EMP; } temp |= (dev->subsys_stat | (dev->vram_is_512k ? 0x00 : 0x80)); @@ -1020,9 +1016,7 @@ ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t if (ibm8514_cpu_src(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } } @@ -1236,7 +1230,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.ssv_len) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1337,7 +1330,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.ssv_len) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1405,15 +1397,11 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } } dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -1521,7 +1509,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1646,7 +1633,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1754,7 +1740,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1858,9 +1843,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } } dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { if (!(dev->accel.cmd & 0x02)) { @@ -1877,9 +1860,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } ibm8514_log("INPUT=%d.\n", dev->accel.input); dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; /*Wait for data from CPU*/ } } @@ -2033,7 +2014,6 @@ skip_vector_rect_write: if (dev->accel.sy < 0) { dev->force_busy = 0; - dev->force_busy2 = 0; dev->fifo_idx = 0; dev->accel.cmd_back = 1; } @@ -2195,7 +2175,6 @@ skip_nibble_rect_write: dev->accel.cmd_back = 1; } dev->force_busy = 0; - dev->force_busy2 = 0; return; } } @@ -2579,15 +2558,11 @@ skip_nibble_rect_write: if (ibm8514_cpu_src(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -2656,7 +2631,6 @@ skip_nibble_rect_write: if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -2765,7 +2739,6 @@ skip_nibble_rect_write: if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -2853,15 +2826,11 @@ skip_nibble_rect_write: } } dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; /*Wait for data from CPU*/ } else ibm8514_log("BitBLT normal: Parameters: DX=%d, DY=%d, CX=%d, CY=%d, dstwidth=%d, dstheight=%d, clipl=%d, clipr=%d, clipt=%d, clipb=%d.\n", dev->accel.dx, dev->accel.dy, dev->accel.cx, dev->accel.cy, dev->accel.sx, dev->accel.sy, clip_l, clip_r, clip_t, clip_b); @@ -3016,7 +2985,6 @@ skip_nibble_bitblt_write: if (dev->accel.sy < 0) { dev->accel.cmd_back = 1; dev->force_busy = 0; - dev->force_busy2 = 0; dev->fifo_idx = 0; } return; @@ -3366,9 +3334,9 @@ ibm8514_render_blank(svga_t *svga) dev->lastline_draw = dev->displine; uint32_t *line_ptr = &buffer32->line[dev->displine + svga->y_add][svga->x_add]; - uint32_t line_width = (uint32_t)(dev->h_disp) * sizeof(uint32_t); + uint32_t line_width = (uint32_t)(dev->hdisp_8514) * sizeof(uint32_t); - if (dev->h_disp > 0) + if (dev->hdisp_8514 > 0) memset(line_ptr, 0, line_width); } @@ -3389,7 +3357,7 @@ ibm8514_render_8bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->h_disp; x += 8) { + for (int x = 0; x <= dev->hdisp_8514; x += 8) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[0] = dev->pallook[dat & dev->dac_mask & 0xff]; p[1] = dev->pallook[(dat >> 8) & dev->dac_mask & 0xff]; @@ -3427,7 +3395,7 @@ ibm8514_render_15bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x += 8) { + for (x = 0; x <= dev->hdisp_8514; x += 8) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 1)) & dev->vram_mask]); p[x] = video_15to32[dat & 0xffff]; p[x + 1] = video_15to32[dat >> 16]; @@ -3467,7 +3435,7 @@ ibm8514_render_16bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x += 8) { + for (x = 0; x <= dev->hdisp_8514; x += 8) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 1)) & dev->vram_mask]); p[x] = video_16to32[dat & 0xffff]; p[x + 1] = video_16to32[dat >> 16]; @@ -3506,7 +3474,7 @@ ibm8514_render_24bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = dat & 0xffffff; @@ -3542,7 +3510,7 @@ ibm8514_render_BGR(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); @@ -3579,7 +3547,7 @@ ibm8514_render_ABGR8888(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); } @@ -3606,7 +3574,7 @@ ibm8514_render_32bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); p[x] = dat & 0xffffff; } @@ -3621,7 +3589,7 @@ ibm8514_render_overscan_left(ibm8514_t *dev, svga_t *svga) if ((dev->displine + svga->y_add) < 0) return; - if (svga->scrblank || (dev->h_disp == 0)) + if (svga->scrblank || (dev->hdisp_8514 == 0)) return; for (int i = 0; i < svga->x_add; i++) @@ -3636,12 +3604,12 @@ ibm8514_render_overscan_right(ibm8514_t *dev, svga_t *svga) if ((dev->displine + svga->y_add) < 0) return; - if (svga->scrblank || (dev->h_disp == 0)) + if (svga->scrblank || (dev->hdisp_8514 == 0)) return; right = (overscan_x >> 1); for (int i = 0; i < right; i++) - buffer32->line[dev->displine + svga->y_add][svga->x_add + dev->h_disp + i] = svga->overscan_color; + buffer32->line[dev->displine + svga->y_add][svga->x_add + dev->hdisp_8514 + i] = svga->overscan_color; } void @@ -3754,10 +3722,10 @@ ibm8514_poll(void *priv) if (svga->fullchange) svga->fullchange--; } - if (dev->vc == dev->v_syncstart) { + if (dev->vc == dev->vsyncstart) { dev->dispon = 0; svga->cgastat |= 8; - x = dev->h_disp; + x = dev->hdisp_8514; if (dev->interlace && !dev->oddeven) dev->lastline++; @@ -3787,7 +3755,7 @@ ibm8514_poll(void *priv) dev->memaddr = (dev->memaddr << 2); dev->memaddr_backup = (dev->memaddr_backup << 2); } - if (dev->vc == dev->v_total) { + if (dev->vc == dev->vtotal_8514) { dev->vc = 0; dev->scanline = (svga->crtc[0x8] & 0x1f); dev->dispon = 1; @@ -3813,38 +3781,39 @@ ibm8514_recalctimings(svga_t *svga) ati8514_recalctimings(svga); } else { if (dev->on) { - dev->hdisp = (dev->hdisped + 1) << 3; - dev->h_total = dev->htotal + 1; + dev->hdisp_vga = (dev->hdisped + 1) << 3; + dev->htotal_8514 = dev->htotal + 1; - if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->h_total = 0x9e; + if (dev->htotal_8514 == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ + dev->htotal_8514 = 0x9e; - dev->vdisp = (dev->vdisp_latch + 1) >> 1; - if ((dev->vdisp == 478) || (dev->vdisp == 766)) - dev->vdisp += 2; + dev->vdisp_vga = (dev->vdisp_8514 + 1) >> 1; + if ((dev->vdisp_vga == 478) || (dev->vdisp_vga == 766)) + dev->vdisp_vga += 2; - dev->v_total = dev->v_total_reg + 1; + dev->vtotal_8514 = dev->vtotal_reg + 1; if (dev->interlace) - dev->v_total >>= 1; + dev->vtotal_8514 >>= 1; + + dev->vsyncstart++; - dev->v_syncstart = dev->v_sync_start + 1; if (dev->interlace) - dev->v_syncstart >>= 1; + dev->vsyncstart >>= 1; dev->rowcount = !!(dev->disp_cntl & 0x08); - if ((dev->hdisp != 640) && (dev->hdisp != 1024)) { + if ((dev->hdisp_vga != 640) && (dev->hdisp_vga != 1024)) { if (dev->accel.advfunc_cntl & 0x04) { - dev->hdisp = 1024; - dev->vdisp = 768; + dev->hdisp_vga = 1024; + dev->vdisp_vga = 768; } else { - dev->hdisp = 640; - dev->vdisp = 480; + dev->hdisp_vga = 640; + dev->vdisp_vga = 480; } } - dev->h_disp = dev->hdisp; - dev->dispend = dev->vdisp; + dev->hdisp_8514 = dev->hdisp_vga; + dev->dispend = dev->vdisp_vga; if (dev->accel.advfunc_cntl & 0x04) svga->clock_8514 = (cpuclock * (double) (1ULL << 32)) / 44900000.0; @@ -3860,7 +3829,7 @@ ibm8514_recalctimings(svga_t *svga) dev->pitch = 1024; dev->rowoffset = 0x80; if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; } dev->accel_bpp = 8; @@ -3868,7 +3837,7 @@ ibm8514_recalctimings(svga_t *svga) ibm8514_log("BPP=%d, Pitch = %d, rowoffset = %d, crtc13 = %02x, highres bit = %02x, has_vga? = %d.\n", dev->bpp, dev->pitch, dev->rowoffset, svga->crtc[0x13], dev->accel.advfunc_cntl & 4, !ibm8514_standalone_enabled); } } - ibm8514_log("8514 enabled, hdisp=%d, vtotal=%d, htotal=%d, dispend=%d, rowoffset=%d, split=%d, vsyncstart=%d, split=%08x\n", dev->hdisp, dev->vtotal, dev->htotal, dev->dispend, dev->rowoffset, dev->split, dev->vsyncstart, dev->split); + ibm8514_log("8514 enabled, hdisp_vga=%d, vtotal=%d, htotal=%d, dispend=%d, rowoffset=%d, split=%d, vsyncstart=%d, split=%08x\n", dev->hdisp_vga, dev->vtotal, dev->htotal, dev->dispend, dev->rowoffset, dev->split, dev->vsyncstart, dev->split); } static uint8_t diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 4a73d6a8e..7bd550f0b 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -371,18 +371,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Extended Bresenham Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Extended Bresenham Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -530,7 +526,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (cpu_input) { mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -539,7 +534,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (cpu_input) { mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -740,7 +734,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if ((mono_src == 1) && !count) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -749,7 +742,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 } else if ((mono_src != 1) && (dev->accel.sx >= mach->accel.width)) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -959,18 +951,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Non-Conforming BitBLT Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Non-Conforming BitBLT Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -989,7 +977,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 mach_log("No DEST.\n"); if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1001,7 +988,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach->accel.sx_end == mach->accel.sx_start) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } mach_log("No SRC.\n"); @@ -1018,7 +1004,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sy == mach->accel.height) { mach_log("No Blit on DPCONFIG=3251.\n"); dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1228,7 +1213,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sy >= mach->accel.height) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1276,18 +1260,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Direct Linedraw Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Direct Linedraw Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -1392,7 +1372,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (!count) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1538,7 +1517,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sx >= mach->accel.width) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1659,7 +1637,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (!count) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1797,7 +1774,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sx >= mach->accel.width) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1930,18 +1906,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Scan To X Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Scan To X Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -2038,7 +2010,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 dev->fifo_idx = 0; dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->accel.cmd_back = 1; dev->accel.cur_x = dev->accel.dx; @@ -2212,7 +2183,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 dev->fifo_idx = 0; dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->accel.cmd_back = 1; return; @@ -2627,7 +2597,7 @@ ati_render_24bpp(svga_t *svga) dev->lastline_draw = dev->displine; if (mach->accel.ext_ge_config & 0x400) { /*BGR, Blue-(23:16), Green-(15:8), Red-(7:0)*/ - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); @@ -2643,7 +2613,7 @@ ati_render_24bpp(svga_t *svga) dev->memaddr += 12; } } else { /*RGB, Red-(23:16), Green-(15:8), Blue-(7:0)*/ - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = dat & 0xffffff; @@ -2683,12 +2653,12 @@ ati_render_32bpp(svga_t *svga) dev->lastline_draw = dev->displine; if (mach->accel.ext_ge_config & 0x400) { /*BGR, Blue-(23:16), Green-(15:8), Red-(7:0)*/ - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0x00ff0000) >> 16) | (dat & 0x0000ff00) | ((dat & 0x000000ff) << 16); } } else { /*RGB, Red-(31:24), Green-(23:16), Blue-(15:8)*/ - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0xffffff00) >> 8); } @@ -2708,22 +2678,22 @@ mach_set_resolution(mach_t *mach, svga_t *svga) ibm8514_t *dev = (ibm8514_t *) svga->dev8514; int ret = 0; - dev->h_total = dev->htotal + 1; + dev->htotal_8514 = dev->htotal + 1; - if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->h_total = 0x9e; + if (dev->htotal_8514 == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ + dev->htotal_8514 = 0x9e; - dev->hdisp = (dev->hdisped + 1) << 3; + dev->hdisp_vga = (dev->hdisped + 1) << 3; - dev->vdisp = (dev->vdisp_latch + 1) >> 1; - if ((dev->vdisp == 478) || (dev->vdisp == 598) || (dev->vdisp == 766) || (dev->vdisp == 1022)) - dev->vdisp += 2; + dev->vdisp_vga = (dev->vdisp_8514 + 1) >> 1; + if ((dev->vdisp_vga == 478) || (dev->vdisp_vga == 598) || (dev->vdisp_vga == 766) || (dev->vdisp_vga == 1022)) + dev->vdisp_vga += 2; - dev->v_total = dev->v_total_reg + 1; + dev->vtotal_8514 = dev->vtotal_reg + 1; - dev->v_syncstart = dev->v_sync_start + 1; + dev->vsyncstart++; - mach_log("VSYNCSTART=%d, VTOTAL=%d, interlace=%02x, vdisp=%d.\n", dev->v_syncstart, dev->v_total, dev->interlace, dev->vdisp); + mach_log("VSYNCSTART=%d, VTOTAL=%d, interlace=%02x, vdisp=%d.\n", dev->vsyncstart, dev->vtotal_8514, dev->interlace, dev->vdisp_vga); if (!ATI_MACH32) { if ((mach->accel.clock_sel & 0x01) && @@ -2757,15 +2727,15 @@ mach_set_resolution(mach_t *mach, svga_t *svga) svga_recalctimings(svga); else { if (dev->accel.advfunc_cntl & 0x04) { - if (dev->hdisp == 640) { - dev->hdisp = 1024; - dev->vdisp = 768; + if (dev->hdisp_vga == 640) { + dev->hdisp_vga = 1024; + dev->vdisp_vga = 768; mach_log("1024x768.\n"); } } else { - if (dev->hdisp == 1024) { - dev->hdisp = 640; - dev->vdisp = 480; + if (dev->hdisp_vga == 1024) { + dev->hdisp_vga = 640; + dev->vdisp_vga = 480; mach_log("640x480.\n"); } } @@ -2785,7 +2755,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) } else svga_recalctimings(svga); - mach_log("Shadow set ATI=%x, shadow set 8514/A and on1=%x, on2=%x, resolution h=%d, v=%d, vtotal=%d, vsyncstart=%d, crtres=%d, ret=%d, actual passthrough=%x.\n", mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01, dev->hdisp, dev->vdisp, dev->v_total, dev->v_syncstart, mach->crt_resolution, ret, dev->on); + mach_log("Shadow set ATI=%x, shadow set 8514/A and on1=%x, on2=%x, resolution h=%d, v=%d, vtotal=%d, vsyncstart=%d, crtres=%d, ret=%d, actual passthrough=%x.\n", mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01, dev->hdisp_vga, dev->vdisp_vga, dev->vtotal_8514, dev->v_syncstart, mach->crt_resolution, ret, dev->on); } void @@ -2806,7 +2776,7 @@ ati8514_recalctimings(svga_t *svga) dev->accel.ge_offset -= mach->accel.crt_offset; mach_log("HDISP=%d, VDISP=%d, shadowset=%x, 8514/A mode=%x, clocksel=%02x.\n", - dev->hdisp, dev->vdisp, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01); + dev->hdisp_vga, dev->vdisp_vga, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01); mach->accel.src_pitch = dev->pitch; mach->accel.dst_pitch = dev->pitch; @@ -2817,11 +2787,11 @@ ati8514_recalctimings(svga_t *svga) mach_log("8514/A ON, pitch=%d, GE offset=%08x.\n", ((mach->accel.ge_pitch & 0xff) << 3), dev->accel.ge_offset); - dev->h_disp = dev->hdisp; - dev->dispend = dev->vdisp; + dev->hdisp_8514 = dev->hdisp_vga; + dev->dispend = dev->vdisp_vga; if (dev->dispend == 600) - dev->h_disp = 800; - else if (dev->h_disp == 640) + dev->hdisp_8514 = 800; + else if (dev->hdisp_8514 == 640) dev->dispend = 480; if (dev->accel.advfunc_cntl & 0x04) @@ -2833,10 +2803,10 @@ ati8514_recalctimings(svga_t *svga) dev->dispend >>= 1; mach_log("cntl=%d, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d.\n", - dev->accel.advfunc_cntl & 0x04, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace); if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -2926,17 +2896,17 @@ mach_recalctimings(svga_t *svga) mach_log("RowCount=%x, rowoffset=%x, pitch=%d, geoffset=%x, crtoffset=%x.\n", dev->rowcount, dev->rowoffset, dev->pitch, dev->accel.ge_offset, mach->accel.crt_offset); mach_log("HDISP=%d, VDISP=%d, shadowset=%x, 8514/A mode=%x, clocksel=%02x, interlace=%x.\n", - dev->hdisp, dev->vdisp, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x04, + dev->hdisp_vga, dev->vdisp_vga, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0xfe, dev->interlace); - dev->h_disp = dev->hdisp; - dev->dispend = dev->vdisp; + dev->hdisp_8514 = dev->hdisp_vga; + dev->dispend = dev->vdisp_vga; if (dev->dispend == 959) { /*FIXME: vertical resolution mess on EEPROM tests on Mach8*/ dev->dispend >>= 1; dev->dispend++; } else if (dev->dispend == 600) - dev->h_disp = 800; - else if (dev->h_disp == 640) + dev->hdisp_8514 = 800; + else if (dev->hdisp_8514 == 640) dev->dispend = 480; svga->clock_8514 = (cpuclock * (double) (1ULL << 32)) / svga->getclock((mach->accel.clock_sel >> 2) & 0x0f, svga->clock_gen); @@ -3005,18 +2975,18 @@ mach_recalctimings(svga_t *svga) break; } mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", - dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace, svga->hdisp); if ((mach->accel.ext_ge_config & 0x800) || (!(mach->accel.ext_ge_config & 0x8000) && !(mach->accel.ext_ge_config & 0x800))) { mach_log("hv=%d,%d, pitch=%d, rowoffset=%d, gextconfig=%03x, bpp=%d, shadow=%x, vgahdisp=%d.\n", - dev->h_disp, dev->dispend, dev->pitch, dev->ext_crt_pitch, mach->accel.ext_ge_config & 0xcec0, + dev->hdisp_8514, dev->dispend, dev->pitch, dev->ext_crt_pitch, mach->accel.ext_ge_config & 0xcec0, dev->accel_bpp, mach->shadow_set & 0x03, svga->hdisp); switch (dev->accel_bpp) { case 8: if ((mach->accel.ext_ge_config & 0x30) == 0x00) { if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -3054,10 +3024,10 @@ mach_recalctimings(svga_t *svga) mach->accel.dst_ge_offset -= mach->accel.crt_offset; mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", - dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 0x03, dev->interlace, svga->hdisp); if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -3199,15 +3169,15 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10) && val) { - dev->v_total_reg = val; - dev->v_total_reg &= 0x1fff; + dev->vtotal_reg = val; + dev->vtotal_reg &= 0x1fff; } } } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->v_total_reg, val); - dev->v_total_reg &= 0x1fff; + WRITE8(port, dev->vtotal_reg, val); + dev->vtotal_reg &= 0x1fff; } } } @@ -3219,8 +3189,8 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { if (!(mach->shadow_cntl & 0x10)) { /*For 8514/A mode, take the shadow sets into account.*/ - WRITE8(port, dev->v_total_reg, val >> 8); - dev->v_total_reg &= 0x1fff; + WRITE8(port, dev->vtotal_reg, val >> 8); + dev->vtotal_reg &= 0x1fff; } } mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): hdisp=0x%02x.\n", CS, cpu_state.pc, port, val); @@ -3232,17 +3202,17 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20) && val) { - dev->vdisp_latch = val; - dev->vdisp_latch &= 0x1fff; + dev->vdisp_8514 = val; + dev->vdisp_8514 &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->vdisp_latch); + mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->vdisp_8514); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->vdisp_latch, val); - dev->vdisp_latch &= 0x1fff; + WRITE8(port, dev->vdisp_8514, val); + dev->vdisp_8514 &= 0x1fff; } } } @@ -3252,11 +3222,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->vdisp_latch, val >> 8); - dev->vdisp_latch &= 0x1fff; + WRITE8(port, dev->vdisp_8514, val >> 8); + dev->vdisp_8514 &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->vdisp_latch); + mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->vdisp_8514); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3266,17 +3236,17 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10) && val) { - dev->v_sync_start = val; - dev->v_sync_start &= 0x1fff; + dev->vsyncstart = val; + dev->vsyncstart &= 0x1fff; } } - mach_log("ATI 8514/A: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + mach_log("ATI 8514/A: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); mach_log("ATI 8514/A: (0x%04x): vsyncstart=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->v_sync_start, val); - dev->v_sync_start &= 0x1fff; + WRITE8(port, dev->vsyncstart, val); + dev->vsyncstart &= 0x1fff; } } } @@ -3286,11 +3256,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->v_sync_start, val >> 8); - dev->v_sync_start &= 0x1fff; + WRITE8(port, dev->vsyncstart, val >> 8); + dev->vsyncstart &= 0x1fff; } } - mach_log("ATI 8514/A: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + mach_log("ATI 8514/A: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); mach_log("ATI 8514/A: (0x%04x): vsyncstart=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3322,7 +3292,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if ((dev->subsys_cntl & 0xc000) == 0x8000) { mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; } break; @@ -3348,7 +3317,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, valxor=%x, shadow crt=%x, hdisp=%d, vdisp=%d, extmode=%02x, accelbpp=%d, crt=%d, crtres=%d.\n", - CS, cpu_state.pc, port, val & 0x01, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp, dev->vdisp, mach->regs[0xb0] & 0x20, dev->accel_bpp, dev->_8514crt, mach->crt_resolution); + CS, cpu_state.pc, port, val & 0x01, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp_vga, dev->vdisp_vga, mach->regs[0xb0] & 0x20, dev->accel_bpp, dev->_8514crt, mach->crt_resolution); if (ATI_MACH32) { mach_set_resolution(mach, svga); @@ -3531,7 +3500,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } } } - mach_log("Write Port=%04x, Busy=%02x.\n", port, dev->force_busy2); + mach_log("Write Port=%04x, Busy=%02x.\n", port, dev->force_busy); break; case 0xaae8: @@ -3787,7 +3756,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u dev->vendor_mode = 1; mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, val=%04x, xor=%d, hdisp=%d, vdisp=%d, accelbpp=%d.\n", - CS, cpu_state.pc, port, mach->accel.clock_sel & 0x01, val, dev->on, dev->hdisp, dev->vdisp, dev->accel_bpp); + CS, cpu_state.pc, port, mach->accel.clock_sel & 0x01, val, dev->on, dev->hdisp_vga, dev->vdisp_vga, dev->accel_bpp); mach_log("Vendor ATI mode set %s resolution.\n", (dev->accel.advfunc_cntl & 0x04) ? "2: 1024x768" : "1: 640x480"); @@ -3995,7 +3964,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.bres_count = val & 0x7ff; mach_log("BresenhamDraw=%04x.\n", mach->accel.dp_config); dev->data_available = 0; - dev->data_available2 = 0; mach->accel.cmd_type = 1; frgd_sel = (mach->accel.dp_config >> 13) & 7; bkgd_sel = (mach->accel.dp_config >> 7) & 3; @@ -4048,7 +4016,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.dest_y_end = 0; } dev->data_available = 0; - dev->data_available2 = 0; mach_log("BitBLT=%04x, pattidx=%d.\n", mach->accel.dp_config, mach->accel.patt_idx); mach_log(".\n"); mach->accel.cmd_type = 2; /*Non-conforming BitBLT from dest_y_end register (0xaeee)*/ @@ -4111,7 +4078,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.scan_to_x = 0; } dev->data_available = 0; - dev->data_available2 = 0; mach->accel.cmd_type = 5; /*Horizontal Raster Draw from scan_to_x register (0xcaee)*/ mach_log("ScanToX len=%d.\n", val); mach_log(".\n"); @@ -4133,7 +4099,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach_log("Data Path Configuration (%04x) write val=%04x, len=%d.\n", port, val, len); if (len == 2) { dev->data_available = 0; - dev->data_available2 = 0; mach->accel.dp_config = val; } break; @@ -4371,26 +4336,26 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in if (len == 1) { dev->fifo_idx = 0; - if (dev->force_busy2) + if (dev->force_busy) temp |= 0x02; /*Hardware busy*/ - dev->force_busy2 = 0; + dev->force_busy = 0; - if (dev->data_available2) { + if (dev->data_available) { temp |= 0x01; /*Read Data available*/ if (mach->accel.cmd_type >= 0) { switch (mach->accel.cmd_type) { case 2: if (dev->accel.sy >= mach->accel.height) - dev->data_available2 = 0; + dev->data_available = 0; break; case 5: if (dev->accel.sx >= mach->accel.width) - dev->data_available2 = 0; + dev->data_available = 0; break; default: if (dev->accel.sy < 0) - dev->data_available2 = 0; + dev->data_available = 0; break; } } else { @@ -4400,11 +4365,11 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in case 4: case 6: if (dev->accel.sy < 0) - dev->data_available2 = 0; + dev->data_available = 0; break; default: if (!dev->accel.sy) - dev->data_available2 = 0; + dev->data_available = 0; break; } } @@ -4595,35 +4560,35 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in case 0xc2ee: if (len == 2) - temp = dev->v_total_reg; + temp = dev->vtotal_reg; else - temp = dev->v_total_reg & 0xff; + temp = dev->vtotal_reg & 0xff; break; case 0xc2ef: if (len == 1) - temp = dev->v_total_reg >> 8; + temp = dev->vtotal_reg >> 8; break; case 0xc6ee: if (len == 2) - temp = dev->vdisp_latch; + temp = dev->vdisp_8514; else - temp = dev->vdisp_latch & 0xff; + temp = dev->vdisp_8514 & 0xff; break; case 0xc6ef: if (len == 1) - temp = dev->vdisp_latch >> 8; + temp = dev->vdisp_8514 >> 8; break; case 0xcaee: if (len == 2) - temp = dev->v_sync_start; + temp = dev->vsyncstart; else - temp = dev->v_sync_start & 0xff; + temp = dev->vsyncstart & 0xff; break; case 0xcaef: if (len == 1) - temp = dev->v_sync_start >> 8; + temp = dev->vsyncstart >> 8; break; case 0xceee: @@ -4787,10 +4752,8 @@ mach_accel_in_call(uint16_t port, mach_t *mach, svga_t *svga, ibm8514_t *dev) if (!dev->fifo_idx && !dev->on) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->data_available = 0; - dev->data_available2 = 0; temp |= INT_FIFO_EMP; mach_log("Fifo Empty.\n"); } @@ -5224,7 +5187,7 @@ mach32_write_common(uint32_t addr, uint8_t val, int linear, mach_t *mach, svga_t ibm8514_t *dev = (ibm8514_t *) svga->dev8514; int writemask2 = svga->writemask; int reset_wm = 0; - latch8514_t vall; + ibm8514_latch_t vall; uint8_t wm = svga->writemask; uint8_t i; @@ -7039,7 +7002,6 @@ mach_reset(void *priv) mach_disable_handlers(mach); mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; if (mach->pci_bus) reset_state->pci_slot = mach->pci_slot; @@ -7246,10 +7208,10 @@ ati8514_init(svga_t *svga, void *ext8514, void *dev8514) dev->accel_bpp = 8; dev->rowoffset = 0x80; dev->hdisped = 0x7f; - dev->vdisp_latch = 0x05ff; + dev->vdisp_8514 = 0x05ff; dev->htotal = 0x9d; - dev->v_total_reg = 0x0668; - dev->v_sync_start = 0x0600; + dev->vtotal_reg = 0x0668; + dev->vsyncstart = 0x0600; dev->disp_cntl = 0x33; mach->accel.clock_sel = 0x1c; dev->accel.cmd_back = 1; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 54856d9e0..8e87e5980 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1030,16 +1030,16 @@ svga_recalctimings(svga_t *svga) if (ibm8514_active && (svga->dev8514 != NULL)) { if (dev->on) { - disptime8514 = dev->h_total; - _dispontime8514 = dev->h_disp; - svga_log("HTOTAL=%d, HDISP=%d.\n", dev->h_total, dev->h_disp); + disptime8514 = dev->htotal_8514; + _dispontime8514 = dev->hdisp_8514; + svga_log("HTOTAL=%d, HDISP=%d.\n", dev->htotal_8514, dev->hdisp_8514); } } if (xga_active && (svga->xga != NULL)) { if (xga->on) { - disptime_xga = xga->h_total ? xga->h_total : TIMER_USEC; - _dispontime_xga = xga->h_disp; + disptime_xga = xga->htotal_xga ? xga->htotal_xga : TIMER_USEC; + _dispontime_xga = xga->hdisp_xga; } } diff --git a/src/video/vid_xga.c b/src/video/vid_xga.c index 51f842cc5..f7a1464e5 100644 --- a/src/video/vid_xga.c +++ b/src/video/vid_xga.c @@ -257,9 +257,9 @@ xga_render_blank(svga_t *svga) xga->lastline_draw = xga->displine; uint32_t *line_ptr = &svga->monitor->target_buffer->line[xga->displine + svga->y_add][svga->x_add]; - uint32_t line_width = (uint32_t)(xga->h_disp) * sizeof(uint32_t); + uint32_t line_width = (uint32_t)(xga->hdisp_xga) * sizeof(uint32_t); - if (xga->h_disp > 0) + if (xga->hdisp_xga > 0) memset(line_ptr, 0, line_width); } @@ -268,14 +268,14 @@ xga_recalctimings(svga_t *svga) { xga_t *xga = (xga_t *) svga->xga; if (xga->on) { - xga->h_total = xga->htotal + 1; - xga->v_total = xga->vtotal + 1; + xga->htotal_xga = xga->htotal + 1; + xga->vtotal_xga = xga->vtotal + 1; xga->dispend = xga->vdispend + 1; - xga->v_syncstart = xga->vsyncstart + 1; + xga->vsyncstart++; xga->split = xga->linecmp + 1; - xga->v_blankstart = xga->vblankstart + 1; + xga->vblankstart_xga = xga->vblankstart + 1; - xga->h_disp = (xga->hdisp + 1) << 3; + xga->hdisp_xga = (xga->hdisp + 1) << 3; xga->rowoffset = xga->pix_map_width; @@ -283,11 +283,11 @@ xga_recalctimings(svga_t *svga) xga->rowcount = (xga->disp_cntl_2 & 0xc0) >> 6; if (xga->interlace) { - xga->v_total >>= 1; + xga->vtotal_xga >>= 1; xga->dispend >>= 1; - xga->v_syncstart >>= 1; + xga->vsyncstart >>= 1; xga->split >>= 1; - xga->v_blankstart >>= 1; + xga->vblankstart_xga >>= 1; } xga->memaddr_latch = xga->disp_start_addr; @@ -296,14 +296,14 @@ xga_recalctimings(svga_t *svga) xga_log("XGA ClkSel1 = %d, ClkSel2 = %02x, dispcntl2=%02x.\n", (xga->clk_sel_1 >> 2) & 3, xga->clk_sel_2 & 0x80, xga->disp_cntl_2 & 0xc0); switch ((xga->clk_sel_1 >> 2) & 3) { case 0: - xga_log("HDISP VGA0 = %d, XGA = %d.\n", svga->hdisp, xga->h_disp); + xga_log("HDISP VGA0 = %d, XGA = %d.\n", svga->hdisp, xga->hdisp_xga); if (xga->clk_sel_2 & 0x80) svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 41539000.0; else svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 25175000.0; break; case 1: - xga_log("HDISP VGA1 = %d, XGA = %d.\n", svga->hdisp, xga->h_disp); + xga_log("HDISP VGA1 = %d, XGA = %d.\n", svga->hdisp, xga->hdisp_xga); svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 28322000.0; break; case 3: @@ -1555,7 +1555,7 @@ xga_bitblt(svga_t *svga) if (srcheight == 7) xga->accel.pattern = 1; else { - if ((dstwidth == (xga->h_disp - 1)) && (srcwidth == 1)) { + if ((dstwidth == (xga->hdisp_xga - 1)) && (srcwidth == 1)) { if ((xga->accel.dst_map == 1) && (xga->accel.src_map == 2)) { if ((xga->accel.px_map_format[xga->accel.dst_map] >= 0x0a) && (xga->accel.px_map_format[xga->accel.src_map] >= 0x0a)) xga->accel.pattern = 1; @@ -1640,8 +1640,8 @@ xga_bitblt(svga_t *svga) else if ((xga->accel.src_map == 1) && (patwidth == 7)) xga->accel.pattern = 1; } else { - if (dstwidth == (xga->h_disp - 1)) { - if (srcwidth == (xga->h_disp - 1)) { + if (dstwidth == (xga->hdisp_xga - 1)) { + if (srcwidth == (xga->hdisp_xga - 1)) { if ((xga->accel.src_map == 1) && (xga->accel.dst_map == 1) && (xga->accel.pat_src == 2)) { if ((xga->accel.px_map_format[xga->accel.dst_map] >= 0x0a) && (xga->accel.px <= 7) && (xga->accel.py <= 3)) xga->accel.pattern = 1; @@ -2591,7 +2591,7 @@ xga_render_overscan_left(xga_t *xga, svga_t *svga) if ((xga->displine + svga->y_add) < 0) return; - if (svga->scrblank || (xga->h_disp == 0)) + if (svga->scrblank || (xga->hdisp_xga == 0)) return; uint32_t *line_ptr = buffer32->line[xga->displine + svga->y_add]; @@ -2607,10 +2607,10 @@ xga_render_overscan_right(xga_t *xga, svga_t *svga) if ((xga->displine + svga->y_add) < 0) return; - if (svga->scrblank || (xga->h_disp == 0)) + if (svga->scrblank || (xga->hdisp_xga == 0)) return; - uint32_t *line_ptr = &buffer32->line[xga->displine + svga->y_add][svga->x_add + xga->h_disp]; + uint32_t *line_ptr = &buffer32->line[xga->displine + svga->y_add][svga->x_add + xga->hdisp_xga]; right = (overscan_x >> 1); for (int i = 0; i < right; i++) *line_ptr++ = svga->overscan_color; @@ -2634,7 +2634,7 @@ xga_render_4bpp(svga_t *svga) xga->lastline_draw = xga->displine; - for (int x = 0; x <= xga->h_disp; x += 8) { + for (int x = 0; x <= xga->hdisp_xga; x += 8) { dat = *(uint32_t *) (&xga->vram[xga->memaddr & xga->vram_mask]); p[0] = xga->pallook[dat & 0x0f]; p[1] = xga->pallook[(dat >> 8) & 0x0f]; @@ -2671,7 +2671,7 @@ xga_render_8bpp(svga_t *svga) xga->firstline_draw = xga->displine; xga->lastline_draw = xga->displine; - for (int x = 0; x <= xga->h_disp; x += 8) { + for (int x = 0; x <= xga->hdisp_xga; x += 8) { dat = *(uint32_t *) (&xga->vram[xga->memaddr & xga->vram_mask]); p[0] = xga->pallook[dat & 0xff]; p[1] = xga->pallook[(dat >> 8) & 0xff]; @@ -2709,7 +2709,7 @@ xga_render_16bpp(svga_t *svga) xga->firstline_draw = xga->displine; xga->lastline_draw = xga->displine; - for (x = 0; x <= xga->h_disp; x += 8) { + for (x = 0; x <= xga->hdisp_xga; x += 8) { dat = *(uint32_t *) (&xga->vram[(xga->memaddr + (x << 1)) & xga->vram_mask]); p[x] = video_16to32[dat & 0xffff]; p[x + 1] = video_16to32[dat >> 16]; @@ -3107,7 +3107,7 @@ xga_poll(void *priv) xga->linepos = 1; if (xga->dispon) { - xga->h_disp_on = 1; + xga->hdispon_xga = 1; xga->memaddr &= xga->vram_mask; @@ -3149,7 +3149,7 @@ xga_poll(void *priv) if (xga->dispon) svga->cgastat &= ~1; - xga->h_disp_on = 0; + xga->hdispon_xga = 0; xga->linepos = 0; if (xga->dispon) { @@ -3194,10 +3194,10 @@ xga_poll(void *priv) if (svga->fullchange) svga->fullchange--; } - if (xga->vc == xga->v_syncstart) { + if (xga->vc == xga->vsyncstart) { xga->dispon = 0; svga->cgastat |= 8; - x = xga->h_disp; + x = xga->hdisp_xga; if (xga->interlace && !xga->oddeven) xga->lastline++; @@ -3227,7 +3227,7 @@ xga_poll(void *priv) xga->memaddr = (xga->memaddr << 2); xga->memaddr_backup = (xga->memaddr_backup << 2); } - if (xga->vc == xga->v_total) { + if (xga->vc == xga->vtotal_xga) { xga->vc = 0; xga->scanline = 0; xga->dispon = 1; From 282ba13948c5bd19f2185fca45df0b29ead6dff0 Mon Sep 17 00:00:00 2001 From: starfrost013 Date: Sat, 21 Jun 2025 01:43:58 +0100 Subject: [PATCH 006/103] How do i keep finding this stuff --- src/include/86box/vid_8514a.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index cecacc507..559df5a2c 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -62,14 +62,11 @@ typedef struct ibm8514_t { rom_t bios_rom; rom_t bios_rom2; mem_mapping_t bios_mapping; - uint8_t *rom1; - uint8_t *rom2; ibm8514_hwcursor_t hwcursor; ibm8514_hwcursor_t hwcursor_latch; uint8_t pos_regs[8]; char *rom_path; - int force_old_addr; int type; ibm8514_card_type local; int bpp; @@ -162,8 +159,6 @@ typedef struct ibm8514_t { int hblankstart; int hblankend; - int hblank_ext; - int vtotal_reg; int vtotal_8514; int dispend; From 8a9e06ff110ad76ca55f2b0e675b71a724d9a40e Mon Sep 17 00:00:00 2001 From: usergithub64 <58270614+usergithub64@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:37:51 +0300 Subject: [PATCH 007/103] Update the Russian translation Update the Russian translation --- src/qt/languages/ru-RU.po | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index bb8a9caf5..b721d6f29 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -147,6 +147,12 @@ msgstr "RGB &цветной" msgid "&RGB Grayscale" msgstr "&RGB монохромный" +msgid "RGB (no brown)" +msgstr "RGB (без коричневого)" + +msgid "Generic RGBI color monitor" +msgstr "Стандартный цветной монитор RGBI" + msgid "&Amber monitor" msgstr "&Янтарный оттенок" @@ -1789,7 +1795,7 @@ msgid "Dithering" msgstr "Дизеринг" msgid "Enable NMI for CGA emulation" -msgstr "Включение NMI для эмуляции CGA" +msgstr "Включить NMI для эмуляции CGA" msgid "Voodoo type" msgstr "Тип Voodoo" From 58aa26127345d00944fe9ba2091898881d85a271 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 24 Jun 2025 01:23:32 -0400 Subject: [PATCH 008/103] LPT ECP/EPP support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Miran Grča --- src/device/CMakeLists.txt | 2 +- src/device/hasp.c | 22 +- src/device/lpt.c | 837 ++++++++++++++++++++++++++++++++++++++ src/include/86box/lpt.h | 59 ++- src/lpt.c | 264 ------------ src/network/net_plip.c | 21 +- src/printer/prt_escp.c | 62 ++- src/printer/prt_ps.c | 71 +++- src/printer/prt_text.c | 53 ++- src/sio/sio_ali5123.c | 12 +- src/sio/sio_pc87306.c | 79 ++-- src/sound/snd_lpt_dac.c | 50 ++- src/sound/snd_lpt_dss.c | 21 +- 13 files changed, 1161 insertions(+), 392 deletions(-) create mode 100644 src/device/lpt.c delete mode 100644 src/lpt.c diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index 29fc0b9b4..999b83aeb 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -41,7 +41,7 @@ add_library(dev OBJECT keyboard.c keyboard_at.c keyboard_xt.c - ../lpt.c + lpt.c mouse.c mouse_bus.c mouse_microtouch_touchscreen.c diff --git a/src/device/hasp.c b/src/device/hasp.c index 3834af4cd..53228c2a0 100644 --- a/src/device/hasp.c +++ b/src/device/hasp.c @@ -27,6 +27,7 @@ #include #define HAVE_STDARG_H #include <86box/86box.h> +#include <86box/timer.h> #include <86box/lpt.h> #include <86box/device.h> @@ -334,13 +335,16 @@ hasp_close(void *priv) } const lpt_device_t lpt_hasp_savquest_device = { - .name = "Protection Dongle for Savage Quest", - .internal_name = "dongle_savquest", - .init = hasp_init_savquest, - .close = hasp_close, - .write_data = hasp_write_data, - .write_ctrl = NULL, - .read_data = NULL, - .read_status = hasp_read_status, - .read_ctrl = NULL + .name = "Protection Dongle for Savage Quest", + .internal_name = "dongle_savquest", + .init = hasp_init_savquest, + .close = hasp_close, + .write_data = hasp_write_data, + .write_ctrl = NULL, + .autofeed = NULL, + .strobe = NULL, + .read_status = hasp_read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; diff --git a/src/device/lpt.c b/src/device/lpt.c new file mode 100644 index 000000000..179dc9a2d --- /dev/null +++ b/src/device/lpt.c @@ -0,0 +1,837 @@ +/* Copyright holders: Sarah Walker + see COPYING for more details +*/ +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include <86box/io.h> +#include <86box/fifo.h> +#include <86box/timer.h> +#include <86box/dma.h> +#include <86box/lpt.h> +#include <86box/pic.h> +#include <86box/sound.h> +#include <86box/prt_devs.h> +#include <86box/thread.h> +#include <86box/device.h> +#include <86box/machine.h> +#include <86box/network.h> + +lpt_port_t lpt_ports[PARALLEL_MAX]; + +const lpt_device_t lpt_none_device = { + .name = "None", + .internal_name = "none", + .init = NULL, + .close = NULL, + .write_data = NULL, + .write_ctrl = NULL, + .read_status = NULL, + .read_ctrl = NULL +}; + +static const struct { + const char *internal_name; + const lpt_device_t *device; +} lpt_devices[] = { + // clang-format off + {"none", &lpt_none_device }, + {"dss", &dss_device }, + {"lpt_dac", &lpt_dac_device }, + {"lpt_dac_stereo", &lpt_dac_stereo_device }, + {"text_prt", &lpt_prt_text_device }, + {"dot_matrix", &lpt_prt_escp_device }, + {"postscript", &lpt_prt_ps_device }, + {"pcl", &lpt_prt_pcl_device }, + {"plip", &lpt_plip_device }, + {"dongle_savquest", &lpt_hasp_savquest_device }, + {"", NULL } + // clang-format on +}; + +#ifdef ENABLE_LPT_LOG +int lpt_do_log = ENABLE_LPT_LOG; + +static void +lpt_log(const char *fmt, ...) +{ + va_list ap; + + if (lpt_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +# define lpt_log(fmt, ...) +#endif + +const char * +lpt_device_get_name(const int id) +{ + if (strlen(lpt_devices[id].internal_name) == 0) + return NULL; + if (lpt_devices[id].device == NULL) + return "None"; + return lpt_devices[id].device->name; +} + +const char * +lpt_device_get_internal_name(const int id) +{ + if (strlen(lpt_devices[id].internal_name) == 0) + return NULL; + return lpt_devices[id].internal_name; +} + +int +lpt_device_get_from_internal_name(const char *s) +{ + int c = 0; + + while (strlen(lpt_devices[c].internal_name) != 0) { + if (strcmp(lpt_devices[c].internal_name, s) == 0) + return c; + c++; + } + + return 0; +} + +void +lpt_devices_init(void) +{ + for (uint8_t i = 0; i < PARALLEL_MAX; i++) { + lpt_ports[i].dt = (lpt_device_t *) lpt_devices[lpt_ports[i].device].device; + + if (lpt_ports[i].dt && lpt_ports[i].dt->init) + lpt_ports[i].priv = lpt_ports[i].dt->init(&lpt_ports[i]); + } +} + +void +lpt_devices_close(void) +{ + for (uint8_t i = 0; i < PARALLEL_MAX; i++) { + lpt_port_t *dev = &lpt_ports[i]; + + if (lpt_ports[i].dt && lpt_ports[i].dt->close) + dev->dt->close(dev->priv); + + dev->dt = NULL; + } +} + +static uint8_t +lpt_get_ctrl_raw(const lpt_port_t *dev) +{ + uint8_t ret; + + if (dev->dt && dev->dt->read_ctrl && dev->priv) + ret = (dev->dt->read_ctrl(dev->priv) & 0xef) | dev->enable_irq; + else + ret = 0xc0 | dev->ctrl | dev->enable_irq; + + return ret & 0xdf; +} + +static uint8_t +lpt_is_epp(const lpt_port_t *dev) +{ + return (dev->epp || ((dev->ecp) && ((dev->ecr & 0xe0) == 0x80))); +} + +static uint8_t +lpt_get_ctrl(const lpt_port_t *dev) +{ + uint8_t ret = lpt_get_ctrl_raw(dev); + + if (!dev->ecp && !dev->epp) + ret |= 0x20; + + return ret; +} + +static void +lpt_write_fifo(lpt_port_t *dev, const uint8_t val, const uint8_t tag) +{ + if (!fifo_get_full(dev->fifo)) { + fifo_write_evt_tagged(tag, val, dev->fifo); + + if (!timer_is_enabled(&dev->fifo_out_timer)) + timer_set_delay_u64(&dev->fifo_out_timer, (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC)); + } +} + +static void +lpt_ecp_update_irq(lpt_port_t *dev) +{ + if (!(dev->ecr & 0x04) && ((dev->fifo_stat | dev->dma_stat) & 0x04)) + picintlevel(1 << dev->irq, &dev->irq_state); + else + picintclevel(1 << dev->irq, &dev->irq_state); +} + +static void +lpt_autofeed(lpt_port_t *dev, const uint8_t val) +{ + if (dev->dt && dev->dt->autofeed && dev->priv) + dev->dt->autofeed(val, dev->priv); + + dev->autofeed = val; +} + +static void +lpt_strobe(lpt_port_t *dev, const uint8_t val) +{ + if (dev->dt && dev->dt->strobe && dev->priv) + dev->dt->strobe(dev->strobe, val, dev->priv); + + dev->strobe = val; +} + +static void +lpt_fifo_out_callback(void *priv) +{ + lpt_port_t *dev = (lpt_port_t *) priv; + + switch (dev->state) { + default: + break; + + case LPT_STATE_READ_DMA: + ; + int ret = 0xff; + + if (dev->dma == 0xff) + ret = DMA_NODATA; + else + ret = dma_channel_read(dev->dma); + + lpt_log("DMA %02X: %08X\n", dev->dma, ret); + + if (ret != DMA_NODATA) { + fifo_write_evt_tagged(0x01, (uint8_t) (ret & 0xff), dev->fifo); + + if (ret & DMA_OVER) + /* Internal flag to indicate we have finished the DMA reads. */ + dev->dma_stat = 0x08; + } + + timer_advance_u64(&dev->fifo_out_timer, + (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC)); + + if (dev->dma_stat || fifo_get_full(dev->fifo)) + dev->state = LPT_STATE_WRITE_FIFO; + break; + + case LPT_STATE_WRITE_FIFO: + if (!fifo_get_empty(dev->fifo)) { + uint8_t tag = 0x00; + const uint8_t val = fifo_read_evt_tagged(&tag, dev->fifo); + + lpt_log("FIFO: %02X, TAG = %02X\n", val, tag); + + /* We do not currently support sending commands. */ + if (tag == 0x01) { + if (dev->dt && dev->dt->write_data && dev->priv) + dev->dt->write_data(val, dev->priv); + + lpt_strobe(dev, 1); + lpt_strobe(dev, 0); + } + } + + if (dev->ecr & 0x08) { + if (fifo_get_empty(dev->fifo)) { + if (dev->dma_stat) { + /* Now actually set the external flag. */ + dev->dma_stat = 0x04; + dev->state = LPT_STATE_IDLE; + lpt_ecp_update_irq(dev); + lpt_autofeed(dev, 0); + } else { + dev->state = LPT_STATE_READ_DMA; + + timer_advance_u64(&dev->fifo_out_timer, + (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC)); + } + } else + timer_advance_u64(&dev->fifo_out_timer, + (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC)); + } else if (!fifo_get_empty(dev->fifo)) + timer_advance_u64(&dev->fifo_out_timer, + (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC)); + else + lpt_autofeed(dev, 0); + break; + } +} + +void +lpt_write(const uint16_t port, const uint8_t val, void *priv) +{ + lpt_port_t *dev = (lpt_port_t *) priv; + uint16_t mask = 0x0407; + + lpt_log("[W] %04X = %02X\n", port, val); + + /* This is needed so the parallel port at 3BC works. */ + if (dev->addr & 0x0004) + mask = 0x0403; + + switch (port & mask) { + case 0x0000: + if (dev->ecp) { + if ((dev->ecr & 0xe0) == 0x60) + /* AFIFO */ + lpt_write_fifo(dev, val, 0x00); + else if (!(dev->ecr & 0xc0) && (!(dev->ecr & 0x20) || !(lpt_get_ctrl_raw(dev) & 0x20)) && + dev->dt && dev->dt->write_data && dev->priv) + /* DATAR */ + dev->dt->write_data(val, dev->priv); + dev->dat = val; + } else { + /* DTR */ + if ((!dev->ext || !(lpt_get_ctrl_raw(dev) & 0x20)) && dev->dt && + dev->dt->write_data && dev->priv) + dev->dt->write_data(val, dev->priv); + dev->dat = val; + } + break; + + case 0x0001: + break; + + case 0x0002: + if (dev->dt && dev->dt->write_ctrl && dev->priv) { + if (dev->ecp) + dev->dt->write_ctrl((val & 0xfc) | dev->autofeed | dev->strobe, dev->priv); + else + dev->dt->write_ctrl(val, dev->priv); + } + dev->ctrl = val; + dev->enable_irq = val & 0x10; + if (!(val & 0x10) && (dev->irq != 0xff)) + picintc(1 << dev->irq); + dev->irq_state = 0; + break; + + case 0x0003: + if (lpt_is_epp(dev)) { + if (dev->dt && dev->dt->epp_write_data && dev->priv) + dev->dt->epp_write_data(1, val, dev->priv); + } + break; + + case 0x0004 ... 0x0007: + if (lpt_is_epp(dev)) { + if (dev->dt && dev->dt->epp_write_data && dev->priv) + dev->dt->epp_write_data(0, val, dev->priv); + } + break; + + case 0x0400: case 0x0404: + switch (dev->ecr >> 5) { + default: + break; + case 2: + lpt_write_fifo(dev, val, 0x01); + break; + case 3: + if (!(lpt_get_ctrl_raw(dev) & 0x20)) + lpt_write_fifo(dev, val, 0x01); + break; + case 6: + /* TFIFO */ + if (!fifo_get_full(dev->fifo)) + fifo_write_evt(val, dev->fifo); + break; + } + break; + + case 0x0402: case 0x0406: + if (!(val & 0x0c)) + lpt_autofeed(dev, 0x00); + else + lpt_autofeed(dev, 0x02); + + if ((dev->ecr & 0x04) && !(val & 0x04)) { + dev->dma_stat = 0x00; + fifo_reset(dev->fifo); + if (val & 0x08) { + dev->state = LPT_STATE_READ_DMA; + dev->fifo_stat = 0x00; + if (!timer_is_enabled(&dev->fifo_out_timer)) + timer_set_delay_u64(&dev->fifo_out_timer, (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC)); + } else { + dev->state = LPT_STATE_WRITE_FIFO; + if (lpt_get_ctrl_raw(dev) & 0x20) + dev->fifo_stat = fifo_get_ready(dev->fifo) ? 0x04 : 0x00; + else + dev->fifo_stat = fifo_get_ready(dev->fifo) ? 0x00 : 0x04; + } + } else if ((val & 0x04) && !(dev->ecr & 0x04)) { + if (timer_is_enabled(&dev->fifo_out_timer)) + timer_disable(&dev->fifo_out_timer); + + dev->state = LPT_STATE_IDLE; + } + dev->ecr = val; + lpt_ecp_update_irq(dev); + break; + + default: + break; + } +} + +static void +lpt_fifo_d_ready_evt(void *priv) +{ + lpt_port_t *dev = (lpt_port_t *) priv; + + if (!(dev->ecr & 0x08)) { + if (lpt_get_ctrl_raw(dev) & 0x20) + dev->fifo_stat = fifo_get_ready(dev->fifo) ? 0x04 : 0x00; + else + dev->fifo_stat = fifo_get_ready(dev->fifo) ? 0x00 : 0x04; + } + + lpt_ecp_update_irq(dev); +} + +void +lpt_write_to_fifo(void *priv, const uint8_t val) +{ + lpt_port_t *dev = (lpt_port_t *) priv; + + if (dev->ecp) { + if (((dev->ecr & 0xe0) == 0x20) && (lpt_get_ctrl_raw(dev) & 0x20)) + dev->dat = val; + else if (((dev->ecr & 0xe0) == 0x60) && (lpt_get_ctrl_raw(dev) & 0x20) && + !fifo_get_full(dev->fifo)) + fifo_write_evt_tagged(0x01, val, dev->fifo); + + if (((dev->ecr & 0x0c) == 0x08) && (dev->dma != 0xff)) { + const int ret = dma_channel_write(dev->dma, val); + + if (ret & DMA_OVER) + dev->dma_stat |= 0x04; + } + } else { + if (dev->ext && (lpt_get_ctrl_raw(dev) & 0x20)) + dev->dat = val; + } +} + +void +lpt_write_to_dat(void *priv, const uint8_t val) +{ + lpt_port_t *dev = (lpt_port_t *) priv; + + dev->dat = val; +} + +static uint8_t +lpt_read_fifo(const lpt_port_t *dev) +{ + uint8_t ret = 0xff; + + if (!fifo_get_empty(dev->fifo)) + ret = fifo_read(dev->fifo); + + return ret; +} + +uint8_t +lpt_read_status(const int port) +{ + lpt_port_t *dev = &lpt_ports[port]; + uint8_t low_bits = 0x07; + uint8_t ret; + + if (dev->ext) { + low_bits = 0x03 | (dev->irq_state ? 0x00 : 0x04); + if (dev->irq != 0xff) + picintclevel(1 << dev->irq, &dev->irq_state); + dev->irq_state = 0; + } + if (dev->epp || dev->ecp) { + low_bits = lpt_is_epp(dev) ? 0x02 : 0x03; + if (lpt_get_ctrl_raw(dev) & 0x10) + low_bits |= (dev->irq_state ? 0x00 : 0x04); + else + low_bits |= 0x04; + } + + if (dev->dt && dev->dt->read_status && dev->priv) + ret = (dev->dt->read_status(dev->priv) & 0xf8) | low_bits; + else + ret = 0xd8 | low_bits; + + return ret; +} + +uint8_t +lpt_read(const uint16_t port, void *priv) +{ + const lpt_port_t *dev = (lpt_port_t *) priv; + uint16_t mask = 0x0407; + uint8_t ret = 0xff; + + /* This is needed so the parallel port at 3BC works. */ + if (dev->addr & 0x0004) + mask = 0x0403; + + switch (port & mask) { + case 0x0000: + if (dev->ecp) { + if (!(dev->ecr & 0xc0)) + ret = dev->dat; + } else { + /* DTR */ + ret = dev->dat; + } + break; + + case 0x0001: + ret = lpt_read_status(dev->id); + break; + + case 0x0002: + ret = lpt_get_ctrl(dev); + if (dev->ecp) + ret = (ret & 0xfc) | (dev->ctrl & 0x03); + break; + + case 0x0003: + if (lpt_is_epp(dev)) { + if (dev->dt && dev->dt->epp_request_read && dev->priv) + dev->dt->epp_request_read(1, dev->priv); + ret = dev->dat; + } + break; + + case 0x0004 ... 0x0007: + if (lpt_is_epp(dev)) { + if (dev->dt && dev->dt->epp_request_read && dev->priv) + dev->dt->epp_request_read(0, dev->priv); + ret = dev->dat; + } + break; + + case 0x0400: case 0x0404: + switch (dev->ecr >> 5) { + default: + break; + case 3: + if (lpt_get_ctrl_raw(dev) & 0x20) + ret = lpt_read_fifo(dev); + break; + case 6: + /* TFIFO */ + if (!fifo_get_empty(dev->fifo)) + ret = fifo_read_evt(dev->fifo); + break; + case 7: + /* CNFGA */ + ret = 0x14; + break; + } + break; + + case 0x0401: case 0x0405: + if ((dev->ecr & 0xe0) == 0xe0) { + /* CNFGB */ + ret = 0x08; + ret |= (dev->irq_state ? 0x40 : 0x00); + ret |= ((dev->irq == 0x05) ? 0x30 : 0x00); + if ((dev->dma >= 1) && (dev->dma <= 3)) + ret |= dev->dma; + } + break; + + case 0x0402: case 0x0406: + ret = dev->ecr | dev->fifo_stat | (dev->dma_stat & 0x04); + ret |= (fifo_get_full(dev->fifo) ? 0x02 : 0x00); + ret |= (fifo_get_empty(dev->fifo) ? 0x01 : 0x00); + break; + + default: + break; + } + + lpt_log("[R] %04X = %02X\n", port, ret); + + return ret; +} + +uint8_t +lpt_read_port(const int port, const uint16_t reg) +{ + lpt_port_t *dev = &(lpt_ports[port]); + + return lpt_read(reg, dev); +} + +void +lpt_irq(void *priv, const int raise) +{ + lpt_port_t *dev = (lpt_port_t *) priv; + + if (dev->enable_irq) { + if (dev->irq != 0xff) { + if (dev->ext) { + if (raise) + picintlevel(1 << dev->irq, &dev->irq_state); + else + picintclevel(1 << dev->irq, &dev->irq_state); + } else { + if (raise) + picint(1 << dev->irq); + else + picintc(1 << dev->irq); + } + } + + if (!dev->ext || (dev->irq == 0xff)) + dev->irq_state = raise; + } else { + if (dev->irq != 0xff) { + if (dev->ext) + picintclevel(1 << dev->irq, &dev->irq_state); + else + picintc(1 << dev->irq); + } + + dev->irq_state = 0; + } +} + +void +lpt_set_ext(const int port, const uint8_t ext) +{ + if (lpt_ports[port].enabled) + lpt_ports[port].ext = ext; +} + +void +lpt_set_ecp(const int port, const uint8_t ecp) +{ + if (lpt_ports[port].enabled) { + const uint16_t addr = lpt_ports[port].addr; + lpt_port_setup(port, 0xfff); + lpt_ports[port].ecp = ecp; + lpt_port_setup(port, addr); + } +} + +void +lpt_set_epp(const int port, const uint8_t epp) +{ + if (lpt_ports[port].enabled) { + const uint16_t addr = lpt_ports[port].addr; + lpt_port_setup(port, 0xfff); + lpt_ports[port].epp = epp; + lpt_port_setup(port, addr); + } +} + +void +lpt_set_lv2(const int port, const uint8_t lv2) +{ + if (lpt_ports[port].enabled) { + const uint16_t addr = lpt_ports[port].addr; + lpt_port_setup(port, 0xfff); + lpt_ports[port].lv2 = lv2; + lpt_port_setup(port, addr); + } +} + +void +lpt_close(void) +{ + for (uint8_t i = 0; i < PARALLEL_MAX; i++) { + if (lpt_ports[i].enabled) { + fifo_close(lpt_ports[i].fifo); + lpt_ports[i].fifo = NULL; + + timer_disable(&lpt_ports[i].fifo_out_timer); + } + } +} + +void +lpt_port_zero(lpt_port_t *dev) +{ + lpt_port_t temp = { 0 }; + + temp.irq = dev->irq; + temp.id = dev->id; + temp.device = dev->device; + temp.dt = dev->dt; + temp.priv = dev->priv; + temp.enabled = dev->enabled; + temp.fifo = dev->fifo; + temp.fifo_out_timer = dev->fifo_out_timer; + + if (dev->enabled) + lpt_port_remove(dev->id); + + memset(dev, 0x00, sizeof(lpt_port_t)); + + dev->addr = 0xffff; + dev->irq = temp.irq; + dev->id = temp.id; + dev->device = temp.device; + dev->dt = temp.dt; + dev->priv = temp.priv; + dev->enabled = temp.enabled; + dev->fifo = temp.fifo; + dev->fifo_out_timer = temp.fifo_out_timer; + + if (machine_has_bus(machine, MACHINE_BUS_MCA)) + dev->ext = 1; +} + +void +lpt_reset(void) +{ + for (uint8_t i = 0; i < PARALLEL_MAX; i++) { + if (lpt_ports[i].enabled) + if (timer_is_enabled(&lpt_ports[i].fifo_out_timer)) + timer_disable(&lpt_ports[i].fifo_out_timer); + + lpt_port_zero(&(lpt_ports[i])); + + if (lpt_ports[i].enabled) { + if (lpt_ports[i].irq_state) { + if (lpt_ports[i].irq == 0xff) + lpt_ports[i].irq_state = 0x00; + else { + picintclevel(lpt_ports[i].irq, &lpt_ports[i].irq_state); + picintc(lpt_ports[i].irq); + } + } + + lpt_ports[i].enable_irq = 0x00; + lpt_ports[i].ext = !!(machine_has_bus(machine, MACHINE_BUS_MCA)); + lpt_ports[i].epp = 0; + lpt_ports[i].ecp = 0; + lpt_ports[i].ecr = 0x15; + lpt_ports[i].dat = 0xff; + lpt_ports[i].fifo_stat = 0x00; + lpt_ports[i].dma_stat = 0x00; + } + } +} + +void +lpt_init(void) +{ + const uint16_t default_ports[PARALLEL_MAX] = { LPT1_ADDR, LPT2_ADDR, LPT_MDA_ADDR, LPT4_ADDR }; + const uint8_t default_irqs[PARALLEL_MAX] = { LPT1_IRQ, LPT2_IRQ, LPT_MDA_IRQ, LPT4_IRQ }; + + for (uint8_t i = 0; i < PARALLEL_MAX; i++) { + lpt_ports[i].id = i; + lpt_ports[i].dt = NULL; + lpt_ports[i].priv = NULL; + lpt_ports[i].fifo = NULL; + memset(&lpt_ports[i].fifo_out_timer, 0x00, sizeof(pc_timer_t)); + + lpt_port_zero(&(lpt_ports[i])); + + lpt_ports[i].addr = 0xffff; + lpt_ports[i].irq = 0xff; + lpt_ports[i].dma = 0xff; + lpt_ports[i].enable_irq = 0x00; + lpt_ports[i].ext = 0; + lpt_ports[i].epp = 0; + lpt_ports[i].ecp = 0; + lpt_ports[i].ecr = 0x15; + + if (lpt_ports[i].enabled) { + lpt_port_setup(i, default_ports[i]); + lpt_port_irq(i, default_irqs[i]); + + lpt_ports[i].fifo = fifo16_init(); + + fifo_set_trigger_len(lpt_ports[i].fifo, 8); + + fifo_set_d_ready_evt(lpt_ports[i].fifo, lpt_fifo_d_ready_evt); + fifo_set_priv(lpt_ports[i].fifo, &lpt_ports[i]); + + timer_add(&lpt_ports[i].fifo_out_timer, lpt_fifo_out_callback, &lpt_ports[i], 0); + } + } +} + +void +lpt_port_setup(const int i, const uint16_t port) +{ + if (lpt_ports[i].enabled) { + if (lpt_ports[i].addr != 0xffff) { + io_removehandler(lpt_ports[i].addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + io_removehandler(lpt_ports[i].addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + } + if (port != 0xffff) { + lpt_log("Set handler: %04X-%04X\n", port, port + 0x0003); + io_sethandler(port, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + if (lpt_ports[i].epp) + io_sethandler(lpt_ports[i].addr + 0x0003, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + if (lpt_ports[i].ecp || lpt_ports[i].lv2) { + io_sethandler(port + 0x0400, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + if (lpt_ports[i].epp) + io_sethandler(lpt_ports[i].addr + 0x0403, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + } + } + lpt_ports[i].addr = port; + } else + lpt_ports[i].addr = 0xffff; +} + +void +lpt_port_irq(const int i, const uint8_t irq) +{ + if (lpt_ports[i].enabled) + lpt_ports[i].irq = irq; + else + lpt_ports[i].irq = 0xff; + + lpt_log("Port %i IRQ = %02X\n", i, irq); +} + +void +lpt_port_dma(const int i, const uint8_t dma) +{ + if (lpt_ports[i].enabled) + lpt_ports[i].dma = dma; + else + lpt_ports[i].dma = 0xff; + + lpt_log("Port %i DMA = %02X\n", i, dma); +} + +void +lpt_port_remove(const int i) +{ + if (lpt_ports[i].enabled && (lpt_ports[i].addr != 0xffff)) { + io_removehandler(lpt_ports[i].addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + io_removehandler(lpt_ports[i].addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); + + lpt_ports[i].addr = 0xffff; + } +} + +void +lpt1_remove_ams(void) +{ + if (lpt_ports[0].enabled) + io_removehandler(lpt_ports[0].addr + 1, 0x0002, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[0]); +} diff --git a/src/include/86box/lpt.h b/src/include/86box/lpt.h index 674d6340f..c13d70291 100644 --- a/src/include/86box/lpt.h +++ b/src/include/86box/lpt.h @@ -25,14 +25,24 @@ typedef struct lpt_device_t { void (*close)(void *priv); void (*write_data)(uint8_t val, void *priv); void (*write_ctrl)(uint8_t val, void *priv); - uint8_t (*read_data)(void *priv); + void (*autofeed)(uint8_t val,void *priv); + void (*strobe)(uint8_t old, uint8_t val,void *priv); uint8_t (*read_status)(void *priv); uint8_t (*read_ctrl)(void *priv); + void (*epp_write_data)(uint8_t is_addr, uint8_t val, void *priv); + void (*epp_request_read)(uint8_t is_addr, void *priv); } lpt_device_t; +extern void lpt_set_ext(int port, uint8_t ext); +extern void lpt_set_ecp(int port, uint8_t ecp); +extern void lpt_set_epp(int port, uint8_t epp); +extern void lpt_set_lv2(int port, uint8_t lv2); +extern void lpt_reset(void); +extern void lpt_close(void); extern void lpt_init(void); extern void lpt_port_setup(int i, uint16_t port); extern void lpt_port_irq(int i, uint8_t irq); +extern void lpt_port_dma(int i, uint8_t dma); extern void lpt_port_remove(int i); extern void lpt1_remove_ams(void); @@ -68,31 +78,62 @@ void lpt_devices_close(void); typedef struct lpt_port_t { uint8_t enabled; uint8_t irq; + uint8_t irq_state; + uint8_t dma; uint8_t dat; uint8_t ctrl; + uint8_t ext; + uint8_t epp; + uint8_t ecp; + uint8_t ecr; + uint8_t in_dat; + uint8_t fifo_stat; + uint8_t dma_stat; + uint8_t state; + uint8_t autofeed; + uint8_t strobe; + uint8_t lv2; + uint8_t pad[7]; uint16_t addr; - uint16_t pad0; + uint16_t id; + uint16_t pad0[2]; int device; int enable_irq; lpt_device_t *dt; +#ifdef FIFO_H + fifo16_t *fifo; +#else + void *fifo; +#endif void *priv; + + pc_timer_t fifo_out_timer; } lpt_port_t; +typedef enum { + LPT_STATE_IDLE = 0, + LPT_STATE_READ_DMA, + LPT_STATE_WRITE_FIFO +} lpt_state_t; + extern lpt_port_t lpt_ports[PARALLEL_MAX]; -extern void lpt_write(uint16_t port, uint8_t val, void *priv); -extern uint8_t lpt_read(uint16_t port, void *priv); +extern void lpt_write(uint16_t port, uint8_t val, void *priv); -extern uint8_t lpt_read_port(int port, uint16_t reg); +extern void lpt_write_to_fifo(void *priv, uint8_t val); -extern uint8_t lpt_read_status(int port); -extern void lpt_irq(void *priv, int raise); +extern uint8_t lpt_read(uint16_t port, void *priv); + +extern uint8_t lpt_read_port(int port, uint16_t reg); + +extern uint8_t lpt_read_status(int port); +extern void lpt_irq(void *priv, int raise); + +extern int lpt_device_get_from_internal_name(const char *s); extern const char *lpt_device_get_name(int id); extern const char *lpt_device_get_internal_name(int id); -extern int lpt_device_get_from_internal_name(char *s); - extern const lpt_device_t lpt_dac_device; extern const lpt_device_t lpt_dac_stereo_device; diff --git a/src/lpt.c b/src/lpt.c deleted file mode 100644 index 072f4a34c..000000000 --- a/src/lpt.c +++ /dev/null @@ -1,264 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include -#include -#include -#include -#include <86box/86box.h> -#include <86box/io.h> -#include <86box/lpt.h> -#include <86box/pic.h> -#include <86box/sound.h> -#include <86box/prt_devs.h> -#include <86box/thread.h> -#include <86box/timer.h> -#include <86box/device.h> -#include <86box/network.h> - -lpt_port_t lpt_ports[PARALLEL_MAX]; - -const lpt_device_t lpt_none_device = { - .name = "None", - .internal_name = "none", - .init = NULL, - .close = NULL, - .write_data = NULL, - .write_ctrl = NULL, - .read_data = NULL, - .read_status = NULL, - .read_ctrl = NULL -}; - -static const struct { - const char *internal_name; - const lpt_device_t *device; -} lpt_devices[] = { - // clang-format off - {"none", &lpt_none_device }, - {"dss", &dss_device }, - {"lpt_dac", &lpt_dac_device }, - {"lpt_dac_stereo", &lpt_dac_stereo_device }, - {"text_prt", &lpt_prt_text_device }, - {"dot_matrix", &lpt_prt_escp_device }, - {"postscript", &lpt_prt_ps_device }, -#ifdef USE_PCL - {"pcl", &lpt_prt_pcl_device }, -#endif - {"plip", &lpt_plip_device }, - {"dongle_savquest", &lpt_hasp_savquest_device }, - {"", NULL } - // clang-format on -}; - -const char * -lpt_device_get_name(int id) -{ - if (strlen(lpt_devices[id].internal_name) == 0) - return NULL; - if (!lpt_devices[id].device) - return "None"; - return lpt_devices[id].device->name; -} - -const char * -lpt_device_get_internal_name(int id) -{ - if (strlen(lpt_devices[id].internal_name) == 0) - return NULL; - return lpt_devices[id].internal_name; -} - -int -lpt_device_get_from_internal_name(char *s) -{ - int c = 0; - - while (strlen(lpt_devices[c].internal_name) != 0) { - if (strcmp(lpt_devices[c].internal_name, s) == 0) - return c; - c++; - } - - return 0; -} - -void -lpt_devices_init(void) -{ - for (uint8_t i = 0; i < PARALLEL_MAX; i++) { - lpt_ports[i].dt = (lpt_device_t *) lpt_devices[lpt_ports[i].device].device; - - if (lpt_ports[i].dt && lpt_ports[i].dt->init) - lpt_ports[i].priv = lpt_ports[i].dt->init(&lpt_ports[i]); - } -} - -void -lpt_devices_close(void) -{ - lpt_port_t *dev; - - for (uint8_t i = 0; i < PARALLEL_MAX; i++) { - dev = &lpt_ports[i]; - - if (lpt_ports[i].dt && lpt_ports[i].dt->close) - dev->dt->close(dev->priv); - - dev->dt = NULL; - } -} - -void -lpt_write(uint16_t port, uint8_t val, void *priv) -{ - lpt_port_t *dev = (lpt_port_t *) priv; - - switch (port & 3) { - case 0: - if (dev->dt && dev->dt->write_data && dev->priv) - dev->dt->write_data(val, dev->priv); - dev->dat = val; - break; - - case 1: - break; - - case 2: - if (dev->dt && dev->dt->write_ctrl && dev->priv) - dev->dt->write_ctrl(val, dev->priv); - dev->ctrl = val; - dev->enable_irq = val & 0x10; - break; - - default: - break; - } -} - -uint8_t -lpt_read(uint16_t port, void *priv) -{ - uint8_t ret = 0xff; - lpt_port_t *dev = (lpt_port_t *) priv; - - switch (port & 3) { - case 0: - if (dev->dt && dev->dt->read_data && dev->priv) - ret = dev->dt->read_data(dev->priv); - else - ret = dev->dat; - break; - - case 1: - if (dev->dt && dev->dt->read_status && dev->priv) - ret = dev->dt->read_status(dev->priv) | 0x07; - else - ret = 0xdf; - break; - - case 2: - if (dev->dt && dev->dt->read_ctrl && dev->priv) - ret = (dev->dt->read_ctrl(dev->priv) & 0xef) | dev->enable_irq; - else - ret = 0xe0 | dev->ctrl | dev->enable_irq; - break; - - default: - break; - } - - return ret; -} - -uint8_t -lpt_read_port(int port, uint16_t reg) -{ - lpt_port_t *dev = &(lpt_ports[port]); - uint8_t ret = lpt_read(reg, dev); - - return ret; -} - -uint8_t -lpt_read_status(int port) -{ - lpt_port_t *dev = &(lpt_ports[port]); - uint8_t ret = 0xff; - - if (dev->dt && dev->dt->read_status && dev->priv) - ret = dev->dt->read_status(dev->priv) | 0x07; - else - ret = 0xdf; - - return ret; -} - -void -lpt_irq(void *priv, int raise) -{ - const lpt_port_t *dev = (lpt_port_t *) priv; - - if (dev->enable_irq && (dev->irq != 0xff)) { - if (raise) - picint(1 << dev->irq); - else - picintc(1 << dev->irq); - } -} - -void -lpt_init(void) -{ - uint16_t default_ports[PARALLEL_MAX] = { LPT1_ADDR, LPT2_ADDR, LPT_MDA_ADDR, LPT4_ADDR }; - uint8_t default_irqs[PARALLEL_MAX] = { LPT1_IRQ, LPT2_IRQ, LPT_MDA_IRQ, LPT4_IRQ }; - - for (uint8_t i = 0; i < PARALLEL_MAX; i++) { - lpt_ports[i].addr = 0xffff; - lpt_ports[i].irq = 0xff; - lpt_ports[i].enable_irq = 0x10; - - if (lpt_ports[i].enabled) { - lpt_port_setup(i, default_ports[i]); - lpt_port_irq(i, default_irqs[i]); - } - } -} - -void -lpt_port_setup(int i, uint16_t port) -{ - if (lpt_ports[i].enabled) { - if ((lpt_ports[i].addr != 0xffff) && (lpt_ports[i].addr != 0x0000)) - io_removehandler(lpt_ports[i].addr, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); - if ((port != 0xffff) && (port != 0x0000)) - io_sethandler(port, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); - lpt_ports[i].addr = port; - } else - lpt_ports[i].addr = 0xffff; -} - -void -lpt_port_irq(int i, uint8_t irq) -{ - if (lpt_ports[i].enabled) - lpt_ports[i].irq = irq; - else - lpt_ports[i].irq = 0xff; -} - -void -lpt_port_remove(int i) -{ - if (lpt_ports[i].enabled && (lpt_ports[i].addr != 0xffff)) { - io_removehandler(lpt_ports[i].addr, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]); - lpt_ports[i].addr = 0xffff; - } -} - -void -lpt1_remove_ams(void) -{ - if (lpt_ports[0].enabled) - io_removehandler(lpt_ports[0].addr + 1, 0x0002, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[0]); -} diff --git a/src/network/net_plip.c b/src/network/net_plip.c index 8c46213c6..ac8ab2850 100644 --- a/src/network/net_plip.c +++ b/src/network/net_plip.c @@ -488,15 +488,18 @@ plip_close(void *priv) } const lpt_device_t lpt_plip_device = { - .name = "Parallel Line Internet Protocol", - .internal_name = "plip", - .init = plip_lpt_init, - .close = plip_close, - .write_data = plip_write_data, - .write_ctrl = plip_write_ctrl, - .read_data = NULL, - .read_status = plip_read_status, - .read_ctrl = NULL + .name = "Parallel Line Internet Protocol", + .internal_name = "plip", + .init = plip_lpt_init, + .close = plip_close, + .write_data = plip_write_data, + .write_ctrl = plip_write_ctrl, + .autofeed = NULL, + .strobe = NULL, + .read_status = plip_read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; const device_t plip_device = { diff --git a/src/printer/prt_escp.c b/src/printer/prt_escp.c index f238341c5..41c81e696 100644 --- a/src/printer/prt_escp.c +++ b/src/printer/prt_escp.c @@ -1881,6 +1881,39 @@ write_data(uint8_t val, void *priv) dev->data = val; } +static void +autofeed(uint8_t val, void *priv) +{ + escp_t *dev = (escp_t *) priv; + + if (dev == NULL) + return; + + dev->autofeed = ((val & 0x02) > 0); +} + +static void +strobe(uint8_t old, uint8_t val, void *priv) +{ + escp_t *dev = (escp_t *) priv; + + if (dev == NULL) + return; + + /* Data is strobed to the parallel printer on the falling edge of the + strobe bit. */ + if (!(val & 0x01) && (old & 0x01)) { + /* Process incoming character. */ + handle_char(dev, dev->data); + + /* ACK it, will be read on next READ STATUS. */ + dev->ack = 1; + timer_set_delay_u64(&dev->pulse_timer, ISACONST); + + timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC); + } +} + static void write_ctrl(uint8_t val, void *priv) { @@ -1919,14 +1952,6 @@ write_ctrl(uint8_t val, void *priv) dev->autofeed = ((val & 0x02) > 0); } -static uint8_t -read_data(void *priv) -{ - const escp_t *dev = (escp_t *) priv; - - return dev->data; -} - static uint8_t read_ctrl(void *priv) { @@ -2058,13 +2083,16 @@ escp_close(void *priv) } const lpt_device_t lpt_prt_escp_device = { - .name = "Generic ESC/P Dot-Matrix Printer", - .internal_name = "dot_matrix", - .init = escp_init, - .close = escp_close, - .write_data = write_data, - .write_ctrl = write_ctrl, - .read_data = read_data, - .read_status = read_status, - .read_ctrl = read_ctrl + .name = "Generic ESC/P Dot-Matrix", + .internal_name = "dot_matrix", + .init = escp_init, + .close = escp_close, + .write_data = write_data, + .write_ctrl = write_ctrl, + .autofeed = autofeed, + .strobe = strobe, + .read_status = read_status, + .read_ctrl = read_ctrl, + .epp_write_data = NULL, + .epp_request_read = NULL }; diff --git a/src/printer/prt_ps.c b/src/printer/prt_ps.c index 1298018ee..904ff34ad 100644 --- a/src/printer/prt_ps.c +++ b/src/printer/prt_ps.c @@ -319,6 +319,35 @@ process_data(ps_t *dev) dev->buffer[dev->buffer_pos] = 0; } +static void +ps_autofeed(uint8_t val, void *priv) +{ + ps_t *dev = (ps_t *) priv; + + if (dev == NULL) + return; + + dev->autofeed = val & 0x02 ? true : false; +} + +static void +ps_strobe(uint8_t old, uint8_t val, void *priv) +{ + ps_t *dev = (ps_t *) priv; + + if (dev == NULL) + return; + + if (!(val & 0x01) && (old & 0x01)) { + process_data(dev); + + dev->ack = true; + + timer_set_delay_u64(&dev->pulse_timer, ISACONST); + timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC); + } +} + static void ps_write_ctrl(uint8_t val, void *priv) { @@ -479,27 +508,33 @@ ps_close(void *priv) } const lpt_device_t lpt_prt_ps_device = { - .name = "Generic PostScript Printer", - .internal_name = "postscript", - .init = ps_init, - .close = ps_close, - .write_data = ps_write_data, - .write_ctrl = ps_write_ctrl, - .read_data = NULL, - .read_status = ps_read_status, - .read_ctrl = NULL + .name = "Generic PostScript Printer", + .internal_name = "postscript", + .init = ps_init, + .close = ps_close, + .write_data = ps_write_data, + .write_ctrl = ps_write_ctrl, + .autofeed = ps_autofeed, + .strobe = ps_strobe, + .read_status = ps_read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; #ifdef USE_PCL const lpt_device_t lpt_prt_pcl_device = { - .name = "Generic PCL5e Printer", - .internal_name = "pcl", - .init = pcl_init, - .close = ps_close, - .write_data = ps_write_data, - .write_ctrl = ps_write_ctrl, - .read_data = NULL, - .read_status = ps_read_status, - .read_ctrl = NULL + .name = "Generic PCL5e Printer", + .internal_name = "pcl", + .init = pcl_init, + .close = ps_close, + .write_data = ps_write_data, + .write_ctrl = ps_write_ctrl, + .autofeed = ps_autofeed, + .strobe = ps_strobe, + .read_status = ps_read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; #endif diff --git a/src/printer/prt_text.c b/src/printer/prt_text.c index e04ef9680..7604d023e 100644 --- a/src/printer/prt_text.c +++ b/src/printer/prt_text.c @@ -367,6 +367,38 @@ write_data(uint8_t val, void *priv) dev->data = val; } +static void +autofeed(uint8_t val, void *priv) +{ + prnt_t *dev = (prnt_t *) priv; + + if (dev == NULL) + return; + + /* set autofeed value */ + dev->autofeed = val & 0x02 ? 1 : 0; +} + +static void +strobe(uint8_t old, uint8_t val, void *priv) +{ + prnt_t *dev = (prnt_t *) priv; + + if (dev == NULL) + return; + + if (!(val & 0x01) && (old & 0x01)) { /* STROBE */ + /* Process incoming character. */ + handle_char(dev); + + /* ACK it, will be read on next READ STATUS. */ + dev->ack = 1; + + timer_set_delay_u64(&dev->pulse_timer, ISACONST); + timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC); + } +} + static void write_ctrl(uint8_t val, void *priv) { @@ -465,13 +497,16 @@ prnt_close(void *priv) } const lpt_device_t lpt_prt_text_device = { - .name = "Generic Text Printer", - .internal_name = "text_prt", - .init = prnt_init, - .close = prnt_close, - .write_data = write_data, - .write_ctrl = write_ctrl, - .read_data = NULL, - .read_status = read_status, - .read_ctrl = NULL + .name = "Generic Text Printer", + .internal_name = "text_prt", + .init = prnt_init, + .close = prnt_close, + .write_data = write_data, + .write_ctrl = write_ctrl, + .autofeed = autofeed, + .strobe = strobe, + .read_status = read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; diff --git a/src/sio/sio_ali5123.c b/src/sio/sio_ali5123.c index 398d00839..436e425d2 100644 --- a/src/sio/sio_ali5123.c +++ b/src/sio/sio_ali5123.c @@ -85,11 +85,18 @@ ali5123_lpt_handler(ali5123_t *dev) uint8_t global_enable = !(dev->regs[0x22] & (1 << 3)); uint8_t local_enable = !!dev->ld_regs[3][0x30]; uint8_t lpt_irq = dev->ld_regs[3][0x70]; + uint8_t lpt_dma = dev->ld_regs[3][0x74]; if (lpt_irq > 15) lpt_irq = 0xff; + if (lpt_dma == 4) + lpt_dma = 0xff; + lpt1_remove(); + lpt_set_epp(0, !!(dev->ld_regs[3][0xf0] & 0x01)); + lpt_set_ecp(0, !!(dev->ld_regs[3][0xf0] & 0x02)); + lpt_set_ext(0, !(dev->ld_regs[3][0xf0] & 0x04) || !!(dev->ld_regs[3][0xf1] & 0x80)); if (global_enable && local_enable) { ld_port = make_port(dev, 3) & 0xFFFC; if ((ld_port >= 0x0100) && (ld_port <= 0x0FFC)) @@ -247,7 +254,7 @@ ali5123_write(uint16_t port, uint8_t val, void *priv) dev->regs[dev->cur_reg] = val; } else { valxor = val ^ dev->ld_regs[cur_ld][dev->cur_reg]; - if (((dev->cur_reg & 0xf0) == 0x70) && (cur_ld < 4)) + if (((dev->cur_reg & 0xf0) == 0x70) && (cur_ld < 4) && (cur_ld != 3)) return; /* Block writes to some logical devices. */ if (cur_ld > 0x0c) @@ -357,6 +364,9 @@ ali5123_write(uint16_t port, uint8_t val, void *priv) case 0x60: case 0x61: case 0x70: + case 0x74: + case 0xf0: + case 0xf1: if ((dev->cur_reg == 0x30) && (val & 0x01)) dev->regs[0x22] &= ~0x08; if (valxor) diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index 41d69b0cc..e42c48ab4 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -121,6 +121,10 @@ lpt1_handler(pc87306_t *dev) uint16_t lptba; uint16_t lpt_port = LPT1_ADDR; uint8_t lpt_irq = LPT2_IRQ; + uint8_t lpt_dma = ((dev->regs[0x18] & 0x06) >> 1); + + if (lpt_dma == 0x00) + lpt_dma = 0xff; temp = dev->regs[0x01] & 3; lptba = ((uint16_t) dev->regs[0x19]) << 2; @@ -157,6 +161,13 @@ lpt1_handler(pc87306_t *dev) lpt1_setup(lpt_port); lpt1_irq(lpt_irq); + + lpt_port_dma(0, lpt_dma); + + lpt_set_ext(0, !!(dev->regs[0x02] & 0x80)); + + lpt_set_epp(0, !!(dev->regs[0x04] & 0x01)); + lpt_set_ecp(0, !!(dev->regs[0x04] & 0x04)); } static void @@ -169,7 +180,7 @@ serial_handler(pc87306_t *dev, int uart) uint8_t pnp_shift; uint8_t irq; - temp = (dev->regs[1] >> (2 << uart)) & 3; + temp = (dev->regs[0x01] >> (2 << uart)) & 3; fer_shift = 2 << uart; /* 2 for UART 1, 4 for UART 2 */ pnp_shift = 2 + (uart << 2); /* 2 for UART 1, 6 for UART 2 */ @@ -188,7 +199,7 @@ serial_handler(pc87306_t *dev, int uart) serial_setup(dev->uart[uart], COM2_ADDR, irq); break; case 2: - switch ((dev->regs[1] >> 6) & 3) { + switch ((dev->regs[0x01] >> 6) & 3) { case 0: serial_setup(dev->uart[uart], COM3_ADDR, irq); break; @@ -207,7 +218,7 @@ serial_handler(pc87306_t *dev, int uart) } break; case 3: - switch ((dev->regs[1] >> 6) & 3) { + switch ((dev->regs[0x01] >> 6) & 3) { case 0: serial_setup(dev->uart[uart], COM4_ADDR, irq); break; @@ -264,41 +275,41 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) switch (dev->cur_reg) { case 0x00: - if (valxor & 1) { + if (valxor & 0x01) { lpt1_remove(); - if ((val & 1) && !(dev->regs[2] & 1)) + if ((val & 1) && !(dev->regs[0x02] & 1)) lpt1_handler(dev); } - if (valxor & 2) { - serial_remove(dev->uart[0]); - if ((val & 2) && !(dev->regs[2] & 1)) + if (valxor & 0x02) { + serial_remove(dev->uart[0x00]); + if ((val & 2) && !(dev->regs[0x02] & 1)) serial_handler(dev, 0); } - if (valxor & 4) { - serial_remove(dev->uart[1]); - if ((val & 4) && !(dev->regs[2] & 1)) + if (valxor & 0x04) { + serial_remove(dev->uart[0x01]); + if ((val & 4) && !(dev->regs[0x02] & 1)) serial_handler(dev, 1); } if (valxor & 0x28) { fdc_remove(dev->fdc); - if ((val & 8) && !(dev->regs[2] & 1)) + if ((val & 8) && !(dev->regs[0x02] & 1)) fdc_set_base(dev->fdc, (val & 0x20) ? FDC_SECONDARY_ADDR : FDC_PRIMARY_ADDR); } break; case 0x01: - if (valxor & 3) { + if (valxor & 0x03) { lpt1_remove(); - if ((dev->regs[0] & 1) && !(dev->regs[2] & 1)) + if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1)) lpt1_handler(dev); } if (valxor & 0xcc) { - serial_remove(dev->uart[0]); - if ((dev->regs[0] & 2) && !(dev->regs[2] & 1)) + serial_remove(dev->uart[0x00]); + if ((dev->regs[0x00] & 2) && !(dev->regs[0x02] & 1)) serial_handler(dev, 0); } if (valxor & 0xf0) { - serial_remove(dev->uart[1]); - if ((dev->regs[0] & 4) && !(dev->regs[2] & 1)) + serial_remove(dev->uart[0x01]); + if ((dev->regs[0x00] & 4) && !(dev->regs[0x02] & 1)) serial_handler(dev, 1); } break; @@ -327,6 +338,11 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) } break; case 0x04: + if (valxor & (0x05)) { + lpt1_remove(); + if ((dev->regs[0x00] & 0x01) && !(dev->regs[0x02] & 0x01)) + lpt1_handler(dev); + } if (valxor & 0x80) nvr_lock_set(0x00, 256, !!(val & 0x80), dev->nvr); break; @@ -352,10 +368,17 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) if (valxor & 0x30) pc87306_gpio_handler(dev); break; + case 0x18: + if (valxor & (0x06)) { + lpt1_remove(); + if ((dev->regs[0x00] & 0x01) && !(dev->regs[0x02] & 0x01)) + lpt1_handler(dev); + } + break; case 0x19: if (valxor) { lpt1_remove(); - if ((dev->regs[0] & 1) && !(dev->regs[2] & 1)) + if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1)) lpt1_handler(dev); } break; @@ -364,18 +387,18 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) lpt1_remove(); if (!(val & 0x40)) dev->regs[0x19] = 0xEF; - if ((dev->regs[0] & 1) && !(dev->regs[2] & 1)) + if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1)) lpt1_handler(dev); } break; case 0x1c: if (valxor) { - serial_remove(dev->uart[0]); - serial_remove(dev->uart[1]); + serial_remove(dev->uart[0x00]); + serial_remove(dev->uart[0x01]); - if ((dev->regs[0] & 2) && !(dev->regs[2] & 1)) + if ((dev->regs[0x00] & 2) && !(dev->regs[0x02] & 1)) serial_handler(dev, 0); - if ((dev->regs[0] & 4) && !(dev->regs[2] & 1)) + if ((dev->regs[0x00] & 4) && !(dev->regs[0x02] & 1)) serial_handler(dev, 1); } break; @@ -432,8 +455,8 @@ pc87306_reset_common(void *priv) */ lpt1_remove(); lpt1_handler(dev); - serial_remove(dev->uart[0]); - serial_remove(dev->uart[1]); + serial_remove(dev->uart[0x00]); + serial_remove(dev->uart[0x01]); serial_handler(dev, 0); serial_handler(dev, 1); fdc_reset(dev->fdc); @@ -471,8 +494,8 @@ pc87306_init(UNUSED(const device_t *info)) dev->fdc = device_add(&fdc_at_nsc_device); - dev->uart[0] = device_add_inst(&ns16550_device, 1); - dev->uart[1] = device_add_inst(&ns16550_device, 2); + dev->uart[0x00] = device_add_inst(&ns16550_device, 1); + dev->uart[0x01] = device_add_inst(&ns16550_device, 2); dev->nvr = device_add(&at_mb_nvr_device); diff --git a/src/sound/snd_lpt_dac.c b/src/sound/snd_lpt_dac.c index 0462818a0..13a430c91 100644 --- a/src/sound/snd_lpt_dac.c +++ b/src/sound/snd_lpt_dac.c @@ -50,6 +50,14 @@ dac_write_data(uint8_t val, void *priv) dac_update(lpt_dac); } +static void +dac_strobe(uint8_t old, uint8_t val, void *priv) +{ + lpt_dac_t *lpt_dac = (lpt_dac_t *) priv; + + lpt_dac->channel = val; +} + static void dac_write_ctrl(uint8_t val, void *priv) { @@ -109,25 +117,31 @@ dac_close(void *priv) } const lpt_device_t lpt_dac_device = { - .name = "LPT DAC / Covox Speech Thing", - .internal_name = "lpt_dac", - .init = dac_init, - .close = dac_close, - .write_data = dac_write_data, - .write_ctrl = dac_write_ctrl, - .read_data = NULL, - .read_status = dac_read_status, - .read_ctrl = NULL + .name = "LPT DAC / Covox Speech Thing", + .internal_name = "lpt_dac", + .init = dac_init, + .close = dac_close, + .write_data = dac_write_data, + .write_ctrl = dac_write_ctrl, + .autofeed = NULL, + .strobe = dac_strobe, + .read_status = dac_read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; const lpt_device_t lpt_dac_stereo_device = { - .name = "Stereo LPT DAC", - .internal_name = "lpt_dac_stereo", - .init = dac_stereo_init, - .close = dac_close, - .write_data = dac_write_data, - .write_ctrl = dac_write_ctrl, - .read_data = NULL, - .read_status = dac_read_status, - .read_ctrl = NULL + .name = "Stereo LPT DAC", + .internal_name = "lpt_dac_stereo", + .init = dac_stereo_init, + .close = dac_close, + .write_data = dac_write_data, + .write_ctrl = dac_write_ctrl, + .autofeed = NULL, + .strobe = dac_strobe, + .read_status = dac_read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; diff --git a/src/sound/snd_lpt_dss.c b/src/sound/snd_lpt_dss.c index 875230518..b609e3add 100644 --- a/src/sound/snd_lpt_dss.c +++ b/src/sound/snd_lpt_dss.c @@ -133,13 +133,16 @@ dss_close(void *priv) } const lpt_device_t dss_device = { - .name = "Disney Sound Source", - .internal_name = "dss", - .init = dss_init, - .close = dss_close, - .write_data = dss_write_data, - .write_ctrl = dss_write_ctrl, - .read_data = NULL, - .read_status = dss_read_status, - .read_ctrl = NULL + .name = "Disney Sound Source", + .internal_name = "dss", + .init = dss_init, + .close = dss_close, + .write_data = dss_write_data, + .autofeed = NULL, + .strobe = NULL, + .write_ctrl = dss_write_ctrl, + .read_status = dss_read_status, + .read_ctrl = NULL, + .epp_write_data = NULL, + .epp_request_read = NULL }; From 33cee0cc46a504b561f93bbf6716715417b46242 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Tue, 24 Jun 2025 18:46:45 +0200 Subject: [PATCH 009/103] fix for conflicting types of Display --- src/qt/qt_vmmanager_details.cpp | 2 ++ src/qt/qt_vmmanager_detailsection.cpp | 1 + src/qt/qt_vmmanager_detailsection.hpp | 2 +- src/qt/qt_vmmanager_system.cpp | 2 ++ src/qt/qt_vmmanager_system.hpp | 7 +++++-- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qt/qt_vmmanager_details.cpp b/src/qt/qt_vmmanager_details.cpp index 23fe5377e..a834e35f8 100644 --- a/src/qt/qt_vmmanager_details.cpp +++ b/src/qt/qt_vmmanager_details.cpp @@ -26,6 +26,8 @@ extern bool windows_is_light_theme(); #endif +using namespace VMManager; + VMManagerDetails::VMManagerDetails(QWidget *parent) : QWidget(parent), ui(new Ui::VMManagerDetails) { ui->setupUi(this); diff --git a/src/qt/qt_vmmanager_detailsection.cpp b/src/qt/qt_vmmanager_detailsection.cpp index bd080e00c..ce42ae281 100644 --- a/src/qt/qt_vmmanager_detailsection.cpp +++ b/src/qt/qt_vmmanager_detailsection.cpp @@ -21,6 +21,7 @@ #include const QString VMManagerDetailSection::sectionSeparator = ";"; +using namespace VMManager; VMManagerDetailSection:: VMManagerDetailSection(const QString §ionName) diff --git a/src/qt/qt_vmmanager_detailsection.hpp b/src/qt/qt_vmmanager_detailsection.hpp index 2eb63685a..7619a476c 100644 --- a/src/qt/qt_vmmanager_detailsection.hpp +++ b/src/qt/qt_vmmanager_detailsection.hpp @@ -60,7 +60,7 @@ public: ~VMManagerDetailSection() override; - void addSection(const QString &name, const QString &value, Display::Name displayField = Display::Name::Unknown); + void addSection(const QString &name, const QString &value, VMManager::Display::Name displayField = VMManager::Display::Name::Unknown); void clear(); CollapseButton *collapseButton; diff --git a/src/qt/qt_vmmanager_system.cpp b/src/qt/qt_vmmanager_system.cpp index 08853feab..7ab7e43ca 100644 --- a/src/qt/qt_vmmanager_system.cpp +++ b/src/qt/qt_vmmanager_system.cpp @@ -51,6 +51,8 @@ extern "C" { #include <86box/mouse.h> } +using namespace VMManager; + VMManagerSystem::VMManagerSystem(const QString &sysconfig_file) { // The 86Box configuration file diff --git a/src/qt/qt_vmmanager_system.hpp b/src/qt/qt_vmmanager_system.hpp index ab2069617..6ac0a7635 100644 --- a/src/qt/qt_vmmanager_system.hpp +++ b/src/qt/qt_vmmanager_system.hpp @@ -34,6 +34,8 @@ inline uint qHash(const T &t, uint seed) { \ return ::qHash(static_cast::type>(t), seed); \ } +namespace VMManager { +Q_NAMESPACE namespace Display { Q_NAMESPACE enum class Name { @@ -58,11 +60,12 @@ enum class Name { Q_ENUM_NS(Name) QHASH_FOR_CLASS_ENUM(Name) } +} class VMManagerSystem : public QWidget { Q_OBJECT - typedef QHash display_table_t; + typedef QHash display_table_t; typedef QHash > config_hash_t; public: @@ -127,7 +130,7 @@ public: bool window_obscured; - QString getDisplayValue(Display::Name key); + QString getDisplayValue(VMManager::Display::Name key); QFileInfoList getScreenshots(); inline bool operator==(const VMManagerSystem &rhs) const From 9040aa1b7084a24e75b63018812f88ae60dc3162 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 24 Jun 2025 14:34:39 -0400 Subject: [PATCH 010/103] Missed bit in lpt.c --- src/device/lpt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/device/lpt.c b/src/device/lpt.c index 179dc9a2d..11afc04f9 100644 --- a/src/device/lpt.c +++ b/src/device/lpt.c @@ -46,7 +46,9 @@ static const struct { {"text_prt", &lpt_prt_text_device }, {"dot_matrix", &lpt_prt_escp_device }, {"postscript", &lpt_prt_ps_device }, +#ifdef USE_PCL {"pcl", &lpt_prt_pcl_device }, +#endif {"plip", &lpt_plip_device }, {"dongle_savquest", &lpt_hasp_savquest_device }, {"", NULL } From de1a3da5a7fe7f8beed0b1808419ae97caf5629c Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Tue, 24 Jun 2025 23:30:45 +0200 Subject: [PATCH 011/103] Add Alaris Cobalt LPX machine code. --- src/machine/m_at_386dx_486.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 0c0582c3c..333bcfd92 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -2869,6 +2869,35 @@ machine_at_ga486l_init(const machine_t *model) return ret; } +int +machine_at_cobalt_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear("roms/machines/cobalt/Cobalt_2.3.BIN", + 0x000e0000, 131072, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init(model); + + device_add(&opti499_device); + device_add(&ide_opti611_vlb_device); + device_add(&ide_isa_sec_device); + device_add(&fdc37c665_device); + + device_add(&keyboard_ps2_ami_device); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + + if (fdc_current[0] == FDC_INTERNAL) + device_add(&fdc_at_device); + + return ret; +} + int machine_at_cougar_init(const machine_t *model) { From 066e7cc5eea6dbf9bb7fc58623b562b7a0759978 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Tue, 24 Jun 2025 23:31:23 +0200 Subject: [PATCH 012/103] Add Alaris Cobalt LPX machine table entry. --- src/machine/machine_table.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 3f324f4d6..2b7da7494 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -7179,6 +7179,45 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + { + .name = "[OPTi 499] Alaris Cobalt LPX", + .internal_name = "cobalt", + .type = MACHINE_TYPE_486_S2, + .chipset = MACHINE_CHIPSET_OPTI_499, + .init = machine_at_cobalt_init, + .p1_handler = NULL, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET3 | CPU_PKG_486BL, + .block = CPU_BLOCK_NONE, + .min_bus = 0, + .max_bus = 0, + .min_voltage = 0, + .max_voltage = 0, + .min_multi = 0, + .max_multi = 0 + }, + .bus_flags = MACHINE_PS2_VLB, + .flags = MACHINE_APM | MACHINE_VIDEO | MACHINE_IDE_DUAL, + .ram = { + .min = 1024, + .max = 65536, + .step = 1024 + }, + .nvrmask = 127, + .kbc_device = NULL, + .kbc_p1 = 0xff, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = &gd5428_vlb_onboard_device, + .snd_device = NULL, + .net_device = NULL + }, /* Has AMIKey-2 'H' KBC firmware. */ { .name = "[OPTi 499] Alaris COUGAR 486BL", From ca1390f3bb25e4bf67671fbc2efa98beaac4ca07 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Tue, 24 Jun 2025 23:32:05 +0200 Subject: [PATCH 013/103] Add Alaris Cobalt LPX machine definition. --- src/include/86box/machine.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 90b596ae8..39fb1a933 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -517,6 +517,7 @@ extern int machine_at_dataexpert386wb_init(const machine_t *); extern int machine_at_isa486c_init(const machine_t *); extern int machine_at_genoa486_init(const machine_t *); extern int machine_at_ga486l_init(const machine_t *); +extern int machine_at_cobalt_init(const machine_t *); extern int machine_at_cougar_init(const machine_t *); extern int machine_at_acc386_init(const machine_t *); From 6e695512f7a21a90464d9921326320e10c419abc Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Tue, 24 Jun 2025 23:49:29 +0200 Subject: [PATCH 014/103] Block usage of Pentium OverDrive on the Alaris Cobalt LPX. It won't post with it. --- src/machine/machine_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 2b7da7494..e779eb753 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -7191,7 +7191,7 @@ const machine_t machines[] = { .gpio_acpi_handler = NULL, .cpu = { .package = CPU_PKG_SOCKET3 | CPU_PKG_486BL, - .block = CPU_BLOCK_NONE, + .block = CPU_BLOCK(CPU_P24T), .min_bus = 0, .max_bus = 0, .min_voltage = 0, From 2e4eed0ac02c836104fe9fba50fa539b4e6ed538 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 04:45:40 +0200 Subject: [PATCH 015/103] Assorted ACC 2036 and OAK OTi-037 fixes, fixes #5697. --- src/chipset/acc2036.c | 2 +- src/device/kbc_at.c | 4 +--- src/video/vid_oak_oti.c | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/chipset/acc2036.c b/src/chipset/acc2036.c index 225c22813..3984f82e0 100644 --- a/src/chipset/acc2036.c +++ b/src/chipset/acc2036.c @@ -158,7 +158,7 @@ acc2036_recalc(acc2036_t *dev) /* 0E0000-0FFFFF */ master_write = dev->regs[0x02] & 0x02; master_read = dev->regs[0x02] & 0x01; - bit = (((i - 8) >> 2) + 2); + bit = ((i - 8) >> 2); val = dev->regs[0x0c] & (1 << bit); if (i >= 20) { ew_flag = MEM_WRITE_EXTANY; diff --git a/src/device/kbc_at.c b/src/device/kbc_at.c index 1338b9555..d19b08f84 100644 --- a/src/device/kbc_at.c +++ b/src/device/kbc_at.c @@ -1817,8 +1817,6 @@ read_p1(atkbc_t *dev) Compaq: Reserved; NCR: DMA mode. */ - kbc_at_log("ATkbc: read P1\n"); - fixed_bits = 4; /* The SMM handlers of Intel AMI Pentium BIOS'es expect bit 6 to be set. */ @@ -2108,7 +2106,7 @@ kbc_at_process_cmd(void *priv) break; case 0xc0: /* read P1 */ - kbc_at_log("ATkbc: read P2\n"); + kbc_at_log("ATkbc: read P1\n"); kbc_delay_to_ob(dev, read_p1(dev), 0, 0x00); break; diff --git a/src/video/vid_oak_oti.c b/src/video/vid_oak_oti.c index 3233f9d00..3ea935b06 100644 --- a/src/video/vid_oak_oti.c +++ b/src/video/vid_oak_oti.c @@ -55,6 +55,7 @@ typedef struct { rom_t bios_rom; int index; + int en_map; uint8_t regs[32]; uint8_t chip_id; @@ -88,6 +89,12 @@ oti_out(uint16_t addr, uint8_t val, void *priv) case 0x3c3: if (!oti->chip_id) { oti->enable_register = val & 1; + if ((val & 0x01) && oti->en_map) + mem_mapping_enable(&svga->mapping); + else if (!(val & 0x01)) { + oti->en_map = svga->mapping.enable; + mem_mapping_disable(&svga->mapping); + } return; } svga_out(addr, val, svga); @@ -245,11 +252,14 @@ oti_in(uint16_t addr, void *priv) case 0x3c8: case 0x3c9: if (oti->chip_id == OTI_077 || oti->chip_id == OTI_077_ACER100T) - return sc1148x_ramdac_in(addr, 0, svga->ramdac, svga); - return svga_in(addr, svga); + temp = sc1148x_ramdac_in(addr, 0, svga->ramdac, svga); + else + temp = svga_in(addr, svga); + break; case 0x3CF: - return svga->gdcreg[svga->gdcaddr & 0xf]; + temp = svga->gdcreg[svga->gdcaddr & 0xf]; + break; case 0x3d4: temp = svga->crtcreg; From cbdfa32e6513872f8e2b1de8aa3ac54f19390c1a Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 05:42:50 +0200 Subject: [PATCH 016/103] Reset the FIFO and update its lengths on test mode set/reset, fixes #5702. --- src/floppy/fdc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 186d4c894..523ae6948 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -191,7 +191,7 @@ fdc_ctrl_reset(void *priv) fdc->step = 0; fdc->power_down = 0; - if (!fdc->lock) { + if (!fdc->lock && !fdc->fifointest) { fdc->fifo = 0; fdc->tfifo = 1; @@ -808,6 +808,9 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->tfifo = 1; fdc->fifointest = 0; } + fifo_reset(fdc->fifo_p); + fifo_set_len(fdc->fifo_p, fdc->tfifo + 1); + fifo_set_trigger_len(fdc->fifo_p, fdc->tfifo + 1); } return; case 4: /* DSR */ From 6d7ab90fd3caff47545c339a3f67098d15adcced Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 05:56:55 +0200 Subject: [PATCH 017/103] Alaris Cobalt machine fixes. --- src/machine/m_at_386dx_486.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 333bcfd92..09efd51bf 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -2880,21 +2880,18 @@ machine_at_cobalt_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_at_common_init(model); + machine_at_common_init(model); device_add(&opti499_device); - device_add(&ide_opti611_vlb_device); - device_add(&ide_isa_sec_device); - device_add(&fdc37c665_device); + device_add(&ide_opti611_vlb_device); + device_add(&ide_isa_sec_device); + device_add(&fdc37c665_device); device_add(&keyboard_ps2_ami_device); - if (gfxcard[0] == VID_INTERNAL) + if (gfxcard[0] == VID_INTERNAL) device_add(machine_get_vid_device(machine)); - if (fdc_current[0] == FDC_INTERNAL) - device_add(&fdc_at_device); - return ret; } From 609a7e45498009de791772e969dc95f2d7e683e1 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 19:31:14 +0200 Subject: [PATCH 018/103] Only enable the change introduced in build 6807 for VLB Mach64GX, fixes #5701. --- src/video/vid_ati_mach64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 74086dab1..8e6b52517 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -94,6 +94,7 @@ typedef struct mach64_t { int type; int pci; + int vlb; uint8_t pci_slot; uint8_t irq_state; @@ -3857,7 +3858,7 @@ mach64_ext_outb(uint16_t port, uint8_t val, void *priv) case 0x6aee: case 0x6aef: WRITE8(port, mach64->config_cntl, val); - if (!mach64->pci) + if (mach64->vlb) mach64->linear_base = (mach64->config_cntl & 0x3ff0) << 18; mach64_updatemapping(mach64); @@ -4764,6 +4765,7 @@ mach64gx_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_mach64_vlb); mach64->pci = !!(info->flags & DEVICE_PCI); + mach64->vlb = !!(info->flags & DEVICE_VLB); mach64->pci_id = 'X' | ('G' << 8); mach64->config_chip_id = 0x000000d7; mach64->dac_cntl = 5 << 16; /*ATI 68860 RAMDAC*/ From 495ee9b9318cf13058f7ebf66ec78f492264ef82 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 19:35:59 +0200 Subject: [PATCH 019/103] MMU: Move the lookup tables to the heap in 64-bit builds and free them on exit in 32-bit builds, prevents memory leaks. --- src/86box.c | 4 ++++ src/include/86box/mem.h | 16 ++++++++++++++++ src/mem/mem.c | 26 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/src/86box.c b/src/86box.c index 8c07daa15..1c11d9bee 100644 --- a/src/86box.c +++ b/src/86box.c @@ -1656,6 +1656,10 @@ pc_close(UNUSED(thread_t *ptr)) scsi_disk_close(); gdbstub_close(); + +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) + mem_free(); +#endif } #ifdef __APPLE__ diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index 62cb493a5..53001b8db 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -265,12 +265,16 @@ extern uint32_t biosmask; extern uint32_t biosaddr; extern int readlookup[256]; +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) extern uintptr_t *readlookup2; +#endif extern uintptr_t old_rl2; extern uint8_t uncached; extern int readlnext; extern int writelookup[256]; +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) extern uintptr_t *writelookup2; +#endif extern int writelnext; extern uint32_t ram_mapped_addr[64]; extern uint8_t page_ff[4096]; @@ -288,7 +292,16 @@ extern mem_mapping_t bios_high_mapping; extern uint32_t mem_logical_addr; extern page_t *pages; +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) extern page_t **page_lookup; +#endif + +#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64) +/* The lookup tables. */ +extern page_t *page_lookup[1048576]; +extern uintptr_t readlookup2[1048576]; +extern uintptr_t writelookup2[1048576]; +#endif extern uint32_t get_phys_virt; extern uint32_t get_phys_phys; @@ -457,6 +470,9 @@ extern void mem_a20_init(void); extern void mem_a20_recalc(void); extern void mem_init(void); +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) +extern void mem_free(void); +#endif extern void mem_close(void); extern void mem_zero(void); extern void mem_reset(void); diff --git a/src/mem/mem.c b/src/mem/mem.c index d365ecffb..fa749002c 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -67,7 +67,9 @@ mem_mapping_t bios_mapping; mem_mapping_t bios_high_mapping; page_t *pages; /* RAM page table */ +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) page_t **page_lookup; /* pagetable lookup */ +#endif uint32_t pages_sz; /* #pages in table */ uint8_t *ram; /* the virtual RAM */ @@ -85,12 +87,23 @@ uint8_t *pccache2; int readlnext; int readlookup[256]; +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) uintptr_t *readlookup2; +#endif uintptr_t old_rl2; uint8_t uncached = 0; int writelnext; int writelookup[256]; +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) uintptr_t *writelookup2; +#endif + +#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64) +/* The lookup tables. */ +page_t *page_lookup[1048576] = { 0 }; +uintptr_t readlookup2[1048576] = { 0 }; +uintptr_t writelookup2[1048576] = { 0 }; +#endif uint32_t mem_logical_addr; @@ -2987,12 +3000,25 @@ mem_init(void) ram2 = NULL; pages = NULL; +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) /* Allocate the lookup tables. */ page_lookup = (page_t **) malloc((1 << 20) * sizeof(page_t *)); readlookup2 = malloc((1 << 20) * sizeof(uintptr_t)); writelookup2 = malloc((1 << 20) * sizeof(uintptr_t)); +#endif } +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) +void +mem_free(void) +{ + free(page_lookup); + free(readlookup2); + free(writelookup2); +} +#endif + + static void umc_page_recalc(uint32_t c, uint32_t phys, int set) { From a18c46e9190eea1b17329cb987934ef1c27f3c43 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 19:45:08 +0200 Subject: [PATCH 020/103] Sort the graphics cards table in the following order: ISA - ISA16 - MCA - VLB - PCI - AGP. --- src/video/vid_table.c | 122 ++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/src/video/vid_table.c b/src/video/vid_table.c index 33a7f30ca..b97defe8c 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -52,10 +52,10 @@ video_cards[] = { // clang-format off { .device = &device_none, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &device_internal, .flags = VIDEO_FLAG_TYPE_NONE }, + /* ISA */ { .device = &atiega800p_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &mach8_vga_isa_device, .flags = VIDEO_FLAG_TYPE_8514 }, { .device = &mach32_isa_device, .flags = VIDEO_FLAG_TYPE_8514 }, - { .device = &mach64gx_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &ati28800k_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &ati18800_vga88_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &ati28800_device, .flags = VIDEO_FLAG_TYPE_NONE }, @@ -71,15 +71,6 @@ video_cards[] = { { .device = &jega_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &gd5401_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &gd5402_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5420_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5422_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5426_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5426_diamond_speedstar_pro_a1_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5428_boca_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5428_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5429_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5434_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5434_diamond_speedstar_64_a3_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &compaq_cga_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &compaq_cga_2_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &cpqega_device, .flags = VIDEO_FLAG_TYPE_NONE }, @@ -88,7 +79,6 @@ video_cards[] = { { .device = &hercules_device, .flags = VIDEO_FLAG_TYPE_MDA }, { .device = &herculesplus_device, .flags = VIDEO_FLAG_TYPE_MDA }, { .device = &incolor_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &inmos_isa_device, .flags = VIDEO_FLAG_TYPE_XGA }, { .device = &im1024_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &iskra_ega_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &et4000_kasan_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, @@ -106,16 +96,8 @@ video_cards[] = { { .device = &colorplus_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &pgc_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &cga_pravetz_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &radius_svga_multiview_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &realtek_rtg3105_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &realtek_rtg3106_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_diamond_stealth_vram_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_orchid_86c911_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_ami_86c924_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_metheus_86c928_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_phoenix_86c801_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_spea_mirage_86c801_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_winner1000_805_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &sigma_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &tvga8900b_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &tvga8900d_device, .flags = VIDEO_FLAG_TYPE_NONE }, @@ -127,16 +109,76 @@ video_cards[] = { { .device = &et3000_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &et4000_tc6058af_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &et4000_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32i_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &vga_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &v7_vga_1024i_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &wy700_device, .flags = VIDEO_FLAG_TYPE_NONE }, + /* ISA16 */ + { .device = &mach64gx_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5420_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5422_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5426_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5426_diamond_speedstar_pro_a1_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5428_boca_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5428_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5429_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5434_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5434_diamond_speedstar_64_a3_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &inmos_isa_device, .flags = VIDEO_FLAG_TYPE_XGA }, + { .device = &radius_svga_multiview_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_diamond_stealth_vram_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_orchid_86c911_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_ami_86c924_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_metheus_86c928_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_phoenix_86c801_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_spea_mirage_86c801_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_winner1000_805_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32i_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, + /* MCA */ { .device = &mach32_mca_device, .flags = VIDEO_FLAG_TYPE_8514 }, { .device = &gd5426_mca_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &gd5428_mca_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &et4000_mca_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &radius_svga_multiview_mca_device, .flags = VIDEO_FLAG_TYPE_NONE }, + /* VLB */ + { .device = &mach32_vlb_device, .flags = VIDEO_FLAG_TYPE_8514 }, + { .device = &mach64gx_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32i_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32p_videomagic_revb_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32p_revc_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32p_cardex_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32p_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &et4000w32p_noncardex_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5424_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5426_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5428_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5428_diamond_speedstar_pro_b1_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5429_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5430_diamond_speedstar_pro_se_a8_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5430_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &gd5434_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_metheus_86c928_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_mirocrystal_8s_805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_mirocrystal_10sd_805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_phoenix_86c805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_spea_mirage_86c805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_diamond_stealth64_964_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_mirocrystal_20sv_964_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_mirocrystal_20sd_864_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_bahamas64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_phoenix_vision864_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_diamond_stealth_se_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_phoenix_trio32_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_diamond_stealth64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_9fx_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_phoenix_trio64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_spea_mirage_p64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_diamond_stealth64_968_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &s3_stb_powergraph_64_video_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &ht216_32_standalone_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &tgui9400cxi_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &tgui9440_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + /* PCI */ { .device = &mach32_pci_device, .flags = VIDEO_FLAG_TYPE_8514 }, { .device = &mach64gx_pci_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &mach64vt2_device, .flags = VIDEO_FLAG_TYPE_NONE }, @@ -200,43 +242,7 @@ video_cards[] = { { .device = &voodoo_3_1000_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &voodoo_3_2000_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &voodoo_3_3000_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &mach32_vlb_device, .flags = VIDEO_FLAG_TYPE_8514 }, - { .device = &mach64gx_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32i_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32p_videomagic_revb_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32p_revc_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32p_cardex_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32p_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &et4000w32p_noncardex_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5424_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5426_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5428_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5428_diamond_speedstar_pro_b1_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5429_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5430_diamond_speedstar_pro_se_a8_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5430_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &gd5434_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_metheus_86c928_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_mirocrystal_8s_805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_mirocrystal_10sd_805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_phoenix_86c805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_spea_mirage_86c805_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_diamond_stealth64_964_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_mirocrystal_20sv_964_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_mirocrystal_20sd_864_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_bahamas64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_phoenix_vision864_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_diamond_stealth_se_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_phoenix_trio32_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_diamond_stealth64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_9fx_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_phoenix_trio64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_spea_mirage_p64_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_diamond_stealth64_968_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &s3_stb_powergraph_64_video_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &ht216_32_standalone_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &tgui9400cxi_device, .flags = VIDEO_FLAG_TYPE_NONE }, - { .device = &tgui9440_vlb_device, .flags = VIDEO_FLAG_TYPE_NONE }, + /* AGP */ { .device = &s3_virge_357_agp_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &s3_diamond_stealth_4000_agp_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &s3_trio3d2x_agp_device, .flags = VIDEO_FLAG_TYPE_NONE }, From 1916a60d6cff1f2a5badd5661e14e96c7a99669f Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 19:49:26 +0200 Subject: [PATCH 021/103] svga_render_overscan_right(): Fix the calculation for the right overscan, fixes #5699. --- src/video/vid_svga_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index bdb496686..5cfcc8889 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -118,7 +118,7 @@ svga_render_overscan_right(svga_t *svga) return; uint32_t *line_ptr = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add + svga->hdisp]; - right = (overscan_x >> 1); + right = overscan_x - svga->left_overscan; for (int i = 0; i < right; i++) *line_ptr++ = svga->overscan_color; } From cd6a3ee48f0e6654b4be23ebb0d0aabc683230ce Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jun 2025 20:24:30 +0200 Subject: [PATCH 022/103] Applied the same sorting to hard disk controllers, network adapters, SCSI controllers, and sound cards as well. --- src/disk/hdc.c | 31 ++++++++++++++++------------ src/network/network.c | 31 +++++++++++++++++----------- src/scsi/scsi.c | 28 +++++++++++++++---------- src/sound/sound.c | 48 ++++++++++++++++++++++++------------------- 4 files changed, 81 insertions(+), 57 deletions(-) diff --git a/src/disk/hdc.c b/src/disk/hdc.c index 582c33428..ecd609476 100644 --- a/src/disk/hdc.c +++ b/src/disk/hdc.c @@ -56,35 +56,40 @@ static const struct { // clang-format off { &device_none }, { &device_internal }, - { &st506_xt_xebec_device }, - { &st506_xt_wdxt_gen_device }, + /* ISA */ + { &xtide_acculogic_device }, { &st506_xt_dtc5150x_device }, + { &st506_xt_xebec_device }, + { &xtide_device }, { &st506_xt_st11_m_device }, - { &st506_xt_wd1002a_wx1_device }, - { &st506_xt_wd1004a_wx1_device }, - { &st506_at_wd1003_device }, { &st506_xt_st11_r_device }, + { &st506_xt_victor_v86p_device }, { &st506_xt_wd1002a_27x_device }, + { &st506_xt_wd1002a_wx1_device }, { &st506_xt_wd1004_27x_device }, { &st506_xt_wd1004a_27x_device }, - { &st506_xt_victor_v86p_device }, - { &esdi_at_wd1007vse1_device }, + { &st506_xt_wd1004a_wx1_device }, + { &xta_wdxt150_device }, + { &st506_xt_wdxt_gen_device }, + /* ISA16 */ { &ide_isa_device }, { &ide_isa_2ch_device }, { &xtide_at_device }, { &xtide_at_2ch_device }, { &xtide_at_ps2_device }, { &xtide_at_ps2_2ch_device }, - { &xta_wdxt150_device }, - { &xtide_acculogic_device }, - { &xtide_device }, + { &st506_at_wd1003_device }, + { &esdi_at_wd1007vse1_device }, + /* MCA */ { &esdi_ps2_device }, { &esdi_integrated_device }, - { &ide_pci_device }, - { &ide_pci_2ch_device }, + { &mcide_device }, + /* VLB */ { &ide_vlb_device }, { &ide_vlb_2ch_device }, - { &mcide_device }, + /* PCI */ + { &ide_pci_device }, + { &ide_pci_2ch_device }, { NULL } // clang-format on }; diff --git a/src/network/network.c b/src/network/network.c index 239178a5d..c1ee82b65 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -85,36 +85,43 @@ static const NETWORK_CARD net_cards[] = { // clang-format off { &device_none }, { &device_internal }, + /* ISA */ { &threec501_device }, { &threec503_device }, - { &pcnet_am79c960_device }, - { &pcnet_am79c961_device }, - { &de220p_device }, { &ne1000_compat_device }, - { &ne2000_compat_device }, { &ne2000_compat_8bit_device }, { &ne1000_device }, - { &ne2000_device }, - { &pcnet_am79c960_eb_device }, - { &rtl8019as_pnp_device }, { &wd8003e_device }, { &wd8003eb_device }, { &wd8013ebt_device }, + /* COM */ + { &modem_device }, + /* LPT */ { &plip_device }, + /* ISA16 */ + { &pcnet_am79c960_device }, + { &pcnet_am79c961_device }, + { &de220p_device }, + { &ne2000_compat_device }, + { &ne2000_device }, + { &pcnet_am79c960_eb_device }, + { &rtl8019as_pnp_device }, + /* MCA */ { ðernext_mc_device }, { &wd8003eta_device }, { &wd8003ea_device }, { &wd8013epa_device }, + /* VLB */ + { &pcnet_am79c960_vlb_device }, + /* PCI */ { &pcnet_am79c973_device }, { &pcnet_am79c970a_device }, + { &dec_tulip_21140_device }, + { &dec_tulip_21040_device }, { &dec_tulip_device }, + { &dec_tulip_21140_vpc_device }, { &rtl8029as_device }, { &rtl8139c_plus_device }, - { &dec_tulip_21140_device }, - { &dec_tulip_21140_vpc_device }, - { &dec_tulip_21040_device }, - { &pcnet_am79c960_vlb_device }, - { &modem_device }, { NULL } // clang-format on }; diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index bbce63651..0b0ca7211 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -54,6 +54,14 @@ typedef const struct { static SCSI_CARD scsi_cards[] = { // clang-format off { &device_none, }, + /* ISA/Sidecar */ + { &scsi_ls2000_device, }, + /* ISA */ + { &scsi_lcs6821n_device, }, + { &scsi_rt1000b_device, }, + { &scsi_t128_device, }, + { &scsi_t130b_device, }, + /* ISA16 */ { &aha154xa_device, }, { &aha154xb_device, }, { &aha154xc_device, }, @@ -63,18 +71,19 @@ static SCSI_CARD scsi_cards[] = { { &buslogic_542bh_device, }, { &buslogic_545s_device, }, { &buslogic_545c_device, }, - { &scsi_ls2000_device, }, - { &scsi_lcs6821n_device, }, - { &scsi_rt1000b_device, }, - { &scsi_rt1000mc_device, }, - { &scsi_t128_device, }, - { &scsi_t228_device, }, - { &scsi_t130b_device, }, + /* MCA */ { &aha1640_device, }, { &buslogic_640a_device, }, - { &ncr53c90a_mca_device, }, { &spock_device, }, { &tribble_device, }, + { &ncr53c90a_mca_device, }, + { &scsi_rt1000mc_device, }, + { &scsi_t228_device, }, + /* VLB */ + { &buslogic_445s_device, }, + { &buslogic_445c_device, }, + /* PCI */ + { &am53c974_pci_device, }, { &buslogic_958d_pci_device, }, { &ncr53c810_pci_device, }, { &ncr53c815_pci_device, }, @@ -82,10 +91,7 @@ static SCSI_CARD scsi_cards[] = { { &ncr53c825a_pci_device, }, { &ncr53c860_pci_device, }, { &ncr53c875_pci_device, }, - { &am53c974_pci_device, }, { &dc390_pci_device, }, - { &buslogic_445s_device, }, - { &buslogic_445c_device, }, { NULL, }, // clang-format on }; diff --git a/src/sound/sound.c b/src/sound/sound.c index 7bf27a136..615df88bc 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -100,31 +100,45 @@ static const SOUND_CARD sound_cards[] = { // clang-format off { &device_none }, { &device_internal }, - { &acermagic_s20_device }, - { &mirosound_pcm10_device }, - { &adlib_device }, + /* ISA */ { &adgold_device }, - { &azt2316a_device }, - { &azt1605_device }, { &cms_device }, - { &cs4235_device }, - { &cs4236b_device }, { &ess_688_device }, { &ess_ess0100_pnp_device }, { &ess_1688_device }, { &ess_ess0102_pnp_device }, { &ess_ess0968_pnp_device }, - { &gus_device }, - { &gus_max_device }, + { &ssi2001_device }, + { &mmb_device }, + { &pasplus_device }, { &sb_1_device }, { &sb_15_device }, { &sb_2_device }, { &sb_pro_v1_device }, { &sb_pro_v2_device }, + { &entertainer_device }, + { &pssj_isa_device }, + { &tndy_device }, +#ifdef USE_LIBSERIALPORT /*The following devices required LIBSERIALPORT*/ + { &opl2board_device }, +#endif + /* ISA/Sidecar */ + { &adlib_device }, + /* ISA16 */ + { &acermagic_s20_device }, + { &azt2316a_device }, + { &azt1605_device }, + { &sb_goldfinch_device }, + { &cs4235_device }, + { &cs4236b_device }, + { &gus_device }, + { &gus_max_device }, + { &mirosound_pcm10_device }, + { &pas16_device }, + { &pas16d_device }, { &sb_16_device }, { &sb_16_pnp_device }, { &sb_16_pnp_ide_device }, - { &sb_goldfinch_device }, { &sb_32_pnp_device }, { &sb_awe32_device }, { &sb_awe32_pnp_device }, @@ -136,15 +150,8 @@ static const SOUND_CARD sound_cards[] = { { &sb_vibra16cl_device }, { &sb_vibra16s_device }, { &sb_vibra16xv_device }, - { &ssi2001_device }, - { &entertainer_device }, - { &mmb_device }, - { &pasplus_device }, - { &pas16_device }, - { &pas16d_device }, - { &pssj_isa_device }, - { &tndy_device }, { &wss_device }, + /* MCA */ { &adlib_mca_device }, { &ess_chipchat_16_mca_device }, { &ncr_business_audio_device }, @@ -153,17 +160,16 @@ static const SOUND_CARD sound_cards[] = { { &sb_16_reply_mca_device }, { &ess_soundpiper_16_mca_device }, { &ess_soundpiper_32_mca_device }, + /* PCI */ { &cmi8338_device }, { &cmi8738_device }, { &es1370_device }, { &es1371_device }, { &es1373_device }, { &ct5880_device }, + /* AC97 */ { &ad1881_device }, { &cs4297a_device }, -#ifdef USE_LIBSERIALPORT /*The following devices required LIBSERIALPORT*/ - { &opl2board_device }, -#endif { NULL } // clang-format on }; From 368834cbd7af6ea834b7975ad9d7ecb28c159fda Mon Sep 17 00:00:00 2001 From: Lili Kurek Date: Wed, 25 Jun 2025 21:05:16 +0000 Subject: [PATCH 023/103] Fix and update pl-PL.po --- src/qt/languages/pl-PL.po | 240 +++++++++++++++++++------------------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/src/qt/languages/pl-PL.po b/src/qt/languages/pl-PL.po index 7433c1d65..c8a7cb886 100644 --- a/src/qt/languages/pl-PL.po +++ b/src/qt/languages/pl-PL.po @@ -13,7 +13,7 @@ msgid "&Keyboard requires capture" msgstr "&Klawaitura wymaga przechwytu myszy" msgid "&Right CTRL is left ALT" -msgstr "&Prawy CTRL to lewy Alt" +msgstr "&Prawy CTRL to lewy ALT" msgid "&Hard Reset..." msgstr "&Twardy reset..." @@ -49,7 +49,7 @@ msgid "Re&nderer" msgstr "Re&nderer" msgid "&Qt (Software)" -msgstr "&Qt (Software)" +msgstr "&Qt (programowy)" msgid "Qt (&OpenGL)" msgstr "Qt (&OpenGL)" @@ -61,13 +61,13 @@ msgid "&VNC" msgstr "&VNC" msgid "Specify dimensions..." -msgstr "Określ rozmiary..." +msgstr "Określ wymiary..." msgid "F&orce 4:3 display ratio" msgstr "&Wymuś proporcje wyświetlania 4:3" msgid "&Window scale factor" -msgstr "&Czynnik skalowania okna" +msgstr "Współ&czynnik skalowania okna" msgid "&0.5x" msgstr "&0.5x" @@ -103,10 +103,10 @@ msgid "Filter method" msgstr "Metoda filtrowania" msgid "&Nearest" -msgstr "&Nearest" +msgstr "&Najbliższa" msgid "&Linear" -msgstr "&Linear" +msgstr "&Liniowa" msgid "Hi&DPI scaling" msgstr "Skalowanie Hi&DPI" @@ -145,7 +145,7 @@ msgid "RGB &Color" msgstr "RGB - &Kolorowy" msgid "&RGB Grayscale" -msgstr "&RGB - Skala szarości" +msgstr "&RGB - Skala odcieni szarości" msgid "&Amber monitor" msgstr "&Bursztynowy monitor" @@ -157,7 +157,7 @@ msgid "&White monitor" msgstr "&Biały monitor" msgid "Grayscale &conversion type" -msgstr "Typ konwersji &w skali szarości" +msgstr "Typ konwersji &w skali odcieni szarości" msgid "BT&601 (NTSC/PAL)" msgstr "BT&601 (NTSC/PAL)" @@ -166,13 +166,13 @@ msgid "BT&709 (HDTV)" msgstr "BT&709 (HDTV)" msgid "&Average" -msgstr "&Średni" +msgstr "&Średnia" msgid "CGA/PCjr/Tandy/E&GA/(S)VGA overscan" msgstr "Overscan dla CGA/PCjr/Tandy/E&GA/(S)VGA" msgid "Change contrast for &monochrome display" -msgstr "Zmień kontrast dla &monochromatycznego ekranu" +msgstr "Zmień kontrast ekranu &monochromatycznego" msgid "&Media" msgstr "&Nośnik" @@ -196,7 +196,7 @@ msgid "&Preferences..." msgstr "&Preferencje..." msgid "Enable &Discord integration" -msgstr "Włącz integrację z &Discord" +msgstr "Włącz integrację z &Discordem" msgid "Sound &gain..." msgstr "Wzmocnienie &dźwięku..." @@ -214,7 +214,7 @@ msgid "&Documentation..." msgstr "&Dokumentacja..." msgid "&About 86Box..." -msgstr "&O 86Box..." +msgstr "&O 86Boxie..." msgid "&New image..." msgstr "&Nowy obraz..." @@ -247,7 +247,7 @@ msgid "E&xport to 86F..." msgstr "E&ksportuj do 86F..." msgid "&Mute" -msgstr "&Ścisz" +msgstr "&Wycisz" msgid "E&mpty" msgstr "P&usty" @@ -256,13 +256,13 @@ msgid "Reload previous image" msgstr "Przeładuj poprzedni obraz" msgid "&Folder..." -msgstr "&Teczka..." +msgstr "&Folder..." msgid "Target &framerate" msgstr "Docelowa &liczba klatek na sekundę" msgid "&Sync with video" -msgstr "&Zsynchronizuj z wideo" +msgstr "&Zsynchronizuj z obrazem" msgid "&25 fps" msgstr "&25 fps" @@ -355,7 +355,7 @@ msgid "Speed:" msgstr "Szybkość:" msgid "Frequency:" -msgstr "Częstotliwość:" +msgstr "Taktowanie:" msgid "FPU:" msgstr "Jednostka FPU:" @@ -391,7 +391,7 @@ msgid "Video #2:" msgstr "Wideo 2:" msgid "Voodoo 1 or 2 Graphics" -msgstr "Grafika Voodoo 1 czy 2" +msgstr "Grafika Voodoo 1 lub 2" msgid "IBM 8514/A Graphics" msgstr "Grafika IBM 8514/A" @@ -505,10 +505,10 @@ msgid "FD Controller:" msgstr "Kontroler dyskietek:" msgid "Tertiary IDE Controller" -msgstr "Trzeciorzędowy kontroler IDE" +msgstr "Trzeciorzędny kontroler IDE" msgid "Quaternary IDE Controller" -msgstr "Czwartorzędowy kontroler IDE" +msgstr "Czwartorzędny kontroler IDE" msgid "SCSI" msgstr "SCSI" @@ -577,7 +577,7 @@ msgid "Floppy drives:" msgstr "Napędy dyskietek:" msgid "Turbo timings" -msgstr "Rozrządy Turbo" +msgstr "Timing Turbo" msgid "Check BPB" msgstr "Sprawdzaj BPB" @@ -628,7 +628,7 @@ msgid "Fatal error" msgstr "Fatalny błąd" msgid " - PAUSED" -msgstr " - PAUSED" +msgstr " - PAUZA" msgid "Speed" msgstr "Szybkość" @@ -664,19 +664,19 @@ msgid "Basic sector images" msgstr "Podstawowe obrazy sektorów" msgid "Surface images" -msgstr "Obrazy powierzchniowe" +msgstr "Obrazy powierzchni" msgid "Machine \"%hs\" is not available due to missing ROMs in the roms/machines directory. Switching to an available machine." -msgstr "Maszyna \"%hs\" nie jest dostępna, ponieważ brakuje obrazów ROM w katalogu roms/machines. Przełączanie na dostępną maszynę." +msgstr "Maszyna \"%hs\" nie jest dostępna, ponieważ brakuje ROM-ów w katalogu roms/machines. Przełączanie na dostępną maszynę." msgid "Video card \"%hs\" is not available due to missing ROMs in the roms/video directory. Switching to an available video card." -msgstr "Karta wideo \"%hs\" nie jest dostępna, ponieważ brakuje obrazów ROM w katalogu roms/video. Przełączanie na dostępną kartę wideo." +msgstr "Karta wideo \"%hs\" nie jest dostępna, ponieważ brakuje ROM-ów w katalogu roms/video. Przełączanie na dostępną kartę graficzną." msgid "Video card #2 \"%hs\" is not available due to missing ROMs in the roms/video directory. Disabling the second video card." -msgstr "Karta wideo 2 \"%hs\" nie jest dostępna, ponieważ brakuje obrazów ROM w katalogu roms/video. Wyłączenie drugiej karty graficznej." +msgstr "Karta wideo 2 \"%hs\" nie jest dostępna, ponieważ brakuje ROM-ów w katalogu roms/video. Wyłączenie drugiej karty graficznej." msgid "Device \"%hs\" is not available due to missing ROMs. Ignoring the device." -msgstr "Urządzenie \"%hs\" nie jest dostępne, ponieważ brakuje obrazów ROM. Ignorowanie urządzenia." +msgstr "Urządzenie \"%hs\" nie jest dostępne, ponieważ brakuje ROM-ów. Ignorowanie urządzenia." msgid "Machine" msgstr "Maszyna" @@ -697,7 +697,7 @@ msgid "Ports (COM & LPT)" msgstr "Porty (COM & LPT)" msgid "Storage controllers" -msgstr "Kontrolery pamięci" +msgstr "Kontrolery danych" msgid "Hard disks" msgstr "Dyski twarde" @@ -712,13 +712,13 @@ msgid "Other peripherals" msgstr "Inne urządzenia peryferyjne" msgid "Click to capture mouse" -msgstr "Kliknij w celu przechwycenia myszy" +msgstr "Kliknij, by przechwycić mysz" msgid "Press %1 to release mouse" -msgstr "Naciśnij klawisze %1 w celu uwolnienia myszy" +msgstr "Naciśnij %1 w celu uwolnienia myszy" msgid "Press %1 or middle button to release mouse" -msgstr "Naciśnij klawisze %1 lub środkowy przycisk w celu uwolnienia myszy" +msgstr "Naciśnij %1 lub środkowy przycisk w celu uwolnienia myszy" msgid "Bus" msgstr "Magistrala" @@ -742,7 +742,7 @@ msgid "Default" msgstr "Domyślny" msgid "%1 Wait state(s)" -msgstr "%1 Stany oczekiwania" +msgstr "%1 stany oczekiwania" msgid "Type" msgstr "Rodzaj" @@ -796,16 +796,16 @@ msgid "Advanced sector images" msgstr "Zaawansowane obrazy sektorów" msgid "Flux images" -msgstr "Flux images" +msgstr "Obrazy Flux" msgid "Are you sure you want to hard reset the emulated machine?" -msgstr "Jesteś pewien że chcesz wykonać twardy reset emulowanej maszyny?" +msgstr "Czy na pewno chcesz wykonać twardy reset emulowanej maszyny?" msgid "Are you sure you want to exit 86Box?" -msgstr "Jesteś pewien że chcesz zakończyć 86Box?" +msgstr "Czy na pewno chcesz zakończyć 86Box?" msgid "Unable to initialize Ghostscript" -msgstr "Nie można zainicjować Ghostscript" +msgstr "Nie można zainicjować Ghostscriptu" msgid "Unable to initialize GhostPCL" msgstr "Nie można zainicjować GhostPCL" @@ -817,7 +817,7 @@ msgid "MO images" msgstr "Obrazy MO" msgid "Welcome to 86Box!" -msgstr "Witamy w 86Box!" +msgstr "Witamy w 86Boxie!" msgid "Internal device" msgstr "Urządzenie wewnętrzne" @@ -826,7 +826,7 @@ msgid "Exit" msgstr "Zakończ" msgid "No ROMs found" -msgstr "Nie znaleziono obrazów ROM" +msgstr "Nie znaleziono ROM-ów" msgid "Do you want to save the settings?" msgstr "Czy chcesz zapisać ustawienia?" @@ -844,7 +844,7 @@ msgid "86Box v" msgstr "86Box v" msgid "An emulator of old computers\n\nAuthors: Miran Grča (OBattler), RichardG867, Jasmine Iwanek, TC1995, coldbrewed, Teemu Korhonen (Manaatti), Joakim L. Gilje, Adrien Moulin (elyosh), Daniel Balsom (gloriouscow), Cacodemon345, Fred N. van Kempen (waltje), Tiseno100, reenigne, and others.\n\nWith previous core contributions from Sarah Walker, leilei, JohnElliott, greatpsycho, and others.\n\nReleased under the GNU General Public License version 2 or later. See LICENSE for more information." -msgstr "Emulator starych komputerów\n\nAutorzy: Miran Grča (OBattler), RichardG867, Jasmine Iwanek, TC1995, coldbrewed, Teemu Korhonen (Manaatti), Joakim L. Gilje, Adrien Moulin (elyosh), Daniel Balsom (gloriouscow), Cacodemon345, Fred N. van Kempen (waltje), Tiseno100, reenigne, i inni.\n\nZ wcześniejszym wkładem od Sarah Walker, leilei, JohnElliott, greatpsycho i innych.\n\nPrzetłumaczony przez: Fanta-Shokata\n\nWydany na licencji GNU General Public License w wersji 2 lub nowszej. Zobacz LICENSE aby uzyskać więcej informacji." +msgstr "Emulator starych komputerów\n\nAutorzy: Miran Grča (OBattler), RichardG867, Jasmine Iwanek, TC1995, coldbrewed, Teemu Korhonen (Manaatti), Joakim L. Gilje, Adrien Moulin (elyosh), Daniel Balsom (gloriouscow), Cacodemon345, Fred N. van Kempen (waltje), Tiseno100, reenigne, i inni.\n\nZ wcześniejszym wkładem od Sarah Walker, leilei, JohnElliott, greatpsycho i innych.\n\nPrzetłumaczony przez: Fanta-Shokata, Lili1228\n\nWydany na licencji GNU General Public License w wersji 2 lub nowszej. Zobacz LICENSE aby uzyskać więcej informacji." msgid "Hardware not available" msgstr "Sprzęt niedostępny" @@ -886,10 +886,10 @@ msgid "GLSL shaders" msgstr "Shadery GLSL" msgid "You are loading an unsupported configuration" -msgstr "Ładujesz nieobsługiwaną konfigurację" +msgstr "Wczytujesz nieobsługiwaną konfigurację" msgid "CPU type filtering based on selected machine is disabled for this emulated machine.\n\nThis makes it possible to choose a CPU that is otherwise incompatible with the selected machine. However, you may run into incompatibilities with the machine BIOS or other software.\n\nEnabling this setting is not officially supported and any bug reports filed may be closed as invalid." -msgstr "Wybór rodzaju procesora oparty na wybranej maszynie jest wyłączony dla tej emulowanej maszyny.\n\nPozwala to na wybór procesora który jest niekompatybilny z wybraną maszyną. Jednak możesz napotkać niezgodności z BIOS-em maszyny lub innym oprogramowaniem.\n\nAktywacja tego ustawienia nie jest wspierana i każde zgłoszenie błędu może zostać zamknięte jako nieważne." +msgstr "Filtrowanie rodzaju procesora na podstawie wybranej maszyny jest wyłączone dla tej emulowanej maszyny.\n\nPozwala to na wybór procesora, który jest niekompatybilny z wybraną maszyną, jednak możesz napotkać niezgodności z BIOS-em maszyny lub innym oprogramowaniem.\n\nAktywacja tego ustawienia nie jest wspierana i każde zgłoszenie błędu może zostać zamknięte jako nieprawidłowe." msgid "Continue" msgstr "Kontynuuj" @@ -901,10 +901,10 @@ msgid "Cassette images" msgstr "Obrazy kaset" msgid "Cartridge %1: %2" -msgstr "Kartrydż %1: %2" +msgstr "Kartridż %1: %2" msgid "Cartridge images" -msgstr "Obrazy kartrydżu" +msgstr "Obrazy kartridżów" msgid "Resume execution" msgstr "Wznów wykonywanie" @@ -994,7 +994,7 @@ msgid "Don't overwrite" msgstr "Nie nadpisuj" msgid "Raw image" -msgstr "Obraz surowy" +msgstr "Surowy obraz" msgid "HDI image" msgstr "Obraz HDI" @@ -1003,19 +1003,19 @@ msgid "HDX image" msgstr "Obraz HDX" msgid "Fixed-size VHD" -msgstr "VHD o stałym rozmiarze" +msgstr "VHD stałego rozmiaru" msgid "Dynamic-size VHD" -msgstr "VHD o dynamicznym rozmiarze" +msgstr "VHD dynamicznego rozmiaru" msgid "Differencing VHD" msgstr "VHD różnicujący" msgid "(N/A)" -msgstr "(Bez)" +msgstr "(N/D)" msgid "Raw image (.img)" -msgstr "Obraz surowy (.img)" +msgstr "Surowy obraz (.img)" msgid "HDI image (.hdi)" msgstr "Obraz HDI (.hdi)" @@ -1030,7 +1030,7 @@ msgid "Dynamic-size VHD (.vhd)" msgstr "VHD o dynamicznym rozmiarze (.vhd)" msgid "Differencing VHD (.vhd)" -msgstr "VHD różnicujący (.vhd)" +msgstr "VHD różnicowy (.vhd)" msgid "Large blocks (2 MB)" msgstr "Duże bloki (2 MB)" @@ -1045,7 +1045,7 @@ msgid "Select the parent VHD" msgstr "Wybierz nadrzędny plik VHD" msgid "This could mean that the parent image was modified after the differencing image was created.\n\nIt can also happen if the image files were moved or copied, or by a bug in the program that created this disk.\n\nDo you want to fix the timestamps?" -msgstr "Może to oznaczać, że obraz nadrzędny został zmodyfikowany po utworzeniu obrazu różnicującego.\n\nMoże się to również zdarzyć, jeśli pliki obrazów zostały przeniesione lub skopiowane, lub wystąpił błąd w programie, który utworzył ten dysk\n\nCzy chcesz naprawić sygnatury czasowe?" +msgstr "Może to oznaczać, że obraz nadrzędny został zmodyfikowany po utworzeniu obrazu różnicowego.\n\nMoże się to również zdarzyć, jeśli pliki obrazów zostały przeniesione lub skopiowane, lub wystąpił błąd w programie, który utworzył ten dysk.\n\nCzy chcesz naprawić sygnatury czasowe?" msgid "Parent and child disk timestamps do not match" msgstr "Sygnatury czasowe dysku nadrzędnego i podrzędnego nie zgadzają się" @@ -1162,10 +1162,10 @@ msgid "The network configuration will be switched to the null driver" msgstr "Konfiguracja sieci zostanie przełączona na sterownik null" msgid "Mouse sensitivity:" -msgstr "Wrażliwość myszy:" +msgstr "Czułość myszy:" msgid "Select media images from program working directory" -msgstr "Wybór obrazów multimedialnych z katalogu roboczego programu" +msgstr "Wybór obrazów nośników z katalogu roboczego programu" msgid "PIT mode:" msgstr "Tryb PIT:" @@ -1186,7 +1186,7 @@ msgid "WinBox is no longer supported" msgstr "WinBox nie jest już wspierany" msgid "Development of the WinBox manager stopped in 2022 due to a lack of maintainers. As we direct our efforts towards making 86Box even better, we have made the decision to no longer support WinBox as a manager.\n\nNo further updates will be provided through WinBox, and you may encounter incorrect behavior should you continue using it with newer versions of 86Box. Any bug reports related to WinBox behavior will be closed as invalid.\n\nGo to 86box.net for a list of other managers you can use." -msgstr "Rozwój menedżera WinBox został zatrzymany w 2022 roku z powodu braku opiekunów. Ponieważ kierujemy nasze wysiłki na uczynienie 86Box jeszcze lepszym, podjęliśmy decyzję o zaprzestaniu wspierania WinBox jako menedżera.\n\nŻadne dalsze aktualizacje nie będą dostarczane za pośrednictwem WinBox i możesz napotkać nieprawidłowe zachowanie, jeśli będziesz go nadal używać z nowszymi wersjami 86Box. Wszelkie zgłoszenia błędów związane z działaniem WinBox zostaną zamknięte jako nieważne.\n\nLista innych menedżerów, z których można korzystać, znajduje się na stronie 86box.net." +msgstr "Menedżer WinBox przestał być rozwijany w 2022 roku z powodu braku opiekunów. Ponieważ kierujemy nasze wysiłki na uczynienie 86Box jeszcze lepszym, podjęliśmy decyzję o zaprzestaniu wspierania WinBox jako menedżera.\n\nŻadne dalsze aktualizacje nie będą dostarczane za pośrednictwem WinBoxa i możesz napotkać nieprawidłowe zachowanie, jeśli będziesz go nadal używać z nowszymi wersjami 86Box. Wszelkie zgłoszenia błędów związane z działaniem WinBox zostaną zamknięte jako nieważne.\n\nLista innych menedżerów, z których można korzystać, znajduje się na stronie 86box.net." msgid "Generate" msgstr "Generuj" @@ -1273,7 +1273,7 @@ msgid "VSync" msgstr "VSync" msgid "Synchronize with video" -msgstr "Zsynchronizuj z wideo" +msgstr "Synchronizuj z obrazem" msgid "Shaders" msgstr "Shadery" @@ -1297,10 +1297,10 @@ msgid "Error initializing OpenGL" msgstr "Błąd inicjalizacji OpenGL" msgid "\nFalling back to software rendering." -msgstr "\nPowrót do renderowania oprogramowania." +msgstr "\nPowrót do renderowania programowego." msgid "

When selecting media images (CD-ROM, floppy, etc.) the open dialog will start in the same directory as the 86Box configuration file. This setting will likely only make a difference on macOS.

" -msgstr "

Podczas wybierania obrazów nośników (CD-ROM, dyskietka itp.) otwarte okno dialogowe rozpocznie się w tym samym katalogu, co plik konfiguracyjny 86Box. To ustawienie prawdopodobnie będzie miało znaczenie tylko na macOS.

" +msgstr "

Podczas wybierania obrazów nośników (CD-ROM, dyskietka itd.), otwarte okno dialogowe rozpocznie się w tym samym katalogu, co plik konfiguracyjny 86Box. To ustawienie prawdopodobnie będzie miało znaczenie tylko na macOS.

" msgid "This machine might have been moved or copied." msgstr "To urządzenie mogło zostać przeniesione lub skopiowane." @@ -1354,25 +1354,25 @@ msgid "Novell NetWare 2.x Key Card" msgstr "Karta klucza Novell NetWare 2.x" msgid "Serial port passthrough 1" -msgstr "Przełączanie portu szeregowego 1" +msgstr "Przelotka portu szeregowego 1" msgid "Serial port passthrough 2" -msgstr "Przełączanie portu szeregowego 2" +msgstr "Przelotka portu szeregowego 2" msgid "Serial port passthrough 3" -msgstr "Przełączanie portu szeregowego 3" +msgstr "Przelotka portu szeregowego 3" msgid "Serial port passthrough 4" -msgstr "Przełączanie portu szeregowego 4" +msgstr "Przelotka portu szeregowego 4" msgid "Renderer options..." msgstr "Opcje renderowania..." msgid "Logitech/Microsoft Bus Mouse" -msgstr "Mysz magistralna Logitech/Microsoft" +msgstr "Mysz magistralowa Logitech/Microsoft" msgid "Microsoft Bus Mouse (InPort)" -msgstr "Mysz magistralna Microsoft (InPort)" +msgstr "Mysz magistralowa Microsoft (InPort)" msgid "Mouse Systems Serial Mouse" msgstr "Mysz szeregowa Mouse Systems" @@ -1387,7 +1387,7 @@ msgid "PS/2 Mouse" msgstr "Mysz PS/2" msgid "3M MicroTouch (Serial)" -msgstr "3M MicroTouch (szeregowa)" +msgstr "3M MicroTouch (szeregowy)" msgid "[COM] Standard Hayes-compliant Modem" msgstr "[COM] Standardowy modem zgodny z Hayes" @@ -1396,7 +1396,7 @@ msgid "Roland MT-32 Emulation" msgstr "Emulacja Roland MT-32" msgid "Roland MT-32 (New) Emulation" -msgstr "Emulacja Roland MT-32 (nowego)" +msgstr "(Nowa) emulacja Roland MT-32" msgid "Roland CM-32L Emulation" msgstr "Emulacja Roland CM-32L" @@ -1405,7 +1405,7 @@ msgid "Roland CM-32LN Emulation" msgstr "Emulacja Roland CM-32LN" msgid "OPL4-ML Daughterboard" -msgstr "Płyta córka OPL4-ML" +msgstr "Płyta-córka OPL4-ML" msgid "System MIDI" msgstr "System MIDI" @@ -1612,7 +1612,7 @@ msgid "CODEC" msgstr "CODEC" msgid "Raise CODEC interrupt on CODEC setup (needed by some drivers)" -msgstr "Podniesienie przerwania CODEC przy konfiguracji CODEC (wymagane przez niektóre sterowniki)" +msgstr "Podnieś przerwanie CODEC podczas konfiguracji CODEC-a (wymagane przez niektóre sterowniki)" msgid "SB Address" msgstr "Adres SB" @@ -1630,7 +1630,7 @@ msgid "Receive MIDI input (MPU-401)" msgstr "Odbiór wejścia MIDI (MPU-401)" msgid "SB low DMA" -msgstr "SB low DMA" +msgstr "Niskie DMA SB" msgid "6CH variant (6-channel)" msgstr "Wariant 6CH (6-kanałowy)" @@ -1645,7 +1645,7 @@ msgid "High DMA" msgstr "Wysokie DMA" msgid "Control PC speaker" -msgstr "Głośnik komputera sterującego" +msgstr "Kontroluj PC speaker" msgid "Memory size" msgstr "Rozmiar pamięci" @@ -1663,10 +1663,10 @@ msgid "GUS type" msgstr "Typ GUS" msgid "Enable 0x04 \"Exit 86Box\" command" -msgstr "Włącz polecenie 0x04 \"Wyjdź z 86Box\"" +msgstr "Włącz polecenie 0x04 \"Wyjdź z 86Boxa\"" msgid "Display type" -msgstr "Typ wyświetlacza" +msgstr "Typ ekranu" msgid "Composite type" msgstr "Typ kompozytowy" @@ -1777,7 +1777,7 @@ msgid "Triangle" msgstr "Trójkątny" msgid "Linear" -msgstr "Liniowa" +msgstr "Liniowy" msgid "4th Order" msgstr "4. rzędu" @@ -1798,13 +1798,13 @@ msgid "Three" msgstr "Trzy" msgid "Wheel" -msgstr "Koło" +msgstr "Rolka" msgid "Five + Wheel" -msgstr "" +msgstr "Pięć + rolka" msgid "Five + 2 Wheels" -msgstr "" +msgstr "Pięć + dwie rolki" msgid "A3 - SMT2 Serial / SMT3(R)V" msgstr "A3 - SMT2 szeregowa / SMT3(R)V" @@ -1876,7 +1876,7 @@ msgid "New" msgstr "Nowość" msgid "Color (generic)" -msgstr "Kolor (generyczny)" +msgstr "Kolorowy (generyczny)" msgid "Green Monochrome" msgstr "Zielony monochromatyczny" @@ -1888,10 +1888,10 @@ msgid "Gray Monochrome" msgstr "Szary monochromatyczny" msgid "Color (no brown)" -msgstr "Kolor (bez brązowego)" +msgstr "Kolorowy (bez brązowego)" msgid "Color (IBM 5153)" -msgstr "Kolor (IBM 5153)" +msgstr "Kolorowy (IBM 5153)" msgid "Simple doubling" msgstr "Proste podwojenie" @@ -1921,7 +1921,7 @@ msgid "Color 80x25 (5153/CGA)" msgstr "Kolor 80x25 (5153/CGA)" msgid "Enhanced Color - Normal Mode (5154/ECD)" -msgstr "Rozszerzone kolory - tryb normalny (5154/ECD)" +msgstr "Rozszerzony kolor - tryb zwykły (5154/ECD)" msgid "Enhanced Color - Enhanced Mode (5154/ECD)" msgstr "Rozszerzony kolor - tryb rozszerzony (5154/ECD)" @@ -1936,10 +1936,10 @@ msgid "Gray" msgstr "Szary" msgid "Color" -msgstr "Kolor" +msgstr "Kolorowy" msgid "U.S. English" -msgstr "Amerykański angielski" +msgstr "Angielski (USA)" msgid "Scandinavian" msgstr "Skandynawski" @@ -1948,13 +1948,13 @@ msgid "Other languages" msgstr "Inne języki" msgid "Bochs latest" -msgstr "Bochs najnowsze" +msgstr "Najnowszy Bochs" msgid "Mono Non-Interlaced" -msgstr "Mono bez przeplotu" +msgstr "Monochromatyczny bez przeplotu" msgid "Color Interlaced" -msgstr "Kolor z przeplotem" +msgstr "Kolorowy z przeplotem" msgid "Color Non-Interlaced" msgstr "Kolor bez przeplotu" @@ -1963,7 +1963,7 @@ msgid "3Dfx Voodoo Graphics" msgstr "Grafika 3Dfx Voodoo" msgid "Obsidian SB50 + Amethyst (2 TMUs)" -msgstr "Obsydian SB50 + Ametyst (2 jednostki TMU)" +msgstr "Obsydian SB50 + Amethyst (2 jednostki TMU)" msgid "8-bit" msgstr "8-bitowy" @@ -1987,7 +1987,7 @@ msgid "High-Speed" msgstr "Wysoka prędkość" msgid "Stereo LPT DAC" -msgstr "Stereofoniczny przetwornik cyfrowo-analogowy LPT" +msgstr "Stereo LPT DAC" msgid "Generic Text Printer" msgstr "Generyczna drukarka tekstowa" @@ -2002,7 +2002,7 @@ msgid "Generic PCL5e Printer" msgstr "Generyczna drukarka PCL5e" msgid "Parallel Line Internet Protocol" -msgstr "Protokół internetowy linii równoległej" +msgstr "Parallel Line Internet Protocol" msgid "Protection Dongle for Savage Quest" msgstr "Klucz ochronny dla Savage Quest" @@ -2017,7 +2017,7 @@ msgid "Host Serial Device" msgstr "Urządzenie szeregowe hosta" msgid "Name of pipe" -msgstr "Nazwa rury" +msgstr "Nazwa potoku" msgid "Data bits" msgstr "Bity danych" @@ -2026,19 +2026,19 @@ msgid "Stop bits" msgstr "Bity stopu" msgid "Baud Rate of Passthrough" -msgstr "Szybkość transmisji Passthrough" +msgstr "Szybkość transmisji przelotowej" msgid "Named Pipe (Server)" -msgstr "Nazwana rura (serwer)" +msgstr "Nazwany potok (serwer)" msgid "Host Serial Passthrough" -msgstr "Przejście przez port szeregowy hosta" +msgstr "Przelot przez port szeregowy hosta" msgid "E&ject %1" msgstr "W&yjmij %1" msgid "&Unmute" -msgstr "&Wycisz" +msgstr "O&dcisz" msgid "Softfloat FPU" msgstr "FPU Softfloat" @@ -2047,28 +2047,28 @@ msgid "High performance impact" msgstr "Wysoki wpływ na wydajność" msgid "[Generic] RAM Disk (max. speed)" -msgstr "[Generic] Dysk RAM (maks. prędkość)" +msgstr "[generyczny] Dysk RAM (maks. prędkość)" msgid "[Generic] 1989 (3500 RPM)" -msgstr "" +msgstr "[generyczny] 1989 (3500 RPM)" msgid "[Generic] 1992 (3600 RPM)" -msgstr "" +msgstr "[generyczny] 1992 (3600 RPM)" msgid "[Generic] 1994 (4500 RPM)" -msgstr "" +msgstr "[generyczny] 1994 (4500 RPM)" msgid "[Generic] 1996 (5400 RPM)" -msgstr "" +msgstr "[generyczny] 1996 (5400 RPM)" msgid "[Generic] 1997 (5400 RPM)" -msgstr "" +msgstr "[generyczny] 1997 (5400 RPM)" msgid "[Generic] 1998 (5400 RPM)" -msgstr "" +msgstr "[generyczny] 1998 (5400 RPM)" msgid "[Generic] 2000 (7200 RPM)" -msgstr "" +msgstr "[generyczny] 2000 (7200 RPM)" msgid "IBM 8514/A clone (ISA)" msgstr "Klon IBM 8514/A (ISA)" @@ -2083,67 +2083,67 @@ msgid "Generic PC/AT Memory Expansion" msgstr "Generyczne rozszerzenie pamięci PC/AT" msgid "Unable to find Dot-Matrix fonts" -msgstr "Nie można znaleźć czcionek igłowych" +msgstr "Nie można znaleźć fontów igłowych" msgid "TrueType fonts in the \"roms/printer/fonts\" directory are required for the emulation of the Generic ESC/P Dot-Matrix Printer." -msgstr "Czcionki TrueType w katalogu \"roms/printer/fonts\" są wymagane do emulacji generyczniej drukarki igłowej ESC/P." +msgstr "Fonty TrueType w katalogu \"roms/printer/fonts\" są wymagane do emulacji generycznej drukarki igłowej ESC/P." msgid "Inhibit multimedia keys" -msgstr "" +msgstr "Przejmij klawisze multimedialne" msgid "Ask for confirmation before saving settings" -msgstr "" +msgstr "Pytaj o potwierdzenie przed zapisaniem ustawień" msgid "Ask for confirmation before hard resetting" -msgstr "" +msgstr "Pytaj o potwierdzenie przed twardym resetem" msgid "Ask for confirmation before quitting" -msgstr "" +msgstr "Pytaj o potwierdzenie przed wyjściem" msgid "Options" -msgstr "" +msgstr "Opcje" msgid "Model" -msgstr "" +msgstr "Model" msgid "Model:" -msgstr "" +msgstr "Model:" msgid "Failed to initialize Vulkan renderer." -msgstr "" +msgstr "Nie udało się zainicjować renderera Vulkan." msgid "GLSL Error" -msgstr "" +msgstr "Błąd GLSL" msgid "Could not load shader: %1" -msgstr "" +msgstr "Nie udało się wczytać shadera: %1" msgid "OpenGL version 3.0 or greater is required. Current GLSL version is %1.%2" -msgstr "" +msgstr "Wymagana jest wersja OpenGL 3.0 lub wyższa. Aktualna wersja GLSL to %1." msgid "Could not load texture: %1" -msgstr "" +msgstr "Nie udało się wczytać tekstury: %1" msgid "Could not compile shader:\n\n%1" -msgstr "" +msgstr "Nie udało się skompilować shadera:\n\n%1" msgid "Program not linked:\n\n%1" -msgstr "" +msgstr "Program niezalinkowany:\n\n%1" msgid "Shader Manager" -msgstr "" +msgstr "Menedżer shaderów" msgid "Shader Configuration" -msgstr "" +msgstr "Konfiguracja shadera" msgid "Add" -msgstr "" +msgstr "Dodaj" msgid "Move up" -msgstr "" +msgstr "Przesuń w górę" msgid "Move down" -msgstr "" +msgstr "Przesuń w dół" msgid "Could not load file %1" -msgstr "" +msgstr "Nie można wczytać pliku %1" From 537ab6ae6fd84ffeecca0f31af8e0f33767e646b Mon Sep 17 00:00:00 2001 From: Lili Kurek Date: Wed, 25 Jun 2025 21:40:49 +0000 Subject: [PATCH 024/103] Incorporate some of the changes suggested by @asiekierka --- src/qt/languages/pl-PL.po | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qt/languages/pl-PL.po b/src/qt/languages/pl-PL.po index c8a7cb886..b161370ed 100644 --- a/src/qt/languages/pl-PL.po +++ b/src/qt/languages/pl-PL.po @@ -172,7 +172,7 @@ msgid "CGA/PCjr/Tandy/E&GA/(S)VGA overscan" msgstr "Overscan dla CGA/PCjr/Tandy/E&GA/(S)VGA" msgid "Change contrast for &monochrome display" -msgstr "Zmień kontrast ekranu &monochromatycznego" +msgstr "Zmień kontrast dla ekranu &monochromatycznego" msgid "&Media" msgstr "&Nośnik" @@ -697,7 +697,7 @@ msgid "Ports (COM & LPT)" msgstr "Porty (COM & LPT)" msgid "Storage controllers" -msgstr "Kontrolery danych" +msgstr "Kontrolery pamięci masowej" msgid "Hard disks" msgstr "Dyski twarde" @@ -742,7 +742,7 @@ msgid "Default" msgstr "Domyślny" msgid "%1 Wait state(s)" -msgstr "%1 stany oczekiwania" +msgstr "%1 stan(y/ów) oczekiwania" msgid "Type" msgstr "Rodzaj" @@ -796,7 +796,7 @@ msgid "Advanced sector images" msgstr "Zaawansowane obrazy sektorów" msgid "Flux images" -msgstr "Obrazy Flux" +msgstr "Obrazy flux" msgid "Are you sure you want to hard reset the emulated machine?" msgstr "Czy na pewno chcesz wykonać twardy reset emulowanej maszyny?" @@ -1003,16 +1003,16 @@ msgid "HDX image" msgstr "Obraz HDX" msgid "Fixed-size VHD" -msgstr "VHD stałego rozmiaru" +msgstr "VHD o stałym rozmiarze" msgid "Dynamic-size VHD" -msgstr "VHD dynamicznego rozmiaru" +msgstr "VHD o dynamicznym rozmiarze" msgid "Differencing VHD" msgstr "VHD różnicujący" msgid "(N/A)" -msgstr "(N/D)" +msgstr "(nd.)" msgid "Raw image (.img)" msgstr "Surowy obraz (.img)" @@ -1630,7 +1630,7 @@ msgid "Receive MIDI input (MPU-401)" msgstr "Odbiór wejścia MIDI (MPU-401)" msgid "SB low DMA" -msgstr "Niskie DMA SB" +msgstr "Low DMA SB" msgid "6CH variant (6-channel)" msgstr "Wariant 6CH (6-kanałowy)" @@ -2119,7 +2119,7 @@ msgid "Could not load shader: %1" msgstr "Nie udało się wczytać shadera: %1" msgid "OpenGL version 3.0 or greater is required. Current GLSL version is %1.%2" -msgstr "Wymagana jest wersja OpenGL 3.0 lub wyższa. Aktualna wersja GLSL to %1." +msgstr "Wymagana jest wersja OpenGL 3.0 lub wyższa. Aktualna wersja GLSL to %1.%2" msgid "Could not load texture: %1" msgstr "Nie udało się wczytać tekstury: %1" From 07af9f12d75cfe724d650583be935f756fb94332 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 26 Jun 2025 13:11:42 +0200 Subject: [PATCH 025/103] Video: more changes and fixes of the day (June 26th, 2025) 1. Convert the ramdac types into an enumerator. 2. Make sure the 8514/A compatible ramdacs are, if in VGA mode, using VGA compatible ports and/or, in 8514/A mode, the 8514/A ports when needed, fixes color issues in 1280x1024 resolutions on NT 3.1 and various stuff using the Mach32. 3. Add pitch initialization on reset, fixes 8514/A display drivers on various stuff on Mach8/Mach32 cards. --- src/include/86box/vid_ati_mach8.h | 8 ++++- src/include/86box/vid_svga.h | 9 +++--- src/video/ramdac/vid_ramdac_ati68860.c | 20 ++++++------- src/video/ramdac/vid_ramdac_ati68875.c | 24 +++++++++++---- src/video/vid_ati_mach64.c | 13 ++++---- src/video/vid_ati_mach8.c | 41 ++++++++++++++------------ src/video/vid_svga.c | 11 ++++--- 7 files changed, 74 insertions(+), 52 deletions(-) diff --git a/src/include/86box/vid_ati_mach8.h b/src/include/86box/vid_ati_mach8.h index e999c7087..ad5281ac3 100644 --- a/src/include/86box/vid_ati_mach8.h +++ b/src/include/86box/vid_ati_mach8.h @@ -18,6 +18,12 @@ #ifndef VIDEO_ATI_MACH8_H #define VIDEO_ATI_MACH8_H +typedef enum { + ATI_68875 = 0, + ATI_68860, + RAMDAC_MAX +} mach_ramdac_type; + typedef struct mach_t { ati_eeprom_t eeprom; svga_t svga; @@ -39,7 +45,7 @@ typedef struct mach_t { uint8_t irq_state; int index; - int ramdac_type; + mach_ramdac_type ramdac_type; int old_mode; uint16_t config1; diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index ad9170ad3..cc67e70bc 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -136,6 +136,7 @@ typedef struct svga_t { int packed_4bpp; int ps_bit_bug; int ati_4color; + int vblankend; /*The three variables below allow us to implement memory maps like that seen on a 1MB Trio64 : 0MB-1MB - VRAM @@ -404,15 +405,15 @@ uint32_t svga_lookup_lut_ram(svga_t* svga, uint32_t val); /* We need a way to add a device with a pointer to a parent device so it can attach itself to it, and possibly also a second ATi 68860 RAM DAC type that auto-sets SVGA render on RAM DAC render change. */ -extern void ati68860_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga); -extern uint8_t ati68860_ramdac_in(uint16_t addr, void *priv, svga_t *svga); +extern void ati68860_ramdac_out(uint16_t addr, uint8_t val, int is_8514, void *priv, svga_t *svga); +extern uint8_t ati68860_ramdac_in(uint16_t addr, int is_8514, void *priv, svga_t *svga); extern void ati68860_set_ramdac_type(void *priv, int type); extern void ati68860_ramdac_set_render(void *priv, svga_t *svga); extern void ati68860_ramdac_set_pallook(void *priv, int i, uint32_t col); extern void ati68860_hwcursor_draw(svga_t *svga, int displine); -extern void ati68875_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svga_t *svga); -extern uint8_t ati68875_ramdac_in(uint16_t addr, int rs2, int rs3, void *priv, svga_t *svga); +extern void ati68875_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, int is_8514, void *priv, svga_t *svga); +extern uint8_t ati68875_ramdac_in(uint16_t addr, int rs2, int rs3, int is_8514, void *priv, svga_t *svga); extern void att49x_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga); extern uint8_t att49x_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga); diff --git a/src/video/ramdac/vid_ramdac_ati68860.c b/src/video/ramdac/vid_ramdac_ati68860.c index e3e486d57..4411f2ee2 100644 --- a/src/video/ramdac/vid_ramdac_ati68860.c +++ b/src/video/ramdac/vid_ramdac_ati68860.c @@ -67,22 +67,22 @@ typedef struct ati68860_ramdac_t { } ati68860_ramdac_t; void -ati68860_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga) +ati68860_ramdac_out(uint16_t addr, uint8_t val, int is_8514, void *priv, svga_t *svga) { ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) priv; switch (addr) { case 0: - svga_out(0x3c8, val, svga); + svga_out(is_8514 ? 0x2ec : 0x3c8, val, svga); break; case 1: - svga_out(0x3c9, val, svga); + svga_out(is_8514 ? 0x2ed : 0x3c9, val, svga); break; case 2: - svga_out(0x3c6, val, svga); + svga_out(is_8514 ? 0x2ea : 0x3c6, val, svga); break; case 3: - svga_out(0x3c7, val, svga); + svga_out(is_8514 ? 0x2eb : 0x3c7, val, svga); break; default: ramdac->regs[addr & 0xf] = val; @@ -172,23 +172,23 @@ ati68860_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga) } uint8_t -ati68860_ramdac_in(uint16_t addr, void *priv, svga_t *svga) +ati68860_ramdac_in(uint16_t addr, int is_8514, void *priv, svga_t *svga) { const ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) priv; uint8_t temp = 0; switch (addr) { case 0: - temp = svga_in(0x3c8, svga); + temp = svga_in(is_8514 ? 0x2ec : 0x3c8, svga); break; case 1: - temp = svga_in(0x3c9, svga); + temp = svga_in(is_8514 ? 0x2ed : 0x3c9, svga); break; case 2: - temp = svga_in(0x3c6, svga); + temp = svga_in(is_8514 ? 0x2ea : 0x3c6, svga); break; case 3: - temp = svga_in(0x3c7, svga); + temp = svga_in(is_8514 ? 0x2eb : 0x3c7, svga); break; case 4: case 8: diff --git a/src/video/ramdac/vid_ramdac_ati68875.c b/src/video/ramdac/vid_ramdac_ati68875.c index 5d573a282..4de0ed3d9 100644 --- a/src/video/ramdac/vid_ramdac_ati68875.c +++ b/src/video/ramdac/vid_ramdac_ati68875.c @@ -38,7 +38,7 @@ typedef struct ati68875_ramdac_t { } ati68875_ramdac_t; void -ati68875_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svga_t *svga) +ati68875_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, int is_8514, void *priv, svga_t *svga) { ati68875_ramdac_t *ramdac = (ati68875_ramdac_t *) priv; uint8_t rs = (addr & 0x03); @@ -48,10 +48,16 @@ ati68875_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, sv switch (rs) { case 0x00: /* Palette Write Index Register (RS value = 0000) */ + svga_out(is_8514 ? 0x2ec : 0x3c8, val, svga); + break; case 0x01: /* Palette Data Register (RS value = 0001) */ + svga_out(is_8514 ? 0x2ed : 0x3c9, val, svga); + break; case 0x02: /* Pixel Read Mask Register (RS value = 0010) */ - case 0x03: - svga_out(addr, val, svga); + svga_out(is_8514 ? 0x2ea : 0x3c6, val, svga); + break; + case 0x03: /* Palette Read Index Register (RS value = 0011) */ + svga_out(is_8514 ? 0x2eb : 0x3c7, val, svga); break; case 0x08: /* General Control Register (RS value = 1000) */ ramdac->gen_cntl = val; @@ -83,7 +89,7 @@ ati68875_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, sv } uint8_t -ati68875_ramdac_in(uint16_t addr, int rs2, int rs3, void *priv, svga_t *svga) +ati68875_ramdac_in(uint16_t addr, int rs2, int rs3, int is_8514, void *priv, svga_t *svga) { const ati68875_ramdac_t *ramdac = (ati68875_ramdac_t *) priv; uint8_t rs = (addr & 0x03); @@ -94,10 +100,16 @@ ati68875_ramdac_in(uint16_t addr, int rs2, int rs3, void *priv, svga_t *svga) switch (rs) { case 0x00: /* Palette Write Index Register (RS value = 0000) */ + temp = svga_in(is_8514 ? 0x2ec : 0x3c8, svga); + break; case 0x01: /* Palette Data Register (RS value = 0001) */ + temp = svga_in(is_8514 ? 0x2ed : 0x3c9, svga); + break; case 0x02: /* Pixel Read Mask Register (RS value = 0010) */ - case 0x03: - temp = svga_in(addr, svga); + temp = svga_in(is_8514 ? 0x2ea : 0x3c6, svga); + break; + case 0x03: /* Palette Read Index Register (RS value = 0011) */ + temp = svga_in(is_8514 ? 0x2eb : 0x3c7, svga); break; case 0x08: /* General Control Register (RS value = 1000) */ temp = ramdac->gen_cntl; diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 8e6b52517..2b89bddf4 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -425,7 +425,7 @@ mach64_out(uint16_t addr, uint8_t val, void *priv) case 0x3C8: case 0x3C9: if (mach64->type == MACH64_GX) - ati68860_ramdac_out((addr & 3) | ((mach64->dac_cntl & 3) << 2), val, svga->ramdac, svga); + ati68860_ramdac_out((addr & 3) | ((mach64->dac_cntl & 3) << 2), val, 0, svga->ramdac, svga); else svga_out(addr, val, svga); return; @@ -492,7 +492,7 @@ mach64_in(uint16_t addr, void *priv) case 0x3C8: case 0x3C9: if (mach64->type == MACH64_GX) - return ati68860_ramdac_in((addr & 3) | ((mach64->dac_cntl & 3) << 2), svga->ramdac, svga); + return ati68860_ramdac_in((addr & 3) | ((mach64->dac_cntl & 3) << 2), 0, svga->ramdac, svga); return svga_in(addr, svga); case 0x3D4: @@ -2530,7 +2530,7 @@ mach64_ext_readb(uint32_t addr, void *priv) case 0xc2: case 0xc3: if (mach64->type == MACH64_GX) - ret = ati68860_ramdac_in((addr & 3) | ((mach64->dac_cntl & 3) << 2), mach64->svga.ramdac, &mach64->svga); + ret = ati68860_ramdac_in((addr & 3) | ((mach64->dac_cntl & 3) << 2), 0, mach64->svga.ramdac, &mach64->svga); else { switch (addr & 3) { case 0: @@ -3313,7 +3313,7 @@ mach64_ext_writeb(uint32_t addr, uint8_t val, void *priv) case 0xc2: case 0xc3: if (mach64->type == MACH64_GX) - ati68860_ramdac_out((addr & 3) | ((mach64->dac_cntl & 3) << 2), val, svga->ramdac, svga); + ati68860_ramdac_out((addr & 3) | ((mach64->dac_cntl & 3) << 2), val, 0, svga->ramdac, svga); else { switch (addr & 3) { case 0: @@ -3574,7 +3574,7 @@ mach64_ext_inb(uint16_t port, void *priv) case 0x5eee: case 0x5eef: if (mach64->type == MACH64_GX) - ret = ati68860_ramdac_in((port & 3) | ((mach64->dac_cntl & 3) << 2), mach64->svga.ramdac, &mach64->svga); + ret = ati68860_ramdac_in((port & 3) | ((mach64->dac_cntl & 3) << 2), 0, mach64->svga.ramdac, &mach64->svga); else { switch (port & 3) { case 0: @@ -3820,7 +3820,7 @@ mach64_ext_outb(uint16_t port, uint8_t val, void *priv) case 0x5eee: case 0x5eef: if (mach64->type == MACH64_GX) - ati68860_ramdac_out((port & 3) | ((mach64->dac_cntl & 3) << 2), val, svga->ramdac, svga); + ati68860_ramdac_out((port & 3) | ((mach64->dac_cntl & 3) << 2), val, 0, svga->ramdac, svga); else { switch (port & 3) { case 0: @@ -4801,6 +4801,7 @@ mach64vt2_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_mach64_pci); mach64->pci = 1; + mach64->vlb = 0; mach64->pci_id = 0x5654; mach64->config_chip_id = 0x40005654; mach64->dac_cntl = 1 << 16; /*Internal 24-bit DAC*/ diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 4133b730e..46d3d98c1 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2422,11 +2422,11 @@ mach_out(uint16_t addr, uint8_t val, void *priv) rs2 = !!(mach->accel.ext_ge_config & 0x1000); rs3 = !!(mach->accel.ext_ge_config & 0x2000); mach_log("8514/A Extended mode=%02x.\n", mach->regs[0xb0] & 0x20); - if (ATI_MACH32 && !dev->on) { - if (mach->pci_bus && !mach->ramdac_type) - ati68860_ramdac_out((addr & 0x03) | (rs2 << 2) | (rs3 << 3), val, svga->ramdac, svga); + if (ATI_MACH32) { + if (mach->pci_bus && (mach->ramdac_type == ATI_68860)) + ati68860_ramdac_out((addr & 0x03) | (rs2 << 2) | (rs3 << 3), val, 1, svga->ramdac, svga); else - ati68875_ramdac_out(addr, rs2, rs3, val, svga->ramdac, svga); + ati68875_ramdac_out(addr, rs2, rs3, val, 1, svga->ramdac, svga); } else svga_out(addr, val, svga); return; @@ -2438,11 +2438,11 @@ mach_out(uint16_t addr, uint8_t val, void *priv) rs2 = !!(mach->regs[0xa0] & 0x20); rs3 = !!(mach->regs[0xa0] & 0x40); mach_log("VGA Extended mode=%02x.\n", mach->regs[0xb0] & 0x20); - if (ATI_MACH32 && !dev->on) { - if (mach->pci_bus && !mach->ramdac_type) - ati68860_ramdac_out((addr & 0x03) | (rs2 << 2) | (rs3 << 3), val, svga->ramdac, svga); + if (ATI_MACH32) { + if (mach->pci_bus && (mach->ramdac_type == ATI_68860)) + ati68860_ramdac_out((addr & 0x03) | (rs2 << 2) | (rs3 << 3), val, 0, svga->ramdac, svga); else - ati68875_ramdac_out(addr, rs2, rs3, val, svga->ramdac, svga); + ati68875_ramdac_out(addr, rs2, rs3, val, 0, svga->ramdac, svga); } else svga_out(addr, val, svga); return; @@ -2563,11 +2563,11 @@ mach_in(uint16_t addr, void *priv) case 0x2ed: rs2 = !!(mach->accel.ext_ge_config & 0x1000); rs3 = !!(mach->accel.ext_ge_config & 0x2000); - if (ATI_MACH32 && !dev->on) { - if (mach->pci_bus && !mach->ramdac_type) - temp = ati68860_ramdac_in((addr & 3) | (rs2 << 2) | (rs3 << 3), svga->ramdac, svga); + if (ATI_MACH32) { + if (mach->pci_bus && (mach->ramdac_type == ATI_68860)) + temp = ati68860_ramdac_in((addr & 3) | (rs2 << 2) | (rs3 << 3), 1, svga->ramdac, svga); else - temp = ati68875_ramdac_in(addr, rs2, rs3, svga->ramdac, svga); + temp = ati68875_ramdac_in(addr, rs2, rs3, 1, svga->ramdac, svga); } else temp = svga_in(addr, svga); break; @@ -3007,6 +3007,7 @@ mach_recalctimings(svga_t *svga) mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace, svga->hdisp); + mach_log("EXTGECONFIG bits 11-15=%04x.\n", mach->accel.ext_ge_config & 0x8800); if ((mach->accel.ext_ge_config & 0x800) || (!(mach->accel.ext_ge_config & 0x8000) && !(mach->accel.ext_ge_config & 0x800))) { mach_log("hv=%d,%d, pitch=%d, rowoffset=%d, gextconfig=%03x, bpp=%d, shadow=%x, vgahdisp=%d.\n", dev->h_disp, dev->dispend, dev->pitch, dev->ext_crt_pitch, mach->accel.ext_ge_config & 0xcec0, @@ -4759,7 +4760,6 @@ mach_accel_in_call(uint16_t port, mach_t *mach, svga_t *svga, ibm8514_t *dev) } } else { switch (mach->accel.cmd_type) { - case 1: case 2: case 5: if ((dev->subsys_cntl & INT_GE_BSY) && @@ -4770,6 +4770,7 @@ mach_accel_in_call(uint16_t port, mach_t *mach, svga_t *svga, ibm8514_t *dev) (dev->accel.dy <= clip_b)) temp |= INT_GE_BSY; break; + case 1: case 3: case 4: if ((dev->subsys_cntl & INT_GE_BSY) && @@ -7068,7 +7069,7 @@ mach8_init(const device_t *info) dev->type = info->flags; dev->local = info->local & 0xff; mach->has_bios = !(info->local & 0xff00); - mach->ramdac_type = mach->pci_bus ? device_get_config_int("ramdac") : 1; + mach->ramdac_type = mach->pci_bus ? device_get_config_int("ramdac") : ATI_68875; dev->vram_amount = device_get_config_int("memory"); dev->vram_512k_8514 = dev->vram_amount == 512; @@ -7119,7 +7120,7 @@ mach8_init(const device_t *info) dev->vram_mask = dev->vram_size - 1; dev->hwcursor.cur_ysize = 64; mach->config1 = 0x20; - if (mach->pci_bus && !mach->ramdac_type) + if (mach->pci_bus && (mach->ramdac_type == ATI_68860)) svga->ramdac = device_add(&ati68860_ramdac_device); else svga->ramdac = device_add(&ati68875_ramdac_device); @@ -7142,7 +7143,7 @@ mach8_init(const device_t *info) } else if (mach->pci_bus) { video_inform(VIDEO_FLAG_TYPE_8514, &timing_mach32_pci); mach->config1 |= 0x0e; - if (mach->ramdac_type) + if (mach->ramdac_type == ATI_68860) mach->config1 |= 0x0400; else mach->config1 |= 0x0a00; @@ -7180,6 +7181,7 @@ mach8_init(const device_t *info) dev->on = 0; dev->pitch = 1024; + dev->ext_pitch = 1024; dev->ext_crt_pitch = 0x80; dev->accel_bpp = 8; svga->force_old_addr = 1; @@ -7242,6 +7244,7 @@ ati8514_init(svga_t *svga, void *ext8514, void *dev8514) /*Init as 1024x768 87hz interlaced first, per 8514/A.*/ dev->on = 0; dev->pitch = 1024; + dev->ext_pitch = 1024; dev->ext_crt_pitch = 0x80; dev->accel_bpp = 8; dev->rowoffset = 0x80; @@ -7390,12 +7393,12 @@ static const device_config_t mach32_pci_config[] = { .description = "RAMDAC type", .type = CONFIG_SELECTION, .default_string = NULL, - .default_int = 0, + .default_int = ATI_68860, .file_filter = NULL, .spinner = { 0 }, .selection = { - { .description = "ATI 68860", .value = 0 }, - { .description = "ATI 68875", .value = 1 }, + { .description = "ATI 68860", .value = ATI_68860 }, + { .description = "ATI 68875", .value = ATI_68875 }, { .description = "" } }, .bios = { { 0 } } diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 2899f3bf7..afeb7a9d6 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -693,7 +693,6 @@ svga_recalctimings(svga_t *svga) double _dispontime_xga = 0.0; double _dispofftime_xga = 0.0; double disptime_xga = 0.0; - int vblankend; #ifdef ENABLE_SVGA_LOG int vsyncend; int hdispend; @@ -913,9 +912,9 @@ svga_recalctimings(svga_t *svga) if (xga_active && (svga->xga != NULL)) xga_recalctimings(svga); - vblankend = (svga->vblankstart & 0xffffff80) | (svga->crtc[0x16] & 0x7f); - if (vblankend <= svga->vblankstart) - vblankend += 0x00000080; + svga->vblankend = (svga->vblankstart & 0xffffff80) | (svga->crtc[0x16] & 0x7f); + if (svga->vblankend <= svga->vblankstart) + svga->vblankend += 0x00000080; if (svga->hoverride || svga->override) { if (svga->hdisp >= 2048) @@ -969,7 +968,7 @@ svga_recalctimings(svga_t *svga) } /* - 1 because + 1 but also - 2 to compensate for the + 2 added to vtotal above. */ - svga->y_add = svga->vtotal - vblankend - 1; + svga->y_add = svga->vtotal - svga->vblankend - 1; svga->monitor->mon_overscan_y = svga->y_add + abs(svga->vblankstart - svga->dispend); if ((svga->dispend >= 2048) || (svga->y_add < 0)) { @@ -1050,7 +1049,7 @@ svga_recalctimings(svga_t *svga) "\n" "\n", svga->vtotal, svga->dispend, svga->vsyncstart, vsyncend, - svga->vblankstart, vblankend, + svga->vblankstart, svga->vblankend, svga->htotal, hdispstart, hdispend, hsyncstart, hsyncend, svga->hblankstart, svga->hblankend); From 7141e15fa8039061f4afce130f362b7d42cfe5f0 Mon Sep 17 00:00:00 2001 From: pankozaC++ <77279607+pankoza2-pl@users.noreply.github.com> Date: Thu, 26 Jun 2025 15:20:19 +0200 Subject: [PATCH 026/103] Olivetti M290 fixes Change minimum RAM to 1 MB and add the name of the AT&T variant, which seems to have the exact same BIOS --- src/machine/machine_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index e779eb753..24b950ad7 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -3141,7 +3141,7 @@ const machine_t machines[] = { }, /* Has Olivetti KBC firmware. */ { - .name = "[ISA] Olivetti M290", + .name = "[ISA] Olivetti M290/AT&T 6286 WGS", .internal_name = "m290", .type = MACHINE_TYPE_286, .chipset = MACHINE_CHIPSET_PROPRIETARY, @@ -3163,7 +3163,7 @@ const machine_t machines[] = { .bus_flags = MACHINE_AT, .flags = MACHINE_FLAGS_NONE, .ram = { - .min = 640, + .min = 1024, .max = 16384, .step = 128 }, From f6caa6ff8d41220659a4b0c7765e53f3b2db5501 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 26 Jun 2025 19:27:58 +0200 Subject: [PATCH 027/103] Tandy graphics: repeat character line 7 in line 8, fixes #5710. --- src/video/vid_tandy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/vid_tandy.c b/src/video/vid_tandy.c index 0609ca378..0ff9ad3df 100644 --- a/src/video/vid_tandy.c +++ b/src/video/vid_tandy.c @@ -447,7 +447,7 @@ vid_poll(void *priv) } if (vid->scanline & 8) { for (c = 0; c < 8; c++) { - buffer32->line[vid->displine << 1][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = cols[0]; + buffer32->line[vid->displine << 1][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0]; } } else { for (c = 0; c < 8; c++) { @@ -483,7 +483,7 @@ vid_poll(void *priv) vid->memaddr++; if (vid->scanline & 8) { for (c = 0; c < 8; c++) - buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[0]; + buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0]; } else { for (c = 0; c < 8; c++) { if (vid->scanline == 8) { From 3d42dbcb0efea299e76b4ba4c1a55ebd17617914 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 26 Jun 2025 19:35:14 +0200 Subject: [PATCH 028/103] Tandy: Improve the fix. --- src/video/vid_tandy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/vid_tandy.c b/src/video/vid_tandy.c index 0ff9ad3df..0504fd096 100644 --- a/src/video/vid_tandy.c +++ b/src/video/vid_tandy.c @@ -447,7 +447,7 @@ vid_poll(void *priv) } if (vid->scanline & 8) { for (c = 0; c < 8; c++) { - buffer32->line[vid->displine << 1][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0]; + buffer32->line[vid->displine << 1][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = ((chr & 0xf0) == 0xb0) ? cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0] : cols[0]; } } else { for (c = 0; c < 8; c++) { @@ -483,7 +483,7 @@ vid_poll(void *priv) vid->memaddr++; if (vid->scanline & 8) { for (c = 0; c < 8; c++) - buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0]; + buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = ((chr & 0xf0) == 0xb0) ? cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0] : cols[0]; } else { for (c = 0; c < 8; c++) { if (vid->scanline == 8) { From 37dfa93c47f24e3082ec4aab4ccbd597870a31cd Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 26 Jun 2025 23:45:40 +0200 Subject: [PATCH 029/103] Manager: Extend the serial_enabled list to 8 entries, fixes the manager. --- src/qt/qt_vmmanager_system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/qt_vmmanager_system.cpp b/src/qt/qt_vmmanager_system.cpp index 7ab7e43ca..0a7382094 100644 --- a/src/qt/qt_vmmanager_system.cpp +++ b/src/qt/qt_vmmanager_system.cpp @@ -719,7 +719,7 @@ VMManagerSystem::setupVars() { // Serial // By default serial 1 and 2 are enabled unless otherwise specified static auto serial_match = QRegularExpression("serial\\d_enabled", QRegularExpression::CaseInsensitiveOption); - QList serial_enabled = {true, true, false, false}; + QList serial_enabled = {true, true, false, false, false, false, false, false}; // Parallel // By default lpt 1 is enabled unless otherwise specified static auto lpt_match = QRegularExpression("lpt\\d_enabled", QRegularExpression::CaseInsensitiveOption); From 78e528c821ac452ab03993bac9d0498cd2ce8507 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 27 Jun 2025 17:51:14 +0200 Subject: [PATCH 030/103] Tandy: Fix the line drawing check to instead take all characters between 0xB0 and 0xDF. --- src/video/vid_tandy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/vid_tandy.c b/src/video/vid_tandy.c index 0504fd096..7d9b5af1a 100644 --- a/src/video/vid_tandy.c +++ b/src/video/vid_tandy.c @@ -447,7 +447,7 @@ vid_poll(void *priv) } if (vid->scanline & 8) { for (c = 0; c < 8; c++) { - buffer32->line[vid->displine << 1][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = ((chr & 0xf0) == 0xb0) ? cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0] : cols[0]; + buffer32->line[vid->displine << 1][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = ((chr >= 0xb3) && (chr <= 0xdf)) ? cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0] : cols[0]; } } else { for (c = 0; c < 8; c++) { @@ -483,7 +483,7 @@ vid_poll(void *priv) vid->memaddr++; if (vid->scanline & 8) { for (c = 0; c < 8; c++) - buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = ((chr & 0xf0) == 0xb0) ? cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0] : cols[0]; + buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[vid->displine << 1][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = ((chr >= 0xb3) && (chr <= 0xdf)) ? cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0] : cols[0]; } else { for (c = 0; c < 8; c++) { if (vid->scanline == 8) { From b21c5f1294dbe11ff65ec232dd6ddbfdcde8e48c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 28 Jun 2025 01:12:49 +0600 Subject: [PATCH 031/103] Force horizontal pixel doubling for 320x400/320x480 modes when possible --- src/include/86box/vid_svga.h | 4 ++++ src/include/86box/vid_svga_render.h | 4 ---- src/video/vid_svga.c | 16 ++++++++++++++++ src/video/vid_svga_render.c | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index ad9170ad3..cd516d42d 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -281,6 +281,10 @@ typedef struct svga_t { you should set this flag when entering that mode*/ int disable_blink; + /*Force special shifter bypass logic for 8-bpp lowres modes. + Needed if the screen is squished on certain S3 cards.*/ + int force_shifter_bypass; + /*Force CRTC to dword mode, regardless of CR14/CR17. Required for S3 enhanced mode*/ int force_dword_mode; diff --git a/src/include/86box/vid_svga_render.h b/src/include/86box/vid_svga_render.h index 097bb4509..226ab8a18 100644 --- a/src/include/86box/vid_svga_render.h +++ b/src/include/86box/vid_svga_render.h @@ -58,10 +58,6 @@ extern void svga_render_8bpp_highres(svga_t *svga); extern void svga_render_8bpp_clone_highres(svga_t *svga); extern void svga_render_8bpp_tseng_lowres(svga_t *svga); extern void svga_render_8bpp_tseng_highres(svga_t *svga); -extern void svga_render_8bpp_gs_lowres(svga_t *svga); -extern void svga_render_8bpp_gs_highres(svga_t *svga); -extern void svga_render_8bpp_rgb_lowres(svga_t *svga); -extern void svga_render_8bpp_rgb_highres(svga_t *svga); extern void svga_render_15bpp_lowres(svga_t *svga); extern void svga_render_15bpp_highres(svga_t *svga); extern void svga_render_15bpp_mix_lowres(svga_t *svga); diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 2899f3bf7..60608acb0 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1193,6 +1193,21 @@ svga_recalctimings(svga_t *svga) if (enable_overscan && (svga->monitor->mon_overscan_x != old_monitor_overscan_x || svga->monitor->mon_overscan_y != old_monitor_overscan_y)) video_force_resize_set_monitor(1, svga->monitor_index); + + svga->force_shifter_bypass = 0; + if (svga->hdisp == 320 && svga->dispend >= 400 && !svga->override && svga->render != svga_render_8bpp_clone_highres) { + svga->hdisp *= 2; + if (svga->render == svga_render_16bpp_highres) svga->render = svga_render_16bpp_lowres; + else if (svga->render == svga_render_15bpp_highres) svga->render = svga_render_15bpp_lowres; + else if (svga->render == svga_render_15bpp_mix_highres) svga->render = svga_render_15bpp_mix_lowres; + else if (svga->render == svga_render_24bpp_highres) svga->render = svga_render_24bpp_lowres; + else if (svga->render == svga_render_32bpp_highres) svga->render = svga_render_32bpp_lowres; + else if (svga->render == svga_render_8bpp_highres) { + svga->render = svga_render_8bpp_lowres; + svga->force_shifter_bypass = 1; + } + else svga->hdisp /= 2; + } } static void @@ -1550,6 +1565,7 @@ svga_init(const device_t *info, svga_t *svga, void *priv, int memsize, svga->monitor->mon_overscan_y = 32; svga->x_add = 8; svga->y_add = 16; + svga->force_shifter_bypass = 1; svga->crtc[0] = 63; svga->crtc[6] = 255; diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index bdb496686..de7242bc2 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -694,7 +694,7 @@ svga_render_indexed_gfx(svga_t *svga, bool highres, bool combine8bits) - HT-216 (+ other Video7 chipsets?) has 0x3C4.0xC8 bit 4 which, when set to 1, loads bytes directly, bypassing the shifters. */ - const bool highres8bpp = combine8bits && highres; + const bool highres8bpp = (combine8bits && highres) || svga->force_shifter_bypass; const bool dwordload = ((svga->seqregs[0x01] & 0x10) != 0); const bool wordload = ((svga->seqregs[0x01] & 0x04) != 0) && !dwordload; From faf7cf9ce689775279c00afc79ae51ff1098acdf Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 28 Jun 2025 01:05:24 +0200 Subject: [PATCH 032/103] PC87310 / ALi M5105 - merge the three device_t's and use device_add_param(). --- src/include/86box/sio.h | 12 ++++++---- src/machine/m_at_286_386sx.c | 6 ++--- src/machine/m_at_386dx_486.c | 2 +- src/sio/sio_pc87310.c | 44 ++++++------------------------------ 4 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/include/86box/sio.h b/src/include/86box/sio.h index 0b07d7a13..72878ff46 100644 --- a/src/include/86box/sio.h +++ b/src/include/86box/sio.h @@ -20,8 +20,6 @@ extern const device_t acc3221_device; /* Acer / ALi */ -extern const device_t ali5105_device; - extern const device_t ali5123_device; /* Chips & Technologies */ @@ -79,10 +77,13 @@ extern const device_t i82091aa_398_device; extern const device_t i82091aa_ide_pri_device; extern const device_t i82091aa_ide_device; -/* National Semiconductors */ -extern const device_t pc87310_device; -extern const device_t pc87310_ide_device; +/* National Semiconductors PC87310 / ALi M5105 */ +#define PC87310_IDE 0x0001 +#define PC87310_ALI 0x0002 +extern const device_t pc87310_device; + +/* National Semiconductors */ extern const device_t pc87306_device; extern const device_t pc87311_device; extern const device_t pc87311_ide_device; @@ -92,6 +93,7 @@ extern const device_t pc87332_398_ide_device; extern const device_t pc87332_398_ide_sec_device; extern const device_t pc87332_398_ide_fdcon_device; +/* National Semiconductors PC87307 / PC87309 */ #define PCX7307_PC87307 0x00c0 #define PCX7307_PC97307 0x00cf diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index eb5394ba4..6a5ac1f47 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -118,7 +118,7 @@ machine_at_ama932j_init(const machine_t *model) machine_at_headland_common_init(model, 2); - device_add(&ali5105_device); + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); return ret; } @@ -858,7 +858,7 @@ machine_at_cmdsl386sx25_init(const machine_t *model) device_add(&ide_isa_device); - device_add(&ali5105_device); /* The FDC is part of the ALi M5105. */ + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); device_add(&vl82c113_device); /* The keyboard controller is part of the VL82c113. */ device_add(&vlsi_scamp_device); @@ -1008,7 +1008,7 @@ machine_at_acer100t_init(const machine_t *model) if (gfxcard[0] == VID_INTERNAL) device_add(&oti077_acer100t_device); - device_add(&ali5105_device); + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); return ret; } diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 09efd51bf..eb91f300c 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -535,7 +535,7 @@ machine_at_acera1g_init(const machine_t *model) device_add(&keyboard_ps2_acer_pci_device); - device_add(&ali5105_device); + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); device_add(&ide_ali5213_device); return ret; diff --git a/src/sio/sio_pc87310.c b/src/sio/sio_pc87310.c index 5bd595f05..ae0f5d977 100644 --- a/src/sio/sio_pc87310.c +++ b/src/sio/sio_pc87310.c @@ -40,9 +40,6 @@ #include <86box/sio.h> #include <86box/plat_unused.h> -#define FLAG_IDE 0x00000001 -#define FLAG_ALI 0x00000002 - #ifdef ENABLE_PC87310_LOG int pc87310_do_log = ENABLE_PC87310_LOG; @@ -137,7 +134,7 @@ serial_handler(pc87310_t *dev) * Then they become simple toggle bits. * Therefore, we do this for easier operation. */ - if (dev->flags & FLAG_ALI) { + if (dev->flags & PC87310_ALI) { temp2 = dev->regs[0] & 0x03; temp2 ^= ((temp2 & 0x02) >> 1); } @@ -197,7 +194,7 @@ pc87310_write(UNUSED(uint16_t port), uint8_t val, void *priv) serial_handler(dev); /* Reconfigure IDE controller. */ - if ((dev->flags & FLAG_IDE) && (valxor & 0x20)) { + if ((dev->flags & PC87310_IDE) && (valxor & 0x20)) { pc87310_log("SIO: HDC disabled\n"); ide_pri_disable(); /* Bit 5: 1 = Disable IDE controller. */ @@ -258,7 +255,7 @@ pc87310_reset(pc87310_t *dev) lpt1_handler(dev); serial_handler(dev); - if (dev->flags & FLAG_IDE) { + if (dev->flags & PC87310_IDE) { ide_pri_disable(); ide_pri_enable(); } @@ -286,21 +283,22 @@ pc87310_init(const device_t *info) dev->uart[0] = device_add_inst(&ns16450_device, 1); dev->uart[1] = device_add_inst(&ns16450_device, 2); - if (dev->flags & FLAG_IDE) - device_add((dev->flags & FLAG_ALI) ? &ide_vlb_device : &ide_isa_device); + if (dev->flags & PC87310_IDE) + device_add((dev->flags & PC87310_ALI) ? &ide_vlb_device : &ide_isa_device); pc87310_reset(dev); io_sethandler(0x3f3, 0x0001, pc87310_read, NULL, NULL, pc87310_write, NULL, NULL, dev); - if (dev->flags & FLAG_ALI) + if (dev->flags & PC87310_ALI) io_sethandler(0x3f1, 0x0001, pc87310_read, NULL, NULL, pc87310_write, NULL, NULL, dev); return dev; } +/* The ALi M5105 is an extended clone of this. */ const device_t pc87310_device = { .name = "National Semiconductor PC87310 Super I/O", .internal_name = "pc87310", @@ -314,31 +312,3 @@ const device_t pc87310_device = { .force_redraw = NULL, .config = NULL }; - -const device_t pc87310_ide_device = { - .name = "National Semiconductor PC87310 Super I/O with IDE functionality", - .internal_name = "pc87310_ide", - .flags = 0, - .local = FLAG_IDE, - .init = pc87310_init, - .close = pc87310_close, - .reset = NULL, - .available = NULL, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -const device_t ali5105_device = { - .name = "ALi M5105 Super I/O", - .internal_name = "ali5105", - .flags = 0, - .local = FLAG_ALI, - .init = pc87310_init, - .close = pc87310_close, - .reset = NULL, - .available = NULL, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; From 245ce96115120c8058fd40a5eeaa3228ff1061b9 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 28 Jun 2025 00:06:45 -0400 Subject: [PATCH 033/103] Corrections to TAP UI --- src/qt/qt_settingsnetwork.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index e5bb67db0..9f97bacd6 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -36,20 +36,22 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) auto *nic_cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); auto *net_type_cbox = findChild(QString("comboBoxNet%1").arg(i + 1)); - auto *intf_label = findChild(QString("labelIntf%1").arg(i + 1)); - auto *intf_cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); + auto *intf_label = findChild(QString("labelIntf%1").arg(i + 1)); + auto *intf_cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); auto *conf_btn = findChild(QString("pushButtonConf%1").arg(i + 1)); // auto *net_type_conf_btn = findChild(QString("pushButtonNetTypeConf%1").arg(i + 1)); auto *vde_socket_label = findChild(QString("labelSocketVDENIC%1").arg(i + 1)); - auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); + auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); - auto *bridge_line = findChild(QString("bridgeTAPNIC%1").arg(i + 1)); + auto *bridge_label = findChild(QString("labelBridgeTAPNIC%1").arg(i + 1)); + auto *bridge_line = findChild(QString("bridgeTAPNIC%1").arg(i + 1)); auto *option_list_label = findChild(QString("labelOptionList%1").arg(i + 1)); - auto *option_list_line = findChild(QString("lineOptionList%1").arg(i + 1)); + auto *option_list_line = findChild(QString("lineOptionList%1").arg(i + 1)); + bridge_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_TAP); intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP); conf_btn->setEnabled(network_card_has_config(nic_cbox->currentData().toInt())); // net_type_conf_btn->setEnabled(network_type_has_config(netType)); @@ -63,7 +65,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) socket_line->setVisible(false); // TAP - bridge_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_TAP); + bridge_label->setVisible(false); + bridge_line->setVisible(false); // PCAP intf_cbox->setVisible(false); @@ -92,6 +95,11 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) break; case NET_TYPE_TAP: + // option_list_label->setText("TAP Options"); + option_list_label->setVisible(true); + option_list_line->setVisible(true); + + bridge_label->setVisible(true); bridge_line->setVisible(true); case NET_TYPE_SLIRP: @@ -235,8 +243,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) QString currentVdeSocket = net_cards_conf[i].host_dev_name; auto editline = findChild(QString("socketVDENIC%1").arg(i+1)); editline->setText(currentVdeSocket); - } - else if (net_cards_conf[i].net_type == NET_TYPE_TAP) { + } else if (net_cards_conf[i].net_type == NET_TYPE_TAP) { QString currentTapDevice = net_cards_conf[i].host_dev_name; auto editline = findChild(QString("bridgeTAPNIC%1").arg(i+1)); editline->setText(currentTapDevice); From 19c86c3f7ecdaa8dd8a981fb08c175f96b8690f2 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 19 Jun 2025 21:39:09 -0400 Subject: [PATCH 034/103] A few cleanups in serial passthrough --- src/device/serial_passthrough.c | 29 +++++++++++++++----------- src/include/86box/serial_passthrough.h | 15 ++++++++----- src/qt/win_serial_passthrough.c | 21 ++++++++++--------- src/unix/unix_serial_passthrough.c | 8 +++---- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/device/serial_passthrough.c b/src/device/serial_passthrough.c index 25db29096..479c1dc24 100644 --- a/src/device/serial_passthrough.c +++ b/src/device/serial_passthrough.c @@ -13,7 +13,7 @@ * Jasmine Iwanek * * Copyright 2021 Andreas J. Reichel. - * Copyright 2021-2022 Jasmine Iwanek. + * Copyright 2021-2025 Jasmine Iwanek. */ #include @@ -222,10 +222,15 @@ serial_passthrough_dev_init(const device_t *info) } const char *serpt_mode_names[SERPT_MODES_MAX] = { - [SERPT_MODE_VCON] = "vcon", - [SERPT_MODE_TCPSRV] = "tcpsrv", - [SERPT_MODE_TCPCLNT] = "tcpclnt", - [SERPT_MODE_HOSTSER] = "hostser", +#ifdef _WIN32 + [SERPT_MODE_NPIPE_SRV] = "npipesrv", + [SERPT_MODE_NPIPE_CLNT] = "npipeclnt", +#else + [SERPT_MODE_VCON] = "vcon", +#endif + [SERPT_MODE_TCP_SRV] = "tcpsrv", + [SERPT_MODE_TCP_CLNT] = "tcpclnt", + [SERPT_MODE_HOSTSER] = "hostser", }; // clang-format off @@ -240,19 +245,19 @@ static const device_config_t serial_passthrough_config[] = { .spinner = { 0 }, .selection = { #ifdef _WIN32 - { .description = "Named Pipe (Server)", .value = SERPT_MODE_VCON }, + { .description = "Named Pipe (Server)", .value = SERPT_MODE_NPIPE_SRV }, #if 0 /* TODO */ - { .description = "Named Pipe (Client)", .value = SERPT_MODE_VCON }, + { .description = "Named Pipe (Client)", .value = SERPT_MODE_NPIPE_CLNT }, #endif #else /* _WIN32 */ - { .description = "Pseudo Terminal/Virtual Console", .value = SERPT_MODE_VCON }, + { .description = "Pseudo Terminal/Virtual Console", .value = SERPT_MODE_VCON }, #endif /* _WIN32 */ #if 0 /* TODO */ - { .description = "TCP Server", .value = SERPT_MODE_TCPSRV }, - { .description = "TCP Client", .value = SERPT_MODE_TCPCLNT }, + { .description = "TCP Server", .value = SERPT_MODE_TCP_SRV }, + { .description = "TCP Client", .value = SERPT_MODE_TCP_CLNT }, #endif - { .description = "Host Serial Passthrough", .value = SERPT_MODE_HOSTSER }, - { .description = "" } + { .description = "Host Serial Passthrough", .value = SERPT_MODE_HOSTSER }, + { .description = "" } }, .bios = { { 0 } } }, diff --git a/src/include/86box/serial_passthrough.h b/src/include/86box/serial_passthrough.h index c5454194a..a5fa0013a 100644 --- a/src/include/86box/serial_passthrough.h +++ b/src/include/86box/serial_passthrough.h @@ -13,7 +13,7 @@ * Jasmine Iwanek * * Copyright 2021 Andreas J. Reichel. - * Copyright 2021-2022 Jasmine Iwanek. + * Copyright 2021-2025 Jasmine Iwanek. */ #ifndef SERIAL_PASSTHROUGH_H @@ -28,10 +28,15 @@ #include <86box/serial.h> enum serial_passthrough_mode { - SERPT_MODE_VCON, /*Named Pipe (Server) / Pseudo Terminal/Virtual Console */ - SERPT_MODE_TCPSRV, /* TCP Server (TODO) */ - SERPT_MODE_TCPCLNT, /* TCP Client (TODO) */ - SERPT_MODE_HOSTSER, /* Host Serial Passthrough */ +#ifdef _WIN32 + SERPT_MODE_NPIPE_SRV, /* Named Pipe (Server) */ + SERPT_MODE_NPIPE_CLNT, /* Named Pipe (Client) */ +#else + SERPT_MODE_VCON, /* Pseudo Terminal/Virtual Console */ +#endif + SERPT_MODE_TCP_SRV, /* TCP Server (TODO) */ + SERPT_MODE_TCP_CLNT, /* TCP Client (TODO) */ + SERPT_MODE_HOSTSER, /* Host Serial Passthrough */ SERPT_MODES_MAX, }; diff --git a/src/qt/win_serial_passthrough.c b/src/qt/win_serial_passthrough.c index c1802ce73..e17d70f16 100644 --- a/src/qt/win_serial_passthrough.c +++ b/src/qt/win_serial_passthrough.c @@ -13,7 +13,7 @@ * Jasmine Iwanek * * Copyright 2021 Andreas J. Reichel - * Copyright 2021-2023 Jasmine Iwanek + * Copyright 2021-2025 Jasmine Iwanek */ #define _XOPEN_SOURCE 500 @@ -46,9 +46,9 @@ plat_serpt_close(void *priv) fclose(dev->master_fd); #endif FlushFileBuffers((HANDLE) dev->master_fd); - if (dev->mode == SERPT_MODE_VCON) + if (dev->mode == SERPT_MODE_NPIPE_SRV) DisconnectNamedPipe((HANDLE) dev->master_fd); - if (dev->mode == SERPT_MODE_HOSTSER) { + else if (dev->mode == SERPT_MODE_HOSTSER) { SetCommState((HANDLE) dev->master_fd, (DCB *) dev->backend_priv); free(dev->backend_priv); } @@ -133,7 +133,8 @@ plat_serpt_write(void *priv, uint8_t data) serial_passthrough_t *dev = (serial_passthrough_t *) priv; switch (dev->mode) { - case SERPT_MODE_VCON: + case SERPT_MODE_NPIPE_SRV: + case SERPT_MODE_NPIPE_CLNT: case SERPT_MODE_HOSTSER: plat_serpt_write_vcon(dev, data); break; @@ -157,7 +158,8 @@ plat_serpt_read(void *priv, uint8_t *data) int res = 0; switch (dev->mode) { - case SERPT_MODE_VCON: + case SERPT_MODE_NPIPE_SRV: + case SERPT_MODE_NPIPE_CLNT: case SERPT_MODE_HOSTSER: res = plat_serpt_read_vcon(dev, data); break; @@ -222,15 +224,14 @@ plat_serpt_open_device(void *priv) serial_passthrough_t *dev = (serial_passthrough_t *) priv; switch (dev->mode) { - case SERPT_MODE_VCON: - if (open_pseudo_terminal(dev)) { + case SERPT_MODE_NPIPE_SRV: + if (open_pseudo_terminal(dev)) return 0; - } break; case SERPT_MODE_HOSTSER: - if (open_host_serial_port(dev)) { + if (open_host_serial_port(dev)) return 0; - } + break; default: break; } diff --git a/src/unix/unix_serial_passthrough.c b/src/unix/unix_serial_passthrough.c index 9929f3298..873c706b9 100644 --- a/src/unix/unix_serial_passthrough.c +++ b/src/unix/unix_serial_passthrough.c @@ -13,7 +13,7 @@ * Jasmine Iwanek * * Copyright 2021 Andreas J. Reichel. - * Copyright 2021-2022 Jasmine Iwanek. + * Copyright 2021-2025 Jasmine Iwanek. */ #ifndef __APPLE__ @@ -310,14 +310,12 @@ plat_serpt_open_device(void *priv) switch (dev->mode) { case SERPT_MODE_VCON: - if (!open_pseudo_terminal(dev)) { + if (!open_pseudo_terminal(dev)) return 1; - } break; case SERPT_MODE_HOSTSER: - if (!open_host_serial_port(dev)) { + if (!open_host_serial_port(dev)) return 1; - } break; default: break; From e8c6fcdd4eaf70a6d7c9ee3448ed1f7718d52f20 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 19 Jun 2025 21:55:54 -0400 Subject: [PATCH 035/103] Add support for Client Named Pipe on Windows --- src/device/serial_passthrough.c | 2 -- src/qt/win_serial_passthrough.c | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/device/serial_passthrough.c b/src/device/serial_passthrough.c index 479c1dc24..426bfbc7b 100644 --- a/src/device/serial_passthrough.c +++ b/src/device/serial_passthrough.c @@ -246,9 +246,7 @@ static const device_config_t serial_passthrough_config[] = { .selection = { #ifdef _WIN32 { .description = "Named Pipe (Server)", .value = SERPT_MODE_NPIPE_SRV }, -#if 0 /* TODO */ { .description = "Named Pipe (Client)", .value = SERPT_MODE_NPIPE_CLNT }, -#endif #else /* _WIN32 */ { .description = "Pseudo Terminal/Virtual Console", .value = SERPT_MODE_VCON }, #endif /* _WIN32 */ diff --git a/src/qt/win_serial_passthrough.c b/src/qt/win_serial_passthrough.c index e17d70f16..725dc096f 100644 --- a/src/qt/win_serial_passthrough.c +++ b/src/qt/win_serial_passthrough.c @@ -189,6 +189,38 @@ open_pseudo_terminal(serial_passthrough_t *dev) return 1; } +static int +connect_named_pipe_client(serial_passthrough_t *dev) +{ + char ascii_pipe_name[1024] = { 0 }; + strncpy(ascii_pipe_name, dev->named_pipe, sizeof(ascii_pipe_name) - 1); + + HANDLE hPipe = CreateFileA( + ascii_pipe_name, // pipe name + GENERIC_READ | GENERIC_WRITE, + 0, // no sharing + NULL, // default security attributes + OPEN_EXISTING, // open existing pipe + 0, // default attributes + NULL); // no template file + + if (hPipe == INVALID_HANDLE_VALUE) { + DWORD error = GetLastError(); + wchar_t errorMsg[1024] = { 0 }; + wchar_t finalMsg[1024] = { 0 }; + FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errorMsg, 1024, NULL); + swprintf(finalMsg, 1024, L"Named Pipe (client, named_pipe=\"%hs\", port=COM%d): %ls\n", ascii_pipe_name, dev->port + 1, errorMsg); + ui_msgbox(MBX_ERROR | MBX_FATAL, finalMsg); + return 0; + } + + DWORD mode = PIPE_READMODE_BYTE | PIPE_NOWAIT; + SetNamedPipeHandleState(hPipe, &mode, NULL, NULL); + dev->master_fd = (intptr_t) hPipe; + pclog("Named Pipe client connected to %s\n", ascii_pipe_name); + return 1; +} + static int open_host_serial_port(serial_passthrough_t *dev) { @@ -228,6 +260,10 @@ plat_serpt_open_device(void *priv) if (open_pseudo_terminal(dev)) return 0; break; + case SERPT_MODE_NPIPE_CLNT: + if (connect_named_pipe_client(dev)) + return 0; + break; case SERPT_MODE_HOSTSER: if (open_host_serial_port(dev)) return 0; From 3dbc4bb77118a098243bb5af8bfbfc83ebbf27a6 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Fri, 20 Jun 2025 19:06:48 -0400 Subject: [PATCH 036/103] More magic number work in CGA --- src/video/vid_cga.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 79b9360f5..2abfe6a5c 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -48,8 +48,10 @@ #define DOUBLE_INTERPOLATE_SRGB 2 #define DOUBLE_INTERPOLATE_LINEAR 3 -typedef union -{ +#define DEVICE_VRAM 0x4000 +#define DEVICE_VRAM_MASK 0x3fff + +typedef union { uint32_t color; struct { uint8_t b; @@ -206,11 +208,11 @@ cga_write(uint32_t addr, uint8_t val, void *priv) { cga_t *cga = (cga_t *) priv; - cga->vram[addr & 0x3fff] = val; + cga->vram[addr & DEVICE_VRAM_MASK] = val; if (cga->snow_enabled) { int offset = ((timer_get_remaining_u64(&cga->timer) / CGACONST) * 2) & 0xfc; - cga->charbuffer[offset] = cga->vram[addr & 0x3fff]; - cga->charbuffer[offset | 1] = cga->vram[addr & 0x3fff]; + cga->charbuffer[offset] = cga->vram[addr & DEVICE_VRAM_MASK]; + cga->charbuffer[offset | 1] = cga->vram[addr & DEVICE_VRAM_MASK]; } cga_waitstates(cga); } @@ -223,10 +225,10 @@ cga_read(uint32_t addr, void *priv) cga_waitstates(cga); if (cga->snow_enabled) { int offset = ((timer_get_remaining_u64(&cga->timer) / CGACONST) * 2) & 0xfc; - cga->charbuffer[offset] = cga->vram[addr & 0x3fff]; - cga->charbuffer[offset | 1] = cga->vram[addr & 0x3fff]; + cga->charbuffer[offset] = cga->vram[addr & DEVICE_VRAM_MASK]; + cga->charbuffer[offset | 1] = cga->vram[addr & DEVICE_VRAM_MASK]; } - return cga->vram[addr & 0x3fff]; + return cga->vram[addr & DEVICE_VRAM_MASK]; } void @@ -253,7 +255,7 @@ cga_recalctimings(cga_t *cga) static void cga_render(cga_t *cga, int line) { - uint16_t cursoraddr = (cga->crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (cga->crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & 0x3fff; + uint16_t cursoraddr = (cga->crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (cga->crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & DEVICE_VRAM_MASK; int drawcursor; int x; int column; @@ -313,8 +315,8 @@ cga_render(cga_t *cga, int line) } else if (!(cga->cgamode & CGA_MODE_FLAG_GRAPHICS)) { for (x = 0; x < cga->crtc[CGA_CRTC_HDISP]; x++) { if (cga->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) { - chr = cga->vram[(cga->memaddr << 1) & 0x3fff]; - attr = cga->vram[((cga->memaddr << 1) + 1) & 0x3fff]; + chr = cga->vram[(cga->memaddr << 1) & DEVICE_VRAM_MASK]; + attr = cga->vram[((cga->memaddr << 1) + 1) & DEVICE_VRAM_MASK]; } else chr = attr = 0; drawcursor = ((cga->memaddr == cursoraddr) && cga->cursorvisible && cga->cursoron); @@ -605,7 +607,7 @@ cga_poll(void *priv) cga->vadj--; if (!cga->vadj) { cga->cgadispon = 1; - cga->memaddr = cga->memaddr_backup = (cga->crtc[CGA_CRTC_START_ADDR_LOW] | (cga->crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff; + cga->memaddr = cga->memaddr_backup = (cga->crtc[CGA_CRTC_START_ADDR_LOW] | (cga->crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & DEVICE_VRAM_MASK; cga->scanline = 0; } } else if (cga->scanline == cga->crtc[CGA_CRTC_MAX_SCANLINE_ADDR]) { @@ -623,7 +625,7 @@ cga_poll(void *priv) cga->vadj = cga->crtc[CGA_CRTC_VTOTAL_ADJUST]; if (!cga->vadj) { cga->cgadispon = 1; - cga->memaddr = cga->memaddr_backup = (cga->crtc[CGA_CRTC_START_ADDR_LOW] | (cga->crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff; + cga->memaddr = cga->memaddr_backup = (cga->crtc[CGA_CRTC_START_ADDR_LOW] | (cga->crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & DEVICE_VRAM_MASK; } switch (cga->crtc[CGA_CRTC_CURSOR_START] & 0x60) { @@ -728,7 +730,7 @@ cga_poll(void *priv) cga->cursorvisible = 1; if (cga->cgadispon && (cga->cgamode & CGA_MODE_FLAG_HIGHRES)) { for (x = 0; x < (cga->crtc[CGA_CRTC_HDISP] << 1); x++) - cga->charbuffer[x] = cga->vram[((cga->memaddr << 1) + x) & 0x3fff]; + cga->charbuffer[x] = cga->vram[((cga->memaddr << 1) + x) & DEVICE_VRAM_MASK]; } } } @@ -754,7 +756,7 @@ cga_standalone_init(UNUSED(const device_t *info)) cga->revision = device_get_config_int("composite_type"); cga->snow_enabled = device_get_config_int("snow_enabled"); - cga->vram = malloc(0x4000); + cga->vram = malloc(DEVICE_VRAM); cga_comp_init(cga->revision); timer_add(&cga->timer, cga_poll, cga, 1); From 10dd476becaf68257160628a414debaec25893d1 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 15:08:20 +0200 Subject: [PATCH 037/103] Add GD5401 On-Board Code for the ICL DRS M35/286. --- src/video/vid_cl54xx.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index b2a221e20..fff344f3a 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -45,6 +45,7 @@ #include <86box/plat_unused.h> #define BIOS_GD5401_PATH "roms/video/cirruslogic/avga1.rom" +#define BIOS_GD5401_ONBOARD_PATH "roms/machines/drsm35286/qpaw01-6658237d5e3c2611427518.bin" #define BIOS_GD5402_PATH "roms/video/cirruslogic/avga2.rom" #define BIOS_GD5402_ONBOARD_PATH "roms/machines/cmdsl386sx25/c000.rom" #define BIOS_GD5420_PATH "roms/video/cirruslogic/5420.vbi" @@ -4236,8 +4237,11 @@ gd54xx_init(const device_t *info) switch (id) { case CIRRUS_ID_CLGD5401: - romfn = BIOS_GD5401_PATH; - break; + if (info->local & 0x100) + romfn = BIOS_GD5401_ONBOARD_PATH; + else + romfn = BIOS_GD5401_PATH; + break; case CIRRUS_ID_CLGD5402: if (info->local & 0x200) @@ -4945,6 +4949,20 @@ const device_t gd5401_isa_device = { .config = NULL, }; +const device_t gd5401_onboard_device = { + .name = "Cirrus Logic GD5401 (ISA) (ACUMOS AVGA1) (On-Board)", + .internal_name = "cl_gd5402_onboard", + .flags = DEVICE_ISA16, + .local = CIRRUS_ID_CLGD5401 | 0x100, + .init = gd54xx_init, + .close = gd54xx_close, + .reset = gd54xx_reset, + .available = NULL, + .speed_changed = gd54xx_speed_changed, + .force_redraw = gd54xx_force_redraw, + .config = NULL, +}; + const device_t gd5402_isa_device = { .name = "Cirrus Logic GD5402 (ISA) (ACUMOS AVGA2)", .internal_name = "cl_gd5402_isa", From 3640bcacb41dceb696b666ced843a2410fa2c2ae Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 15:09:17 +0200 Subject: [PATCH 038/103] Add video definition for the on-board GD5401. --- src/include/86box/video.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/video.h b/src/include/86box/video.h index 99f00c3cc..986529d6f 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -358,6 +358,7 @@ extern const device_t chips_69000_onboard_device; /* Cirrus Logic GD54xx */ extern const device_t gd5401_isa_device; +extern const device_t gd5401_onboard_device; extern const device_t gd5402_isa_device; extern const device_t gd5402_onboard_device; extern const device_t gd5420_isa_device; From d04cadb1b9f899a314b77c0cccdd1bd9acb1a55c Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 15:12:49 +0200 Subject: [PATCH 039/103] Add ICL DRS M35/286 machine code. --- src/machine/m_at_286_386sx.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index 6a5ac1f47..856436700 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -529,6 +529,29 @@ machine_at_gw286ct_init(const machine_t *model) return ret; } +int +machine_at_drsm35286_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear("roms/machines/drsm35286/syab04-665821fb81363428830424.bin", + 0x000f0000, 65536, 0); + + if (bios_only || !ret) + return ret; + + device_add(&f82c710_device); + + machine_at_scat_init(model, 1, 0); + + device_add(&ide_isa_device); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + + return ret; +} + int machine_at_senor_scat286_init(const machine_t *model) { From 9767e7795190c393e2cbc41e391ef6f216e54281 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 15:14:40 +0200 Subject: [PATCH 040/103] Add ICL DRS M35/286 machine table entry. --- src/machine/machine_table.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 24b950ad7..2e110df82 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -3981,6 +3981,45 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + { + .name = "[SCAT] ICL DRS M35/286", + .internal_name = "drsm35286", + .type = MACHINE_TYPE_286, + .chipset = MACHINE_CHIPSET_SCAT, + .init = machine_at_drsm35286_init, + .p1_handler = NULL, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_286, + .block = CPU_BLOCK_NONE, + .min_bus = 0, + .max_bus = 0, + .min_voltage = 0, + .max_voltage = 0, + .min_multi = 0, + .max_multi = 0 + }, + .bus_flags = MACHINE_PS2, + .flags = MACHINE_IDE | MACHINE_VIDEO, + .ram = { + .min = 512, + .max = 5000, + .step = 128 + }, + .nvrmask = 127, + .kbc_device = NULL, + .kbc_p1 = 0xff, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = &gd5401_onboard_device, + .snd_device = NULL, + .net_device = NULL + }, /* Has IBM PS/2 Type 1 KBC firmware. */ { .name = "[SCAT] Samsung SPC-4200P", From b9e72c0b08624dd51eae9627f18cb971f908cea6 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 15:15:59 +0200 Subject: [PATCH 041/103] Add ICL DRS M35/286 machine definition. --- src/include/86box/machine.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 39fb1a933..f2ca1d591 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -469,6 +469,7 @@ extern int machine_at_quadt386sx_init(const machine_t *); extern int machine_at_award286_init(const machine_t *); extern int machine_at_gdc212m_init(const machine_t *); extern int machine_at_gw286ct_init(const machine_t *); +extern int machine_at_drsm35286_init(const machine_t *); extern int machine_at_senor_scat286_init(const machine_t *); extern int machine_at_super286c_init(const machine_t *); extern int machine_at_super286tr_init(const machine_t *); From 528581b87a9325539008ce735e3e2cfb82a347a5 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:05:13 +0200 Subject: [PATCH 042/103] ICL DRS M35/286: Use the FDC37C651 instead. --- src/machine/m_at_286_386sx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index 856436700..85c093829 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -540,7 +540,7 @@ machine_at_drsm35286_init(const machine_t *model) if (bios_only || !ret) return ret; - device_add(&f82c710_device); + device_add(&fdc37c651_device); machine_at_scat_init(model, 1, 0); From 79d97194330205c9906199eb3d2a146307722d30 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:26:27 +0200 Subject: [PATCH 043/103] ICL DRS M35/286 fixes. --- src/machine/m_at_286_386sx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index 85c093829..e91b9bcf5 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -540,11 +540,10 @@ machine_at_drsm35286_init(const machine_t *model) if (bios_only || !ret) return ret; - device_add(&fdc37c651_device); + device_add(&ide_isa_device); + device_add(&fdc37c651_ide_device); machine_at_scat_init(model, 1, 0); - - device_add(&ide_isa_device); if (gfxcard[0] == VID_INTERNAL) device_add(machine_get_vid_device(machine)); From d15e062c83c4756502aaf603dcb06c20f3ae4e0f Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 28 Jun 2025 20:41:04 +0200 Subject: [PATCH 044/103] Remove the OpenGL (non-Core) and OpenGL ES renderers. --- src/qt/CMakeLists.txt | 2 - src/qt/qt.c | 27 +--- src/qt/qt_hardwarerenderer.cpp | 257 --------------------------------- src/qt/qt_hardwarerenderer.hpp | 103 ------------- src/qt/qt_mainwindow.cpp | 24 +-- src/qt/qt_mainwindow.ui | 2 - src/qt/qt_rendererstack.cpp | 19 --- src/qt/qt_rendererstack.hpp | 2 - 8 files changed, 10 insertions(+), 426 deletions(-) delete mode 100644 src/qt/qt_hardwarerenderer.cpp delete mode 100644 src/qt/qt_hardwarerenderer.hpp diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index bed9d27c0..076d5cc42 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -85,8 +85,6 @@ add_library(ui STATIC qt_renderercommon.hpp qt_softwarerenderer.cpp qt_softwarerenderer.hpp - qt_hardwarerenderer.cpp - qt_hardwarerenderer.hpp qt_openglrenderer.cpp qt_openglrenderer.hpp qt_glsl_parser.cpp diff --git a/src/qt/qt.c b/src/qt/qt.c index 9ec907f33..f9c617e9d 100644 --- a/src/qt/qt.c +++ b/src/qt/qt.c @@ -38,21 +38,16 @@ qt_nvr_save(void) int plat_vidapi(const char *api) { - if (!strcasecmp(api, "default") || !strcasecmp(api, "system")) { + if (!strcasecmp(api, "default") || !strcasecmp(api, "system")) return 0; - } else if (!strcasecmp(api, "qt_software")) { + else if (!strcasecmp(api, "qt_software")) return 0; - } else if (!strcasecmp(api, "qt_opengl")) { + else if (!strcasecmp(api, "qt_opengl") || !strcasecmp(api, "qt_opengles") || !strcasecmp(api, "qt_opengl3")) return 1; - } else if (!strcasecmp(api, "qt_opengles")) { + else if (!strcasecmp(api, "qt_vulkan")) return 2; - } else if (!strcasecmp(api, "qt_opengl3")) { + else if (!strcasecmp(api, "vnc")) return 3; - } else if (!strcasecmp(api, "qt_vulkan")) { - return 4; - } else if (!strcasecmp(api, "vnc")) { - return 5; - } return 0; } @@ -67,18 +62,12 @@ plat_vidapi_name(int api) name = "qt_software"; break; case 1: - name = "qt_opengl"; - break; - case 2: - name = "qt_opengles"; - break; - case 3: name = "qt_opengl3"; break; - case 4: + case 2: name = "qt_vulkan"; break; - case 5: + case 3: name = "vnc"; break; default: @@ -87,4 +76,4 @@ plat_vidapi_name(int api) } return name; -} \ No newline at end of file +} diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp deleted file mode 100644 index fb84606b0..000000000 --- a/src/qt/qt_hardwarerenderer.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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. - * - * Hardware renderer module. - * - * - * - * Authors: Joakim L. Gilje - * Cacodemon345 - * Teemu Korhonen - * - * Copyright 2021 Joakim L. Gilje - * Copyright 2021-2022 Cacodemon345 - * Copyright 2021-2022 Teemu Korhonen - */ -#include "qt_hardwarerenderer.hpp" -#include -#include -#include - -#include -#include -#include - -extern "C" { -#include <86box/86box.h> -#include <86box/plat.h> -#include <86box/video.h> -} - -void -HardwareRenderer::resizeGL(int w, int h) -{ - m_context->makeCurrent(this); - glViewport(0, 0, qRound(w * devicePixelRatioF()), qRound(h * devicePixelRatioF())); -} - -#define PROGRAM_VERTEX_ATTRIBUTE 0 -#define PROGRAM_TEXCOORD_ATTRIBUTE 1 - -void -HardwareRenderer::initializeGL() -{ - m_context->makeCurrent(this); - initializeOpenGLFunctions(); - auto image = QImage(2048, 2048, QImage::Format_RGB32); - image.fill(0xff000000); - m_texture = new QOpenGLTexture(image); - m_blt = new QOpenGLTextureBlitter; - m_blt->setRedBlueSwizzle(true); - m_blt->create(); - QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this); - const char *vsrc = "attribute highp vec4 VertexCoord;\n" - "attribute mediump vec4 TexCoord;\n" - "varying mediump vec4 texc;\n" - "uniform mediump mat4 MVPMatrix;\n" - "void main(void)\n" - "{\n" - " gl_Position = MVPMatrix * VertexCoord;\n" - " texc = TexCoord;\n" - "}\n"; - QString vsrccore = "in highp vec4 VertexCoord;\n" - "in mediump vec4 TexCoord;\n" - "out mediump vec4 texc;\n" - "uniform mediump mat4 MVPMatrix;\n" - "void main(void)\n" - "{\n" - " gl_Position = MVPMatrix * VertexCoord;\n" - " texc = TexCoord;\n" - "}\n"; - if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0)) { - vsrccore.prepend("#version 300 es\n"); - vshader->compileSourceCode(vsrccore); - } else if (m_context->format().version() >= qMakePair(3, 0) && m_context->format().profile() == QSurfaceFormat::CoreProfile) { - vsrccore.prepend("#version 130\n"); - vshader->compileSourceCode(vsrccore); - } else - vshader->compileSourceCode(vsrc); - - QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this); - const char *fsrc = "uniform sampler2D texture;\n" - "varying mediump vec4 texc;\n" - "void main(void)\n" - "{\n" - " gl_FragColor = texture2D(texture, texc.st).bgra;\n" - "}\n"; - QString fsrccore = "uniform sampler2D texture;\n" - "in mediump vec4 texc;\n" - "out highp vec4 FragColor;\n" - "void main(void)\n" - "{\n" - " FragColor = texture2D(texture, texc.st).bgra;\n" - "}\n"; - if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0)) { - fsrccore.prepend("#version 300 es\n"); - fshader->compileSourceCode(fsrccore); - } else if (m_context->format().version() >= qMakePair(3, 0) && m_context->format().profile() == QSurfaceFormat::CoreProfile) { - fsrccore.prepend("#version 130\n"); - fshader->compileSourceCode(fsrccore); - } else - fshader->compileSourceCode(fsrc); - - m_prog = new QOpenGLShaderProgram; - m_prog->addShader(vshader); - m_prog->addShader(fshader); - m_prog->bindAttributeLocation("VertexCoord", PROGRAM_VERTEX_ATTRIBUTE); - m_prog->bindAttributeLocation("TexCoord", PROGRAM_TEXCOORD_ATTRIBUTE); - m_prog->link(); - - m_prog->bind(); - m_prog->setUniformValue("texture", 0); - - if (m_context->format().version() >= qMakePair(3, 0) && m_vao.create()) { - m_vao.bind(); - } - - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].create(); - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].bind(); - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].allocate(sizeof(QVector2D) * 4); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].create(); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].bind(); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].allocate(sizeof(QVector2D) * 4); - - pclog("OpenGL vendor: %s\n", glGetString(GL_VENDOR)); - pclog("OpenGL renderer: %s\n", glGetString(GL_RENDERER)); - pclog("OpenGL version: %s\n", glGetString(GL_VERSION)); - pclog("OpenGL shader language version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); - glClearColor(0, 0, 0, 1); - m_texture->setWrapMode(QOpenGLTexture::ClampToEdge); - glClear(GL_COLOR_BUFFER_BIT); - m_context->swapBuffers(this); -} - -void -HardwareRenderer::paintGL() -{ - m_context->makeCurrent(this); - glClear(GL_COLOR_BUFFER_BIT); - QVector verts; - QVector texcoords; - QMatrix4x4 mat; - mat.setToIdentity(); - mat.ortho(QRectF(0, 0, (qreal) width() * (qreal) devicePixelRatioF(), (qreal) height() * (qreal) devicePixelRatioF())); - verts.push_back(QVector2D((float) destination.x(), (float) destination.y())); - verts.push_back(QVector2D((float) destination.x(), (float) destination.y() + (float) destination.height())); - verts.push_back(QVector2D((float) destination.x() + (float) destination.width(), (float) destination.y() + (float) destination.height())); - verts.push_back(QVector2D((float) destination.x() + (float) destination.width(), (float) destination.y())); - texcoords.push_back(QVector2D((float) source.x() / 2048.f, (float) (source.y()) / 2048.f)); - texcoords.push_back(QVector2D((float) source.x() / 2048.f, (float) (source.y() + source.height()) / 2048.f)); - texcoords.push_back(QVector2D((float) (source.x() + source.width()) / 2048.f, (float) (source.y() + source.height()) / 2048.f)); - texcoords.push_back(QVector2D((float) (source.x() + source.width()) / 2048.f, (float) (source.y()) / 2048.f)); - - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].bind(); - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].write(0, verts.data(), sizeof(QVector2D) * 4); - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].release(); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].bind(); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].write(0, texcoords.data(), sizeof(QVector2D) * 4); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].release(); - - m_prog->setUniformValue("MVPMatrix", mat); - m_prog->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE); - m_prog->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE); - - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].bind(); - m_prog->setAttributeBuffer(PROGRAM_VERTEX_ATTRIBUTE, GL_FLOAT, 0, 2, 0); - m_vbo[PROGRAM_VERTEX_ATTRIBUTE].release(); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].bind(); - m_prog->setAttributeBuffer(PROGRAM_TEXCOORD_ATTRIBUTE, GL_FLOAT, 0, 2, 0); - m_vbo[PROGRAM_TEXCOORD_ATTRIBUTE].release(); - m_texture->bind(); - m_texture->setMinMagFilters(video_filter_method ? QOpenGLTexture::Linear : QOpenGLTexture::Nearest, video_filter_method ? QOpenGLTexture::Linear : QOpenGLTexture::Nearest); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); -} - -void -HardwareRenderer::setRenderType(RenderType type) -{ - QSurfaceFormat format; - switch (type) { - case RenderType::OpenGL3: - format.setVersion(3, 0); - format.setProfile(QSurfaceFormat::CoreProfile); - case RenderType::OpenGL: - format.setRenderableType(QSurfaceFormat::OpenGL); - break; - case RenderType::OpenGLES: - format.setRenderableType(QSurfaceFormat::OpenGLES); - break; - } - format.setSwapInterval(0); - setFormat(format); -} - -void -HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) -{ - auto tval = this; - void *nuldata = 0; - if (memcmp(&tval, &nuldata, sizeof(void *)) == 0) - return; - auto origSource = source; - if (!m_texture || !m_texture->isCreated()) { - buf_usage[buf_idx].clear(); - source.setRect(x, y, w, h); - return; - } - m_context->makeCurrent(this); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - m_texture->setData(x, y, 0, w, h, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void *) ((uintptr_t) imagebufs[buf_idx].get() + (uintptr_t) (2048 * 4 * y + x * 4)), &m_transferOptions); -#else - m_texture->bind(); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 2048); - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void *) ((uintptr_t) imagebufs[buf_idx].get() + (uintptr_t) (2048 * 4 * y + x * 4))); - m_texture->release(); -#endif - buf_usage[buf_idx].clear(); - source.setRect(x, y, w, h); - if (origSource != source) { - this->pixelRatio = devicePixelRatioF(); - onResize(this->width(), this->height()); - } - update(); -} - -void -HardwareRenderer::resizeEvent(QResizeEvent *event) -{ - this->pixelRatio = devicePixelRatioF(); - onResize(width(), height()); - - QOpenGLWindow::resizeEvent(event); -} - -bool -HardwareRenderer::event(QEvent *event) -{ - bool res = false; - if (!eventDelegate(event, res)) - return QOpenGLWindow::event(event); - return res; -} - -std::vector> -HardwareRenderer::getBuffers() -{ - std::vector> buffers; - - buffers.push_back(std::make_tuple(imagebufs[0].get(), &buf_usage[0])); - buffers.push_back(std::make_tuple(imagebufs[1].get(), &buf_usage[1])); - - return buffers; -} diff --git a/src/qt/qt_hardwarerenderer.hpp b/src/qt/qt_hardwarerenderer.hpp deleted file mode 100644 index f7861d2bd..000000000 --- a/src/qt/qt_hardwarerenderer.hpp +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "qt_renderercommon.hpp" - -#ifdef WAYLAND -# include "wl_mouse.hpp" -#endif - -class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, public RendererCommon { - Q_OBJECT - -private: - bool wayland = false; - QOpenGLContext *m_context; - QOpenGLTexture *m_texture { nullptr }; - QOpenGLShaderProgram *m_prog { nullptr }; - QOpenGLTextureBlitter *m_blt { nullptr }; - QOpenGLBuffer m_vbo[2]; - QOpenGLVertexArrayObject m_vao; - QOpenGLPixelTransferOptions m_transferOptions; - -public: - enum class RenderType { - OpenGL, - OpenGLES, - OpenGL3, - }; - void resizeGL(int w, int h) override; - void initializeGL() override; - void paintGL() override; - void exposeEvent(QExposeEvent *event) override - { - onResize(size().width(), size().height()); - } - - std::vector> getBuffers() override; - HardwareRenderer(QWidget *parent = nullptr, RenderType rtype = RenderType::OpenGL) - : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent->windowHandle()) - , QOpenGLFunctions() - { - imagebufs[0] = std::unique_ptr(new uint8_t[2048 * 2048 * 4]); - imagebufs[1] = std::unique_ptr(new uint8_t[2048 * 2048 * 4]); - - buf_usage = std::vector(2); - buf_usage[0].clear(); - buf_usage[1].clear(); - - setMinimumSize(QSize(16, 16)); - setFlags(Qt::FramelessWindowHint); - parentWidget = parent; - setRenderType(rtype); - - m_transferOptions.setRowLength(2048); - - m_context = new QOpenGLContext(); - m_context->setFormat(format()); - m_context->create(); - update(); - } - ~HardwareRenderer() - { - m_context->makeCurrent(this); - if (m_blt) - m_blt->destroy(); - m_prog->release(); - delete m_prog; - m_prog = nullptr; - m_context->doneCurrent(); - delete m_context; - } - - void setRenderType(RenderType type); - -public slots: - void onBlit(int buf_idx, int x, int y, int w, int h); - -protected: - std::array, 2> imagebufs; - - void resizeEvent(QResizeEvent *event) override; - bool event(QEvent *event) override; -}; diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 5c9e10a85..e7835b5a4 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -420,22 +420,10 @@ MainWindow::MainWindow(QWidget *parent) ui->actionEnable_Discord_integration->setEnabled(discord_loaded); #endif -#if defined Q_OS_WINDOWS || defined Q_OS_MACOS - /* Make the option visible only if ANGLE is loaded. */ - ui->actionHardware_Renderer_OpenGL_ES->setVisible(QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES); - if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGLES && vid_api == 2) - vid_api = 1; -#endif - ui->actionHardware_Renderer_OpenGL->setVisible(QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGLES); - if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES && vid_api == 1) - vid_api = 0; - if ((QApplication::platformName().contains("eglfs") || QApplication::platformName() == "haiku")) { if (vid_api >= 1) fprintf(stderr, "OpenGL renderers are unsupported on %s.\n", QApplication::platformName().toUtf8().data()); vid_api = 0; - ui->actionHardware_Renderer_OpenGL->setVisible(false); - ui->actionHardware_Renderer_OpenGL_ES->setVisible(false); ui->actionVulkan->setVisible(false); ui->actionOpenGL_3_0_Core->setVisible(false); } @@ -469,8 +457,6 @@ MainWindow::MainWindow(QWidget *parent) auto actGroup = new QActionGroup(this); actGroup->addAction(ui->actionSoftware_Renderer); - actGroup->addAction(ui->actionHardware_Renderer_OpenGL); - actGroup->addAction(ui->actionHardware_Renderer_OpenGL_ES); actGroup->addAction(ui->actionOpenGL_3_0_Core); actGroup->addAction(ui->actionVulkan); actGroup->addAction(ui->actionVNC); @@ -495,19 +481,13 @@ MainWindow::MainWindow(QWidget *parent) newVidApi = RendererStack::Renderer::Software; break; case 1: - newVidApi = RendererStack::Renderer::OpenGL; - break; - case 2: - newVidApi = RendererStack::Renderer::OpenGLES; - break; - case 3: newVidApi = RendererStack::Renderer::OpenGL3; break; - case 4: + case 2: newVidApi = RendererStack::Renderer::Vulkan; break; #ifdef USE_VNC - case 5: + case 3: { newVidApi = RendererStack::Renderer::Software; startblit(); diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui index 83a80342b..7f443495c 100644 --- a/src/qt/qt_mainwindow.ui +++ b/src/qt/qt_mainwindow.ui @@ -121,8 +121,6 @@ Re&nderer
- - diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 31cc495b0..b47ea3f7a 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -21,7 +21,6 @@ #include "qt_rendererstack.hpp" #include "ui_qt_rendererstack.h" -#include "qt_hardwarerenderer.hpp" #include "qt_openglrenderer.hpp" #include "qt_softwarerenderer.hpp" #include "qt_vulkanwindowrenderer.hpp" @@ -336,24 +335,6 @@ RendererStack::createRenderer(Renderer renderer) #endif } break; - case Renderer::OpenGL: - { - this->createWinId(); - auto hw = new HardwareRenderer(this); - rendererWindow = hw; - connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection); - current.reset(this->createWindowContainer(hw, this)); - break; - } - case Renderer::OpenGLES: - { - this->createWinId(); - auto hw = new HardwareRenderer(this, HardwareRenderer::RenderType::OpenGLES); - rendererWindow = hw; - connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection); - current.reset(this->createWindowContainer(hw, this)); - break; - } case Renderer::OpenGL3: { this->createWinId(); diff --git a/src/qt/qt_rendererstack.hpp b/src/qt/qt_rendererstack.hpp index 3a76f3ada..99de85c99 100644 --- a/src/qt/qt_rendererstack.hpp +++ b/src/qt/qt_rendererstack.hpp @@ -80,8 +80,6 @@ public: enum class Renderer { Software, - OpenGL, - OpenGLES, OpenGL3, Vulkan, None = -1 From 51736193af30db6a20b49d163beb50e53a0e2698 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:45:21 +0200 Subject: [PATCH 045/103] Add Acer V12P machine table entry. --- src/machine/machine_table.c | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 2e110df82..f4ffecae3 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -72,6 +72,7 @@ extern const device_t d943_device; extern const device_t dells333sl_device; extern const device_t hot433a_device; extern const device_t pbl300sx_device; +extern const device_t v12p_device; const machine_filter_t machine_types[] = { { "None", MACHINE_TYPE_NONE }, @@ -10057,6 +10058,45 @@ const machine_t machines[] = { /* Socket 4 machines */ /* 430LX */ + { + .name = "[i430LX] Acer V12P", + .internal_name = "v12p", + .type = MACHINE_TYPE_SOCKET4, + .chipset = MACHINE_CHIPSET_INTEL_430LX, + .init = machine_at_v12p_init, + .p1_handler = NULL, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_SOCKET4, + .block = CPU_BLOCK_NONE, + .min_bus = 60000000, + .max_bus = 66666667, + .min_voltage = 5000, + .max_voltage = 5000, + .min_multi = MACHINE_MULTIPLIER_FIXED, + .max_multi = MACHINE_MULTIPLIER_FIXED + }, + .bus_flags = MACHINE_PS2_PCI, + .flags = MACHINE_IDE | MACHINE_SCSI | MACHINE_APM, + .ram = { + .min = 2048, + .max = 131072, + .step = 2048 + }, + .nvrmask = 127, + .kbc_device = NULL, + .kbc_p1 = 0xff, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = &v12p_device, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = NULL, + .net_device = NULL + }, /* Has AMIKey H KBC firmware (AMIKey-2), per POST screen with BIOS string shown in the manual. Has PS/2 mouse support with serial-style (DB9) connector. From 9e3b4c2c08fcf0da707e95bf5a6c25ad56d5e0f9 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:46:37 +0200 Subject: [PATCH 046/103] Add Acer V12P machine code. --- src/machine/m_at_socket4.c | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/machine/m_at_socket4.c b/src/machine/m_at_socket4.c index 2d4e1a51a..439bcba9a 100644 --- a/src/machine/m_at_socket4.c +++ b/src/machine/m_at_socket4.c @@ -117,6 +117,81 @@ machine_at_excaliburpci_init(const machine_t *model) return ret; } +int +machine_at_v12p_init(const machine_t *model) + +{ + int ret = 0; + const char* fn; + + /* No ROMs available */ + if (!device_available(model->device)) + return ret; + + device_context(model->device); + fn = device_get_bios_file(machine_get_device(machine), device_get_config_bios("bios_versions"), 0); + ret = bios_load_linear(fn, 0x000e0000, 131072, 0); + device_context_restore(); + + machine_at_common_init(model); + + device_add(&ide_isa_device); + pci_init(PCI_CONFIG_TYPE_2 | PCI_NO_IRQ_STEERING); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x01, PCI_CARD_SCSI, 1, 4, 3, 2); + pci_register_slot(0x02, PCI_CARD_SOUTHBRIDGE, 2, 1, 4, 3); + pci_register_slot(0x03, PCI_CARD_NORMAL, 3, 2, 1, 4); + pci_register_slot(0x04, PCI_CARD_NORMAL, 4, 0, 0, 0); + pci_register_slot(0x05, PCI_CARD_NORMAL, 0, 0, 0, 0); + device_add(&i430lx_device); + device_add(&keyboard_ps2_acer_pci_device); + device_add(&sio_zb_device); + device_add(&ali5105_device); + device_add(&amd_am28f010_flash_device); + device_add(&ncr53c810_onboard_pci_device); + + return ret; +} + +static const device_config_t v12p_config[] = { + // clang-format off + { + .name = "bios_versions", + .description = "BIOS Versions", + .type = CONFIG_BIOS, + .default_string = "v12p_14", + .default_int = 0, + .file_filter = "", + .spinner = { 0 }, /*W1*/ + .bios = { + { .name = "Core Version 1.2 Version R1.4", .internal_name = "v12p_14", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/v12p/v12p_14.bin", "" } }, + { .name = "Core Version 1.2 Version R1.6", .internal_name = "v12p_16", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/v12p/v12p_16.bin", "" } }, + + }, + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + + + +const device_t v12p_device = { + .name = "Acer V12P", + .internal_name = "v12p", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = &v12p_config[0] +}; + + int machine_at_p5mp3_init(const machine_t *model) { From 7383b1b296506c6613109747eec9c4931cb9393a Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:47:39 +0200 Subject: [PATCH 047/103] Add Acer V12P machine definition. --- src/include/86box/machine.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index f2ca1d591..93080538b 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -655,6 +655,7 @@ extern void machine_at_award_common_init(const machine_t *); extern void machine_at_sp4_common_init(const machine_t *model); +extern int machine_at_v12p_init(const machine_t *); extern int machine_at_excaliburpci_init(const machine_t *); extern int machine_at_p5mp3_init(const machine_t *); extern int machine_at_dellxp60_init(const machine_t *); From bbf90d857ed60dc622897b7e9fef0f9cc6fc847d Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:48:50 +0200 Subject: [PATCH 048/103] Move the Acer V12P code. --- src/machine/m_at_socket4.c | 149 ++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/src/machine/m_at_socket4.c b/src/machine/m_at_socket4.c index 439bcba9a..12d8ccd1b 100644 --- a/src/machine/m_at_socket4.c +++ b/src/machine/m_at_socket4.c @@ -41,6 +41,80 @@ #include <86box/video.h> #include <86box/machine.h> +int +machine_at_v12p_init(const machine_t *model) + +{ + int ret = 0; + const char* fn; + + /* No ROMs available */ + if (!device_available(model->device)) + return ret; + + device_context(model->device); + fn = device_get_bios_file(machine_get_device(machine), device_get_config_bios("bios_versions"), 0); + ret = bios_load_linear(fn, 0x000e0000, 131072, 0); + device_context_restore(); + + machine_at_common_init(model); + + device_add(&ide_isa_device); + pci_init(PCI_CONFIG_TYPE_2 | PCI_NO_IRQ_STEERING); + pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); + pci_register_slot(0x01, PCI_CARD_SCSI, 1, 4, 3, 2); + pci_register_slot(0x02, PCI_CARD_SOUTHBRIDGE, 2, 1, 4, 3); + pci_register_slot(0x03, PCI_CARD_NORMAL, 3, 2, 1, 4); + pci_register_slot(0x04, PCI_CARD_NORMAL, 4, 0, 0, 0); + pci_register_slot(0x05, PCI_CARD_NORMAL, 0, 0, 0, 0); + device_add(&i430lx_device); + device_add(&keyboard_ps2_acer_pci_device); + device_add(&sio_zb_device); + device_add(&ali5105_device); + device_add(&amd_am28f010_flash_device); + device_add(&ncr53c810_onboard_pci_device); + + return ret; +} + +static const device_config_t v12p_config[] = { + // clang-format off + { + .name = "bios_versions", + .description = "BIOS Versions", + .type = CONFIG_BIOS, + .default_string = "v12p_14", + .default_int = 0, + .file_filter = "", + .spinner = { 0 }, /*W1*/ + .bios = { + { .name = "Core Version 1.2 Version R1.4", .internal_name = "v12p_14", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/v12p/v12p_14.bin", "" } }, + { .name = "Core Version 1.2 Version R1.6", .internal_name = "v12p_16", .bios_type = BIOS_NORMAL, + .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/v12p/v12p_16.bin", "" } }, + + }, + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on +}; + + + +const device_t v12p_device = { + .name = "Acer V12P", + .internal_name = "v12p", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = &v12p_config[0] +}; + void machine_at_premiere_common_init(const machine_t *model, int pci_switch) { @@ -117,81 +191,6 @@ machine_at_excaliburpci_init(const machine_t *model) return ret; } -int -machine_at_v12p_init(const machine_t *model) - -{ - int ret = 0; - const char* fn; - - /* No ROMs available */ - if (!device_available(model->device)) - return ret; - - device_context(model->device); - fn = device_get_bios_file(machine_get_device(machine), device_get_config_bios("bios_versions"), 0); - ret = bios_load_linear(fn, 0x000e0000, 131072, 0); - device_context_restore(); - - machine_at_common_init(model); - - device_add(&ide_isa_device); - pci_init(PCI_CONFIG_TYPE_2 | PCI_NO_IRQ_STEERING); - pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); - pci_register_slot(0x01, PCI_CARD_SCSI, 1, 4, 3, 2); - pci_register_slot(0x02, PCI_CARD_SOUTHBRIDGE, 2, 1, 4, 3); - pci_register_slot(0x03, PCI_CARD_NORMAL, 3, 2, 1, 4); - pci_register_slot(0x04, PCI_CARD_NORMAL, 4, 0, 0, 0); - pci_register_slot(0x05, PCI_CARD_NORMAL, 0, 0, 0, 0); - device_add(&i430lx_device); - device_add(&keyboard_ps2_acer_pci_device); - device_add(&sio_zb_device); - device_add(&ali5105_device); - device_add(&amd_am28f010_flash_device); - device_add(&ncr53c810_onboard_pci_device); - - return ret; -} - -static const device_config_t v12p_config[] = { - // clang-format off - { - .name = "bios_versions", - .description = "BIOS Versions", - .type = CONFIG_BIOS, - .default_string = "v12p_14", - .default_int = 0, - .file_filter = "", - .spinner = { 0 }, /*W1*/ - .bios = { - { .name = "Core Version 1.2 Version R1.4", .internal_name = "v12p_14", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/v12p/v12p_14.bin", "" } }, - { .name = "Core Version 1.2 Version R1.6", .internal_name = "v12p_16", .bios_type = BIOS_NORMAL, - .files_no = 1, .local = 0, .size = 131072, .files = { "roms/machines/v12p/v12p_16.bin", "" } }, - - }, - }, - { .name = "", .description = "", .type = CONFIG_END } - // clang-format on -}; - - - -const device_t v12p_device = { - .name = "Acer V12P", - .internal_name = "v12p", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - .available = NULL, - .speed_changed = NULL, - .force_redraw = NULL, - .config = &v12p_config[0] -}; - - int machine_at_p5mp3_init(const machine_t *model) { From 2230118215f394b98c56473ebb1ac5de38be9da6 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:51:43 +0200 Subject: [PATCH 049/103] And also limit the DRS M35/286 to 4 MB RAM. More RAM breaks stuff. --- src/machine/machine_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index f4ffecae3..c8b866143 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -4006,7 +4006,7 @@ const machine_t machines[] = { .flags = MACHINE_IDE | MACHINE_VIDEO, .ram = { .min = 512, - .max = 5000, + .max = 4096, .step = 128 }, .nvrmask = 127, From 5fbcbde4ba089e43840ecf374616c8de157aeb88 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sat, 28 Jun 2025 20:55:14 +0200 Subject: [PATCH 050/103] More fixes to the mode switching of the ATI/IBM 8514/A compatibles (June 28th, 2025) The mode switching phase now takes account of the display enable/reset bits of port 0x22e8 (bits 5-6). Fixes Solaris mode switching and keeps everything else happy (I hope). --- src/include/86box/vid_8514a.h | 9 ++ src/video/vid_8514a.c | 12 ++- src/video/vid_ati_mach8.c | 169 +++++++++++++++++----------------- src/video/vid_svga.c | 78 +++++++++++----- 4 files changed, 158 insertions(+), 110 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 9d19d916c..5aa8927e0 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -37,6 +37,13 @@ typedef enum { EXTENSIONS_MAX } ibm8514_extensions_t; +typedef enum { + VGA_MODE = 0, + IBM_MODE, + ATI_MODE, + MODE_MAX +} ibm8514_mode_t; + typedef struct hwcursor8514_t { int ena; int x; @@ -202,6 +209,7 @@ typedef struct ibm8514_t { int split; int h_disp; int h_total; + int h_sync_start; int h_sync_width; int h_disp_time; int rowoffset; @@ -260,6 +268,7 @@ typedef struct ibm8514_t { int ext_pitch; int ext_crt_pitch; ibm8514_extensions_t extensions; + ibm8514_mode_t mode; int onboard; int linear; uint32_t vram_amount; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index 97202340d..b1e38fef7 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -911,8 +911,10 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) switch (port) { case 0x2e8: - if (dev->vc == dev->v_syncstart) - temp |= 0x02; + if (dev->vc == dev->v_syncstart) { + if (dev->accel.advfunc_cntl & 0x04) + temp |= 0x02; + } ibm8514_log("Read: Display Status1=%02x.\n", temp); break; @@ -3817,7 +3819,7 @@ ibm8514_recalctimings(svga_t *svga) } else { if (dev->on) { dev->hdisp = (dev->hdisped + 1) << 3; - dev->h_total = dev->htotal + 1; + dev->h_total = (dev->htotal + 1) << 3; if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ dev->h_total = 0x9e; @@ -3827,10 +3829,14 @@ ibm8514_recalctimings(svga_t *svga) dev->vdisp += 2; dev->v_total = dev->v_total_reg + 1; + if (dev->v_total == 1) + dev->v_total = 0x0669; if (dev->interlace) dev->v_total >>= 1; dev->v_syncstart = dev->v_sync_start + 1; + if (dev->v_syncstart == 1) + dev->v_syncstart = 0x0601; if (dev->interlace) dev->v_syncstart >>= 1; diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 46d3d98c1..d4ec7a4aa 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2699,93 +2699,80 @@ ati_render_32bpp(svga_t *svga) } /*The situation is the following: - When ATI mode is selected, allow complete auto-detection. - But when 8514/A mode is selected, allow detection based on the shadow register sets. + When ATI (0x4aee) mode is selected, allow complete auto-detection. + When 8514/A (0x4ae8) mode is selected, allow detection based on the shadow register sets. */ static void mach_set_resolution(mach_t *mach, svga_t *svga) { - ibm8514_t *dev = (ibm8514_t *) svga->dev8514; - int ret = 0; + ibm8514_t *dev = (ibm8514_t *) svga->dev8514; - dev->h_total = dev->htotal + 1; - - if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->h_total = 0x9e; + dev->h_total = (dev->htotal + 1) << 3; + if (dev->h_total == 8) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ + dev->h_total = 0x9e << 3; dev->hdisp = (dev->hdisped + 1) << 3; dev->vdisp = (dev->v_disp + 1) >> 1; - if ((dev->vdisp == 478) || (dev->vdisp == 598) || (dev->vdisp == 766) || (dev->vdisp == 1022)) + if ((dev->vdisp == 478) || (dev->vdisp == 598) || (dev->vdisp == 766) || (dev->vdisp == 898) || (dev->vdisp == 1022)) dev->vdisp += 2; dev->v_total = dev->v_total_reg + 1; + if (dev->v_total == 1) + dev->v_total = 0x0669; dev->v_syncstart = dev->v_sync_start + 1; + if (dev->v_syncstart == 1) + dev->v_syncstart = 0x0601; - mach_log("VSYNCSTART=%d, VTOTAL=%d, interlace=%02x, vdisp=%d.\n", dev->v_syncstart, dev->v_total, dev->interlace, dev->vdisp); + mach_log("ATI Mode: set=%02x, dispcntl=%02x, h_total=%d, hdisp=%d, vdisp=%d, v_total=%04x, v_syncstart=%04x, hsync_start=%d, hsync_width=%d, clocksel=%02x, advancedcntl=%02x.\n", mach->shadow_set & 0x03, dev->disp_cntl, dev->h_total, dev->hdisp, dev->vdisp, dev->v_total, dev->v_syncstart, dev->hsync_start, dev->hsync_width, mach->accel.clock_sel & 0xff, dev->accel.advfunc_cntl & 0x05); + if ((dev->disp_cntl >> 5) == 1) { /*Enable the 8514/A subsystem and set modes according to the shadow sets if needed.*/ + switch (mach->shadow_set & 0x03) { + case 0x01: + if (!(dev->accel.advfunc_cntl & 0x04)) { + dev->h_total = 0x64 << 3; + dev->hdisp = 640; + dev->vdisp = 480; + dev->v_total = 0x0419; + dev->v_syncstart = 0x03d7; + } + break; + case 0x02: + if (dev->accel.advfunc_cntl & 0x04) { + dev->h_total = 0x9e << 3; + dev->hdisp = 1024; + dev->vdisp = 768; + dev->v_total = 0x0669; + dev->v_syncstart = 0x0601; + } + break; - if (!ATI_MACH32) { - if ((mach->accel.clock_sel & 0x01) && - !(dev->accel.advfunc_cntl & 0x01)) - ret = 2; - else if ((dev->accel.advfunc_cntl & 0x01) && - !(mach->accel.clock_sel & 0x01)) - ret = 1; - else if ((!(dev->accel.advfunc_cntl & 0x01) && (mach->old_on1 & 0x01)) || - (!(mach->accel.clock_sel & 0x01) && (mach->old_on2 & 0x01))) - ret = 0; - } else { - if ((mach->accel.clock_sel & 0x01) && !(mach->old_on2 & 0x01) && - !(dev->accel.advfunc_cntl & 0x01)) - ret = 2; - else if ((dev->accel.advfunc_cntl & 0x01) && !(mach->old_on1 & 0x01) && - !(mach->accel.clock_sel & 0x01)) - ret = 1; - else if ((!(dev->accel.advfunc_cntl & 0x01) && (mach->old_on1 & 0x01)) || - (!(mach->accel.clock_sel & 0x01) && (mach->old_on2 & 0x01))) - ret = 0; - } - - if (ret) { - if (ret == 2) - svga_recalctimings(svga); - else { - switch (mach->shadow_set & 0x03) { - case 0x00: - if (mach->crt_resolution) - svga_recalctimings(svga); - else { - if (dev->accel.advfunc_cntl & 0x04) { - if (dev->hdisp == 640) { - dev->hdisp = 1024; - dev->vdisp = 768; - mach_log("1024x768.\n"); - } - } else { - if (dev->hdisp == 1024) { - dev->hdisp = 640; - dev->vdisp = 480; - mach_log("640x480.\n"); - } - } - svga_recalctimings(svga); - } - break; - case 0x01: - mach->crt_resolution = 0x01; - break; - case 0x02: - mach->crt_resolution = 0x02; - break; - default: - break; + default: + break; + } + svga_recalctimings(svga); + } else if ((dev->disp_cntl >> 5) == 2) { /*Reset 8514/A to defaults if needed.*/ + if (dev->accel.advfunc_cntl & 0x04) { + if (dev->hdisp == 640) { + dev->h_total = 0x9e << 3; + dev->hdisp = 1024; + dev->vdisp = 768; + dev->v_total = 0x0669; + dev->v_syncstart = 0x0601; + svga_recalctimings(svga); + } + } else { + if (dev->hdisp == 1024) { + dev->h_total = 0x64 << 3; + dev->hdisp = 640; + dev->vdisp = 480; + dev->v_total = 0x0419; + dev->v_syncstart = 0x03d7; + svga_recalctimings(svga); } } - } else + } else /*No change (type 0) or reset type 3.*/ svga_recalctimings(svga); - - mach_log("Shadow set ATI=%x, shadow set 8514/A and on1=%x, on2=%x, resolution h=%d, v=%d, vtotal=%d, vsyncstart=%d, crtres=%d, ret=%d, actual passthrough=%x.\n", mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01, dev->hdisp, dev->vdisp, dev->v_total, dev->v_syncstart, mach->crt_resolution, ret, dev->on); } void @@ -2845,7 +2832,7 @@ ati8514_recalctimings(svga_t *svga) svga->render8514 = ibm8514_render_8bpp; } else - mach->crt_resolution = 0; + dev->mode = VGA_MODE; } static void @@ -2899,9 +2886,9 @@ mach_recalctimings(svga_t *svga) svga->ati_4color = 0; } - mach_log("ON=%d, override=%d, gelo=%04x, gehi=%04x, vgahdisp=%d.\n", dev->on, svga->override, mach->accel.ge_offset_lo, mach->accel.ge_offset_hi, svga->hdisp); + mach_log("ON=%d, override=%d, gelo=%04x, gehi=%04x, crtlo=%04x, crthi=%04x, vgahdisp=%d.\n", dev->on, svga->override, mach->accel.ge_offset_lo, mach->accel.ge_offset_hi, mach->accel.crt_offset_lo, mach->accel.crt_offset_hi, svga->hdisp); if (dev->on) { - dev->memaddr_latch = 0; /*(mach->accel.crt_offset_lo | (mach->accel.crt_offset_hi << 16)) << 2;*/ + dev->memaddr_latch = 0; /*(mach->accel.crt_offset_lo | (mach->accel.crt_offset_hi << 16)) << 2;*/ dev->interlace = !!(dev->disp_cntl & 0x10); dev->pitch = dev->ext_pitch; dev->rowoffset = dev->ext_crt_pitch; @@ -2949,8 +2936,8 @@ mach_recalctimings(svga_t *svga) if (ATI_MACH32) { switch ((mach->shadow_set >> 8) & 0x03) { case 0x00: - mach->accel.src_pitch = ((mach->accel.ge_pitch & 0xff) << 3); - mach->accel.dst_pitch = ((mach->accel.ge_pitch & 0xff) << 3); + mach->accel.src_pitch = dev->pitch; + mach->accel.dst_pitch = dev->pitch; mach->accel.src_ge_offset = (mach->accel.ge_offset_lo | (mach->accel.ge_offset_hi << 16)); mach->accel.dst_ge_offset = (mach->accel.ge_offset_lo | (mach->accel.ge_offset_hi << 16)); if (dev->bpp) { @@ -2972,7 +2959,7 @@ mach_recalctimings(svga_t *svga) dev->accel.dst_ge_offset = mach->accel.dst_ge_offset; break; case 0x01: - mach->accel.dst_pitch = ((mach->accel.ge_pitch & 0xff) << 3); + mach->accel.dst_pitch = dev->pitch; mach->accel.dst_ge_offset = (mach->accel.ge_offset_lo | (mach->accel.ge_offset_hi << 16)); if (dev->bpp) mach->accel.dst_ge_offset <<= 1; @@ -2987,7 +2974,7 @@ mach_recalctimings(svga_t *svga) dev->accel.dst_ge_offset = mach->accel.dst_ge_offset; break; case 0x02: - mach->accel.src_pitch = ((mach->accel.ge_pitch & 0xff) << 3); + mach->accel.src_pitch = dev->pitch; mach->accel.src_ge_offset = (mach->accel.ge_offset_lo | (mach->accel.ge_offset_hi << 16)); if (dev->bpp) mach->accel.src_ge_offset <<= 1; @@ -3067,7 +3054,7 @@ mach_recalctimings(svga_t *svga) svga->render8514 = ibm8514_render_8bpp; } } else { - mach->crt_resolution = 0; + dev->mode = VGA_MODE; if (!svga->scrblank && (svga->crtc[0x17] & 0x80) && svga->attr_palette_enable) { mach_log("GDCREG5=%02x, ATTR10=%02x, ATI B0 bit 5=%02x, ON=%d.\n", svga->gdcreg[5] & 0x60, svga->attrregs[0x10] & 0x40, mach->regs[0xb0] & 0x20, dev->on); @@ -3240,7 +3227,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach_log("ATI 8514/A: V_DISP write 16E8=%d, vdisp2=%d.\n", dev->v_disp, dev->v_disp2); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } else { - if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ + if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { WRITE8(port, dev->v_disp, val); dev->v_disp &= 0x1fff; @@ -3265,7 +3252,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u case 0x1ae8: if (len == 2) { - if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ + if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10) && val) { dev->v_sync_start = val; dev->v_sync_start &= 0x1fff; @@ -3274,7 +3261,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach_log("ATI 8514/A: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); mach_log("ATI 8514/A: (0x%04x): vsyncstart=0x%02x.\n", port, val); } else { - if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ + if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { WRITE8(port, dev->v_sync_start, val); dev->v_sync_start &= 0x1fff; @@ -3285,7 +3272,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u break; case 0x1ae9: if (len == 1) { - if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ + if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { WRITE8(port, dev->v_sync_start, val >> 8); dev->v_sync_start &= 0x1fff; @@ -3334,7 +3321,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u case 0x4ae8: case 0x4ae9: - mach->old_on1 = dev->accel.advfunc_cntl & 0x01; WRITE8(port, dev->accel.advfunc_cntl, val); if (len == 2) { WRITE8(port + 1, dev->accel.advfunc_cntl, val >> 8); @@ -3348,6 +3334,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } } + dev->mode = IBM_MODE; mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, valxor=%x, shadow crt=%x, hdisp=%d, vdisp=%d, extmode=%02x, accelbpp=%d, crt=%d, crtres=%d.\n", CS, cpu_state.pc, port, val & 0x01, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp, dev->vdisp, mach->regs[0xb0] & 0x20, dev->accel_bpp, dev->_8514crt, mach->crt_resolution); @@ -3686,7 +3673,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } else dev->_8514crt = 1; - mach_set_resolution(mach, svga); + if (dev->mode != VGA_MODE) + mach_set_resolution(mach, svga); + else + svga_recalctimings(svga); + if (ATI_GRAPHICS_ULTRA || ATI_MACH32) mach32_updatemapping(mach, svga); @@ -3779,13 +3770,15 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u case 0x4aee: case 0x4aef: - mach->old_on2 = mach->accel.clock_sel & 0x01; WRITE8(port, mach->accel.clock_sel, val); if (len == 2) { WRITE8(port + 1, mach->accel.clock_sel, val >> 8); } - dev->on = mach->accel.clock_sel & 0x01; + if (!(dev->accel.advfunc_cntl & 0x01)) + dev->on = mach->accel.clock_sel & 0x01; + dev->vendor_mode = 1; + dev->mode = ATI_MODE; mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, val=%04x, xor=%d, hdisp=%d, vdisp=%d, accelbpp=%d.\n", CS, cpu_state.pc, port, mach->accel.clock_sel & 0x01, val, dev->on, dev->hdisp, dev->vdisp, dev->accel_bpp); @@ -3937,7 +3930,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } svga_set_ramdac_type(svga, !!(mach->accel.ext_ge_config & 0x4000)); mach_log("ATI 8514/A: (0x%04x) Extended Configuration=%04x, val=%04x.\n", port, mach->accel.ext_ge_config, val); - mach_set_resolution(mach, svga); + if (dev->mode != VGA_MODE) + mach_set_resolution(mach, svga); + else + svga_recalctimings(svga); + mach32_updatemapping(mach, svga); } else ati_eeprom_write(&mach->eeprom, !!(mach->accel.ext_ge_config & 0x04), !!(mach->accel.ext_ge_config & 0x02), !!(mach->accel.ext_ge_config & 0x01)); @@ -7195,6 +7192,7 @@ mach8_init(const device_t *info) mach_io_set(mach); mach->accel.cmd_type = -2; dev->accel.cmd_back = 1; + dev->mode = IBM_MODE; if (ATI_MACH32) { svga->decode_mask = (4 << 20) - 1; @@ -7256,6 +7254,7 @@ ati8514_init(svga_t *svga, void *ext8514, void *dev8514) dev->disp_cntl = 0x33; mach->accel.clock_sel = 0x1c; dev->accel.cmd_back = 1; + dev->mode = IBM_MODE; io_sethandler(0x02ea, 4, ati8514_in, NULL, NULL, ati8514_out, NULL, NULL, svga); ati8514_io_set(svga); diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index c9e02ac78..2073fb8c0 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -977,29 +977,57 @@ svga_recalctimings(svga_t *svga) } } -#ifdef TBD +#if TBD if (ibm8514_active && (svga->dev8514 != NULL)) { if (dev->on) { - uint32_t dot8514 = dev->h_blankstart; - uint32_t adj_dot8514 = dev->h_blankstart; - uint32_t eff_mask8514 = 0x0000001f; - dev->hblank_sub = 0; + uint32_t _8514_dot = dev->h_sync_start; + uint32_t _8514_adj_dot = dev->h_sync_start; + uint32_t _8514_eff_mask = (dev->h_blank_end_val & ~0x0000001f) ? dev->h_blank_end_mask : 0x0000001f; + dev->h_blank_sub = 0; - while (adj_dot8514 < (dev->h_total << 1)) { - if (dot8514 == dev->h_total) - dot8514 = 0; + mach_log("8514/A: HDISP=%d, HDISPED=%d, Blank: %04i-%04i, Total: %04i, " + "Mask: %02X, ADJ_DOT=%04i.\n", dev->hdisp, (dev->hdisped + 1) << 3, + dev->h_sync_start, dev->h_blank_end_val, + dev->h_total, _8514_eff_mask, _8514_adj_dot); - if (adj_dot8514 >= dev->h_total) - dev->hblank_sub++; + while (_8514_adj_dot < (dev->h_total << 1)) { + if (_8514_dot == dev->h_total) + _8514_dot = 0; - if ((dot8514 & eff_mask8514) == (dev->h_blank_end_val & eff_mask8514)) + if (_8514_adj_dot >= dev->h_total) + dev->h_blank_sub++; + + mach_log("8514/A: Loop: adjdot=%d, htotal=%d, dotmask=%02x, " + "hblankendvalmask=%02x, blankendval=%02x.\n", adj_dot, + dev->h_total, _8514_dot & _8514_eff_mask, dev->h_blank_end_val & _8514_eff_mask, + dev->h_blank_end_val); + if ((_8514_dot & _8514_eff_mask) == (dev->h_blank_end_val & _8514_eff_mask)) break; - dot8514++; - adj_dot8514++; + _8514_dot++; + _8514_adj_dot++; } - dev->h_disp -= dev->hblank_sub; + uint32_t _8514_hd = dev->hdisp; + dev->hdisp -= dev->h_blank_sub; + + svga->left_overscan = svga->x_add = (dev->h_total - _8514_adj_dot - 1) << 3; + svga->monitor->mon_overscan_x = svga->x_add + (dev->h_sync_start << 3) - _8514_hd + 8; + svga->monitor->mon_overscan_x++; + + if ((dev->hdisp >= 2048) || (svga->left_overscan < 0)) { + svga->left_overscan = svga->x_add = 0; + svga->monitor->mon_overscan_x = 0; + } + + /* - 1 because + 1 but also - 2 to compensate for the + 2 added to vtotal above. */ + svga->y_add = svga->vtotal - svga->vblankend - 1; + svga->monitor->mon_overscan_y = svga->y_add + abs(svga->vblankstart - svga->dispend); + + if ((svga->dispend >= 2048) || (svga->y_add < 0)) { + svga->y_add = 0; + svga->monitor->mon_overscan_y = 0; + } } } #endif @@ -1194,18 +1222,24 @@ svga_recalctimings(svga_t *svga) video_force_resize_set_monitor(1, svga->monitor_index); svga->force_shifter_bypass = 0; - if (svga->hdisp == 320 && svga->dispend >= 400 && !svga->override && svga->render != svga_render_8bpp_clone_highres) { - svga->hdisp *= 2; - if (svga->render == svga_render_16bpp_highres) svga->render = svga_render_16bpp_lowres; - else if (svga->render == svga_render_15bpp_highres) svga->render = svga_render_15bpp_lowres; - else if (svga->render == svga_render_15bpp_mix_highres) svga->render = svga_render_15bpp_mix_lowres; - else if (svga->render == svga_render_24bpp_highres) svga->render = svga_render_24bpp_lowres; - else if (svga->render == svga_render_32bpp_highres) svga->render = svga_render_32bpp_lowres; + if ((svga->hdisp == 320) && (svga->dispend >= 400) && !svga->override && (svga->render != svga_render_8bpp_clone_highres)) { + svga->hdisp <<= 1; + if (svga->render == svga_render_16bpp_highres) + svga->render = svga_render_16bpp_lowres; + else if (svga->render == svga_render_15bpp_highres) + svga->render = svga_render_15bpp_lowres; + else if (svga->render == svga_render_15bpp_mix_highres) + svga->render = svga_render_15bpp_mix_lowres; + else if (svga->render == svga_render_24bpp_highres) + svga->render = svga_render_24bpp_lowres; + else if (svga->render == svga_render_32bpp_highres) + svga->render = svga_render_32bpp_lowres; else if (svga->render == svga_render_8bpp_highres) { svga->render = svga_render_8bpp_lowres; svga->force_shifter_bypass = 1; } - else svga->hdisp /= 2; + else + svga->hdisp >>= 1; } } From 9a02cb62c6a64896fc0544e6f6c46493d2f1634a Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:55:23 +0200 Subject: [PATCH 051/103] and another RAM correction - the Acer V12P takes up to 192 MB RAM. --- src/machine/machine_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index c8b866143..64ef7cbc2 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -10082,7 +10082,7 @@ const machine_t machines[] = { .flags = MACHINE_IDE | MACHINE_SCSI | MACHINE_APM, .ram = { .min = 2048, - .max = 131072, + .max = 196608, .step = 2048 }, .nvrmask = 127, From 76e8454fa4ea9f3d29afd0ddffd32aa4d684c160 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 28 Jun 2025 21:02:00 +0200 Subject: [PATCH 052/103] Attempt to fix compile on Linux and Mac. --- src/qt/qt_rendererstack.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index b47ea3f7a..5256de3d6 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -40,6 +40,22 @@ #include #include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifdef WAYLAND +# include "wl_mouse.hpp" +#endif + #ifdef __APPLE__ # include #endif From 1db77f4a32d7673bcbe252543699e505221b9b71 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 21:17:59 +0200 Subject: [PATCH 053/103] take the DRS/M35 286 "fix" back Turns out it does work with 5120 KB, but just not with 5000 KB. --- src/machine/machine_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 64ef7cbc2..85a6610a8 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -4006,7 +4006,7 @@ const machine_t machines[] = { .flags = MACHINE_IDE | MACHINE_VIDEO, .ram = { .min = 512, - .max = 4096, + .max = 5120, .step = 128 }, .nvrmask = 127, From 034902ee5ec3a73fda673e556b8c16c63f3c2721 Mon Sep 17 00:00:00 2001 From: toggo9 <121191375+toggo9@users.noreply.github.com> Date: Sat, 28 Jun 2025 21:35:46 +0200 Subject: [PATCH 054/103] another V12P fix (to make compile possible again) --- src/machine/m_at_socket4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/m_at_socket4.c b/src/machine/m_at_socket4.c index 12d8ccd1b..8d1f518b8 100644 --- a/src/machine/m_at_socket4.c +++ b/src/machine/m_at_socket4.c @@ -70,7 +70,7 @@ machine_at_v12p_init(const machine_t *model) device_add(&i430lx_device); device_add(&keyboard_ps2_acer_pci_device); device_add(&sio_zb_device); - device_add(&ali5105_device); + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); device_add(&amd_am28f010_flash_device); device_add(&ncr53c810_onboard_pci_device); From 765567bf33efa377d03d9698de0c8cbb86de9bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miran=20Gr=C4=8Da?= Date: Sat, 28 Jun 2025 21:46:17 +0200 Subject: [PATCH 055/103] Update qt_openglrenderer.hpp - #include . --- src/qt/qt_openglrenderer.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/qt_openglrenderer.hpp b/src/qt/qt_openglrenderer.hpp index 4d1f68acb..776a2f53e 100644 --- a/src/qt/qt_openglrenderer.hpp +++ b/src/qt/qt_openglrenderer.hpp @@ -34,6 +34,7 @@ # include #endif +#include #include #include #include From 5ea9edd6a3630cb39937cd7651a4069d1a6bf1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miran=20Gr=C4=8Da?= Date: Sat, 28 Jun 2025 22:29:05 +0200 Subject: [PATCH 056/103] Update hdd_image.c - hide the empty_sector_1m variable on Unix. --- src/disk/hdd_image.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/disk/hdd_image.c b/src/disk/hdd_image.c index 09f48ad50..75c27f4d1 100644 --- a/src/disk/hdd_image.c +++ b/src/disk/hdd_image.c @@ -56,7 +56,9 @@ typedef struct hdd_image_t { hdd_image_t hdd_images[HDD_NUM]; static char empty_sector[512]; +#ifndef __unix__ static char *empty_sector_1mb; +#endif #ifdef ENABLE_HDD_IMAGE_LOG int hdd_image_do_log = ENABLE_HDD_IMAGE_LOG; From c441bb75c572319c48b45d8cfed55c1a9d40c4a4 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sun, 29 Jun 2025 00:07:04 +0200 Subject: [PATCH 057/103] Actually use the configuration of the FDC cards when needed. Should fix unavailable configuration boxes in the 86box settings GUI. --- src/qt/qt_settingsstoragecontrollers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/qt_settingsstoragecontrollers.cpp b/src/qt/qt_settingsstoragecontrollers.cpp index b3d827fa2..d282bcb8b 100644 --- a/src/qt/qt_settingsstoragecontrollers.cpp +++ b/src/qt/qt_settingsstoragecontrollers.cpp @@ -243,7 +243,7 @@ SettingsStorageControllers::on_comboBoxFD_currentIndexChanged(int index) if (index < 0) return; - ui->pushButtonFD->setEnabled(hdc_has_config(ui->comboBoxFD->currentData().toInt()) > 0); + ui->pushButtonFD->setEnabled(fdc_card_has_config(ui->comboBoxFD->currentData().toInt()) > 0); } void From c15f6d757cb205599b0ec89de2bc03d06d9a175f Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 29 Jun 2025 00:35:38 +0200 Subject: [PATCH 058/103] Fixed all the vid_api checks in the QT code. --- src/qt/qt_main.cpp | 2 +- src/qt/qt_mainwindow.cpp | 6 +++--- src/qt/qt_mainwindow.ui | 28 +++------------------------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index cffae1597..89525635f 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -835,7 +835,7 @@ main(int argc, char *argv[]) /* Set the PAUSE mode depending on the renderer. */ #ifdef USE_VNC - if (vid_api == 5) + if (vid_api == 3) plat_pause(1); else #endif diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index e7835b5a4..14bf85f27 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -429,7 +429,7 @@ MainWindow::MainWindow(QWidget *parent) } #ifndef USE_VNC - if (vid_api == 5) + if (vid_api == 3) vid_api = 0; ui->actionVNC->setVisible(false); #endif @@ -450,7 +450,7 @@ MainWindow::MainWindow(QWidget *parent) if (!vulkanAvailable) #endif { - if (vid_api == 4) + if (vid_api == 2) vid_api = 0; ui->actionVulkan->setVisible(false); } @@ -465,7 +465,7 @@ MainWindow::MainWindow(QWidget *parent) connect(actGroup, &QActionGroup::triggered, [this](QAction *action) { vid_api = action->property("vid_api").toInt(); #ifdef USE_VNC - if (vnc_enabled && vid_api != 5) { + if (vnc_enabled && vid_api != 3) { startblit(); vnc_enabled = 0; vnc_close(); diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui index 7f443495c..63bc0b01b 100644 --- a/src/qt/qt_mainwindow.ui +++ b/src/qt/qt_mainwindow.ui @@ -397,28 +397,6 @@ 0 - - - true - - - Qt (&OpenGL) - - - 1 - - - - - true - - - Qt (OpenGL &ES) - - - 2 - - true @@ -749,7 +727,7 @@ Open&GL (3.0 Core) - 3 + 1 @@ -841,7 +819,7 @@ &Vulkan - 4 + 2 @@ -865,7 +843,7 @@ VNC - 5 + 3 From 766bd1cfb9b280b1fd7154aeb19437a0313e86d1 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Sun, 29 Jun 2025 00:42:27 +0200 Subject: [PATCH 059/103] Fix swapped value of the ramdacs used by the Mach32 PCI. Now it correctly detects what's selected as the ramdac. --- src/video/vid_ati_mach8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index d4ec7a4aa..c5cb2ccca 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -7141,9 +7141,9 @@ mach8_init(const device_t *info) video_inform(VIDEO_FLAG_TYPE_8514, &timing_mach32_pci); mach->config1 |= 0x0e; if (mach->ramdac_type == ATI_68860) - mach->config1 |= 0x0400; - else mach->config1 |= 0x0a00; + else + mach->config1 |= 0x0400; mach->config2 |= 0x2000; svga->clock_gen = device_add(&ati18811_1_device); } else { From 9e34464759f13d4e2bc5089753cdb2f5ac01d7e6 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 28 Jun 2025 18:48:30 -0400 Subject: [PATCH 060/103] Deal with renderer magic numbers --- src/include/86box/renderdefs.h | 40 ++++++++++++++++++++++++++++++++++ src/qt/qt.c | 39 +++++++++++++++++---------------- src/qt/qt_main.cpp | 3 ++- src/qt/qt_mainwindow.cpp | 23 +++++++++---------- 4 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 src/include/86box/renderdefs.h diff --git a/src/include/86box/renderdefs.h b/src/include/86box/renderdefs.h new file mode 100644 index 000000000..36c3d9f74 --- /dev/null +++ b/src/include/86box/renderdefs.h @@ -0,0 +1,40 @@ +/* + * 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. + * + * definitions for renderers + * + * Authors: Jasmine Iwanek, + * + * Copyright 2025 Jasmine Iwanek. + */ +#ifndef EMU_RENDERDEFS_H +#define EMU_RENDERDEFS_H + +#define RENDERER_NAME_DEFAULT "default" +#define RENDERER_NAME_SYSTEM "system" +#define RENDERER_NAME_QT_SOFTWARE "qt_software" +#define RENDERER_NAME_QT_OPENGL "qt_opengl" +#define RENDERER_NAME_QT_OPENGLES "qt_opengles" +#define RENDERER_NAME_QT_OPENGL3 "qt_opengl3" +#define RENDERER_NAME_QT_VULKAN "qt_vulkan" +#define RENDERER_NAME_VNC "vnc" + +#define RENDERER_SOFTWARE 0 +#define RENDERER_OPENGL3 1 +#define RENDERER_VULKAN 2 +#define RENDERER_VNC 3 + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*EMU_RENDERDEFS_H*/ diff --git a/src/qt/qt.c b/src/qt/qt.c index f9c617e9d..e19cf1aac 100644 --- a/src/qt/qt.c +++ b/src/qt/qt.c @@ -28,6 +28,7 @@ #include <86box/plat.h> #include <86box/timer.h> #include <86box/nvr.h> +#include <86box/renderdefs.h> int qt_nvr_save(void) @@ -38,16 +39,16 @@ qt_nvr_save(void) int plat_vidapi(const char *api) { - if (!strcasecmp(api, "default") || !strcasecmp(api, "system")) - return 0; - else if (!strcasecmp(api, "qt_software")) - return 0; - else if (!strcasecmp(api, "qt_opengl") || !strcasecmp(api, "qt_opengles") || !strcasecmp(api, "qt_opengl3")) - return 1; - else if (!strcasecmp(api, "qt_vulkan")) - return 2; - else if (!strcasecmp(api, "vnc")) - return 3; + if (!strcasecmp(api, RENDERER_NAME_DEFAULT) || !strcasecmp(api, RENDERER_NAME_SYSTEM)) + return RENDERER_SOFTWARE; + else if (!strcasecmp(api, RENDERER_NAME_QT_SOFTWARE)) + return RENDERER_SOFTWARE; + else if (!strcasecmp(api, RENDERER_NAME_QT_OPENGL) || !strcasecmp(api, RENDERER_NAME_QT_OPENGLES) || !strcasecmp(api, RENDERER_NAME_QT_OPENGL3)) + return RENDERER_OPENGL3; + else if (!strcasecmp(api, RENDERER_NAME_QT_VULKAN)) + return RENDERER_VULKAN; + else if (!strcasecmp(api, RENDERER_NAME_VNC)) + return RENDERER_VNC; return 0; } @@ -55,20 +56,20 @@ plat_vidapi(const char *api) char * plat_vidapi_name(int api) { - char *name = "default"; + char *name = RENDERER_NAME_DEFAULT; switch (api) { - case 0: - name = "qt_software"; + case RENDERER_SOFTWARE: + name = RENDERER_NAME_QT_SOFTWARE; break; - case 1: - name = "qt_opengl3"; + case RENDERER_OPENGL3: + name = RENDERER_NAME_QT_OPENGL3; break; - case 2: - name = "qt_vulkan"; + case RENDERER_VULKAN: + name = RENDERER_NAME_QT_VULKAN; break; - case 3: - name = "vnc"; + case RENDERER_VNC: + name = RENDERER_NAME_VNC; break; default: fatal("Unknown renderer: %i\n", api); diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 89525635f..afb5fcc1d 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -55,6 +55,7 @@ extern "C" { #endif #include <86box/gdbstub.h> #include <86box/version.h> +#include <86box/renderdefs.h> } #ifdef Q_OS_WINDOWS @@ -835,7 +836,7 @@ main(int argc, char *argv[]) /* Set the PAUSE mode depending on the renderer. */ #ifdef USE_VNC - if (vid_api == 3) + if (vid_api == RENDERER_VNC) plat_pause(1); else #endif diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 14bf85f27..6f87c3ce0 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -52,6 +52,7 @@ extern "C" { #include <86box/apm.h> #include <86box/nvr.h> #include <86box/acpi.h> +#include <86box/renderdefs.h> #ifdef USE_VNC # include <86box/vnc.h> @@ -421,16 +422,16 @@ MainWindow::MainWindow(QWidget *parent) #endif if ((QApplication::platformName().contains("eglfs") || QApplication::platformName() == "haiku")) { - if (vid_api >= 1) + if ((vid_api == RENDERER_OPENGL3) || (vid_api == RENDERER_VULKAN)) fprintf(stderr, "OpenGL renderers are unsupported on %s.\n", QApplication::platformName().toUtf8().data()); - vid_api = 0; + vid_api = RENDERER_SOFTWARE; ui->actionVulkan->setVisible(false); ui->actionOpenGL_3_0_Core->setVisible(false); } #ifndef USE_VNC - if (vid_api == 3) - vid_api = 0; + if (vid_api == RENDERER_VNC) + vid_api = RENDERER_SOFTWARE; ui->actionVNC->setVisible(false); #endif @@ -450,8 +451,8 @@ MainWindow::MainWindow(QWidget *parent) if (!vulkanAvailable) #endif { - if (vid_api == 2) - vid_api = 0; + if (vid_api == RENDERER_VULKAN) + vid_api = RENDERER_SOFTWARE; ui->actionVulkan->setVisible(false); } @@ -465,7 +466,7 @@ MainWindow::MainWindow(QWidget *parent) connect(actGroup, &QActionGroup::triggered, [this](QAction *action) { vid_api = action->property("vid_api").toInt(); #ifdef USE_VNC - if (vnc_enabled && vid_api != 3) { + if (vnc_enabled && vid_api != RENDERER_VNC) { startblit(); vnc_enabled = 0; vnc_close(); @@ -477,17 +478,17 @@ MainWindow::MainWindow(QWidget *parent) switch (vid_api) { default: break; - case 0: + case RENDERER_SOFTWARE: newVidApi = RendererStack::Renderer::Software; break; - case 1: + case RENDERER_OPENGL3: newVidApi = RendererStack::Renderer::OpenGL3; break; - case 2: + case RENDERER_VULKAN: newVidApi = RendererStack::Renderer::Vulkan; break; #ifdef USE_VNC - case 3: + case RENDERER_VNC: { newVidApi = RendererStack::Renderer::Software; startblit(); From e8c77562fc58a25d8d01556356d76cde49c118fe Mon Sep 17 00:00:00 2001 From: MaxwellS04 Date: Sun, 29 Jun 2025 07:58:06 +0700 Subject: [PATCH 061/103] Correct RAM memory step for D943 --- src/machine/machine_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 85a6610a8..f1bcd36c3 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -12290,7 +12290,7 @@ const machine_t machines[] = { .ram = { .min = 8192, .max = 131072, - .step = 8192 + .step = 4096 }, .nvrmask = 511, .kbc_device = NULL, From 3a26b9d46be193096f7d1aa599d988a92c1d8c86 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 28 Jun 2025 19:33:57 -0400 Subject: [PATCH 062/103] Many warning fixes --- src/codegen_new/codegen_backend_x86-64_ops.c | 2 +- src/cpu/cpu.h | 2 +- src/cpu/softfloat3e/s_shiftRightJam256M.c | 5 +- src/device/isarom.c | 2 +- src/disk/hdc_xtide.c | 2 +- src/qt/dummy_cdrom_ioctl.c | 2 + src/qt/qt_downloader.hpp | 2 +- src/qt/qt_glsl_parser.cpp | 82 +++++---- src/qt/qt_keybind.hpp | 4 +- src/qt/qt_openglrenderer.cpp | 82 +++++---- src/qt/qt_updatedetails.cpp | 2 +- src/qt/qt_vmmanager_main.cpp | 4 +- src/qt/win_serial_passthrough.c | 6 +- src/qt/wl_mouse.cpp | 6 - src/unix/dummy_cdrom_ioctl.c | 2 + src/unix/unix.c | 121 ++++++++----- src/video/vid_jega.c | 172 ++++++++++--------- 17 files changed, 274 insertions(+), 224 deletions(-) diff --git a/src/codegen_new/codegen_backend_x86-64_ops.c b/src/codegen_new/codegen_backend_x86-64_ops.c index 1569e693c..9ac8d2474 100644 --- a/src/codegen_new/codegen_backend_x86-64_ops.c +++ b/src/codegen_new/codegen_backend_x86-64_ops.c @@ -786,7 +786,7 @@ host_x86_MOV32_REG_ABS(codeblock_t *block, int dst_reg, void *p) codegen_addquad(block, (uintptr_t) p); codegen_addbyte3(block, 0x41, 0x8b, 0x01 | ((dst_reg & 7) << 3)); /*MOV dst_reg, [R9]*/ } else { - fatal("host_x86_MOV32_REG_ABS - RAM offset = %016" PRIX64 " (p - ram = %016" PRIX64 ")\n", ram_offset, (uintptr_t) p - (uintptr_t) ram); + fatal("host_x86_MOV32_REG_ABS - RAM offset = %016" PRIX64 " (p - ram = %016" PRIXPTR ")\n", ram_offset, (uintptr_t) p - (uintptr_t) ram); codegen_alloc_bytes(block, 6); codegen_addbyte(block, 0x8b); /*MOV [p], src_reg*/ codegen_addbyte(block, 0x05 | ((dst_reg & 7) << 3)); diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index b6f5f593c..47f3e7f5c 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -381,7 +381,7 @@ typedef struct { MMX_REG MM[8]; #ifdef USE_NEW_DYNAREC -# if defined(__APPLE__) && defined(__aarch64__) +# if (defined(__APPLE__) && defined(__aarch64__)) || defined(__aarch64__) uint64_t old_fp_control; uint64_t new_fp_control; # else diff --git a/src/cpu/softfloat3e/s_shiftRightJam256M.c b/src/cpu/softfloat3e/s_shiftRightJam256M.c index 654e01234..c92204c4d 100644 --- a/src/cpu/softfloat3e/s_shiftRightJam256M.c +++ b/src/cpu/softfloat3e/s_shiftRightJam256M.c @@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =============================================================================*/ +#include #include #include "primitiveTypes.h" @@ -64,7 +65,7 @@ void softfloat_shiftRightJam256M(const uint64_t *aPtr, uint32_t dist, uint64_t * { uint64_t wordJam; uint32_t wordDist; - uint64_t *ptr; + uint64_t *ptr = NULL; uint8_t i, innerDist; wordJam = 0; @@ -89,7 +90,7 @@ void softfloat_shiftRightJam256M(const uint64_t *aPtr, uint32_t dist, uint64_t * aPtr, innerDist, zPtr + indexMultiwordLoBut(4, wordDist) - ); + ); if (! wordDist) goto wordJam; } else { aPtr += indexWordLo(4 - wordDist); diff --git a/src/device/isarom.c b/src/device/isarom.c index f742a9eae..cdf5a61c6 100644 --- a/src/device/isarom.c +++ b/src/device/isarom.c @@ -156,7 +156,7 @@ isarom_init(const device_t *info) snprintf(dev->socket[i].nvr_path, sizeof(dev->socket[i].nvr_path), "isarom_%i_%i.nvr", dev->inst, i + 1); FILE *fp = nvr_fopen(dev->socket[i].nvr_path, "rb"); if (fp != NULL) { - fread(dev->socket[i].rom.rom, 1, dev->socket[i].size, fp); + (void) !fread(dev->socket[i].rom.rom, 1, dev->socket[i].size, fp); fclose(fp); isarom_log("isarom[%u]: loaded %zu bytes from %s\n", dev->inst, read_bytes, dev->socket[i].nvr_path); } else diff --git a/src/disk/hdc_xtide.c b/src/disk/hdc_xtide.c index 1c8e2c8da..9a122f595 100644 --- a/src/disk/hdc_xtide.c +++ b/src/disk/hdc_xtide.c @@ -154,7 +154,7 @@ xtide_init(const device_t *info) sprintf(xtide->nvr_path, "xtide_%i.nvr", device_get_instance()); FILE *fp = nvr_fopen(xtide->nvr_path, "rb"); if (fp != NULL) { - fread(xtide->bios_rom.rom, 1, 0x2000, fp); + (void) !fread(xtide->bios_rom.rom, 1, 0x2000, fp); fclose(fp); } } diff --git a/src/qt/dummy_cdrom_ioctl.c b/src/qt/dummy_cdrom_ioctl.c index bddfabb5b..8dffc6758 100644 --- a/src/qt/dummy_cdrom_ioctl.c +++ b/src/qt/dummy_cdrom_ioctl.c @@ -162,6 +162,7 @@ ioctl_is_empty(const void *local) return 1; } +#if 0 static int ioctl_ext_medium_changed(UNUSED(void *local)) { @@ -174,6 +175,7 @@ ioctl_ext_medium_changed(UNUSED(void *local)) return ret; } +#endif static void ioctl_close(void *local) diff --git a/src/qt/qt_downloader.hpp b/src/qt/qt_downloader.hpp index 0bd3f1fee..2164ba59c 100644 --- a/src/qt/qt_downloader.hpp +++ b/src/qt/qt_downloader.hpp @@ -24,7 +24,7 @@ #include -class Downloader : public QObject { +class Downloader final : public QObject { Q_OBJECT public: enum class DownloadLocation { diff --git a/src/qt/qt_glsl_parser.cpp b/src/qt/qt_glsl_parser.cpp index 9efeb430b..934dd2052 100644 --- a/src/qt/qt_glsl_parser.cpp +++ b/src/qt/qt_glsl_parser.cpp @@ -69,13 +69,12 @@ static inline int wx_config_has_entry(void *config, const char *name) { return i static inline void wx_config_free(void *config) { ini_close(config); }; static int endswith(const char *str, const char *ext) { - int i; const char *p; int elen = strlen(ext); int slen = strlen(str); if (slen >= elen) { p = &str[slen - elen]; - for (i = 0; i < elen; ++i) { + for (int i = 0; i < elen; ++i) { if (tolower(p[i]) != tolower(ext[i])) return 0; } @@ -118,12 +117,18 @@ static char *load_file(const char *fn) { char *data = (char*)malloc(fsize + 1); - (void) fread(data, fsize, 1, fp); - fclose(fp); + size_t read_bytes = fread(data, fsize, 1, fp); + if (read_bytes != 1) { + fclose(fp); + free(data); + return nullptr; + } else { + fclose(fp); - data[fsize] = 0; + data[fsize] = 0; - return data; + return data; + } } static void strip_lines(const char *program, const char *starts_with) { @@ -147,17 +152,15 @@ static void strip_defines(const char *program) { } static int has_parameter(glslp_t *glsl, char *id) { - int i; - for (i = 0; i < glsl->num_parameters; ++i) + for (int i = 0; i < glsl->num_parameters; ++i) if (!strcmp(glsl->parameters[i].id, id)) return 1; return 0; } static int get_parameters(glslp_t *glsl) { - int i; struct parameter p; - for (i = 0; i < glsl->num_shaders; ++i) { + for (int i = 0; i < glsl->num_shaders; ++i) { size_t size = 0; char* line = NULL; struct shader *shader = &glsl->shaders[i]; @@ -197,8 +200,7 @@ static int get_parameters(glslp_t *glsl) { } static struct parameter *get_parameter(glslp_t *glslp, const char *id) { - int i; - for (i = 0; i < glslp->num_parameters; ++i) { + for (int i = 0; i < glslp->num_parameters; ++i) { if (!strcmp(glslp->parameters[i].id, id)) { return &glslp->parameters[i]; } @@ -207,8 +209,7 @@ static struct parameter *get_parameter(glslp_t *glslp, const char *id) { } static glslp_t *glsl_parse(const char *f) { - glslp_t *glslp = (glslp_t*)malloc(sizeof(glslp_t)); - memset(glslp, 0, sizeof(glslp_t)); + glslp_t *glslp = (glslp_t*) calloc(1, sizeof(glslp_t)); glslp->num_shaders = 1; struct shader *shader = &glslp->shaders[0]; strcpy(shader->shader_fn, f); @@ -233,7 +234,9 @@ extern "C" { void get_glslp_name(const char *f, char *s, int size) { safe_strncpy(s, path_get_filename((char *)f), size); } glslp_t *glslp_parse(const char *f) { - int i, j, len, sublen; + int j; + int len; + int sublen; char s[513], t[513], z[540]; memset(s, 0, sizeof(s)); @@ -247,8 +250,7 @@ glslp_t *glslp_parse(const char *f) { return 0; } - glslp_t *glslp = (glslp_t*)malloc(sizeof(glslp_t)); - memset(glslp, 0, sizeof(glslp_t)); + glslp_t *glslp = (glslp_t*) calloc(1, sizeof(glslp_t)); get_glslp_name(f, glslp->name, sizeof(glslp->name)); @@ -256,7 +258,7 @@ glslp_t *glslp_parse(const char *f) { wx_config_get_bool(cfg, "filter_linear0", &glslp->input_filter_linear, -1); - for (i = 0; i < glslp->num_shaders; ++i) { + for (int i = 0; i < glslp->num_shaders; ++i) { struct shader *shader = &glslp->shaders[i]; snprintf(s, sizeof(s) - 1, "shader%d", i); @@ -267,12 +269,31 @@ glslp_t *glslp_parse(const char *f) { } strcpy(s, f); *path_get_filename(s) = 0; - snprintf(shader->shader_fn, sizeof(shader->shader_fn) - 1, "%s%s", s, t); + + size_t max_len = sizeof(shader->shader_fn); + size_t s_len = strlen(s); + + if (s_len >= max_len) { + // s alone fills or overflows the buffer, truncate and null-terminate + size_t copy_len = max_len - 1 < s_len ? max_len - 1 : s_len; + memcpy(shader->shader_fn, s, copy_len); + shader->shader_fn[copy_len] = '\0'; + } else { + // Copy s fully + memcpy(shader->shader_fn, s, s_len); + // Copy as much of t as fits after s + size_t avail = max_len - 1 - s_len; // space left for t + null terminator + // Copy as much of t as fits into the remaining space + memcpy(shader->shader_fn + s_len, t, avail); + // Null-terminate + shader->shader_fn[s_len + avail] = '\0'; + } + shader->shader_program = load_file(shader->shader_fn); if (!shader->shader_program) { - fprintf(stderr, "GLSLP Error: Could not load shader %s\n", shader->shader_fn); - glslp_free(glslp); - return 0; + fprintf(stderr, "GLSLP Error: Could not load shader %s\n", shader->shader_fn); + glslp_free(glslp); + return 0; } strip_parameters(shader->shader_program); strip_defines(shader->shader_program); @@ -327,7 +348,7 @@ glslp_t *glslp_parse(const char *f) { len = strlen(t); j = 0; sublen = 0; - for (i = 0; i < len; ++i) { + for (int i = 0; i < len; ++i) { if (t[i] == ';' || i == len - 1) { sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1; safe_strncpy(s, t + j, sublen); @@ -361,7 +382,7 @@ glslp_t *glslp_parse(const char *f) { len = strlen(t); j = 0; sublen = 0; - for (i = 0; i < len; ++i) { + for (int i = 0; i < len; ++i) { if (t[i] == ';' || i == len - 1) { sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1; safe_strncpy(s, t + j, sublen); @@ -382,8 +403,7 @@ glslp_t *glslp_parse(const char *f) { } void glslp_free(glslp_t *p) { - int i; - for (i = 0; i < p->num_shaders; ++i) + for (int i = 0; i < p->num_shaders; ++i) if (p->shaders[i].shader_program) free(p->shaders[i].shader_program); free(p); @@ -391,10 +411,9 @@ void glslp_free(glslp_t *p) { void glslp_read_shader_config(glslp_t *shader) { char s[512]; - int i; char *name = shader->name; - sprintf(s, "GL3 Shaders - %s", name); - for (i = 0; i < shader->num_parameters; ++i) { + snprintf(s, sizeof(s) -1, "GL3 Shaders - %s", name); + for (int i = 0; i < shader->num_parameters; ++i) { struct parameter *param = &shader->parameters[i]; param->value = config_get_double(s, param->id, param->default_value); } @@ -402,12 +421,11 @@ void glslp_read_shader_config(glslp_t *shader) { void glslp_write_shader_config(glslp_t *shader) { char s[512]; - int i; char *name = shader->name; startblit(); - sprintf(s, "GL3 Shaders - %s", name); - for (i = 0; i < shader->num_parameters; ++i) { + snprintf(s, sizeof(s) - 1, "GL3 Shaders - %s", name); + for (int i = 0; i < shader->num_parameters; ++i) { struct parameter *param = &shader->parameters[i]; config_set_double(s, param->id, param->value); } diff --git a/src/qt/qt_keybind.hpp b/src/qt/qt_keybind.hpp index 393ee0f5c..25f4a9168 100644 --- a/src/qt/qt_keybind.hpp +++ b/src/qt/qt_keybind.hpp @@ -26,8 +26,8 @@ public: private: Ui::KeyBinder *ui; - bool eventFilter(QObject *obj, QEvent *event); - void showEvent( QShowEvent* event ); + bool eventFilter(QObject *obj, QEvent *event) override; + void showEvent( QShowEvent* event ) override; }; #endif // QT_KeyBinder_HPP diff --git a/src/qt/qt_openglrenderer.cpp b/src/qt/qt_openglrenderer.cpp index 9ca2d887e..f1fa5eecf 100644 --- a/src/qt/qt_openglrenderer.cpp +++ b/src/qt/qt_openglrenderer.cpp @@ -303,27 +303,27 @@ OpenGLRenderer::find_uniforms(struct glsl_shader *glsl, int num_pass) u->orig.texture_size = get_uniform(p, "OrigTextureSize"); for (i = 0; i < glsl->num_passes; ++i) { - sprintf(s, "Pass%dTexture", (i + 1)); + snprintf(s, sizeof(s) -1, "Pass%dTexture", (i + 1)); u->pass[i].texture = get_uniform(p, s); - sprintf(s, "Pass%dInputSize", (i + 1)); + snprintf(s, sizeof(s) -1, "Pass%dInputSize", (i + 1)); u->pass[i].input_size = get_uniform(p, s); - sprintf(s, "Pass%dTextureSize", (i + 1)); + snprintf(s, sizeof(s) -1, "Pass%dTextureSize", (i + 1)); u->pass[i].texture_size = get_uniform(p, s); - sprintf(s, "PassPrev%dTexture", num_pass - i); + snprintf(s, sizeof(s) -1, "PassPrev%dTexture", num_pass - i); u->prev_pass[i].texture = get_uniform(p, s); - sprintf(s, "PassPrev%dInputSize", num_pass - i); + snprintf(s, sizeof(s) -1, "PassPrev%dInputSize", num_pass - i); u->prev_pass[i].input_size = get_uniform(p, s); - sprintf(s, "PassPrev%dTextureSize", num_pass - i); + snprintf(s, sizeof(s) -1, "PassPrev%dTextureSize", num_pass - i); u->prev_pass[i].texture_size = get_uniform(p, s); } u->prev[0].texture = get_uniform(p, "PrevTexture"); u->prev[0].tex_coord = get_attrib(p, "PrevTexCoord"); for (i = 1; i < MAX_PREV; ++i) { - sprintf(s, "Prev%dTexture", i); + snprintf(s, sizeof(s) -1, "Prev%dTexture", i); u->prev[i].texture = get_uniform(p, s); - sprintf(s, "Prev%dTexCoord", i); + snprintf(s, sizeof(s) -1, "Prev%dTexCoord", i); u->prev[i].tex_coord = get_attrib(p, s); } for (i = 0; i < MAX_PREV; ++i) @@ -434,23 +434,21 @@ OpenGLRenderer::delete_prev(struct shader_prev *prev) void OpenGLRenderer::delete_shader(struct glsl_shader *glsl) { - int i; - for (i = 0; i < glsl->num_passes; ++i) + for (int i = 0; i < glsl->num_passes; ++i) delete_pass(&glsl->passes[i]); if (glsl->has_prev) { delete_pass(&glsl->prev_scene); - for (i = 0; i < MAX_PREV; ++i) + for (int i = 0; i < MAX_PREV; ++i) delete_prev(&glsl->prev[i]); } - for (i = 0; i < glsl->num_lut_textures; ++i) + for (int i = 0; i < glsl->num_lut_textures; ++i) delete_texture(&glsl->lut_textures[i].texture); } void OpenGLRenderer::delete_glsl(glsl_t *glsl) { - int i; - for (i = 0; i < glsl->num_shaders; ++i) + for (int i = 0; i < glsl->num_shaders; ++i) delete_shader(&glsl->shaders[i]); delete_pass(&glsl->scene); delete_pass(&glsl->fs_color); @@ -622,7 +620,6 @@ load_texture(const char *f, struct shader_texture *tex) glsl_t * OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f) { - int i, j; glslp_t *p = glslp_parse(f); if (p) { @@ -639,10 +636,10 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f) gshader->num_lut_textures = p->num_textures; - for (i = 0; i < p->num_textures; ++i) { + for (int i = 0; i < p->num_textures; ++i) { struct texture *texture = &p->textures[i]; - sprintf(file, "%s%s", path, texture->path); + snprintf(file, sizeof(file) - 1, "%s%s", path, texture->path); struct shader_lut_texture *tex = &gshader->lut_textures[i]; strcpy(tex->name, texture->name); @@ -681,18 +678,18 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f) gshader->input_filter_linear = p->input_filter_linear; gshader->num_parameters = p->num_parameters; - for (j = 0; j < gshader->num_parameters; ++j) + for (int j = 0; j < gshader->num_parameters; ++j) memcpy(&gshader->parameters[j], &p->parameters[j], sizeof(struct shader_parameter)); gshader->num_passes = p->num_shaders; - for (i = 0; i < p->num_shaders; ++i) { + for (int i = 0; i < p->num_shaders; ++i) { struct shader *shader = &p->shaders[i]; struct shader_pass *pass = &gshader->passes[i]; strcpy(pass->alias, shader->alias); if (!strlen(pass->alias)) - sprintf(pass->alias, "Pass %u", (i + 1)); + snprintf(pass->alias, sizeof(pass->alias) - 1, "Pass %u", (i + 1)); ogl3_log("Creating pass %u (%s)\n", (i + 1), pass->alias); ogl3_log("Loading shader %s...\n", shader->shader_fn); @@ -726,7 +723,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f) if (num_shader == glsl->num_shaders - 1) { pass->fbo.id = -1; - for (j = 0; j < 2; ++j) { + for (uint8_t j = 0; j < 2; ++j) { if (pass->scale.mode[j] != SCALE_SOURCE || pass->scale.value[j] != 1) { setup_fbo(shader, &pass->fbo); break; @@ -755,7 +752,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f) if (gshader->has_prev) { struct shader scene_shader_conf; memset(&scene_shader_conf, 0, sizeof(struct shader)); - for (i = 0; i < MAX_PREV; ++i) { + for (int i = 0; i < MAX_PREV; ++i) { setup_fbo(&scene_shader_conf, &gshader->prev[i].fbo); } } @@ -772,7 +769,6 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f) glsl_t * OpenGLRenderer::load_shaders(int num, char shaders[MAX_USER_SHADERS][512]) { - int i; glsl_t *glsl; glsl = (glsl_t *) malloc(sizeof(glsl_t)); @@ -780,7 +776,7 @@ OpenGLRenderer::load_shaders(int num, char shaders[MAX_USER_SHADERS][512]) glsl->num_shaders = num; int failed = 0; - for (i = num - 1; i >= 0; --i) { + for (int i = num - 1; i >= 0; --i) { const char *f = shaders[i]; if (f && strlen(f)) { if (!load_glslp(glsl, i, f)) { @@ -800,13 +796,12 @@ void OpenGLRenderer::read_shader_config() { char s[512]; - int i, j; - for (i = 0; i < active_shader->num_shaders; ++i) { + for (int i = 0; i < active_shader->num_shaders; ++i) { struct glsl_shader *shader = &active_shader->shaders[i]; char *name = shader->name; - sprintf(s, "GL3 Shaders - %s", name); + snprintf(s, sizeof(s) -1, "GL3 Shaders - %s", name); // shader->shader_refresh_rate = config_get_float(CFG_MACHINE, s, "shader_refresh_rate", -1); - for (j = 0; j < shader->num_parameters; ++j) { + for (int j = 0; j < shader->num_parameters; ++j) { struct shader_parameter *param = &shader->parameters[j]; param->value = config_get_double(s, param->id, param->default_value); } @@ -1233,7 +1228,6 @@ OpenGLRenderer::resizeEvent(QResizeEvent *event) void OpenGLRenderer::render_pass(struct render_data *data) { - int i; GLuint texture_unit = 0; // ogl3_log("pass %d: %gx%g, %gx%g -> %gx%g, %gx%g, %gx%g\n", num_pass, pass->state.input_size[0], @@ -1278,7 +1272,7 @@ OpenGLRenderer::render_pass(struct render_data *data) if (data->shader) { /* parameters */ - for (i = 0; i < data->shader->num_parameters; ++i) + for (int i = 0; i < data->shader->num_parameters; ++i) if (u->parameters[i] >= 0) glw.glUniform1f(u->parameters[i], data->shader->parameters[i].value); @@ -1296,7 +1290,7 @@ OpenGLRenderer::render_pass(struct render_data *data) if (u->orig.texture_size >= 0) glw.glUniform2fv(u->orig.texture_size, 1, orig->state.input_texture_size); - for (i = 0; i < data->pass; ++i) { + for (int i = 0; i < data->pass; ++i) { if (u->pass[i].texture >= 0) { glw.glActiveTexture(GL_TEXTURE0 + texture_unit); glw.glBindTexture(GL_TEXTURE_2D, passes[i].fbo.texture.id); @@ -1323,7 +1317,7 @@ OpenGLRenderer::render_pass(struct render_data *data) if (data->shader->has_prev) { /* loop through each previous frame */ - for (i = 0; i < MAX_PREV; ++i) { + for (int i = 0; i < MAX_PREV; ++i) { if (u->prev[i].texture >= 0) { glw.glActiveTexture(GL_TEXTURE0 + texture_unit); glw.glBindTexture(GL_TEXTURE_2D, data->shader->prev[i].fbo.texture.id); @@ -1340,7 +1334,7 @@ OpenGLRenderer::render_pass(struct render_data *data) } } - for (i = 0; i < data->shader->num_lut_textures; ++i) { + for (int i = 0; i < data->shader->num_lut_textures; ++i) { if (u->lut_textures[i] >= 0) { glw.glActiveTexture(GL_TEXTURE0 + texture_unit); glw.glBindTexture(GL_TEXTURE_2D, data->shader->lut_textures[i].texture.id); @@ -1364,7 +1358,7 @@ OpenGLRenderer::render_pass(struct render_data *data) glw.glDisableVertexAttribArray(data->shader_pass->uniforms.color); if (data->shader && data->shader->has_prev) { - for (i = 0; i < MAX_PREV; ++i) { + for (int i = 0; i < MAX_PREV; ++i) { if (u->prev[i].tex_coord >= 0) glw.glDisableVertexAttribArray(u->prev[i].tex_coord); } @@ -1401,10 +1395,11 @@ OpenGLRenderer::render() if (notReady()) return; - int s, i, j; - struct { - uint32_t x, y, w, h; + uint32_t x; + uint32_t y; + uint32_t w; + uint32_t h; } window_rect; window_rect.x = destination.x(); @@ -1434,7 +1429,10 @@ OpenGLRenderer::render() struct shader_pass *pass = &active_shader->scene; struct { - uint32_t x, y, w, h; + uint32_t x; + uint32_t y; + uint32_t w; + uint32_t h; } rect; rect.x = 0; rect.y = 0; @@ -1496,20 +1494,20 @@ OpenGLRenderer::render() struct shader_pass *orig = &active_shader->scene; struct shader_pass *input = &active_shader->scene; - for (s = 0; s < active_shader->num_shaders; ++s) { + for (int s = 0; s < active_shader->num_shaders; ++s) { struct glsl_shader *shader = &active_shader->shaders[s]; int frame_count = frameCounter; /* loop through each pass */ - for (i = 0; i < shader->num_passes; ++i) { + for (int i = 0; i < shader->num_passes; ++i) { bool resetFiltering = false; struct shader_pass *pass = &shader->passes[i]; memcpy(pass->state.input_size, input->state.output_size, 2 * sizeof(GLfloat)); memcpy(pass->state.input_texture_size, input->state.output_texture_size, 2 * sizeof(GLfloat)); - for (j = 0; j < 2; ++j) { + for (uint8_t j = 0; j < 2; ++j) { if (pass->scale.mode[j] == SCALE_VIEWPORT) pass->state.output_size[j] = orig_output_size[j] * pass->scale.value[j]; else if (pass->scale.mode[j] == SCALE_ABSOLUTE) @@ -1640,7 +1638,7 @@ OpenGLRenderer::render() memcpy(pass->state.input_size, input->state.output_size, 2 * sizeof(GLfloat)); memcpy(pass->state.input_texture_size, input->state.output_texture_size, 2 * sizeof(GLfloat)); - for (j = 0; j < 2; ++j) { + for (uint8_t j = 0; j < 2; ++j) { if (pass->scale.mode[j] == SCALE_VIEWPORT) pass->state.output_size[j] = orig_output_size[j] * pass->scale.value[j]; else if (pass->scale.mode[j] == SCALE_ABSOLUTE) diff --git a/src/qt/qt_updatedetails.cpp b/src/qt/qt_updatedetails.cpp index 1328da732..1d6846dd6 100644 --- a/src/qt/qt_updatedetails.cpp +++ b/src/qt/qt_updatedetails.cpp @@ -46,7 +46,7 @@ UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) : const auto downloadButton = new QPushButton(tr("Visit download page")); ui->buttonBox->addButton(downloadButton, QDialogButtonBox::AcceptRole); // Override accepted to mean "I want to visit the download page" - connect(ui->buttonBox, &QDialogButtonBox::accepted, [this, updateResult] { + connect(ui->buttonBox, &QDialogButtonBox::accepted, [updateResult] { visitDownloadPage(updateResult.channel); }); const auto logo = QPixmap(":/assets/86box.png").scaled(QSize(64, 64), Qt::KeepAspectRatio, Qt::SmoothTransformation); diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 8c83b549f..88b9456cc 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -62,7 +62,7 @@ VMManagerMain::VMManagerMain(QWidget *parent) : QAction openSystemFolderAction(tr("Open folder")); contextMenu.addAction(&openSystemFolderAction); - connect(&openSystemFolderAction, &QAction::triggered, [this, indexAt] { + connect(&openSystemFolderAction, &QAction::triggered, [indexAt] { if (const auto configDir = indexAt.data(VMManagerModel::Roles::ConfigDir).toString(); !configDir.isEmpty()) { QDir dir(configDir); if (!dir.exists()) @@ -78,7 +78,7 @@ VMManagerMain::VMManagerMain(QWidget *parent) : QAction setSystemIcon(tr("Set icon")); contextMenu.addAction(&setSystemIcon); - connect(&setSystemIcon, &QAction::triggered, [this, indexAt] { + connect(&setSystemIcon, &QAction::triggered, [this] { IconSelectionDialog dialog(":/systemicons/"); if(dialog.exec() == QDialog::Accepted) { const QString iconName = dialog.getSelectedIconName(); diff --git a/src/qt/win_serial_passthrough.c b/src/qt/win_serial_passthrough.c index 725dc096f..4ea6a1875 100644 --- a/src/qt/win_serial_passthrough.c +++ b/src/qt/win_serial_passthrough.c @@ -193,7 +193,11 @@ static int connect_named_pipe_client(serial_passthrough_t *dev) { char ascii_pipe_name[1024] = { 0 }; - strncpy(ascii_pipe_name, dev->named_pipe, sizeof(ascii_pipe_name) - 1); + size_t len = strlen(dev->named_pipe); + if ((len + 1) >= sizeof(ascii_pipe_name)) + memcpy(ascii_pipe_name, dev->named_pipe, sizeof(ascii_pipe_name)); + else + memcpy(ascii_pipe_name, dev->named_pipe, len + 1); HANDLE hPipe = CreateFileA( ascii_pipe_name, // pipe name diff --git a/src/qt/wl_mouse.cpp b/src/qt/wl_mouse.cpp index 9201c4ec8..6f90bac18 100644 --- a/src/qt/wl_mouse.cpp +++ b/src/qt/wl_mouse.cpp @@ -50,12 +50,6 @@ static struct zwp_relative_pointer_v1_listener rel_listener = { rel_mouse_event }; -static struct zwp_keyboard_shortcuts_inhibitor_v1_listener kbd_listener -{ - [](void *data, struct zwp_keyboard_shortcuts_inhibitor_v1 *zwp_keyboard_shortcuts_inhibitor_v1) -> void {}, - [](void *data, struct zwp_keyboard_shortcuts_inhibitor_v1 *zwp_keyboard_shortcuts_inhibitor_v1) -> void {} -}; - static void display_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) diff --git a/src/unix/dummy_cdrom_ioctl.c b/src/unix/dummy_cdrom_ioctl.c index bddfabb5b..8dffc6758 100644 --- a/src/unix/dummy_cdrom_ioctl.c +++ b/src/unix/dummy_cdrom_ioctl.c @@ -162,6 +162,7 @@ ioctl_is_empty(const void *local) return 1; } +#if 0 static int ioctl_ext_medium_changed(UNUSED(void *local)) { @@ -174,6 +175,7 @@ ioctl_ext_medium_changed(UNUSED(void *local)) return ret; } +#endif static void ioctl_close(void *local) diff --git a/src/unix/unix.c b/src/unix/unix.c index 2e92a90d3..2bbbda067 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -208,22 +208,33 @@ dynld_module(const char *name, dllimp_t *table) return modhandle; } +#define TMPFILE_BUFSIZE 1024 // Assumed max buffer size void plat_tempfile(char *bufp, char *prefix, char *suffix) { struct tm *calendertime; struct timeval t; time_t curtime; + size_t used = 0; if (prefix != NULL) - sprintf(bufp, "%s-", prefix); - else - strcpy(bufp, ""); + used = snprintf(bufp, TMPFILE_BUFSIZE, "%s-", prefix); + else if (TMPFILE_BUFSIZE > 0) + bufp[0] = '\0'; + gettimeofday(&t, NULL); curtime = time(NULL); calendertime = localtime(&curtime); - sprintf(&bufp[strlen(bufp)], "%d%02d%02d-%02d%02d%02d-%03ld%s", calendertime->tm_year, calendertime->tm_mon, calendertime->tm_mday, calendertime->tm_hour, calendertime->tm_min, calendertime->tm_sec, t.tv_usec / 1000, suffix); + + if (used < TMPFILE_BUFSIZE) { + snprintf(bufp + used, TMPFILE_BUFSIZE - used, + "%d%02d%02d-%02d%02d%02d-%03" PRId32 "%s", + calendertime->tm_year, calendertime->tm_mon, calendertime->tm_mday, + calendertime->tm_hour, calendertime->tm_min, calendertime->tm_sec, + (int32_t)(t.tv_usec / 1000), suffix); + } } +#undef TMPFILE_BUFSIZE int plat_getcwd(char *bufp, int max) @@ -783,65 +794,83 @@ plat_pause(int p) } } +#define TMP_PATH_BUFSIZE 1024 void plat_init_rom_paths(void) { #ifndef __APPLE__ - if (getenv("XDG_DATA_HOME")) { - char xdg_rom_path[1024] = { 0 }; - - strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024); - path_slash(xdg_rom_path); - strncat(xdg_rom_path, "86Box/", 1023); - - if (!plat_dir_check(xdg_rom_path)) + const char *xdg_data_home = getenv("XDG_DATA_HOME"); + if (xdg_data_home) { + char xdg_rom_path[TMP_PATH_BUFSIZE] = {0}; + size_t used = snprintf(xdg_rom_path, sizeof(xdg_rom_path), "%s/", xdg_data_home); + if (used < sizeof(xdg_rom_path)) + used += snprintf(xdg_rom_path + used, sizeof(xdg_rom_path) - used, "86Box/"); + if (used < sizeof(xdg_rom_path) && !plat_dir_check(xdg_rom_path)) plat_dir_create(xdg_rom_path); - strcat(xdg_rom_path, "roms/"); - - if (!plat_dir_check(xdg_rom_path)) + if (used < sizeof(xdg_rom_path)) + used += snprintf(xdg_rom_path + used, sizeof(xdg_rom_path) - used, "roms/"); + if (used < sizeof(xdg_rom_path) && !plat_dir_check(xdg_rom_path)) plat_dir_create(xdg_rom_path); - rom_add_path(xdg_rom_path); + if (used < sizeof(xdg_rom_path)) + rom_add_path(xdg_rom_path); } else { - char home_rom_path[1024] = { 0 }; - - snprintf(home_rom_path, 1024, "%s/.local/share/86Box/", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir); - - if (!plat_dir_check(home_rom_path)) - plat_dir_create(home_rom_path); - strcat(home_rom_path, "roms/"); - - if (!plat_dir_check(home_rom_path)) - plat_dir_create(home_rom_path); - rom_add_path(home_rom_path); - } - if (getenv("XDG_DATA_DIRS")) { - char *xdg_rom_paths = strdup(getenv("XDG_DATA_DIRS")); - char *xdg_rom_paths_orig = xdg_rom_paths; - char *cur_xdg_rom_path = NULL; - - if (xdg_rom_paths) { - while (xdg_rom_paths[strlen(xdg_rom_paths) - 1] == ':') { - xdg_rom_paths[strlen(xdg_rom_paths) - 1] = '\0'; - } - while ((cur_xdg_rom_path = local_strsep(&xdg_rom_paths, ":")) != NULL) { - char real_xdg_rom_path[1024] = { '\0' }; - strcat(real_xdg_rom_path, cur_xdg_rom_path); - path_slash(real_xdg_rom_path); - strcat(real_xdg_rom_path, "86Box/roms/"); - rom_add_path(real_xdg_rom_path); - } + const char *home = getenv("HOME"); + if (!home) { + struct passwd *pw = getpwuid(getuid()); + if (pw) + home = pw->pw_dir; + } + + if (home) { + char home_rom_path[TMP_PATH_BUFSIZE] = {0}; + size_t used = snprintf(home_rom_path, sizeof(home_rom_path), + "%s/.local/share/86Box/", home); + if (used < sizeof(home_rom_path) && !plat_dir_check(home_rom_path)) + plat_dir_create(home_rom_path); + if (used < sizeof(home_rom_path)) + used += snprintf(home_rom_path + used, + sizeof(home_rom_path) - used, "roms/"); + if (used < sizeof(home_rom_path) && !plat_dir_check(home_rom_path)) + plat_dir_create(home_rom_path); + if (used < sizeof(home_rom_path)) + rom_add_path(home_rom_path); + } + } + + const char *xdg_data_dirs = getenv("XDG_DATA_DIRS"); + if (xdg_data_dirs) { + char *xdg_rom_paths = strdup(xdg_data_dirs); + if (xdg_rom_paths) { + // Trim trailing colons + size_t len = strlen(xdg_rom_paths); + while (len > 0 && xdg_rom_paths[len - 1] == ':') + xdg_rom_paths[--len] = '\0'; + + char *saveptr = NULL; + char *cur_xdg = strtok_r(xdg_rom_paths, ":", &saveptr); + while (cur_xdg) { + char real_xdg_rom_path[TMP_PATH_BUFSIZE] = {0}; + size_t used = snprintf(real_xdg_rom_path, + sizeof(real_xdg_rom_path), + "%s/86Box/roms/", cur_xdg); + if (used < sizeof(real_xdg_rom_path)) + rom_add_path(real_xdg_rom_path); + cur_xdg = strtok_r(NULL, ":", &saveptr); + } + + free(xdg_rom_paths); } - free(xdg_rom_paths_orig); } else { rom_add_path("/usr/local/share/86Box/roms/"); rom_add_path("/usr/share/86Box/roms/"); } #else - char default_rom_path[1024] = { '\0' }; + char default_rom_path[TMP_PATH_BUFSIZE] = {0}; getDefaultROMPath(default_rom_path); rom_add_path(default_rom_path); #endif } +#undef TMP_PATH_BUFSIZE void plat_get_global_config_dir(char *outbuf, const uint8_t len) diff --git a/src/video/vid_jega.c b/src/video/vid_jega.c index f49c92e64..eafdceb9c 100644 --- a/src/video/vid_jega.c +++ b/src/video/vid_jega.c @@ -123,7 +123,7 @@ typedef struct jega_t { int start_scan_lower; int start_scan_upper; int start_scan_count; - uint8_t * vram; + uint8_t *vram; uint8_t jfont_sbcs_19[SBCS19_FILESIZE]; /* 8 x 19 font */ uint8_t jfont_dbcs_16[DBCS16_FILESIZE]; /* 16 x 16 font. Use dbcs_read/write to access it. */ } jega_t; @@ -134,30 +134,30 @@ static void jega_recalctimings(void *priv); #define FONTX_LEN_FN 8 typedef struct { - char id[FONTX_LEN_ID]; - char name[FONTX_LEN_FN]; - uint8_t width; - uint8_t height; - uint8_t type; + char id[FONTX_LEN_ID]; + char name[FONTX_LEN_FN]; + uint8_t width; + uint8_t height; + uint8_t type; } fontx_h; typedef struct { - uint16_t start; - uint16_t end; + uint16_t start; + uint16_t end; } fontx_tbl; -extern uint32_t pallook16[256]; -extern uint32_t pallook64[256]; -static bool is_SJIS_1(uint8_t chr) { return (chr >= 0x81 && chr <= 0x9f) || (chr >= 0xe0 && chr <= 0xfc); } -static bool is_SJIS_2(uint8_t chr) { return (chr >= 0x40 && chr <= 0x7e) || (chr >= 0x80 && chr <= 0xfc); } +extern uint32_t pallook16[256]; +extern uint32_t pallook64[256]; +static bool is_SJIS_1(uint8_t chr) { return (chr >= 0x81 && chr <= 0x9f) || (chr >= 0xe0 && chr <= 0xfc); } +static bool is_SJIS_2(uint8_t chr) { return (chr >= 0x40 && chr <= 0x7e) || (chr >= 0x80 && chr <= 0xfc); } -static uint8_t jega_in(uint16_t addr, void *priv); +static uint8_t jega_in(uint16_t addr, void *priv); static uint16_t SJIS_to_SEQ(uint16_t sjis) { uint32_t chr1 = (sjis >> 8) & 0xff; - uint32_t chr2 = sjis & 0xff; + uint32_t chr2 = sjis & 0xff; if (!is_SJIS_1(chr1) || !is_SJIS_2(chr2)) return INVALIDACCESS16; @@ -179,8 +179,8 @@ SJIS_to_SEQ(uint16_t sjis) static uint8_t dbcs_read(uint16_t sjis, int index, void *priv) { - jega_t *jega = (jega_t *) priv; - int seq = SJIS_to_SEQ(sjis); + jega_t *jega = (jega_t *) priv; + int seq = SJIS_to_SEQ(sjis); if ((seq >= DBCS16_CHARS) || (index >= 32)) return INVALIDACCESS8; return jega->jfont_dbcs_16[seq * 32 + index]; @@ -188,8 +188,8 @@ dbcs_read(uint16_t sjis, int index, void *priv) { static void dbcs_write(uint16_t sjis, int index, uint8_t val, void *priv) { - jega_t *jega = (jega_t *) priv; - int seq = SJIS_to_SEQ(sjis); + jega_t *jega = (jega_t *) priv; + int seq = SJIS_to_SEQ(sjis); if ((seq >= DBCS16_CHARS) || (index >= 32)) return; jega->jfont_dbcs_16[seq * 32 + index] = val; @@ -199,38 +199,38 @@ dbcs_write(uint16_t sjis, int index, uint8_t val, void *priv) { void jega_render_text(void *priv) { - jega_t * jega = (jega_t *) priv; + jega_t *jega = (jega_t *) priv; #ifdef USE_DOUBLE_WIDTH_AND_LINE_CHARS - uint8_t * seqregs = jega->is_vga ? jega->vga.svga.seqregs : + uint8_t *seqregs = jega->is_vga ? jega->vga.svga.seqregs : jega->ega.seqregs; - uint8_t * attrregs = jega->is_vga ? jega->vga.svga.attrregs : + uint8_t *attrregs = jega->is_vga ? jega->vga.svga.attrregs : jega->ega.attrregs; #endif - uint8_t * crtc = jega->is_vga ? jega->vga.svga.crtc : + uint8_t *crtc = jega->is_vga ? jega->vga.svga.crtc : jega->ega.crtc; - uint8_t * vram = jega->is_vga ? jega->vga.svga.vram : + uint8_t *vram = jega->is_vga ? jega->vga.svga.vram : jega->ega.vram; - int * firstline_draw = jega->is_vga ? &jega->vga.svga.firstline_draw : + int *firstline_draw = jega->is_vga ? &jega->vga.svga.firstline_draw : &jega->ega.firstline_draw; - int * lastline_draw = jega->is_vga ? &jega->vga.svga.lastline_draw : + int *lastline_draw = jega->is_vga ? &jega->vga.svga.lastline_draw : &jega->ega.lastline_draw; - int * displine = jega->is_vga ? &jega->vga.svga.displine : + int *displine = jega->is_vga ? &jega->vga.svga.displine : &jega->ega.displine; - int * fullchange = jega->is_vga ? &jega->vga.svga.fullchange : + int *fullchange = jega->is_vga ? &jega->vga.svga.fullchange : &jega->ega.fullchange; - int * blink = jega->is_vga ? &jega->vga.svga.blink : + int *blink = jega->is_vga ? &jega->vga.svga.blink : &jega->ega.blink; - int * x_add = jega->is_vga ? &jega->vga.svga.x_add : + int *x_add = jega->is_vga ? &jega->vga.svga.x_add : &jega->ega.x_add; - int * y_add = jega->is_vga ? &jega->vga.svga.y_add : + int *y_add = jega->is_vga ? &jega->vga.svga.y_add : &jega->ega.y_add; - int * sc = jega->is_vga ? &jega->vga.svga.scanline : + int *sc = jega->is_vga ? &jega->vga.svga.scanline : &jega->ega.scanline; - int * hdisp = jega->is_vga ? &jega->vga.svga.hdisp : + int *hdisp = jega->is_vga ? &jega->vga.svga.hdisp : &jega->ega.hdisp; - int * scrollcache = jega->is_vga ? &jega->vga.svga.scrollcache : + int *scrollcache = jega->is_vga ? &jega->vga.svga.scrollcache : &jega->ega.scrollcache; - uint32_t *memaddr = jega->is_vga ? &jega->vga.svga.memaddr : + uint32_t *memaddr = jega->is_vga ? &jega->vga.svga.memaddr : &jega->ega.memaddr; uint8_t mask = jega->is_vga ? jega->vga.svga.dac_mask : 0xff; @@ -255,7 +255,7 @@ jega_render_text(void *priv) uint32_t attr_basic = 0; uint32_t chr_first; int fg = 0; - int bg; + int bg = 0; for (int x = 0; x < (*hdisp + *scrollcache); x += charwidth) { uint32_t addr = 0; @@ -391,9 +391,9 @@ jega_render_text(void *priv) for (int xx = 0; xx < charwidth; xx++) p[xx] = (dat & (0x80 >> xx)) ? fg : bg; - if (attr_basic & 0x20) { /* vertical line */ + if (attr_basic & 0x20) /* vertical line */ p[0] = fg; - } + if ((*sc == jega->regs[RPULP]) && (attr_basic & 0x10)) { /* underline */ for (int xx = 0; xx < charwidth; xx++) p[xx] = fg; @@ -655,11 +655,11 @@ jega_in(uint16_t addr, void *priv) static int getfontx2header(FILE *fp, fontx_h *header) { - fread(header->id, FONTX_LEN_ID, 1, fp); - if (strncmp(header->id, "FONTX2", FONTX_LEN_ID) != 0) { + (void) !fread(header->id, FONTX_LEN_ID, 1, fp); + if (strncmp(header->id, "FONTX2", FONTX_LEN_ID) != 0) return 1; - } - fread(header->name, FONTX_LEN_FN, 1, fp); + + (void) !fread(header->name, FONTX_LEN_FN, 1, fp); header->width = (uint8_t) getc(fp); header->height = (uint8_t) getc(fp); header->type = (uint8_t) getc(fp); @@ -669,9 +669,8 @@ getfontx2header(FILE *fp, fontx_h *header) static uint16_t chrtosht(FILE *fp) { - uint16_t i, j; - i = (uint16_t) getc(fp); - j = (uint16_t) getc(fp) << 8; + uint16_t i = (uint16_t) getc(fp); + uint16_t j = (uint16_t) getc(fp) << 8; return (i | j); } @@ -695,7 +694,6 @@ LoadFontxFile(const char *fn, void *priv) uint16_t scode; uint8_t size; uint8_t buf; - int line; jega_t *jega = (jega_t *) priv; FILE *fp = rom_fopen(fn, "rb"); jega_log("JEGA: Loading font\n"); @@ -718,10 +716,10 @@ LoadFontxFile(const char *fn, void *priv) for (code = ftbl[i].start; code <= ftbl[i].end; code++) { scode = SJIS_to_SEQ(code); if (scode != INVALIDACCESS16) { - for (line = 0; line < 16; line++) { - fread(&buf, sizeof(uint8_t), 1, fp); + for (uint8_t line = 0; line < 16; line++) { + (void) !fread(&buf, sizeof(uint8_t), 1, fp); jega->jfont_dbcs_16[(int) (scode * 32) + line] = buf; - fread(&buf, sizeof(uint8_t), 1, fp); + (void) !fread(&buf, sizeof(uint8_t), 1, fp); jega->jfont_dbcs_16[(int) (scode * 32) + line + 16] = buf; } } else { @@ -735,9 +733,9 @@ LoadFontxFile(const char *fn, void *priv) return 1; } } else { - if (fhead.width == 8 && fhead.height == 19) { - fread(jega->jfont_sbcs_19, sizeof(uint8_t), SBCS19_FILESIZE, fp); - } else { + if (fhead.width == 8 && fhead.height == 19) + (void) !fread(jega->jfont_sbcs_19, sizeof(uint8_t), SBCS19_FILESIZE, fp); + else { fclose(fp); jega_log("JEGA: Width or height of SBCS font doesn't match.\n"); return 1; @@ -768,7 +766,7 @@ jega_commoninit(const device_t *info, void *priv, int vga) jega->pallook = jega->vga.svga.pallook; io_sethandler(0x03c0, 0x0020, jega_in, NULL, NULL, jega_out, NULL, NULL, jega); } else { - for (int c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { pallook64[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); pallook64[c] += makecol32(((c >> 5) & 1) * 0x55, ((c >> 4) & 1) * 0x55, ((c >> 3) & 1) * 0x55); } @@ -821,40 +819,44 @@ jega_close(void *priv) { jega_t *jega = (jega_t *) priv; #ifdef ENABLE_JEGA_LOG - FILE *f; - // f = fopen("jega_font16.dmp", "wb"); - // if (f != NULL) { - // fwrite(jega->jfont_dbcs_16, DBCS16_FILESIZE, 1, f); - // fclose(f); - // } - // f = fopen("jega_font19.dmp", "wb"); - // if (f != NULL) { - // fwrite(jega->jfont_sbcs_19, SBCS19_FILESIZE, 1, f); - // fclose(f); - // } - f = fopen("jega_regs.txt", "wb"); - if (f != NULL) { - for (int i = 0; i < 49; i++) - fprintf(f, "Regs %02X: %4X\n", i, jega->regs[i]); - for (int i = 0; i < 32; i++) - fprintf(f, "Attr %02X: %4X\n", i, jega->attrregs[i]); - for (int i = 0; i < 16; i++) - fprintf(f, "JEGAPal %02X: %4X\n", i, jega->egapal[i]); - for (int i = 0; i < 16; i++) - fprintf(f, "EGAPal %02X: %4X\n", i, jega->ega.egapal[i]); - for (int i = 0; i < 64; i++) - fprintf(f, "RealPal %02X: %4X\n", i, jega->pallook[i]); + FILE *fp; +#if 0 + fp = fopen("jega_font16.dmp", "wb"); + if (fp != NULL) { + fwrite(jega->jfont_dbcs_16, DBCS16_FILESIZE, 1, fp); fclose(f); } - // f = fopen("ega_vram.dmp", "wb"); - // if (f != NULL) { - // fwrite(jega->ega.vram, 256 * 1024, 1, f); - // fclose(f); - // } - f = fopen("ram_bda.dmp", "wb"); + fp = fopen("jega_font19.dmp", "wb"); + if (fp != NULL) { + fwrite(jega->jfont_sbcs_19, SBCS19_FILESIZE, 1, fp); + fclose(fp); + } +#endif + f = fopen("jega_regs.txt", "wb"); if (f != NULL) { - fwrite(&ram[0x0], 0x500, 1, f); - fclose(f); + for (uint8_t i = 0; i < 49; i++) + fprintf(fp, "Regs %02X: %4X\n", i, jega->regs[i]); + for (uint8_t i = 0; i < 32; i++) + fprintf(fp, "Attr %02X: %4X\n", i, jega->attrregs[i]); + for (uint8_t i = 0; i < 16; i++) + fprintf(fp, "JEGAPal %02X: %4X\n", i, jega->egapal[i]); + for (uint8_t i = 0; i < 16; i++) + fprintf(fp, "EGAPal %02X: %4X\n", i, jega->ega.egapal[i]); + for (uint8_t i = 0; i < 64; i++) + fprintf(fp, "RealPal %02X: %4X\n", i, jega->pallook[i]); + fclose(fp); + } +#if 0 + fp = fopen("ega_vram.dmp", "wb"); + if (fp != NULL) { + fwrite(jega->ega.vram, 256 * 1024, 1, fp); + fclose(fp); + } +#endif + fp = fopen("ram_bda.dmp", "wb"); + if (fp != NULL) { + fwrite(&ram[0x0], 0x500, 1, fp); + fclose(fp); } pclog("jeclosed %04X:%04X DS %04X\n", cs >> 4, cpu_state.pc, DS); #endif @@ -974,7 +976,7 @@ if386_p6x_write(uint16_t port, uint8_t val, void *priv) p65[p65idx] = val; if (p65idx == 0x03) { if (val & 0x04) { /* Color monitor */ - for (int c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { pallook64[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); pallook64[c] += makecol32(((c >> 5) & 1) * 0x55, ((c >> 4) & 1) * 0x55, ((c >> 3) & 1) * 0x55); pallook16[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); @@ -983,7 +985,7 @@ if386_p6x_write(uint16_t port, uint8_t val, void *priv) pallook16[c] = makecol32(0xaa, 0x55, 0); } } else { /* Monochrome LCD */ - for (int c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { int cval = 0; #ifdef SIMPLE_BW if (c & 0x0f) From cb5cb7e660093d0f3b8977160b4d9bc5a64d4d3e Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 28 Jun 2025 19:46:13 -0400 Subject: [PATCH 063/103] Do less work on Github Actions We don't need it running CodeQL on every push to every branch --- .github/workflows/codeql_linux.yml | 5 +++++ .github/workflows/codeql_macos.yml | 5 +++++ .github/workflows/codeql_windows_msys2.yml | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/.github/workflows/codeql_linux.yml b/.github/workflows/codeql_linux.yml index fc0397703..2b542b186 100644 --- a/.github/workflows/codeql_linux.yml +++ b/.github/workflows/codeql_linux.yml @@ -3,6 +3,7 @@ name: CodeQL Analysis (Linux) on: push: + branches: [ "master" ] paths: - src/** - cmake/** @@ -13,6 +14,7 @@ on: - "!**/Makefile*" pull_request: + branches: [ "master" ] paths: - src/** - cmake/** @@ -23,6 +25,9 @@ on: - vcpkg.json - "!**/Makefile*" + schedule: + - cron: '22 11 * * 0' + jobs: analyze-linux: diff --git a/.github/workflows/codeql_macos.yml b/.github/workflows/codeql_macos.yml index 841ca98f5..eeab0ecc8 100644 --- a/.github/workflows/codeql_macos.yml +++ b/.github/workflows/codeql_macos.yml @@ -3,6 +3,7 @@ name: CodeQL Analysis (macos) on: push: + branches: [ "master" ] paths: - src/** - cmake/** @@ -13,6 +14,7 @@ on: - "!**/Makefile*" pull_request: + branches: [ "master" ] paths: - src/** - cmake/** @@ -23,6 +25,9 @@ on: - vcpkg.json - "!**/Makefile*" + schedule: + - cron: '22 11 * * 0' + jobs: analyze-macos13-x86_64: diff --git a/.github/workflows/codeql_windows_msys2.yml b/.github/workflows/codeql_windows_msys2.yml index 7a0055910..f513831e8 100644 --- a/.github/workflows/codeql_windows_msys2.yml +++ b/.github/workflows/codeql_windows_msys2.yml @@ -3,6 +3,7 @@ name: CodeQL Analysis (Windows, msys2) on: push: + branches: [ "master" ] paths: - src/** - cmake/** @@ -13,6 +14,7 @@ on: - "!**/Makefile*" pull_request: + branches: [ "master" ] paths: - src/** - cmake/** @@ -23,6 +25,9 @@ on: - vcpkg.json - "!**/Makefile*" + schedule: + - cron: '22 11 * * 0' + jobs: analyze-msys2: From 026f76549565344c78e6d0aa5f6c777b6f93f358 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 28 Jun 2025 23:02:10 -0400 Subject: [PATCH 064/103] Some codeql fixes --- src/86box.c | 22 +++++++++++-- src/cdrom/cdrom_image_viso.c | 63 +++++++++++++++++++++++------------- src/cpu/386_ops.h | 12 ++++++- src/nvr.c | 23 ++++++++----- src/qt/qt_platform.cpp | 22 +++++++++++-- src/utils/log.c | 15 +++++---- 6 files changed, 113 insertions(+), 44 deletions(-) diff --git a/src/86box.c b/src/86box.c index 1c11d9bee..ae58aca03 100644 --- a/src/86box.c +++ b/src/86box.c @@ -782,7 +782,11 @@ usage: goto usage; temp2 = (char *) calloc(2048, 1); - sscanf(argv[++c], "%c:%s", &drive, temp2); + if (sscanf(argv[++c], "%c:%2047s", &drive, temp2) != 2) { + fprintf(stderr, "Invalid input format for --image option.\n"); + free(temp2); + goto usage; + } if (drive > 0x40) drive = (drive & 0x1f) - 1; else @@ -1021,9 +1025,21 @@ usage: * This is where we start outputting to the log file, * if there is one. Create a little info header first. */ + struct tm time_buf; + (void) time(&now); - info = localtime(&now); - strftime(temp, sizeof(temp), "%Y/%m/%d %H:%M:%S", info); +#ifdef _WIN32 + if (localtime_s(&time_buf, &now) == 0) + info = &time_buf; +#else + info = localtime_r(&now, &time_buf); +#endif + + if (info) + strftime(temp, sizeof(temp), "%Y/%m/%d %H:%M:%S", info); + else + strcpy(temp, "unknown"); + pclog("#\n# %ls v%ls logfile, created %s\n#\n", EMU_NAME_W, EMU_VERSION_FULL_W, temp); pclog("# VM: %s\n#\n", vm_name); diff --git a/src/cdrom/cdrom_image_viso.c b/src/cdrom/cdrom_image_viso.c index cf132c560..3eec6d5a1 100644 --- a/src/cdrom/cdrom_image_viso.c +++ b/src/cdrom/cdrom_image_viso.c @@ -446,24 +446,36 @@ static int viso_fill_time(uint8_t *data, time_t time, int format, int longform) { uint8_t *p = data; - struct tm *time_s = localtime(&time); - if (!time_s) { - /* localtime will return NULL if the time_t is negative (Windows) - or way too far into 64-bit space (Linux). Fall back to epoch. */ - time_t epoch = 0; - time_s = localtime(&epoch); - if (UNLIKELY(!time_s)) - fatal("VISO: localtime(0) = NULL\n"); + struct tm time_s_buf; + struct tm *time_s = NULL; + time_t epoch = 0; - /* Force year clamping if the timestamp is known to be outside the supported ranges. */ +#ifdef _WIN32 + if (localtime_s(&time_s_buf, &time) == 0) + time_s = &time_s_buf; +#else + time_s = localtime_r(&time, &time_s_buf); +#endif + + if (!time_s) { + /* localtime may return NULL if time is negative or out of range */ +#ifdef _WIN32 + if (localtime_s(&time_s_buf, &epoch) == 0) + time_s = &time_s_buf; +#else + time_s = localtime_r(&epoch, &time_s_buf); +#endif + if (!time_s) + fatal("VISO: localtime fallback to epoch failed\n"); + + /* Force year clamping for out-of-range times */ if (time < (longform ? -62135596800LL : -2208988800LL)) /* 0001-01-01 00:00:00 : 1900-01-01 00:00:00 */ time_s->tm_year = -1901; else if (time > (longform ? 253402300799LL : 5869583999LL)) /* 9999-12-31 23:59:59 : 2155-12-31 23:59:59 */ time_s->tm_year = 8100; } - /* Clamp year to the supported ranges, and assume the - OS returns valid numbers in the other struct fields. */ + /* Clamp year within supported ranges */ if (time_s->tm_year < (longform ? -1900 : 0)) { time_s->tm_year = longform ? -1900 : 0; time_s->tm_mon = time_s->tm_hour = time_s->tm_min = time_s->tm_sec = 0; @@ -476,18 +488,18 @@ viso_fill_time(uint8_t *data, time_t time, int format, int longform) time_s->tm_min = time_s->tm_sec = 59; } - /* Convert timestamp. */ + /* Convert timestamp */ if (longform) { - p += sprintf((char *) p, "%04u%02u%02u%02u%02u%02u00", - 1900 + time_s->tm_year, 1 + time_s->tm_mon, time_s->tm_mday, + p += sprintf((char *)p, "%04u%02u%02u%02u%02u%02u00", + 1900 + (unsigned)time_s->tm_year, 1 + time_s->tm_mon, time_s->tm_mday, time_s->tm_hour, time_s->tm_min, time_s->tm_sec); } else { - *p++ = time_s->tm_year; /* year since 1900 */ - *p++ = 1 + time_s->tm_mon; /* month */ - *p++ = time_s->tm_mday; /* day */ - *p++ = time_s->tm_hour; /* hour */ - *p++ = time_s->tm_min; /* minute */ - *p++ = time_s->tm_sec; /* second */ + *p++ = (uint8_t)time_s->tm_year; /* year since 1900 */ + *p++ = (uint8_t)(1 + time_s->tm_mon); /* month */ + *p++ = (uint8_t)time_s->tm_mday; /* day */ + *p++ = (uint8_t)time_s->tm_hour; /* hour */ + *p++ = (uint8_t)time_s->tm_min; /* minute */ + *p++ = (uint8_t)time_s->tm_sec; /* second */ } if (format & VISO_FORMAT_ISO) *p++ = tz_offset; /* timezone (ISO only) */ @@ -1034,8 +1046,15 @@ next_dir: the timezone offset for descriptors and file times to use. */ tzset(); time_t now = time(NULL); - if (viso->format & VISO_FORMAT_ISO) /* timezones are ISO only */ - tz_offset = (now - mktime(gmtime(&now))) / (3600 / 4); + struct tm now_tm; + if (viso->format & VISO_FORMAT_ISO) { /* timezones are ISO only */ +#ifdef _WIN32 + gmtime_s(&now_tm, &now); // Windows: output first param, input second +#else + gmtime_r(&now, &now_tm); // POSIX: input first param, output second +#endif + tz_offset = (now - mktime(&now_tm)) / (3600 / 4); + } /* Get root directory basename for the volume ID. */ const char *basename = path_get_filename(viso->root_dir->path); diff --git a/src/cpu/386_ops.h b/src/cpu/386_ops.h index 5113ca817..73626acd2 100644 --- a/src/cpu/386_ops.h +++ b/src/cpu/386_ops.h @@ -264,6 +264,7 @@ opVPCEXT(uint32_t fetchdat) uint8_t b2; uint16_t cent; time_t now; + struct tm tm_buf; struct tm *tm = NULL; if (!is_vpc) /* only emulate this on Virtual PC machines */ @@ -282,7 +283,16 @@ opVPCEXT(uint32_t fetchdat) /* 0f 3f 03 xx opcodes are mostly related to the host clock, so fetch it now */ if (b1 == 0x03) { (void) time(&now); - tm = localtime(&now); + +#ifdef _WIN32 + if (localtime_s(&tm_buf, &now) == 0) + tm = &tm_buf; +#else + tm = localtime_r(&now, &tm_buf); +#endif + + if (!tm) + fatal("localtime() failed for host clock\n"); } if ((b1 == 0x07) && (b2 == 0x0b)) { diff --git a/src/nvr.c b/src/nvr.c index 7f43a76c1..b6bf2a5a5 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -310,18 +310,25 @@ nvr_close(void) void nvr_time_sync(void) { - struct tm *tm; - time_t now; + struct tm tm; + time_t now; /* Get the current time of day, and convert to local time. */ (void) time(&now); - if (time_sync & TIME_SYNC_UTC) - tm = gmtime(&now); - else - tm = localtime(&now); - /* Set the internal clock. */ - nvr_time_set(tm); +#ifdef _WIN32 + if (time_sync & TIME_SYNC_UTC) + gmtime_s(&tm, &now); + else + localtime_s(&tm, &now); +#else + if (time_sync & TIME_SYNC_UTC) + gmtime_r(&now, &tm); + else + localtime_r(&now, &tm); +#endif + + nvr_time_set(&tm); } /* Get current time from internal clock. */ diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index 8c2586482..8677a6a91 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -341,9 +341,25 @@ path_get_slash(char *path) void path_append_filename(char *dest, const char *s1, const char *s2) { - strcpy(dest, s1); - path_slash(dest); - strcat(dest, s2); + size_t dest_size = 260; + size_t len; + + if (!dest || !s1 || !s2) + return; + + snprintf(dest, dest_size, "%s", s1); + len = strlen(dest); + + if (len > 0 && dest[len - 1] != '/' && dest[len - 1] != '\\') { + if (len + 1 < dest_size) { + dest[len++] = '/'; + dest[len] = '\0'; + } + } + + if (len < dest_size - 1) { + strncat(dest, s2, dest_size - len - 1); + } } void diff --git a/src/utils/log.c b/src/utils/log.c index 257029b51..f10dff56b 100644 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -106,7 +106,6 @@ log_out(void *priv, const char *fmt, va_list ap) { log_t *log = (log_t *) priv; char temp[1024]; - char fmt2[1024]; if (log == NULL) pclog("WARNING: Logging called with a NULL log pointer\n"); @@ -115,18 +114,20 @@ log_out(void *priv, const char *fmt, va_list ap) else if (fmt[0] != '\0') { log_ensure_stdlog_open(); - vsprintf(temp, fmt, ap); + vsnprintf(temp, sizeof(temp), fmt, ap); + if (log->suppr_seen && !strcmp(log->buff, temp)) log->seen++; else { if (log->suppr_seen && log->seen) { - log_copy(log, fmt2, "*** %d repeats ***\n", 1024); - fprintf(stdlog, fmt2, log->seen); + fprintf(stdlog, "*** %d repeats ***\n", log->seen); } log->seen = 0; - strcpy(log->buff, temp); - log_copy(log, fmt2, temp, 1024); - fprintf(stdlog, fmt2, ap); + + strncpy(log->buff, temp, sizeof(log->buff) - 1); + log->buff[sizeof(log->buff) - 1] = '\0'; + + fprintf(stdlog, "%s", temp); } fflush(stdlog); From 979eb934a846cc902aad83866d1117cc66319b12 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 29 Jun 2025 06:42:51 +0200 Subject: [PATCH 065/103] Acer V12P: Remove on-board SCSI. --- src/machine/m_at_socket4.c | 5 ++--- src/machine/machine_table.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/machine/m_at_socket4.c b/src/machine/m_at_socket4.c index 8d1f518b8..3de3bc871 100644 --- a/src/machine/m_at_socket4.c +++ b/src/machine/m_at_socket4.c @@ -57,7 +57,7 @@ machine_at_v12p_init(const machine_t *model) ret = bios_load_linear(fn, 0x000e0000, 131072, 0); device_context_restore(); - machine_at_common_init(model); + machine_at_common_init(model); device_add(&ide_isa_device); pci_init(PCI_CONFIG_TYPE_2 | PCI_NO_IRQ_STEERING); @@ -71,8 +71,7 @@ machine_at_v12p_init(const machine_t *model) device_add(&keyboard_ps2_acer_pci_device); device_add(&sio_zb_device); device_add_params(&pc87310_device, (void *) (PC87310_ALI)); - device_add(&amd_am28f010_flash_device); - device_add(&ncr53c810_onboard_pci_device); + device_add(&amd_am28f010_flash_device); return ret; } diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index f1bcd36c3..d5e2af58b 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -10079,7 +10079,7 @@ const machine_t machines[] = { .max_multi = MACHINE_MULTIPLIER_FIXED }, .bus_flags = MACHINE_PS2_PCI, - .flags = MACHINE_IDE | MACHINE_SCSI | MACHINE_APM, + .flags = MACHINE_IDE | MACHINE_APM, .ram = { .min = 2048, .max = 196608, From a560abe2aaf98269f6055539bc93899270a22344 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sun, 29 Jun 2025 01:10:34 -0400 Subject: [PATCH 066/103] Correct some macos GHA deps --- .github/workflows/cmake_macos.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cmake_macos.yml b/.github/workflows/cmake_macos.yml index 2ae417e13..4db41304e 100644 --- a/.github/workflows/cmake_macos.yml +++ b/.github/workflows/cmake_macos.yml @@ -66,7 +66,6 @@ jobs: - name: Install dependencies run: >- brew install - ninja sdl2 rtmidi openal-soft @@ -159,12 +158,12 @@ jobs: - name: Install dependencies run: >- brew install - ninja sdl2 rtmidi openal-soft fluidsynth libslirp + vde libserialport ${{ matrix.ui.packages }} From 6ba5dc107b84ba00f793c490b7f33d35ae3e3e79 Mon Sep 17 00:00:00 2001 From: Kotori <191649996+kotori06@users.noreply.github.com> Date: Sun, 29 Jun 2025 09:57:19 +0200 Subject: [PATCH 067/103] fix SID emulation logic, add some UI elements for SID config --- src/sound/snd_resid.cpp | 13 +++++++++---- src/sound/snd_ssi2001.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/sound/snd_resid.cpp b/src/sound/snd_resid.cpp index b0503cac2..3dda5363b 100644 --- a/src/sound/snd_resid.cpp +++ b/src/sound/snd_resid.cpp @@ -20,23 +20,28 @@ typedef struct psid_t { psid_t *psid; void * -sid_init(uint8_t type) +sid_init(uint8_t type, double range) { reSIDfp::SamplingMethod method = reSIDfp::RESAMPLE; float cycles_per_sec = 14318180.0 / 16.0; psid = new psid_t; psid->sid = new SID; - + psid->sid->setFilter6581Range(range); + psid->sid->reset(); switch (type) { default: + psid->sid->setChipModel(reSIDfp::MOS6581); + break; case 0: psid->sid->setChipModel(reSIDfp::MOS6581); + break; case 1: psid->sid->setChipModel(reSIDfp::MOS8580); + break; } - psid->sid->reset(); + for (uint8_t c = 0; c < 32; c++) psid->sid->write(c, 0); @@ -101,4 +106,4 @@ sid_fillbuf(int16_t *buf, int len, UNUSED(void *priv)) int x = CLOCK_DELTA(len); fillbuf2(x, buf, len); -} +} \ No newline at end of file diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index f1620b817..9cc41c504 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -72,7 +72,7 @@ ssi2001_init(UNUSED(const device_t *info)) { ssi2001_t *ssi2001 = calloc(1, sizeof(ssi2001_t)); - ssi2001->psid = sid_init(0); + ssi2001->psid = sid_init(device_get_config_int("sid_config"),device_get_config_int("sid_adjustment")); sid_reset(ssi2001->psid); uint16_t addr = device_get_config_hex16("base"); ssi2001->gameport_enabled = device_get_config_int("gameport"); @@ -112,7 +112,7 @@ entertainer_init(UNUSED(const device_t *info)) ssi2001_t *ssi2001 = calloc(1, sizeof(ssi2001_t)); entertainer_t *entertainer = calloc(1, sizeof(entertainer_t)); - ssi2001->psid = sid_init(0); + ssi2001->psid = sid_init(0, 0.5); sid_reset(ssi2001->psid); ssi2001->gameport_enabled = device_get_config_int("gameport"); io_sethandler(0x200, 0x0001, entertainer_read, NULL, NULL, entertainer_write, NULL, NULL, entertainer); @@ -163,6 +163,33 @@ static const device_config_t ssi2001_config[] = { .selection = { { 0 } }, .bios = { { 0 } } }, + + { + .name = "sid_config", + .description = "SID Model", + .type = CONFIG_HEX16, + .default_string = NULL, + .default_int = 0x000, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "8580", .value = 0x001 }, + { .description = "6581", .value = 0x000 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "sid_adjustment", + .description = "SID Filter Strength", + .type = CONFIG_STRING, + .default_string = "0.5", + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = {{"0.5"}}, + .bios = { { 0 } } + }, { .name = "", .description = "", .type = CONFIG_END } // clang-format off }; From 789e1239d16af1caee06f8d947df28306a5c369f Mon Sep 17 00:00:00 2001 From: Kotori <191649996+kotori06@users.noreply.github.com> Date: Sun, 29 Jun 2025 10:07:37 +0200 Subject: [PATCH 068/103] Update snd_resid.h --- src/include/86box/snd_resid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/86box/snd_resid.h b/src/include/86box/snd_resid.h index c7e97ac0f..c6a616a3e 100644 --- a/src/include/86box/snd_resid.h +++ b/src/include/86box/snd_resid.h @@ -4,7 +4,7 @@ #ifdef __cplusplus extern "C" { #endif -void *sid_init(uint8_t type); +void *sid_init(uint8_t type, double range); void sid_close(void *priv); void sid_reset(void *priv); uint8_t sid_read(uint16_t addr, void *priv); From 8e3202446dd2bfc4329a894629e46c11b25b4f00 Mon Sep 17 00:00:00 2001 From: MaxwellS04 Date: Mon, 30 Jun 2025 01:31:12 +0700 Subject: [PATCH 069/103] Correct minimum memory on two ALi SS7 machines --- src/machine/machine_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index d5e2af58b..87dd38786 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -14730,7 +14730,7 @@ const machine_t machines[] = { .bus_flags = MACHINE_PS2_AGP | MACHINE_BUS_USB, .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_ACPI | MACHINE_USB, .ram = { - .min = 1024, + .min = 8192, .max = 1572864, .step = 8192 }, @@ -14770,7 +14770,7 @@ const machine_t machines[] = { .bus_flags = MACHINE_PS2_AGP | MACHINE_BUS_USB, .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_ACPI | MACHINE_USB, .ram = { - .min = 1024, + .min = 8192, .max = 1572864, .step = 8192 }, From 96734590cae3e13fac6b922df039d833580d75bd Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 30 Jun 2025 01:10:58 +0600 Subject: [PATCH 070/103] x86-specific FADD implementation --- src/cpu/x87_ops_arith.h | 59 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/cpu/x87_ops_arith.h b/src/cpu/x87_ops_arith.h index 8d0c02167..efcb64ebc 100644 --- a/src/cpu/x87_ops_arith.h +++ b/src/cpu/x87_ops_arith.h @@ -1,3 +1,56 @@ + +#ifdef X87_INLINE_ASM +static inline double float_add(double src, double val, int round) +{ + int orig_round, new_round; + __asm volatile("" + : + : + : "memory"); + asm ( + "fnstcw %0\n" : "=m"(orig_round) + ); + new_round = orig_round & ~(3 << 10); + new_round |= (round << 10); + + __asm volatile("" + : + : + : "memory"); + + asm ( + "fldl %0\n" + "fldcw %1\n" + "faddl %2\n" + "fstl %0\n" + "fldcw %3\n" + : "=m"(src) + : "m"(new_round), "m"(val), "m"(orig_round) + ); + + return src; +} + +#define DO_FADD(use_var) \ + do \ + { \ + ST(0) = float_add(ST(0), use_var, (cpu_state.npxc >> 10) & 3); \ + } \ + while (0) + +#else +#define DO_FADD(use_var) \ + do \ + { \ + if ((cpu_state.npxc >> 10) & 3) \ + fesetround(rounding_modes[(cpu_state.npxc >> 10) & 3]); \ + ST(0) += use_var; \ + if ((cpu_state.npxc >> 10) & 3) \ + fesetround(FE_TONEAREST); \ + } \ + while (0) +#endif + #define opFPU(name, optype, a_size, load_var, get, use_var, cycle_postfix) \ static int opFADD##name##_a##a_size(UNUSED(uint32_t fetchdat)) \ { \ @@ -8,11 +61,7 @@ load_var = get(); \ if (cpu_state.abrt) \ return 1; \ - if ((cpu_state.npxc >> 10) & 3) \ - fesetround(rounding_modes[(cpu_state.npxc >> 10) & 3]); \ - ST(0) += use_var; \ - if ((cpu_state.npxc >> 10) & 3) \ - fesetround(FE_TONEAREST); \ + DO_FADD(use_var); \ FP_TAG_VALID; \ CLOCK_CYCLES_FPU((fpu_type >= FPU_487SX) ? (x87_timings.fadd##cycle_postfix) : ((x87_timings.fadd##cycle_postfix) * cpu_multi)); \ CONCURRENCY_CYCLES((fpu_type >= FPU_487SX) ? (x87_concurrency.fadd##cycle_postfix) : ((x87_concurrency.fadd##cycle_postfix) * cpu_multi)); \ From b44042ef1ce1fbfe2c2beab7a5fc5555853db6cc Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 30 Jun 2025 02:08:48 +0600 Subject: [PATCH 071/103] x86-specific FADD (SSE2 version) --- src/cpu/x87_ops.h | 24 ++++++++++++++---------- src/cpu/x87_ops_arith.h | 38 ++++++++++++++------------------------ 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/cpu/x87_ops.h b/src/cpu/x87_ops.h index 0bd8209e1..c60a0d171 100644 --- a/src/cpu/x87_ops.h +++ b/src/cpu/x87_ops.h @@ -22,6 +22,20 @@ */ #include #include +#if defined(_MSC_VER) && !defined(__clang__) +# if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _M_IX86 +# define X87_INLINE_ASM +# endif +#else +# if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _M_IX86 || defined _M_X64 || defined __amd64__ +# define X87_INLINE_ASM +# endif +#endif + +#ifdef X87_INLINE_ASM +#include +#endif + #include "x87_timings.h" #ifdef _MSC_VER # include @@ -64,16 +78,6 @@ typedef union { }; } double_decompose_t; -#if defined(_MSC_VER) && !defined(__clang__) -# if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _M_IX86 -# define X87_INLINE_ASM -# endif -#else -# if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _M_IX86 || defined _M_X64 || defined __amd64__ -# define X87_INLINE_ASM -# endif -#endif - #ifdef FPU_8087 # define x87_div(dst, src1, src2) \ do { \ diff --git a/src/cpu/x87_ops_arith.h b/src/cpu/x87_ops_arith.h index efcb64ebc..bf3fbf253 100644 --- a/src/cpu/x87_ops_arith.h +++ b/src/cpu/x87_ops_arith.h @@ -2,33 +2,23 @@ #ifdef X87_INLINE_ASM static inline double float_add(double src, double val, int round) { - int orig_round, new_round; - __asm volatile("" - : - : - : "memory"); - asm ( - "fnstcw %0\n" : "=m"(orig_round) - ); - new_round = orig_round & ~(3 << 10); - new_round |= (round << 10); + int rounding_mode_orig; - __asm volatile("" - : - : - : "memory"); + __m128d xmm_src = _mm_load_sd(&src); + __m128d xmm_dst = _mm_load_sd(&val); + __m128d xmm_res; - asm ( - "fldl %0\n" - "fldcw %1\n" - "faddl %2\n" - "fstl %0\n" - "fldcw %3\n" - : "=m"(src) - : "m"(new_round), "m"(val), "m"(orig_round) - ); + rounding_mode_orig = _MM_GET_ROUNDING_MODE(); + if (round == 0) _MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST); + if (round == 1) _MM_SET_ROUNDING_MODE(_MM_ROUND_DOWN); + if (round == 2) _MM_SET_ROUNDING_MODE(_MM_ROUND_UP); + if (round == 3) _MM_SET_ROUNDING_MODE(_MM_ROUND_TOWARD_ZERO); - return src; + xmm_res = _mm_add_sd(xmm_src, xmm_dst); + + _MM_SET_ROUNDING_MODE(rounding_mode_orig); + + return _mm_cvtsd_f64(xmm_res); } #define DO_FADD(use_var) \ From f29675e5d4c6f1d086bed3f80a673982059ade49 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 00:15:29 +0200 Subject: [PATCH 072/103] Manager: Remove the pointless "Convert system to PIII" option. --- src/qt/qt_vmmanager_main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 88b9456cc..7916abca8 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -72,10 +72,6 @@ VMManagerMain::VMManagerMain(QWidget *parent) : } }); - QAction convertToP3(tr("Convert system to PIII")); - contextMenu.addAction(&convertToP3); - convertToP3.setEnabled(false); - QAction setSystemIcon(tr("Set icon")); contextMenu.addAction(&setSystemIcon); connect(&setSystemIcon, &QAction::triggered, [this] { From e601f258057551b704b1ec948d086da19b6726ae Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 00:17:33 +0200 Subject: [PATCH 073/103] x87: Fix the rounding_modes warnings. --- src/cpu/x87_ops.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpu/x87_ops.h b/src/cpu/x87_ops.h index c60a0d171..b134bf8fc 100644 --- a/src/cpu/x87_ops.h +++ b/src/cpu/x87_ops.h @@ -52,7 +52,9 @@ extern void fpu_log(const char *fmt, ...); extern double exp_pow_table[0x800]; +#ifndef X87_INLINE_ASM static int rounding_modes[4] = { FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO }; +#endif #define ST(x) cpu_state.ST[((cpu_state.TOP + (x)) & 7)] From ad5aa6e52f664bc9f57d3f42b8637610b4c41091 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 00:18:59 +0200 Subject: [PATCH 074/103] Attempt to undefine wait to avoid the conflicts on Mac. --- src/cpu/808x.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cpu/808x.c b/src/cpu/808x.c index dda688ee1..62c8395af 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -297,6 +297,10 @@ fetch_and_bus(int c, int bus) } } +#ifdef wait +#undef wait +#endif + static void wait(int c, int bus) { From d8669a522710beae21dca7282293503c260dbfe6 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 00:36:00 +0200 Subject: [PATCH 075/103] (S)VGA: Recalculate pel panning on every line instead of on every frame. --- src/include/86box/vid_svga.h | 1 + src/video/vid_svga.c | 53 ++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 8a18f0865..78e025746 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -137,6 +137,7 @@ typedef struct svga_t { int ps_bit_bug; int ati_4color; int vblankend; + int panning_blank; /*The three variables below allow us to implement memory maps like that seen on a 1MB Trio64 : 0MB-1MB - VRAM diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 2073fb8c0..e4a6d9efc 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1435,10 +1435,8 @@ svga_poll(void *priv) svga->memaddr_backup = (svga->memaddr_backup << 2); svga->scanline = 0; - if (svga->attrregs[0x10] & 0x20) { - svga->scrollcache = 0; - svga->x_add = svga->left_overscan; - } + if (svga->attrregs[0x10] & 0x20) + svga->panning_blank = 1; } } if (svga->vc == svga->dispend) { @@ -1526,25 +1524,6 @@ svga_poll(void *priv) svga->dispon = 1; svga->displine = (svga->interlace && svga->oddeven) ? 1 : 0; - svga->scrollcache = (svga->attrregs[0x13] & 0x0f); - if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /*Text mode*/ - if (svga->seqregs[1] & 1) - svga->scrollcache &= 0x07; - else { - svga->scrollcache++; - if (svga->scrollcache > 8) - svga->scrollcache = 0; - } - } else if ((svga->render == svga_render_2bpp_lowres) || (svga->render == svga_render_2bpp_highres) || (svga->render == svga_render_4bpp_lowres) || (svga->render == svga_render_4bpp_highres)) - svga->scrollcache &= 0x07; - else - svga->scrollcache = (svga->scrollcache & 0x06) >> 1; - - if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) - svga->scrollcache <<= 1; - - svga->x_add = svga->left_overscan - svga->scrollcache; - svga->linecountff = 0; svga->hwcursor_on = 0; @@ -1555,9 +1534,37 @@ svga_poll(void *priv) svga->overlay_on = 0; svga->overlay_latch = svga->overlay; + + svga->panning_blank = 0; } + if (svga->scanline == (svga->crtc[10] & 31)) svga->cursorvisible = 1; + + if (svga->panning_blank) { + svga->scrollcache = 0; + svga->x_add = svga->left_overscan; + } else { + svga->scrollcache = (svga->attrregs[0x13] & 0x0f); + if (!(svga->gdcreg[6] & 1) && !(svga->attrregs[0x10] & 1)) { /*Text mode*/ + if (svga->seqregs[1] & 1) + svga->scrollcache &= 0x07; + else { + svga->scrollcache++; + if (svga->scrollcache > 8) + svga->scrollcache = 0; + } + } else if ((svga->render == svga_render_2bpp_lowres) || (svga->render == svga_render_2bpp_highres) || + (svga->render == svga_render_4bpp_lowres) || (svga->render == svga_render_4bpp_highres)) + svga->scrollcache &= 0x07; + else + svga->scrollcache = (svga->scrollcache & 0x06) >> 1; + + if ((svga->seqregs[1] & 8) || (svga->render == svga_render_8bpp_lowres)) + svga->scrollcache <<= 1; + + svga->x_add = svga->left_overscan - svga->scrollcache; + } } } From 4a468246cc0e43203a3844a60f5b03f71b824748 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 00:52:00 +0200 Subject: [PATCH 076/103] 808x: Rename wait() to wait_cycs() to avoid conflict with the Apple SDK. --- src/cpu/808x.c | 572 ++++++++++++++++++++--------------------- src/cpu/x87_ops.h | 2 +- src/cpu/x87_ops_misc.h | 2 +- src/cpu/x87_ops_sf.h | 2 +- 4 files changed, 287 insertions(+), 291 deletions(-) diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 62c8395af..2e24d3c49 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -90,44 +90,44 @@ static bool cpu_md_write_disable = 1; #define fetch_ea_32(val) #define PREFETCH_RUN(a, b, c, d, e, f, g, h) -#define CYCLES(val) \ - { \ - wait(val, 0); \ +#define CYCLES(val) \ + { \ + wait_cycs(val, 0); \ } #define CLOCK_CYCLES_ALWAYS(val) \ { \ - wait(val, 0); \ + wait_cycs(val, 0); \ } #if 0 # define CLOCK_CYCLES_FPU(val) \ { \ - wait(val, 0); \ + wait_cycs(val, 0); \ } -# define CLOCK_CYCLES(val) \ - { \ - if (fpu_cycles > 0) { \ - fpu_cycles -= (val); \ - if (fpu_cycles < 0) { \ - wait(val, 0); \ - } \ - } else { \ - wait(val, 0); \ - } \ +# define CLOCK_CYCLES(val) \ + { \ + if (fpu_cycles > 0) { \ + fpu_cycles -= (val); \ + if (fpu_cycles < 0) { \ + wait_cycs(val, 0); \ + } \ + } else { \ + wait_cycs(val, 0); \ + } \ } # define CONCURRENCY_CYCLES(c) fpu_cycles = (c) #else -# define CLOCK_CYCLES(val) \ - { \ - wait(val, 0); \ +# define CLOCK_CYCLES(val) \ + { \ + wait_cycs(val, 0); \ } # define CLOCK_CYCLES_FPU(val) \ { \ - wait(val, 0); \ + wait_cycs(val, 0); \ } # define CONCURRENCY_CYCLES(c) @@ -297,12 +297,8 @@ fetch_and_bus(int c, int bus) } } -#ifdef wait -#undef wait -#endif - static void -wait(int c, int bus) +wait_cycs(int c, int bus) { cycles -= c; fetch_and_bus(c, bus); @@ -344,13 +340,13 @@ cpu_io(int bits, int out, uint16_t port) int old_cycles = cycles; if (out) { - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); if (bits == 16) { if (is8086 && !(port & 1)) { old_cycles = cycles; outw(port, AX); } else { - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); old_cycles = cycles; outb(port++, AL); outb(port, AH); @@ -360,13 +356,13 @@ cpu_io(int bits, int out, uint16_t port) outb(port, AL); } } else { - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); if (bits == 16) { if (is8086 && !(port & 1)) { old_cycles = cycles; AX = inw(port); } else { - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); old_cycles = cycles; AL = inb(port++); AH = inb(port); @@ -386,7 +382,7 @@ readmemb(uint32_t a) { uint8_t ret; - wait(4, 1); + wait_cycs(4, 1); ret = read_mem_b(a); return ret; @@ -410,11 +406,11 @@ readmemw(uint32_t s, uint16_t a) { uint16_t ret; - wait(4, 1); + wait_cycs(4, 1); if (is8086 && !(a & 1)) ret = read_mem_w(s + a); else { - wait(4, 1); + wait_cycs(4, 1); ret = read_mem_b(s + a); ret |= read_mem_b(s + ((is186 && !is_nec) ? (a + 1) : (a + 1) & 0xffff)) << 8; } @@ -469,7 +465,7 @@ writememb(uint32_t s, uint32_t a, uint8_t v) { uint32_t addr = s + a; - wait(4, 1); + wait_cycs(4, 1); write_mem_b(addr, v); if ((addr >= 0xf0000) && (addr <= 0xfffff)) @@ -482,12 +478,12 @@ writememw(uint32_t s, uint32_t a, uint16_t v) { uint32_t addr = s + a; - wait(4, 1); + wait_cycs(4, 1); if (is8086 && !(a & 1)) write_mem_w(addr, v); else { write_mem_b(addr, v & 0xff); - wait(4, 1); + wait_cycs(4, 1); addr = s + ((is186 && !is_nec) ? (a + 1) : ((a + 1) & 0xffff)); write_mem_b(addr, v >> 8); } @@ -564,7 +560,7 @@ pfq_fetchb_common(void) /* Reset prefetch queue internal position. */ pfq_ip = cpu_state.pc; /* Fill the queue. */ - wait(4 - (biu_cycles & 3), 0); + wait_cycs(4 - (biu_cycles & 3), 0); } /* Fetch. */ @@ -578,7 +574,7 @@ pfq_fetchb(void) uint8_t ret; ret = pfq_fetchb_common(); - wait(1, 0); + wait_cycs(1, 0); return ret; } @@ -590,7 +586,7 @@ pfq_fetchw(void) uint16_t temp; temp = pfq_fetchb_common(); - wait(1, 0); + wait_cycs(1, 0); temp |= (pfq_fetchb_common() << 8); return temp; @@ -764,38 +760,38 @@ do_mod_rm(void) if (cpu_mod == 3) return; - wait(1, 0); + wait_cycs(1, 0); if ((rmdat & 0xc7) == 0x06) { - wait(1, 0); + wait_cycs(1, 0); cpu_state.eaaddr = pfq_fetchw(); easeg = ovr_seg ? *ovr_seg : ds; - wait(1, 0); + wait_cycs(1, 0); return; } else switch (cpu_rm) { case 0: case 3: - wait(2, 0); + wait_cycs(2, 0); break; case 1: case 2: - wait(3, 0); + wait_cycs(3, 0); break; } cpu_state.eaaddr = (*mod1add[0][cpu_rm]) + (*mod1add[1][cpu_rm]); easeg = ovr_seg ? *ovr_seg : *mod1seg[cpu_rm]; switch (rmdat & 0xc0) { case 0x40: - wait(3, 0); + wait_cycs(3, 0); cpu_state.eaaddr += sign_extend(pfq_fetchb()); break; case 0x80: - wait(3, 0); + wait_cycs(3, 0); cpu_state.eaaddr += pfq_fetchw(); break; } cpu_state.eaaddr &= 0xffff; - wait(2, 0); + wait_cycs(2, 0); } #undef getr8 @@ -987,7 +983,7 @@ access(int num, UNUSED(int bits)) case 62: case 66: case 68: - wait(1, 0); + wait_cycs(1, 0); break; case 3: case 11: @@ -1003,7 +999,7 @@ access(int num, UNUSED(int bits)) case 52: case 53: case 54: - wait(2, 0); + wait_cycs(2, 0); break; case 16: case 18: @@ -1012,7 +1008,7 @@ access(int num, UNUSED(int bits)) case 32: case 37: case 42: - wait(3, 0); + wait_cycs(3, 0); break; case 10: case 12: @@ -1025,59 +1021,59 @@ access(int num, UNUSED(int bits)) case 39: case 41: case 60: - wait(4, 0); + wait_cycs(4, 0); break; case 4: case 70: - wait(5, 0); + wait_cycs(5, 0); break; case 31: case 38: case 40: - wait(6, 0); + wait_cycs(6, 0); break; case 5: if (opcode == 0xcc) - wait(7, 0); + wait_cycs(7, 0); else - wait(4, 0); + wait_cycs(4, 0); break; case 36: - wait(1, 0); + wait_cycs(1, 0); pfq_clear(); - wait(1, 0); + wait_cycs(1, 0); if (cpu_mod != 3) - wait(1, 0); - wait(3, 0); + wait_cycs(1, 0); + wait_cycs(3, 0); break; case 43: - wait(2, 0); + wait_cycs(2, 0); pfq_clear(); - wait(1, 0); + wait_cycs(1, 0); break; case 57: if (cpu_mod != 3) - wait(2, 0); - wait(4, 0); + wait_cycs(2, 0); + wait_cycs(4, 0); break; case 58: if (cpu_mod != 3) - wait(1, 0); - wait(4, 0); + wait_cycs(1, 0); + wait_cycs(4, 0); break; case 59: - wait(2, 0); + wait_cycs(2, 0); pfq_clear(); if (cpu_mod != 3) - wait(1, 0); - wait(3, 0); + wait_cycs(1, 0); + wait_cycs(3, 0); break; case 65: - wait(1, 0); + wait_cycs(1, 0); pfq_clear(); - wait(2, 0); + wait_cycs(2, 0); if (cpu_mod != 3) - wait(1, 0); + wait_cycs(1, 0); break; } } @@ -1100,7 +1096,7 @@ interrupt(uint16_t addr) old_cs = CS; access(5, 16); new_ip = readmemw(0, cpu_state.eaaddr); - wait(1, 0); + wait_cycs(1, 0); cpu_state.eaaddr = (cpu_state.eaaddr + 2) & 0xffff; access(6, 16); new_cs = readmemw(0, cpu_state.eaaddr); @@ -1136,7 +1132,7 @@ interrupt_brkem(uint16_t addr) old_cs = CS; access(5, 16); new_ip = readmemw(0, cpu_state.eaaddr); - wait(1, 0); + wait_cycs(1, 0); cpu_state.eaaddr = (cpu_state.eaaddr + 2) & 0xffff; access(6, 16); new_cs = readmemw(0, cpu_state.eaaddr); @@ -1205,7 +1201,7 @@ custom_nmi(void) access(5, 16); (void) readmemw(0, cpu_state.eaaddr); new_ip = custom_nmi_vector & 0xffff; - wait(1, 0); + wait_cycs(1, 0); cpu_state.eaaddr = (cpu_state.eaaddr + 2) & 0xffff; access(6, 16); (void) readmemw(0, cpu_state.eaaddr); @@ -1264,20 +1260,20 @@ check_interrupts(void) repeating = 0; completed = 1; ovr_seg = NULL; - wait(3, 0); + wait_cycs(3, 0); /* ACK to PIC */ temp = pic_irq_ack(); - wait(4, 1); - wait(1, 0); + wait_cycs(4, 1); + wait_cycs(1, 0); /* ACK to PIC */ temp = pic_irq_ack(); - wait(4, 1); - wait(1, 0); + wait_cycs(4, 1); + wait_cycs(1, 0); in_lock = 0; clear_lock = 0; - wait(1, 0); + wait_cycs(1, 0); /* Here is where temp should be filled, but we cheat. */ - wait(3, 0); + wait_cycs(3, 0); opcode = 0x00; interrupt(temp); } @@ -1291,7 +1287,7 @@ rep_action(int bits) if (in_rep == 0) return 0; - wait(2, 0); + wait_cycs(2, 0); t = CX; if (irq_pending() && (repeating != 0)) { access(71, bits); @@ -1303,16 +1299,16 @@ rep_action(int bits) t = 0; } if (t == 0) { - wait(1, 0); + wait_cycs(1, 0); completed = 1; repeating = 0; return 1; } --CX; completed = 0; - wait(2, 0); + wait_cycs(2, 0); if (!repeating) - wait(2, 0); + wait_cycs(2, 0); return 0; } @@ -1322,7 +1318,7 @@ jump(uint16_t delta) uint16_t old_ip; access(67, 8); pfq_clear(); - wait(5, 0); + wait_cycs(5, 0); old_ip = cpu_state.pc; set_ip((cpu_state.pc + delta) & 0xffff); return old_ip; @@ -1346,9 +1342,9 @@ jcc(uint8_t opcode, int cond) { /* int8_t offset; */ - wait(1, 0); + wait_cycs(1, 0); cpu_data = pfq_fetchb(); - wait(1, 0); + wait_cycs(1, 0); if ((!cond) == !!(opcode & 0x01)) jump_short(); } @@ -1538,32 +1534,32 @@ mul(uint16_t a, uint16_t b) bit_count = 16; high_bit = 0x8000; } else - wait(8, 0); + wait_cycs(8, 0); size_mask = (1 << bit_count) - 1; if ((rmdat & 0x38) == 0x28) { if (!top_bit(a, bit_count)) { if (top_bit(b, bit_count)) { - wait(1, 0); + wait_cycs(1, 0); if ((b & size_mask) != ((opcode & 1) ? 0x8000 : 0x80)) - wait(1, 0); + wait_cycs(1, 0); b = ~b + 1; negate = 1; } } else { - wait(1, 0); + wait_cycs(1, 0); a = ~a + 1; negate = 1; if (top_bit(b, bit_count)) { b = ~b + 1; negate = 0; } else - wait(4, 0); + wait_cycs(4, 0); } - wait(10, 0); + wait_cycs(10, 0); } - wait(3, 0); + wait_cycs(3, 0); } c = 0; @@ -1571,13 +1567,13 @@ mul(uint16_t a, uint16_t b) carry = (a & 1) != 0; a >>= 1; for (i = 0; i < bit_count; ++i) { - wait(7, 0); + wait_cycs(7, 0); if (carry) { cpu_src = c; cpu_dest = b; add(bit_count); c = cpu_data & size_mask; - wait(1, 0); + wait_cycs(1, 0); carry = !!(cpu_state.flags & C_FLAG); } r = (c >> 1) + (carry ? high_bit : 0); @@ -1592,7 +1588,7 @@ mul(uint16_t a, uint16_t b) a = (~a + 1) & size_mask; if (a == 0) ++c; - wait(9, 0); + wait_cycs(9, 0); } cpu_data = a; cpu_dest = c; @@ -1637,7 +1633,7 @@ set_co_mul(UNUSED(int bits), int carry) set_of(carry); set_zf_ex(!carry); if (!carry) - wait(1, 0); + wait_cycs(1, 0); } /* Was div(), renamed to avoid conflicts with stdlib div(). */ @@ -1668,28 +1664,28 @@ x86_div(uint16_t l, uint16_t h) h &= size_mask; negative = 1; dividend_negative = 1; - wait(4, 0); + wait_cycs(4, 0); } if (top_bit(cpu_src, bit_count)) { cpu_src = ~cpu_src + 1; negative = !negative; } else - wait(1, 0); - wait(9, 0); + wait_cycs(1, 0); + wait_cycs(9, 0); } - wait(3, 0); + wait_cycs(3, 0); } - wait(8, 0); + wait_cycs(8, 0); cpu_src &= size_mask; if (h >= cpu_src) { if (opcode != 0xd4) - wait(1, 0); + wait_cycs(1, 0); interrupt(0); return 0; } if (opcode != 0xd4) - wait(1, 0); - wait(2, 0); + wait_cycs(1, 0); + wait_cycs(2, 0); carry = 1; for (b = 0; b < bit_count; ++b) { r = (l << 1) + (carry ? 1 : 0); @@ -1698,32 +1694,32 @@ x86_div(uint16_t l, uint16_t h) r = (h << 1) + (carry ? 1 : 0); carry = top_bit(h, bit_count); h = r; - wait(8, 0); + wait_cycs(8, 0); if (carry) { carry = 0; h -= cpu_src; if (b == bit_count - 1) - wait(2, 0); + wait_cycs(2, 0); } else { carry = cpu_src > h; if (!carry) { h -= cpu_src; - wait(1, 0); + wait_cycs(1, 0); if (b == bit_count - 1) - wait(2, 0); + wait_cycs(2, 0); } } } l = ~((l << 1) + (carry ? 1 : 0)); if (opcode != 0xd4 && (rmdat & 0x38) == 0x38) { - wait(4, 0); + wait_cycs(4, 0); if (top_bit(l, bit_count)) { if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); interrupt(0); return 0; } - wait(7, 0); + wait_cycs(7, 0); if (negative) l = ~l + 1; if (dividend_negative) @@ -1782,7 +1778,7 @@ aa(void) { set_pzs(8); AL = cpu_data & 0x0f; - wait(6, 0); + wait_cycs(6, 0); } static void @@ -1852,7 +1848,7 @@ cpu_inb(uint16_t port) int old_cycles = cycles; uint8_t ret; - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); old_cycles = cycles; ret = inb(port); @@ -1868,12 +1864,12 @@ cpu_inw(uint16_t port) int old_cycles = cycles; uint16_t ret; - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); if (is8086 && !(port & 1)) { old_cycles = cycles; ret = inw(port); } else { - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); old_cycles = cycles; ret = inb(port++); ret |= (inb(port) << 8); @@ -1889,7 +1885,7 @@ cpu_outb(uint16_t port, uint16_t val) { int old_cycles = cycles; - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); old_cycles = cycles; outb(port, val); @@ -1902,13 +1898,13 @@ cpu_outw(uint16_t port, uint16_t val) { int old_cycles = cycles; - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); if (is8086 && !(port & 1)) { old_cycles = cycles; outw(port, val); } else { - wait(is_mazovia ? 5 : 4, 1); + wait_cycs(is_mazovia ? 5 : 4, 1); old_cycles = cycles; outb(port++, val); outb(port, val >> 8); @@ -1958,7 +1954,7 @@ execx86(int cycs) in_lock = 0; clear_lock = 0; } - wait(1, 0); + wait_cycs(1, 0); } completed = 1; @@ -1967,7 +1963,7 @@ execx86(int cycs) switch (opcode) { case 0x60: /*PUSHA/PUSH R*/ orig_sp = SP; - wait(1, 0); + wait_cycs(1, 0); push(&AX); push(&CX); push(&DX); @@ -1979,7 +1975,7 @@ execx86(int cycs) handled = 1; break; case 0x61: /*POPA/POP R*/ - wait(9, 0); + wait_cycs(9, 0); DI = pop(); SI = pop(); BP = pop(); @@ -2011,7 +2007,7 @@ execx86(int cycs) case 0x65: if (is_nec) { /* REPC/REPNC */ - wait(1, 0); + wait_cycs(1, 0); in_rep = (opcode == 0x64 ? 1 : 2); rep_c_flag = 1; completed = 0; @@ -2021,7 +2017,7 @@ execx86(int cycs) case 0x68: wordtopush = pfq_fetchw(); - wait(1, 0); + wait_cycs(1, 0); push(&wordtopush); handled = 1; break; @@ -2061,12 +2057,12 @@ execx86(int cycs) bits = 8 << (opcode & 1); handled = 1; if (!repeating) - wait(2, 0); + wait_cycs(2, 0); if (rep_action(bits)) break; else if (!repeating) - wait(7, 0); + wait_cycs(7, 0); if (bits == 16) { writememw(es, DI, cpu_inw(DX)); @@ -2089,12 +2085,12 @@ execx86(int cycs) bits = 8 << (opcode & 1); handled = 1; if (!repeating) - wait(2, 0); + wait_cycs(2, 0); if (rep_action(bits)) break; else if (!repeating) - wait(7, 0); + wait_cycs(7, 0); if (bits == 16) { cpu_outw(DX, readmemw(dest_seg, SI)); @@ -2137,12 +2133,12 @@ execx86(int cycs) bits = 8 << (opcode & 1); do_mod_rm(); if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); access(53, bits); cpu_data = get_ea(); cpu_src = pfq_fetchb(); - wait((cpu_mod != 3) ? 9 : 6, 0); + wait_cycs((cpu_mod != 3) ? 9 : 6, 0); if (!is_nec) cpu_src &= 0x1F; @@ -2214,7 +2210,7 @@ execx86(int cycs) break; } if ((opcode & 2) != 0) - wait(4, 0); + wait_cycs(4, 0); --cpu_src; } access(17, bits); @@ -2248,7 +2244,7 @@ execx86(int cycs) switch (opcode) { case 0x28: /* ROL4 r/m */ do_mod_rm(); - wait(21, 0); + wait_cycs(21, 0); temp_val = geteab(); temp_al = AL; @@ -2266,7 +2262,7 @@ execx86(int cycs) case 0x2a: /* ROR4 r/m */ do_mod_rm(); - wait(21, 0); + wait_cycs(21, 0); temp_val = geteab(); temp_al = AL; @@ -2285,7 +2281,7 @@ execx86(int cycs) case 0x19: /* TEST1 r16/m16, imm4 */ bits = 8 << (opcode & 0x1); do_mod_rm(); - wait(3, 0); + wait_cycs(3, 0); bit = (opcode & 0x8) ? (pfq_fetchb()) : (CL); bit &= ((1 << (3 + (opcode & 0x1))) - 1); @@ -2303,7 +2299,7 @@ execx86(int cycs) case 0x1f: /* NOT1 r16/m16, imm4 */ bits = 8 << (opcode & 0x1); do_mod_rm(); - wait(3, 0); + wait_cycs(3, 0); bit = (opcode & 0x8) ? (pfq_fetchb()) : (CL); bit &= ((1 << (3 + (opcode & 0x1))) - 1); @@ -2323,7 +2319,7 @@ execx86(int cycs) case 0x1d: /* SET1 r16/m16, imm4 */ bits = 8 << (opcode & 0x1); do_mod_rm(); - wait(3, 0); + wait_cycs(3, 0); bit = (opcode & 0x8) ? (pfq_fetchb()) : (CL); bit &= ((1 << (3 + (opcode & 0x1))) - 1); @@ -2343,7 +2339,7 @@ execx86(int cycs) case 0x1b: /* CLR1 r16/m16, imm4 */ bits = 8 << (opcode & 0x1); do_mod_rm(); - wait(3, 0); + wait_cycs(3, 0); bit = (opcode & 0x8) ? (pfq_fetchb()) : (CL); bit &= ((1 << (3 + (opcode & 0x1))) - 1); @@ -2366,9 +2362,9 @@ execx86(int cycs) nibble = 0; srcseg = ovr_seg ? *ovr_seg : ds; - wait(5, 0); + wait_cycs(5, 0); for (i = 0; i < ((nibbles_count / 2) + odd); i++) { - wait(19, 0); + wait_cycs(19, 0); destcmp = read_mem_b((es) + DI + i); for (nibble = 0; nibble < 2; nibble++) { destbyte = destcmp >> (nibble ? 4 : 0); @@ -2401,9 +2397,9 @@ execx86(int cycs) nibble = 0; srcseg = ovr_seg ? *ovr_seg : ds; - wait(5, 0); + wait_cycs(5, 0); for (i = 0; i < ((nibbles_count / 2) + odd); i++) { - wait(19, 0); + wait_cycs(19, 0); destcmp = read_mem_b((es) + DI + i); for (nibble = 0; nibble < 2; nibble++) { destbyte = destcmp >> (nibble ? 4 : 0); @@ -2436,9 +2432,9 @@ execx86(int cycs) nibble = 0; srcseg = ovr_seg ? *ovr_seg : ds; - wait(5, 0); + wait_cycs(5, 0); for (i = 0; i < ((nibbles_count / 2) + odd); i++) { - wait(19, 0); + wait_cycs(19, 0); destcmp = read_mem_b((es) + DI + i); for (nibble = 0; nibble < 2; nibble++) { destbyte = destcmp >> (nibble ? 4 : 0); @@ -2464,7 +2460,7 @@ execx86(int cycs) case 0x31: /* INS reg1, reg2 */ case 0x39: /* INS reg8, imm4 */ do_mod_rm(); - wait(1, 0); + wait_cycs(1, 0); bit_length = ((opcode & 0x8) ? (pfq_fetchb() & 0xF) : (getr8(cpu_reg) & 0xF)) + 1; bit_offset = getr8(cpu_rm) & 0xF; @@ -2493,7 +2489,7 @@ execx86(int cycs) case 0x33: /* EXT reg1, reg2 */ case 0x3b: /* EXT reg8, imm4 */ do_mod_rm(); - wait(1, 0); + wait_cycs(1, 0); bit_length = ((opcode & 0x8) ? (pfq_fetchb() & 0xF) : (getr8(cpu_reg) & 0xF)) + 1; bit_offset = getr8(cpu_rm) & 0xF; @@ -2541,7 +2537,7 @@ execx86(int cycs) pfq_pos = 0; } else load_seg(pop(), _opseg[(opcode >> 3) & 0x03]); - wait(1, 0); + wait_cycs(1, 0); /* All POP segment instructions suppress interrupts for one instruction. */ noint = 1; break; @@ -2550,7 +2546,7 @@ execx86(int cycs) case 0x2E: /*CS:*/ case 0x36: /*SS:*/ case 0x3E: /*DS:*/ - wait(1, 0); + wait_cycs(1, 0); ovr_seg = opseg[(opcode >> 3) & 0x03]; completed = 0; break; @@ -2601,21 +2597,21 @@ execx86(int cycs) cpu_src = tempw; } if (cpu_mod != 3) - wait(2, 0); - wait(1, 0); + wait_cycs(2, 0); + wait_cycs(1, 0); alu_op(bits); if (cpu_alu_op != 7) { if ((opcode & 2) == 0) { access(10, bits); set_ea(cpu_data); if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); } else { set_reg(cpu_reg, cpu_data); - wait(1, 0); + wait_cycs(1, 0); } } else - wait(1, 0); + wait_cycs(1, 0); break; case 0x04: @@ -2636,7 +2632,7 @@ execx86(int cycs) case 0x3d: /* alu A, imm */ bits = 8 << (opcode & 1); - wait(1, 0); + wait_cycs(1, 0); cpu_data = pfq_fetch(); cpu_dest = get_accum(bits); /* AX/AL */ cpu_src = cpu_data; @@ -2644,7 +2640,7 @@ execx86(int cycs) alu_op(bits); if (cpu_alu_op != 7) set_accum(bits, cpu_data); - wait(1, 0); + wait_cycs(1, 0); break; case 0x27: /*DAA*/ @@ -2667,7 +2663,7 @@ execx86(int cycs) } AL = cpu_dest; set_pzs(8); - wait(3, 0); + wait_cycs(3, 0); break; case 0x2F: /*DAS*/ cpu_dest = AL; @@ -2689,10 +2685,10 @@ execx86(int cycs) } AL = cpu_dest; set_pzs(8); - wait(3, 0); + wait_cycs(3, 0); break; case 0x37: /*AAA*/ - wait(1, 0); + wait_cycs(1, 0); if ((cpu_state.flags & A_FLAG) || ((AL & 0xf) > 9)) { cpu_src = 6; ++AH; @@ -2700,7 +2696,7 @@ execx86(int cycs) } else { cpu_src = 0; clear_ca(); - wait(1, 0); + wait_cycs(1, 0); } cpu_dest = AL; cpu_data = cpu_dest + cpu_src; @@ -2708,7 +2704,7 @@ execx86(int cycs) aa(); break; case 0x3F: /*AAS*/ - wait(1, 0); + wait_cycs(1, 0); if ((cpu_state.flags & A_FLAG) || ((AL & 0xf) > 9)) { cpu_src = 6; --AH; @@ -2716,7 +2712,7 @@ execx86(int cycs) } else { cpu_src = 0; clear_ca(); - wait(1, 0); + wait_cycs(1, 0); } cpu_dest = AL; cpu_data = cpu_dest - cpu_src; @@ -2741,7 +2737,7 @@ execx86(int cycs) case 0x4E: case 0x4F: /* INCDEC rw */ - wait(1, 0); + wait_cycs(1, 0); cpu_dest = cpu_state.regs[opcode & 7].w; cpu_src = 1; bits = 16; @@ -2778,7 +2774,7 @@ execx86(int cycs) case 0x5F: access(23, 16); cpu_state.regs[opcode & 0x07].w = pop(); - wait(1, 0); + wait_cycs(1, 0); break; case 0x60: /*JO alias*/ @@ -2845,20 +2841,20 @@ execx86(int cycs) cpu_data = get_ea(); cpu_dest = cpu_data; if (cpu_mod != 3) - wait(3, 0); + wait_cycs(3, 0); if (opcode == 0x81) { if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); cpu_src = pfq_fetchw(); } else { if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); if (opcode == 0x83) cpu_src = sign_extend(pfq_fetchb()); else cpu_src = pfq_fetchb() | 0xff00; } - wait(1, 0); + wait_cycs(1, 0); cpu_alu_op = (rmdat & 0x38) >> 3; alu_op(bits); if (cpu_alu_op != 7) { @@ -2866,7 +2862,7 @@ execx86(int cycs) set_ea(cpu_data); } else { if (cpu_mod != 3) - wait(1, 0); + wait_cycs(1, 0); } break; @@ -2879,8 +2875,8 @@ execx86(int cycs) cpu_data = get_ea(); test(bits, cpu_data, get_reg(cpu_reg)); if (cpu_mod == 3) - wait(2, 0); - wait(2, 0); + wait_cycs(2, 0); + wait_cycs(2, 0); break; case 0x86: case 0x87: @@ -2891,7 +2887,7 @@ execx86(int cycs) cpu_data = get_ea(); cpu_src = get_reg(cpu_reg); set_reg(cpu_reg, cpu_data); - wait(3, 0); + wait_cycs(3, 0); access(12, bits); set_ea(cpu_src); break; @@ -2901,7 +2897,7 @@ execx86(int cycs) /* MOV rm, reg */ bits = 8 << (opcode & 1); do_mod_rm(); - wait(1, 0); + wait_cycs(1, 0); access(13, bits); set_ea(get_reg(cpu_reg)); break; @@ -2912,15 +2908,15 @@ execx86(int cycs) do_mod_rm(); access(50, bits); set_reg(cpu_reg, get_ea()); - wait(1, 0); + wait_cycs(1, 0); if (cpu_mod != 3) - wait(2, 0); + wait_cycs(2, 0); break; case 0x8C: /*MOV w,sreg*/ do_mod_rm(); if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); access(14, 16); seteaw(_opseg[(rmdat & 0x18) >> 3]->seg); break; @@ -2928,9 +2924,9 @@ execx86(int cycs) case 0x8D: /*LEA*/ do_mod_rm(); cpu_state.regs[cpu_reg].w = cpu_state.eaaddr; - wait(1, 0); + wait_cycs(1, 0); if (cpu_mod != 3) - wait(2, 0); + wait_cycs(2, 0); break; case 0x8E: /*MOV sreg,w*/ @@ -2942,23 +2938,23 @@ execx86(int cycs) pfq_pos = 0; } else load_seg(tempw, _opseg[(rmdat & 0x18) >> 3]); - wait(1, 0); + wait_cycs(1, 0); if (cpu_mod != 3) - wait(2, 0); + wait_cycs(2, 0); if (((rmdat & 0x18) >> 3) == 2) noint = 1; break; case 0x8F: /*POPW*/ do_mod_rm(); - wait(1, 0); + wait_cycs(1, 0); cpu_src = cpu_state.eaaddr; access(24, 16); if (cpu_mod != 3) - wait(2, 0); + wait_cycs(2, 0); cpu_data = pop(); cpu_state.eaaddr = cpu_src; - wait(2, 0); + wait_cycs(2, 0); access(15, 16); seteaw(cpu_data); break; @@ -2972,30 +2968,30 @@ execx86(int cycs) case 0x96: case 0x97: /* XCHG AX, rw */ - wait(1, 0); + wait_cycs(1, 0); cpu_data = cpu_state.regs[opcode & 7].w; cpu_state.regs[opcode & 7].w = AX; AX = cpu_data; - wait(1, 0); + wait_cycs(1, 0); break; case 0x98: /*CBW*/ - wait(1, 0); + wait_cycs(1, 0); AX = sign_extend(AL); break; case 0x99: /*CWD*/ - wait(4, 0); + wait_cycs(4, 0); if (!top_bit(AX, 16)) DX = 0; else { - wait(1, 0); + wait_cycs(1, 0); DX = 0xffff; } break; case 0x9A: /*CALL FAR*/ - wait(1, 0); + wait_cycs(1, 0); new_ip = pfq_fetchw(); - wait(1, 0); + wait_cycs(1, 0); new_cs = pfq_fetchw(); pfq_clear(); access(31, 16); @@ -3009,11 +3005,11 @@ execx86(int cycs) break; case 0x9B: /*WAIT*/ if (!repeating) - wait(2, 0); - wait(5, 0); + wait_cycs(2, 0); + wait_cycs(5, 0); #ifdef NO_HACK if (irq_pending()) { - wait(7, 0); + wait_cycs(7, 0); check_interrupts(); } else { repeating = 1; @@ -3021,7 +3017,7 @@ execx86(int cycs) clock_end(); } #else - wait(7, 0); + wait_cycs(7, 0); check_interrupts(); #endif break; @@ -3039,16 +3035,16 @@ execx86(int cycs) cpu_state.flags = pop() | 0x8002; else cpu_state.flags = pop() | 0x0002; - wait(1, 0); + wait_cycs(1, 0); sync_to_i8080(); break; case 0x9E: /*SAHF*/ - wait(1, 0); + wait_cycs(1, 0); cpu_state.flags = (cpu_state.flags & 0xff02) | AH; - wait(2, 0); + wait_cycs(2, 0); break; case 0x9F: /*LAHF*/ - wait(1, 0); + wait_cycs(1, 0); AH = cpu_state.flags & 0xd7; break; @@ -3056,17 +3052,17 @@ execx86(int cycs) case 0xA1: /* MOV A, [iw] */ bits = 8 << (opcode & 1); - wait(1, 0); + wait_cycs(1, 0); cpu_state.eaaddr = pfq_fetchw(); access(1, bits); set_accum(bits, readmem((ovr_seg ? *ovr_seg : ds))); - wait(1, 0); + wait_cycs(1, 0); break; case 0xA2: case 0xA3: /* MOV [iw], A */ bits = 8 << (opcode & 1); - wait(1, 0); + wait_cycs(1, 0); cpu_state.eaaddr = pfq_fetchw(); access(7, bits); writemem((ovr_seg ? *ovr_seg : ds), get_accum(bits)); @@ -3078,18 +3074,18 @@ execx86(int cycs) case 0xAD: /* LODS */ bits = 8 << (opcode & 1); if (!repeating) { - wait(1, 0); + wait_cycs(1, 0); if ((opcode & 8) == 0 && in_rep != 0) - wait(1, 0); + wait_cycs(1, 0); } if (rep_action(bits)) { - wait(1, 0); + wait_cycs(1, 0); if ((opcode & 8) != 0) - wait(1, 0); + wait_cycs(1, 0); break; } if (in_rep != 0 && (opcode & 8) != 0) - wait(1, 0); + wait_cycs(1, 0); access(20, bits); lods(bits); if ((opcode & 8) == 0) { @@ -3098,12 +3094,12 @@ execx86(int cycs) } else { set_accum(bits, cpu_data); if (in_rep != 0) - wait(2, 0); + wait_cycs(2, 0); } if (in_rep == 0) { - wait(3, 0); + wait_cycs(3, 0); if ((opcode & 8) != 0) - wait(1, 0); + wait_cycs(1, 0); break; } repeating = 1; @@ -3116,19 +3112,19 @@ execx86(int cycs) case 0xAF: /* SCAS */ bits = 8 << (opcode & 1); if (!repeating) - wait(1, 0); + wait_cycs(1, 0); if (rep_action(bits)) { - wait(2, 0); + wait_cycs(2, 0); break; } if (in_rep != 0) - wait(1, 0); - wait(1, 0); + wait_cycs(1, 0); + wait_cycs(1, 0); cpu_dest = get_accum(bits); if ((opcode & 8) == 0) { access(21, bits); lods(bits); - wait(1, 0); + wait_cycs(1, 0); cpu_dest = cpu_data; } access(2, bits); @@ -3137,14 +3133,14 @@ execx86(int cycs) DI = string_increment(bits); cpu_src = cpu_data; sub(bits); - wait(2, 0); + wait_cycs(2, 0); if (in_rep == 0) { - wait(3, 0); + wait_cycs(3, 0); break; } if ((!!(cpu_state.flags & (rep_c_flag ? C_FLAG : Z_FLAG))) == (in_rep == 1)) { completed = 1; - wait(4, 0); + wait_cycs(4, 0); break; } repeating = 1; @@ -3155,29 +3151,29 @@ execx86(int cycs) case 0xA9: /* TEST A, imm */ bits = 8 << (opcode & 1); - wait(1, 0); + wait_cycs(1, 0); cpu_data = pfq_fetch(); test(bits, get_accum(bits), cpu_data); - wait(1, 0); + wait_cycs(1, 0); break; case 0xAA: case 0xAB: /* STOS */ bits = 8 << (opcode & 1); if (!repeating) { - wait(1, 0); + wait_cycs(1, 0); if (in_rep != 0) - wait(1, 0); + wait_cycs(1, 0); } if (rep_action(bits)) { - wait(1, 0); + wait_cycs(1, 0); break; } cpu_data = AX; access(28, bits); stos(bits); if (in_rep == 0) { - wait(3, 0); + wait_cycs(3, 0); break; } repeating = 1; @@ -3192,12 +3188,12 @@ execx86(int cycs) case 0xB5: case 0xB6: case 0xB7: - wait(1, 0); + wait_cycs(1, 0); if (opcode & 0x04) cpu_state.regs[opcode & 0x03].b.h = pfq_fetchb(); else cpu_state.regs[opcode & 0x03].b.l = pfq_fetchb(); - wait(1, 0); + wait_cycs(1, 0); break; case 0xB8: @@ -3208,9 +3204,9 @@ execx86(int cycs) case 0xBD: case 0xBE: case 0xBF: - wait(1, 0); + wait_cycs(1, 0); cpu_state.regs[opcode & 0x07].w = pfq_fetchw(); - wait(1, 0); + wait_cycs(1, 0); break; case 0xC0: @@ -3224,28 +3220,28 @@ execx86(int cycs) /* RET */ bits = 8 + (opcode & 0x08); if ((opcode & 9) != 1) - wait(1, 0); + wait_cycs(1, 0); if (!(opcode & 1)) { cpu_src = pfq_fetchw(); - wait(1, 0); + wait_cycs(1, 0); } if ((opcode & 9) == 9) - wait(1, 0); + wait_cycs(1, 0); pfq_clear(); access(26, bits); new_ip = pop(); - wait(2, 0); + wait_cycs(2, 0); if ((opcode & 8) == 0) new_cs = CS; else { access(42, bits); new_cs = pop(); if (opcode & 1) - wait(1, 0); + wait_cycs(1, 0); } if (!(opcode & 1)) { SP += cpu_src; - wait(1, 0); + wait_cycs(1, 0); } load_cs(new_cs); access(72, bits); @@ -3263,7 +3259,7 @@ execx86(int cycs) access(57, bits); read_ea2(bits); load_seg(cpu_data, (opcode & 0x01) ? &cpu_state.seg_ds : &cpu_state.seg_es); - wait(1, 0); + wait_cycs(1, 0); break; case 0xC6: @@ -3271,12 +3267,12 @@ execx86(int cycs) /* MOV rm, imm */ bits = 8 << (opcode & 1); do_mod_rm(); - wait(1, 0); + wait_cycs(1, 0); if (cpu_mod != 3) - wait(2, 0); + wait_cycs(2, 0); cpu_data = pfq_fetch(); if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); access(16, bits); set_ea(cpu_data); break; @@ -3285,13 +3281,13 @@ execx86(int cycs) interrupt(3); break; case 0xCD: /*INT*/ - wait(1, 0); + wait_cycs(1, 0); interrupt(pfq_fetchb()); break; case 0xCE: /*INTO*/ - wait(3, 0); + wait_cycs(3, 0); if (cpu_state.flags & V_FLAG) { - wait(2, 0); + wait_cycs(2, 0); interrupt(4); } break; @@ -3299,7 +3295,7 @@ execx86(int cycs) case 0xCF: /*IRET*/ access(43, 8); new_ip = pop(); - wait(3, 0); + wait_cycs(3, 0); access(44, 8); new_cs = pop(); load_cs(new_cs); @@ -3310,7 +3306,7 @@ execx86(int cycs) cpu_state.flags = pop() | 0x8002; else cpu_state.flags = pop() | 0x0002; - wait(5, 0); + wait_cycs(5, 0); noint = 1; nmi_enable = 1; if (is_nec && !(cpu_state.flags & MD_FLAG)) @@ -3325,15 +3321,15 @@ execx86(int cycs) bits = 8 << (opcode & 1); do_mod_rm(); if (cpu_mod == 3) - wait(1, 0); + wait_cycs(1, 0); access(53, bits); cpu_data = get_ea(); if ((opcode & 2) == 0) { cpu_src = 1; - wait((cpu_mod != 3) ? 4 : 0, 0); + wait_cycs((cpu_mod != 3) ? 4 : 0, 0); } else { cpu_src = CL; - wait((cpu_mod != 3) ? 9 : 6, 0); + wait_cycs((cpu_mod != 3) ? 9 : 6, 0); } if (is186 && !is_nec) cpu_src &= 0x1F; @@ -3405,7 +3401,7 @@ execx86(int cycs) break; } if ((opcode & 2) != 0) - wait(4, 0); + wait_cycs(4, 0); --cpu_src; } access(17, bits); @@ -3413,7 +3409,7 @@ execx86(int cycs) break; case 0xD4: /*AAM*/ - wait(1, 0); + wait_cycs(1, 0); #ifdef NO_VARIANT_ON_NEC if (is_nec) { (void) pfq_fetchb(); @@ -3429,7 +3425,7 @@ execx86(int cycs) } break; case 0xD5: /*AAD*/ - wait(1, 0); + wait_cycs(1, 0); if (is_nec) { (void) pfq_fetchb(); mul(10, AH); @@ -3444,9 +3440,9 @@ execx86(int cycs) break; case 0xD6: /*SALC*/ if (!is_nec) { - wait(1, 0); + wait_cycs(1, 0); AL = (cpu_state.flags & C_FLAG) ? 0xff : 0x00; - wait(1, 0); + wait_cycs(1, 0); break; } fallthrough; @@ -3454,7 +3450,7 @@ execx86(int cycs) cpu_state.eaaddr = (BX + AL) & 0xffff; access(4, 8); AL = readmemb((ovr_seg ? *ovr_seg : ds) + cpu_state.eaaddr); - wait(1, 0); + wait_cycs(1, 0); break; case 0xD8: @@ -3535,9 +3531,9 @@ execx86(int cycs) } cpu_state.pc = tempw; /* Do this as the x87 code advances it, which is needed on the 286+ core, but not here. */ - wait(1, 0); + wait_cycs(1, 0); if (cpu_mod != 3) - wait(2, 0); + wait_cycs(2, 0); break; case 0xE0: @@ -3545,10 +3541,10 @@ execx86(int cycs) case 0xE2: case 0xE3: /* LOOP */ - wait(3, 0); + wait_cycs(3, 0); cpu_data = pfq_fetchb(); if (opcode != 0xe2) - wait(1, 0); + wait_cycs(1, 0); if (opcode != 0xe3) { --CX; oldc = (CX != 0); @@ -3578,7 +3574,7 @@ execx86(int cycs) case 0xEF: bits = 8 << (opcode & 1); if ((opcode & 0x0e) != 0x0c) - wait(1, 0); + wait_cycs(1, 0); if ((opcode & 8) == 0) cpu_data = pfq_fetchb(); else @@ -3590,7 +3586,7 @@ execx86(int cycs) cpu_io(16, 0, cpu_data); else cpu_io(8, 0, cpu_data); - wait(1, 0); + wait_cycs(1, 0); } else { if ((opcode & 8) == 0) access(8, bits); @@ -3604,19 +3600,19 @@ execx86(int cycs) break; case 0xE8: /*CALL rel 16*/ - wait(1, 0); + wait_cycs(1, 0); cpu_state.oldpc = jump_near(); access(34, 8); push((uint16_t *) &(cpu_state.oldpc)); break; case 0xE9: /*JMP rel 16*/ - wait(1, 0); + wait_cycs(1, 0); jump_near(); break; case 0xEA: /*JMP far*/ - wait(1, 0); + wait_cycs(1, 0); addr = pfq_fetchw(); - wait(1, 0); + wait_cycs(1, 0); tempw = pfq_fetchw(); load_cs(tempw); access(70, 8); @@ -3624,22 +3620,22 @@ execx86(int cycs) set_ip(addr); break; case 0xEB: /*JMP rel*/ - wait(1, 0); + wait_cycs(1, 0); cpu_data = (int8_t) pfq_fetchb(); jump_short(); - wait(1, 0); + wait_cycs(1, 0); break; case 0xF0: case 0xF1: /*LOCK - F1 is alias*/ in_lock = 1; - wait(1, 0); + wait_cycs(1, 0); completed = 0; break; case 0xF2: /*REPNE*/ case 0xF3: /*REPE*/ - wait(1, 0); + wait_cycs(1, 0); in_rep = (opcode == 0xf2 ? 1 : 2); completed = 0; rep_c_flag = 0; @@ -3647,12 +3643,12 @@ execx86(int cycs) case 0xF4: /*HLT*/ if (!repeating) { - wait(1, 0); + wait_cycs(1, 0); pfq_clear(); } - wait(1, 0); + wait_cycs(1, 0); if (irq_pending()) { - wait(cycles & 1, 0); + wait_cycs(cycles & 1, 0); check_interrupts(); } else { repeating = 1; @@ -3661,7 +3657,7 @@ execx86(int cycs) } break; case 0xF5: /*CMC*/ - wait(1, 0); + wait_cycs(1, 0); cpu_state.flags ^= C_FLAG; break; @@ -3675,18 +3671,18 @@ execx86(int cycs) case 0x00: case 0x08: /* TEST */ - wait(2, 0); + wait_cycs(2, 0); if (cpu_mod != 3) - wait(1, 0); + wait_cycs(1, 0); cpu_src = pfq_fetch(); - wait(1, 0); + wait_cycs(1, 0); test(bits, cpu_data, cpu_src); if (cpu_mod != 3) - wait(1, 0); + wait_cycs(1, 0); break; case 0x10: /* NOT */ case 0x18: /* NEG */ - wait(2, 0); + wait_cycs(2, 0); if ((rmdat & 0x38) == 0x10) cpu_data = ~cpu_data; else { @@ -3700,7 +3696,7 @@ execx86(int cycs) case 0x20: /* MUL */ case 0x28: /* IMUL */ old_flags = cpu_state.flags; - wait(1, 0); + wait_cycs(1, 0); mul(get_accum(bits), cpu_data); if (opcode & 1) { AX = cpu_data; @@ -3717,7 +3713,7 @@ execx86(int cycs) set_sf(bits); set_pf(); if (cpu_mod != 3) - wait(1, 0); + wait_cycs(1, 0); /* NOTE: When implementing the V20, care should be taken to not change the zero flag. */ if (is_nec) @@ -3726,10 +3722,10 @@ execx86(int cycs) case 0x30: /* DIV */ case 0x38: /* IDIV */ if (cpu_mod != 3) - wait(1, 0); + wait_cycs(1, 0); cpu_src = cpu_data; if (x86_div(AL, AH)) - wait(1, 0); + wait_cycs(1, 0); break; } break; @@ -3737,19 +3733,19 @@ execx86(int cycs) case 0xF8: case 0xF9: /* CLCSTC */ - wait(1, 0); + wait_cycs(1, 0); set_cf(opcode & 1); break; case 0xFA: case 0xFB: /* CLISTI */ - wait(1, 0); + wait_cycs(1, 0); set_if(opcode & 1); break; case 0xFC: case 0xFD: /* CLDSTD */ - wait(1, 0); + wait_cycs(1, 0); set_df(opcode & 1); break; @@ -3774,22 +3770,22 @@ execx86(int cycs) } do_af(); set_pzs(bits); - wait(2, 0); + wait_cycs(2, 0); access(19, bits); set_ea(cpu_data); break; case 0x10: /* CALL rm */ cpu_data_opff_rm(); access(63, bits); - wait(1, 0); + wait_cycs(1, 0); pfq_clear(); - wait(4, 0); + wait_cycs(4, 0); if (cpu_mod != 3) - wait(1, 0); - wait(1, 0); /* Wait. */ + wait_cycs(1, 0); + wait_cycs(1, 0); /* Wait. */ cpu_state.oldpc = cpu_state.pc; set_ip(cpu_data); - wait(2, 0); + wait_cycs(2, 0); access(35, bits); push((uint16_t *) &(cpu_state.oldpc)); break; @@ -3803,7 +3799,7 @@ execx86(int cycs) access(36, bits); push(&(CS)); access(64, bits); - wait(4, 0); + wait_cycs(4, 0); cpu_state.oldpc = cpu_state.pc; load_cs(new_cs); set_ip(new_ip); @@ -3829,7 +3825,7 @@ execx86(int cycs) case 0x30: /* PUSH rm */ case 0x38: if (cpu_mod != 3) - wait(1, 0); + wait_cycs(1, 0); access(38, bits); push((uint16_t *) &(cpu_data)); break; @@ -3839,7 +3835,7 @@ execx86(int cycs) default: x808x_log("Illegal opcode: %02X\n", opcode); pfq_fetchb(); - wait(8, 0); + wait_cycs(8, 0); break; } } diff --git a/src/cpu/x87_ops.h b/src/cpu/x87_ops.h index b134bf8fc..1e4504949 100644 --- a/src/cpu/x87_ops.h +++ b/src/cpu/x87_ops.h @@ -581,7 +581,7 @@ static int FPU_ILLEGAL_a16(UNUSED(uint32_t fetchdat)) { geteaw(); - wait(timing_rr, 0); + wait_cycs(timing_rr, 0); return 0; } #else diff --git a/src/cpu/x87_ops_misc.h b/src/cpu/x87_ops_misc.h index 9a01f7496..417beea62 100644 --- a/src/cpu/x87_ops_misc.h +++ b/src/cpu/x87_ops_misc.h @@ -7,7 +7,7 @@ opFI(uint32_t fetchdat) cpu_state.npxc &= ~0x80; if (rmdat == 0xe1) cpu_state.npxc |= 0x80; - wait(3, 0); + wait_cycs(3, 0); return 0; } #else diff --git a/src/cpu/x87_ops_sf.h b/src/cpu/x87_ops_sf.h index 0d4fee81a..adbaa2003 100644 --- a/src/cpu/x87_ops_sf.h +++ b/src/cpu/x87_ops_sf.h @@ -354,7 +354,7 @@ sf_FI(uint32_t fetchdat) fpu_state.cwd &= ~FPU_SW_Summary; if (rmdat == 0xe1) fpu_state.cwd |= FPU_SW_Summary; - wait(3, 0); + wait_cycs(3, 0); return 0; } #else From 7d579fb3f994bfb98c186902803e5787aabe5761 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 00:53:21 +0200 Subject: [PATCH 077/103] Qt: Remove the superfluous second instance of the CPU override warning. --- src/qt/qt_main.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index afb5fcc1d..eb7d6ac44 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -790,20 +790,6 @@ main(int argc, char *argv[]) main_window->installEventFilter(&manager_socket); } - /* Warn the user about unsupported configs */ - if (cpu_override) { - QMessageBox warningbox(QMessageBox::Icon::Warning, QObject::tr("You are loading an unsupported configuration"), - QObject::tr("CPU type filtering based on selected machine is disabled for this emulated machine.\n\nThis makes it possible to choose a CPU that is otherwise incompatible with the selected machine. However, you may run into incompatibilities with the machine BIOS or other software.\n\nEnabling this setting is not officially supported and any bug reports filed may be closed as invalid."), - QMessageBox::NoButton, main_window); - warningbox.addButton(QObject::tr("Continue"), QMessageBox::AcceptRole); - warningbox.addButton(QObject::tr("Exit"), QMessageBox::RejectRole); - warningbox.exec(); - if (warningbox.result() == QDialog::Accepted) { - confirm_exit_cmdl = 0; /* skip the confirmation prompt without touching the config */ - emit main_window->close(); - } - } - // pc_reset_hard_init(); QTimer onesec; From 7abddb0b3575ca4a54ddac69ceebbfd37ab98b8e Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 18:31:07 +0200 Subject: [PATCH 078/103] Tseng graphics cards: restore some legacy renderers, fixes Slackware in 4bpp high resolution mode. --- src/video/vid_et3000.c | 3 +++ src/video/vid_et4000.c | 11 +++++++++++ src/video/vid_et4000w32.c | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/video/vid_et3000.c b/src/video/vid_et3000.c index a82f93385..482cc60a3 100644 --- a/src/video/vid_et3000.c +++ b/src/video/vid_et3000.c @@ -476,6 +476,9 @@ et3000_recalctimings(svga_t *svga) svga->clock = (cpuclock * (double) (1ULL << 32)) / 36000000.0; break; } + + if (svga->render == svga_render_4bpp_highres) + svga->render = svga_render_4bpp_tseng_highres; } static void * diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index a99cb8872..d7de0706e 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -723,6 +723,17 @@ et4000_recalctimings(svga_t *svga) svga->rowoffset <<= 1; svga->render = svga_render_8bpp_highres; } + + if (svga->render == svga_render_4bpp_highres) + svga->render = svga_render_4bpp_tseng_highres; + + if (dev->type == ET4000_TYPE_TC6058AF) { + if (svga->render == svga_render_8bpp_lowres) + svga->render = svga_render_8bpp_tseng_lowres; + + else if (svga->render == svga_render_8bpp_highres) + svga->render = svga_render_8bpp_tseng_highres; + } } static void diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index 533bd1f28..2e9a7796a 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -600,6 +600,9 @@ et4000w32p_recalctimings(svga_t *svga) } } } + + if (svga->render == svga_render_4bpp_highres) + svga->render = svga_render_4bpp_tseng_highres; } void From fe3ad0000b581f6d25ad1ebf982ee4e96f1c0ea3 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 18:48:53 +0200 Subject: [PATCH 079/103] Forgotten the vid_svga_render.c and .h files. --- src/include/86box/vid_svga_render.h | 1 + src/video/vid_svga_render.c | 120 ++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/src/include/86box/vid_svga_render.h b/src/include/86box/vid_svga_render.h index 226ab8a18..7ead95838 100644 --- a/src/include/86box/vid_svga_render.h +++ b/src/include/86box/vid_svga_render.h @@ -55,6 +55,7 @@ extern void svga_render_4bpp_lowres(svga_t *svga); extern void svga_render_4bpp_highres(svga_t *svga); extern void svga_render_8bpp_lowres(svga_t *svga); extern void svga_render_8bpp_highres(svga_t *svga); +extern void svga_render_4bpp_tseng_highres(svga_t *svga); extern void svga_render_8bpp_clone_highres(svga_t *svga); extern void svga_render_8bpp_tseng_lowres(svga_t *svga); extern void svga_render_8bpp_tseng_highres(svga_t *svga); diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 0f9a4a253..bd471e72e 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -913,6 +913,126 @@ void svga_render_4bpp_highres(svga_t *svga) { svga_render_indexed_gfx(svga, true void svga_render_8bpp_lowres(svga_t *svga) { svga_render_indexed_gfx(svga, false, true); } void svga_render_8bpp_highres(svga_t *svga) { svga_render_indexed_gfx(svga, true, true); } +void +svga_render_4bpp_tseng_highres(svga_t *svga) +{ + int changed_offset; + int x; + int oddeven; + uint32_t addr; + uint32_t *p; + uint8_t edat[4]; + uint8_t dat; + uint32_t changed_addr; + + if ((svga->displine + svga->y_add) < 0) + return; + + if (svga->force_old_addr) { + changed_offset = (svga->memaddr + (svga->scanline & ~svga->crtc[0x17] & 3) * 0x8000) >> 12; + + if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset + 1] || svga->fullchange) { + p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; + + if (svga->firstline_draw == 2000) + svga->firstline_draw = svga->displine; + svga->lastline_draw = svga->displine; + + for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { + addr = svga->memaddr; + oddeven = 0; + + if (!(svga->crtc[0x17] & 0x40)) { + addr = (addr << 1) & svga->vram_mask; + + if (svga->seqregs[1] & 4) + oddeven = (addr & 4) ? 1 : 0; + + addr &= ~7; + + if ((svga->crtc[0x17] & 0x20) && (svga->memaddr & 0x20000)) + addr |= 4; + if (!(svga->crtc[0x17] & 0x20) && (svga->memaddr & 0x8000)) + addr |= 4; + } + + if (!(svga->crtc[0x17] & 0x01)) + addr = (addr & ~0x8000) | ((svga->scanline & 1) ? 0x8000 : 0); + if (!(svga->crtc[0x17] & 0x02)) + addr = (addr & ~0x10000) | ((svga->scanline & 2) ? 0x10000 : 0); + + if (svga->seqregs[1] & 4) { + edat[0] = svga->vram[addr | oddeven]; + edat[2] = svga->vram[addr | oddeven | 0x2]; + edat[1] = edat[3] = 0; + svga->memaddr += 2; + } else { + *(uint32_t *) (&edat[0]) = *(uint32_t *) (&svga->vram[addr]); + svga->memaddr += 4; + } + svga->memaddr &= svga->vram_mask; + + dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); + p[0] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[1] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); + p[2] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); + p[4] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[5] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); + p[6] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + + p += 8; + } + } + } else { + changed_addr = svga->remap_func(svga, svga->memaddr); + + if (svga->changedvram[changed_addr >> 12] || svga->changedvram[(changed_addr >> 12) + 1] || svga->fullchange) { + p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; + + if (svga->firstline_draw == 2000) + svga->firstline_draw = svga->displine; + svga->lastline_draw = svga->displine; + + for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { + addr = svga->remap_func(svga, svga->memaddr); + oddeven = 0; + + if (svga->seqregs[1] & 4) { + oddeven = (addr & 4) ? 1 : 0; + edat[0] = svga->vram[addr | oddeven]; + edat[2] = svga->vram[addr | oddeven | 0x2]; + edat[1] = edat[3] = 0; + svga->memaddr += 2; + } else { + *(uint32_t *) (&edat[0]) = *(uint32_t *) (&svga->vram[addr]); + svga->memaddr += 4; + } + svga->memaddr &= svga->vram_mask; + + dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); + p[0] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[1] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); + p[2] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); + p[4] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[5] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); + p[6] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + + p += 8; + } + } + } +} + void svga_render_8bpp_clone_highres(svga_t *svga) { From c537e614536a7104e426b6068bf4ed4c31db6033 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 30 Jun 2025 23:09:29 +0600 Subject: [PATCH 080/103] Copper demo wobbling effects now show up correctly --- src/include/86box/vid_svga.h | 3 +++ src/video/vid_et4000.c | 3 +++ src/video/vid_svga.c | 10 ++++++++ src/video/vid_svga_render.c | 45 ++++++++++++++++++++++++++++++++++-- 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 78e025746..14f3c933a 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -30,6 +30,7 @@ # define FLAG_S3_911_16BIT 256 # define FLAG_512K_MASK 512 # define FLAG_NO_SHIFT3 1024 /* Needed for Bochs VBE. */ +# define FLAG_PRECISETIME 2048 /* Needed for Copper demo if on dynarec. */ struct monitor_t; typedef struct hwcursor_t { @@ -138,6 +139,8 @@ typedef struct svga_t { int ati_4color; int vblankend; int panning_blank; + int render_line_offset; + int start_retrace_latch; /*The three variables below allow us to implement memory maps like that seen on a 1MB Trio64 : 0MB-1MB - VRAM diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index d7de0706e..7dccd9747 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -892,6 +892,9 @@ et4000_init(const device_t *info) if (dev->type >= ET4000_TYPE_ISA) dev->svga.ramdac = device_add(&sc1502x_ramdac_device); + if (dev->type == ET4000_TYPE_TC6058AF) + dev->svga.adv_flags |= FLAG_PRECISETIME; + dev->vram_mask = dev->vram_size - 1; rom_init(&dev->bios_rom, fn, diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index e4a6d9efc..5f2d2d89c 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -703,6 +703,13 @@ svga_recalctimings(svga_t *svga) int old_monitor_overscan_x = svga->monitor->mon_overscan_x; int old_monitor_overscan_y = svga->monitor->mon_overscan_y; + if (svga->adv_flags & FLAG_PRECISETIME) { +#ifdef USE_DYNAREC + if (cpu_use_dynarec) + update_tsc(); +#endif + } + svga->vtotal = svga->crtc[6]; svga->dispend = svga->crtc[0x12]; svga->vsyncstart = svga->crtc[0x10]; @@ -1253,6 +1260,7 @@ svga_do_render(svga_t *svga) } if (!svga->override) { + svga->render_line_offset = svga->start_retrace_latch - svga->crtc[0x4]; svga->render(svga); svga->x_add = svga->left_overscan; @@ -1514,6 +1522,8 @@ svga_poll(void *priv) if (svga->vsync_callback) svga->vsync_callback(svga); + + svga->start_retrace_latch = svga->crtc[0x4]; } #if 0 if (svga->vc == lines_num) { diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index bd471e72e..5905a25dd 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -744,6 +744,13 @@ svga_render_indexed_gfx(svga_t *svga, bool highres, bool combine8bits) return; p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; + if (svga->render_line_offset) { + if (svga->render_line_offset > 0) { + memset(p, svga->overscan_color, charwidth * svga->render_line_offset * sizeof(uint32_t)); + p += charwidth * svga->render_line_offset; + } + } + if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; @@ -900,6 +907,12 @@ svga_render_indexed_gfx(svga_t *svga, bool highres, bool combine8bits) else p += charwidth; } + + if (svga->render_line_offset < 0) { + uint32_t *orig_line = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; + memmove(orig_line, orig_line + (charwidth * -svga->render_line_offset), (svga->hdisp) * 4); + memset((orig_line + svga->hdisp) - (charwidth * -svga->render_line_offset), svga->overscan_color, charwidth * -svga->render_line_offset * 4); + } } /* @@ -1279,17 +1292,26 @@ svga_render_8bpp_tseng_lowres(svga_t *svga) { uint32_t *p; uint32_t dat; + int x = 0; if ((svga->displine + svga->y_add) < 0) return; - if (svga->changedvram[svga->memaddr >> 12] || svga->changedvram[(svga->memaddr >> 12) + 1] || svga->fullchange) { + if (svga->changedvram[svga->memaddr >> 12] || svga->changedvram[(svga->memaddr >> 12) + 1] || svga->fullchange || svga->render_line_offset) { + int end = svga->hdisp + svga->scrollcache; p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; + if (svga->render_line_offset) { + if (svga->render_line_offset > 0) { + memset(p, svga->overscan_color, 8 * svga->render_line_offset * sizeof(uint32_t)); + p += 8 * svga->render_line_offset; + } + } + for (int x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) { dat = *(uint32_t *) (&svga->vram[svga->memaddr & svga->vram_display_mask]); if (svga->attrregs[0x10] & 0x80) @@ -1311,6 +1333,11 @@ svga_render_8bpp_tseng_lowres(svga_t *svga) svga->memaddr += 4; p += 8; } + if (svga->render_line_offset < 0) { + uint32_t *orig_line = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; + memmove(orig_line, orig_line + (8 * -svga->render_line_offset), (svga->hdisp) * 4); + memset((orig_line + svga->hdisp) - (8 * -svga->render_line_offset), svga->overscan_color, 8 * -svga->render_line_offset * 4); + } svga->memaddr &= svga->vram_display_mask; } } @@ -1324,13 +1351,20 @@ svga_render_8bpp_tseng_highres(svga_t *svga) if ((svga->displine + svga->y_add) < 0) return; - if (svga->changedvram[svga->memaddr >> 12] || svga->changedvram[(svga->memaddr >> 12) + 1] || svga->fullchange) { + if (svga->changedvram[svga->memaddr >> 12] || svga->changedvram[(svga->memaddr >> 12) + 1] || svga->fullchange || svga->render_line_offset) { p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; + if (svga->render_line_offset) { + if (svga->render_line_offset > 0) { + memset(p, svga->overscan_color, 8 * svga->render_line_offset * sizeof(uint32_t)); + p += 8 * svga->render_line_offset; + } + } + for (int x = 0; x <= (svga->hdisp /* + svga->scrollcache*/); x += 8) { dat = *(uint32_t *) (&svga->vram[svga->memaddr & svga->vram_display_mask]); if (svga->attrregs[0x10] & 0x80) @@ -1369,6 +1403,13 @@ svga_render_8bpp_tseng_highres(svga_t *svga) svga->memaddr += 8; p += 8; } + + if (svga->render_line_offset < 0) { + uint32_t *orig_line = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; + memmove(orig_line, orig_line + (8 * -svga->render_line_offset), (svga->hdisp) * 4); + memset((orig_line + svga->hdisp) - (8 * -svga->render_line_offset), svga->overscan_color, 8 * -svga->render_line_offset * 4); + } + svga->memaddr &= svga->vram_display_mask; } } From 474dfb666bd8c1ec797af1f0a619816cb652d877 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Jun 2025 19:12:56 +0200 Subject: [PATCH 081/103] Fixed two newly introduced warnings. --- src/video/vid_svga_render.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 5905a25dd..0c3252414 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -1292,13 +1292,11 @@ svga_render_8bpp_tseng_lowres(svga_t *svga) { uint32_t *p; uint32_t dat; - int x = 0; if ((svga->displine + svga->y_add) < 0) return; if (svga->changedvram[svga->memaddr >> 12] || svga->changedvram[(svga->memaddr >> 12) + 1] || svga->fullchange || svga->render_line_offset) { - int end = svga->hdisp + svga->scrollcache; p = &svga->monitor->target_buffer->line[svga->displine + svga->y_add][svga->x_add]; if (svga->firstline_draw == 2000) From 54b2f4237d1a304542bf12772ea14fa3ead16553 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Mon, 30 Jun 2025 19:51:35 +0200 Subject: [PATCH 082/103] Adjust the timings of the 8514/A and compatibles (June 30th, 2025) --- src/video/vid_8514a.c | 3 ++- src/video/vid_ati_mach8.c | 14 ++++++++------ src/video/vid_svga.c | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index b1e38fef7..c8191a876 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -3819,7 +3819,7 @@ ibm8514_recalctimings(svga_t *svga) } else { if (dev->on) { dev->hdisp = (dev->hdisped + 1) << 3; - dev->h_total = (dev->htotal + 1) << 3; + dev->h_total = dev->htotal + 1; if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ dev->h_total = 0x9e; @@ -3854,6 +3854,7 @@ ibm8514_recalctimings(svga_t *svga) dev->h_disp = dev->hdisp; dev->dispend = dev->vdisp; + dev->h_disp_time = dev->hdisp >> 3; if (dev->accel.advfunc_cntl & 0x04) svga->clock_8514 = (cpuclock * (double) (1ULL << 32)) / 44900000.0; diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index c5cb2ccca..df8965caf 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2707,9 +2707,9 @@ mach_set_resolution(mach_t *mach, svga_t *svga) { ibm8514_t *dev = (ibm8514_t *) svga->dev8514; - dev->h_total = (dev->htotal + 1) << 3; + dev->h_total = (dev->htotal + 1); if (dev->h_total == 8) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->h_total = 0x9e << 3; + dev->h_total = 0x9e; dev->hdisp = (dev->hdisped + 1) << 3; @@ -2730,7 +2730,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) switch (mach->shadow_set & 0x03) { case 0x01: if (!(dev->accel.advfunc_cntl & 0x04)) { - dev->h_total = 0x64 << 3; + dev->h_total = 0x64; dev->hdisp = 640; dev->vdisp = 480; dev->v_total = 0x0419; @@ -2739,7 +2739,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) break; case 0x02: if (dev->accel.advfunc_cntl & 0x04) { - dev->h_total = 0x9e << 3; + dev->h_total = 0x9e; dev->hdisp = 1024; dev->vdisp = 768; dev->v_total = 0x0669; @@ -2754,7 +2754,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) } else if ((dev->disp_cntl >> 5) == 2) { /*Reset 8514/A to defaults if needed.*/ if (dev->accel.advfunc_cntl & 0x04) { if (dev->hdisp == 640) { - dev->h_total = 0x9e << 3; + dev->h_total = 0x9e; dev->hdisp = 1024; dev->vdisp = 768; dev->v_total = 0x0669; @@ -2763,7 +2763,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) } } else { if (dev->hdisp == 1024) { - dev->h_total = 0x64 << 3; + dev->h_total = 0x64; dev->hdisp = 640; dev->vdisp = 480; dev->v_total = 0x0419; @@ -2926,6 +2926,8 @@ mach_recalctimings(svga_t *svga) else if (dev->h_disp == 640) dev->dispend = 480; + dev->h_disp_time = dev->hdisp >> 3; + svga->clock_8514 = (cpuclock * (double) (1ULL << 32)) / svga->getclock((mach->accel.clock_sel >> 2) & 0x0f, svga->clock_gen); if (mach->accel.clock_sel & 0x40) svga->clock_8514 *= 2; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 5f2d2d89c..8ed71645e 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1031,7 +1031,7 @@ svga_recalctimings(svga_t *svga) svga->y_add = svga->vtotal - svga->vblankend - 1; svga->monitor->mon_overscan_y = svga->y_add + abs(svga->vblankstart - svga->dispend); - if ((svga->dispend >= 2048) || (svga->y_add < 0)) { + if ((dev->dispend >= 2048) || (svga->y_add < 0)) { svga->y_add = 0; svga->monitor->mon_overscan_y = 0; } @@ -1094,7 +1094,7 @@ svga_recalctimings(svga_t *svga) if (ibm8514_active && (svga->dev8514 != NULL)) { if (dev->on) { disptime8514 = dev->h_total; - _dispontime8514 = dev->h_disp; + _dispontime8514 = dev->h_disp_time; svga_log("HTOTAL=%d, HDISP=%d.\n", dev->h_total, dev->h_disp); } } From aef9d1ed94e19a8951967eedd2ee5209e5bbe4e4 Mon Sep 17 00:00:00 2001 From: Daniel Gurney Date: Tue, 1 Jul 2025 03:04:14 +0300 Subject: [PATCH 083/103] Revert "Merge branch 'bugfixes' into master" This reverts commit 8250b57325d7b6c85309ee46c97d12c0ec51edc2, reversing changes made to 6c643d05b8d58269ae80125a2f6d392d85c7c388. --- src/include/86box/vid_8514a.h | 92 ++++-- src/include/86box/vid_ati_eeprom.h | 2 +- src/include/86box/vid_ega.h | 127 ++++---- src/include/86box/vid_svga.h | 3 +- src/include/86box/vid_xga.h | 16 +- src/video/ramdac/vid_ramdac_bt48x.c | 2 +- src/video/ramdac/vid_ramdac_ibm_rgb528.c | 2 +- src/video/ramdac/vid_ramdac_tvp3026.c | 6 +- src/video/vid_8514a.c | 196 +++++++------ src/video/vid_ati_eeprom.c | 12 +- src/video/vid_ati_mach64.c | 14 +- src/video/vid_ati_mach8.c | 354 ++++++++++++----------- src/video/vid_chips_69000.c | 2 +- src/video/vid_cl54xx.c | 4 +- src/video/vid_ega.c | 5 + src/video/vid_et4000w32.c | 2 +- src/video/vid_ht216.c | 2 +- src/video/vid_mga.c | 9 +- src/video/vid_ps55da2.c | 3 + src/video/vid_s3.c | 16 +- src/video/vid_s3_virge.c | 12 +- src/video/vid_svga.c | 79 ++++- src/video/vid_tgui9440.c | 2 +- src/video/vid_voodoo_banshee.c | 8 +- src/video/vid_xga.c | 58 ++-- 25 files changed, 616 insertions(+), 412 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 9109dd9ab..5aa8927e0 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -18,8 +18,6 @@ #ifndef VIDEO_8514A_H #define VIDEO_8514A_H -#include - #define INT_VSY (1 << 0) #define INT_GE_BSY (1 << 1) #define INT_FIFO_OVR (1 << 2) @@ -46,34 +44,39 @@ typedef enum { MODE_MAX } ibm8514_mode_t; -typedef struct ibm8514_hwcursor_s { - int enable; +typedef struct hwcursor8514_t { + int ena; int x; int y; int xoff; int yoff; int cur_xsize; int cur_ysize; + int v_acc; + int h_acc; uint32_t addr; uint32_t pitch; -} ibm8514_hwcursor_t; +} hwcursor8514_t; typedef union { uint64_t q; uint32_t d[2]; uint16_t w[4]; uint8_t b[8]; -} ibm8514_latch_t; +} latch8514_t; typedef struct ibm8514_t { rom_t bios_rom; rom_t bios_rom2; mem_mapping_t bios_mapping; - ibm8514_hwcursor_t hwcursor; - ibm8514_hwcursor_t hwcursor_latch; + uint8_t *rom1; + uint8_t *rom2; + hwcursor8514_t hwcursor; + hwcursor8514_t hwcursor_latch; uint8_t pos_regs[8]; char *rom_path; + int force_old_addr; int type; ibm8514_card_type local; int bpp; @@ -96,14 +99,18 @@ typedef struct ibm8514_t { int dac_r; int dac_g; int dac_b; + int internal_pitch; int hwcursor_on; + int modechange; uint64_t dispontime; uint64_t dispofftime; struct { uint16_t subsys_cntl; + uint16_t setup_md; uint16_t advfunc_cntl; + uint16_t advfunc_cntl_old; uint16_t cur_y; uint16_t cur_x; int16_t destx; @@ -131,51 +138,84 @@ typedef struct ibm8514_t { uint16_t clip_bottom; int16_t clip_left; int16_t clip_top; + uint8_t pix_trans[2]; + int poly_draw; int ssv_state; - + int x1; + int x2; + int x3; + int y1; + int y2; int temp_cnt; + int16_t dx_ibm; + int16_t dy_ibm; int16_t cx; + int16_t cx_back; int16_t cy; - /* oldcx was not used! */ + int16_t oldcx; int16_t oldcy; int16_t sx; int16_t sy; int16_t dx; int16_t dy; + int16_t err; uint32_t src; uint32_t dest; int x_count; - /* y_count not used */ + int xx_count; + int y_count; int input; int input2; int output; + int output2; int ssv_len; int ssv_len_back; uint8_t ssv_dir; uint8_t ssv_draw; int odd_in; + int odd_out; + uint16_t scratch; int fill_state; + int xdir; + int ydir; + int linedraw; uint32_t ge_offset; uint32_t src_ge_offset; uint32_t dst_ge_offset; uint16_t src_pitch; uint16_t dst_pitch; + int64_t cur_x_24bpp; + int64_t cur_y_24bpp; + int64_t dest_x_24bpp; + int64_t dest_y_24bpp; } accel; + uint16_t test; + int h_blankstart; + int h_blank_end_val; int hblankstart; + int hblank_end_val; int hblankend; - int vtotal_reg; - int vtotal_8514; + int hblank_ext; + int hblank_sub; + + int v_total_reg; + int v_total; int dispend; - int vsyncstart; + int v_sync_start; + int v_syncstart; int split; - int hdisp_8514; - int htotal_8514; + int h_disp; + int h_total; + int h_sync_start; + int h_sync_width; + int h_disp_time; int rowoffset; int dispon; - int hdispon; + int hdisp_on; + int linecountff; int vc; int linepos; int oddeven; @@ -196,27 +236,34 @@ typedef struct ibm8514_t { uint8_t linedbl; uint8_t data_available; + uint8_t data_available2; uint8_t rowcount; int hsync_start; int hsync_width; int htotal; - int hdisp_vga; + int hdisp; + int hdisp2; int hdisped; int scanline; + int vsyncstart; int vsyncwidth; int vtotal; - int vdisp_8514; - int vdisp_vga; + int v_disp; + int v_disp2; + int vdisp; + int vdisp2; int disp_cntl; int interlace; uint16_t subsys_cntl; uint8_t subsys_stat; atomic_int force_busy; + atomic_int force_busy2; atomic_int fifo_idx; int blitter_busy; uint64_t blitter_time; + uint64_t status_time; int pitch; int ext_pitch; int ext_crt_pitch; @@ -224,15 +271,14 @@ typedef struct ibm8514_t { ibm8514_mode_t mode; int onboard; int linear; - bool vram_is_512k; - uint32_t vram_amount; + int vram_512k_8514; int vendor_mode; int _8514on; int _8514crt; PALETTE _8514pal; - ibm8514_latch_t latch; + latch8514_t latch; void (*vblank_start)(void *priv); void (*accel_out_fifo)(void *priv, uint16_t port, uint16_t val, int len); diff --git a/src/include/86box/vid_ati_eeprom.h b/src/include/86box/vid_ati_eeprom.h index 84e09f946..c52b5bd4b 100644 --- a/src/include/86box/vid_ati_eeprom.h +++ b/src/include/86box/vid_ati_eeprom.h @@ -49,7 +49,7 @@ typedef struct ati_eeprom_t { void ati_eeprom_load(ati_eeprom_t *eeprom, char *fn, int type); void ati_eeprom_load_mach8(ati_eeprom_t *eeprom, char *fn, int mca); void ati_eeprom_load_mach8_vga(ati_eeprom_t *eeprom, char *fn); -void ati_eeprom_write(ati_eeprom_t *eeprom, int enable, int clk, int dat); +void ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat); int ati_eeprom_read(ati_eeprom_t *eeprom); #endif /*VIDEO_ATI_EEPROM_H*/ diff --git a/src/include/86box/vid_ega.h b/src/include/86box/vid_ega.h index caa8a63d5..beef6f98d 100644 --- a/src/include/86box/vid_ega.h +++ b/src/include/86box/vid_ega.h @@ -13,18 +13,14 @@ * * Authors: Sarah Walker, * Miran Grca, - * Connor Hyde / starfrost, * * Copyright 2008-2020 Sarah Walker. * Copyright 2016-2020 Miran Grca. - * Copyright 2025 Connor Hyde. */ #ifndef VIDEO_EGA_H #define VIDEO_EGA_H -#include - #if defined(EMU_MEM_H) && defined(EMU_ROM_H) typedef struct ega_t { mem_mapping_t mapping; @@ -61,52 +57,65 @@ typedef struct ega_t { uint16_t light_pen; - int32_t vidclock; - int32_t vres; - int32_t readmode; - int32_t writemode; - int32_t readplane; - int32_t vrammask; - int32_t chain4; - int32_t chain2_read; - int32_t chain2_write; - int32_t cursorvisible; - int32_t vc; - int32_t real_vc; - int32_t scanline; - int32_t dispon; - int32_t cursoron; - int32_t blink; - int32_t fullchange; - int32_t linepos; - int32_t vslines; - int32_t linecountff; - int32_t oddeven; - int32_t interlace; - int32_t linedbl; - int32_t rowcount; - int32_t vtotal; - int32_t dispend; - int32_t vsyncstart; - int32_t split; - int32_t hdisp; - int32_t htotal; - int32_t rowoffset; - int32_t vblankstart; - int32_t scrollcache; - int32_t firstline; - int32_t lastline; - int32_t firstline_draw; - int32_t lastline_draw; - int32_t x_add; - int32_t y_add; - int32_t displine; - int32_t index; - bool remap_required; - int32_t actual_type; - int32_t chipset; + int vidclock; + int fast; + int extvram; + int vres; + int readmode; + int writemode; + int readplane; + int vrammask; + int chain4; + int chain2_read; + int chain2_write; + int cursorvisible; + int oddeven_page; + int oddeven_chain; + int vc; + int real_vc; + int scanline; + int dispon; + int hdisp_on; + int cursoron; + int blink; + int fullchange; + int linepos; + int vslines; + int linecountff; + int oddeven; + int lowres; + int interlace; + int linedbl; + int lindebl; + int rowcount; + int vtotal; + int dispend; + int vsyncstart; + int split; + int hdisp; + int hdisp_old; + int htotal; + int hdisp_time; + int rowoffset; + int vblankstart; + int scrollcache; + int firstline; + int lastline; + int firstline_draw; + int lastline_draw; + int x_add; + int y_add; + int displine; + int res_x; + int res_y; + int bpp; + int index; + int remap_required; + int actual_type; + int chipset; + int mono_display; - int32_t mda_attr_to_color_table[256][2][2]; + int mda_attr_to_color_table[256][2][2]; uint32_t charseta; uint32_t charsetb; @@ -155,7 +164,7 @@ extern const device_t jega_device; extern const device_t jvga_device; #endif -extern int32_t update_overscan; +extern int update_overscan; #define DISPLAY_RGB 0 #define DISPLAY_COMPOSITE 1 @@ -165,7 +174,7 @@ extern int32_t update_overscan; #define DISPLAY_WHITE 5 #if defined(EMU_MEM_H) && defined(EMU_ROM_H) -extern void ega_init(ega_t *ega, int32_t monitor_type, int32_t is_mono); +extern void ega_init(ega_t *ega, int monitor_type, int is_mono); extern void ega_recalctimings(struct ega_t *ega); extern void ega_recalc_remap_func(struct ega_t *ega); #endif @@ -177,18 +186,18 @@ extern void ega_write(uint32_t addr, uint8_t val, void *priv); extern uint8_t ega_read(uint32_t addr, void *priv); extern void ega_set_type(void *priv, uint32_t local); -extern int32_t firstline_draw; -extern int32_t lastline_draw; -extern int32_t displine; -extern int32_t scanline; +extern int firstline_draw; +extern int lastline_draw; +extern int displine; +extern int scanline; extern uint32_t memaddr; extern uint32_t cursoraddr; -extern int32_t cursorvisible; -extern int32_t cursoron; -extern int32_t cgablink; +extern int cursorvisible; +extern int cursoron; +extern int cgablink; -extern int32_t scrollcache; +extern int scrollcache; extern uint8_t edatlookup[4][4]; extern uint8_t egaremap2bpp[256]; diff --git a/src/include/86box/vid_svga.h b/src/include/86box/vid_svga.h index 610372c4c..14f3c933a 100644 --- a/src/include/86box/vid_svga.h +++ b/src/include/86box/vid_svga.h @@ -34,7 +34,7 @@ struct monitor_t; typedef struct hwcursor_t { - int enable; + int ena; int x; int y; int xoff; @@ -99,6 +99,7 @@ typedef struct svga_t { int hdisp_time; int rowoffset; int dispon; + int hdisp_on; int vc; int scanline; int linepos; diff --git a/src/include/86box/vid_xga.h b/src/include/86box/vid_xga.h index a8c7e09cd..e72c7af40 100644 --- a/src/include/86box/vid_xga.h +++ b/src/include/86box/vid_xga.h @@ -20,7 +20,7 @@ #include <86box/rom.h> typedef struct xga_hwcursor_t { - int enable; + int ena; int x; int y; int xoff; @@ -114,16 +114,18 @@ typedef struct xga_t { int dac_pos; int dac_r; int dac_g; - int vtotal_xga; + int v_total; int dispend; + int v_syncstart; int split; - int vblankstart_xga; - int hdisp_xga; - int hdispold_xga; - int htotal_xga; + int v_blankstart; + int h_disp; + int h_disp_old; + int h_total; + int h_disp_time; int rowoffset; int dispon; - int hdispon_xga; + int h_disp_on; int vc; int scanline; int linepos; diff --git a/src/video/ramdac/vid_ramdac_bt48x.c b/src/video/ramdac/vid_ramdac_bt48x.c index 0a70afdbd..d608750e3 100644 --- a/src/video/ramdac/vid_ramdac_bt48x.c +++ b/src/video/ramdac/vid_ramdac_bt48x.c @@ -161,7 +161,7 @@ bt48x_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svga_ break; case 0x09: /* Command Register 2 (RS value = 1001) */ ramdac->cmd_r2 = val; - svga->dac_hwcursor.enable = !!(val & 0x03); + svga->dac_hwcursor.ena = !!(val & 0x03); bt48x_set_bpp(ramdac, svga); break; case 0x0a: diff --git a/src/video/ramdac/vid_ramdac_ibm_rgb528.c b/src/video/ramdac/vid_ramdac_ibm_rgb528.c index 947c251e9..cd7d5c1b6 100644 --- a/src/video/ramdac/vid_ramdac_ibm_rgb528.c +++ b/src/video/ramdac/vid_ramdac_ibm_rgb528.c @@ -631,7 +631,7 @@ ibm_rgb528_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *s } svga->dac_hwcursor.addr = ramdac->smlc_part; svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = (val & 0x04) ? 64 : 32; - svga->dac_hwcursor.enable = ((val & 0x03) != 0x00); + svga->dac_hwcursor.ena = ((val & 0x03) != 0x00); break; case 0x031: if (!updt_cntl) diff --git a/src/video/ramdac/vid_ramdac_tvp3026.c b/src/video/ramdac/vid_ramdac_tvp3026.c index e80aeedab..bd5a83fd0 100644 --- a/src/video/ramdac/vid_ramdac_tvp3026.c +++ b/src/video/ramdac/vid_ramdac_tvp3026.c @@ -170,7 +170,7 @@ tvp3026_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svg svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = 64; svga->dac_hwcursor.x = ramdac->hwc_x - svga->dac_hwcursor.cur_xsize; svga->dac_hwcursor.y = ramdac->hwc_y - svga->dac_hwcursor.cur_ysize; - svga->dac_hwcursor.enable = !!(val & 0x03); + svga->dac_hwcursor.ena = !!(val & 0x03); ramdac->mode = val & 0x03; } break; @@ -182,13 +182,13 @@ tvp3026_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svg svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = 64; svga->dac_hwcursor.x = ramdac->hwc_x - svga->dac_hwcursor.cur_xsize; svga->dac_hwcursor.y = ramdac->hwc_y - svga->dac_hwcursor.cur_ysize; - svga->dac_hwcursor.enable = !!(val & 0x03); + svga->dac_hwcursor.ena = !!(val & 0x03); ramdac->mode = val & 0x03; } else { svga->dac_hwcursor.cur_xsize = svga->dac_hwcursor.cur_ysize = 64; svga->dac_hwcursor.x = ramdac->hwc_x - svga->dac_hwcursor.cur_xsize; svga->dac_hwcursor.y = ramdac->hwc_y - svga->dac_hwcursor.cur_ysize; - svga->dac_hwcursor.enable = !!(ramdac->dcc & 0x03); + svga->dac_hwcursor.ena = !!(ramdac->dcc & 0x03); ramdac->mode = ramdac->dcc & 0x03; } break; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index d5cdbe64a..c8191a876 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -376,19 +376,19 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x12e8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->vtotal_reg = val; - dev->vtotal_reg &= 0x1fff; + dev->v_total_reg = val; + dev->v_total_reg &= 0x1fff; ibm8514_log("IBM 8514/A compatible: (0x%04x): vtotal=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->vtotal_reg, val); + WRITE8(port, dev->v_total_reg, val); } break; case 0x12e9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->vtotal_reg, val >> 8); - dev->vtotal_reg &= 0x1fff; + WRITE8(port, dev->v_total_reg, val >> 8); + dev->v_total_reg &= 0x1fff; ibm8514_log("IBM 8514/A compatible: (0x%04x): vtotal=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -397,21 +397,21 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x16e8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->vdisp_8514 = val; - dev->vdisp_8514 &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_8514); + dev->v_disp = val; + dev->v_disp &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->v_disp); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->vdisp_8514, val); + WRITE8(port, dev->v_disp, val); } break; case 0x16e9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->vdisp_8514, val >> 8); - dev->vdisp_8514 &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_8514); + WRITE8(port, dev->v_disp, val >> 8); + dev->v_disp &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->v_disp); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -420,26 +420,25 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x1ae8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->vsyncstart = val; - dev->vsyncstart &= 0x1fff; - ibm8514_log("IBM 8514/A compatible: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); + dev->v_sync_start = val; + dev->v_sync_start &= 0x1fff; + ibm8514_log("IBM 8514/A compatible: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); ibm8514_log("IBM 8514/A compatible: (0x%04x): vsyncstart=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->vsyncstart, val); + WRITE8(port, dev->v_sync_start, val); } break; case 0x1ae9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->vsyncstart, val >> 8); - dev->vsyncstart &= 0x1fff; - dev->vsyncstart++; - // change this if it breaks + WRITE8(port, dev->v_sync_start, val >> 8); + dev->v_sync_start &= 0x1fff; + dev->v_syncstart = dev->v_sync_start + 1; if (dev->interlace) - dev->vsyncstart >>= 1; + dev->v_syncstart >>= 1; - ibm8514_log("IBM 8514/A compatible: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); + ibm8514_log("IBM 8514/A compatible: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); ibm8514_log("IBM 8514/A compatible: (0x%04x): vsyncstart=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -466,6 +465,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) dev->subsys_stat &= ~val; if ((val & 0xc000) == 0x8000) { dev->force_busy = 0; + dev->force_busy2 = 0; } } else { WRITE8(port, dev->subsys_cntl, val); @@ -477,6 +477,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) WRITE8(port, dev->subsys_cntl, val); if ((val & 0xc0) == 0x80) { dev->force_busy = 0; + dev->force_busy2 = 0; } } break; @@ -484,7 +485,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x4ae8: WRITE8(port, dev->accel.advfunc_cntl, val); dev->on = dev->accel.advfunc_cntl & 0x01; - ibm8514_log("[%04X:%08X]: IBM 8514/A: (0x%04x): ON=%d, shadow crt=%x, hdisp=%d, vdisp=%d.\n", CS, cpu_state.pc, port, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp_vga, dev->vdisp_vga); + ibm8514_log("[%04X:%08X]: IBM 8514/A: (0x%04x): ON=%d, shadow crt=%x, hdisp=%d, vdisp=%d.\n", CS, cpu_state.pc, port, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp, dev->vdisp); ibm8514_log("IBM mode set %s resolution.\n", (dev->accel.advfunc_cntl & 0x04) ? "2: 1024x768" : "1: 640x480"); svga_recalctimings(svga); break; @@ -519,6 +520,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x92e8: if (len == 2) { + dev->test = val; dev->accel.err_term = val & 0x3fff; if (val & 0x2000) dev->accel.err_term |= ~0x1fff; @@ -536,6 +538,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) dev->accel.ssv_state = 0; if (len == 2) { dev->data_available = 0; + dev->data_available2 = 0; dev->accel.cmd = val; dev->accel.cmd_back = 1; if (dev->accel.cmd & 0x100) @@ -787,7 +790,7 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) case 0x92e8: if (len == 2) - temp = dev->accel.err_term; + temp = dev->test; break; case 0x96e8: @@ -845,12 +848,12 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) if (len == 1) { dev->fifo_idx = 0; - if (dev->force_busy) + if (dev->force_busy2) temp |= 0x02; /*Hardware busy*/ - dev->force_busy = 0; + dev->force_busy2 = 0; - if (dev->data_available) { + if (dev->data_available2) { temp |= 0x01; /*Read Data available*/ switch (dev->accel.cmd >> 13) { case 2: @@ -858,11 +861,11 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) case 4: case 6: if (dev->accel.sy < 0) - dev->data_available = 0; + dev->data_available2 = 0; break; default: if (!dev->accel.sy) - dev->data_available = 0; + dev->data_available2 = 0; break; } } @@ -908,9 +911,11 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) switch (port) { case 0x2e8: + if (dev->vc == dev->v_syncstart) { + if (dev->accel.advfunc_cntl & 0x04) + temp |= 0x02; + } - if (dev->vc == dev->vsyncstart && dev->accel.advfunc_cntl & 0x04) - temp |= 0x02; ibm8514_log("Read: Display Status1=%02x.\n", temp); break; @@ -960,10 +965,12 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) if (!dev->fifo_idx && !dev->on) { dev->force_busy = 0; + dev->force_busy2 = 0; dev->data_available = 0; + dev->data_available2 = 0; temp |= INT_FIFO_EMP; } - temp |= (dev->subsys_stat | (dev->vram_is_512k ? 0x00 : 0x80)); + temp |= (dev->subsys_stat | (dev->vram_512k_8514 ? 0x00 : 0x80)); temp |= 0x20; } break; @@ -1016,7 +1023,9 @@ ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t if (ibm8514_cpu_src(svga)) { dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 0; + dev->data_available2 = 0; return; /*Wait for data from CPU*/ } } @@ -1230,6 +1239,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.ssv_len) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1330,6 +1340,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.ssv_len) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1397,11 +1408,15 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } } dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 0; + dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 1; + dev->data_available2 = 1; return; } } @@ -1509,6 +1524,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1633,6 +1649,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1740,6 +1757,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1843,7 +1861,9 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } } dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 0; + dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { if (!(dev->accel.cmd & 0x02)) { @@ -1860,7 +1880,9 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } ibm8514_log("INPUT=%d.\n", dev->accel.input); dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 1; + dev->data_available2 = 1; return; /*Wait for data from CPU*/ } } @@ -2014,6 +2036,7 @@ skip_vector_rect_write: if (dev->accel.sy < 0) { dev->force_busy = 0; + dev->force_busy2 = 0; dev->fifo_idx = 0; dev->accel.cmd_back = 1; } @@ -2175,6 +2198,7 @@ skip_nibble_rect_write: dev->accel.cmd_back = 1; } dev->force_busy = 0; + dev->force_busy2 = 0; return; } } @@ -2408,7 +2432,7 @@ skip_nibble_rect_write: ((compare_mode == 0x28) && (dest_dat == compare)) || ((compare_mode == 0x30) && (dest_dat <= compare)) || ((compare_mode == 0x38) && (dest_dat > compare))) { - ibm8514_log("Results c(%d,%d):rdmask=%02x, wrtmask=%02x, mix=%02x, destdat=%02x\n", dev->accel.cx, dev->accel.cy, rd_mask_polygon, wrt_mask, mix_dat, dest_dat); + ibm8514_log("Results c(%d,%d):rdmask=%02x, wrtmask=%02x, mix=%02x, destdat=%02x, nowrite=%d.\n", dev->accel.cx, dev->accel.cy, rd_mask_polygon, wrt_mask, mix_dat, dest_dat, dev->accel.cx_back); WRITE(dev->accel.dest + dev->accel.cx, dest_dat); } } else @@ -2558,11 +2582,15 @@ skip_nibble_rect_write: if (ibm8514_cpu_src(svga)) { dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 0; + dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 1; + dev->data_available2 = 1; return; } } @@ -2631,6 +2659,7 @@ skip_nibble_rect_write: if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -2739,6 +2768,7 @@ skip_nibble_rect_write: if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -2826,11 +2856,15 @@ skip_nibble_rect_write: } } dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 0; + dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; + dev->force_busy2 = 1; dev->data_available = 1; + dev->data_available2 = 1; return; /*Wait for data from CPU*/ } else ibm8514_log("BitBLT normal: Parameters: DX=%d, DY=%d, CX=%d, CY=%d, dstwidth=%d, dstheight=%d, clipl=%d, clipr=%d, clipt=%d, clipb=%d.\n", dev->accel.dx, dev->accel.dy, dev->accel.cx, dev->accel.cy, dev->accel.sx, dev->accel.sy, clip_l, clip_r, clip_t, clip_b); @@ -2985,6 +3019,7 @@ skip_nibble_bitblt_write: if (dev->accel.sy < 0) { dev->accel.cmd_back = 1; dev->force_busy = 0; + dev->force_busy2 = 0; dev->fifo_idx = 0; } return; @@ -3334,9 +3369,9 @@ ibm8514_render_blank(svga_t *svga) dev->lastline_draw = dev->displine; uint32_t *line_ptr = &buffer32->line[dev->displine + svga->y_add][svga->x_add]; - uint32_t line_width = (uint32_t)(dev->hdisp_8514) * sizeof(uint32_t); + uint32_t line_width = (uint32_t)(dev->h_disp) * sizeof(uint32_t); - if (dev->hdisp_8514 > 0) + if (dev->h_disp > 0) memset(line_ptr, 0, line_width); } @@ -3357,7 +3392,7 @@ ibm8514_render_8bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->hdisp_8514; x += 8) { + for (int x = 0; x <= dev->h_disp; x += 8) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[0] = dev->pallook[dat & dev->dac_mask & 0xff]; p[1] = dev->pallook[(dat >> 8) & dev->dac_mask & 0xff]; @@ -3395,7 +3430,7 @@ ibm8514_render_15bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->hdisp_8514; x += 8) { + for (x = 0; x <= dev->h_disp; x += 8) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 1)) & dev->vram_mask]); p[x] = video_15to32[dat & 0xffff]; p[x + 1] = video_15to32[dat >> 16]; @@ -3435,7 +3470,7 @@ ibm8514_render_16bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->hdisp_8514; x += 8) { + for (x = 0; x <= dev->h_disp; x += 8) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 1)) & dev->vram_mask]); p[x] = video_16to32[dat & 0xffff]; p[x + 1] = video_16to32[dat >> 16]; @@ -3474,7 +3509,7 @@ ibm8514_render_24bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->hdisp_8514; x += 4) { + for (int x = 0; x <= dev->h_disp; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = dat & 0xffffff; @@ -3510,7 +3545,7 @@ ibm8514_render_BGR(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->hdisp_8514; x += 4) { + for (int x = 0; x <= dev->h_disp; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); @@ -3547,7 +3582,7 @@ ibm8514_render_ABGR8888(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->hdisp_8514; x++) { + for (x = 0; x <= dev->h_disp; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); } @@ -3574,7 +3609,7 @@ ibm8514_render_32bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->hdisp_8514; x++) { + for (x = 0; x <= dev->h_disp; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); p[x] = dat & 0xffffff; } @@ -3589,7 +3624,7 @@ ibm8514_render_overscan_left(ibm8514_t *dev, svga_t *svga) if ((dev->displine + svga->y_add) < 0) return; - if (svga->scrblank || (dev->hdisp_8514 == 0)) + if (svga->scrblank || (dev->h_disp == 0)) return; for (int i = 0; i < svga->x_add; i++) @@ -3604,12 +3639,12 @@ ibm8514_render_overscan_right(ibm8514_t *dev, svga_t *svga) if ((dev->displine + svga->y_add) < 0) return; - if (svga->scrblank || (dev->hdisp_8514 == 0)) + if (svga->scrblank || (dev->h_disp == 0)) return; right = (overscan_x >> 1); for (int i = 0; i < right; i++) - buffer32->line[dev->displine + svga->y_add][svga->x_add + dev->hdisp_8514 + i] = svga->overscan_color; + buffer32->line[dev->displine + svga->y_add][svga->x_add + dev->h_disp + i] = svga->overscan_color; } void @@ -3631,12 +3666,12 @@ ibm8514_poll(void *priv) if (dev->on) { ibm8514_log("ON!\n"); if (!dev->linepos) { - if ((dev->displine == ((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y)) && dev->hwcursor_latch.enable) { + if ((dev->displine == ((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y)) && dev->hwcursor_latch.ena) { dev->hwcursor_on = dev->hwcursor_latch.cur_ysize - dev->hwcursor_latch.yoff; dev->hwcursor_oddeven = 0; } - if ((dev->displine == (((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y) + 1)) && dev->hwcursor_latch.enable && dev->interlace) { + if ((dev->displine == (((dev->hwcursor_latch.y < 0) ? 0 : dev->hwcursor_latch.y) + 1)) && dev->hwcursor_latch.ena && dev->interlace) { dev->hwcursor_on = dev->hwcursor_latch.cur_ysize - (dev->hwcursor_latch.yoff + 1); dev->hwcursor_oddeven = 1; } @@ -3646,6 +3681,7 @@ ibm8514_poll(void *priv) dev->linepos = 1; if (dev->dispon) { + dev->hdisp_on = 1; dev->memaddr &= dev->vram_mask; @@ -3688,6 +3724,7 @@ ibm8514_poll(void *priv) timer_advance_u64(&svga->timer, dev->dispontime); if (dev->dispon) svga->cgastat &= ~1; + dev->hdisp_on = 0; dev->linepos = 0; if (dev->dispon) { @@ -3722,10 +3759,10 @@ ibm8514_poll(void *priv) if (svga->fullchange) svga->fullchange--; } - if (dev->vc == dev->vsyncstart) { + if (dev->vc == dev->v_syncstart) { dev->dispon = 0; svga->cgastat |= 8; - x = dev->hdisp_8514; + x = dev->h_disp; if (dev->interlace && !dev->oddeven) dev->lastline++; @@ -3755,7 +3792,7 @@ ibm8514_poll(void *priv) dev->memaddr = (dev->memaddr << 2); dev->memaddr_backup = (dev->memaddr_backup << 2); } - if (dev->vc == dev->vtotal_8514) { + if (dev->vc == dev->v_total) { dev->vc = 0; dev->scanline = (svga->crtc[0x8] & 0x1f); dev->dispon = 1; @@ -3781,48 +3818,43 @@ ibm8514_recalctimings(svga_t *svga) ati8514_recalctimings(svga); } else { if (dev->on) { - dev->hdisp_vga = (dev->hdisped + 1) << 3; - dev->htotal_8514 = dev->htotal + 1; + dev->hdisp = (dev->hdisped + 1) << 3; + dev->h_total = dev->htotal + 1; - if (dev->htotal_8514 == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->htotal_8514 = 0x9e; + if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ + dev->h_total = 0x9e; - dev->vdisp_vga = (dev->vdisp_8514 + 1) >> 1; - if ((dev->vdisp_vga == 478) || (dev->vdisp_vga == 766)) - dev->vdisp_vga += 2; - - dev->vtotal_8514 = dev->vtotal_reg + 1; - if (dev->vtotal_8514 == 1) - dev->vtotal_8514 = 0x0669; - + dev->vdisp = (dev->v_disp + 1) >> 1; + if ((dev->vdisp == 478) || (dev->vdisp == 766)) + dev->vdisp += 2; + dev->v_total = dev->v_total_reg + 1; + if (dev->v_total == 1) + dev->v_total = 0x0669; if (dev->interlace) - dev->vtotal_8514 >>= 1; - - dev->vsyncstart++; - - dev->vsyncstart_8514 = dev-vsyncstart_8514 + 1; - if (dev->vsyncstart_8514 == 1) - dev->vsyncstart_8514 = 0x0601; + dev->v_total >>= 1; + dev->v_syncstart = dev->v_sync_start + 1; + if (dev->v_syncstart == 1) + dev->v_syncstart = 0x0601; if (dev->interlace) - dev->vsyncstart >>= 1; + dev->v_syncstart >>= 1; dev->rowcount = !!(dev->disp_cntl & 0x08); - if ((dev->hdisp_vga != 640) && (dev->hdisp_vga != 1024)) { + if ((dev->hdisp != 640) && (dev->hdisp != 1024)) { if (dev->accel.advfunc_cntl & 0x04) { - dev->hdisp_vga = 1024; - dev->vdisp_vga = 768; + dev->hdisp = 1024; + dev->vdisp = 768; } else { - dev->hdisp_vga = 640; - dev->vdisp_vga = 480; + dev->hdisp = 640; + dev->vdisp = 480; } } - dev->hdisp_8514 = dev->hdisp_vga; - dev->dispend = dev->vdisp_vga; - + dev->h_disp = dev->hdisp; + dev->dispend = dev->vdisp; + dev->h_disp_time = dev->hdisp >> 3; if (dev->accel.advfunc_cntl & 0x04) svga->clock_8514 = (cpuclock * (double) (1ULL << 32)) / 44900000.0; @@ -3837,8 +3869,8 @@ ibm8514_recalctimings(svga_t *svga) dev->pitch = 1024; dev->rowoffset = 0x80; - if (dev->vram_is_512k) { - if (dev->hdisp_8514 == 640) + if (dev->vram_512k_8514) { + if (dev->h_disp == 640) dev->pitch = 640; } dev->accel_bpp = 8; @@ -3846,7 +3878,7 @@ ibm8514_recalctimings(svga_t *svga) ibm8514_log("BPP=%d, Pitch = %d, rowoffset = %d, crtc13 = %02x, highres bit = %02x, has_vga? = %d.\n", dev->bpp, dev->pitch, dev->rowoffset, svga->crtc[0x13], dev->accel.advfunc_cntl & 4, !ibm8514_standalone_enabled); } } - ibm8514_log("8514 enabled, hdisp_vga=%d, vtotal=%d, htotal=%d, dispend=%d, rowoffset=%d, split=%d, vsyncstart=%d, split=%08x\n", dev->hdisp_vga, dev->vtotal, dev->htotal, dev->dispend, dev->rowoffset, dev->split, dev->vsyncstart, dev->split); + ibm8514_log("8514 enabled, hdisp=%d, vtotal=%d, htotal=%d, dispend=%d, rowoffset=%d, split=%d, vsyncstart=%d, split=%08x\n", dev->hdisp, dev->vtotal, dev->htotal, dev->dispend, dev->rowoffset, dev->split, dev->vsyncstart, dev->split); } static uint8_t @@ -3922,7 +3954,7 @@ ibm8514_init(const device_t *info) svga->ext8514 = NULL; dev->vram_amount = device_get_config_int("memory"); - dev->vram_is_512k = dev->vram_amount == 512; + dev->vram_512k_8514 = dev->vram_amount == 512; dev->vram_size = dev->vram_amount << 10; dev->vram = calloc(dev->vram_size, 1); dev->changedvram = calloc((dev->vram_size >> 12) + 1, 1); diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index 1efb506d1..a057f1f39 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -107,18 +107,18 @@ ati_eeprom_save(ati_eeprom_t *eeprom) } void -ati_eeprom_write(ati_eeprom_t *eeprom, int enable, int clk, int dat) +ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) { - if (!enable) + if (!ena) eeprom->out = 1; if (clk && !eeprom->oldclk) { - if (enable && !eeprom->oldena) { + if (ena && !eeprom->oldena) { eeprom->state = EEPROM_WAIT; eeprom->opcode = 0; eeprom->count = 3; eeprom->out = 1; - } else if (enable) { + } else if (ena) { switch (eeprom->state) { case EEPROM_WAIT: if (!dat) @@ -231,9 +231,9 @@ ati_eeprom_write(ati_eeprom_t *eeprom, int enable, int clk, int dat) break; } } - eeprom->oldena = enable; + eeprom->oldena = ena; } else if (!clk && eeprom->oldclk) { - if (enable) { + if (ena) { switch (eeprom->state) { case EEPROM_OUTPUT: eeprom->out = (eeprom->dat & 0x10000) ? 1 : 0; diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index a428b5ed3..2b89bddf4 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -256,6 +256,9 @@ typedef struct mach64_t { event_t *wake_fifo_thread; event_t *fifo_not_full_event; + uint64_t blitter_time; + uint64_t status_time; + uint16_t pci_id; uint32_t config_chip_id; uint32_t block_decoded_io; @@ -1187,6 +1190,8 @@ fifo_thread(void *param) thread_reset_event(mach64->wake_fifo_thread); mach64->blitter_busy = 1; while (!FIFO_EMPTY) { + uint64_t start_time = plat_timer_read(); + uint64_t end_time; fifo_entry_t *fifo = &mach64->fifo[mach64->fifo_read_idx & FIFO_MASK]; switch (fifo->addr_type & FIFO_TYPE) { @@ -1209,6 +1214,9 @@ fifo_thread(void *param) if (FIFO_ENTRIES > 0xe000) thread_set_event(mach64->fifo_not_full_event); + + end_time = plat_timer_read(); + mach64->blitter_time += end_time - start_time; } mach64->blitter_busy = 0; } @@ -2298,7 +2306,7 @@ mach64_vblank_start(svga_t *svga) svga->overlay.addr = mach64->buf_offset[0] & 0x3ffff8; svga->overlay.pitch = mach64->buf_pitch[0] & 0xfff; - svga->overlay.enable = (mach64->overlay_scale_cntl & OVERLAY_EN) && (overlay_cmp_mix != 1); + svga->overlay.ena = (mach64->overlay_scale_cntl & OVERLAY_EN) && (overlay_cmp_mix != 1); mach64->overlay_v_acc = 0; mach64->scaler_update = 1; @@ -3345,9 +3353,9 @@ mach64_ext_writeb(uint32_t addr, uint8_t val, void *priv) ati_eeprom_write(&mach64->eeprom, mach64->gen_test_cntl & 0x10, mach64->gen_test_cntl & 2, mach64->gen_test_cntl & 1); mach64->gen_test_cntl = (mach64->gen_test_cntl & ~8) | (ati_eeprom_read(&mach64->eeprom) ? 8 : 0); if (mach64->type == MACH64_GX) - svga->dac_hwcursor.enable = !!(mach64->gen_test_cntl & 0x80); + svga->dac_hwcursor.ena = !!(mach64->gen_test_cntl & 0x80); else - svga->hwcursor.enable = !!(mach64->gen_test_cntl & 0x80); + svga->hwcursor.ena = !!(mach64->gen_test_cntl & 0x80); break; case 0xdc: diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 842e56320..df8965caf 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -371,14 +371,18 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Extended Bresenham Write pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; + dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Extended Bresenham Read pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; + dev->data_available2 = 1; return; } } @@ -526,6 +530,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (cpu_input) { mach->force_busy = 0; dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -534,6 +539,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (cpu_input) { mach->force_busy = 0; dev->force_busy = 0; + dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -734,6 +740,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if ((mono_src == 1) && !count) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -742,6 +749,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 } else if ((mono_src != 1) && (dev->accel.sx >= mach->accel.width)) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -951,14 +959,18 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Non-Conforming BitBLT Write pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; + dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Non-Conforming BitBLT Read pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; + dev->data_available2 = 1; return; } } @@ -977,6 +989,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 mach_log("No DEST.\n"); if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -988,6 +1001,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach->accel.sx_end == mach->accel.sx_start) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } mach_log("No SRC.\n"); @@ -1004,6 +1018,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sy == mach->accel.height) { mach_log("No Blit on DPCONFIG=3251.\n"); dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1213,6 +1228,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sy >= mach->accel.height) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1260,14 +1276,18 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Direct Linedraw Write pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; + dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Direct Linedraw Read pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; + dev->data_available2 = 1; return; } } @@ -1372,6 +1392,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (!count) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1517,6 +1538,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sx >= mach->accel.width) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1637,6 +1659,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (!count) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1774,6 +1797,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sx >= mach->accel.width) { if (cpu_input) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1906,14 +1930,18 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Scan To X Write pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; + dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Scan To X Read pixtrans.\n"); dev->force_busy = 1; + dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; + dev->data_available2 = 1; return; } } @@ -2010,6 +2038,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 dev->fifo_idx = 0; dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; dev->accel.cmd_back = 1; dev->accel.cur_x = dev->accel.dx; @@ -2183,6 +2212,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 dev->fifo_idx = 0; dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; dev->accel.cmd_back = 1; return; @@ -2597,7 +2627,7 @@ ati_render_24bpp(svga_t *svga) dev->lastline_draw = dev->displine; if (mach->accel.ext_ge_config & 0x400) { /*BGR, Blue-(23:16), Green-(15:8), Red-(7:0)*/ - for (int x = 0; x <= dev->hdisp_8514; x += 4) { + for (int x = 0; x <= dev->h_disp; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); @@ -2613,7 +2643,7 @@ ati_render_24bpp(svga_t *svga) dev->memaddr += 12; } } else { /*RGB, Red-(23:16), Green-(15:8), Blue-(7:0)*/ - for (int x = 0; x <= dev->hdisp_8514; x += 4) { + for (int x = 0; x <= dev->h_disp; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = dat & 0xffffff; @@ -2653,12 +2683,12 @@ ati_render_32bpp(svga_t *svga) dev->lastline_draw = dev->displine; if (mach->accel.ext_ge_config & 0x400) { /*BGR, Blue-(23:16), Green-(15:8), Red-(7:0)*/ - for (x = 0; x <= dev->hdisp_8514; x++) { + for (x = 0; x <= dev->h_disp; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0x00ff0000) >> 16) | (dat & 0x0000ff00) | ((dat & 0x000000ff) << 16); } } else { /*RGB, Red-(31:24), Green-(23:16), Blue-(15:8)*/ - for (x = 0; x <= dev->hdisp_8514; x++) { + for (x = 0; x <= dev->h_disp; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0xffffff00) >> 8); } @@ -2677,84 +2707,72 @@ mach_set_resolution(mach_t *mach, svga_t *svga) { ibm8514_t *dev = (ibm8514_t *) svga->dev8514; - dev->htotal_8514 = dev->htotal + 1; + dev->h_total = (dev->htotal + 1); + if (dev->h_total == 8) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ + dev->h_total = 0x9e; - if (dev->htotal_8514 == 8) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->htotal_8514 = 0x9e; - dev->hdisp_vga = (dev->hdisped + 1) << 3; + dev->hdisp = (dev->hdisped + 1) << 3; + dev->vdisp = (dev->v_disp + 1) >> 1; + if ((dev->vdisp == 478) || (dev->vdisp == 598) || (dev->vdisp == 766) || (dev->vdisp == 898) || (dev->vdisp == 1022)) + dev->vdisp += 2; - dev->vdisp_vga = (dev->vdisp_8514 + 1) >> 1; - if ((dev->vdisp_vga == 478) || (dev->vdisp_vga == 598) || (dev->vdisp_vga == 766) || (dev->vdisp_vga == 1022)) - dev->vdisp_vga += 2; + dev->v_total = dev->v_total_reg + 1; + if (dev->v_total == 1) + dev->v_total = 0x0669; - dev->vtotal_8514 = dev->vtotal_reg + 1; + dev->v_syncstart = dev->v_sync_start + 1; + if (dev->v_syncstart == 1) + dev->v_syncstart = 0x0601; - dev->vsyncstart++; + mach_log("ATI Mode: set=%02x, dispcntl=%02x, h_total=%d, hdisp=%d, vdisp=%d, v_total=%04x, v_syncstart=%04x, hsync_start=%d, hsync_width=%d, clocksel=%02x, advancedcntl=%02x.\n", mach->shadow_set & 0x03, dev->disp_cntl, dev->h_total, dev->hdisp, dev->vdisp, dev->v_total, dev->v_syncstart, dev->hsync_start, dev->hsync_width, mach->accel.clock_sel & 0xff, dev->accel.advfunc_cntl & 0x05); + if ((dev->disp_cntl >> 5) == 1) { /*Enable the 8514/A subsystem and set modes according to the shadow sets if needed.*/ + switch (mach->shadow_set & 0x03) { + case 0x01: + if (!(dev->accel.advfunc_cntl & 0x04)) { + dev->h_total = 0x64; + dev->hdisp = 640; + dev->vdisp = 480; + dev->v_total = 0x0419; + dev->v_syncstart = 0x03d7; + } + break; + case 0x02: + if (dev->accel.advfunc_cntl & 0x04) { + dev->h_total = 0x9e; + dev->hdisp = 1024; + dev->vdisp = 768; + dev->v_total = 0x0669; + dev->v_syncstart = 0x0601; + } + break; - mach_log("VSYNCSTART=%d, VTOTAL=%d, interlace=%02x, vdisp=%d.\n", dev->vsyncstart, dev->vtotal_8514, dev->interlace, dev->vdisp_vga); - - if (!ATI_MACH32) { - if ((mach->accel.clock_sel & 0x01) && - !(dev->accel.advfunc_cntl & 0x01)) - ret = 2; - else if ((dev->accel.advfunc_cntl & 0x01) && - !(mach->accel.clock_sel & 0x01)) - ret = 1; - else if ((!(dev->accel.advfunc_cntl & 0x01) && (mach->old_on1 & 0x01)) || - (!(mach->accel.clock_sel & 0x01) && (mach->old_on2 & 0x01))) - ret = 0; - } else { - if ((mach->accel.clock_sel & 0x01) && !(mach->old_on2 & 0x01) && - !(dev->accel.advfunc_cntl & 0x01)) - ret = 2; - else if ((dev->accel.advfunc_cntl & 0x01) && !(mach->old_on1 & 0x01) && - !(mach->accel.clock_sel & 0x01)) - ret = 1; - else if ((!(dev->accel.advfunc_cntl & 0x01) && (mach->old_on1 & 0x01)) || - (!(mach->accel.clock_sel & 0x01) && (mach->old_on2 & 0x01))) - ret = 0; - } - - if (ret) { - if (ret == 2) - svga_recalctimings(svga); - else { - switch (mach->shadow_set & 0x03) { - case 0x00: - if (mach->crt_resolution) - svga_recalctimings(svga); - else { - if (dev->accel.advfunc_cntl & 0x04) { - if (dev->hdisp_vga == 640) { - dev->hdisp_vga = 1024; - dev->vdisp_vga = 768; - mach_log("1024x768.\n"); - } - } else { - if (dev->hdisp_vga == 1024) { - dev->hdisp_vga = 640; - dev->vdisp_vga = 480; - mach_log("640x480.\n"); - } - } - svga_recalctimings(svga); - } - break; - case 0x01: - mach->crt_resolution = 0x01; - break; - case 0x02: - mach->crt_resolution = 0x02; - break; - default: - break; + default: + break; + } + svga_recalctimings(svga); + } else if ((dev->disp_cntl >> 5) == 2) { /*Reset 8514/A to defaults if needed.*/ + if (dev->accel.advfunc_cntl & 0x04) { + if (dev->hdisp == 640) { + dev->h_total = 0x9e; + dev->hdisp = 1024; + dev->vdisp = 768; + dev->v_total = 0x0669; + dev->v_syncstart = 0x0601; + svga_recalctimings(svga); + } + } else { + if (dev->hdisp == 1024) { + dev->h_total = 0x64; + dev->hdisp = 640; + dev->vdisp = 480; + dev->v_total = 0x0419; + dev->v_syncstart = 0x03d7; + svga_recalctimings(svga); } } } else /*No change (type 0) or reset type 3.*/ svga_recalctimings(svga); - - mach_log("Shadow set ATI=%x, shadow set 8514/A and on1=%x, on2=%x, resolution h=%d, v=%d, vtotal=%d, vsyncstart=%d, crtres=%d, ret=%d, actual passthrough=%x.\n", mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01, dev->hdisp_vga, dev->vdisp_vga, dev->vtotal_8514, dev->v_syncstart, mach->crt_resolution, ret, dev->on); } void @@ -2775,7 +2793,7 @@ ati8514_recalctimings(svga_t *svga) dev->accel.ge_offset -= mach->accel.crt_offset; mach_log("HDISP=%d, VDISP=%d, shadowset=%x, 8514/A mode=%x, clocksel=%02x.\n", - dev->hdisp_vga, dev->vdisp_vga, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01); + dev->hdisp, dev->vdisp, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01); mach->accel.src_pitch = dev->pitch; mach->accel.dst_pitch = dev->pitch; @@ -2786,11 +2804,11 @@ ati8514_recalctimings(svga_t *svga) mach_log("8514/A ON, pitch=%d, GE offset=%08x.\n", ((mach->accel.ge_pitch & 0xff) << 3), dev->accel.ge_offset); - dev->hdisp_8514 = dev->hdisp_vga; - dev->dispend = dev->vdisp_vga; + dev->h_disp = dev->hdisp; + dev->dispend = dev->vdisp; if (dev->dispend == 600) - dev->hdisp_8514 = 800; - else if (dev->hdisp_8514 == 640) + dev->h_disp = 800; + else if (dev->h_disp == 640) dev->dispend = 480; if (dev->accel.advfunc_cntl & 0x04) @@ -2802,10 +2820,10 @@ ati8514_recalctimings(svga_t *svga) dev->dispend >>= 1; mach_log("cntl=%d, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d.\n", - dev->accel.advfunc_cntl & 0x04, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace); - if (dev->vram_is_512k) { - if (dev->hdisp_8514 == 640) + if (dev->vram_512k_8514) { + if (dev->h_disp == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -2886,7 +2904,7 @@ mach_recalctimings(svga_t *svga) mach->accel.crt_offset <<= 2; } - if (ATI_MACH32 && !dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (ATI_MACH32 && !dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { dev->accel.ge_offset <<= 1; mach->accel.crt_offset <<= 1; } @@ -2895,17 +2913,17 @@ mach_recalctimings(svga_t *svga) mach_log("RowCount=%x, rowoffset=%x, pitch=%d, geoffset=%x, crtoffset=%x.\n", dev->rowcount, dev->rowoffset, dev->pitch, dev->accel.ge_offset, mach->accel.crt_offset); mach_log("HDISP=%d, VDISP=%d, shadowset=%x, 8514/A mode=%x, clocksel=%02x, interlace=%x.\n", - dev->hdisp_vga, dev->vdisp_vga, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x04, + dev->hdisp, dev->vdisp, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0xfe, dev->interlace); - dev->hdisp_8514 = dev->hdisp_vga; - dev->dispend = dev->vdisp_vga; + dev->h_disp = dev->hdisp; + dev->dispend = dev->vdisp; if (dev->dispend == 959) { /*FIXME: vertical resolution mess on EEPROM tests on Mach8*/ dev->dispend >>= 1; dev->dispend++; } else if (dev->dispend == 600) - dev->hdisp_8514 = 800; - else if (dev->hdisp_8514 == 640) + dev->h_disp = 800; + else if (dev->h_disp == 640) dev->dispend = 480; dev->h_disp_time = dev->hdisp >> 3; @@ -2931,7 +2949,7 @@ mach_recalctimings(svga_t *svga) mach->accel.src_ge_offset <<= 2; mach->accel.dst_ge_offset <<= 2; } - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { mach->accel.src_ge_offset <<= 1; mach->accel.dst_ge_offset <<= 1; } @@ -2950,7 +2968,7 @@ mach_recalctimings(svga_t *svga) else mach->accel.dst_ge_offset <<= 2; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) mach->accel.dst_ge_offset <<= 1; mach->accel.dst_ge_offset -= mach->accel.crt_offset; @@ -2965,7 +2983,7 @@ mach_recalctimings(svga_t *svga) else mach->accel.src_ge_offset <<= 2; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) mach->accel.src_ge_offset <<= 1; mach->accel.src_ge_offset -= mach->accel.crt_offset; @@ -2976,19 +2994,19 @@ mach_recalctimings(svga_t *svga) break; } mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", - dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace, svga->hdisp); mach_log("EXTGECONFIG bits 11-15=%04x.\n", mach->accel.ext_ge_config & 0x8800); if ((mach->accel.ext_ge_config & 0x800) || (!(mach->accel.ext_ge_config & 0x8000) && !(mach->accel.ext_ge_config & 0x800))) { mach_log("hv=%d,%d, pitch=%d, rowoffset=%d, gextconfig=%03x, bpp=%d, shadow=%x, vgahdisp=%d.\n", - dev->hdisp_8514, dev->dispend, dev->pitch, dev->ext_crt_pitch, mach->accel.ext_ge_config & 0xcec0, + dev->h_disp, dev->dispend, dev->pitch, dev->ext_crt_pitch, mach->accel.ext_ge_config & 0xcec0, dev->accel_bpp, mach->shadow_set & 0x03, svga->hdisp); switch (dev->accel_bpp) { case 8: if ((mach->accel.ext_ge_config & 0x30) == 0x00) { - if (dev->vram_is_512k) { - if (dev->hdisp_8514 == 640) + if (dev->vram_512k_8514) { + if (dev->h_disp == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -3026,10 +3044,10 @@ mach_recalctimings(svga_t *svga) mach->accel.dst_ge_offset -= mach->accel.crt_offset; mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", - dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 0x03, dev->interlace, svga->hdisp); - if (dev->vram_is_512k) { - if (dev->hdisp_8514 == 640) + if (dev->vram_512k_8514) { + if (dev->h_disp == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -3171,15 +3189,15 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10) && val) { - dev->vtotal_reg = val; - dev->vtotal_reg &= 0x1fff; + dev->v_total_reg = val; + dev->v_total_reg &= 0x1fff; } } } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->vtotal_reg, val); - dev->vtotal_reg &= 0x1fff; + WRITE8(port, dev->v_total_reg, val); + dev->v_total_reg &= 0x1fff; } } } @@ -3191,8 +3209,8 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { if (!(mach->shadow_cntl & 0x10)) { /*For 8514/A mode, take the shadow sets into account.*/ - WRITE8(port, dev->vtotal_reg, val >> 8); - dev->vtotal_reg &= 0x1fff; + WRITE8(port, dev->v_total_reg, val >> 8); + dev->v_total_reg &= 0x1fff; } } mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): hdisp=0x%02x.\n", CS, cpu_state.pc, port, val); @@ -3204,17 +3222,17 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20) && val) { - dev->vdisp_8514 = val; - dev->vdisp_8514 &= 0x1fff; + dev->v_disp = val; + dev->v_disp &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->vdisp_8514); + mach_log("ATI 8514/A: V_DISP write 16E8=%d, vdisp2=%d.\n", dev->v_disp, dev->v_disp2); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->vdisp_8514, val); - dev->vdisp_8514 &= 0x1fff; + WRITE8(port, dev->v_disp, val); + dev->v_disp &= 0x1fff; } } } @@ -3224,11 +3242,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->vdisp_8514, val >> 8); - dev->vdisp_8514 &= 0x1fff; + WRITE8(port, dev->v_disp, val >> 8); + dev->v_disp &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->vdisp_8514); + mach_log("ATI 8514/A: V_DISP write 16E8=%d, vdisp2=%d.\n", dev->v_disp, dev->v_disp2); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3238,17 +3256,17 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10) && val) { - dev->vsyncstart = val; - dev->vsyncstart &= 0x1fff; + dev->v_sync_start = val; + dev->v_sync_start &= 0x1fff; } } - mach_log("ATI 8514/A: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); + mach_log("ATI 8514/A: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); mach_log("ATI 8514/A: (0x%04x): vsyncstart=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->vsyncstart, val); - dev->vsyncstart &= 0x1fff; + WRITE8(port, dev->v_sync_start, val); + dev->v_sync_start &= 0x1fff; } } } @@ -3258,11 +3276,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->vsyncstart, val >> 8); - dev->vsyncstart &= 0x1fff; + WRITE8(port, dev->v_sync_start, val >> 8); + dev->v_sync_start &= 0x1fff; } } - mach_log("ATI 8514/A: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); + mach_log("ATI 8514/A: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); mach_log("ATI 8514/A: (0x%04x): vsyncstart=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3294,6 +3312,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if ((dev->subsys_cntl & 0xc000) == 0x8000) { mach->force_busy = 0; dev->force_busy = 0; + dev->force_busy2 = 0; } break; @@ -3319,7 +3338,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u dev->mode = IBM_MODE; mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, valxor=%x, shadow crt=%x, hdisp=%d, vdisp=%d, extmode=%02x, accelbpp=%d, crt=%d, crtres=%d.\n", - CS, cpu_state.pc, port, val & 0x01, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp_vga, dev->vdisp_vga, mach->regs[0xb0] & 0x20, dev->accel_bpp, dev->_8514crt, mach->crt_resolution); + CS, cpu_state.pc, port, val & 0x01, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp, dev->vdisp, mach->regs[0xb0] & 0x20, dev->accel_bpp, dev->_8514crt, mach->crt_resolution); if (ATI_MACH32) { mach_set_resolution(mach, svga); @@ -3502,7 +3521,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } } } - mach_log("Write Port=%04x, Busy=%02x.\n", port, dev->force_busy); + mach_log("Write Port=%04x, Busy=%02x.\n", port, dev->force_busy2); break; case 0xaae8: @@ -3565,7 +3584,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } mach->cursor_offset_lo = mach->cursor_offset_lo_reg; dev->hwcursor.addr = ((mach->cursor_offset_lo | (mach->cursor_offset_hi << 16)) << 2); - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) dev->hwcursor.addr <<= 1; break; @@ -3575,10 +3594,10 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { WRITE8(port + 1, mach->cursor_offset_hi_reg, val >> 8); } - dev->hwcursor.enable = !!(mach->cursor_offset_hi_reg & 0x8000); + dev->hwcursor.ena = !!(mach->cursor_offset_hi_reg & 0x8000); mach->cursor_offset_hi = mach->cursor_offset_hi_reg & 0x0f; dev->hwcursor.addr = ((mach->cursor_offset_lo | (mach->cursor_offset_hi << 16)) << 2); - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) dev->hwcursor.addr <<= 1; break; @@ -3764,7 +3783,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u dev->mode = ATI_MODE; mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, val=%04x, xor=%d, hdisp=%d, vdisp=%d, accelbpp=%d.\n", - CS, cpu_state.pc, port, mach->accel.clock_sel & 0x01, val, dev->on, dev->hdisp_vga, dev->vdisp_vga, dev->accel_bpp); + CS, cpu_state.pc, port, mach->accel.clock_sel & 0x01, val, dev->on, dev->hdisp, dev->vdisp, dev->accel_bpp); mach_log("Vendor ATI mode set %s resolution.\n", (dev->accel.advfunc_cntl & 0x04) ? "2: 1024x768" : "1: 640x480"); @@ -3976,6 +3995,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.bres_count = val & 0x7ff; mach_log("BresenhamDraw=%04x.\n", mach->accel.dp_config); dev->data_available = 0; + dev->data_available2 = 0; mach->accel.cmd_type = 1; frgd_sel = (mach->accel.dp_config >> 13) & 7; bkgd_sel = (mach->accel.dp_config >> 7) & 3; @@ -4028,6 +4048,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.dest_y_end = 0; } dev->data_available = 0; + dev->data_available2 = 0; mach_log("BitBLT=%04x, pattidx=%d.\n", mach->accel.dp_config, mach->accel.patt_idx); mach_log(".\n"); mach->accel.cmd_type = 2; /*Non-conforming BitBLT from dest_y_end register (0xaeee)*/ @@ -4090,6 +4111,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.scan_to_x = 0; } dev->data_available = 0; + dev->data_available2 = 0; mach->accel.cmd_type = 5; /*Horizontal Raster Draw from scan_to_x register (0xcaee)*/ mach_log("ScanToX len=%d.\n", val); mach_log(".\n"); @@ -4111,6 +4133,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach_log("Data Path Configuration (%04x) write val=%04x, len=%d.\n", port, val, len); if (len == 2) { dev->data_available = 0; + dev->data_available2 = 0; mach->accel.dp_config = val; } break; @@ -4348,26 +4371,26 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in if (len == 1) { dev->fifo_idx = 0; - if (dev->force_busy) + if (dev->force_busy2) temp |= 0x02; /*Hardware busy*/ - dev->force_busy = 0; + dev->force_busy2 = 0; - if (dev->data_available) { + if (dev->data_available2) { temp |= 0x01; /*Read Data available*/ if (mach->accel.cmd_type >= 0) { switch (mach->accel.cmd_type) { case 2: if (dev->accel.sy >= mach->accel.height) - dev->data_available = 0; + dev->data_available2 = 0; break; case 5: if (dev->accel.sx >= mach->accel.width) - dev->data_available = 0; + dev->data_available2 = 0; break; default: if (dev->accel.sy < 0) - dev->data_available = 0; + dev->data_available2 = 0; break; } } else { @@ -4377,11 +4400,11 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in case 4: case 6: if (dev->accel.sy < 0) - dev->data_available = 0; + dev->data_available2 = 0; break; default: if (!dev->accel.sy) - dev->data_available = 0; + dev->data_available2 = 0; break; } } @@ -4572,35 +4595,35 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in case 0xc2ee: if (len == 2) - temp = dev->vtotal_reg; + temp = dev->v_total_reg; else - temp = dev->vtotal_reg & 0xff; + temp = dev->v_total_reg & 0xff; break; case 0xc2ef: if (len == 1) - temp = dev->vtotal_reg >> 8; + temp = dev->v_total_reg >> 8; break; case 0xc6ee: if (len == 2) - temp = dev->vdisp_8514; + temp = dev->v_disp; else - temp = dev->vdisp_8514 & 0xff; + temp = dev->v_disp & 0xff; break; case 0xc6ef: if (len == 1) - temp = dev->vdisp_8514 >> 8; + temp = dev->v_disp >> 8; break; case 0xcaee: if (len == 2) - temp = dev->vsyncstart; + temp = dev->v_sync_start; else - temp = dev->vsyncstart & 0xff; + temp = dev->v_sync_start & 0xff; break; case 0xcaef: if (len == 1) - temp = dev->vsyncstart >> 8; + temp = dev->v_sync_start >> 8; break; case 0xceee: @@ -4764,12 +4787,14 @@ mach_accel_in_call(uint16_t port, mach_t *mach, svga_t *svga, ibm8514_t *dev) if (!dev->fifo_idx && !dev->on) { dev->force_busy = 0; + dev->force_busy2 = 0; mach->force_busy = 0; dev->data_available = 0; + dev->data_available2 = 0; temp |= INT_FIFO_EMP; mach_log("Fifo Empty.\n"); } - temp |= (dev->subsys_stat | (dev->vram_is_512k ? 0x00 : 0x80)); + temp |= (dev->subsys_stat | (dev->vram_512k_8514 ? 0x00 : 0x80)); if (mach->accel.ext_ge_config & 0x08) temp |= ((mach->accel.ext_ge_config & 0x07) << 4); else @@ -5199,19 +5224,19 @@ mach32_write_common(uint32_t addr, uint8_t val, int linear, mach_t *mach, svga_t ibm8514_t *dev = (ibm8514_t *) svga->dev8514; int writemask2 = svga->writemask; int reset_wm = 0; - ibm8514_latch_t vall; + latch8514_t vall; uint8_t wm = svga->writemask; uint8_t i; cycles -= svga->monitor->mon_video_timing_write_b; if (linear) { - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; dev->changedvram[addr >> 12] = svga->monitor->mon_changeframecount; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { switch (addr & 0x06) { case 0x00: case 0x06: @@ -5362,7 +5387,7 @@ mach32_write(uint32_t addr, uint8_t val, void *priv) return; } - if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; switch (addr & 0x06) { case 0x00: @@ -5402,7 +5427,7 @@ mach32_writew(uint32_t addr, uint16_t val, void *priv) return; } - if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; if (addr & 0x04) { mach32_write_common(addr - 2, val & 0x0f, 0, mach, svga); @@ -5437,7 +5462,7 @@ mach32_writel(uint32_t addr, uint32_t val, void *priv) return; } - if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; mach32_write_common(addr, val & 0x0f, 0, mach, svga); mach32_write_common(addr + 1, (val >> 4) & 0x0f, 0, mach, svga); @@ -5680,12 +5705,12 @@ mach32_writew_linear(uint32_t addr, uint16_t val, mach_t *mach) ibm8514_t *dev = (ibm8514_t *) svga->dev8514; cycles -= svga->monitor->mon_video_timing_write_w; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; dev->changedvram[addr >> 12] = svga->monitor->mon_changeframecount; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { if (addr & 0x04) { dev->vram[addr - 2] = val & 0x0f; dev->vram[addr - 1] = (val >> 4) & 0x0f; @@ -5709,12 +5734,12 @@ mach32_writel_linear(uint32_t addr, uint32_t val, mach_t *mach) cycles -= svga->monitor->mon_video_timing_write_l; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; dev->changedvram[addr >> 12] = svga->monitor->mon_changeframecount; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { dev->vram[addr] = val & 0x0f; dev->vram[addr + 1] = (val >> 4) & 0x0f; dev->vram[addr + 4] = (val >> 8) & 0x0f; @@ -5740,11 +5765,11 @@ mach32_read_common(uint32_t addr, int linear, mach_t *mach, svga_t *svga) cycles -= svga->monitor->mon_video_timing_read_b; if (linear) { - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) addr <<= 1; addr &= dev->vram_mask; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { switch ((addr & 0x06) >> 1) { case 0x00: case 0x03: @@ -5854,7 +5879,7 @@ mach32_read(uint32_t addr, void *priv) (void) xga_read_test(addr, svga); addr = (addr & svga->banked_mask) + svga->read_bank; - if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; switch ((addr & 0x06) >> 1) { case 0x00: @@ -5891,7 +5916,7 @@ mach32_readw(uint32_t addr, void *priv) (void) xga_read_test(addr, svga); addr = (addr & svga->banked_mask) + svga->read_bank; - if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; if (addr & 0x04) { ret = mach32_read_common(addr - 2, 0, mach, svga) & 0x0f; @@ -5923,7 +5948,7 @@ mach32_readl(uint32_t addr, void *priv) (void) xga_read_test(addr, svga); addr = (addr & svga->banked_mask) + svga->read_bank; - if ((ATI_MACH32 && !dev->vram_is_512k) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if ((ATI_MACH32 && !dev->vram_512k_8514) && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; ret = mach32_read_common(addr, 0, mach, svga) & 0x0f; ret |= (mach32_read_common(addr + 1, 0, mach, svga) << 4); @@ -5951,7 +5976,7 @@ mach32_readw_linear(uint32_t addr, mach_t *mach) uint16_t ret; cycles -= svga->monitor->mon_video_timing_read_w; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; addr &= dev->vram_mask; if (addr & 0x04) { @@ -5979,7 +6004,7 @@ mach32_readl_linear(uint32_t addr, mach_t *mach) uint32_t ret; cycles -= svga->monitor->mon_video_timing_read_l; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) { addr <<= 1; addr &= dev->vram_mask; ret = dev->vram[addr] & 0x0f; @@ -6276,7 +6301,7 @@ mach32_hwcursor_draw(svga_t *svga, int displine) int shift = 0; offset = dev->hwcursor_latch.x - dev->hwcursor_latch.xoff; - if (!dev->vram_is_512k && ((mach->accel.ext_ge_config & 0x30) == 0x00)) + if (!dev->vram_512k_8514 && ((mach->accel.ext_ge_config & 0x30) == 0x00)) shift = 1; mach_log("BPP=%d, displine=%d.\n", dev->accel_bpp, displine); @@ -7014,6 +7039,7 @@ mach_reset(void *priv) mach_disable_handlers(mach); mach->force_busy = 0; dev->force_busy = 0; + dev->force_busy2 = 0; if (mach->pci_bus) reset_state->pci_slot = mach->pci_slot; @@ -7044,7 +7070,7 @@ mach8_init(const device_t *info) mach->has_bios = !(info->local & 0xff00); mach->ramdac_type = mach->pci_bus ? device_get_config_int("ramdac") : ATI_68875; dev->vram_amount = device_get_config_int("memory"); - dev->vram_is_512k = dev->vram_amount == 512; + dev->vram_512k_8514 = dev->vram_amount == 512; if (ATI_MACH32) { if (mach->pci_bus) { @@ -7223,10 +7249,10 @@ ati8514_init(svga_t *svga, void *ext8514, void *dev8514) dev->accel_bpp = 8; dev->rowoffset = 0x80; dev->hdisped = 0x7f; - dev->vdisp_8514 = 0x05ff; + dev->v_disp = 0x05ff; dev->htotal = 0x9d; - dev->vtotal_reg = 0x0668; - dev->vsyncstart = 0x0600; + dev->v_total_reg = 0x0668; + dev->v_sync_start = 0x0600; dev->disp_cntl = 0x33; mach->accel.clock_sel = 0x1c; dev->accel.cmd_back = 1; diff --git a/src/video/vid_chips_69000.c b/src/video/vid_chips_69000.c index c63886b04..70b2b9e16 100644 --- a/src/video/vid_chips_69000.c +++ b/src/video/vid_chips_69000.c @@ -1906,7 +1906,7 @@ chips_69000_write_ext_reg(chips_69000_t* chips, uint8_t val) break; case 0xA0: chips->ext_regs[chips->ext_index] = val; - chips->svga.hwcursor.enable = ((val & 7) == 0b101) || ((val & 7) == 0b1); + chips->svga.hwcursor.ena = ((val & 7) == 0b101) || ((val & 7) == 0b1); chips->svga.hwcursor.cur_xsize = chips->svga.hwcursor.cur_ysize = ((val & 7) == 0b1) ? 32 : 64; break; case 0xA2: diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index ddaccd49f..fff344f3a 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -814,7 +814,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *priv) else svga->overscan_color = svga->pallook[svga->attrregs[0x11]]; svga_recalctimings(svga); - svga->hwcursor.enable = val & CIRRUS_CURSOR_SHOW; + svga->hwcursor.ena = val & CIRRUS_CURSOR_SHOW; if (svga->crtc[0x27] >= CIRRUS_ID_CLGD5422) svga->hwcursor.cur_xsize = svga->hwcursor.cur_ysize = ((svga->crtc[0x27] >= CIRRUS_ID_CLGD5422) && @@ -1245,7 +1245,7 @@ gd54xx_out(uint16_t addr, uint8_t val, void *priv) break; case 0x3e: gd54xx->overlay.mode = (val >> 1) & 7; - svga->overlay.enable = (val & 1) != 0; + svga->overlay.ena = (val & 1) != 0; gd54xx_update_overlay(gd54xx); break; diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index b928a5293..21671f4b3 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -665,6 +665,7 @@ ega_recalctimings(ega_t *ega) ega->hdisp *= (ega->seqregs[1] & 8) ? 16 : 8; ega->render = ega_render_graphics; } + ega->hdisp_old = ega->hdisp; } if (ega->chipset) { @@ -842,6 +843,7 @@ ega_poll(void *priv) ega->linepos = 1; if (ega->dispon) { + ega->hdisp_on = 1; ega->memaddr &= ega->vrammask; if (ega->firstline == 2000) { @@ -897,6 +899,7 @@ ega_poll(void *priv) if (ega->dispon) ega->status &= ~1; + ega->hdisp_on = 0; ega->linepos = 0; if ((ega->scanline == (ega->crtc[11] & 31)) || (ega->scanline == ega->rowcount)) @@ -1538,8 +1541,10 @@ ega_init(ega_t *ega, int monitor_type, int is_mono) old_overscan_color = 0; ega->miscout |= 0x22; + ega->oddeven_page = 0; ega->seqregs[4] |= 2; + ega->extvram = 1; update_overscan = 0; diff --git a/src/video/vid_et4000w32.c b/src/video/vid_et4000w32.c index 27f33a834..2e9a7796a 100644 --- a/src/video/vid_et4000w32.c +++ b/src/video/vid_et4000w32.c @@ -277,7 +277,7 @@ et4000w32p_out(uint16_t addr, uint8_t val, void *priv) et4000->regs[et4000->index] = val; svga->hwcursor.x = et4000->regs[0xE0] | ((et4000->regs[0xE1] & 7) << 8); svga->hwcursor.y = et4000->regs[0xE4] | ((et4000->regs[0xE5] & 7) << 8); - svga->hwcursor.enable = !!(et4000->regs[0xF7] & 0x80); + svga->hwcursor.ena = !!(et4000->regs[0xF7] & 0x80); svga->hwcursor.xoff = et4000->regs[0xE2]; svga->hwcursor.yoff = et4000->regs[0xE6]; svga->hwcursor.cur_xsize = svga->hwcursor.cur_ysize = ((et4000->regs[0xEF] & 4) || ((et4000->type == ET4000W32) && (et4000->regs[0xe2] >= 0x1f) && (et4000->regs[0xe6] >= 0x1f))) ? 128 : 64; diff --git a/src/video/vid_ht216.c b/src/video/vid_ht216.c index 061b70246..3089ae26d 100644 --- a/src/video/vid_ht216.c +++ b/src/video/vid_ht216.c @@ -299,7 +299,7 @@ ht216_out(uint16_t addr, uint8_t val, void *priv) break; case 0xa5: - svga->hwcursor.enable = !!(val & 0x80); + svga->hwcursor.ena = !!(val & 0x80); break; case 0xc0: diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index e5ac55648..294e6ce75 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -474,6 +474,8 @@ typedef struct mystique_t { atomic_uint status; atomic_bool softrap_status_read; + uint64_t blitter_time, status_time; + pc_timer_t softrap_pending_timer, wake_timer; fifo_entry_t fifo[FIFO_SIZE]; @@ -1380,7 +1382,7 @@ mystique_write_xreg(mystique_t *mystique, int reg, uint8_t val) case XREG_XCURCTRL: mystique->xcurctrl = val; - svga->hwcursor.enable = (val & 3) ? 1 : 0; + svga->hwcursor.ena = (val & 3) ? 1 : 0; break; case XREG_XCURCOL0R: @@ -6046,6 +6048,8 @@ static void mystique_start_blit(mystique_t *mystique) { svga_t *svga = &mystique->svga; + uint64_t start_time = plat_timer_read(); + uint64_t end_time; /*Make sure we don't get any artifacts.*/ svga->chain2_write = 0; @@ -6115,6 +6119,9 @@ mystique_start_blit(mystique_t *mystique) fatal("mystique_start_blit: unknown blit %08x\n", mystique->dwgreg.dwgctrl_running & DWGCTRL_OPCODE_MASK); break; } + + end_time = plat_timer_read(); + mystique->blitter_time += end_time - start_time; } static void diff --git a/src/video/vid_ps55da2.c b/src/video/vid_ps55da2.c index 29eefabbf..938e4bf6b 100644 --- a/src/video/vid_ps55da2.c +++ b/src/video/vid_ps55da2.c @@ -356,6 +356,7 @@ typedef struct da2_t { uint64_t da2const; int dispon; + int hdisp_on; uint32_t memaddr, memaddr_backup, cursoraddr; int vc; @@ -3019,6 +3020,7 @@ da2_poll(void *priv) da2->linepos = 1; if (da2->dispon) { + da2->hdisp_on = 1; da2->memaddr &= da2->vram_display_mask; if (da2->firstline == 2000) { @@ -3050,6 +3052,7 @@ da2_poll(void *priv) if (da2->dispon) da2->cgastat &= ~1; + da2->hdisp_on = 0; da2->linepos = 0; if (da2->scanline == (da2->crtc[LC_CURSOR_ROW_END] & 31)) diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index 4f890dcdf..d0495dca0 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -375,6 +375,8 @@ typedef struct s3_t { event_t *fifo_not_full_event; atomic_int blitter_busy; + uint64_t blitter_time; + uint64_t status_time; uint8_t subsys_cntl, subsys_stat; @@ -3037,7 +3039,7 @@ s3_out(uint16_t addr, uint8_t val, void *priv) case 0x45: if ((s3->chip == S3_VISION964) || (s3->chip == S3_VISION968)) break; - svga->hwcursor.enable = val & 1; + svga->hwcursor.ena = val & 1; break; case 0x46: case 0x47: @@ -4442,13 +4444,13 @@ s3_trio64v_recalctimings(svga_t *svga) else svga->overlay.addr = s3->streams.sec_fb0; - svga->overlay.enable = (svga->overlay.x >= 0); + svga->overlay.ena = (svga->overlay.x >= 0); svga->overlay.h_acc = s3->streams.dda_horiz_accumulator; svga->overlay.v_acc = s3->streams.dda_vert_accumulator; svga->rowoffset = s3->streams.pri_stride >> 3; - if (svga->overlay.enable) { - svga->overlay.enable = (((s3->streams.blend_ctrl >> 24) & 7) == 0b000) || + if (svga->overlay.ena) { + svga->overlay.ena = (((s3->streams.blend_ctrl >> 24) & 7) == 0b000) || (((s3->streams.blend_ctrl >> 24) & 7) == 0b101); } switch ((s3->streams.pri_ctrl >> 24) & 0x7) { @@ -9696,6 +9698,8 @@ static void fifo_thread(void *param) { s3_t *s3 = (s3_t *) param; + uint64_t start_time; + uint64_t end_time; while (s3->fifo_thread_run) { thread_set_event(s3->fifo_not_full_event); @@ -9703,6 +9707,7 @@ fifo_thread(void *param) thread_reset_event(s3->wake_fifo_thread); s3->blitter_busy = 1; while (!FIFO_EMPTY) { + start_time = plat_timer_read(); fifo_entry_t *fifo = &s3->fifo[s3->fifo_read_idx & FIFO_MASK]; switch (fifo->addr_type & FIFO_TYPE) { @@ -9734,6 +9739,9 @@ fifo_thread(void *param) if (FIFO_ENTRIES > 0xe000) thread_set_event(s3->fifo_not_full_event); + + end_time = plat_timer_read(); + s3->blitter_time += (end_time - start_time); } s3->blitter_busy = 0; s3->subsys_stat |= INT_FIFO_EMP; diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index 1258b549a..774b0d4b7 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -585,7 +585,7 @@ s3_virge_out(uint16_t addr, uint8_t val, void *priv) break; case 0x45: - svga->hwcursor.enable = val & 1; + svga->hwcursor.ena = val & 1; break; case 0x46: case 0x47: @@ -966,19 +966,19 @@ s3_virge_recalctimings(svga_t *svga) else svga->overlay.addr = virge->streams.sec_fb0; - svga->overlay.enable = (svga->overlay.x >= 0); + svga->overlay.ena = (svga->overlay.x >= 0); svga->overlay.h_acc = virge->streams.dda_horiz_accumulator; svga->overlay.v_acc = virge->streams.dda_vert_accumulator; if (virge->chip < S3_VIRGEGX2) svga->rowoffset = virge->streams.pri_stride >> 3; - if (virge->chip <= S3_VIRGEDX && svga->overlay.enable) { - svga->overlay.enable = (((virge->streams.blend_ctrl >> 24) & 7) == 0b000) || (((virge->streams.blend_ctrl >> 24) & 7) == 0b101); - } else if (virge->chip >= S3_VIRGEGX2 && svga->overlay.enable) { + if (virge->chip <= S3_VIRGEDX && svga->overlay.ena) { + svga->overlay.ena = (((virge->streams.blend_ctrl >> 24) & 7) == 0b000) || (((virge->streams.blend_ctrl >> 24) & 7) == 0b101); + } else if (virge->chip >= S3_VIRGEGX2 && svga->overlay.ena) { /* 0x20 = Secondary Stream enabled */ /* 0x2000 = Primary Stream enabled */ - svga->overlay.enable = !!(virge->streams.blend_ctrl & 0x20); + svga->overlay.ena = !!(virge->streams.blend_ctrl & 0x20); } if (virge->chip >= S3_VIRGEGX2) { diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 2ba2863b7..8ed71645e 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -984,6 +984,61 @@ svga_recalctimings(svga_t *svga) } } +#if TBD + if (ibm8514_active && (svga->dev8514 != NULL)) { + if (dev->on) { + uint32_t _8514_dot = dev->h_sync_start; + uint32_t _8514_adj_dot = dev->h_sync_start; + uint32_t _8514_eff_mask = (dev->h_blank_end_val & ~0x0000001f) ? dev->h_blank_end_mask : 0x0000001f; + dev->h_blank_sub = 0; + + mach_log("8514/A: HDISP=%d, HDISPED=%d, Blank: %04i-%04i, Total: %04i, " + "Mask: %02X, ADJ_DOT=%04i.\n", dev->hdisp, (dev->hdisped + 1) << 3, + dev->h_sync_start, dev->h_blank_end_val, + dev->h_total, _8514_eff_mask, _8514_adj_dot); + + while (_8514_adj_dot < (dev->h_total << 1)) { + if (_8514_dot == dev->h_total) + _8514_dot = 0; + + if (_8514_adj_dot >= dev->h_total) + dev->h_blank_sub++; + + mach_log("8514/A: Loop: adjdot=%d, htotal=%d, dotmask=%02x, " + "hblankendvalmask=%02x, blankendval=%02x.\n", adj_dot, + dev->h_total, _8514_dot & _8514_eff_mask, dev->h_blank_end_val & _8514_eff_mask, + dev->h_blank_end_val); + if ((_8514_dot & _8514_eff_mask) == (dev->h_blank_end_val & _8514_eff_mask)) + break; + + _8514_dot++; + _8514_adj_dot++; + } + + uint32_t _8514_hd = dev->hdisp; + dev->hdisp -= dev->h_blank_sub; + + svga->left_overscan = svga->x_add = (dev->h_total - _8514_adj_dot - 1) << 3; + svga->monitor->mon_overscan_x = svga->x_add + (dev->h_sync_start << 3) - _8514_hd + 8; + svga->monitor->mon_overscan_x++; + + if ((dev->hdisp >= 2048) || (svga->left_overscan < 0)) { + svga->left_overscan = svga->x_add = 0; + svga->monitor->mon_overscan_x = 0; + } + + /* - 1 because + 1 but also - 2 to compensate for the + 2 added to vtotal above. */ + svga->y_add = svga->vtotal - svga->vblankend - 1; + svga->monitor->mon_overscan_y = svga->y_add + abs(svga->vblankstart - svga->dispend); + + if ((dev->dispend >= 2048) || (svga->y_add < 0)) { + svga->y_add = 0; + svga->monitor->mon_overscan_y = 0; + } + } + } +#endif + if (svga->vblankstart < svga->dispend) { svga_log("DISPEND > VBLANKSTART.\n"); svga->dispend = svga->vblankstart; @@ -1038,16 +1093,16 @@ svga_recalctimings(svga_t *svga) if (ibm8514_active && (svga->dev8514 != NULL)) { if (dev->on) { - disptime8514 = dev->htotal_8514; - _dispontime8514 = dev->hdisp_8514; - svga_log("HTOTAL=%d, HDISP=%d.\n", dev->htotal_8514, dev->hdisp_8514); + disptime8514 = dev->h_total; + _dispontime8514 = dev->h_disp_time; + svga_log("HTOTAL=%d, HDISP=%d.\n", dev->h_total, dev->h_disp); } } if (xga_active && (svga->xga != NULL)) { if (xga->on) { - disptime_xga = xga->htotal_xga ? xga->htotal_xga : TIMER_USEC; - _dispontime_xga = xga->hdisp_xga; + disptime_xga = xga->h_total ? xga->h_total : TIMER_USEC; + _dispontime_xga = xga->h_disp; } } @@ -1253,32 +1308,32 @@ svga_poll(void *priv) svga_log("SVGA Poll.\n"); if (!svga->linepos) { - if (svga->displine == ((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) && svga->hwcursor_latch.enable) { + if (svga->displine == ((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) && svga->hwcursor_latch.ena) { svga->hwcursor_on = svga->hwcursor_latch.cur_ysize - svga->hwcursor_latch.yoff; svga->hwcursor_oddeven = 0; } - if (svga->displine == (((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) + 1) && svga->hwcursor_latch.enable && svga->interlace) { + if (svga->displine == (((svga->hwcursor_latch.y < 0) ? 0 : svga->hwcursor_latch.y) + 1) && svga->hwcursor_latch.ena && svga->interlace) { svga->hwcursor_on = svga->hwcursor_latch.cur_ysize - (svga->hwcursor_latch.yoff + 1); svga->hwcursor_oddeven = 1; } - if (svga->displine == ((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) && svga->dac_hwcursor_latch.enable) { + if (svga->displine == ((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) && svga->dac_hwcursor_latch.ena) { svga->dac_hwcursor_on = svga->dac_hwcursor_latch.cur_ysize - svga->dac_hwcursor_latch.yoff; svga->dac_hwcursor_oddeven = 0; } - if (svga->displine == (((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) + 1) && svga->dac_hwcursor_latch.enable && svga->interlace) { + if (svga->displine == (((svga->dac_hwcursor_latch.y < 0) ? 0 : svga->dac_hwcursor_latch.y) + 1) && svga->dac_hwcursor_latch.ena && svga->interlace) { svga->dac_hwcursor_on = svga->dac_hwcursor_latch.cur_ysize - (svga->dac_hwcursor_latch.yoff + 1); svga->dac_hwcursor_oddeven = 1; } - if (svga->displine == svga->overlay_latch.y && svga->overlay_latch.enable) { + if (svga->displine == svga->overlay_latch.y && svga->overlay_latch.ena) { svga->overlay_on = svga->overlay_latch.cur_ysize - svga->overlay_latch.yoff; svga->overlay_oddeven = 0; } - if (svga->displine == svga->overlay_latch.y + 1 && svga->overlay_latch.enable && svga->interlace) { + if (svga->displine == svga->overlay_latch.y + 1 && svga->overlay_latch.ena && svga->interlace) { svga->overlay_on = svga->overlay_latch.cur_ysize - svga->overlay_latch.yoff; svga->overlay_oddeven = 1; } @@ -1288,6 +1343,7 @@ svga_poll(void *priv) svga->linepos = 1; if (svga->dispon) { + svga->hdisp_on = 1; svga->memaddr &= svga->vram_display_mask; if (svga->firstline == 2000) { @@ -1334,6 +1390,7 @@ svga_poll(void *priv) if (svga->dispon) svga->cgastat &= ~1; + svga->hdisp_on = 0; svga->linepos = 0; if ((svga->scanline == (svga->crtc[11] & 31)) || (svga->scanline == svga->rowcount)) diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index c0ba06a07..5cc3a8a78 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -530,7 +530,7 @@ tgui_out(uint16_t addr, uint8_t val, void *priv) case 0x50: if (tgui->type >= TGUI_9440) { - svga->hwcursor.enable = !!(val & 0x80); + svga->hwcursor.ena = !!(val & 0x80); svga->hwcursor.cur_xsize = svga->hwcursor.cur_ysize = ((val & 1) ? 64 : 32); } break; diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 12cccdccb..4bcf8a479 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -679,7 +679,7 @@ banshee_recalctimings(svga_t *svga) svga->interlace = !!(banshee->vidProcCfg & VIDPROCCFG_INTERLACE); - svga->overlay.enable = banshee->vidProcCfg & VIDPROCCFG_OVERLAY_ENABLE; + svga->overlay.ena = banshee->vidProcCfg & VIDPROCCFG_OVERLAY_ENABLE; svga->overlay.x = voodoo->overlay.start_x; svga->overlay.y = voodoo->overlay.start_y; @@ -689,8 +689,8 @@ banshee_recalctimings(svga_t *svga) if (banshee->vidProcCfg & VIDPROCCFG_OVERLAY_TILE) svga->overlay.pitch *= 128 * 32; if (svga->overlay.cur_xsize <= 0 || svga->overlay.cur_ysize <= 0) - svga->overlay.enable = 0; - if (svga->overlay.enable) { + svga->overlay.ena = 0; + if (svga->overlay.ena) { #if 0 banshee_log("Overlay enabled : start=%i,%i end=%i,%i size=%i,%i pitch=%x\n", voodoo->overlay.start_x, voodoo->overlay.start_y, @@ -894,7 +894,7 @@ banshee_ext_outl(uint16_t addr, uint32_t val, void *priv) banshee_log("vidProcCfg=%08x\n", val); #endif banshee->overlay_pix_fmt = (val & VIDPROCCFG_OVERLAY_PIX_FORMAT_MASK) >> VIDPROCCFG_OVERLAY_PIX_FORMAT_SHIFT; - svga->hwcursor.enable = val & VIDPROCCFG_HWCURSOR_ENA; + svga->hwcursor.ena = val & VIDPROCCFG_HWCURSOR_ENA; svga->fullchange = changeframecount; svga->lut_map = !(val & VIDPROCCFG_DESKTOP_CLUT_BYPASS) && (svga->bpp < 24); svga_recalctimings(svga); diff --git a/src/video/vid_xga.c b/src/video/vid_xga.c index f7a1464e5..8f4dc0d0e 100644 --- a/src/video/vid_xga.c +++ b/src/video/vid_xga.c @@ -257,9 +257,9 @@ xga_render_blank(svga_t *svga) xga->lastline_draw = xga->displine; uint32_t *line_ptr = &svga->monitor->target_buffer->line[xga->displine + svga->y_add][svga->x_add]; - uint32_t line_width = (uint32_t)(xga->hdisp_xga) * sizeof(uint32_t); + uint32_t line_width = (uint32_t)(xga->h_disp) * sizeof(uint32_t); - if (xga->hdisp_xga > 0) + if (xga->h_disp > 0) memset(line_ptr, 0, line_width); } @@ -268,14 +268,14 @@ xga_recalctimings(svga_t *svga) { xga_t *xga = (xga_t *) svga->xga; if (xga->on) { - xga->htotal_xga = xga->htotal + 1; - xga->vtotal_xga = xga->vtotal + 1; + xga->h_total = xga->htotal + 1; + xga->v_total = xga->vtotal + 1; xga->dispend = xga->vdispend + 1; - xga->vsyncstart++; + xga->v_syncstart = xga->vsyncstart + 1; xga->split = xga->linecmp + 1; - xga->vblankstart_xga = xga->vblankstart + 1; + xga->v_blankstart = xga->vblankstart + 1; - xga->hdisp_xga = (xga->hdisp + 1) << 3; + xga->h_disp = (xga->hdisp + 1) << 3; xga->rowoffset = xga->pix_map_width; @@ -283,11 +283,11 @@ xga_recalctimings(svga_t *svga) xga->rowcount = (xga->disp_cntl_2 & 0xc0) >> 6; if (xga->interlace) { - xga->vtotal_xga >>= 1; + xga->v_total >>= 1; xga->dispend >>= 1; - xga->vsyncstart >>= 1; + xga->v_syncstart >>= 1; xga->split >>= 1; - xga->vblankstart_xga >>= 1; + xga->v_blankstart >>= 1; } xga->memaddr_latch = xga->disp_start_addr; @@ -296,14 +296,14 @@ xga_recalctimings(svga_t *svga) xga_log("XGA ClkSel1 = %d, ClkSel2 = %02x, dispcntl2=%02x.\n", (xga->clk_sel_1 >> 2) & 3, xga->clk_sel_2 & 0x80, xga->disp_cntl_2 & 0xc0); switch ((xga->clk_sel_1 >> 2) & 3) { case 0: - xga_log("HDISP VGA0 = %d, XGA = %d.\n", svga->hdisp, xga->hdisp_xga); + xga_log("HDISP VGA0 = %d, XGA = %d.\n", svga->hdisp, xga->h_disp); if (xga->clk_sel_2 & 0x80) svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 41539000.0; else svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 25175000.0; break; case 1: - xga_log("HDISP VGA1 = %d, XGA = %d.\n", svga->hdisp, xga->hdisp_xga); + xga_log("HDISP VGA1 = %d, XGA = %d.\n", svga->hdisp, xga->h_disp); svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 28322000.0; break; case 3: @@ -424,7 +424,7 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val) case 0x36: xga->hwc_control = val; - xga->hwcursor.enable = xga->hwc_control & 1; + xga->hwcursor.ena = xga->hwc_control & 1; break; case 0x38: @@ -1555,7 +1555,7 @@ xga_bitblt(svga_t *svga) if (srcheight == 7) xga->accel.pattern = 1; else { - if ((dstwidth == (xga->hdisp_xga - 1)) && (srcwidth == 1)) { + if ((dstwidth == (xga->h_disp - 1)) && (srcwidth == 1)) { if ((xga->accel.dst_map == 1) && (xga->accel.src_map == 2)) { if ((xga->accel.px_map_format[xga->accel.dst_map] >= 0x0a) && (xga->accel.px_map_format[xga->accel.src_map] >= 0x0a)) xga->accel.pattern = 1; @@ -1640,8 +1640,8 @@ xga_bitblt(svga_t *svga) else if ((xga->accel.src_map == 1) && (patwidth == 7)) xga->accel.pattern = 1; } else { - if (dstwidth == (xga->hdisp_xga - 1)) { - if (srcwidth == (xga->hdisp_xga - 1)) { + if (dstwidth == (xga->h_disp - 1)) { + if (srcwidth == (xga->h_disp - 1)) { if ((xga->accel.src_map == 1) && (xga->accel.dst_map == 1) && (xga->accel.pat_src == 2)) { if ((xga->accel.px_map_format[xga->accel.dst_map] >= 0x0a) && (xga->accel.px <= 7) && (xga->accel.py <= 3)) xga->accel.pattern = 1; @@ -2591,7 +2591,7 @@ xga_render_overscan_left(xga_t *xga, svga_t *svga) if ((xga->displine + svga->y_add) < 0) return; - if (svga->scrblank || (xga->hdisp_xga == 0)) + if (svga->scrblank || (xga->h_disp == 0)) return; uint32_t *line_ptr = buffer32->line[xga->displine + svga->y_add]; @@ -2607,10 +2607,10 @@ xga_render_overscan_right(xga_t *xga, svga_t *svga) if ((xga->displine + svga->y_add) < 0) return; - if (svga->scrblank || (xga->hdisp_xga == 0)) + if (svga->scrblank || (xga->h_disp == 0)) return; - uint32_t *line_ptr = &buffer32->line[xga->displine + svga->y_add][svga->x_add + xga->hdisp_xga]; + uint32_t *line_ptr = &buffer32->line[xga->displine + svga->y_add][svga->x_add + xga->h_disp]; right = (overscan_x >> 1); for (int i = 0; i < right; i++) *line_ptr++ = svga->overscan_color; @@ -2634,7 +2634,7 @@ xga_render_4bpp(svga_t *svga) xga->lastline_draw = xga->displine; - for (int x = 0; x <= xga->hdisp_xga; x += 8) { + for (int x = 0; x <= xga->h_disp; x += 8) { dat = *(uint32_t *) (&xga->vram[xga->memaddr & xga->vram_mask]); p[0] = xga->pallook[dat & 0x0f]; p[1] = xga->pallook[(dat >> 8) & 0x0f]; @@ -2671,7 +2671,7 @@ xga_render_8bpp(svga_t *svga) xga->firstline_draw = xga->displine; xga->lastline_draw = xga->displine; - for (int x = 0; x <= xga->hdisp_xga; x += 8) { + for (int x = 0; x <= xga->h_disp; x += 8) { dat = *(uint32_t *) (&xga->vram[xga->memaddr & xga->vram_mask]); p[0] = xga->pallook[dat & 0xff]; p[1] = xga->pallook[(dat >> 8) & 0xff]; @@ -2709,7 +2709,7 @@ xga_render_16bpp(svga_t *svga) xga->firstline_draw = xga->displine; xga->lastline_draw = xga->displine; - for (x = 0; x <= xga->hdisp_xga; x += 8) { + for (x = 0; x <= xga->h_disp; x += 8) { dat = *(uint32_t *) (&xga->vram[(xga->memaddr + (x << 1)) & xga->vram_mask]); p[x] = video_16to32[dat & 0xffff]; p[x + 1] = video_16to32[dat >> 16]; @@ -3092,12 +3092,12 @@ xga_poll(void *priv) xga_log("XGA Poll=%d.\n", xga->on); if (xga->on) { if (!xga->linepos) { - if (xga->displine == xga->hwcursor_latch.y && xga->hwcursor_latch.enable) { + if (xga->displine == xga->hwcursor_latch.y && xga->hwcursor_latch.ena) { xga->hwcursor_on = xga->hwcursor_latch.cur_ysize - ((xga->hwcursor_latch.yoff & 0x20) ? 32 : 0); xga->hwcursor_oddeven = 0; } - if (xga->displine == (xga->hwcursor_latch.y + 1) && xga->hwcursor_latch.enable && xga->interlace) { + if (xga->displine == (xga->hwcursor_latch.y + 1) && xga->hwcursor_latch.ena && xga->interlace) { xga->hwcursor_on = xga->hwcursor_latch.cur_ysize - ((xga->hwcursor_latch.yoff & 0x20) ? 33 : 1); xga->hwcursor_oddeven = 1; } @@ -3107,7 +3107,7 @@ xga_poll(void *priv) xga->linepos = 1; if (xga->dispon) { - xga->hdispon_xga = 1; + xga->h_disp_on = 1; xga->memaddr &= xga->vram_mask; @@ -3149,7 +3149,7 @@ xga_poll(void *priv) if (xga->dispon) svga->cgastat &= ~1; - xga->hdispon_xga = 0; + xga->h_disp_on = 0; xga->linepos = 0; if (xga->dispon) { @@ -3194,10 +3194,10 @@ xga_poll(void *priv) if (svga->fullchange) svga->fullchange--; } - if (xga->vc == xga->vsyncstart) { + if (xga->vc == xga->v_syncstart) { xga->dispon = 0; svga->cgastat |= 8; - x = xga->hdisp_xga; + x = xga->h_disp; if (xga->interlace && !xga->oddeven) xga->lastline++; @@ -3227,7 +3227,7 @@ xga_poll(void *priv) xga->memaddr = (xga->memaddr << 2); xga->memaddr_backup = (xga->memaddr_backup << 2); } - if (xga->vc == xga->vtotal_xga) { + if (xga->vc == xga->v_total) { xga->vc = 0; xga->scanline = 0; xga->dispon = 1; From 204617d62abe157549e50d0b82149e65ea0f6f28 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 1 Jul 2025 02:13:09 +0200 Subject: [PATCH 084/103] Auto-update: Fix the links so they are actually correct for the given update channel. --- src/qt/qt_updatedetails.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/qt_updatedetails.cpp b/src/qt/qt_updatedetails.cpp index 1d6846dd6..dceeea47c 100644 --- a/src/qt/qt_updatedetails.cpp +++ b/src/qt/qt_updatedetails.cpp @@ -102,10 +102,10 @@ UpdateDetails::visitDownloadPage(const UpdateCheck::UpdateChannel &channel) { switch (channel) { case UpdateCheck::UpdateChannel::Stable: - QDesktopServices::openUrl(QUrl("https://ci.86box.net/job/86Box/lastSuccessfulBuild/artifact/")); - break; - case UpdateCheck::UpdateChannel::CI: QDesktopServices::openUrl(QUrl("https://github.com/86Box/86Box/releases/latest")); - break; + break; + case UpdateCheck::UpdateChannel::CI: + QDesktopServices::openUrl(QUrl("https://ci.86box.net/job/86Box/lastSuccessfulBuild/artifact/")); + break; } } From 69c5e1b3492634a96c3826590b531451e5c9c287 Mon Sep 17 00:00:00 2001 From: GetDizzy Date: Mon, 30 Jun 2025 20:25:38 -0400 Subject: [PATCH 085/103] Disable update menu if EMU_BUILD_NUM == 0 --- src/qt/qt_vmmanager_mainwindow.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qt/qt_vmmanager_mainwindow.cpp b/src/qt/qt_vmmanager_mainwindow.cpp index 767bbcef2..a6f598f58 100644 --- a/src/qt/qt_vmmanager_mainwindow.cpp +++ b/src/qt/qt_vmmanager_mainwindow.cpp @@ -48,8 +48,13 @@ VMManagerMainWindow(QWidget *parent) connect(ui->actionNew_Machine, &QAction::triggered, vmm, &VMManagerMain::newMachineWizard); // Set up menu actions - connect(ui->actionCheck_for_updates, &QAction::triggered, this, &VMManagerMainWindow::checkForUpdatesTriggered); - + // (Disable this if the EMU_BUILD_NUM == 0) + #if EMU_BUILD_NUM == 0 + ui->actionCheck_for_updates->setVisible(false); + #else + connect(ui->actionCheck_for_updates, &QAction::triggered, this, &VMManagerMainWindow::checkForUpdatesTriggered); + #endif + // TODO: Remove all of this (all the way to END REMOVE) once certain the search will no longer be in the toolbar. // BEGIN REMOVE // Everything is still setup here for it but it is all hidden. None of it will be From f92c907299541f82335cd2ab6470d828c5431cfd Mon Sep 17 00:00:00 2001 From: GetDizzy Date: Mon, 30 Jun 2025 20:27:48 -0400 Subject: [PATCH 086/103] Stub out background update check if EMU_BUILD_NUM is 0 --- src/qt/qt_vmmanager_main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 7916abca8..8d59b0996 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -456,6 +456,7 @@ VMManagerMain::onPreferencesUpdated() void VMManagerMain::backgroundUpdateCheckStart() const { +#if EMU_BUILD_NUM != 0 auto updateChannel = UpdateCheck::UpdateChannel::CI; #ifdef RELEASE_BUILD updateChannel = UpdateCheck::UpdateChannel::Stable; @@ -464,6 +465,7 @@ VMManagerMain::backgroundUpdateCheckStart() const connect(updateCheck, &UpdateCheck::updateCheckComplete, this, &VMManagerMain::backgroundUpdateCheckComplete); connect(updateCheck, &UpdateCheck::updateCheckError, this, &VMManagerMain::backgroundUpdateCheckError); updateCheck->checkForUpdates(); +#endif } void From ccf43f62f9fd147eb617f2b5b6293e721d470799 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Tue, 1 Jul 2025 12:51:01 +0600 Subject: [PATCH 087/103] Make picture bouncing effect work on Copper demo --- src/video/vid_et3000.c | 12 ++++++++++++ src/video/vid_et4000.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/video/vid_et3000.c b/src/video/vid_et3000.c index 482cc60a3..a75a63829 100644 --- a/src/video/vid_et3000.c +++ b/src/video/vid_et3000.c @@ -481,6 +481,17 @@ et3000_recalctimings(svga_t *svga) svga->render = svga_render_4bpp_tseng_highres; } +static int +et3000_line_compare(svga_t* svga) +{ + if (svga->split > svga->vsyncstart) { + /* Don't do line compare if we're already in vertical retrace. */ + /* This makes picture bouncing effect work on Copper demo. */ + return 0; + } + return 1; +} + static void * et3000_init(const device_t *info) { @@ -514,6 +525,7 @@ et3000_init(const device_t *info) dev->svga.miscout = 1; dev->svga.packed_chain4 = 1; + dev->svga.line_compare = et3000_line_compare; return dev; } diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index 7dccd9747..b19aad20a 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -784,6 +784,17 @@ et4000_mca_feedb(UNUSED(void *priv)) return et4000->pos_regs[2] & 1; } +static int +et4000_line_compare(svga_t* svga) +{ + if (svga->split > svga->vsyncstart) { + /* Don't do line compare if we're already in vertical retrace. */ + /* This makes picture bouncing effect work on Copper demo. */ + return 0; + } + return 1; +} + static void * et4000_init(const device_t *info) { @@ -897,6 +908,8 @@ et4000_init(const device_t *info) dev->vram_mask = dev->vram_size - 1; + dev->svga.line_compare = et4000_line_compare; + rom_init(&dev->bios_rom, fn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); From e9d289f2a41b65efc3cfe1d6187fb19c4ea271d5 Mon Sep 17 00:00:00 2001 From: Lili Kurek Date: Tue, 1 Jul 2025 11:29:49 +0000 Subject: [PATCH 088/103] Manager: Allow whitespace and some special characters in machine creation wizard I'm not sure why whitespace was disallowed in the first place as Windows accepts them everywhere, including at the start of the name. The character blacklist was Windows-centric, but macOS accepts everything besides slash and colon and Linux disallows only a slash. --- src/qt/qt_vmmanager_addmachine.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qt/qt_vmmanager_addmachine.cpp b/src/qt/qt_vmmanager_addmachine.cpp index db40972a1..3005c0346 100644 --- a/src/qt/qt_vmmanager_addmachine.cpp +++ b/src/qt/qt_vmmanager_addmachine.cpp @@ -210,7 +210,13 @@ NameAndLocationPage(QWidget *parent) { setTitle(tr("System name and location")); - dirValidate = QRegularExpression(R"(^[^\\/:*?"<>|\s]+$)"); +#if defined(_WIN32) + dirValidate = QRegularExpression(R"(^[^\\/:*?"<>|]+$)"); +#elif defined(__APPLE__) + dirValidate = QRegularExpression(R"(^[^/:]+$)"); +#else + dirValidate = QRegularExpression(R"(^[^/]+$)"); +#endif const auto topLabel = new QLabel(tr("Enter the name of the system and choose the location")); topLabel->setWordWrap(true); @@ -282,7 +288,7 @@ NameAndLocationPage::isComplete() const if (systemName->text().isEmpty()) { systemNameValidation->setText(tr("Please enter a system name")); } else if (!systemName->text().contains(dirValidate)) { - systemNameValidation->setText(tr("System name cannot contain a space or certain characters")); + systemNameValidation->setText(tr("System name cannot certain characters")); } else if (const QDir newDir = QDir::cleanPath(systemLocation->text() + "/" + systemName->text()); newDir.exists()) { systemNameValidation->setText(tr("System name already exists")); } else { From bef3b9e155d26b539002e1a88edd5adfc0b6c8c7 Mon Sep 17 00:00:00 2001 From: Lili Kurek Date: Tue, 1 Jul 2025 11:33:18 +0000 Subject: [PATCH 089/103] Cut too much of a string --- src/qt/qt_vmmanager_addmachine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/qt_vmmanager_addmachine.cpp b/src/qt/qt_vmmanager_addmachine.cpp index 3005c0346..597c2ef11 100644 --- a/src/qt/qt_vmmanager_addmachine.cpp +++ b/src/qt/qt_vmmanager_addmachine.cpp @@ -288,7 +288,7 @@ NameAndLocationPage::isComplete() const if (systemName->text().isEmpty()) { systemNameValidation->setText(tr("Please enter a system name")); } else if (!systemName->text().contains(dirValidate)) { - systemNameValidation->setText(tr("System name cannot certain characters")); + systemNameValidation->setText(tr("System name cannot contain certain characters")); } else if (const QDir newDir = QDir::cleanPath(systemLocation->text() + "/" + systemName->text()); newDir.exists()) { systemNameValidation->setText(tr("System name already exists")); } else { From e30f0864826839678819f7159056530615389d56 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 3 Jul 2025 18:22:17 -0400 Subject: [PATCH 090/103] Updates to GHA scripts --- .github/workflows/cmake_linux.yml | 20 ++----- .github/workflows/cmake_macos.yml | 45 +++----------- .github/workflows/cmake_windows_msys2.yml | 48 +++++++++------ .github/workflows/codeql_linux.yml | 40 ++++++++++--- .github/workflows/codeql_macos.yml | 40 ++++++++++--- .github/workflows/codeql_windows_msys2.yml | 68 +++++++++++++++++----- 6 files changed, 159 insertions(+), 102 deletions(-) diff --git a/.github/workflows/cmake_linux.yml b/.github/workflows/cmake_linux.yml index 83672974f..901f5864a 100644 --- a/.github/workflows/cmake_linux.yml +++ b/.github/workflows/cmake_linux.yml @@ -8,6 +8,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" + - "!.github/workflows/**" - .github/workflows/cmake_linux.yml - vcpkg.json - "!**/Makefile*" @@ -18,7 +19,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" - - .github/workflows/** + - "!.github/workflows/**" - .github/workflows/cmake_linux.yml - vcpkg.json - "!**/Makefile*" @@ -26,13 +27,11 @@ on: jobs: linux: + name: "${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64" runs-on: ubuntu-22.04 - env: - BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed - strategy: fail-fast: true matrix: @@ -90,9 +89,6 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Install sonar-scanner and build-wrapper - uses: SonarSource/sonarcloud-github-c-cpp@v3 - - name: Configure CMake run: >- cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }} @@ -103,15 +99,7 @@ jobs: - name: Build run: | - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build - - - name: Run sonar-scanner - if: 0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + cmake --build build - name: Generate package run: | diff --git a/.github/workflows/cmake_macos.yml b/.github/workflows/cmake_macos.yml index 4db41304e..c917932fe 100644 --- a/.github/workflows/cmake_macos.yml +++ b/.github/workflows/cmake_macos.yml @@ -8,6 +8,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" + - "!.github/workflows/**" - .github/workflows/cmake_macos.yml - vcpkg.json - "!**/Makefile*" @@ -18,7 +19,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" - - .github/workflows/** + - "!.github/workflows/**" - .github/workflows/cmake_macos.yml - vcpkg.json - "!**/Makefile*" @@ -26,13 +27,11 @@ on: jobs: macos13-x86_64: + name: "${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64" runs-on: macos-13 - env: - BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed - strategy: fail-fast: true matrix: @@ -80,9 +79,6 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Install sonar-scanner and build-wrapper - uses: SonarSource/sonarcloud-github-c-cpp@v3 - - name: Configure CMake run: >- cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }} @@ -96,20 +92,10 @@ jobs: -D LIBSERIALPORT_ROOT=$(brew --prefix libserialport) - name: Build - run: | - build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build - - - name: Run sonar-scanner - if: 0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + run: cmake --build build - name: Generate package - run: | - cmake --install build + run: cmake --install build - name: Upload artifact uses: actions/upload-artifact@v4 @@ -118,13 +104,11 @@ jobs: path: build/artifacts/** macos14-arm64: + name: "${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, arm64" runs-on: macos-14 -# env: -# BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed - strategy: fail-fast: true matrix: @@ -172,9 +156,6 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis -# - name: Install sonar-scanner and build-wrapper -# uses: SonarSource/sonarcloud-github-c-cpp@v3 - - name: Configure CMake run: >- cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }} @@ -188,20 +169,10 @@ jobs: -D LIBSERIALPORT_ROOT=$(brew --prefix libserialport) - name: Build - run: | - cmake --build build - -# - name: Run sonar-scanner -# if: 0 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# run: | -# sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + run: cmake --build build - name: Generate package - run: | - cmake --install build + run: cmake --install build - name: Upload artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/cmake_windows_msys2.yml b/.github/workflows/cmake_windows_msys2.yml index ca48599a0..eb83d4674 100644 --- a/.github/workflows/cmake_windows_msys2.yml +++ b/.github/workflows/cmake_windows_msys2.yml @@ -8,6 +8,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" + - "!.github/workflows/**" - .github/workflows/cmake_windows_msys2.yml - vcpkg.json - "!**/Makefile*" @@ -18,6 +19,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" + - "!.github/workflows/**" - .github/workflows/cmake_windows_msys2.yml - vcpkg.json - "!**/Makefile*" @@ -25,13 +27,11 @@ on: jobs: msys2: + name: "${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.environment.msystem }}" runs-on: ${{ matrix.environment.runner }} - env: - BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed - defaults: run: shell: msys2 {0} @@ -40,23 +40,47 @@ jobs: fail-fast: true matrix: build: - - name: Dev Debug +# - name: Regular +# preset: regular + - name: Debug preset: dev_debug - slug: -Dev-Debug + slug: -Debug - name: Dev preset: development slug: -Dev dynarec: - name: ODR new: off + slug: -ODR - name: NDR new: on slug: -NDR + ui: + - name: Qt GUI + qt: on + static: on + slug: -Qt + packages: >- + qt5-base:p + qt5-tools:p + vulkan-headers:p environment: +# - msystem: MSYS +# toolchain: ./cmake/flags-gcc-x86_64.cmake +# slug: "-MSYS64" - msystem: MINGW64 + prefix: mingw-w64-x86_64 toolchain: ./cmake/flags-gcc-x86_64.cmake slug: "-64" runner: windows-2022 +# - msystem: CLANG64 +# prefix: mingw-w64-clang-x86_64 +# toolchain: ./cmake/llvm-win32-x86_64.cmake +# slug: "CLANG64" +# - msystem: UCRT64 +# prefix: mingw-w64-ucrt-x86_64 +# toolchain: ./cmake/flags-gcc-x86_64.cmake +# slug: "UCRT64" - msystem: CLANGARM64 toolchain: ./cmake/flags-gcc-aarch64.cmake slug: -arm64 @@ -97,9 +121,6 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - # - name: Install sonar-scanner and build-wrapper - # uses: SonarSource/sonarcloud-github-c-cpp@v3 - - name: Configure CMake run: >- cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }} @@ -107,20 +128,9 @@ jobs: -D NEW_DYNAREC=${{ matrix.dynarec.new }} -D CMAKE_INSTALL_PREFIX=./build/artifacts - # - name: Build - # run: | - # .sonar/build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build - - name: Build run: cmake --build build - # - name: Run sonar-scanner - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # run: | - # .sonar/sonar-scanner-5.0.1.3006-windows/bin/sonar-scanner.bat --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" - - name: Generate package run: cmake --install build diff --git a/.github/workflows/codeql_linux.yml b/.github/workflows/codeql_linux.yml index 2b542b186..b8fb93ef6 100644 --- a/.github/workflows/codeql_linux.yml +++ b/.github/workflows/codeql_linux.yml @@ -9,6 +9,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" + - "!.github/workflows/**" - .github/workflows/codeql_linux.yml - vcpkg.json - "!**/Makefile*" @@ -20,7 +21,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" - - .github/workflows/** + - "!.github/workflows/**" - .github/workflows/codeql_linux.yml - vcpkg.json - "!**/Makefile*" @@ -32,10 +33,13 @@ jobs: analyze-linux: - name: "Analyze Linux GCC 11 (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64)" + name: "Analyze (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64)" runs-on: ubuntu-22.04 + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + permissions: actions: read contents: read @@ -48,12 +52,12 @@ jobs: build: # - name: Regular # preset: regular -# - name: Debug -# preset: debug -# slug: -Debug - - name: Dev + - name: Debug preset: dev_debug - slug: -Dev + slug: -Debug +# - name: Dev +# preset: development +# slug: -Dev dynarec: - name: ODR new: off @@ -64,6 +68,7 @@ jobs: ui: - name: SDL GUI qt: off + static: on - name: Qt GUI qt: on slug: -Qt @@ -95,6 +100,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Install Build Wrapper + uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 - name: Initialize CodeQL uses: github/codeql-action/init@v3 @@ -111,9 +121,23 @@ jobs: -D QT=${{ matrix.ui.qt }} - name: Build - run: cmake --build build + run: | + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" + + - name: SonarQube Scan + if: matrix.build.preset == 'dev_debug' && matrix.dynarec.new == 'on' && matrix.ui.qt == 'on' && env.SONAR_TOKEN != '' +# if: 0 + uses: SonarSource/sonarqube-scan-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }} + with: + # Consult https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/sonarscanner/ for more information and options + args: > + --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" diff --git a/.github/workflows/codeql_macos.yml b/.github/workflows/codeql_macos.yml index eeab0ecc8..203f385ff 100644 --- a/.github/workflows/codeql_macos.yml +++ b/.github/workflows/codeql_macos.yml @@ -9,6 +9,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" + - "!.github/workflows/**" - .github/workflows/codeql_macos.yml - vcpkg.json - "!**/Makefile*" @@ -20,7 +21,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" - - .github/workflows/** + - "!.github/workflows/**" - .github/workflows/codeql_macos.yml - vcpkg.json - "!**/Makefile*" @@ -32,10 +33,13 @@ jobs: analyze-macos13-x86_64: - name: "${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64" + name: "Analyze (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64)" runs-on: macos-13 + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + permissions: actions: read contents: read @@ -48,12 +52,12 @@ jobs: build: # - name: Regular # preset: regular -# - name: Debug -# preset: debug -# slug: -Debug - - name: Dev + - name: Debug preset: dev_debug - slug: -Dev + slug: -Debug +# - name: Dev +# preset: development +# slug: -Dev dynarec: - name: ODR new: off @@ -74,7 +78,6 @@ jobs: - name: Install dependencies run: >- brew install - ninja sdl2 rtmidi openal-soft @@ -86,6 +89,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Install Build Wrapper + uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 - name: Initialize CodeQL uses: github/codeql-action/init@v3 @@ -106,9 +114,23 @@ jobs: -D LIBSERIALPORT_ROOT=$(brew --prefix libserialport) - name: Build - run: cmake --build build + run: | + build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" + + - name: SonarQube Scan +# if: matrix.build.preset == 'dev_debug' && matrix.dynarec.new == 'on' && matrix.ui.qt == 'on' && env.SONAR_TOKEN != '' + if: 0 + uses: SonarSource/sonarqube-scan-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }} + with: + # Consult https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/sonarscanner/ for more information and options + args: > + --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" diff --git a/.github/workflows/codeql_windows_msys2.yml b/.github/workflows/codeql_windows_msys2.yml index f513831e8..e8f2158b0 100644 --- a/.github/workflows/codeql_windows_msys2.yml +++ b/.github/workflows/codeql_windows_msys2.yml @@ -9,6 +9,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" + - "!.github/workflows/**" - .github/workflows/codeql_windows_msys2.yml - vcpkg.json - "!**/Makefile*" @@ -20,7 +21,7 @@ on: - cmake/** - "**/CMakeLists.txt" - "CMakePresets.json" - - .github/workflows/** + - "!.github/workflows/**" - .github/workflows/codeql_windows_msys2.yml - vcpkg.json - "!**/Makefile*" @@ -32,9 +33,12 @@ jobs: analyze-msys2: - name: "${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.environment.msystem }}" + name: "Analyze (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.environment.msystem }})" - runs-on: windows-2022 + runs-on: ${{ matrix.environment.runner }} + + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed permissions: actions: read @@ -52,12 +56,12 @@ jobs: build: # - name: Regular # preset: regular -# - name: Debug -# preset: debug -# slug: -Debug - - name: Dev + - name: Debug preset: dev_debug - slug: -Dev + slug: -Debug +# - name: Dev +# preset: development +# slug: -Dev dynarec: - name: ODR new: off @@ -77,21 +81,37 @@ jobs: environment: # - msystem: MSYS # toolchain: ./cmake/flags-gcc-x86_64.cmake +# slug: "-MSYS64" - msystem: MINGW64 prefix: mingw-w64-x86_64 toolchain: ./cmake/flags-gcc-x86_64.cmake + slug: "-64" + runner: windows-2022 # - msystem: CLANG64 # prefix: mingw-w64-clang-x86_64 # toolchain: ./cmake/llvm-win32-x86_64.cmake - - msystem: UCRT64 - prefix: mingw-w64-ucrt-x86_64 - toolchain: ./cmake/flags-gcc-x86_64.cmake +# slug: "CLANG64" +# runner: windows-2022 +# - msystem: UCRT64 +# prefix: mingw-w64-ucrt-x86_64 +# toolchain: ./cmake/flags-gcc-x86_64.cmake +# slug: "UCRT64" +# runner: windows-2022 + - msystem: CLANGARM64 + toolchain: ./cmake/flags-gcc-aarch64.cmake + slug: -arm64 + runner: windows-11-arm + exclude: + - dynarec: + new: off + environment: + msystem: CLANGARM64 steps: - name: Prepare MSYS2 environment uses: msys2/setup-msys2@v2 with: - release: false + release: true update: true msystem: ${{ matrix.environment.msystem }} pacboy: >- @@ -109,9 +129,15 @@ jobs: fluidsynth:p libserialport:p ${{ matrix.ui.packages }} + openmp:p - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Install Build Wrapper + uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 - name: Initialize CodeQL uses: github/codeql-action/init@v3 @@ -128,11 +154,27 @@ jobs: -D QT=${{ matrix.ui.qt }} -D STATIC_BUILD=${{ matrix.ui.static }} + # - name: Build + # run: | + # .sonar/build-wrapper-win-x86/build-wrapper-win-x86-64.exe --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build + - name: Build run: cmake --build build - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" + + - name: SonarQube Scan +# if: matrix.build.preset == 'dev_debug' && matrix.dynarec.new == 'on' && matrix.ui.qt == 'on' && env.SONAR_TOKEN != '' + if: 0 + uses: SonarSource/sonarqube-scan-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }} + with: + # Consult https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/sonarscanner/ for more information and options + args: > + --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" From e9554aafe0fd7c166d304d8ae2439d3b389e1a8c Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 3 Jul 2025 21:02:35 -0400 Subject: [PATCH 091/103] arm64 linux build support --- .github/workflows/cmake_linux.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake_linux.yml b/.github/workflows/cmake_linux.yml index 901f5864a..ecfedd6ca 100644 --- a/.github/workflows/cmake_linux.yml +++ b/.github/workflows/cmake_linux.yml @@ -28,9 +28,9 @@ jobs: linux: - name: "${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64" + name: "${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.environment.arch }}" - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.environment.runner }} strategy: fail-fast: true @@ -65,6 +65,15 @@ jobs: qttranslations5-l10n libevdev-dev libxkbcommon-x11-dev + environment: + - arch: x86_64 + toolchain: ./cmake/flags-gcc-x86_64.cmake + slug: "-x86_64" + runner: ubuntu-22.04 + - arch: arm64 + toolchain: ./cmake/flags-gcc-aarch64.cmake + slug: -arm64 + runner: ubuntu-22.04-arm steps: - name: Install dependencies @@ -92,7 +101,7 @@ jobs: - name: Configure CMake run: >- cmake -G Ninja -S . -B build --preset ${{ matrix.build.preset }} - --toolchain ./cmake/flags-gcc-x86_64.cmake + --toolchain ${{ matrix.environment.toolchain }} -D NEW_DYNAREC=${{ matrix.dynarec.new }} -D CMAKE_INSTALL_PREFIX=./build/artifacts -D QT=${{ matrix.ui.qt }} @@ -108,5 +117,5 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: '86Box${{ matrix.ui.slug }}${{ matrix.dynarec.slug }}${{ matrix.build.slug }}-UbuntuJammy-x86_64-gha${{ github.run_number }}' + name: '86Box${{ matrix.ui.slug }}${{ matrix.dynarec.slug }}${{ matrix.build.slug }}-UbuntuJammy${{ matrix.environment.slug }}-gha${{ github.run_number }}' path: build/artifacts/** From e4994c24c0bc0c8c82b1739b177e764b1449ac54 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 3 Jul 2025 21:43:14 -0400 Subject: [PATCH 092/103] Fix codeql on arm64 windows --- .github/workflows/codeql_windows_msys2.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeql_windows_msys2.yml b/.github/workflows/codeql_windows_msys2.yml index e8f2158b0..c7edae77f 100644 --- a/.github/workflows/codeql_windows_msys2.yml +++ b/.github/workflows/codeql_windows_msys2.yml @@ -97,10 +97,10 @@ jobs: # toolchain: ./cmake/flags-gcc-x86_64.cmake # slug: "UCRT64" # runner: windows-2022 - - msystem: CLANGARM64 - toolchain: ./cmake/flags-gcc-aarch64.cmake - slug: -arm64 - runner: windows-11-arm +# - msystem: CLANGARM64 +# toolchain: ./cmake/flags-gcc-aarch64.cmake +# slug: -arm64 +# runner: windows-11-arm exclude: - dynarec: new: off @@ -136,8 +136,8 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Install Build Wrapper - uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 +# - name: Install Build Wrapper +# uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 - name: Initialize CodeQL uses: github/codeql-action/init@v3 From 5ab5c7b7c9d39be1d3f323989227cc4004cd3e50 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 3 Jul 2025 22:09:24 -0400 Subject: [PATCH 093/103] Missed bit --- .github/workflows/cmake_linux.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cmake_linux.yml b/.github/workflows/cmake_linux.yml index ecfedd6ca..012db79b7 100644 --- a/.github/workflows/cmake_linux.yml +++ b/.github/workflows/cmake_linux.yml @@ -74,6 +74,11 @@ jobs: toolchain: ./cmake/flags-gcc-aarch64.cmake slug: -arm64 runner: ubuntu-22.04-arm + exclude: + - dynarec: + new: off + environment: + arch: arm64 steps: - name: Install dependencies From f27e1fb8a296140ddc95e12f7c0bb988570d7288 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Wed, 11 Dec 2024 13:03:21 -0500 Subject: [PATCH 094/103] Support for Quadram Quadcolor I / I + II --- src/include/86box/vid_quadcolor.h | 93 +++ src/include/86box/video.h | 3 + src/video/CMakeLists.txt | 5 +- src/video/vid_cga_quadcolor.c | 981 ++++++++++++++++++++++++++++++ src/video/vid_table.c | 1 + 5 files changed, 1081 insertions(+), 2 deletions(-) create mode 100644 src/include/86box/vid_quadcolor.h create mode 100644 src/video/vid_cga_quadcolor.c diff --git a/src/include/86box/vid_quadcolor.h b/src/include/86box/vid_quadcolor.h new file mode 100644 index 000000000..41b39dfb0 --- /dev/null +++ b/src/include/86box/vid_quadcolor.h @@ -0,0 +1,93 @@ +/* + * 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. + * + * Quadram Quadcolor I / I+II emulation + * + * Authors: Benedikt Freisen, + * Jasmine Iwanek, + * + * Copyright 2024 Benedikt Freisen. + Copyright 2025 Jasmine Iwanek. + */ + +#ifndef _VID_QUADCOLOR_H_ +#define _VID_QUADCOLOR_H_ + +typedef struct quadcolor_t { + mem_mapping_t mapping; + mem_mapping_t mapping_2; + + int crtcreg; +#if 0 + uint8_t crtc[CGA_NUM_CRTC_REGS]; +#else + uint8_t crtc[32]; +#endif + uint8_t cgastat; + + uint8_t cgamode; + uint8_t cgacol; + + uint8_t lp_strobe; + + uint8_t quadcolor_ctrl; + uint8_t quadcolor_2_oe; + uint16_t page_offset; + + int fontbase; + int linepos; + int displine; + int scanline; + int vc; + int cgadispon; + int cursorvisible; // Determines if the cursor is visible FOR THE CURRENT SCANLINE. + int cursoron; + int cgablink; + int vsynctime; + int vadj; + uint16_t memaddr; + uint16_t memaddr_backup; + int oddeven; + + int qc2idx; + uint8_t qc2mask; + + uint64_t dispontime; + uint64_t dispofftime; + pc_timer_t timer; + + int firstline; + int lastline; + + int drawcursor; + + int fullchange; + + uint8_t *vram; + uint8_t *vram_2; + + uint8_t charbuffer[256]; + + int revision; + int composite; + int rgb_type; + int double_type; + + int has_2nd_charset; + int has_quadcolor_2; +} quadcolor_t; + +void quadcolor_init(quadcolor_t *quadcolor); +void quadcolor_out(uint16_t addr, uint8_t val, void *priv); +uint8_t quadcolor_in(uint16_t addr, void *priv); +void quadcolor_write(uint32_t addr, uint8_t val, void *priv); +uint8_t quadcolor_read(uint32_t addr, void *priv); +void quadcolor_recalctimings(quadcolor_t *quadcolor); +void quadcolor_poll(void *priv); + +#endif /* _VID_QUADCOLOR_H_ */ diff --git a/src/include/86box/video.h b/src/include/86box/video.h index 986529d6f..70d031a4f 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -491,6 +491,9 @@ extern const device_t paradise_wd90c11_megapc_device; extern const device_t paradise_wd90c11_device; extern const device_t paradise_wd90c30_device; +/* Quadram Quadcolor I / I + II */ +extern const device_t quadcolor_device; + /* Realtek (S)VGA */ extern const device_t realtek_rtg3105_device; extern const device_t realtek_rtg3106_device; diff --git a/src/video/CMakeLists.txt b/src/video/CMakeLists.txt index 4cac8b76d..1159c93e2 100644 --- a/src/video/CMakeLists.txt +++ b/src/video/CMakeLists.txt @@ -55,8 +55,9 @@ add_library(vid OBJECT vid_cga_colorplus.c vid_cga_ncr.c vid_cga_olivetti.c - vid_cga_toshiba_t1000.c - vid_cga_toshiba_t3100e.c + vid_cga_quadcolor.c + vid_cga_toshiba_t1000.c + vid_cga_toshiba_t3100e.c # PCJr/Tandy vid_pcjr.c diff --git a/src/video/vid_cga_quadcolor.c b/src/video/vid_cga_quadcolor.c new file mode 100644 index 000000000..5974682c8 --- /dev/null +++ b/src/video/vid_cga_quadcolor.c @@ -0,0 +1,981 @@ +/* + * 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. + * + * Quadram Quadcolor I / I+II emulation + * + * Authors: Sarah Walker, + * Miran Grca, + * W. M. Martinez, + * Benedikt Freisen, + * Jasmine Iwanek, + * + * Copyright 2008-2019 Sarah Walker. + * Copyright 2016-2019 Miran Grca. + * Copyright 2023 W. M. Martinez + * Copyright 2024 Benedikt Freisen. + * Copyright 2025 Jasmine Iwanek. + */ + +/* This has been derived from CGA emulation */ +/* omissions: simulated snow (Quadcolor has dual-ported RAM), single and dual 8x16 font configuration */ +/* additions: ports 0x3dd and 0x3de, 2nd char set, 2nd VRAM bank, hi-res bg color, Quadcolor II memory and mode */ +/* assumptions: MA line 12 XORed with Bank Select, hi-res bg is also border color, QC2 mode has simple address counter */ + +#include +#include +#include +#include +#include +#include +#include <86box/86box.h> +#include "cpu.h" +#include <86box/io.h> +#include <86box/timer.h> +#include <86box/pit.h> +#include <86box/mem.h> +#include <86box/rom.h> +#include <86box/device.h> +#include <86box/video.h> +#include <86box/vid_cga.h> +#include <86box/vid_quadcolor.h> +#include <86box/vid_cga_comp.h> +#include <86box/plat_unused.h> + +#define CGA_RGB 0 +#define CGA_COMPOSITE 1 + +#define COMPOSITE_OLD 0 +#define COMPOSITE_NEW 1 + +#define DOUBLE_NONE 0 +#define DOUBLE_SIMPLE 1 +#define DOUBLE_INTERPOLATE_SRGB 2 +#define DOUBLE_INTERPOLATE_LINEAR 3 + +#define DEVICE_VRAM 0x8000 +#define DEVICE_VRAM_MASK 0x7fff + +typedef union { + uint32_t color; + struct { + uint8_t b; + uint8_t g; + uint8_t r; + uint8_t a; + }; +} color_t; + +static uint8_t crtcmask[32] = { + 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +static uint8_t interp_lut[2][256][256]; + +static video_timings_t timing_quadcolor = { .type = VIDEO_ISA, .write_b = 8, .write_w = 16, .write_l = 32, .read_b = 8, .read_w = 16, .read_l = 32 }; + +void quadcolor_recalctimings(quadcolor_t *quadcolor); + +static void +quadcolor_update_latch(quadcolor_t *quadcolor) +{ + uint32_t lp_latch = quadcolor->displine * quadcolor->crtc[CGA_CRTC_HDISP]; + + quadcolor->crtc[CGA_CRTC_LIGHT_PEN_ADDR_HIGH] = (lp_latch >> 8) & 0x3f; + quadcolor->crtc[CGA_CRTC_LIGHT_PEN_ADDR_LOW] = lp_latch & 0xff; +} + +void +quadcolor_out(uint16_t addr, uint8_t val, void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + uint8_t old; + + if ((addr >= 0x3d0) && (addr <= 0x3d7)) + addr = (addr & 0xff9) | 0x004; + + switch (addr) { + case CGA_REGISTER_CRTC_INDEX: + quadcolor->crtcreg = val & 31; + return; + case CGA_REGISTER_CRTC_DATA: + old = quadcolor->crtc[quadcolor->crtcreg]; + quadcolor->crtc[quadcolor->crtcreg] = val & crtcmask[quadcolor->crtcreg]; + if (old != val) { + // Recalc the timings if we are writing any invalid CRTC register or a valid CRTC register + // except the CURSOR and LIGHT PEN registers + if ((quadcolor->crtcreg < 0xe) || (quadcolor->crtcreg > 0x11)) { + quadcolor->fullchange = changeframecount; + quadcolor_recalctimings(quadcolor); + } + } + return; + case CGA_REGISTER_MODE_CONTROL: + old = quadcolor->cgamode; + quadcolor->cgamode = val; + + if (old ^ val) { + if ((old ^ val) & 0x07) + update_cga16_color(val); + + quadcolor_recalctimings(quadcolor); + } + return; + case CGA_REGISTER_COLOR_SELECT: + old = quadcolor->cgacol; + quadcolor->cgacol = val; + if (old ^ val) + quadcolor_recalctimings(quadcolor); + return; + + case CGA_REGISTER_CLEAR_LIGHT_PEN_LATCH: + if (quadcolor->lp_strobe == 1) + quadcolor->lp_strobe = 0; + return; + case CGA_REGISTER_SET_LIGHT_PEN_LATCH: + if (quadcolor->lp_strobe == 0) { + quadcolor->lp_strobe = 1; + quadcolor_update_latch(quadcolor); + } + return; + + case 0x3dd: + quadcolor->quadcolor_ctrl = val & 0x3f; + /* helper variable that can be XORed onto the VRAM address to select the page to display */ + quadcolor->page_offset = (val & 0x10) << 8; + /* in dual 8x8 font configuration, use fontbase 256 if "Character Set Select" bit is set */ + if (quadcolor->has_2nd_charset) + quadcolor->fontbase = (val & 0x20) << 3; + return; + case 0x3de: + /* NOTE: the polarity of this register is the opposite of what the manual says */ + if (quadcolor->has_quadcolor_2) + quadcolor->quadcolor_2_oe = !(val & 0x10); + return; + + default: + break; + } +} + +uint8_t +quadcolor_in(uint16_t addr, void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + uint8_t ret = 0xff; + + if ((addr >= 0x3d0) && (addr <= 0x3d7)) + addr = (addr & 0xff9) | 0x004; + + switch (addr) { + case CGA_REGISTER_CRTC_INDEX: + ret = quadcolor->crtcreg; + break; + case CGA_REGISTER_CRTC_DATA: + ret = quadcolor->crtc[quadcolor->crtcreg]; + break; + case CGA_REGISTER_STATUS: + ret = quadcolor->cgastat; + break; + case CGA_REGISTER_CLEAR_LIGHT_PEN_LATCH: + if (quadcolor->lp_strobe == 1) + quadcolor->lp_strobe = 0; + break; + case CGA_REGISTER_SET_LIGHT_PEN_LATCH: + if (quadcolor->lp_strobe == 0) { + quadcolor->lp_strobe = 1; + quadcolor_update_latch(quadcolor); + } + break; + + default: + break; + } + + return ret; +} + +void +quadcolor_waitstates(UNUSED(void *priv)) +{ + int ws_array[16] = { 3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8 }; + int ws; + + ws = ws_array[cycles & 0xf]; + cycles -= ws; +} + +void +quadcolor_write(uint32_t addr, uint8_t val, void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + + quadcolor->vram[addr & DEVICE_VRAM_MASK] = val; + quadcolor_waitstates(quadcolor); +} + +uint8_t +quadcolor_read(uint32_t addr, void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + + quadcolor_waitstates(quadcolor); + return quadcolor->vram[addr & DEVICE_VRAM_MASK]; +} + +void +quadcolor_2_write(uint32_t addr, uint8_t val, void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + quadcolor->vram_2[addr & 0xffff] = val; +} + +uint8_t +quadcolor_2_read(uint32_t addr, void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + return quadcolor->vram_2[addr & 0xffff]; +} + +void +quadcolor_recalctimings(quadcolor_t *quadcolor) +{ + double disptime; + double _dispontime; + double _dispofftime; + + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) { + disptime = (double) (quadcolor->crtc[CGA_CRTC_HTOTAL] + 1); + _dispontime = (double) quadcolor->crtc[CGA_CRTC_HDISP]; + } else { + disptime = (double) ((quadcolor->crtc[CGA_CRTC_HTOTAL] + 1) << 1); + _dispontime = (double) (quadcolor->crtc[CGA_CRTC_HDISP] << 1); + } + _dispofftime = disptime - _dispontime; + _dispontime = _dispontime * CGACONST; + _dispofftime = _dispofftime * CGACONST; + quadcolor->dispontime = (uint64_t) (_dispontime); + quadcolor->dispofftime = (uint64_t) (_dispofftime); +} + +static inline uint8_t +get_next_qc2_pixel(quadcolor_t *quadcolor) +{ + uint8_t mask = quadcolor->qc2mask; + quadcolor->qc2mask = ~quadcolor->qc2mask; + uint8_t pixel = (quadcolor->vram_2[quadcolor->qc2idx] & mask) >> (quadcolor->qc2mask & 4); + + quadcolor->qc2idx += quadcolor->qc2mask >> 7; + + return quadcolor->quadcolor_2_oe ? pixel : 0; +} + +static void +quadcolor_render(quadcolor_t *quadcolor, int line) +{ + uint16_t cursoraddr = (quadcolor->crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (quadcolor->crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & DEVICE_VRAM_MASK; + int drawcursor; + int x; + int column; + uint8_t chr; + uint8_t attr; + uint16_t dat; + int cols[4]; + int col; + + int32_t highres_graphics_flag = (CGA_MODE_FLAG_HIGHRES_GRAPHICS | CGA_MODE_FLAG_GRAPHICS); + + if (((quadcolor->cgamode & highres_graphics_flag) == highres_graphics_flag)) { + for (column = 0; column < 8; ++column) { + buffer32->line[line][column] = 0; + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) + buffer32->line[line][column + (quadcolor->crtc[CGA_CRTC_HDISP] << 3) + 8] = (quadcolor->quadcolor_ctrl & 15); /* TODO: Is Quadcolor bg color actually relevant, here? */ + else + buffer32->line[line][column + (quadcolor->crtc[CGA_CRTC_HDISP] << 4) + 8] = (quadcolor->quadcolor_ctrl & 15); /* TODO: Is Quadcolor bg color actually relevant, here? */ + } + } else { + for (column = 0; column < 8; ++column) { + buffer32->line[line][column] = (quadcolor->cgacol & 15) + 16; + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) + buffer32->line[line][column + (quadcolor->crtc[CGA_CRTC_HDISP] << 3) + 8] = (quadcolor->cgacol & 15) + 16; + else + buffer32->line[line][column + (quadcolor->crtc[CGA_CRTC_HDISP] << 4) + 8] = (quadcolor->cgacol & 15) + 16; + } + } + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) { /* 80-column text */ + for (x = 0; x < quadcolor->crtc[CGA_CRTC_HDISP]; x++) { + if (quadcolor->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) { + chr = quadcolor->charbuffer[x << 1]; + attr = quadcolor->charbuffer[(x << 1) + 1]; + } else + chr = attr = 0; + drawcursor = ((quadcolor->memaddr == cursoraddr) && quadcolor->cursorvisible && quadcolor->cursoron); + cols[1] = (attr & 15) + 16; + if (quadcolor->cgamode & CGA_MODE_FLAG_BLINK) { + cols[0] = ((attr >> 4) & 7) + 16; + if ((quadcolor->cgablink & 8) && (attr & 0x80) && !quadcolor->drawcursor) + cols[1] = cols[0]; + } else + cols[0] = (attr >> 4) + 16; + if (drawcursor) { + for (column = 0; column < 8; column++) { + buffer32->line[line][(x << 3) + column + 8] + = (cols[(fontdat[chr + quadcolor->fontbase][quadcolor->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0] ^ 15) | get_next_qc2_pixel(quadcolor); + } + } else { + for (column = 0; column < 8; column++) { + buffer32->line[line][(x << 3) + column + 8] + = cols[(fontdat[chr + quadcolor->fontbase][quadcolor->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0] | get_next_qc2_pixel(quadcolor); + } + } + quadcolor->memaddr++; + } + } else if (!(quadcolor->cgamode & CGA_MODE_FLAG_GRAPHICS)) { /* not graphics (nor 80-column text) => 40-column text */ + for (x = 0; x < quadcolor->crtc[CGA_CRTC_HDISP]; x++) { + if (quadcolor->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) { + chr = quadcolor->vram[(quadcolor->page_offset ^ (quadcolor->memaddr << 1)) & DEVICE_VRAM_MASK]; + attr = quadcolor->vram[(quadcolor->page_offset ^ ((quadcolor->memaddr << 1) + 1)) & DEVICE_VRAM_MASK]; + } else + chr = attr = 0; + drawcursor = ((quadcolor->memaddr == cursoraddr) && quadcolor->cursorvisible && quadcolor->cursoron); + cols[1] = (attr & 15) + 16; + if (quadcolor->cgamode & CGA_MODE_FLAG_BLINK) { + cols[0] = ((attr >> 4) & 7) + 16; + if ((quadcolor->cgablink & 8) && (attr & 0x80)) + cols[1] = cols[0]; + } else + cols[0] = (attr >> 4) + 16; + quadcolor->memaddr++; + if (drawcursor) { + for (column = 0; column < 8; column++) { + dat = (cols[(fontdat[chr + quadcolor->fontbase][quadcolor->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0] ^ 15); + buffer32->line[line][(x << 4) + (column << 1) + 8] = dat | get_next_qc2_pixel(quadcolor); + buffer32->line[line][(x << 4) + (column << 1) + 9] = dat | get_next_qc2_pixel(quadcolor); + + } + } else { + for (column = 0; column < 8; column++) { + dat = cols[(fontdat[chr + quadcolor->fontbase][quadcolor->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0]; + buffer32->line[line][(x << 4) + (column << 1) + 8] = dat | get_next_qc2_pixel(quadcolor); + buffer32->line[line][(x << 4) + (column << 1) + 9] = dat | get_next_qc2_pixel(quadcolor); + + } + } + } + } else if (!(quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) { /* not hi-res (but graphics) => 4-color mode */ + cols[0] = (quadcolor->cgacol & 15) | 16; + col = (quadcolor->cgacol & 16) ? 24 : 16; + if (quadcolor->cgamode & CGA_MODE_FLAG_BW) { + cols[1] = col | 3; /* Cyan */ + cols[2] = col | 4; /* Red */ + cols[3] = col | 7; /* White */ + } else if (quadcolor->cgacol & 32) { + cols[1] = col | 3; /* Cyan */ + cols[2] = col | 5; /* Magenta */ + cols[3] = col | 7; /* White */ + } else { + cols[1] = col | 2; /* Green */ + cols[2] = col | 4; /* Red */ + cols[3] = col | 6; /* Yellow */ + } + for (x = 0; x < quadcolor->crtc[CGA_CRTC_HDISP]; x++) { + if (quadcolor->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) + dat = (quadcolor->vram[quadcolor->page_offset ^ (((quadcolor->memaddr << 1) & 0x1fff) + ((quadcolor->scanline & 1) * 0x2000))] << 8) | + quadcolor->vram[quadcolor->page_offset ^ (((quadcolor->memaddr << 1) & 0x1fff) + ((quadcolor->scanline & 1) * 0x2000) + 1)]; + else + dat = 0; + quadcolor->memaddr++; + for (column = 0; column < 8; column++) { + buffer32->line[line][(x << 4) + (column << 1) + 8] = cols[dat >> 14] | get_next_qc2_pixel(quadcolor); + buffer32->line[line][(x << 4) + (column << 1) + 9] = cols[dat >> 14] | get_next_qc2_pixel(quadcolor); + dat <<= 2; + } + } + } else { /* 2-color hi-res graphics mode */ + cols[0] = quadcolor->quadcolor_ctrl & 15; /* background color (Quadcolor-specific) */; + cols[1] = (quadcolor->cgacol & 15) + 16; + for (x = 0; x < quadcolor->crtc[CGA_CRTC_HDISP]; x++) { + if (quadcolor->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) /* video enabled */ + dat = (quadcolor->vram[quadcolor->page_offset ^ (((quadcolor->memaddr << 1) & 0x1fff) + ((quadcolor->scanline & 1) * 0x2000))] << 8) | + quadcolor->vram[quadcolor->page_offset ^ (((quadcolor->memaddr << 1) & 0x1fff) + ((quadcolor->scanline & 1) * 0x2000) + 1)]; + else + dat = quadcolor->quadcolor_ctrl & 15; /* TODO: Is Quadcolor bg color actually relevant, here? Probably. See QC2 manual p.46 1. */; + quadcolor->memaddr++; + for (column = 0; column < 16; column++) { + buffer32->line[line][(x << 4) + column + 8] = cols[dat >> 15] | get_next_qc2_pixel(quadcolor); + dat <<= 1; + } + } + } +} + +static void +quadcolor_render_blank(quadcolor_t *quadcolor, int line) +{ + int32_t highres_graphics_flag = (CGA_MODE_FLAG_HIGHRES_GRAPHICS | CGA_MODE_FLAG_GRAPHICS); + + /* `+ 16` isn't in PCem's version */ + int col = ((quadcolor->cgamode & highres_graphics_flag) == highres_graphics_flag) ? (quadcolor->quadcolor_ctrl & 15) + 16 : (quadcolor->cgacol & 15) + 16; /* TODO: Is Quadcolor bg color actually relevant, here? */ + + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) + hline(buffer32, 0, line, (quadcolor->crtc[CGA_CRTC_HDISP] << 3) + 16, col); + else + hline(buffer32, 0, line, (quadcolor->crtc[CGA_CRTC_HDISP] << 4) + 16, col); +} + +static void +quadcolor_render_process(quadcolor_t *quadcolor, int line) +{ + int x; + uint8_t border; + int32_t highres_graphics_flag = (CGA_MODE_FLAG_HIGHRES_GRAPHICS | CGA_MODE_FLAG_GRAPHICS); + + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) + x = (quadcolor->crtc[CGA_CRTC_HDISP] << 3) + 16; + else + x = (quadcolor->crtc[CGA_CRTC_HDISP] << 4) + 16; + + if (quadcolor->composite) { + border = ((quadcolor->cgamode & highres_graphics_flag) == highres_graphics_flag) ? 0 : (quadcolor->cgacol & 15); + + Composite_Process(quadcolor->cgamode, border, x >> 2, buffer32->line[line]); + } else + video_process_8(x, line); +} + +static uint8_t +quadcolor_interpolate_srgb(uint8_t co1, uint8_t co2, double fraction) +{ + uint8_t ret = ((co2 - co1) * fraction + co1); + + return ret; +} + +static uint8_t +quadcolor_interpolate_linear(uint8_t co1, uint8_t co2, double fraction) +{ + double c1, c2; + double r1, r2; + uint8_t ret; + + c1 = ((double) co1) / 255.0; + c1 = pow((co1 >= 0) ? c1 : -c1, 2.19921875); + if (co1 <= 0) + c1 = -c1; + c2 = ((double) co2) / 255.0; + c2 = pow((co2 >= 0) ? c2 : -c2, 2.19921875); + if (co2 <= 0) + c2 = -c2; + r1 = ((c2 - c1) * fraction + c1); + r2 = pow((r1 >= 0.0) ? r1 : -r1, 1.0 / 2.19921875); + if (r1 <= 0.0) + r2 = -r2; + ret = (uint8_t) round(r2 * 255.0); + + return ret; +} + +static color_t +quadcolor_interpolate_lookup(quadcolor_t *quadcolor, color_t color1, color_t color2, UNUSED(double fraction)) +{ + color_t ret; + uint8_t dt = quadcolor->double_type - DOUBLE_INTERPOLATE_SRGB; + + ret.a = 0x00; + ret.r = interp_lut[dt][color1.r][color2.r]; + ret.g = interp_lut[dt][color1.g][color2.g]; + ret.b = interp_lut[dt][color1.b][color2.b]; + + return ret; +} + +static void +quadcolor_interpolate(quadcolor_t *quadcolor, int x, int y, int w, int h) +{ + double quotient = 0.5; + + for (int i = y; i < (y + h); i++) { + if (i & 1) for (int j = x; j < (x + w); j++) { + int prev = i - 1; + int next = i + 1; + color_t prev_color, next_color; + color_t black; + color_t interim_1, interim_2; + color_t final; + + if (i < 0) + continue; + + black.color = 0x00000000; + + if ((prev >= 0) && (prev < (y + h))) + prev_color.color = buffer32->line[prev][j]; + else + prev_color.color = 0x00000000; + + if ((next >= 0) && (next < (y + h))) + next_color.color = buffer32->line[next][j]; + else + next_color.color = 0x00000000; + + interim_1 = quadcolor_interpolate_lookup(quadcolor, prev_color, black, quotient); + interim_2 = quadcolor_interpolate_lookup(quadcolor, black, next_color, quotient); + final = quadcolor_interpolate_lookup(quadcolor, interim_1, interim_2, quotient); + + buffer32->line[i][j] = final.color; + } + } +} + +static void +quadcolor_blit_memtoscreen(quadcolor_t *quadcolor, int x, int y, int w, int h) +{ + if (quadcolor->double_type > DOUBLE_SIMPLE) + quadcolor_interpolate(quadcolor, x, y, w, h); + + video_blit_memtoscreen(x, y, w, h); +} + +void +quadcolor_poll(void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + int x; + int scanline_old; + int oldvc; + int xs_temp; + int ys_temp; + int old_ma; + + if (!quadcolor->linepos) { + timer_advance_u64(&quadcolor->timer, quadcolor->dispofftime); + quadcolor->cgastat |= 1; + quadcolor->linepos = 1; + scanline_old = quadcolor->scanline; + if ((quadcolor->crtc[CGA_CRTC_INTERLACE] & 3) == 3) + quadcolor->scanline = ((quadcolor->scanline << 1) + quadcolor->oddeven) & 7; + if (quadcolor->cgadispon) { + if (quadcolor->displine < quadcolor->firstline) { + quadcolor->firstline = quadcolor->displine; + video_wait_for_buffer(); + } + quadcolor->lastline = quadcolor->displine; + switch (quadcolor->double_type) { + default: + quadcolor_render(quadcolor, quadcolor->displine << 1); + quadcolor_render_blank(quadcolor, (quadcolor->displine << 1) + 1); + break; + case DOUBLE_NONE: + quadcolor_render(quadcolor, quadcolor->displine); + break; + case DOUBLE_SIMPLE: + old_ma = quadcolor->memaddr; + quadcolor_render(quadcolor, quadcolor->displine << 1); + quadcolor->memaddr = old_ma; + quadcolor_render(quadcolor, (quadcolor->displine << 1) + 1); + break; + } + } else { + switch (quadcolor->double_type) { + default: + quadcolor_render_blank(quadcolor, quadcolor->displine << 1); + break; + case DOUBLE_NONE: + quadcolor_render_blank(quadcolor, quadcolor->displine); + break; + case DOUBLE_SIMPLE: + quadcolor_render_blank(quadcolor, quadcolor->displine << 1); + quadcolor_render_blank(quadcolor, (quadcolor->displine << 1) + 1); + break; + } + } + + switch (quadcolor->double_type) { + default: + quadcolor_render_process(quadcolor, quadcolor->displine << 1); + quadcolor_render_process(quadcolor, (quadcolor->displine << 1) + 1); + break; + case DOUBLE_NONE: + quadcolor_render_process(quadcolor, quadcolor->displine); + break; + } + + quadcolor->scanline = scanline_old; + if (quadcolor->vc == quadcolor->crtc[CGA_CRTC_VSYNC] && !quadcolor->scanline) + quadcolor->cgastat |= 8; + quadcolor->displine++; + if (quadcolor->displine >= 360) + quadcolor->displine = 0; + } else { + timer_advance_u64(&quadcolor->timer, quadcolor->dispontime); + quadcolor->linepos = 0; + if (quadcolor->vsynctime) { + quadcolor->vsynctime--; + if (!quadcolor->vsynctime) + quadcolor->cgastat &= ~8; + quadcolor->qc2idx = 0; + quadcolor->qc2mask = 0xf0; + } + if (quadcolor->scanline == (quadcolor->crtc[CGA_CRTC_CURSOR_END] & 31) || ((quadcolor->crtc[CGA_CRTC_INTERLACE] & 3) == 3 && + quadcolor->scanline == ((quadcolor->crtc[CGA_CRTC_CURSOR_END] & 31) >> 1))) { + quadcolor->cursorvisible = 0; + } + if ((quadcolor->crtc[CGA_CRTC_INTERLACE] & 3) == 3 && quadcolor->scanline == (quadcolor->crtc[CGA_CRTC_MAX_SCANLINE_ADDR] >> 1)) + quadcolor->memaddr_backup = quadcolor->memaddr; + if (quadcolor->vadj) { + quadcolor->scanline++; + quadcolor->scanline &= 31; + quadcolor->memaddr = quadcolor->memaddr_backup; + quadcolor->vadj--; + if (!quadcolor->vadj) { + quadcolor->cgadispon = 1; + quadcolor->memaddr = quadcolor->memaddr_backup = (quadcolor->crtc[CGA_CRTC_START_ADDR_LOW] | (quadcolor->crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & DEVICE_VRAM_MASK; + quadcolor->scanline = 0; + } + } else if (quadcolor->scanline == quadcolor->crtc[CGA_CRTC_MAX_SCANLINE_ADDR]) { + quadcolor->memaddr_backup = quadcolor->memaddr; + quadcolor->scanline = 0; + oldvc = quadcolor->vc; + quadcolor->vc++; + quadcolor->vc &= 127; + + if (quadcolor->vc == quadcolor->crtc[CGA_CRTC_VDISP]) + quadcolor->cgadispon = 0; + + if (oldvc == quadcolor->crtc[CGA_CRTC_VTOTAL]) { + quadcolor->vc = 0; + quadcolor->vadj = quadcolor->crtc[CGA_CRTC_VTOTAL_ADJUST]; + if (!quadcolor->vadj) { + quadcolor->cgadispon = 1; + quadcolor->memaddr = quadcolor->memaddr_backup = (quadcolor->crtc[CGA_CRTC_START_ADDR_LOW] | (quadcolor->crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & DEVICE_VRAM_MASK; + } + + switch (quadcolor->crtc[CGA_CRTC_CURSOR_START] & 0x60) { + case 0x20: + quadcolor->cursoron = 0; + break; + case 0x60: + quadcolor->cursoron = quadcolor->cgablink & 0x10; + break; + default: + quadcolor->cursoron = quadcolor->cgablink & 0x08; + break; + } + } + + if (quadcolor->vc == quadcolor->crtc[CGA_CRTC_VSYNC]) { + quadcolor->cgadispon = 0; + quadcolor->displine = 0; + quadcolor->vsynctime = 16; + if (quadcolor->crtc[CGA_CRTC_VSYNC]) { + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) + x = (quadcolor->crtc[CGA_CRTC_HDISP] << 3) + 16; + else + x = (quadcolor->crtc[CGA_CRTC_HDISP] << 4) + 16; + quadcolor->lastline++; + + xs_temp = x; + ys_temp = quadcolor->lastline - quadcolor->firstline; + if (quadcolor->double_type > DOUBLE_NONE) + ys_temp <<= 1; + + if ((xs_temp > 0) && (ys_temp > 0)) { + if (xs_temp < 64) + xs_temp = 656; + if (ys_temp < 32) + ys_temp = 200; + if (!enable_overscan) + xs_temp -= 16; + + if ((quadcolor->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) && ((xs_temp != xsize) || + (ys_temp != ysize) || video_force_resize_get())) { + xsize = xs_temp; + ysize = ys_temp; + if (quadcolor->double_type > DOUBLE_NONE) + set_screen_size(xsize, ysize + (enable_overscan ? 16 : 0)); + else + set_screen_size(xsize, ysize + (enable_overscan ? 8 : 0)); + + if (video_force_resize_get()) + video_force_resize_set(0); + } + + if (quadcolor->double_type > DOUBLE_NONE) { + if (enable_overscan) + quadcolor_blit_memtoscreen(quadcolor, 0, (quadcolor->firstline - 4) << 1, + xsize, ((quadcolor->lastline - quadcolor->firstline) << 1) + 16); + else + quadcolor_blit_memtoscreen(quadcolor, 8, quadcolor->firstline << 1, + xsize, (quadcolor->lastline - quadcolor->firstline) << 1); + } else { + if (enable_overscan) + video_blit_memtoscreen(0, quadcolor->firstline - 4, + xsize, (quadcolor->lastline - quadcolor->firstline) + 8); + else + video_blit_memtoscreen(8, quadcolor->firstline, + xsize, quadcolor->lastline - quadcolor->firstline); + } + } + + frames++; + + video_res_x = xsize; + video_res_y = ysize; + if (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES) { + video_res_x /= 8; + video_res_y /= quadcolor->crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1; + video_bpp = 0; + } else if (!(quadcolor->cgamode & CGA_MODE_FLAG_GRAPHICS)) { + video_res_x /= 16; + video_res_y /= quadcolor->crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1; + video_bpp = 0; + } else if (!(quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) { + video_res_x /= 2; + video_bpp = 2; + } else + video_bpp = 1; + } + quadcolor->firstline = 1000; + quadcolor->lastline = 0; + quadcolor->cgablink++; + quadcolor->oddeven ^= 1; + } + } else { + quadcolor->scanline++; + quadcolor->scanline &= 31; + quadcolor->memaddr = quadcolor->memaddr_backup; + } + if (quadcolor->cgadispon) + quadcolor->cgastat &= ~1; + if (quadcolor->scanline == (quadcolor->crtc[CGA_CRTC_CURSOR_START] & 31) || ((quadcolor->crtc[CGA_CRTC_INTERLACE] & 3) == 3 && + quadcolor->scanline == ((quadcolor->crtc[CGA_CRTC_CURSOR_START] & 31) >> 1))) + quadcolor->cursorvisible = 1; + if (quadcolor->cgadispon && (quadcolor->cgamode & CGA_MODE_FLAG_HIGHRES)) { + for (x = 0; x < (quadcolor->crtc[CGA_CRTC_HDISP] << 1); x++) + quadcolor->charbuffer[x] = quadcolor->vram[(quadcolor->page_offset ^ ((quadcolor->memaddr << 1) + x)) & DEVICE_VRAM_MASK]; + } + } +} + +void +quadcolor_init(quadcolor_t *quadcolor) +{ + timer_add(&quadcolor->timer, quadcolor_poll, quadcolor, 1); + quadcolor->composite = 0; +} + +void * +quadcolor_standalone_init(UNUSED(const device_t *info)) +{ + int display_type; + quadcolor_t *quadcolor = calloc(1, sizeof(quadcolor_t)); + + video_inform(VIDEO_FLAG_TYPE_CGA, &timing_quadcolor); + + display_type = device_get_config_int("display_type"); + quadcolor->composite = (display_type != CGA_RGB); + quadcolor->revision = device_get_config_int("composite_type"); + quadcolor->has_2nd_charset = device_get_config_int("has_2nd_charset"); + quadcolor->has_quadcolor_2 = device_get_config_int("has_quadcolor_2"); + + quadcolor->vram = malloc(DEVICE_VRAM); + quadcolor->vram_2 = malloc(0x10000); + + cga_comp_init(quadcolor->revision); + timer_add(&quadcolor->timer, quadcolor_poll, quadcolor, 1); + mem_mapping_add(&quadcolor->mapping, 0xb8000, 0x08000, quadcolor_read, NULL, NULL, quadcolor_write, NULL, NULL, NULL /*quadcolor->vram*/, MEM_MAPPING_EXTERNAL, quadcolor); + /* add mapping for vram_2 at 0xd0000, mirrored at 0xe0000 */ + if (quadcolor->has_quadcolor_2) + mem_mapping_add(&quadcolor->mapping_2, 0xd0000, 0x20000, quadcolor_2_read, NULL, NULL, quadcolor_2_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, + quadcolor); + + io_sethandler(0x03d0, 0x0010, quadcolor_in, NULL, NULL, quadcolor_out, NULL, NULL, quadcolor); + + overscan_x = overscan_y = 16; + + quadcolor->rgb_type = device_get_config_int("rgb_type"); + cga_palette = (quadcolor->rgb_type << 1); + cgapal_rebuild(); + update_cga16_color(quadcolor->cgamode); + + quadcolor->double_type = device_get_config_int("double_type"); + + for (uint16_t i = 0; i < 256; i++) { + for (uint16_t j = 0; j < 256; j++) { + interp_lut[0][i][j] = quadcolor_interpolate_srgb(i, j, 0.5); + interp_lut[1][i][j] = quadcolor_interpolate_linear(i, j, 0.5); + } + } + + switch(device_get_config_int("font")) { + case 0: + loadfont(FONT_IBM_MDA_437_PATH, 0); + break; + case 1: + loadfont(FONT_IBM_MDA_437_NORDIC_PATH, 0); + break; + case 4: + loadfont(FONT_TULIP_DGA_PATH, 0); + break; + } + + return quadcolor; +} + +void +quadcolor_close(void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + + free(quadcolor->vram); + free(quadcolor->vram_2); + free(quadcolor); +} + +void +quadcolor_speed_changed(void *priv) +{ + quadcolor_t *quadcolor = (quadcolor_t *) priv; + + quadcolor_recalctimings(quadcolor); +} + +// clang-format off +const device_config_t quadcolor_config[] = { + { + .name = "display_type", + .description = "Display type", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = CGA_RGB, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "RGB", .value = CGA_RGB }, + { .description = "Composite", .value = CGA_COMPOSITE }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "composite_type", + .description = "Composite type", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = COMPOSITE_OLD, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "Old", .value = COMPOSITE_OLD }, + { .description = "New", .value = COMPOSITE_NEW }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "rgb_type", + .description = "RGB type", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 5, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "Color (generic)", .value = 0 }, + { .description = "Green Monochrome", .value = 1 }, + { .description = "Amber Monochrome", .value = 2 }, + { .description = "Gray Monochrome", .value = 3 }, + { .description = "Color (no brown)", .value = 4 }, + { .description = "Color (IBM 5153)", .value = 5 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "double_type", + .description = "Line doubling type", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = DOUBLE_NONE, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "None", .value = DOUBLE_NONE }, + { .description = "Simple doubling", .value = DOUBLE_SIMPLE }, + { .description = "sRGB interpolation", .value = DOUBLE_INTERPOLATE_SRGB }, + { .description = "Linear interpolation", .value = DOUBLE_INTERPOLATE_LINEAR }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "font", + .description = "Font", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "US (CP 437)", .value = 0 }, + { .description = "IBM Nordic (CP 437-Nordic)", .value = 1 }, + { .description = "Tulip DGA", .value = 4 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "has_2nd_charset", + .description = "Has secondary 8x8 character set", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { + .name = "has_quadcolor_2", + .description = "Has Quadcolor II daughter board", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 1, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { + .name = "contrast", + .description = "Alternate monochrome contrast", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { .name = "", .description = "", .type = CONFIG_END } +}; +// clang-format on + +const device_t quadcolor_device = { + .name = "Quadram Quadcolor I / I+II", + .internal_name = "quadcolor", + .flags = DEVICE_ISA, + .local = 0, + .init = quadcolor_standalone_init, + .close = quadcolor_close, + .reset = NULL, + .available = NULL, + .speed_changed = quadcolor_speed_changed, + .force_redraw = NULL, + .config = quadcolor_config +}; diff --git a/src/video/vid_table.c b/src/video/vid_table.c index b97defe8c..2e42e5c2c 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -67,6 +67,7 @@ video_cards[] = { { .device = &ati18800_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &ati18800_wonder_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &cga_device, .flags = VIDEO_FLAG_TYPE_NONE }, + { .device = &quadcolor_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &sega_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &jega_device, .flags = VIDEO_FLAG_TYPE_NONE }, { .device = &gd5401_isa_device, .flags = VIDEO_FLAG_TYPE_NONE }, From 6814a11ae6c0140af6227e6f7341a023eb9cdfc1 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sun, 29 Jun 2025 19:42:57 -0400 Subject: [PATCH 095/103] Minor changes in cga --- src/include/86box/vid_cga.h | 29 ++++++++++++----------------- src/include/86box/video.h | 7 +++++++ src/machine/m_xt_zenith.c | 2 +- src/video/vid_cga.c | 15 ++++++--------- src/video/vid_cga_olivetti.c | 1 + 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/include/86box/vid_cga.h b/src/include/86box/vid_cga.h index 04616431e..2198154ed 100644 --- a/src/include/86box/vid_cga.h +++ b/src/include/86box/vid_cga.h @@ -8,15 +8,13 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * - * * Authors: Sarah Walker, - * Miran Grca, , + * Miran Grca, * Connor Hyde / starfrost, * * Copyright 2008-2018 Sarah Walker. * Copyright 2016-2018 Miran Grca. - * Copyright 2025 starfrost (refactoring) + * Copyright 2025 starfrost (refactoring). */ #ifndef VIDEO_CGA_H @@ -24,8 +22,7 @@ // Mode flags for the CGA. // Set by writing to 3D8 -typedef enum cga_mode_flags_e -{ +typedef enum cga_mode_flags_e { CGA_MODE_FLAG_HIGHRES = 1 << 0, // 80-column text mode CGA_MODE_FLAG_GRAPHICS = 1 << 1, // Graphics mode CGA_MODE_FLAG_BW = 1 << 2, // Black and white @@ -35,8 +32,7 @@ typedef enum cga_mode_flags_e } cga_mode_flags; // Motorola MC6845 CRTC registers -typedef enum cga_crtc_registers_e -{ +typedef enum cga_crtc_registers_e { CGA_CRTC_HTOTAL = 0x0, // Horizontal total (total number of characters incl. hsync) CGA_CRTC_HDISP = 0x1, // Horizontal display CGA_CRTC_HSYNC_POS = 0x2, // Horizontal position of horizontal ysnc @@ -58,8 +54,7 @@ typedef enum cga_crtc_registers_e } cga_crtc_registers; // Registers for the CGA -typedef enum cga_registers_e -{ +typedef enum cga_registers_e { CGA_REGISTER_CRTC_INDEX = 0x3D4, CGA_REGISTER_CRTC_DATA = 0x3D5, CGA_REGISTER_MODE_CONTROL = 0x3D8, @@ -129,11 +124,11 @@ uint8_t cga_read(uint32_t addr, void *priv); void cga_recalctimings(cga_t *cga); void cga_poll(void *priv); -#ifdef EMU_DEVICE_H -extern const device_config_t cga_config[]; - -extern const device_t cga_device; -extern const device_t cga_pravetz_device; -#endif - +//#ifdef EMU_DEVICE_H +//extern const device_config_t cga_config[]; +// +//extern const device_t cga_device; +//extern const device_t cga_pravetz_device; +//#endif +// #endif /*VIDEO_CGA_H*/ diff --git a/src/include/86box/video.h b/src/include/86box/video.h index 70d031a4f..62fea0b9a 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -399,6 +399,13 @@ extern const device_t gd5446_pci_device; extern const device_t gd5446_stb_pci_device; extern const device_t gd5480_pci_device; + +/* IBM CGA*/ +extern const device_t cga_device; + +/* pravetz CGA */ +extern const device_t cga_pravetz_device; + /* Compaq CGA */ extern const device_t compaq_cga_device; extern const device_t compaq_cga_2_device; diff --git a/src/machine/m_xt_zenith.c b/src/machine/m_xt_zenith.c index 62c6496d1..2159c18e5 100644 --- a/src/machine/m_xt_zenith.c +++ b/src/machine/m_xt_zenith.c @@ -45,7 +45,7 @@ #include <86box/serial.h> #include <86box/machine.h> #include <86box/io.h> -#include <86box/vid_cga.h> +#include <86box/video.h> #include <86box/plat_unused.h> typedef struct { diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c index 2abfe6a5c..1ca742890 100644 --- a/src/video/vid_cga.c +++ b/src/video/vid_cga.c @@ -8,15 +8,13 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * - * * Authors: Sarah Walker, * Miran Grca, * W. M. Martinez, * * Copyright 2008-2019 Sarah Walker. * Copyright 2016-2019 Miran Grca. - * Copyright 2023 W. M. Martinez + * Copyright 2023 W. M. Martinez */ #include #include @@ -284,7 +282,7 @@ cga_render(cga_t *cga, int line) buffer32->line[line][column + (cga->crtc[CGA_CRTC_HDISP] << 4) + 8] = (cga->cgacol & 15) + 16; } } - if (cga->cgamode & CGA_MODE_FLAG_HIGHRES) { + if (cga->cgamode & CGA_MODE_FLAG_HIGHRES) { /* 80-column text */ for (x = 0; x < cga->crtc[CGA_CRTC_HDISP]; x++) { if (cga->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) { chr = cga->charbuffer[x << 1]; @@ -342,7 +340,7 @@ cga_render(cga_t *cga, int line) } } } - } else if (!(cga->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) { + } else if (!(cga->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) { /* not hi-res (but graphics) => 4-color mode */ cols[0] = (cga->cgacol & 15) | 16; col = (cga->cgacol & 16) ? 24 : 16; if (cga->cgamode & CGA_MODE_FLAG_BW) { @@ -372,7 +370,7 @@ cga_render(cga_t *cga, int line) dat <<= 2; } } - } else { + } else { /* 2-color hi-res graphics mode */ cols[0] = 0; cols[1] = (cga->cgacol & 15) + 16; for (x = 0; x < cga->crtc[CGA_CRTC_HDISP]; x++) { @@ -500,7 +498,7 @@ cga_interpolate(cga_t *cga, int x, int y, int w, int h) interim_1 = cga_interpolate_lookup(cga, prev_color, black, quotient); interim_2 = cga_interpolate_lookup(cga, black, next_color, quotient); - final = cga_interpolate_lookup(cga, interim_1, interim_2, quotient); + final = cga_interpolate_lookup(cga, interim_1, interim_2, quotient); buffer32->line[i][j] = final.color; } @@ -746,9 +744,8 @@ void * cga_standalone_init(UNUSED(const device_t *info)) { int display_type; - cga_t *cga = malloc(sizeof(cga_t)); + cga_t *cga = calloc(1, sizeof(cga_t)); - memset(cga, 0, sizeof(cga_t)); video_inform(VIDEO_FLAG_TYPE_CGA, &timing_cga); display_type = device_get_config_int("display_type"); diff --git a/src/video/vid_cga_olivetti.c b/src/video/vid_cga_olivetti.c index 8be40ee2e..147529f6e 100644 --- a/src/video/vid_cga_olivetti.c +++ b/src/video/vid_cga_olivetti.c @@ -38,6 +38,7 @@ #include <86box/rom.h> #include <86box/device.h> #include <86box/vid_cga.h> +extern const device_config_t cga_config[]; /* defined in vid_cga.c */ #include <86box/vid_ogc.h> #include <86box/vid_cga_comp.h> #include <86box/plat_unused.h> From be7406637ed11eb1d1df92a4279243ca7ef985d9 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 30 Jun 2025 09:00:23 -0400 Subject: [PATCH 096/103] A few joystick related cleanups --- src/game/gameport.c | 2 +- src/game/joystick_standard.c | 5 ++-- src/include/86box/gameport.h | 50 +++++++++++++++--------------------- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/game/gameport.c b/src/game/gameport.c index 8ae1c7d25..57476e463 100644 --- a/src/game/gameport.c +++ b/src/game/gameport.c @@ -15,7 +15,7 @@ * * Copyright 2016-2022 Miran Grca. * Copyright 2008-2018 Sarah Walker. - * Copyright 2021 RichardG. + * Copyright 2021 RichardG. * Copyright 2021-2025 Jasmine Iwanek. */ #include diff --git a/src/game/joystick_standard.c b/src/game/joystick_standard.c index 5f200cb98..38571dc21 100644 --- a/src/game/joystick_standard.c +++ b/src/game/joystick_standard.c @@ -8,13 +8,14 @@ * * Implementation of a standard joystick. * - * - * * Authors: Miran Grca, * Sarah Walker, + * Miran Grca, + * Jasmine Iwanek, * * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. + * Copyright 2021-2025 Jasmine Iwanek. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/include/86box/gameport.h b/src/include/86box/gameport.h index 7928cdd30..6bbf89312 100644 --- a/src/include/86box/gameport.h +++ b/src/include/86box/gameport.h @@ -15,7 +15,7 @@ * * Copyright 2016-2022 Miran Grca. * Copyright 2008-2018 Sarah Walker. - * Copyright 2021 RichardG. + * Copyright 2021 RichardG. * Copyright 2021-2025 Jasmine Iwanek. */ #ifndef EMU_GAMEPORT_H @@ -52,6 +52,26 @@ #define GAMEPORT_8ADDR 0x080000 #define GAMEPORT_SIO 0x1000000 +typedef struct joystick_if_t { + const char *name; + const char *internal_name; + + void *(*init)(void); + void (*close)(void *priv); + uint8_t (*read)(void *priv); + void (*write)(void *priv); + int (*read_axis)(void *priv, int axis); + void (*a0_over)(void *priv); + + int axis_count; + int button_count; + int pov_count; + int max_joysticks; + const char *axis_names[MAX_JOY_AXES]; + const char *button_names[MAX_JOY_BUTTONS]; + const char *pov_names[MAX_JOY_POVS]; +} joystick_if_t; + typedef struct plat_joystick_t { char name[260]; @@ -90,26 +110,6 @@ typedef struct joystick_t { int pov_mapping[MAX_JOY_POVS][2]; } joystick_t; -typedef struct joystick_if_t { - const char *name; - const char *internal_name; - - void *(*init)(void); - void (*close)(void *priv); - uint8_t (*read)(void *priv); - void (*write)(void *priv); - int (*read_axis)(void *priv, int axis); - void (*a0_over)(void *priv); - - int axis_count; - int button_count; - int pov_count; - int max_joysticks; - const char *axis_names[MAX_JOY_AXES]; - const char *button_names[MAX_JOY_BUTTONS]; - const char *pov_names[MAX_JOY_POVS]; -} joystick_if_t; - extern device_t game_ports[GAMEPORT_MAX]; #ifdef __cplusplus @@ -186,14 +186,6 @@ extern const joystick_if_t joystick_sw_pad; extern const joystick_if_t joystick_tm_fcs; extern const joystick_if_t joystick_tm_fcs_rcs; -extern int gameport_available(int); -extern int gameport_has_config(int); -extern const char *gameport_get_internal_name(int); -extern int gampeport_get_from_internal_name(char *); -#ifdef EMU_DEVICE_H -extern const device_t *gameport_getdevice(int); -#endif - #ifdef __cplusplus } #endif From 5697a0ba79732b01d0efca1c58e569a69125d42b Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 30 Jun 2025 17:12:53 -0400 Subject: [PATCH 097/103] Fix a memory leak in windows rawinput joystick --- src/qt/win_joystick_rawinput.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/win_joystick_rawinput.c b/src/qt/win_joystick_rawinput.c index 5173d4f05..ecd885d3a 100644 --- a/src/qt/win_joystick_rawinput.c +++ b/src/qt/win_joystick_rawinput.c @@ -222,6 +222,7 @@ joystick_get_capabilities(raw_joystick_t *rawjoy, plat_joystick_t *joy) UINT size = 0; PHIDP_BUTTON_CAPS btn_caps = NULL; PHIDP_VALUE_CAPS val_caps = NULL; + HIDP_CAPS caps; /* Get preparsed data (HID data format) */ GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_PREPARSEDDATA, NULL, &size); @@ -229,7 +230,6 @@ joystick_get_capabilities(raw_joystick_t *rawjoy, plat_joystick_t *joy) if (GetRawInputDeviceInfoW(rawjoy->hdevice, RIDI_PREPARSEDDATA, rawjoy->data, &size) <= 0) fatal("joystick_get_capabilities: Failed to get preparsed data.\n"); - HIDP_CAPS caps; HidP_GetCaps(rawjoy->data, &caps); /* Buttons */ @@ -356,6 +356,7 @@ end_loop: free(info); } + free(deviceList); joystick_log("joystick_init: joysticks_present=%i\n", joysticks_present); /* Initialize the RawInput (joystick and gamepad) module. */ From def6d71f4be1caaa3d55c40307159415425c1524 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 30 Jun 2025 18:51:27 -0400 Subject: [PATCH 098/103] Add gamepads, flight yokes and steering wheels --- src/game/gameport.c | 7 ++ src/game/joystick_standard.c | 157 +++++++++++++++++++++++++++++++++++ src/include/86box/gameport.h | 7 ++ 3 files changed, 171 insertions(+) diff --git a/src/game/gameport.c b/src/game/gameport.c index 57476e463..67447d447 100644 --- a/src/game/gameport.c +++ b/src/game/gameport.c @@ -90,11 +90,18 @@ static const struct { } joysticks[] = { { &joystick_none }, { &joystick_2axis_2button }, + { &joystick_2button_gamepad }, + { &joystick_2button_flight_yoke }, { &joystick_2axis_4button }, + { &joystick_4button_gamepad }, + { &joystick_4button_flight_yoke }, { &joystick_2axis_6button }, { &joystick_2axis_8button }, { &joystick_3axis_2button }, + { &joystick_2button_yoke_throttle }, { &joystick_3axis_4button }, + { &joystick_win95_steering_wheel }, // Temp + { &joystick_4button_yoke_throttle }, { &joystick_4axis_4button }, { &joystick_ch_flightstick_pro }, { &joystick_ch_flightstick_pro_ch_pedals }, diff --git a/src/game/joystick_standard.c b/src/game/joystick_standard.c index 38571dc21..593bc6596 100644 --- a/src/game/joystick_standard.c +++ b/src/game/joystick_standard.c @@ -148,6 +148,37 @@ joystick_standard_read_axis_4button(UNUSED(void *priv), int axis) } } +static int +joystick_standard_read_axis_with_pov(UNUSED(void *priv), int axis) +{ + if (!JOYSTICK_PRESENT(0, 0)) + return AXIS_NOT_PRESENT; + + switch (axis) { + case 0: // X-axis + return joystick_state[0][0].axis[0]; + case 1: // Y-axis + return joystick_state[0][0].axis[1]; + case 2: // POV Hat (mapped to the 3rd logical axis, index 2) + if (joystick_state[0][0].pov[0] == -1) + return 32767; // Centered/No input (as per tm_fcs_rcs_read_axis example) + if (joystick_state[0][0].pov[0] > 315 || joystick_state[0][0].pov[0] < 45) + return -32768; // Up + if (joystick_state[0][0].pov[0] >= 45 && joystick_state[0][0].pov[0] < 135) + return -16384; // Up-Right (example value, matches tm_fcs_rcs_read_axis) + if (joystick_state[0][0].pov[0] >= 135 && joystick_state[0][0].pov[0] < 225) + return 0; // Right/Left (example, matches tm_fcs_rcs_read_axis) + if (joystick_state[0][0].pov[0] >= 225 && joystick_state[0][0].pov[0] < 315) + return 16384; // Down-Left (example value, matches tm_fcs_rcs_read_axis) + return 0; // Fallback + case 3: // This case might be used for a Z-axis if present, or can return 0 if not. + // For gamepads with only X/Y and POV, this will likely be unused or return 0. + return 0; + default: + return 0; + } +} + static int joystick_standard_read_axis_3axis(UNUSED(void *priv), int axis) { @@ -258,6 +289,42 @@ const joystick_if_t joystick_2axis_2button = { .pov_names = { NULL } }; +const joystick_if_t joystick_2button_gamepad = { + .name = "2-button gamepad(s)", + .internal_name = "2button_gamepad", + .init = joystick_standard_init, + .close = joystick_standard_close, + .read = joystick_standard_read, + .write = joystick_standard_write, + .read_axis = joystick_standard_read_axis, + .a0_over = joystick_standard_a0_over, + .axis_count = 2, + .button_count = 2, + .pov_count = 0, + .max_joysticks = 2, + .axis_names = { "X axis", "Y axis" }, + .button_names = { "Button 1", "Button 2" }, + .pov_names = { NULL } +}; + +const joystick_if_t joystick_2button_flight_yoke = { + .name = "2-button flight yoke", + .internal_name = "2button_flight_yoke", + .init = joystick_standard_init, + .close = joystick_standard_close, + .read = joystick_standard_read, + .write = joystick_standard_write, + .read_axis = joystick_standard_read_axis, + .a0_over = joystick_standard_a0_over, + .axis_count = 2, + .button_count = 2, + .pov_count = 0, + .max_joysticks = 2, + .axis_names = { "Roll axis", "Pitch axis" }, + .button_names = { "Trigger", "Button 2" }, + .pov_names = { NULL } +}; + const joystick_if_t joystick_2axis_4button = { .name = "2-axis, 4-button joystick", .internal_name = "2axis_4button", @@ -276,6 +343,42 @@ const joystick_if_t joystick_2axis_4button = { .pov_names = { NULL } }; +const joystick_if_t joystick_4button_gamepad = { + .name = "4-button gamepad", + .internal_name = "4button_gamepad", + .init = joystick_standard_init, + .close = joystick_standard_close, + .read = joystick_standard_read_4button, + .write = joystick_standard_write, + .read_axis = joystick_standard_read_axis_4button, + .a0_over = joystick_standard_a0_over, + .axis_count = 2, + .button_count = 4, + .pov_count = 0, + .max_joysticks = 1, + .axis_names = { "X axis", "Y axis" }, + .button_names = { "Button 1", "Button 2", "Button 3", "Button 4" }, + .pov_names = { NULL } +}; + +const joystick_if_t joystick_4button_flight_yoke = { + .name = "4-button flight yoke", + .internal_name = "4button_flight_yoke", + .init = joystick_standard_init, + .close = joystick_standard_close, + .read = joystick_standard_read_4button, + .write = joystick_standard_write, + .read_axis = joystick_standard_read_axis_4button, + .a0_over = joystick_standard_a0_over, + .axis_count = 2, + .button_count = 4, + .pov_count = 0, + .max_joysticks = 1, + .axis_names = { "Roll axis", "Pitch axis" }, + .button_names = { "Trigger", "Button 2", "Button 3", "Button 4" }, + .pov_names = { NULL } +}; + const joystick_if_t joystick_3axis_2button = { .name = "3-axis, 2-button joystick", .internal_name = "3axis_2button", @@ -294,6 +397,24 @@ const joystick_if_t joystick_3axis_2button = { .pov_names = { NULL } }; +const joystick_if_t joystick_2button_yoke_throttle = { + .name = "2-button flight yoke with throttle", + .internal_name = "2button_yoke_throttle", + .init = joystick_standard_init, + .close = joystick_standard_close, + .read = joystick_standard_read, + .write = joystick_standard_write, + .read_axis = joystick_standard_read_axis_3axis, + .a0_over = joystick_standard_a0_over, + .axis_count = 3, + .button_count = 2, + .pov_count = 0, + .max_joysticks = 1, + .axis_names = { "Roll axis", "Pitch axis", "Throttle axis" }, + .button_names = { "Trigger", "Button 2" }, + .pov_names = { NULL } +}; + const joystick_if_t joystick_3axis_4button = { .name = "3-axis, 4-button joystick", .internal_name = "3axis_4button", @@ -312,6 +433,42 @@ const joystick_if_t joystick_3axis_4button = { .pov_names = { NULL } }; +const joystick_if_t joystick_4button_yoke_throttle = { + .name = "4-button flight yoke with throttle", + .internal_name = "4button_yoke_throttle", + .init = joystick_standard_init, + .close = joystick_standard_close, + .read = joystick_standard_read_4button, + .write = joystick_standard_write, + .read_axis = joystick_standard_read_axis_3axis, + .a0_over = joystick_standard_a0_over, + .axis_count = 3, + .button_count = 4, + .pov_count = 0, + .max_joysticks = 1, + .axis_names = { "Roll axis", "Pitch axis", "Throttle axis" }, + .button_names = { "Button 1", "Button 2", "Button 3", "Button 4" }, + .pov_names = { NULL } +}; + +const joystick_if_t joystick_win95_steering_wheel = { + .name = "Win95 Steering Wheel (3-axis, 4-button)", + .internal_name = "win95_steering_wheel", + .init = joystick_standard_init, + .close = joystick_standard_close, + .read = joystick_standard_read_4button, + .write = joystick_standard_write, + .read_axis = joystick_standard_read_axis_3axis, + .a0_over = joystick_standard_a0_over, + .axis_count = 3, + .button_count = 4, + .pov_count = 0, + .max_joysticks = 1, + .axis_names = { "Steering axis", "Accelerator axis", "Brake axis" }, + .button_names = { "Button 1", "Button 2", "Button 3", "Button 4" }, + .pov_names = { NULL } +}; + const joystick_if_t joystick_4axis_4button = { .name = "4-axis, 4-button joystick", .internal_name = "4axis_4button", diff --git a/src/include/86box/gameport.h b/src/include/86box/gameport.h index 6bbf89312..655eea942 100644 --- a/src/include/86box/gameport.h +++ b/src/include/86box/gameport.h @@ -171,9 +171,16 @@ extern void gameport_remap(void *priv, uint16_t address); extern void *gameport_add(const device_t *gameport_type); extern const joystick_if_t joystick_2axis_2button; +extern const joystick_if_t joystick_2button_gamepad; +extern const joystick_if_t joystick_2button_flight_yoke; extern const joystick_if_t joystick_2axis_4button; +extern const joystick_if_t joystick_4button_gamepad; +extern const joystick_if_t joystick_4button_flight_yoke; extern const joystick_if_t joystick_3axis_2button; +extern const joystick_if_t joystick_2button_yoke_throttle; extern const joystick_if_t joystick_3axis_4button; +extern const joystick_if_t joystick_4button_yoke_throttle; +extern const joystick_if_t joystick_win95_steering_wheel; extern const joystick_if_t joystick_4axis_4button; extern const joystick_if_t joystick_2axis_6button; extern const joystick_if_t joystick_2axis_8button; From 8b3465287a27d7ed834123eb2edbb1a370e96a51 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 4 Jul 2025 05:26:37 +0200 Subject: [PATCH 099/103] cdrom_read_disc_information(): Make sure ls_last is in buffer[6], not buffer[5]. --- src/cdrom/cdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index e0fa8b0b6..9f6966d24 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -2655,7 +2655,7 @@ cdrom_read_disc_information(const cdrom_t *dev, uint8_t *buffer) buffer[ 3] = first; /* Number of First Track on Disc */ buffer[ 4] = sessions; /* Number of Sessions (LSB) */ buffer[ 5] = ls_first; /* First Track Number in Last Session (LSB) */ - buffer[ 5] = ls_last; /* Last Track Number in Last Session (LSB) */ + buffer[ 6] = ls_last; /* Last Track Number in Last Session (LSB) */ buffer[ 7] = 0x20; /* Unrestricted use */ buffer[ 8] = t[0].ps; /* Disc Type */ buffer[ 9] = 0x00; /* Number Of Sessions (MSB) */ From 5defb8d171750617b1807beea4fa6f0480882afb Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 3 Jul 2025 15:20:53 -0400 Subject: [PATCH 100/103] Fix some bugs relating to tap on non unix platforms --- src/config.c | 8 ++++---- src/qt/qt_settingsnetwork.cpp | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index d33813e7d..272ca43b7 100644 --- a/src/config.c +++ b/src/config.c @@ -658,9 +658,9 @@ load_network(void) nc->net_type = NET_TYPE_PCAP; else if (!strcmp(p, "slirp") || !strcmp(p, "2")) nc->net_type = NET_TYPE_SLIRP; - else if (!strcmp(p, "vde") || !strcmp(p, "2")) + else if (!strcmp(p, "vde") || !strcmp(p, "3")) nc->net_type = NET_TYPE_VDE; - else if (!strcmp(p, "tap") || !strcmp(p, "3")) + else if (!strcmp(p, "tap") || !strcmp(p, "4")) nc->net_type = NET_TYPE_TAP; else nc->net_type = NET_TYPE_NONE; @@ -706,9 +706,9 @@ load_network(void) nc->net_type = NET_TYPE_PCAP; else if (!strcmp(p, "slirp") || !strcmp(p, "2")) nc->net_type = NET_TYPE_SLIRP; - else if (!strcmp(p, "vde") || !strcmp(p, "2")) + else if (!strcmp(p, "vde") || !strcmp(p, "3")) nc->net_type = NET_TYPE_VDE; - else if (!strcmp(p, "tap") || !strcmp(p, "3")) + else if (!strcmp(p, "tap") || !strcmp(p, "4")) nc->net_type = NET_TYPE_TAP; else nc->net_type = NET_TYPE_NONE; diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 9f97bacd6..e2cfe9f7d 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -94,6 +94,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) intf_label->setVisible(true); break; +#if defined(__unix__) || defined(__APPLE__) case NET_TYPE_TAP: // option_list_label->setText("TAP Options"); option_list_label->setVisible(true); @@ -101,6 +102,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) bridge_label->setVisible(true); bridge_line->setVisible(true); + break; +#endif case NET_TYPE_SLIRP: default: @@ -149,8 +152,10 @@ SettingsNetwork::save() strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1); else if (net_cards_conf[i].net_type == NET_TYPE_VDE) strncpy(net_cards_conf[i].host_dev_name, socket_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); +#if defined(__unix__) || defined(__APPLE__) else if (net_cards_conf[i].net_type == NET_TYPE_TAP) strncpy(net_cards_conf[i].host_dev_name, bridge_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); +#endif } } @@ -217,7 +222,9 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) if (network_devmap.has_vde) Models::AddEntry(model, "VDE", NET_TYPE_VDE); +#if defined(__unix__) || defined(__APPLE__) Models::AddEntry(model, "TAP", NET_TYPE_TAP); +#endif model->removeRows(0, removeRows); cbox->setCurrentIndex(cbox->findData(net_cards_conf[i].net_type)); @@ -243,10 +250,12 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) QString currentVdeSocket = net_cards_conf[i].host_dev_name; auto editline = findChild(QString("socketVDENIC%1").arg(i+1)); editline->setText(currentVdeSocket); +#if defined(__unix__) || defined(__APPLE__) } else if (net_cards_conf[i].net_type == NET_TYPE_TAP) { QString currentTapDevice = net_cards_conf[i].host_dev_name; auto editline = findChild(QString("bridgeTAPNIC%1").arg(i+1)); editline->setText(currentTapDevice); +#endif } } } From 0e0cb5f88f52a0419d5f100c964e2bc846576349 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Fri, 4 Jul 2025 00:08:10 -0400 Subject: [PATCH 101/103] Fix warning in joystick_standard.c --- src/game/joystick_standard.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/game/joystick_standard.c b/src/game/joystick_standard.c index 593bc6596..8136935ea 100644 --- a/src/game/joystick_standard.c +++ b/src/game/joystick_standard.c @@ -148,6 +148,8 @@ joystick_standard_read_axis_4button(UNUSED(void *priv), int axis) } } +#if 0 +// For later use static int joystick_standard_read_axis_with_pov(UNUSED(void *priv), int axis) { @@ -178,6 +180,7 @@ joystick_standard_read_axis_with_pov(UNUSED(void *priv), int axis) return 0; } } +#endif static int joystick_standard_read_axis_3axis(UNUSED(void *priv), int axis) From 3b7f2683cf2466ee28719ab9afbc34bd844aaa8c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 4 Jul 2025 14:39:09 +0600 Subject: [PATCH 102/103] Backport https://github.com/aaronsgiles/ymfm/pull/66 --- src/sound/ymfm/ymfm_opl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound/ymfm/ymfm_opl.h b/src/sound/ymfm/ymfm_opl.h index 843e5b274..71b098e97 100644 --- a/src/sound/ymfm/ymfm_opl.h +++ b/src/sound/ymfm/ymfm_opl.h @@ -52,7 +52,7 @@ namespace ymfm // // System-wide registers: // 01 xxxxxxxx Test register -// --x----- Enable OPL compatibility mode [OPL2 only] (1 = enable) +// --x----- Enable OPL compatibility mode [OPL2 only] (0 = enable) // 02 xxxxxxxx Timer A value (4 * OPN) // 03 xxxxxxxx Timer B value // 04 x------- RST @@ -243,7 +243,7 @@ public: uint32_t op_decay_rate(uint32_t opoffs) const { return byte(0x60, 0, 4, opoffs); } uint32_t op_sustain_level(uint32_t opoffs) const { return byte(0x80, 4, 4, opoffs); } uint32_t op_release_rate(uint32_t opoffs) const { return byte(0x80, 0, 4, opoffs); } - uint32_t op_waveform(uint32_t opoffs) const { return IsOpl2Plus ? byte(0xe0, 0, newflag() ? 3 : 2, opoffs) : 0; } + uint32_t op_waveform(uint32_t opoffs) const { return waveform_enable() ? byte(0xe0, 0, newflag() ? 3 : 2, opoffs) : 0; } protected: // return a bitfield extracted from a byte From b44b7ff81a07f35311af3c27a25b98d14ff53c30 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 4 Jul 2025 14:39:22 +0600 Subject: [PATCH 103/103] Backport https://github.com/aaronsgiles/ymfm/pull/67 --- src/sound/ymfm/ymfm_opn.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sound/ymfm/ymfm_opn.cpp b/src/sound/ymfm/ymfm_opn.cpp index 16ca3416c..60469e1c0 100644 --- a/src/sound/ymfm/ymfm_opn.cpp +++ b/src/sound/ymfm/ymfm_opn.cpp @@ -155,14 +155,13 @@ bool opn_registers_base::write(uint16_t index, uint8_t data, uint32_t &c // writes to the upper half just latch (only low 6 bits matter) if (bitfield(index, 2)) - m_regdata[latchindex] = data | 0x80; + m_regdata[latchindex] = data & 0x3f; - // writes to the lower half only commit if the latch is there - else if (bitfield(m_regdata[latchindex], 7)) + // writes to the lower half also apply said latch + else { m_regdata[index] = data; - m_regdata[index | 4] = m_regdata[latchindex] & 0x3f; - m_regdata[latchindex] = 0; + m_regdata[index | 4] = m_regdata[latchindex]; } return false; }