Add "load CD into RAM" feature/hack

This commit is contained in:
twinaphex 2012-10-20 22:35:08 +02:00
parent e35a20cf0a
commit 74ce0a6b21
3 changed files with 16 additions and 5 deletions

View File

@ -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

View File

@ -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(...)
{

View File

@ -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;