diff options
Diffstat (limited to 'libretro.c')
-rw-r--r-- | libretro.c | 83 |
1 files changed, 69 insertions, 14 deletions
@@ -20,6 +20,7 @@ #endif #include <libretro.h> +#include <retro_miscellaneous.h> #ifdef _3DS void* linearMemAlign(size_t size, size_t alignment); @@ -34,8 +35,11 @@ static retro_audio_sample_batch_t audio_batch_cb = NULL; static retro_environment_t environ_cb = NULL; struct retro_perf_callback perf_cb; -char retro_save_directory[PATH_MAX]; -char retro_base_name[PATH_MAX]; +char retro_save_directory[PATH_MAX_LENGTH]; +char retro_base_name[PATH_MAX_LENGTH]; +bool overclock_cycles = false; +bool reduce_sprite_flicker = false; +int one_c, slow_one_c, two_c; #ifdef _WIN32 char slash = '\\'; @@ -170,7 +174,7 @@ void S9xInitDisplay(void) GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1; } -#ifndef __WIN32__ +#ifndef _WIN32 void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext) { (void) drive; @@ -245,17 +249,6 @@ const char* S9xGetFilename(const char* in) return filename; } -void GetBaseName(const char* ex) -{ - char drive [_MAX_DRIVE + 1]; - char dir [_MAX_DIR + 1]; - char fname [_MAX_FNAME + 1]; - char ext [_MAX_EXT + 1]; - (void) ex; - _splitpath(Memory.ROMFilename, drive, dir, fname, ext); - snprintf(retro_base_name,sizeof(retro_base_name),"%s",fname); -} - void init_sfc_setting(void) { memset(&Settings, 0, sizeof(Settings)); @@ -305,6 +298,8 @@ void retro_init(void) static const struct retro_variable vars[] = { { "catsfc_VideoMode", "Video Mode; auto|NTSC|PAL" }, + { "catsfc_overclock_cycles", "Reduce Slowdown (Hack, Unsafe, Restart); disabled|compatible|max" }, + { "catsfc_reduce_sprite_flicker", "Reduce Flickering (Hack, Unsafe); disabled|enabled" }, { NULL, NULL }, }; @@ -389,6 +384,40 @@ static void check_variables(void) Settings.ForceNTSC = !strcmp(var.value, "NTSC"); Settings.ForcePAL = !strcmp(var.value, "PAL"); } + + var.key = "catsfc_overclock_cycles"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "compatible") == 0) + { + overclock_cycles = true; + one_c = 4; + slow_one_c = 5; + two_c = 6; + } + else if (strcmp(var.value, "max") == 0) + { + overclock_cycles = true; + one_c = 3; + slow_one_c = 3; + two_c = 3; + } + else + overclock_cycles = false; + } + + var.key = "catsfc_reduce_sprite_flicker"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + reduce_sprite_flicker = true; + else + reduce_sprite_flicker = false; + } } #ifdef PSP @@ -399,6 +428,8 @@ static int32_t samples_to_play = 0; void retro_run(void) { bool updated = false; + int result; + bool okay; #ifndef USE_BLARGG_APU static int16_t audio_buf[2048]; #endif @@ -411,6 +442,28 @@ void retro_run(void) IPPU.RenderThisFrame = false; #endif + result = -1; + okay = environ_cb(RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE, &result); + if (okay) + { + bool audioEnabled = 0 != (result & 2); + bool videoEnabled = 0 != (result & 1); + bool hardDisableAudio = 0 != (result & 8); + IPPU.RenderThisFrame = videoEnabled; +#ifdef USE_BLARGG_APU + S9xSetSoundMute(!audioEnabled || hardDisableAudio); +#endif + Settings.HardDisableAudio = hardDisableAudio; + } + else + { + IPPU.RenderThisFrame = true; +#ifdef USE_BLARGG_APU + S9xSetSoundMute(false); +#endif + Settings.HardDisableAudio = false; + } + poll_cb(); RETRO_PERFORMANCE_INIT(S9xMainLoop_func); @@ -427,6 +480,8 @@ void retro_run(void) audio_batch_cb(audio_buf, samples_to_play); samples_to_play = 0; } +#else + S9xAudioCallback(); #endif #ifdef NO_VIDEO_OUTPUT |