CHKIN, CHKOUT: address the channel by the file's secondary address

chkin_iec and ckout_iec read the secondary address from LAT, the table
of logical file numbers, instead of SAT, the table of secondary
addresses. A file whose number differed from its secondary address,
such as OPEN 3,8,2, was read from or written to the wrong channel, and
the read-only and write-only checks tested the file number.

The contract (Michael Steil, "Commodore Peripheral Bus: Part 2",
https://www.pagetable.com/?p=1031): CHKIN sends TALK and CHKOUT sends
LISTEN, each followed by the secondary address OPEN was given; Compute!'s
Mapping the Commodore 64 (p. 52) keeps the logical file numbers at
$0259 (LAT) and the secondary addresses at $026D (SAT). Both routines
now read SAT.

Not reported upstream (https://github.com/MEGA65/open-roms); it may be
what upstream issue #117's OPEN 1,8,0,"$" test met:
https://github.com/MEGA65/open-roms/issues/117
This commit is contained in:
chris committed 2026-10-15 02:17:03 +02:00
1 parent 29124377fc
commit 340bbefd06
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ chkin_iec:
; Fail if the file is open for writing (secondary address 1)
lda LAT, Y
lda SAT, Y
cmp #$01
+beq chkin_file_not_input
@@ -24,7 +24,7 @@ chkin_iec:
jsr TALK
+bcs chkinout_device_not_present
lda LAT, Y
lda SAT, Y
ora #$60
jsr TKSA
+bcs chkinout_device_not_present
+2 -2
View File
@@ -14,7 +14,7 @@ ckout_iec:
; Fail if the file is open for reading (secondary address 0)
lda LAT, Y
lda SAT, Y
+beq ckout_file_not_output
; Send LISTEN + SECOND first
@@ -23,7 +23,7 @@ ckout_iec:
jsr LISTEN
+bcs chkinout_device_not_present
lda LAT, Y
lda SAT, Y
ora #$60
jsr SECOND
+bcs chkinout_device_not_present