From c044e3e5d62089a53f1eacf99be9ecc1bb7cd012 Mon Sep 17 00:00:00 2001 From: gameblabla Date: Thu, 18 Jul 2019 02:26:18 +0200 Subject: [PATCH] psxbios: Add checks for strcmp & strncmp. Yes, it's supposed to have a lot of checks like these. Also merge some more fixes from PCSX4ALL. (upstream did not have these as far as i know) --- libpcsxcore/psxbios.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index df0550e8..44711b53 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -541,13 +541,35 @@ void psxBios_strncat() { // 0x16 void psxBios_strcmp() { // 0x17 char *p1 = (char *)Ra0, *p2 = (char *)Ra1; - + s32 n=0; + if (a0 == 0 && a1 == 0) + { + v0 = 0; + pc0 = ra; + return; + } + else if (a0 == 0 && a1 != 0) + { + v0 = -1; + pc0 = ra; + return; + } + else if (a0 != 0 && a1 == 0) + { + v0 = 1; + pc0 = ra; + return; + } #ifdef PSXBIOS_LOG PSXBIOS_LOG("psxBios_%s: %s (%x), %s (%x)\n", biosA0n[0x17], Ra0, a0, Ra1, a1); #endif while (*p1 == *p2++) { + n++; if (*p1++ == '\0') { + v1=n-1; + a0+=n; + a1+=n; v0 = 0; pc0 = ra; return; @@ -555,6 +577,9 @@ void psxBios_strcmp() { // 0x17 } v0 = (*p1 - *--p2); + v1 = n; + a0+=n; + a1+=n; pc0 = ra; } -- 2.39.5