X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fpsxmem.h;h=f3c2051b875392c7d4aed35731e0ae1081729fca;hb=bf58ac4cd633bbd3c40bd7f79f9e00b98e156572;hp=ec4b970a6710a910c54db88bfc281b9adc3c8c28;hpb=96c6ec7055ecef55b3dd221c86b796512bf52107;p=pcsx_rearmed.git diff --git a/libpcsxcore/psxmem.h b/libpcsxcore/psxmem.h index ec4b970a..f3c2051b 100644 --- a/libpcsxcore/psxmem.h +++ b/libpcsxcore/psxmem.h @@ -46,6 +46,12 @@ extern "C" { #endif +#ifdef LIGHTREC +#define INVALID_PTR ((void *)-1) +#else +#define INVALID_PTR NULL +#endif + extern s8 *psxM; #define psxMs8(mem) psxM[(mem) & 0x1fffff] #define psxMs16(mem) (SWAP16(*(s16 *)&psxM[(mem) & 0x1fffff])) @@ -108,8 +114,52 @@ extern s8 *psxH; extern u8 **psxMemWLUT; extern u8 **psxMemRLUT; +extern int cache_isolated; + +#ifndef DISABLE_MEM_LUTS +#define DISABLE_MEM_LUTS 0 +#endif + +static inline void * psxm_lut(u32 mem, int write, u8 **lut) +{ + if (!DISABLE_MEM_LUTS) { + void *ptr = lut[mem >> 16]; + + return ptr == INVALID_PTR ? INVALID_PTR : ptr + (u16)mem; + } + + if (mem >= 0xa0000000) + mem -= 0xa0000000; + else + mem &= ~0x80000000; + + if (mem < 0x800000) { + if (cache_isolated) + return INVALID_PTR; + + return &psxM[mem & 0x1fffff]; + } + + if (mem > 0x1f800000 && mem <= 0x1f810000) + return &psxH[mem - 0x1f800000]; + + if (!write) { + if (mem > 0x1fc00000 && mem <= 0x1fc80000) + return &psxR[mem - 0x1fc00000]; + + if (mem > 0x1f000000 && mem <= 0x1f010000) + return &psxP[mem - 0x1f000000]; + } + + return INVALID_PTR; +} + +static inline void * psxm(u32 mem, int write) +{ + return psxm_lut(mem, write, write ? psxMemWLUT : psxMemRLUT); +} -#define PSXM(mem) (psxMemRLUT[(mem) >> 16] == 0 ? NULL : (u8*)(psxMemRLUT[(mem) >> 16] + ((mem) & 0xffff))) +#define PSXM(mem) psxm(mem, 0) #define PSXMs8(mem) (*(s8 *)PSXM(mem)) #define PSXMs16(mem) (SWAP16(*(s16 *)PSXM(mem))) #define PSXMs32(mem) (SWAP32(*(s32 *)PSXM(mem))) @@ -121,6 +171,7 @@ extern u8 **psxMemRLUT; int psxMemInit(); void psxMemReset(); +void psxMemOnIsolate(int enable); void psxMemShutdown(); u8 psxMemRead8 (u32 mem);