libretro / beetle-psx-libretro

Standalone port/fork of Mednafen PSX to the Libretro API.
GNU General Public License v2.0
310 stars 130 forks source link

Feature request: allowing users to manually select Region / Video Mode (PAL, NTSC, AUTO) #67

Closed Ryunam closed 3 years ago

Ryunam commented 8 years ago

This is to kindly inquire about the possibility of exposing an option to select the Region / Video Mode in the Core Options of beetle-psx-libretro, thus allowing the user to either force a specific format (PAL / 50hz or NTSC / 60hz) or leave it up to the automatic region detection normally performed by the emulator.

The reason behind this request lies in being able to circumvent the technical limitations that affected the PAL-exclusive localizations of several classics. Back in the day, PAL PS1 games were released on the market in a crippled form that capped them at 50hz, making the overall framerate 17,5% slower if compared to their respective NTSC counterparts. Furthermore, because of the intrinsic difference between the two formats and the different number of lines displayed, PAL versions were often plagued with black borders.

While it appears that the latter effect is mitigated in emulation, the former is still firmly in place. That is because, as far as I understand, Mednafen PSX faithfully reads the regional code of each game and then proceeds to run it with the corresponding Region / Video Mode, but this makes it so that some German, French, Italian and Spanish translations are inevitably hindered by the slower framerate. Being able to choose between modes would allow a wider array of options, while keeping the goal of accuracy.

Thanks in advance!

simias commented 8 years ago

That sounds trivial enough to implement, a "force PAL/NTSC" option in the core. I'll give it a try.

simias commented 8 years ago

On 2nd thought just changing the detected video format won't be enough, you'd also have to hijack the game to prevent it from setting the PAL bit in the GPU DisplayMode (all PSX GPUs can output both PAL and NTSC, there's a register to configure this behaviour).

Ryunam commented 8 years ago

I see. In fact one thing I want to highlight here is that I had attempted to patch my PAL localized games to NTSC through some tools available around (which I assume have the effect of changing the GPU DisplayMode you referenced), but since Mednafen automatically detects the video format in an automatic way they would play in their usual crippled speed (50hz).

I wonder if in the meantime the option you have mentioned in your first post could be implemented anyway, so as to test how it behaves with NTSC-patched images.

Or, another idea that comes to my mind, would it be possible to make it so that when you activate a forced Region / Video mode from the Core options, it would also impose the same configuration for the GPU bit?

SomeoneIsWorking commented 8 years ago

PAL versions were often plagued with black borders

oddly enough, Spyro PAL games cover whole (4:3) screen while NTSC are letterbox. I'd play them in PAL if framerate wasn't crippling

simias commented 8 years ago

Spyro PAL runs at 30fps, same framerate as the NTSC version:

retroarch-0621-144157

It just has a slightly higher vertical resolution.

I actually had trouble finding PAL ports that ran slower that the NTSC version, it seems I've been lucky with the few games from my collection I've ripped. I should try a final fantasy game, they're quite notorious for their crappy PAL ports.

SomeoneIsWorking commented 8 years ago

Those green bars on bottom and right appear at NTSC version for me.

I put NTSC vs PAL side by side RetroArch Mednafen PSX (Software) I thought I could be mistaking versions but there is a language selector in PAL in main screen

PAL NTSC
Display 4:3 4:3 letterbox
Framerate 29.97 feels like 20 29.97
Artifacts none Bars on bottom and right depending on the screen you are nevermind, these only appear above 1x internal resolution
simias commented 8 years ago

Oh you're right, the internal FPS counter is broken currently, it always assumes NTSC. Let me try to fix that.

Spyro PAL really runs at 25fps.

rz5 commented 8 years ago

@simias, is '25 fps' something that Spyro (PAL) requests and something we can intercept? From my experience messing with the rustation renderer I know there this: https://github.com/libretro/beetle-psx-libretro/blob/master/rustation-libretro/src/retrogl/retrogl.cpp#L327

I guess this would be one of the places where we'd read a hypothetical Region/Video mode core option and force some mode if it's not on 'auto'.

simias commented 8 years ago

@rz5 I think you'd have to do it earlier than that. You can't completely pretend that the game is NTSC however (because things like BIOS detection will fail otherwise).

However you have to lie to the GPU by passing "is_pal = false" to the GPU constructor at least, and you also have to tell the GPU to ignore the game's attempt at setting the PAL video format.

However you'll still want to display the full PAL range if you don't want to crop things out. Not sure how that'll go. I'll give it a try I guess.

simias commented 8 years ago

So the problem is that the internal renderer poops itself if I lie about the game rendering in PAL (it's not really surprising, it messes up its internal counters).

The GL renderer however works at a higher level (I don't actually count lines and whatnot) so it works somewhat better, unfortunately it seems that the software renderer commits suicide and stops uploading the textures so I get an untextured Spyro, albeit running at 30fps:

spyro-pal-60

I don't really get why the software renderer refuses to proceed. At any rate I don't see how we could get the software renderer to render PAL at 60fps without cropping some lines since it wouldn't fit the timings. Maybe by fudging the timings somewhat but I don't feel comfortable doing that, it's quite the state machine we have there.

SomeoneIsWorking commented 8 years ago

What about running NTSC with PAL resolution? Can the letterbox get expanded?

simias commented 8 years ago

The black bars are here because of mednafen's emulation of a real monitor, this way it can implement things like the screen shaking in some games: https://www.youtube.com/watch?v=a-ovOoISyLA

The GL renderer doesn't implement that currently so you don't have black bars, all you need to do is had something similar to the widescreen hack to increase the vertical angle to match the PAL resolution. It would probably break with some games though. That wouldn't increase the actual resolution but the camera would match and you could just run the game at 2x or more to effectively increase the resolution to compensate.

I'm not sure it's worth bothering with it though, why not just play the NTSC version with increased internal res? The camera will be a bit "flatter" than on PAL counterparts (for proper ports at least) but that's the only downside really.

Ryunam commented 8 years ago

First of all, I'd like to thank simias for their patience and dedication. It is nice to hear that the Internal FPS Counter was fixed: when I first read your previous reports stating that PAL games had the same framerate if compared to their NTSC variants, I was a bit perplexed! Unfortunately this is an issue that European players have been living with for ages, long before Video Mode selectors were implemented in more modern systems (ie from the PS2 onwards), so the difference in smoothness and actual game speed is very noticeable while playing.

With regards to the Video / Region Code I've been thinking a few things:

1) I had managed to find a way to play my PAL Italian version of Final Fantasy VIII at perfectly smooth NTSC speeds (60hz) on the emulator ePSXe. I basically activated an option that would force the emulator to always use an NTSC BIOS (either US or JPN) and tell the game that it was running on a non-PAL console. Then, on the video plugin side, there was an option to indicate '60fps' as the minimum framerate. As far as I remember this combination of settings worked well: the game played exactly like my Japanese copy in terms of speed / smoothness and audio and video appeared to be well synchronized. I know mednafen doesn't use plugins and is much more accurate, but I wonder whether this method could be useful to devise a workaround.

2) The way I usually force NTSC on the actual hardware (a modded PS1 PAL system) is by using one of the many Boot disks that float around the internet. The most effective one is ImportPlayer / ImportPlayer Light: you start the system with this disk inside the tray, you then select the actual Video Mode that you want to force, then you swap the disks and put the game you want to play with the forced Region / Video Mode. Last time I tried using these Boot Disks on mednafen (by using all the proper commands to cycle the tray and swap the respective CD images) it would hang, as referenced in this thread I made a few months ago on the libretro boards: http://libretro.com/forums/showthread.php?t=4913 I am wondering though if the code that these disks use could be useful to implement a similar option at a core-wide level.

3) There are also many patches available for PAL PS1 titles that add a Video Mode selector right before starting the actual game. They work very well on actual hardware (albeit once again modded). The problem with these modifications is that on Mednafen, when forcing NTSC through these patches, the game displays a black screen even though you can still hear the sound going. This is also referenced in another issue that was opened here on github: https://github.com/libretro/beetle-psx-libretro/issues/3. RagnaStrife says he managed to play these modded games with NTSC speeds once he forced the NTSC video mode on standalone Mednafen.

Hope this is helpful one way or another!

SomeoneIsWorking commented 8 years ago

If the display resolution of NTSC is known, perhaps a zoom feature might do it, scale the screen preserving aspect ratio?

simias commented 8 years ago

@Ryunam for your methods 2 and 3 I assume that those methods completely switch to NTSC video mode, i.e. you also lose a bit of vertical resolution?

The difficulty is to run at 60fps while keeping the PAL resolution I think (PAL60).

Very late edit: I don't know why I said "PAL60" here, PAL60 is simply NTSC with PAL colors so it doesn't have PAL resolution.

Ryunam commented 8 years ago

@simias : Yes, I can confirm that. My CRT TV switches to NTSC completely with both methods 2 and 3. Framerate improves drastically since at that point the game is running at NTSC speeds (60hz), but the vertical resolution is indeed reduced.

Still, it would be great to actually have this option on Mednafen, for all the reasons already indicated.

simias commented 8 years ago

I think I have a working patch for that:

spyro

It requires a lot more testing though, I wish we had an "experimental" core for that stuff.

Anyway, I'm going to turn it into a core option and you'll tell me if it does what you want.

simias commented 8 years ago

Just pushed the option, it seems to mess up the SCEE boot logo for some reason (but it's already glitchy with beetle currently for some reason). Spyro, MSG and Rollcage all seem to work at 30FPS when forcing the NTSC videomode with no obvious glitch. That being said I'm bad at noticing framerate stuff so let me know if it doesn't work properly.

simias commented 8 years ago

Oh and you need to restart the emulator for changes to this option to take effect, it's not applied directly.

SomeoneIsWorking commented 8 years ago

Spyro NTSC on PAL res. A part on bottom area is missing, top area seems to be fine retroarch-0625-095053

There is also a recent speed issue, I play on x2 software and it slows down. Throttling at x1, using d3d or sdl2, threaded video(causes spikes) or using exclusive fullscreen fixes it. Probably isn't related to core but started happening recently

Ryunam commented 8 years ago

Thanks for the patch, @simias! Unfortunately there seem to be some issues with the current implementation. I have performed a few tests so far, namely trying to force my PAL Italian copy of Final Fantasy VIII to NTSC and the results I've got are quite odd.

With the software renderer

With the opengl renderer

simias commented 8 years ago

Mmmh. That's odd. I did only try the GL shader, I'll try with software mode. How do you measure the "external FPS" exactly? Using RA's builtin "Display Framerate" option I was running at 60fps in Spyro.

saftle commented 8 years ago

@simias I run RetroArch through Steam with the in-game overlay FPS enabled. Or others use MSI Afterburner, or Fraps.

Ryunam commented 8 years ago

Yes, sorry for the imprecise wording, @simias . Where I said 'external FPS' in my previous post, I referred to the value reported by Retroarch's builtin Display Framerate.

I have retried once again with the OpenGL renderer, going past the initial starting Menus and once again I can confirm my initial results:

simias commented 8 years ago

so you mean that RA reports running at 60fps but it really runs at 50?

Ryunam commented 8 years ago

Basically, with PAL Final Fantasy VIII forced to NTSC, Mednafen's internal FPS is reporting 59.97 / 29.97 (NTSC), but RA's display framerate displays 50fps. This happens in both software and OpenGL renderers, so it's still rendering in PAL / 50hz.

The only difference between both renderers is that:

I'll try to grab some screenshots to show my results more clearly.

simias commented 8 years ago

Okay, I'll give PAL FFVIII a try then. I tried with Rollcage, MGS and Spyro.

Ryunam commented 8 years ago

I got a few screen grabs to further demonstrate the issues I'm having while forcing PAL Final Fantasy VIII to NTSC.

With the Software renderer

Internal FPS: retroarch-0625-204149

Retroarch's Display FPS: retroarch-0625-204315

With the OpenGL renderer

Internal FPS: retroarch-0625-205333

Retroarch's Display FPS: retroarch-0625-205253

With the OpenGL renderer, after alternating between Fullscreen and Windowed

retroarch-0625-205359

Ryunam commented 8 years ago

Did you find out anything new about this, @simias? I've seen that the previous implementation was reverted as it seemed to break PAL emulation completely.

simias commented 8 years ago

No, I'm not sure why it even broke anything to begin with. I'll have to give it an other try later.

E38IK commented 5 years ago

Is there any interest in resuming work on a feature like this?

There have been a raft of improvements to beetle since this was opened, and it's by far the best PS1 emulator around now. Not being able to run PAL games at 60hz is one of the few remaining blemishes. I understand this is a problem with mednafen-psx at its core, but maybe something could be done about it from this side. There are a number of games where, content-wise, the PAL version is the better one, but the associated slowdown (and judder on non-VRR displays or displays with broken 50hz modes) is a dealbreaker.

hizzlekizzle commented 5 years ago

Is it any more complicated than adding a core option for PAL60 and changing: float fps = is_pal ? FPS_PAL : FPS_NTSC; to float fps = (is_pal && !PAL60) ? FPS_PAL : FPS_NTSC;

E38IK commented 5 years ago

Presumably. Currently, mednafen-psx (standalone as well as beetle-psx) will autodetect the region of a game and forcibly ignore any PAL2NTSC patches you may have applied to the images. Those patches do work on actual hardware as well as various other emulators (like pSX). Mednafen-psx exposes an option to disable region auto detection (which isn't accessible via beetle-psx as far as I can tell); however, it will then throw a video standard mismatch error and not display any video output (but actual emulation will continue, including accepting input, audio, etc.). As this runs counter to the way actual hardware behaves, I would assume there is a reason for this and something else would break.

bigboo3000 commented 5 years ago

I also tried hard-patching .bin image files for pal60 with no luck with beetle-psx, now I understand why. A core option to force PAL games to PAL60 would be so great.

Maybe something related to this? https://github.com/libretro/beetle-psx-libretro/issues/376

E38IK commented 5 years ago

Maybe something related to this?

376

While that technically gets you 60hz, this will really mess with the audio. It's unfortunately not a very useful solution.

ghost commented 5 years ago

Is there no way to make this work on Beetle PSX HW? If you have a patched PAL2NTSC game, that the core recognizes it and just treats it as an NTSC game? On the ReARMed core it works and the patched PAL game will run as NTSC no problem, as long as you manually set the region in the options tab to "NTSC". But that core doesn't have those great gaphics enhancement options as Beetle PSX HW does.

In the Discord I've read that this is some kind of issue with upstream mednafen. Beetle PSX HW uses the disc's serial to determine if it is NTSC or PAL, regardless on if it has been patched with Zapper2K/PAL4U.

Maybe if there was a manual option to set PAL / NTSC / AUTO on region detection, it would work with patched PAL games at least.

Forcing unpatched games into NTSC seems to be the main problem here as far as I can tell. But maybe the result will be better by just trying how it'll work with patched PAl2NTSC games.

This .diff file here has been created by the Discord user radius from the libretro Discord Server: region.zip Maybe it'll help in this effort. He said that if you are able to build a core yourself, this might do the trick with patched games.

Whoever is still working on this, maybe give it a try. It would help with a lot of problems PAL games come with such as de-synched 3D ingame cutscenes or that "teleport"-effect on video scenes, where it jumps ahead 5 frames every second, if the core would allow patched games to work as NTSC.

Papermanzero commented 5 years ago

I only want to emphasize that the realisation of the features needs to differentiate between two settings. The color component (PAL, NTSC, SECAM) and the Refresh Rate (25Hz, 30Hz, 50Hz, 60Hz) The details can be read in the linked (and closed) issue https://github.com/libretro/beetle-psx-libretro/issues/503

rz5 commented 5 years ago

@Papermanzero - You linked to a forum thread discussing ways to force PS1/PS2 hardware into different modes.

So an interesting thing to try out is to attempt the same thing but with beetle-psx. Put one of those boot discs in beetle-psx's virtual disc tray (just launch the .cue/.chd file), do the mode diddling stuff and when the mode switching program asks you to insert a game CD, replace the virtual mode switching disc with a game disc (Quick Menu > Disk Control > Disk Image Append > game.chd; Disk Control > Disk Cycle Tray Status).

If that works, great. It's a clue on how to get an implementation going. It if does not work, that's great too. We can go to upstream's bug tracker and file that as a bug.

trostboot commented 5 years ago

That doesn't work. Like it was alluded to by E38IK a few posts up in the issue, mednafen/beetle will simply ignore these kinds of patches - whether they're on-the-fly or applied to the image. Just to be sure, I checked it out using ImportPlayer Light, and it doesn't work.

trostboot commented 5 years ago

Actually, I may be mostly wrong. Using beetle and a German Final Fantasy IX image with a US region ImportPlayer Light it does appear to run correctly at 60hz (with internal FPS correctly reporting 29.97) - using the EU IPL version does not, it will stay at 50hz. For this to work on upstream mednafen, regio auto detect has to be on.

Final Fantasy IX  PAL-G -190513-193208

darkcloudl commented 5 years ago

I actually use the method explained by rz5 since RA 1.7.5 in beetle psx hw(vulkan) with 'skip bios' off and works, i use "ImportPlayer Light v2.1 [EURO]" and force to ntsc the pal games exhumed(eur version of powerslave) RRT4, everybody's golf(eur version of hot shots golf 1),dino crisis 1(in this you even can adjust ingame the image with the L1+R1+L2+R2+Up/down keys; keep in mind this game requires sbi fie because LibCrypt protection if someone else want to test) and others; didn't work with metal gear solid(SLES-01734, stuck in anti piracy message screen). The games displays a 60hz image and even you can notice the difference (especially with RRT4 and Exhumed) but the 'display internal FPS' option in the core still displays pal framerate (the RA 'display framerate' option and even msi afterburner shows 60 fps).

Papermanzero commented 5 years ago

Interesting that the boot discs are correctly emulated.

ghost commented 4 years ago

Is there any progress being made on this?

To me this is a very important issue, so many PAL games usually are the definitive version of a game but are crippled with 50 FPS, causing FMV's to always skip frames.

Papermanzero commented 4 years ago

Also agree. Several PAL versions are locked on 50Hz but contain various bonuses like several languages and content. It would be really nice to speed them up to their original speed.

simias commented 4 years ago

I only want to emphasize that the realisation of the features needs to differentiate between two settings. The color component (PAL, NTSC, SECAM) and the Refresh Rate (25Hz, 30Hz, 50Hz, 60Hz)

I'm not sure I understand what you mean by "color component", the actual color encoding isn't relevant for the emulator because it doesn't actually simulate the PAL/NTSC/SECAM signal, it stops at the RGB buffer being sent to the output. Therefore as far as the emulator is concerned PAL and SECAM are the exact same thing and the only difference between PAL and NTSC are different timings.

Papermanzero commented 4 years ago

I wanted to say that PAL, NTSC and Secam are color coding information. They are independent of the refresh rate. Means, you can have pal in 50hz and 60hz. in theory you could also limit ntsc to 50hz but this would be outside of the standard.

simias commented 4 years ago

That's true for PAL and Secam (same video timings, different color coding) but NTSC does have different timings. PAL 60 exists but that's effectively a different standard that came after the fact. The original PSX doesn't support PAL 60.

It's not just nitpicking, as far as the PSX is concerned there's a very significant timing difference between PAL and NTSC console. Even the hardware GPU clock is different!

That being said forcing a different standard shouldn't normally be very difficult, the only "problem" with mednafen/beetle is that it emulates some low-level details about scanlines and blankings that would probably cause some issues with a naive implementation. Since mednafen outputs one line at a time if you increase the framerate without reducing the line count you'll have the problem since there won't be enough time to draw everything correctly.

Intuitively the solution would be to change Mednafen's rendering to allow rendering one frame at a time instead of one line at a time. This way the number of lines being rendered won't directly be tied to the timings.

I'm currently in the process of writing my own renderer based on mednafen's so I'll try to keep that in mind. Slow and steady.

simias commented 4 years ago

I made a new attempt in my branch to see if I could cheat by telling the GPU code to use "shorter' lines (timing-wise, not resolution-wise) for PAL: https://github.com/simias/beetle-psx-libretro/tree/dev/pal-60fps

It does seem to desync the audio from time to time in Spyro, mainly during cinematics. If somebody wants to give it a try (there's no option, it's just hardcoded for every PAL game).

simias commented 4 years ago

Yet an other possibility would be to speed up the entire system by a factor of 30/25 to fake the 30fps, but have the SPU run at the normal speed so that the sound wouldn't be distorted.

Ryunam commented 4 years ago

Thanks @simias, I'm glad that this issue is still getting some attention after 4 years! I can only echo once again the other commenters: this feature would be extremely handy since so many interesting improvements and translations are locked behind the slowdown associated with the PAL versions.

I'll test your branch in a second, though just as a comparison I will note that, if you use a boot disc with a PAL / NTSC force boot feature such as Import Player Light, PAL games will typically run at the NTSC framerate without any desynchronization (both on the Beetle PSX core - based on the few tests I've run before - and on real hardware).

The only issue with that method is that some content will end up displaying some anomalies in the geometry of the picture for some reason (even on real hardware): for instance, when booting the European version of FFVIII in NTSC mode with the Import Player Light disc, anytime you open the menu the whole picture will be shifted upwards by a significant amount.