SCC Blaffer NT file format
This page was last modified 14:00, 13 January 2012 by D-fader. Based on work by Huey and Hydragon and others.


The .SBM (SCC Blaffer NT Music) format


Data in an SBM file is stored as follows:

[000h..00Fh] -  16 bytes - Init bytes (Blaf NT Song    )
[010h..052h] -  67 bytes - Song name
[053h..05Dh] -  11 bytes - Instrument kit name
[05Eh..05Eh] -   1 byte  - Last Position
[05Fh..060h] -   2 bytes - Loop Position
[061h..160h] - 256 bytes - Patterns to play
[161h..161h] -   1 byte  - Initial Tempo
[162h..166h] -   5 bytes - Start volumes
[167h..16Bh] -   4 bytes - Start instruments
[16Ch..170h] -   5 bytes - Detune Settings
[170h..174h] -   5 bytes - Auto volume slide settings
[175h..1CFh] -  91 bytes - Future expansions
[1D0h..1D0h] -   1 byte  - Number of patterns stored
[1D1h..???h] - ??? bytes - Pattern data

The init bytes are to recognize the song when it's loaded. The song name is the name of the song, the instrument kit has 11 characters, because the extension is also saved with the kit. This is done because you can load files with another extension than the original in SCC-Blaffer NT. The last position is what it indicates, the loop position has two bytes, because you can loop from position 0 till position 255, and you can set the loop position OFF. The first byte determines wheter to loop or not. If the first byte is zero, then there's a loop position, else the loop position is OFF. Patterns to play are the patterns to play at the positions. The initial tempo is what it indicates, the start instruments only have four bytes, that's because of the fact channel 5 hasn't got its own instrument (it uses the instrument of channel 4). Detune settings are the detune values upon song start, the the auto volume slide settings are also defined as start values.

The future expansions data is empty data and may be used in future versions of SCC Blaffer NT. This is done so backwards compatibility can be guaranteed.

Pattern build up

The first 2 bytes contain the address where to store the pattern. All bytes hereafter are pattern data. The pattern data is stored as follows:

16 rows * ((5 channels * 2 bytes) + 2 bytes)

5 channels of 2 bytes is note plus 'action' data, the 2 bytes after that is the PSG channel value and the command channel value. So a pattern has 16*12 bytes = 192 bytes, plus the 2 pointer bytes, that's in total 194 bytes.

The reason a pointer is stored is to keep the SBM file as small as possible. When a song e.g. has 2 positions (last position = 1) and on the first position you use pattern 0, and at the second you use pattern 82, and the song data is stored as follows: Save the song from pattern 0 till the highest pattern used, then the song is large, and pattern 1 till 81 are not in use! So only the patterns actually used are stored (0 and 82).

So the size of a song is always 16 + 67 + 11 + 1 + 2 + 256 + 1 + 5 + 4 + 5 + 5 + 1 + 91 + ((number of patterns used) * 194) bytes

In this way a song can be exactly 16.567 bytes large. Since that won't fit in the memory bank (which is 16.384 bytes), but the addresses of the patterns are only stored in the song, they won't be stored in RAM, so we get rid of 166 bytes. Well 16.597 - 166 = 16.401. The Number of patterns byte doesn't have to be stored, so 16.401 - 1 = 16.400, and the song won't have to be stored either, so 16.400 - 16 = 16.384 bytes! And that *will* fit in 1 memory bank! :)

Channel build up

Each SCC channel entry (5 in total) are build up out of 2 bytes. The first byte is the note/action byte and the second byte is the parameter

Value(s)| Note/action        | Parameter
000       no operation         <none>
001-096   new note             volume
097       channel off          <none>
098       change instrument    instrument
099       pitch up             frequency step value
100       pitch down           frequency step value
101       pitch2 up            frequency step value
102       pitch2 down          frequency step value
103       modulation up        step value
104       modulation down      step value
105       detune up            value
106       detune down          value
107       volume slide up      volume step value
108       volume slide down    volume step value
109       auto slide up        number of notes
110       auto slide down      number of notes
Command channel
00        no operation
01-25     Tempo (1-25) (TMP??)
26        End of pattern (EndOp)
27-32     Transpose minus (TRP-6 - TRP-1)
33        Transpose zero (TRP 0)
34-39     Transpose plus (TRP+1 - TRP+6)

Assembly info

You can read some song data when a song is loaded in memory. The locations are defined as follows.

MusicAddress            .equ 8000h
SongName                .equ MusicAddress
InsKitName              .equ SongName+67
LastPos                 .equ InsKitName+11
LoopPos                 .equ LastPos+1
Patterns                .equ LoopPos+2
InitialTempo            .equ Patterns+256
StartVolumes            .equ InitialTempo+1
StartInstruments        .equ StartVolumes+5
DetuneSettings          .equ StartInstruments+4
VolumeSlideSettings     .equ DetuneSettings+5
PatternData             .equ MusicAddress+448

The .SBK format (SCC Blaffer NT Instrument Kit)

Data in an SBM file is stored as follows.

In total an .SBK file contains 207 SCC instruments and 44 PSG Instruments.

SCC instrument storage

One instrument contains 40 bytes of data. 8 bytes for the name and 32 bytes data.

The data is stored as follows...

 [0000..0007] -  8 Bytes - Name of SCC instrument
 [0008..0039] - 32 Bytes - Instrument data

PSG instrument storage

One instrument contains 184 bytes of data. 8 bytes for the name and 176 bytes of data.

The data is stored as follows...

 [0000..0007] -   8 Bytes - Name of PSG instrument
 [0008..0183] - 176 Bytes - Instrument data

SBK file explained

This sections contains a per byte representation of data stored in an SBK file.

[00000..00015] -  16 Bytes - Header "Blaf NT Ins Kit "
[00016..00023] -   8 Bytes - Name of SCC instrumemt 0
[00024..00055] -  32 Bytes - Data of SCC instrument 0
[08256..08263] -   8 Bytes - Name of SCC instrument 206
[08264..08295] -  32 Bytes - Data of SCC instrument 206
[08296..08303] -   8 Bytes - Empty data "********"
[08204..08211] -   8 Bytes - Name of PSG instrument 1
[08212..08388] - 176 Bytes - Data of PSG instrument 1
[16216..16223] -   8 Bytes - Name of PSG instrument 44
[16224..16399] - 176 Bytes - Data of PSG instrument 44

In this way an instrument kit is always 16.400 bytes, but when stored in memory, the header won't be stored, so then it is 16.384 bytes in total, which will fit exactly in one memory bank!

SBS and SBP files

The storage of the SCC Blaffer NT SCC Instrument (.SBS) and SCC Blaffer NT PSG Instrument (.SBP) files are exactly the same as explained in the previous paragraph, only the file will store an extra 16 byte header to the file:

For SCC instruments: "Blaf NT SCC Ins " For PSG instruments: "Blaf NT PSG Ins "

So a .SBS file is 56 bytes and a .SBP file is 200 bytes.