===================================================================== NESA FILE FORMAT Documentation v1.01 (4/10-1998) ===================================================================== Document & fileformat by:........................... Morgan Johansson Thanks to.................................. Leo Flavum (for the idea) What is this then? Well, NESA is a format for storing NES Audio data. As the NES has no standard music format (as far as I know), I invented NESA to implement in the A/NES emulator for Amiga. The theory is to rip the audio while it's played and then save it into a NESA (.nsa) file. ===================================================================== Header explanation ===================================================================== The header consists of 16 bytes. NESAHeader: dc.b 'NESA' ;NES AUDIO NESAVersion: dc.b %00100010 NESASndControl: dc.b %00000111 NESAControl1: dc.b %10000000 NESAControl2: dc.b %00000000 NESAControl3: dc.b %00000000 NESAControl4: dc.b %00000000 NESAControl5: dc.b %00000000 NESAControl6: dc.b %00000000 NESALength: dc.b 0,0,0,0 NESAHeader ---------- Here is four bytes of file-identification. Simple. NESAVersion ----------- bit 0-4 = Version of file format (=2) bit 5-7 = Audio compression (=1) NESASndControl -------------- Bits 0-4 explains which soundchannels that are saved in the file. Bit 0 = SquareWave 1 Bit 1 = SquareWave 2 Bit 2 = TriangleWave Bit 3 = Noise (Not yet supported!) Bit 4 = PCM (Not yet supported!) Bits 5-7 are not in use (yet) NESAControl1 ------------ Bit 7 tells if the song was recorded on a PAL (1) or NTSC (0) system. Bit 6 = 1)32 byte title enabled Bit 5 = 1)32 byte comment enabled Bit 4 = Future Bit 3 = Future Bit 2 = Future Bit 1 = Future Bit 0 = Future NOTE! Possible title/comment data is ALWAYS stored right after the 16-byte header bytes. NESALength: ----------- Four bytes which tells the length of the NESA-song in bytes. ===================================================================== Compression types ===================================================================== The NESA header is quite flexible and will support more compression types in the future. Just be sure, if you're coding a player for NESA, to check the version bits and NOT to play the data if the version number of the file is higher than the ones you support. ===================================================================== * Compression type 0/1 ===================================================================== Ignore this, for internal use only. ===================================================================== * Compression type 2 ===================================================================== This type is very simple but it has some limitations (sound channels cannot be enabled or disabled during play for example). However, it should work very well when ripping title-songs and similar. A/NES v0.99.95b saves the audio in type 2. All data is stored three-bytes-in-a-row. Byte 1 ------ Bit 7-4 = Register to write ($0-$B, add $4000 to get NES-address). Bit 3-0 = Timer upper 4-bits Note! Register values above $B will be ignored. Byte 2 ------ Timer Lower 8-bits (total 12 bits) Byte 3 ------ Data to be written to register The timer describes how many NES-vertical blanks to wait before writing the data to the current register. As several registers sometimes are written to at the same time, the timer sometimes are zero. Note! The last three bytes of the data is always $FF $FF $FF (NOT counted in the NESA-length in the header!) ==================================================================== History ==================================================================== v1.02 (27/2-1999) ~~~~~~~~~~~~~~~~~ - Minor fixes. - Use NESA v3 instead! v1.01 ~~~~~ - Fixed some minor errors... v1.00 ~~~~~ - First public release