CHKIN and CKOUT refactoring

This commit is contained in:
FeralChild64 committed 2019-10-29 21:24:25 +01:00
1 parent e00bda3548
commit 7eca8ea05b
12 files changed
+223 -164

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
//
// Common part of CHKIN and CKOUT
//
chkinout_device_not_present:
ply_trash_a
pla
jsr kernalstatus_DEVICE_NOT_FOUND
jmp kernalerror_DEVICE_NOT_FOUND
chkinout_file_not_open:
ply_trash_a
pla
jmp kernalerror_FILE_NOT_OPEN
+69
View File
@@ -0,0 +1,69 @@
//
// Official Kernal routines, described in:
//
// - [RG64] C64 Programmer's Reference Guide - page 275
// - [CM64] Compute's Mapping the Commodore 64 - page 229
//
// CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213)
//
CHKIN:
// Store registers for preservation
pha
phy_trash_a
// Reset status
jsr kernalstatus_reset
// First retrieve the FAT/LAT/SAT table index (and check if file is open)
txa
jsr find_fls
bcs_far chkinout_file_not_open
// Now we have table index in Y
lda FAT,Y
// Handle all the devices
beq chkin_set_device // 0 - keyboard
// Tape not supported here
#if HAS_RS232
cmp #$02
beq_far chkin_rs232
#endif // HAS_RS232
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_far chkin_iec
#endif // CONFIG_IEC
cmp #$03 // screen - only legal one left
bne_far chkinout_device_not_present
chkin_set_device:
lda FAT,Y
sta DFLTN
// FALLTROUGH
chkinout_end:
ply_trash_a
pla
clc // indicate success
rts
chkin_file_not_input:
ply_trash_a
pla
jmp kernalerror_FILE_NOT_INPUT
+8
View File
@@ -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.
+76
View File
@@ -0,0 +1,76 @@
//
// Official Kernal routines, described in:
//
// - [RG64] C64 Programmer's Reference Guide - page 276
// - [CM64] Compute's Mapping the Commodore 64 - page 229
//
// CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213)
//
CKOUT:
// Store registers for preservation
pha
phy_trash_a
// Reset status
jsr kernalstatus_reset
// First retrieve the FAT/LAT/SAT table index (and check if file is open)
txa
jsr find_fls
bcs_far chkinout_file_not_open
// Now we have table index in Y
lda FAT,Y
// Handle all the devices
beq ckout_file_not_output // 0 - keyboard
// Tape not supported here
#if HAS_RS232
cmp #$02
beq_far ckout_rs232
#endif // HAS_RS232
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_far ckout_iec
#endif // CONFIG_IEC
cmp #$03 // screen - only legal one left
bne_far chkinout_device_not_present
ckout_set_device:
lda FAT,Y
sta DFLTO
jmp chkinout_end
ckout_file_not_output:
ply_trash_a
pla
jmp kernalerror_FILE_NOT_OUTPUT
+8
View File
@@ -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.