MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Discussion about old graphics cards, monitors and video related things.

MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-01 @ 21:53

I recently started contributing to an open source project first developed by hoglet on the stardot forums, to convert the TTL RGB outputs of the Acorn BBC micro and Electron to HDMI / DVI using a Raspberry Pi Zero and a small CPLD on a 'Hat' PCB. My initial contributions were to get deinterlacing working for the BBC's mode 7 teletext output and also to support genlocking so that the Pi's video output was locked to the source. Original thread here: https://stardot.org.uk/forums/viewtopic.php?f=3&t=14430

These Acorn machines have TTL RGB ouputs similar to CGA and I thought it might be worth trying to get it working on such sources. After a lot of code optimisation in ARM assembler and reworking the CPLD, we now have it working with MDA / CGA / EGA type sources and also with monochrome non-TTL sources like the ZX80/ZX81, Apple II, UK101 using a small external circuit to extract the sync and video.

Here is a photo of the adapter:
case2.jpg

The system will work up to VGA frequencies with 6 bits/pixel although you need a card that will output VGA over TTL 9 pin D-type or an EGA+ type card to use those high resolutions and it is menu driven with multiple profiles stored on SD card so you can tweak any of the parameters like clock frequency, line length, size etc to support any number of non-standard outputs. Also it will autoswitch between all the profiles in a "switching set" and you can have multiple switching sets.

One interesting option that it supports is integer scaling where the original pixels of the source are scaled to an exact multiple of pixels on the LCD panel without any interpolation filter which makes the output look very sharp like it's at the native resolution of the panel. The disadvantage is that the image won't completely fill the screen but the quality difference is so great it is well worth it. (You can select normal interpolation to fill the screen if preferred).

Normal scaling with interpolation (view full size):
interpolated.jpg

Integer scaling (view full size):
integer.jpg

There is an option to screencap the displayed output to the Pi's SD card so here are some more examples captured in this way.
If you view these at 100% on a 1080p monitor you will see the exact quality you get from the output using integer scaling:
(Click on the thumbnails then click again on the images to get them at 100%)

EGA 640x200 60Hz:
egakeen.png

CGA 640x200 60Hz:
cgamaniac.png
Last edited by IanB on 2019-4-02 @ 01:15, edited 6 times in total.
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-01 @ 21:54

I've just started working on NTSC artifact colours:
cgaartifactmaniac.png

640x200 60Hz ega:
egamaniac.png

EGA text 640x350 60Hz:
egatext.png

CGA 640x200 60Hz:
cga.png

VGA 640x480 60Hz:
vga win311.png
Last edited by IanB on 2019-4-01 @ 22:00, edited 1 time in total.
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-01 @ 21:54

These captures show a couple of the menus:
main menu.png

geometry.png

It's still a work in progress but I don't have any original MDA CGA or EGA cards, just a couple of 'universal' cards that can be switched to all resolutions with DIP switches so maybe someone would like to help out with testing that.
Last edited by IanB on 2019-4-01 @ 23:03, edited 1 time in total.
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby keropi » 2019-4-01 @ 22:49

this is all very interesting, how can I build this to test? I've made some tests with the mce2vga adapter , you can read the thread here if you haven't already : viewtopic.php?f=63&t=56313&start=220 , if there is any way to contribute to testing do tell!
The profiles and proper scaling sound and look just awesome. :cool:

Is it possible to add a scanlines effect as well?
User avatar
keropi
l33t++
 
Posts: 7250
Joined: 2003-9-08 @ 06:45
Location: Greece

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-02 @ 00:37

keropi wrote:this is all very interesting, how can I build this to test?

The PCB design and code are on github
This is my fork:
https://github.com/IanSB/RGBtoHDMI/tree/dev
This is hoglet's original (my changes are usually merged back in)
https://github.com/hoglet67/RGBtoHDMI/tree/dev
(All the current work is in the dev branch at the moment)

keropi wrote:if there is any way to contribute to testing do tell!

Do you want to build one yourself? I still have a few prototype pcbs
Construction details here:
https://github.com/hoglet67/RGBtoHDMI/w ... -Materials

Note the current PCB was designed for the BBC micro which has composite sync and 3 bits RGB so had to be reworked slightly to connect the separate H and V sync and 6 bits RGB:
extrabits.jpg

There will be a new pcb design sometime fairly soon which will be more universal.

keropi wrote:Is it possible to add a scanlines effect as well?

Yes although it can interact with the integer scaling depending on monitor size and source resolution. In the case of CGA/EGA 640x200 on a 1080p monitor below, there are 2 LCD pixels of video and 3 pixels of black for each line pair: (Make sure to zoom to 100%)
scanlines.png

If there are any unevenness issues with integer scaling and scanlines you can always switch on interpolation.

One other feature I forgot to mention is that it supports reprogramming of the output palette by displaying specific patterns of pixels which are unlikely to occur with normal operation as they look like random noise. (Although this feature can be disabled in case something triggers it accidentally)

This was primarily for use on the BBC micro to do things like change this:
RawRGB.png

Into this:
palette.png

But a DOS command line tool could be written to change the palettes on old CGA games to something less garish.
Last edited by IanB on 2019-4-02 @ 01:13, edited 2 times in total.
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-02 @ 01:09

For comparison, here's a closeup of scanlines with interpolation switched on to even out the 3:2 lines:
interpolation.jpg

(The Pi can't screencap the interpolated output as that's done in hardware by the Pi's GPU)
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby keropi » 2019-4-02 @ 06:58

looking good! I have to ask , what kind of latency is there with this adapter?
still very interested to test this, soldering/modifications are no issue :)
User avatar
keropi
l33t++
 
Posts: 7250
Joined: 2003-9-08 @ 06:45
Location: Greece

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-02 @ 10:46

keropi wrote:looking good! I have to ask , what kind of latency is there with this adapter?

When the input and output frame rates match and they are genlocked together (e.g. CGA/EGA 60Hz to 1080p60), the phase relationship is arranged so that the source video is written to the Pi's frame buffer approx 1ms before it's read out by the Pi's display hardware so the inherent delay of the capture system is aroud one or two milliseconds. However, I'm not sure if there is any further delay introduced by the Pi's display hardware but that delay would affect anything running on a Pi in the same way.
If the input and output frame rates don't match or genlock is switched off then you can enable multiple buffering to eliminate tears but that does introduce a frame's delay for each buffer (normally this is not used).
Last edited by IanB on 2019-4-02 @ 11:19, edited 1 time in total.
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby root42 » 2019-4-02 @ 11:17

I would also be interested in a prototype PCB. Just need BOM and instructions on how to mod it for EGA usage.
Soldering, retro game reviews and more on YouTube and Bonus videos
80386DX@25 MHz, 8 MiB RAM, Tseng ET4000 1 MiB, Jazz16, PC MIDI Card + SC55MkII + MT32, XT CF Lite, OSSC 1.6
User avatar
root42
Oldbie
 
Posts: 1251
Joined: 2018-1-27 @ 13:23

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby keropi » 2019-4-02 @ 13:16

very good indeed then , looking forward to test this!
User avatar
keropi
l33t++
 
Posts: 7250
Joined: 2003-9-08 @ 06:45
Location: Greece

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-02 @ 14:40

One caveat about the integer scaling: It only really works well on 1920x1080, 1920x1200 and 1600x1200 monitors as there have to be enough LCD pixels to fit the integer scaled output.
e.g. CGA and EGA lores scale from 640x200 to 1280x1000, EGA hires scales from 640x350 to 1280x1050, MDA scales from 720x350 to 1440x1050 and VGA scales from 640x480 to 1280x960 which all fit nicely into the above resolutions with minimal borders. Below those resolutions, integer scaling is less useful as you mostly end up with large borders and wrong aspect ratios.

You can make CGA/EGA lores work at 1280x1024 but there can be a problem because the text and graphics versions of some modes can shift horizontally by a few pixels so if you are configured to capture exactly 640 pixels one or the other will get a few pixels cut off. There are two ways around this, one is to capture more than 640 pixels such as 648 pixels but then the 2x integer scaling for that is 1296 so it won't fit and the other is to adjust the capture position each time there is a change from text to graphics and back again. I might add that adjustment to the existing built in auto calibration function.
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-03 @ 17:43

keropi wrote:what kind of latency is there with this adapter?

I just figured out a way to test this exactly:
I connected a HDMI to VGA converter lead to the HDMI output and then wrote a program to flash the screen briefly.
The VGA converter lead is just a simple D to A converter and doesn't introduce much delay itself.
I then looked at one of the RGB inputs (from the computer) and one of the RGB outputs from the HDMI to VGA lead on a scope and it shows the total delay is 2.4 milliseconds:
(Yellow is the computer RGB source, Cyan is the output of the converter)

Converter Lag.png

I think roughly half of the delay is due to the capture side and the other half is the Pi's scaler.
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby keropi » 2019-4-03 @ 18:12

that's a very nice and low latency - almost nothing considering the frameister has ~20ms of processing lag
User avatar
keropi
l33t++
 
Posts: 7250
Joined: 2003-9-08 @ 06:45
Location: Greece

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby IanB » 2019-4-05 @ 16:10

I've added variable intensity scanlines from 0 - 15 with 0 = black and 15 = about 94% of full brightness. I also switched around the integer heights so there are 3 pixels of video and 2 pixels of scanline although that evens out if interpolation is switched on.

Here is the integer version with level set to 6:
Newscanlines.png

Here's a closeup with interpolation switched on:
interpolation scanlines.jpg
User avatar
IanB
Member
 
Posts: 137
Joined: 2017-1-21 @ 04:46

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby keropi » 2019-4-05 @ 16:55

another great move, these scanlines are better looking IMHO!
User avatar
keropi
l33t++
 
Posts: 7250
Joined: 2003-9-08 @ 06:45
Location: Greece

Re: MDA/CGA/EGA/VGA to HDMI using Raspberry Pi Zero

Postby dreamblaster » 2019-4-05 @ 21:02

looks great, i'd like to try it, will pm you !
Visit http://www.serdashop.com for retro sound cards, video converters, ...
OPL2LPT, OPL3LPT, X2, S2, S2P, MCE2VGA, ... many projects !
Special vogons LPT bundle : https://www.serdashop.com/Parallel-port-retro-sound-bundle
Thanks for your support !
dreamblaster
Oldbie
 
Posts: 683
Joined: 2015-1-18 @ 19:34
Location: Belgium


Return to Video

Who is online

Users browsing this forum: Errius, ShovelKnight, Skanque and 3 guests