VOGONS


First post, by IanB

User metadata
Rank Member
Rank
Member

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
Filename
case2.jpg
File size
196.98 KiB
Views
1221 views
File license
Fair use/fair dealing exception

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
Filename
interpolated.jpg
File size
670.73 KiB
Views
1221 views
File license
Fair use/fair dealing exception

Integer scaling (view full size):

integer.jpg
Filename
integer.jpg
File size
687.17 KiB
Views
1221 views
File license
Fair use/fair dealing exception

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
Filename
egakeen.png
File size
29.95 KiB
Views
1221 views
File license
Fair use/fair dealing exception

CGA 640x200 60Hz:

cgamaniac.png
Filename
cgamaniac.png
File size
15.93 KiB
Views
1221 views
File license
Fair use/fair dealing exception
Last edited by IanB on 2019-04-02, 01:15. Edited 6 times in total.

Reply 1 of 15, by IanB

User metadata
Rank Member
Rank
Member

I've just started working on NTSC artifact colours:

cgaartifactmaniac.png
Filename
cgaartifactmaniac.png
File size
18.75 KiB
Views
1220 views
File license
Fair use/fair dealing exception

640x200 60Hz ega:

egamaniac.png
Filename
egamaniac.png
File size
16.08 KiB
Views
1220 views
File license
Fair use/fair dealing exception

EGA text 640x350 60Hz:

egatext.png
Filename
egatext.png
File size
21.64 KiB
Views
1220 views
File license
Fair use/fair dealing exception

CGA 640x200 60Hz:

cga.png
Filename
cga.png
File size
13.29 KiB
Views
1220 views
File license
Fair use/fair dealing exception

VGA 640x480 60Hz:

vga win311.png
Filename
vga win311.png
File size
18.15 KiB
Views
1220 views
File license
Fair use/fair dealing exception
Last edited by IanB on 2019-04-01, 22:00. Edited 1 time in total.

Reply 2 of 15, by IanB

User metadata
Rank Member
Rank
Member

These captures show a couple of the menus:

main menu.png
Filename
main menu.png
File size
14.62 KiB
Views
1218 views
File license
Fair use/fair dealing exception
geometry.png
Filename
geometry.png
File size
16.47 KiB
Views
1218 views
File license
Fair use/fair dealing exception

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-04-01, 23:03. Edited 1 time in total.

Reply 3 of 15, by keropi

User metadata
Rank l33t++
Rank
l33t++

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 : MDA/CGA/EGA to VGA Converter Released! , if there is any way to contribute to testing do tell!
The profiles and proper scaling sound and look just awesome. 😎

Is it possible to add a scanlines effect as well?

🎵Link to buy a PCMIDI mpu
🎧Orpheus soundcard project
💻WTB Amstrad PC7486SLC-33 system

Reply 4 of 15, by IanB

User metadata
Rank Member
Rank
Member
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/wiki/Bill-of-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
Filename
extrabits.jpg
File size
316.79 KiB
Views
1198 views
File license
Fair use/fair dealing exception

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
Filename
scanlines.png
File size
27.64 KiB
Views
1198 views
File license
Fair use/fair dealing exception

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
Filename
RawRGB.png
File size
18.43 KiB
Views
1198 views
File license
Fair use/fair dealing exception

Into this:

palette.png
Filename
palette.png
File size
16.2 KiB
Views
1198 views
File license
Fair use/fair dealing exception

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-04-02, 01:13. Edited 2 times in total.

Reply 5 of 15, by IanB

User metadata
Rank Member
Rank
Member

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

interpolation.jpg
Filename
interpolation.jpg
File size
675.85 KiB
Views
1195 views
File license
Fair use/fair dealing exception

(The Pi can't screencap the interpolated output as that's done in hardware by the Pi's GPU)

Reply 6 of 15, by keropi

User metadata
Rank l33t++
Rank
l33t++

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 😀

🎵Link to buy a PCMIDI mpu
🎧Orpheus soundcard project
💻WTB Amstrad PC7486SLC-33 system

Reply 7 of 15, by IanB

User metadata
Rank Member
Rank
Member
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-04-02, 11:19. Edited 1 time in total.

Reply 8 of 15, by root42

User metadata
Rank Oldbie
Rank
Oldbie

I would also be interested in a prototype PCB. Just need BOM and instructions on how to mod it for EGA usage.

YouTube and Bonus
80386DX@25 MHz, 8 MiB RAM, Tseng ET4000 1 MiB, SnarkBarker & BlasterBoard, PC MIDI Card + SC55 + MT32, XT CF Lite, OSSC

Reply 10 of 15, by IanB

User metadata
Rank Member
Rank
Member

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.

Reply 11 of 15, by IanB

User metadata
Rank Member
Rank
Member
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
Filename
Converter Lag.png
File size
44.71 KiB
Views
1089 views
File license
Fair use/fair dealing exception

I think roughly half of the delay is due to the capture side and the other half is the Pi's scaler.

Reply 12 of 15, by keropi

User metadata
Rank l33t++
Rank
l33t++

that's a very nice and low latency - almost nothing considering the frameister has ~20ms of processing lag

🎵Link to buy a PCMIDI mpu
🎧Orpheus soundcard project
💻WTB Amstrad PC7486SLC-33 system

Reply 13 of 15, by IanB

User metadata
Rank Member
Rank
Member

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
Filename
Newscanlines.png
File size
49.31 KiB
Views
995 views
File license
Fair use/fair dealing exception

Here's a closeup with interpolation switched on:

interpolation scanlines.jpg
Filename
interpolation scanlines.jpg
File size
762.8 KiB
Views
995 views
File license
Fair use/fair dealing exception

Reply 14 of 15, by keropi

User metadata
Rank l33t++
Rank
l33t++

another great move, these scanlines are better looking IMHO!

🎵Link to buy a PCMIDI mpu
🎧Orpheus soundcard project
💻WTB Amstrad PC7486SLC-33 system

Reply 15 of 15, by dreamblaster

User metadata
Rank Oldbie
Rank
Oldbie

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 !