RSF format is smaller than PSG, contains text information about file and easy to stream it using atmega & so on…
RSF (Registers Stream Flow)
Format description:
VERSION 1 HEADER:
Offset | SIZE | Type or content -------+------+------------------------------------------------------- 00 | 3 | Signature "RSF" (text) 03 | 1 | byte, Version (current is 1) 04 | 1 | byte, Frame rate (interrupt frequency) usually 50(Hz) 05 | 4 | UInt32, frameCount (total frames of the song) 09 | 4 | UInt32, loopFrame (frame for loop) 13 | X | Null terminated string containing Title XX | X | Null terminated string containing Author XX | X | Null terminated string containing Comment
VERSION 2 HEADER:
Offset | SIZE | Type or content -------+------+------------------------------------------------------- 00 | 3 | Signature "RSF" (text) 03 | 1 | byte, Version (current is 2) 04 | 2 | UInt16, Frame rate (interrupt frequency) usually 50(Hz) 06 | 4 | UInt32, frameCount (total frames of the song) 10 | 4 | UInt32, loopFrame (frame for loop) 14 | 4 | UInt32, chipFrequency (frequency of AY) 18 | X | Null terminated string containing Title XX | X | Null terminated string containing Author XX | X | Null terminated string containing Comment
VERSION 3 HEADER:
Offset | SIZE | Type or content -------+------+------------------------------------------------------- 00 | 3 | Signature "RSF" (text) 03 | 1 | byte, Version (current is 3) 04 | 2 | UInt16, Frame rate (interrupt frequency) usually 50(Hz) 06 | 2 | UInt16, offset to song data 08 | 4 | UInt32, frameCount (total frames of the song) 12 | 4 | UInt32, loopFrame (frame for loop) 16 | 4 | UInt32, chipFrequency (frequency of AY) 20 | X | Null terminated string containing Title XX | X | Null terminated string containing Author XX | X | Null terminated string containing Comment
SONG DATA:
(versions 1, 2)————————————-
first check for 3 special values
0xFF – interrupt, dont send registers to the chip (just skip sending one time)
0xFE,XX – number of interrupts XX * 16 without changing of registers (just skip sending XX*16 times)
0xFD,XX – number of interrupts XX * 2 without changing of registers (just skip sending XX*2 times)
——————————————————
(version 3)
first check for 2 special values
0xFF – interrupt, dont send registers to the chip (just skip sending one time)
0xFE,XX – number of interrupts XX without changing of registers (just skip sending XX times)
——————————————————-
register values is for registers 0-13 (registers 14,15 ignored in this format) that changed from previous interrupt
XX1, XX2,REG0,REG5,REG7 (depends on register mask)
Register mask
XX1 – HI value of register mask
XX2 – LO value of register mask
if register mask bit contains 1, register value should follow the register mask
Example
0x00,0x03,REG0,REG1 (XX1=00000000 XX2=00000011)
0x03,0x02,REG1,REG8,REG9 (XX1=00000011 XX2=00000010)
Warning! Player versions before 11.3 has rsf v2 format and may contain 255 value for 13 register!
[ad name=”HTML”]
Почему нельзя в следующей, 4-й версии формата, сделать служебными значения не только 0xFF и 0xFE, а целый диапазон [0x40:0xFF]? Тем самым можно одним байтом кодировать количество пропускаемых прерываний в подавляющем большинстве ситуаций. Байт 0xFF – это ‘-1’ (пропуск одного прерывания), 0xFE – ‘-2’ (пропуск двух), … 0x40 – ‘-192’ (пропуск 192-х прерываний!). На мой взгляд и этого более чем достаточно. Но можно предусмотреть 0x40 в качестве спецбайта, когда следующий байт будет дополняющим положительным. Например, 0x40 0x10 говорит о пропуске 0x00 – 0x40 + 0x10 = 0xD0 (208) байт.
*Пропуск 208 прерываний конечно, а не байт.