From: gameblabla Date: Wed, 17 Jul 2019 23:58:44 +0000 (+0200) Subject: psxbios: Adds putc and getc implementation X-Git-Tag: r23~156^2~43 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=324cec89343c216ad232fbcaf50faed6e528beef;p=pcsx_rearmed.git psxbios: Adds putc and getc implementation getc will need to be fixed later but this should do as it is. No issues with putc. Both are similar to psxBios_read and psxBios_write, except size is 1. --- diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 775fba7e..b13874ea 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -316,6 +316,58 @@ static inline void LoadRegs() { // * // System calls A0 */ +/* Internally redirects to "FileRead(fd,tempbuf,1)".*/ +/* For some strange reason, the returned character is sign-expanded; */ +/* So if a return value of FFFFFFFFh could mean either character FFh, or error. */ +/* TODO FIX ME : Properly implement this behaviour */ +void psxBios_getc(void) // 0x03, 0x35 +{ + void *pa1 = Ra1; +#ifdef PSXBIOS_LOG + PSXBIOS_LOG("psxBios_%s\n", biosA0n[0x03]); +#endif + v0 = -1; + + if (pa1) { + switch (a0) { + case 2: buread(pa1, 1, 1); break; + case 3: buread(pa1, 2, 1); break; + } + } + + pc0 = ra; +} + +/* Copy of psxBios_write, except size is 1. */ +void psxBios_putc(void) // 0x09, 0x3B +{ + void *pa1 = Ra1; +#ifdef PSXBIOS_LOG + PSXBIOS_LOG("psxBios_%s\n", biosA0n[0x09]); +#endif + v0 = -1; + if (!pa1) { + pc0 = ra; + return; + } + + if (a0 == 1) { // stdout + char *ptr = (char *)pa1; + + v0 = a2; + while (a2 > 0) { + printf("%c", *ptr++); a2--; + } + pc0 = ra; return; + } + + switch (a0) { + case 2: buwrite(pa1, 1, 1); break; + case 3: buwrite(pa1, 2, 1); break; + } + + pc0 = ra; +} void psxBios_abs() { // 0x0e if ((s32)a0 < 0) v0 = -(s32)a0; @@ -2378,8 +2430,8 @@ void psxBiosInit() { //biosA0[0x05] = psxBios_ioctl; //biosA0[0x06] = psxBios_exit; //biosA0[0x07] = psxBios_sys_a0_07; - //biosA0[0x08] = psxBios_getc; - //biosA0[0x09] = psxBios_putc; + biosA0[0x08] = psxBios_getc; + biosA0[0x09] = psxBios_putc; //biosA0[0x0a] = psxBios_todigit; //biosA0[0x0b] = psxBios_atof; //biosA0[0x0c] = psxBios_strtoul;