Friday, July 16, 2021

Keeping the Upscale and Capture Pure - The RGBtoHDMI and Digital PC Video Standards

When IBM was designing video display adapters for its IBM PC, it treated video quality as important.  While the world of displays was in 1980 essentially analog, IBM chose to use digital outputs for its IBM Monochrome Display and Printer Adapter and Color Graphics Adapter.  Later it continued to use a digital TTL interface for the IBM PCjr.'s built in video and its Enhanced Graphics Adapters.  Competitors and copycats, like the Hercules Graphics Card and the Tandy 1000's built-in video, also copied IBM's usage of the DE-9 port carrying digital color signals.  While some of the color cards had composite color video support, serious business usage demanded the use of a monitor which could accept those digital signals for the highest possible picture quality possible.  

By 1987, the limitations of the digital interface, with each color primary requiring a separate collection of wires, was too limiting for IBM's Video Graphics Array.  The connector was changed and the colors were output over an analog interface, which only required one pin per color primary.  The VGA analog video standard remained the principal way by which PCs connected their displays for over fifteen years.  By the time the digital DVI connector became popular enough to replace VGA, the older pre-VGA standards had been long consigned to the realm of retro-computing.  

Today the modern display device tends to eschew any display standard older than DVI, with most only having HDMI and DisplayPort inputs.  The digital standards of old used special CRTs, which have become expensive and often require repair or restoration due to age.  Those of us who enjoy working on retro computers are faced with having to "settle" for composite video, having to fork out large amounts of money and space for the special digital CRTs displays or use rather particular capture cards to see what was intended.  The RGBtoHDMI is one really good solution for these issues, let's take a look at it.

Introducing the RGBtoHDMI

Tandy 1000 320x200

The RGBtoHDMI was originally designed to capture, upscale and display the native video from a BBC Micro.  The BBC Micro displayed six modes with combinations of 160, 320 and 640 pixels by either 200 or 256 lines (for PAL) by using the 6845 CRTC and producing eight colors digitally (3-bit color) (red, green, blue, cyan, magenta, yellow, black, white). This video hardware was very similar to the IBM CGA, which also used the 6845 and could display sixteen colors (4-bit color) digitally.

The RGBtoHDMI consists, at its core, of two circuit boards.  The first is a a Raspberry Pi Zero with a header soldered onto it.  The Zero comes in two varieties, the "regular" and the "W" version.  The "W" adds Wi-Fi support but the basic processing power of the Zero is unchanged.  The regular Pi Zero retails for $5.00 and the Pi Zero W for $10.00.  The Pi Zero has a port for a mini-SD card and a mini-HDMI connector, two microUSB ports, a 2x20 pin header for GPIO and a flat flex connector for the Pi Zero Camera.  The Pi Zero WH is a "W" version with a header pre-installed and goes for $14.00.  You will need the header to use the RGBtoHDMI.

The second part of the RGBtoHDMI is the Converter Board.  Several versions of the Converter Board have been released but they are all based off a single CPLD, the XC9572XL.  This chip is very commonly used to interface between 3.3v devices like the Pi Zero and 5v devices.  In this case, the digital TTL video outputs signals at 5v and the CPLD can convert this into a Pi-friendly 3.3v as well as convert the signal into something the Pi's bus can understand.  

The RGBtoHDMI supports most of the popular 8-bit and 16-bit microcomputers.  Some computers, like the Apple II or TRS-80 will require a third board, the Analog Board, to make sense of the video signal.  Other computers will need to be pre-modded like the Commodore 64 to output component video or have their signals tapped directly off the board like a Macintosh SE or an Amiga.  

Features of the RGBtoHDMI

CGA 320x200 (with border)

The RGBtoHDMI offers a huge range of scaling and display features, and the sheer number of options can make it a little intimidating at first.  The RGBtoHDMI can upscale video from its native 240p modes to 480p, 720p, 1080p, 1200p and 1440p.  It can also upscale with very little latency, if the RGBtoHDMI can Genlock to the original video signal, you may be able to get a little as 4ms of lag, or 1/4 of a frame.  The RGBtoHDMI software is loaded off a microSD card when power is applied to the Raspberry Pi Zero and boots to "bare metal", so there is no underlying operating system dictating when the software and have access to resources.  

Some modern displays can accept 240p signals directly via a VGA or component input, but the picture quality usually leaves something to be desired. The RGBtoHDMI can perform an integer or a filtered scale and can show or leave out most borders.  It can also apply scanlines, different base palette colors for monochrome video standards and supports artifact color generation for those systems which support it.  

Most of the supported systems have software profiles built-into the RGBtoHDMI firmware.  You can add your own profiles and define not only minimum/maximum horizontal pixel and line counts but also the dot clock and the phase offsets.  The RGBtoHDMI also has an automatic phase adjustment option which can eliminate any shimmering due to poor phase alignment between the retro machine's dot clock and the the sampling clock.  You can adjust the built-in software profiles if they do not match what your hardware expects and make your own.

Unlike certain other methods of video capture, for video signals whose source origins were digital, the  RGBtoHDMI captures them as digital, introducing no noise or color variations into the process ouf outputting the scaled image via HDMI.  If your capture card can losslessly capture HDMI in the RGB domain, you should be able to get a near-perfect digital capture of the video being output from your machine.  Also, as the input video from the HDMI is using very few colors, you can have massive storage savings when it comes to working with video capture footage.

Getting Started with RGBtoHDMI and PC Video

CGA 640x200

The RGBtoHDMI is a terrific scaler, but it does require some effort to get the most out of the device.  First of all, while the Pi Zero may be freely available, the same cannot be said for the RGBtoHDMI specific boards.  To use the RGBtoHDMI with MDA, CGA, Hercules, PCjr., Tandy 1000 or EGA, you must have at least the 6-bit/8-bit Converter Board.  The current Converter Board is the 12-bit board, suitable for capture of the Amiga's video but backwards compatible.  The RGBtoHDMI project is open source in hardware and software, but you may need to get a board fabricated at a place like pcbway and solder the components on yourself.  The only component that may give you pause is the 44-pin XC9572XL, which uses a surface mount QFP layout.  

In addition to the required Converter Board, you may wish to build the TTL Buffer Board.  The TTL buffer board is not essential for PC Video, but it can help keep you equipment safe and provides a DE-9 connector suitable for swapping cables.  I was able to acquire the converter board by being in the right place at the right time, but not wanting to wait for the parts to arrive for a TTL Buffer Board I rewired a DE-9 connector which plugged into a serial port header on a motherboard.  The header on the Converter Board is wired like this looking from the top down with the 40-pin connector on the left :

11 09 07 05 03 01

12 10 08 06 04 02

03 = Ground

04 = Secondary Green/Intensity

05 = Secondary Red

06 = Secondary Blue/Monochrome Video

07 = Primary Red

08 = Horizontal Sync

09 = Primary Green

10 = Vertical Sync

11 = Primary Blue

Pins 01, 02 and 12 are not used, and especially avoid pin 12 because that is +5v. That signal powers the Converter Board and the Pi, but PC Video connectors of this vintage do not provide +5v.  Use a microUSB cable to power the RGBtoHDMI. 

The pins of the serial connector, with the possible exception of pin 1, will need to be rewired to match the Converter Board's header.

CGA 320x200 with Composite Filter

When you have all the parts you need, unzip the RGBtoHDMI software onto the microSD card.  Connect the RGBtoHDMI to an HDMI display device but do not connect it to a retro computer yet.  Switch to the HDMI input where the RGBtoHDMI is plugged into and you should see a menu asking you how you wish to program the CPLD.  Pick RGB CPLD. wait a few moments for the device to reprogram the CPLD and then you can use the RGBtoHDMI without further CPLD reprogramming as long as you stick with those systems which use the RGB CPLD program.  Then you can get to the Main Menu by pressing the button next to the upper left of the CPLD's text.  Navigating through the menu is done with that button and the two buttons below it.  

Hereafter all Menu Options discussed will be in bold.

Specific Video Adapter Issues : CGA, Tandy & PCjr.

CGA 640x200 with Composite Filter

The Profile you should use with 200-line only PC video adapters like CGA, Tandy 1000 and PCjr. is PC CGA MDA for IBM devices and Tandy 1000 200 Lines or Tandy 1000 225 Lines for Tandy devices.  The Palette Menu allows you to turn on Artifact Colour, choose the Artifact Phase and Artifact Quality.  

Tandy 1000 160x200

The Presets should be fine for just about anything that runs on these adapters.  The only issue I have encountered is with Windmill Software titles that use a "tweaked" 80-column text mode to achieve a 160x100 resolution with 16 colors (Styx, The Exterminator, Moon Bugs).  The video output would flicker constantly regardless of anything I did until I saw the Source Summary in the Info Menu that the video was outputting 256 lines per frame instead of the normal 262 lines per frame.  When I changed Lines per Frame to 256 in the Geometry Menu, the screen stopped flickering.  I had to change it back to 262 Lines per Frame to have more regular CGA video working again without flicker.

EGA 640x200

Specific Video Adapter Issues : EGA

EGA cards should use the PC EGA Profile.  There are profiles for PC ET3000AX and PC OTIVGA, I assume these are for dual EGA/VGA cards which have enhanced capabilities over IBM's EGA.  EGA supports both 200 and 350-line video modes, and the PC EGA Profile is smart enough to distinguish between the two.  This Profile has Sub-Profile from which you can select CGA, MDA, EGA, Hercules Text, Hercules Gfx, set it to EGA if you are booting the EGA in a 350-line mode.

EGA 640x350

Make sure you have your jumpers and dipswitches set appropriately for EGA's "Enhanced" 350-line modes, the text is so much nicer than the 200-line modes you may have had to put up with if you do not have a pricey EGA monitor.  Also, make sure the jumper or dipswitch for the secondary red is set to pass that signal through to the connector, otherwise your 640x350 with 16 color captures will have an unwanted bluish tint to them.  The color of EGA's 640x350 monochrome mode can be set to something other than white with the Output Colour option in the Palette Menu.

Tandy 1000/EGA 320x200

Specific Video Adapter Issues : MDA and Hercules

MDA 720x350

I strongly recommend getting a feel for the RGBtoHDMI by using one of the other PC modes if you can before tackling MDA and Hercules.  First, unlike CGA, PCjr., Tandy or EGA, MDA and Hercules use 50Hz refresh.  Your output or capture device must support 50Hz at the output resolution chosen. Set Refresh = 50Hz on the Main Menu.  Here either the PC EGA or PC CGA MDA Profile can be used, but those profiles have at least one incorrect setting.  You must change the Sync Type in the Geometry Menu to +H-V, otherwise the picture may constantly flicker.  You may also need to play with the H Offset and V Offset values in the Geometry Menu to ensure no part of the active display is cut off.

The Sub-Profiles has selections for MDA, Hercules Text and Hercules Gfx, but you will need to adjust the Sync Type for each separately.  While generally not noticeable in use, MDA text has subtle differences from Hercules Text and Hercules Graphics, mainly due to MDA using a 16.257MHz pixel clock and Hercules using a 16MHz pixel clock.  The Auto Calibtrate for Video Sampling can fix pixel shimmering issues.  Remember to Save Configuration once you have a stable picture.  If you lose signal while adjusting settings, you may wish to unplug the RGBtoHDMI from the video source and make the adjustments without the underlying video and then try them after plugging in again.

Having mastered both the IBM MDA card and the Hercules Graphics Card, I still had difficulties capturing Hercules graphics as output by my Tandy 1000 TL.  I am still not sure exactly how I managed to get the picture correct. One thing I had to do was to change the Clock Frequency in the Geometry Menu from 16000000 to 16257000, which seemed the opposite of what I had to do.  The error number was very high with the Hercules Gfx Sub-Profile even after setting the Sync Type correctly.  However, every time I incremented that value, the PPM error number came closer to zero, and when it was at 16257000 the issues with the video went away and I was left with stable video without any phase artifacts.

The Perfect Fit

I have been talking a lot about this device's abilities to augment a capture setup, but what about its ability to drive an LCD?  Well, it does that rather well, but let me discuss how to get the best out of the device.  My regular display is an ASUS VW266, a 25.5" LCD with a 16:10 aspect ratio and a native 1920x1200 resolution.  Most DOS games use a 320x200 resolution and when I was last looking for a monitor, I wanted something that would be friendly to DOS resolutions as well as more modern games and video.  In the past I have been able to get DOSBox to scale 320x200 to 1600x1200 and the pixels will appear sharp and evenly sized.

In order to achieve the same result in the RGBtoHDMI, select a Profile like Tandy 200-lines go into the Geometry menu.  From there set the Min H Width and Max H Width to 320 and the Min V Height and Max V Height to 200.  Next sent the H Pixel Aspect and the V Pixel Aspect to 0.  Finally set the Line Length to 456.  You will probably need to adjust the H Offset and V Offset to get the actual display area fully in the picture.  If you wish to set the brightness of the scanlines. set FB Size to Double Height+Double Width.

Final Words

Hercules 720x348

If capturing with a Datapath card, there may be an annoying amount of instances of lost signal when screen resolutions change unless you turn Genlock off.  All screenshots shown in this post were taken by using the RGBtoHDMI and the Datapath E1s.  

The RRGBtoHDMI adapter offers new life to old PCs, not just for capture but also use.  Grab an old 1280x1024 or 1600x1200 monitor at the thrift store, find the best scaling options for you and you will have a working system.  Or if you want sharp, high quality and eventual low-sized captues, the RGBtoHDMI is also an excellent way to accomplish that.

1 comment:

  1. I have a 1600x1200 CRT monitor (though needs some recapping), what if I wanted to be "that guy" and split between it and the RGB2HDMI? May be a while before I get the analog solution back from TexElec though.

    ReplyDelete