forked from mist64/cbmsrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lccread.src
139 lines (139 loc) · 2.8 KB
/
lccread.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
.page 'lcc.read'
;
;
;
;
;
; *read
;
; read in track,sector specified
; in header
;
;
reed cmp #0 ; test if read job
beq read01 ; go test if write
jmp wright
;
read01 jsr dstrt ; find header and start reading data
;
read11 bvc * ; wait for byte
clv
;
lda data2 ; store away data
sta (bufpnt),y ; in data buffer
iny
bne read11
;
ldy #255-toprd ; store rest in overflow buffer
;
read20 bvc *
clv
;
lda data2
sta ovrbuf,y
iny
bne read20
;
jsr gcrbin ; convert buffer to binary
;
lda bid ; test if its a data block
cmp dbid
beq read28
;
lda #4 ; not a data block
jmp errr
;
read28 jsr chkblk ; calc checksum
;
cmp chksum
beq read40
;
lda #5 ; data block checksum error
.byte skip2
;
read40 lda #1 ; read data block ok
jmp errr
;
;
;
dstrt jsr srch ; find header
jmp sync ; and then data block sync
;
;
srch lda drive ; create header image
asl a
tax
;
lda dskid,x ; get master id for the drive
sta header
lda dskid+1,x
sta header+1
;
ldy #0 ; get track,sector
lda (hdrpnt),y
sta header+2
iny
lda (hdrpnt),y
sta header+3
;
lda #0
;create header checksum
eor header
eor header+1
eor header+2
eor header+3
;
sta header+4 ; store the checksum
;
jsr conhdr ; convert header to gcr
;
ldx #90 ; search 90 sync chars
;
srch20 jsr sync ; find sync
;
ldy #0 ; test 8 gcr bytes
;
srch25 bvc *
clv ; wait for byte
;
lda data2
cmp stab,y ; test if the same
bne srch30 ; nope
;
iny
cpy #8
bne srch25
;
rts
;
;
srch30 dex ; try again
bne srch20
;
lda #2 ; cant find this header
err jmp errr
;
;
;
;
sync
;
lda #$80+80 ; wait 20 ms for sync max
sta timer1
;
lda #3 ; error code for no sync
;
sync10 bit timer1 ; test for time out
bpl err
bit dskcnt ; test for sync
bmi sync10
;
;
lda data2 ; reset pa latch
clv
ldy #0 ; clear pointer
rts
;
;
;
;.end