Written and Maintained by Gregory Nacu

C64 OS TECHNICAL DOCS

Last modified: May 02, 2019

Files and File References

C64 OS uses the C64 KERNAL ROM's implementation for IEC serial bus access, and File I/O. C64 OS does not provide a fast loader. C64 OS is compatible with JiffyDOS, and purchasing a copy (from Retro Innovations) is highly recommended.

File Module KERNAL Calls

finit

RegPtr → Pointer to a File Reference
A ← Error Code
C ← Set on Error

Initializes the device specified by the file reference. Set's the device's default partition and default path to match the file reference. Called automatically by fopen.

ferror

currentdv → a device number
A ← Value of L_CODE

Reads and clears the current device's status.
Populates: L_CODE, L_DEV, L_STAT, L_MSG, L_TRK and L_SEC.

ferror

currentdv → a device number
A ← Value of L_CODE

Reads and clears the current device's status.
Populates: L_CODE, L_DEV, L_STAT, L_MSG, L_TRK and L_SEC.


fopen

RegPtr → Pointer to an unopen File Reference
A → File Access Flags

Opens the file, on the device, specified by the File Reference.
Marks the file reference as open by setting its logical file number.
Calls ferror to retrieve device status.

fread

RegPtr → Pointer to an Open File Reference
A1 → .W Pointer to Buffer
A2 → .W 16-bit Length to Read

Reads from the current offset into the file, length number of bytes, into buffer.
If the end of file is reached before reading the requested length, no error results, it just stops reading.
The file must be open for read or a file not open error will be generated.

fwrite

RegPtr → Pointer to an Open File Reference
A1 → .W Pointer to Buffer
A2 → .W 16-bit Length to Write

Writes length number of bytes from the buffer to the file.
If the specified length is longer than the buffer, random data following the buffer will be written out to disk.
The file must be open for write or a file not open error will be generated.

fclose

RegPtr → Pointer to an Open File Reference

Closes the file, on the device and in the KERNAL open files table, specified by the File Reference.
If the file is already closed, no error will be produced.


frefcvt

C → Set for Serialize
RegPtr → Pointer to a File Reference Structure
RegPtr ← Pointer to a File Reference String

C → Clear for Unserialize
RegPtr → Pointer to a File Reference String
RegPtr ← Pointer to a File Reference Structure

Converts a file reference between a 1-Memory Page structure and a packed string representation. The string representation is used for storage to disk. The in–memory structure is used for opening and working with the file, as it maintains runtime flags and pointers that have no representation in the string format.


File Constants

A File Reference in–memory structure.

File Ref Part Description
FREFDEV The standard Commodore device number, from 8 to 30.
FREFPART The partition number on devices which support multiple partitions. On 1541, 1571, and 1581 drives partition number is always 0.
FREFLFN The KERNAL ROM's logical file number. This is assigned automatically by fopen. Doubles as a flag to indicate file open status. It is 0 when the file is closed.
FREFBLKS Size of the file in 254-byte blocks.
FREFNAME A filename, up to 16 characters long.
FREFPATH An absolute path, CMD Format (SD2IEC compatible.) Maximum path length 234 bytes.

[... DOCUMENTATION IN PROGRESS ...]

File System

File References

For a detailed explanation of File References, what they are for, how they work and why they are necessary, see the weblog post KERNAL, File Refs and Services.

Drive Detection

Drive and File Status


Next Section: Screen Compositor

Table of Contents



This is a document in progress.
Check back again soon.