libretro / pcsx_rearmed

ARM optimized PCSX fork
GNU General Public License v2.0
165 stars 118 forks source link

[Request] Add the "Core Overscan" Option #313

Closed Immersion95 closed 11 months ago

Immersion95 commented 5 years ago

Hi,

Would it be possible to add the following option 'Crop Overscan" to the core options ?

Disabling it is useful for PSX Capcom fighting games as it allows to see the missing area at the far right.

Example : Street Fighter Alpha 3, Marvel vs. Capcom Series, etc...

Why ? I will quote to thread here

"In the PS1 HW, the game sets the resolution to 368, but it is actually rasterizing a game screen which is 384 pixels wide."

You then have to adjust the area in the in-game menu which is working on the real PS1 but not on the emulator (SFA3 for example).

The option is there on Beetle PSX ("Crop Overscan") and also there on plugins based emulators ("0x2000 Expand screen Width").

Thanks for your help and sorry if the option is somehow already there and I missed it :).

ghost commented 5 years ago

can you or anyone verify if this feature is only missing in libretro's pcsx port(e.g. other pcsx-based emus has overscan options)? coz if this feature is not already in the emu core, thats gonna ba a pain to add...

Immersion95 commented 5 years ago

can you or anyone verify if this feature is only missing in libretro's pcsx port(e.g. other pcsx-based emus has overscan options)? coz if this feature is not already in the emu core, thats gonna ba a pain to add...

Hi,

I tested it with PCSXR, the option is in : ---->Graphics Plugins---->"Activate special game fixes"---->"Expand screen width" Sans titre 1

hizzlekizzle commented 5 years ago

It looks like that option only exists for peops in ReARMed: https://github.com/notaz/pcsx_rearmed/blob/8a55ebcc07d4f860633db8c77bb9e16bcfa03313/frontend/menu.c#L1393

Immersion95 commented 5 years ago

It looks like that option only exists for peops in ReARMed: https://github.com/notaz/pcsx_rearmed/blob/8a55ebcc07d4f860633db8c77bb9e16bcfa03313/frontend/menu.c#L1393

Hi,

Is that a good or bad sign ?

Thanks :)

VGkav commented 5 years ago

That's a bad sign because the NEON builds are the best for ARM devices and it may not be available for those builds.

Random general question: does the enhanced resolution option do anything in non-NEON builds?

hizzlekizzle commented 5 years ago

Random general question: does the enhanced resolution option do anything in non-NEON builds?

No it does not.

ghost commented 5 years ago

sent PR to add a few gpu options to core options menu, which includes the setting Expand screen width. Not sure if all are working in our port. It an option does not work, try restarting core since some are only set during rom load.

Immersion95 commented 5 years ago

Hi,

Thanks !

Unfortunately the setting is missing in Android, I can find it in the windows version though but the "expand screen width" option doesn't produce any effect.

Immersion95 commented 4 years ago

Hi, do you have any news regading those options ? They still don't work (Windows) or appear (Android).

Thanks !

notaz commented 11 months ago

There are now options to adjust the borders.

vaguerant commented 3 months ago

Where are the new options? I've got RetroArch with the PCSX-ReARMed core on Windows x86_64 and Nintendo Wii U, but I can't find the option/s to display the full width in either.

As an example, here's Street Fighter Alpha 3 in DuckStation (standalone):

![Uncropped screenshot](https://github.com/libretro/pcsx_rearmed/assets/5259025/b8b4b39e-3bee-47bd-bd56-c72e4f3f6b31) 384\*240

And here's the same game in PCSX-ReARMed (RetroArch):

![Cropped screenshot](https://github.com/libretro/pcsx_rearmed/assets/5259025/84c4a99b-92de-4272-8e12-d05496e31881) 368\*240

There's been decades of confusion over the available resolutions on the PS1. Apparently, even Sony's own development documents list the valid horizontal resolutions as:

However, there is no actual 368-wide mode; the mode in question is 384 pixels wide. Some games which run in this mode do internally pillarbox to lower resolutions (i.e. place empty black bars on the sides so that the active area is less than 384 pixels), but the actual resolution is still 384 regardless.

Here is a Shmups Forum thread which discusses the 384-wide mode and its idiosyncrasies but which affirms that 384 is the correct resolution captured from the output of a real, physical PlayStation.

Linked from that thread is another resource which affirms 384, the JunkerHQ wiki page on optimal timings for OSSC (a scaler device for retro platforms) for different platforms and individual video modes within those platforms. These people are even bigger nerds about this stuff than I am, you can be reasonably assured that they're right even if you distrust me.

If it's helpful to you for testing, another resource from that link is this Google Docs spreadsheet of PS1 game resolutions. It is a non-exhaustive list which includes 16 titles which make use of the 384-wide mode. As mentioned previously, that does not mean these games fill all 384 pixels of the available framebuffer with meaningful picture, only that they run in that mode. Some likely do use pillarboxing to fill out the image.

The games that I have personally confirmed fill the entire 384-pixel area without pillarboxing are:

Both of these games have helpful display adjustment screens which provide a good way to check for cropping. Alpha 3 is seen above, here is an uncropped version (from DuckStation) of the Strider screen:

![Uncropped screenshot](https://github.com/libretro/pcsx_rearmed/assets/5259025/cd3fa278-87fb-4c6a-b390-b45fda3fdcea)

Using Core Options -> Video -> (GPU) Screen centering set to Manual, it is possible to scroll the visible window left/right by adjusting the (GPU) Manual screen centering X setting, but this does not change the resolution in any way, only which part of the image is being cropped. I've tried looking for any other options related to the display resolution but have not found anything else relevant.

I have the Settings -> Video -> Scaling -> Crop Overscan (Restart required) feature disabled, but this likewise does not allow me to see the full 384-wide image in games that run in that mode.

Incidentally, if there isn't currently a way to enable 384-wide display that I've missed, the above setting would be the ideal place to implement the optional cropping down from 384 to a lower resolution. Overscan is most of the reason for cropping the 384-wide mode, so it would make sense here. But I don't think anybody would be terribly concerned to find it in Core Options instead, as long as it's available somewhere.

EDIT: I was just informed in the RetroArch Discord that the Scaling -> Crop Overscan setting is deprecated, so Core Options would indeed be the ideal place for such a setting.

Big nerd stuff

To nerd out a bit (I wasn't already?) the PlayStation resolutions each have different timings to adjust how wide they appear on-screen. Most of the widths use a timing which results in them displaying the same width on screen--hence why games that use the 256-wide mode display with the same width as games in the 640-wide mode even though one is more than double the other in resolution. This is also how games are able to switch between horizontal resolutions at runtime (e.g. when opening/closing menus) without the picture changing in shape.

The one exception to this is the 384-wide mode. The timing in this mode is not proportionate with its resolution, which is an annoying way of saying "It displays wider than any other video mode." Below I'll chart out an approximation of the video modes and their aspect ratios by accounting for the pixel clock frequencies which determine how long each pixel is sampled when generating analog scanlines (i.e. how wide each pixel should look on-screen and therefore how wide the entire image appears). Told you I was gonna nerd out.

For this table, we will assume that all games are running at 240p, no 480i here. The final aspect ratio is the number of pixels (256 to 640), multiplied by their pixel aspect ratio, divided by the vertical resolution (240). The final aspect ratios also hold for the 480i modes, as the PAR width is doubled at the same time as the vertical resolution is doubled.

| Horizontal Width | Dot clock rate | Pixel aspect ratio | Resulting aspect ratio | |:-:|--:|--:|--:| | 256 | 5.37 MHz | 8:7 or 1.14 | 256 * (8/7) / 240 ≈ 1.22 | 320 | 6.71 MHz | 32:35 or 0.91 | 320 * (32/35) / 240 ≈ 1.22 | 384 | 7.67 MHz | 4:5 or 0.80 | 384 * (4/5) / 240 = 1.28 | 512 | 10.74 MHz | 4:7 or 0.57 | 512 * (4/7) / 240 ≈ 1.22 | 640 | 13.42 MHz | 16:35 or 0.46 | 640 * (16/35) / 240 ≈ 1.22

Even if you've never thought about "pixel aspect ratios" before, you have probably intuited that the higher the resolution gets, the smaller the pixels are, allowing for more detail. You can see this in the Pixel Aspect Ratio column, where the width of each pixel decreases (they get smaller) as the total resolution increases.

By the way, the page these pixel clock frequencies are sourced from also affirms 384 as the PS1's third horizontal width, if you wanted some additional support for the claim.

As you can see from the table above, the PS1's aspect ratio is usually 1.22:1 (slightly slimmer than 4:3 or 1.33:1). Note that these are approximations to 2 decimal places; feel free to plug any of the above into a calculator to get a more detailed figure. The 384-wide mode is the one exception to this, resolving to (exactly) 1.28:1, or about 5% wider than any other mode. This is most likely the reason why 368 was advised by Sony, as that brings it closer to the actual aspect ratio shown in other video modes: 368 * (4/5) / 240 ≈ 1.23

If you wanted to come even closer, you could go with 366: 366 * (4/5) / 240 = 1.22 (exactly)

By pillarboxing down to ~366-368 (i.e. displaying in 384-wide mode but putting black borders on both sides), games can toggle between 384-wide and any other mode without any jarring shifts in the visible width, because the active area remains about the same. However, not all games choose to perform pillarboxing, instead taking advantage of the entire 384 pixels available. There's two obvious downsides here:

Obviously, some games did not feel this was worth worrying about and preferred the increased resolution over the risk of loss to overscan and continuity of aspect ratio, especially for cases like Capcom CPS arcade hardware ports (like Street Fighter Alpha 3 and Strider) where the original hardware ran at 384*224 and simply running the game natively at PS1's 384*240 provides a closer likeness to the original game than adjusting down to a lower resolution.

tl;dr

The current behavior shouldn't go away, cropping the extra width is a valid option that may even be preferable in some games (mostly ones which toggle between video modes frequently), but it should certainly be possible to display the entire 384-wide image, as other games intended.

Technically, the core should also change how it reports the aspect ratio to the frontend, as it currently reports 4:3 which is not quite accurate to any of the video modes, but this is such a minor consideration for extremely big nerds (bigger than me) that it's probably not worth worrying about.

notaz commented 2 months ago

There is some truth in your wall of text but it isn't entirely correct. I'd say there isn't even a concept of horizontal resolution, PSX is much more flexible than that. Instead the programmer can specify the amount of clocks ticks of the GPU oscillator to output each line as the active display and choose a divider that specifies how many clocks of that oscillator a single pixel takes. Here is the oscillator in my SCPH5552 PAL console: psx_pal_osc As you can see it's 57.737MHz. The available dividers are 10, 8, 7, 5 and 4. The clocks setting typically used by games is 2560, so to put that in a table we get:

Divider Dot clock rate Pixels (2560/x)
10 5.77 MHz 256
8 7.22 MHz 320
7 8.25 MHz 365.7
5 11.55 MHz 512
4 14.43 MHz 640

Notice the 365.7 figure which is much closer to 368 than 384 (the hardware does some rounding but I'm unsure by how much exactly, nocash claims by 4), so I'd say the official docs are right. But as mentioned this is all very flexible and the games don't have to use the 2560 master figure and some don't. Street Fighter Alpha 3 uses 2688 which is the thing that gives your desired 384 pixel width, not the mode 7 (let's just call it that for simplicity, aka "mode with divider 7"). The games could use 2680 for mode10 that would equally give 268x240 (for example, height is also flexible) instead of 256x240, and that 268x240 in mode10 would take roughly the same width of screen as 384x240 in mode7.

Anyway there is now a new overscan option in the latest commit, try it to see if it does what you want.

vaguerant commented 2 months ago

Can confirm, all working exactly as expected in Street Fighter Alpha 3 and Strider. Tested the Auto, Hack and Off settings and all behave as intended.

Thanks so much for both the update and the correction. It's great to learn more about the fascinating PS1 hardware; it is way more flexible than I assumed! Thanks again.