diff --git a/c64/kernal/iec/load_iec.s b/c64/kernal/iec/load_iec.s index 0e91c125..56787e90 100644 --- a/c64/kernal/iec/load_iec.s +++ b/c64/kernal/iec/load_iec.s @@ -69,20 +69,23 @@ load_iec: jsr iec_turnaround_to_listen bcs load_iec_error - // Get load address and store it if secondary address is zero + // Get load address + jsr iec_rx_byte bcs load_iec_file_not_found - - ldx SA - beq !+ - sta STAL+0 -!: + sta EAL+0 jsr iec_rx_byte bcs load_iec_file_not_found + sta EAL+1 - ldx SA - beq !+ - sta STAL+1 + // If secondary address is 0, override EAL with STAL + + lda SA + bne !+ + lda STAL+0 + sta EAL+0 + lda STAL+1 + sta EAL+1 !: // Display start address jsr lvs_display_loading_verifying @@ -102,7 +105,7 @@ iec_load_loop: // Handle STOP key; it is probably an overkill to do it // with every byte, once per 32 bytes should be enough - lda STAL + lda EAL and #$1F bne !+ phx_trash_a diff --git a/c64/kernal/iec/save_iec.s b/c64/kernal/iec/save_iec.s index 5c1d3e81..e2fffbc8 100644 --- a/c64/kernal/iec/save_iec.s +++ b/c64/kernal/iec/save_iec.s @@ -5,7 +5,7 @@ // XXX this is untested! -// test EAL/STAL - LOAD (tape, disk), SAVE - Open ROMs vs hybrid vs original +// also test STAL/EAL - Open ROMs vs hybrid vs original diff --git a/c64/kernal/iostack/load_save_common.s b/c64/kernal/iostack/load_save_common.s index e852f624..b139d849 100644 --- a/c64/kernal/iostack/load_save_common.s +++ b/c64/kernal/iostack/load_save_common.s @@ -22,7 +22,7 @@ lvs_handle_byte_load_verify: ldx #$33 stx $01 ldy #0 - sta (STAL),y + sta (EAL),y ldx #$37 stx $01 plp @@ -30,7 +30,7 @@ lvs_handle_byte_load_verify: #else ldy #0 - sta (STAL),y + sta (EAL),y #endif @@ -55,7 +55,7 @@ lvs_handle_byte_verify: ldx #$33 stx $01 ldy #0 - lda (STAL),y + lda (EAL),y ldx #$37 stx $01 plp @@ -66,7 +66,7 @@ lvs_handle_byte_verify: #else ldy #0 - cmp (STAL),y + cmp (EAL),y #endif @@ -79,9 +79,9 @@ lvs_handle_byte_verify: lvs_advance_pointer: // Advance pointer - inc STAL+0 + inc EAL+0 bne !+ - inc STAL+1 + inc EAL+1 !: rts @@ -135,9 +135,9 @@ lvs_display_start_addr: !: jsr print_kernal_message - lda STAL+1 + lda EAL+1 jsr print_hex_byte - lda STAL+0 + lda EAL+0 jmp print_hex_byte lvs_display_done: @@ -181,8 +181,8 @@ lvs_return_last_address: // Return last address - Compute's Mapping the 64 says without the '+1', // checked (short test program) on original ROMs that this is really the case - ldx STAL+0 - ldy STAL+1 + ldx EAL+0 + ldy EAL+1 // FALLTHROUGH lvs_success_end: diff --git a/c64/kernal/tape/load_tape_turbo.s b/c64/kernal/tape/load_tape_turbo.s index 6b9ef138..4f50c732 100644 --- a/c64/kernal/tape/load_tape_turbo.s +++ b/c64/kernal/tape/load_tape_turbo.s @@ -61,36 +61,45 @@ load_tape_turbo_header_loop: // this strange loop puts metadata after load_tape_turbo_payload: + // Initial checksum value + + lda #$00 + sta PRTY + // Read file payload jsr tape_turbo_sync_payload - ldy #$00 - sty PRTY // initial checksum value - // FALLTROUGH load_tape_turbo_loop: jsr tape_turbo_get_byte - sta (STAL),y + sta (MEMUSS),y eor PRTY // handle checksum sta PRTY - jsr lvs_advance_pointer - - lda STAL+1 + // Advance MEMUSS (see Mapping the C64, page 36) + inc MEMUSS+0 + bne !+ + inc MEMUSS+1 +!: + lda MEMUSS+1 cmp EAL+1 bne load_tape_turbo_loop - lda STAL+0 + lda MEMUSS+0 cmp EAL+0 bne load_tape_turbo_loop - // Verify the checksum + // Get the checksum jsr tape_turbo_get_byte - cmp PRTY + tax + + // Verify the checksum + + cpx PRTY beq_far tape_load_success jmp tape_load_error diff --git a/c64/kernal/tape/tape_common.s b/c64/kernal/tape/tape_common.s index 13d2415b..2acd0110 100644 --- a/c64/kernal/tape/tape_common.s +++ b/c64/kernal/tape/tape_common.s @@ -208,9 +208,29 @@ tape_handle_header: adc STAL+1 sta EAL+1 !: - // Print LOADING + // Setup MEMUSS (see Mapping the C64, page 36) - jsr lvs_display_loading_verifying + lda STAL+0 + sta MEMUSS+0 + lda STAL+1 + sta MEMUSS+1 + + // Print LOADING and start address + + lda MSGFLG + bpl tape_handle_header_displayed + + ldx #__MSG_KERNAL_LOADING + jsr print_kernal_message + ldx #__MSG_KERNAL_FROM_HEX + jsr print_kernal_message + + lda STAL+1 + jsr print_hex_byte + lda STAL+0 + jsr print_hex_byte + +tape_handle_header_displayed: // Load the file