Pad/SIO: Mask unused mode bits and write-only control bits on read

Matches psxdiag and the SIO register docs.
This commit is contained in:
Stenzek committed 2026-10-19 18:14:16 +10:00
1 parent a89dc5501b
commit 5215e06dfd
2 files changed
+14 -4

No files matched your search

+7 -2
View File
@@ -59,6 +59,9 @@ union JOYCTRLRegister
BitField<u16, bool, 11, 1> RXINTEN;
BitField<u16, bool, 12, 1> ACKINTEN;
BitField<u16, u8, 13, 1> SLOT;
// Acknowledge and reset are write-only, bits 7/14/15 always read as zero.
static constexpr u16 READ_MASK = 0b00111111'00101111;
};
union JOYSTATRegister
@@ -82,6 +85,8 @@ union JOYMODERegister
BitField<u16, bool, 4, 1> parity_enable;
BitField<u16, u8, 5, 1> parity_type;
BitField<u16, u8, 8, 1> clk_polarity;
static constexpr u16 WRITE_MASK = 0b00000001'00111111;
};
static bool CanTransfer();
@@ -580,7 +585,7 @@ u32 Pad::ReadRegister(u32 offset)
return ZeroExtend32(s_state.JOY_MODE.bits);
case 0x0A: // JOY_CTRL
return ZeroExtend32(s_state.JOY_CTRL.bits);
return ZeroExtend32(s_state.JOY_CTRL.bits & JOYCTRLRegister::READ_MASK);
case 0x0E: // JOY_BAUD
return ZeroExtend32(s_state.JOY_BAUD);
@@ -650,7 +655,7 @@ void Pad::WriteRegister(u32 offset, u32 value)
case 0x08: // JOY_MODE
{
DEBUG_LOG("JOY_MODE <- 0x{:08X}", value);
s_state.JOY_MODE.bits = Truncate16(value);
s_state.JOY_MODE.bits = Truncate16(value) & JOYMODERegister::WRITE_MASK;
return;
}
+7 -2
View File
@@ -35,6 +35,9 @@ union SIO_CTRL
BitField<u16, bool, 10, 1> TXINTEN;
BitField<u16, bool, 11, 1> RXINTEN;
BitField<u16, bool, 12, 1> ACKINTEN;
// Acknowledge and reset are write-only, bits 13-15 always read as zero.
static constexpr u16 READ_MASK = 0b00011111'10101111;
};
union SIO_STAT
@@ -63,6 +66,8 @@ union SIO_MODE
BitField<u16, bool, 4, 1> parity_enable;
BitField<u16, u8, 5, 1> parity_type;
BitField<u16, u8, 6, 2> stop_bit_length;
static constexpr u16 WRITE_MASK = 0b00000000'11111111;
};
} // namespace
@@ -122,7 +127,7 @@ u32 SIO::ReadRegister(u32 offset)
return ZeroExtend32(s_SIO_MODE.bits);
case 0x0A: // SIO_CTRL
return ZeroExtend32(s_SIO_CTRL.bits);
return ZeroExtend32(s_SIO_CTRL.bits & SIO_CTRL::READ_MASK);
case 0x0E: // SIO_BAUD
return ZeroExtend32(s_SIO_BAUD);
@@ -161,7 +166,7 @@ void SIO::WriteRegister(u32 offset, u32 value)
case 0x08: // SIO_MODE
{
DEBUG_LOG("SIO_MODE <- 0x{:08X}", value);
s_SIO_MODE.bits = Truncate16(value);
s_SIO_MODE.bits = Truncate16(value) & SIO_MODE::WRITE_MASK;
return;
}