From 74ce0a6b2175e20a2be5954c45422435de92aee8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 20 Oct 2012 22:35:08 +0200 Subject: [PATCH] Add "load CD into RAM" feature/hack --- Makefile | 8 ++++++++ mednafen/cdrom/CDAccess_Image.cpp | 10 +++++----- mednafen/settings.cpp | 3 +++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6f076c2..bb9cf59 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),) endif endif +# If you have a system with 1GB RAM or more - cache the whole +# CD in order to prevent file access delays/hiccups +CACHE_CD = 0 + ifeq ($(platform), unix) TARGET := libretro.so fpic := -fPIC @@ -140,6 +144,10 @@ WARNINGS := -Wall \ FLAGS += $(ENDIANNESS_DEFINES) -DSIZEOF_DOUBLE=8 $(WARNINGS) \ -DMEDNAFEN_VERSION=\"0.9.26\" -DPACKAGE=\"mednafen\" -DMEDNAFEN_VERSION_NUMERIC=926 -DPSS_STYLE=1 -DMPC_FIXED_POINT -DARCH_X86 -DWANT_PSX_EMU -DSTDC_HEADERS -D__STDC_LIMIT_MACROS -D__LIBRETRO__ -DNDEBUG +ifeq ($(CACHE_CD), 1) +FLAGS += -D__LIBRETRO_CACHE_CD__ +endif + CXXFLAGS += $(FLAGS) CFLAGS += $(FLAGS) -std=gnu99 diff --git a/mednafen/cdrom/CDAccess_Image.cpp b/mednafen/cdrom/CDAccess_Image.cpp index 2b356d8..3f3d7b0 100644 --- a/mednafen/cdrom/CDAccess_Image.cpp +++ b/mednafen/cdrom/CDAccess_Image.cpp @@ -192,7 +192,7 @@ void CDAccess_Image::ParseTOCFileLineInfo(CDRFILE_TRACK_INFO *track, const int t efn = MDFN_EvalFIP(base_dir, filename); track->fp = new FileStream(efn.c_str(), FileStream::MODE_READ); - if(image_memcache) + if(MDFN_GetSettingB("libretro.cd_load_into_ram")) track->fp = new MemoryStream(track->fp); if(strlen(filename) >= 4 && !strcasecmp(filename + strlen(filename) - 4, ".wav")) @@ -415,7 +415,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache) length = args[2]; } //printf("%s, %s, %s, %s\n", args[0], binoffset, msfoffset, length); - ParseTOCFileLineInfo(&TmpTrack, active_track, args[0], binoffset, msfoffset, length, image_memcache); + ParseTOCFileLineInfo(&TmpTrack, active_track, args[0], binoffset, msfoffset, length, MDFN_GetSettingB("libretro.cd_load_into_ram")); } else if(!strcasecmp(cmdbuf, "DATAFILE")) { @@ -430,7 +430,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache) else length = args[1]; - ParseTOCFileLineInfo(&TmpTrack, active_track, args[0], binoffset, NULL, length, image_memcache); + ParseTOCFileLineInfo(&TmpTrack, active_track, args[0], binoffset, NULL, length, MDFN_GetSettingB("libretro.cd_load_into_ram")); } else if(!strcasecmp(cmdbuf, "INDEX")) { @@ -477,7 +477,7 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache) TmpTrack.fp = new FileStream(efn.c_str(), FileStream::MODE_READ); TmpTrack.FirstFileInstance = 1; - if(image_memcache) + if(MDFN_GetSettingB("libretro.cd_load_into_ram")) TmpTrack.fp = new MemoryStream(TmpTrack.fp); if(!strcasecmp(args[1], "BINARY")) @@ -696,7 +696,7 @@ CDAccess_Image::CDAccess_Image(const char *path, bool image_memcache) : NumTrack try { - ImageOpen(path, image_memcache); + ImageOpen(path, MDFN_GetSettingB("libretro.cd_load_into_ram")); } catch(...) { diff --git a/mednafen/settings.cpp b/mednafen/settings.cpp index ddb9426..b94325b 100644 --- a/mednafen/settings.cpp +++ b/mednafen/settings.cpp @@ -68,6 +68,9 @@ bool MDFN_GetSettingB(const char *name) { if(!strcmp("cheats", name)) return 0; + /* LIBRETRO */ + if(!strcmp("libretro.cd.load_into_ram", name)) + return 0; /* PCE_FAST */ if(!strcmp("pce_fast.input.multitap", name)) return 1;