lightrec_map[PSX_MAP_SCRATCH_PAD].address = psxH;
lightrec_map[PSX_MAP_PARALLEL_PORT].address = psxP;
+ if (LIGHTREC_CUSTOM_MAP) {
+ lightrec_map[PSX_MAP_MIRROR1].address = psxM + 0x200000;
+ lightrec_map[PSX_MAP_MIRROR2].address = psxM + 0x400000;
+ lightrec_map[PSX_MAP_MIRROR3].address = psxM + 0x600000;
+ }
+
lightrec_debug = !!getenv("LIGHTREC_DEBUG");
lightrec_very_debug = !!getenv("LIGHTREC_VERY_DEBUG");
use_lightrec_interpreter = !!getenv("LIGHTREC_INTERPRETER");
#include "psxhw.h"
#include "debug.h"
+#include "lightrec/mem.h"
#include "memmap.h"
#ifdef USE_LIBRETRO_VFS
0xbfc0_0000-0xbfc7_ffff BIOS Mirror (512K) Uncached
*/
-int psxMemInit() {
- int i;
-
+static int psxMemInitMap(void)
+{
psxM = psxMap(0x80000000, 0x00210000, 1, MAP_TAG_RAM);
if (psxM == MAP_FAILED)
psxM = psxMap(0x77000000, 0x00210000, 0, MAP_TAG_RAM);
return -1;
}
+ return 0;
+}
+
+static void psxMemFreeMap(void)
+{
+ psxUnmap(psxM, 0x00210000, MAP_TAG_RAM); psxM = NULL;
+ psxUnmap(psxH, 0x10000, MAP_TAG_OTHER); psxH = NULL;
+ psxUnmap(psxR, 0x80000, MAP_TAG_OTHER); psxR = NULL;
+}
+
+int psxMemInit(void)
+{
+ unsigned int i;
+ int ret;
+
+ if (LIGHTREC_CUSTOM_MAP && Config.Cpu == CPU_DYNAREC)
+ ret = lightrec_init_mmap();
+ else
+ ret = psxMemInitMap();
+ if (ret) {
+ SysMessage(_("Error allocating memory!"));
+ psxMemShutdown();
+ return -1;
+ }
+
psxMemRLUT = (u8 **)malloc(0x10000 * sizeof(void *));
psxMemWLUT = (u8 **)malloc(0x10000 * sizeof(void *));
}
void psxMemShutdown() {
- psxUnmap(psxM, 0x00210000, MAP_TAG_RAM); psxM = NULL;
- psxUnmap(psxH, 0x10000, MAP_TAG_OTHER); psxH = NULL;
- psxUnmap(psxR, 0x80000, MAP_TAG_OTHER); psxR = NULL;
+ if (LIGHTREC_CUSTOM_MAP && Config.Cpu == CPU_DYNAREC)
+ lightrec_free_mmap();
+ else
+ psxMemFreeMap();
free(psxMemRLUT); psxMemRLUT = NULL;
free(psxMemWLUT); psxMemWLUT = NULL;