mirror of
https://github.com/libretro/beetle-psx-libretro.git
synced 2025-02-11 12:05:58 +00:00
Cleanups
This commit is contained in:
parent
b8767cfd48
commit
8d705a90ff
@ -65,7 +65,8 @@ endif
|
||||
|
||||
|
||||
ifneq ($(HAVE_GRIFFIN), 1)
|
||||
MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/error.cpp \
|
||||
MEDNAFEN_SOURCES := \
|
||||
$(MEDNAFEN_DIR)/error.cpp \
|
||||
$(MEDNAFEN_DIR)/settings.cpp \
|
||||
$(MEDNAFEN_DIR)/general.cpp \
|
||||
$(MEDNAFEN_DIR)/FileWrapper.cpp \
|
||||
@ -73,18 +74,18 @@ MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/error.cpp \
|
||||
$(MEDNAFEN_DIR)/MemoryStream.cpp \
|
||||
$(MEDNAFEN_DIR)/Stream.cpp \
|
||||
$(MEDNAFEN_DIR)/state.cpp \
|
||||
$(MEDNAFEN_DIR)/endian.cpp
|
||||
|
||||
MEDNAFEN_SOURCES += $(CDROM_SOURCES)
|
||||
|
||||
MEDNAFEN_SOURCES += $(MEDNAFEN_DIR)/mempatcher.cpp \
|
||||
$(MEDNAFEN_DIR)/endian.cpp \
|
||||
$(CDROM_SOURCES) \
|
||||
$(MEDNAFEN_DIR)/mempatcher.cpp \
|
||||
$(MEDNAFEN_DIR)/video/Deinterlacer.cpp \
|
||||
$(MEDNAFEN_DIR)/video/surface.cpp \
|
||||
$(RESAMPLER_SOURCES) \
|
||||
$(MEDNAFEN_DIR)/file.cpp \
|
||||
$(OKIADPCM_SOURCES) \
|
||||
$(MEDNAFEN_DIR)/md5.cpp
|
||||
|
||||
MEDNAFEN_SOURCES_C += \
|
||||
$(MEDNAFEN_DIR)/file.c
|
||||
|
||||
LIBRETRO_SOURCES += libretro.cpp
|
||||
endif
|
||||
|
||||
@ -94,7 +95,7 @@ TRIO_SOURCES += $(MEDNAFEN_DIR)/trio/trio.c \
|
||||
ifeq ($(HAVE_GRIFFIN), 1)
|
||||
SOURCES_C := beetle_psx_griffin_c.c
|
||||
else
|
||||
SOURCES_C := $(TREMOR_SRC) $(LIBRETRO_SOURCES_C) $(TRIO_SOURCES) $(THREAD_SOURCES) $(CRC32_SOURCES)
|
||||
SOURCES_C := $(TREMOR_SRC) $(LIBRETRO_SOURCES_C) $(TRIO_SOURCES) $(THREAD_SOURCES) $(CRC32_SOURCES) $(MEDNAFEN_SOURCES_C)
|
||||
endif
|
||||
|
||||
SOURCES := $(LIBRETRO_SOURCES) $(CORE_SOURCES) $(MEDNAFEN_SOURCES) $(HW_CPU_SOURCES) $(HW_MISC_SOURCES) $(HW_SOUND_SOURCES) $(HW_VIDEO_SOURCES)
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "mednafen/mempatcher.cpp"
|
||||
#include "mednafen/video/Deinterlacer.cpp"
|
||||
#include "mednafen/video/surface.cpp"
|
||||
#include "mednafen/file.cpp"
|
||||
#include "mednafen/md5.cpp"
|
||||
|
||||
#include "libretro.cpp"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "mednafen/tremor/bitwise.c"
|
||||
#include "mednafen/tremor/window.c"
|
||||
|
||||
#include "mednafen/file.c"
|
||||
#include "mednafen/trio/trio.c"
|
||||
#include "mednafen/trio/triostr.c"
|
||||
|
||||
|
139
libretro.cpp
139
libretro.cpp
@ -1983,7 +1983,7 @@ static bool DecodeGS(const std::string& cheat_string, MemoryPatch* patch)
|
||||
|
||||
static CheatFormatStruct CheatFormats[] =
|
||||
{
|
||||
{ "GameShark", gettext_noop("Sharks with lamprey eels for eyes."), DecodeGS },
|
||||
{ "GameShark", "Sharks with lamprey eels for eyes.", DecodeGS },
|
||||
};
|
||||
|
||||
static CheatFormatInfoStruct CheatFormatInfo =
|
||||
@ -1994,80 +1994,80 @@ static CheatFormatInfoStruct CheatFormatInfo =
|
||||
|
||||
static const FileExtensionSpecStruct KnownExtensions[] =
|
||||
{
|
||||
{ ".psf", gettext_noop("PSF1 Rip") },
|
||||
{ ".psx", gettext_noop("PS-X Executable") },
|
||||
{ ".exe", gettext_noop("PS-X Executable") },
|
||||
{ ".psf", "PSF1 Rip" },
|
||||
{ ".psx", "PS-X Executable" },
|
||||
{ ".exe", "PS-X Executable" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const MDFNSetting_EnumList Region_List[] =
|
||||
{
|
||||
{ "jp", REGION_JP, gettext_noop("Japan") },
|
||||
{ "na", REGION_NA, gettext_noop("North America") },
|
||||
{ "eu", REGION_EU, gettext_noop("Europe") },
|
||||
{ "jp", REGION_JP, "Japan" },
|
||||
{ "na", REGION_NA, "North America" },
|
||||
{ "eu", REGION_EU, "Europe" },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
#if 0
|
||||
static const MDFNSetting_EnumList MultiTap_List[] =
|
||||
{
|
||||
{ "0", 0, gettext_noop("Disabled") },
|
||||
{ "1", 1, gettext_noop("Enabled") },
|
||||
{ "auto", 0, gettext_noop("Automatically-enable multitap."), gettext_noop("NOT IMPLEMENTED YET(currently equivalent to 0)") },
|
||||
{ "0", 0, "Disabled" },
|
||||
{ "1", 1, "Enabled" },
|
||||
{ "auto", 0, "Automatically-enable multitap.", "NOT IMPLEMENTED YET(currently equivalent to 0") },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
#endif
|
||||
|
||||
static MDFNSetting PSXSettings[] =
|
||||
{
|
||||
{ "psx.input.mouse_sensitivity", MDFNSF_NOFLAGS, gettext_noop("Emulated mouse sensitivity."), NULL, MDFNST_FLOAT, "1.00", NULL, NULL },
|
||||
{ "psx.input.mouse_sensitivity", MDFNSF_NOFLAGS, "Emulated mouse sensitivity.", NULL, MDFNST_FLOAT, "1.00", NULL, NULL },
|
||||
|
||||
{ "psx.input.analog_mode_ct", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Enable analog mode combo-button alternate toggle."), gettext_noop("When enabled, instead of the configured Analog mode toggle button for the emulated DualShock, use a combination of buttons to toggle it instead. When Select, Start, and all four shoulder buttons are held down for about 1 second, the mode will toggle."), MDFNST_BOOL, "0", NULL, NULL },
|
||||
{ "psx.input.analog_mode_ct", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Enable analog mode combo-button alternate toggle.", "When enabled, instead of the configured Analog mode toggle button for the emulated DualShock, use a combination of buttons to toggle it instead. When Select, Start, and all four shoulder buttons are held down for about 1 second, the mode will toggle.", MDFNST_BOOL, "0", NULL, NULL },
|
||||
|
||||
{ "psx.input.pport1.multitap", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Enable multitap on PSX port 1."), gettext_noop("Makes 3 more virtual ports available.\n\nNOTE: Enabling multitap in games that don't fully support it may cause deleterious effects."), MDFNST_BOOL, "0", NULL, NULL }, //MDFNST_ENUM, "auto", NULL, NULL, NULL, NULL, MultiTap_List },
|
||||
{ "psx.input.pport2.multitap", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Enable multitap on PSX port 2."), gettext_noop("Makes 3 more virtual ports available.\n\nNOTE: Enabling multitap in games that don't fully support it may cause deleterious effects."), MDFNST_BOOL, "0", NULL, NULL },
|
||||
{ "psx.input.pport1.multitap", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Enable multitap on PSX port 1.", "Makes 3 more virtual ports available.\n\nNOTE: Enabling multitap in games that don't fully support it may cause deleterious effects.", MDFNST_BOOL, "0", NULL, NULL }, //MDFNST_ENUM, "auto", NULL, NULL, NULL, NULL, MultiTap_List },
|
||||
{ "psx.input.pport2.multitap", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Enable multitap on PSX port 2.", "Makes 3 more virtual ports available.\n\nNOTE: Enabling multitap in games that don't fully support it may cause deleterious effects.", MDFNST_BOOL, "0", NULL, NULL },
|
||||
|
||||
{ "psx.input.port1.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 1."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port2.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 2."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port3.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 3."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port4.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 4."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port5.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 5."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port6.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 6."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port7.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 7."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port8.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate memcard on virtual port 8."), NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port1.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 1.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port2.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 2.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port3.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 3.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port4.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 4.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port5.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 5.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port6.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 6.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port7.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 7.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
{ "psx.input.port8.memcard", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Emulate memcard on virtual port 8.", NULL, MDFNST_BOOL, "1", NULL, NULL, },
|
||||
|
||||
|
||||
{ "psx.input.port1.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 1."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0xFF0000", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port2.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 2."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0x00FF00", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port3.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 3."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0xFF00FF", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port4.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 4."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0xFF8000", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port5.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 5."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0xFFFF00", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port6.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 6."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0x00FFFF", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port7.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 7."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0x0080FF", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port8.gun_chairs", MDFNSF_NOFLAGS, gettext_noop("Crosshairs color for lightgun on virtual port 8."), gettext_noop("A value of 0x1000000 disables crosshair drawing."), MDFNST_UINT, "0x8000FF", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port1.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 1.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0xFF0000", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port2.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 2.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0x00FF00", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port3.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 3.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0xFF00FF", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port4.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 4.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0xFF8000", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port5.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 5.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0xFFFF00", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port6.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 6.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0x00FFFF", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port7.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 7.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0x0080FF", "0x000000", "0x1000000" },
|
||||
{ "psx.input.port8.gun_chairs", MDFNSF_NOFLAGS, "Crosshairs color for lightgun on virtual port 8.", "A value of 0x1000000 disables crosshair drawing.", MDFNST_UINT, "0x8000FF", "0x000000", "0x1000000" },
|
||||
|
||||
{ "psx.region_autodetect", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Attempt to auto-detect region of game."), NULL, MDFNST_BOOL, "1" },
|
||||
{ "psx.region_default", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Default region to use."), gettext_noop("Used if region autodetection fails or is disabled."), MDFNST_ENUM, "jp", NULL, NULL, NULL, NULL, Region_List },
|
||||
{ "psx.region_autodetect", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Attempt to auto-detect region of game.", NULL, MDFNST_BOOL, "1" },
|
||||
{ "psx.region_default", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, "Default region to use.", "Used if region autodetection fails or is disabled.", MDFNST_ENUM, "jp", NULL, NULL, NULL, NULL, Region_List },
|
||||
|
||||
{ "psx.bios_jp", MDFNSF_EMU_STATE, gettext_noop("Path to the Japan SCPH-5500 ROM BIOS"), NULL, MDFNST_STRING, "scph5500.bin" },
|
||||
{ "psx.bios_na", MDFNSF_EMU_STATE, gettext_noop("Path to the North America SCPH-5501 ROM BIOS"), gettext_noop("SHA1 0555c6fae8906f3f09baf5988f00e55f88e9f30b"), MDFNST_STRING, "scph5501.bin" },
|
||||
{ "psx.bios_eu", MDFNSF_EMU_STATE, gettext_noop("Path to the Europe SCPH-5502 ROM BIOS"), NULL, MDFNST_STRING, "scph5502.bin" },
|
||||
{ "psx.bios_jp", MDFNSF_EMU_STATE, "Path to the Japan SCPH-5500 ROM BIOS", NULL, MDFNST_STRING, "scph5500.bin" },
|
||||
{ "psx.bios_na", MDFNSF_EMU_STATE, "Path to the North America SCPH-5501 ROM BIOS", "SHA1 0555c6fae8906f3f09baf5988f00e55f88e9f30b", MDFNST_STRING, "scph5501.bin" },
|
||||
{ "psx.bios_eu", MDFNSF_EMU_STATE, "Path to the Europe SCPH-5502 ROM BIOS", NULL, MDFNST_STRING, "scph5502.bin" },
|
||||
|
||||
{ "psx.spu.resamp_quality", MDFNSF_NOFLAGS, gettext_noop("SPU output resampler quality."),
|
||||
gettext_noop("0 is lowest quality and CPU usage, 10 is highest quality and CPU usage. The resampler that this setting refers to is used for converting from 44.1KHz to the sampling rate of the host audio device Mednafen is using. Changing Mednafen's output rate, via the \"sound.rate\" setting, to \"44100\" will bypass the resampler, which will decrease CPU usage by Mednafen, and can increase or decrease audio quality, depending on various operating system and hardware factors."), MDFNST_UINT, "5", "0", "10" },
|
||||
{ "psx.spu.resamp_quality", MDFNSF_NOFLAGS, "SPU output resampler quality.",
|
||||
"0 is lowest quality and CPU usage, 10 is highest quality and CPU usage. The resampler that this setting refers to is used for converting from 44.1KHz to the sampling rate of the host audio device Mednafen is using. Changing Mednafen's output rate, via the \"sound.rate\" setting, to \"44100\" will bypass the resampler, which will decrease CPU usage by Mednafen, and can increase or decrease audio quality, depending on various operating system and hardware factors.", MDFNST_UINT, "5", "0", "10" },
|
||||
|
||||
|
||||
{ "psx.slstart", MDFNSF_NOFLAGS, gettext_noop("First displayed scanline in NTSC mode."), NULL, MDFNST_INT, "0", "0", "239" },
|
||||
{ "psx.slend", MDFNSF_NOFLAGS, gettext_noop("Last displayed scanline in NTSC mode."), NULL, MDFNST_INT, "239", "0", "239" },
|
||||
{ "psx.slstart", MDFNSF_NOFLAGS, "First displayed scanline in NTSC mode.", NULL, MDFNST_INT, "0", "0", "239" },
|
||||
{ "psx.slend", MDFNSF_NOFLAGS, "Last displayed scanline in NTSC mode.", NULL, MDFNST_INT, "239", "0", "239" },
|
||||
|
||||
{ "psx.slstartp", MDFNSF_NOFLAGS, gettext_noop("First displayed scanline in PAL mode."), NULL, MDFNST_INT, "0", "0", "287" },
|
||||
{ "psx.slendp", MDFNSF_NOFLAGS, gettext_noop("Last displayed scanline in PAL mode."), NULL, MDFNST_INT, "287", "0", "287" },
|
||||
{ "psx.slstartp", MDFNSF_NOFLAGS, "First displayed scanline in PAL mode.", NULL, MDFNST_INT, "0", "0", "287" },
|
||||
{ "psx.slendp", MDFNSF_NOFLAGS, "Last displayed scanline in PAL mode.", NULL, MDFNST_INT, "287", "0", "287" },
|
||||
|
||||
#if PSX_DBGPRINT_ENABLE
|
||||
{ "psx.dbg_level", MDFNSF_NOFLAGS, gettext_noop("Debug printf verbosity level."), NULL, MDFNST_UINT, "0", "0", "4" },
|
||||
{ "psx.dbg_level", MDFNSF_NOFLAGS, "Debug printf verbosity level.", NULL, MDFNST_UINT, "0", "0", "4" },
|
||||
#endif
|
||||
|
||||
{ "psx.clobbers_lament", MDFNSF_NOFLAGS, gettext_noop("Enable experimental save state functionality."), gettext_noop("Save states will destroy your saved game/memory card data if you're careless, and that will make clobber sad. Poor clobber."), MDFNST_BOOL, "0" },
|
||||
{ "psx.clobbers_lament", MDFNSF_NOFLAGS, "Enable experimental save state functionality.", "Save states will destroy your saved game/memory card data if you're careless, and that will make clobber sad. Poor clobber.", MDFNST_BOOL, "0" },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
@ -2788,8 +2788,10 @@ MDFNGI *MDFNI_LoadCD(const char *force_module, const char *devicename)
|
||||
|
||||
static MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
|
||||
{
|
||||
MDFNFILE GameFile;
|
||||
std::vector<FileExtensionSpecStruct> valid_iae;
|
||||
MDFNFILE *GameFile = file_open(name);
|
||||
|
||||
if(!GameFile)
|
||||
goto error;
|
||||
|
||||
#ifdef NEED_CD
|
||||
if(strlen(name) > 4 && (!strcasecmp(name + strlen(name) - 4, ".cue") || !strcasecmp(name + strlen(name) - 4, ".ccd") || !strcasecmp(name + strlen(name) - 4, ".toc") || !strcasecmp(name + strlen(name) - 4, ".m3u")))
|
||||
@ -2799,40 +2801,11 @@ static MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_INFO, "Loading %s...\n", name);
|
||||
|
||||
// Construct a NULL-delimited list of known file extensions for MDFN_fopen()
|
||||
const FileExtensionSpecStruct *curexts = MDFNGameInfo->FileExtensions;
|
||||
if(MDFNGameInfo->Load(name, GameFile) <= 0)
|
||||
goto error;
|
||||
|
||||
while(curexts->extension && curexts->description)
|
||||
{
|
||||
valid_iae.push_back(*curexts);
|
||||
curexts++;
|
||||
}
|
||||
|
||||
if(!GameFile.Open(name, &valid_iae[0], _("game")))
|
||||
{
|
||||
MDFNGameInfo = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_INFO, "Using module: %s(%s)\n", MDFNGameInfo->shortname, MDFNGameInfo->fullname);
|
||||
|
||||
//
|
||||
// Load per-game settings
|
||||
//
|
||||
// Maybe we should make a "pgcfg" subdir, and automatically load all files in it?
|
||||
// End load per-game settings
|
||||
//
|
||||
|
||||
if(MDFNGameInfo->Load(name, &GameFile) <= 0)
|
||||
{
|
||||
GameFile.Close();
|
||||
MDFNGameInfo = NULL;
|
||||
return(0);
|
||||
}
|
||||
|
||||
MDFN_LoadGameCheats(NULL);
|
||||
MDFNMP_InstallReadPatches();
|
||||
file_close(GameFile);
|
||||
GameFile = NULL;
|
||||
|
||||
if(!MDFNGameInfo->name)
|
||||
{
|
||||
@ -2851,6 +2824,13 @@ static MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
|
||||
}
|
||||
|
||||
return(MDFNGameInfo);
|
||||
|
||||
error:
|
||||
if (GameFile)
|
||||
file_close(GameFile);
|
||||
GameFile = NULL;
|
||||
MDFNGameInfo = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define MAX_PLAYERS 8
|
||||
@ -3071,6 +3051,9 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
if (!MDFNI_LoadGame(MEDNAFEN_CORE_NAME_MODULE, info->path))
|
||||
return false;
|
||||
|
||||
MDFN_LoadGameCheats(NULL);
|
||||
MDFNMP_InstallReadPatches();
|
||||
|
||||
MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24);
|
||||
|
||||
surf = new MDFN_Surface(NULL, MEDNAFEN_CORE_GEOMETRY_MAX_W, (CalcDiscSCEx() == REGION_EU) ? MEDNAFEN_CORE_GEOMETRY_MAX_H : 480, MEDNAFEN_CORE_GEOMETRY_MAX_W, pix_fmt);
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <stdexcept>
|
||||
|
||||
class ErrnoHolder;
|
||||
class MDFN_Error : public std::exception
|
||||
|
176
mednafen/file.c
Normal file
176
mednafen/file.c
Normal file
@ -0,0 +1,176 @@
|
||||
/* Mednafen - Multi-system Emulator
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "file.h"
|
||||
#include "mednafen-endian.h"
|
||||
|
||||
struct MDFNFILE *file_open(const char *path)
|
||||
{
|
||||
const char *ld;
|
||||
FILE *fp;
|
||||
struct MDFNFILE *file = (struct MDFNFILE*)calloc(1, sizeof(*file));
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
|
||||
if (!fp)
|
||||
goto error;
|
||||
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
fseek((FILE *)fp, 0, SEEK_END);
|
||||
file->size = ftell((FILE *)fp);
|
||||
fseek((FILE *)fp, 0, SEEK_SET);
|
||||
|
||||
if (!(file->data = (uint8_t*)malloc(file->size)))
|
||||
goto error;
|
||||
fread(file->data, 1, file->size, (FILE *)fp);
|
||||
|
||||
ld = (const char*)strrchr(path, '.');
|
||||
file->ext = strdup(ld ? ld + 1 : "");
|
||||
|
||||
return file;
|
||||
|
||||
error:
|
||||
if (fp)
|
||||
fclose((FILE*)fp);
|
||||
if (file)
|
||||
free(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int file_close(struct MDFNFILE *file)
|
||||
{
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
if (file->ext)
|
||||
free(file->ext);
|
||||
file->ext = NULL;
|
||||
|
||||
if (file->data)
|
||||
free(file->data);
|
||||
file->data = NULL;
|
||||
|
||||
free(file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint64_t file_read(struct MDFNFILE *file, void *ptr,
|
||||
size_t element_size, size_t nmemb)
|
||||
{
|
||||
uint32_t total = element_size * nmemb;
|
||||
|
||||
if (file->location >= file->size)
|
||||
return 0;
|
||||
|
||||
if ((file->location + total) > file->size)
|
||||
{
|
||||
int64_t ak = file->size - file->location;
|
||||
|
||||
memcpy((uint8_t*)ptr, file->data + file->location, ak);
|
||||
|
||||
file->location = file->size;
|
||||
|
||||
return(ak / element_size);
|
||||
}
|
||||
|
||||
memcpy((uint8_t*)ptr, file->data + file->location, total);
|
||||
|
||||
file->location += total;
|
||||
|
||||
return nmemb;
|
||||
}
|
||||
|
||||
int file_seek(struct MDFNFILE *file, int64_t offset, int whence)
|
||||
{
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
if (offset >= file->size)
|
||||
return -1;
|
||||
|
||||
file->location = offset;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
if ((offset + file->location) > file->size)
|
||||
return -1;
|
||||
|
||||
file->location += offset;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int file_read16le(struct MDFNFILE *file, uint16_t *val)
|
||||
{
|
||||
if ((file->location + 2) > file->size)
|
||||
return 0;
|
||||
|
||||
*val = MDFN_de16lsb(file->data + file->location);
|
||||
|
||||
file->location += 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int file_read32le(struct MDFNFILE *file, uint32_t *val)
|
||||
{
|
||||
if ((file->location + 4) > file->size)
|
||||
return 0;
|
||||
|
||||
*val = MDFN_de32lsb(file->data + file->location);
|
||||
|
||||
file->location += 4;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *file_fgets(struct MDFNFILE *file, char *s, int len)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
if (!len)
|
||||
return(NULL);
|
||||
|
||||
if (file->location >= len)
|
||||
return(NULL);
|
||||
|
||||
while(pos < (len - 1) && file->location < len)
|
||||
{
|
||||
int v = file->data[file->location];
|
||||
s[pos] = v;
|
||||
file->location++;
|
||||
pos++;
|
||||
if (v == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
if (len)
|
||||
s[pos] = 0;
|
||||
|
||||
return s;
|
||||
}
|
@ -1,234 +0,0 @@
|
||||
/* Mednafen - Multi-system Emulator
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "mednafen.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "file.h"
|
||||
#include "general.h"
|
||||
|
||||
// This function should ALWAYS close the system file "descriptor"(gzip library, zip library, or FILE *) it's given,
|
||||
// even if it errors out.
|
||||
bool MDFNFILE::MakeMemWrapAndClose(void *fp)
|
||||
{
|
||||
bool ret = FALSE;
|
||||
|
||||
location = 0;
|
||||
|
||||
::fseek((FILE *)fp, 0, SEEK_END);
|
||||
f_size = ::ftell((FILE *)fp);
|
||||
::fseek((FILE *)fp, 0, SEEK_SET);
|
||||
|
||||
if (!(f_data = (uint8*)malloc((size_t)f_size)))
|
||||
goto fail;
|
||||
::fread(f_data, 1, (size_t)f_size, (FILE *)fp);
|
||||
|
||||
ret = TRUE;
|
||||
fail:
|
||||
fclose((FILE*)fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
MDFNFILE::MDFNFILE()
|
||||
{
|
||||
f_data = NULL;
|
||||
f_size = 0;
|
||||
f_ext = NULL;
|
||||
|
||||
location = 0;
|
||||
}
|
||||
|
||||
MDFNFILE::MDFNFILE(const char *path, const void *known_ext, const char *purpose)
|
||||
{
|
||||
(void)known_ext;
|
||||
if (!Open(path, known_ext, purpose, false))
|
||||
throw(MDFN_Error(0, "TODO ERROR"));
|
||||
}
|
||||
|
||||
|
||||
MDFNFILE::~MDFNFILE()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
bool MDFNFILE::Open(const char *path, const void *known_ext, const char *purpose, const bool suppress_notfound_pe)
|
||||
{
|
||||
FILE *fp;
|
||||
(void)known_ext;
|
||||
|
||||
if (!(fp = fopen(path, "rb")))
|
||||
return FALSE;
|
||||
|
||||
::fseek(fp, 0, SEEK_SET);
|
||||
|
||||
if (!MakeMemWrapAndClose(fp))
|
||||
return FALSE;
|
||||
|
||||
const char *ld = (const char*)strrchr(path, '.');
|
||||
f_ext = strdup(ld ? ld + 1 : "");
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
bool MDFNFILE::Close(void)
|
||||
{
|
||||
if (f_ext)
|
||||
free(f_ext);
|
||||
f_ext = 0;
|
||||
|
||||
if (f_data)
|
||||
free(f_data);
|
||||
f_data = 0;
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
uint64 MDFNFILE::fread(void *ptr, size_t element_size, size_t nmemb)
|
||||
{
|
||||
uint32 total = element_size * nmemb;
|
||||
|
||||
if (location >= f_size)
|
||||
return 0;
|
||||
|
||||
if ((location + total) > f_size)
|
||||
{
|
||||
size_t ak = f_size - location;
|
||||
|
||||
memcpy((uint8*)ptr, f_data + location, ak);
|
||||
|
||||
location = f_size;
|
||||
|
||||
return(ak / element_size);
|
||||
}
|
||||
|
||||
memcpy((uint8*)ptr, f_data + location, total);
|
||||
|
||||
location += total;
|
||||
|
||||
return nmemb;
|
||||
}
|
||||
|
||||
int MDFNFILE::fseek(int64 offset, int whence)
|
||||
{
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
if (offset >= f_size)
|
||||
return -1;
|
||||
|
||||
location = offset;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
if ((offset + location) > f_size)
|
||||
return -1;
|
||||
|
||||
location += offset;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MDFNFILE::read16le(uint16 *val)
|
||||
{
|
||||
if ((location + 2) > f_size)
|
||||
return 0;
|
||||
|
||||
*val = MDFN_de16lsb(f_data + location);
|
||||
|
||||
location += 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MDFNFILE::read32le(uint32 *val)
|
||||
{
|
||||
if ((location + 4) > f_size)
|
||||
return 0;
|
||||
|
||||
*val = MDFN_de32lsb(f_data + location);
|
||||
|
||||
location += 4;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *MDFNFILE::fgets(char *s, int buffer_size)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
if (!buffer_size)
|
||||
return(NULL);
|
||||
|
||||
if (location >= buffer_size)
|
||||
return(NULL);
|
||||
|
||||
while(pos < (buffer_size - 1) && location < buffer_size)
|
||||
{
|
||||
int v = f_data[location];
|
||||
s[pos] = v;
|
||||
location++;
|
||||
pos++;
|
||||
if (v == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
if (buffer_size)
|
||||
s[pos] = 0;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static INLINE bool MDFN_DumpToFileReal(const char *filename, int compress, const std::vector<PtrLengthPair> &pearpairs)
|
||||
{
|
||||
FILE *fp = fopen(filename, "wb");
|
||||
|
||||
if (!fp)
|
||||
return 0;
|
||||
|
||||
for(unsigned int i = 0; i < pearpairs.size(); i++)
|
||||
{
|
||||
const void *data = pearpairs[i].GetData();
|
||||
const uint64 length = pearpairs[i].GetLength();
|
||||
|
||||
if (fwrite(data, 1, length, fp) != length)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose(fp) == EOF)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool MDFN_DumpToFile(const char *filename, int compress, const std::vector<PtrLengthPair> &pearpairs)
|
||||
{
|
||||
return (MDFN_DumpToFileReal(filename, compress, pearpairs));
|
||||
}
|
||||
|
||||
bool MDFN_DumpToFile(const char *filename, int compress, const void *data, uint64 length)
|
||||
{
|
||||
std::vector<PtrLengthPair> tmp_pairs;
|
||||
tmp_pairs.push_back(PtrLengthPair(data, length));
|
||||
return (MDFN_DumpToFileReal(filename, compress, tmp_pairs));
|
||||
}
|
110
mednafen/file.h
110
mednafen/file.h
@ -1,108 +1,40 @@
|
||||
#ifndef MDFN_FILE_H
|
||||
#define MDFN_FILE_H
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MDFNFILE_EC_NOTFOUND 1
|
||||
#define MDFNFILE_EC_OTHER 2
|
||||
|
||||
class MDFNFILE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct MDFNFILE
|
||||
{
|
||||
public:
|
||||
|
||||
MDFNFILE();
|
||||
// WIP constructors:
|
||||
MDFNFILE(const char *path, const void *known_ext, const char *purpose = NULL);
|
||||
|
||||
~MDFNFILE();
|
||||
|
||||
bool Open(const char *path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE);
|
||||
INLINE bool Open(const std::string &path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE)
|
||||
{
|
||||
return(Open(path.c_str(), known_ext, purpose, suppress_notfound_pe));
|
||||
}
|
||||
|
||||
bool Close(void);
|
||||
|
||||
uint64 fread(void *ptr, size_t size, size_t nmemb);
|
||||
int fseek(int64 offset, int whence);
|
||||
|
||||
inline uint64 ftell(void)
|
||||
{
|
||||
return(location);
|
||||
}
|
||||
|
||||
inline void rewind(void)
|
||||
{
|
||||
location = 0;
|
||||
}
|
||||
|
||||
int read32le(uint32 *Bufo);
|
||||
int read16le(uint16 *Bufo);
|
||||
|
||||
inline int fgetc(void)
|
||||
{
|
||||
if(location < f_size)
|
||||
return f_data[location++];
|
||||
|
||||
return EOF;
|
||||
}
|
||||
|
||||
inline int fisarchive(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
char *fgets(char *s, int size);
|
||||
uint8 *f_data;
|
||||
int64 f_size;
|
||||
char *f_ext;
|
||||
|
||||
private:
|
||||
|
||||
int64 location;
|
||||
|
||||
bool MakeMemWrapAndClose(void *tz);
|
||||
uint8_t *data;
|
||||
int64_t size;
|
||||
char *ext;
|
||||
int64_t location;
|
||||
};
|
||||
|
||||
class PtrLengthPair
|
||||
{
|
||||
public:
|
||||
struct MDFNFILE *file_open(const char *path);
|
||||
|
||||
inline PtrLengthPair(const void *new_data, const uint64 new_length)
|
||||
{
|
||||
data = new_data;
|
||||
length = new_length;
|
||||
}
|
||||
int file_close(struct MDFNFILE *file);
|
||||
|
||||
~PtrLengthPair()
|
||||
{
|
||||
uint64_t file_read(struct MDFNFILE *file, void *ptr,
|
||||
size_t element_size, size_t nmemb);
|
||||
|
||||
}
|
||||
int file_seek(struct MDFNFILE *file, int64_t offset, int whence);
|
||||
|
||||
INLINE const void *GetData(void) const
|
||||
{
|
||||
return(data);
|
||||
}
|
||||
int file_read16le(struct MDFNFILE *file, uint16_t *val);
|
||||
|
||||
INLINE uint64 GetLength(void) const
|
||||
{
|
||||
return(length);
|
||||
}
|
||||
int file_read32le(struct MDFNFILE *file, uint32_t *val);
|
||||
|
||||
private:
|
||||
const void *data;
|
||||
uint64 length;
|
||||
};
|
||||
char *file_fgets(struct MDFNFILE *file, char *s, int buffer_size);
|
||||
|
||||
#include <vector>
|
||||
|
||||
// These functions should be used for data like save states and non-volatile backup memory.
|
||||
// Until(if, even) we add LoadFromFile functions, for reading the files these functions generate, just use gzopen(), gzread(), etc.
|
||||
// "compress" is set to the zlib compression level. 0 disables compression entirely, and dumps the file without a gzip header or footer.
|
||||
// (Note: There is a setting that will force compress to 0 in the internal DumpToFile logic, for hackers who don't want to ungzip save files.)
|
||||
|
||||
bool MDFN_DumpToFile(const char *filename, int compress, const void *data, const uint64 length);
|
||||
bool MDFN_DumpToFile(const char *filename, int compress, const std::vector<PtrLengthPair> &pearpairs);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -15,33 +15,14 @@
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
#define GET_FDATA(fp) (fp.f_data)
|
||||
#define GET_FSIZE(fp) (fp.f_size)
|
||||
#define GET_FEXTS(fp) (fp.f_ext)
|
||||
#define GET_FDATA_PTR(fp) (fp->f_data)
|
||||
#define GET_FSIZE_PTR(fp) (fp->f_size)
|
||||
#define GET_FEXTS_PTR(fp) (fp->f_ext)
|
||||
#define GET_FDATA_PTR(fp) (fp->data)
|
||||
#define GET_FSIZE_PTR(fp) (fp->size)
|
||||
#define GET_FEXTS_PTR(fp) (fp->ext)
|
||||
#define gzopen(a, b) fopen(a, b)
|
||||
#define gzread(a, b, c) fread(b, c, 1, a)
|
||||
#define gzclose(a) fclose(a)
|
||||
#define gzgetc(a) fgetc(a)
|
||||
#define gzseek(a,b,c) fseek(a,b,c)
|
||||
#else
|
||||
#define GET_FDATA(fp) (fp.Data())
|
||||
#define GET_FSIZE(fp) (fp.Size())
|
||||
#define GET_FDATA_PTR(fp) (fp->data)
|
||||
#define GET_FSIZE_PTR(fp) (fp->size)
|
||||
#define GET_FEXTS_PTR(fp) (fp->ext)
|
||||
#define gzread(a, b, c) gzread(a, b, c)
|
||||
#define gzclose(a) gzclose(a)
|
||||
#define gzgetc(a) gzgetc(a)
|
||||
#define gzseek(a,b,c) gzseek(a,b,c)
|
||||
#endif
|
||||
|
||||
#ifndef gettext_noop
|
||||
#define gettext_noop(a) (a)
|
||||
#endif
|
||||
|
||||
extern MDFNGI *MDFNGameInfo;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user