Compare commits

...
10 Commits
Author SHA1 Message Date
chris 7ee9d164e2 NOTICE: list the CLOSE fix for a device that does not answer 2026-10-15 02:50:48 +02:00
chris 51a2a43520 CLOSE: a device that does not answer sets ST to device not present
When LISTEN or the CLOSE command found no device on the serial bus,
close_iec freed the file number but left ST as it was, so READST after
the CLOSE said 0.

The contract: every device on the bus must answer ATN by pulling DATA,
and when none does the result is DEVICE NOT PRESENT (Michael Steil,
"Commodore Peripheral Bus: Part 2", https://www.pagetable.com/?p=1031);
the C64 Programmer's Reference Guide's READST reports that as ST bit 7
($80). close_iec now sets that bit when LISTEN or the CLOSE command
fails, and still frees the file number. Commodore's ROMs give the same
ST in the same scenario, as a differential test in arnitech shows.

Not reported upstream (https://github.com/MEGA65/open-roms).
2026-10-15 02:50:48 +02:00
chris ec7707d4cc NOTICE: list the serial-bus fix for a byte with no listener 2026-10-15 02:32:03 +02:00
chris 74ef17d292 Serial bus: a data byte with no listener says DEVICE NOT PRESENT
iec_tx_byte never checked that anyone was listening. With no listener,
DATA stays released, so the wait for listeners to be ready returned at
once, and a byte sent with EOI then waited forever for an EOI
acknowledgement that never came. UNLSN, which sends the byte CIOUT holds
back with EOI, hung the C64 after CHKOUT to a channel the drive refuses
(DOS 2.6 leaves the bus when no write channel is open), or to a channel
a CLOSE 15 has closed.

The contract (Michael Steil, "Commodore Peripheral Bus: Part 4",
https://www.pagetable.com/?p=1135): a listener holds DATA until the
talker releases CLK; if at the beginning of a byte no receiver pulls
DATA within 256 us, that is a DEVICE NOT PRESENT error. The C64
Programmer's Reference Guide's READST gives it as ST bit 7 ($80).
iec_tx_byte now waits up to about 256 us for DATA to be pulled, and
without it sets ST $80 and returns with DEVICE NOT PRESENT. Commodore's
ROMs give the same ST in the same scenarios, as a differential test in
arnitech shows.

Not reported upstream (https://github.com/MEGA65/open-roms).
2026-10-15 02:31:56 +02:00
chris b95a6ff057 NOTICE: list the serial-bus fixes of 2026-10-15
CIOUT's buffer, CLOSE's LISTEN/CLOSE/UNLISTEN, CHKIN's and CHKOUT's
secondary address, and TKSA's secondary address.
2026-10-15 02:19:08 +02:00
chris f1df180bf8 TKSA: send the secondary address the caller gives
TKSA ORed the accumulator with $90 before sending it. Its callers pass
the secondary address plus $60, as the routine's own comment asks, so
TKSA turned a TALK secondary address $60-$6F into $F0-$FF, the OPEN
command, on the bus.

The contract (C64 Programmer's Reference Guide, TKSA; Michael Steil,
"Commodore Peripheral Bus: Part 2", https://www.pagetable.com/?p=1031,
which gives TKSA's argument as A = $60 + secondary address): TKSA sends
the byte in A as the secondary address to the device told to TALK.
TKSA now sends A as it is.

Upstream: https://github.com/MEGA65/open-roms/issues/116 (bug 1)
2026-10-15 02:18:55 +02:00
chris 340bbefd06 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
2026-10-15 02:17:03 +02:00
chris 29124377fc 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).
2026-10-15 02:15:38 +02:00
chris 264e9792a5 CIOUT: buffer the byte where iec_tx_byte sends it from
CIOUT kept the byte to send next in BSOUR ($95), but iec_tx_byte, which
CIOUT and iec_tx_flush (called by UNLSN, UNTLK, LISTEN, TALK) use to
send it, transmits TBTCNT ($A4). So every byte CHROUT sent to a serial
device was whatever TBTCNT held, and a file written with CHKOUT and
CHROUT held the wrong bytes.

The contract (C64 Programmer's Reference Guide, CIOUT): CIOUT sends a
byte to the listening device, always holding one back so that the last
byte goes with EOI when UNLSN ends the transfer. CIOUT now buffers the
byte in TBTCNT, the one-line fix of upstream PR #113; changing the send
path to read BSOUR would also move LOAD's and SAVE's bytes.

Upstream: https://github.com/MEGA65/open-roms/pull/113
2026-10-15 02:15:38 +02:00
chris 840c5f1b61 Add the mc64 configuration, the Firmware of arnitech's mc64
A copy of the c64 configuration with its own ID ($6D), the brand "MC64",
and BCD_SAFE_INTERRUPTS off, plus its Makefile targets
build/kernal_mc64.rom and build/basic_mc64.rom, made the same way as the
c64 ones. NOTICE says who modified the fork, when, and what changed.
2026-10-14 18:32:24 +02:00
9 changed files with 210 additions and 10 deletions

No files matched your search

+20
View File
@@ -137,6 +137,7 @@ GEN_ZMAC_H = $(DIR_ZMAC_TMP)/doc.inl
# List of build directories
DIR_C64 = build/target_c64
DIR_MC64 = build/target_mc64
DIR_CUS = build/target_custom
DIR_GEN = build/target_generic
DIR_GENCRT = build/target_generic_crt
@@ -151,6 +152,7 @@ DIR_X16 = build/target_cx16
CFG_CUS = src/,,config_custom.s
CFG_C64 = src/,,config_c64.s
CFG_MC64 = src/,,config_mc64.s
CFG_GEN = src/,,config_generic.s
CFG_GENCRT = src/,,config_generic_crt.s
CFG_TST38 = src/,,config_testing_38K.s
@@ -164,6 +166,7 @@ CFG_U64CRT = src/,,config_ultimate64_crt.s
GEN_STR_CUS = $(DIR_CUS)/,generated/,packed_strings.s
GEN_STR_C64 = $(DIR_C64)/,generated/,packed_strings.s
GEN_STR_MC64 = $(DIR_MC64)/,generated/,packed_strings.s
GEN_STR_GEN = $(DIR_GEN)/,generated/,packed_strings.s
GEN_STR_GENCRT = $(DIR_GENCRT)/,generated/,packed_strings.s
GEN_STR_TST38 = $(DIR_TST38)/,generated/,packed_strings.s
@@ -212,6 +215,7 @@ TARGET_CHR_PXL = build/chargen_pxlfont.rom
TARGET_CUS_B = build/basic_custom.rom
TARGET_C64_B = build/basic_c64.rom
TARGET_MC64_B = build/basic_mc64.rom
TARGET_GEN_B = build/basic_generic.rom
TARGET_GENCRT_B = build/basic_generic_crt.rom
TARGET_TST38_B = build/basic_testing_38K.rom
@@ -221,6 +225,7 @@ TARGET_U64CRT_B = build/basic_ultimate64_crt.rom
TARGET_CUS_K = build/kernal_custom.rom
TARGET_C64_K = build/kernal_c64.rom
TARGET_MC64_K = build/kernal_mc64.rom
TARGET_GEN_K = build/kernal_generic.rom
TARGET_GENCRT_K = build/kernal_generic_crt.rom
TARGET_TST38_K = build/kernal_testing_38K.rom
@@ -237,6 +242,7 @@ TARGET_X16_x = build/cx16-dummy.rom
TARGET_LIST_CUS = $(TARGET_CUS_B) $(TARGET_CUS_K)
TARGET_LIST_C64 = $(TARGET_C64_B) $(TARGET_C64_K)
TARGET_LIST_MC64 = $(TARGET_MC64_B) $(TARGET_MC64_K)
TARGET_LIST_GEN = $(TARGET_GEN_B) $(TARGET_GEN_K)
TARGET_LIST_GENCRT = $(TARGET_GENCRT_B) $(TARGET_GENCRT_K) $(TARGET_GENCRT_X)
TARGET_LIST_TST38 = $(TARGET_TST38_B) $(TARGET_TST38_K)
@@ -249,6 +255,7 @@ TARGET_Z80TEST = ./build/cpm/Z80TEST.COM
TARGET_LIST = $(TARGET_CHR_ORF) \
$(TARGET_LIST_CUS) \
$(TARGET_LIST_C64) \
$(TARGET_LIST_MC64) \
$(TARGET_LIST_GEN) \
$(TARGET_LIST_GENCRT) \
$(TARGET_LIST_TST38) \
@@ -385,6 +392,8 @@ $(DIR_CUS)/OUTB_x.BIN $(DIR_CUS)/BASIC_combined.vs: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_CUS) $(GEN_STR_CUS) $(DIR_CUS)/KERNAL_combined.sym
$(DIR_C64)/OUTB_x.BIN $(DIR_C64)/BASIC_combined.vs: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_C64) $(GEN_STR_C64) $(DIR_C64)/KERNAL_combined.sym
$(DIR_MC64)/OUTB_x.BIN $(DIR_MC64)/BASIC_combined.vs: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_MC64) $(GEN_STR_MC64) $(DIR_MC64)/KERNAL_combined.sym
$(DIR_GEN)/OUTB_x.BIN $(DIR_GEN)/BASIC_combined.vs: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_GEN) $(GEN_STR_GEN) $(DIR_GEN)/KERNAL_combined.sym
$(DIR_TST38)/OUTB_x.BIN $(DIR_TST38)/BASIC_combined.vs: \
@@ -398,6 +407,8 @@ $(DIR_CUS)/OUTK_x.BIN $(DIR_CUS)/KERNAL_combined.vs $(DIR_CUS)/KERNAL_combined.s
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_CUS) $(GEN_STR_CUS)
$(DIR_C64)/OUTK_x.BIN $(DIR_C64)/KERNAL_combined.vs $(DIR_C64)/KERNAL_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_C64) $(GEN_STR_C64)
$(DIR_MC64)/OUTK_x.BIN $(DIR_MC64)/KERNAL_combined.vs $(DIR_MC64)/KERNAL_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_MC64) $(GEN_STR_MC64)
$(DIR_GEN)/OUTK_x.BIN $(DIR_GEN)/KERNAL_combined.vs $(DIR_GEN)/KERNAL_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_GEN) $(GEN_STR_GEN)
$(DIR_TST38)/OUTK_x.BIN $(DIR_TST38)/KERNAL_combined.vs $(DIR_TST38)/KERNAL_combined.sym: \
@@ -457,6 +468,7 @@ $(DIR_X16)/kernal.seg_1 $(DIR_X16)/KERNAL_1_combined.vs $(DIR_X16)/KERNAL_1_comb
$(DIR_CUS)/OUTx_x.BIN: $(DIR_CUS)/OUTB_x.BIN $(DIR_CUS)/OUTK_x.BIN
$(DIR_C64)/OUTx_x.BIN: $(DIR_C64)/OUTB_x.BIN $(DIR_C64)/OUTK_x.BIN
$(DIR_MC64)/OUTx_x.BIN: $(DIR_MC64)/OUTB_x.BIN $(DIR_MC64)/OUTK_x.BIN
$(DIR_GEN)/OUTx_x.BIN: $(DIR_GEN)/OUTB_x.BIN $(DIR_GEN)/OUTK_x.BIN
$(DIR_GENCRT)/OUTx_0.BIN: $(DIR_GENCRT)/OUTB_0.BIN $(DIR_GENCRT)/OUTK_0.BIN
$(DIR_TST38)/OUTx_x.BIN: $(DIR_TST38)/OUTB_x.BIN $(DIR_TST38)/OUTK_x.BIN
@@ -468,6 +480,7 @@ $(DIR_X16)/OUTx_0.BIN: $(DIR_X16)/OUTB_0.BIN $(DIR_X16)/OUTK_0.BIN
$(TARGET_CUS_B): $(DIR_CUS)/OUTx_x.BIN
$(TARGET_C64_B): $(DIR_C64)/OUTx_x.BIN
$(TARGET_MC64_B): $(DIR_MC64)/OUTx_x.BIN
$(TARGET_GEN_B): $(DIR_GEN)/OUTx_x.BIN
$(TARGET_TST38_B): $(DIR_TST38)/OUTx_x.BIN
$(TARGET_TST60_B): $(DIR_TST60)/OUTx_x.BIN
@@ -475,6 +488,7 @@ $(TARGET_U64_B): $(DIR_U64)/OUTx_x.BIN
$(TARGET_CUS_K): $(DIR_CUS)/OUTx_x.BIN
$(TARGET_C64_K): $(DIR_C64)/OUTx_x.BIN
$(TARGET_MC64_K): $(DIR_MC64)/OUTx_x.BIN
$(TARGET_GEN_K): $(DIR_GEN)/OUTx_x.BIN
$(TARGET_TST38_K): $(DIR_TST38)/OUTx_x.BIN
$(TARGET_TST60_K): $(DIR_TST60)/OUTx_x.BIN
@@ -482,6 +496,7 @@ $(TARGET_U64_K): $(DIR_U64)/OUTx_x.BIN
build/symbols_custom.vs: $(DIR_CUS)/BASIC_combined.vs $(DIR_CUS)/KERNAL_combined.vs
build/symbols_c64.vs: $(DIR_C64)/BASIC_combined.vs $(DIR_C64)/KERNAL_combined.vs
build/symbols_mc64.vs: $(DIR_MC64)/BASIC_combined.vs $(DIR_MC64)/KERNAL_combined.vs
build/symbols_generic.vs: $(DIR_GEN)/BASIC_combined.vs $(DIR_GEN)/KERNAL_combined.vs
build/symbols_generic_crt.vs: $(DIR_GENCRT)/BASIC_0_combined.vs $(DIR_GENCRT)/KERNAL_0_combined.vs
build/symbols_testing_38K.vs: $(DIR_TST38)/BASIC_combined.vs $(DIR_TST38)/KERNAL_combined.vs
@@ -499,6 +514,10 @@ $(GEN_STR_C64): $(TOOL_GENERATE_STRINGS) $(CFG_C64)
@mkdir -p $(DIR_C64)/,generated
$(TOOL_GENERATE_STRINGS) -o $@ -c $(CFG_C64)
$(GEN_STR_MC64): $(TOOL_GENERATE_STRINGS) $(CFG_MC64)
@mkdir -p $(DIR_MC64)/,generated
$(TOOL_GENERATE_STRINGS) -o $@ -c $(CFG_MC64)
$(GEN_STR_GEN): $(TOOL_GENERATE_STRINGS) $(CFG_GEN)
@mkdir -p $(DIR_GEN)/,generated
$(TOOL_GENERATE_STRINGS) -o $@ -c $(CFG_GEN)
@@ -541,6 +560,7 @@ build/,generated/,z80_tables.s: $(TOOL_GENERATE_Z80_TABLES)
GEN_STR_custom = $(GEN_STR_CUS)
GEN_STR_c64 = $(GEN_STR_C64)
GEN_STR_mc64 = $(GEN_STR_MC64)
GEN_STR_generic = $(GEN_STR_GEN)
GEN_STR_generic_crt = $(GEN_STR_GENCRT)
GEN_STR_testing_38K = $(GEN_STR_TST38)
+28
View File
@@ -0,0 +1,28 @@
This is a modified version of MEGA65 Open ROMs (https://github.com/MEGA65/open-roms),
forked at upstream commit ad178dbe4d48cd6a317737a8e0e7e662f7e33d32.
Modified by Christian Werner, 2026-10-14 and 2026-10-15, for the mc64 computers of
arnitech, a set of Minecraft mods (https://git.susdog.de/chris/arnitech). The fork lives
at https://git.susdog.de/chris/open-roms, branch mc64.
Changes:
- src/,,config_mc64.s: a new build configuration, copied from src/,,config_c64.s, with its
own config ID ($6D), the brand "MC64", and BCD_SAFE_INTERRUPTS turned off.
- Makefile: targets for that configuration, build/kernal_mc64.rom and build/basic_mc64.rom,
made the same way as the c64 ones.
- src/kernal/iec/ciout.s (2026-10-15): CIOUT buffers its byte in TBTCNT, where the send
routine takes it from, not in BSOUR (upstream PR #113).
- src/kernal/iec/close_iec.s (2026-10-15): CLOSE sends LISTEN, $E0 plus the secondary
address, and UNLISTEN; it sent a command ORed with zero page $E0 and no LISTEN.
- src/kernal/iec/chkin_iec.s, ckout_iec.s (2026-10-15): CHKIN and CHKOUT take the secondary
address from SAT, not from LAT, the logical file numbers.
- src/kernal/iec/tksa.s (2026-10-15): TKSA sends the secondary address it is given, without
ORing $90 into it (upstream issue #116).
- src/kernal/iec/iec_tx_byte.s (2026-10-15): a data byte that no listener holds DATA for
sets ST to $80 (device not present) and returns, instead of waiting forever.
- src/kernal/iec/close_iec.s (2026-10-15): a CLOSE that finds no device sets ST to $80
(device not present), and still frees the file number.
- NOTICE: this file.
The licence terms are unchanged; see LICENSE, COPYING, and COPYING.LESSER.
+130
View File
@@ -0,0 +1,130 @@
;; #CONFIG# ID $6D ; should be 1 byte, different for each config file!
;
; Please read CONFIG.md before modifying this file!
;
; Idea:
; The Firmware of arnitech's mc64 computers, a Minecraft mod
; Same as the 'c64' configuration, except:
; - the banner names mc64
; - BCD_SAFE_INTERRUPTS is off, for IRQ entry timing closer to the original
; --- Hardware platform and brand
;; #CONFIG# PLATFORM_COMMODORE_64 YES
;; #CONFIG# BRAND_CUSTOM "MC64"
; --- Processor instruction set
;; #CONFIG# CPU_MOS_6502 YES
;; #CONFIG# CPU_DTV_6502 NO
;; #CONFIG# CPU_RCW_65C02 NO
;; #CONFIG# CPU_WDC_65C02 NO
;; #CONFIG# CPU_WDC_65816 NO
;; #CONFIG# CPU_CSG_65CE02 NO
; --- Memory model
;; #CONFIG# MEMORY_MODEL_38K YES
;; #CONFIG# MEMORY_MODEL_46K NO
;; #CONFIG# MEMORY_MODEL_50K NO
;; #CONFIG# MEMORY_MODEL_60K NO
; --- IEC bus configuration
;; #CONFIG# IEC YES
;; #CONFIG# IEC_DOLPHINDOS NO
;; #CONFIG# IEC_DOLPHINDOS_FAST NO
;; #CONFIG# IEC_JIFFYDOS NO
;; #CONFIG# IEC_JIFFYDOS_BLANK NO
; --- Tape deck configuration
;; #CONFIG# TAPE_NORMAL YES
;; #CONFIG# TAPE_TURBO NO
;; #CONFIG# TAPE_AUTODETECT NO
;; #CONFIG# TAPE_NO_KEY_SENSE NO
;; #CONFIG# TAPE_NO_MOTOR_CONTROL NO
; --- Sound support
;; #CONFIG# SID_2ND_ADDRESS NO
;; #CONFIG# SID_3RD_ADDRESS NO
;; #CONFIG# SID_D4XX NO
;; #CONFIG# SID_D5XX NO
;; #CONFIG# SID_D6XX NO
;; #CONFIG# SID_D7XX NO
; --- Keyboard settings
;; #CONFIG# KEYBOARD_C128 NO
;; #CONFIG# KEYBOARD_C128_CAPS_LOCK NO
;; #CONFIG# KEY_REPEAT_DEFAULT NO
;; #CONFIG# KEY_REPEAT_ALWAYS NO
;; #CONFIG# KEY_FAST_SCAN YES
;; #CONFIG# JOY1_CURSOR YES
;; #CONFIG# JOY2_CURSOR YES
;; #CONFIG# PROGRAMMABLE_KEYS YES
;; #CONFIG# KEYCMD_RUN "\5FL"
;; #CONFIG# KEYCMD_F1 "@8$"
;; #CONFIG# KEYCMD_F2 "LOAD"
;; #CONFIG# KEYCMD_F3 "@9$"
;; #CONFIG# KEYCMD_F4 "RUN:"
;; #CONFIG# KEYCMD_F5 "@10$"
;; #CONFIG# KEYCMD_F6 NO
;; #CONFIG# KEYCMD_F7 "@11$"
;; #CONFIG# KEYCMD_F8 NO
;; #CONFIG# KEYCMD_HELP "LIST"
; --- Screen editor
;; #CONFIG# EDIT_STOPQUOTE YES
; --- Software features
;; #CONFIG# PANIC_SCREEN YES
;; #CONFIG# DOS_WEDGE NO
;; #CONFIG# TAPE_WEDGE NO
;; #CONFIG# TAPE_HEAD_ALIGN NO
;; #CONFIG# BCD_SAFE_INTERRUPTS NO
; --- BASIC features
;; #CONFIG# ORIGINAL_UNPATCHED_BASIC YES
;; #CONFIG# TRANSCENDENTAL_FUNCTIONS YES
; --- Eye candy
;; #CONFIG# COLORS_BRAND NO
;; #CONFIG# BANNER_SIMPLE YES
;; #CONFIG# BANNER_FANCY NO
;; #CONFIG# SHOW_FEATURES YES
; --- Debug options
;; #CONFIG# DBG_STUBS_BRK NO
;; #CONFIG# DBG_PRINTF NO
; --- Other
;; #CONFIG# COMPRESSION_LVL_2 NO
+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
+3 -2
View File
@@ -28,9 +28,10 @@ CIOUT:
ciout_store_in_buffer:
; Store in the buffer data to be sent next, return
; Store in the buffer data to be sent next, return; iec_tx_byte
; sends the byte from TBTCNT, so that is our buffer, not BSOUR
pla
sta BSOUR
sta TBTCNT
rts
ciout_send_byte:
+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
+14 -2
View File
@@ -23,11 +23,23 @@ 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_not_present
lda SAT, y
ora #$E0 ; CLOSE command
sta TBTCNT
jsr iec_tx_command
bcs close_iec_end
bcs close_iec_not_present
jsr iec_tx_command_finalize
jsr UNLSN
jmp close_remove_from_table
close_iec_not_present:
; The file is closed all the same; READST says device not present
jsr kernalstatus_DEVICE_NOT_FOUND
; FALLTROUGH
+11
View File
@@ -51,6 +51,17 @@ iec_tx_byte:
+phx_trash_a
+phy_trash_a
; A listener holds DATA until we release CLK; if nobody pulls it
; within 256us, no device is present - see https://www.pagetable.com/?p=1135
ldx #$18
@0:
lda CIA2_PRA
bpl @1 ; branch if DATA is pulled
dex
bne @0
jsr kernalstatus_DEVICE_NOT_FOUND
jmp iec_return_DEVICE_NOT_FOUND
@1:
; Notify all devices that we are going to send a byte
; and it is going to be a data byte (released ATN)
jsr iec_release_atn_clk_data
-2
View File
@@ -28,8 +28,6 @@ TKSA:
; - https://www.lemon64.com/forum/viewtopic.php?t=57694&sid=531ba3592bcffadef2ac8b9162f2e529
; - https://www.pagetable.com/?p=1031 (Kernal API description)
ora #$90
jmp common_untlk_tksa
} else {