Added calibration specific error codes
This commit is contained in:
@@ -4649,7 +4649,7 @@ CLOADB: inc hl ; skip #
|
|||||||
; hl contains block, check block type
|
; hl contains block, check block type
|
||||||
ld a,(hl)
|
ld a,(hl)
|
||||||
cp 1 ; first block needs to be a header
|
cp 1 ; first block needs to be a header
|
||||||
jr nz,CLNOHDR ; First block is not a header
|
jp nz,CLNOHDR ; First block is not a header
|
||||||
; first block is a header, get nr of blocks
|
; first block is a header, get nr of blocks
|
||||||
inc hl
|
inc hl
|
||||||
ld de,(hl)
|
ld de,(hl)
|
||||||
@@ -4706,7 +4706,9 @@ CLREADBLOCK:
|
|||||||
jr nc,2$
|
jr nc,2$
|
||||||
; error, make sure it is silent again
|
; error, make sure it is silent again
|
||||||
push af
|
push af
|
||||||
|
push bc ; save specific error code
|
||||||
call BIOS_CAS_WAIT_SILENCE
|
call BIOS_CAS_WAIT_SILENCE
|
||||||
|
pop bc
|
||||||
pop af
|
pop af
|
||||||
jr CLERR
|
jr CLERR
|
||||||
1$: push hl ; save hl
|
1$: push hl ; save hl
|
||||||
@@ -4727,7 +4729,10 @@ CLERR: cp 1
|
|||||||
cp 4
|
cp 4
|
||||||
jr z,CLECHS
|
jr z,CLECHS
|
||||||
jp FCERR ; Unknown error
|
jp FCERR ; Unknown error
|
||||||
CLECAL: ld hl, CLECALMSG
|
CLECAL: ld h,0
|
||||||
|
ld l,b ; get specific error code
|
||||||
|
call PRNTHL ; print specific error code
|
||||||
|
ld hl, CLECALMSG
|
||||||
jr CLEPRINT
|
jr CLEPRINT
|
||||||
CLESYN: ld hl, CLESYNMSG
|
CLESYN: ld hl, CLESYNMSG
|
||||||
jr CLEPRINT
|
jr CLEPRINT
|
||||||
@@ -4745,7 +4750,7 @@ CLEPRINT:
|
|||||||
jp FCERR
|
jp FCERR
|
||||||
|
|
||||||
CLSTARTMSG: .db "Play tape...",0ah,0dh,00h
|
CLSTARTMSG: .db "Play tape...",0ah,0dh,00h
|
||||||
CLECALMSG: .db "Calibration failed",0ah,0dh,00h
|
CLECALMSG: .db " - Calibration failed",0ah,0dh,00h
|
||||||
CLESYNMSG: .db "Synchronization failed",0ah,0dh,00h
|
CLESYNMSG: .db "Synchronization failed",0ah,0dh,00h
|
||||||
CLEREDMSG: .db "Read failed",0ah,0dh,00h
|
CLEREDMSG: .db "Read failed",0ah,0dh,00h
|
||||||
CLECHSMSG: .db "Checksum error",0ah,0dh,00h
|
CLECHSMSG: .db "Checksum error",0ah,0dh,00h
|
||||||
|
|||||||
@@ -13,6 +13,18 @@ LONG_MIN .equ TAPE_WORKSPACE + 004h ; byte
|
|||||||
LONG_MAX .equ TAPE_WORKSPACE + 005h ; byte
|
LONG_MAX .equ TAPE_WORKSPACE + 005h ; byte
|
||||||
BLOCK_BUFFER .equ TAPE_WORKSPACE + 006h ; BLOCK_SIZE
|
BLOCK_BUFFER .equ TAPE_WORKSPACE + 006h ; BLOCK_SIZE
|
||||||
|
|
||||||
|
; -------------------------------------------------------
|
||||||
|
; Error return callback macro
|
||||||
|
; creates a simple macro which puts a return code in a
|
||||||
|
; and sets the carry flag
|
||||||
|
; -------------------------------------------------------
|
||||||
|
create_error_return MACRO &name, &code
|
||||||
|
&name:
|
||||||
|
ld a,&code
|
||||||
|
scf
|
||||||
|
ret
|
||||||
|
ENDM
|
||||||
|
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
; Measure edge-to-edge pulse
|
; Measure edge-to-edge pulse
|
||||||
; needs d (comparator state)
|
; needs d (comparator state)
|
||||||
@@ -133,7 +145,7 @@ make_window:
|
|||||||
; Calibration
|
; Calibration
|
||||||
; d needs to be kept from now on
|
; d needs to be kept from now on
|
||||||
; uses a,b,c,e,h,l
|
; uses a,b,c,e,h,l
|
||||||
; carry is error
|
; carry is error, a contains error code
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
calibrate:
|
calibrate:
|
||||||
ld a,(TAPE_PORT) ; get current state
|
ld a,(TAPE_PORT) ; get current state
|
||||||
@@ -155,7 +167,7 @@ calibrate:
|
|||||||
; edge found
|
; edge found
|
||||||
; get short leader timing
|
; get short leader timing
|
||||||
call average8
|
call average8
|
||||||
jr c,cal_err ; timeout
|
jr c,cal_err_short_leader_average
|
||||||
ld (SHORT_AVG),a
|
ld (SHORT_AVG),a
|
||||||
call make_window
|
call make_window
|
||||||
ld a,b
|
ld a,b
|
||||||
@@ -175,9 +187,9 @@ calibrate:
|
|||||||
; is ignored
|
; is ignored
|
||||||
4$:
|
4$:
|
||||||
call sample_pulse
|
call sample_pulse
|
||||||
jr c,cal_err
|
jr c,cal_err_wait_for_long
|
||||||
call sample_pulse
|
call sample_pulse
|
||||||
jr c,cal_err
|
jr c,cal_err_wait_for_long
|
||||||
ld a,b
|
ld a,b
|
||||||
; try again if its a short pulse
|
; try again if its a short pulse
|
||||||
cp c
|
cp c
|
||||||
@@ -187,7 +199,7 @@ calibrate:
|
|||||||
jr nz,4$ ; repeat this 4 times
|
jr nz,4$ ; repeat this 4 times
|
||||||
; long leader found
|
; long leader found
|
||||||
call average8
|
call average8
|
||||||
jr c,cal_err ; timeout
|
jr c,cal_err_long_leader_average
|
||||||
ld (LONG_AVG),a
|
ld (LONG_AVG),a
|
||||||
call make_window
|
call make_window
|
||||||
ld a,b
|
ld a,b
|
||||||
@@ -202,7 +214,7 @@ calibrate:
|
|||||||
ld c,a ; c = 1.5*short
|
ld c,a ; c = 1.5*short
|
||||||
ld a,(LONG_AVG)
|
ld a,(LONG_AVG)
|
||||||
cp c
|
cp c
|
||||||
jr c,cal_err
|
jr c,cal_err_sanity_check
|
||||||
; Find the marker. marker is 2*long
|
; Find the marker. marker is 2*long
|
||||||
; threshold is 1.5*long
|
; threshold is 1.5*long
|
||||||
ld a,(LONG_AVG)
|
ld a,(LONG_AVG)
|
||||||
@@ -215,7 +227,7 @@ calibrate:
|
|||||||
ld e,0
|
ld e,0
|
||||||
6$:
|
6$:
|
||||||
call measure_pulse
|
call measure_pulse
|
||||||
jr c,cal_err ; timeout
|
jr c,cal_err_marker_measure
|
||||||
ld a,b
|
ld a,b
|
||||||
cp c
|
cp c
|
||||||
jr c,5$ ; not a marker
|
jr c,5$ ; not a marker
|
||||||
@@ -227,15 +239,21 @@ calibrate:
|
|||||||
; we are at the beginning of the first data pulse
|
; we are at the beginning of the first data pulse
|
||||||
; next 8 bytes is the training byte 0x55
|
; next 8 bytes is the training byte 0x55
|
||||||
call read_byte
|
call read_byte
|
||||||
jr c,cal_err
|
jr c,cal_err_training_read
|
||||||
cp a,055h
|
cp a,055h
|
||||||
jr nz,cal_err ; training byte not 0x55
|
jr nz,cal_err_training_incorrect
|
||||||
; calibration complete
|
; calibration complete
|
||||||
or a ; clear carry
|
or a ; clear carry
|
||||||
ret
|
ret
|
||||||
cal_err:
|
|
||||||
scf
|
create_error_return cal_err, 000h
|
||||||
ret
|
create_error_return cal_err_short_leader_average, 001h
|
||||||
|
create_error_return cal_err_wait_for_long, 002h
|
||||||
|
create_error_return cal_err_long_leader_average, 003h
|
||||||
|
create_error_return cal_err_sanity_check, 004h
|
||||||
|
create_error_return cal_err_marker_measure, 005h
|
||||||
|
create_error_return cal_err_training_read, 006h
|
||||||
|
create_error_return cal_err_training_incorrect, 007h
|
||||||
|
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
; Read a single bit
|
; Read a single bit
|
||||||
@@ -351,7 +369,7 @@ read_sync:
|
|||||||
; Read a block into BLOCK_BUFFER
|
; Read a block into BLOCK_BUFFER
|
||||||
; needs d (comparator state)
|
; needs d (comparator state)
|
||||||
; uses b,c,d,e,h,l
|
; uses b,c,d,e,h,l
|
||||||
; returns error code in a
|
; returns error code in a, specific error code in b
|
||||||
; returns start of block in hl
|
; returns start of block in hl
|
||||||
; carry is fail
|
; carry is fail
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
@@ -364,6 +382,7 @@ read_block:
|
|||||||
; calibrate reader
|
; calibrate reader
|
||||||
call calibrate
|
call calibrate
|
||||||
jr nc,1$ ; if no error jump
|
jr nc,1$ ; if no error jump
|
||||||
|
ld b,a
|
||||||
ld a,BLOCK_ERROR_CALIBRATION
|
ld a,BLOCK_ERROR_CALIBRATION
|
||||||
scf
|
scf
|
||||||
jr 101$
|
jr 101$
|
||||||
|
|||||||
Reference in New Issue
Block a user