Monday, February 18, 2013

protyping VGA out

The basics of the VGA generation board are set now, so I’ll present my different protypes.

First, I tried a 8 bit approach, as I’ve seen a demo on the internets using one of those, and I wanted to try something that I knew worked. Look at it, it’s fine ; it’s called peridiummm, running 320x200, double buffered.

So I soldered a R2R 8 bit DAC to my STM32F4 discovery board (cheap and powerful .. so nice).

Finally got around setting a proper ARM toolset under linux, and compiled away : everything worked right away (yeah, right. Well, after a while pulling my hairs, blasting my ears plugging an earphone to a sound output with no volume control and finally getting something compiled …  whoah It’s … alive !!)

The STM32F4DISCOVERY board. Cheap, nice, plenty of extras (accelerometer, I2S sound, DAC..pick any three. Alas, no Ethernet - we're spoiled !)

Top-of-the-line homemade radeon with 12 SMT resistors

Then, fast forward a few moments after with a nicer 12 bits VGA “graphic card” using 1% SMD resistors,  inverting bits which from a nice RRRRGGGGBBBB bit layout set me to a not so nice layout of RRRR(descending)GGGG(descending)B0B0B0B0 - this is NOT a nice and natural layout but that's how it went ! Inconvenient is that computing R,V,B values won't be pretty ... well, keep in mind that

  1. it’s a prototype
  2. it’s software fixable since all my data is converted offline (although computing pixels for effects will be HARD like this)
SO, I got a ~600-er x 480 12bit colors ! Woot !
Other resolutions were around 700 pixels wide ; nice but less clocks per pixel available to put that image to screen.

But …. eh, what’s that ? At every try, output was a little off, colors not so nice, and vertical lines were not that perfect...What was wrong as that the lines were not shut off at the end, so the screen was trying to compensate to get blacks ... so I overclocked the thing a bit (around 10%) to be able to have a nice 640x480 resolution - outputting a nice 25MHz pixel clock, and I fixed the end of lines so that the color bars ended to black at the end of the display, and …

tada ! it worked, the screen didn’t try to fix the colors / fight the sync by setting them completely off…cool, nice colors & all !

So here I am, having a nice 640x480 12 console. … more a single frame photo frame for now, but let's continue it in a next installment..

more on storing pixels

I recently thought about an extra possibility to reduce storage of tiles.

Since we directly store many strings in flash, and that we will store pointers to those strings, I will try to use "string tiling" (which is of course the same word as tiling but with a totally different meaning).

String tiling consists of detecting how to store efficiently N strings given pointers by taking advantage of overlaps.

By example, if you want to store AAAABBBBCCCC and BBBBCCCCDDDD and AABBB, you might as well store AAAABBBBCCCCDDDD only + pointers/length pairs (0,12), (4,12) and (2,4)

My current simple implementation detects for a string when a string begins by another (only partly match is needed, but only at beginning/end of strings respectively), or a string is included withing another (string must be completely included but place is free).

This leads to reduction of up to 17% with real life data, not bad for a free decompression !