/ibm515x

Raspberry Pi network video adapter software for IBM 515x-compatible monitors

Primary LanguageC++MIT LicenseMIT

ibm515x

IBM 5153 and RPi CGA

This repository contains code and configuration for rendering an UDP video stream (netvid) to an IBM 5153 compatible monitor via a Raspberry Pi. Crude hooks are available for RetroArch and Open Broadcaster Software to provide the video stream.

Dependencies

  • Boost
  • Eigen 3

DPI-based code

  • SDL (optional)

GPIO-based code (non-functional)

Interface

Video signals are provided through the DPI (Parallel Display Interface), using 4 bits of color (RGBI) and 2 sync signals. Due to the RPi pixel clock being picky, the pixel clock and the relevant timings had to be tripled. The actual framebuffer resolution is therefore 1920x200.

The repository also includes a GPIO interface, which was never finished, after oscilloscope analysis revealed timing issues (suspected main culprit: USB polling).

Pinout on RPi header

RGBI pinout on RPi header

Adapter

Photo of adapter Adapter circuit diagram

The actual adapter board and timings were based on the previous work by Benjamin Gould. I added some resistors to limit the current draw; purely precautionary. On my monitor I also needed to adjust the vertical and horizontal porches to provide a centered image.

The required config, cmdline and device tree overlay files suitable for a Raspberry Pi 3 have been added to this repository.

16-color palette as rendered by fbrender_test

The adapter can render the complete 16 color CGA palette at up to 640x200 resolution.

136-color palette as rendered by fbrender_test

Temporal dithering is supported for extending the palette to 136 colors. The image above shows two 60 Hz exposures combined.

Downsampling

A downsample application provides needed processing to convert a 16-bit/32-bit RGB video stream (as provided by RetroArch/OBS) into a CGA compatible 4-bit video stream. It supports nearest neighbor color downsampling (for rendering conventional CGA/EGA output), temporal and bayer dithering, local contrast enhancement and black level adjustment.

Examples

Command line:

./downsampling/main --recv 0:<input-port> --send <output-host>:<output-port> --algorithm nearest

Command line:

./downsampling/main --recv 0:<input-port> --send <output-host>:<output-port> --algorithm bayer --bayer 2,2

Command line:

./downsampling/main --recv 0:<input-port> --send <output-host>:<output-port> --algorithm bayer --bayer 2,2 --local-contrast-gain .25 --local-contrast-stddev 32

Local contrast enhancement tries to maximize the range of luminosities for different parts of the image. This is useful when you're limited to a palette that has very few gradations but wide range, as with the IBM5153. Works well where the video input does not consist of large uniform areas, e.g. cartoons.

Command line:

./downsampling/main --recv 0:<input-port> --send <output-host>:<output-port> --algorithm bayer --bayer 2,2 --local-contrast-gain .25 --local-contrast-stddev 32 --temporal-dither client --staggered-temporal-dithering

Switching pixel color every frame gives the appearance of more colors, but at the expense of flickering.

Command line:

./downsampling/main --recv 0:<input-port> --send <output-host>:<output-port> --algorithm bayer --bayer 2,4 --local-contrast-gain .25 --local-contrast-stddev 32 --temporal-dither client --staggered-temporal-dithering

This example uses a 640x200 input and a non-square bayer pattern to accommodate the pixel aspect ratio.

Demo videos

Space Quest 3 Quest for Glory (EGA) Beneath a Steel Sky Loom (EGA) Caren and the Tangled Tentacles (C64)