From 6d521967e5c47c16dd13321236f4993527c69d4a Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 12 Jul 2019 23:09:27 +0200 Subject: [PATCH] implemented CIOUT routine --- c64/basic/,aliases.s | 2 ++ c64/kernal/,aliases.s | 2 ++ c64/kernal/ciout.s | 28 ++++++++++++++++++++++++++++ c64/kernal/unlsn.s | 15 ++++++++++++++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 8a4733fc..a9898755 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -57,6 +57,8 @@ ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 .alias BUCKYSTATUS $91 .alias load_or_verify_flag $93 + .alias C3PO $94 ; flag - is BSOUR content valid + .alias BSOUR $95 ; serial bus buffered output byte .alias current_file_num $98 .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 3f6150db..e5616ae3 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -8,6 +8,8 @@ ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 .alias BUCKYSTATUS $91 .alias kernal_load_or_verify_flag $93 + .alias C3PO $94 ; flag - is BSOUR content valid + .alias BSOUR $95 ; serial bus buffered output byte .alias current_file_num $98 .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 diff --git a/c64/kernal/ciout.s b/c64/kernal/ciout.s index e389806a..cc6f666a 100644 --- a/c64/kernal/ciout.s +++ b/c64/kernal/ciout.s @@ -1,3 +1,31 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide ciout: + + ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 224 + + pha + lda C3PO + bne ciout_send_byte + + ;; Nothing to send - set buffer as valid, store byte there + inc + sta C3PO + + ;; Clear carry flag to indicate success + clc + +ciout_store_in_buffer: + + ;; Store in the buffer data to be sent next, return + pla + sta BSOUR rts + +ciout_send_byte: + + ;; Send previous data + lda BSOUR + clc ; don't send with EOI + jsr iec_tx_byte + jmp ciout_store_in_buffer + diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 24180aa5..8dc84fcf 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -2,7 +2,20 @@ unlsn: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 + ;; 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 + + lda BSOUR + sec ; send it with EOI + jsr iec_tx_byte ; XXX what about the status of this operation? + ;; Mark the buffer as invalid + lda #$00 + sta C3PO +* + ;; Buffer empty send the command lda #$3F jmp iec_tx_command +