BBC Micro Mode 7 frame renderer
The idea is to take raw frames intended for the "teletext mode", mode 7, on BBC micros, and render them into a nice-looking PNG. The eventual idea is to do this for many such frames, for example where they might be animated.
The design decisions for this code were a little different to other renderers. I was trying to make something that would do the job quickly and would allow changes to the data at any point in the frame, not just scanning left-to-right. This kind of rendering isn't available just yet, but everything is in place to make it easy to implement.
The neatest way to do it normally would probably be to store the locations of the control characters and when rendering each cell, just scan backwards along that line to see what attributes to use. This then is cheap to edit but expensive to render.
Instead, my code, when a control character is written, will then propagate the attributes along the line for later rendering. This stops us having to then update the characters after the new control character, each of which have to do a full reverse scan of the line. However, we need to store attributes for each character cell, and need to propagate for each new control character found.
Whether this actually has any noticable effect is another matter. I suspect for long sequences of frames as we might find in an animation, it might help with the render time.
Really simple, 25 lines of 40 characters, in the original character set. Everything beyond 40 characters or after 25 lines is ignored.
You need to have the ImageMagick convert command on your path, so the script can convert from the ppm format to png. The Debian/Ubuntu package is "imagemagick".
Have a look at the demo directory, which has some example frames, and the output from them. There is also a reference directory which shows how the testcard frame should look. There is a also a trace directory which shows each character cell's attributes in a text format.
To re-render these frames, run the m7demo program, which also serves as a usage example.
I've been playing around with using cursor control codes to make video from streams of characters in mode 7. There's an example stream in demo/animation by @puppeh for CRTC's BBC teletext video player. You can convert it with the m7animdemo program, but make sure you've got the avconv program, or the whole long process will fail at the last minute!
More example frames (or character streams) are gratefully received.
All of the characters which are meaningful in a PNG conversion like this are supported. The remaining are for things like combining with a television picture, or are just not supported by the BBC Micro teletext chip.
,------------.----------.---------------------. | hex | decimal | description | +------------+----------+---------------------+ | 0x80 | 128 | black text  | | 0x81..0x87 | 129..135 | text | | | | | | 0x88 | 136 | flash | | 0x89 | 137 | steady | | | | | | 0x8a..0x8b | 138..139 | not implemented  | | | | | | 0x8c | 140 | normal height | | 0x8d | 141 | double height | | | | | | 0x8e..0x8f | 142..143 | not implemented  | | | | | | 0x90 | 144 | black graphics  | | 0x91..0x97 | 145..151 | graphics | | | | | | 0x98 | 152 | conceal  | | | | | | 0x99 | 153 | solid graphics | | 0x9a | 154 | separated graphics | | | | | | 0x9b | 155 | does nothing  | | | | | | 0x9c | 156 | black background | | 0x9d | 157 | new background | | | | | | 0x9e | 158 | hold graphics | | 0x9f | 159 | release graphics | `------------^----------^---------------------'  not supported in many adaptors  'end box' and 'start box', which 'punch boxes' in the picture for subtitling.  sometimes 'SO' and 'SI' 'double width' and 'double size' in some adaptors. Heresy.  cancelled with a text or graphics colour change.  ESC (0x1A+0x80=27+128), reserved for compatibility with other data codes.
- Better representation of graphics layers and layer merging.
- Proper documentation maybe.
- Write it in C or something.
SAA5050 datasheet, the reference hardware: http://www-uxsup.csx.cam.ac.uk/~bjh21/BBCdata/SAA5050.pdf
Rob's Teletext preservation project, the source of many of the test frames (thanks Rob): http://www.teletext.org.uk/ Also by Rob, something that does pretty much what this does, and more besides, in PHP: http://www.irrelevant.com/vv/ http://code.google.com/p/viewdataviewer/
There are also a lot of other viewers and converters out there.