diff --git a/c64/kernal/tape/tape_normal_get_data_2.s b/c64/kernal/tape/tape_normal_get_data_2.s index ccbc56fb..85f89fef 100644 --- a/c64/kernal/tape/tape_normal_get_data_2.s +++ b/c64/kernal/tape/tape_normal_get_data_2.s @@ -15,7 +15,7 @@ tape_normal_get_data_2: cmp #$01 rts -#elif DISABLED_DISABLED +#elif XXX_DISABLED tape_normal_get_data_2: @@ -28,7 +28,7 @@ tape_normal_get_data_2: ldy #$09 jsr tape_normal_sync - bcs tape_normal_get_data_2_done // Carry already set, will indicate error + bcs tape_normal_get_data_2_done // Carry already set, will indicate error jsr tape_normal_get_marker // FALLTROUGH @@ -51,27 +51,50 @@ tape_normal_get_data_2_loop: tape_normal_get_data_2_loop_byte_OK: jsr load_cmp_log_MEMUSS - bne tape_normal_get_data_2_loop_advance + beq tape_normal_get_data_2_loop_byte_correct // branch if byte from the log + + jsr tape_normal_get_marker + bcs tape_normal_get_data_2_log_checksum // branch if end of blocks + bcc tape_normal_get_data_2_loop_advance + + +tape_normal_get_data_2_loop_byte_correct: // This is a byte from the log - // XXX store correct byte + jsr tape_normal_get_marker + bcs !+ + lda INBIT + ldy #$00 + sta (MEMUSS), y +!: + jsr tape_normal_update_checksum + + // FALLTROUGH tape_normal_get_data_2_loop_advance: - // XXX finish the implementation + // Advance pointer +#if !HAS_OPCODES_65CE02 + jsr lvs_advance_MEMUSS +#else + inw MEMUSS+0 +#endif - sec - rts + jmp tape_normal_get_data_2_loop -tape_normal_get_data_2_checksum: +tape_normal_get_data_2_log_checksum: + + lda PTR1 + cmp PTR2 + bne tape_normal_get_data_2_done // Carry already set // Validate checksum lda RIPRTY - cmp #$01 // sets Carry if checksum verification fails + cmp #$01 // sets Carry if checksum verification fails // FALLTROUGH @@ -83,8 +106,27 @@ tape_normal_get_data_2_done: load_cmp_log_MEMUSS: - // XXX + lda PTR1 // XXX this comparison can be probably moved somewhere else + cmp PTR2 + bne !+ + lda #$01 // to clear Zero flag + rts +!: + ldx PTR2 + lda STACK+0, x + cmp MEMUSS+0 + bne !+ + + lda STACK+1, x + cmp MEMUSS+1 + bne !+ + + // MEMUSS matches address from the log + + inc PTR2 + inc PTR2 + lda #$00 // to set Zero flag !: rts