home *** CD-ROM | disk | FTP | other *** search
/ CBM Funet Archive / cbm-funet-archive-2003.iso / cbm / c128 / diskutil / transfer / CrossLink21b.sfx / xlink.doc < prev    next >
Text File  |  1990-02-12  |  11KB  |  200 lines

  1.  
  2. Part II - A Practical Example of Data Portability
  3.  
  4.  
  5.  
  6. CROSS LINK is a short BASIC 7 program for use on the C-128 with a single
  7. 1571 drive.  It allows you to read a file into a 45 k RAM buffer from any one
  8. of the following seven disk formats:
  9.   
  10.     SEQ - ASCII
  11.     SEQ - with PETSCII <> ASCII conversion
  12.     PRG - ASCII
  13.     PRG - with screen code <> ASCII conversion
  14.     C-128 CP/M single sided
  15.     C-128 CP/M double sided
  16.     IBM PC-DOS double sided, 9 sectors/track
  17.  
  18. The buffer can then be written to another disk in any of the same list of
  19. formats or to a printer.  (It should be noted that the IBM PC-DOS double
  20. sided format is NOT the same as the "IBM-DS" which is supported by C-128 CP/M
  21. mode.  The latter format is used by CP/M-86 which is the 16 bit version of
  22. CP/M designed to run on the IBM-PC instead of PC-DOS.  PC-DOS and CP/M-86
  23. are not compatible.)  CROSS LINK is simple to use, just follow the prompts on
  24. the screen.  One word of caution, however.  Because the 1571 is not a true
  25. PC-DOS disk drive, never write PC-DOS files to an original, irreplaceable
  26. disk.  Play it safe, always use scratch disks for writing files.  (Although
  27. I have had no problems with disks from three different IBM-PCs and two PC
  28. compatibles, the possibility does exist for mis-matched sector timing, etc.
  29. This could hopelessly corrupt the disk being written to.)
  30.  
  31. CROSS LINK uses burst mode on the 1571 to read and write PC-DOS and CP/M
  32. files, consequently it is quite fast.  (A detailed description of 1571
  33. burst mode and how to use it is presented in a series of articles by
  34. this author in TPUG magazine, starting in May 1986.)  A typical conversion
  35. of a 16k (65 SEQ block) text file from SEQ PETSCII to PC-DOS takes about
  36. 65 seconds, including about 25 seconds of "overhead" required to
  37. decode and recode the PC-DOS directory and file allocation table (FAT).
  38. Notice that I specify the conversion of a text file.  This brings up a
  39. general caveat: program files written to run under PC-DOS (i.e. with a file
  40. type of .EXE or .COM) will not work in C-128 mode or CP/M mode (the CP/M
  41. executable file also has a file type of .COM, but the two are not
  42. interchangeable) or vice versa.  However, if you download a CP/M program to
  43. a PC-DOS disk and then convert the file to CP/M format, the program will
  44. work in CP/M mode on the C-128.  This is useful, for example, if you do not
  45. have a modem on your C-128 but have access to one on an IBM-PC where you
  46. work.  The same goes for downloading to a C-128 program to PC-DOS then
  47. converting to a PRG ASCII file or downloading to SEQ format in C-128
  48. mode and then converting to CP/M format.  (The original CP/M system files
  49. for the C-128 did not support a modem.  The upgraded version now does.)
  50. Text and data files, on the other hand, from one machine can usually be
  51. used without trouble on the other.  Text files transferred using screen
  52. code PRG files may require reformatting on the target word processor.
  53. Screen code files written by CROSS LINK may not work with all C-128
  54. word processors.  Some wp's, such as Paperback Writer 128, include a
  55. header block at the beginning of the file.  The header contains info
  56. on the file characteristics such as margins etc.  If it is not present,
  57. the wp may not be able to read the file correctly.  These wp's can
  58. usually read SEQ files as well, however, so it is better to write
  59. a SEQ file with CROSS LINK for use on most wp's.  CROSS LINK can
  60. read PRG text files with headers, but you must delete the header block
  61. with the target wp.
  62.  
  63.  
  64. LISTING 1 is a BASIC loader for the machine language portion of the
  65. program.  It will create a program file named "XL.ML3" which is
  66. automatically loaded by the main program.  The ML routine, which is located
  67. in the cassette and RS 232 buffers, contains several entry points.  These
  68. are:
  69.  
  70.     hex     dec               function
  71.  
  72.    0b69    2921              burst sector read (for CP/M and PC-DOS)
  73.    0b9c    2972              read SEQ or PRG file, no convert
  74.    0bd0    3024              write SEQ, PRG file or printer, no convert
  75.    0c02    3074              burst sector write (for CP/M and PC-DOS)
  76.    0c45    3141              write SEQ or printer , convert ASCII to PETSCII
  77.    0ce0    3296              read SEQ file, convert PETSCII to ASCII
  78.    0d7d    3453              read PRG file, convert screen code to ASCII
  79.    0ddf    3551              write PRG file, convert ASCII to screen
  80.  
  81. If you are interested, you can disassemble the machine language with
  82. the C-128's built in monitor.  The burst mode read and write routines
  83. are similar to those described in parts 2 and 3 of the TPUG series.
  84.  
  85.  
  86. LISTING 2 is the main BASIC program.  As you can see, there are no REM
  87. statements.  Beside the fact that I don't like REMs (they clutter up the
  88. listing and serve no real purpose anyway), they also take up a considerable
  89. amount of RAM.  In trying to maximize the buffer space, I chose to leave
  90. them out.  For the benefit of those who are interested the following
  91. table summarizes its main parts.
  92.  
  93.  
  94.      line                 function
  95.  
  96.      10-80           opening display, default parameters, etc.
  97.      90-120          calculate CP/M sector filling table
  98.      130-150         DB=start of directory buffer,
  99.                      TB=start of data buffer in bank 0 RAM
  100.                      DV() and TY$() are the supported devices
  101.                      and file types.
  102.      160             main menu select
  103.      170-200         read SEQ or PRG file
  104.      210-240         write SEQ or PRG file or printer
  105.      250-300         read CP/M file
  106.      310-380         write CP/M file
  107.      390             read SEQ directory
  108.      400-420         read CP/M directory
  109.      440-450         read a specific CP/M sector
  110.      460-470         write a specific CP/M sector
  111.      480-540         analyze CP/M directory and FAT
  112.      550-560         exit and error routines
  113.      570             log in current disk
  114.      580-600         read PC-DOS directory
  115.      610-620         read a specific PC-DOS sector
  116.      630-650         analyze PC-DOS FAT and directory
  117.      660-720         read PC-DOS file
  118.      730-770         write PC-DOS file
  119.      780-820         recode and write PC-DOS directory and FAT
  120.      830-840         write a specific PC-DOS sector
  121.      850             find free space on PC-DOS disk
  122.      860-870         normalize PC DOS and CP/M filenames
  123.      880             display file stats
  124.      890-            enter menu options
  125.  
  126.  
  127.  
  128. The maximum file size that can be transferred in any directions is 45.5
  129. k bytes.  Longer files will be truncated to this length.  This is
  130. equivalent to 183 SEQ blocks or nearly 3 full CP/M directory extents.
  131. All files in memory are assumed to be in ASCII format.  SEQ files read
  132. with the conversion option are assumed to be PETSCII on the disk and
  133. are translated to ASCII as they are read in.  SEQ files written
  134. with the conversion option are assumed to be ASCII in memory and are
  135. converted to PETSCII as they are written to disk.  Similarly, conversions
  136. are made when reading from or writing to PRG screen code files.  All
  137. other transfers are done in a binary what-you-see-is-what-you-get fashion.
  138.  
  139. CROSS LINK can be used for simple ASCII <> PETSCII conversion of SEQ
  140. files with either a 1571 or 1541 (or other compatible ) drive in the
  141. following manner:
  142.  
  143.      PETSCII to ASCII - read the file in PETSCII <> ASCII conversion
  144.                         mode, then write it in binary mode.
  145.  
  146.      ASCII to PETSCII - read the file in binary mode, then write it in
  147.                         PETSCII <> ASCII conversion mode.
  148.  
  149. One word of caution for PETSCII <> ASCII conversions.  CROSS LINK passes
  150. control codes (ASCII value less than 32) and certain other special
  151. codes through in both directions unchanged.  It also adds a linefeed
  152. character (ASCII CHR$(10)) after each carriage return when converting
  153. to ASCII and removes all linefeeds when converting to PETSCII.  The
  154. presence of these codes in, for example, text formatted on a CP/M
  155. word processor may require the text to be reformatted with a C-128
  156. word processor before it can be used in C-128 mode.  In addition,
  157. documents originally written or edited with some word processors
  158. (such as WordStar- either CP/M or PC-DOS version) should be handled
  159. in non-document mode (i.e. standard ASCII) on these word processors
  160. if they are intended to be subsequently used in C-128 mode.  WordStar
  161. sets the high bits in the last character of each word in document
  162. mode.  This results in an incorrect ASCII to PETSCII conversion.  The high
  163. bit can also be stripped out using the Z option (zero the parity bit) of
  164. CP/M's PIP command to copy the original file to an ASCII compatible file.
  165. A similar routine can be used for converting between SEQ and PRG text
  166. files.
  167.  
  168. When reading the directory, CROSS LINK ignores the file attribute (byte 11)
  169. except for the volume label and subdirectory attributes which do not
  170. represent valid files.  Thus you can display and access hidden and
  171. system files which do not show up on an IBM-PC DIR command.
  172. CROSS LINK sets directory bytes 11-25 and 30-31 to 0 when it is writing a new
  173. file.  This is easier than trying to calculate a file creation time, date,
  174. attribute, etc.  Zero bytes in these locations are accepted by PC-DOS.  For
  175. a more detailed description of PC-DOS file formats, Part I of this article.
  176.  
  177.  
  178. CROSS LINK will recover unused and scratched directory and data space for both
  179. CP/M and PC-DOS disks.  This is handled automatically by Commodore DOS when
  180. writing to SEQ files.  CROSS LINK is currently configured to work with
  181. up to two drives and a printer.  For CP/M and PC-DOS files, at least one
  182. of the drives must be a 1571.  The device configuration can be changed
  183. by altering the definitions of arrays DV() and DV$() in line 130-150.
  184. To use the printer for a file dump, select SEQ ASCII (for an ASCII printer)
  185. or SEQ PETSCII as the target file type with the "SET TARGET" option
  186. on the main menu.  (There is no need to specify a filename for the
  187. printer. A <return> at the filename prompt is sufficient.) You can then 
  188. select the printer as the target device.   Of course, the 1541 or
  189. compatible can only be used to read or write SEQ files, since it does
  190. not support burst mode.
  191.  
  192. Although it is not an IBM-PC emulator, you will find CROSS LINK an invaluable
  193. utility for transferring files from one machine to another (and between
  194. modes on the C-128 also) if you use both an IBM-PC and a C-128.  It is also
  195. possible with a little detailed knowledge of the disk formats to use the
  196. same principles for transferring files to/from other computers and
  197. operating systems that use MFM type disks, such as TRSDOS used on the
  198. Radio Shack computers or possibly RS CoCo OS/9 disks to PET OS/9 format.
  199.  
  200.