Close

Story of a whim (and a splashscreen)

A project log for SMART Response XE BASIC

Turn a SMART Response XE terminal into an 80's flavour pocket computer

fdufnewsfdufnews 01/11/2020 at 22:270 Comments

The whim

When I received my terminals, I first powered them to see if they were operational. I liked the terminal startup screen and found it really attractive. There was a little picture of the terminal in level of gray.

So today I decided there was no reason why my terminal didn't have one.

The Problem

The problem is that a bitmap the size of the display is quite a large amount of bytes.

I first reproduced the bitmap of the original startup screen with GIMP. And, of course, found the file really large. 

To simplify the software in the Arduino the picture was coded 3 pixels in a byte as the display expected it. The file was still large.

The solution

The second step was to find a way to compress the file in a way that allows it to be displayed with the limited power of the Arduino while significantly reducing the size of the file. For this I decided to choose an RLE compression. This type of compression is easy to program and it does not require a large buffer because decompression can be performed on the fly. To simplify data handling, the length of a run was limited to 254 bytes so the length can be stored on a single byte. 

The file is a succession of bytes coding the size and the value each on a byte.

In order for the software to handle any size of picture, the width and the height of the picture are added at the beginning of the file. 

// Original file LogoSMART2.data

#include <avr/pgmspace.h>

const uint8_t bitmap_logo2_rle[384/3*136+4+1] PROGMEM ={
    0x80, 0x01, // image width=384
    0x88, 0x00, // image height=136
    0X82,0x00,0X23,0xff,0X5C,0x00,0X01,0x1f,0X22,0x00,0X01,0x03,0X01,0xe0,0X5B,0x00,
    0X01,0xe0,0X01,0x09,0X21,0x49,0X01,0x40,0X01,0x1f,0X5A,0x00,0X01,0x1f,0X01,0x01,

.....
    0XFE,0x00,0XFE,0x00,0XF3,0x00,0X00,0x00
};

As a remainder, the name of the original picture is inserted as a comment in the header

The array is named bitmap_+<name of the output file>.

The first four bytes of the array are the size of the picture

Following are pairs of size, value, size, value as explained before.

The file ends with a pair of 00.

The tools

I have written a short python script to convert a picture in RAW format into a .h file that can be compiled with the software.

Here are the steps to generate the file:

  1. Create the picture with GIMP using only 4 colors
  2. Convert it to indexed palette
  3. Export to RAW (.data). Two files are generated image.data, image.data.pal (the second is of no use, it can be discarded)
  4. Using the python script a image.h file is generated

The syntaxe of the script is:

python genbitmapRLE.py <image.data> <image.h> <width> <height>

image.data : name of the picture in RAW format

image.h      : name of the generated .h file

width          : width of the picture (see note)

height        : height of the picture (see note)

Note : as RAW files does not contain any information on the geometry of the picture it is necessary to add it by hand.

The result

The source picture is 384 x 136 pixels in 4 level of gray.

After encoding in "display format" the file is 384 x 136 / 3 = 17408 bytes large

After RLE compression the file is 7164 bytes large. This is still quite a large number of data but the ATmega128RFA1 has 128kB of flash so there is currently no problem.

This solution is quite efficient. The full screen picture is displayed in a fraction of a second (I have not made any measure, maybe I will do it one day)

Discussions