Tracker Packer v3 format
Created by Crazy Crack / Complex (1993-1994)
Analysed by Asle / ReDoX (asle@mygale.org)

Source :
 - Own converted MODs with the packer (sent by Gryzor !)
 - Tons of intros/demos/zikdisk ...

Note: It's the same format as the version 2 save for the repacking of
     the notes. I guess it was done for the replayer because this version
     does not gain one single byte. I had to fight hard to understand this
     new packing ... I cant figure out how Crazy Crack managed to enhance
     his replayer with such a way of packing !.

Offset    size (byte)    Comment
------    -----------    -------
  0           8          ID "CPLX_TP3"
  8        20 (14h)      title

 28           2          (NOS) Number of sample (*8). Also, that's the size
(1Ch)                    of the whole sample headers.

      ***************************************
      * the following is repeated NOS times *
      * with 8 bytes description for 1 smp  *
******************************************************
                                                     *
 30            1         Finetune (0 -> F)           *
(1Eh)                                                *
 31            1         Volume (0 - 40h)            *
(1Fh)                                                *
 32            2         Sample Size / 2             *
(20h)                                                *
 34            2         Loop Start / 2              *
(22h)                                                *
 36            2         Loop Size / 2               *
(24h)                                                *
                                                     *
******************************************************

30+8*NOS       1         ?!? ($00)

31+8*NOS       1         (PLS) Pattern list size.

32+8*NOS     PLS*2       The pattern list. Each number of pattern is *8 !.

32+8*NOS     NOP*8       (NOP stands for the REAL number of pattern which value
+PLS*2                    is known by getting the highest value in the previous
                          table and by adding 1 since the first is 0)
                         Track table per pattern. Each SAVED pattern is made of
                         4 tracks and here are the addresses of each track.
                         This is a table of words. The first address is $0000!.
                         To get the real track address, add to the present
                         value : (34+8*NOS+2*PLS+NOP*8).

32+8*NOS       2         ?!?
+PLS*2
+NOP*8

34+8*NOS       ?         Tracks datas. Each track is saved one after another.
+PLS*2                   It consists of 64 possible notes. the size of each
+NOP*8                   track is variable and is between 1 byte and
                         300h bytes. Here follows the whole lot of cases one
                         can find in the track data (the note packing).


case 1:

     value
    /   \
   |     |
 1100-0000
 ||
 if these bits are set, you have to bypass (80h - value) bytes for those
are empty notes.


case 2:

    -description bit set to 0
   /
  |
 1000-0000  0000-0000
 |  |   |   |       |
 |   \ /     \     /
 | effect  effect value
  \
   -description bit set to 1


case 3: no effect

     - sample number
    /         /\
   |         |  |
  0000-0000  0000-0000
  | |     |       |  |
 /   \   /         \/
|   relative     effect
|     note
|    number
|------------description bit set to 0

Note: effect, here, is EMPTY !.
Note2: To get the real note number, here, you have to NOT this value, or you
      can do that: result = 7Fh - byte1;


case 4:

     - sample number
    /         /\
   |         |  |
  0000-0000  0000-0000  0000-0000
  | |     |       |  |  |       |
 /   \   /         \/    \     /
|  relative      effect   effect
|    note                 value
|   number
|------------description bit set to 0


For all those cases:

effect:
 the arpeggio (0) effect has been remapped to 8
 Note that all the volume slide commands (5,6,A) are signed !. Here an example:
  A 01 -> A 10    A FF -> A 01    etc. ..

relative note number: (Protracker)

C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453
C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226
C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113

becomes : (TP3)

C-1 to B-1 : 01,02,03,04,05,06,07,08,09,0a,0b,0c
C-2 to B-2 : 0d,0e,0f,10,11,12,13,14,15,16,17,18
C-3 to B-3 : 19,1a,1b,1c,1d,1e,1f,20,21,22,23,24



 Follows Sample datas stored like Protracker.

Note: As in NoisePacker v3, the sample data address MUST be even !. It means
     you have to bypass one byte after reading the tracks datas if the address
     where you are is uneven.

Note: Tracker Packer 3.1 (the original packer) puts two empty bytes at the
     end of every module it converts. No matter the MOD I converted, these
     two bytes are always here ... .