Skip to content

Latest commit

 

History

History
129 lines (127 loc) · 5.51 KB

File metadata and controls

129 lines (127 loc) · 5.51 KB

CAS IN OPEN (Main Jumpblock)

Index: 125

Address: #BC77

CAS IN OPEN (TAPE)

Open a file for input.

Action:

Set up the read stream for reading a file and read the first block.

Entry conditions:

B contains the length of the filename.
HL contains the address of the filename.
DE contains the address of a 2K buffer to use.

Exit conditions:

If the file was opened OK:
Carry true.
Zero false.
HL contains the address of a buffer containing the file header.
DE contains the data location (from the header).
BC contains the logical file length (from the header).
A contains the file type (from the header).

If the stream is in use:
Carry false.
Zero false.
In V1.1: A contains an error number (#0E).
In V1.0: A corrupt.
BC, DE and HL corrupt.

If the user hit escape:
Carry false.
Zero true.
In V1.1: A contains an error number (#00).
In V1.0: A corrupt BC, DE and HL corrupt.

Always:
IX and other flags corrupt.
All other registers preserved

Notes:

This routine can return two error numbers:

  • #00: The user hit escape.
  • #0E: The stream is already in use.

The 2K buffer (2048 bytes) supplied is used to store the contents of a block of the file when it is read from tape. It will remain in use until the file is closed by calling either CAS IN CLOSE or CAS IN ABANDON. The buffer may lie anywhere in memory, even underneath a ROM.

The filename passed is copied into the read stream descriptor. If it is longer than i6 characters then it is truncated to 16 characters. If it is shorter than 16 characters then it is padded with nulls (#00) to 16 characters. While the filename may contain any character, it is best to avoid nulls. Lower case ASCII letters (characters #61..#7A) are converted to their upper case equivalents (characters #41.. #5A). The filename may lie anywhere in RAM, even underneath a ROM.

The filename is normally the name of the file that is to be read. However, a zero length filename (or one starting with a null) is treated specially. It is taken to mean read the next file on the tape.

When the file is opened for reading the first block of the file is read immediately. The address of the area where the header from this block is stored is passed back to the user so that information can be extracted from it. This area will lie in the central 32K of RAM. The user is not allowed to write to the header, only to read from it. The Cassette Manager uses some fields in the header for its own purposes and so these may differ from those read from the tape. The file type, logical length, entry point and all user fields will remain unchanged. (See The Cassette Manager for a description of the header.)

Related entries:

CAS IN ABANDON
CAS IN CHAR
CAS IN CLOSE
CAS IN DIRECT
CAS IN OPEN (DISC)
CAS OUT OPEN

CAS IN OPEN (DISC)

Open a file for input.

Action:

Set up the read stream for reading a file and read the header if there is one, otherwise create a fake header in store.

Entry conditions:

B contains the length of the filename.
HL contains the address of the filename.
DE contains the address of a 2K buffer to use.

Exit conditions:

If the file was opened OK:
Carry true.
Zero false.
HL contains the address of a buffer containing the file header.
DE contains the data location (from the header).
BC contains the logical file length (from the header).
A contains the file type from the header).

If the stream is already open:
Carry false.
Zero false.
A contains an error number (#0E).
BC, DE and HL corrupt.

If the open failed for any other reason:
Carry false.
Zero true.
A contains an error number.
BC, DE and HL corrupt.

Always:
IX and other flags corrupt. All other registers preserved.

Notes:

The 2K buffer (2048 bytes) supplied is used to store the contents of the file when it is read from disc. It will remain in use until the file is closed by calling either CAS IN CLOSE or CAS IN ABANDON. The buffer may lie anywhere in memory, even underneath a ROM.

The filename must conform to the AMSDOS conventions with no wild cards.

The filename may lie anywhere in RAM, even underneath a ROM.

If the type part of the filename is omitted AMSDOS will attempt to open, in turn, a file with the following type parts '.', '.BAS', '.BIN', If none of these exist then the open will fail.

When the file is opened the first record of the file is read immediately. If this record contains a header then it is copied into store, otherwise a fake header is constructed in store. The address of the area where the header is stored is passed back to the user so that information can be extracted from it, This area will lie in the central 32K of RAM. The user is not allowed to write to the header, only to read from it. AMSDOS uses some fields in the header for its own purposes and so these may differ from those read from the disc. The file type, logical length, entry point and all user fields will remain unchanged.

Related entries:

CAS IN ABANDON (DISC)
CAS IN CHAR (DISC)
CAS IN CLOSE (DISC)
CAS IN DIRECT (DISC)
CAS IN OPEN (TAPE)
CAS OUT OPEN (DISC)