From 3f28b64fb1baeedec76a150ee40eaec0b9095d92 Mon Sep 17 00:00:00 2001 From: gameblabla Date: Thu, 18 Jul 2019 02:17:35 +0200 Subject: [PATCH] psxbios : Add checks to memset. This now can be a tricky pony and an improper memset implementation means that you can't play Tomb Raider 4 properly. (Trying to put in the eye of horus will just result in Lara sidestepping) This should hopefully be fixed (and follows nocash doc). --- libpcsxcore/psxbios.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index b327632b..97c79519 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -805,8 +805,19 @@ void psxBios_memcpy() { // 0x2a void psxBios_memset() { // 0x2b char *p = (char *)Ra0; + v0 = a0; + if (a2 > 0x7FFFFFFF || a2 == 0) + { + v0 = 0; + pc0 = ra; + return; + } + if (a0 == 0) + { + pc0 = ra; + return; + } while ((s32)a2-- > 0) *p++ = (char)a1; - a2 = 0; v0 = a0; pc0 = ra; } -- 2.39.2