VTX format
ZXNet echo conference «code.zx»
From Aleksandr Majorov → To Andrew Lee 27 November 1999
Hayushki, Andrew!
Somehow on 11/27/99 at approximately 03:10:04 someone Andrew Lee reported
for All that "VTX format"
AL> I remember once a subject flew by. if anyone has
AL> throw it on the origin pls...
================================================================================
┌────────────────── ──────────────────── ─────────────────── ───────────────────┐
│▒▒ Description of the .VTX format ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
└────────────────── ──────────────────── ─────────────────── ───────────────────┘
The .VTX format is a universal music format supported by
Vortex package. The file consists of a header and data. The title is in
uncompressed, at the beginning of the file, and the data is packed using the LHARC method. Table 1
The header structure is presented:
Table.1
┌──────────┬──────────┬───────────┬─ ───────────────────────────────────·
│ Offset │ Size │ Type │ Description
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ 00 dec │ 2 bytes │ Word │ VTX file ID (ay or ym)
│ │ │ │ is the default chip type:
│ │ │ │ what is 7961h or 31073 dec (ay)│ │ │ │ what is 6D79h or 28025 dec (ym)
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ 02 │ 1 │ Byte bit │ Default playback modes:
│ │ │ │ Bits 0-2 are responsible for stereo mode:
│ │ │ │ 0 - MONO, 1 - ABC, 2 - ACB, 3 - BAC,
│ │ │ │ 4 - BCA, 5 - CAB, 6 - CBA (dec)
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ 03 │ 2 │ Word │ Quantum number of the cycle (starting from zero =
│ │ │ │ beginning of the melody). Can be disabled in the player
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ 05 │ 4 │ DWord │ AY chip frequency for this melody
│ │ │ │ (introduced for ringtone compatibility,
│ │ │ │ transferred, for example from Atari)
│ │ │ │ Standard values:
│ │ │ │ ZX_Spectrum: 1773400 (or 001B0F58h)
│ │ │ │ Atari: 2000000 (or 001E8480h)
│ │ │ │ Amstrad CPC: 1000000 (or 000F4240h)
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·│ 09 │ 1 │ Byte │ Player frequency. Those. number of quanta in
│ │ │ │ second. Standard value, 50 =
│ │ │ │ 1/50 second (20ms).
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ 10 │ 2 bytes │ Word │ Year the composition was written
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ 12 │ 4 │ DWord │ Size of unpacked data. Needed
│ │ │ │ to unzip.
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ 16 │ 1-255 │ NTString │ String containing the melody name
│ │ │ │ (1-254 characters), must be
│ │ │ │ end with zero even if the entry
│ │ │ │ missing!
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ ?? │ 1-255 │ NTString │ String containing the author's name (see ^)
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ ?? │ 1-255 │ NTString │ Program where the melody comes from (see ^)
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ ?? │ 1-255 │ NTString │ Name of music. editor (see^)├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ ?? │ 1-255 │ NTString │ Comment line (see ^)
├──────────┼──────────┼───────────┼─ ───────────────────────────────────·
│ ?? │ ?? │ Array │ Compressed data packet...
└──────────┴──────────┴───────────┴─ ───────────────────────────────────·
Following the header is the data packet. In uncompressed form, this is a dump of the first 14 regions.
islands AY-3-8912, related to sound generation, but they are located in
slightly different sequence than in order. This provides high
compression level of the final file. So, let there be a melody in which there are N
quanta Let's say one quantum is equal to 1/50 sec. (see player frequency in Table.1).
Then in the data block it is necessary to create the following arrangement of register values:
Table.2
Q1:R0, Q2:R0, Q3:R0, Q4:R0, Q5:R0, ... , QN:R0 (total N bytes)
Q1:R1, Q2:R1, Q3:R1, Q4:R1, Q5:R1, ... , QN:R1 (N bytes in total)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Q1:R13, Q2:R13, Q3:R13, Q4:R13, Q5:R13, ..., QN:R13 (total N bytes)
In total, the length of the data block is: N * 14 bytes.
This method of storing data about the values of the AY registers at a specific time,has one drawback: the large size of such a block, and high requirements
to the disk space. For example, a composition 10 minutes long will take: 600 *
* 50 * 14 = 420000 bytes ~= 410 kilobytes. To compensate for this shortcoming, I
introduced data block compression using the LHARC method, implemented in the LHA archiver (author
Haruyasu Yoshizaki), and specifically using type 5, which is present in
this archiver since version 2.XX (for example in lha v2.55b). Compressed file size
with this archiver in our case it will be equal to ~10 kilobytes...
Now let's talk about how to prepare a compressed data block. Packaging with LHA archiver
is not the only way to obtain such a structure. You can use
your own packer, taken, for example, from SWAG, or write your own. It is important
so that the method is fully compatible with LH5. Well, now I will describe how to get
data block using an external LHA archiver. First you need to compress the file with
data (for example, tune.bin):
lha.exe a tune.lzh tune.bin
The resulting .lzh file is not yet suitable for pasting into a header. Firstly,
we need to find out the length of the unpacked file (either from the LZH header, or even before
measure compression). Then, cut off the last zero byte from LZH - it gives us
not needed. Then, find out the length of the packed data from the LZH header and getthem in their pure form, cutting off this very title. And now add this data
with VTX format header.
Important Note:
─────────────────
It is known that the R13 register of the AY-3-8912 is responsible for the shape of the envelope and its transformation
loading will cause a new cycle to begin. In the Vortex engine, this is taken into account by the following:
at once: if you need to indicate to the player that changes to the register value
the envelope shape was not present at this quantum - this should be recorded in a memory cell for
R13 value FFh (255 dec). Having encountered such code, the player will continue executing
current envelope algorithm.
Well, that seems to be all that could be said about the presentation of the format
VTX supported by Vortex engine. I hope that it will find wide application in
Your products that I would love to hear about and include in my package.
================================================================================
Well that's it *MAS* with a sledgehammer