From d124349e5036d6fabb21ad89444c7e1aa481f8f6 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sat, 4 May 2019 23:05:23 +0930 Subject: [PATCH] handle EOI and generally get closer to a working LOAD routine --- c64/kernal/iec_rx_byte.s | 6 ++- c64/kernal/load.s | 94 ++++++---------------------------------- 2 files changed, 18 insertions(+), 82 deletions(-) diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 78dc715b..599e254d 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -31,8 +31,10 @@ iec_rx_clk_wait: dex bpl iec_rx_clk_wait - inc $0632 - inc $d020 + ;; Remember EOI condition + lda IOSTATUS + ora #$40 + sta IOSTATUS ;; EOI timeout: So pulse DATA line for 60 usec jsr iec_assert_data diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 66b21f2c..fcdc8d7f 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -15,66 +15,6 @@ load: ;; also p16 tells us this routine doesn't mess with the file table in the C64, ;; only in the drive. - ;; Now command device to listen (p16) - jsr iec_assert_atn - lda #$28 - jsr iec_tx_byte - bcs load_error - - inc $0609 - - lda #$6f ; open channel / data (p3) , required according to p13 - jsr iec_tx_byte - bcs load_error - jsr iec_release_atn - - - ;; Send invalid "Q" command to drive as test - lda #$51 - jsr iec_tx_byte - bcs load_error - lda #$0d - jsr iec_tx_byte - bcs load_error - - inc $060a - - ;; Now command device to talk (p16) - jsr iec_assert_atn - lda #$48 - jsr iec_tx_byte - bcs load_error - - lda #$6f ; open channel / data (p3) , required according to p13 - jsr iec_tx_byte - bcs load_error - jsr iec_release_atn - - ;; We are currently talker, so do the IEC turn around so that we - ;; are the listener (p16) - jsr iec_turnaround_to_listen - bcs load_error - - inc $060b - - jsr printf - .byte "READING DATA...",$0d,0 - -read_loop: -* jsr iec_rx_byte - php - ;; Write read data to screen for now - inc $ff - ldx $ff - sta $1000,x - plp - bcs load_done - bcc - - jmp read_loop - - - - ;; Begin sending under attention jsr iec_assert_atn @@ -108,32 +48,25 @@ read_loop: bcs load_error jsr iec_release_atn - inc $0608 - ;; Now command device to talk (p16) jsr iec_assert_atn lda #$48 jsr iec_tx_byte bcs load_error - inc $0609 - lda #$60 ; open channel / data (p3) , required according to p13 jsr iec_tx_byte bcs load_error jsr iec_release_atn - inc $060a - ;; We are currently talker, so do the IEC turn around so that we ;; are the listener (p16) + ;; An error here means FILE NOT FOUND ? jsr iec_turnaround_to_listen bcs load_error - inc $060b - jsr printf - .byte "READING DATA...",$0d,0 + .byte "LOADING",$0d,0 ;; We are now ready to receive bytes * jsr iec_rx_byte @@ -143,14 +76,18 @@ read_loop: ldx $ff sta $0400,x plp - bcs load_done - bcc - + bcs load_error + + ;; Check for EOI -- if so, read one last byte + lda IOSTATUS + and #$40 + beq - load_done: - ;; Close file on drive + jsr printf + .byte "LOADED",$0d,0 - inc $060c - + ;; Close file on drive ;; Command drive to listen and to close the file jsr iec_assert_atn @@ -160,22 +97,19 @@ load_done: jsr iec_tx_byte jsr iec_release_atn - inc $060d - ;; Tell drive to unlisten jsr iec_assert_atn lda #$3f jsr iec_tx_byte jsr iec_release_atn - inc $060e - ;; FALL THROUGH + clc load_error: - inc $060f - + ;; XXX - Indicate KERNAL (not BASIC) LOAD error condtion + ;; Re-enable interrupts and return cli ;; (iec_tx_byte will have set/cleared C flag and put result code