/* IconEdit.h */

/* Revised 16feb2005js */

/* ************************** */
/* Black & White data formats */
/* ************************** */ 

/* The LCD Icon Editor use one or more letters and numbers
   in the beginning of the file to identify the filetype,
   single icon files with "C" code use Slash-Asterix-Character
   to be sure it is a valid datafile. If you want to generate
   datafiles yourself with a text editor be sure to include
   the header,

   The LCD Icon Editor support 2 groups of text besed data
   formats: A "C" format that can have 4 bit orientations 
   and 2 byte successions, and the RAMTEX format with fixed
   orientation and succession.

   I all formats there can be only one icon or symbol, or
   there can be a whole group like characters in a font.
/*


   
/* ******************* */
/* RAMTEX data formats */
/* ******************* */

/* There are 2 versions of the RAMTEX icon or symbol header
   ver. 1 with character number and X and Y size, and ver. 2
   where there is only the X and Y size. Ver. 1 is only for
   backwards compatibility.
   
   A RAMTEX ver.1 and 2 Black & White icon or element should
   look like this:
*/

/*I 8 RAMTEX ver.1 icon */
{{'C', 8, 8},{
0x0E,    /*  ....$$$.  */
0x19,    /*  ...$$..$  */
0x10,    /*  ...$....  */
0x10,    /*  ...$....  */
0x10,    /*  ...$....  */
0x19,    /*  ...$$..$  */
0x0E,    /*  ....$$$.  */
0x00     /*  ........  */
}}

/*X 8 RAMTEX ver. 2 icon */
{{8, 8},{
0x0E,    /*  ....$$$.  */
0x19,    /*  ...$$..$  */
0x10,    /*  ...$....  */
0x10,    /*  ...$....  */
0x10,    /*  ...$....  */
0x19,    /*  ...$$..$  */
0x0E,    /*  ....$$$.  */
0x00     /*  ........  */
}}

/* The characters I and X tells if it is a 3 or 2 byte header,
   and 8 that there are 8 bits pr byte in the datafield.

   The element is contained in a structure sUnit:
*/

#define BYTE unsigned char
#define MAXBYTE 48
           
typedef struct
   {         
   char ccChar;   /*   This entry is only in ver. 1   */
   int cxPix;
   int cyPix;
   } sHeader;

typedef struct
   {
   sHeader sH;
   BYTE b[MAXBYTE];
   } sUnit;

/*
	Byte is placed horizontally with Least Significant
	Bit to the left.
	The succession of the bytes  is downwards in columns 
	from left to right.
*/
   
/* Groups and fonts are more complex, the LCD Icon Editor
   need to know the number and max. size of the elements
   and how to arrange them. A small 7x8 font of 2 elements
   should look like this:   
*/

/* Version 1: 
*/

/*Z 8 7 8 2 . SAMP_AB[2]={  SAMP_AB.OLD   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
{{'A', 7, 8},{
0x30,  /*  ..%%....  */
0x78,  /*  .%%%%...  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0xFC,  /*  %%%%%%..  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0x00   /*  ........  */
}}
,
{{'B', 7, 8},{
0xFC,  /*  %%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0x7C,  /*  .%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0xFC,  /*  %%%%%%..  */
0x00   /*  ........  */
}}

/* Version 2: 
*/

/*Y 8 7 8 1 . Samp_ab[2]={  RAMTEX ver.2 group */
/* Put Your Comments Here */
{{7, 8},{
0x30,  /*  ..%%....  */
0x78,  /*  .%%%%...  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0xFC,  /*  %%%%%%..  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0x00   /*  ........  */
}}
,
{{7, 8},{
0xFC,  /*  %%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0x7C,  /*  .%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0xFC,  /*  %%%%%%..  */
0x00   /*  ........  */
}}

/* The characters Z and Y tells if it is a 3 or 2 byte header,
   8 that there are 8 bits pr byte in the datafield,
   7 that the maximum X size of a character is 7 pixels,
   8 that the maximum Y size of a character is 8 pixels,
   1 or 2 is the number of elements pr. row in the display,
   . the point is a marker for font name  
   Name for autogenerated fonts is the name of the
        symbol file at the time of generation,
   and [2] is the number of elements in the group.
   The { tells that it is a group.
   
   The fonts are included as samp_ab.old and samp_ab.sym
*/

/* If the font use CodePage, the name without Dir is included
   in the header of ver. 2:
*/

/*Y 8 7 8 1  CP<AB_Cp.cp> . AB[2]={  AB_Cp.sym   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
{{7, 8},{
0x30,  /*  ..%%....  */
0x78,  /*  .%%%%...  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0xFC,  /*  %%%%%%..  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0x00   /*  ........  */
}}
,
{{7, 8},{
0xFC,  /*  %%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0x7C,  /*  .%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0xFC,  /*  %%%%%%..  */
0x00   /*  ........  */
}}

/* And the CodePage file will look like this
*/

/*W  AB_Cp.cp    LCDIcon FileDescriptor: Do not edit or move */
{1,0x20},{ /*  First number is number of ranges, 
               last number is default Character like ASCII space  */
{ 0x0041, 0x0042, 0x0000 }/* Segment 0, 0x0002 Symbols */
}

/* In the font data the character Y tells that it is a 2 byte header font,
   8 that there are 8 bits pr byte in the datafield,
   7 that the maximum X size of a character is 7 pixels,
   8 that the maximum Y size of a character is 8 pixels,
   1 or 2 is the number of elements pr. row in the display,
   CP<> is the marker for associated CodePage file name,
   and [2] is the number of elements in the group.
   The { tells that it is a group.

   In the CodePage data the character W tells that it is a CodePage file.
   1 is the number of ranges == segments
   0x20 is the default character 
   0x0041 is A the first character in the range
   0x0042 is B the last character in the range
   0x0000 is the offset of first character in the range in the font data
   
   The font and CodePage files are included as AB_Cp.sym and AB_Cp.cp
*/


/* If you have a file without header like this example in 
   RAMTEX ver. 2 icon format, you can read the file with
   the Import C utility in the LCD Icon editor AFTER setting
   the appropriate icon og group size in the Setup menu
*/

{{8, 8},{
0x0E,    /*  ....$$$.  */
0x19,    /*  ...$$..$  */
0x10,    /*  ...$....  */
0x10,    /*  ...$....  */
0x10,    /*  ...$....  */
0x19,    /*  ...$$..$  */
0x0E,    /*  ....$$$.  */
0x00     /*  ........  */
}}




/* ******************* */
/* C-code data formats */
/* ******************* */

/* The "C" dataformats have all 8 combinations of orientation and 
   succession. Each combination has a unique character in the start
   of the file:

   Element:
   LSB:           Right    Left    Top    Bottom
   Horizontal:      E       F       G       H
   Vertical:        I       J       K       L

   Group:
   LSB:           Right    Left    Top    Bottom
   Horizontal:      M       N       O       P
   Vertical:        Q       R       S       T

   The element header can be with or without a character. If the
   dataformat character is followed with a number, the header 
   character is present, if the dataformat character is followed
   with a letter A, the header character is Absent.
/*

/* The two variants of Element - Right - Horizontal look like
   this:
*/

/*E 8  F.h   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
{{'F', 8, 8},{
0x7F,  /*  .%%%%%%%  */
0x31,  /*  ..%%...%  */
0x34,  /*  ..%%.%..  */
0x3C,  /*  ..%%%%..  */
0x34,  /*  ..%%.%..  */
0x30,  /*  ..%%....  */
0x78,  /*  .%%%%...  */
0x00   /*  ........  */
}}

/*E A 8  FA.h   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
{{8, 8},{
0x7F,  /*  .%%%%%%%  */
0x31,  /*  ..%%...%  */
0x34,  /*  ..%%.%..  */
0x3C,  /*  ..%%%%..  */
0x34,  /*  ..%%.%..  */
0x30,  /*  ..%%....  */
0x78,  /*  .%%%%...  */
0x00   /*  ........  */
}}


/* The two variants of Group - Top - Vertical look like
   this:
*/

/*S 8 8 8 32  FG.h   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
sUnit FG[2] = 
{
{{'\0', 8, 8},{
0x00,  /*  ........  */
0x41,  /*  ......  */
0x7F,  /*  .  */
0x7F,  /*  .  */
0x49,  /*  .....  */
0x1D,  /*  ....  */
0x01,  /*  .......  */
0x03   /*  ......  */
}}
,
{{'\0', 8, 8},{
0x00,  /*  ........  */
0x1C,  /*  .....  */
0x3E,  /*  ...  */
0x63,  /*  ....  */
0x41,  /*  ......  */
0x51,  /*  .....  */
0x73,  /*  ...  */
0x72   /*  ....  */
}}
};

/*S A 8 8 8 32  FG.h   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
sUnit FG[2] = 
{
{{8, 8},{
0x00,  /*  ........  */
0x41,  /*  ......  */
0x7F,  /*  .  */
0x7F,  /*  .  */
0x49,  /*  .....  */
0x1D,  /*  ....  */
0x01,  /*  .......  */
0x03   /*  ......  */
}}
,
{{8, 8},{
0x00,  /*  ........  */
0x1C,  /*  .....  */
0x3E,  /*  ...  */
0x63,  /*  ....  */
0x41,  /*  ......  */
0x51,  /*  .....  */
0x73,  /*  ...  */
0x72   /*  ....  */
}}
};



/* ****************** */
/* Color data formats */
/* ****************** */

/* The Color version can read and write Color data formats
   The B&W version can read Color data formats as B&W */

/* The LCD Icon Editor use V in the beginning of the file to
   mark that it is a color file, and F, P, Q or R to identify
   the filetype. All files with "C" code use Slash-Asterix-Character
   to be sure it is a valid datafile.
*/

/* A RAMTEX ver.2 Color icon with RGB values should look like this:
*/

/*V R C 0 16 8 7 6 5  4RGB.sym   LCDIcon FileDescriptor: Do not edit or move */
{{ 0, 21, 4, 4 },{
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0xFF, 0x00, 0x00,
0xFF, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0xFF, 0x00, 0x00,
0xFF, 0x00, 0x00,
0x00, 0xFE, 0x00,
0x00, 0xFE, 0x00,
0x00, 0x01, 0xF8,
0x00, 0x01, 0xF8,
0x00, 0xFE, 0x00,
0x00, 0xFE, 0x00,
0x00, 0x01, 0xF8,
0x00, 0x01, 0xF8
}}

/* The character V tells that it is a color file,
   R that data is RedGreenBlue values,
   C or G that data is real Colors or Gray shades,
   0 is internally used Version index,
   16 is PaletteSize, it is common for Colors
      and Gray Palette or RGB values,
   8 is number of bits in RedColorResolution,
   7 is number of bits in GreenColorResolution,
   6 is number of bits in BlueColorResolution,
   5 is number of bits in GrayColorResolution.
   4RGB.sym is the file name without path,
   { is the start of the header for the Symbol,
   0 shows that it is a color or gray file,
   21 bit per pixel in the data for RGB values,
   4 is number of pixels in the X direction, the next
   4 is number of pixels in the Y direction,
     so the icon is 4x4 pixels
   } is the end of the header for the Symbol
   0x00, 0x00, 0x00   is the Red Green and Blue value
                      for one pixel, the bits are packed
					  so that Red starts in the most
					  significant bit in the first byte,
					  and blue ends somewhere the number
					  of bits per pixel later, only the
					  number of bits corosponding to the
					  color resolution is saved, the rest
					  of the present byte is filled by
					  zeroes. There will be 8, 16 or 24
					  bits in the datafile.
*/

/* A RAMTEX ver.2 Color icon with Palette indexes should look like this:
*/

/*V Q  PAL<4FontPal.pal>  4Pal.sym   LCDIcon FileDescriptor: Do not edit or move */
{{ 0, 2, 4, 4 },{
0x05,
0x05,
0xAF,
0xAF
}}

/* The character V tells that it is a color file,
   Q that data is Palette indexes,
   PAL<> specify the name of the palette for the indexes
   4FontPal.pal is the palette file name without path,
   4Pal.sym is the index file name without path,
   { is the start of the header for the Symbol,
   0 is a color or gray indicator,
   2 is the number of bits in each index, here 2,
   4 is number of pixels in the X direction, the next
   4 is number of pixels in the Y direction, so the icon is 4x4 pixels
   } is the end of the header for the Symbol
   0x05 is 4 indexes packed into an 8 bit byte. The indexes are
        packed as 1, 2, 4, 8, or 16 bits per pixel.
*/

/* A RAMTEX ver.2 Color Palette should look like this:
*/

/*V P C 0 4 8 7 6 5 4 21 0  4FontPal.pal   LCDIcon FileDescriptor: Do not edit or move */
{
{0x00, 0x00, 0x00},
{0xFF, 0x00, 0x00},
{0x00, 0xFF, 0x00},
{0x00, 0x00, 0xFF}
}

/* The character V tells that it is a color file,
   P that data is RedGreenBlue for the Palette values,
     if S it is for SystemPalette
   C or G that data is real Colors or Gray shades, 
        H for gray with only 1 byte per shade.
   0 is Version number, 0 for normal, 1 for system palette present,
   4 is total PaletteSize, it is common for Colors and Gray 
     Palette or RGB values,
   8 is number of bits in RedColorResolution,
   7 is number of bits in GreenColorResolution,
   6 is number of bits in BlueColorResolution,
   5 is number of bits in GrayColorResolution.
   4 is number of used colors in the palette,
   21 bit per pixel in the data for RGB values =
      RaxTex Bit per Pixel,
   0 is number of colors in the system palette,
   4FontPal.pal is the file name without path, it would be 
                4FontPal.spl for a System Palette
   {0x00, 0x00, 0x00} is the Red Green and Blue value for 
                      one pixel, the bits are packed so 
					  that Red starts in the most significant
					  bit in the first byte, and blue ends 
					  somewhere the number of bits per pixel
					  later, only the number of bits
					  corosponding to the color resolution
					  is saved, the rest of the present byte
					  is filled by zeroes. There will be 8,
					  16 or 24 bits in the datafile.
*/

/* A RAMTEX ver.2 Color font with RGB values should look like this:
*/

/*V F 4 2 2 2 N R C 0 16 8 7 6 5  4FontRGB.sym   LCDIcon FileDescriptor: Do not edit or move */
{{ 0, 21, 2, 2 },{
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
}},{{ 0, 21, 2, 2 },{
0xFF, 0x00, 0x00,
0xFF, 0x00, 0x00,
0xFF, 0x00, 0x00,
0xFF, 0x00, 0x00,
}},{{ 0, 21, 2, 2 },{
0x00, 0xFE, 0x00,
0x00, 0xFE, 0x00,
0x00, 0xFE, 0x00,
0x00, 0xFE, 0x00,
}},{{ 0, 21, 2, 2 },{
0x00, 0x01, 0xF8,
0x00, 0x01, 0xF8,
0x00, 0x01, 0xF8,
0x00, 0x01, 0xF8
}}

/* The character V tells that it is a color file,
   F that data is a Font, i.e. a Group of color Symbols,
   4 is the number of Symbols in the font
   2 is the number of Symbols in a row in the font = 
     number of columns,
   2 is the maximum number of pixels in the X direction,
   2 is the maximum number of pixels in the Y direction, 
     so the largest Symbol is 4x4 pixels
   N that there is no CodePage,
   R that data is RedGreenBlue values,
   C or G that data is real Colors or Gray shades,
   0 is internally used Version index,
   16 is PaletteSize, it is common for Colors and Gray 
      Palette or RGB values,
   8 is number of bits in RedColorResolution,
   7 is number of bits in GreenColorResolution,
   6 is number of bits in BlueColorResolution,
   5 is number of bits in GrayColorResolution.
   4FontRGB.sym is the file name without path,
   { is the start of the header for each Symbol,
   0 is a color or gray indicator,
   24 is one of the codes for RGB values,
   2 is number of pixels in the X direction, the next
   2 is number of pixels in the Y direction, so the 
     icon is 4x4 pixels
   } is the end of the header for each Symbol
   0x00, 0x00, 0x00   is the Red Green and Blue value for one pixel,
                      the bits are packed so that Red starts in 
					  the most significant bit in the first byte,
					  and blue ends somewhere the number of bits
					  per pixel later, only the number of bits 
					  corosponding to the color resolution is 
					  saved, the rest of the present byte
					  is filled by zeroes. There will be 8,
					  16 or 24 bits in the datafile.
*/


/* A RAMTEX ver.2 Color font with Palette indexes should look like this:
*/

/*V F 4 2 2 2 N Q  PAL<4FontPal.pal>  4FontPal.sym   LCDIcon FileDescriptor: Do not edit or move */
{{ 0, 2, 2, 2 },{
0x05,
0x05,
}},{{ 0, 2, 2, 2 },{
0x50,
0x50,
}},{{ 0, 2, 2, 2 },{
0xAF,
0xAF
}},{{ 0, 2, 2, 2 },{
0xF0,
0xF0
}}

/* The character V tells that it is a color file,
   F that data is a Font, i.e. a Group of color Symbols,
   4 is the number of Symbols in the font
   2 is the number of Symbols in a row in the font = 
     number of columns,
   2 is the maximum number of pixels in the X direction,
   2 is the maximum number of pixels in the Y direction,
     so the largest Symbol is 6x8 pixels
   N that there is no CodePage,
   Q that data is Palette indexes,
   PAL<> specify the name of the palette for the indexes
   4FontPal.pal is the palette file name without path,
   4FontPal.sym is the index file name without path,
   { is the start of the header for the Symbol,
   0 is a color or gray indicator,
   2 is the code for the number of bits in each index, 
     here 2,
   2 is number of pixels in the X direction, the next
   2 is number of pixels in the Y direction, so the icon
     is 4x4 pixels
   } is the end of the header for the Symbol
   0x05 is 4 indexes packed into an 8 bit byte..
*/


   
/* ******************* */
/* Binary data formats */
/* ******************* */

/* The binary format is based on unsigned bytes with LSB first.

   In the single icon data format the first 4 bytes of 
   the header identify the file format, the next 4 bytes 
   are X-size and Y-size. The data bytes follow 
   immediately after the 8 byte header.

   Sample_3.bin:

00,00,   - binary identifier
0B,      - single icon - VERTICAL LSB BOTTOM
08,      - version
10,00,   - X size - LSB first
18.00,   - Y size - LSB first
00,00,00,- data 3 bytes per vertical line in image
0C,00,30,- directions:
1C,00,38,  <- UP  
3C,00,3C,
3C,00,3C,  |  RIGHT
38,30,1C,  V
30,30,0C,
30,30,0C,
30,30,0C,
30,30,0C,
38,78,1C,
3F,FF,FC,
3F,FF,FC,
1F,CF,F8,
0F,87,F0,
00,00,00 

   This will look like this in 'C'

   Sample_3.h
*/

/*L 8  SAMPLE_3.h   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
{{'3', 16, 24},{
0x00,0x00,0x00,  /*  ........................  */
0x0C,0x00,0x30,  /*  ....................  */
0x1C,0x00,0x38,  /*  ..................  */
0x3C,0x00,0x3C,  /*  ................  */
0x3C,0x00,0x3C,  /*  ................  */
0x38,0x30,0x1C,  /*  ................  */
0x30,0x30,0x0C,  /*  ..................  */
0x30,0x30,0x0C,  /*  ..................  */
0x30,0x30,0x0C,  /*  ..................  */
0x30,0x30,0x0C,  /*  ..................  */
0x38,0x78,0x1C,  /*  ..............  */
0x3F,0xFF,0xFC,  /*  ....  */
0x3F,0xFF,0xFC,  /*  ....  */
0x1F,0xCF,0xF8,  /*  ........  */
0x0F,0x87,0xF0,  /*  ............  */
0x00,0x00,0x00   /*  ........................  */
}}

/* In the group of elements data format the first 4 bytes of the 
   header identify the file format, the next 4 bytes are X-size and
   Y-size of the group (just like in single icon format). 
   The next 2 bytes is Element Count, and the next is number of 
   elements in the horizontal display of the group. This makes 
   a group header of 11 bytes.

   For each Element in the group there is a 2 byte header with 
   X-size and Y-size before the data for that Element.

   Samp_ab.bin:

00,00,   - binary identifier
0C,      - single icon - HORIZONTAL LSB RIGHT
08,      - version
07,00,   - X size of whole group - LSB first
10.00,   - Y size of whole group - LSB first
02,00,   - number of elements in the group
01,      - number of columns of elements in X direction

07,      - X size of this element
08,      - Y size of this element
30,
78,
CC,
CC,
FC,
CC,
CC,
00, 

07,      - X size of this element
08,      - Y size of this element
FC,
66,
66,
7C,
66,
66,
FC,
00,

53,61,6D.70,5F,61,62,3B - Samp_ab;

   This will look like this in 'C'

   Samp_ab.h
*/

/*M 8 7 8 1  Samp_ab.h   LCDIcon FileDescriptor: Do not edit or move */
/* Put Your Comments Here */
sUnit Samp_ab[2] = 
{
{{'\0', 7, 8},{
0x30,  /*  ..%%....  */
0x78,  /*  .%%%%...  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0xFC,  /*  %%%%%%..  */
0xCC,  /*  %%..%%..  */
0xCC,  /*  %%..%%..  */
0x00   /*  ........  */
}}
,
{{'\x01', 7, 8},{
0xFC,  /*  %%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0x7C,  /*  .%%%%%..  */
0x66,  /*  .%%..%%.  */
0x66,  /*  .%%..%%.  */
0xFC,  /*  %%%%%%..  */
0x00   /*  ........  */
}}
};
