From 7254a126cb63789161f62762da6a5b1659fff471 Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Thu, 12 Dec 2024 14:38:06 -0500 Subject: [PATCH 1/2] IOPBios: Defer to iopMemSafeWriteBytes when HLEing reads --- pcsx2/IopBios.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index 2c8617cb7f490..843f2a027539d 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -852,8 +852,16 @@ namespace R3000A v0 = file->read(buf.get(), count); - for (s32 i = 0; i < (s32)v0; i++) - iopMemWrite8(data + i, buf[i]); + [[likely]] + if (v0 >= 0 && iopMemSafeWriteBytes(data, buf.get(), v0)) + { + psxCpu->Clear(data, (v0 + 3) / 4); + } + else + { + for (s32 i = 0; i < static_cast(v0); i++) + iopMemWrite8(data + i, buf[i]); + } pc = ra; return 1; From 0e2e650e909c4189645bb8aa23351a658a5fa0e1 Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Thu, 12 Dec 2024 17:54:00 -0500 Subject: [PATCH 2/2] IOPBios: Defer to iopMemSafeReadBytes when HLEing writes --- pcsx2/IopBios.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index 843f2a027539d..6d848c492a89d 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -907,8 +907,12 @@ namespace R3000A { auto buf = std::make_unique(count); - for (u32 i = 0; i < count; i++) - buf[i] = iopMemRead8(data + i); + [[unlikely]] + if (!iopMemSafeReadBytes(data, buf.get(), count)) + { + for (u32 i = 0; i < count; i++) + buf[i] = iopMemRead8(data + i); + } v0 = file->write(buf.get(), count);