From: Twinaphex Date: Sun, 7 Dec 2014 11:00:27 +0000 (+0100) Subject: Merge pull request #9 from Kekun/fix-load-invalid-game X-Git-Tag: r24l~898 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13bb560e427a36c6900ea09061efecc2a67d53d0;hp=89329f140b3a7982dd3529ab374195b0e0b23dc8;p=pcsx_rearmed.git Merge pull request #9 from Kekun/fix-load-invalid-game Fixes an infinite loop when loading an invalid game --- diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 874624dd..a27f60fb 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -109,6 +109,7 @@ void mmssdd( char *b, char *p ) int GetCdromFile(u8 *mdir, u8 *time, char *filename) { struct iso_directory_record *dir; + int retval = -1; u8 ddir[4096]; u8 *buf; int i; @@ -122,7 +123,7 @@ int GetCdromFile(u8 *mdir, u8 *time, char *filename) { if (dir->length[0] == 0) { return -1; } - i += dir->length[0]; + i += (u8)dir->length[0]; if (dir->flags[0] & 0x2) { // it's a dir if (!strnicmp((char *)&dir->name[0], filename, dir->name_len[0])) { @@ -138,11 +139,12 @@ int GetCdromFile(u8 *mdir, u8 *time, char *filename) { } else { if (!strnicmp((char *)&dir->name[0], filename, strlen(filename))) { mmssdd(dir->extent, (char *)time); + retval = 0; break; } } } - return 0; + return retval; } static const unsigned int gpu_ctl_def[] = { diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 45edd655..9ee832ef 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -3999,10 +3999,16 @@ static int emit_fastpath_cmp_jump(int i,int addr,int *addr_reg_override) type=0; } else if(type==MTYPE_1F80) { // scratchpad - emit_addimm(addr,-0x1f800000,HOST_TEMPREG); - emit_cmpimm(HOST_TEMPREG,0x1000); - jaddr=(int)out; - emit_jc(0); + if (psxH == (void *)0x1f800000) { + emit_addimm(addr,-0x1f800000,HOST_TEMPREG); + emit_cmpimm(HOST_TEMPREG,0x1000); + jaddr=(int)out; + emit_jc(0); + } + else { + // do usual RAM check, jump will go to the right handler + type=0; + } } #endif diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index 2ca5dd58..7001744b 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -150,11 +150,11 @@ int psxMemInit() { } psxP = &psxM[0x200000]; - psxH = psxMap(0x1f800000, 0x10000, 1, MAP_TAG_OTHER); + psxH = psxMap(0x1f800000, 0x10000, 0, MAP_TAG_OTHER); psxR = psxMap(0x1fc00000, 0x80000, 0, MAP_TAG_OTHER); if (psxMemRLUT == NULL || psxMemWLUT == NULL || - psxR == NULL || psxP == NULL || psxH != (void *)0x1f800000) { + psxR == NULL || psxP == NULL || psxH == NULL) { SysMessage(_("Error allocating memory!")); psxMemShutdown(); return -1;