byte decoding for normal tape finished

This commit is contained in:
FeralChild64 committed 2019-12-18 21:34:25 +01:00
1 parent c81b04d923
commit 3ac17185f1
3 files changed
+50 -22

No files matched your search

-3
View File
@@ -50,9 +50,6 @@ load_tape_normal:
ldx #%00010001 // start timer, force latch reload
stx CIA2_CRA // $DD0E
// Prepare for sound effects
jsr tape_clean_sid // XXX implement some effects
// Start playing
jsr tape_ask_play
+3 -4
View File
@@ -2,7 +2,7 @@
//
// Tape (turbo) helper routine - bit reading
//
// Returns bit in Zero flag, Carry set means error
// Returns bit in Zero flag, Carry set means error, on 0 bit .A is 0 too
//
@@ -23,7 +23,7 @@ tape_normal_get_bit:
// We have a bit '1'
clc
// Carry flag already clear
lda #$06
// FALLTROUGH
@@ -43,13 +43,12 @@ tape_normal_get_bit_0:
// We have a bit '0'
// Carry flag already clear
clc
lda #$00
beq tape_normal_get_bit_done // branch always
tape_normal_get_bit_error:
sec
rts
+47 -15
View File
@@ -2,7 +2,7 @@
//
// Tape (turbo) helper routine - byte reading
//
// Returns byte in .A
// Returns byte in .A, Carry flag set = error
//
@@ -11,11 +11,13 @@
tape_normal_get_byte:
lda #$0B
sta VIC_EXTCOL
// Init byte checksum and canary bit
lda #$01
sta ROPRTY
lda #%01111111 // canary bit is 0
pha
// First we need a byte marker - (L,M)
!:
jsr tape_normal_get_pulse
cmp #($100 - $95 - $05)
@@ -25,25 +27,55 @@ tape_normal_get_byte:
// Now fetch individual bits
// XXX finish this
tape_normal_get_byte_loop:
jsr tape_normal_get_bit
bcs tape_normal_get_byte_error
beq !+
// Handle parity bit
lda #$01
eor ROPRTY
sta ROPRTY
sec
!: // moved bit state from Zero to Carry flag
pla
ror // put the bit in
pha
bcs tape_normal_get_byte_loop // loop if no canary bit reached
// Byte retrieved (on stack), now we need to validate the checksum
jsr tape_normal_get_bit
jsr tape_normal_get_bit
jsr tape_normal_get_bit
jsr tape_normal_get_bit
jsr tape_normal_get_bit
jsr tape_normal_get_bit
jsr tape_normal_get_bit
bcs tape_normal_get_byte_error
beq !+
lda #$01
!:
eor ROPRTY
beq tape_normal_get_byte_error
// Checksum validated succesfully
ldx #$0B
// Carry already clear
// FALLTROUGH
tape_normal_get_byte_done:
pla
stx VIC_EXTCOL
rts
tape_normal_get_byte_error:
ldx #$09
sec // make sure Carry is set to indicate error
bcs tape_normal_get_byte_done
#endif