                        Scream Tracker 3.0 file formats
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
                                Song/Module header
          0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
        Ŀ
  0000:  Song name, max 28 chars (incl. NUL)                           
        Ĵ
  0010:                                                1AhTyp x  x 
        Ĵ
  0020: OrdNum InsNum PatNum  Flags  Cwt/v   Ffv  'S''C''R''M'
        Ĵ
  0030: m.vi.si.tm.m x  x  x  x  x  x  x  x  x  x  x  x 
        Ĵ
  0040: Channel settings for 32 channels, 255=unused,+128=disabled     
        Ĵ
  0050:                                                                
        Ĵ
  0060: Orders; length=OrdNum (must be even)                           
        Ĵ
  xxxx: Parapointers to instruments; length=InsNum*2                   
        Ĵ
  xxxx: Parapointers to patterns; length=PatNum*2                      
        

 
        Typ     = File type: 16=module,17=song
        Ordnum  = Number of orders in file
        Insnum  = Number of instruments in file
        Patnum  = Number of patterns in file
        Cwt/v   = Created with tracker / version: &0xfff=version, >>12=tracker
                        ST30:0x1300
        Ffv     = File format version;
                        1=original
                        2=original BUT samples unsigned
        Parapointers are OFFSET/16 relative to the beginning of the header.
 
        PLAYING AFFECTORS / INITIALIZERS:
        Flags   =  +1:st2vibrato 
                   +2:st2tempo
                   +4:amigaslides
                   +8:0vol optimizations
                   +16:amiga limits
                   +32:enable filter/sfx
        m.v     = master volume
        m.m     = master multiplier (&15) + stereo(=+16)
        i.s     = initial speed (command A)
        i.t     = initial tempo (command T)
 
        Channel types:
        &128=on, &127=type: (127=unused)
        8  - L-Adlib-Melody 1 (A1)      0  - L-Sample 1 (S1)
        9  - L-Adlib-Melody 2 (A2)      1  - L-Sample 2 (S2)
        10 - L-Adlib-Melody 3 (A3)      2  - L-Sample 3 (S3)
        11 - L-Adlib-Melody 4 (A4)      3  - L-Sample 4 (S4)
        12 - L-Adlib-Melody 5 (A5)      4  - R-Sample 5 (S5)
        13 - L-Adlib-Melody 6 (A6)      5  - R-Sample 6 (S6)
        14 - L-Adlib-Melody 7 (A7)      6  - R-Sample 7 (S7)
        15 - L-Adlib-Melody 8 (A8)      7  - R-Sample 8 (S8)
        16 - L-Adlib-Melody 9 (A9)
                                        26 - L-Adlib-Bassdrum (AB)
        17 - R-Adlib-Melody 1 (B1)      27 - L-Adlib-Snare    (AS)
        18 - R-Adlib-Melody 2 (B2)      28 - L-Adlib-Tom      (AT)
        19 - R-Adlib-Melody 3 (B3)      29 - L-Adlib-Cymbal   (AC)
        20 - R-Adlib-Melody 4 (B4)      30 - L-Adlib-Hihat    (AH)
        21 - R-Adlib-Melody 5 (B5)      31 - R-Adlib-Bassdrum (BB)
        22 - R-Adlib-Melody 6 (B6)      32 - R-Adlib-Snare    (BS)
        23 - R-Adlib-Melody 7 (B7)      33 - R-Adlib-Tom      (BT)
        24 - R-Adlib-Melody 8 (B8)      34 - R-Adlib-Cymbal   (BC)
        25 - R-Adlib-Melody 9 (B9)      35 - R-Adlib-Hihat    (BH)
        
                
                        Digiplayer/ST3.0 samplefileformat
          0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
        Ŀ
  0000: [T] Dos filename (12345678.ABC)                       MemSeg 
        Ĵ
  0010: Length HI:lengLoopBegHI:LBegLoopEndHI:LendVolDsk[P][F]
        Ĵ
  0020: C2Spd  HI:C2sp x  x  x  x GVSPOS Int:512Int:lastused   
        Ĵ
  0030:  Sample name, 28 characters max... (incl. NUL)                 
        Ĵ
  0040:  ...sample name...                             'S''C''R''S'
        
  xxxx:	sampledata

        NOTES:
        Inside module, MemSeg tells the paragraph position of
        the actual sampledata (offset/16). In separate insfile the same,
        in memory segment of data relative to beginning of module.
        GVSPOS=Position in gravis memory /32 (used inside player only)
        [T]ype, 1=Sample
        [F]lags, +1=loop on
                 +2=stereo (after Length bytes for LEFT channel,
                          another Length bytes for RIGHT channel)
                 +4=16-bit samples (intel LO-HI byteorder)
        { [P]ack, 0=8 bit normal (1=DP30ADPCM1 for holland project) }
 
                        ST3.0 adlib instrument format
          0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
        Ŀ
  0000: [T] Dos filename (12345678.123)                   00h00h00h
        Ĵ
  0010: D00D01D02D03D04D05D06D07D08D09D0AD0BVolDsk x  x 
        Ĵ
  0020: C2Spd  HI:C2sp x  x  x  x  x  x  x  x  x  x  x  x 
        Ĵ
  0030:  Sample name, 28 characters max... (incl. NUL)                 
        Ĵ
  0040:  ...sample name...                             'S''C''R''I'
        

        NOTES:
        [T]ype, 2..7=amel,abd,asnare,atom,acym,ahihat
        modulator:                                              carrier:
        D00=[freq.muliplier]+[?scale env.]*16+[?sustain]*32+
                [?pitch vib]*64+[?vol.vib]*128                  =D01
        D02=[63-volume]+[levelscale&1]*128+[l.s.&2]*64          =D03
        D04=[Attack]*16+[decay]                                 =D05
        D06=[15-sustain]*16+[release]                           =D07
        D08=[wave select]                                       =D09
        D0A=[modulation feedback]*2+[?additive synthesis]
        D0B=unused
 
 
Unpacked Internal memoryformat for patterns:
 
REMARK: each channel takes 320 bytes, rows for each channel
are sequential.
byte:
0 - Note; hi=oct, lo=note, 255=empty note,254=key off (used with adlib)
1 - Instrument ;255=..
2 - Volume ;255=..
3 - Special command ;255=..
4 - Command info 
 
 
Packed Internal memoryformat for patterns:
 
Pattern length fixed for 64 rows.
 
BYTE:flag, 0=end of row
        &31=channel
        &32=follows;  BYTE:note, BYTE:instrument
        &64=follows;  BYTE:volume
        &128=follows; BYTE:command, BYTE:info
        
************************************************
NOTES on [memseg].
In memory, the memseg's highest byte (3) is always zero
(thus also the ASCIIZ terminator). For the actual 16 bit
memseg the following storage method is used:
0..EFFF = Segment to memory
F000... = EMS page ####-F000


And here is info for STM:

Song/Module file structure:
        Offset: Info:
        0       Song/File name, max 20 chars, ASCIIZ, except if 20 chars long
        20      Tracker name, max 8 chars, NO NUL
        28      0x1A
        29      File type: 1=song, 2=module
        30      Version major (eg. 2)
        31      Version minor (eg. 2)
        32      byte; tempo
        33      byte; num of patterns saved
        34      byte; global volume
        36      reserved, 13 bytes
 
        48      Instruments (31 kpl) (see below) Instrument structure:
                Offset  Info
                0       Inst. Filename, 12 bytes max, ASCIIZ
                12      0x00
                13      byte; instrument disk
                14      word; reserved (used as internal segment while playing)
                16      word; length in bytes
                18      word; loop start
                20      word; loop end
                22      byte; volume
                23      byte; reserved
                24      word; speed for mid-C (in Hz)
                26      reserved, 4 bytes
                30      word; internal segment address/(in modules:)length in paragraphs
 
        XXXX    Music pattern orders (64 bytes/orders)
         
        XXXX    Patterns (number in header, each pattern 1KB)
                Patterns consist of 64 rows, each 4 channels. Each channel
                is 4 bytes in length, and the channels are stored from left
                to right, row by row.
                Special [BYTE0] contents:
                         251=last 3 bytes NOT in file, all bytes 0
                         252=last 3 bytes NOT in file, note: -0-
                         253=last 3 bytes NOT in file, note: ...
                         254=(in memory), -0- 
                         255=(in memory), ...
                otherwise:
                        note=[BYTE0] and 15 (C=0,C#=1,D=2...)
                        octave=[BYTE0] / 16
                        instrument=[BYTE1]/8
                        volume=([BYTE1] and 7)+[BYTE2]/2
                        command=[BYTE2] and 15
                        command info=[BYTE3]
        
        [XXXX]  In modules: Samples, padded to 16 byte limits. Sample lengths in
                paragraphs (and as saved) are storen in instruments internal
                segment address.

