diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index 2c8617cb7f490..6d848c492a89d 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<s32>(v0); i++) + iopMemWrite8(data + i, buf[i]); + } pc = ra; return 1; @@ -899,8 +907,12 @@ namespace R3000A { auto buf = std::make_unique<char[]>(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);