Skip to content

Commit

Permalink
Mimic 8-bit overflow manually in SCBRR2_write
Browse files Browse the repository at this point in the history
  • Loading branch information
vkedwardli committed Nov 7, 2024
1 parent fc6142b commit 301a926
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/hw/sh4/modules/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<signed char>(data) < 0)
SCIF_SCBRR2 = static_cast<signed char>(data) + 256;
else
SCIF_SCBRR2 = data;

Instance().updateBaudRate();
}

Expand Down

0 comments on commit 301a926

Please sign in to comment.