CLOSE: send LISTEN, CLOSE, UNLISTEN to a serial device

close_iec sent its CLOSE command under ATN without first addressing the
device with LISTEN and without UNLISTEN after it, and built the command
with ORA $E0 (zero page) instead of ORA #$E0, so the byte it sent was
the secondary address ORed with whatever $E0 held. The drive never
learned of the CLOSE, so a file written on a channel was never written
to the disk.

The contract (Michael Steil, "Commodore Peripheral Bus: Part 2",
https://www.pagetable.com/?p=1031): CLOSE of a file on a serial device
sends LISTEN, then $E0 plus the secondary address, then UNLISTEN.
close_iec now does that, as iec_close_load already does for LOAD.

Not reported upstream (https://github.com/MEGA65/open-roms).
This commit is contained in:
chris committed 2026-10-15 02:15:38 +02:00
1 parent 264e9792a5
commit 29124377fc
1 file changed
+7 -1
+7 -1
View File
@@ -23,11 +23,17 @@ close_iec:
jsr iec_close_load
jmp close_remove_from_table
@1:
ora $E0 ; CLOSE command
; LISTEN, CLOSE, UNLISTEN - see https://www.pagetable.com/?p=1031
lda FAT, y
jsr LISTEN
bcs close_iec_end
lda SAT, y
ora #$E0 ; CLOSE command
sta TBTCNT
jsr iec_tx_command
bcs close_iec_end
jsr iec_tx_command_finalize
jsr UNLSN
; FALLTROUGH