Disk management commandsBACKUP n TO mCopy all files from one disk to anotherBACKUP nBACKUP a disk using only a single disk driveCOPY file1 TO file2Make a duplicate of a fileDIR nList the files that are on the diskDRIVE nUse drive n as the defaultDSKINInInitialize (format) a diskKILL fileDelete a file from the diskLOAD fileLoad a programLOAD file,RLoad a program and start it runningLOADM file,offsetLoad a machine-code program, shifting by offsetMERGE fileLoad an ASCII program without clearing the old oneMERGE file,RMerge a program and start it runningRENAME file1 TO file2Change the name of a fileRUN fileLoad a program and start it runningRUN file,RLoad and run program, leaving files openSAVE fileSave a programSAVE file,ASave a program in ASCII formatSAVEM file,a1,a2,axSave a machine-code program, from a1 to a2, exec at axVERIFY ONDouble-check all writes to the diskVERIFY OFFDon't double-checkProgramming commands FILES max_f,sizeReserve buffers for open filesFREE(n)Returns the number of free granules (2304 bytes each)UNLOAD nClose all open files on drive nDSKI$ n,t,s,v1$,v2$Read track t sector s into v1$ and v2$DSKO$ n,t,s,v1$,v2$Write track t sector s from v1$ and v2$OPEN "I",f,fileOpen a file for sequential input (ie:INPUT)OPEN "O",f,fileOpen a file for sequential output (ie:WRITE)OPEN "D",f,file,lenOpen a file for direct access; (ie:GET/PUT); record length len is optionalCLOSE #fClose a fileSequential file commands EOF(f)Returns true if file f has been read to the endINPUT #f, var,...Read variables from a fileLINE INPUT #f,var$Read an entire line from a file into a string variableWRITE #f,valuesWrite values to file, with commas, strings in quotes,...PRINT #f,valuesWrite values to file, just asPRINT #f,USING f$;valuesFormatted printing; many options for f$ Direct-access file commandsFIELD #f, size AS v$,...Give variable names to parts of the file bufferRSET v$ = value$Fill in a named part of the file buffer, right-justifiedLSET v$ = value$Fill in ..., left justifiedPUT #f,rWrite the buffer to record rGET #f,rRead record r into the bufferCVN(var$)Make a number out of a binary stringMKN$(num)Make a binary string out of a numberLOC(f)Return the current record number in the bufferLOF(f)Return the highest record number in the file In all cases, f is a file number, n and m are drive numbers, file is a filename, and dollar signs signify variables that must be string-variables. Note that filenames must be either string variables or string constants in quotes. Upper-case words are keywords, lower-case words are supplied by the user.Special file numbers are -2=printer -1=cassette and 0=screen
Syntax for a filename, in BNF. (Things in square brackets are optional, the vertical bar separates alternatives, angle brackets surround nonterminals, and uppercase words denote single-letter constants.)
<filename> ::= <name> [(DOT|SLASH) <extension>] [COLON <drivenum>]The name can be up to eight characters long, and cannot include a dot, slash, colon, or zero. The extension can be up to three characters long, and also cannot include those four characters. The drive number is a single digit, from zero up to the highest drive on your system.
Examples of legal filenames:
PROGRAM.BAS -- filename=PROGRAM, extension=BAS, no drivenum PROGRAM/BAS -- filename=PROGRAM, extension=BAS, no drivenum FOO.BAR:0 -- filename=FOO, extension=BAR, drivenum=0 FOO:1 -- filename=FOO, no extension, drivenum=1 FRED -- filename=FRED no extension, no drivenum
There is one documented subroutine in the Disk BASIC ROM that you can use to access the disk. Its address is stored at $C004 and $C005, so you jump to it using indirection: JSR [$C004] .Before calling that, you should load the X register with the address of a data structure that describes what you want to do. The examples in the manual always load this address from locations $C006 and $C007. I have not tried using this, so I don't know it will work if you put your structure anyplace else. This data structure is seven bytes long:
1 byte op code (0 - 3) 1 byte drive number (0 - 3) 1 byte track number (0 - 34) 1 byte sector number (1 - 18) 2 bytes address of 128-byte data buffer 1 byte error codeOp codes are either 0 (restore to track 0), 1 (no op), 2 (read sector), or 3 (write sector).Bits in the error code seem to come straight from the chip in the disk controller. See that for more details.
The disk control routine modifies the contents of only the condition code register.
Back to my top-level CoCo page
16-Jun-99
yakowenk@csx.unxc.edu (remove all "x"s to get a valid address)