Skip to content

Dynamic Image Serving – First Try

April 5, 2015

15-04-05 1861-95
So yesterday, I was able to serve an image that i had pre-stored as binary data in the olduino’s memory. My goal is to serve an image that doesn’t pre-exist but gets made up on the fly when it’s requested.

One model for that is the 1861 video controllers that were used with the 1802 back in the day. The 1861 used DMA to pull data from the 1802’s memory. Each video line was 8 bytes of memory for 64 bits across the screen. The 1861 requested a fresh transfer for each of the 128 screen lines but software would typically adjust pointers so that the same line was delivered multiple times – in my example it’s four times.

The Starship Enterprise bitmap I’ve been using is 128 bits wide by 95 high(the original would have been 64X24). As it happens, the 95 lines consist of 23 sets of 4 identical lines plus 3 identical at the bottom. To do my proof of concept I edited the data and pulled out the duplicates so i only had 24 lines. I also had to edit the bitmap header to add 1 to the row count and 16 to each of total file size and payload size.

I then wrote a delivery routine that sends the header then each of the 24 “scan lines” four times in succession. This displays a bit pattern that never existed, even in memory!

My results are decent with some puzzling elements.
To distinguish the dynamically generated image from the static one I changed the bottom “scan line” which had been blank to be alternating runs of light and dark. Curiously, the pattern showed up at the TOP of the image rather than the bottom. I noticed that the browser was still calling it a 128X95 image; having forgotten to change the row count in the bmp header i thought maybe the browser was wrapping the extra line to the top. When I changed the header and restarted though, the pattern still showed at the top although the browser called it 128X96.
15-04-05 1861-96

This is probably some dumb thing that will shake out as i go along. UPDATE: looking at the binary header below I notice i had changed the row count but not the binary length fields. That’s probably the issue.

I’ve also noticed some odd browser behaviour that may be inconvenient. First of all, as soon as I type as much as “10.0.0.180/b”, the browser autocompletes “/bitmap” AND SENDS THE REQUEST TO THE SERVER! Next, if I start to backspace in the url to change it, the browser again offers the autocomplete AND REFETCHES THE IMAGE! With an ordinary server you wouldn’t know or care but i had visions of having behaviour in the server that would depend on the fetches and this may be incompatible with that plan.

I had put code to turn on the Q LED during the static and the dynamic bitmap send. I don’t have a way of timing them here but the static send is very quick – maybe 1/10 to 1/4 second. The dynamic send seems much longer, maybe a second or more. I can probably reduce it somewhat once i have something stable to work on.

Finally, there’s something just plain wrong with the code. After a few passes through the generated image serving the server dies. Again, this will probably play out as i go along.

I found the original bitmap data here and i’ll probably switch to that anyway. The smaller image will just make for less of the tedious hex editing i’ve been doing.

void send1861bmp(){
	int row=0,cycle=0;
	dynamics++;
	printf("sending the bmp\n");
	asm(" seq\n");
	sendconst(httpbmphdr); 	// Now Send an http header
	sendbin(starship1861hdr);//and the fixed part of thebinary data!
	for (row=0;row<24;row++){
		for (cycle=0;cycle<4;cycle++){
			sendbin(starship1861bin[row]);//and the rest of the binary data!
		}
	}
	asm(" req\n");
}
char starshipbmp[]={0x42,0x4D,0x2E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
0x3E,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x80,0x00,
0x00,0x00,0x5F,0x00,0x00,0x00,0x01,0x00,0x01,0x00,
0x00,0x00,0x00,0x00,0xF0,0x05,0x00,0x00,0x87,0x1D,
0x00,0x00,0x87,0x1D,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
0xFF,0x00,//this is the end of the bmp header
//The following four lines are identical
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//the next four lines are identical
0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
..........And so on ad nauseam - 95 lines total.............
unsigned char starship1861hdr[]={
//        --total file size--(was 2E 06 00 00+16=3E 06 00 00)n.b. little-endian data
0x42,0x4D,0x2E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
0x3E,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x80,0x00,
0x00,0x00,0x60,0x00,0x00,0x00,0x01,0x00,0x01,0x00,
          //rows (was 5f=95)
0x00,0x00,0x00,0x00,0xF0,0x05,0x00,0x00,0x87,0x1D,
//                  ----bitmap size----(was F0 05 00 00+16=00 06 00 00)
0x00,0x00,0x87,0x1D,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
0xFF,0x00};
unsigned char starship1861bin[24][16]=
{
  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
  {0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
   ........and so on for 24 lines total........
Advertisements

From → web server

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: