added proper buffer handling to several IEC commands
This commit is contained in:
1 parent
fea097e795
commit
504f0ffb81
10 files changed
+67
-34
No files matched your search
+1
-5
@@ -25,11 +25,7 @@ close:
|
|||||||
|
|
||||||
;; IEC device
|
;; IEC device
|
||||||
|
|
||||||
;; First check whether we have something to be sent in the buffer
|
jsr iec_tx_flush ; make sure no byte is awaiting
|
||||||
lda C3PO
|
|
||||||
beq +
|
|
||||||
sec ; send it with EOI
|
|
||||||
jsr iec_tx_byte ; send the command regardless of the status
|
|
||||||
*
|
*
|
||||||
lda SAT, y ; get secondary address
|
lda SAT, y ; get secondary address
|
||||||
ora $E0 ; CLOSE command
|
ora $E0 ; CLOSE command
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
;; Routine to finalize these IEC commands which do not end in turnaround
|
;; Routine to finalize some IEC commands - which do not end in turnaround and are not followed by others
|
||||||
;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
;; Expects byte to send in BSOUR; Carry flag set = signal EOI
|
;; Expects byte to send in BSOUR; Carry flag set = signal EOI
|
||||||
|
|
||||||
|
;; XXX is it OK to use BSOUR for data exchange? Maybe there is a better way?
|
||||||
|
|
||||||
iec_tx_common:
|
iec_tx_common:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
;; Flush the IEC output buffer (if not empty) - send byte with EOI
|
||||||
|
;;
|
||||||
|
;; Preserves .X, .Y and .A registers
|
||||||
|
|
||||||
|
iec_tx_flush:
|
||||||
|
|
||||||
|
pha
|
||||||
|
lda C3PO
|
||||||
|
beq +
|
||||||
|
sec ; send it with EOI
|
||||||
|
jsr iec_tx_byte ; send the command regardless of the status
|
||||||
|
*
|
||||||
|
pla
|
||||||
|
rts
|
||||||
+11
-3
@@ -5,6 +5,7 @@
|
|||||||
;; - [RG64] C64 Programmer's Reference Guide - page 285
|
;; - [RG64] C64 Programmer's Reference Guide - page 285
|
||||||
;; - [CM64] Compute's Mapping the Commodore 64 - page 223
|
;; - [CM64] Compute's Mapping the Commodore 64 - page 223
|
||||||
;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
||||||
|
;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||||
;;
|
;;
|
||||||
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
||||||
;;
|
;;
|
||||||
@@ -12,10 +13,17 @@
|
|||||||
|
|
||||||
listen:
|
listen:
|
||||||
|
|
||||||
;; First check whether device number is correct
|
;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
|
jsr iec_tx_flush
|
||||||
|
|
||||||
|
;; Check whether device number is correct
|
||||||
jsr iec_devnum_check
|
jsr iec_devnum_check
|
||||||
bcs kernalerror_DEVICE_NOT_FOUND
|
bcs kernalerror_DEVICE_NOT_FOUND
|
||||||
|
|
||||||
;; Encode and execute the command
|
;; Encode and execute the command
|
||||||
ora #$20
|
ora #$20
|
||||||
sta BSOUR
|
|
||||||
jmp iec_tx_command
|
jmp common_talk_listen
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+3
-6
@@ -18,9 +18,6 @@ second:
|
|||||||
bcs kernalerror_FILE_NOT_INPUT
|
bcs kernalerror_FILE_NOT_INPUT
|
||||||
|
|
||||||
ora #$60
|
ora #$60
|
||||||
sta BSOUR
|
|
||||||
jsr iec_tx_command
|
jmp common_unlsn_second
|
||||||
bcs + ; branch if error
|
|
||||||
jmp iec_tx_command_finalize
|
|
||||||
*
|
|
||||||
rts
|
|
||||||
+11
-1
@@ -5,6 +5,7 @@
|
|||||||
;; - [RG64] C64 Programmer's Reference Guide - page 301/302
|
;; - [RG64] C64 Programmer's Reference Guide - page 301/302
|
||||||
;; - [CM64] Compute's Mapping the Commodore 64 - page 223
|
;; - [CM64] Compute's Mapping the Commodore 64 - page 223
|
||||||
;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
||||||
|
;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||||
;;
|
;;
|
||||||
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
||||||
;;
|
;;
|
||||||
@@ -12,10 +13,19 @@
|
|||||||
|
|
||||||
talk:
|
talk:
|
||||||
|
|
||||||
;; First check whether device number is correct
|
;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
|
jsr iec_tx_flush
|
||||||
|
|
||||||
|
;; Check whether device number is correct
|
||||||
jsr iec_devnum_check
|
jsr iec_devnum_check
|
||||||
bcs kernalerror_DEVICE_NOT_FOUND
|
bcs kernalerror_DEVICE_NOT_FOUND
|
||||||
|
|
||||||
;; Encode and execute the command
|
;; Encode and execute the command
|
||||||
ora #$40
|
ora #$40
|
||||||
|
|
||||||
|
common_talk_listen: ; common part of TALK and LISTEN
|
||||||
|
|
||||||
sta BSOUR
|
sta BSOUR
|
||||||
jmp iec_tx_command
|
jmp iec_tx_command
|
||||||
|
|
||||||
|
|
||||||
+3
-10
@@ -18,15 +18,8 @@ tksa:
|
|||||||
bcs kernalerror_FILE_NOT_INPUT
|
bcs kernalerror_FILE_NOT_INPUT
|
||||||
|
|
||||||
ora #$F0
|
ora #$F0
|
||||||
sta BSOUR
|
|
||||||
jsr iec_tx_command
|
jmp common_untlk_tksa
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
+9
-8
@@ -5,6 +5,7 @@
|
|||||||
;; - [RG64] C64 Programmer's Reference Guide - page 303
|
;; - [RG64] C64 Programmer's Reference Guide - page 303
|
||||||
;; - [CM64] Compute's Mapping the Commodore 64 - page 224
|
;; - [CM64] Compute's Mapping the Commodore 64 - page 224
|
||||||
;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc
|
;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc
|
||||||
|
;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||||
;;
|
;;
|
||||||
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
||||||
;;
|
;;
|
||||||
@@ -12,19 +13,19 @@
|
|||||||
|
|
||||||
unlsn:
|
unlsn:
|
||||||
|
|
||||||
;; This routine is documented in 'Compute's Mapping the Commodore 64', page 224
|
;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
|
jsr iec_tx_flush
|
||||||
;; First check whether we have something to be sent in the buffer
|
|
||||||
lda C3PO
|
|
||||||
beq +
|
|
||||||
sec ; send it with EOI
|
|
||||||
jsr iec_tx_byte ; send the command regardless of the status
|
|
||||||
*
|
|
||||||
;; Buffer empty, send the command
|
;; Buffer empty, send the command
|
||||||
lda #$3F
|
lda #$3F
|
||||||
|
|
||||||
|
common_unlsn_second: ; common part of UNSLS and SECOND
|
||||||
|
|
||||||
sta BSOUR
|
sta BSOUR
|
||||||
jsr iec_tx_command
|
jsr iec_tx_command
|
||||||
bcs + ; branch if error
|
bcs + ; branch if error
|
||||||
jmp iec_tx_command_finalize
|
jmp iec_tx_command_finalize
|
||||||
*
|
*
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
;; - [RG64] C64 Programmer's Reference Guide - page 304
|
;; - [RG64] C64 Programmer's Reference Guide - page 304
|
||||||
;; - [CM64] Compute's Mapping the Commodore 64 - page 224
|
;; - [CM64] Compute's Mapping the Commodore 64 - page 224
|
||||||
;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc
|
;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc
|
||||||
|
;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||||
;;
|
;;
|
||||||
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
;; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
||||||
;;
|
;;
|
||||||
@@ -12,10 +13,21 @@
|
|||||||
|
|
||||||
untlk:
|
untlk:
|
||||||
|
|
||||||
|
;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
|
jsr iec_tx_flush
|
||||||
|
|
||||||
|
;; Buffer empty, send the command
|
||||||
lda #$5F
|
lda #$5F
|
||||||
|
|
||||||
|
common_untlk_tksa: ; common part of UNTLK and TKSA
|
||||||
|
|
||||||
sta BSOUR
|
sta BSOUR
|
||||||
jsr iec_tx_command
|
jsr iec_tx_command
|
||||||
bcs + ; branch if error
|
bcs + ; branch if error
|
||||||
|
;; XXX - for TKSA, 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
|
jmp iec_turnaround_to_listen
|
||||||
*
|
*
|
||||||
rts
|
rts
|
||||||
Reference in new issue
Block a user