added proper buffer handling to several IEC commands

This commit is contained in:
FeralChild64 committed 2019-07-25 17:07:33 +02:00
1 parent fea097e795
commit 504f0ffb81
10 files changed
+67 -34

No files matched your search

+1 -5
View File
@@ -25,11 +25,7 @@ close:
;; IEC device
;; 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
jsr iec_tx_flush ; make sure no byte is awaiting
*
lda SAT, y ; get secondary address
ora $E0 ; CLOSE command
+1 -1
View File
@@ -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
+1
View File
@@ -5,6 +5,7 @@
;; 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:
+15
View File
@@ -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
View File
@@ -5,6 +5,7 @@
;; - [RG64] C64 Programmer's Reference Guide - page 285
;; - [CM64] Compute's Mapping the Commodore 64 - page 223
;; - 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
;;
@@ -12,10 +13,17 @@
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
bcs kernalerror_DEVICE_NOT_FOUND
;; Encode and execute the command
ora #$20
sta BSOUR
jmp iec_tx_command
jmp common_talk_listen
+3 -6
View File
@@ -18,9 +18,6 @@ second:
bcs kernalerror_FILE_NOT_INPUT
ora #$60
sta BSOUR
jsr iec_tx_command
bcs + ; branch if error
jmp iec_tx_command_finalize
*
rts
jmp common_unlsn_second
+11 -1
View File
@@ -5,6 +5,7 @@
;; - [RG64] C64 Programmer's Reference Guide - page 301/302
;; - [CM64] Compute's Mapping the Commodore 64 - page 223
;; - 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
;;
@@ -12,10 +13,19 @@
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
bcs kernalerror_DEVICE_NOT_FOUND
;; Encode and execute the command
ora #$40
common_talk_listen: ; common part of TALK and LISTEN
sta BSOUR
jmp iec_tx_command
+3 -10
View File
@@ -18,15 +18,8 @@ tksa:
bcs kernalerror_FILE_NOT_INPUT
ora #$F0
sta BSOUR
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
jmp common_untlk_tksa
+9 -8
View File
@@ -5,6 +5,7 @@
;; - [RG64] C64 Programmer's Reference Guide - page 303
;; - [CM64] Compute's Mapping the Commodore 64 - page 224
;; - 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
;;
@@ -12,19 +13,19 @@
unlsn:
;; This routine is documented in 'Compute's Mapping the Commodore 64', page 224
;; 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
*
;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
jsr iec_tx_flush
;; Buffer empty, send the command
lda #$3F
common_unlsn_second: ; common part of UNSLS and SECOND
sta BSOUR
jsr iec_tx_command
bcs + ; branch if error
jmp iec_tx_command_finalize
*
rts
+12
View File
@@ -5,6 +5,7 @@
;; - [RG64] C64 Programmer's Reference Guide - page 304
;; - [CM64] Compute's Mapping the Commodore 64 - page 224
;; - 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
;;
@@ -12,10 +13,21 @@
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
common_untlk_tksa: ; common part of UNTLK and TKSA
sta BSOUR
jsr iec_tx_command
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
*
rts