fix(memory): ignore CPU and DMA writes to unused I/O addresses

Stores to I/O addresses with no register returned Unmapped and stopped the
machine. Hardware ignores them. Emulated writes there now pay their bus cost and
change nothing; host writes stay strict. The unmodeled internal memory control
register at 0x04xx0800 and all unused I/O reads remain diagnostics.

Rollback tests that used unused I/O as their failing word now run the block on
to a register that rejects the stored value: SIOMULTI2 outside multiplayer
mode, an RCNT GPIO serial IRQ, or 64-sample wave playback. Where no reachable
register can fail (JOYSTAT, POSTFLG/HALTCNT, IME, DMA3CNT), the test now checks
that the block commits and the unused word is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HhfHfHEuzv2AUTd6erW1gU
This commit is contained in:
0xrsydn 2026-10-14 11:38:51 +07:00
commit 20176716d9
16 changed files with 166 additions and 92 deletions

View file

@ -1035,6 +1035,9 @@ impl Memory {
}
for (offset, byte) in bytes.into_iter().enumerate() {
let byte_address = address + offset as u32;
if !Io::mapped(byte_address) {
continue; // Validated unused I/O; the write has no effect.
}
if matches!(byte_address, POSTFLG | HALTCNT) && !self.can_write_power_control() {
continue; // BIOS-only CPU writes; ignored elsewhere, including STOP requests.
}
@ -1116,8 +1119,11 @@ impl Memory {
0x07 => Ok((address & 0x3ff) as usize),
0x04 => {
for offset in 0..N as u32 {
if !Io::mapped(address + offset) {
return Err(MemoryError::Unmapped(address + offset));
let at = address + offset;
// Unused I/O ignores emulated writes; host setup stays strict.
let ignored = access == WriteAccess::Emulated && Io::unused(at);
if !(Io::mapped(at) || ignored) {
return Err(MemoryError::Unmapped(at));
}
}
Ok(0) // I/O does not use a RAM index.