-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathdsk.src
256 lines (249 loc) · 6.12 KB
/
dsk.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
;02/13/84 ds
;***********************************************************
;
; hardware error display routine
;
;***********************************************************
power0 ldx #$00
.byte $2c ; skip next two bytes
powerr ldx temp ; get error #
txs ; save error # in sp due to bad ram
;
;
perr0 tsx ; retrieve
perr1 lda #$6f ; setup ports
sta ddrb2 ; data dir. regs
and #$60 ; *
sta dskcnt ; turn on led
;
tya
per2a clc ; waste time
perr3 adc #$01
bne perr3
dey
bne per2a
lda #$68 ; turn off leds
sta dskcnt ; *
;
perr4 tya
perr5 clc
perr6 adc #$01 ; waste more time
bne perr6
dey
bne perr5
dex
bpl perr1 ; blinked enough times ?
;
cpx #$f4 ; waste a whole lot of time
bne perr4
beq perr0
;
;
perr jmp powerr
pezro jmp power0
;**************************************************************
; d i s k i n i t
;**************************************************************
;
dskint sei
cld
;
;
;*********************************
; *
; power up diagnostic *
; *
;*********************************
;
ldy #0
ldx #2
pu10 txa ; fill z-page accend pattern
sta $0,x
inx
bne pu10
ldx #2
pu20 txa ; check pattern by inc...
cmp $0,x ; ...back to orig #
bne pezro ; bad bits
pu30
inc $0,x ; bump contents
iny
bne pu30 ; not done
;
cmp $0,x ; check for good count
bne pezro ; something's wrong
;
sty $0,x ; leave z-page zeroed
lda $0,x ; check it
bne pezro ; wrong
;
inx ; next!
bne pu20 ; not all done
;
;
; test two 64k-bit roms
;
; enter x=start page
; exit if ok
;
rm10 inc temp ; next error #
stx ip+1 ; save page, start x=0
lda #0
sta ip ; zero lo indirect
tay
ldx #64 ; 64 pages in 16k rom
clc
rt10 dec ip+1 ; do it backwards
rt20 adc (ip),y ; total checksum in a
iny
bne rt20
dex
bne rt10
sta ledflg
adc #$ff ; add in last carry & -1
bne perr
; test all common ram
;
cr20 lda #$01 ; start of 1st block
cr30 sta ip+1 ; save page #
inc temp ; bump error #
; enter x=# of pages in block
; ip ptr to first page in block
; exit if ok
;
ramtst ldx #7 ; save page count
ra10 tya ; fill with adr sensitive pattern
clc
adc ip+1
sta (ip),y
iny
bne ra10
inc ip+1
dex
bne ra10
ldx #7 ; restore page count
ra30 dec ip+1 ; check pattern backwards
ra40 dey
tya ; gen pattern again
clc
adc ip+1
cmp (ip),y ; ok ?
bne perr2 ; no - show error #
eor #$ff ; yes - test inverse pattern
sta (ip),y
eor (ip),y ; ok ?
sta (ip),y ; leave memory zero
bne perr2 ; no - show error #
tya
bne ra40
dex
bne ra30
;
beq diagok
;
perr2 jmp perr
;
;
diagok
ldx #topwrt
stx eoiflg ; *
txs ; set (sp)
jsr cmdrst
;
;**********************************
;
; controller initialization
;
;**********************************
;
jsr cntint
;
dskit1 lda #17 ; set up sector offset
sta secinc
lda #5
sta revcnt ; set up recovery count
;
; initialize buffer pntr table
;
inttab ldx #0
ldy #0
intt1 lda #0
sta buftab,x
inx
lda bufind,y
sta buftab,x
inx
iny
cpy #bfcnt
bne intt1
;
lda #<cmdbuf ; set pntr to cmdbuf
sta buftab,x
inx
lda #>cmdbuf
sta buftab,x
inx
lda #<errbuf ; set pntr to errbuf
sta buftab,x
inx
lda #>errbuf
sta buftab,x
;
lda #$ff
ldx #maxsa
dskin1 sta lintab,x
dex
bpl dskin1
;
ldx #mxchns-1
dskin2
sta buf0,x ; set buffers as unused
sta buf1,x
sta ss,x
dex
bpl dskin2
;
lda #bfcnt ; set buffer pointers
sta buf0+cmdchn
lda #bfcnt+1
sta buf0+errchn
lda #$ff
sta buf0+blindx
sta buf1+blindx
lda #errchn
sta lintab+errsa
lda #cmdchn+$80
sta lintab+cmdsa
lda #lxint ; lindx 0 to 5 free
sta linuse
lda #rdylst
sta chnrdy+cmdchn
lda #rdytlk
sta chnrdy+errchn
lda #$e0
sta bufuse
lda #$ff
sta bufuse+1
lda #1
sta wpsw
sta wpsw+1
jsr usrint ; init user jmp
jsr lruint
;
;*
;*******************************
;*
;* seterr
;* set up power on error msg
;*
;* cbm dos v2.6 tdsk
;*
;*******************************
;*
;*
;
seterr lda #$73
jsr errts0
;
;
;must be contiguous to .file idle