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 >
Wrap
Text File
|
1990-02-12
|
11KB
|
200 lines
Part II - A Practical Example of Data Portability
CROSS LINK is a short BASIC 7 program for use on the C-128 with a single
1571 drive. It allows you to read a file into a 45 k RAM buffer from any one
of the following seven disk formats:
SEQ - ASCII
SEQ - with PETSCII <> ASCII conversion
PRG - ASCII
PRG - with screen code <> ASCII conversion
C-128 CP/M single sided
C-128 CP/M double sided
IBM PC-DOS double sided, 9 sectors/track
The buffer can then be written to another disk in any of the same list of
formats or to a printer. (It should be noted that the IBM PC-DOS double
sided format is NOT the same as the "IBM-DS" which is supported by C-128 CP/M
mode. The latter format is used by CP/M-86 which is the 16 bit version of
CP/M designed to run on the IBM-PC instead of PC-DOS. PC-DOS and CP/M-86
are not compatible.) CROSS LINK is simple to use, just follow the prompts on
the screen. One word of caution, however. Because the 1571 is not a true
PC-DOS disk drive, never write PC-DOS files to an original, irreplaceable
disk. Play it safe, always use scratch disks for writing files. (Although
I have had no problems with disks from three different IBM-PCs and two PC
compatibles, the possibility does exist for mis-matched sector timing, etc.
This could hopelessly corrupt the disk being written to.)
CROSS LINK uses burst mode on the 1571 to read and write PC-DOS and CP/M
files, consequently it is quite fast. (A detailed description of 1571
burst mode and how to use it is presented in a series of articles by
this author in TPUG magazine, starting in May 1986.) A typical conversion
of a 16k (65 SEQ block) text file from SEQ PETSCII to PC-DOS takes about
65 seconds, including about 25 seconds of "overhead" required to
decode and recode the PC-DOS directory and file allocation table (FAT).
Notice that I specify the conversion of a text file. This brings up a
general caveat: program files written to run under PC-DOS (i.e. with a file
type of .EXE or .COM) will not work in C-128 mode or CP/M mode (the CP/M
executable file also has a file type of .COM, but the two are not
interchangeable) or vice versa. However, if you download a CP/M program to
a PC-DOS disk and then convert the file to CP/M format, the program will
work in CP/M mode on the C-128. This is useful, for example, if you do not
have a modem on your C-128 but have access to one on an IBM-PC where you
work. The same goes for downloading to a C-128 program to PC-DOS then
converting to a PRG ASCII file or downloading to SEQ format in C-128
mode and then converting to CP/M format. (The original CP/M system files
for the C-128 did not support a modem. The upgraded version now does.)
Text and data files, on the other hand, from one machine can usually be
used without trouble on the other. Text files transferred using screen
code PRG files may require reformatting on the target word processor.
Screen code files written by CROSS LINK may not work with all C-128
word processors. Some wp's, such as Paperback Writer 128, include a
header block at the beginning of the file. The header contains info
on the file characteristics such as margins etc. If it is not present,
the wp may not be able to read the file correctly. These wp's can
usually read SEQ files as well, however, so it is better to write
a SEQ file with CROSS LINK for use on most wp's. CROSS LINK can
read PRG text files with headers, but you must delete the header block
with the target wp.
LISTING 1 is a BASIC loader for the machine language portion of the
program. It will create a program file named "XL.ML3" which is
automatically loaded by the main program. The ML routine, which is located
in the cassette and RS 232 buffers, contains several entry points. These
are:
hex dec function
0b69 2921 burst sector read (for CP/M and PC-DOS)
0b9c 2972 read SEQ or PRG file, no convert
0bd0 3024 write SEQ, PRG file or printer, no convert
0c02 3074 burst sector write (for CP/M and PC-DOS)
0c45 3141 write SEQ or printer , convert ASCII to PETSCII
0ce0 3296 read SEQ file, convert PETSCII to ASCII
0d7d 3453 read PRG file, convert screen code to ASCII
0ddf 3551 write PRG file, convert ASCII to screen
If you are interested, you can disassemble the machine language with
the C-128's built in monitor. The burst mode read and write routines
are similar to those described in parts 2 and 3 of the TPUG series.
LISTING 2 is the main BASIC program. As you can see, there are no REM
statements. Beside the fact that I don't like REMs (they clutter up the
listing and serve no real purpose anyway), they also take up a considerable
amount of RAM. In trying to maximize the buffer space, I chose to leave
them out. For the benefit of those who are interested the following
table summarizes its main parts.
line function
10-80 opening display, default parameters, etc.
90-120 calculate CP/M sector filling table
130-150 DB=start of directory buffer,
TB=start of data buffer in bank 0 RAM
DV() and TY$() are the supported devices
and file types.
160 main menu select
170-200 read SEQ or PRG file
210-240 write SEQ or PRG file or printer
250-300 read CP/M file
310-380 write CP/M file
390 read SEQ directory
400-420 read CP/M directory
440-450 read a specific CP/M sector
460-470 write a specific CP/M sector
480-540 analyze CP/M directory and FAT
550-560 exit and error routines
570 log in current disk
580-600 read PC-DOS directory
610-620 read a specific PC-DOS sector
630-650 analyze PC-DOS FAT and directory
660-720 read PC-DOS file
730-770 write PC-DOS file
780-820 recode and write PC-DOS directory and FAT
830-840 write a specific PC-DOS sector
850 find free space on PC-DOS disk
860-870 normalize PC DOS and CP/M filenames
880 display file stats
890- enter menu options
The maximum file size that can be transferred in any directions is 45.5
k bytes. Longer files will be truncated to this length. This is
equivalent to 183 SEQ blocks or nearly 3 full CP/M directory extents.
All files in memory are assumed to be in ASCII format. SEQ files read
with the conversion option are assumed to be PETSCII on the disk and
are translated to ASCII as they are read in. SEQ files written
with the conversion option are assumed to be ASCII in memory and are
converted to PETSCII as they are written to disk. Similarly, conversions
are made when reading from or writing to PRG screen code files. All
other transfers are done in a binary what-you-see-is-what-you-get fashion.
CROSS LINK can be used for simple ASCII <> PETSCII conversion of SEQ
files with either a 1571 or 1541 (or other compatible ) drive in the
following manner:
PETSCII to ASCII - read the file in PETSCII <> ASCII conversion
mode, then write it in binary mode.
ASCII to PETSCII - read the file in binary mode, then write it in
PETSCII <> ASCII conversion mode.
One word of caution for PETSCII <> ASCII conversions. CROSS LINK passes
control codes (ASCII value less than 32) and certain other special
codes through in both directions unchanged. It also adds a linefeed
character (ASCII CHR$(10)) after each carriage return when converting
to ASCII and removes all linefeeds when converting to PETSCII. The
presence of these codes in, for example, text formatted on a CP/M
word processor may require the text to be reformatted with a C-128
word processor before it can be used in C-128 mode. In addition,
documents originally written or edited with some word processors
(such as WordStar- either CP/M or PC-DOS version) should be handled
in non-document mode (i.e. standard ASCII) on these word processors
if they are intended to be subsequently used in C-128 mode. WordStar
sets the high bits in the last character of each word in document
mode. This results in an incorrect ASCII to PETSCII conversion. The high
bit can also be stripped out using the Z option (zero the parity bit) of
CP/M's PIP command to copy the original file to an ASCII compatible file.
A similar routine can be used for converting between SEQ and PRG text
files.
When reading the directory, CROSS LINK ignores the file attribute (byte 11)
except for the volume label and subdirectory attributes which do not
represent valid files. Thus you can display and access hidden and
system files which do not show up on an IBM-PC DIR command.
CROSS LINK sets directory bytes 11-25 and 30-31 to 0 when it is writing a new
file. This is easier than trying to calculate a file creation time, date,
attribute, etc. Zero bytes in these locations are accepted by PC-DOS. For
a more detailed description of PC-DOS file formats, Part I of this article.
CROSS LINK will recover unused and scratched directory and data space for both
CP/M and PC-DOS disks. This is handled automatically by Commodore DOS when
writing to SEQ files. CROSS LINK is currently configured to work with
up to two drives and a printer. For CP/M and PC-DOS files, at least one
of the drives must be a 1571. The device configuration can be changed
by altering the definitions of arrays DV() and DV$() in line 130-150.
To use the printer for a file dump, select SEQ ASCII (for an ASCII printer)
or SEQ PETSCII as the target file type with the "SET TARGET" option
on the main menu. (There is no need to specify a filename for the
printer. A <return> at the filename prompt is sufficient.) You can then
select the printer as the target device. Of course, the 1541 or
compatible can only be used to read or write SEQ files, since it does
not support burst mode.
Although it is not an IBM-PC emulator, you will find CROSS LINK an invaluable
utility for transferring files from one machine to another (and between
modes on the C-128 also) if you use both an IBM-PC and a C-128. It is also
possible with a little detailed knowledge of the disk formats to use the
same principles for transferring files to/from other computers and
operating systems that use MFM type disks, such as TRSDOS used on the
Radio Shack computers or possibly RS CoCo OS/9 disks to PET OS/9 format.