From 301a92655f284141687df4538f4ca40d99597c1d Mon Sep 17 00:00:00 2001 From: Edward Li Date: Thu, 7 Nov 2024 13:25:12 +0800 Subject: [PATCH] Mimic 8-bit overflow manually in SCBRR2_write --- core/hw/sh4/modules/serial.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/hw/sh4/modules/serial.cpp b/core/hw/sh4/modules/serial.cpp index 3c1da16f2c..d99fb0c744 100644 --- a/core/hw/sh4/modules/serial.cpp +++ b/core/hw/sh4/modules/serial.cpp @@ -339,7 +339,12 @@ void SCIFSerialPort::SCFCR2_write(u16 data) // SCBRR2 - Bit Rate Register void SCIFSerialPort::SCBRR2_write(u32 addr, u8 data) { - SCIF_SCBRR2 = data; + // Mimic 8-bit overflow manually: -94 could become 4294967202 with 32-bit overflow in macOS arm64 + if (static_cast(data) < 0) + SCIF_SCBRR2 = static_cast(data) + 256; + else + SCIF_SCBRR2 = data; + Instance().updateBaudRate(); }