BWII File Format

****************************************************************************************************************

Bells & Whistles 2

Bells & Whistles II Score Block & File Format (RSDOS)

(Any addresses noted are before any modifications)

BWII files are stored in simple RSDOS Machine Language type files.

This means the first 5 bytes of the file are the M/L header.

BWII Header:

Byte 1 EQU $00

Byte 2 EQU MSB of File length -+- = File length not including Header

Byte 3 EQU LSB of File length -+- or Footer

Byte 4 EQU MSB of Load Address -+- =$2E00 for Complete Song w/Tables

Byte 5 EQU LSB of Load Address -+- =$4000 for Song only.

What follows is determined by the "Save" method.

BWII uses two "Save" modes. The first is a "Complete" save

in which all tables are saved with the song.

The Load Address will be $2E00 for this type of file.

The 2nd is a simple "Song" save which saves only the song.

The Load Address will be $4000 for this type of file.

Table Block: (Only with load address of $2E00)

Bytes Contains

$0005-$0104 = Frequency Table

$0105-$0204 = Equalizer Table

$0205-$0A04 = 8 Wavetables of 256 bytes each

$0A05-$1204 = 8 Envelope Tables of 256 bytes each.

Song Block:Offset into file of $1205 w/Tables, $0005 without tables.

Load address will be $4000 without tables.

Song length is: File Length - Tablesize (omit tablesize if Song only)

The actual Song length should be divisable by 5

Dividing by 5 will give you the number of Note/Control blocks in the file.

Note/Control Blocks are as follows:

Blocks consist of control byte followed by 4 data bytes (all blocks = 5 bytes)

Control Bytes:

ENDBLK EQU #$00 End of song block

CTLBLK EQU #$FD Control block

VOLBLK EQU #$FE Volume block

EVWBLK EQU #$FF Envelope/Wave block

All other values (1-252) are Note blocks.

NOTBLK byte 1 = Note Length

128th=1, 64th=2, 64th(dot)=3, 32nd=4, 32nd(dot)=6, 16th=8

16th(dot)=12, 8th=16, 8th(dot)=24, Qtr=32, Qtr(dot)=48,n Hlf=64,

Hlf(dot)=96, Whl=128, Whl(dot)=192

bytes 2-5 = Note value for each of the 4 voices (1-255)

ENDBLK byte 1 = #$00 Stops the song

bytes 2-5 Ignored

CTLBLK byte 1 = #$FD followed by 1 function byte and 3 data bytes

byte 2 = #$01 Label flag

byte 3 - ASCII code of single character label

bytes 4-5 Ignored

#$02 Sync flag Used to sync voices with the same notes

byte 3 = bits 0-3 = voices 1-4

bytes 4-5 ignored

#$04 Repeat Start flag

bytes 3-5 ignored

#$08 Repeat End flag

byte 3-5 ignored

#$10 Breakpoint (pauses music)

bytes 3-5 ignored

#$20 Tempo flag

bytes 3-4 = tempo (1-65535). Byte 5 ignored

#40 Jump flag Jumps to point in music

bytes 3-4 = Hex address of destination

byte 5 ignored

#$80 NOP flag does nothing

bytes 3-5 ignored

VOLBLK byte 1 = #$FE followed by 4 volume data bytes, 1 for each voice ($00-$FF)

EVWBLK byte 1 = #$FF followed by 4 envelope/wave data bytes ($00-$77)

bytes 2-5 = Bits 0-3 = wave 0-7

bits 4-7 = envelope 0-7

The File "Footer" is the same as standard RSDOS M/L files

consisting 5 bytes of:

Byte 1 EQU $FF

Byte 2 EQU $00

Byte 3 EQU $00

Byte 4 EQU MSB of Exec address -+- These 2 bytes are ignored.

Byte 5 EQU LSB of Exec address -+