SND

From Wulinshu
Jump to navigation Jump to search

The SND file, also known as DTPK, is used for both sequenced music and packages of sound effects.
The format is played back via the AM2 AICA driver, located as AICADRV.BIN in the MISC folder on the Dreamcast versions of the game.

SND File format

Header

Position Length Type Description
0x00 0x04 string Identifier 0x4454504B (DTPK)
0x08 0x04 uint Size of file
0x3C 0x04 uint Location of Sample Table

Sample Table

Position Length Type Description
0x00 0x04 uint Index of last sample (Add 1 for number of samples)
0x04 N/A N/A First sample entry (0x10 bytes each)

Sample Entries

Position Length Type Description
0x00 0x04 uint Sample Location & Type packed as follows:
& 0x007FFFFF Sample Offset
& 0x00800000 Sample quality. 0 Normal, 1 Half
& 0x01000000 Format flag - 0 PCM, 1 ADPCM
& 0x02000000 Unknown flag. Is NOT Mono/Stereo
0x04 0x2 ushort Loop start offset from start of sample
0x06 0x2 ushort Loop end offset from start of sample
0x08 0x4 uint Related to sample frequency. Either 0 or 0x80. 0x80 = Half sample rate
0x0C 0xC uint Size of sample data

AICA Driver

The AICA driver is loaded right into the start of AICA RAM at 0. The driver always loads the SND file for music into the hard-coded offset of 0x10000. Subsequent files can be loaded after that, the offset(s) written to a table found at 0xDB00 with 0x20 byte entries per file. The table contains 8 slots, (ends at 0xDC00) and they don't always need to be filled in order. This loaded files table will be further documented later.

AICA Driver Commands

There is a rolling buffer from 0x400 to 0x500 in memory where 4 byte commands are sent to the driver. As each command is executed, the sound driver clears those bytes back to 00. New commands should be sent to the next set of 4 bytes and roll back to 0x400 once you hit 0x500. Commands to be documented when further understood.