xovox / RetroCRT

RetroPie on CRT! RetroTink, JAMMA, SCART & more!
GNU General Public License v3.0
44 stars 6 forks source link

RetroTink Ultimate RGB connector outputs horizontally squeezed video #37

Closed MiltosKoutsokeras closed 3 years ago

MiltosKoutsokeras commented 4 years ago

Hi and thank you for this project.

The setup I have a RetroTink Ultimate connect to a Raspberry Pi 3B+ and the output I use is the 15-pin RGB connector. I use the RGBHV instead of RGBS on the on-board switch, as the VGA to RGB SCART cable I got is not properly syncing the image when set to RGBS. The output is connect to a European PAL TV which properly supports NTSC, I use it with real NTSC hardware. I have updated RetroPie and then RetroCRT, following a reboot.

RetroCRT image: RetroCRT-20200108-rpi3.7z (latest in the time I write this)

The problem The output video does not fill the screen in any emulated machine horizontally, it has black borders left and right like huge overscan. I tried with the ROMs you have already in your image and I also tried real cartridges with the corresponding ROM. As expected, there is no difference. Attached screenshots are from a NTSC/J SEGA Mega Drive Model 1 and the corresponding emulator. Tested on both SCART enabled, NTSC compatible TVs I have and the behavior is the same. The output fills the screen when starting up in the intro video and while in the menus.

Configuration files config.txt retrocrt.txt

Screenshots

Main menu: Main menu

RetroCRT Real Hardware
Phantom Gear RetroCRT Phantom Gear MD
Shadow Dancer RetroCRT Shadow Dancer MD
Shadow Dancer RetroCRT Shadow Dancer MD
240p Suite 320x224 Grid RetroCRT 240p Suite 320x224 Grid MD

As you can see there is a noticeable and annoying difference. I wonder if this is not happening on US CRT TVs via Component YPbPr.

MiltosKoutsokeras commented 4 years ago

The problem lies within the RetroArch configuration generated by RetroCRT. All HDMI timings in $retrocrt_install/retrocrt_timings/rgb/15khz are for 1920x240@60Hz emulator output. So every emulator outputs at this resolution, while the RetroArch configurations have a narrower viewport width. See:

# grep -n 'custom_viewport_width' /opt/retropie/configs/*/retroarch.cfg
opt/retropie/configs/all/retroarch.cfg:910:custom_viewport_width = 1920
opt/retropie/configs/arcade/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/arcade/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/atari2600/retroarch.cfg:7:custom_viewport_width = 1680
opt/retropie/configs/atari2600/retroarch.cfg:13:custom_viewport_width = 1680
opt/retropie/configs/atari5200/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/atari5200/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/atari7800/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/atari7800/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/atarilynx/retroarch.cfg:7:custom_viewport_width = 960
opt/retropie/configs/fba/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/fba/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/fds/retroarch.cfg:7:custom_viewport_width = 1792
opt/retropie/configs/fds/retroarch.cfg:13:custom_viewport_width = 1792
opt/retropie/configs/gamegear/retroarch.cfg:7:custom_viewport_width = 960
opt/retropie/configs/gba/retroarch.cfg:7:custom_viewport_width = 1440
opt/retropie/configs/gbc/retroarch.cfg:7:custom_viewport_width = 960
opt/retropie/configs/gb/retroarch.cfg:7:custom_viewport_width = 960
opt/retropie/configs/mame-libretro/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/mame-libretro/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/mastersystem/retroarch.cfg:7:custom_viewport_width = 1536
opt/retropie/configs/mastersystem/retroarch.cfg:13:custom_viewport_width = 1536
opt/retropie/configs/megadrive/retroarch.cfg:7:custom_viewport_width = 1792
opt/retropie/configs/megadrive/retroarch.cfg:13:custom_viewport_width = 1792
opt/retropie/configs/msx/retroarch.cfg:3:custom_viewport_width = 1920
opt/retropie/configs/msx/retroarch.cfg:9:custom_viewport_width = 1920
opt/retropie/configs/n64/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/n64/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/neogeo/retroarch.cfg:7:custom_viewport_width = 1792
opt/retropie/configs/neogeo/retroarch.cfg:13:custom_viewport_width = 1792
opt/retropie/configs/nes/retroarch.cfg:7:custom_viewport_width = 1792
opt/retropie/configs/nes/retroarch.cfg:13:custom_viewport_width = 1792
opt/retropie/configs/ngpc/retroarch.cfg:7:custom_viewport_width = 960
opt/retropie/configs/ngp/retroarch.cfg:7:custom_viewport_width = 960
opt/retropie/configs/pcengine/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/pcengine/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/psx/retroarch.cfg:7:custom_viewport_width = 1920
opt/retropie/configs/psx/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/sega32x/retroarch.cfg:7:custom_viewport_width = 1792
opt/retropie/configs/sega32x/retroarch.cfg:13:custom_viewport_width = 1920
opt/retropie/configs/segacd/retroarch.cfg:7:custom_viewport_width = 1792
opt/retropie/configs/segacd/retroarch.cfg:13:custom_viewport_width = 1792
opt/retropie/configs/snes/retroarch.cfg:7:custom_viewport_width = 1792
opt/retropie/configs/snes/retroarch.cfg:13:custom_viewport_width = 1792
opt/retropie/configs/virtualboy/retroarch.cfg:3:custom_viewport_width = 1920
opt/retropie/configs/wonderswancolor/retroarch.cfg:3:custom_viewport_width = 1344
opt/retropie/configs/wonderswan/retroarch.cfg:3:custom_viewport_width = 1344

Emulators for machines that use 1920 width are not having the black borders and fill the screen, with a lot of overscan of course in most cases. For example the PC Engine fills the screen, while SNES, Mega Drive, Sega CD and NES have squeezed picture.

I can see 2 main problems here:

The first one may be a limitation of RetroTink Ultimate hat, but the second seems like a software BUG. The ideal solution is to produce a signal that is an integer scale of the original horizontal dot count (e.g. 320 or 640 or 960 and so on for NTSC Mega Drive), an exact match of vertical number of scanlines (e.g. 224 for NTSC Mega Drive) and exact vertical refresh rate (e.g. 59,92Hz).

MiltosKoutsokeras commented 4 years ago

Quick fix for current setup: manually edit the files and set every machine custom_viewport_width = 1920.

xovox commented 3 years ago

the reason why it's this way is to have an actual 4:3 image displayed.

I keep a 60hz 1920x240@60 display so i don't have to recalibrate my CRT every time a new resolution & refresh is required by a platform. these games look perfect on my arcade cabinet & my RetroTink Ultimate on Panasonic CRT because i've calibrated both to have a 240p game fill the screen. everything else will have bars.

actual hardware makes allowances for uncalibrated hardware & will expand the image past the screen's boundaries

retroarch's different widths are based on native vertical resolution percentages vs 240p.

so, if a game's vertical resolution is 80% of 240p, then i calculate and set the horizontal resolution to be 80% of 1920, which will keep an authentic 4:3 aspect ratio.

there's a "fix" for uncalibrated displays coming at some point, i'm going to have an alternative 224p mode that'll probably make you happier.

i won't work on the 60hz stuff, i don't have time in my life for it. if someone else comes up with a good solution, i'll implement it in my project.

MiltosKoutsokeras commented 3 years ago

Hi and thanks for the reply. I know I'm quite late to the party but I want to discuss an important matter for your project. Aspect ratio is NOT dictated by the output signal in CRT screens. Never had, never will. The CRT will always try to display in physical screen aspect ratio, in most cases 4:3. Why is that? CRT screens do not care how many dots/pixels your signals contains in each axis. They only care about the signal timings in order to scan from top to bottom a number of lines. So a 1920x240@120Hz and a 640x480@60Hz or a 320x200@75Hz will be stretched to 4:3 by the screen itself.

There is no reason to calculate 4:3 or any other aspect ratio before output. The things that matter is the horizontal and vertical refresh plus the number of lines drawn. So the fix is to never re-calculate horizontal number of pixels when a system has 224 instead of 240 lines. Keep the Horizontal pixels in the range allowed by hardware and just change the number of lines drawn. This way all systems will have a filled horizontal axis. The matter of shimmering due to non-integer scaling is another matter but you should also try to make each axis have a 1x, 2x, 3x, ... number of pixels and never a fractional number.

The Vertical refresh frequency cannot be fixed in software according to my knowledge, it is a limitation of the RetroTink Ultimate. It operates on a strict modeline dictated in /boot/config.txt and all systems are either sped up, frameskipping or slowed down to match the modeline vertical refresh. This is completely wrong and I haven't found a solution yet.