From 04998786cad0e0785c9d4cc021e85aeb955feb5f Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 Jul 2012 05:44:32 +0200 Subject: [PATCH] Don't assume slash is appended at the end of the system dir --- libretro/libretro.c | 34 ++++++++++++++++++++-------------- source/sound/blip.c | 6 ++++++ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index 0ed184a..a251c30 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -824,6 +824,7 @@ size_t retro_get_memory_size(unsigned id) void retro_init(void) { const char *dir = NULL; + char slash[6]; unsigned level; #if defined(USE_NTSC) sms_ntsc = calloc(1, sizeof(sms_ntsc_t)); @@ -834,20 +835,25 @@ void retro_init(void) if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) { - snprintf(CD_BRAM_EU, sizeof(CD_BRAM_EU), "%sscd_E.brm", dir); - snprintf(CD_BRAM_US, sizeof(CD_BRAM_US), "%sscd_U.brm", dir); - snprintf(CD_BRAM_JP, sizeof(CD_BRAM_JP), "%sscd_J.brm", dir); - snprintf(CD_BIOS_EU, sizeof(CD_BIOS_EU), "%sbios_CD_E.bin", dir); - snprintf(CD_BIOS_US, sizeof(CD_BIOS_US), "%sbios_CD_U.bin", dir); - snprintf(CD_BIOS_JP, sizeof(CD_BIOS_JP), "%sbios_CD_J.bin", dir); - snprintf(MS_BIOS_EU, sizeof(MS_BIOS_EU), "%sbios_E.sms", dir); - snprintf(MS_BIOS_US, sizeof(MS_BIOS_US), "%sbios_U.sms", dir); - snprintf(MS_BIOS_JP, sizeof(MS_BIOS_JP), "%sbios_J.sms", dir); - snprintf(GG_BIOS, sizeof(GG_BIOS), "%sbios.gg", dir); - snprintf(SK_ROM, sizeof(SK_ROM), "%ssk.bin", dir); - snprintf(SK_UPMEM, sizeof(SK_UPMEM), "%ssk2chip.bin", dir); - snprintf(GG_ROM, sizeof(GG_ROM), "%sggenie.bin", dir); - snprintf(AR_ROM, sizeof(AR_ROM), "%sareplay.bin", dir); +#ifdef _XBOX + snprintf(slash, sizeof(slash), "\\"); +#else + snprintf(slash, sizeof(slash), "/"); +#endif + snprintf(CD_BRAM_EU, sizeof(CD_BRAM_EU), "%s%sscd_E.brm", dir, slash); + snprintf(CD_BRAM_US, sizeof(CD_BRAM_US), "%s%sscd_U.brm", dir, slash); + snprintf(CD_BRAM_JP, sizeof(CD_BRAM_JP), "%s%sscd_J.brm", dir, slash); + snprintf(CD_BIOS_EU, sizeof(CD_BIOS_EU), "%s%sbios_CD_E.bin", dir, slash); + snprintf(CD_BIOS_US, sizeof(CD_BIOS_US), "%s%sbios_CD_U.bin", dir, slash); + snprintf(CD_BIOS_JP, sizeof(CD_BIOS_JP), "%s%sbios_CD_J.bin", dir, slash); + snprintf(MS_BIOS_EU, sizeof(MS_BIOS_EU), "%s%sbios_E.sms", dir, slash); + snprintf(MS_BIOS_US, sizeof(MS_BIOS_US), "%s%sbios_U.sms", dir, slash); + snprintf(MS_BIOS_JP, sizeof(MS_BIOS_JP), "%s%sbios_J.sms", dir, slash); + snprintf(GG_BIOS, sizeof(GG_BIOS), "%s%sbios.gg", dir, slash); + snprintf(SK_ROM, sizeof(SK_ROM), "%s%ssk.bin", dir, slash); + snprintf(SK_UPMEM, sizeof(SK_UPMEM), "%s%ssk2chip.bin", dir, slash); + snprintf(GG_ROM, sizeof(GG_ROM), "%s%sggenie.bin", dir, slash); + snprintf(AR_ROM, sizeof(AR_ROM), "%s%sareplay.bin", dir, slash); fprintf(stderr, "Sega CD EU BRAM should be located at: %s\n", CD_BRAM_EU); fprintf(stderr, "Sega CD US BRAM should be located at: %s\n", CD_BRAM_US); fprintf(stderr, "Sega CD JP BRAM should be located at: %s\n", CD_BRAM_JP); diff --git a/source/sound/blip.c b/source/sound/blip.c index 378b33d..bf896e2 100644 --- a/source/sound/blip.c +++ b/source/sound/blip.c @@ -84,6 +84,12 @@ void blip_add( blip_buffer_t* s, int clocks, int delta ) int blip_clocks_needed( const blip_buffer_t* s, int samples ) { +#ifdef __LIBRETRO__ + /* int fixed_needed */ + if (samples > s->size) + samples = s->size; +#endif + /* Fixed-point number of samples needed in addition to those in buffer */ int fixed_needed = samples * time_unit - s->offset;