From c577aa85f2966f03e5c63678c312d4d83d17261c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 16 Feb 2022 01:09:11 +0600 Subject: [PATCH 01/19] qt: Add fullscreen status icons support and option --- src/config.c | 6 +++++ src/include/86box/plat.h | 5 ++-- src/qt/qt_hardwarerenderer.cpp | 22 ++++++++++++++-- src/qt/qt_hardwarerenderer.hpp | 1 + src/qt/qt_mainwindow.cpp | 14 ++++++++--- src/qt/qt_mainwindow.hpp | 4 ++- src/qt/qt_mainwindow.ui | 9 +++++++ src/qt/qt_renderercommon.cpp | 46 ++++++++++++++++++++++++++++++++++ src/qt/qt_renderercommon.hpp | 1 + src/qt/qt_softwarerenderer.cpp | 4 ++- src/unix/unix.c | 3 ++- src/win/win_ui.c | 1 + 12 files changed, 106 insertions(+), 10 deletions(-) diff --git a/src/config.c b/src/config.c index 5f3503ea9..b110d6984 100644 --- a/src/config.c +++ b/src/config.c @@ -521,6 +521,7 @@ load_general(void) rctrl_is_lalt = config_get_int(cat, "rctrl_is_lalt", 0); update_icons = config_get_int(cat, "update_icons", 1); + status_icons_fullscreen = !!config_get_int(cat, "status_icons_fullscreen", 0); window_remember = config_get_int(cat, "window_remember", 0); if (window_remember || (vid_resize & 2)) { @@ -2294,6 +2295,11 @@ save_general(void) else config_delete_var(cat, "enable_discord"); + if (status_icons_fullscreen) + config_set_int(cat, "status_icons_fullscreen", status_icons_fullscreen); + else + config_delete_var(cat, "status_icons_fullscreen"); + if (video_framerate != -1) config_set_int(cat, "video_gl_framerate", video_framerate); else diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index c60e6d922..d00bc1b87 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -75,7 +75,7 @@ extern "C" { /* Global variables residing in the platform module. */ extern int dopause, /* system is paused */ - mouse_capture; /* mouse is captured in app */ + mouse_capture; /* mouse is captured in app */ extern atomic_flag_t doresize; /* screen resize requested */ extern volatile int is_quit; /* system exit requested */ @@ -88,9 +88,10 @@ extern int infocus; extern char emu_version[200]; /* version ID string */ extern int rctrl_is_lalt; extern int update_icons; +extern int status_icons_fullscreen; extern int unscaled_size_x, /* current unscaled size X */ - unscaled_size_y; /* current unscaled size Y */ + unscaled_size_y; /* current unscaled size Y */ extern int kbd_req_capture, hide_status_bar, hide_tool_bar; diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index 1a89b93be..e4d2b4900 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -86,6 +86,7 @@ void HardwareRenderer::initializeGL() "void main(void)\n" "{\n" " gl_FragColor = texture2D(texture, texc.st).bgra;\n" + " gl_FragColor.a = 1.0;\n" "}\n"; QString fsrccore = "uniform sampler2D texture;\n" @@ -94,6 +95,7 @@ void HardwareRenderer::initializeGL() "void main(void)\n" "{\n" " FragColor = texture2D(texture, texc.st).bgra;\n" + " FragColor.a = 1.0;\n" "}\n"; if (m_context->isOpenGLES() && m_context->format().version() >= qMakePair(3, 0)) { @@ -135,6 +137,22 @@ void HardwareRenderer::initializeGL() glClearColor(0, 0, 0, 1); } +void HardwareRenderer::paintOverGL() +{ + // Context switching is needed to make use of QPainter to draw status bar icons in fullscreen. + // Especially since it seems to be impossible to use QPainter on externally-created OpenGL contexts. + if (video_fullscreen && status_icons_fullscreen) + { + m_context->makeCurrent(nullptr); + makeCurrent(); + QPainter painter(this); + drawStatusBarIcons(&painter); + painter.end(); + doneCurrent(); + m_context->makeCurrent(this); + } +} + void HardwareRenderer::paintGL() { m_context->makeCurrent(this); glClear(GL_COLOR_BUFFER_BIT); @@ -200,7 +218,7 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { void HardwareRenderer::resizeEvent(QResizeEvent *event) { onResize(width(), height()); - + QOpenGLWindow::resizeEvent(event); } @@ -214,7 +232,7 @@ bool HardwareRenderer::event(QEvent *event) 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])); diff --git a/src/qt/qt_hardwarerenderer.hpp b/src/qt/qt_hardwarerenderer.hpp index af4f05464..9720a8c2e 100644 --- a/src/qt/qt_hardwarerenderer.hpp +++ b/src/qt/qt_hardwarerenderer.hpp @@ -47,6 +47,7 @@ public: void resizeGL(int w, int h) override; void initializeGL() override; void paintGL() override; + void paintOverGL() override; std::vector> getBuffers() override; HardwareRenderer(QWidget* parent = nullptr, RenderType rtype = RenderType::OpenGL) : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent->windowHandle()), QOpenGLFunctions() diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 6a54bf200..8cb107192 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -132,7 +132,7 @@ MainWindow::MainWindow(QWidget *parent) : return; } if (!hide_tool_bar) -#ifdef _WIN32 +#ifdef _WIN32 toolbar_label->setText(title); #else { @@ -187,12 +187,12 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, &MainWindow::resizeContents, this, [this](int w, int h) { if (!QApplication::platformName().contains("eglfs") && vid_resize == 0) { w = qRound(w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)); - + int modifiedHeight = qRound(h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)) + menuBar()->height() + (statusBar()->height() * !hide_status_bar) + (ui->toolBar->height() * !hide_tool_bar); - + ui->stackedWidget->resize(w, h); setFixedSize(w, modifiedHeight); } @@ -225,6 +225,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionHide_tool_bar->setChecked(hide_tool_bar); ui->actionUpdate_status_bar_icons->setChecked(update_icons); ui->actionEnable_Discord_integration->setChecked(enable_discord); + ui->actionShow_status_icons_in_fullscreen->setChecked(status_icons_fullscreen); #if defined Q_OS_WINDOWS || defined Q_OS_MACOS /* Make the option visible only if ANGLE is loaded. */ @@ -1614,3 +1615,10 @@ void MainWindow::changeEvent(QEvent* event) #endif QWidget::changeEvent(event); } + +void MainWindow::on_actionShow_status_icons_in_fullscreen_triggered() +{ + status_icons_fullscreen = !status_icons_fullscreen; + ui->actionShow_status_icons_in_fullscreen->setChecked(status_icons_fullscreen); +} + diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 3d5a6a02a..90f7ddcff 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -110,6 +110,8 @@ private slots: void on_actionEnable_Discord_integration_triggered(bool checked); + void on_actionShow_status_icons_in_fullscreen_triggered(); + protected: void keyPressEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override; @@ -124,7 +126,7 @@ private: Ui::MainWindow *ui; std::unique_ptr status; std::shared_ptr mm; - + /* If main window should send keyboard input */ bool send_keyboard_input = true; bool shownonce = false; diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui index 6a35279c2..edc692a85 100644 --- a/src/qt/qt_mainwindow.ui +++ b/src/qt/qt_mainwindow.ui @@ -149,6 +149,7 @@ + @@ -697,6 +698,14 @@ false + + + true + + + Show status icons in fullscreen + + diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index 0974c1f78..e8300dfa0 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -17,17 +17,25 @@ #include "qt_renderercommon.hpp" #include "qt_mainwindow.hpp" +#include "qt_machinestatus.hpp" +#include "ui_qt_mainwindow.h" #include #include #include #include +#include +#include +#include #include extern "C" { #include <86box/86box.h> +#include <86box/plat.h> #include <86box/video.h> + +int status_icons_fullscreen = 0; } RendererCommon::RendererCommon() = default; @@ -101,6 +109,44 @@ void RendererCommon::onResize(int width, int height) { } } +void RendererCommon::drawStatusBarIcons(QPainter* painter) +{ + uint32_t x = 0; + auto prevcompositionMode = painter->compositionMode(); + painter->setCompositionMode(QPainter::CompositionMode::CompositionMode_SourceOver); + for (int i = 0; i < main_window->ui->statusbar->children().count(); i++) + { + QLabel* label = qobject_cast(main_window->ui->statusbar->children()[i]); + if (label) + { + auto pixmap = label->pixmap(Qt::ReturnByValue); + if (!pixmap.isNull()) + { + painter->setBrush(QColor(0, 0, 0, 255)); + painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, pixmap.width(), pixmap.height() + 4, QColor(0, 0, 0, 127)); + painter->drawPixmap(x, painter->device()->height() - pixmap.height(), pixmap); + x += pixmap.width(); + if (i <= main_window->ui->statusbar->children().count() - 3) + { + painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, main_window->ui->statusbar->layout()->spacing(), pixmap.height() + 4, QColor(0, 0, 0, 127)); + x += main_window->ui->statusbar->layout()->spacing(); + } + else painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, 4, pixmap.height() + 4, QColor(0, 0, 0, 127)); + } + } + } + if (main_window->status->getMessage().isEmpty() == false) + { + auto curStatusMsg = main_window->status->getMessage(); + auto textSize = painter->fontMetrics().size(Qt::TextSingleLine, curStatusMsg); + painter->setPen(QColor(0, 0, 0, 127)); + painter->fillRect(painter->device()->width() - textSize.width(), painter->device()->height() - textSize.height(), textSize.width(), textSize.height(), QColor(0, 0, 0, 127)); + painter->setPen(QColor(255, 255, 255, 255)); + painter->drawText(QRectF(painter->device()->width() - textSize.width(), painter->device()->height() - textSize.height(), textSize.width(), textSize.height()), Qt::TextSingleLine, curStatusMsg); + } + painter->setCompositionMode(prevcompositionMode); +} + bool RendererCommon::eventDelegate(QEvent *event, bool& result) { switch (event->type()) diff --git a/src/qt/qt_renderercommon.hpp b/src/qt/qt_renderercommon.hpp index f55f3ee03..fe4d278c7 100644 --- a/src/qt/qt_renderercommon.hpp +++ b/src/qt/qt_renderercommon.hpp @@ -20,6 +20,7 @@ public: virtual std::vector> getBuffers() = 0; protected: bool eventDelegate(QEvent* event, bool& result); + void drawStatusBarIcons(QPainter* painter); QRect source, destination; QWidget* parentWidget{nullptr}; diff --git a/src/qt/qt_softwarerenderer.cpp b/src/qt/qt_softwarerenderer.cpp index 13d727e83..2d260eca3 100644 --- a/src/qt/qt_softwarerenderer.cpp +++ b/src/qt/qt_softwarerenderer.cpp @@ -24,6 +24,7 @@ extern "C" { #include <86box/86box.h> +#include <86box/plat.h> #include <86box/video.h> } @@ -53,7 +54,7 @@ void SoftwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) { cur_image = buf_idx; buf_usage[(buf_idx + 1) % 2].clear(); - + source.setRect(x, y, w, h), update(); } @@ -83,6 +84,7 @@ void SoftwareRenderer::onPaint(QPaintDevice* device) { #endif painter.setCompositionMode(QPainter::CompositionMode_Plus); painter.drawImage(destination, *images[cur_image], source); + if (video_fullscreen && status_icons_fullscreen) drawStatusBarIcons(&painter); } std::vector> SoftwareRenderer::getBuffers() diff --git a/src/unix/unix.c b/src/unix/unix.c index a93609e2e..11f00b786 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -48,6 +48,7 @@ extern wchar_t sdl_win_title[512]; plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; joystick_t joystick_state[MAX_JOYSTICKS]; int joysticks_present; +int status_icons_fullscreen = 0; /* unused. */ SDL_mutex *blitmtx; SDL_threadID eventthread; static int exit_event = 0; @@ -1272,4 +1273,4 @@ void endblit() void ui_sb_mt32lcd(char* str) { -} \ No newline at end of file +} diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 6f0301d09..3e027021d 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -67,6 +67,7 @@ int fixed_size_x = 0, fixed_size_y = 0; int kbd_req_capture = 0; int hide_status_bar = 0; int hide_tool_bar = 0; +int status_icons_fullscreen = 0; /* unused. */ int dpi = 96; extern char openfilestring[512]; From 611486cb71b72e23e83d2076b2ed5bfdc651142d Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 16 Feb 2022 14:37:09 +0600 Subject: [PATCH 02/19] qt: Fix compilation with Qt 5 --- src/qt/qt_renderercommon.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index e8300dfa0..3ced773d4 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -119,7 +119,11 @@ void RendererCommon::drawStatusBarIcons(QPainter* painter) QLabel* label = qobject_cast(main_window->ui->statusbar->children()[i]); if (label) { - auto pixmap = label->pixmap(Qt::ReturnByValue); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const QPixmap pixmap = label->pixmap(); +#else + const QPixmap pixmap = *label->pixmap(); +#endif if (!pixmap.isNull()) { painter->setBrush(QColor(0, 0, 0, 255)); From ab4c68402dfcce87ca82580098c36a706d23ec68 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 16 Feb 2022 14:57:22 +0600 Subject: [PATCH 03/19] qt: Fix crash on fullscreen with status icons enabled --- src/qt/qt_renderercommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index 3ced773d4..82856d206 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -122,7 +122,7 @@ void RendererCommon::drawStatusBarIcons(QPainter* painter) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) const QPixmap pixmap = label->pixmap(); #else - const QPixmap pixmap = *label->pixmap(); + const QPixmap pixmap = label->pixmap() ? *label->pixmap() : QPixmap(); #endif if (!pixmap.isNull()) { From ed9b67c4335d4c3a6dfbca8acc9e564617f4148c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 16 Feb 2022 15:56:37 +0600 Subject: [PATCH 04/19] qt: Improve appearance of text and status icons in fullscreen --- src/qt/qt_renderercommon.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index 82856d206..d08fe9a26 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -18,7 +18,6 @@ #include "qt_renderercommon.hpp" #include "qt_mainwindow.hpp" #include "qt_machinestatus.hpp" -#include "ui_qt_mainwindow.h" #include #include @@ -114,9 +113,9 @@ void RendererCommon::drawStatusBarIcons(QPainter* painter) uint32_t x = 0; auto prevcompositionMode = painter->compositionMode(); painter->setCompositionMode(QPainter::CompositionMode::CompositionMode_SourceOver); - for (int i = 0; i < main_window->ui->statusbar->children().count(); i++) + for (int i = 0; i < main_window->statusBar()->children().count(); i++) { - QLabel* label = qobject_cast(main_window->ui->statusbar->children()[i]); + QLabel* label = qobject_cast(main_window->statusBar()->children()[i]); if (label) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -127,13 +126,13 @@ void RendererCommon::drawStatusBarIcons(QPainter* painter) if (!pixmap.isNull()) { painter->setBrush(QColor(0, 0, 0, 255)); - painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, pixmap.width(), pixmap.height() + 4, QColor(0, 0, 0, 127)); - painter->drawPixmap(x, painter->device()->height() - pixmap.height(), pixmap); + painter->fillRect(x, painter->device()->height() - pixmap.height() - 5, pixmap.width(), pixmap.height() + 5, QColor(0, 0, 0, 127)); + painter->drawPixmap(x + main_window->statusBar()->layout()->spacing() / 2, painter->device()->height() - pixmap.height() - 3, pixmap); x += pixmap.width(); - if (i <= main_window->ui->statusbar->children().count() - 3) + if (i <= main_window->statusBar()->children().count() - 3) { - painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, main_window->ui->statusbar->layout()->spacing(), pixmap.height() + 4, QColor(0, 0, 0, 127)); - x += main_window->ui->statusbar->layout()->spacing(); + painter->fillRect(x, painter->device()->height() - pixmap.height() - 5, main_window->statusBar()->layout()->spacing(), pixmap.height() + 5, QColor(0, 0, 0, 127)); + x += main_window->statusBar()->layout()->spacing(); } else painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, 4, pixmap.height() + 4, QColor(0, 0, 0, 127)); } @@ -142,11 +141,11 @@ void RendererCommon::drawStatusBarIcons(QPainter* painter) if (main_window->status->getMessage().isEmpty() == false) { auto curStatusMsg = main_window->status->getMessage(); - auto textSize = painter->fontMetrics().size(Qt::TextSingleLine, curStatusMsg); + auto textSize = painter->fontMetrics().size(Qt::TextSingleLine, QChar(' ') + curStatusMsg + QChar(' ')); painter->setPen(QColor(0, 0, 0, 127)); painter->fillRect(painter->device()->width() - textSize.width(), painter->device()->height() - textSize.height(), textSize.width(), textSize.height(), QColor(0, 0, 0, 127)); painter->setPen(QColor(255, 255, 255, 255)); - painter->drawText(QRectF(painter->device()->width() - textSize.width(), painter->device()->height() - textSize.height(), textSize.width(), textSize.height()), Qt::TextSingleLine, curStatusMsg); + painter->drawText(QRectF(painter->device()->width() - textSize.width(), painter->device()->height() - textSize.height(), textSize.width(), textSize.height()), Qt::TextSingleLine, QChar(' ') + curStatusMsg + QChar(' ')); } painter->setCompositionMode(prevcompositionMode); } From 9e0ca23060baacf8fa82fec7f16aa28ab42fc801 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 16 Feb 2022 16:10:54 +0600 Subject: [PATCH 05/19] qt: Construct colors from floating point values --- src/qt/qt_renderercommon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index d08fe9a26..82fa78628 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -125,16 +125,17 @@ void RendererCommon::drawStatusBarIcons(QPainter* painter) #endif if (!pixmap.isNull()) { - painter->setBrush(QColor(0, 0, 0, 255)); - painter->fillRect(x, painter->device()->height() - pixmap.height() - 5, pixmap.width(), pixmap.height() + 5, QColor(0, 0, 0, 127)); + painter->setBrush(QColor::fromRgbF(0, 0, 0, 1.)); + painter->fillRect(x, painter->device()->height() - pixmap.height() - 5, pixmap.width(), pixmap.height() + 5, QColor::fromRgbF(0, 0, 0, .5)); painter->drawPixmap(x + main_window->statusBar()->layout()->spacing() / 2, painter->device()->height() - pixmap.height() - 3, pixmap); x += pixmap.width(); if (i <= main_window->statusBar()->children().count() - 3) { - painter->fillRect(x, painter->device()->height() - pixmap.height() - 5, main_window->statusBar()->layout()->spacing(), pixmap.height() + 5, QColor(0, 0, 0, 127)); + painter->fillRect(x, painter->device()->height() - pixmap.height() - 5, main_window->statusBar()->layout()->spacing(), pixmap.height() + 5, QColor::fromRgbF(0, 0, 0, .5)); x += main_window->statusBar()->layout()->spacing(); } - else painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, 4, pixmap.height() + 4, QColor(0, 0, 0, 127)); + else painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, 4, pixmap.height() + 4, QColor::fromRgbF(0, 0, 0, .5)); + pixheight = qMax((unsigned int)pixheight, (unsigned int)pixmap.height()); } } } From d25a16eedbe5bae33abd3b4f4efa14e8ba429a49 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 16 Feb 2022 16:19:55 +0600 Subject: [PATCH 06/19] qt: Fix compile error --- src/qt/qt_renderercommon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index 82fa78628..c76067add 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -135,7 +135,6 @@ void RendererCommon::drawStatusBarIcons(QPainter* painter) x += main_window->statusBar()->layout()->spacing(); } else painter->fillRect(x, painter->device()->height() - pixmap.height() - 4, 4, pixmap.height() + 4, QColor::fromRgbF(0, 0, 0, .5)); - pixheight = qMax((unsigned int)pixheight, (unsigned int)pixmap.height()); } } } From fad290df77baee0c6757704f88c9b5a7d340f063 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Tue, 7 Nov 2023 12:39:42 +0100 Subject: [PATCH 07/19] add cpl_override in pmodeiret() when cpu_state.flags has NT_FLAG --- src/cpu/x86seg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index eaa63f846..709253a20 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -1796,7 +1796,9 @@ pmodeiret(int is32) } if (cpu_state.flags & NT_FLAG) { + cpl_override = 1; seg = readmemw(tr.base, 0); + cpl_override = 0; addr = seg & 0xfff8; if (seg & 0x0004) { x86seg_log("TS LDT %04X %04X IRET\n", seg, gdt.limit); From a436c12de3b79e105ef9dd694678b9036040107d Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Tue, 7 Nov 2023 20:45:45 +0100 Subject: [PATCH 08/19] pmodeiret(): move the second cpl_override after read_descriptor() because the flag is reset by the function --- src/cpu/x86seg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index 709253a20..96061d3fa 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -1811,8 +1811,8 @@ pmodeiret(int is32) } addr += gdt.base; } - cpl_override = 1; read_descriptor(addr, segdat, segdat32, 1); + cpl_override = 1; op_taskswitch286(seg, segdat, segdat[2] & 0x0800); cpl_override = 0; return; From 1005756e6eb8cc35fe8baaa872b47f3c25f56cf9 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 8 Nov 2023 03:48:49 +0100 Subject: [PATCH 09/19] ACPI no longer raises SCI IRQ if the overall SCI enable bit is clear, fixes #3810. --- src/acpi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/acpi.c b/src/acpi.c index 7b070257f..d60699f1b 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -124,7 +124,7 @@ acpi_update_irq(acpi_t *dev) if (dev->vendor == VEN_SMC) sci_level |= (dev->regs.pmsts & BM_STS); - if (sci_level) { + if ((dev->regs.pmcntrl & 0x01) && sci_level) { if (dev->irq_mode == 1) pci_set_irq(dev->slot, dev->irq_pin, &dev->irq_state); else if (dev->irq_mode == 2) @@ -658,6 +658,7 @@ acpi_reg_write_common_regs(UNUSED(int size), uint16_t addr, uint8_t val, void *p acpi_t *dev = (acpi_t *) priv; int shift16; int sus_typ; + uint8_t old; addr &= 0x3f; #ifdef ENABLE_ACPI_LOG @@ -684,6 +685,7 @@ acpi_reg_write_common_regs(UNUSED(int size), uint16_t addr, uint8_t val, void *p case 0x04: case 0x05: /* PMCNTRL - Power Management Control Register (IO) */ + old = dev->regs.pmcntrl & 0xff; if ((addr == 0x05) && (val & 0x20)) { sus_typ = dev->suspend_types[(val >> 2) & 7]; acpi_log("ACPI suspend type %d flags %02X\n", (val >> 2) & 7, sus_typ); @@ -726,6 +728,8 @@ acpi_reg_write_common_regs(UNUSED(int size), uint16_t addr, uint8_t val, void *p } } dev->regs.pmcntrl = ((dev->regs.pmcntrl & ~(0xff << shift16)) | (val << shift16)) & 0x3f07 /* 0x3c07 */; + if ((addr == 0x04) && ((old ^ val) & 0x01)) + acpi_update_irq(dev); break; default: @@ -789,7 +793,7 @@ acpi_reg_write_ali(int size, uint16_t addr, uint8_t val, void *priv) dev->regs.gpcntrl = ((dev->regs.gpcntrl & ~(0xff << shift32)) | (val << shift32)) & 0x00000001; break; case 0x30: - /* PM2_CNTRL - Power Management 2 Control Register( */ + /* PM2_CNTRL - Power Management 2 Control Register */ dev->regs.pmcntrl = val & 1; break; default: From 9d61b3a2626bb6994be4b9d4f05d347e395eda0d Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 8 Nov 2023 03:51:40 +0100 Subject: [PATCH 10/19] Fixed two warnings in sound/snd_sb.c. --- src/sound/snd_sb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 5efb56bd1..5f1aeb261 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -1636,8 +1636,6 @@ static void sb_vibra16_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv) { sb_t *sb = (sb_t *) priv; - uint16_t addr = sb->dsp.sb_addr; - uint8_t val; switch (ld) { case 0: /* Audio */ From 6c356df9e77e3c91e6ec7904537a64a7029d5b62 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 8 Nov 2023 23:47:16 +0100 Subject: [PATCH 11/19] More and more video changes and fixes (8514/A and compatibles): 1. Made the 8514/A mode switch to VGA and viceversa (including ATI mode) actually usable and eliminating the last bugs related to them. Fixes 8514/A mode in OS/2 1.x/2.x (both IBM and Microsoft). 2. More sanity checks to the 8514/A and XGA pointers. Should fix emulator crashes on hard resets. --- src/include/86box/vid_8514a.h | 4 +- src/video/vid_8514a.c | 20 ++++---- src/video/vid_ati_mach8.c | 95 +++++++++++++++-------------------- src/video/vid_svga.c | 20 ++++---- 4 files changed, 63 insertions(+), 76 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 983e98cd1..da4e9e700 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -41,7 +41,7 @@ typedef struct ibm8514_t { int type; int local; int bpp; - int on; + int on[2]; int accel_bpp; uint32_t vram_size; @@ -64,7 +64,7 @@ typedef struct ibm8514_t { struct { uint16_t subsys_cntl; uint16_t setup_md; - uint8_t advfunc_cntl; + uint16_t advfunc_cntl; uint8_t ext_advfunc_cntl; uint16_t cur_y; uint16_t cur_y_bitres; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index a2cabfb0d..314fee307 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -964,8 +964,8 @@ ibm8514_accel_out(uint16_t port, uint32_t val, svga_t *svga, int len) if (!val) break; dev->accel.advfunc_cntl = val & 0x0f; - dev->on = val & 0x01; - vga_on = !dev->on; + dev->on[0] = val & 0x01; + vga_on = !dev->on[0]; ibm8514_log("IBM 8514/A: VGA ON = %i, val = %02x\n", vga_on, val); svga_recalctimings(svga); break; @@ -1200,17 +1200,16 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (cpu_input) { if ((dev->accel.cmd & 2) || (pixcntl == 2)) { - if ((frgd_mix == 2) || (bkgd_mix == 2)) { + if ((frgd_mix == 2) || (bkgd_mix == 2)) count >>= 3; - } else if (pixcntl == 2) { - if (dev->accel.cmd & 2) { + else if (pixcntl == 2) { + if (dev->accel.cmd & 2) count >>= 1; - } else + else count >>= 3; } - } else { + } else count >>= 3; - } if (dev->bpp) { if ((dev->accel.cmd & 0x200) && (count == 2)) @@ -1299,7 +1298,8 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat /*Bit 4 of the Command register is the draw yes bit, which enables writing to memory/reading from memory when enabled. When this bit is disabled, no writing to memory/reading from memory is allowed. (This bit is almost meaningless on the NOP command)*/ - ibm8514_log("CMD8514: CMD=%d, full=%04x, pixcntl=%x, count=%d, frgdmix = %02x, bkgdmix = %02x, polygon=%x.\n", cmd, dev->accel.cmd, pixcntl, count, frgd_mix, bkgd_mix, dev->accel.multifunc[0x0a] & 6); + if (dev->accel.cmd == 0x53b1 && !cpu_dat) + ibm8514_log("CMD8514: CMD=%d, full=%04x, pixcntl=%x, count=%d, frgdmix = %02x, bkgdmix = %02x, polygon=%x, cpu=%08x, frgdmix=%02x, bkgdmix=%02x.\n", cmd, dev->accel.cmd, pixcntl, count, frgd_mix, bkgd_mix, dev->accel.multifunc[0x0a] & 6, cpu_dat, dev->accel.frgd_mix, dev->accel.bkgd_mix); switch (cmd) { case 0: /*NOP (Short Stroke Vectors)*/ @@ -4243,7 +4243,7 @@ ibm8514_recalctimings(svga_t *svga) { ibm8514_t *dev = (ibm8514_t *) svga->dev8514; - if (dev->on) { + if (dev->on[0]) { dev->h_disp = (dev->hdisp + 1) << 3; dev->pitch = (dev->accel.advfunc_cntl & 4) ? 1024 : 640; dev->h_total = (dev->htotal + 1); diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 8e7174666..90e41d9ba 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -100,8 +100,8 @@ typedef struct mach_t { uint8_t bank_w; uint8_t bank_r; uint16_t shadow_set; - int ext_on; - int ati_mode; + int ext_on[2]; + int ati_mode[2]; struct { uint8_t line_idx; @@ -1140,9 +1140,9 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 mix = 1; break; case 1: - if (mach->accel.mono_pattern_enable) { + if (mach->accel.mono_pattern_enable) mix = mach->accel.mono_pattern[dev->accel.dy & 7][dev->accel.dx & 7]; - } else { + else { if ((dev->accel_bpp == 24) && (frgd_sel == 5) && (mach->accel.patt_len_reg & 0x4000)) mix = 1; else { @@ -1205,18 +1205,16 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 src_dat = cpu_dat; else { READ(dev->accel.src + (dev->accel.cx), src_dat); - if (mono_src == 3) { + if (mono_src == 3) src_dat = (src_dat & rd_mask) == rd_mask; - } } break; case 5: if (mix) { - if (dev->bpp) { + if (dev->bpp) src_dat = mach->accel.color_pattern_word[mach->accel.color_pattern_idx]; - } else { + else src_dat = mach->accel.color_pattern[mach->accel.color_pattern_idx]; - } } else src_dat = 0; break; @@ -1318,9 +1316,9 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 mach->accel.color_pattern_idx++; if (mach->accel.color_pattern_idx == 3) mach->accel.color_pattern_idx = 0; - } else { + } else mach->accel.color_pattern_idx = (mach->accel.color_pattern_idx + mach->accel.stepx) & mach->accel.patt_len; - } + } else if ((dev->accel_bpp == 24) && (mach->accel.patt_len_reg & 0x4000) && (frgd_sel == 5)) { mach->accel.color_pattern_idx++; if (mach->accel.color_pattern_idx == 3) @@ -1346,9 +1344,9 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->bpp) dev->accel.dest = (mach->accel.ge_offset << 1) + (dev->accel.dy * (dev->pitch)); - else { + else dev->accel.dest = (mach->accel.ge_offset << 2) + (dev->accel.dy * (dev->pitch)); - } + if ((mono_src == 1) && (dev->accel_bpp == 24) && (frgd_sel == 5)) mach->accel.color_pattern_idx = 0; else @@ -2347,7 +2345,7 @@ mach_out(uint16_t addr, uint8_t val, void *priv) mach->bank_r |= ((mach->regs[0xae] & 0x0c) << 2); mach->bank_w |= ((mach->regs[0xae] & 3) << 4); } - if (dev->on) + if (dev->on[0] || dev->on[1]) mach_log("Separate B2Bank = %02x, AEbank = %02x.\n", mach->regs[0xb2], mach->regs[0xae]); } else { /* Single bank mode */ mach->bank_w = ((mach->regs[0xb2] & 0x1e) >> 1); @@ -2355,7 +2353,7 @@ mach_out(uint16_t addr, uint8_t val, void *priv) mach->bank_w |= ((mach->regs[0xae] & 3) << 4); } mach->bank_r = mach->bank_w; - if (dev->on) + if (dev->on[0] || dev->on[1]) mach_log("Single B2Bank = %02x, AEbank = %02x.\n", mach->regs[0xb2], mach->regs[0xae]); } svga->read_bank = mach->bank_r << 16; @@ -2590,7 +2588,7 @@ mach_recalctimings(svga_t *svga) if (mach->regs[0xb0] & 0x20) svga->gdcreg[5] |= 0x40; - if (dev->on) { + if (dev->on[0] || dev->on[1]) { mach_log("8514/A ON.\n"); if (dev->local >= 2) { dev->h_disp = (dev->hdisp + 1) << 3; @@ -3686,19 +3684,16 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach) case 0x4ae8: case 0x4ae9: - if (!(port & 1)) { - if (dev->local < 2) - dev->ext_crt_pitch = 128; + if (dev->local < 2) + dev->ext_crt_pitch = 128; - dev->accel.advfunc_cntl = val & 0x0f; - } else { - dev->on = (dev->accel.advfunc_cntl & 0x01); - vga_on = !dev->on; - mach->ext_on = dev->on; - mach_log("ATI 8514/A: (0x4ae9) val = %04x, ext = %d.\n", dev->accel.advfunc_cntl & 0x01, mach->ext_on); - mach32_updatemapping(mach); - } - mach->ati_mode = 0; + WRITE8(port, dev->accel.advfunc_cntl, val); + dev->on[port & 1] = (dev->accel.advfunc_cntl & 0x01); + mach_log("%04x: ON=%d.\n", port, dev->on[port & 1]); + vga_on = !dev->on[port & 1]; + mach->ext_on[port & 1] = dev->on[port & 1]; + mach32_updatemapping(mach); + mach->ati_mode[port & 1] = 0; svga_recalctimings(svga); break; @@ -3806,29 +3801,22 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach) break; case 0x42ee: - mach->accel.test2[0] = val; - break; case 0x42ef: - mach->accel.test2[1] = val; + mach->accel.test2[port & 1] = val; break; case 0x46ee: - mach->accel.test3[0] = val; - break; case 0x46ef: - mach->accel.test3[1] = val; + mach->accel.test3[port & 1] = val; break; case 0x4aee: case 0x4aef: WRITE8(port, mach->accel.clock_sel, val); - if (port & 1) { - dev->on = mach->accel.clock_sel & 0x01; - mach->ext_on = dev->on; - vga_on = !dev->on; - mach_log("ATI 8514/A: (0x4aef) val = %04x, ext = %d.\n", mach->accel.clock_sel & 0x01, mach->ext_on); - } - mach->ati_mode = 1; + dev->on[port & 1] = mach->accel.clock_sel & 0x01; + mach->ext_on[port & 1] = dev->on[port & 1]; + vga_on = !dev->on[port & 1]; + mach->ati_mode[port & 1] = 1; svga_recalctimings(svga); break; @@ -3836,16 +3824,14 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach) case 0x52ef: mach_log("ATI 8514/A: (0x%04x) val = %04x.\n", port, val); WRITE8(port, mach->accel.scratch0, val); - if (port & 1) - mach->ext_on = 1; + mach->ext_on[port & 1] = 1; break; case 0x56ee: case 0x56ef: mach_log("ATI 8514/A: (0x%04x) val = %04x.\n", port, val); WRITE8(port, mach->accel.scratch1, val); - if (port & 1) - mach->ext_on = 1; + mach->ext_on[port & 1] = 1; break; case 0x5aee: @@ -3926,11 +3912,8 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach) break; } svga_set_ramdac_type(svga, !!(mach->accel.ext_ge_config & 0x4000)); - if (port & 1) { - mach->ati_mode = 1; - mach_log("ATI 8514/A: (0x%04x) val = %04x.\n", port, val); - mach32_updatemapping(mach); - } + mach->ati_mode[port & 1] = 1; + mach32_updatemapping(mach); } svga_recalctimings(svga); break; @@ -5115,10 +5098,12 @@ mach32_updatemapping(mach_t *mach) mach->ap_size = 4; mem_mapping_disable(&mach->mmio_linear_mapping); } - if (mach->ext_on && (dev->local >= 2) && mach->ati_mode) { + if ((mach->ext_on[0] || mach->ext_on[1]) && (dev->local >= 2) && (mach->ati_mode[0] || mach->ati_mode[1])) { + mach_log("ExtON.\n"); mem_mapping_set_handler(&svga->mapping, mach32_read, mach32_readw, mach32_readl, mach32_write, mach32_writew, mach32_writel); mem_mapping_set_p(&svga->mapping, mach); } else { + mach_log("ExtOFF.\n"); mem_mapping_set_handler(&svga->mapping, svga_read, svga_readw, svga_readl, svga_write, svga_writew, svga_writel); mem_mapping_set_p(&svga->mapping, svga); } @@ -5456,7 +5441,8 @@ mach_mca_reset(void *priv) mem_mapping_disable(&mach->bios_rom.mapping); mem_mapping_disable(&mach->bios_rom2.mapping); mach_log("MCA reset.\n"); - dev->on = 0; + dev->on[0] = 0; + dev->on[1] = 0; vga_on = 1; mach_mca_write(0x102, 0, mach); } @@ -5564,12 +5550,10 @@ mach32_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv) case 0x12: mach->linear_base = (mach->linear_base & 0xff000000) | ((val & 0xc0) << 16); - mach->ati_mode = 1; mach32_updatemapping(mach); break; case 0x13: mach->linear_base = (mach->linear_base & 0xc00000) | (val << 24); - mach->ati_mode = 1; mach32_updatemapping(mach); break; @@ -5722,7 +5706,8 @@ mach8_init(const device_t *info) dev->bpp = 0; svga->getclock = ics2494_getclock; - dev->on = 0; + dev->on[0] = 0; + dev->on[1] = 0; dev->ext_pitch = 1024; dev->ext_crt_pitch = 0x80; dev->accel_bpp = 8; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 8ec645016..c48baeb6e 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -212,10 +212,12 @@ svga_out(uint16_t addr, uint8_t val, void *priv) svga_recalctimings(svga); break; case 0x3c3: - if (xga_active) + if (xga_active && xga) xga->on = (val & 0x01) ? 0 : 1; - if (ibm8514_active) - dev->on = (val & 0x01) ? 0 : 1; + if (ibm8514_active && dev) { + dev->on[0] = (val & 0x01) ? 0 : 1; + dev->on[1] = dev->on[0]; + } svga_log("3C3: XGA ON = %d.\n", xga->on); vga_on = val & 0x01; @@ -527,7 +529,7 @@ svga_set_ramdac_type(svga_t *svga, int type) svga->ramdac_type = type; for (int c = 0; c < 256; c++) { - if (ibm8514_active) { + if (ibm8514_active && dev) { if (svga->ramdac_type == RAMDAC_8BIT) dev->pallook[c] = makecol32(svga->vgapal[c].r, svga->vgapal[c].g, svga->vgapal[c].b); else @@ -535,7 +537,7 @@ svga_set_ramdac_type(svga_t *svga, int type) (svga->vgapal[c].g & 0x3f) * 4, (svga->vgapal[c].b & 0x3f) * 4); } - if (xga_active) { + if (xga_active && xga) { if (svga->ramdac_type == RAMDAC_8BIT) xga->pallook[c] = makecol32(svga->vgapal[c].r, svga->vgapal[c].g, svga->vgapal[c].b); else @@ -834,11 +836,11 @@ svga_poll(void *priv) int old_ma; if (!svga->override) { - if (ibm8514_active && dev->on) { + if (ibm8514_active && dev && (dev->on[0] || dev->on[1])) { ibm8514_poll(dev, svga); return; } - if (xga_active && xga->on) { + if (xga_active && xga && xga->on) { if ((xga->disp_cntl_2 & 7) >= 2) { xga_poll(xga, svga); return; @@ -1253,7 +1255,7 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *priv) cycles -= svga->monitor->mon_video_timing_write_b; if (!linear) { - if (xga_active) { + if (xga_active && xga) { if (((xga->op_mode & 7) >= 4) && (xga->aperture_cntl >= 1)) { if (val == 0xa5) { /*Memory size test of XGA*/ xga->test = val; @@ -1474,7 +1476,7 @@ svga_read_common(uint32_t addr, uint8_t linear, void *priv) cycles -= svga->monitor->mon_video_timing_read_b; if (!linear) { - if (xga_active) { + if (xga_active && xga) { if (((xga->op_mode & 7) >= 4) && (xga->aperture_cntl >= 1)) { if (xga->test == 0xa5) { /*Memory size test of XGA*/ if (addr == 0xa0001) { From 849c3f27f8e32f1e532fef8151cf33766765165b Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 9 Nov 2023 16:51:48 +0100 Subject: [PATCH 12/19] The option to show status icons in full screen now calls config_save() on toggle, fixes #3815. --- src/qt/qt_mainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 4b849edd6..a5651eada 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -2033,5 +2033,6 @@ void MainWindow::on_actionShow_status_icons_in_fullscreen_triggered() { status_icons_fullscreen = !status_icons_fullscreen; ui->actionShow_status_icons_in_fullscreen->setChecked(status_icons_fullscreen); + config_save(); } From 45f0ecc87e0a3d622a07ce70129fafaf02feca8b Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 9 Nov 2023 23:58:58 +0100 Subject: [PATCH 13/19] Forgot to apply the correction to the ATI 68860 ramdac, should clear the compile warnings. --- src/video/vid_ati68860_ramdac.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/video/vid_ati68860_ramdac.c b/src/video/vid_ati68860_ramdac.c index 8b4c4924b..7cdd18019 100644 --- a/src/video/vid_ati68860_ramdac.c +++ b/src/video/vid_ati68860_ramdac.c @@ -73,16 +73,16 @@ ati68860_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga) switch (addr) { case 0: - svga_out((dev && dev->on) ? 0x2ec : 0x3c8, val, svga); + svga_out((dev && (dev->on[0] || dev->on[1])) ? 0x2ec : 0x3c8, val, svga); break; case 1: - svga_out((dev && dev->on) ? 0x2ed : 0x3c9, val, svga); + svga_out((dev && (dev->on[0] || dev->on[1])) ? 0x2ed : 0x3c9, val, svga); break; case 2: - svga_out((dev && dev->on) ? 0x2ea : 0x3c6, val, svga); + svga_out((dev && (dev->on[0] || dev->on[1])) ? 0x2ea : 0x3c6, val, svga); break; case 3: - svga_out((dev && dev->on) ? 0x2eb : 0x3c7, val, svga); + svga_out((dev && (dev->on[0] || dev->on[1])) ? 0x2eb : 0x3c7, val, svga); break; default: ramdac->regs[addr & 0xf] = val; @@ -178,16 +178,16 @@ ati68860_ramdac_in(uint16_t addr, void *priv, svga_t *svga) switch (addr) { case 0: - temp = svga_in((dev && dev->on) ? 0x2ec : 0x3c8, svga); + temp = svga_in((dev && (dev->on[0] || dev->on[1])) ? 0x2ec : 0x3c8, svga); break; case 1: - temp = svga_in((dev && dev->on) ? 0x2ed : 0x3c9, svga); + temp = svga_in((dev && (dev->on[0] || dev->on[1])) ? 0x2ed : 0x3c9, svga); break; case 2: - temp = svga_in((dev && dev->on) ? 0x2ea : 0x3c6, svga); + temp = svga_in((dev && (dev->on[0] || dev->on[1])) ? 0x2ea : 0x3c6, svga); break; case 3: - temp = svga_in((dev && dev->on) ? 0x2eb : 0x3c7, svga); + temp = svga_in((dev && (dev->on[0] || dev->on[1])) ? 0x2eb : 0x3c7, svga); break; case 4: case 8: From ad9da9bd4a8ddae053eab54e5348a29ef8f3b070 Mon Sep 17 00:00:00 2001 From: Alexander Babikov <2708460+lemondrops@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:23:18 +0500 Subject: [PATCH 14/19] Fix ATAPI HDDs not being displayed in the status bar --- src/qt/qt_machinestatus.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/qt/qt_machinestatus.cpp b/src/qt/qt_machinestatus.cpp index bb3002df2..d7b115a64 100644 --- a/src/qt/qt_machinestatus.cpp +++ b/src/qt/qt_machinestatus.cpp @@ -429,11 +429,12 @@ MachineStatus::refresh(QStatusBar *sbar) bool has_xta = machine_has_flags(machine, MACHINE_XTA) > 0; bool has_esdi = machine_has_flags(machine, MACHINE_ESDI) > 0; - int c_mfm = hdd_count(HDD_BUS_MFM); - int c_esdi = hdd_count(HDD_BUS_ESDI); - int c_xta = hdd_count(HDD_BUS_XTA); - int c_ide = hdd_count(HDD_BUS_IDE); - int c_scsi = hdd_count(HDD_BUS_SCSI); + int c_mfm = hdd_count(HDD_BUS_MFM); + int c_esdi = hdd_count(HDD_BUS_ESDI); + int c_xta = hdd_count(HDD_BUS_XTA); + int c_ide = hdd_count(HDD_BUS_IDE); + int c_atapi = hdd_count(HDD_BUS_ATAPI); + int c_scsi = hdd_count(HDD_BUS_SCSI); sbar->removeWidget(d->cassette.label.get()); for (int i = 0; i < 2; ++i) { @@ -597,12 +598,21 @@ MachineStatus::refresh(QStatusBar *sbar) d->hdds[HDD_BUS_XTA].label->setToolTip(tr("Hard disk (%s)").replace("%s", "XTA")); sbar->addWidget(d->hdds[HDD_BUS_XTA].label.get()); } - if ((hasIDE() || hdc_name.left(5) == QStringLiteral("xtide") || hdc_name.left(3) == QStringLiteral("ide")) && c_ide > 0) { - d->hdds[HDD_BUS_IDE].label = std::make_unique(); - d->hdds[HDD_BUS_IDE].setActive(false); - d->hdds[HDD_BUS_IDE].refresh(); - d->hdds[HDD_BUS_IDE].label->setToolTip(tr("Hard disk (%s)").replace("%s", "IDE")); - sbar->addWidget(d->hdds[HDD_BUS_IDE].label.get()); + if (hasIDE() || hdc_name.left(5) == QStringLiteral("xtide") || hdc_name.left(3) == QStringLiteral("ide")) { + if (c_ide > 0) { + d->hdds[HDD_BUS_IDE].label = std::make_unique(); + d->hdds[HDD_BUS_IDE].setActive(false); + d->hdds[HDD_BUS_IDE].refresh(); + d->hdds[HDD_BUS_IDE].label->setToolTip(tr("Hard disk (%s)").replace("%s", "IDE")); + sbar->addWidget(d->hdds[HDD_BUS_IDE].label.get()); + } + if (c_atapi > 0) { + d->hdds[HDD_BUS_ATAPI].label = std::make_unique(); + d->hdds[HDD_BUS_ATAPI].setActive(false); + d->hdds[HDD_BUS_ATAPI].refresh(); + d->hdds[HDD_BUS_ATAPI].label->setToolTip(tr("Hard disk (%s)").replace("%s", "ATAPI")); + sbar->addWidget(d->hdds[HDD_BUS_ATAPI].label.get()); + } } if ((hasSCSI() || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) || (scsi_card_current[2] != 0) || (scsi_card_current[3] != 0)) && c_scsi > 0) { d->hdds[HDD_BUS_SCSI].label = std::make_unique(); From 9bcece63fc52a308b8938427df2f3874410f6725 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 10 Nov 2023 17:27:30 -0300 Subject: [PATCH 15/19] Fix some random comments which have been bugging me --- src/cdrom/cdrom.c | 2 +- src/scsi/scsi_cdrom.c | 2 +- src/video/vid_tgui9440.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 22cefb991..40686f14a 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -1414,7 +1414,7 @@ cdrom_read_disc_info_toc(cdrom_t *dev, unsigned char *b, unsigned char track, in b[3] = ti.attr; cdrom_log("CD-ROM %i: Returned Toshiba/NEC disc information (type 2) at %02i:%02i.%02i, track=%d, m=%02i,s=%02i,f=%02i, tno=%02x.\n", dev->id, b[0], b[1], b[2], bcd2bin(track), m, s, f, ti.attr); break; - case 3: /*Undocumented on NEC CD-ROM's, from information based on sr_vendor.c from Android's source code*/ + case 3: /* Undocumented on NEC CD-ROM's, from information based on sr_vendor.c from the Linux kernel */ switch (dev->type) { case CDROM_TYPE_NEC_25_10a: case CDROM_TYPE_NEC_38_103: diff --git a/src/scsi/scsi_cdrom.c b/src/scsi/scsi_cdrom.c index 056c7fdfe..fb52ca898 100644 --- a/src/scsi/scsi_cdrom.c +++ b/src/scsi/scsi_cdrom.c @@ -1997,7 +1997,7 @@ begin: case CDROM_TYPE_NEC_211_100: case CDROM_TYPE_NEC_464_105: /*GPCMD_READ_DISC_INFORMATION_NEC*/ scsi_cdrom_set_phase(dev, SCSI_PHASE_DATA_IN); - scsi_cdrom_buf_alloc(dev, 22); /*NEC manual claims 4 bytes, but the Android source code (namely sr_vendor.c) actually states otherwise.*/ + scsi_cdrom_buf_alloc(dev, 22); /* NEC manual claims 4 bytes, but the Linux kernel (namely sr_vendor.c) actually states otherwise. */ if (!dev->drv->ops) { scsi_cdrom_not_ready(dev); diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index 0b5e99c4c..7bed43ac2 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -1462,7 +1462,7 @@ tgui_accel_command(int count, uint32_t cpu_dat, tgui_t *tgui) } } - /*See this: https://android.googlesource.com/kernel/tegra/+/android-tegra-flounder-3.10-lollipop-release/drivers/video/tridentfb.c for the pitch*/ + /* See Linux kernel drivers/video/tridentfb.c for the pitch */ tgui->accel.pitch = svga->rowoffset; switch (svga->bpp) { From c8ef85c249880d525103064c2d46bef43073706f Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 10 Nov 2023 22:42:36 +0100 Subject: [PATCH 16/19] Stop the initialization of a ZIP or Magneto-Optical drive if its task file structure pointer is NULL. --- src/disk/mo.c | 3 +++ src/disk/zip.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/disk/mo.c b/src/disk/mo.c index ad781a8ac..dda4222ca 100644 --- a/src/disk/mo.c +++ b/src/disk/mo.c @@ -2152,6 +2152,9 @@ mo_hard_reset(void) mo_init(dev); + if (dev->tf == NULL) + continue; + if (strlen(mo_drives[c].image_path)) mo_load(dev, mo_drives[c].image_path); diff --git a/src/disk/zip.c b/src/disk/zip.c index c498383e8..69af18e74 100644 --- a/src/disk/zip.c +++ b/src/disk/zip.c @@ -2391,6 +2391,9 @@ zip_hard_reset(void) zip_init(dev); + if (dev->tf == NULL) + continue; + if (strlen(zip_drives[c].image_path)) zip_load(dev, zip_drives[c].image_path); From f35a042f42d36c327dc7a0759bca9126f2fcc2d5 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 10 Nov 2023 22:53:56 +0100 Subject: [PATCH 17/19] Moved the sanity checks to the correct place. --- src/disk/mo.c | 6 +++--- src/disk/zip.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/disk/mo.c b/src/disk/mo.c index dda4222ca..27bf7e5e0 100644 --- a/src/disk/mo.c +++ b/src/disk/mo.c @@ -2147,14 +2147,14 @@ mo_hard_reset(void) dev = (mo_t *) mo_drives[c].priv; + if (dev->tf == NULL) + continue; + dev->id = c; dev->drv = &mo_drives[c]; mo_init(dev); - if (dev->tf == NULL) - continue; - if (strlen(mo_drives[c].image_path)) mo_load(dev, mo_drives[c].image_path); diff --git a/src/disk/zip.c b/src/disk/zip.c index 69af18e74..887a9c68e 100644 --- a/src/disk/zip.c +++ b/src/disk/zip.c @@ -2386,14 +2386,14 @@ zip_hard_reset(void) dev = (zip_t *) zip_drives[c].priv; + if (dev->tf == NULL) + continue; + dev->id = c; dev->drv = &zip_drives[c]; zip_init(dev); - if (dev->tf == NULL) - continue; - if (strlen(zip_drives[c].image_path)) zip_load(dev, zip_drives[c].image_path); From 6153c84b8f0a21e7e07a9d07de8bb4e9f62644bf Mon Sep 17 00:00:00 2001 From: maximus105 <58270614+maximus105@users.noreply.github.com> Date: Sat, 11 Nov 2023 14:02:56 +0200 Subject: [PATCH 18/19] Update qt_mainwindow.cpp This commit fixes issue #3485 --- src/qt/qt_mainwindow.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index a5651eada..2fe9d22c2 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -615,6 +615,15 @@ MainWindow::MainWindow(QWidget *parent) if (!vnc_enabled) video_setblit(qt_blit); + if (start_in_fullscreen) { + connect(ui->stackedWidget, &RendererStack::blit, this, [this] () { + if (start_in_fullscreen) { + QTimer::singleShot(100, ui->actionFullscreen, &QAction::trigger); + start_in_fullscreen = 0; + } + }); + } + #ifdef MTR_ENABLED { ui->actionBegin_trace->setVisible(true); @@ -841,10 +850,6 @@ MainWindow::showEvent(QShowEvent *event) QApplication::processEvents(); this->adjustSize(); } - if (start_in_fullscreen) { - start_in_fullscreen = 0; - QTimer::singleShot(0, ui->actionFullscreen, &QAction::trigger); - } } void From 8637066855d00dab6180a01e4ee0fca85c375f26 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 11 Nov 2023 15:42:15 +0100 Subject: [PATCH 19/19] Fixed some newly introduced indentation mess. --- src/qt/qt_mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 2fe9d22c2..a372dbfb8 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -615,7 +615,7 @@ MainWindow::MainWindow(QWidget *parent) if (!vnc_enabled) video_setblit(qt_blit); - if (start_in_fullscreen) { + if (start_in_fullscreen) { connect(ui->stackedWidget, &RendererStack::blit, this, [this] () { if (start_in_fullscreen) { QTimer::singleShot(100, ui->actionFullscreen, &QAction::trigger);