Giter Club home page Giter Club logo

ibm515x's Introduction

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)

ibm515x's People

Contributors

trylle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ibm515x's Issues

Pixel artist and beginner electronics hobbyist - setup help

I was absolutely stoked to find this project! I have an IBM 5153 and am planning an art installation that uses it to display an interactive video. I've looked at other VGA to CGA options and this one seems the most desirable for the monitor I'll be using. I'm new to using a Raspberry Pi for something like this and could use some pointers on how to properly implement it.

  1. For the timing breakout board, is the IC you're using a 74AHCT125 quad-level shifter? The link to Benjamin Gould's page is dead. Any more information on the circuit you built would be appreciated.
  2. Can this be used to play video directly from a Raspberry Pi or is it streaming from another source? Is there a means for me to play a video through the Raspberry Pi itself? If so, what are the limitations for doing so?

Any advice would be deeply appreciated.

2023: we managed to replicate this project at the Slovenian Computer History Museum

fb_render_test

Here are the photos of our (mine & @bertronika's) setup and results so far (RPi desktop shows and one can use it, also the dpi/fb_render_test works; have not tested netvid/streaming/dithering yet!):
https://imgur.com/a/e6RcodQ

Hardware

  • To buy/obtain: Raspberry Pi 3, 2x SN74AHCT125N chip, 6 resistors, protoboard, jumper wires
  • Can use jumper wires to directly interface the male CGA connector
  • We will provide schematics ASAP!
  • Our goal is to run a Dosbox application just like it would show on the original IBM PC (or PC XT) with CGA graphics

Software
Complete instructions for fresh RPi install + latest Chrome + VirtualXT emulator in browser.
Since the resolution is 1920x200, normal Dosbox software doesn't properly render, thus the easiest "hack" for this was to use an emulator in browser and stretch it to fill screen. We use old Raspbian version from the time of this project to avoid incompatibilities.

sudo apt update (apt upgrade not needed if just doing basic stuff!)
sudo apt install snapd
sudo reboot
sudo snap install core
sudo snap install chromium
git clone https://github.com/trylle/ibm515x
cd ibm515x/configs
dtc -@ -I dts -O dtb -o cga.dtbo cga.dts
sudo cp cga.dtbo /boot/overlays/
  • Edit ibm515x/configs/config.txt and add line avoid_warnings=1
    sudo cp config.txt /boot

  • Edit ibm515x/configs/cmdline.txt and change root=/dev/mmcblk0p7 to root=/dev/mmcblk0p2
    sudo cp cmdline.txt /boot

  • Edit /etc/lightdm/lightdm.conf and set under [Seat:*] (not before!):
    xserver-command=X -s 0 -p 0 -dpms -nocursor

sudo apt install apache2

  • Copy virtualxt to /var/www/html/virtualxt (see section below!)
  • Add line to /etc/mime.types: application/wasm wasm
  • Remove the only line in /etc/ld.so.preload
  • Create /home/pi/virtualxt.sh with contents, then do chmod +x virtualxt.sh:
    /snap/bin/chromium --kiosk --app="http://localhost/virtualxt/?activity=0&touch=0"
  • Replace file /home/pi/.config/lxsession/LXDE-pi/autostart contents with this line:
    /home/pi/virtualxt.sh

sudo reboot

  • To build project binaries (OPTIONAL - we did NOT use this for our project and couldn't get streaming to work):
git clone https://github.com/trylle/ibm515x
cd ibm515x/
git clone https://github.com/trylle/netvid
sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev libeigen3-dev
cmake .
make

VirtualXT

  • Obtain the following files: (Copyright (c) 2019-2023 Andreas T Jonsson [email protected])
https://app.virtualxt.org/index.html
https://app.virtualxt.org/freedos_web_hd.img
https://app.virtualxt.org/script.js
https://app.virtualxt.org/virtualxt.wasm
  • In index.html change
    <body style="background-color:black;">
    to
    <body style="background-color:black; margin:0px; padding:0px; overflow:hidden;">

  • In script.js change
    canvas.style.setProperty("transform", "matrix(" + xScale + ",0,0," + (xScale * yScale) + "," + transX + ",0)");
    to
    canvas.style.setProperty("scale", (document.body.clientWidth / width) + " " + (window.innerHeight / height));

  • Edit the hard disk image (freedos_web_hd.img) as you see fit.
    Tip: DiskExplorer works great for editing - use the profile "vmware plain disk"

Cool Project - request?

Hi,

This is a really cool project and I am excited to build it and test it out on my CGA monitor. I am sure you have moved on from this to new pursuits, but can't help but ask a few things.

  1. On the temporal dithering, one thing that I have noticed when doing that (on a Tandy and on tweaked CGA) is that if you take the resulting image and swap every other line you get a consistent brightness across both images and it helps flicker a lot. https://www.youtube.com/watch?v=MR1uq4y9G34 The picture is true to life, it doesn't flicker a lot. Certainly, it is there.
  2. Have you thought about making the display 640x400 interlaced video? Not sure if 640x480 might work as well? Not sure how awful or full of flicker it will be, but would be neat. The ATI VGA Wonder will allow you to display 640x350 using some kind of process to get more colors on the monitor (and it does) but not sure if it is temporal or something else.
  3. Last one, do you think you could overmodulate the signal to get more colors in 60 Hz? So, we have 16 levels of TTL, what if you were to drive the signal FASTER than the actual rate the pixel changed using PWM. So, if you are able to drive a 15.75 KHz signal and you could drive a signal at 4 times that at 63 KHz then I think during the pixel draw portion of the signal you could switch it faster than the raster scan and drive more than one color per pixel. At 4X you could drive Red-Black-Black-Black and probably get a darker red, or Blue, Blue, White, Red and get a light magenta. Odd combinations like Brown, Cyan, Red, Yellow would give even additional colors. I think the math works out to with 16 colors and 4 "cycles" per pixel you could get 3,876 combinations. If you could do 8 cycles per pixel that would require precision control of a 126 KHz signal that would give you 490,314 combinations. 12 "cycles" per pixel would be 17.4M colors which has to have every color close to 24 bit. 12 would require precision control of a 189 KHz signal. I don't know how the TTL to Analog RGB circuitry inside the 5153 would handle the frequency though or if it would switch fast enough. Anyway, if you read this far this is what your project made me think of.

Regardless, 640x400x17M colors on a TTL CGA monitor would be something to see for sure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.