From 340bbefd0649650da8956fe6a3c4469099433faa Mon Sep 17 00:00:00 2001 From: Christian Werner Date: Thu, 15 Oct 2026 02:17:03 +0200 Subject: [PATCH] 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 --- src/kernal/iec/chkin_iec.s | 4 ++-- src/kernal/iec/ckout_iec.s | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/kernal/iec/chkin_iec.s b/src/kernal/iec/chkin_iec.s index 6112239f..7ae9b82f 100644 --- a/src/kernal/iec/chkin_iec.s +++ b/src/kernal/iec/chkin_iec.s @@ -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 diff --git a/src/kernal/iec/ckout_iec.s b/src/kernal/iec/ckout_iec.s index 02719b5f..5141c79b 100644 --- a/src/kernal/iec/ckout_iec.s +++ b/src/kernal/iec/ckout_iec.s @@ -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