Custom configs for CRT using the built-in composite out
Hi, this is my first post here but I've been a lurker since I bought my Raspberry Pi.
Since the Raspberry Pi has a built-in composite video out I was curious about using it to emulate retroconsoles on a CRT TV as intended but as the signal it produces isn't exactly as the emulated consoles it didn't looked very good.
That's why I decided to try and find a convenient way to achieve that without having to buy external stuff that cost more than the raspi itself.
As a second goal I also wanted to enable HDMI output without interfering with the CRT configurations.
The results are good for consumer TV's but I don't think it would be good enough if you want to use it on a high grade or professional CRT monitor (it is composite video after all).
Portable consoles are also supported
Vertical mode for arcade
- from github: https://github.com/Sakitoshi/retropie-crt-tvout
How to use
- Download and copy the contents of the github to your (preferably fresh) retropie installation through samba shares.
- Detailed instructions are in the readme of the github page.
PSOne games that use a horizontal resolution of 256px are blurrier that it should. I'm working on fixing this. A workaround is creating per game configurations for them with the tv-out_sharp shader instead of the regular one.Solved already (Jul 22, 2018). PSOne needs adjusts per game if the game in question doesn't run at a native vertical resolution of 240px (Metal Gear Solid, Crash games and Spyro games are among them). This is because lr-pcsx-rearmed always reports a resolution of 320x240 and the overscan is always cropped.Fixed with a new shader that can detect the resolution and add overscan accordingly. The shader was also added to the PC configuration for the nature of that system (Jul 25, 2018). I'm unable of supporting WonderSwan/Color because of how that system alternates between vertical and horizontal mid-game. Custom configurations and rotation don't play nice on Retroarch.Lies, added support for WonderSwan/Color, it isn't perfect (only supports pixel perfect without border) but the rotation works like a charm (Jul 26, 2018).
- Added support for borders for WonderSwan/Color (CRT only, HDMI only has pixelperfect mode) (Jul 29, 2018)
- Better configuration for Neo Geo, it should look more like the real thing (Jul 29, 2018).
- Improved adjusts for all home console systems to center the image properly (Jul 29, 2018).
- Added support for Atari 8bit machines (8bit family computers, 2600, 5200 and 7800)(Aug 3, 2018).
- Added support for Sega sg-1000 and improved Master System, Arcade and Gamegear settings (Sep 4, 2018).
- Added support for Nintendo 64 (standalone mupen64plus was already working without modifications, but the libretro needed a config), improved PC Engine settings (highres games now display correctly and mednafen supergrafx is now officially supported) and fixed bug with ports ignoring 480i forcing (this allow kodi to boot in 480i, more info at the github readme) (Sep 5, 2018).
- Improved adjusts for Neo Geo and little adjust to the scaling shader of PC Engine (Sep 8, 2018).
- Greatly improved visualization of runcommand on 240p while maintaining high resolution for retropie-setup on 480i. updated all configurations to comply with changes made in retroarch 1.7.4 and onward (aspect_ratio_index from 22 to 23) (Oct 31, 2018).
- Added support for Nec PC-9801. also some slight adjusts to PC, Cave Story and runcommand (Feb 5, 2019).
- Added support for Colecovision, Intellivision and MSX (Feb 6, 2019).
- Super Gameboy borders are now used instead of the generic one when using mgba, if the game has no border the generic one is still used (Mar 21, 2019).
- Fix for EmulationStation overscan issue (Apr 18, 2019).
- Vertical mode for arcade is here. also some slight corrections for genesis low res and neogeo and shader preset clean up (Sep 9, 2019. happy Cirno day!).
- Added support for ZX Spectrum (Sep 23, 2019).
- More optional enhancements for arcade (Oct 6, 2019).
Interesting. I'm back on RGB at the moment but might try it out in a few months if I get back to my Composite setup.
Did you use the shaders from this thread https://retropie.org.uk/forum/topic/11628/240p-and-mame-scaling/12 or write your own?
@youxia not my own shader.
I used the tvout shaders that come with retroarch, but as those don't work on the raspberry pi. Investigating a little I found out that if I converted the cg version of it to glsl (using cg2glsl python script) it worked, so I used that and modified it a little to fit my needs.
I remember seeing those shaders you mention, but don't work as I need.
@youxia the shaders I'm using add slight blur.
in order for the image to look good on a regular crt the signal needs to be lowres, the problem is that the raspi sends a composite signal too clean to look good, so I need to mangle it a bit. the raspi sends a 720x480 image even on 240p mode, it just skips drawing every other line to make a 720x240 image compatible with the 240p signal, 720 is more than double the horizontal resolution of any retro console (even accounting overscan), so no wonder the image is so clean and high res and while crt's really don't care about horizontal resolution, if I don't do that it generates horrible rainbow banding (disable all shaders and play earthworm jim 2 on ps1, load the level villi people and you'll see it or play a match of the king of fighters 2000, the depleted part of the health bars use a checkerboard pattern for transparency).
you may be wondering "why not just set the screen resolution to match every console?", the answer is you can't. while you can change the resolution it needs to maintain the 3:2 ar and the raspi will scale it to 720x480 using a linear filter before output no matter what, that would blur the image vertically and we don't want that. besides that having a 480 tall image is more beneficial for those games that use 480i mode.
This solves 95% of the lingering issues I had setting up my CRT. Thank you! I just need to recall how I fixed the screen flicker in ES (started fresh, been awhile since I did anything with RetroPie through a CRT).
@sakitoshi You seem to be knowledgeable in this subject and I respect all your hard work, I do however have objections regarding any kind of added blurring. I'm not an expert myself but I have been fighting this for a very long time and tried various solutions on various TVs. With composite, I have been using @ghogan42's shader - it works really well in SNES for example. There are indeed some colour artifacts in Megadrive and some other machines such as ZX Spectrum though I'm not sure if these were not the fault of the NTSC TV I was using. I also recall struggling with PC Engine scaling. But, again, this might have been the fault of my configs.
Would it not be possible to combine your methods with @ghogan42's somehow for better results? Blur is really unwelcome, for me at least, this is why I do not use bilinear filtering, which is one of the lesser methods of dealing with composite connection. I'd like to see how severe it is using your setup but for the next few months I will be using strictly RGB. Then probably back to composite, a new good solution would be most welcome.
- support for wonderswan/color with border added for crt.
- improved configuration for neogeo, it should look more accurate to real hardware now.
- better centering for all the home console systems.
@youxia I get what you mean, but to get a good picture out of a crt tv having low resolution is essential because those screens aren't designed to handle images as sharp as the rpi can output and artifacts happen. the shader I'm using does the color correction and only blends the image horizontally just the right amount depending on the input, I modified it to calculate how much blending needs to be done and s/nes and other 256px wide systems look really sharp because the blur applied is minimal while 320px wide systems are blurred just a little more to eliminate artifacts while maintaining a clean image and some hours ago I updated it to apply a little less blur to 304px wide neogeo games, think of it like using the sharp-bilinear shader but for crt. the main problem is that I cannot change the timings of the composite out on the raspberry pi so a shader to deal with resolution differences is needed, but as the rpi outputs 720 horizontal pixels is kind of like using a super resolution.
I do not own all the consoles I'm supporting with my configs, but most use the same video modes so if I do one the configurations for the others are almost the same. I have only
verified SNES (via a wii and a retroduo, my snes died), Genesis (wii using genesis plus gx) and neogeo (wii running virtual console), I'm yet to 100% verify playstation (via a ps2 fat 50001) but it looks very good from some quick tests.
pc engine is a tricky system because it has a wide range of resolutions, I don't know if my configurations are correct, I could verify it with my wii but I'm not 100% sure if that system virtual console runs exactly as the original console like the others, but looks pretty good at least.
you can replace the tvout shader with the iq shader and see how it looks, I haven't tried it, maybe it looks good, but I prefer to stick with my shader for the reasons I explained above.
@jcook84 ES flickers because is using 480i mode to have better visibility. 240p can be used there but is hard to read that's why I left it that way.
@sakitoshi Yep, I see what you mean. It's a bummer about that 720p output from Pi. I guess minimal blur is not a problem for most people but I do have a bit of an OCD when it comes to that and any other artifacts non-native to the CRT set itself. That's why I don't really use shaders and actually don't emulate anything apart from test purposes on my PC. I will give it a go in a couple of months when I'm back to my composite TV set, see maybe it's within my tolerance zone after all. I t definitely would be nice to have an uniform solution... Your setup is missing all the microcomputers though, these are still popular in some quarters.
Wish @ghogan42 was still around maybe he or others who use that iq shader could chime in, regarding these colour banding artifacts.
- Added support for Atari machines (8bit computers and consoles).
I'm not able to test if the configurations are true to the original consoles as I don't own any and don't know of any port or emulated collection that display them as the real consoles do like wii virtual console. one of my cousins had an atari 800xl and loaded games by cassette but that was centuries ago, I was probably 4 or 5 so I barely remember how they looked on a tv, a b/w tv btw because the adults used the color tv so we only had the b/w tv available to play (or maybe it was because of that silly belief that color tv's could be harmed if you connected video games to them).
@sakitoshi Sorry if this is a "sacrilegious" question since the amount of work you have put into this is beyond laudable, but is there a "vanilla" or "Stripped down" way to do this without shaders? Meaning, is anything else in the settings and cfg files that you have provided made impossible or non functional (as opposed to simply worse looking subjectively) if shaders were left out?
I ask, because like another poster further up I also dislike blurring effects, and also am using dispmanx driver for latency reduction, but am keenly interested in using the resolutions and positioning that you've worked really hard on here.
@rc_cola I haven't tested but you can always try how good it looks for you, AFAIK the shaders will be simply ignored while using dispmanx.
the shaders don't blur the image per se, they just blend the pixels just enough to compensate for the incorrect resolution, just like upscaling 720p to 1080p but only in the horizontal axis, the vertical is pixel perfect. the horizontal resolution isn't as important as the vertical on crt tv's.
there are 3 cases where there is a shader that also handles the vertical scaling: arcade, pc and psone. those systems have a range of resolutions and the shader detects it and centers the image perfectly.
portable systems will also suffer a little, the pixel perfect mode should work fine (albeit with the same horizontal scaling issues than the rest), but the fullscreen configuration will look absolutely terrible and wonderswan/color will probably have an incorrect aspect ratio while rotated.
TL;DR it should work but not as good.
EDIT: just tested and no, it doesn't work as intended.
dispmanx disables all the scaling altogether (except for the horizontal scaling using the aspect ratio setting strangely enough), the video is forced to be displayed at 480 instead of 448 causing uneven scaling. all that for a measly frame which is pretty much already gained by using a crt tv without converters.
new TL;DR dispmanx causes more bad than good, do not use.
@sakitoshi I confirmed the same thing myself. Abandoning any hope of using that.
Thanks for the reply.
One more quick question: If I do a safe, fresh install of your settings and want to change exactly two things universally across all systems in retroarch.cfg, what is the "safe" way to do it without generating another .cfg file that unintentionally might create problems with the individual system retroarch.cfg sets that you have made?
Here's what I would like to do:
Universally in /configs/all/retroarch.cfg
audio_out_rate = "44100"
video_threaded = "false"
audio_driver = "alsa" (seems to have started with alsathreaded for some reason?)
input_polling_type = "0" (aka "Early" input polling. Still playing around with this one)
Also specific to 8-bit cores only (gb/gbc/nes) I wanted to add the following to each individual system /configs/[system]/retroarch.cfg:
video_max_swapchain_images = "2"
video_frame_delay = "4" (or lower if I see a performance hit)
When I first did a clean image install and then added your files, I strangely did not have a "real" retroarch.cfg file in the /all/ folder, just one that when opened was a skeleton file full of commented out descriptions and no actual settings. So from the ES main screen, I opened up the retroarch menu and made my tweaks above, but that generated a new file with ALL settings, not just the ones I had adjusted, and now I am a bit worried that some or all might be trampling on the individual core settings you so carefully crafted.
And thanks again for all your hard work. Even while tweaking this, I am already in CRT heaven.
@rc_cola you can add those lines at the end of the skeleton retroarch.cfg that comes with a fresh install or do the changes directly in es like you just did, it doesn't matter.
the per system settings (/config/[system]/retroarch.cfg) take priority over the general settings (/config/all/retroarch.cfg), so it doesn't matter what is set in the general settings, it will be overtaken by the per system settings but only if is set there.
- Added support for Sega sg-1000.
- Little adjusts to Master System, Arcade and Gamegear.
- Arcade Mortal Kombat series looks way better now.
- The aspect ratio of Gamegear was adjusted to be close to real hardware.
Sega sg-1000 was almost the only fully funtional console without configurations, the only one left would be N64, but since N64 runs poorly on the libretro cores and standalone mupen looks good enough without any special configuration I prefer focusing on other tasks instead. I guess I'll add support for libretro mupen soon since there is little left to do and improve.
When I created the configuration for Master System I was using other methods to get the measures, it was very good but kinda unreliable. Later I learned a better way to do it and Master System was a little off (by 2 pixels to be exact).
In the previous to last update I introduced a shader to deal with variable vertical resolutions, Arcade machines being very unique I applied that new shader to its config, but as I did just a quick test I didn't noticed that Mortal Kombat was among arcades that use such off-spec resolutions that even with the new shader it was a problem. Now with some numbers changed the Mortal Kombat series (and hopefully other arcade games) should look acceptable enough. I say acceptable because arcade monitors are very different than consumer tv's, so it will never be perfect.
As I've never seen a Gamegear in person I didn't knew that its screen didn't used square pixels and as such its aspect ratio wasn't the same as its internal resolution (which is 160x144, same as the gameboy). Doing some research I found out that its screen is actually very close to 4:3, so I did some adjustments to make it look close to like it should.
@sakitoshi Thanks again for all your hard work on this. I've had more fun with my pi in the last few days than ever before bathing in the warm x-rays of the old CRT...
Quick Question(s): As discussed in this reddit topic, any way to reliably fit Kodi as a media core into this setup, at the last perhaps any advice on reliably forcing it into 480i mode/output?
Also, despite what themes I try, the ES menus seem very chopped off even though the systems are very nicely aligned. Since the individual system .cfg take priority as I udnerstand it, can overscan be re-enabled in the /boot/config.txt just to align emulationstation on my TV, or somewhere else?
If nothing else I can leave it alone, of course, but it seems that even on themes that are designed for 4:3 like pixel-tft (to my understanding anyway they are designed that way, I haven't changed anything in terms of the .xml files and resolutions), the help buttons and some of the screen are still chopped off on the sides and bottom mostly on my TV.
chipsnblip last edited by chipsnblip
regarding the es menu, i think the best course of action is to create/modify a theme (e.g. gbz35-dark) specifically for smaller screens. i'm currently in the process of doing so for my 13" CRT which has rounded bezel corners, so i just have to cram all the elements in:
(quick image to demonstrate)
it's going to take time, but that's part of the fun as you say :)
- fixed pc engine games that use highres mode not displaying correctly.
- along side that tested mednafen supergrafx and it works fine with the new config, so it's safe to use it.
- added nintendo 64 support.
- fixed ports ignoring the 480i.txt override (this allows kodi to be displyed at 480i if you add a 480i.txt in the kodi config folder as instructed in the updated readme at github).
@RC_Cola sorry about the kodi thing, I barely use it and when I do is on an hd tv so I didn't noticed.
the overscan cannot be changed at run time and adding overscan to display emulationstation centered will break all the configuration, so it's a choice your poison situation, have a centered es or accurate console display emulation.
themes taking overscan into account would be the only solution, but I don't know how taxing would be for theme creators to create that variant or if it is posible to easily modify personally any theme to do it. but since a wide variety of themes have most of the information at the center I don't think that it is a big problem.
- neogeo now uses a scaling shader like pc engine.
- several now unnecessary files removed from the neogeo config folder. be sure to remove the "FB Alpha" folder inside "config_crt" (or the whole "config_crt" folder if is the only thing inside) in your neogeo config folder.
- updated pc engine shader because of an (almost imperceptible on crt) uneven scaling issue.
A small update with little visual benefits really, but helps maintain things clean.
Neogeo uses 2 resolutions and I created profiles for the games using the 320 px wide mode (those were less numerous, so less files to create), with this scaling shader those profiles became useless so it's safe to delete them, it shouldn't hurt leaving them there for now at least, but you'll only be wasting space (2808 bytes is nothing to scream about though).
@chipsnblip That makes sense. I found the main GitHub page here for creating my own theme, but what setting where would I modify if my sole intention is to take an existing theme like pixel-tft and make it fit RE: the grid like you showed above? Is there a "universal size" adjustment to make to an existing theme setup that works in an overscan-esque fashion like that?