From: notaz Date: Sat, 22 Oct 2022 16:16:46 +0000 (+0300) Subject: psxbios: use noninvasive print for -psxout X-Git-Tag: r24l~354 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c02b90b22d36025085d2382eef641681b4eb01f8;p=pcsx_rearmed.git psxbios: use noninvasive print for -psxout --- diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 5a8f71bb..69e531f7 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -1252,7 +1252,7 @@ void psxBios_getchar() { //0x3b v0 = getchar(); pc0 = ra; } -void psxBios_printf() { // 0x3f +static void psxBios_printf_psxout() { // 0x3f char tmp[1024]; char tmp2[1024]; u32 save[4]; @@ -1317,11 +1317,14 @@ _start: } *ptmp = 0; - if (psp) + if (psp != INVALID_PTR) memcpy(psp, save, 4 * 4); SysPrintf("%s", tmp); +} +void psxBios_printf() { // 0x3f + psxBios_printf_psxout(); pc0 = ra; } @@ -2212,6 +2215,25 @@ void psxBios_write() { // 0x35/0x03 pc0 = ra; } +static void psxBios_write_psxout() { + if (a0 == 1) { // stdout + const char *ptr = Ra1; + int len = a2; + + if (ptr != INVALID_PTR) + while (len-- > 0) + SysPrintf("%c", *ptr++); + } +} + +static void psxBios_putchar_psxout() { // 3d + SysPrintf("%c", (char)a0); +} + +static void psxBios_puts_psxout() { // 3e/3f + SysPrintf("%s", Ra0); +} + /* * int close(int fd); */ @@ -2704,11 +2726,10 @@ void psxBiosInit() { biosB0[i] = NULL; biosC0[i] = NULL; } - biosA0[0x3e] = psxBios_puts; - biosA0[0x3f] = psxBios_printf; - - biosB0[0x3d] = psxBios_putchar; - biosB0[0x3f] = psxBios_puts; + biosA0[0x03] = biosB0[0x35] = psxBios_write_psxout; + biosA0[0x3c] = biosB0[0x3d] = psxBios_putchar_psxout; + biosA0[0x3e] = biosB0[0x3f] = psxBios_puts_psxout; + biosA0[0x3f] = psxBios_printf_psxout; if (!Config.HLE) return;