From 86e8bcbe7fccc59cd6d5542a5275828563aa8cf7 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 6 Nov 2019 17:29:27 +0100 Subject: [PATCH] more work on SAVE routine --- ...iec_close_load_save.s => iec_close_load.s} | 12 +------ c64/kernal/iec/iec_tx_byte.s | 2 +- c64/kernal/iec/save_iec.s | 33 ++++++++++++++++--- 3 files changed, 31 insertions(+), 16 deletions(-) rename c64/kernal/iec/{iec_close_load_save.s => iec_close_load.s} (69%) diff --git a/c64/kernal/iec/iec_close_load_save.s b/c64/kernal/iec/iec_close_load.s similarity index 69% rename from c64/kernal/iec/iec_close_load_save.s rename to c64/kernal/iec/iec_close_load.s index 445379e0..5cc8e76a 100644 --- a/c64/kernal/iec/iec_close_load_save.s +++ b/c64/kernal/iec/iec_close_load.s @@ -13,7 +13,7 @@ iec_close_load: // Command drive to stop talking before closing the file jsr UNTLK -!: + txa jsr LISTEN @@ -28,14 +28,4 @@ iec_close_load: rts -iec_close_save: - - tax - - // Command drive to stop listening before closing the file - jsr UNLSN - - bne !- // branch alwayys - - #endif // CONFIG_IEC diff --git a/c64/kernal/iec/iec_tx_byte.s b/c64/kernal/iec/iec_tx_byte.s index 060d5afc..a58a1689 100644 --- a/c64/kernal/iec/iec_tx_byte.s +++ b/c64/kernal/iec/iec_tx_byte.s @@ -28,7 +28,7 @@ iec_tx_common: // Timing is critical here - execute on disabled IRQs // The best practice would be to do PHP first, but it seems this is not // what the original ROM does; furthermore, pushing additional bytes to - // stack can wreck autostart softwaree loading at $0100 + // stack can wreck autostart software loading at $0100 sei // Wait till all receivers are ready, they should all release DATA diff --git a/c64/kernal/iec/save_iec.s b/c64/kernal/iec/save_iec.s index e565f713..d77fac45 100644 --- a/c64/kernal/iec/save_iec.s +++ b/c64/kernal/iec/save_iec.s @@ -5,6 +5,8 @@ // XXX this is untested! +// test EAL/STAL - LOAD (tape, disk), SAVE - Open ROMs vs hybrid vs original + #if CONFIG_IEC @@ -46,6 +48,17 @@ save_iec: // XXX finish the implementation jsr iec_tx_command bcs save_iec_error + // Save start address XXX optimize this + lda STAL+0 + sta TBTCNT + clc + jsr iec_tx_byte + + lda STAL+1 + sta TBTCNT + clc + jsr iec_tx_byte + ldy #$00 iec_save_loop: @@ -76,13 +89,25 @@ iec_save_loop_end: // Send last byte sta TBTCNT - sec // mark end of stream + clc // XXX really? jsr iec_tx_byte - - // Close file on drive + // Close file on drive // XXX does not work properly lda FA - jsr iec_close_save + jsr UNLSN + + lda FA + jsr LISTEN + + lda #$E1 // CLOSE command + sta TBTCNT + jsr iec_tx_command + jsr iec_tx_command_finalize + + // Tell drive to unlisten + lda FA + jsr UNLSN + // Return success clc