libretro / fuse-libretro

A port of the Fuse Unix Spectrum Emulator to libretro
GNU General Public License v3.0
36 stars 46 forks source link

Support native resolution output #137

Closed cyberluke closed 1 year ago

cyberluke commented 1 year ago

Windows 10 - AMD CrtEmuDriver

Resolutions in Windows 10: 320x240 256x224 256x192 (this should be native ZX Spectrum resolution) 248x192 240x192

What part can I change in the code to run in 256x192? Now it always runs in 320x240 on 15Khz CRT (Sony PVM) and messing with video border does not help - it scales in a ugly way and stretches horizontally so square image is not square anymore.

Found something here: https://github.com/libretro/fuse-libretro/blob/330655e4735ce2ace887dcc641a837fb5747d47f/src/compat/display.c https://github.com/libretro/fuse-libretro/blob/d019e96922f631cb3a99eeb95059df437c4bba78/src/libretro.c https://github.com/libretro/fuse-libretro/blob/330655e4735ce2ace887dcc641a837fb5747d47f/fuse/ui/svga/svgadisplay.c https://github.com/libretro/fuse-libretro/blob/330655e4735ce2ace887dcc641a837fb5747d47f/fuse/ui/sdl/sdldisplay.c

cyberluke commented 1 year ago

Ok, so I enabled debug and have some screenshots: Full Border will have 320x240 fuse_resolutions_full_border

cyberluke commented 1 year ago

Minimal border will have 264x198 fuse_resolutions

cyberluke commented 1 year ago

Finally no border will have 256x192 and I have that super resolution defined as well. But the behavior or aspect ratio is not correct.

fuse_resolutions_no_border I'm uploading real photo from iPad down below

cyberluke commented 1 year ago

81B0C1C3-5510-47C5-8CF8-B58628EB7D18 B6A76D20-3C0F-4E37-B960-1BF3A65E09F7

Here is the problem, 256x192 (no video border option). Should not have top and bottom border and left and right stretched. This changes the pixel aspect ratio.

Currently I’m using Spectrum 48K NTSC bios because I want 60hz, but I tried also 50hz PAL bios. TV can handle both.

cyberluke commented 1 year ago

The same issue happens when not using super resolution 2560x? but in RetroArch setting CRT SwitchRes to NATIVE

Now it seems to switch to 256x192, but the output is still exactly same as on TV screenshot above.

Log output: fuse_resolutions_crtswitch_native

hizzlekizzle commented 1 year ago

Are you sure that's not working as intended? All of the debug info looks like it is, AFAICT.

cyberluke commented 1 year ago

Yes, judging by the console logs, it looks ok.

I don't have much experience with gaming on TV. This Sony PVM probably supports only 240p and 480i. I can switch to other resolutions, but only 240p scanlines do look good. The scanlines do not change when using any other resolutions (I thought it would).

So the question is: What TV or CRT monitor would natively display this 256x192 including scanlines? Was it that no TV supports this resolution? And people were using some cheap TV via RF antenna cable and just stretch it using TV knob? I had Didaktik Gama clone in Czechoslovakia as a kid.

One last note: So if we take into account that on real photo of the TV above, it will switch to 2560x192 super resolution (remember I tried also 256x192 native resolution and it was exactly same), but TV in fact does still 320x240. Then I would understand the top and bottom border, because height 240-192 = borders and that make sense. What does not make sense if we apply this logic to width: 320-256 => then we should see borders on the sides as well. But the width is stretched to the edges and you see the aspect ratio is not 256/192=1.3. The aspect ratio is more like 320/192=1.6. While, as a software developer, I agree there is nothing visible in the logs, there is something fishy going on somewhere on the way. I read that RetroArch would have some hardcoded limit of 200p minimum resolution, but I could not verify that.

For a newbie, it would be good, if it would be documented that video border is actually changing output resolutions and to list what they are (in the docs).

cyberluke commented 1 year ago

And the reason why I posted it here is that all other RetroArch emulators do display properly on this exact configuration: Amiga PUAE: works correctly (both PAL and NTSC) NES: works correctly SNES: works correctly RetroArch DOSBOX: works correctly (tested JazzJack Rabbit and Duke Nukem 3d in 320x200)

Only Fuse with 256x192 does not produce the correct result.

cyberluke commented 1 year ago

The issues are due to tech debt in RetroArch. Not implementing SwitchRes properly, using outdated implementation and/or not providing switchres.ini by default.

On top of that, Sony PVM is the gold standard and almost everyone, who does emulation with CRT gaming has one. It is the most common monitor for 15kHz. It should be finally supported and tested.

Sources: https://forums.libretro.com/t/force-custom-native-resolution-in-retroarch/39030/11

and here - confirmed by other users: https://forum.batocera.org/d/5865-scaling-all-games-properly-with-retroarch-on-a-crt-tv-screen/2

Here is outdated LibRetro documentation about Switchres confirming there is a tech debt and bugs: https://docs.libretro.com/guides/crtswitchres/

cyberluke commented 1 year ago

I found the bug and solution. Switchres is by default using monitor setting: 'arcade_15'

Which results in this: [INFO] Switchres: Modeline "704x576_50i 15.677190KHz 50.006985Hz" 14.344628 704 733 800 915 576 583 589 627 interlace -hsync -vsync

If you create switchres.ini (from the doc link) and set monitor to 'pal' It will use this modeline and it will work: [INFO] Switchres: Modeline "704x576_50i 15.625000KHz 50.000000Hz" 13.531250 704 724 788 866 576 582 587 625 interlace -hsync -vsync