Files
open-roms/c64/kernal/tape/tape_normal_get_data_1.s
T
FeralChild64 d489e7bf41 tape routines can now be placed in Mega65 extra ROM space
commit 2f27e29758da1f1ec965588c0712125051a6f71a
Merge: ba722b1 796b62f
Author: FeralChild64 <you@example.com>
Date:   Tue Jan 28 17:34:53 2020 +0100

    Merge branch 'master' into tape_redirect

commit ba722b17e627af7dd067932688de0a3d86423e37
Author: FeralChild64 <you@example.com>
Date:   Tue Jan 28 17:28:19 2020 +0100

    finished Mega65 variant of tape routines

commit 47de685f2e08576504c5e00a5b7cb78498d22e72
Author: FeralChild64 <you@example.com>
Date:   Mon Jan 27 23:06:45 2020 +0100

    compilation fix

commit c3641acec049a7a6b53c35795b1f9e2df212cec2
Author: FeralChild64 <you@example.com>
Date:   Mon Jan 27 22:53:30 2020 +0100

    dependencies fix

commit dfad7a30bde043fa077005624dde1de4b72573b6
Merge: e4b0ec9 e410bc0
Author: FeralChild64 <you@example.com>
Date:   Mon Jan 27 21:25:49 2020 +0100

    Merge branch 'master' into tape_redirect

commit e4b0ec9c85861bde2ce52e0828d3bf895a681e17
Author: FeralChild64 <you@example.com>
Date:   Sat Jan 25 22:25:20 2020 +0100

    initial attempt to move tape code to Mega65 extra ROM
2020-01-28 17:35:42 +01:00

122 lines
2.1 KiB
ArmAsm

// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE
//
// Tape (normal) helper routine - data block (primary) reading
//
// Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too
// .Y not equal to 0 - returns error if data block is longer (length includes checksum)
// XXX improve error handling - do not ignore second copy, handle damaged sync part
#if CONFIG_TAPE_NORMAL
tape_normal_get_data_1:
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html)
// and pointers for error log and correction mechanism
lda #$00
sta RIPRTY
#if !CONFIG_TAPE_NO_ERROR_CORRECTION
sta PTR1
sta PTR2
#endif
// FALLTROUGH
tape_normal_get_data_1_block:
//
// Read the 1st copy of the block
//
// Read sync of the block
ldy #$89
jsr tape_normal_sync
bcs tape_normal_get_data_1_fail
jsr tape_normal_get_marker
tape_normal_get_data_1_loop:
jsr tape_normal_get_byte
bcc tape_normal_get_data_1_loop_byte_OK
#if CONFIG_TAPE_NO_ERROR_CORRECTION
bcs tape_normal_get_data_1_fail
#else
// Problem reading a byte, try to add it to the error log
tsx
cpx #$20 // just to be on a safe side
bcc tape_normal_get_data_1_fail // branch if no more space in error log
ldx PTR1
lda MEMUSS+0
sta STACK, x
inx
lda MEMUSS+1
sta STACK, x
inx
stx PTR1
// Addres added to error log, check if this was a checksum
jsr tape_normal_get_marker
bcc tape_normal_get_data_1_loop_advance
bcs tape_normal_get_data_1_success
#endif
tape_normal_get_data_1_loop_byte_OK:
jsr tape_normal_get_marker
bcc !+
// End of the block
jsr tape_normal_update_checksum
jmp tape_normal_get_data_1_success
!:
// Store byte, calculate checksum
lda INBIT
ldy #$00
#if ROM_LAYOUT_M65
jsr tape_normal_byte_store
#else
sta (MEMUSS), y
#endif
jsr tape_normal_update_checksum
// FALLTROUGH
tape_normal_get_data_1_loop_advance:
// Advance pointer
#if !HAS_OPCODES_65CE02
jsr lvs_advance_MEMUSS
#else
inw MEMUSS+0
#endif
jmp tape_normal_get_data_1_loop
tape_normal_get_data_1_success:
clc
rts
tape_normal_get_data_1_fail:
sec
rts
#endif