Shop OBEX P1 Docs P2 Docs Learn Events
A GUI for the Propeller — Parallax Forums

A GUI for the Propeller

Dr_AculaDr_Acula Posts: 5,484
edited 2011-05-31 10:21 in Propeller 1
A quick update on the crazy GUI project for the propeller. See below for a screenshot.

We now have:
* Button
* Check box
* Radio button
* Textbox
* Label
* Multiline text box with scrollbar
* Mouse
* Different fonts (MS Sans Serif and Courier New 10. More on the way)
* Loading and reloading cogs from within code
* Support for a 20x4 LCD display (this involves starting a cog, pausing Catalina and then restarting the C code)

The cog code was previously being loaded from an SD card, but it works out a bit quicker to include the cog code in the program as an array declaration. Also, this makes the code below completely self contained - no need to put any extra files on an SD card.

Apologies for my style of C programming and some of the lines not being commented.

This is a work in progress, next step is to get more things working when you click on them.

Code below has been split over two posts as the program is too big for the forum!
// GUI demonstration in catalina C  
// compile with catalina -lcx -D PLUGIN -lm -x5 -M 256k -d DRACBLADE -D SHARED_XMM -D HIRES_VGA myprog.c
// compile using XMM

#include <stdio.h>
#include <string.h>
// cogjects - can load from the sd card OR can include here in the external ram array declarations

	char	       lcddisplay[90];					// buffer for LCD display 80 chars plus the column,row data, in external ram
	int click_area[100][5] = {0};					      // list of buttons, text boxes, radio etc where a mouseclick does something x1,y1,x2,y2,objectnumber and initialize to zero with the {0}
	char lineoftext[80]; 						// general purpose string buffer
	char richtext[20][80];						// large text buffer, cols, rows
//	unsigned long screen_external[4800]	;			// external memory for a screen buffer

	unsigned long cogject_color[512] =					// external memory for color vga driver source cog_kye160120.spin
{
    0xa0bc8df0, 0x08bc7c46, 0x80fc8c04, 0x08bc7e46, 
    0x80fc8c04, 0x08bc7646, 0x80fc8c04, 0x08bc7846, 
    0x80fc8c04, 0x08bc7a46, 0xa0bffc3c, 0xa0bff43d, 
    0x58fff00d, 0xa0bc8bf0, 0xa0fc8678, 0xa0fc8404, 
    0xa0bffe35, 0xa0fc8028, 0x08bc8245, 0x80fc8a04, 
    0x68bc823a, 0xfc7c82e4, 0xe4fc8012, 0xa0bffe34, 
    0xfc3c7037, 0x84fc8aa0, 0xe4fc8410, 0x80fc8aa0, 
    0xe4fc860f, 0x80fc8801, 0x003c883f, 0xa0fc800b, 
    0xa0bffe36, 0xfc7c7000, 0xa0bffe34, 0xfc3c7037, 
    0xe4fc8020, 0xa0fc8004, 0xa0bffe36, 0xfc7c7200, 
    0xa0bffe34, 0xfc3c7237, 0xe4fc8026, 0xa0fc801f, 
    0xa0bffe36, 0xfc7c7000, 0xa0bffe34, 0xfc3c7037, 
    0xe4fc802c, 0x02bc823e, 0x7cbfec3b, 0x5c7c000d, 
    0x000100a0, 0x00004010, 0x00000280, 0x00003ffc, 
    0x01030103, 0x00020002, 0x03030303, 0x00000000, 
    0x00000000, 0x00000000, 0x00000000, 0x00000000
};

unsigned long cogject_gray[512] = 					// external memory for gray vga driver, source cog_vga_320_240_gray.spin
{
    0xa0bccbf0, 0x08bcb265, 0x80fcca04, 0x08bcb665, 
    0x80fcca04, 0x08bcb865, 0x80fcca04, 0x08bc9c65, 
    0x80fcca04, 0x08bc9e65, 0x80fcca04, 0x08bca065, 
    0x80fcca04, 0x08bca265, 0x80fcca04, 0x08bca465, 
    0x80fcca04, 0x08bca665, 0x80fcca04, 0x08bca865, 
    0x80fcca04, 0x08bcaa65, 0x80fcca04, 0x08bcac65, 
    0x80fcca04, 0x08bcae65, 0x80fcca04, 0x08bcb065, 
    0x80fcca04, 0x08bcb465, 0xa0bffc4f, 0xa0bff450, 
    0x58fff00d, 0xa0bcbc59, 0xa0bcc054, 0xa0bcbe52, 
    0xa0bffe55, 0xa0bcba57, 0x08bcc25e, 0x80fcbc04, 
    0xfc3cc461, 0xe4fcba26, 0xa0bffe56, 0xfc3c964a, 
    0x84bcbc58, 0xe4fcbe24, 0x80bcbc58, 0xe4fcc023, 
    0x08bcc45a, 0x68bcc44d, 0x80fcc601, 0x003cc65c, 
    0xa0fcba0b, 0xa0bffe49, 0xfc7c9600, 0xa0bffe56, 
    0xfc3c964a, 0xe4fcba35, 0xa0fcba04, 0xa0bffe49, 
    0xfc7c9800, 0xa0bffe56, 0xfc3c984a, 0xe4fcba3b, 
    0xa0fcba1f, 0xa0bffe49, 0xfc7c9600, 0xa0bffe56, 
    0xfc3c964a, 0xe4fcba41, 0x02bcbc5b, 0x7cbfec4e, 
    0x5c7c0021, 0x00000280, 0x00003ffc, 0x01030103, 
    0x00020002, 0x03030303, 0x00000000, 0x00000000, 
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 
    0x00000000
};

unsigned long cogject_mouse[512] =				// source cog_mouse.spin
{
    0xa0bd3bf0, 0x80fd3a14, 0x08bd4a9d, 0x80fd3a04, 
    0x08bd4c9d, 0xa0fd3201, 0x2cbd32a5, 0xa0fd3401, 
    0x2cbd34a6, 0x617d4a20, 0x70bcba96, 0x70bcce96, 
    0x70fcf201, 0x70fd1001, 0x617d4c20, 0x70bcb496, 
    0x70bcc096, 0x70fd0e01, 0x54fc28a0, 0xa0fd3a05, 
    0xa0fc0000, 0x80bc2896, 0xe4fd3a14, 0xa0ffec00, 
    0xa0ffee00, 0xa0fd3601, 0x54fc3aa0, 0xa0bd3bf0, 
    0xa0fd3c05, 0x083c009d, 0x80bc3a96, 0x80fd3a04, 
    0xe4fd3c1d, 0x617d3601, 0xa0f138ff, 0x5cf0e45a, 
    0xa0fd3600, 0x5cfd0473, 0x867d38aa, 0x5c68003e, 
    0xa0bd469c, 0x5cfd0473, 0x617d4610, 0x70bd3898, 
    0x80bd409c, 0x5cfd0473, 0x617d4620, 0x70bd3898, 
    0x80bd429c, 0x60fd4607, 0x857d4802, 0x5c70001a, 
    0x5cfd0473, 0x867d4803, 0x61693810, 0x68e14608, 
    0x61693820, 0x68e14610, 0x2cfd381c, 0x38fd381c, 
    0x84bd449c, 0x5c7c001a, 0x5cfd0473, 0x50fc9a64, 
    0x5cfca84b, 0x50fc9ac8, 0x5cfca84b, 0x28fd3801, 
    0x80fd3801, 0xa0bd489c, 0x50fcaec8, 0x5cfcb255, 
    0xa0fd38f4, 0x5cfce45a, 0x5c7c001a, 0x50fcaec8, 
    0x5cfcb255, 0x50fcae02, 0x5cfcb255, 0x50fcae50, 
    0x5cfcb255, 0xa0fd38f2, 0x5cfce45a, 0x5cfd0473, 
    0x5c7c0000, 0xa0fd38f3, 0x5cfce45a, 0xa0fd3800, 
    0x5cfce45a, 0x5c7c0000, 0x68bfec9a, 0x50fd220d, 
    0x5cfd2a90, 0x68bfec99, 0x50fd2212, 0x5cfd2a90, 
    0x6cbfec9a, 0x617d38ff, 0x74fd3900, 0x68bd3896, 
    0xa0fd3a0a, 0x5cfd1683, 0x29fd3801, 0x74bfec99, 
    0xa0bd128d, 0x5cfd1684, 0xe4fd3a65, 0xa0bd128e, 
    0x5cfd1684, 0xa0bd128f, 0x5cfd1684, 0x5cfd0475, 
    0x867d38fa, 0x5c540017, 0x5c7c0000, 0x617d4c20, 
    0xf43d349a, 0xa0fd3a0b, 0x5cfd1683, 0x50fd2210, 
    0x5cfd2a90, 0x613d33f2, 0x30fd3801, 0xa0bd128d, 
    0x5cfd1684, 0xe4fd3a76, 0x28fd3816, 0x617d39ff, 
    0x5c4c0017, 0x60fd38ff, 0x5c7c0000, 0xa0bd128c, 
    0xa0bd3c97, 0x50fd2212, 0x5cfd2a90, 0x613d35f2, 
    0x623d33f2, 0xe4c13c85, 0xec7d3c17, 0x5c7c0000, 
    0xe4f13c85, 0xe4cd3c85, 0xe4f53c85, 0xe4ed3c85, 
    0x08fd3e00, 0x28fd3e00, 0x48fd3e03, 0x80bd3ff1, 
    0xf8fd3e00, 0x5c7c0000, 0x00000200, 0x000009c4, 
    0xffffff00
};

unsigned long cogject_lcd[512] =						// lcdplug.spin = source
{
    0x0cfd0601, 0x2cfd0602, 0x80bd07f0, 0x08bd0283, 
    0x60bd027d, 0x08bd1081, 0x083d0a81, 0xa0fd0808, 
    0x2cfd0818, 0x68bd0881, 0x083d0883, 0x0abd0681, 
    0x5c68000b, 0xa0bd0488, 0x08bd0682, 0x863d0687, 
    0x5c68001e, 0xa0bd0883, 0x28fd0808, 0x60bd088b, 
    0xa0bd0c83, 0x60bd0c8b, 0x867d0800, 0x5ce8f872, 
    0x867d0801, 0x5ce8d033, 0x867d0802, 0x5ce8e269, 
    0x80fd0404, 0x5c7c000e, 0xa0bfec85, 0x083d0a81, 
    0x5c7c0020, 0x68fd0602, 0x5cfc642c, 0xa0bd01f1, 
    0x80bd008f, 0xf8fd0000, 0x64fd0602, 0x5cfc642c, 
    0xa0bd01f1, 0x80bd008f, 0xf8fd0000, 0x5c7c0000, 
    0xa0bfec8c, 0x60fd06ff, 0x68bd068d, 0xa0bfe883, 
    0x68ffe900, 0xa0bfec85, 0x5c7c0000, 0xa0bd0685, 
    0x5cfc642c, 0xa0bd01f1, 0x80bd007f, 0xf8fd0000, 
    0xa0fd060c, 0x5cfc5621, 0xa0fd060c, 0x5cfc5621, 
    0xa0fd060c, 0x5cfc5621, 0xa0fd0608, 0x5cfc5621, 
    0xa0fd0608, 0x5cfc5621, 0xa0fd0620, 0x5cfc5621, 
    0xa0fd0c0e, 0xa0bd0686, 0x28fd0602, 0x60fd063c, 
    0x5cfc5621, 0xa0bd0686, 0x2cfd0602, 0x60fd063c, 
    0x5cfc5621, 0xa0fd0c01, 0xa0bd0686, 0x28fd0602, 
    0x60fd063c, 0x5cfc5621, 0xa0bd0686, 0x2cfd0602, 
    0x60fd063c, 0x5cfc5621, 0xa0fd0c0d, 0xa0bd0686, 
    0x28fd0602, 0x60fd063c, 0x5cfc5621, 0xa0bd0686, 
    0x2cfd0602, 0x60fd063c, 0x5cfc5621, 0xa0fd0c80, 
    0xa0bd0686, 0x28fd0602, 0x60fd063c, 0x5cfc5621, 
    0xa0bd0686, 0x2cfd0602, 0x60fd063c, 0x5cfc5621, 
    0x5c7c0000, 0xa0bd0686, 0x28fd0602, 0x60fd063c, 
    0x5cfc5621, 0xa0bd0686, 0x2cfd0602, 0x60fd063c, 
    0x5cfc5621, 0x5c7c0000, 0xa0bd0686, 0x28fd0602, 
    0x60fd063c, 0x68fd0601, 0x5cfc5621, 0xa0bd0686, 
    0x2cfd0602, 0x60fd063c, 0x68fd0601, 0x5cfc5621, 
    0x5c7c0000, 0x00ffffff, 0x09896800, 0x00f42400, 
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 
    0x00000000, 0x00000000, 0x00000000, 0xffffffff, 
    0x00000000, 0x00001000, 0x12345678, 0x000000ff, 
    0x00000fff, 0x00000a00, 0x00000002, 0x00004e20
};

// MS Sans Serif font - 128 rows, one for each ascii character 0 to 127
// first long is 0000HHWW where HH is the height in hex and WW is the width in hex (HH is always 0c for this font)
       unsigned long sans_serif_font[1664] =
       {
              0x00000c00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
              0x00000c00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c05,0x00000000, 0x00000009, 0x00000009, 0x00000009, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x00000012, 0x00000012, 0x0000003f, 0x00000012, 0x00000012, 0x00000012, 0x0000003f, 0x00000012, 0x00000012, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000004, 0x0000000e, 0x00000015, 0x00000014, 0x0000000c, 0x00000006, 0x00000005, 0x00000015, 0x0000000e, 0x00000004, 0x00000000, 
              0x00000c08,0x00000000, 0x00000030, 0x00000049, 0x00000032, 0x00000004, 0x00000008, 0x00000010, 0x00000026, 0x00000049, 0x00000006, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000008, 0x00000014, 0x00000014, 0x00000008, 0x00000008, 0x00000015, 0x00000012, 0x00000012, 0x0000000d, 0x00000000, 0x00000000, 
              0x00000c02,0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000001, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000001, 
              0x00000c03,0x00000000, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000002, 
              0x00000c04,0x00000000, 0x00000005, 0x00000002, 0x00000005, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x0000001f, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c05,0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000002, 0x00000002, 0x00000004, 0x00000004, 0x00000008, 0x00000008, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000000e, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000004, 0x0000001c, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000000e, 0x00000011, 0x00000001, 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x0000001f, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000000e, 0x00000011, 0x00000001, 0x00000001, 0x00000006, 0x00000001, 0x00000001, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000002, 0x00000006, 0x00000006, 0x0000000a, 0x0000000a, 0x00000012, 0x0000001f, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000001f, 0x00000010, 0x00000010, 0x0000001e, 0x00000011, 0x00000001, 0x00000001, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000000e, 0x00000011, 0x00000010, 0x00000010, 0x0000001e, 0x00000011, 0x00000011, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000001f, 0x00000001, 0x00000002, 0x00000002, 0x00000004, 0x00000004, 0x00000008, 0x00000008, 0x00000008, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000000e, 0x00000011, 0x00000011, 0x00000011, 0x0000000e, 0x00000011, 0x00000011, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000000e, 0x00000011, 0x00000011, 0x00000011, 0x0000000f, 0x00000001, 0x00000001, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000008, 0x00000004, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001f, 0x00000000, 0x0000001f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000008, 0x00000004, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000000e, 0x00000011, 0x00000001, 0x00000001, 0x00000002, 0x00000004, 0x00000004, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 
              0x00000c0b,0x00000000, 0x00000078, 0x00000186, 0x00000102, 0x00000239, 0x00000249, 0x00000249, 0x00000237, 0x00000100, 0x00000180, 0x0000007c, 0x00000000, 
              0x00000c07,0x00000000, 0x00000008, 0x00000008, 0x00000014, 0x00000014, 0x00000022, 0x00000022, 0x0000003e, 0x00000041, 0x00000041, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x0000003c, 0x00000022, 0x00000022, 0x00000022, 0x0000003c, 0x00000022, 0x00000022, 0x00000022, 0x0000003c, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x0000001e, 0x00000021, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000021, 0x0000001e, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x00000078, 0x00000044, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000044, 0x00000078, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x0000003e, 0x00000020, 0x00000020, 0x00000020, 0x0000003c, 0x00000020, 0x00000020, 0x00000020, 0x0000003e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x0000001f, 0x00000010, 0x00000010, 0x00000010, 0x0000001e, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x0000003c, 0x00000042, 0x00000040, 0x00000040, 0x0000004e, 0x00000042, 0x00000042, 0x00000046, 0x0000003a, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x0000007e, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c05,0x00000000, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000012, 0x00000012, 0x0000000c, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x00000022, 0x00000024, 0x00000028, 0x00000030, 0x00000030, 0x00000028, 0x00000024, 0x00000022, 0x00000021, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x0000001f, 0x00000000, 0x00000000, 
              0x00000c09,0x00000000, 0x00000082, 0x00000082, 0x000000c6, 0x000000c6, 0x000000aa, 0x000000aa, 0x00000092, 0x00000092, 0x00000082, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x00000042, 0x00000062, 0x00000062, 0x00000052, 0x00000052, 0x0000004a, 0x00000046, 0x00000046, 0x00000042, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x0000003c, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x0000003c, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x0000003e, 0x00000021, 0x00000021, 0x00000021, 0x0000003e, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x0000003c, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x0000004a, 0x00000046, 0x0000003c, 0x00000002, 0x00000000, 
              0x00000c08,0x00000000, 0x0000007c, 0x00000042, 0x00000042, 0x00000042, 0x0000007c, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x0000001c, 0x00000022, 0x00000020, 0x00000020, 0x0000001c, 0x00000002, 0x00000002, 0x00000022, 0x0000001c, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x0000003e, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x00000042, 0x0000003c, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x00000041, 0x00000041, 0x00000022, 0x00000022, 0x00000022, 0x00000014, 0x00000014, 0x00000008, 0x00000008, 0x00000000, 0x00000000, 
              0x00000c0b,0x00000000, 0x00000401, 0x00000401, 0x00000222, 0x00000222, 0x00000222, 0x00000154, 0x00000154, 0x00000088, 0x00000088, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x00000041, 0x00000041, 0x00000022, 0x00000014, 0x00000008, 0x00000014, 0x00000022, 0x00000041, 0x00000041, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x00000041, 0x00000041, 0x00000022, 0x00000014, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000000, 0x00000000, 
              0x00000c07,0x00000000, 0x0000007f, 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x0000007f, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000003, 
              0x00000c05,0x00000000, 0x00000008, 0x00000008, 0x00000008, 0x00000004, 0x00000004, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000003, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000003, 
              0x00000c06,0x00000004, 0x0000000a, 0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000003f, 
              0x00000c03,0x00000000, 0x00000002, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000e, 0x00000001, 0x0000000f, 0x00000011, 0x00000011, 0x0000000f, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000010, 0x00000010, 0x00000010, 0x0000001e, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x0000001e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000e, 0x00000011, 0x00000010, 0x00000010, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x0000000f, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x0000000f, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000e, 0x00000011, 0x0000001f, 0x00000010, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000001, 0x00000002, 0x00000002, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x0000000f, 0x00000001, 0x0000001e, 
              0x00000c06,0x00000000, 0x00000010, 0x00000010, 0x00000010, 0x00000016, 0x00000019, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x00000000, 0x00000000, 
              0x00000c02,0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 
              0x00000c02,0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 
              0x00000c06,0x00000000, 0x00000010, 0x00000010, 0x00000010, 0x00000012, 0x00000014, 0x00000018, 0x00000014, 0x00000012, 0x00000011, 0x00000000, 0x00000000, 
              0x00000c02,0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000076, 0x00000049, 0x00000049, 0x00000049, 0x00000049, 0x00000049, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000016, 0x00000019, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000e, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001e, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x0000001e, 0x00000010, 0x00000010, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x0000000f, 0x00000001, 0x00000001, 
              0x00000c03,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 
              0x00000c05,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000006, 0x00000009, 0x00000004, 0x00000002, 0x00000009, 0x00000006, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000002, 0x00000002, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000001, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00000011, 0x00000011, 0x00000011, 0x00000013, 0x0000000d, 0x00000000, 0x00000000, 
              0x00000c06,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00000011, 0x0000000a, 0x0000000a, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 
              0x00000c08,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000049, 0x00000049, 0x00000055, 0x00000055, 0x00000022, 0x00000022, 0x00000000, 0x00000000, 
              0x00000c05,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000009, 0x00000009, 0x00000006, 0x00000006, 0x00000009, 0x00000009, 0x00000000, 0x00000000, 
              0x00000c05,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000009, 0x00000009, 0x00000009, 0x00000009, 0x00000006, 0x00000004, 0x00000004, 0x00000018, 
              0x00000c05,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000f, 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x0000000f, 0x00000000, 0x00000000, 
              0x00000c04,0x00000001, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000004, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000001, 0x00000000, 
              0x00000c02,0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 
              0x00000c04,0x00000004, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000001, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000004, 0x00000000, 
              0x00000c07,0x00000000, 0x00000000, 0x00000019, 0x00000026, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000c03,0x00000000, 0x00000000, 0x00000007, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000005, 0x00000007, 0x00000000, 0x00000000, 
       };

// 128 rows, one for each ascii character 0 to 127
// first long is 0000HHWW where HH is the height in hex and WW is the width in hex
       unsigned long courier10_font[2048] =
       {
              0x00000f00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f00,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000000, 0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000006c, 0x0000006c, 0x00000048, 0x00000048, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000024, 0x00000024, 0x00000048, 0x000000fc, 0x00000048, 0x00000048, 0x000000fc, 0x00000048, 0x00000090, 0x00000090, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000010, 0x00000038, 0x00000048, 0x00000040, 0x00000030, 0x00000008, 0x00000048, 0x00000070, 0x00000010, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x000000a0, 0x00000040, 0x00000018, 0x000000e0, 0x00000010, 0x00000028, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0x00000020, 0x00000020, 0x00000030, 0x00000054, 0x00000048, 0x0000003c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000008, 0x00000008, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000008, 0x00000008, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x00000040, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000040, 0x00000040, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x0000007c, 0x00000010, 0x00000028, 0x00000028, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000010, 0x00000010, 0x000000fe, 0x00000010, 0x00000010, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000030, 0x00000020, 0x00000060, 0x00000040, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000fc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000008, 0x00000008, 0x00000010, 0x00000010, 0x00000020, 0x00000020, 0x00000040, 0x00000040, 0x00000080, 0x00000080, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x00000084, 0x00000084, 0x00000084, 0x00000084, 0x00000084, 0x00000084, 0x00000078, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000070, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000070, 0x00000088, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000088, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000070, 0x00000088, 0x00000008, 0x00000030, 0x00000008, 0x00000008, 0x00000088, 0x00000070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000018, 0x00000028, 0x00000048, 0x00000048, 0x000000fc, 0x00000008, 0x00000008, 0x0000001c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000007c, 0x00000040, 0x00000040, 0x00000078, 0x00000004, 0x00000004, 0x00000084, 0x00000078, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0x00000020, 0x00000040, 0x00000078, 0x00000044, 0x00000044, 0x00000044, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000fc, 0x00000084, 0x00000004, 0x00000008, 0x00000008, 0x00000010, 0x00000010, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x00000084, 0x00000084, 0x00000078, 0x00000084, 0x00000084, 0x00000084, 0x00000078, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x00000084, 0x00000084, 0x00000084, 0x0000007c, 0x00000004, 0x00000008, 0x000000f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000030, 0x00000060, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000018, 0x00000020, 0x000000c0, 0x00000020, 0x00000018, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000fc, 0x00000000, 0x000000fc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000080, 0x00000060, 0x00000010, 0x0000000c, 0x00000010, 0x00000060, 0x00000080, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000038, 0x00000044, 0x00000004, 0x00000004, 0x00000008, 0x00000010, 0x00000000, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000070, 0x00000088, 0x00000088, 0x00000098, 0x000000a8, 0x000000a8, 0x00000098, 0x00000080, 0x00000088, 0x00000070, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000030, 0x00000010, 0x00000028, 0x00000028, 0x00000028, 0x00000038, 0x00000044, 0x000000ee, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000f8, 0x00000044, 0x00000044, 0x00000078, 0x00000044, 0x00000044, 0x00000044, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000003c, 0x00000044, 0x00000080, 0x00000080, 0x00000080, 0x00000080, 0x00000044, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000f0, 0x00000048, 0x00000044, 0x00000044, 0x00000044, 0x00000044, 0x00000048, 0x000000f0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000fc, 0x00000044, 0x00000050, 0x00000070, 0x00000050, 0x00000040, 0x00000044, 0x000000fc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000fc, 0x00000044, 0x00000050, 0x00000070, 0x00000050, 0x00000040, 0x00000040, 0x000000e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000003c, 0x00000044, 0x00000080, 0x00000080, 0x0000008e, 0x00000084, 0x00000044, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000044, 0x0000007c, 0x00000044, 0x00000044, 0x00000044, 0x000000ee, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000007c, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000003c, 0x00000008, 0x00000008, 0x00000008, 0x00000088, 0x00000088, 0x00000088, 0x00000070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000048, 0x00000050, 0x00000070, 0x00000048, 0x00000044, 0x000000e6, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000e0, 0x00000040, 0x00000040, 0x00000040, 0x00000040, 0x00000044, 0x00000044, 0x000000fc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x0000006c, 0x0000006c, 0x00000054, 0x00000054, 0x00000044, 0x00000044, 0x000000ee, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000001ce, 0x000000c4, 0x000000a4, 0x000000a4, 0x00000094, 0x00000094, 0x0000008c, 0x000001cc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000038, 0x00000044, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000044, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000f8, 0x00000044, 0x00000044, 0x00000044, 0x00000078, 0x00000040, 0x00000040, 0x000000e0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000038, 0x00000044, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000044, 0x00000038, 0x0000003e, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000f8, 0x00000044, 0x00000044, 0x00000044, 0x00000078, 0x00000048, 0x00000044, 0x000000e2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000074, 0x0000008c, 0x00000080, 0x00000078, 0x00000004, 0x00000004, 0x000000c4, 0x000000b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000092, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000044, 0x00000044, 0x00000044, 0x00000044, 0x00000044, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000001ce, 0x00000084, 0x00000084, 0x00000048, 0x00000048, 0x00000048, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000044, 0x00000054, 0x00000054, 0x00000054, 0x00000054, 0x00000028, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000028, 0x00000010, 0x00000010, 0x00000028, 0x00000044, 0x000000ee, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000028, 0x00000028, 0x00000010, 0x00000010, 0x00000010, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000007c, 0x00000044, 0x00000008, 0x00000010, 0x00000010, 0x00000020, 0x00000044, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000038, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000038, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000080, 0x00000080, 0x00000040, 0x00000040, 0x00000020, 0x00000020, 0x00000020, 0x00000010, 0x00000010, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000e0, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x000000e0, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000020, 0x00000020, 0x00000050, 0x00000088, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001fe, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000020, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x00000084, 0x0000007c, 0x00000084, 0x0000008c, 0x00000076, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000180, 0x00000080, 0x000000b8, 0x000000c4, 0x00000084, 0x00000084, 0x000000c4, 0x000001b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000074, 0x0000008c, 0x00000080, 0x00000080, 0x00000084, 0x00000078, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000000c, 0x00000004, 0x00000074, 0x0000008c, 0x00000084, 0x00000084, 0x0000008c, 0x00000076, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x00000084, 0x000000fc, 0x00000080, 0x00000080, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0x00000020, 0x000000fc, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x000000fc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000076, 0x0000008c, 0x00000084, 0x00000084, 0x0000008c, 0x00000074, 0x00000004, 0x00000078, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000c0, 0x00000040, 0x00000058, 0x00000064, 0x00000044, 0x00000044, 0x00000044, 0x000000ee, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000000, 0x00000070, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000000, 0x00000078, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x000000f0, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x000000c0, 0x00000040, 0x0000005e, 0x00000048, 0x00000070, 0x00000050, 0x00000048, 0x000000ce, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000030, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001a4, 0x000000da, 0x00000092, 0x00000092, 0x00000092, 0x000001da, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000d8, 0x00000064, 0x00000044, 0x00000044, 0x00000044, 0x000000ee, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000078, 0x00000084, 0x00000084, 0x00000084, 0x00000084, 0x00000078, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000d8, 0x00000064, 0x00000044, 0x00000044, 0x00000044, 0x00000078, 0x00000040, 0x000000e0, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000076, 0x0000008c, 0x00000084, 0x00000084, 0x0000008c, 0x00000074, 0x00000004, 0x0000000e, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000dc, 0x00000060, 0x00000040, 0x00000040, 0x00000040, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000007c, 0x00000084, 0x00000078, 0x00000004, 0x00000084, 0x000000f8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x000000f8, 0x00000040, 0x00000040, 0x00000040, 0x00000044, 0x00000038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000cc, 0x00000044, 0x00000044, 0x00000044, 0x0000004c, 0x00000036, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001ce, 0x00000084, 0x00000048, 0x00000048, 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000054, 0x00000054, 0x00000054, 0x00000028, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000cc, 0x00000048, 0x00000030, 0x00000030, 0x00000048, 0x000000cc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ee, 0x00000044, 0x00000044, 0x00000028, 0x00000028, 0x00000010, 0x00000010, 0x00000070, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000007c, 0x00000048, 0x00000010, 0x00000020, 0x00000044, 0x0000007c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000020, 0x00000020, 0x00000020, 0x00000040, 0x00000020, 0x00000020, 0x00000020, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000040, 0x00000020, 0x00000020, 0x00000020, 0x00000010, 0x00000020, 0x00000020, 0x00000020, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f09,0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000064, 0x00000098, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
              0x00000f08,0x00000000, 0x00000000, 0x00000000, 0x000000fe, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x00000082, 0x000000fe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
       };

780 x 738 - 98K
«1

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-18 07:00
    Rest of the program:
    // start of C functions
    
    void text_clearscreen()                                                   // white text on dark blue background
    {
           int i;
           for (i=0;i<40;i++)
           {
                   t_setpos(0,0,i);                                      // move cursor to next line
                   t_color(0,0x08FC);                                    // RRGGBBxx eg dark blue background 00001000 white text 11111100
           }
    }
    
    void sleep(int milliseconds)                                         // sleep function
    {
           _waitcnt(_cnt()+(milliseconds*(_clockfreq()/1000))-4296);
    }
    
    char peek(int address)                                               // function implementation of peek
    {
           return *((char *)address);
    }
    
    void poke(int address, char value)                                   // function implementation of poke
    {
           *((char *)address) = value;
    }
    
    void pokelong(int address, unsigned long value)				// poke a long into hub memory 'little endian'
    {
    	poke(address+0, (char) (value & 0x000000ff));
    	poke(address+1, (char) ((value & 0x0000ff00) >> 8));
    	poke(address+2, (char) ((value & 0x00ff0000) >> 16));
    	poke(address+3, (char) ((value & 0xff000000) >> 24));
    }
    
    unsigned long peeklong(int address)				// peek a long from hub memory 'little endian'
    {
    	unsigned long value;
    	value = peek(address) | (peek(address+1) <<8) | (peek(address+2) <<16) | (peek(address+3)<<24);
    	return value;
    }
    
    // *************************************************
    //                 Runtime Functions from BCX
    // *************************************************
    
    char *BCX_TmpStr (size_t Bites)
    {
      static int   StrCnt;
      static char *StrFunc[2048];
      StrCnt=(StrCnt + 1) & 2047;
      if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
      return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
    }
    
    char *str (double d)
    {
      register char *strtmp = BCX_TmpStr(24);
      sprintf(strtmp,"% .15G",d);
      return strtmp;
    }
    
    char *hex (int a)
    {
     register char *strtmp = BCX_TmpStr(16);
      sprintf(strtmp,"%X",a);
      return strtmp;
    }
    // *************************************************************
    
    void external_memory_cog_load(int cognumber, unsigned long cogdata[], unsigned long parameters_array[])    	//  load a cog from external memory
    {
    	unsigned long hubcog[512];						// create a local array, this is in hub ram, not external ram	
    	int i;	
    	for(i=0;i<512;i++)								
    	{
    		hubcog[i]=cogdata[i];					// move from external memory to a local array in hub
    	}
     	_coginit((int)parameters_array>>2, (int)hubcog>>2, cognumber);		// load the cog
    }  
    
    int EoF (FILE* stream)
    {
      	register int c, status = ((c = fgetc(stream)) == EOF);
      	ungetc(c,stream);
      	return status;
    }
    
    void readcog(char *filename,unsigned long external_cog[])		// read in a .cog file into external memory array 
    {
    	int i;
    	FILE *FP1;
    	i = 0;
    	if((FP1=fopen(filename,"rb"))==0)					// open the file
       	{
      		fprintf(stderr,"Can't open file %s\n",filename);
    		exit(1);
       	}
      	fseek(FP1,0,0);
    	for(i=0;i<24;i++)
    	{
    		getc(FP1);							// read in the first 24 bytes and discard
    	}
    	i = 0;
      	while(!EoF(FP1) & (i<505))						// run until end of file or 511-6
    	{
    		external_cog[i] = getc(FP1) | (getc(FP1)<<8) | (getc(FP1)<<16) | (getc(FP1)<<24);	// get the long
    		i+=1;
    	}
    	if(FP1)
           {
         		fclose(FP1);							// close the file
         		FP1=NULL;
       	}
    	//printf("external array cog first long = 0x%x \n",external_cog[0]);	// hex value
    }
    
    void pix_clearscreen(unsigned long screen[])
    {
    	int i;
    	for (i=0;i<4800;i++)
    	{
    		screen[i] = 0x00000000;		// fill with black, use longs rather than bytes so 4 pixels per loop
    	}
    }
    
    void pix_pixel(unsigned long screen[], int x, int y, char color)
    {
    	poke((y*160+x+(unsigned long)&screen[0]),color);		
    }
    
    void pix_readscreen(char *filename, unsigned long screen[])		// read a full screen 19200 byte file into the screen
    {
    	int i;
    	FILE *FP1;
    	i = 0;
    	FP1=fopen(filename,"rb");					// open the file
      	fseek(FP1,0,0);
    	for(i=0;i<=4800;i++)
    	{
    		screen[i] = getc(FP1) | (getc(FP1)<<8) | (getc(FP1)<<16) | (getc(FP1)<<24);	// get the long
    	}
    	fclose(FP1);							// close the file
         	FP1=NULL;
    }
    
    char pix_color(char red,char green,char blue)				// pass red,green,blue 0-3, returns a combined value
    {
    	return ((red & 0x3) << 6 ) | ((green & 0x3) << 4) | ((blue & 0x3) << 2);
    }
    
    void pix_screengray(unsigned long screen[])				// whole screen gray
    {
    	int i;
    	for(i=0;i<4800;i++)
    	{
    		screen[i] = 0xa8a8a8a8;					// same as pix_color(2,2,2)
    	}
    }
    
    void pixenginestart(int cognumber, unsigned long cogarray[], unsigned long screen[], unsigned long pingroup, char color_parameters[])
    {
    	int i;
    	unsigned long frequencystate;
    	screen[2] = (0xff << (8*pingroup));
    	screen[3] = (0x300000ff | (pingroup << 9));      
    	frequencystate = ((25175000 + 1600) / 4);
    	screen[4] = 1;
    	for(i=0;i<32;i++)
    	{
    		frequencystate = frequencystate << 1;
    		screen[4] = (screen[4] << 1) | (screen[4] >> 31);
    		if (frequencystate >= _clockfreq())
    		{
    			frequencystate -= _clockfreq();
    			screen[4] += 1;
    		}
    	}
    	color_parameters[0] = 1;			// displayindicator
    	color_parameters[1] = 0;			// syncindicator
    	screen[0] = (unsigned long) &color_parameters[0]; // pointer to displayindicator
    	screen[1] = (unsigned long) &color_parameters[1]; // pointer to syncindicator
    	_cogstop(cognumber); 					// stop just before starting the next one
    	external_memory_cog_load(cognumber,cogarray,screen);		// load from external ram, pass some values in screen[]
    	//pix_clearscreen(screen);					// clear the screen to black
    	pix_screengray(screen);					// screen gray
    }
    
    void pix_colorbar(unsigned long screen[])
    {
    	int x;
    	int c;
    	x = 0;
    	for (c=0;c<64;c++)
    	{
    		pix_pixel(screen,x+10,6,(c<<2));			// print all the colors in a bar
    		x++;
    	}
    }
    
    void pix_line(unsigned long screen[], int startx, int starty, int endx, int endy, char color) 
    {
    	int row;								// also does an unfilled box
    	int col;
    	for(col=startx;col <= endx ;col++)
    	{
    		pix_pixel(screen,col,starty,color);			// horizontal lines
    		pix_pixel(screen,col,endy,color);
    	}
    	for(row=starty;row <= endy;row++)
    	{
    		pix_pixel(screen,startx,row,color);
    		pix_pixel(screen,endx,row,color);
    	}
    }
    
    void pix_box_fill(unsigned long screen[], int startx, int starty, int endx, int endy, char color) 
    {
    	int row;
    	int col;
    	for(row =starty;row <= endy; row++)
    	{
    		for(col=startx;col <=endx; col++)
    		{
    			pix_pixel(screen,col,row,color);			// horizontal line
    		}
    	}
    }
    
    
    void copyscreen(unsigned long source[],unsigned long destination[])
    {
    	memcpy(destination,source,19200);					// a strings.h function
    }
    
    void color_demo(unsigned long screen[],char color_parameters[],int cognumber)					// kye graphics demo
    {
           pixenginestart(cognumber,cogject_color,screen,2,color_parameters);				// start the driver
           pix_pixel(screen,3,3,0x44);
    	pix_pixel(screen,4,4,0xFF);
    	pix_pixel(screen,5,5,pix_color(1,2,3));				// rgb each 0,1,2 or 3
    	pix_line(screen,0,0,159,119,pix_color(3,0,0));			// red border for screen
    	pix_colorbar(screen);						// a color bar
    	pix_line(screen,10,10,30,30,pix_color(3,3,0));		// a yellow box
    	pix_box_fill(screen,10,50,40,60,pix_color(3,0,3));		// magenta filled rectangle
    //	pix_readscreen("wallaby.vga",screen);				// display whole screen image 
    //	copyscreen(screen,screen_external);				// copy to external ram
    //	pix_readscreen("Giraffe.vga",screen);				// display whole screen image 
    //	copyscreen(screen_external,screen);				// copy back to hub
    //	pix_readscreen("prop160.vga",screen);				// display whole screen image
    //	pix_box_fill(screen, 0, 0, 159,119,pix_color(2,2,2));		// whole screen gray	
    }
    
    // ****************** end color screen code *********************************
    
    // ******************* LCD 20x4 routines *****************************************
    
    int external_plugin_cog_load(int cognumber, unsigned long cogdata[])    	//  load a plugin from external memory
    {
    	unsigned long hubcog[512];						// create a local array, this is in hub ram, not external ram
    	int i;
    	int result;
    	for(i=0;i<512;i++)
    	{
    		hubcog[i]=cogdata[i];					// move from external memory to a local array in hub
    	}
     	_coginit (_registry() >> 2, (int) hubcog >> 2, cognumber); 	// pass the registry, location of cog data and cog to load into
    	return result;
    }
    
    void pass_plugin_data(unsigned long p_array[],int cognumber)
    {
    	int reg;
    	int a;								
    	unsigned long b,c;
    //	print_registry();
    	reg = _registry();
    	a=reg + (cognumber << 2); 						// registry + cognumber *4
    	b=peeklong(a);							// get the registry for this cog ff007fcc
    	b = b & 0x0000ffff;							// mask off upper two bytes
    	c = (unsigned long) &p_array[0];					// pointer to p_array
    //	printf("pointer value is %x \n",c);
    	pokelong(b,c);							// address,value 7fcc now contains a pointer to the p_array[0]
    //	print7fcc();			
    }
    
    
    
    void init_lcd(int cognumber)
    {
    	unsigned long lcd_array[10]; 					// temporary array for sending a string of data to the LCD
    	int i;
    	lcd_array[0] = 0x00000100;						// command to initialise nnnn01nn
    	lcd_array[1] = 0x0000020e;						// cursor on
    	lcd_array[2] = 0x00000201;						// cls
    	lcd_array[3] = 0x0000020d;						// flashing cursor
    	lcd_array[4] = 0x00000280;						// top left hand corner
    	lcd_array[5] = 0xffffffff;						// finish command = -1
    
    
    	pass_plugin_data(lcd_array,cognumber);				// tell the plugin where the data is
    	external_plugin_cog_load(cognumber, cogject_lcd);		// move plugin from external memory to cog 7
    	_sys_plugin(8, 1);   						// 8 is dummy plugin, and 1 is any non zero number
    	for(i=0;i<80;i++)
    	{
    		lcddisplay[i]=32;						// clear the buffer to spaces(common hub array)
    	}
    	lcddisplay[80]=0;							// column 0-19
    	lcddisplay[81]=1;							// line number 1,2,3 or 4
    }
    
    void redraw(int cognumber)							// redraw the entire screen
    {
    	int linenumber;
    	int n,m,i,j,c;
    	unsigned long lcd_array[90];					// enough room to pass all 80 characters and start and finish
    	linenumber = (int) lcddisplay[81];					// get the linenumber in a local variable
    	n = (linenumber - 1) * 20;						// convert to a pointer to the correct array location
    	lcd_array[0] = 0x00000280;						// instruction (02) and value (0x80 = 128 = line 1)
    	lcd_array[21] = 0x000002c0;						// instruction (02) and value (0xC0 = 192 = line 2)
    	lcd_array[42] = 0x00000294;						// instruction (02) and value (0x94 = 148 = line 3)
    	lcd_array[63] = 0x000002d4;						// instruction (02) and value (0xD4 = 212 = line 4)
    	lcd_array[84] = 0x000002d4;						// instruction (02) and value (0xD4 = 212 = line 4) at end
    	lcd_array[85] = 0x0000020d;						// flashing cursor
    	lcd_array[86] = 0xffffffff;						// finish command
    	n=1;
    	m=0;
    	for(i=0;i<20;i++)
    	{
    		lcd_array[n]=lcddisplay[m];					// move in data 20 chars at a time
    		m++;
    		n++;
    	}
    	n=22;
    	m=20;
    	for(i=0;i<20;i++)
    	{
    		lcd_array[n]=lcddisplay[m];					// move in data 20 chars at a time
    		m++;
    		n++;
    	}
    	n=43;
    	m=40;
    	for(i=0;i<20;i++)
    	{
    		lcd_array[n]=lcddisplay[m];					// move in data 20 chars at a time
    		m++;
    		n++;
    	}
    	n=64;
    	m=60;
    	for(i=0;i<20;i++)
    	{
    		lcd_array[n]=lcddisplay[m];					// move in data 20 chars at a time
    		m++;
    		n++;
    	}
      										// load cog, send out all data, hand control back to catalina
    	pass_plugin_data(lcd_array,cognumber);				// tell the plugin where the data is
    	external_plugin_cog_load(cognumber, cogject_lcd);		// move plugin from external memory to hub ram
    	_sys_plugin(8, 1);   						// and start it 8 is dummy plugin, and 1 is any non zero number
    }
    
    void newline(int cognumber)							// move the line up by 1, clear line 4, move cursor to start of line 4
    {
    	int i;
    	for(i=0;i<60;i++)
    	{
    		lcddisplay[i] = lcddisplay[i+20];				// shuffle up a line
    	}
    	for(i=60;i<80;i++)
    	{
    		lcddisplay[i] = 32;						// spaces on the last line
    	}
    	lcddisplay[80]=0;							// column = 0
    	redraw(cognumber);
    }
    
    
    void printf_lcd(int cognumber, char textstring[])	// note that this loads and unloads a cog to print just one char so do in a group if print a string
    {
    	int col,i,length,p,overflow;
    	unsigned long lcd_array[20];					// enough room to pass characters
    	col = (int) lcddisplay[80];						// get the column number
    	length = strlen(textstring);
    //	printf("length is %i \n",length);
    	overflow = col+length-20;						// off the end?
    	if (overflow <0) overflow = 0;
    	for(i=0;i < length -overflow;i++)
    	{
    		lcddisplay[60 + col + i] = textstring[i];			// store in the screen buffer
    //		printf("value of i is %i \n",i);
    	}
    	for(i=0;i < length - overflow;i++)
    	{
    		lcd_array[i] = textstring[i];				// print out
    	}
    	p = length;	
    										// pointer to where we are up to
    //	printf("length is %i \n",p);
    	if (col+length >19)
    	{
    		lcd_array[p] = 0x0000020c;					// cursor off if last char on the line
    //		printf("cursor off \n");
    		p++;
    	}
    	lcd_array[p] = 0xffffffff;						// terminate command
    	col = col + length;
    //	printf("column is %i \n",col);
    	lcddisplay[80] = (char) col;					// put the column number back in the array
    	pass_plugin_data(lcd_array,cognumber);				// tell the plugin where the data is
    	external_plugin_cog_load(cognumber, cogject_lcd);		// move plugin from external memory to hub ram
    	_sys_plugin(8, 1);   						// and start it 8 is dummy plugin, and 1 is any non zero number	
    }
    
    //void backspace(int cognumber)
    //{
    // backspace is a special case - need to subtract 1 off the column, make the last character a space
    // and redraw the screen and print out column number of characters on last line
    // only really works on line 4 but most of the time the display is on line 4 anyway
    // not working as yet
    //	int col,i;
    //	char tempstring[20];
    //	col = (int) lcddisplay[80];						// get the column number
    //	if ((col>1) & (col<20))
    //	{
    //		lcddisplay[col + 60] = 32;				// was 1 past the character
    //		col--;
    //	}
    //	lcddisplay[80] = (char) col;					// put the column number back in the array
    //	redraw(cognumber);							// cursor to beginning of the last line
    //	for(i=0;i<(col-2);i++)
    //	{
    //		tempstring[i]=lcddisplay[60+i];				// print out characters on the last line so cursor in the right place
    //	}
    //	tempstring[col-2] = 0;						// terminator
    //	printf("temp string is ",tempstring);
    //	printf_lcd(cognumber,tempstring);
    //}
    
    
    void lcd_demo()
    {
    //	printf("Read in LCD display driver 'lcdplug.cog' \n");
    //	readcog("lcdplug.cog",cogject_lcd);				// read from sd card into an external memory array
    	init_lcd(7);								// clear the screen, turn on the cursor
    	redraw(7);								// redraw the lcd, using driver in cog 7
    	newline(7);								// scroll up a line
    	strcpy(lineoftext, "Catalina Demo");
    	printf_lcd(7,lineoftext);						// print string (reloads cog)
    //	strcpy(lineoftext, "World");
    //	printf_lcd(7,lineoftext);						// print string (reloads cog)
    //	newline(7);								// scroll
    //	sleep(2000);
    //	redraw(7);								// check same as on the display
    //	printf("Finish \n");
    //	printf("debug value @ 0x1000 = 0x%x \n",peeklong(0x1000));		// useful debug location
    //       while (1);                                                    // Prop reboots on exit from main()
    }
    
    
    
    // ****************** begin gray screen code ********************************
    
    
    void gray_pixel(unsigned long screen[], unsigned long x, unsigned long y, unsigned long color)
    {
    	// unsigned long bitsperpixel = gray_parameters[3];
    	unsigned long bitsperpixel = 1;		// always is 1
    	unsigned long i;
    	i = (x >>4) + (20 * y);		// i = the long that contains our pixel	
           x = ((x & (0x1f >> bitsperpixel)) << bitsperpixel);
    	//mask = (0x3 << xpixel); 	// xpixel holds the number of bits to shift to the left, and invert this
    	//mask = ~mask;				// invert this
    	screen[i] = (( screen[i] & ~(0x3 << x)) | (color << x)); // do the and with a mask and the or in one line
    }
    
    
    int gray_printf(unsigned long screen[],int startx, int starty, char lineoftext[])
    {
    	int width,ascii,a,x,y,i,curx,fontheight;
    	unsigned long font;
    	fontheight = sans_serif_font[0] >>8;
    	curx=startx;							// cursor
    	for(i=0;i<strlen(lineoftext);i++)				// get each letter in the string
    	{
    		ascii=lineoftext[i];
    		a=ascii * (fontheight+1);				// calculate the address of the character, the 1 is because the first long is the height/width data
    		width = sans_serif_font[a] & 0x000000FF;		// mask out the height
    		for(y=0;y<fontheight;y++)				// one row at a time
    		{
    			font=sans_serif_font[a+y+1];		// get the font long
    			for(x=0;x<width;x++)				// do each pixel
    			{
    				if((font & 0x00000001) == 1)	// test if a 1
    				{
    					gray_pixel(screen,curx+(width-1-x),starty+y,0x00);
    				}
    				font = font >> 1;			// shift in the next bit
    			}
    		}
    		curx += width;					// move cursor along by width amount
    	}
    	return curx-startx;						// return the width of all the text
    }
    
    int gray_printf_courier10(unsigned long screen[],int startx, int starty, char lineoftext[])
    {
    	int width,ascii,a,x,y,i,curx,fontheight;
    	unsigned long font;
    	fontheight = courier10_font[0] >>8;
    	curx=startx;							// cursor
    	for(i=0;i<strlen(lineoftext);i++)				// get each letter in the string
    	{
    		ascii=lineoftext[i];
    		a=ascii * (fontheight+1);				// calculate the address of the character, the 1 is because the first long is the height/width data
    		width = courier10_font[a] & 0x000000FF;		// mask out the height
    		for(y=0;y<fontheight;y++)				// one row at a time
    		{
    			font=courier10_font[a+y+1];		// get the font long
    			for(x=0;x<width;x++)				// do each pixel
    			{
    				if((font & 0x00000001) == 1)	// test if a 1
    				{
    					gray_pixel(screen,curx+(width-1-x),starty+y,0x00);
    				}
    				font = font >> 1;			// shift in the next bit
    			}
    		}
    		curx += width;					// move cursor along by width amount
    	}
    	return curx-startx;						// return the width of all the text
    }
    
    void gray_debug_hex(unsigned long screen[],unsigned long hexnumber) // print a debug hex value on the screen at x=10, y=200
    {
    	int i,j;
    	char lineoftext[20];
    	for(j=0;j<12;j++)
    	{
    		for(i=4000;i<4006;i++)					// clear the previous text
    		{
    			screen[i+(20*j)]=0xaaaaaaaa;				// light gray
    			//screen[i+(20*j)]=0xffffffff;				// white
    
    		}
    	}
    	strcpy(lineoftext,hex(hexnumber));
    	gray_printf(screen,10,200,lineoftext);
    }
    
    void gray_debug_dec(unsigned long screen[],unsigned long decnumber) // print a debug decimal value on the screen at x=10, y=212
    {
    	int i,j;
    	char lineoftext[20];
    	for(j=0;j<12;j++)
    	{
    		for(i=4240;i<4246;i++)					// clear the previous text
    		{
    			screen[i+(20*j)]=0xaaaaaaaa;				// light gray
    			//screen[i+(20*j)]=0xffffffff;				// white
    		}
    	}
    	strcpy(lineoftext,str(decnumber));
    	gray_printf(screen,10,212,lineoftext);
    }
    
    void gray_clearscreen(unsigned long screen[])
    {
    	int i;
    	for (i=0;i<4800;i++)
    	{
    		screen[i] = 0xaaaaaaaa;		// fill with light gray, use longs rather than bytes so 4 pixels per loop
    	}
    }
    
    void gray_fastwhiteline(unsigned long screen[], int startx, int pixels, int starty) // drawing a line with pixels is slow so do as a whole long
    {
    	int r,n,m,a,c,b;						// errors for values of pixels < 32 but this is mainly for large fills
    	int finishx;
    	unsigned long i;
    	finishx = startx + pixels;
    	c = startx;
    	r = startx % 16;						// get the remainder when divided by 16
    	for(n=0;n<(16-r);n++)
    	{
    		gray_pixel(screen,n+startx,starty,0x3);		// print the first few one at a time till gets to next long
    		c++;							// add to counter
    	}
    	i = (startx >>4) + (20 * starty);				// i = the long that contains our pixel	
    	if (r != 0) i++;						// get next long
    	n = (pixels -(16-r)) >> 4;						// number of longs to change (subtract ones already done and divide by 16)
    	for(m=0;m < n;m++)
    	{
    		screen[i+m] = 0xffffffff;				// white
    		c = c+16;
    	}
    	a = pixels - ((16-r) + (n << 4));				// number of pixels left
    	for(m=0;m<=a;m++)
    	{
    		gray_pixel(screen,m+c,starty,0x3);			// fill in the last few pixels
    	}
    }
    /*
    void testline(unsigned long screen[])
    {
    	int x,y,width;
    	y=20;
    	for(x=40;x<80;x++)
    	{
    		for(width=30;width<100;width++)
    		{
    			gray_fastwhiteline(screen,x,width,y);
    			y++;
    		}
    		y=20;
    		gray_clearscreen(screen);
    	}
    
    }
    */
    
    void click_areas_add(int x, int y, int sizex, int sizey, int objectnumber)
    {
    	int i = 0;
    	while (click_area[i][0] != 0)						// get the first free entry
    	{
    		i +=1;
    	}
    	click_area[i][0] = x;
    	click_area[i][1] = y;
    	click_area[i][2] = x + sizex;
    	click_area[i][3] = y + sizey;
    	click_area[i][4] = objectnumber;
    }
    
    void gray_horizontal_line(unsigned long screen[], int startx, int starty, int sizex, char color) 
    {
    	int col;	
    	for(col=startx;col <= startx+sizex ;col++)
    	{
    		gray_pixel(screen,col,starty,color);			// horizontal line
    	}
    }
    
    void gray_vertical_line(unsigned long screen[], int startx, int starty, int sizey, char color) 
    {
    	int row;	
    	for(row=starty;row <= starty+sizey;row++)
    	{
    		gray_pixel(screen,startx,row,color);			// vertical line
    	}
    }
    
    void gray_box_fill(unsigned long screen[], int startx, int starty, int sizex, int sizey, char color) 
    {
    	int row,col;
    	for(row =starty;row <= starty+sizey; row++)
    	{
    		for(col=startx;col <= startx+sizex; col++)
    		{
    			gray_pixel(screen,col,row,color);			// fill in pixels
    		}
    	}
    }
    
    void gray_box_fast_white(unsigned long screen[],int startx, int starty, int sizex, int sizey) // faster than above 
    {
    	int row,col;
    	for(row =starty;row <= starty+sizey; row++)
    	{
    		gray_fastwhiteline(screen, startx, sizex, row);
    	}
    
    }
    
    
    void gray_groupbox(unsigned long screen[], int startx, int starty, int sizex, int sizey, char lineoftext[])
    {
    	int textwidth;
    	gray_horizontal_line(screen,startx,starty,10,0x1);						// dark gray horizontal line
    	gray_horizontal_line(screen,startx+1,starty+1,9,0x3);						// white horizontal line
    	gray_vertical_line(screen,startx,starty,sizey,0x1);						// dark gray vertical
    	gray_vertical_line(screen,startx+1,starty+1,sizey-1,0x3);					// white vertical
    	gray_horizontal_line(screen,startx,starty+sizey,sizex,0x1);					// dark gray horizontal line
    	gray_horizontal_line(screen,startx,starty+sizey+1,sizex+1,0x3);				// white horizontal line
    	gray_vertical_line(screen,startx+sizex,starty,sizey,0x1);					// dark gray vertical
    	gray_vertical_line(screen,startx+sizex+1,starty,sizey,0x3);					// white vertical
    	textwidth = gray_printf(screen, startx+14,starty-4,lineoftext);				// print the frame title
    	gray_horizontal_line(screen,startx+18+textwidth,starty,sizex-textwidth-18,0x1);		// dark gray horizontal line
    	gray_horizontal_line(screen,startx+18+textwidth,starty+1,sizex-textwidth-19,0x3);		// white horizontal line
    }
    
    void gray_button(unsigned long screen[],int startx, int starty, int sizex, int sizey, char lineoftext[],int objectnumber,int task)
    {
    	gray_vertical_line(screen, startx, starty, sizey, 0x3);					// white vertical line
    	gray_horizontal_line(screen, startx, starty, sizex, 0x3);					// white horizontal line
    	gray_vertical_line(screen, startx+sizex, starty+1, sizey-1, 0x1); 				// vertical dark gray line
    	gray_horizontal_line(screen, startx+1, starty+sizey, sizex, 0x1); 				// horizontal dark gray line
    	gray_vertical_line(screen, startx+sizex+1, starty, sizey+1, 0x0); 				// vertical black line
    	gray_horizontal_line(screen, startx, starty+sizey+1, sizex+1, 0x0); 				// horizontal black line
    	gray_printf(screen,startx+4,starty+4,lineoftext);						// print the button text
    	if (task == 1) click_areas_add(startx,starty,sizex,sizey,objectnumber);			// add to list of areas that can be clicked
    }
    
    void gray_text(unsigned long screen[], int startx, int starty, int sizex, int sizey, char lineoftext[], int objectnumber,int task)
    {
    //	gray_box_fill(screen, startx+1, starty+1, sizex-2, sizey-2,0x3);				// white centre
    	gray_box_fast_white(screen, startx+1, starty+1, sizex-2, sizey-2);				// white centre faster
    	gray_vertical_line(screen, startx, starty, sizey-1, 0x0);					// black vertical line
    	gray_horizontal_line(screen, startx, starty, sizex-1,  0x0);					// black horizontal line
    	gray_vertical_line(screen, startx+sizex, starty+1, sizey,0x2); 				// vertical light gray line
    	gray_horizontal_line(screen, startx, starty+sizey, sizex, 0x2); 				// horizontal light gray line
    	gray_vertical_line(screen, startx-1, starty-1, sizey+1, 0x1);					// dark gray vertical line
    	gray_horizontal_line(screen, startx-1, starty-1, sizex+1, 0x1);				// dark gray horizontal line
    	gray_vertical_line(screen, startx+sizex+1, starty-1, sizey+2, 0x3);				// vertical whiteline
    	gray_horizontal_line(screen, startx-1, starty+sizey+1, sizex+1, 0x3);			// horizontal whiteline
    	gray_printf(screen,startx+2,starty+2,lineoftext);						// print the text
    	if (task == 1) click_areas_add(startx,starty,sizex,sizey,objectnumber);			// add to list of areas that can be clicked
    }
    
    void gray_verticalscroll(unsigned long screen[],int startx, int starty, int sizey, int percent)
    {
    	int x,y,p;
    	p = 16 + (percent * (sizey - 16 *2)) / 100;							// position of the scrollbar
    
    	for(y=starty+16;y < (starty+sizey-16);y+=2)
    	{
    		for(x=startx;x < (startx + 16);x+=2)
    		{
    			gray_pixel(screen,x,y,0x2);								// light gray hash pattern
    			gray_pixel(screen,x+1,y,0x3);							
    			gray_pixel(screen,x+1,y+1,0x2);
    			gray_pixel(screen,x,y+1,0x3);
    		}
    	}
    													// upper box
    	gray_horizontal_line(screen,startx,starty,15,0x2);						// light gray horizontal line
    	gray_horizontal_line(screen,startx+1,starty+1,13,0x3);						// white horizontal line
    	gray_horizontal_line(screen,startx+1,starty+14,13,0x1);					// dark gray horizontal line
    	gray_horizontal_line(screen,startx,starty+15,15,0x0);						// black horizontal line
    	gray_box_fill(screen, startx+2, starty+2, 11, 11,0x2);						// light gray box
    	gray_vertical_line(screen, startx, starty, 14, 0x2);						// light gray vertical line
    	gray_vertical_line(screen, startx+1, starty+1, 12, 0x3);					// white vertical line
    	gray_vertical_line(screen, startx+14, starty+1, 13, 0x1);					// dark gray vertical line
    	gray_vertical_line(screen, startx+15, starty, 15, 0x0);					// black vertical line
    	gray_pixel(screen,startx+7,starty+6,0x0);								// triangle
    	gray_horizontal_line(screen,startx+6,starty+7,2,0x0);						// triangle
    	gray_horizontal_line(screen,startx+5,starty+8,4,0x0);						// triangle
    	gray_horizontal_line(screen,startx+4,starty+9,6,0x0);						// triangle
    													// lower box
    	gray_horizontal_line(screen,startx,starty+sizey-17,15,0x2);					// light gray horizontal line
    	gray_horizontal_line(screen,startx+1,starty+sizey-16,13,0x3);					// white horizontal line
    	gray_horizontal_line(screen,startx+1,starty+sizey-3,13,0x1);					// dark gray horizontal line
    	gray_horizontal_line(screen,startx,starty+sizey-2,15,0x0);					// black horizontal line
    	gray_box_fill(screen, startx+2, starty+sizey-15, 11, 11,0x2);					// light gray box
    	gray_vertical_line(screen, startx, starty+sizey-17, 14, 0x2);					// light gray vertical line
    	gray_vertical_line(screen, startx+1, starty+sizey-16, 12, 0x3);				// white vertical line
    	gray_vertical_line(screen, startx+14, starty+sizey-16, 13, 0x1);				// dark gray vertical line
    	gray_vertical_line(screen, startx+15, starty+sizey-17, 15, 0x0);				// black vertical line
    	gray_pixel(screen,startx+7,starty+sizey-8,0x0);							// triangle
    	gray_horizontal_line(screen,startx+6,starty+sizey-9,2,0x0);					// triangle
    	gray_horizontal_line(screen,startx+5,starty+sizey-10,4,0x0);					// triangle
    	gray_horizontal_line(screen,startx+4,starty+sizey-11,6,0x0);					// triangle
    													// scrollbar
    	gray_horizontal_line(screen,startx,starty+p,15,0x2);						// light gray horizontal line
    	gray_horizontal_line(screen,startx+1,starty+1+p,13,0x3);					// white horizontal line
    	gray_horizontal_line(screen,startx+1,starty+14+p,13,0x1);					// dark gray horizontal line
    	gray_horizontal_line(screen,startx,starty+15+p,15,0x0);					// black horizontal line
    	gray_box_fill(screen, startx+2, starty+2+p, 11, 11,0x2);					// light gray box
    	gray_vertical_line(screen, startx, starty+p, 14, 0x2);						// light gray vertical line
    	gray_vertical_line(screen, startx+1, starty+1+p, 12, 0x3);					// white vertical line
    	gray_vertical_line(screen, startx+14, starty+1+p, 13, 0x1);					// dark gray vertical line
    	gray_vertical_line(screen, startx+15, starty+p, 15, 0x0);					// black vertical line
    								
    }
    
    void gray_richtext(unsigned long screen[], int startx, int starty, int sizex, int sizey, int objectnumber,int task)
    {
    	int row,col;
    
    //	gray_box_fill(screen, startx+1, starty+1, sizex-2, sizey-2,0x3);				// white centre
    	gray_box_fast_white(screen, startx+1, starty+1, sizex-2, sizey-2);				// white centre faster
    	gray_vertical_line(screen, startx, starty, sizey-1, 0x0);					// black vertical line
    	gray_horizontal_line(screen, startx, starty, sizex-1,  0x0);					// black horizontal line
    	gray_vertical_line(screen, startx+sizex, starty+1, sizey,0x2); 				// vertical light gray line
    	gray_horizontal_line(screen, startx, starty+sizey, sizex, 0x2); 				// horizontal light gray line
    	gray_vertical_line(screen, startx-1, starty-1, sizey+1, 0x1);					// dark gray vertical line
    	gray_horizontal_line(screen, startx-1, starty-1, sizex+1, 0x1);				// dark gray horizontal line
    	gray_vertical_line(screen, startx+sizex+1, starty-1, sizey+2, 0x3);				// vertical whiteline
    	gray_horizontal_line(screen, startx-1, starty+sizey+1, sizex+1, 0x3);			// horizontal whiteline
    
    	gray_verticalscroll(screen,startx+sizex-16,starty+1,sizey,10);				// scrollbar
    	for(row=0;row<20;row++)
    	{
    		strcpy(lineoftext,richtext[row]);
    		gray_printf_courier10(screen,startx+2,starty+2+(row*13),lineoftext);				// print the text ? use font height instead of 13
    	}
    	if (task == 1) click_areas_add(startx,starty,sizex,sizey,objectnumber);			// add to list of areas that can be clicked
    }
    
    void gray_checkbox(unsigned long screen[], int startx, int starty, char check, char lineoftext[]) // check box
    {
    	int sizex = 10;
    	int sizey = 10;
    	int x,y,i = 0;
    	char tick[49] = {
    	0x3,0x3,0x3,0x3,0x3,0x3,0x0,			// black = 0x0, dark gray = 0x1, light gray = 0x2, white = 0x3
    	0x3,0x3,0x3,0x3,0x3,0x0,0x0,
    	0x0,0x3,0x3,0x3,0x0,0x0,0x0,
    	0x0,0x0,0x3,0x0,0x0,0x0,0x3,
    	0x0,0x0,0x0,0x0,0x0,0x3,0x3,
    	0x3,0x0,0x0,0x0,0x3,0x3,0x3,
    	0x3,0x3,0x0,0x3,0x3,0x3,0x3,
    	};
    	gray_box_fill(screen, startx+1, starty+1, sizex-2, sizey-2,0x3);				// white centre
    	gray_vertical_line(screen, startx, starty, sizey-1, 0x0);					// black vertical line
    	gray_horizontal_line(screen, startx, starty, sizex-1,  0x0);					// black horizontal line
    	gray_vertical_line(screen, startx+sizex, starty+1, sizey,0x2); 				// vertical light gray line
    	gray_horizontal_line(screen, startx, starty+sizey, sizex, 0x2); 				// horizontal light gray line
    	gray_vertical_line(screen, startx-1, starty-1, sizey+1, 0x1);					// dark gray vertical line
    	gray_horizontal_line(screen, startx-1, starty-1, sizex+1, 0x1);				// dark gray horizontal line
    	gray_vertical_line(screen, startx+sizex+1, starty-1, sizey+2, 0x3);				// vertical whiteline
    	gray_horizontal_line(screen, startx-1, starty+sizey+1, sizex+1, 0x3);			// horizontal whiteline
    	if(check != 0)
    	{												// print the tick if check not zero
    		for(y=0;y<7;y++)
    		{
    			for(x=0;x<7;x++)
    			{
    				if(tick[i] == 0x0)							// is it black?
    				{
    					gray_pixel(screen,startx+x+2, starty+y+2, tick[i]);	// draw the tick pixel
    				}
    				i++;
    			}
    		}
    	}
    	gray_printf(screen,startx+16,starty,lineoftext);						// print the text
    }
    
    void gray_radio(unsigned long screen[], int startx, int starty, char check,char lineoftext[])
    {
    	char radio[144] = {				// black = 0x0, dark gray = 0x1, light gray = 0x2, white = 0x3
    	0x2,0x2,0x2,0x2,0x1,0x1,0x1,0x1,0x2,0x2,0x2,0x2,	// a radio button
    	0x2,0x2,0x1,0x1,0x0,0x0,0x0,0x0,0x1,0x1,0x2,0x2,
    	0x2,0x1,0x0,0x0,0x3,0x3,0x3,0x3,0x0,0x0,0x3,0x2,
    	0x2,0x1,0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x2,0x3,0x2,
    	0x1,0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x2,0x3,
    	0x1,0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x2,0x3,
    	0x1,0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x2,0x3,
    	0x1,0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x2,0x3,
    	0x2,0x1,0x0,0x3,0x3,0x3,0x3,0x3,0x3,0x2,0x3,0x2,
    	0x2,0x1,0x2,0x2,0x3,0x3,0x3,0x3,0x2,0x2,0x3,0x2,
    	0x2,0x2,0x3,0x3,0x2,0x2,0x2,0x2,0x3,0x3,0x2,0x2,
    	0x2,0x2,0x2,0x2,0x3,0x3,0x3,0x3,0x2,0x2,0x2,0x2
    	};
    	int x;
    	int y;
    	int i = 0;
    	if(check !=0)
    	{
    		radio[53]=radio[54]=0x00;
    		radio[64]=radio[65]=radio[66]=radio[67]=0x00;		// draw the circle in the middle
    		radio[76]=radio[77]=radio[78]=radio[79]=0x00;
    		radio[89]=radio[90]=0x00;
    	}
    	for(y=0;y<12;y++)
    	{
    		for(x=0;x<12;x++)
    		{
    			gray_pixel(screen,startx+x, starty+y, radio[i]);	// draw a radio button, white centre
    			i++;
    		}
    	}
    	gray_printf(screen,startx+16,starty,lineoftext);			// print the text
    }
    
    void gray_mousepointer(unsigned long screen[],unsigned long mousebuffer[],int x, int y) 			// 21 high, 13 wide = 1 long wide 
    {
    	unsigned long mouse_mask[21] = {							// mask 00=pixel, 11=transparant
    	0xfffffff0,0xffffffc0,0xffffff00,0xfffffc00,0xfffff000,0xffffc000,	// order is reversed in each long
    	0xffff0000,0xfffc0000,0xfff00000,0xffc00000,0xff000000,0xfc000000,
    	0xfffc0000,0xfffc0000,0xfff00300,0xfff003c0,0xffc00ff0,0xffc00fff,
    	0xff003fff,0xff003fff,0xffc0ffff
    	};
    	unsigned long mouse_icon[21] = {							// icon, 00, 01, 10 or 11=pixel, 00 = transparent if transparent above
    	0x00000004,0x00000010,0x0000004c,0x0000013c,0x000004fc,0x000013fc,
    	0x00004ffc,0x00013ffc,0x0004fffc,0x0013fffc,0x004ffffc,0x01003ffc,
    	0x00013cfc,0x00013c3c,0x0004f04c,0x0004f010,0x0013c004,0x0013c000,
    	0x004f0000,0x004f0000,0x00100000
    	};	
    	// mousebuffer 0-41 is the screen to restore, 42 is 0 for startup, 1 for redraw, 43 = oldx, 44=oldy
    	int i,j,n,m,r,s;
    	unsigned long pixels;
    	if (mousebuffer[42] ==1)								// restore. Skip first time if is zero
    	{
    		m=(mousebuffer[44]*20)+(mousebuffer[43]/16);				// oldy and oldx
    		for(i=0;i<21;i++)								// store the longs behind the mouse
    		{
    			screen[m]=mousebuffer[i];
    			screen[m+1]=mousebuffer[i+21];
    			m = m+20;
    		}
    	}
    	mousebuffer[42] = 1;									// always restore from now on
    	mousebuffer[43]=x;									// store current x
    	mousebuffer[44]=y;
    	n=0;
    	m=(y*20)+(x/16);									// get the screen long - 20 longs per row
    	r=x%16;										// work out the bitshift remainder - 16 pixels per long
    	//gray_debug_dec(screen,r);
    	for(i=0;i<21;i++)									// store the longs behind the mouse
    	{
    		mousebuffer[i]=screen[m];
    		mousebuffer[i+21]=screen[m+1];
    		m = m+20;
    	}
    	m=(y*20)+(x/16);									// recalculate m
    
    	if (r==0)										// no remainder so fits exactly in a long
    	{
    		for (i=0;i<21;i++)									// rows
    		{
    			{
    				screen[m] = screen[m] & mouse_mask[n];					// mask out pixel bits, ignore transparent bits
    				screen[m] = screen[m] | mouse_icon[n];					// draw the icon
    				n++;
    			}
    			m = m+20;									// next row
    		}
    	}
    	else
    											// bitshift so fits
    	{
    
    		s=r<<1;										// multiply by 2
    		for (i=0;i<21;i++)									// rows
    		{
    			{
    				// move mask and icon value into pixels. Shift. Leave bits on left as 11 for mask(transparent) and 00 for icon
    				// note also the order is reversed so shifts to the left move bits to the right. Very confusing!				
    				pixels = mouse_mask[n] << s;						// shift s=2 to 30 step 2
    				pixels = pixels | (0xffffffff >> (32-s));				// leave in transparent bits
    				screen[m] = screen[m] & pixels;					// mask out pixel bits, ignore transparent bits
    				pixels = mouse_mask[n] >> (32-s);						// shift in next long to the right	
    				pixels = pixels | (0xffffffff << s);
    				screen[m+1] = screen[m+1] & pixels;				// finished drawing the mask, now the icon
    				pixels = mouse_icon[n] << s;						// shift s=2 to 30 step 2
    				screen[m] = screen[m] | pixels;					// mask out pixel bits, ignore transparent bits
    				pixels = mouse_icon[n] >> (32-s);						// shift in next long to the right	
    				screen[m+1] = screen[m+1] | pixels;
    				n++;
    			}
    			m = m+20;									// next row
    		}
    
    	}
    }
    
    void gray_engine_start(int cognumber, unsigned long cogarray[], unsigned long screen[], unsigned long gray_parameters[])
    {
    	unsigned long pingroup = 2;						// pins 16 to 23
    	int i;
    	unsigned long frequencystate;
    	gray_parameters[0] = 0xfca85400;				// pixelcolors in reverse order
    	gray_parameters[1] = 1;					// displayindicator
    	gray_parameters[2] = 0;					// syncindicator
    	gray_parameters[3] = 2;					// bitsperpixel, starts at 2 but gets changed later to 1
    	screen[0] = (unsigned long) &screen[0];			// the first long in the screen array now points to the location of itself
    	screen[1] = (unsigned long) &gray_parameters[1];	// pointer to displayindicator
    	screen[2] = (unsigned long) &gray_parameters[2];	// pointer to syncindicator
    	screen[3] = (0xff << (8*pingroup));
    	screen[4] = (0x200000ff | (pingroup << 9) | ((gray_parameters[3] -1) << 28));   // (0x200000ff | (pingroup << 9) | ((bitsperpixel-1) << 28)); this one not working
    	gray_parameters[3] = gray_parameters[3]  - 1;             // bitsperpixel now equal to 1, used below
    	frequencystate = ((25175000 + 1600) / 4);					// calculate frequencystate	 
    	screen[5] = 1;
    	for(i=0;i<32;i++)
    	{
    		frequencystate = frequencystate << 1;
    		screen[5] = (screen[5] << 1) | (screen[5] >> 31);
    		if (frequencystate >= _clockfreq())
    		{
    			frequencystate -= _clockfreq();
    			screen[5] += 1;
    		}
    	}
    	screen[6] = 2;						// horizontal scaling
    	screen[7] = 2;						// vertical scaling
    	screen[8] = 320;						// horizontal pixels
    	screen[9] = 240;						// vertical pixels
           screen[10] = ((screen[6] << 12) + (((640 * 32) >> gray_parameters[3] ) / screen[8])); // visible scale
    	screen[11] = (((8 << gray_parameters[3] ) << 12) + 160);	// invisible scale
           screen[12] = (screen[8] / (32 >> gray_parameters[3] ));	// horizongal longs
    	screen[13] = screen[12] * 4;				// horizontal loops
    	screen[14] = (unsigned long) &gray_parameters[0];	// pixel colors 
    	_cogstop(cognumber);							// stop graphics cog
    	external_memory_cog_load(cognumber,cogarray,screen);		// load from external ram to this cog, pass some values in screen[]
    	gray_clearscreen(screen);
    }
     
    void object1_click(unsigned long screen[])
    {
    	gray_printf(screen, 150,200,"Object 1");				// print text on the screen 
    
    }
    
    void object2_click(unsigned long screen[])
    {
    	gray_printf(screen, 150,220,"Object 2");				// print text on the screen
    }
    
    void object3_click(unsigned long screen[])
    {
    
    }
    
    void object4_click(unsigned long screen[])
    {
    
    }
    
    
    void mouse_button(unsigned long screen[], unsigned long mouse_parameters[])
    {
    	unsigned long mx,my;
    	int i;
    	int n;
    	mx = mouse_parameters[0];
    	my = 219-mouse_parameters[1];					// so top left is 0,0
    	if (mx>0x80000000) mx = 0;						// x < 0 
    	if (mx > 307) mx = 307;						// x > 307
    	if (my>0x80000000) my = 0;						// y < 0
    	if (my>219) my=219;							// y > 219
    	i = 0;
    	while (click_area[i][0] != 0)					// test for clickable areas - added when objects drawn on screen
    	{
    		if ((mx > click_area[i][0]) & (my > click_area[i][1]) & (mx < click_area[i][2]) & (my < click_area[i][3]))
    		{
    			// process the click if matches an object
    			//gray_debug_dec(screen,click_area[i][4]); 		 				// print the x value
    			switch (click_area[i][4])
    			{
    				case 1: object1_click(screen);
    					 break;
    				case 2: object2_click(screen);
    					 break;
    				case 3: object3_click(screen);
    					 break;
    				case 4: object4_click(screen);
    					 break;
    			}
    		}
    		i +=1;
    	}
    }
    
    void screen_refresh_speedtest(unsigned long screen[])			// see how long it takes in C to refresh the screen
    {
    	int i;
    	unsigned long n = 0xffffffff;
    	for(i=0;i<4800;i++)
    	{
    		screen[i] = (screen[i] <<5) | n;				// read old value, shift, do a logic OR - see if need to do this pasm
    	}
    }
    
    void gray_demo(unsigned long screen[], unsigned long mousebuffer[], unsigned long gray_parameters[],unsigned long mouse_parameters[], int cognumber)
    {
    	unsigned long oldx,oldy = 1;					// previous mouse pointers, set to anything except 0 so draws the mouse on startup
    	unsigned long mx,my;
    	unsigned long old_button = 0;					// previous button state 1=left button, 2=right button, 0=no button
    	unsigned long new_button = 0;					// new button press
           strcpy(richtext[0],"Lorem ipsum dolor sit amet,");		// add some text to the rich text box
    	strcpy(richtext[1],"consectetur adipiscing elit.");
    	strcpy(richtext[2],"Sed a ante erat, ac pretium");
    	strcpy(richtext[3],"odio. Nullam sagittis massa");
    	strcpy(richtext[4],"ac ligula tincidunt euismod.");
    	strcpy(richtext[5],"Curabitur lacinia, magna");
    	strcpy(richtext[6],"nec consectetur viverra,");
    
    	gray_engine_start(cognumber,cogject_gray,screen,gray_parameters);
    	gray_debug_hex(screen,m_present());				// is the mouse present?
    	gray_printf(screen, 8,6,"File      Edit       Program");	// print menu text on the screen
    	gray_button(screen, 10, 130,50,19,"Button1",1,1);		// a button - object 1, 1=add to list
    //	gray_button(screen, 90,40,50,19,"Button2",2,1);			// a button - object 2, 1 = add to list
    	gray_text(screen, 80, 130, 60,16, "Textbox1",3,1);		// a text box - object 3, 1= add to list
    //	gray_text(screen, 90, 70, 60,16, "Textbox2",4,1);		// a text box - object 4, 1=add to list
    	gray_richtext(screen, 10,20,300,100,5,1);				// a richtext box prints richtext array - object 5, 1=add to list
    	gray_radio(screen, 10,165,1,"Radio1");				// a checked radio button
    //	gray_radio(screen, 10,120,0,"Radio2");				// an unchecked radio button
    	gray_checkbox(screen,80,165,1,"Checkbox");			// a checkbox
    	gray_groupbox(screen,150,130,80,50,"GroupBox1");		// draw groupbox
           gray_printf(screen, 160,145,"Label1");				// print text on the screen
    //	gray_printf(screen, 150,165,"Label2");				// print text on the screen
    //	gray_printf(screen, 150,185,"Label3");				// print text on the screen
    	gray_printf(screen,10,186,"Debug value");
    
    //	gray_fastwhiteline(screen,2,35,20);				// draw lines/boxes faster by filling in longs rather than pixels
    //	testline(screen);
    //	screen_refresh_speedtest(screen);					// speed test 
    //	gray_debug_hex(screen,123456);					// print a debug hex value on the screen at 10,200
    //	gray_debug_dec(screen,123456);
    //	gray_mousepointer(screen,mousebuffer,21,45);			// print a mouse pointer
    //	gray_mousepointer(screen,mousebuffer,25,48);			// move the mouse pointer
    	while(1)
    	{
    		if ((oldx != mouse_parameters[0]) | (oldy != mouse_parameters[1]))
    		{
    			mx = mouse_parameters[0];
    			my = mouse_parameters[1];
    			if (mx>0x80000000) mx = 0;				// x < 0 
    			if (mx > 307) mx = 307;				// x > 307
    			if (my>0x80000000) my = 0;				// y < 0
    			if (my>219) my=219;					// y > 219
    			gray_mousepointer(screen,mousebuffer,mx, 219-my); // move the pointer 
    			//gray_debug_hex(screen,mouse_parameters[1]);  // print the value
    			oldx = mouse_parameters[0];				// store the previous value
    			oldy = mouse_parameters[1];
    		}
    		new_button = mouse_parameters[3];				// in case state changes in the next few lines
    		if ((old_button == 0) & (new_button == 1))		// mouse has changed from zero to 1
    		{
    			mouse_button(screen, mouse_parameters);		// mouse down
    		}
    		old_button = new_button;					// store current state of buttons
    	}
    
    }
    
    void mouse_engine_start(int cognumber, unsigned long cogarray[], unsigned long mouse_parameters[], int dpin, int cpin)
    {
    	mouse_parameters[0] = (unsigned long) &mouse_parameters[0];	// the first long of the array points to the location of the array itself
    	mouse_parameters[5] = (unsigned long) dpin;			// data pin
    	mouse_parameters[6] = (unsigned long) cpin;
    	_cogstop(cognumber);							// stop this cog
    	external_memory_cog_load(cognumber,cogarray,mouse_parameters);			// load from external ram to this cog, pass location of the array
    }
    
    
    void main ()
    {
    	char color_parameters[1];						// displayindicator and syncindicater are permanent hub variables
    	unsigned long screen[4800];						// graphics and text video buffer in hub - eg 19200 bytes = 4800 longs
    	unsigned long gray_parameters[4];					// permanent hub variables for the gray 320x240 driver
    	unsigned long mousebuffer[45];					// pixels behind the mouse cursor 42 longs then some data
    	unsigned long mouse_parameters[19];				// group of 7 plus 12 longs in par_x in the spin version
    	int i;
    	mousebuffer[42] = 0;							// mouse 0 if startup, 1 if redraw
    	//m_bound_limits(0,300,0,0,220,0);					// set the mouse limits
    	sleep(3000); 								// for vga screen to warm up
    	text_clearscreen();							// white on blue vga clearscreen
           printf("Clock speed %u \n",_clockfreq());                     // see page 28 of the propeller manual for other useful commands
           printf("Catalina running in cog number %i \n",_cogid());      // integer
    	lcd_demo();								// set up the 20x4 LCD display and print a string
    //	printf("Read vga color cogject into external ram array cogject_color\n");
    //	readcog("vgagraph.cog",cogject_color);					// read in kye's graphics driver
    //	printf("Read vga gray cogject into external ram array cogject_gray\n");
    //	readcog("vga320.cog",cogject_gray);
    //	printf("Read mouse cogject into external ram array cogject_mouse\n");
    //	readcog("mouse.cog",cogject_mouse);
    	mouse_engine_start(7, cogject_mouse, mouse_parameters, 24, 25);	// start the mouse driver (takes 2 secs to reply with the mouse type)
    	printf("Finished reading cogjects into external ram \n");
    	_cogstop(3);								// stop cog 3 = one of the two default graphics cogs
    	color_demo(screen,color_parameters,1);				// start in cog 1 (stops cog 1 prior to restarting)
    	sleep(2000);								// so can see it
    	gray_demo(screen, mousebuffer, gray_parameters, mouse_parameters, 1);	// gray screen demo in cog 1
    	while (1); 								// endless loop as prop reboots on exit from main() 
    }
    
  • TinkersALotTinkersALot Posts: 535
    edited 2011-05-18 07:02
    wow! very nicely done. what platform are you using for this? is the propeller bursting with code to pull this off or does it remaining bandwidth for other tasks?
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-18 07:08
    This is running on a dracblade - propeller plus 512k external ram chip using the lower 12 pins. It ought to be portable to any of the platforms that can run external memory (Catalina has a number of platforms now).

    There are some spare cogs as some things are loading cogs, doing specific tasks then unloading cogs to free up the cog. So there is lots of spare capacity.

    Some code is not as fast as one would like, but for every bit of slow C code, there would be a faster solution in pasm. Eg rendering the text in a text box could be done in pasm by passing a pointer to the text, and a pointer to the font, and the x and y coordinates. Load a cog, render the text, then unload the cog.

    Multiple reloads of cogs are a different way of using the propeller. I'm still getting used to using the propeller in this way. It is quite powerful, eg at the beginning the program starts with a white on blue text driver, unloads those 2 video cog drivers and loads in a 64 color graphics driver for a brief 2 second demo, then unloads that and loads in the gray screen driver.
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-18 07:47
    Way cool. This may indeed bring some attention to the Prop. Very well done.
  • VernVern Posts: 75
    edited 2011-05-18 18:06
    Amazing, this will make a great front end for plenty of projects.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-05-18 18:43
    Drac: Nicely done. How about posting a pic of the screen results like I saw at our recent UPESH (Southern Hemisphere in Adelaide, South Australia).

    Everyone: This was great when Drac showed me this working at Easter when I was over there. He has now added some other features. This is the beginning of a real Prop hosted computer (for those of us who are bent this way) :)
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-05-19 00:29
    That is really wonderful.

    So was all that Latin the result of brain crash from having to type in all those Hex numbers ??? I remember typing in pages and pages of Hex into a C64, and then wondering why !


    I have just thought, now that I have upgraded the KBD Dracblade to 3 latches, I could try it on that one (minus the LCD bits)
  • TinkersALotTinkersALot Posts: 535
    edited 2011-05-19 00:34
    Will this also run with additional room to spare on the prop-2 ? or is that Prop/II ? I sure would want it to.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-19 01:10
    Yes it will run on the prop II. There is a group working on getting C running on the prop II and this program is standard C. I just couldn't wait and wanted to get something working now!

    The Latin goes back to the 1500's and was used then for the same reason it is used here - to demonstrate a font without the words themselves being distracting. http://www.lipsum.com/ (the text itself is over 2000 years old). Plus I like Latin. Lots of medical words are Latin (or Greek) in origin.

    Next project is writing the code to display a window, then restore the pixels that were behind the window.

    Any board with external memory and a display ought to work. And any help with this little project would be most appreciated!
  • william chanwilliam chan Posts: 1,326
    edited 2011-05-19 01:30
    Can this work on C3?
  • TonyDTonyD Posts: 210
    edited 2011-05-19 01:52
    Drac, nice piece work. I'm looking forward to seeing this on a Prop II
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-19 02:27
    I haven't tested it on the C3 but it should run. I think Ross has got the caching working. I copied this from the Catalina thread - it looks very promising
    •Full SPI Flash support on both the C3 and Morpheus (CPU #1) - this gives those platforms up to 1Mb of additional space for program code, with seamless integration of Flash support in both Catalyst and Payload (i.e. you use the Flash just like any other type of RAM).
    •Full caching XMM RAM driver support on all platforms. The caching RAM driver can improve program performance by an order of magnitude when using serial memory as XMM RAM (such as on the C3). The caching driver can also improve program performance significantly on other platforms with slow parallel memory. Enabling the cache always costs an extra cog, but the Hub RAM it uses can be configured - from 1k to 8k.
  • RossHRossH Posts: 5,519
    edited 2011-05-19 03:42
    Dr_Acula wrote: »
    I haven't tested it on the C3 but it should run. I think Ross has got the caching working. I copied this from the Catalina thread - it looks very promising
    The C code will run - but any embedded cogjects that contain drivers may need to be recompiled to take into account the pin differences on the C3 (i.e. VGA, keyboard drivers etc). Also, the C3 cannot support keyboard and mouse at the same time (it has only one PS/2 connector!).

    Ross.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-19 05:21
    Thanks Ross. The cogjects should be ok as they are as the parameters are passed from Spin or C. The C setup code was copied from the Spin setup code, eg in the video driver there is the line
    unsigned long pingroup = 2; // pins 16 to 23

    and ditto for the mouse.

    But as you point out, mouse and keyboard at the same time is not possible. And a GUI probably needs both, though maybe a mouse only solution might be possible in some applications.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-19 07:32
    Now have windows where the background is stored and can be restored once the window is finished. This is useful for dropdown menus as well as for simple yes/no questionboxes and messageboxes.

    This also highlights something very clever with Catalina and external memory. The memory buffer for a 320x240 gray scale screen is 19200 bytes and with all the C stack code, there is no room left to store the background, which could be up to another 19200 bytes in size.

    No matter - in Catalina you can define arrays at the beginning of the program, and these end up in external ram. Store the background to an array in external ram, then when it is finished with that window, restore the background.

    There are a few little traps along the way - eg I need to blank the mouse prior to drawing the window and restoring the background. But overall this seems to be working very well.

    Who knows, soon we might be able to load and save that text as a .txt file on the sd card...
    996 x 831 - 124K
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-19 07:40
    Careful:
    Dr_Aucula wrote:
    Next project is writing the code to display a window, then restore the pixels that were behind the window.
    Dr_Aucula wrote:
    Now have windows where the background is stored and can be restored once the window is finished.
    You do not want to do this by saving the pixel values as MS holds a patent on that method. So be careful how you do this.
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-19 07:44
    I should have dropped this earlier than this. My apologies. It has (latter in this thread) been made clear that this patent does not apply in this case.
    Dr_Aucula wrote:
    Store the background to an array in external ram, then when it is finished with that window, restore the background.
    And this describes the patent. If you just kept a full screen buffer for the full background and a separate buffer for the contents of each window, but no separate buffers for the area behind a window you can avoid the patent.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-19 07:45
    You do not want to do this by saving the pixel values as MS holds a patent on that method. So be careful how you do this.

    Ah, ok, well there are other ways to do this, eg by storing the data in a higher level tokenized form.

    Mind you, I always thought patents did not apply when the idea was obvious. Storing the pixels seems obvious, but maybe that is just me. So I'm off to the patent office now to register a patent on the wheel. Or more particularly, my special three sided wheel. It has one less bump per revolution than the old four sided one. *grin*
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-19 07:58
    Keep up the great work, I like this project.
    Dr_Aucula wrote:
    Mind you, I always thought patents did not apply when the idea was obvious. Storing the pixels seems obvious, but maybe that is just me.

    Yea, I dislike software patents as well. 99% of them seem to be something obvious.
    Though this is the reason that no one uses this very simple method in GUIs that are widely available. I find it interesting that this patent (as I understand) was filed the same week that rumors began that Apple was going to be using this in Copland OS to improve speed.
    Dr_Aucula wrote:
    So I'm off to the patent office now to register a patent on the wheel. Or more particularly, my special three sided wheel. It has one less bump per revolution than the old four sided one. *grin*
    If it is a software wheel, you just might get away with it :) .
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-05-19 08:08
    And this describes the patent. If you just kept a full screen buffer for the full background and a separate buffer for the contents of each window, but no separate buffers for the area behind a window you can avoid the patent.
    David, do you have the patent number for that patent? I would like to take a look at it. Their claim may be restricted to how the pieces are repainted, such as by the app instead of by the OS. It's always annoying on a Windows system when the app becomes unresponsive and the graphics under the dead app's window becomes obscured until the app is killed or the system is rebooted.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-05-19 08:10
    Just as I was working up the enthusiasm to get this onto KBD Dracblade I remembered that I didn't put a mouse socket on it..... I can feel a Mk3 coming on.
  • RavenkallenRavenkallen Posts: 1,057
    edited 2011-05-19 08:17
    That is really sharp looking... It would be cool to see something like that on a C3. Keep us posted:)
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-19 08:34
    Original Post OT and provocative, my apologies.
  • potatoheadpotatohead Posts: 10,261
    edited 2011-05-19 09:34
    Are software patents valid in Australia? They aren't in the EU.

    (and a patent on backing store is silly, given it's been done since the early days of computing)

    I'll bet that patent isn't just backing store. That would be very basic and obvious. Bet they've got a data structure or something that facilitates doing that in a fast way, which would not be obvious.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-05-19 11:03
    Really nice job Drac :)

    I would be interested to know the date the patent was filed because the ProDos for the Apple //e used a form of text windowing and I bet they stored the pixels it replaced. Also, Apple had their GUI for Lisa well before Microsoft was into windows (and Bill had access to their source) and remember, Apple borrowed these ideas from Xerox Parc IIRC. Seems to me that if the patent is for what has been described, it was already being used. There was also the Perc that had a windowing system and mouse.

    Is there no expiry date on a software patent?
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-19 11:14
    Cluso99:
    Do not quote me: I think that the patent was filed in 1997.

    As far as Lisa, Macintosh System Software/Mac OS, GEM, X, AmigaDOS/Amiga OS, all versions of MS-Windows, etc:
    None of these used this method, most of them redraw any field that was under or overlapped by the window in question. In some cases the contents of the background, and the contents of all Windows, Menus, Icons, Sprites were stored in buffers in memory so as to speed up the redraw process, though no buffer for the area behind a window. I do note one exception (that I know of), that preceded the MS-Patent, that is that DR-GEM would save the area under a menu before it drew the menu and then redraw it (and it treated static [no tittle] dialog boxes as menus, in this regard [though only one was allowed at any given time]).
  • jazzedjazzed Posts: 11,803
    edited 2011-05-19 11:20
    Patents only matter in almost all cases if you have enough money to pay enough lawyers to win.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-05-19 12:31
    jazzed wrote: »
    Patents only matter in almost all cases if you have enough money to pay enough lawyers to win.

    Sad, but dead on...
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-19 13:06
    Dr_Aucula:
    I must thank you. You have inspired me to work on my first PropBASIC program some more (a simple memory efficient windowing system [GUI] using LMM). So when I am board (happens often when trying to solve a problem on another project) I will continue to work on that. The idea is something along the lines of DR-GEM 1.3, with a look more like TOS 4.0.x GEM, though with a limit of 15 open windows, and 1 menu (the desktop counts as a window). For this I am using simple rectangular bounds checking to see what needs to be redrawn (this was common in earlier GUIs as it saves memory).
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-19 16:22
    If you just kept a full screen buffer for the full background and a separate buffer for the contents of each window, but no separate buffers for the area behind a window you can avoid the patent.

    That is good to know, because that is how it is working. One full screen buffer for the entire background so that will avoid the patent. It is simpler too if there is only one 'layer' of windows.

    @davidsaunders, your LMM idea sounds interesting. I'm writing in C because it is simpler for me to 'think' in C, but there is a lot of scope for speeding up code by moving portions to assembly/LMM.
Sign In or Register to comment.