Post by jmpff3d on Nov 25, 2018 23:49:01 GMT
Three versions of XLINK.v2.1 exist, The 2.1 (original), v2.1a (modified by K. Woodall), v2.1b (corrected by G. Schwarz). They are now available in a standalone package, along with other (even more useful) software at csdb.dk/release/?id=171968&show=summary#summary
CROSS LINK 2.1 - for IBM-PC <> C-128 file transfers
<c> by M. Garamszeghy 86-04-15
(rev 1: 86-06-01)
67 Callender Street
Toronto Ontario
CANADA M6R 2H2
****PLEASE NOTE****
Permission is hereby granted to reproduce this program and documentation file for personal use only. This material is NOT FOR SALE under any circumstances!! I encourage copying and distribution, subject to the above restrictions. Please address all comments, suggestions, etc to me at the above address or at the TPUG BBS (416) 273-6300 [Punternet Node 2]
CROSS LINK is a short BASIC 7 program for use on the C-128 with a 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. BASIC program listings created on one machine can often be used on another with only minor editing. C-128 BASIC 7.0, CP/M MBASIC and IBM-PC BASIC, as well as most other types of BASIC, are all versions of Microsoft BASIC, thus the commands and syntax are very similar. To transfer the listings from one machine to another, the program must be first saved as an ASCII text file on the original machine. (The tokenized programs for the various BASICs are not compatible in both format and keyword tokens.) In IBM and CP/M BASIC, this is done
by appending an ",A" to the end of the SAVE statement:
SAVE "filename",A
In C-128 BASIC 7.0, it is done using the following sequence of steps in direct mode:
OPEN 8,8,8,"0:filename,s,w"
CMD8:LIST
PRINT#8:CLOSE8
This file should be read in by CROSS LINK as a SEQ-PETSCII file. Non standard character codes embedded in program text (such as color codes, reverse video and cursor controls) should be edited out, either before or after conversion, because they may cause IBM and CP/M BASIC to behave in odd manners. To load an ASCII file with IBM or CP/M BASIC, the normal LOAD"filename" command is used. A SEQ text file can also be loaded as a program on the C-128. This is done in the following manner (many thanks to colleague Jim Butterfield for demonstrating this trick to me):
DOPEN #1,"filename"
SYS 65478,0,1
DCLOSE
(Incidentally, this is no magical ROM routine, but the normal KERNAL CHKIN function at hex $FFC6 which has been enhanced on the 128.) The file to be read in should be saved as a SEQ-ASCII file with CROSS link. This routine reads in the text file listing and converts it to a program, just as if you had entered each line directly from the keyboard. Because of this, it will not erase the program currently in memory. The new program will be merged with any that is currently in memory. It can therefore also be used to merge two or more C-128 programs. You may get a "syntax error" or "out of data" message after the program listing has been read in. This is caused by any extraneous text which may be included at the end of the listing file. Normally, however, it has no effect on the loading of the program. The format of the BASIC listing is important for files to be used with IBM or CP/M BASIC. C-128 BASIC 7.0 does not require spaces between keywords and arguments, while both IBM and CP/M BASIC do. For example, the statement:
10 FORI=1TO10
is legitimate in BASIC 7.0. For IBM and CP/M BASIC it must be changed to:
10 FOR I=1 TO 10
It is also important to remember that the number of significant characters in BASIC 7.0 variable names is limited to 2, while both IBM and CP/M BASIC have no such restriction. VARIABLE1 and VALUE2 are distinct variable names in IBM and CP/M BASIC, while in BASIC 7.0, they are both equivalent to "VA".
The machine language portion of the program is a 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.
As you can see, there are no REM statements in the main BASIC program. 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 or PRG directory
400-420 read CP/M directory
430 wait till next key press
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 read a specific PC-DOS sector
620-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 write a specific PC-DOS sector
840 find free space on PC-DOS disk
850-860 normalize PC DOS and CP/M filenames
870 display file stats
880- 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 linefeedcharacter (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 PC-DOS 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, see 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 or PRG 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 or PRG 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.
m.g.