From: David Date: Sun, 13 Dec 2015 13:54:13 +0000 (+0100) Subject: Add core option to force the Region FPS (NTSC, PAL) X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48582bcfb85529a40a585a7f9c0b8e3baf690b21;p=picodrive.git Add core option to force the Region FPS (NTSC, PAL) This new core option will override the Region option. So it's possible to choose the Europe Region and the NTSC FPS. Strangely the region protection has no effect on megadrive :-) But will happend on 32x and SegaCD (Maybe it can be fixed by activating this core option after a little delay on startup) --- diff --git a/pico/pico.c b/pico/pico.c index 8535d486..866f6973 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -12,12 +12,13 @@ struct Pico Pico; int PicoOpt; -int PicoSkipFrame; // skip rendering frame? -int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU -int PicoPadInt[2]; // internal copy -int PicoAHW; // active addon hardware: PAHW_* -int PicoQuirks; // game-specific quirks -int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoSkipFrame; // skip rendering frame? +int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU +int PicoPadInt[2]; // internal copy +int PicoAHW; // active addon hardware: PAHW_* +int PicoQuirks; // game-specific quirks +int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoRegionFPSOverride; // override the refresh rate of the region 0: Auto, 1: NTSC, 2: PAL int PicoAutoRgnOrder; struct PicoSRAM SRam; @@ -91,6 +92,10 @@ void PicoPower(void) PICO_INTERNAL void PicoDetectRegion(void) { + // PicoDetectRegion not ready yet + if (Pico.romsize <= 0) + return; + int support=0, hw=0, i; unsigned char pal=0; @@ -143,6 +148,10 @@ PICO_INTERNAL void PicoDetectRegion(void) else hw=0x80; // USA Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached + + if (PicoRegionFPSOverride > 0) + pal = PicoRegionFPSOverride - 1; // pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL + Pico.m.pal=pal; } @@ -216,9 +225,16 @@ int PicoReset(void) // flush config changes before emu loop starts void PicoLoopPrepare(void) { - if (PicoRegionOverride) + if (PicoRegionFPSOverride) // PicoRegionFPSOverride is proprietary on PicoRegionOverride + { + // force setting possibly changed.. + Pico.m.pal = PicoRegionFPSOverride - 1; // Pico.m.pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL + } + else if (PicoRegionOverride) + { // force setting possibly changed.. Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0; + } // FIXME: PAL has 313 scanlines.. scanlines_total = Pico.m.pal ? 312 : 262; diff --git a/pico/pico.h b/pico/pico.h index d5416727..624adacc 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -81,9 +81,10 @@ extern int PicoAHW; // Pico active hw #define PQUIRK_FORCE_6BTN (1<<0) extern int PicoQuirks; -extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff -extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe -extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP +extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff +extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +extern int PicoRegionFPSOverride; // override the refresh rate of the region 0: Auto, 1: NTSC, 2: PAL +extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP extern int PicoSVPCycles; void PicoInit(void); void PicoExit(void); diff --git a/pico/sound/sound.c b/pico/sound/sound.c index 69c1be03..18e12250 100644 --- a/pico/sound/sound.c +++ b/pico/sound/sound.c @@ -118,6 +118,10 @@ PICO_INTERNAL void PsndReset(void) // to be called after changing sound rate or chips void PsndRerate(int preserve_state) { + // PsndRerate not ready yet + if (Pico.romsize <= 0) + return; + void *state = NULL; int target_fps = Pico.m.pal ? 50 : 60; diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 799ff8d4..0a4ab495 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -477,12 +477,12 @@ void lprintf(const char *fmt, ...) void retro_set_environment(retro_environment_t cb) { static const struct retro_variable vars[] = { - //{ "region", "Region; Auto|NTSC|PAL" }, - { "picodrive_input1", "Input device 1; 3 button pad|6 button pad|None" }, - { "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" }, - { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, - { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, - { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, + { "picodrive_input1", "Input device 1; 3 button pad|6 button pad|None" }, + { "picodrive_input2", "Input device 2; 3 button pad|6 button pad|None" }, + { "picodrive_sprlim", "No sprite limit; disabled|enabled" }, + { "picodrive_ramcart", "MegaCD RAM cart; disabled|enabled" }, + { "picodrive_region", "Region; Auto|Japan NTSC|Japan PAL|US|Europe" }, + { "picodrive_region_fps", "Region FPS; Auto|NTSC|PAL"}, #ifdef DRC_SH2 { "picodrive_drc", "Dynamic recompilers; enabled|disabled" }, #endif @@ -1144,6 +1144,7 @@ static void update_variables(void) PicoOpt &= ~POPT_EN_MCD_RAMCART; } + int OldPicoRegionOverride = PicoRegionOverride; var.value = NULL; var.key = "picodrive_region"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { @@ -1159,6 +1160,27 @@ static void update_variables(void) PicoRegionOverride = 8; } + int OldPicoRegionFPSOverride = PicoRegionFPSOverride; + var.value = NULL; + var.key = "picodrive_region_fps"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "Auto") == 0) + PicoRegionFPSOverride = 0; + else if (strcmp(var.value, "NTSC") == 0) + PicoRegionFPSOverride = 1; + else if (strcmp(var.value, "PAL") == 0) + PicoRegionFPSOverride = 2; + } + + // Update region, fps and sound flags if needed + if (PicoRegionOverride != OldPicoRegionOverride || + PicoRegionFPSOverride != OldPicoRegionFPSOverride) + { + PicoDetectRegion(); + PicoLoopPrepare(); + PsndRerate(1); + } + #ifdef DRC_SH2 var.value = NULL; var.key = "picodrive_drc";