Merge pull request #511 from negativeExponent/updates
[pcsx_rearmed.git] / libpcsxcore / psxmem.c
index cfd880b..53edfab 100644 (file)
@@ -23,6 +23,8 @@
 
 // TODO: Implement caches & cycle penalty.
 
+#include <compat/fopen_utf8.h>
+
 #include "psxmem.h"
 #include "psxmem_map.h"
 #include "r3000a.h"
@@ -43,7 +45,11 @@ 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
@@ -142,6 +148,9 @@ int psxMemInit() {
 
 #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
@@ -157,7 +166,12 @@ int psxMemInit() {
        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);
@@ -205,7 +219,7 @@ void psxMemReset() {
 
        if (strcmp(Config.Bios, "HLE") != 0) {
                sprintf(bios, "%s/%s", Config.BiosDir, Config.Bios);
-               f = fopen(bios, "rb");
+               f = fopen_utf8(bios, "rb");
 
                if (f == NULL) {
                        SysMessage(_("Could not open BIOS:\"%s\". Enabling HLE Bios!\n"), bios);