YM vectrex generator

With the supplied ym utility you can generate different YM data files (and players). Following is a list of these formats.

Uncompressed

The data is written in without any compressing to data statements - this is very easy understandable. (for comparisson, playing speed ~ 1700 cycles)

YMSound (historic)

This output is 100% compatible to the tool I released about 15 years ago. The structure of the generated ym file is explained in YM-Conversion I.

YMSound (opimized speed)

This is still in basic the same as YMSound, but with a few ehancements. The data between these two are NOT compatible.

The generated data uses a little bit more space (10% more ~ about). The average unpacking speed is about the same amount faster (a little bit more than 10%), but the main aspect is, that the "peaks" are reduced.

With my given example file, peaks by playing using the old routines were up to nearly 20000 cycles (average 3200 cycles). The new routines have a maximum peak of less thean 7500 cycles (in the whole song only 3 times) - and an average of about 2400 cycles.

Changes to YMSound historic:

Streamed

This is another way, that Vide can encode YM-data. It uses more (quite a bit more) memory than the old YM-Sound data, but unpacking is faster and nearly without peaks. If you have enough memory, have quite short ym-files and do not have many cycles to spare – this might just be the right format.

Playing my example averages at about 1300 cycles with peaks up to 2400 cycles.

Here a short explanation:

The ym data is bit encodeded in a stream of "bits". At first the ym-data is analyzed, the analysis results in following "knowledge":

According to the above knowlegde only used registers are encoded.

The idea behind streamed encoding is to only supply information for changes and leave out all data that is unchanged.

There are two good reasons for that:

Following decoding is used (for each ym-line, a complete set of data for one refresh cycle – encoding is the opposite way):

 read bit, if bit is 0 than nothing at all changed → goto done
 for channel 0 to 2 do
   read bit, if bit is 0
        than channel did not change at all → do next channel
   read bit, if bit is not 0
        read 4(5) bits of amplitude
   read bit, if bit is 1
        than set noise,
        otherwise clear noise
   read bit, if bit is 1
        than set tone,
        otherwise clear tone
   read bit, if bit is not 0
        read 8 bits of frequency low
   read bit, if bit is not 0
        read 4 bits of frequency high
 end for
 read bit, if bit is not 0
        read 5 bits of noise frequency
 if envelope is used
        read bit, if bit is not 0
                read 16 bits of envelope frequency
 done:

Note:
5 amplitude bits are used, when envelope data is used by the YM file.

Vectrex unpacking is done like described above. The unpacker is a bit "longish" since read bit is realized as a macro and often used :-).

The mentioned analysis is also respected by the vectrex sources. Code parts that are not needed are omitted (using "if then else").

The resulting player is usually quite a lot faster than the other packing – but the data used is by far not reduced as much. It depends on how "tight" (cycles) the circumstances are, what strategy of packing is more useful to you.