NESA Version 3 technical information Written by Morgan Johansson morgan.johansson@mbox301.swipnet.se Updated: 21/3-1999 --------------------------------------------------------------------- Important! --------------------------------------------------------------------- You are allowed to make use of the NESA fileformat in your own applications if you want. However, if you decide to use it, we would appreciate if you gave us, the A/NES crew some credit (something like an URL to our homepage, http://www.emuclassics.com/anes/). This format was constructed during the development of A/NES. It has it's limits but it is quite simple and works very good in most cases. Have fun with it! --------------------------------------------------------------------- What is it? --------------------------------------------------------------------- It's a fileformat for storing NES audio. --------------------------------------------------------------------- New features since v2. --------------------------------------------------------------------- + Fileformat is more efficient. + Noise support. + PCM 1-bit support. Not included: + PCM 8-bit RAW samples doesn't work. This is a limitation with the NESA-format. However, 98% of all ROMs doesn't use 8-bit PCM so you could probably calm down. :) --------------------------------------------------------------------- HEADER --------------------------------------------------------------------- Check this out carefully, there is some changes compared to version 2. Offset: 4.L 'NESA' ;File ID 5.B %00000011 ;NESAVersion 6.B %00011111 ;NESASndControl 7.B %00000000 ;NESAControl1 8.B %00000000 ;NESAControl2 9.B %00000000 ;NESAControl3 (unused) 10.B %00000000 ;NESAControl4 (unused) 11.B %00000000 ;NESAControl5 (unused) 12.B %00000000 ;NESAControl6 (unused) 13.L 0 ;NESALength (32 bits) NESAVersion: ~~~~~~~~~~~~ Bit 0-4 = Version (=3) Bit 5-7 = Audio Compression type (=1) NESASndControl: ~~~~~~~~~~~~~~~ Which channels are available in this file? Bit 0 = Squarewave1 Bit 1 = Squarewave2 Bit 2 = Trianglewave Bit 3 = Noise Bit 4 = PCM Bits 5-7 are unused and should always be set to zero. Will probably be used for more soundchannels in the future (for FDS games or games with extended MMC's that supports more sound-channels). NESAControl1 ~~~~~~~~~~~~ Bit 7 = Prefered playrate (1=PAL,0=NTSC) Bit 6 = 1)32 byte title enabled Bit 5 = 1)32 byte comment enabled Bit 4 = 1)32 byte author-name enabled Bit 3-0 = Future, set to zero Note, on bit 7, NESA v2 says: "tells if the song was recorded on a PAL (1) or NTSC (0) system.". This is not accurate and should be ignored. This bit should be a copy of the PAL/NTSC bit in the iNES header. However, as Marat has not yet defined such a bit in the header (for some unknown and weird reason) A/NES will assume that all ROMs are NTSC ROMs and this bit will be set to 0. However you can always set this bit manually if you know if the game was designed for PAL or NTSC. NESAControl2 (1 byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is an ID of what version of A/NES that saved this file. A/NES v0.99.99 will have the number "99". NESALength ~~~~~~~~~~ Here is the length of the NESA-song (in bytes). Possible PCM-samples/table are not included. --------------------------------------------------------------------- DATA --------------------------------------------------------------------- Delay-counter (1 byte) ~~~~~~~~~~~~~~~~~~~~~~ How many vertical blanks to wait for register-write. This one is 8-bit only and is limited to max 5 seconds (on PAL screens). Data-register #1 (1 byte) ~~~~~~~~~~~~~~~~~~~~~~~~~ Data to be written to register. Data-register #2 (1 byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~ Bits 0-4 controls the register to be written to. Valid addresses are from $0-$13 & $15. News here from v3 is that Noise/PCM registers are included, aswell with the sound-control register ($4015). Notice that register $12 does NOT contain the original NES-written data, instead this register contains a sample number to play. Bit 5 is set to 1 if next databyte coming up is a new register or 0 if next byte is a "Delay-counter". Bit 6 is a loop-mark (set to 1 for loop=enable). This means that the NESA-song will restart from this point if defined. Bit 7 is currently unused and should be set to 0. End-sequence ------------ All NESA-files ends with $FFFFFF. --------------------------------------------------------------------- PCM --------------------------------------------------------------------- Right after the sound-table-data in the NESA-file, the PCM information is stored. First, there is a 64 bytes large table which contains the length(in bytes) of each PCM-sample (2 bytes/sample). So, this limits v3 with maximum 32 PCM-samples, however this should be more than enough for all ROMs. After the table you can find the PCM raw 1-bit data. Simple! :) Notice that the PCM table+samples are only present if PCM registers was written too when recording the song. Many games doesn't use the PCM-registers so this section of the NESA file won't be present.