
  Lieves!Tuore SCREEN 2 picture file format (.LT2)

  written by Yzi/L!T 2010


  In MSX's SCREEN 2 video mode, the screen is divided vertically to three parts
  of equal size. Each of the thirds, or "slices", is split to two different
  areas in the LT2 picture's pattern and color table data:

   - The "non-copied" part, for which the pattern/color data are preloaded
   to VRAM and the color-interlacing is done by changing the name table.
   Each 8x8 block ("character") of the non-copied part has different name table
   bytes for the two frames that are interlaced/flashed to make an illusion of
   mixed colors.

   - The "copied" part, where each 8x8 block has the same byte in both name
   tables. For the copied part, the pattern/color table data is reuploaded
   from main RAM to VRAM with the CPU for each frame.

   On the screen (and to keep things simple, also in the VRAM), the copied part
   is located after the non-copied part, so that the "vpoke" updating stays
   ahead of the CRT refresh.

   So the VRAM layout looks like in the following

     "N" : frame 1 data that's not copied on-the-fly
     "n" : frame 2 data that's not copied on-the-fly
     "C" : frame 1/2 data that needs to be re-copied for each CRT frame
           (PAL 50Hz)

     --- PATTERN table part 1/3 (offset 0000h) ---
     NNNNNNNN...nnnnnnnn...CCCCC
     --- PATTERN table part 2/3 (offset 0800h) ---
     NNNNNNNN...nnnnnnnn...CCCCC
     --- PATTERN table part 3/3 (offset 1000h) ---
     NNNNNNNN...nnnnnnnn...CCCCC
     --- NAME table for frame 1 (offset 1800h) ---
     NNNNNNNNNNNNN...
     --- some empty space
     --- COLOR table for part 1/3 (offset 2000h) ---
     NNNNNNNN...nnnnnnnn...CCCCC
     --- COLOR table for part 2/3 1 (offset 2800h) ---
     NNNNNNNN...nnnnnnnn...CCCCC
     --- COLOR table for part 3/3 1 (offset 3000h) ---
     NNNNNNNN...nnnnnnnn...CCCCC
     --- NAME table for frame 2 (offset 3800h) ---
     NNNNNNNNNNNNN...

   It is worth noting that the lengths of non-copied/copied pattern data areas
   may differ from the lengths for the corresponding color data areas. By having
   more non-copied pattern bytes than color bytes, we can have a third type of
   8x8 block, where pattern data stays the same between frames, but color data
   is changed. In other words, the pattern (i.e. bit plane) data doesn't have
   to be updated, so the area consumes 50% less CPU cycles compared to areas
   where both pattern and color table have to be updated.

   In the LT2 file format, data is stored in the same order as data in VRAM,
   with the exception of name table data, which is stored last in the file.
   There is also a 76-byte header at the beginning of the file.


   (HEADER) HEADER

   (DATA)   PATTERN 1/3 non-copied bytes
            PATTERN 1/3 copied bytes
            PATTERN 2/3 non-copied bytes
            PATTERN 2/3 copied bytes
            PATTERN 3/3 non-copied bytes
            PATTERN 3/3 copied bytes
            PATTERN 1/3 non-copied bytes
            PATTERN 1/3 copied bytes
            PATTERN 2/3 non-copied bytes
            PATTERN 2/3 copied bytes
            PATTERN 3/3 non-copied bytes
            PATTERN 3/3 copied bytes


In the following are byte offsets to the file header, for use in your own
programs.

// Offsets to the LT2 file header. All offsets, lengths and sizes are specified
// in Bytes and stored as unsigned 16-bit integers.
// Offsets are relative to the beginning of the file, i.e. the beginning of
// the header.
//
// The purpose of storing all these offsets is to make the job of the
// picture displayer program a little bit easier. Some of the offsets and/or
// lengths could be calculated from each other.

  LT2_PATTERN_NC_OFS_1 = 0;  // Offset to "non-copied" pattern data (in the file) for part 1/3
  LT2_PATTERN_NC_LEN_1 = 2;  // Length of "non-copied" pattern data for part 1/3
  LT2_PATTERN_C1_OFS_1 = 4;  // Offset to frame 1 "copied" pattern data (in the file), part 1/3
  LT2_PATTERN_C1_LEN_1 = 6;  // Length of frame 1 "copied" pattern data, part 1/3
  LT2_PATTERN_C2_OFS_1 = 8;  // Offset to frame 2 "copied" pattern data (in the file), part 1/3
  LT2_PATTERN_C2_LEN_1 = 10; // Length of frame 2 "copied" pattern data, part 1/3

  LT2_PATTERN_NC_OFS_2 = 12; // Offset to "non-copied" pattern data (in the file) for part 2/3
  LT2_PATTERN_NC_LEN_2 = 14; // Length of "non-copied" pattern data for part 2/3
  LT2_PATTERN_C1_OFS_2 = 16; // Offset to frame 1 "copied" pattern data (in the file), part 2/3
  LT2_PATTERN_C1_LEN_2 = 18; // Length of frame 1 "copied" pattern data, part 2/3
  LT2_PATTERN_C2_OFS_2 = 20; // Offset to frame 2 "copied" pattern data (in the file), part 2/3
  LT2_PATTERN_C2_LEN_2 = 22; // Length of frame 2 "copied" pattern data, part 2/3

  LT2_PATTERN_NC_OFS_3 = 24; // Offset to "non-copied" pattern data (in the file) for part 3/3
  LT2_PATTERN_NC_LEN_3 = 26; // Length of "non-copied" pattern data for part 3/3
  LT2_PATTERN_C1_OFS_3 = 28; // Offset to frame 1 "copied" pattern data (in the file), part 3/3
  LT2_PATTERN_C1_LEN_3 = 30; // Length of frame 1 "copied" pattern data, part 3/3
  LT2_PATTERN_C2_OFS_3 = 32; // Offset to frame 2 "copied" pattern data (in the file), part 3/3
  LT2_PATTERN_C2_LEN_3 = 34; // Length of frame 2 "copied" pattern data, part 3/3

  LT2_COLOR_NC_OFS_1 = 36; // Offset to "non-copied" color data (in the file) for part 1/3
  LT2_COLOR_NC_LEN_1 = 38; // Length of "non-copied" color data for part 1/3
  LT2_COLOR_C1_OFS_1 = 40; // Offset to frame 1 "copied" color data (in the file), part 1/3
  LT2_COLOR_C1_LEN_1 = 42; // Length of frame 1 "copied" color data, part 1/3
  LT2_COLOR_C2_OFS_1 = 44; // Offset to frame 2 "copied" color data (in the file), part 1/3
  LT2_COLOR_C2_LEN_1 = 46; // Length of frame 2 "copied" color data, part 1/3

  LT2_COLOR_NC_OFS_2 = 48; // Offset to "non-copied" color data (in the file) for part 2/3
  LT2_COLOR_NC_LEN_2 = 50; // Length of "non-copied" color data for part 2/3
  LT2_COLOR_C1_OFS_2 = 52; // Offset to frame 1 "copied" color data (in the file), part 2/3
  LT2_COLOR_C1_LEN_2 = 54; // Length of frame 1 "copied" color data, part 2/3
  LT2_COLOR_C2_OFS_2 = 56; // Offset to frame 2 "copied" color data (in the file), part 2/3
  LT2_COLOR_C2_LEN_2 = 58; // Length of frame 2 "copied" color data, part 2/3

  LT2_COLOR_NC_OFS_3 = 60; // Offset to "non-copied" color data (in the file) for part 3/3
  LT2_COLOR_NC_LEN_3 = 62; // Length of "non-copied" color data for part 3/3
  LT2_COLOR_C1_OFS_3 = 64; // Offset to frame 1 "copied" color data (in the file), part 3/3
  LT2_COLOR_C1_LEN_3 = 66; // Length of frame 1 "copied" color data, part 3/3
  LT2_COLOR_C2_OFS_3 = 68; // Offset to frame 2 "copied" color data (in the file), part 3/3
  LT2_COLOR_C2_LEN_3 = 70; // Length of frame 2 "copied" color data, part 3/3

  LT2_NAME_F1 = 72; // Offset to frame 1 name table
  LT2_NAME_F2 = 74; // Offset to frame 2 name table

  // The lengths of the name tables is not stored, because the name tables are
  // are always 768 bytes each.

  // That's it! The length of the header is 76 bytes.   

-------------------------------------------------------------------------------------------------
