IEC turnaround move to proper (I hope...) places
This commit is contained in:
1 parent
c909f323ce
commit
5b70404563
11 files changed
+77
-38
No files matched your search
@@ -52,9 +52,6 @@ chkin:
|
|||||||
jsr tksa
|
jsr tksa
|
||||||
bcs chkinout_end
|
bcs chkinout_end
|
||||||
|
|
||||||
jsr iec_turnaround_to_listen ;; XXX shouldn't this be sent by TALK/TKSA???
|
|
||||||
bcs chkinout_end
|
|
||||||
|
|
||||||
chkin_set_device:
|
chkin_set_device:
|
||||||
lda FAT,Y
|
lda FAT,Y
|
||||||
sta DFLTN
|
sta DFLTN
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
iec_turnaround_to_listen:
|
iec_turnaround_to_listen:
|
||||||
|
|
||||||
|
;; Store .X and .Y on the stack - preserve them
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
tya
|
||||||
|
pha
|
||||||
|
|
||||||
;; Timing is critical here - execute on disabled IRQs
|
;; Timing is critical here - execute on disabled IRQs
|
||||||
php
|
php
|
||||||
sei
|
sei
|
||||||
@@ -20,14 +26,13 @@ iec_turnaround_to_listen:
|
|||||||
dex
|
dex
|
||||||
bne -
|
bne -
|
||||||
|
|
||||||
;; Timeout
|
;; Timeout - XXX what errors do original Kernal report?
|
||||||
plp
|
plp
|
||||||
sec
|
jmp iec_return_DEVICE_NOT_FOUND
|
||||||
rts
|
|
||||||
|
|
||||||
;; CLK is pulled by the device, OK
|
;; CLK is pulled by the device, OK
|
||||||
*
|
*
|
||||||
plp
|
plp
|
||||||
clc
|
jmp iec_return_success
|
||||||
rts
|
|
||||||
|
|
||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
iec_turnaround_to_talk:
|
iec_turnaround_to_talk:
|
||||||
|
|
||||||
|
;; Store .X and .Y on the stack - preserve them
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
tya
|
||||||
|
pha
|
||||||
|
|
||||||
;; Timing is critical here - execute on disabled IRQs
|
;; Timing is critical here - execute on disabled IRQs
|
||||||
php
|
php
|
||||||
sei
|
sei
|
||||||
@@ -19,5 +25,5 @@ iec_turnaround_to_talk:
|
|||||||
jsr iec_pull_clk_release_data
|
jsr iec_pull_clk_release_data
|
||||||
|
|
||||||
plp
|
plp
|
||||||
clc
|
jmp iec_return_success
|
||||||
rts
|
|
||||||
@@ -55,12 +55,6 @@ iec_tx_command:
|
|||||||
|
|
||||||
jmp iec_return_DEVICE_NOT_FOUND
|
jmp iec_return_DEVICE_NOT_FOUND
|
||||||
*
|
*
|
||||||
;; All done
|
;; Done
|
||||||
|
|
||||||
;; XXX All the documentation says we should release ATN at this point, but when I do so
|
|
||||||
;; the turnaround mechanism does not work. Why???
|
|
||||||
;; jsr iec_wait20us
|
|
||||||
;; jsr iec_set_idle
|
|
||||||
|
|
||||||
jmp iec_return_success
|
jmp iec_return_success
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
;; Routine to finalize these IEC commands which do not end in turnaround
|
||||||
|
;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||||
|
|
||||||
|
|
||||||
|
iec_tx_command_finalize:
|
||||||
|
|
||||||
|
;; Store .X and .Y on the stack - preserve them
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
tya
|
||||||
|
pha
|
||||||
|
|
||||||
|
;; Give device some time to complete command reception, release ATN,
|
||||||
|
;; give it some time again before (possible) next command
|
||||||
|
jsr iec_wait20us
|
||||||
|
jsr iec_set_idle
|
||||||
|
jsr iec_wait20us
|
||||||
|
|
||||||
|
jmp iec_return_success
|
||||||
+3
-6
@@ -63,8 +63,9 @@ load:
|
|||||||
bcs lvs_device_not_found_error
|
bcs lvs_device_not_found_error
|
||||||
|
|
||||||
;; Open channel #0 (p16)
|
;; Open channel #0 (p16)
|
||||||
lda #$00
|
lda #$F0 ; $F0 for TKSA + 0 for channel number
|
||||||
jsr tksa
|
sta BSOUR
|
||||||
|
jsr iec_tx_command
|
||||||
bcs lvs_load_verify_error
|
bcs lvs_load_verify_error
|
||||||
|
|
||||||
;; Send filename (p16)
|
;; Send filename (p16)
|
||||||
@@ -155,10 +156,6 @@ load_loop:
|
|||||||
;; Command drive to stop talking and to close the file
|
;; Command drive to stop talking and to close the file
|
||||||
jsr untlk
|
jsr untlk
|
||||||
|
|
||||||
;; Turnaround to talker - according to https://www.pagetable.com/?p=1135
|
|
||||||
;; the turnaround only happens after a command
|
|
||||||
jsr iec_turnaround_to_talk
|
|
||||||
|
|
||||||
lda current_device_number
|
lda current_device_number
|
||||||
jsr listen
|
jsr listen
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -12,7 +12,15 @@
|
|||||||
|
|
||||||
second:
|
second:
|
||||||
|
|
||||||
and #$1F ; make sure bits encoding the command are cleared out
|
;; Due to TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
|
||||||
|
;; allowed channels are 0-15; report error if out of range
|
||||||
|
cmp #$10
|
||||||
|
bcs kernalerror_FILE_NOT_INPUT
|
||||||
|
|
||||||
ora #$60
|
ora #$60
|
||||||
sta BSOUR
|
sta BSOUR
|
||||||
jmp iec_tx_command
|
jsr iec_tx_command
|
||||||
|
bcs + ; branch if error
|
||||||
|
jmp iec_tx_command_finalize
|
||||||
|
*
|
||||||
|
rts
|
||||||
@@ -10,8 +10,6 @@
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
;; XXX shouldn't this do a turnaround?
|
|
||||||
|
|
||||||
talk:
|
talk:
|
||||||
|
|
||||||
;; First check whether device number is correct
|
;; First check whether device number is correct
|
||||||
|
|||||||
+15
-4
@@ -10,12 +10,23 @@
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
;; XXX shouldn't this do a turnaround?
|
|
||||||
|
|
||||||
tksa:
|
tksa:
|
||||||
|
|
||||||
and #$1F ; make sure bits encoding the command are cleared out
|
;; Due to TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
|
||||||
|
;; allowed channels are 0-15; report error if out of range
|
||||||
|
cmp #$10
|
||||||
|
bcs kernalerror_FILE_NOT_INPUT
|
||||||
|
|
||||||
ora #$F0
|
ora #$F0
|
||||||
sta BSOUR
|
sta BSOUR
|
||||||
jmp iec_tx_command
|
jsr iec_tx_command
|
||||||
|
bcs + ; branch if error
|
||||||
|
;; XXX - is it really the right place to do a turnaround? I've got some doubts
|
||||||
|
;; (it forces us to send the TKSA command 'manually' sometimes), but
|
||||||
|
;; Luigi Di Fraia (https://luigidifraia.wordpress.com/2017/06/27/codebase64-on-the-kernal-behaviour/)
|
||||||
|
;; claims TKSA Kernal routine actually does the turnaround
|
||||||
|
jmp iec_turnaround_to_listen
|
||||||
|
*
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
+5
-3
@@ -23,6 +23,8 @@ unlsn:
|
|||||||
;; Buffer empty, send the command
|
;; Buffer empty, send the command
|
||||||
lda #$3F
|
lda #$3F
|
||||||
sta BSOUR
|
sta BSOUR
|
||||||
jmp iec_tx_command
|
jsr iec_tx_command
|
||||||
|
bcs + ; branch if error
|
||||||
|
jmp iec_tx_command_finalize
|
||||||
|
*
|
||||||
|
rts
|
||||||
+5
-4
@@ -10,11 +10,12 @@
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
;; XXX shouldn't this do a turnaround?
|
|
||||||
|
|
||||||
untlk:
|
untlk:
|
||||||
|
|
||||||
lda #$5F
|
lda #$5F
|
||||||
sta BSOUR
|
sta BSOUR
|
||||||
jmp iec_tx_command
|
jsr iec_tx_command
|
||||||
|
bcs + ; branch if error
|
||||||
|
jmp iec_turnaround_to_listen
|
||||||
|
*
|
||||||
|
rts
|
||||||
Reference in new issue
Block a user