X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fpsxmem.h;h=f3c2051b875392c7d4aed35731e0ae1081729fca;hb=9a0a61d27586bfb93aa443cc59d9588d2b9cf992;hp=129973cf9ade1673b5128f44f792eeba75712b26;hpb=4d66d894c6563cbfb78fe8ccc0b374809fc44b0d;p=pcsx_rearmed.git diff --git a/libpcsxcore/psxmem.h b/libpcsxcore/psxmem.h index 129973cf..f3c2051b 100644 --- a/libpcsxcore/psxmem.h +++ b/libpcsxcore/psxmem.h @@ -114,8 +114,52 @@ extern s8 *psxH; extern u8 **psxMemWLUT; extern u8 **psxMemRLUT; +extern int cache_isolated; -#define PSXM(mem) (psxMemRLUT[(mem) >> 16] == INVALID_PTR ? INVALID_PTR : (u8*)(psxMemRLUT[(mem) >> 16] + ((mem) & 0xffff))) +#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) psxm(mem, 0) #define PSXMs8(mem) (*(s8 *)PSXM(mem)) #define PSXMs16(mem) (SWAP16(*(s16 *)PSXM(mem))) #define PSXMs32(mem) (SWAP32(*(s32 *)PSXM(mem)))