hoglet67 / RGBtoHDMI

Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI
GNU General Public License v3.0
841 stars 115 forks source link

Artifact color autodetection? #337

Open evan opened 1 year ago

evan commented 1 year ago

Thank you for the amazing work on this.

I'm using it with an XT and CGA output. I can use the long press shortcuts to enable/disable artifact color, but I wondered if it would be possible to autodetect it.

When the adapter is color-capable but the software is outputting dithered mono, like California games, it is likely to be artifact color. I'm not sure how to detect color-dithered artifact color, like in the Black Cauldron, but maybe there is a way.

IanSB commented 1 year ago

@evan There are a few possible ways to do this:

  1. Do a statistical analysis comparing the bit patterns when displaying 80 column mono text and 640x200 mono graphics output to see if there is any reliable way of determining either mode. Any bit patterns are possible in mono graphics mode but some of those patterns may never appear in text mode but I don't know how reliable this detection method would be. I suppose that would also be the case in four colour modes.

  2. Use a signal from the video card itself which changes state between mono and graphics mode (e.g colour burst on/off). This obviously requires some hardware mods, possibly a link to one of the unused pins on the CGA connector that could then be detected by the matching input on RGBtoHDMI. This would likely only work on original IBM CGA cards and their clones using discrete chips where such a signal was easy to find.

  3. Detect the colour burst on/off on the composite output. This is similar to 2 and would avoid modifications but would require extra hardware and again would only work on original CGA cards and clones with a composite output

evan commented 1 year ago

My Leading Edge Model D does not have composite output, only TTL, so I was hoping some version of strategy 1 would be possible.

It did occur to me that if the screen was sampled over multiple seconds it may improve accuracy of the detection and prevent the color mode from flapping on and off.