Unofficial KSS format specification

Introduction

This document is an unofficial KSS(X) format specification version 1.20 based on KSS format specification version 'unofficial 1.03'. KSS is a sound data file format for Z80-based sound emulators. It can be played through NEZplug and MSXplug. The normal file extension is .KSS. KSS files usually contains the entire songs and it may also contain sound effects. KSS files can be GZip compressed. The zipped file extension is also .KSS.

File Structure

SizeData
16Basic Header
16Extra Header (if exists)
*ROM/RAM ImageBank 0 image
Bank 1 image
...
(Max 255 bank images)
16Playlist Header (if exists)
*Playlist ItemsItem #1 (if exists)
Item #2 (if exists)
...(Max 255 items)

Header structure

Basic Header
OffsetTypeData
0000BYTE[4]Magic 'KSSX'
0004WORDLoad Address
0006WORDLoad Size
0008WORDInit Address
000AWORDPlay Address
000CBYTEInitial bank number
000DBYTE8/16K bank mode selector
bit 0-6number of the extra banks
bit 70: 16K mapper
1: 8K mapper
000EBYTEExtra header size ($0 or $10)
000FBYTEDevice Flags
bit0Disable(0) or enable(1) MSX-MUSIC/FMUNIT
bit1Disable(0) or enable(1) SN76489
bit2Disable(0) or enable(1) RAM mode if bit1==0
Disable(0) or enable(1) GG stereo if bit1==1
bit3-4Extra device selector
0: none
1: MSX-AUDIO
2: Majyutsushi 8bits D/A
3: MSX-AUDIO (Stereo)
bit5Reserved must be 0
bit6VSYNC frequency NTSC 60Hz(0) or PAL 50Hz(1)
bit7Reserved must be 0
Extra Header
0010DWORDSize of the ROM/RAM Images
0014DWORDReserved must be 0.
0018WORDNumber of the first song.
001AWORDNumber of the last song.
001CBYTEPSG/SN76489 VOLUME
001DBYTESCC VOLUME
001EBYTEMSX-MUSIC/FM-UNIT VOLUME
001FBYTEMSX-AUDIO VOLUME

Note that all values except VOLUME are unsigned integers in little-endian. VOLUME is a signed integer value from -128 to 127.

VOLUME$81...$E0$F0$00$10$20...$7F
RatioMINx1/4x1/2x1x2x4MAX

Namely, output wave is calculated as OUTPUT = INPUT * 2^(VOLUME/16)

Playlist Header
+0000BYTE[4]Magic 'INFO'
+0004DWORDTotal size of the Playlist Items.
+0008WORDNumber of the playlist items.
+000ABYTE[6]Reserved must be zero.
Playlist Item
+0000BYTESong Number
+0001BYTESong Type $00: Music $10: S.E
+0002DWORDPlaytime in msec
+0006DWORDFadetime in msec
+000AVARCHARNUL(\0)-terminated maximum 255 bytes title string