From 13fab97ccf3297292728cca2d356339cc8e5ee5a Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 3 Aug 2019 08:35:12 +0800 Subject: Silence warning -Wformat-overflow - Increasing the maximum size of destination char array to x2 to silence this warning. --- libpcsxcore/plugins.c | 4 ++-- libpcsxcore/ppf.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libpcsxcore') diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 4f52ed2..0c2b190 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -1064,7 +1064,7 @@ void CALLBACK clearDynarec(void) { int LoadPlugins() { int ret; - char Plugin[MAXPATHLEN]; + char Plugin[MAXPATHLEN * 2]; ReleasePlugins(); SysLibError(); @@ -1169,7 +1169,7 @@ int ReloadCdromPlugin() if (UsingIso()) { LoadCDRplugin(NULL); } else { - char Plugin[MAXPATHLEN]; + char Plugin[MAXPATHLEN * 2]; sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr); if (LoadCDRplugin(Plugin) == -1) return -1; } diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index edebdd0..f6ccfca 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -183,7 +183,7 @@ void BuildPPFCache() { char method, undo = 0, blockcheck = 0; int dizlen, dizyn; unsigned char ppfmem[512]; - char szPPF[MAXPATHLEN]; + char szPPF[MAXPATHLEN * 2]; int count, seekpos, pos; u32 anz; // use 32-bit to avoid stupid overflows s32 ladr, off, anx; -- cgit v1.2.3 From 3e42b1155e892eae2dcd0ee62d0645ef43b889a5 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 3 Aug 2019 11:13:47 +0800 Subject: Silence warning -Wstringop-truncation -strncpy replaced with strcpy and memcpy where appropriate --- libpcsxcore/cdrom.c | 3 ++- libpcsxcore/misc.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'libpcsxcore') diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 17d65ab..a65ca54 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -877,7 +877,8 @@ void cdrInterrupt() { } cdr.Result[0] |= (cdr.Result[1] >> 4) & 0x08; - strncpy((char *)&cdr.Result[4], "PCSX", 4); + /* This adds the string "PCSX" in Playstation bios boot screen */ + memcpy((char *)&cdr.Result[4], "PCSX", 4); cdr.Stat = Complete; break; diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 433d4be..0b151a5 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -73,7 +73,7 @@ void mmssdd( char *b, char *p ) m = ((m / 10) << 4) | m % 10; s = ((s / 10) << 4) | s % 10; - d = ((d / 10) << 4) | d % 10; + d = ((d / 10) << 4) | d % 10; p[0] = m; p[1] = s; @@ -191,7 +191,7 @@ int LoadCdrom() { READTRACK(); // skip head and sub, and go to the root directory record - dir = (struct iso_directory_record*) &buf[12+156]; + dir = (struct iso_directory_record*) &buf[12+156]; mmssdd(dir->extent, (char*)time); @@ -236,7 +236,7 @@ int LoadCdrom() { psxRegs.pc = SWAP32(tmpHead.pc0); psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0); - psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); + psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00; tmpHead.t_size = SWAP32(tmpHead.t_size); @@ -275,7 +275,7 @@ int LoadCdromFile(const char *filename, EXE_HEADER *head) { READTRACK(); // skip head and sub, and go to the root directory record - dir = (struct iso_directory_record *)&buf[12 + 156]; + dir = (struct iso_directory_record *)&buf[12 + 156]; mmssdd(dir->extent, (char*)time); @@ -329,7 +329,7 @@ int CheckCdrom() { strncpy(CdromLabel, buf + 52, 32); // skip head and sub, and go to the root directory record - dir = (struct iso_directory_record *)&buf[12 + 156]; + dir = (struct iso_directory_record *)&buf[12 + 156]; mmssdd(dir->extent, (char *)time); @@ -426,7 +426,7 @@ size_t fread_to_ram(void *ptr, size_t size, size_t nmemb, FILE *stream) { void *tmp; size_t ret = 0; - + tmp = malloc(size * nmemb); if (tmp) { ret = fread(tmp, size, nmemb, stream); @@ -445,8 +445,8 @@ int Load(const char *ExePath) { u32 section_address, section_size; void *mem; - strncpy(CdromId, "SLUS99999", 9); - strncpy(CdromLabel, "SLUS_999.99", 11); + strcpy(CdromId, "SLUS99999"); + strcpy(CdromLabel, "SLUS_999.99"); tmpFile = fopen(ExePath, "rb"); if (tmpFile == NULL) { @@ -461,14 +461,14 @@ int Load(const char *ExePath) { section_size = SWAP32(tmpHead.t_size); mem = PSXM(section_address); if (mem != NULL) { - fseek(tmpFile, 0x800, SEEK_SET); + fseek(tmpFile, 0x800, SEEK_SET); fread_to_ram(mem, section_size, 1, tmpFile); psxCpu->Clear(section_address, section_size / 4); } fclose(tmpFile); psxRegs.pc = SWAP32(tmpHead.pc0); psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0); - psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); + psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00; retval = 0; -- cgit v1.2.3 From 1893f4083d715eb37bf8051cd539597d2abd922b Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 3 Aug 2019 12:02:35 +0800 Subject: Fix region detection for Wild Arms - Wild Arms EU and US version has non-standard string (probably for region protection) causing auto-region detection to fail and wrong CDROM info in log. - This fix sanitizes the string name to remove unneeded characters ("EXE\" in this case that comes before the serial-number). This would sanitize the CD-ROM info in log as well. --- libpcsxcore/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libpcsxcore') diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 0b151a5..82e6b8b 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -357,6 +357,14 @@ int CheckCdrom() { return -1; } } + /* Workaround for Wild Arms EU/US which has non-standard string causing incorrect region detection */ + if (exename[0] == 'E' && exename[1] == 'X' && exename[2] == 'E' && exename[3] == '\\') { + size_t offset = 4; + size_t i, len = strlen(exename) - offset; + for (i = 0; i < len; i++) + exename[i] = exename[i + offset]; + exename[i] = '\0'; + } } else if (GetCdromFile(mdir, time, "PSX.EXE;1") != -1) { strcpy(exename, "PSX.EXE;1"); strcpy(CdromId, "SLUS99999"); -- cgit v1.2.3 From a6a44e964a9759ff89ae4489bb638901984c0211 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 3 Aug 2019 17:53:45 +0800 Subject: psxbios.c: Cleanup buopen() - This just silences some [-Wpointer-sign] warning from last PR --- libpcsxcore/psxbios.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'libpcsxcore') diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 388d606..ed43045 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -2025,17 +2025,18 @@ void psxBios_UnDeliverEvent() { // 0x20 char ffile[64], *pfile; int nfile; -static void buopen(int mcd, u8 *ptr, u8 *cfg) + +static void buopen(int mcd, char *ptr, char *cfg) { int i; - u8 *fptr = ptr; + char *mcd_data = ptr; strcpy(FDesc[1 + mcd].name, Ra0+5); FDesc[1 + mcd].offset = 0; FDesc[1 + mcd].mode = a1; for (i=1; i<16; i++) { - fptr += 128; + const char *fptr = mcd_data + 128 * i; if ((*fptr & 0xF0) != 0x50) continue; if (strcmp(FDesc[1 + mcd].name, fptr+0xa)) continue; FDesc[1 + mcd].mcfile = i; @@ -2044,12 +2045,11 @@ static void buopen(int mcd, u8 *ptr, u8 *cfg) break; } if (a1 & 0x200 && v0 == -1) { /* FCREAT */ - fptr = ptr; for (i=1; i<16; i++) { int j, xor, nblk = a1 >> 16; - u8 *pptr, *fptr2; + char *pptr, *fptr2; + char *fptr = mcd_data + 128 * i; - fptr += 128; if ((*fptr & 0xF0) != 0xa0) continue; FDesc[1 + mcd].mcfile = i; @@ -2094,8 +2094,6 @@ static void buopen(int mcd, u8 *ptr, u8 *cfg) */ void psxBios_open() { // 0x32 - int i; - char *ptr; void *pa0 = Ra0; #ifdef PSXBIOS_LOG -- cgit v1.2.3 From 6e522b2b410e29bc2984d621dd368aa2d2d489af Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 3 Aug 2019 20:27:27 +0800 Subject: HLE BIOS: Fix corrupted memory card saves - Save files for games that are suppose to work with HLE bios are now corrupted from the last HLE BIOS improvements PR. - This only affects memcard 2 slot when enabled and used. Saves on memcard 1 are fine since those are directly handled through the Libretro API. - This is fixed by adding the missing SaveMcd() to buwrite(). Tested on Wild Arms and Breath of Fire III NOTE: HLE bios is still not compatible for most games. For example, memory card save functions are broken or does not work at all. Most of Konami games i have tested does not work with HLE BIOS for memory card saves. --- libpcsxcore/psxbios.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libpcsxcore') diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index ed43045..0121a7b 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -347,6 +347,7 @@ static inline void LoadRegs() { ptr = Mcd##mcd##Data + offset; \ memcpy(ptr, Ra1, length); \ FDesc[1 + mcd].offset += length; \ + SaveMcd(Config.Mcd##mcd, Mcd##mcd##Data, offset, length); \ if (FDesc[1 + mcd].mode & 0x8000) { \ DeliverEvent(0x11, 0x2); /* 0xf0000011, 0x0004 */ \ DeliverEvent(0x81, 0x2); /* 0xf4000001, 0x0004 */ \ -- cgit v1.2.3 From e6f1e7f70c3ee3816e417f97aef1501a1f950976 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 3 Aug 2019 20:56:36 +0800 Subject: Silence a few more warnings - silence a few more truncated warnings - change "disable" to "disabled" in core options --- libpcsxcore/plugins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpcsxcore') diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 0c2b190..af7ebed 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -1182,7 +1182,7 @@ void SetIsoFile(const char *filename) { IsoFile[0] = '\0'; return; } - strncpy(IsoFile, filename, MAXPATHLEN); + strncpy(IsoFile, filename, MAXPATHLEN - 1); } const char *GetIsoFile(void) { -- cgit v1.2.3