.byte $2c and the following two bytes (lda #0) constitute a BIT instruction which is meant to skip the following lda #$3f instruction in case of UNTALK ($3F is the UNLISTEN command):
send_untalk_iec:
sei
jsr CLOCK_hi
jsr ATN_hi
lda #$5f
.byte $2c
send_unlisten_iec:
lda #0
sta ch_state
lda #$3f
pha
It seems that a possible fix may be to swap these lines around so that the .byte $2c skips the lda #$3f instruction as expected:
send_unlisten_iec:
lda #$3f
pha
lda #0
sta ch_state
I presume the existing code works as-is with a real 1541, but it turned out that my emulator was sensitive to this protocol violation.
Playing around with LNG in my own C64/1541 emulator, I noticed that LNG sends
UNLISTEN
when it should sendUNTALK
, e.g. in sequences like this:(TALK 8) (SECOND 9) (UNLISTEN)
Looking at the code in this repository, it seems there is a bug here:
https://github.com/ytmytm/c64-lng/blob/c1fb00d2ab26ceb1c513ab3852e66b7698dd712d/kernel/opt/iec_1541.s#L141
.byte $2c
and the following two bytes (lda #0
) constitute aBIT
instruction which is meant to skip the followinglda #$3f
instruction in case of UNTALK ($3F
is theUNLISTEN
command):It seems that a possible fix may be to swap these lines around so that the
.byte $2c
skips thelda #$3f
instruction as expected:I presume the existing code works as-is with a real 1541, but it turned out that my emulator was sensitive to this protocol violation.