some work towards I/O stack modularization
This commit is contained in:
1 parent
966658eae0
commit
6fa2c5b570
56 files changed
+357
-69
No files matched your search
@@ -0,0 +1,52 @@
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmer's Reference Guide - page 281/282
|
||||
// - [CM64] Compute's Mapping the Commodore 64 - page 229/230
|
||||
// - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc (IEC command)
|
||||
//
|
||||
// CPU registers that has to be preserved (see [RG64]): none
|
||||
//
|
||||
|
||||
CLOSE:
|
||||
|
||||
// XXX this needs more testing (opening 10 files at once, closing in various orders, etc) once the code is more mature
|
||||
|
||||
// Find the LAT / SAT / FAT entry which LAT corresponds to A
|
||||
|
||||
jsr find_fls
|
||||
bcs close_end // XXX can we report error in IOSTATUS here?
|
||||
|
||||
#if CONFIG_IEC
|
||||
|
||||
// We have the entry index in .Y - check whether this is IEC device
|
||||
lda FAT, y
|
||||
jsr iec_check_devnum_oc
|
||||
bcc_far close_iec
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
close_remove_from_table:
|
||||
|
||||
// Remove channel from the table
|
||||
iny
|
||||
cpy #$0A
|
||||
bpl !+
|
||||
lda LAT, y
|
||||
sta LAT-1, y
|
||||
lda FAT, y
|
||||
sta FAT-1, y
|
||||
lda SAT, y
|
||||
sta SAT-1, y
|
||||
jmp close_remove_from_table
|
||||
!:
|
||||
// Decrement the list size variable
|
||||
dec LDTND
|
||||
|
||||
clc // report success - not sure if original CLOSE does this, but it's nevertheless a good practice
|
||||
|
||||
close_end:
|
||||
rts
|
||||
@@ -0,0 +1,8 @@
|
||||
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
|
||||
|
||||
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
|
||||
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
|
||||
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
|
||||
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
|
||||
|
||||
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
|
||||
@@ -0,0 +1,8 @@
|
||||
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
|
||||
|
||||
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
|
||||
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
|
||||
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
|
||||
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
|
||||
|
||||
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
|
||||
@@ -0,0 +1,71 @@
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmer's Reference Guide - page 289
|
||||
// - [CM64] Compute's Mapping the Commodore 64 - page 230/231
|
||||
//
|
||||
// CPU registers that has to be preserved (see [RG64]): none
|
||||
//
|
||||
|
||||
|
||||
OPEN:
|
||||
|
||||
// Reset status
|
||||
jsr kernalstatus_reset
|
||||
|
||||
// Check if the logical file number is unique
|
||||
ldy LDTND
|
||||
!:
|
||||
beq !+
|
||||
dey
|
||||
lda LAT, y
|
||||
cmp LA
|
||||
bne open_not_yet_open
|
||||
jmp kernalerror_FILE_ALREADY_OPEN
|
||||
|
||||
open_not_yet_open:
|
||||
cpy #$00
|
||||
jmp !-
|
||||
!:
|
||||
// Check if we have space in tables
|
||||
|
||||
ldy LDTND
|
||||
cpy #$0A
|
||||
bcc open_has_space
|
||||
!:
|
||||
// Table is full
|
||||
jmp kernalerror_TOO_MANY_OPEN_FILES
|
||||
|
||||
open_has_space:
|
||||
|
||||
// Update the tables
|
||||
|
||||
// LAT / FAT / SAT support implemented according to
|
||||
// 'Compute's Mapping the Commodore 64', page 52
|
||||
|
||||
lda LA
|
||||
sta LAT, y
|
||||
lda FA
|
||||
sta FAT, y
|
||||
lda SA
|
||||
sta SAT, y
|
||||
|
||||
iny
|
||||
sty LDTND
|
||||
|
||||
// Check for command to send
|
||||
lda FNLEN
|
||||
beq open_done_success
|
||||
|
||||
// Check for IEC device
|
||||
lda FA
|
||||
jsr iec_check_devnum_oc
|
||||
bcc_far open_iec
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
open_done_success:
|
||||
|
||||
clc
|
||||
rts
|
||||
@@ -40,15 +40,9 @@ LOAD:
|
||||
// Check whether we support the requested device
|
||||
lda FA
|
||||
|
||||
// Try IEC - legal device numbers for LOAD are 8-30
|
||||
// Device numbers above 30 can not be used as IEC (see https://www.pagetable.com/?p=1031),
|
||||
// as the protocol combines device number with command code in one byte, above 30 it is
|
||||
// no longer possible. Original ROMs show ILLEGAL DEVICE NUMBER error only for devices
|
||||
// 0-3; our implementation is more strict here
|
||||
#if CONFIG_IEC
|
||||
jsr iec_check_devnum_lvs
|
||||
bcc_far load_iec
|
||||
#endif // CONFIG_IEC
|
||||
|
||||
cmp #$1F
|
||||
bcs !+ // >= 31
|
||||
cmp #$08
|
||||
bcs_far load_iec // >= 8
|
||||
!:
|
||||
jmp lvs_illegal_device_number
|
||||
Reference in new issue
Block a user