The Cassette/AMSDOS manager


NOTE: Some of these routines are only applicable to the cassette manager; where a disc version exists it is indicated by an asterisk (*) next to the command name. These disc version jumpblocks are automatically installed by the Operating System on switch on.


&BC65CAS INITIALISE
ActionInitialises the cassette manager
EntryNo entry conditions
ExitAF, BC, DE and HL are corrupt, and all the other registers are preserved
NotesBoth read and write streams are closed; tape messages are switched on; the default speed is reselected
&BC68CAS SET SPEED
ActionSets the speed at which the cassette manager saves programs
EntryHL holds the length of `half a zero' bit, and A contains the amount of precompensation
ExitAF and HL are corrupt
NotesThe value in HL is the length of time that half a zero bit is written as; a one bit is twice the length of a zero bit; the default values (ie SPEED WRITE 0) are 333 microseconds (HL) and 25 microseconds (A) for SPEED WRITE 1, the values are given as 107 microseconds and 50 microseconds respectiveIy
&BC6BCAS NOISY
ActionEnables or disables the display of cassette handling messages
EntryTo enable the messages then A must be 0, otherwise the messages are disabled
ExitAF is corrupt, and all other registers are preserved
&BC6ECAS START MOTOR
ActionSwitches on the tape motor
EntryNo entry conditions
ExitIf the motor operates properly then Carry is true; if ESC was pressed then Carry is false; in either case, A contains the motor's previous state, tbe flags are corrupt, and all others are preserved
&BC71CAS STOP MOTOR
ActionSwitches off the tape motor
EntryNo entry conditions
ExitIf the motor turns off then Carry is true; if ESC was pressed then Carry is false; in both cases, A holds tbe motor's previous state, the other flags are corrupt, all others are preserved
&BC74CAS RESTORE MOTOR
ActionResets the tape motor to its previous state
EntryA contains the previous state of the motor (eg from CAS START MOTOR or CAS STOP MOTOR)
ExitIf the motor operates properly then Carry is true; if ESC was pressed then Carry is false; in all cases, A and the other flags are corrupt and all others are preserved
&BC77*CAS IN OPEN
ActionOpens an input buffer and reads the first block of the file
EntryB contains the length of the filename, HL contains the filename's address, and DE contains the address of the 2K buffer to use for reading the file
ExitIf the file was opened successfully, then Carry is true, Zero is false, HL holds the address of a buffer contauling the file header data, DE holds the address of the destination for the file, BC holds the file length, and A holds the file type; if the read stream is already open then Carry and Zero are false, A contains an error nurnber (664/6128 only) and BC, DE and HL are corrupt; if ESC was pressed by the user, then Carry is false, Zero is true, A holds an error number (664/6128 only) and BC, DE and HL are corrupt; in all cases, IX and the other flags are corrupt, and the others are preserved
NotesA filename of zero length means `read the neXt file on the tape'; the stream remains open until it is closed by either CAS IN CLOSE or CAS IN ABANDON
DiscSimilar to tape except that if there is no header on the file, then a fake header is put into memory by this routine
&BC7A*CAS IN CLOSE
ActionCloses an input file
EntryNo entry conditions
ExitIf the file was closed successfully, then Carry is true and A is corrupt; if the read stream was not open, then Carry is false, and A holds an error code (664/6128 only); in both cases, BC, DE, HL and the other flags are all corrupt
DiscAll the above applies, but also if the file failed to close for any other reason, then Carry is false, Zero is true and A contains an error number; in all cases the drive motor is turned off immediately
&BC7D*CAS IN ABANDON
ActionAbandons an input file
EntryNo entry conditions
ExitAF, BC, DE and HL are corrupt, and all others are preserved
DiscAll the above applies for the disc routine
&BC80*CAS IN CHAR
ActionReads in a single byte from a file
EntryNo entry conditions
ExitIf a byte was read, then Carry is true, Zero is false, and A contains the byte read from the file; if the end of file was reached, then Carry and Zero are false, A contains an error number (664/6128 only) or is corrupt (for the 464); if ESC was pressed, then Carry is false, Zero is true, and A holds an error number (664/6128 only) or is corrupt (for the 464); in all cases, IX and the other flags are corrupt, and all others are preserved
DiscAll the above applies for the disc routine
&BC83*CAS IN DIRECT
ActionReads an entire file directly into memory
EntryHL contains the address where the file is to be placed in RAM
ExitIf the operation was successful, then Carry is true, Zero is false, HL contains the entry address and A is corrupt; if it was not open, then Carry and Zero are both false, HL is corrupt, and A holds an error code (664/6128) or is corrupt (464); if ESC was pressed, Carry is false, Zero is true, HL is corrupt, and A holds an error code (664/6128 only); in all cases, BC, DE and IX and the other flags are corrupt, and the others are preserved
NotesThis routine cannot be used once CAS IN CHAR has been used
DiscAll the above applies to the disc routine
&BC86*CAS RETURN
ActionPuts the last byte read back into the input buffer so that it can be read again at a later time
EntryNo entry conditions
ExitAll registers are preserved
NotesThe routine can only return the last byte read and at least one byte must have been read
DiscAll the above applies to the disc routine
&BC89*CAS TEST EOF
ActionTests whether the end of file has been encountered
EntryNo entry conditions
ExitIf the end of file has been reached, then Carry and Zero are false, and A is corrupt; if the end of file has not been encountered, then Carry is true, Zero is false, and A is corrupt; if ESC was pressed then Carry is false, Zero is true and A contains an error number (664/6128 only); in all cases, IX and the other flags are corrupt, and all others are preserved
DiscAll the above applies to the disc routine
&BC8C*CAS OUT OPEN
ActionOpens an output file
EntryB contains the length of the filename, HL contains the address of the filename, and DE holds the address of the 2K buffer to be used
ExitIf the file was opened correctly, then Carry is true, Zero is false, HL holds the address of the buffer containing the file header data that will be written to each block, and A is corrupt; if the write stream is already open, then Carry and Zero are false, A holds an error nurnber (66~/6128) and HL is corrupt; if ESC was pressed then Carry is false, Zero is true, A holds an error number (664/6128) and HL is corrupt; in all cases, BC, DE, IX and the other flags are corrupt, and the others are preserved
NotesThe buffer is used to store the contents of a file block before it is actually written to tape
DiscThe same as for tape except that the filename must be present in its usual AMSDOS format
&BC8F*CAS OUT CLOSE
ActionCloses an output file
EntryNo entry conditions
ExitIf the file was closed successfully, then Carry is true, Zero is false, and A is corrupt; if the write stream was not open, then Carry and Zero are false and A holds an error code (664/6128 only); if ESC was pressed then Carry is false, Zero is true, and A contains an error code (664/6128 only); in all cases, BC, DE, HL, IX and the other flags are all corrupt
NotesThe last block of a file is written only when this routine is called; if writing the file is to be abandoned, then CAS OUT ABANDON should be used instead
DiscAll the above applies to the disc routine
&BC92*CAS OUT ABANDON
ActionAbandons an output file
EntryNo entry conditions
ExitAF, BC, DE and HL are corrupt, and all others are preserved
NotesWhen using this routine, the current last block of the file is not written to the tape
DiscSimilar to the tape routine; if more than 16K of a file has been written to the disc, then the first 16K of the file will exist on the disc with a file extension of .$$$ because each 16K section of the file requires a separate directory entry
&BC95*CAS OUT CHAR
ActionWrites a single byte to a file
EntryA contains the byte to be written to the file output buffer
ExitIf a byte was written to the buffer, then Carry is true, Zero is false, and A is corrupt; if the file was not open, then Carry and Zero are false, and A contains an error number (664/6128 only) or is corrupt (on the 464); if ESC was pressed, then Carry is false, Zero is true, and A contains an error number (664/6128 only) or it is corrupt (on the 464); in all cases, IX and the other flags are corrupt, and all others are preserved
NotesIf the 2K buffer is full of data then it is written to the tape before the new character is placed in the buffer; it is important to call CAS OUT CLOSE when all the data has been sent to the file so that the last block is written to the tape
DiscAll the above applies to the disc routine
&BC98*CAS OUT DIRECT
ActionWrites an entire file directly to tape
EntryHL contains the address of the data which is to be written to tape, DE contains the length of this data, BC contains the e~ecution address, and A contains the file type
ExitIf the operation was successful, then Carry is true, Zero is false, and A is corrupt; if the file was not open, Carry and Zero are false, A holds an error number (664/6128) or is corrupt (464); if ESC was pressed, then Carry is false, Zero is true, and A holds an error code (664/6128 only); in all cases BC, DE, HL, IX and the other flags are corrupt, and the others are preserved
NotesThis routine cannot be used once CAS OUT CHAR has been used
DiscAll the above applies to the disc routine
&BC9B*CAS CATALOG
ActionCreates a catalogue of all the files on the tape
EntryDE contains the address of the 2K buffer to be used to store the information
ExitIf the operation was successful, then Carry is true, Zero is false, and A is corrupt; if the read stream is already being used, then Carry and Zero are false, and A holds an error code (664/6128 or is corrupt (for the 464); in all cases, BC, DE, HL, IX and the other flags are corrupt and all others are preserved
NotesThis routine is only left when the ESC key is pressed (cassette only) and is identical to BASIC's CAT command
DiscAll tbe above applies, except that a sorted list of files is displayed; system files are not listed by this routine
&BC9ECAS WRITE
ActionWrites data to the tape in one long file (ie not in 2K blocks)
EntryHL contains the address of the data to be written to tape, DE contains the length of the data to be written, and A contains the sync character
ExitIf the operation was successful, then Carry is true and A is corrupt; if an error occurred then Carry is false and A contains an error code; in both cases, BC, DE, HL and lX are corrupt, and all other registers are preserved
NotesFor header records the sync character is &2C, and for data it is &16; this routine starts and stops the cassette motor and also tums off interrupts whilst writing data
&BCA1CAS READ
ActionReads data from the tape in one long file (ie as originally written by CAS WRITE only)
EntryHL holds the address to place the file, DE holds the length of the data, and A holds the expected sync character
ExitIf the operation was successful, then Carry is true and A is corrupt; if an error occurred then Carry is false and A contains an error code; in both cases, BC, DE, HL and IX are corrupt, and all other registers are preserved
NotesFor header records the sync character is &2C, and for data it is &16; this routine starts and stops the cassette motor and turns off interrupts whilst reading data
&BCA4CAS CHECK
ActionCompares the contents of memory with a file record (ie header or data) on tape
EntryHL contains the address of the data to check, DE contains the length of the data and A holds the sync character that was used when the file was originally written to the tape
ExitIf the two are identical, then Carry is true and A is corrupt; if an error occurred then Carry is false and A holds an error code; in all cases, BC, DE, HL, IX and other flags are corrupt, and all other registers are preserved
NotesFor header records the sync character is &2C, and for data it is &16; this routine starts and stops the cassette motor and turns off interrupts whilst reading data; does not have to read the whole of a record, but must start at the beginning


David Cantrell, March 1996