ÚÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÃÙ À´ ³ ÛÛ¿ ÛÛ¿ Û¿ Û¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛ¿ ÛÛÛÛÛÛ¿ ³ ³ ÛÛ³ ÛÛ³ ÛÛ¿ ÛÛ³ ÛÛÚÄÄÄÙ ÀÄÛÛÚÄÙ ÛÛ³ ÛÛÚÄÄÄÙ ³ ³ ÀÛÛÛÛÚÙ ÛÛÛÛÛÛ³ ÛÛÛÛÛ¿ ÛÛ³ ÛÛ³ ÛÛÛÛÛ¿ ³ ³ ÀÛÛÚÙ ÛÛÚÄÛÛ³ ÛÛÚÄÄÙ ÛÛ³ ÛÛ³ ÛÛÚÄÄÙ ³ ³ ÛÛ³ ÛÛ³ ÛÛ³ ÛÛ³ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ³ ³ ÀÄÙ ÀÄÙ ÀÄÙ ÀÄÙ ÀÄÄÄÄÄÙ ÀÄÄÄÄÄÙ ÀÄÄÄÄÄÙ ³ ³ÛßßßÜ ÛßßßÛ Ûßßßß Û Û ÛÜ ÜÛ Ûßßßß ÛÛÜ Û ßßÛßß ÛßßßÛ ßßÛßß Û ÛßßßÛ ÛÛÜ Û³ ³ÛÛ Û ÛÛ Û ÛÛ ÛÛ Û ÛÛß Û ÛÛßß ÛÛßÛÛ ÛÛ ÛÛßßÛ ÛÛ ÛÛ ÛÛ Û ÛÛßÛÛ³ ³ßßßß ßßßßß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßß ßß ß ßß ßß ßßßßß ßß ß³ ³ ³ ÿ Written by Arnaud Carre. (acarre%siam@cal.fr) Ú´ ÀÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÙ Many people asked me how to find new YM files. Well, the problem is that it takes me too much time to convert new modules. Then I decide to give you my YM-File format, so you can generate YM-File by yourself ! As you probably know, YM is only an YM2149 Chip emulator, not a true MC68000 emulator. (For the moment !). YM-Files does not contain any 68000 code routine. A music-file is composed of YM2149 registers generated by the original play-routine for each 50th seconds. As the YM2149 has 14 registers 8 bits each, that means 14 bytes for 1/50 second, so 700 bytes for one second of soundchip. When I convert an ATARI music, I play the music on the ATARI, and I store YM2149 registers set each 1/50sec (Vertical Blank time, VBL) in a big file as follow: VBL1: store reg0,reg1,reg2,...,reg12,reg13 (14 regs) VBL2: store reg0,reg1,reg2,...,reg12,reg13 (14 regs) .......... VBLn: store reg0,reg1,reg2,...,reg12,reg13 (14 regs) The problem is that is takes a lot of disk-space. Just count: A 10 minutes song will take 420000 bytes on disk. But don't panic, the music are compressed with LHARC method (using LHA program from Haruyasu Yoshizaki). To reach best compression ratio, I store registers in a different order: VBL1 reg0, VBL2 reg0, VBL3 reg0 .... VBLn reg0 VBL1 reg1, VBL2 reg1, VBL3 reg1 .... VBLn reg1 .......... VBL1 reg14,VBL2 reg14,VBL3 reg14.... VBLn reg14 So, here is the old YM3 file format: Offset Size Name Value Comments 0 4 ID 'YM3!' File type Identificator. then YM2149 registers starts a offset 4. The number of used VBL for music can be computed as follow: nvbl = (ymfile_size-4)/14; ------------------------------------------------------------------------------ WARNING: The LHA compression must be called AFTER the file is generated. ALWAYS USE THE HEADER TYPE 0 when compressing (-h0). Ex: You just create your binary file, starting with 'YM3!' ID, then all YM registers. The music is 2 minutes long, that means your binary is 2*60*700 + 4 = 84004 bytes long. you must compress it before using the file with YM.EXE: (ex: your binary is TEST.BIN) LHA a -h0 TEST.LHA TEST.BIN Then a file TEST.LHA is created, wich is DIRECTLY a valid YM file. just type: ren test.lha test.ym Then you can hear the file with YM.EXE (I use LHA.EXE v2.13). ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ WARNING: Some old and specific music starts with header 'YM2!', don't use this ID. ------------------------------------------------------------------------------ SPECIAL: Register 13 ! ---------------------- Creating a binary with YM registers for each VBL is easy. However there is special case concerning register 13. Reg13 is used for the volume envelope wave-form on the YM2149. The problem is writing to that register "restarts" the wave-form at beginning. That is, you CAN'T access this regis- ter each VBL if the original play-routine does not. So, if the original player does not write to register 13 on VBL n, write 0xff value. (So when YM.EXE read 0xff as reg13, the internal emulator register is not updated). That's all for 'YM3!' file. --------------------------- That's all for the 'YM3!' format. As you see, it is very simple (then not very powerfull) but you can convert many atari soundchip tunes with that format. (Especially old game-music, wich use very simple play-routine, or AMSTRAD CPC music). But if you know the ATARI demos, you probably know there is many tricks used by sound-player to produce real-drums or distorted sound: sample for drums, additional tone synthesis using TIMER etc... The 'YM3!' format can not play such music so... ÚÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÃÙ À´ ³ ÛÛ¿ ÛÛ¿ Û¿ Û¿ ÛÛ¿ ³ ³ ÛÛ³ ÛÛ³ ÛÛ¿ ÛÛ³ ÛÛ³ÛÛ¿ ³ ³ ÀÛÛÛÛÚÙ ÛÛÛÛÛÛ³ ÛÛÛÛÛÛ¿ ³ ³ ÀÛÛÚÙ ÛÛÚÄÛÛ³ ÀÄÄÛÛÚÙ ³ ³ ÛÛ³ ÛÛ³ ÛÛ³ ÛÛ³ ³ ³ ÀÄÙ ÀÄÙ ÀÄÙ ÀÄÙ ³ ³ Û Û ÛßßßÛ ÛÛßßß ÛßßÛ ÛßßßÛ ÛßßßÛ ÛÛÜ Û ³ ³ ÛÛßÜÛ ÛÛßßÛ ßßßßÛ ÛÛßßÛ ÛÛ Û ÛÛßÛß ÛÛßÛÛ ÜÜ ÜÜ ÜÜ ³ ³ ß ß ßß ß ßßßßß ßßßßß ßßßßß ßß ß ßß ß ßß ßß ßß ³ ³ ³ ÿ Ú´ ÀÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÙ The 'YM4!' format is not currently implemented in the YM emulator, but I have written the most complete format to play all "evoluated" music such as SCAVENGER or ETERNAL tunes. If you convert a music wich the player does not use any "hardware" trick such digi-drum or synth-tune, use 'YM3!' format describe above: it will be faster and easyer to create. (Almost all standart YM file existing around the world (exept DIGI-Drums ones) can be written in YM3 format). If you want to convert a SPECIAL music wich use many tricks to produce strange sound, you must be familiar with ATARI-ST sound programing and follow next instructions... Additional sound effects used by strange-player are only two types differents: 1) Digi-Drums -------------- Generally digi-drums is a bunch of sample in the orignal play-rout. You will have to localize and extract them. In the YM file, you have to store the sample with their respective size. (see next part) when playing, a digi-drum is defined with one value: timer frequency to replay sample. 2) Tone synthesis ----------------- To produce very funny sound, some player use the ATARI-ST timer controller to change YM2149 volume more than 1 time per VBL. Generally the routine in the player is as follow: lab1: move.l #$08000f00,$ffff8800.w move.l #lab2,$134.w rte lab2: move.l #$08000000,$ffff8800.w move.l #lab1,$134.w rte So the volume is set to 15 then to 0 then to 15 etc... many times in the same VBL at a given frequency. In fact, the volume switch always between 0 and vmax. So a tone-synthesis is define by two values: vmax and timer frequency. 3) 'YM4!' File format: ---------------------- Here is the description of the binary YM4 file. After the file is created, you can compress it with LHA -h0 as above. Legend: BYTE 8bits integer. WORD 16bits integer. DWORD 32bits integer. string[n] Ascci string of n bytes long. NT-String NULL-Terminated string. WARNING: All DWORD or WORD are strored in MOTOROLA order in the file (INTEL reverse) Offset Size Type Comment 0 4 DWORD ID of YM4 format. ('YM4!') 4 8 string[8] Check String ('LeOnArD!') 12 4 DWORD Nb of valid VBL of the file. 16 4 DWORD Song attributes (see bellow) 20 2 WORD Nb of digi-drum sample (can be 0) For each digidrum sample: { .. 4 DWORD sample size .. ? BYTES sample data (8bits per sample) } .. ? NT-String Name of the song. .. ? NT-String Name of the author. .. ? NT-String Comments .. ? All YM2149 registers. .. 4 DWORD End-File check. ('End!') So you've seen in the YM3 format that all 14 registers of the YM2149 are saved in file each VBL. Now, I had to add 2 "virtual" registers to store extended information. So there is 16 bytes in the file for each VBL. Now the VBL number n will be noticed "Vn" and register m "Rm". First VBL is V0 and first register is R0. (R0 to R15) The file data block will be composed of: V0R0,V0R1,V0R2,....,V0R14,V0R15 V1R0,V1R1,V1R2,....,V1R14,V1R15 ..... This is the non-interleaved format block. The data block can be on a different form: V0R0,V1R0,V2R0,....,VnR0 V0R1,V1R1,V2R1,....,VnR1 .... V0R15,V1R15,V2R15,....,VnR15 This is the interleaved format block. Those who are reading till now have noticed that the YM3 format is an interleaved format. In fact, the YM4 format can be interleaved or not. (Interleaved format offers a very powerfull compression ratio when compressed with LHA). Let's see the DWORD "song attribute": (bn represent the bit n of the DWORD) b0: Set if Interleaved data block. b1: Set if the digi-drum samples are signed data. b2-b31: Not used yet, MUST BE 0. Here come valid bits for standard 14 first registers: (Same as YM3 Format.) (- means Unused, X means used) NOTE: Now, digi-drum will be noticed DD and Timer-Synth will be noticed TS. b7 b6 b5 b4 b3 b2 b1 b0 r0: X X X X X X X X Period voice A r1: - - - - X X X X " " " r2: X X X X X X X X Period voice B r3: - - - - X X X X " " " r4: X X X X X X X X Period voice C r5: - - - - X X X X " " " r6: - - - X X X X X Noise period r7: X X X X X X X X Mixer control r8: - - - X X X X X Volume voice A r9: - - - X X X X X Volume voice B r10: - - - X X X X X Volume voice C r11: X X X X X X X X Waveform period. r12: X X X X X X X X " " r13: - - - - X X X X Waveform shape. New "virtual" registers to store extra data: r14: - - - - - - - - Frequency for DD1 or TS1. r15: - - - - - - - - Frequency for DD2 or TS2. As we've seen, r13 has a particular status. If the value stored in the file is 0xff, YM emulator will not reset the waveform position. The YM4 format provides to start or run 1 TS and 1 DD during the same VBL. You notice there is a least 28 free bits in the 14 standard registers. YM4 format use them to store "extra" information. Let's see the "extra" bits: r1 free bits are used to code TS: r1 bits b5-b4 is a 2bits code wich means: 00: No TS. 01: TS running on voice A 10: TS running on voice B 11: TS running on voice C r1 bit b6 is only used if there is a TS running. If b6 is set, YM emulator must restart the TIMER to first position. (You must be VERY sound- chip specialist to hear the difference). r3 free bits are used to code a DD start. r3 b5-b4 is a 2bits code wich means: 00: No DD 01: DD starts on voice A 10: DD starts on voice B 11: DD starts on voice C WARNING:If a DD starts on voice V , the volume register corresponding to V (Ex r8 for voice A, r9 for B and r10 for C) contains the sample number in 8 bits. Concerning DD and TS, both effects need to be played at a given frequency. On the ATARI-ST, play routine use the MFP-TIMER chip. That is, any frequency can be coded on 13bits: 8bits for timer count, and 3bits for timer predivisor. The MFP runs at 2457600 Hz and has a preset of predivisor: 000: Timer stop. 001: Prediv by 4 010: Prediv by 10 011: Prediv by 16 100: Prediv by 50 101: Prediv by 64 110: Prediv by 100 111: Prediv by 200 The 8 bits timer count value is named TC and 3bits prediv value is named TP. Some ex to endserstand how it works: TP TC Frequency (Hz) 1 28 (2457600/4)/28 = 21942 Hz 4 150 (2457600/50)/150 = 327 Hz Encode: ------- TP for TS is stored in the 3 free bits of r6 (b7-b5) TP for DD is stored in the 3 free bits of r8 (b7-b5) TC for TS is stored in the 8 bits of r14 TC for DD is stored in the 8 bits of r15 4bits volume value (vmax) for TS is stored in the 4 free bits of r5 (b7-b4) 4) Pfff.... ----------- That's all for the YM4 format wich allow you to encode most of the demo-soundchip from the ATARI. If some of you think the file format is a bit hard to assume I agree with you. I only prefer a complex but shorter format than simple and big one... If you have any trouble, problem or questions about YM3 or YM4 format, write or mail me: Internet E-Mail: acarre%siam@cal.fr French "Minitel" 3615 RTEL bal "LEONHARD" (with a H) ------------------------------------------------------------------------------ Have a nice day ! ------------------------------------------------------------------------------