X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fpsxmem.c;h=6f85f82f7dbeae377329563a6eeedd01f338384f;hb=630b122be82914a74fac752688abe5d5dd798aa8;hp=2f427acfa48f3cfe0381b92284c841d3ef0fa734;hpb=9abd586c96e8a2e37e92b620c70668a57d6f89f7;p=pcsx_rearmed.git diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index 2f427acf..6f85f82f 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -39,6 +39,8 @@ #define MAP_ANONYMOUS MAP_ANON #endif +boolean writeok = TRUE; + #ifndef NDEBUG #include "debug.h" #else @@ -52,16 +54,7 @@ void (*psxUnmapHook)(void *ptr, size_t size, enum psxMapTag tag); void *psxMap(unsigned long addr, size_t size, int is_fixed, enum psxMapTag tag) { -#ifdef LIGHTREC -#ifdef MAP_FIXED_NOREPLACE - int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE; -#else - int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED; -#endif -#else int flags = MAP_PRIVATE | MAP_ANONYMOUS; -#endif - int try_ = 0; unsigned long mask; void *req, *ret; @@ -154,36 +147,17 @@ int psxMemInit() { memset(psxMemRLUT, 0, 0x10000 * sizeof(void *)); memset(psxMemWLUT, 0, 0x10000 * sizeof(void *)); -#ifdef LIGHTREC - psxM = psxMap(0x30000000, 0x00210000, 1, MAP_TAG_RAM); - if (psxM == NULL) - psxM = psxMap(0x70000000, 0x00210000, 1, MAP_TAG_RAM); - -#else psxM = psxMap(0x80000000, 0x00210000, 1, MAP_TAG_RAM); -#endif -#ifndef RAM_FIXED if (psxM == NULL) psxM = psxMap(0x77000000, 0x00210000, 0, MAP_TAG_RAM); -#endif if (psxM == NULL) { SysMessage(_("mapping main RAM failed")); return -1; } psxP = &psxM[0x200000]; -#ifdef LIGHTREC - psxH = psxMap(0x4f800000, 0x10000, 0, MAP_TAG_OTHER); - if (psxH == NULL) - psxH = psxMap(0x8f800000, 0x10000, 0, MAP_TAG_OTHER); - - psxR = psxMap(0x4fc00000, 0x80000, 0, MAP_TAG_OTHER); - if (psxR == NULL) - psxR = psxMap(0x8fc00000, 0x80000, 0, MAP_TAG_OTHER); -#else psxH = psxMap(0x1f800000, 0x10000, 0, MAP_TAG_OTHER); psxR = psxMap(0x1fc00000, 0x80000, 0, MAP_TAG_OTHER); -#endif if (psxMemRLUT == NULL || psxMemWLUT == NULL || psxR == NULL || psxP == NULL || psxH == NULL) { @@ -212,7 +186,11 @@ int psxMemInit() { memcpy(psxMemWLUT + 0x8000, psxMemWLUT, 0x80 * sizeof(void *)); memcpy(psxMemWLUT + 0xa000, psxMemWLUT, 0x80 * sizeof(void *)); - psxMemWLUT[0x1f00] = (u8 *)psxP; + // Don't allow writes to PIO Expansion region (psxP) to take effect. + // NOTE: Not sure if this is needed to fix any games but seems wise, + // seeing as some games do read from PIO as part of copy-protection + // check. (See fix in psxMemReset() regarding psxP region reads). + psxMemWLUT[0x1f00] = NULL; psxMemWLUT[0x1f80] = (u8 *)psxH; return 0; @@ -254,8 +232,6 @@ void psxMemShutdown() { free(psxMemWLUT); psxMemWLUT = NULL; } -static int writeok = 1; - u8 psxMemRead8(u32 mem) { char *p; u32 t; @@ -276,7 +252,7 @@ u8 psxMemRead8(u32 mem) { #ifdef PSXMEM_LOG PSXMEM_LOG("err lb %8.8lx\n", mem); #endif - return 0; + return 0xFF; } } } @@ -301,7 +277,7 @@ u16 psxMemRead16(u32 mem) { #ifdef PSXMEM_LOG PSXMEM_LOG("err lh %8.8lx\n", mem); #endif - return 0; + return 0xFFFF; } } } @@ -326,7 +302,7 @@ u32 psxMemRead32(u32 mem) { #ifdef PSXMEM_LOG if (writeok) { PSXMEM_LOG("err lw %8.8lx\n", mem); } #endif - return 0; + return 0xFFFFFFFF; } } } @@ -347,7 +323,7 @@ void psxMemWrite8(u32 mem, u8 value) { if (Config.Debug) DebugCheckBP((mem & 0xffffff) | 0x80000000, W1); *(u8 *)(p + (mem & 0xffff)) = value; -#ifdef PSXREC +#ifndef DRC_DISABLE psxCpu->Clear((mem & (~3)), 1); #endif } else { @@ -374,7 +350,7 @@ void psxMemWrite16(u32 mem, u16 value) { if (Config.Debug) DebugCheckBP((mem & 0xffffff) | 0x80000000, W2); *(u16 *)(p + (mem & 0xffff)) = SWAPu16(value); -#ifdef PSXREC +#ifndef DRC_DISABLE psxCpu->Clear((mem & (~3)), 1); #endif } else { @@ -402,12 +378,12 @@ void psxMemWrite32(u32 mem, u32 value) { if (Config.Debug) DebugCheckBP((mem & 0xffffff) | 0x80000000, W4); *(u32 *)(p + (mem & 0xffff)) = SWAPu32(value); -#ifdef PSXREC +#ifndef DRC_DISABLE psxCpu->Clear(mem, 1); #endif } else { if (mem != 0xfffe0130) { -#ifdef PSXREC +#ifndef DRC_DISABLE if (!writeok) psxCpu->Clear(mem, 1); #endif @@ -425,6 +401,8 @@ void psxMemWrite32(u32 mem, u32 value) { memset(psxMemWLUT + 0x0000, 0, 0x80 * sizeof(void *)); memset(psxMemWLUT + 0x8000, 0, 0x80 * sizeof(void *)); memset(psxMemWLUT + 0xa000, 0, 0x80 * sizeof(void *)); + /* Required for icache interpreter otherwise Armored Core won't boot on icache interpreter */ + psxCpu->Notify(R3000ACPU_NOTIFY_CACHE_ISOLATED, NULL); break; case 0x00: case 0x1e988: if (writeok == 1) break; @@ -432,6 +410,8 @@ void psxMemWrite32(u32 mem, u32 value) { for (i = 0; i < 0x80; i++) psxMemWLUT[i + 0x0000] = (void *)&psxM[(i & 0x1f) << 16]; memcpy(psxMemWLUT + 0x8000, psxMemWLUT, 0x80 * sizeof(void *)); memcpy(psxMemWLUT + 0xa000, psxMemWLUT, 0x80 * sizeof(void *)); + /* Dynarecs might take this opportunity to flush their code cache */ + psxCpu->Notify(R3000ACPU_NOTIFY_CACHE_UNISOLATED, NULL); break; default: #ifdef PSXMEM_LOG