1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-20 03:16:45 +00:00

C64: File I/O support

This commit is contained in:
Karol Stasiak
2019-01-05 01:19:14 +01:00
parent 7d596f3ed6
commit 492300d298
15 changed files with 485 additions and 2 deletions
+5 -1
View File
@@ -2,14 +2,18 @@
# Commodore 64-oriented modules
## `c64_kernal` module
## c64_kernal module
The `c64_kernal` module is imported automatically on the C64 target.
It provides access to Kernal routines, so it requires the Kernal ROM to be enabled.
TODO
## c64_basic module
The `c64_basic` module provides access to Kernal routines, so it requires the Basic ROM to be enabled.
In particular, this means that it will not work on cartridge targets without extra preparations.
TODO
## c64_hardware
+81
View File
@@ -0,0 +1,81 @@
[< back to index](../index.md)
## cbm_file
The `cbm_file` module provides support for loading and saving files to tape and disk.
Currently, it works only for Commodore 64 targets, although support for more targets is coming.
It uses Kernal routines, so it requires the Kernal ROM to be enabled.
#### byte last_used_device()
Returns the last device number, or 8 if none.
#### void load_file(byte device, pointer name)
Loads a PRG file with the given null-terminated name to the address specified in the file.
Sets `errno`.
#### void load_file_at(byte device, pointer name, pointer addr)
Loads a PRG file with the given null-terminated name to the given address.
Sets `errno`.
#### void save_file(byte device, pointer name, pointer start, word length)
Saves `length` bytes starting from `start` to a PRG file named `name` on device `device`.
Sets `errno`.
#### void exec_disk(byte device, pointer command)
Executes a CBM DOS command on the given drive.
#### void delete_file(byte device, pointer name)
Deletes given file in the given drive. (`S0:`)
#### void rename_file(byte device, pointer old_name, pointer new_name)
Renames given file in the given drive. (`R0:`)
#### void copy_file(byte device, pointer old_name, pointer new_name)
Copies given file in the given drive. (`C0:`)
#### void initialize_disk(byte device)
Reinitialized disk status in the given drive. (`I0`)
#### void validate_disk(byte device)
Validates disk status in the given drive. (`V0`)
#### void format_disk(byte device)
Formats disk status in the given drive. (`N0:`)
#### void open_file(byte device, pointer name, byte fd, byte mode)
Opens a file.
Sets `errno`.
TODO: buggy.
#### const byte MODE_READ = 0
#### const byte MODE_WRITE = 1
#### void close_file(byte fd)
Closes the given file.
Sets `errno`.
TODO: buggy.
#### byte getbyte_safe()
Reads a byte from file.
Sets `errno` to `err_eof` when reading the last byte, so don't abort reading when getting `errno != err_ok`.
TODO: buggy.
#### void putbyte_safe(byte b)
Wrires a byte from file.
Sets `errno`.
TODO: buggy.
+5
View File
@@ -23,3 +23,8 @@ If the source string is longer than 255 bytes, then the behaviour is undefined (
Converts a null-terminated string to a number.
Sets `errno`.
#### `void strzappend(pointer buffer, pointer str)`
#### `void strzappendchar(pointer buffer, byte char)`
Modifies the given null-terminated buffer by appending a null-terminated string or s single character respectively.