High level file routines
------------------------------------------------------------------
1-401
Function Name: FindFTypes
Purpose: Create a list of filenames.
Call address: $C23B
Input requirements:
$0E-$0F R6 Pointer to buffer area for file names.
$10 R7L GEOS file type.
$11 R7H Maximum number of file names.
$16-$17 R10 Pointer to class.
Output:
$11 R7H Number of files not found.
The table is filled with filenames.
Errors: See Appendix I.
Description: This is a very useful routine. Given a GEOS file
type, a list of files with that type is created. If the class
pointer is non-zero then each file's info sector is checked for
proper class. This is how GEOpaint and GEOwrite can both create
Application Data files and not see each others files. The
filenames are text strings with zero byte terminators. Each entry
is indexed with a multiple of 17 (16 byte filename max. plus zero
byte). Location $11 R7H has the number of table entries unfilled.
To get the number of files actually found, this value must be
subtracted from the original maximum buffer length.
1-402
Function Name: FindFile
Procedure: Lookup a filename in the directory.
Call address: $C20B
Input requirements:
$0E-$0F R6 Pointer to filename.
$886E Flag byte.
Output:
$04 R1L Track for directory sector.
$05 R1H Sector for directory sector.
$0C-$0D R5 Pointer to file name entry.
$8000-$80FF diskBlkBuf: Directory sector.
$8400-$841D dirEntryBuf: Copy of directory entry.
Errors: See Appendix
Description: This is a very useful routine. Given a text string
of a filename, this routine will find it in the directory. If the
flag byte at $886E is $FF, then both drives 8 and 9 will be
scanned if necessary. If the flag is $00, then the lookup is only
to the current drive. If there is only one drive, then this flag
has no effect. The directory sector is loaded into a buffer at
$8000, and the track and sector are in locations $04 and $05. The
particular directory entry is copied to $8400 and the pointer to
the entry in the buffer is stored at $0C-$0D R5.
1-403
Function Name: SaveFile
Purpose: Save memory to a file.
Call address: $C1ED
Input requirements:
$14-$15 R9 Pointer to information sector data.
$16 R10L # directory sectors to skip first.
Errors: See Appendix
Description: This routine will save memory to a file; each sector
is verified after the write is finished. The info sector has all
the necessary information. i.e. start and stop addresses, file
type and structure. It must also contain the address of the
filename string somewhere in memory, in the first two bytes. If
the file is a VLIR file, the memory is saved to chain 0. Location
$16 R10L specifies the number of directory sectors to skip for
SetGDirEntry and GetFreeDirBlk.
1-404
Function Name: WriteFile
Purpose: Save memory to specified sectors on the disk.
Call address: $C1F9
Input requirements:
$0E-$0F R6 Pointer to list of tracks and sectors to use.
$10-$11 R7 Start address of memory to be saved.
Preparatory routines: BlkAlloc
Errors: See Appendix
Description: This routine is called by SaveFile to actually save the
memory. All of the sectors should have already been allocated.
This routine stops saving memory when track 0 is found in the
list of tracks and sectors.
1-405
Function Name: RenameFile
Purpose: Rename a file.
Call address: $C259
Input requirements:
$02-$03 R0 Pointer to new file name.
$0E-$0F R6 Pointer to old file name.
Output:
$04 R1L Track of directory sector.
$05 R1H Sector of directory sector.
$0C-$0D R5 Pointer to file name in directory entry.
$8400-$841D dirEntryBuf: Copy of old directory entry.
Errors: See Appendix I.
Description: This routine renames a file by calling FindFile, then
copying the new name into the entry. Finally, the sector is
rewritten to the disk.
1-406
Function Name: DeleteFile
Purpose: Delete a file from the disk.
Call address: $C238
Input requirements:
$02-$03 R0 Pointer to file name.
Errors: See appendix I.
Description: The specified file is deleted from the current
drive.
1-407
Function Name: FastDelFile
Purpose: Delete a temporary file.
Call address: $C244
Input requirements:
$08-$09 R3 Pointer to table of tracks and sectors.
$0E-$0F R6 Pointer to file name.
Errors: See appendix I.
Description: This routine removes the file from the directory. It
uses the table of tracks and sectors to free up the sectors used
by the file. This routine is used to clean up a temporary file
that was not completed.
1-408
Function Name: FreeFile
Purpose: Deallocates all of a file's sectors.
Call address: $C226
Input requirements:
$8400 dirEntryBuf: Current directory entry.
$14-$15 R9 Pointer to directory entry.
Preparatory routines: FindFile (Pointer must be copied).
Errors: See Appendix I.
Description: Given the directory entry of a file, all of its
sectors are returned to the free pool. The directory pointer
should be pointing to the directory entry at $8400 and not the
pointer returned by FindFile. This is due to memory conflicts that
will arise. This routine uses $8000-$82FF for its buffer areas.
1-409
Function Name: RstrAppl
Purpose: Reload the SWAPFILE.
Call address: $C23E
Preparatory routines: LdDeskAcc
Errors: See Appendix I.
Description: This routine reloads the SWAPFILE, then deletes it.
The last window description is reprocessed to restore the screen
and control is returned to the original program that called
LdDeskAcc.
1-410
Function Name: GetFile
Purpose: Load and run a file.
Call address: $C208
Input requirements:
$02 R0L Flag byte (See description).
$06-$07 R2 Optional data pointer.
$08-$09 R3 Optional data pointer.
$0E-$0F R6 Pointer to filename.
$10-$11 R7 Load address (optional).
Output:
$8100-$81FF fileHeader: Info sector for file.
$8300-$83FF fileTrScTab: Table of tracks and sectors loaded.
Errors: See Appendix
Description: This routine loads and runs a given file. The file
must be one of the following GEOS types:
System File Desk Accessory
Application Application Data
Printer Driver Input Driver
The execution address is taken from the information sector. If it
is zero, the file is not executed, only loaded. VLIR files have
only their first chain loaded. Desk Accessories swap out the
memory that they use to the SWAPFILE. Upon completion, the
SWAPFILE is reloaded. The flag byte at location $02 has two
purposes. This first is if bit 0 is set and the file was an
application, then it is not executed. Also if bit 0 is set, then
locations $10-$11 R7 have the load address; otherwise, the load
address is taken from the information sector. This bit does not
apply to Desk Accessories. If either bit 6 or 7 are set, then
$06-$07 R2 points to 16 bytes which are copied to $8453
(dataDiskName), and $07-$08 point to 16 bytes which are copied to
$8442 (dataFileName).
1-411
Function Name: LdFile
Purpose: Load a file.
Call address: $C211
Input requirements:
$8400 dirEntryBuf - File directory entry.
$14-$15 R9 Pointer to directory entry ($8400).
$886B Flag byte.
$886C-$886D Load address.
Output:
$8100-$81FF fileHeader: Info sector for file.
$8300-$83FF fileTrScTab: Table of tracks and sectors loaded.
Preparatory routines: FindFile (Pointer must be copied)
Errors: See Appendix
Description: This routine is called by GetFile to perform the load.
This routine does not try to execute the file loaded, nor is it
limited to the file types that GetFile is. However, this routine can
not be used to load Non-GEOS files because the info sector must
be present. If bit 0 of location $886B is set, then the load
address is taken from locations $886C-$886D instead of the info
sector. The directory entry pointer should point to $8400 and
not the pointer returned by FindFile. This is due to memory
conflicts that will arise.
1-412
Function Name: LdApplic
Purpose: Load and possibly run a file.
Call address: $C21D
$02 R0L Flag byte (See description).
$06-$07 R2 Optional data pointer.
$08-$09 R3 Optional data pointer.
$0E-$0F R6 Pointer to filename.
$10-$11 R7 Load address (optional).
Output:
$8100-$81FF fileHeader: Info sector for file.
$8300-$83FF fileTrScTab: Table of tracks and sectors loaded.
Errors: See Appendix
Description: This routine is called by GetFile to load Application
files. Like LdFile, this routine is not limited to any particular
file type, except that it also can not load a Non-GEOS file. See
GetFile for a description of the flag byte, data pointers and load
address.
1-413
Function Name: LdDeskAcc
Purpose: Load and run a file using the SWAPFILE.
Call address: $C217
Input requirements:
$14-$15 R9 Pointer to directory entry.
Output:
$8100-$81FF fileHeader: Info sector for file (Modified).
$8300-$83FF fileTrScTab: List of tracks and sectors loaded.
Preparatory routines: FindFile (Pointer must be copied).
Errors: See Appendix I.
Description: This routine is used to load Desk Accessories. The
info sector is loaded to determine the necessary memory region.
This region is saved to a file called 'SWAPFILE', whose info
sector is the same as the file to be loaded. The difference is
that the text field is cleared, and the file type is System file
(Type 4). RstrAppl must be eventually called to reload the SWAPFILE
and return to normal operation. The directory entry pointer
should point to $8400, and the pointer returned by FindFile. This
is due to memory conflicts that will arise.
1-414
Function Name: ReadByte
Purpose: Read a byte from a file.
Call address: $C2B6
Input requirements:
$0C R5L Index of last byte in buffer.
$0D R5H Index to next character in buffer.
$0A-$0B R4 Pointer to disk buffer.
Output:
A Character that was read.
Errors: See Appendix I.
Description: The initial sector must have been read because the
first two bytes in the buffer are used to find the next track and
sector. Bytes are read from the buffer until there are no more,
then the next sector is read from the disk. This can continue
until the last character of the last sector is read. After this
an error 11 (End of file) will be returned.
1-415
Function Name: ReadFile
Purpose: Load memory from disk.
Call address: $C1FF
Input requirements:
$04 R1L Initial track number.
$05 R1H Initial sector number.
$06-$07 R2 Byte count of load.
$10-$11 R7 Load address.
Output:
$0C R5L Index to last sector loaded.
$8300- fileTrScTab: List of tracks and sectors loaded.
Preparatory routines: GetFHdrInfo
Errors: See Appendix I.
Description: This routine assumes that the file has been located
in the directory and that the initial track and sector are known.
1-416
Function Name: GetFreeDirBlk
Purpose: Find a hole in the directory, or make one.
Call address: $C1F6
Output:
Y Index of hole in buffer.
$04 R1L Directory track number (Should be 18).
$05 R1H Directory sector number.
$16 R10L # directory sectors to skip first.
$8000-$80FF diskBlkBuf: Buffer for directory sector.
Description: This routine scans the disk's directory looking for
a deleted file, by first skipping a certain number of sectors.
This allows the user to find a hole in a given directory page.
If one is not found in any of the available directory sectors,
then a new sector is added to the directory.
1-417
Function Name: SetGDirEntry
Purpose: Creates a directory entry on the disk.
Call address: $C1F0
Input requirements:
$14-$15 R9 fileHeader ($8100), required.
$16 R10L # of directory sectors to skip first.
$8100-$81FF fileHeader: Information sector for file.
$8300- fileTrScTab: Track and sector list for file.
Outputs:
$8400-$841D dirEntryBuf: Directory entry.
Directory entry is written to the disk.
Preparatory routines: BlkAlloc
Errors: See appendix
Description: This routine is used by SaveFile and calls BldGDirEntry.
Because of this, assumptions are made. The first is that the
information sector is at $8100-$81FF and that $14-$15 R9 point
there. The first two bytes of the information sector are the
address of the filename. These are reset by this routine to $00,
$FF. Another assumption made by this routine is that $8300 is a
list of useable tracks and sectors; specifically, $8300-$8301 are
the track and sector for the information sector and $8302-$8303
are the track and sector of the first sector of the file.
1-418
Function Name: BldGDirEntry
Purpose: Create a directory entry in memory.
Call address: $C1F3
Input requirements:
$14-$15 R9 fileHeader ($8100), required.
$8100-$81FF fileHeader: Information sector for file.
$8300- fileTrScTab: Track and sector list for file.
Outputs:
$8400-$841D dirEntryBuf: Directory entry.
Preparatory routines: BlkAlloc
Errors: See appendix
Description: See SetGDirEntry for a complete list of all the
assumptions made by this routine.
1-419
Function Name: GetFHdrInfo
Purpose: Get the load address of a file.
Call address: $C229
Input requirements:
$14-$15 R9 Pointer to directory entry.
Output:
$04 R1L Track of file's first sector.
$05 R1H Sector of file's first sector.
$10-$11 R7 Load address for file.
$8100-$81FF fileHeader: Info sector for file.
$8300-$8301 fileTrScTab: Track and sector of info sector.
Errors: See Appendix I.
Description: This routine loads the info sector for a file into
the buffer at $8100 (fileHeader). The load address is set from
$8147-$8148. This routine is called by all the load routines.
1-420
Function Name: FollowChain
Purpose: Create a table of tracks and sectors.
Call address: $C205
Input requirements:
$04 R1L Initial track number.
$05 R1H Initial sector number.
$08-$09 R3 Address of table to be created.
Output:
Table pointed to by $08-$09 is filled with all the tracks
and sectors linked to the initial sector.
Errors: See Appendix
Description: Given an initial track and sector, this routine
traces a chain and returns a list of all the tracks and sectors
encountered. This routine uses diskBlkBuf at $8000-$80FF to read
the sectors.