Saturday, March 29, 2014

TVs and Retro Gaming / Emulation

INTRODUCTION

Retro gaming is a hobby of mine and, as I started looking into hooking my retro consoles up to modern displays, I found a bunch of incomplete information and dead links scattered among various enthusiast forums, along with misunderstandings and oft-repeated misinformation. So, after diving down the rabbit hole and exploring a bunch of different options, I decided to post my findings in the hopes of saving others from making any costly, avoidable mistakes.

THE ISSUES

I have a big LCD HDTV with a HTPC connected that I use for watching videos and playing emulated games, and I can use various shaders to achieve an aesthetically satisfying approximation of how my retro games looked on CRT TVs. However, there are a number of reasons to use the real hardware instead of emulation, such as emulation accuracy deficiencies--which can render some games unplayable or unenjoyable--and/or latency concerns.

Sadly, modern displays like my HDTV make retro consoles look like absolute crap and can create/exacerbate latency issues, as they recognize the consoles' double-strike/"240p" signal as 480i(nterlaced)--and rightly so, since standard NTSC signals are always 480i regardless of how they're presented; the 240p standard was not created until decades later and even then it wasn't referring to the signal from retro consoles--and attempt to deinterlace them. This adds at least 1-2 frames (16-32 ms) of latency as the deinterlacer tries to combine 2 sets of fields to create a full picture, and that's before the signal even reaches the TV's upscaling circuit, which then adds even more latency (how much is added by the scaler can vary wildly from display to display).

To avoid this whole mess, we have a couple of options:

DIGITAL VS ANALOG

If you really want to use your big, digital HDTV but want to minimize latency, you'll want to sidestep the deinterlacing/slow-scaling issue by plugging your console into an external line-doubler/scaler. The cadillac in this area is the XRGB-Mini Framemeister, which is a Japanese import and costs an arm and a leg (about $475 at the time of this writing). This sexy lady will take your "240p" input, double the lines to a true progressive signal and then upscale it to an HD resolution that gets piped to your HDTV via HDMI, all essentially laglessly (it adds ~1.5 frames of latency according to Fudoh from the shmups forum). It will even add in a scanline effect, if you want. If, like me, you don't have $500 to piss away on this sort of thing--awesome as it may be--there are some cheap Chinese boxes that can handle the upscaling and deinterlacing (but not the scanline effect) at a slightly lower quality and substantially lower price. This seems like a good compromise to me, though the loss of scanlines is unfortunate. However, if your upscaler has a VGA output (like these) and your HDTV also has a VGA input, you can put a separate scanline generator, like the SLG-3000 or Toodles' T-SLG, in between and get close to the same quality as the XRGB-Mini for much cheaper.

Another consideration, though, is that the XRGB-Mini also accepts RGB/SCART signals (see the 'Analog Signals' section below for more details), while the cheaper models like the one linked above only accept composite and S-video. :(

UPDATE: I actually did purchase an XRGB-Mini recently and it's beautiful. I highly recommend it and think it's well-worth the money for an enthusiast.

It's also worth noting that any of these upscalers will give you an extremely sharp picture, similar to what you get from unfiltered emulation with nearest neighbor scaling (i.e., super-sharp/pointy pixel edges), so this option is ideal for the pixel fetishists out there but may not be desirable to old-schoolers who grew up playing on crappy little CRT TVs.

If you chose to go the digital route, congratulations: you're done! Your upscaler is providing you with the finest picture available. However, you might still want to read the rest of the information here, as some of it may be useful to you anyway, particularly the parts about analog signal quality.

Personally, those digital, super-sharp pixels never looked good to me. I'm a big fan of the way CRT TVs look and how they handle those low-res images, so I am/was forced to purchase an analog CRT. Even on an old analog display, though, we still want to keep our picture as nice as possible, which brings us to our next concern:

ANALOG SIGNALS

As far as analog signals are concerned, the top of the heap is RGB, meaning you get an isolated signal for each color, which provides a crisp, clear picture when they're all combined. Just below that is S-video, which separates the luma signal (brightness information only; produces a black and white picture) from the chroma (color; R, G and B all together) signal so they don't interfere with each other. Far below that we have composite--the familiar yellow RCA jacks--which combines chroma and luma into a single signal where interference between the two (known as chroma/luma "crosstalk") significantly degrades the picture. Slightly below composite(!), we have RF, which takes the signal and encodes it into the same format used in over-the-air broadcasts (and you know how good those tend to look...). You can compare how these signals differ in quality by loading up an emulator with Blargg's NTSC filter, which has presets to emulate RGB, S-video, composite and RF.

MATCHING INPUTS TO SIGNALS

In the USA, high-quality inputs, such as component and S-video, are not commonly found outside of large (24" and up), high-priced televisions, such as Sony's Wega line, so if you have a big house and plenty of room (and a strong back), you'll probably want to go for a real hoss of a TV with plenty of inputs. Sadly, most small CRT TVs have only coaxial/RF and *maybe* composite/RCA, which means your picture will always look pretty crummy. I lucked out and found an Apex 14" model with an integrated DVD player that also has S-video, which is good enough quality for me, so my retro consoles are now covered.

If--like me--you are satisfied with the quality of S-video and will only be hooking retro consoles up to your analog CRT, congratulations: you're done! If, however, you are a super-picky "videophile" and you think S-video is only fit for unwashed plebs and/or you want to hook your PC up to your CRT, there's more to consider:

THE MANY FACES OF RGB

Within the RGB family, there are about a million different subsets that each serve their own purpose. For TVs in the USA/NTSC world, we have "component" video (terrible, vague name, btw), which is also referred to by the color space it occupies, YPbPr. For PCs, we have VGA, which uses the familiar--typically blue--15-pin connector. For European/PAL-land TVs, we have 21-pin SCART.

Note: Europeans are lucky enough to have SCART as a standard input for CRT televisions, and many retro consoles--SNES, for example--can output this standard directly. This is a pure RGB signal and will provide the cleanest, most crisp analog picture around. HOWEVER!!, Japanese SCART (also known as JP-21 pin) and European SCART have a different pinout and, as such, are not compatible, even though they have the same connector. If you want to use a Japanese/NTSC JP-21 pin cable with a European/PAL TV with a Euro-SCART input, you will need a pin converter like this one. The aforementioned XRGB-Mini, as a Japanese device, does not require such a converter.

Aside from SCART, it's generally pretty difficult to get RGB from retro consoles, but it's usually possible if you're determined enough.

Now, even though all of these signals and connectors are technically RGB, they are incompatible with each other due to differing sync methods and signal frequencies, which means you'll need a display that is compatible with the signal and has jacks available. This brings us to:

15 KHZ VS 31 KHZ DISPLAYS

One of the major limiting factors in a CRT is the horizontal scan rate, which is the frequency at which a display can move the electron gun from the left side of the display to the right and back again. CRT monitors, like the kind you would find attached to a crummy old Packard Bell computer, have a high horiz. scan rate of 31 kHz, while NTSC TVs have a comparatively low scan rate of 15 kHz. Furthermore, devices that expect the high scan rate of 31 kHz displays and send a high-resolution signal are not compatible with--and can actually damage--displays with the lower scan rate if connected. On the other hand, 31 kHz monitors can be coaxed into displaying a "240p" signal using driver hacks like CRT_EmuDriver or xrandr and/or custom xorg.conf modelines (for some excellent info on getting 240p in Windows, see Monroe88's comments after the post). This will produce the highest-quality image possible with an emulator:


The drawback to this setup is that each system you want to emulate needs to render in exactly its native resolution or else it looks like shit, with misshapen pixels and inconsistent scrolling everywhere. The specialized Groovy Arcade distro automates some of this, but you may still have to use your monitor's hardware calibration controls to get the image to fit/center properly. I found the constant tweaking to be a tremendous pain in my ass and not really worth it.

If you're in linux, here's how you can force your monitor to act like an NTSC TV (type into a terminal from an X-session desktop):
xrandr -q
This will tell you which display you're using and which modes are available by default. My display was hooked up to DVI-0 via a DVI-to-VGA adapter.
xrandr --newmode "240p" 5.979 320 332 368 380 240 242 246 263 +CSync
xrandr --addmode DVI-0 240p
(replace DVI-0 with whatever your card reports)
xrandr --output DVI-0 --mode 240p
Some older video cards (like my Radeon X600 pictured below) for PCs will have an S-video output next to their conventional VGA and/or DVI outputs, which allows them to connect directly to a standard 15 kHz TV with S-video input:

This is very convenient, but it comes at a price: the card presents an 800x600 resolution to the PC and then crunches that down to 480i (that is, a standard NTSC signal), and it *cannot* be convinced to do anything else under any circumstances (AFAIK). This output looks pretty good, but it's not nearly as crisp as the VGA 240p 31 kHz image, obviously:
On the other hand, it is only slightly worse than a direct S-video connection from console to 15 kHz TV:
While S-video will always be slightly blurrier than RGB, the 15 kHz display is simply not capable of producing an image as high-quality as the 31 kHz display's due to its lower resolution and larger, chunkier phosphors. If you have a TV with component/YPbPr jacks, you can use a VGA-to-component transcoder box--like this one--to keep a clean RGB signal from your PC to the TV. Since it's a 'transcoder,' you shouldn't suffer any signal degradation, ideally.

UPDATE (11/14/14): Here's a pic of a PC hooked up to a 15 kHz display (an arcade monitor, to be specific) via RGB:
The photo kinda sucks and doesn't really do it justice, but you can see that the space between scanlines is much less pronounced vs the 31 kHz monitor. There's also no NTSC color changes like you see in the S-Video shots, for better or for worse. Anyway, back to the original post...

Sometimes you want to use your actual retro consoles rather than emulating on a PC--particularly in cases where emulation quality is still relatively poor, such as Sega Saturn or Dreamcast--but you still want to get the highest quality possible, which brings us to:

BROADCAST MONITORS

Broadcast monitors are high-resolution CRTs that were used by video professionals, such as broadcasters and video editors, to preview high-quality signals during the production process. They cost thousands of dollars new but are now cheap as dirt (relatively), since those professions have moved on to digital/HD signals and formats. Sony's PVM and BVM series of monitors are the most well-known and sought-after among retro gamers and, as such, often command a higher price than some similar products from other manufacturers. Nevertheless, the *VMs and other similar broadcast monitors tend to come with a variety of high-quality inputs, including one or more RGB equivalents (though often with separate sync, which can require conversion from, say, SCART). Another nice thing about these monitors is that they tend to come with nice, flat sides, unlike most TVs, which allows them to be rolled onto their sides easily for TATE mode games, like shooters.

Broadcast monitors are available in sizes up to 30" or so, though models that large are extremely hard to find and tend to be quite expensive, even now, due to their rarity. They are also very expensive to ship, due to their weight, which means many of the auctions on eBay are local-pickup-only (and tend to be in California...). The smaller models of 20" or less are much more common, and can usually be had for between $200 and $300 dollars at the time of this writing. A direct RGB connection from a console to one of these monitors should produce a picture as glorious as the aforementioned PC-VGA-to-240p-31-kHz setup, only without the hassles of modelines, hacked drivers, etc. Unfortunately, I don't have such a monitor, so I can't share any pictures :(

In the cases of either the 31 kHz or broadcast monitors, I personally find the image to be a bit sterile and actually prefer the 15 kHz option. I have opted to use the S-video-out on my video card for the convenience it provides, and the quality degradation is only about as bad as choosing bilinear vs nearest neighbor scaling in an emulator (i.e., fine for me, unbearable for perfectionists and pixel-lovers).

UPDATE (4/13/2015): I recently picked up a PVM 20M2U 20" monitor and posted some closeup shots on this page. The picture is indeed awesome and actually sits somewhere between regular SD/CGA displays and high-res 31 kHz monitors in "sterility" and how crisp the scanlines render.

Anyway, here are some more PC-VGA-to-240p-31-kHz pics :D



Good detail shot of the scanlines and the black gaps visible between.
This is what happens to SNES pseudo-hires transparency (bsnes) for some reason :/








Some other considerations that I will add to this post soon: CRTs for 480p and higher consoles (PS2, Dreamcast, 360, etc.), 31 kHz at 1024x768 (shaders vs the real thing), I plan to add a decision-making flowchart with approximate costs at some point, as well.

22 comments:

GPDP said...

Per the need of having to tweak endlessly to get 240p working on CRT monitors, there is one catch-all solution that heavily cuts down on this: a superwide 240p resolution at 120Hz with black frame insertion. The great thing about CRT monitors is that they don't really care much about horizontal pixel count. As such, you can actually create a resolution such as 3840x240@120Hz, and the monitor will sync to it because it's still 31KHz. The benefit of this is that pretty much no monitor has a big enough dot pitch to resolve all the pixels in such an image, and thus scaling errors are unnoticeable. So instead of having to set a bunch of modelines for every resolution used by old games, you can just set one that will work with all of them without perceivable issues.

RetroArch in particular can make wonderful use of such a resolution thanks to its custom aspect correction options, as well as its black frame insertion support to effectively bring the image back down to 60Hz. The only downside to black frame insertion is that framerate drops become very noticeable. Also, games that use hi-res 480i modes won't work well with this.

An alternative method is to set a similar superwide resolution, but at 480p, and use a custom version of CRT-Geom to black out every other line, effectively achieving 240p. This method is nice in that it doesn't require black frame insertion, and has compatibility with 480i content. That said, it can be quite resource heavy.

All of this has been tested on Windows, by the way. A program such as Custom Resolution Utility can be used to create custom modelines, bypassing the need of hacky drivers.

Monroe88 said...

On a PC CRT monitor, the best way to get flawless 240p is to use an ultrawide resolution and scale output to fit that. If you use a very large horizontal resolution, your monitor's dot pitch will hide any scaling errors from non-integer scale factors, meaning you can use one output resolution for all games that output 240p at different horizontal resolution. This is especially useful for PlayStation games that can change output resolution on the fly, so setting an unscaled resolution will be impossible there without automatic mode changing. It will also let you use blur shaders more effectively if you want blending effects.

I use RetroArch on Windows for most of my emulation, so when I want to use one of these modes, I set the following in my config files:
video_fullscreen_x
video_fullscreen_y
video_aspect_ratio (set to 60.000 most of the time)
video_refresh_rate (set to x / y)
video_fullscreen = "true"
video_windowed_fullscreen = "false"

The last one is important so RetroArch won't just use your desktop resolution instead of your custom resolution. Before using the video mode, it has to be set in your video driver using your video driver's custom resolution function (or using ToastyX's Custom Resolution Utility to create an EDID override).

Some of the video modes I use on my 17-inch Dell dot mask CRT monitor:

3840x240 @120hz
video_aspect_ratio = "16"
This one doubles the refresh rate to compensate for the low resolution to keep the horizontal refresh at 31khz. You will need to either use frame doubling or black frame insertion on this one or else you get motion jitter. Set the follwing in your config file:
video_black_frame_insertion = "true"
or
video_swap_interval = "2"
but not both or it will run half speed. Black frame insertion will have smoother motion but will be half as bright, while frame doubling will be fully bright but will have double imaging on scrolling images. Unfortunately, this won't handle games that run in interlaced mode without downscaling them. For those I take a different approach.

---

3840x480 @60hz
video_aspect_ratio = "8"
This one will display 240p games with line doubling by default, but you can use 100% black scanlines to eliminate the extra scanlines. The image should be the same as it is using 240p 120hz with black frame insertion, with some very minor differences. You can use a scanline shader get the black scanlines, but if you want interlacing you'll need the CRT-Geom shader to do that. I've put together a modified CRT-Geom that will do this for 480p: http://www.mediafire.com/download/01bahm4mza1w3ar/interlacing_scanlines.7z When I use this, I get proper interlacing on 480i content (such as Tekken 3 on Playstation) and proper scanlines on 240p content, with seamless switching between the two (needed for several Playstation games such as Chrono Cross to look correct).

----

I sometimes use other modes for arcade games in MAME that run at different refresh rates (i.e setting 640x480p 57.551hz for DoDonPachi), and you can use the same ultawide resolutions on them if you have games that use different horizontal resolutions but the same refresh rate.

Monroe88 said...

I have some pics of different display modes in action on my CRT using RetroArch:

https://www.dropbox.com/sh/gvw08wlvbom5xyj/ECeJQRPUsR?lst

Hunter K. said...

Excellent information. I'll have to play around with some of those "super" resolutions to avoid having to mess with it all the time.

GPDP said...

After playing around with the superwide 480p+CRT-Geom solution a bit, I have determined it does leave a bit to be desired. It's very subtle, but because the custom shader does not 100% black out every other line, there is a slight "downward blur" effect. Furthermore, with superwide 240p resolution, I could slap Blargg's NTSC RGB filter on top plus regular bilinear filtering, and the result is phenomenal. On 480p plus CRT-Geom, adding bilinear filtering breaks the shader completely, and NTSC-RGB looks a bit crap without it IMO.

I'm thinking a new shader needs to be created, one which ONLY applies 100% black scanlines, plus ONLY the interlacing support from CRT-Geom.

Monroe88 said...

>adding bilinear filtering breaks the shader completely

Linear filtering works if you set the first stock pass to linear, and it will only apply horizontally.

Upon close inspection, it does have some instances of bleeding into the black lines, but I can only see it when I take a screenshot and zoom in or look really closely at the screen on a spot I know it shows up on. It's not really noticeable at all in regular use and is an acceptable trade-off to allow proper display of interlacing, at least until a simple scanline shader that can do interlacing is created.



GPDP said...

I'd imagine it wouldn't be a hard thing to do at all. Is there an existing simple scanlines shader that just completely blacks out every other line? It might be possible to just adapt the interlacing code in CRT-Geom to it if so. I know there's a bsnes filter that produces 100% black scanlines, which looks identical to true 240p, but a shader version would be ideal.

Hunter K. said...

Can you guys try this one?
http://pastebin.com/2SUuFaUG
It just checks to see if the height is > 400 pixels, and if so, assumes it's interlaced. If it is, it makes the scanlines oscillate with the framecounter.

Monroe88 said...

It didn't work correctly for me but I was able to figure out how to get it to work right

http://pastebin.com/xZKgndGu

On even frames, it behaves normally, on odd frames it is shifted down one pixel.
I had to spend some time tweaking brightness on interlaced vs progressive output, interlaced was too dark with the brightness settings used for progressive.

It only works correctly explicitly set to 2x scale, and for some reason needs a stock pass with no scale to display correctly.

Here's a cgp that make it work:

http://pastebin.com/yhUDazDb

It works great on my monitor @ 480p and the black lines are actually totally black this time.

Hunter K. said...

@Monroe88 and GPDP
Hey guys, got a new shader for you to try:
https://github.com/libretro/common-shaders/blob/master/misc/interlacing.cg
This one should provide 100% black scanlines on 240p content and will blank alternating fields on 480i content. Let me know how it treats you :)

Monroe88 said...

That one works good, it's more straightforward than the one I did.

Anonymous said...

Nobody noticing those scanlines in 31kHz "240p" are way too black and too wide, making the whole screen much darker than it should be.
The original SNES S-Video is a good look-out on how "scanlines" should look but really, you should compare some timt with true 240 p on RGB SCART, it's amazing and nothing comparable to this fake "240p" using VGA CRTs.

Monroe88 said...

It isn't dark at all if you boost brightness by maxing color intensity or some other option that doesn't compromise black levels. If that's not possible, you can just use true 240p 120hz with frame doubling, which retains brightness due to the raster scan actually being focused onto the scanlines.

If it's the scanlines being too sharp and defined, then that's due to the finer phosphor dot pitch monitors have compared to TVs. I don't really care for the ultra bloomy scanlines found on common CRT TVs anyway, I actually prefer the sharp and defined scanlines like you see on a Sony PVM/BVM professional RGB monitor. PC CRTs can get close to that quality or maybe even better with the right setup, and it's less painful to get working with emulation on PC (as well as being much easier to find in the first place).

Unknown said...

I have a mint condish 14" Sony PVM crt broadcast monitor ('03 model) up for grabs. PM me if interested.

Business Man said...

I recently acquired a CRT VGA monitor and a 27" Sony Trinitron CRT 15khz tv to play old arcade games. I first tried outputing 640 x 240 to the vga monitor at 120hz and while it produced an image, it looked terrible without the HLSL settings that I used on my lcd (minus bilinear filtering). The graphics lost a lot of detail and they were very blocky.. The main point is that this does not produce anything close to an authentic look. With the HLSL settings turned on, the look was passable but far softer and less detailed than the real thing. A 31khz CRT monitor is only a little better than an lcd with HLSL and just as bad without it.

The 15khz tv was a different story. I output the signal through an extron SRC 200 at 480i and the image on the 27" tv looks about the same as I remember it looking in the arcades. The thick black spaces in between scanlines that those Sony broadcasting monitors produce is not how games looked on real arcade monitors which were far lower quality and had far more bloom (which blurred a lot of the rough edges and visible gaps in the image). Arcade monitors use the same type of tubes found in regular tv's.

I could create a 240p 15khz image from my set-up with the addition of a $25 RGB interface but there is no point. I would be spending more to make the image worse.

My advice to anyone looking to get a great looking image from mame games, would be to pick up one of the Sony Trinitron tv's that people are literally giving away free on craigslist and use an extron scan converter to convert vga to tv out. Mine is hooked up via s-video and the image is far more detailed than is possible on the vga monitor.

I would try it at 480i before going to the trouble and expense of trying to output 240p. There is no noticable flicker on mine unless my nose is pressed up against the screen and if there was, my extron has settings to reduce it. The Sony trinitron tubes in their consumer tv's were already of a higher quality than those found in your average arcade monitor. There is no need to pay more to get one of those tiny broadcast monitor screens.

Check out the pics that people post online of S F 2 running on a real arcade monitor and you will see that there were no prominent thick black lines across the image. The methods that some people use to achieve this look now include rendering a 480p image and then literally throwing out half of the scanlines. That approach can't possibly retain all of the detail. A 480i image without double strike may not be 100% authentic but neither are many of the approaches that people are using to get a 240p image and it looks close enough for me.

The extron scan converters can be picked up for as little as $30 and with CRT tv's being literally free, I don't know why any fan of classic games would use anything else. Tv's with a decent sized screen are way easier to find than large video monitors too.

I thought hard about spending $150 to get the extron emotia that can output 240p but I don't believe that downscaling a 480p image to 240p produces a look that is more authentic than what I have.

I can display a 640 x 240 image on my lcd monitor (at 120 hz) and it looks terrible. There is more to creating an authentic arcade look than matching the original number of pixels....

Anonymous said...

Thanks for not ignoring and covering 31kHz CRTs. The 15 kHz screens are impossible to find anymore, and if you do find one they are far away and cost a crap ton of money now. Best most of can get is to use a regular PC CRT, and even those can be tough to find depending on the area.

Yardley said...

Hello! I recently purchased a PVM and got GroovyMMAME up and running with CRT Emudriver. I am struggling with Retroarch though. I am using display changer (resolution changing software) to set the Windows 7 resolution to 320x240 60Hz prior to launching Retroarch. The picture displayed looks good, but testing with SNES, the side scrolling motion is very jerky. I have tried using super wide resolutions as suggested here but this causes the image to shrink towards the center of the screen. Can anyone help me out with the proper settings to use with a PVM? Here's a video of the side scrolling issue: https://www.youtube.com/watch?v=BAJLPqvaT3I&feature=youtu.be

Hunter K. said...

@Yardley
You have a couple of options. For SNES, its horizontal res is 256 (sometimes 512), so the bad scrolling is coming from non-integer scaling on the horizontal axis as it stretches up to 320 px. Your options are to: switch to bilinear filtering, which will be a little bit blurrier than nearest neighbor, but scrolling should be smooth; apply an atialiasing shader, like pixellate or sharp-bilinear, to soften just those horizontal edge pixels; use a 256x240 modeline; or use an ultrawide modeline.

When you try an ultrawide res, you need to set RetroArch's aspect ratio to 'custom' and then set integer scaling to ON and then increase the horizontal res until it fills the screen.

Yardley said...

@Hunter K.
Thanks so much! I will give this a try tomorrow. Does it matter which ultra wide resolution I use; is 2560x240 ok? What about the refresh rate? Should I leave it at 60Hz or set it to each systems original spec like 60.0988Hz in the case of SNES?

Hunter K. said...

You can keep it at 60 for RetroArch, or set it to the original spec. Whatever you prefer. It'll automatically change the game's speed to match the refresh rate you set. I personally leave everything at 60.

Yardley said...

@Hunter K.
Should I have vsync enabled? Seems to be the only way to get rid of the issue with the motion. I got 2560x240 working by the way, is this preferable to using 256x240?

Hunter K. said...

Yes, vsync enabled. 2560x240 will work with pretty much any cores, while 256x240 will only work for S/NES (and a few others, like some PCE games).

Analytics Tracking Footer