*****************************************************************
* File format of the VTI 2.5 skin files                         *
* Documentation by Romain Lievin <roms@tilp.info>               *
*                                                               *
* These informations have been extracted from the VTI source    *
* code (rom.cpp) which have been released by R. Wagner.         *
*                                                               *
* Begin: 2002/04/17                                             *
* Last update: 2006/03/25                                       *
*****************************************************************


Remark: I use the C notation for numbers (12: decimal, 0x1A: hexadecimal, 
'C': character). Moreover, all words are in LSB-MSB format.

This document describes the file format of VTi v2.1 & v2.5 skins.
A skin file (.skn) is a composite file which contains informations and data 
(image).


The VTi v2.1 skin file format
-----------------------------

  The following is a table of the bytes that make up a skin file.

  Adress                   Size    What It Contains
  ---------------------------------------------------------------------------
  0x000-0x007   0-7        8       A header: "VTIv2.1 "
  0x008-0x047   8-71       64      Skin's name (not NULL-terminated)
  0x048-0x04B   72-75      4       Calculator type
  0x04C-0x04F   76-79      4       Color type (0, 1, or 2)
  0x050-0x053   80-83      4       The value of the 'White' LCD pixel (32 bits / true color)
  0x054-0x057   84-87      4       The value of the 'Black' LCD pixel (32 bits / true color)
  0x058-0x067   88-103     16*1    1x RECT structure (the display coords in skin)
  0x068-0x567   104-1383   16*80   80x RECT structures (the keys coords in skin)

  0x568-0x...   1384-...           A JPEG encoded image placed right after


The VTi v2.5 skin file format
-----------------------------

  The following is a table of the bytes that make up a skin file.

  Address                  Size    What It Contains
  ---------------------------------------------------------------------------
  0x000-0x007   0-7        8       An header: "VTIv2.5 "
  0x008-0x047   8-71       64      Skin's name (not NULL-terminated)
  0x048-0x087   72-135     64      Skin's author (idem)
  0x088-0x08B   136-139    4       Calculator type
  0x08C-0x08F   140-143    4       Color type (0, 1 or 2)
  0x090-0x093   144-147    4       The value of the 'White' LCD pixel (32 bits / true color)
  0x094-0x09B   148-151    4       The value of the 'Black' LCD pixel (32 bits / true color)
  0x09C-0x0A7   152-167    16*1    RECT structure (the display coords in skin)
  0x0A8-0x5A7   168-1447   16*80   RECT structures (the keys coords in skin)

  0x5A8-0x...   1448-...           A JPEG encoded image placed right after


  RECT is a common Win32 structure which has the following format:

  typedef struct tagRECT {
    uint32_t left;
    uint32_t top;
    uint32_t right;
    uint32_t bottom;
  } RECT;

  The keys coordinates are stored in an array of 80 structures. These 
  structures are parsed for searching a mouse position which fits into. Once 
  found, the index is mapped into a TI key by an array such as:

  const char sknKey89[] = {
    TIKEY_F1, TIKEY_F2, TIKEY_F3, TIKEY_F4, TIKEY_F5,
    TIKEY_2ND, TIKEY_SHIFT, TIKEY_ESCAPE, TIKEY_LEFT, TIKEY_RIGHT,
    TIKEY_UP, TIKEY_DOWN, TIKEY_DIAMOND, TIKEY_ALPHA, TIKEY_APPS,
    TIKEY_COS, TIKEY_MODE, TIKEY_F6, TIKEY_BACKSPACE, TIKEY_CLEAR,
    TIKEY_X, TIKEY_Y, TIKEY_Z, TIKEY_T, TIKEY_POWER,
    TIKEY_EQUALS, TIKEY_PALEFT, TIKEY_PARIGHT, TIKEY_COMMA, TIKEY_DIVIDE,
    TIKEY_LN, TIKEY_7, TIKEY_8, TIKEY_9, TIKEY_MULTIPLY,
    TIKEY_SIN, TIKEY_4, TIKEY_5, TIKEY_6, TIKEY_MINUS,
    TIKEY_STORE, TIKEY_1, TIKEY_2, TIKEY_3, TIKEY_PLUS,
    TIKEY_ON, TIKEY_0, TIKEY_PERIOD, TIKEY_NEGATE, TIKEY_ENTER1
  };

  This array contains some values which come from an enumeration. Values 
  contained in this array must match with the keys placed in the skin in the 
  same order.

  The enumeration is also used for keyboard mapping. The order is not 
  important but this enumeration is a basis for some other transcoding arrays 
  (TIKEY_XXX to row/col hardware key).

  enum {
    TIKEY_DOWN, TIKEY_RIGHT, TIKEY_UP, TIKEY_LEFT, TIKEY_HAND, TIKEY_SHIFT, ...
    MAX_KEY // important !
  };

  Color types:
  - 0: low contrast
  - 1: high contrast
  - 2: custom contrast (use the B & W pixel values)

  Calculator types:
  - 73
  - 82
  - 83
  - 84 -> 83+
  - 85
  - 86
  - 89
  - 92
  - 94 -> 92+
