Tutorial How To Generate TSX Files Nataliapc - makeTSX Wiki GitHub
Tutorial How To Generate TSX Files Nataliapc - makeTSX Wiki GitHub
Every project on GitHub comes with a version-controlled wiki to give your documentation the high
level of care it deserves. It’s easy to create well-maintained, Markdown or rich text documentation
alongside your code.
INDEX
1. Basic technical concepts of tape data encoding
1.1. Bits encoding
1.2. Bytes encoding
1.3. Data blocks
1.3.1. Header blocks
1.3.2. Data content blocks
1 4 The new #4B block
1.4. The new #4B block
Most of the old 8-bit computers hare using FSK (Frequency-shift keying) to storing data on
magnetic media. This method is based on changing the frequency of the signal to define two
or more symbols to store. More specifically, in the case at hand, there would be two: zeros
and ones.
Each system used its own coding system: different frequencies, pulse repetitions, parity
systems and control bits. Here we will see the ones used by the MSX computers.
As we can see in the following image, to encode a bit 0 we use 2 pulses while for a bit 1 we
use 4, being its duration the same due to their different frequency. This is true in the MSX
system, unlike the Spectrum or SVI-318/328 encoding, in which a bit 0 and a bit 1 don't have
the same length.
1.2. Bytes encoding
The MSX standard uses LSB (Least Significant Bit) convention to encoding bytes, which
consists in showing bits from the least significant bit to the most significant bit, unlike
Spectrum that uses MSB (Most Significant Bit) that reverses the order of appearance.
In addition to LSB, there is several control bits surrounding the bytes called start bits and
stop bits. In this case a single start bit to 0 and two stop bits to 1 are used. So, to encode a
byte, we would have 11 bits in the following way:
0 b0 b1 b2 b3 b4 b5 b6 b7 1 1
This type of coding comes within KCS (Kansas City Standard) which is the one adopted by the
MSX system for tape recordings. There are several forms of KCS coding incompatible with
each other, for example those of the following systems: MSX, ABC 80, Acorn BBC/Electron,
MicroBee, Dragon/CoCo, SVI-3x8, ...
In MSX there are two types of pilot pulses: long (for the header blocks) and short (for the
data content blocks). Both are encoded like they were a series of consecutive bits 1 (using
bit1 frequency), but they differ in the number of pulses that contains.
The following table has information about the different pilot pulses:
On the other hand, there are 3 standard types of data blocks: BINARY, ASCII and BASIC. They
are differentiated by an ID byte repeated 10 times in its header blocks and by the data
structure of its data content blocks as we will see below.
BINARY (0xD0),
10 bytes ID telling us the type of data
0x00‑0x09 ASCII (0xEA),
content block that will come next
BASIC (0xD3)
The BINARY type have 6 bytes at the beginning indicating the start (2), end (2) and execution
(2) addresses of the block in RAM. Following is the byte data.
The ASCII blocks contain a BASIC program in ASCII format that are divided in subblocks of
256 bytes length. Each subblock has its own short pulse pilots and are separated by
silences. The last subblock is filled with 0x1A until it reaches 256 bytes length.
And the BASIC blocks contain a tokenized BASIC program followed by 7 bytes 0x00
indicating the end of the file.
This new block with ID #4B and created by @Blackhole, allows coding blocks of data that
follow the KCS standard, so data from all the systems that adopted it can be included.
For the specific case of the MSX, the configuration of a block #4B for a header block at 1200
baud would be this way:
0 08 N Pil t l 30720 l
0x08 No. Pilot pulses 30720 pulses
Offset Description Values
0x24 (00100100b):
0x0E BIT Configuration 0010 = 2 pulses for a ZERO
0100 = 4 pulses for a ONE
0x54 (01010100b):
01 = 1 start bit
0 = Start bits are ZERO
0x0F BYTE Configuration 10 = 2 stop bits
1 = Stop bits are ONE
0 = Reserved
0 = LSB bits order
This program is very similar to WAV2CAS or MAKETZX, since it allows to extract data from a
WAV file, as long as the quality of the digitalization or the deterioration of the tape allows it.
Processing an audio with squared and defined pulses is the best, but various problems can
occur due to deterioration of the tape such as:
Sometimes several of these can occur at the same time, making it more difficult the tape
rescue.
As you can see in the images, the data will be recoverable as long as the transition between
pulses crosses the zero (horizontal line). Otherwise (as it appears at the red boxes) you
would have to edit the waves by hand to fix them, which is a hard work and can be
exasperating.
In order to see this type of graphics we recommend using some audio editing program such
as Audacity (a free, open source, cross-platform audio software).
Now we will go on to enumerate the steps and methods to get a correct and validated TSX as
far as possible.
To create the WAV from tape you can use the above mentioned Audacity program.
To get square pulses you need to disable any type of filter/preprocessing that the cassette
player has, the sound driver of your PC, or the audio record program.
In order to minimize the background noise, it is necessary to find a balance with the
reproduction volume of the cassette. You must find the point where the signal is high enough
so that the pulses are well defined and their transitions cross the center line of the zero, but
low enough so that the signal does not saturate or increase the tape noise too much. This is
mostly seen in the silences between data blocks.
If by deterioration of the tape or action of a filter a sinusoidal signal is obtained, the data can
still be readable if the wave correctly crosses the central line in each transition.
There are other parameters that will be useful for controlling errors such as -v that will
inform us for each bit and byte of everything that is found in the WAV file.
For more information about all of them you can run makeTSX without parameters and you
will get a complete help list.
Unfortunately, it is not always possible to determine the correct value of this faulty bit, so in
this situation makeTSX will ask us for the action to be taken, choosing between adding a bit
#0 or #1.
In the blocks Spectrum (#10 and #11) the control of errors is something more complex since
the control bits do not exist, however usually they have a modulation of much more precise
frequency. Reason why the check method the times of a complete cycle (2 pulses) to
determine if we are facing a bit #0 or #1. You can also use as a check the last byte of the
block that is the checksum of bytes block to know if the conversion was correct or not.
makeTSX is prepared to read Spectrum blocks only if they are standard #10. For non-
standard Spectrum blocks or with some type of error not recognized by the program, it's
recommended to use MAKETZX to extract those specific blocks and add them to the final
TSX using the ZXBlockEditor utility. The MAKETZX program is specialized in Spectrum blocks
extraction, so it will do it much more reliably in case of signal problems.
At next image we can see a signal with a damaged wave and later corrected to a square
shape so that's easily recognizable by makeTSX.
The best option would be to have several WAVs of different tapes for each game to convert,
but that can be quite complicated to achieve, so we use indirect verification methods.
If everything matches, it will be a great indication that we have a correct conversion to 99%.
If in any block the CRC do not match we will have to look at which byte/bytes are the
differences, to do that we need to export both blocks with ZXBlockEditor (right mouse click ->
Export as... -> Binary file *.bin) and use some program like vbindiff, that is a good choice of
multiplatform command line binary comparer.
Suppose that the byte that differs is at 0x0217 offset of second block. Then we go to the
makeTSX again and with the option -v we navigate de output and look for the millisecond
where that byte is found in the WAV.
We can see below that a strange pulse has been detected at bit no.7, so we will have to open
the WAV with Audacity and do zoom at second 14.4420.
y
Here we can see the original signal above and the manually corrected below where we have
corrected bits no.7 and 8.
The important thing to remember is that in case of any discrepancy between the CAS and the
TSX, the best is go to the original source, the WAV, and so be able/try to determine the
correct value of those bits.
Everything indicated in previous section is valid for the MSX blocks of these tapes, except
that at least one of the #4B blocks there will be a group of bytes that will be different to their
respective in CAS block. This is due to the Spectrum blocks load routine (patched in the CAS
to read only MSX blocks). In this case, if the TSX load is checked correctly we could assume
the Spectrum load routine as correct.
In the Spectrum blocks (with ID #10 and #11) you can easily check if the checksum is correct
or not, even so, you can also compare their CRCs with their respective CAS blocks even if
they have different formats, just export the blocks to files and take care if flag (first block
byte) and checksum (last one) are present in both files before compare them.
Be careful also with zeros at end of CAS block due a CAS format limitation: all blocks must
have a byte length multiple of 8 so blocks are zero filled if needed. You need to remove them
for CRCs comparation.
The goal is therefore to obtain two blocks of same size, starting and finishing with the same
bytes, only then we can compare their CRCs.
It is important to always remember that if we doubt about the verification of Spectrum blocks
we can always use MAKETZX as indicated in chapter 3.3 and add those problematic blocks
by editing your TSX.
Pages 3
Find a Page…
Home
https://github.com/nataliapc/makeTSX.wiki.git