From 4295c49158ad9ce6a20235d5ea5d45139ff63fe9 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 26 May 2013 16:25:24 +0300 Subject: cdriso: use correct buffer in .toc check --- libpcsxcore/cdriso.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 9ca4172..f7359ce 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -329,8 +329,8 @@ static int parsetoc(const char *isofile) { } // check if it's really a TOC named as a .cue fgets(linebuf, sizeof(linebuf), fi); - token = strtok(tmp, " "); - if (strncmp(token, "CD", 2) != 0 && strcmp(token, "CATALOG") != 0) { + token = strtok(linebuf, " "); + if (token && strncmp(token, "CD", 2) != 0 && strcmp(token, "CATALOG") != 0) { fclose(fi); return -1; } -- cgit v1.2.3 From 689e0447dd52128f79d4f3a6f90456e56cd459c0 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 26 May 2013 17:16:07 +0300 Subject: cdriso: make sure to open correct file for cdda --- libpcsxcore/cdriso.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index f7359ce..bfa7d76 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -1213,6 +1213,8 @@ static void PrintTracks(void) { // file for playback static long CALLBACK ISOopen(void) { boolean isMode1ISO = FALSE; + char alt_bin_filename[MAXPATHLEN]; + const char *bin_filename; if (cdHandle != NULL) { return 0; // it's already open @@ -1268,27 +1270,30 @@ static long CALLBACK ISOopen(void) { fseek(cdHandle, 0, SEEK_END); // maybe user selected metadata file instead of main .bin .. + bin_filename = GetIsoFile(); if (ftell(cdHandle) < 2352 * 0x10) { static const char *exts[] = { ".bin", ".BIN", ".img", ".IMG" }; - char tmp[MAXPATHLEN], *p; - FILE *tmpf; + FILE *tmpf = NULL; size_t i; + char *p; - strncpy(tmp, GetIsoFile(), sizeof(tmp)); - tmp[MAXPATHLEN - 1] = '\0'; - if (strlen(tmp) >= 4) { - p = tmp + strlen(tmp) - 4; + strncpy(alt_bin_filename, bin_filename, sizeof(alt_bin_filename)); + alt_bin_filename[MAXPATHLEN - 1] = '\0'; + if (strlen(alt_bin_filename) >= 4) { + p = alt_bin_filename + strlen(alt_bin_filename) - 4; for (i = 0; i < sizeof(exts) / sizeof(exts[0]); i++) { strcpy(p, exts[i]); - tmpf = fopen(tmp, "rb"); - if (tmpf != NULL) { - fclose(cdHandle); - cdHandle = tmpf; - fseek(cdHandle, 0, SEEK_END); + tmpf = fopen(alt_bin_filename, "rb"); + if (tmpf != NULL) break; - } } } + if (tmpf != NULL) { + bin_filename = alt_bin_filename; + fclose(cdHandle); + cdHandle = tmpf; + fseek(cdHandle, 0, SEEK_END); + } } // guess whether it is mode1/2048 @@ -1314,7 +1319,7 @@ static long CALLBACK ISOopen(void) { // make sure we have another handle open for cdda if (numtracks > 1 && ti[1].handle == NULL) { - ti[1].handle = fopen(GetIsoFile(), "rb"); + ti[1].handle = fopen(bin_filename, "rb"); } cdda_cur_sector = 0; cdda_file_offset = 0; -- cgit v1.2.3 From 72f68e8c3d017b4e30855844d6b847965bf424a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 8 Apr 2013 02:03:35 +0200 Subject: (libretro) Update header --- frontend/libretro.h | 88 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 12 deletions(-) mode change 100644 => 100755 frontend/libretro.h diff --git a/frontend/libretro.h b/frontend/libretro.h old mode 100644 new mode 100755 index 0c39e6e..b02855a --- a/frontend/libretro.h +++ b/frontend/libretro.h @@ -333,6 +333,8 @@ enum retro_mod RETROKMOD_DUMMY = INT_MAX // Ensure sizeof(enum) == sizeof(int) }; +// If set, this call is not part of the public libretro API yet. It can change or be removed at any time. +#define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000 // Environment commands. #define RETRO_ENVIRONMENT_SET_ROTATION 1 // const unsigned * -- @@ -348,18 +350,7 @@ enum retro_mod // Boolean value whether or not frontend supports frame duping, // passing NULL to video frame callback. // -#define RETRO_ENVIRONMENT_GET_VARIABLE 4 // struct retro_variable * -- - // Interface to aquire user-defined information from environment - // that cannot feasibly be supported in a multi-system way. - // Mostly used for obscure, - // specific features that the user can tap into when neseccary. - // -#define RETRO_ENVIRONMENT_SET_VARIABLES 5 // const struct retro_variable * -- - // Allows an implementation to signal the environment - // which variables it might want to check for later using GET_VARIABLE. - // 'data' points to an array of retro_variable structs terminated by a { NULL, NULL } element. - // retro_variable::value should contain a human readable description of the key. - // +// Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), and reserved to avoid possible ABI clash. #define RETRO_ENVIRONMENT_SET_MESSAGE 6 // const struct retro_message * -- // Sets a message to be displayed in implementation-specific manner for a certain amount of 'frames'. // Should not be used for trivial messages, which should simply be logged to stderr. @@ -421,7 +412,80 @@ enum retro_mod // Sets an interface which frontend can use to eject and insert disk images. // This is used for games which consist of multiple images and must be manually // swapped out by the user (e.g. PSX). +#define RETRO_ENVIRONMENT_SET_HW_RENDER (14 | RETRO_ENVIRONMENT_EXPERIMENTAL) + // struct retro_hw_render_callback * -- + // NOTE: This call is currently very experimental, and should not be considered part of the public API. + // The interface could be changed or removed at any time. + // Sets an interface to let a libretro core render with hardware acceleration. + // Should be called in retro_load_game(). + // If successful, libretro cores will be able to render to a frontend-provided framebuffer. + // The size of this framebuffer will be at least as large as max_width/max_height provided in get_av_info(). + // If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or NULL to retro_video_refresh_t. +#define RETRO_ENVIRONMENT_GET_VARIABLE 15 + // struct retro_variable * -- + // Interface to aquire user-defined information from environment + // that cannot feasibly be supported in a multi-system way. + // 'key' should be set to a key which has already been set by SET_VARIABLES. + // 'data' will be set to a value or NULL. + // +#define RETRO_ENVIRONMENT_SET_VARIABLES 16 + // const struct retro_variable * -- + // Allows an implementation to signal the environment + // which variables it might want to check for later using GET_VARIABLE. + // This allows the frontend to present these variables to a user dynamically. + // This should be called as early as possible (ideally in retro_set_environment). + // + // 'data' points to an array of retro_variable structs terminated by a { NULL, NULL } element. + // retro_variable::key should be namespaced to not collide with other implementations' keys. E.g. A core called 'foo' should use keys named as 'foo_option'. + // retro_variable::value should contain a human readable description of the key as well as a '|' delimited list of expected values. + // The number of possible options should be very limited, i.e. it should be feasible to cycle through options without a keyboard. + // First entry should be treated as a default. + // + // Example entry: + // { "foo_option", "Speed hack coprocessor X; false|true" } + // + // Text before first ';' is description. This ';' must be followed by a space, and followed by a list of possible values split up with '|'. + // Only strings are operated on. The possible values will generally be displayed and stored as-is by the frontend. + // +#define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17 + // bool * -- + // Result is set to true if some variables are updated by + // frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE. + // Variables should be queried with GET_VARIABLE. + +// Pass this to retro_video_refresh_t if rendering to hardware. +// Passing NULL to retro_video_refresh_t is still a frame dupe as normal. +#define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1) + +// Invalidates the current HW context. +// If called, all GPU resources must be reinitialized. +// Usually called when frontend reinits video driver. +// Also called first time video driver is initialized, allowing libretro core to init resources. +typedef void (*retro_hw_context_reset_t)(void); +// Gets current framebuffer which is to be rendered to. Could change every frame potentially. +typedef uintptr_t (*retro_hw_get_current_framebuffer_t)(void); + +// Get a symbol from HW context. +typedef void (*retro_proc_address_t)(void); +typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym); + +enum retro_hw_context_type +{ + RETRO_HW_CONTEXT_NONE = 0, + RETRO_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. + RETRO_HW_CONTEXT_OPENGLES2, // GLES 2.0 + + RETRO_HW_CONTEXT_DUMMY = INT_MAX +}; +struct retro_hw_render_callback +{ + enum retro_hw_context_type context_type; // Which API to use. Set by libretro core. + retro_hw_context_reset_t context_reset; // Set by libretro core. + retro_hw_get_current_framebuffer_t get_current_framebuffer; // Set by frontend. + retro_hw_get_proc_address_t get_proc_address; // Set by frontend. + bool depth; // Set if render buffers should have depth component attached. +}; // Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. Called by the frontend in response to keyboard events. // down is set if the key is being pressed, or false if it is being released. -- cgit v1.2.3 From 468564e2b261d063db34139152a24aac60e878a3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 17 Apr 2013 18:40:14 +0200 Subject: Update target names in Makefile --- Makefile.libretro | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 36e0531..7edf54d 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -19,17 +19,19 @@ AS ?= as CC_AS ?= $(CC) CFLAGS ?= +TARGET_NAME := pcsx_rearmed + ifeq ($(platform), unix) - TARGET := pcsx_rearmed_libretro.so + TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC SHARED := -shared -Wl,--version-script=libretro/link.T else ifeq ($(platform), osx) - TARGET := pcsx_rearmed_libretro.dylib + TARGET := $(TARGET_NAME)_libretro.dylib fpic := -fPIC SHARED := -dynamiclib else ifeq ($(platform), ios) ARCH := arm - TARGET := pcsx_rearmed_libretro.dylib + TARGET := $(TARGET_NAME)_libretro.dylib fpic := -fPIC SHARED := -dynamiclib @@ -43,42 +45,42 @@ ARCH := arm USE_DYNAREC = 1 CFLAGS += -DIOS else ifeq ($(platform), ps3) - TARGET := libretro_pcsx_rearmed_ps3.a + TARGET := libretro_$(TARGET_NAME)_ps3.a CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), sncps3) - TARGET := libretro_pcsx_rearmed_ps3.a + TARGET := libretro_$(TARGET_NAME)_ps3.a CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), psl1ght) - TARGET := libretro_pcsx_rearmed_psl1ght.a + TARGET := libretro_$(TARGET_NAME)_psl1ght.a CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT) CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), psp1) - TARGET := libretro_pcsx_rearmed_psp1.a + TARGET := libretro_$(TARGET_NAME)_psp1.a CC = psp-gcc$(EXE_EXT) AR = psp-ar$(EXE_EXT) CFLAGS += -DPSP -G0 else ifeq ($(platform), xenon) - TARGET := libretro_pcsx_rearmed_xenon360.a + TARGET := libretro_$(TARGET_NAME)_xenon360.a CC = xenon-gcc$(EXE_EXT) AR = xenon-ar$(EXE_EXT) CFLAGS += -D__LIBXENON__ -m32 -D__ppc__ else ifeq ($(platform), ngc) - TARGET := libretro_pcsx_rearmed_ngc.a + TARGET := libretro_$(TARGET_NAME)_ngc.a CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), wii) - TARGET := libretro_pcsx_rearmed_wii.a + TARGET := libretro_$(TARGET_NAME)_wii.a CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), qnx) - TARGET := libretro_pcsx_rearmed_qnx.so + TARGET := libretro_$(TARGET_NAME)_qnx.so CC ?= qcc -Vgcc_ntoarmv7le CC_AS = $(CC) HAVE_NEON = 1 @@ -89,7 +91,7 @@ else ifeq ($(platform), qnx) CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp ASFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp else ifeq ($(platform), arm) - TARGET := pcsx_rearmed_libretro.so + TARGET := $(TARGET_NAME)_libretro.so HAVE_NEON = 1 USE_DYNAREC = 1 DRC_CACHE_BASE = 0 @@ -98,7 +100,7 @@ else ifeq ($(platform), arm) CFLAGS += -marm -mcpu=cortex-a8 -mfpu=neon ASFLAGS += -mcpu=cortex-a8 -mfpu=neon else - TARGET := pcsx_rearmed_retro.dll + TARGET := $(TARGET_NAME)_retro.dll CC = gcc fpic := -fPIC LD_FLAGS := -fPIC -- cgit v1.2.3 From fc6dbefffc5588db462fdb341a17c47a531745b6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 30 Apr 2013 16:31:52 +0200 Subject: (QNX) Compilation fix --- Makefile.libretro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 7edf54d..1ab4cc4 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -81,15 +81,15 @@ else ifeq ($(platform), wii) CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), qnx) TARGET := libretro_$(TARGET_NAME)_qnx.so - CC ?= qcc -Vgcc_ntoarmv7le + CC = qcc -Vgcc_ntoarmv7le CC_AS = $(CC) HAVE_NEON = 1 USE_DYNAREC = 1 DRC_CACHE_BASE = 0 BUILTIN_GPU = neon ARCH = arm - CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp - ASFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp + CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp + ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp else ifeq ($(platform), arm) TARGET := $(TARGET_NAME)_libretro.so HAVE_NEON = 1 -- cgit v1.2.3 From 0ed87574dfc808e0576a9820f6705a45ced7e60a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 Mar 2013 00:25:50 +0100 Subject: (libretro) Library version is too long to show in RGUI --- frontend/libretro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index e22ef5b..f916f57 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -250,7 +250,7 @@ void retro_get_system_info(struct retro_system_info *info) { memset(info, 0, sizeof(*info)); info->library_name = "PCSX-ReARMed"; - info->library_version = REV; + info->library_version = "r19"; info->valid_extensions = "bin|cue|img|mdf|pbp|cbn"; info->need_fullpath = true; } -- cgit v1.2.3 From 93305561891374a32e3fccadb7d74c87f99502ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 3 May 2013 17:12:23 +0200 Subject: Add .toc to valid_extensions --- Makefile.libretro | 14 +++++++------- frontend/libretro.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 1ab4cc4..8e9cdd1 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -45,32 +45,32 @@ ARCH := arm USE_DYNAREC = 1 CFLAGS += -DIOS else ifeq ($(platform), ps3) - TARGET := libretro_$(TARGET_NAME)_ps3.a + TARGET := $(TARGET_NAME)_libretro_ps3.a CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), sncps3) - TARGET := libretro_$(TARGET_NAME)_ps3.a + TARGET := $(TARGET_NAME)_libretro_ps3.a CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), psl1ght) - TARGET := libretro_$(TARGET_NAME)_psl1ght.a + TARGET := $(TARGET_NAME)_libretro_psl1ght.a CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT) CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), psp1) - TARGET := libretro_$(TARGET_NAME)_psp1.a + TARGET := $(TARGET_NAME)_libretro_psp1.a CC = psp-gcc$(EXE_EXT) AR = psp-ar$(EXE_EXT) CFLAGS += -DPSP -G0 else ifeq ($(platform), xenon) - TARGET := libretro_$(TARGET_NAME)_xenon360.a + TARGET := $(TARGET_NAME)_libretro_xenon360.a CC = xenon-gcc$(EXE_EXT) AR = xenon-ar$(EXE_EXT) CFLAGS += -D__LIBXENON__ -m32 -D__ppc__ else ifeq ($(platform), ngc) - TARGET := libretro_$(TARGET_NAME)_ngc.a + TARGET := $(TARGET_NAME)_libretro_ngc.a CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__ @@ -80,7 +80,7 @@ else ifeq ($(platform), wii) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__ else ifeq ($(platform), qnx) - TARGET := libretro_$(TARGET_NAME)_qnx.so + TARGET := $(TARGET_NAME)_libretro_qnx.so CC = qcc -Vgcc_ntoarmv7le CC_AS = $(CC) HAVE_NEON = 1 diff --git a/frontend/libretro.c b/frontend/libretro.c index f916f57..f44cc28 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -251,7 +251,7 @@ void retro_get_system_info(struct retro_system_info *info) memset(info, 0, sizeof(*info)); info->library_name = "PCSX-ReARMed"; info->library_version = "r19"; - info->valid_extensions = "bin|cue|img|mdf|pbp|cbn"; + info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn"; info->need_fullpath = true; } -- cgit v1.2.3 From 9fba39a9876565426e31cf562d53bb3c587eb18f Mon Sep 17 00:00:00 2001 From: ToadKing Date: Tue, 7 May 2013 17:17:02 -0400 Subject: add support for mednafen-style .m3u files for multi-disc games --- frontend/libretro.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index f44cc28..b8a5b77 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -251,7 +251,7 @@ void retro_get_system_info(struct retro_system_info *info) memset(info, 0, sizeof(*info)); info->library_name = "PCSX-ReARMed"; info->library_version = "r19"; - info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn"; + info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn|m3u"; info->need_fullpath = true; } @@ -514,9 +514,69 @@ static struct retro_disk_control_callback disk_control = { .add_image_index = disk_add_image_index, }; +// just in case, maybe a win-rt port in the future? +#ifdef _WIN32 +#define SLASH '\\' +#else +#define SLASH '/' +#endif + +static char base_dir[PATH_MAX]; + +static bool read_m3u(const char *file) +{ + char line[PATH_MAX]; + char name[PATH_MAX]; + size_t i = 0; + FILE *f = fopen(file, "r"); + if (!f) + return false; + + while (fgets(line, sizeof(line), f) && i < sizeof(disks) / sizeof(disks[0])) { + if (line[0] == '#') + continue; + char *carrige_return = strchr(line, '\r'); + if (carrige_return) + *carrige_return = '\0'; + char *newline = strchr(line, '\n'); + if (newline) + *newline = '\0'; + + if (line[0] != '\0') + { + snprintf(name, sizeof(name), "%s%c%s", base_dir, SLASH, line); + disks[i++].fname = strdup(name); + } + } + + fclose(f); + return (i != 0); +} + +static void extract_directory(char *buf, const char *path, size_t size) +{ + char *base; + strncpy(buf, path, size - 1); + buf[size - 1] = '\0'; + + base = strrchr(buf, '/'); + if (!base) + base = strrchr(buf, '\\'); + + if (base) + *base = '\0'; + else + { + buf[0] = '.'; + buf[1] = '\0'; + } +} + bool retro_load_game(const struct retro_game_info *info) { size_t i; + bool is_m3u = (strcasestr(info->path, ".m3u") != NULL); + #ifdef FRONTEND_SUPPORTS_RGB565 enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { @@ -543,7 +603,16 @@ bool retro_load_game(const struct retro_game_info *info) } disk_current_index = 0; - disks[0].fname = strdup(info->path); + extract_directory(base_dir, info->path, sizeof(base_dir)); + + if (is_m3u) { + if (!read_m3u(info->path)) { + SysPrintf("failed to read m3u file\n"); + return false; + } + } + else + disks[0].fname = strdup(info->path); set_cd_image(disks[0].fname); @@ -578,9 +647,11 @@ bool retro_load_game(const struct retro_game_info *info) emu_on_new_cd(0); // multidisk images - for (i = 1; i < sizeof(disks) / sizeof(disks[0]) && i < cdrIsoMultidiskCount; i++) { - disks[i].fname = strdup(info->path); - disks[i].internal_index = i; + if (!is_m3u) { + for (i = 1; i < sizeof(disks) / sizeof(disks[0]) && i < cdrIsoMultidiskCount; i++) { + disks[i].fname = strdup(info->path); + disks[i].internal_index = i; + } } return true; -- cgit v1.2.3 From b40a83db932d2c2a250e68a06e88a334509968ec Mon Sep 17 00:00:00 2001 From: ToadKing Date: Tue, 7 May 2013 17:17:46 -0400 Subject: fix bug with memory card files being overwritten with RTC files --- frontend/libretro.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index b8a5b77..9e73fc7 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -673,12 +673,18 @@ unsigned retro_get_region(void) void *retro_get_memory_data(unsigned id) { - return Mcd1Data; + if (id == RETRO_MEMORY_SAVE_RAM) + return Mcd1Data; + else + return NULL; } size_t retro_get_memory_size(unsigned id) { - return MCD_SIZE; + if (id == RETRO_MEMORY_SAVE_RAM) + return MCD_SIZE; + else + return 0; } void retro_reset(void) -- cgit v1.2.3 From 51ba74081fe32f7581b75acded217a9a67ede429 Mon Sep 17 00:00:00 2001 From: ToadKing Date: Tue, 7 May 2013 17:52:43 -0400 Subject: implement "add_image_index" correctly --- frontend/libretro.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 9e73fc7..7a7c2ef 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -394,6 +394,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) /* multidisk support */ static bool disk_ejected; static unsigned int disk_current_index; +static unsigned int disk_count; static struct disks_state { char *fname; int internal_index; // for multidisk eboots @@ -463,14 +464,7 @@ static bool disk_set_image_index(unsigned int index) static unsigned int disk_get_num_images(void) { - unsigned int count = 0; - size_t i; - - for (i = 0; i < sizeof(disks) / sizeof(disks[0]); i++) - if (disks[i].fname != NULL) - count++; - - return count; + return disk_count; } static bool disk_replace_image_index(unsigned index, @@ -500,7 +494,10 @@ static bool disk_replace_image_index(unsigned index, static bool disk_add_image_index(void) { - // TODO?? + if (disk_count >= 8) + return false; + + disk_count++; return true; } @@ -527,12 +524,11 @@ static bool read_m3u(const char *file) { char line[PATH_MAX]; char name[PATH_MAX]; - size_t i = 0; FILE *f = fopen(file, "r"); if (!f) return false; - while (fgets(line, sizeof(line), f) && i < sizeof(disks) / sizeof(disks[0])) { + while (fgets(line, sizeof(line), f) && disk_count < sizeof(disks) / sizeof(disks[0])) { if (line[0] == '#') continue; char *carrige_return = strchr(line, '\r'); @@ -545,12 +541,12 @@ static bool read_m3u(const char *file) if (line[0] != '\0') { snprintf(name, sizeof(name), "%s%c%s", base_dir, SLASH, line); - disks[i++].fname = strdup(name); + disks[disk_count++].fname = strdup(name); } } fclose(f); - return (i != 0); + return (disk_count != 0); } static void extract_directory(char *buf, const char *path, size_t size) @@ -610,9 +606,10 @@ bool retro_load_game(const struct retro_game_info *info) SysPrintf("failed to read m3u file\n"); return false; } - } - else + } else { + disk_count = 1; disks[0].fname = strdup(info->path); + } set_cd_image(disks[0].fname); @@ -648,6 +645,7 @@ bool retro_load_game(const struct retro_game_info *info) // multidisk images if (!is_m3u) { + disk_count = cdrIsoMultidiskCount < 8 ? cdrIsoMultidiskCount : 8; for (i = 1; i < sizeof(disks) / sizeof(disks[0]) && i < cdrIsoMultidiskCount; i++) { disks[i].fname = strdup(info->path); disks[i].internal_index = i; -- cgit v1.2.3 From aa0e931b7dbd98359d3b0aa0db16c4d2ee8ca197 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 18 May 2013 03:42:37 +0200 Subject: (iOS) Standardize target name --- Makefile.libretro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index 8e9cdd1..9436c8a 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -31,7 +31,7 @@ else ifeq ($(platform), osx) SHARED := -dynamiclib else ifeq ($(platform), ios) ARCH := arm - TARGET := $(TARGET_NAME)_libretro.dylib + TARGET := $(TARGET_NAME)_libretro_ios.dylib fpic := -fPIC SHARED := -dynamiclib -- cgit v1.2.3 From e268a47e483b139b3c337c5fc37e3551138fbb99 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 24 May 2013 00:08:10 +0200 Subject: (NEON ARM) Add NEON ARM core option (Enhanced resolution - slow) --- frontend/libretro.c | 41 ++++++++++++++++++++++++++++++++++++++++- frontend/libretro.h | 9 ++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 7a7c2ef..8fb58b7 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -230,7 +230,22 @@ void out_register_libretro(struct out_driver *drv) } /* libretro */ -void retro_set_environment(retro_environment_t cb) { environ_cb = cb; } +void retro_set_environment(retro_environment_t cb) +{ +#ifdef __ARM_NEON__ + static const struct retro_variable vars[] = { + { "neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" }, + { NULL, NULL }, + }; + + environ_cb = cb; + + cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars); +#else + environ_cb = cb; +#endif +} + void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; } void retro_set_audio_sample(retro_audio_sample_t cb) { (void)cb; } void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_batch_cb = cb; } @@ -710,11 +725,33 @@ static const unsigned short retro_psx_map[] = { }; #define RETRO_PSX_MAP_LEN (sizeof(retro_psx_map) / sizeof(retro_psx_map[0])) +static void update_variables(void) +{ +#ifdef __ARM_NEON__ + struct retro_variable var; + var.value = NULL; + var.key = "neon_enhancement_enable"; + + if (!environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || !var.value) + return; + + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_neon.enhancement_enable = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_neon.enhancement_enable = 1; +#endif +} + void retro_run(void) { int i; input_poll_cb(); + + bool updated = false; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) + update_variables(); + in_keystate = 0; for (i = 0; i < RETRO_PSX_MAP_LEN; i++) if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) @@ -795,6 +832,8 @@ void retro_init(void) SaveFuncs.write = save_write; SaveFuncs.seek = save_seek; SaveFuncs.close = save_close; + + update_variables(); } void retro_deinit(void) diff --git a/frontend/libretro.h b/frontend/libretro.h index b02855a..dc5b52b 100755 --- a/frontend/libretro.h +++ b/frontend/libretro.h @@ -452,6 +452,13 @@ enum retro_mod // Result is set to true if some variables are updated by // frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE. // Variables should be queried with GET_VARIABLE. + // +#define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18 + // const bool * -- + // If true, the libretro implementation supports calls to retro_load_game() with NULL as argument. + // Used by cores which can run without particular game data. + // This should be called within retro_set_environment() only. + // Pass this to retro_video_refresh_t if rendering to hardware. // Passing NULL to retro_video_refresh_t is still a frame dupe as normal. @@ -496,7 +503,7 @@ typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, uint32_t cha struct retro_keyboard_callback { - retro_keyboard_event_t callback; + retro_keyboard_event_t callback; }; // Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. -- cgit v1.2.3 From 7d68d030b6a2c294ab6f18892f61e1861ecdd40f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 24 May 2013 01:19:56 +0200 Subject: (Libretro) Add core options - Frameskip and (for ARM NEON only) Software filter (None/Scale2x/Eagle2x) --- frontend/libretro.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 8fb58b7..f212cdd 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -39,6 +39,8 @@ static int samples_sent, samples_to_send; static int plugins_opened; static int is_pal_mode; +extern int soft_filter; + /* memory card data */ extern char Mcd1Data[MCD_SIZE]; extern char McdDisable[2]; @@ -232,18 +234,18 @@ void out_register_libretro(struct out_driver *drv) /* libretro */ void retro_set_environment(retro_environment_t cb) { -#ifdef __ARM_NEON__ static const struct retro_variable vars[] = { + { "frameskip", "Frameskip; 0|1|2|3" }, +#ifdef __ARM_NEON__ + { "soft_filter", "Software filter; none|scale2x|eagle2x" }, { "neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" }, +#endif { NULL, NULL }, }; environ_cb = cb; cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars); -#else - environ_cb = cb; -#endif } void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; } @@ -727,18 +729,37 @@ static const unsigned short retro_psx_map[] = { static void update_variables(void) { -#ifdef __ARM_NEON__ struct retro_variable var; + var.value = NULL; - var.key = "neon_enhancement_enable"; + var.key = "frameskip"; - if (!environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || !var.value) - return; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + pl_rearmed_cbs.frameskip = atoi(var.value); +#ifdef __ARM_NEON__ + var.value = NULL; + var.key = "soft_filter"; - if (strcmp(var.value, "disabled") == 0) - pl_rearmed_cbs.gpu_neon.enhancement_enable = 0; - else if (strcmp(var.value, "enabled") == 0) - pl_rearmed_cbs.gpu_neon.enhancement_enable = 1; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "none")) + soft_filter = 0; + else if (strcmp(var.value, "scale2x")) + soft_filter = 1; + else if (strcmp(var.value, "eagle2x")) + soft_filter = 2; + } + + var.value = NULL; + var.key = "neon_enhancement_enable"; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_neon.enhancement_enable = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_neon.enhancement_enable = 1; + } #endif } -- cgit v1.2.3 From 5bed9d68e0ece9708cd384305418ca7a42d6e3ff Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 24 May 2013 01:28:43 +0200 Subject: Take out soft_filter for now as core option --- frontend/libretro.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index f212cdd..53e7fa5 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -39,8 +39,6 @@ static int samples_sent, samples_to_send; static int plugins_opened; static int is_pal_mode; -extern int soft_filter; - /* memory card data */ extern char Mcd1Data[MCD_SIZE]; extern char McdDisable[2]; @@ -237,7 +235,6 @@ void retro_set_environment(retro_environment_t cb) static const struct retro_variable vars[] = { { "frameskip", "Frameskip; 0|1|2|3" }, #ifdef __ARM_NEON__ - { "soft_filter", "Software filter; none|scale2x|eagle2x" }, { "neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" }, #endif { NULL, NULL }, @@ -737,19 +734,6 @@ static void update_variables(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) pl_rearmed_cbs.frameskip = atoi(var.value); #ifdef __ARM_NEON__ - var.value = NULL; - var.key = "soft_filter"; - - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) - { - if (strcmp(var.value, "none")) - soft_filter = 0; - else if (strcmp(var.value, "scale2x")) - soft_filter = 1; - else if (strcmp(var.value, "eagle2x")) - soft_filter = 2; - } - var.value = NULL; var.key = "neon_enhancement_enable"; -- cgit v1.2.3 From 9f5a28d9d0f0a294e72ab6ae61a1dc18adbe8aaa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 24 May 2013 03:13:24 +0200 Subject: (Libretro) Add NEON interlace enable core option and region core option --- frontend/libretro.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/frontend/libretro.c b/frontend/libretro.c index 53e7fa5..8b67f17 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -234,7 +234,9 @@ void retro_set_environment(retro_environment_t cb) { static const struct retro_variable vars[] = { { "frameskip", "Frameskip; 0|1|2|3" }, + { "region", "Region; Auto|NTSC|PAL" }, #ifdef __ARM_NEON__ + { "neon_interlace_enable", "Enable interlacing mode(s); disabled|enabled" }, { "neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" }, #endif { NULL, NULL }, @@ -733,7 +735,33 @@ static void update_variables(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) pl_rearmed_cbs.frameskip = atoi(var.value); + + var.value = NULL; + var.key = "region"; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + Config.PsxAuto = 0; + if (strcmp(var.value, "Automatic") == 0) + Config.PsxAuto = 1; + else if (strcmp(var.value, "NTSC") == 0) + Config.PsxType = 0; + else if (strcmp(var.value, "PAL") == 0) + Config.PsxType = 1; + } #ifdef __ARM_NEON__ + var.value = "NULL"; + var.key = "neon_interlace_enable"; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_neon.allow_interlace = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_neon.allow_interlace = 1; + } + + var.value = NULL; var.key = "neon_enhancement_enable"; -- cgit v1.2.3 From 094ec2043e80c12a5b692c6b9db791b7ae4df8e2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 24 May 2013 13:41:26 +0200 Subject: Comment out neon_enhancement_enable for now --- frontend/libretro.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 8b67f17..16feeec 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -237,7 +237,9 @@ void retro_set_environment(retro_environment_t cb) { "region", "Region; Auto|NTSC|PAL" }, #ifdef __ARM_NEON__ { "neon_interlace_enable", "Enable interlacing mode(s); disabled|enabled" }, +#if 0 { "neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" }, +#endif #endif { NULL, NULL }, }; @@ -761,7 +763,7 @@ static void update_variables(void) pl_rearmed_cbs.gpu_neon.allow_interlace = 1; } - +#if 0 var.value = NULL; var.key = "neon_enhancement_enable"; @@ -773,6 +775,7 @@ static void update_variables(void) pl_rearmed_cbs.gpu_neon.enhancement_enable = 1; } #endif +#endif } void retro_run(void) -- cgit v1.2.3 From a69536d7f28f096b5bc9075abcb18821524ebdd8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 25 May 2013 23:00:18 +0200 Subject: Add system message warning if a BIOS file could not be found --- frontend/libretro.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/libretro.c b/frontend/libretro.c index 16feeec..024ea7a 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -842,7 +842,11 @@ void retro_init(void) fclose(f); } else + { SysPrintf("no BIOS files found.\n"); + const char *str = "no BIOS found, expect bugs!"; + environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&str); + } level = 1; environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); -- cgit v1.2.3 From 69823a60b04945462d035403d688a9ebf9019b7d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 25 May 2013 23:11:31 +0200 Subject: Pass correct type for RETRO_ENVIRONMENT_SET_MESSAGE --- frontend/libretro.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 024ea7a..62f968a 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -844,8 +844,12 @@ void retro_init(void) else { SysPrintf("no BIOS files found.\n"); - const char *str = "no BIOS found, expect bugs!"; - environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&str); + struct retro_message msg = + { + "no BIOS found, expect bugs!", + 180 + }; + environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg); } level = 1; -- cgit v1.2.3