The player 4.0A and 4.0B Created by Jarno Paananen (Guru/Sahara Surfers) Analysed by Asle / ReDoX (asle@mygale.org) Source: - 3 P40A files sent by Gryzor ! (thx). - 3 P40B files sent by Gryzor ! (thx). Offset size (byte) Comment ------ ----------- ------- 0 4 "P40A" Id. "P40B" Id. Note: It's the only difference I've found !. 4 1 Real number of pattern 5 1 Size of pattern list (PatSize) (number of pattern to play) 6 1 Number of sample (NOS) 7 1 ?????????? (00h) 8 4 tracks data address (TDA) add 4 bytes .. the size of a dword. 12 (Ch) 4 tracks table address (TTA) add 4 bytes. 16 (10h) 4 samples data address (SDA) add 4 bytes. *************************************** * the following is repeated NOS times * * with 16 bytes description for 1 smp * ****************************************************** * 20 (14h) 4 THIS sample data address * (first is 00000000h !) * (so, add SDA+4 ...) * 24 (18h) 2 Sample size (/2) * 26 (1Ah) 4 loop start address * (same shit as data address) * 30 (1Eh) 2 Loop Size / 2 * 32 (22h) 2 finetune *74 ?!? * 34 (23h) 1 ?!?!? (00h) * 35 (24h) 1 volume (0->40h) * * ****************************************************** Note: The sample address can be the same for several samples !. The player saves only once the same samples. ? PatSize*8 Pattern list. it consists of a list of 4 word which are the address of each track. Add TTA to each address to find the conresponding data of a track. ? 2 two bytes set to $FFFF. A "refer-to" as to specify for sure the end of the pattern list .. I guess :). ? ? track datas. Each track is 64 notes. One note is 4 bytes long ... most of the time :). Note description: case 1: (flag byte set to 0) - flag byte set to 0 / | Sample | Number | / /\ | | | | 0000-0000 0000-0000 0000-0000 0000-0000 | | | | | | | | \ / \/ \ / \ / relative effect effect info byte note value number info byte: This is a signed byte. Two cases follow .. case 1: (this byte is > 00h) it is, then, the number of empty lines that follow after this note. case 2: (this byte is >= 80h) it is the number of time this note is repeated. case 3: Heh ... not a case actually, merely noting that if this byte is null, then nothing happens :). sample number: The last bit of the sample number is also the first of the relative note number. It's entirely possible considering the fact that the notes are *2 ... so this bit is never used by the note. effect: * Effects with volume slide (5,6,A) are recoded. In fact, if the effect value is > 80h, then it's a slide up. (e.g. : A81 is A10 and A01 stays A01). I've only encountered this thing with A command ... I'm only suspecting it's the same for effects 5 and 6. * Arpeggio effect number is 8h in this format. relative note number (P40): C-1 to B-1 : 02,04,06,08,0a,0c,0e,10,12,14,16,18 C-2 to B-2 : 1a,1c,1e,20,22,24,26,28,2a,2c,2e,30 C-3 to B-3 : 32,34,36,38,3a,3c,3e,40,42,44,46,48 becomes (PTK): C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453 C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226 C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113 case 2: (flag byte set to 1) - flag byte set to 1 / | | | | 0000-0000 0000-0000 0000-0000 0000-0000 | | | | | | \ / \ / \ / empty number \ / of lines starting address to repeat some explanations are needed, I guess :) : So, if the first byte is 80h, the second byte is the number of lines one will have to repeat. Those "have to be repeated lines" are at the "starting address" specified by the last two bytes. Dont forget to add TDA + 4 bytes to this value to really have the address in the file. As an exemple, if you have N lines to repeat from address A, you have to point at A and read N notes and put them in this track. Remember that each note is 4 bytes !. Also, remember that the note at the corresponding address can have a not-null info-byte !. Thus, the empty lines or the repeat lines are to be counted !. Follows Sample datas stored like Protracker. Nothing is packed..