Difference between revisions of "Tape\Disk Preservation"

From The Dragon Archive
(WAV to CAS)
Line 3: Line 3:
 
== Tools ==
 
== Tools ==
  
=== Tape to CAS File ===
+
=== WAV/VOC to CAS ===
 
 
Current preferred method is a special version of XROAR that will output the byte stream its virtual ADC reads from a WAV file as the tape loads (CLOAD/CLOADM).
 
 
 
Previously DC.EXE (Dragon Convert) was used to create CAS files from WAV samples but this often resulted in CAS files with truncated sync bytes rather than an accurate dump of the original media. DC.EXE had two operating modes, the default mode assumed that the tape content followed the documented dragon tape format and the /R option simply created a CAS file that was a RAW stream of the input bytes.
 
  
 +
'''XROAR'''
 +
Currently the preferred method is the XROAR emulator, this can be using to output the byte stream that its virtual ADC reads from a WAV file as the tape loads (CLOAD/CLOADM). Because this method is using an emulated ADC and the actual Dragon ROM routines to read the "tape" the success ratio for conversion is much higher.
  
=== WAV/VOC to CAS ===
 
 
'''Dragon Convert (DC.EXE)'''
 
'''Dragon Convert (DC.EXE)'''
 
Where the input to Dragon Convert is a WAV or VOC file the audio information is  scanned  for  Dragon cassette data and converted to a  virtual  cassette file.  The  output filename is derived from the Dragon filename rather than the input filename.
 
Where the input to Dragon Convert is a WAV or VOC file the audio information is  scanned  for  Dragon cassette data and converted to a  virtual  cassette file.  The  output filename is derived from the Dragon filename rather than the input filename.
Line 51: Line 48:
 
=== CAS to WAV ===
 
=== CAS to WAV ===
  
DC.EXE will create a clean WAV sample from a CAS file. If the CAS file has all its SYNC bytes then the resultant WAV can be loaded by a real Dragon 32/64.
+
A  secondary  use  of Dragon Convert (DC.EXE) is to convert cassette  files  back  to digital audio format so that they can be written to cassette and loaded into a real  machine. When converting to audio format the cassette file  is  not examined  thereby  enabling  any  file type  or  proprietary  format  to  be converted. To  use  Dragon  Convert for this  purpose  imply  specify  the filename of a cassette file when you start the program.
 +
 +
By  default  a  44KHz  WAV file will result. This gives  very  high  quality playback  but  requires more than 8Mb of hard disk space for  a  32K  Dragon file.  You  can therefore optionally specify /22 on  the  command  line  to request a 22KHz output file (or /11 for 11KHz).
  
 +
If the CAS file has all its SYNC bytes (See CAS Format below) then the resultant WAV can be loaded by a real Dragon 32/64.
  
 
=== "Fixing old CAS files" ===
 
=== "Fixing old CAS files" ===
Line 88: Line 88:
 
=== Dumping ROMS ===
 
=== Dumping ROMS ===
  
CSAVEM, start, end, exec
+
There  are  several  ways to transfer your ROM for use with  Dragon emulators.  The method  suggested  here  is to use the Dragon  Convert  utility  to transfer  the  ROM  in  the same way as cassettes. An alternative method would be to place the ROM in an EEPROM reader connected to a PC and dump the contents to a file.
Convert to CAS
+
Use DC.EXE to extract from CAS to ROM format
+
The procedure for transfer via cassette and the Dragon Convert utility is as follows:
 
+
.DGN format is a only an 8 byte header that can be removed or added to a raw rom dump.
+
    1)  Boot up your Dragon 32, Dragon 64 or Tandy CoCo.
 +
         
 +
    2)  Ready  your  tape  recorder for recording  and  commit  the  ROM  to
 +
          cassette by typing:
 +
         
 +
                      CSAVEM "DRAGROM", &H8000, &HBFFF, 0
 +
                                     
 +
        If  you  have a Tandy CoCo you may optionally use the name  TANDYROM
 +
          rather than DRAGROM.
 +
         
 +
    3)  Boot  up  your  PC  and SoundBlaster Pro wave form editor  software.
 +
          Sample  the cassette recorded in step 2 into a file. Alternatively,
 +
          use  the  parallel cable and the ReadVoc utility.  A  large  output
 +
          file should result.
 +
         
 +
    4)  Now use Dragon Convert to extract the cassette data. Type:
 +
         
 +
                                  DC DRAGROM
 +
                                     
 +
        Please  don't  expect the conversion to work on the  first  attempt.
 +
          You  are  likely to need to adjust the command line switches  until
 +
          you  find  a combination which is suited to your hardware. If  you
 +
          still  have no success then you may wish to try repeating  step  3.
 +
          Upon successful conversion the file DRAGROM.CAS will be created.
 +
         
 +
    5)  Now  use  Dragon  Convert again to convert the cassette  data  to a
 +
          cartridge file. Type:
 +
         
 +
                              DC  /D  DRAGROM.CAS
 +
                                     
 +
        This should produce the file DRAGROM.DGN in the current directory.
 +
         
 +
    6)  If  you  have  a  Dragon  64 then you may optionally  also  wish  to
 +
          transfer  the 64K version of the Dragon ROM. This will  enable  you
 +
          to  use  the emulator in 64K BASIC mode. The procedure to  transfer
 +
          this  second  ROM  is much as before. Boot up your  Dragon  64  and
 +
          switch  to  64K mode by typing `EXEC 48000'. Now commit the  second
 +
          ROM to cassette by typing:
 +
         
 +
                      CSAVEM "D64ROM2", &HC000, &HFEFF, 0
 +
                                     
 +
        Transfer  this  file  to  your PC by using the  procedure  described
 +
          before  in  steps 3 to 5. This time the result should be the  file
 +
          D64ROM2.DGN.
 +
         
  
 
== File Formats ==
 
== File Formats ==

Revision as of 22:57, 23 December 2009

(Community info on how to preserve existing tape and disk software - conversion from native Dragon to PC formats - WAV, CAS, VDK, DMK, conversion between formats and restoration back to physical media)

Tools

WAV/VOC to CAS

XROAR Currently the preferred method is the XROAR emulator, this can be using to output the byte stream that its virtual ADC reads from a WAV file as the tape loads (CLOAD/CLOADM). Because this method is using an emulated ADC and the actual Dragon ROM routines to read the "tape" the success ratio for conversion is much higher.

Dragon Convert (DC.EXE) Where the input to Dragon Convert is a WAV or VOC file the audio information is scanned for Dragon cassette data and converted to a virtual cassette file. The output filename is derived from the Dragon filename rather than the input filename.

During conversion Dragon Convert displays a counter to show the progress in converting the files. If the cassette programs conform to the conventional Dragon cassette format then the filenames and load/execution addresses of binary files are listed as the programs are encountered. All of the files contained in a single input file will be placed in a single output file.

If Dragon Convert detects a loading error in the WAV or VOC file then you are given the option to abort the conversion, retry a block, or proceed with the conversion ignoring the error. If you choose to ignore errors then the converted file is unlikely to be usable, although several programs do exist which deliberately contain errors.

If you choose to retry a block then the current conversion parameters (see below) appear so that different parameters may be entered. Type the new values at the prompt or press RETURN to leave a parameter unchanged. Dragon Convert then attempts to load the block using the new parameter values. There is, of course, no advantage to be gained by retrying a block without adjusting either of the parameters.

Dragon Convert will normally assume that the sampled file begins with a leader, and will initially seek the leader to synchronise with the data. In cases where a leader is not present this may cause data to be missed. To avoid this give the /L option on the command line to disable the feature.

Although Dragon Convert is designed to work with data in the conventional Dragon cassette format it may also be used with cassettes which use a proprietary format. For such programs specify /R on the command line and Dragon Convert will scan the input as a raw bit stream. This results in a file called CASSETTE.CAS. When Dragon Convert is used with this option the display shows only the number of bytes converted and loading errors cannot be reported.

The following actions may be taken if you suffer from loading errors:

          Use  the  highest available sampling rate for your sound card.  At
          least 22KHz is required.
          
          The  amplitude  of  the  input data should  comfortably  span  the
          available range. Increase the input volume if necessary.
          
          It  is a good idea to clean up the wave form before presenting  it
          for  conversion.  Try  cutting any white space  before  the  first
          program block and omitting any noisy parts of the leaders.
          
          MS-Windows  software (Eg. Creative Wave Studio)  usually  produces
          better results than MS-DOS based software.
          
          The wavelength amplitude threshold may be specified on the command
          line using the /Wn option. For a 44KHz sample a threshold of 29 to
          31 is usually correct. For 22KHz files the value of n should be in
          the range 12 to 15.
          
          The  relative volume of the wave form may be specified  using  the
          /Sn command line option, where 0 < n < 126.
          

You can abort the operation of Dragon Convert in the middle of a conversion by pressing the CTRL key.

CAS to WAV

A secondary use of Dragon Convert (DC.EXE) is to convert cassette files back to digital audio format so that they can be written to cassette and loaded into a real machine. When converting to audio format the cassette file is not examined thereby enabling any file type or proprietary format to be converted. To use Dragon Convert for this purpose imply specify the filename of a cassette file when you start the program.

By default a 44KHz WAV file will result. This gives very high quality playback but requires more than 8Mb of hard disk space for a 32K Dragon file. You can therefore optionally specify /22 on the command line to request a 22KHz output file (or /11 for 11KHz).

If the CAS file has all its SYNC bytes (See CAS Format below) then the resultant WAV can be loaded by a real Dragon 32/64.

"Fixing old CAS files"

Some of the older CAS files with truncated SYNC bytes can be rescued using the FIXCAS.EXE tool that attempts to insert the appropriate number of missing SYNC bytes into the CAS file.


Disk to VDK

Using and old PC with a 5.25 inch drive and a DOS environment, the VCOPY.EXE tool can be used to copy some common Dragon disk formats to .VDK files.


Disk to JVC

Linux - dd


JVC to VDK

Perl Tool to add VDK header


VDK to JVC

Perl Tool to remove VDK header

VDK to Disk

Using and old PC with a 5.25 inch drive and a DOS environment, the VCOPY.EXE tool can be used to copy some common Dragon disk formats from .VDK files to disks. The disks must have been formatted in a real Dragon first....

JVC to Disk

Linux - dd

Dumping ROMS

There are several ways to transfer your ROM for use with Dragon emulators. The method suggested here is to use the Dragon Convert utility to transfer the ROM in the same way as cassettes. An alternative method would be to place the ROM in an EEPROM reader connected to a PC and dump the contents to a file.

The procedure for transfer via cassette and the Dragon Convert utility is as follows:

    1)  Boot up your Dragon 32, Dragon 64 or Tandy CoCo.
         
    2)  Ready  your  tape  recorder for recording  and  commit  the  ROM  to
         cassette by typing:
         
                     CSAVEM "DRAGROM", &H8000, &HBFFF, 0
                                      
        If  you  have a Tandy CoCo you may optionally use the name  TANDYROM
         rather than DRAGROM.
         
    3)  Boot  up  your  PC  and SoundBlaster Pro wave form editor  software.
         Sample  the cassette recorded in step 2 into a file. Alternatively,
         use  the  parallel cable and the ReadVoc utility.  A  large  output
         file should result.
         
    4)  Now use Dragon Convert to extract the cassette data. Type:
         
                                 DC  DRAGROM
                                      
        Please  don't  expect the conversion to work on the  first  attempt.
         You  are  likely to need to adjust the command line switches  until
         you  find  a combination which is suited to your hardware.  If  you
         still  have no success then you may wish to try repeating  step  3.
         Upon successful conversion the file DRAGROM.CAS will be created.
         
    5)  Now  use  Dragon  Convert again to convert the cassette  data  to  a
         cartridge file. Type:
         
                             DC  /D  DRAGROM.CAS
                                      
        This should produce the file DRAGROM.DGN in the current directory.
         
    6)  If  you  have  a  Dragon  64 then you may optionally  also  wish  to
         transfer  the 64K version of the Dragon ROM. This will  enable  you
         to  use  the emulator in 64K BASIC mode. The procedure to  transfer
         this  second  ROM  is much as before. Boot up your  Dragon  64  and
         switch  to  64K mode by typing `EXEC 48000'. Now commit the  second
         ROM to cassette by typing:
         
                     CSAVEM "D64ROM2", &HC000, &HFEFF, 0
                                      
        Transfer  this  file  to  your PC by using the  procedure  described
         before  in  steps 3 to 5. This time the result should be  the  file
         D64ROM2.DGN.
         

File Formats

CAS File Format

The CAS file format is one way of representing programs or data stored on Dragon cassette tapes. The CAS file format comes in two flavours, the most usual and default format is modelled after how the Dragon actually stores data on cassettes but with truncated leader and header bytes. The alternate format is simply the RAW byte stream and was only used for games that did not conform to the standard tape format (an early form of copy protection). The true tape format is documented in Inside the Dragon (Section 8.4.4).

The standard CAS file consists of a number of blocks. Each block contains:

  • A leader, comprising of any number of bytes with value 0x55.
  • A sync byte of value 0x3c.
  • A block type byte. Valid types are 0 for namefile block, 1 for data block and 0xff for EOF block.
  • A byte containing the data payload size (0-255).
  • 0-255 bytes of payload data.
  • A checksum byte. The checksum is the sum of the block type, the payload size and the data bytes.

For a namefile block, the payload data contains the following information:

  • An 8-byte program name.
  • A byte indicating the file type. Valid types are 0 for a BASIC program, 1 for a data file, and 2 for a machine code program.
  • A byte indicating whether the file is encoded as ASCII or binary.
  • A byte indicating whether the file is written with gaps between blocks. A value of 1 indicates that the file is written without gaps, and a value of 0xff indicates that it contains gaps between blocks.
  • Two bytes indicating the start address of a machine code program.
  • Two bytes indicating the load address of a machine code program.

The first block of a standard CAS file should be a namefile block, and the last block should normally be an EOF block. Some games used copy protection where the number of blocks to be loaded did not match the number specified in the file header and a fake EOF block was included so a simply copy of the file would result in a truncated file.

Note that standard format CAS files may omit leaders. Use the FIXCAS utility to add leaders to more closely resemble the true Dragon cassette tape format. Since the standard format CAS file is a fairly simple representation of the data stream read from a tape after demodulation and decoding of the audio signals, certain properties of cassette tapes cannot be reproduced, e.g. gaps of silence (at least one game loader uses this as a copy protection mechanism that needs the RAW format of CAS to work - although this doesn't store silence it does store noise in those gaps).

The above description makes it pretty easy to create CAS files. Reading CAS files can be a bit more difficult though. Data is actually represented as a stream of bits on cassette tapes, and the Dragon uses different audio signals to represent different bit values. When decoding such an audio signal into a bit stream and creating a CAS file, the structure described above might not align to byte boundaries in the CAS file. Especially the leader may not be decoded to an integral number of bytes. To make matters even worse, both leaders and sync bytes may contain noise and still be readable. A robust CAS file reader must take this into account.

For an example of a RAW format CAS file exhibiting both byte misalignment and leader noise, see Beyond Software's Kriegspiel (last modified 2009-01-04) in the download area.

JVC/DSK File Format

A disk format created by Jeff Vavasour for his Tandy emulator series, this is the simplest disk image format. It consists of an optional header followed by the DATA portion of each disk sector in order of track, then side, then sector number.

Taken from Tim Lindner's JVC format documentation, the header is as follows:

Byte Offset Description Default
0 Sectors per track 18
1 Side count 1
2 Sector size code 1
3 First sector ID 1
4 Sector attribute flag 0

Sector size code indicates sector is (128 << n) bytes long. The default of 1 means a sector size of 256 bytes.

The sector attribute flag indicates that each sector is preceeded by an attribute byte. This contains which bits would be set in the WD279x status field after a read sector command, and can indicate record type, record not found and CRC error.

The presence of the sector attribute flag confuses things slightly, as if it is set, suddenly the header size is the file size modulo 257 instead of modulo 256.

VDK File Format

Similar to the JVC/DSK format, this contains a header followed by a raw dump of sector data. Data is in track, then side, then sector number order.

Complete header information from the source code:

Byte Offset Description
0, 1 'd', 'k'
2, 3 Header size (little-endian)
4 Version of VDK format
5 Backwards compatibility version
6 Identity of file source
7 Version of file source
8 Number of tracks
9 Number of sides
10 Flags
11 Compression flags and name length

DMK File Format

A file format created by David Keil, carrying a lot more information about the underlying structure of the disk. Almost every piece of information that can be reported to the WD279x is recorded.

DMK Format Documentation