X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fpsxmem.h;fp=libpcsxcore%2Fpsxmem.h;h=a52472c6d08a422da2ae02ea3138f3a30a753d4e;hp=129973cf9ade1673b5128f44f792eeba75712b26;hb=4bb8d7e16bad9322d862d6d0dcaa048d75064c1f;hpb=abf094858889145af1fde9840429dfb8a0e70a39 diff --git a/libpcsxcore/psxmem.h b/libpcsxcore/psxmem.h index 129973cf..a52472c6 100644 --- a/libpcsxcore/psxmem.h +++ b/libpcsxcore/psxmem.h @@ -114,8 +114,48 @@ 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))) +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)))