Browse Source

added DOS_1551

master
Michael Steil 1 month ago
parent
commit
f9588adb00
75 changed files with 11690 additions and 0 deletions
  1. 103
    0
      DOS_1551/add.src
  2. 177
    0
      DOS_1551/adr.src
  3. 17
    0
      DOS_1551/all.src
  4. 255
    0
      DOS_1551/bin.src
  5. 422
    0
      DOS_1551/blo.src
  6. 221
    0
      DOS_1551/clo.src
  7. 215
    0
      DOS_1551/cnt.src
  8. 47
    0
      DOS_1551/com.src
  9. 53
    0
      DOS_1551/con.src
  10. 35
    0
      DOS_1551/cop.src
  11. 74
    0
      DOS_1551/d1551.src
  12. 32
    0
      DOS_1551/dis.src
  13. 56
    0
      DOS_1551/dnm.src
  14. 40
    0
      DOS_1551/dos.src
  15. 114
    0
      DOS_1551/drv.src
  16. 256
    0
      DOS_1551/dsk.src
  17. 48
    0
      DOS_1551/dup.src
  18. 1
    0
      DOS_1551/edtini.src
  19. 49
    0
      DOS_1551/equ.src
  20. 416
    0
      DOS_1551/erp.src
  21. 138
    0
      DOS_1551/fin.src
  22. 321
    0
      DOS_1551/fm2.src
  23. 89
    0
      DOS_1551/fm3.src
  24. 101
    0
      DOS_1551/fm4.src
  25. 158
    0
      DOS_1551/fnd.src
  26. 312
    0
      DOS_1551/fre.src
  27. 195
    0
      DOS_1551/gbn.src
  28. 270
    0
      DOS_1551/gcr.src
  29. 90
    0
      DOS_1551/get.src
  30. 49
    0
      DOS_1551/idl.src
  31. 81
    0
      DOS_1551/ini.src
  32. 39
    0
      DOS_1551/io.src
  33. 19
    0
      DOS_1551/iod.src
  34. 64
    0
      DOS_1551/it2.src
  35. 340
    0
      DOS_1551/job.src
  36. 10
    0
      DOS_1551/led.src
  37. 119
    0
      DOS_1551/lst.src
  38. 386
    0
      DOS_1551/lup.src
  39. 124
    0
      DOS_1551/maw.src
  40. 57
    0
      DOS_1551/mem.src
  41. 104
    0
      DOS_1551/nes.src
  42. 91
    0
      DOS_1551/new.src
  43. 60
    0
      DOS_1551/nul.src
  44. 198
    0
      DOS_1551/opc.src
  45. 423
    0
      DOS_1551/ope.src
  46. 250
    0
      DOS_1551/par.src
  47. 207
    0
      DOS_1551/ram.src
  48. 144
    0
      DOS_1551/rec.src
  49. 241
    0
      DOS_1551/red.src
  50. 227
    0
      DOS_1551/ren.src
  51. 128
    0
      DOS_1551/rl1.src
  52. 150
    0
      DOS_1551/rl2.src
  53. 57
    0
      DOS_1551/rl3.src
  54. 83
    0
      DOS_1551/rl4.src
  55. 85
    0
      DOS_1551/rom.src
  56. 74
    0
      DOS_1551/scr.src
  57. 205
    0
      DOS_1551/see.src
  58. 45
    0
      DOS_1551/sse.src
  59. 41
    0
      DOS_1551/sst.src
  60. 189
    0
      DOS_1551/ssu.src
  61. 215
    0
      DOS_1551/tfn.src
  62. 254
    0
      DOS_1551/trn.src
  63. 237
    0
      DOS_1551/trp.src
  64. 646
    0
      DOS_1551/ts2.src
  65. 337
    0
      DOS_1551/ts3.src
  66. 235
    0
      DOS_1551/ts4.src
  67. 87
    0
      DOS_1551/tst.src
  68. 190
    0
      DOS_1551/tsu.src
  69. 45
    0
      DOS_1551/uti.src
  70. 281
    0
      DOS_1551/utl.src
  71. 156
    0
      DOS_1551/var.src
  72. 30
    0
      DOS_1551/vec.src
  73. 72
    0
      DOS_1551/ver.src
  74. 306
    0
      DOS_1551/wrt.src
  75. 4
    0
      README.md

+ 103
- 0
DOS_1551/add.src View File

@@ -0,0 +1,103 @@
1
+;11/28/83 ds
2
+; add file to directory
3
+
4
+addfil  lda  sa         ; save variables 
5
+        pha      
6
+        lda  lindx       
7
+        pha      
8
+        lda  sector      
9
+        pha      
10
+        lda  track       
11
+        pha      
12
+        lda  #irsa       
13
+        sta  sa          
14
+        jsr  curblk     ; use last accessed search
15
+        lda  type        
16
+        pha      
17
+        lda  fildrv      
18
+        and  #1          
19
+        sta  drvnum      
20
+        ldx  jobnum      
21
+        eor  lstjob,x    
22
+        lsr  a   
23
+        bcc  af08       ; same drive as required
24
+
25
+        ldx  #1          
26
+        stx  delind     ; look for deleted entry
27
+        jsr  srchst      
28
+        beq  af15       ; all full, new sector 
29
+        bne  af20       ; found one
30
+
31
+af08    lda  delsec      
32
+        beq  af10       ; deleted entry not located
33
+        cmp  sector      
34
+        beq  af20       ; sector is resident
35
+        sta  sector      
36
+        jsr  drtrd      ; read sector in
37
+        jmp  af20        
38
+
39
+af10    lda  #1         ; find deleted entry
40
+        sta  delind      
41
+        jsr  search      
42
+        bne  af20        
43
+af15    jsr  nxdrbk     ; all full, new sector
44
+        lda  sector      
45
+        sta  delsec      
46
+        lda  #2          
47
+        sta  delind      
48
+af20    lda  delind      
49
+        jsr  setpnt      
50
+        pla      
51
+        sta  type       ; set type
52
+        cmp  #reltyp     
53
+        bne  af25        
54
+        ora  #$80        
55
+af25             
56
+        jsr  putbyt      
57
+        pla      
58
+        sta  filtrk     ; ...table & entry
59
+        jsr  putbyt      
60
+        pla      
61
+        sta  filsec     ; set sector link in...
62
+        jsr  putbyt     ; ...table & entry
63
+        jsr  getact      
64
+        tay      
65
+        lda  filtbl      
66
+        tax      
67
+        lda  #16         
68
+        jsr  trname     ; transfer name
69
+        ldy  #16         
70
+        lda  #0         ; clear # of blocks &...
71
+af30    sta  (dirbuf),y         ; ...& replace links
72
+        iny      
73
+        cpy  #27         
74
+        bcc  af30        
75
+        lda  type       ; a relative file ?
76
+        cmp  #reltyp     
77
+        bne  af50       ; no
78
+        ldy  #16        ; yes
79
+        lda  trkss      ; get ss track
80
+        sta  (dirbuf),y         ; put in directory
81
+        iny      
82
+        lda  secss      ; get ss sector
83
+        sta  (dirbuf),y         ; put in
84
+        iny      
85
+        lda  rec        ; get record size
86
+        sta  (dirbuf),y          
87
+af50    jsr  drtwrt     ; write it out
88
+        pla      
89
+        sta  lindx       
90
+        tax      
91
+        pla      
92
+        sta  sa          
93
+        lda  delsec      
94
+        sta  entsec      
95
+        sta  dsec,x      
96
+        lda  delind      
97
+        sta  entind      
98
+        sta  dind,x      
99
+        lda  type        
100
+        sta  pattyp      
101
+        lda  drvnum      
102
+        sta  fildrv      
103
+        rts      

+ 177
- 0
DOS_1551/adr.src View File

@@ -0,0 +1,177 @@
1
+;11/28/83 ds
2
+;*********************************
3
+;* addrel: add blocks to relative*
4
+;*         file.                 *
5
+;*   vars:                       *
6
+;*   regs:                       *
7
+;*                               *
8
+;*********************************
9
+;
10
+addrel           
11
+        jsr  setdrn      
12
+        jsr  ssend      ; set up end of file
13
+        jsr  posbuf      
14
+        jsr  dbset       
15
+        lda  ssind       
16
+        sta  r1         ; save ss index
17
+        lda  ssnum       
18
+        sta  r0         ; save ss number
19
+        lda  #0          
20
+        sta  r2         ; clear flag for one block
21
+;
22
+        lda  #0         ; clear for calculation...
23
+        sta  recptr     ; ...to 1st byte in record
24
+        jsr  fndrel     ; calc ss ptrs
25
+addr1           ;  entry for rel record fix
26
+        jsr  numfre     ; calc available...
27
+;
28
+        ldy  lindx      ; record span?
29
+        ldx  rs,y        
30
+        dex      
31
+        txa      
32
+        clc      
33
+        adc  relptr      
34
+        bcc  ar10       ; no span
35
+;
36
+        inc  ssind      ; inc ss ptrs & check
37
+        inc  ssind      ; inc ss ptrs & check
38
+        bne  ar10        
39
+        inc  ssnum       
40
+        lda  #ssioff     
41
+        sta  ssind       
42
+ar10             
43
+        lda  r1          
44
+        clc      
45
+        adc  #2          
46
+        jsr  setssp      
47
+;
48
+        lda  ssnum       
49
+        cmp  #nssl       
50
+        bcc  ar25       ; valid range
51
+;
52
+ar20             
53
+        lda  #bigfil     
54
+        jsr  cmderr     ; too many ss's
55
+ar25             
56
+        lda  ssind      ; calc # blocks needed...
57
+        sec     ; ...& check against avail.
58
+        sbc  r1          
59
+        bcs  ar30        
60
+        sbc  #ssioff-1   
61
+        clc      
62
+ar30             
63
+        sta  t3         ; # ss indices
64
+        lda  ssnum       
65
+        sbc  r0          
66
+        sta  t4         ; # ss needed
67
+;
68
+        ldx  #0         ; clear accum.
69
+        stx  t1          
70
+        stx  t2          
71
+        tax     ; .x=# ss
72
+        jsr  sscalc     ; calc # of blocks needed
73
+;
74
+        lda  t2          
75
+        bne  ar35        
76
+        ldx  t1          
77
+        dex      
78
+        bne  ar35        
79
+;
80
+        inc  r2          
81
+ar35             
82
+        cmp  nbtemp+1    
83
+        bcc  ar40       ; ok!!
84
+        bne  ar20        
85
+        lda  nbtemp      
86
+        cmp  t1          
87
+        bcc  ar20       ; not enuf blocks
88
+ar40             
89
+        lda  #1          
90
+        jsr  drdbyt     ; look at sector link
91
+        clc      
92
+        adc  #1         ; +1 is nr
93
+        ldx  lindx       
94
+        sta  nr,x        
95
+        jsr  nxtts      ; get next block...
96
+        jsr  setlnk     ; ...& set link.
97
+        lda  r2          
98
+        bne  ar50       ; add one block
99
+;
100
+        jsr  wrtout     ; write current last rec
101
+ar45             
102
+        jsr  dblbuf     ; switch bufs
103
+        jsr  sethdr     ; set hdr from t & s
104
+        jsr  nxtts      ; get another
105
+        jsr  setlnk     ; set up link
106
+        jsr  nulbuf     ; clean it out
107
+        jmp  ar55        
108
+ar50             
109
+        jsr  dblbuf     ; switch bufs
110
+        jsr  sethdr     ; set hdr from t & s
111
+        jsr  nulbuf     ; clean buffer
112
+        jsr  nullnk     ; last block =0,lstchr
113
+ar55             
114
+        jsr  wrtout     ; write buffer
115
+        jsr  getlnk     ; get t&s from link
116
+        lda  track       
117
+        pha     ; save 'em
118
+        lda  sector      
119
+        pha      
120
+        jsr  gethdr     ; now get hdr t&s
121
+        lda  sector      
122
+        pha     ; save 'em
123
+        lda  track       
124
+        pha      
125
+        jsr  gsspnt     ; check ss ptr
126
+        tax      
127
+        bne  ar60        
128
+;
129
+        jsr  newss      ; need another ss
130
+        lda  #ssioff     
131
+        jsr  setssp     ; .a=bt val
132
+        inc  r0         ; advance ss count
133
+ar60             
134
+        pla      
135
+        jsr  putss      ; record t&s...
136
+        pla      
137
+        jsr  putss      ; ...in ss.
138
+        pla     ; get t&s from link
139
+        sta  sector      
140
+        pla      
141
+        sta  track       
142
+        beq  ar65       ; t=0: that's all!!
143
+;
144
+        lda  r0          
145
+        cmp  ssnum       
146
+        bne  ar45       ; not even done yet
147
+;
148
+        jsr  gsspnt      
149
+        cmp  ssind       
150
+        bcc  ar45       ; almost done
151
+        beq  ar50       ; one more block left
152
+ar65             
153
+        jsr  gsspnt      
154
+        pha      
155
+        lda  #0          
156
+        jsr  ssdir       
157
+        lda  #0          
158
+        tay      
159
+        sta  (dirbuf),y          
160
+        iny      
161
+        pla      
162
+        sec      
163
+        sbc  #1          
164
+        sta  (dirbuf),y          
165
+        jsr  wrtss      ; write ss
166
+        jsr  watjob      
167
+        jsr  mapout      
168
+        jsr  fndrel      
169
+        jsr  dblbuf     ; get back to leading buffer
170
+        jsr  sspos       
171
+        bvs  ar70        
172
+        jmp  positn      
173
+ar70             
174
+        lda  #lrf        
175
+        jsr  setflg      
176
+        lda  #norec      
177
+        jsr  cmderr      

+ 17
- 0
DOS_1551/all.src View File

@@ -0,0 +1,17 @@
1
+;11/28/83 ds
2
+;
3
+; set up subroutine
4
+;
5
+pups1   lda  #0          
6
+        sta  rec         
7
+        sta  drvcnt      
8
+        sta  filtrk      
9
+        sta  filtrk+1    
10
+        lda  fildrv+1   ; get drive number
11
+        and  #1         ; only
12
+        sta  drvnum      
13
+        ora  #1          
14
+        sta  delsec     ; nonzero
15
+        lda  filtbl+1   ; fn1=fn2
16
+        sta  filtbl      
17
+        rts      

+ 255
- 0
DOS_1551/bin.src View File

@@ -0,0 +1,255 @@
1
+; 08/17/83 ds
2
+;
3
+;
4
+put4bg  lda  #0         ;  clear table
5
+        sta  gtab+1      
6
+        sta  gtab+4      
7
+;
8
+        ldy  gcrpnt      
9
+;
10
+        lda  btab        
11
+        and  #$f0        
12
+        lsr  a   
13
+        lsr  a   
14
+        lsr  a   
15
+        lsr  a   
16
+        tax      
17
+        lda  bgtab,x     
18
+;
19
+        asl  a   
20
+        asl  a   
21
+        asl  a   
22
+        sta  gtab        
23
+;
24
+        lda  btab        
25
+        and  #$0f        
26
+        tax      
27
+        lda  bgtab,x     
28
+;
29
+        ror  a   
30
+        ror  gtab+1      
31
+        ror  a   
32
+        ror  gtab+1      
33
+;
34
+        and  #$07        
35
+        ora  gtab        
36
+        sta  (bufpnt),y          
37
+;
38
+        iny      
39
+;
40
+        lda  btab+1      
41
+        and  #$f0        
42
+        lsr  a   
43
+        lsr  a   
44
+        lsr  a   
45
+        lsr  a   
46
+        tax      
47
+        lda  bgtab,x     
48
+;
49
+        asl  a   
50
+        ora  gtab+1      
51
+        sta  gtab+1      
52
+;
53
+;
54
+        lda  btab+1      
55
+        and  #$0f        
56
+        tax      
57
+        lda  bgtab,x     
58
+;
59
+        rol  a   
60
+        rol  a   
61
+        rol  a   
62
+        rol  a   
63
+        sta  gtab+2      
64
+;
65
+        rol  a   
66
+        and  #1          
67
+        ora  gtab+1      
68
+        sta  (bufpnt),y          
69
+;
70
+        iny      
71
+;
72
+        lda  btab+2      
73
+        and  #$f0        
74
+        lsr  a   
75
+        lsr  a   
76
+        lsr  a   
77
+        lsr  a   
78
+        tax      
79
+        lda  bgtab,x     
80
+;
81
+        clc      
82
+        ror  a   
83
+        ora  gtab+2      
84
+        sta  (bufpnt),y          
85
+        iny      
86
+;
87
+        ror  a   
88
+        and  #$80        
89
+        sta  gtab+3      
90
+;
91
+        lda  btab+2      
92
+        and  #$0f        
93
+        tax      
94
+        lda  bgtab,x     
95
+        asl  a   
96
+        asl  a   
97
+        and  #$7c        
98
+        ora  gtab+3      
99
+        sta  gtab+3      
100
+;
101
+        lda  btab+3      
102
+        and  #$f0        
103
+        lsr  a   
104
+        lsr  a   
105
+        lsr  a   
106
+        lsr  a   
107
+        tax      
108
+        lda  bgtab,x     
109
+;
110
+        ror  a   
111
+        ror  gtab+4      
112
+        ror  a   
113
+        ror  gtab+4      
114
+        ror  a   
115
+        ror  gtab+4      
116
+;
117
+        and  #$03        
118
+        ora  gtab+3      
119
+        sta  (bufpnt),y          
120
+        iny      
121
+        bne  bing35      
122
+;
123
+        lda  savpnt+1    
124
+        sta  bufpnt+1    
125
+        lda  #$00        
126
+        sta  bufpnt      
127
+;
128
+;
129
+bing35  lda  btab+3      
130
+        and  #$0f        
131
+        tax      
132
+        lda  bgtab,x     
133
+        ora  gtab+4      
134
+        sta  (bufpnt),y          
135
+        iny      
136
+        sty  gcrpnt      
137
+        rts      
138
+;
139
+;
140
+;
141
+bgtab   .byte    $0a      
142
+	.byte    $0b     
143
+	.byte    $12     
144
+	.byte    $13     
145
+	.byte    $0e     
146
+	.byte    $0f     
147
+	.byte    $16     
148
+	.byte    $17     
149
+	.byte    $09     
150
+	.byte    $19     
151
+	.byte    $1a     
152
+	.byte    $1b     
153
+	.byte    $0d     
154
+	.byte    $1d     
155
+	.byte    $1e     
156
+	.byte    $15     
157
+;
158
+;
159
+;
160
+;******************************
161
+;*
162
+;*
163
+;*       binary to gcr conversion
164
+;*
165
+;*
166
+;*   does inplace conversion of
167
+;*   buffer to gcr using overflow
168
+;*   block
169
+;*
170
+;*
171
+;*   creates write image
172
+;*
173
+;*     1 block id char
174
+;*   256 data bytes
175
+;*     1 check sum
176
+;*     2 off bytes
177
+;*   ---
178
+;*   260 binary bytes
179
+;*
180
+;*  260 binary bytes >> 325 gcr
181
+;*
182
+;*  325 = 256 + 69 overflow
183
+;*
184
+;*
185
+;********************************
186
+;*
187
+bingcr  lda  #0         ;  init pointers
188
+        sta  savpnt      
189
+        sta  bytcnt      
190
+;
191
+        lda  #$60        
192
+        sta  bufpnt      
193
+;
194
+        lda  #$bb       ;  overflow buff offset
195
+        sta  gcrpnt     ;  start saving gcr here
196
+;
197
+        sta  gcrflg     ;  buffer converted flag
198
+;
199
+        lda  bufpnt+1   ;  save buffer pointer
200
+        sta  savpnt+1    
201
+;
202
+        lda  #$00       ;  point at (msb $00)+(lsb $60 + offset $bb)
203
+        sta  bufpnt+1    
204
+;
205
+        lda  #dbid      ;  store data block id
206
+        sta  btab       ;  and next 3 data bytes
207
+;
208
+        ldy  bytcnt      
209
+;
210
+        lda  (savpnt),y          
211
+        sta  btab+1      
212
+        iny      
213
+;
214
+        lda  (savpnt),y          
215
+        sta  btab+2      
216
+        iny      
217
+;
218
+        lda  (savpnt),y          
219
+        sta  btab+3      
220
+        iny      
221
+;
222
+bing07  sty  bytcnt     ;  next byte to get
223
+;
224
+        jsr  put4bg     ;  convert and store
225
+;
226
+        ldy  bytcnt      
227
+;
228
+        lda  (savpnt),y          
229
+        sta  btab        
230
+        iny      
231
+        beq  bing20      
232
+;
233
+        lda  (savpnt),y          
234
+        sta  btab+1      
235
+        iny      
236
+;
237
+        lda  (savpnt),y          
238
+        sta  btab+2      
239
+        iny      
240
+;
241
+        lda  (savpnt),y          
242
+        sta  btab+3      
243
+        iny      
244
+;
245
+        bne  bing07     ;  jmp
246
+;
247
+;
248
+bing20  lda  chksum     ;  store chksum
249
+        sta  btab+1      
250
+;
251
+        lda  #0         ;  store 0 off byte
252
+        sta  btab+2      
253
+        sta  btab+3      
254
+;
255
+        jmp  put4bg     ;  convert and store and return

+ 422
- 0
DOS_1551/blo.src View File

@@ -0,0 +1,422 @@
1
+        .page  'block'   
2
+;08/22/84 ds
3
+;  rom 1.1 additions
4
+; user commands
5
+
6
+user    ldy  cmdbuf+1    
7
+        cpy  #'0         
8
+        bne  us10       ; 0 resets pntr
9
+
10
+usrint  lda  #<ublock   ; set default block add
11
+        sta  usrjmp      
12
+        lda  #>ublock    
13
+        sta  usrjmp+1    
14
+        rts      
15
+
16
+us10    jsr  usrexc     ; execute code by table
17
+        jmp  endcmd      
18
+
19
+usrexc  dey     ; entry is(((index-1)and$f)*2)
20
+        tya      
21
+        and  #$f         
22
+        asl  a   
23
+        tay      
24
+        lda  (usrjmp),y          
25
+        sta  ip          
26
+        iny      
27
+        lda  (usrjmp),y          
28
+        sta  ip+1        
29
+        jmp  (ip)        
30
+        .page  'block  commands'         
31
+; open direct access buffer
32
+;  from open "#"
33
+
34
+opnblk  lda  lstdrv      
35
+        sta  drvnum      
36
+        lda  sa         ; sa is destroyed by this patch
37
+        pha      
38
+        jsr  autoi      ; init disk for proper channel assignment
39
+        pla     ; restore sa
40
+        sta  sa          
41
+        ldx  cmdsiz      
42
+        dex      
43
+        bne  ob10        
44
+
45
+        lda  #1         ; get any buffer
46
+        jsr  getrch      
47
+        jmp  ob30        
48
+
49
+ob05    lda  #nochnl     
50
+        jmp  cmderr      
51
+
52
+ob10    ldy  #1         ; buffer # is requested
53
+        jsr  bp05        
54
+        ldx  filsec      
55
+        cpx  #bfcnt     ; must be less than 5
56
+        bcs  ob05        
57
+
58
+        lda  #0          
59
+        sta  temp        
60
+        sta  temp+1      
61
+        sec      
62
+
63
+ob15             
64
+        rol  temp        
65
+        rol  temp+1      
66
+        dex      
67
+        bpl  ob15        
68
+
69
+        lda  temp        
70
+        and  bufuse      
71
+        bne  ob05       ; buffer is used
72
+        lda  temp+1      
73
+        and  bufuse+1    
74
+        bne  ob05       ; buf is used
75
+
76
+        lda  temp        
77
+        ora  bufuse     ; set buffer as used
78
+        sta  bufuse      
79
+        lda  temp+1      
80
+        ora  bufuse+1    
81
+        sta  bufuse+1    
82
+
83
+        lda  #0         ; set up channel
84
+        jsr  getrch      
85
+        ldx  lindx       
86
+        lda  filsec      
87
+        sta  buf0,x      
88
+        tax      
89
+        lda  drvnum      
90
+        sta  jobs,x      
91
+        sta  lstjob,x    
92
+
93
+ob30    ldx  sa          
94
+        lda  lintab,x   ; set lindx table
95
+        ora  #$40        
96
+        sta  lintab,x    
97
+
98
+        ldy  lindx       
99
+        lda  #$ff        
100
+        sta  lstchr,y    
101
+
102
+        lda  #rndrdy     
103
+        sta  chnrdy,y   ; set channel ready
104
+
105
+        lda  buf0,y      
106
+        sta  chndat,y   ; buffer # as 1st char
107
+        asl  a   
108
+        tax      
109
+        lda  #1          
110
+        sta  buftab,x    
111
+        lda  #dirtyp+dirtyp      
112
+        sta  filtyp,y   ; set direct file type
113
+        jmp  endcmd      
114
+        .page    
115
+; block commands
116
+block   ldy  #0          
117
+        ldx  #0          
118
+        lda  #'-        ; "-" separates cmd from subcmd
119
+        jsr  parse      ; locate sub-cmd
120
+        bne  blk40       
121
+
122
+blk10   lda  #badcmd     
123
+        jmp  cmderr      
124
+
125
+blk30   lda  #badsyn     
126
+        jmp  cmderr      
127
+
128
+blk40   txa      
129
+        bne  blk30       
130
+
131
+        ldx  #nbcmds-1          ; find command
132
+        lda  cmdbuf,y    
133
+blk50   cmp  bctab,x     
134
+        beq  blk60       
135
+        dex      
136
+        bpl  blk50       
137
+        bmi  blk10       
138
+
139
+blk60            
140
+        txa      
141
+        ora  #$80        
142
+        sta  cmdnum      
143
+        jsr  blkpar     ; parse parms
144
+
145
+        lda  cmdnum      
146
+        asl  a   
147
+        tax      
148
+        lda  bcjmp+1,x   
149
+        sta  temp+1      
150
+        lda  bcjmp,x     
151
+        sta  temp        
152
+
153
+        jmp  (temp)     ; goto command
154
+
155
+bctab    .byte  'AFRWEP'         
156
+nbcmds   =*-bctab        
157
+
158
+bcjmp   .word    blkalc         ; block-allocate
159
+	.word    blkfre         ; block-free
160
+	.word    blkrd          ; block-read
161
+	.word    blkwt          ; block-write
162
+	.word    blkexc         ; block-execute
163
+	.word    blkptr         ; block-pointer
164
+
165
+blkpar  ldy  #0         ; parse block parms
166
+        ldx  #0          
167
+        lda  #':         
168
+        jsr  parse       
169
+        bne  bp05       ; found ":"
170
+
171
+        ldy  #3         ; else char #3 is beginning
172
+bp05    lda  cmdbuf,y    
173
+        cmp  #'          
174
+        beq  bp10        
175
+
176
+        cmp  #29        ; skip character
177
+        beq  bp10        
178
+
179
+        cmp  #',         
180
+        bne  bp20        
181
+
182
+bp10    iny      
183
+        cpy  cmdsiz      
184
+        bcc  bp05        
185
+
186
+        rts     ; that's all
187
+
188
+bp20    jsr  aschex      
189
+        inc  f1cnt       
190
+        ldy  f2ptr       
191
+        cpx  #mxfils-1   
192
+        bcc  bp10        
193
+
194
+        bcs  blk30      ; bad syntax
195
+
196
+; convert ascii to hex (binary)
197
+;  & store conversion in tables
198
+;  .y= ptr into cmdbuf
199
+aschex  lda  #0          
200
+        sta  temp        
201
+        sta  temp+1      
202
+        sta  temp+3      
203
+
204
+        ldx  #$ff        
205
+ah10    lda  cmdbuf,y   ; test for dec #
206
+        cmp  #$40        
207
+        bcs  ah20       ; non-numeric terminates
208
+        cmp  #$30        
209
+        bcc  ah20       ; non-numeric
210
+
211
+        and  #$f         
212
+        pha      
213
+        lda  temp+1     ; shift digits (*10)
214
+        sta  temp+2      
215
+        lda  temp        
216
+        sta  temp+1      
217
+        pla      
218
+        sta  temp        
219
+        iny      
220
+        cpy  cmdsiz      
221
+        bcc  ah10       ; still in string
222
+
223
+ah20    sty  f2ptr      ; convert digits to...
224
+        clc     ; ...binary by dec table
225
+        lda  #0          
226
+
227
+ah30    inx      
228
+        cpx  #3          
229
+        bcs  ah40        
230
+
231
+        ldy  temp,x      
232
+ah35    dey      
233
+        bmi  ah30        
234
+
235
+        adc  dectab,x    
236
+        bcc  ah35        
237
+
238
+        clc      
239
+        inc  temp+3      
240
+        bne  ah35        
241
+
242
+ah40    pha      
243
+        ldx  f1cnt       
244
+        lda  temp+3      
245
+        sta  filtrk,x   ; store result in table
246
+        pla      
247
+        sta  filsec,x    
248
+        rts      
249
+
250
+dectab   .byte  1,10,100        ; decimal table
251
+
252
+;block-free
253
+blkfre  jsr  blktst      
254
+        jsr  frets       
255
+        jmp  endcmd      
256
+
257
+;block-allocate
258
+        lda  #1          
259
+        sta  wbam        
260
+blkalc           
261
+        jsr  blktst      
262
+
263
+ba10             
264
+        lda  sector      
265
+        pha      
266
+        jsr  getsec      
267
+        beq  ba15       ; none greater on this track
268
+        pla      
269
+        cmp  sector      
270
+        bne  ba30       ; requested sector not avail
271
+        jsr  wused       
272
+        jmp  endcmd      
273
+;
274
+ba15             
275
+        pla     ; pop stack
276
+ba20             
277
+        lda  #0          
278
+        sta  sector      
279
+        inc  track       
280
+        lda  track       
281
+        cmp  maxtrk      
282
+        bcs  ba40       ; gone all the way
283
+;
284
+        jsr  getsec      
285
+        beq  ba20        
286
+ba30             
287
+        lda  #noblk      
288
+        jsr  cmder2      
289
+ba40             
290
+        lda  #noblk      
291
+        jsr  cmderr     ; t=0,s=0 :none left
292
+;
293
+
294
+; block read subs
295
+blkrd2  jsr  bkotst     ; test parms
296
+        jmp  drtrd       
297
+
298
+getsim  jsr  getpre     ; get byte w/o inc
299
+        lda  (buftab,x)          
300
+        rts      
301
+
302
+; block read
303
+blkrd3  jsr  blkrd2      
304
+        lda  #0          
305
+        jsr  setpnt      
306
+        jsr  getsim     ; y=lindx
307
+ 
308
+
309
+        sta  lstchr,y    
310
+        lda  #rndrdy     
311
+        sta  chnrdy,y    
312
+        rts      
313
+blkrd            
314
+        jsr  blkrd3      
315
+        jsr  rnget1      
316
+        jmp  endcmd      
317
+
318
+;user direct read, lstchr=$ff
319
+ublkrd           
320
+        jsr  blkpar      
321
+        jsr  blkrd3      
322
+        lda  lstchr,y    
323
+        sta  chndat,y    
324
+        lda  #$ff        
325
+        sta  lstchr,y    
326
+        jmp  endcmd     ; (rts)
327
+
328
+;block-write
329
+blkwt   jsr  bkotst      
330
+
331
+        jsr  getpnt      
332
+        tay      
333
+        dey      
334
+        cmp  #2          
335
+        bcs  bw10        
336
+        ldy  #1          
337
+
338
+bw10    lda  #0         ; set record size
339
+        jsr  setpnt      
340
+        tya      
341
+        jsr  putbyt      
342
+        txa      
343
+        pha      
344
+
345
+bw20    jsr  drtwrt     ; write block
346
+        pla      
347
+        tax      
348
+        ldy  lindx      ; 08/22/84 ds fix
349
+        jsr  rnget2      
350
+        jmp  endcmd      
351
+
352
+;user dirct write, no lstchr
353
+ublkwt  jsr  blkpar      
354
+        jsr  bkotst      
355
+        jsr  drtwrt      
356
+        jmp  endcmd      
357
+
358
+
359
+;block-execute
360
+blkexc           
361
+        jsr  blkrd2     ; read block & execute
362
+        lda  #0          
363
+
364
+be05    sta  temp        
365
+        ldx  jobnum      
366
+        lda  bufind,x    
367
+        sta  temp+1      
368
+        jsr  be10       ; indirect jsr
369
+        jmp  endcmd      
370
+
371
+be10    jmp  (temp)      
372
+
373
+;buffer-pointer, set buffer pointer 
374
+blkptr  jsr  buftst      
375
+        lda  jobnum      
376
+        asl  a   
377
+        tax      
378
+        lda  filsec+1    
379
+        sta  buftab,x    
380
+        jsr  getpre      
381
+        jsr  rnget2     ; set up get
382
+        jmp  endcmd      
383
+
384
+;test for allocated buffer..
385
+;  ..related to sa
386
+buftst  ldx  f1ptr       
387
+        inc  f1ptr       
388
+        lda  filsec,x    
389
+        tay      
390
+        dey      
391
+        dey      
392
+        cpy  #$c        ;  set limit to # of sas
393
+        bcc  bt20        
394
+
395
+bt15    lda  #nochnl     
396
+        jmp  cmderr      
397
+
398
+bt20    sta  sa          
399
+        jsr  fndrch      
400
+        bcs  bt15        
401
+        jsr  getact      
402
+        sta  jobnum      
403
+        rts      
404
+
405
+;test block operation parms
406
+bkotst  jsr  buftst      
407
+;
408
+;test for legal block &..
409
+;  ..set up drv, trk, sec
410
+blktst  ldx  f1ptr       
411
+        lda  filsec,x    
412
+        and  #1          
413
+        sta  drvnum      
414
+        lda  filsec+2,x          
415
+        sta  sector      
416
+        lda  filsec+1,x          
417
+        sta  track       
418
+bt05             
419
+        jsr  tschk       
420
+        rts      
421
+
422
+; rsr 1/19/80 add autoi to #cmd

+ 221
- 0
DOS_1551/clo.src View File

@@ -0,0 +1,221 @@
1
+;11/28/83 ds
2
+; close the file associated with sa
3
+;
4
+close            
5
+        lda  #0          
6
+        sta  wbam        
7
+        lda  sa          
8
+        bne  cls10      ;  directory close
9
+        lda  #0          
10
+        sta  dirlst     ; clear dir list
11
+        jsr  frechn      
12
+cls05            
13
+        jmp  freich      
14
+cls10            
15
+        cmp  #$f         
16
+        beq  clsall     ;  close cmd chanl
17
+        jsr  clschn     ; close channel
18
+        lda  sa          
19
+        cmp  #2          
20
+        bcc  cls05       
21
+;
22
+        lda  erword      
23
+        bne  cls15      ;  last command had an error
24
+        jmp  endcmd      
25
+cls15            
26
+        jmp  scren1      
27
+;
28
+clsall           
29
+        lda  #14         
30
+        sta  sa          
31
+cls20            
32
+        jsr  clschn      
33
+        dec  sa          
34
+        bpl  cls20       
35
+        lda  erword      
36
+        bne  cls25      ;  last command had an error
37
+        jmp  endcmd      
38
+cls25            
39
+        jmp  scren1      
40
+;
41
+clschn           
42
+        ldx  sa          
43
+        lda  lintab,x    
44
+        cmp  #$ff        
45
+        bne  clsc28      
46
+        rts      
47
+clsc28           
48
+        and  #$f         
49
+        sta  lindx       
50
+;
51
+        jsr  typfil      
52
+        cmp  #dirtyp     
53
+        beq  clsc30     ; direct channel
54
+        cmp  #reltyp     
55
+        beq  clsrel      
56
+;
57
+        jsr  fndwch     ; look for write channel
58
+        bcs  clsc31      
59
+;
60
+        jsr  clswrt     ; close seq write
61
+        jsr  clsdir     ; close directory
62
+clsc30           
63
+        jsr  mapout     ; write bam
64
+clsc31           
65
+        jmp  frechn      
66
+;
67
+clsrel           
68
+        jsr  scrub       
69
+        jsr  dblbuf      
70
+        jsr  ssend       
71
+        ldx  ssnum       
72
+        stx  t4          
73
+        inc  t4          
74
+        lda  #0          
75
+        sta  t1          
76
+        sta  t2          
77
+        lda  ssind       
78
+        sec      
79
+        sbc  #ssioff-2   
80
+        sta  t3          
81
+        jsr  sscalc      
82
+        ldx  lindx       
83
+        lda  t1          
84
+        sta  nbkl,x      
85
+        lda  t2          
86
+        sta  nbkh,x      
87
+        lda  #dyfile     
88
+        jsr  tstflg      
89
+        beq  clsr1       
90
+        jsr  clsdir      
91
+clsr1   jmp  frechn      
92
+;
93
+; close a write chanl
94
+;
95
+clswrt          ; close seq write file
96
+        ldx  lindx       
97
+        lda  nbkl,x      
98
+        ora  nbkh,x      
99
+        bne  clsw10     ; at least 1 block written
100
+;
101
+        jsr  getpnt      
102
+        cmp  #2          
103
+        bne  clsw10     ; at least 1 byte written
104
+;
105
+        lda  #cr         
106
+        jsr  putbyt      
107
+clsw10           
108
+        jsr  getpnt      
109
+        cmp  #2          
110
+        bne  clsw20     ; not mt buffer
111
+;
112
+        jsr  dblbuf     ; switch bufs
113
+;
114
+        ldx  lindx       
115
+        lda  nbkl,x      
116
+        bne  clsw15      
117
+        dec  nbkh,x      
118
+clsw15           
119
+        dec  nbkl,x      
120
+;
121
+        lda  #0          
122
+clsw20           
123
+        sec      
124
+        sbc  #1         ; back up 1
125
+        pha     ; save it
126
+        lda  #0          
127
+        jsr  setpnt      
128
+        jsr  putbyt     ; tlink=0
129
+        pla     ; lstchr count
130
+        jsr  putbyt      
131
+;
132
+        jsr  wrtbuf     ; write out last buffer
133
+        jsr  watjob     ; finish job up
134
+        jmp  dblbuf     ; make sure both bufs ok
135
+;rts
136
+;
137
+; directory close on open write file
138
+;
139
+clsdir  ldx  lindx      ; save lindx
140
+        stx  wlindx     ; &sa
141
+        lda  sa          
142
+        pha      
143
+        lda  dsec,x     ; get directory sector
144
+        sta  sector      
145
+        lda  dind,x     ; get sector offset
146
+        sta  index       
147
+        lda  filtyp,x   ; drv # in filtyp
148
+        and  #1          
149
+        sta  drvnum      
150
+        lda  dirtrk      
151
+        sta  track       
152
+        jsr  getact     ; allocate a buffer
153
+        pha      
154
+        sta  jobnum      
155
+        jsr  drtrd      ; read directory sector
156
+        ldy  #0          
157
+        lda  bufind,x   ; .x is job#
158
+        sta  r0+1        
159
+        lda  index       
160
+        sta  r0          
161
+        lda  (r0),y      
162
+        and  #$20        
163
+        beq  clsd5       
164
+        jsr  typfil      
165
+        cmp  #reltyp     
166
+        beq  clsd6       
167
+;
168
+        lda  (r0),y      
169
+        and  #$8f       ; replace file
170
+        sta  (r0),y      
171
+        iny      
172
+        lda  (r0),y      
173
+        sta  track       
174
+        sty  temp+2      
175
+        ldy  #27        ; extract replacement link
176
+        lda  (r0),y     ;  to last sector
177
+        pha      
178
+        dey      
179
+        lda  (r0),y      
180
+        bne  clsd4       
181
+        sta  track       
182
+        pla      
183
+        sta  sector      
184
+        lda  #$67        
185
+        jsr  cmder2      
186
+clsd4            
187
+        pha      
188
+        lda  #0          
189
+        sta  (r0),y      
190
+        iny      
191
+        sta  (r0),y      
192
+        pla      
193
+        ldy  temp+2      
194
+        sta  (r0),y      
195
+        iny      
196
+        lda  (r0),y      
197
+        sta  sector      
198
+        pla      
199
+        sta  (r0),y      
200
+        jsr  delfil     ; delete old file
201
+        jmp  clsd6      ; set close bit
202
+clsd5            
203
+        lda  (r0),y      
204
+        and  #$f         
205
+        ora  #$80        
206
+        sta  (r0),y      
207
+clsd6   ldx  wlindx      
208
+        ldy  #28        ; set # of blocks
209
+        lda  nbkl,x      
210
+        sta  (r0),y      
211
+        iny      
212
+        lda  nbkh,x      
213
+        sta  (r0),y      
214
+        pla      
215
+        tax      
216
+        lda  #write     ; write directory sector
217
+        ora  drvnum      
218
+        jsr  doit        
219
+        pla      
220
+        sta  sa          
221
+        jmp  fndwch     ; restore lindx

+ 215
- 0
DOS_1551/cnt.src View File

@@ -0,0 +1,215 @@
1
+;08/22/84 ds
2
+;
3
+;
4
+;    *contrl
5
+;
6
+;    main controller loop
7
+;
8
+;    scans job que for jobs
9
+;
10
+;   finds job on current track
11
+;   if it exists
12
+;
13
+sysirq  pha      
14
+        txa      
15
+        pha      
16
+        tya      
17
+        pha      
18
+        tsx     ; save current stack pointer
19
+        stx  savsp      ; *
20
+;
21
+top     ldy  #numjob-1          ; pointer into job que
22
+;
23
+;
24
+cont10           
25
+        lda  jobs,y     ; find a job (msb set)
26
+        bmi  cont30     ; branch if there is a job
27
+        dey      
28
+        bpl  cont10      
29
+;
30
+        lda  joberr     ; are we to blink?
31
+        bne  cont22     ; br, we are
32
+;
33
+;   check for open files
34
+;
35
+cont11  lda  dskcnt     ; load in port
36
+        ora  #8         ; set mask to turn off led(x)
37
+        ldy  bthdrv     ; check to see if drv#(x) has an open file
38
+        beq  cont21     ; br, it does not
39
+        and  #$f7       ; else mask led#(x) on
40
+cont21  sta  dskcnt      
41
+        jmp  cont25     ; 
42
+;
43
+;   blink appropriate led
44
+;
45
+cont22           
46
+        dec  errcnt      
47
+        bpl  cont25      
48
+        lda  #30        ; 30*6ms blink rate
49
+        sta  errcnt      
50
+        lda  dskcnt      
51
+        eor  #$08        
52
+        sta  dskcnt      
53
+;
54
+cont25  jmp  end         
55
+;
56
+cont30           
57
+        and  #drvmsk    ;  get drive #
58
+        tax      
59
+        cmp  cdrive     ;  test if current drive
60
+        beq  cont40      
61
+;
62
+        sta  cdrive      
63
+        and  #01         
64
+        sta  drviof     ; drive i/o offset 0 or 1
65
+        ror  a   
66
+        ror  a   
67
+        ror  a          ; into msb's
68
+        sta  work        
69
+        lda  portc      ; set in portc
70
+        and  #%00111111         ; mask
71
+        ora  work       ; set bits
72
+        sta  portc       
73
+        jsr  turnon     ; turn drive on
74
+        jmp  end        ;  go clean up
75
+;
76
+;
77
+cont40  lda  drvst      ;  test if motor up to speed
78
+        bmi  cont50      
79
+;
80
+        asl  a          ;  test if stepping
81
+        bpl  que        ;  not stepping
82
+;
83
+cont50  jmp  end         
84
+;
85
+;
86
+que     lda  #$20       ;  status=running
87
+        sta  drvst       
88
+;
89
+        lda  dskcnt     ;  turn on activity led
90
+        and  #$f7        
91
+        sta  dskcnt      
92
+que9    ldy  #numjob-1   
93
+        sty  jobn        
94
+;
95
+que10   jsr  setjb       
96
+        bmi  que20       
97
+;
98
+que05   dec  jobn        
99
+        bpl  que10       
100
+;
101
+;
102
+        ldy  nxtjob      
103
+        jsr  setjb1      
104
+;
105
+        lda  nxtrk       
106
+        sta  steps       
107
+        asl  steps      ;  steps*2
108
+;
109
+        lda  #$60       ;  set status=stepping
110
+        sta  drvst       
111
+;
112
+;
113
+;
114
+        lda  (hdrpnt),y         ;  get dest track #
115
+        sta  drvtrk      
116
+fin     jmp  end         
117
+;
118
+;
119
+que20   and  #drvmsk    ;  test if same drive
120
+        cmp  cdrive      
121
+        bne  que05      ;  test if current drive
122
+;
123
+        lda  drvtrk      
124
+        beq  gotu       ;  uninit. track #
125
+;
126
+        sec     ;  calc distance to track
127
+        lda  (hdrpnt),y          
128
+        sbc  drvtrk      
129
+        beq  gotu       ;  on track
130
+;
131
+        sta  nxtrk       
132
+        lda  jobn       ;  save job# and dist to track
133
+        sta  nxtjob      
134
+;
135
+        jmp  que05       
136
+;
137
+;
138
+;
139
+;
140
+gotu    ldx  #4         ;  set track and sectr
141
+        lda  (hdrpnt),y          
142
+        sta  tracc       
143
+;
144
+gotu10  cmp  trknum-1,x          
145
+;
146
+        dex      
147
+        bcs  gotu10      
148
+;
149
+        lda  numsec,x    
150
+        sta  sectr       
151
+;
152
+        txa     ;  set density
153
+        asl  a   
154
+        asl  a   
155
+        asl  a   
156
+        asl  a   
157
+        asl  a          ; to high order
158
+        sta  work        
159
+;
160
+        lda  dskcnt      
161
+        and  #$9f       ;  clear density bits
162
+        ora  work        
163
+        sta  dskcnt     ; set density bits
164
+;
165
+;
166
+        lda  job        ;  yes, go do the job
167
+        cmp  #bump-$80          ;  test for bump
168
+        beq  bmp         
169
+;
170
+;
171
+;
172
+        cmp  #frmt-$80          ;  is it a format code
173
+        beq  fmt         
174
+;
175
+        jmp  seak       ;  do a sector seek
176
+fmt     jmp  formt      ;  do the format
177
+;
178
+;
179
+bmp              
180
+        lda  dskcnt      
181
+        and  #$ff-$03   ;  set phase a
182
+        sta  dskcnt      
183
+        lda  #$60       ;  set status=stepping
184
+        sta  drvst       
185
+;
186
+        lda  #256-92    ;  step back 45 traks
187
+        sta  steps       
188
+        lda  #1         ;  drvtrk now 1
189
+        sta  drvtrk      
190
+        jmp  errr        
191
+;
192
+setjb   ldy  jobn        
193
+setjb1  lda  jobs,y      
194
+        pha      
195
+        bpl  setj10     ;  no job here
196
+;
197
+        and  #$78        
198
+        sta  job         
199
+        tya      
200
+        asl  a   
201
+        adc  #<hdrs     ; hdrpnt,trk,sec for job
202
+        sta  hdrpnt      
203
+        lda  #>hdrs      
204
+        sta  hdrpnt+1    
205
+        tya     ;  point at buffer
206
+        clc      
207
+        adc  #>bufs      
208
+        sta  bufpnt+1    
209
+;
210
+;
211
+setj10  ldy  #0          
212
+        sty  bufpnt      
213
+;
214
+        pla      
215
+        rts      

+ 47
- 0
DOS_1551/com.src View File

@@ -0,0 +1,47 @@
1
+;**********************************************
2
+;*                                            *
3
+;*   commodore business machines software     *
4
+;*                                            *
5
+;**********************************************
6
+;*                                            *
7
+;*    4         88888888        1             *
8
+;*    4  4      8      8      1 1             *
9
+;*    4  4      88888888        1             *
10
+;*    4444444   8      8        1             *
11
+;*       4      8      8        1             *
12
+;*       4      88888888     1111111          *
13
+;*                                            *
14
+;*                                            *
15
+;**********************************************
16
+;*                                            *
17
+;*   disk operating system and controller     *
18
+;*   routines.                                *
19
+;*                                            *
20
+;*   copyright (c) 1984 by                    *
21
+;*   commodore business machines (cbm)  ds    *
22
+;*                                            *
23
+;**********************************************
24
+;
25
+;     01/23/84  :: 01/23/84 ::: 01/23/84
26
+;
27
+;**********************************************
28
+;*   this software is furnished for use in    *
29
+;*  the double/single tedisk floppy disk unit.*
30
+;*                                            *
31
+;*   copies thereof may not be provided or    *
32
+;*  made available for use on any other       *
33
+;*  system.                                   *
34
+;*                                            *
35
+;*   the information in this document is      *
36
+;*  subject to change without notice.         *
37
+;*                                            *
38
+;*   no responsibility is assumed for         *
39
+;*  reliability of this software.             *
40
+;*                                            *
41
+;**********************************************
42
+        .page  'dos  version  011684'    
43
+;
44
+;
45
+;
46
+;       .end
47
+;

+ 53
- 0
DOS_1551/con.src View File

@@ -0,0 +1,53 @@
1
+; 08/26/83 ds
2
+;
3
+;
4
+;    *conhdr
5
+;
6
+;    convert header
7
+;    into gcr search image
8
+;    and place in stab
9
+;
10
+;   image contains :
11
+;
12
+;   00 id id tr sc cs hbid
13
+;
14
+;
15
+conhdr  lda  bufpnt+1   ; save buffer pointer
16
+        sta  savpnt+1    
17
+;
18
+        lda  #>ovroff    
19
+        sta  bufpnt+1    
20
+;
21
+        lda  #$11       ; store in staboff @$0111
22
+        sta  gcrpnt      
23
+;
24
+        lda  #hbid       
25
+        sta  btab        
26
+;
27
+        lda  header+4    
28
+        sta  btab+1      
29
+;
30
+        lda  header+3    
31
+        sta  btab+2      
32
+;
33
+        lda  header+2    
34
+        sta  btab+3      
35
+;
36
+        jsr  put4bg      
37
+;
38
+        lda  header+1    
39
+        sta  btab        
40
+;
41
+        lda  header      
42
+        sta  btab+1      
43
+;
44
+        lda  #0          
45
+        sta  btab+2      
46
+        sta  btab+3      
47
+;
48
+        jsr  put4bg      
49
+;
50
+        lda  savpnt+1   ; restore buffer pointer
51
+        sta  bufpnt+1    
52
+;
53
+        rts      

+ 35
- 0
DOS_1551/cop.src View File

@@ -0,0 +1,35 @@
1
+;11/28/83 ds
2
+;
3
+; dskcpy check for type
4
+; and parses special case
5
+;
6
+dskcpy           
7
+        lda  #$e0       ; kill bam buffer
8
+        sta  bufuse      
9
+        jsr  clnbam     ; clr tbam
10
+        jsr  bam2x      ; get bam lindx in .x
11
+        lda  #$ff        
12
+        sta  buf0,x     ; mark bam out-of-memory
13
+        lda  #$0f        
14
+        sta  linuse     ; free all lindxs
15
+        jsr  prscln     ; find ":"
16
+        bne  dx0000      
17
+        jmp  duplct     ; bad command error, cx=x not allowed
18
+;
19
+dx0000  jsr  tc30       ; normal parse
20
+dx0005  jsr  alldrs     ; put drv's in filtbl
21
+        lda  image      ; get parse image
22
+        and  #%01010101         ; val for patt copy
23
+        bne  dx0020     ; must be concat or normal
24
+        ldx  filtbl     ; chk for *
25
+        lda  cmdbuf,x    
26
+        cmp  #'*         
27
+        bne  dx0020      
28
+;
29
+dx0010  lda  #badsyn    ; syntax error
30
+        jmp  cmderr      
31
+dx0020  lda  image      ; chk for normal
32
+        and  #%11011001          
33
+        bne  dx0010      
34
+        jmp  copy        
35
+;       .end

+ 74
- 0
DOS_1551/d1551.src View File

@@ -0,0 +1,74 @@
1
+	.nam "1551 DOS"
2
+	.include com
3
+	.include var
4
+	.include dos
5
+	.include equ
6
+	.include io
7
+	.include iod
8
+	.include ram
9
+	.include it2
10
+	.include trp
11
+	.include dnm
12
+	.include par
13
+	.include drv
14
+	.include lup
15
+	.include trn
16
+	.include scr
17
+	.include dup
18
+	.include cop
19
+	.include all
20
+	.include ren
21
+	.include mem
22
+	.include blo
23
+	.include fnd
24
+	.include ts2
25
+	.include ts3
26
+	.include ts4
27
+	.include job
28
+	.include add
29
+	.include ope
30
+	.include clo
31
+	.include opc
32
+	.include tst
33
+	.include tsu
34
+	.include ssu
35
+	.include sst
36
+	.include get
37
+	.include rl1
38
+	.include rl2
39
+	.include rl3
40
+	.include rl4
41
+	.include sse
42
+	.include rec
43
+	.include nul
44
+	.include adr
45
+	.include nes
46
+	.include erp
47
+	.include utl
48
+	.include dsk
49
+	.include idl
50
+	.include lst
51
+	.include ver
52
+	.include new
53
+	.include maw
54
+	.include fre
55
+	.include tfn
56
+	.include rom
57
+	.include vec
58
+	.include dis
59
+	.include ini
60
+	.include cnt
61
+	.include see
62
+	.include con
63
+	.include led
64
+	.include red
65
+	.include wrt
66
+	.include gcr
67
+	.include bin
68
+	.include gbn
69
+	.include uti
70
+	.include fin
71
+	.include fm2
72
+	.include fm3
73
+	.include fm4
74
+	.end

+ 32
- 0
DOS_1551/dis.src View File

@@ -0,0 +1,32 @@
1
+;**********************************************
2
+;*                                            *
3
+;*   commodore business machines software     *
4
+;*                                            *
5
+;**********************************************
6
+;
7
+;**********************************************
8
+;*                                            *
9
+;*   disk controller routines                 *
10
+;*   copyright (c) 1984 by                    *
11
+;*   commodore business machines (cbm)        *
12
+;*   ds                                       *
13
+;*                                            *
14
+;**********************************************
15
+;
16
+;
17
+;
18
+;**********************************************
19
+;*   this software is furnished for use in    *
20
+;*   ted disk unit only.                      *
21
+;*                                            *
22
+;*   copies thereof may not be provided or    *
23
+;*   made available for use on any other      *
24
+;*   system.                                  *
25
+;*                                            *
26
+;*   the information in this document is      *
27
+;*   subject to change without notice.        *
28
+;*                                            *
29
+;*   no responsibility is assumed for         *
30
+;*   reliability of this software.            *
31
+;*                                     ds     *
32
+;**********************************************

+ 56
- 0
DOS_1551/dnm.src View File

@@ -0,0 +1,56 @@
1
+;08/22/84 ds
2
+;********************************
3
+;**  change device number util.**
4
+;**  & sector increment util.  **
5
+;********************************
6
+;
7
+chgdnm           
8
+        ldx  cmdsiz     ; check for drive number after command
9
+        dex      
10
+        beq  chgtgl     ; if none then toggle what you have
11
+        lda  cmdbuf+1    
12
+        tay     ; save
13
+        cmp  #'R        ; is it "r" if so then goto cmd section
14
+        beq  cmdsec      
15
+        cmp  #'S        ; is it "s" if so then goto cmd section
16
+        beq  cmdsec      
17
+        cmp  #'9        ; is it "9"
18
+        beq  donine      
19
+        cmp  #'8        ; * * * "8"
20
+        bne  chgerr      
21
+doeght           
22
+        ldx  #$08        
23
+        bne  donchg      
24
+chgtgl  lda  tedrv      ; toggle what you have
25
+        cmp  #$08        
26
+        beq  donine      
27
+        bne  doeght      
28
+chgerr           
29
+        lda  #badcmd    ; invalid drive number or syntax
30
+        jmp  cmderr      
31
+donine           
32
+        ldx  #$09        
33
+donchg           
34
+        stx  tedrv       
35
+        txa      
36
+adjdrv  asl  a   
37
+        asl  a          ; shft into bit 2
38
+        and  #%00000100          
39
+        eor  #%00000100         ; $fef0 = 1, $fec0 = 0
40
+        sta  tdstat      
41
+        lda  portc       
42
+        and  #%11111011         ; clear bit 2
43
+        ora  tdstat     ; or in dev#
44
+        sta  portc       
45
+        rts      
46
+;
47
+cmdsec  dex      
48
+        beq  chgerr     ; br, error
49
+        ldx  #$01       ; just in case
50
+        lda  cmdbuf+2   ; retrieve
51
+        cpy  #'R        ; br, retry w/ x=1
52
+        beq  rtyok       
53
+        dex     ; x=0
54
+rtyok   sta  secinc,x   ; change sector interleave or retry
55
+        rts      
56
+;       .end

+ 40
- 0
DOS_1551/dos.src View File

@@ -0,0 +1,40 @@
1
+        .page  'dos.var'         
2
+; 09/02/83 ds
3
+;
4
+;
5
+;
6
+c3po2    *=*+1          ; extra byte buffered flag
7
+bsour2   *=*+1          ; extra byte buffered
8
+xspsv    *=*+1          ; stack pointer save area
9
+tlkact   *=*+1          ; active talker flag
10
+lsnact   *=*+1          ; active listen flag
11
+;
12
+;
13
+;  for par interface stuff
14
+;
15
+;
16
+dskver   *=*+2          ; disk version
17
+;
18
+;
19
+;  constants
20
+;
21
+jmpc     =$50   ;  jump command
22
+bumpc    =$40   ;  bump command
23
+execd    =$60   ;  execute command
24
+bufs     =$0300         ;  start of buffers
25
+tolong   =$2    ;  format errors
26
+tomany   =$3     
27
+tobig    =$4     
28
+tosmal   =$5     
29
+notfnd   =$6     
30
+skip2    =$2c   ;  bit abs
31
+topwrt   =255   ;  top of stack
32
+gap2     =  4   ;  gap after data block min size
33
+rdmax    =  6   ;  sector distance wait
34
+wrtmin   =  9    
35
+disbf    =  $80          
36
+wrtmax   =  12   
37
+tim      =58    ; irq rate for 15ms
38
+;
39
+;
40
+;       .end

+ 114
- 0
DOS_1551/drv.src View File

@@ -0,0 +1,114 @@
1
+;12/06/83 ds
2
+;set 1st drive and table pointers
3
+onedrv  lda  f2cnt       
4
+        sta  f1cnt       
5
+        lda  #1          
6
+        sta  f2cnt       
7
+        sta  f2ptr       
8
+
9
+;set up all drives from f2cnt
10
+alldrs  ldy  lstdrv     ; set up drive #'s...
11
+        ldx  #0         ; ...into file entry table... 
12
+ad10    stx  f1ptr      ; ...on sector ptr byte
13
+        lda  filtbl,x    
14
+        jsr  setdrv      
15
+        ldx  f1ptr       
16
+        sta  filtbl,x   ; incr ptr past ":"
17
+        tya     ; bits rep drives
18
+        sta  fildrv,x   ; bit7: default
19
+        inx     ; bit0: drive #
20
+        cpx  f2cnt       
21
+        bcc  ad10        
22
+        rts      
23
+
24
+;set drive number
25
+;  determines drive # from text or
26
+;  uses default (-d)
27
+;  a: in,out: index, cmdbuf
28
+;  y: in: default drive!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29
+;    out: drive number, - if default
30
+
31
+setdrv  tax     ; x= cmdbuf index
32
+        ldy  #0         ; set default drive to zero!!!!!!!!!!!!!!!!!!!!!
33
+        lda  #':         
34
+        cmp  cmdbuf+1,x         ; for xxx:file
35
+        beq  sd40       ;       ~ 
36
+        cmp  cmdbuf,x   ; for xxx:file
37
+        bne  sd20       ;        ~
38
+        inx     ; found ":", so...
39
+sd20    tya     ; drive= default
40
+sd22    and  #1         ; convert to numeric
41
+sd24    tay     ; restore drive
42
+        txa     ; a=index & xxxxfile
43
+        rts     ;               ~
44
+
45
+sd40    lda  cmdbuf,x    
46
+        inx     ;  xxx:file
47
+        inx     ;    --~
48
+        cmp  #'0        ; for xx0:file
49
+        beq  sd22       ;         ~
50
+        cmp  #'1        ; for xx1:file
51
+        beq  t0v2       ;         ~     error !!!!!!!!!!
52
+        bne  sd20       ; cmd:file or xx,:file
53
+sd50     =*     ;     ~           ~
54
+        tya     ; for xxx,file or xx=file
55
+        ora  #$80       ;         ~          ~
56
+        and  #$81       ; drive= -default
57
+        bne  sd24       ; finish testing
58
+
59
+;set drive from any config.
60
+setany  lda  #0          
61
+        sta  image       
62
+        ldy  filtbl      
63
+sa05    lda  (cb),y      
64
+        jsr  tst0v1      
65
+        bpl  sa20        
66
+        iny      
67
+        cpy  cmdsiz      
68
+        bcs  sa10        
69
+        ldy  cmdsiz      
70
+        dey      
71
+        bne  sa05        
72
+sa10    dec  image       
73
+        lda  #0          
74
+;default to zero!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75
+sa20    and  #1          
76
+        sta  drvnum      
77
+        rts      
78
+;toggle drvnum
79
+togdrv  lda  drvnum      
80
+        eor  #1          
81
+        and  #1          
82
+        sta  drvnum      
83
+        rts      
84
+
85
+;set ptrs to one file stream & chk type
86
+fs1set  ldy  #0          
87
+        lda  f1cnt       
88
+        cmp  f2cnt       
89
+        beq  fs15        
90
+        dec  f2cnt       
91
+        ldy  f2cnt       
92
+        lda  filtbl,y    
93
+        tay      
94
+        lda  (cb),y      
95
+        ldy  #ntypes-1   
96
+fs10    cmp  typlst,y    
97
+        beq  fs15        
98
+        dey      
99
+        bne  fs10        
100
+fs15    tya      
101
+        sta  typflg      
102
+        rts      
103
+
104
+;test char in accum for "0" or "1"
105
+tst0v1  cmp  #'0         
106
+        beq  t0v1        
107
+        cmp  #'1         
108
+        beq  t0v2        
109
+        ora  #$80        
110
+t0v1    and  #$81        
111
+        rts      
112
+
113
+t0v2    lda  #badcmd     
114
+        jmp  cmderr      

+ 256
- 0
DOS_1551/dsk.src View File

@@ -0,0 +1,256 @@
1
+;02/13/84 ds
2
+;***********************************************************
3
+;
4
+; hardware error display routine
5
+;
6
+;***********************************************************
7
+power0  ldx  #$00        
8
+	.byte    $2c    ;  skip next two bytes
9
+powerr  ldx  temp       ;  get error #
10
+        txs     ;  save error # in sp due to bad ram
11
+;
12
+;
13
+perr0   tsx     ;  retrieve
14
+perr1   lda  #$6f       ;  setup ports
15
+        sta  ddrb2      ;  data dir. regs
16
+        and  #$60       ;  *
17
+        sta  dskcnt     ;  turn on led
18
+;
19
+        tya      
20
+per2a   clc     ;  waste time
21
+perr3   adc  #$01        
22
+        bne  perr3       
23
+        dey      
24
+        bne  per2a       
25
+        lda  #$68       ;  turn off leds
26
+        sta  dskcnt     ;  *
27
+;
28
+perr4   tya      
29
+perr5   clc      
30
+perr6   adc  #$01       ;  waste more time
31
+        bne  perr6       
32
+        dey      
33
+        bne  perr5       
34
+        dex      
35
+        bpl  perr1      ;  blinked enough times ?
36
+;
37
+        cpx  #$f4       ;  waste a whole lot of time
38
+        bne  perr4       
39
+        beq  perr0       
40
+;
41
+;
42
+perr    jmp  powerr      
43
+pezro   jmp  power0      
44
+;**************************************************************
45
+;                     d i s k  i n i t
46
+;**************************************************************
47
+;
48
+dskint  sei      
49
+        cld      
50
+;
51
+;
52
+;*********************************
53
+;                                *
54
+;      power up diagnostic       *
55
+;                                *
56
+;*********************************
57
+;
58
+        ldy  #0          
59
+        ldx  #2          
60
+pu10    txa     ; fill z-page accend pattern
61
+        sta  $0,x        
62
+        inx      
63
+        bne  pu10        
64
+        ldx  #2          
65
+pu20    txa     ; check pattern by inc...
66
+        cmp  $0,x       ; ...back to orig #
67
+        bne  pezro      ; bad bits
68
+pu30             
69
+        inc  $0,x       ; bump contents
70
+        iny      
71
+        bne  pu30       ; not done
72
+;
73
+        cmp  $0,x       ; check for good count
74
+        bne  pezro      ; something's wrong
75
+;
76
+        sty  $0,x       ; leave z-page zeroed
77
+        lda  $0,x       ; check it
78
+        bne  pezro      ; wrong
79
+;
80
+        inx     ; next!
81
+        bne  pu20       ; not all done
82
+;
83
+;
84
+; test two 64k-bit roms
85
+;
86
+; enter x=start page
87
+; exit if ok
88
+;
89
+rm10    inc  temp       ; next error #
90
+        stx  ip+1       ; save page, start x=0
91
+        lda  #0          
92
+        sta  ip         ; zero lo indirect
93
+        tay      
94
+        ldx  #64        ; 64 pages in 16k rom
95
+        clc      
96
+rt10    dec  ip+1       ; do it backwards
97
+rt20    adc  (ip),y     ; total checksum in a
98
+        iny      
99
+        bne  rt20        
100
+        dex      
101
+        bne  rt10        
102
+        sta  ledflg      
103
+        adc  #$ff       ; add in last carry & -1
104
+        bne  perr        
105
+
106
+; test all common ram
107
+;
108
+cr20    lda  #$01       ; start of 1st block
109
+cr30    sta  ip+1       ; save page #
110
+        inc  temp       ; bump error #
111
+; enter x=# of pages in block
112
+;  ip ptr to first page in block
113
+; exit if ok
114
+;
115
+ramtst  ldx  #7         ; save page count
116
+ra10    tya     ; fill with adr sensitive pattern
117
+        clc      
118
+        adc  ip+1        
119
+        sta  (ip),y      
120
+        iny      
121
+        bne  ra10        
122
+        inc  ip+1        
123
+        dex      
124
+        bne  ra10        
125
+        ldx  #7         ; restore page count
126
+ra30    dec  ip+1       ; check pattern backwards
127
+ra40    dey      
128
+        tya     ; gen pattern again
129
+        clc      
130
+        adc  ip+1        
131
+        cmp  (ip),y     ; ok ?
132
+        bne  perr2      ; no - show error #
133
+        eor  #$ff       ; yes - test inverse pattern
134
+        sta  (ip),y      
135
+        eor  (ip),y     ; ok ?
136
+        sta  (ip),y     ; leave memory zero
137
+        bne  perr2      ; no - show error #
138
+        tya      
139
+        bne  ra40        
140
+        dex      
141
+        bne  ra30        
142
+;
143
+        beq  diagok      
144
+;
145
+perr2   jmp  perr        
146
+
147
+;
148
+
149
+;
150
+diagok           
151
+        ldx  #topwrt     
152
+        stx  eoiflg     ; *
153
+        txs     ; set (sp)
154
+        jsr  cmdrst      
155
+;
156
+;**********************************
157
+;
158
+; controller initialization
159
+;
160
+;**********************************
161
+;
162
+        jsr  cntint      
163
+
164
+;
165
+dskit1  lda  #17        ; set up sector offset
166
+        sta  secinc      
167
+        lda  #5          
168
+        sta  revcnt     ; set up recovery count
169
+;
170
+; initialize buffer pntr table
171
+;
172
+inttab  ldx  #0          
173
+        ldy  #0          
174
+intt1   lda  #0          
175
+        sta  buftab,x    
176
+        inx      
177
+        lda  bufind,y    
178
+        sta  buftab,x    
179
+        inx      
180
+        iny      
181
+        cpy  #bfcnt      
182
+        bne  intt1       
183
+;
184
+        lda  #<cmdbuf   ; set pntr to cmdbuf
185
+        sta  buftab,x    
186
+        inx      
187
+        lda  #>cmdbuf    
188
+        sta  buftab,x    
189
+        inx      
190
+        lda  #<errbuf   ; set pntr to errbuf
191
+        sta  buftab,x    
192
+        inx      
193
+        lda  #>errbuf    
194
+        sta  buftab,x    
195
+;
196
+        lda  #$ff        
197
+        ldx  #maxsa      
198
+dskin1  sta  lintab,x    
199
+        dex      
200
+        bpl  dskin1      
201
+;
202
+        ldx  #mxchns-1   
203
+dskin2           
204
+        sta  buf0,x     ; set buffers as unused
205
+        sta  buf1,x      
206
+        sta  ss,x        
207
+        dex      
208
+        bpl  dskin2      
209
+;
210
+        lda  #bfcnt     ; set buffer pointers
211
+        sta  buf0+cmdchn         
212
+        lda  #bfcnt+1    
213
+        sta  buf0+errchn         
214
+        lda  #$ff        
215
+        sta  buf0+blindx         
216
+        sta  buf1+blindx         
217
+
218
+        lda  #errchn     
219
+        sta  lintab+errsa        
220
+        lda  #cmdchn+$80         
221
+        sta  lintab+cmdsa        
222
+        lda  #lxint     ; lindx 0 to 5 free
223
+        sta  linuse      
224
+
225
+        lda  #rdylst     
226
+        sta  chnrdy+cmdchn       
227
+        lda  #rdytlk     
228
+        sta  chnrdy+errchn       
229
+        lda  #$e0        
230
+        sta  bufuse      
231
+        lda  #$ff        
232
+        sta  bufuse+1    
233
+        lda  #1          
234
+        sta  wpsw        
235
+        sta  wpsw+1      
236
+        jsr  usrint     ; init user jmp
237
+        jsr  lruint      
238
+;
239
+
240
+;*
241
+;*******************************
242
+;*
243
+;*    seterr
244
+;*    set up power on error msg
245
+;*
246
+;*    cbm dos v2.6 tdsk
247
+;*
248
+;*******************************
249
+;*
250
+;*
251
+;
252
+seterr  lda  #$73        
253
+        jsr  errts0      
254
+;
255
+;
256
+;must be contiguous to .file idle

+ 48
- 0
DOS_1551/dup.src View File

@@ -0,0 +1,48 @@
1
+;08/22/84 ds
2
+; duplicate disk
3
+
4
+duplct  lda  #badcmd     
5
+        jmp  cmderr     ;  single drv
6
+;
7
+; format routine
8
+;
9
+;  have controller format disk
10
+;
11
+format  lda  #3          
12
+        jsr  seth        
13
+        ldx  #3          
14
+;
15
+        lda  #$f0       ; format cmd
16
+        sta  tsttrk     ; init speed var
17
+        sta  fmtsav     ; save cmd
18
+;
19
+        jsr  stbfmt     ; give it to the controller
20
+;
21
+;read track one sector zero
22
+;
23
+        lda  #1         ; track 1
24
+        sta  hdrs+6     ; *
25
+        lda  #0         ; sector 0
26
+        sta  hdrs+7     ; *
27
+        lda  #$80       ; read
28
+        sta  fmtsav      
29
+        jmp  stbfmt     ; sector read on track 1, sector 0
30
+;
31
+stbfmt  ldy  #3         ; 3 retries
32
+fmtstb  lda  fmtsav     ; get cmd
33
+        sta  jobs,x     ; give job to controller
34
+        jsr  stbctl     ; wake him up
35
+        cmp  #2         ; error?
36
+        bcc  okfmt       
37
+        lda  #$ff        
38
+        sta  ftnum      ; reset cntrl track
39
+        sta  tsttrk      
40
+        dey      
41
+        bne  fmtstb      
42
+;
43
+        ldx  #0         ; set for offset for buffer to det. trk & sect.
44
+        jmp  error      ; show error
45
+;
46
+okfmt   rts     ; good return
47
+;
48
+;       .end

+ 1
- 0
DOS_1551/edtini.src View File

@@ -0,0 +1 @@
1
+set mode change

+ 49
- 0
DOS_1551/equ.src View File

@@ -0,0 +1,49 @@
1
+        .page  'equate.sf'       
2
+;08/17/83 ds
3
+;******************************
4
+;*  equates
5
+;******************************
6
+;
7
+zp2      =*     ; save zero page for dos
8
+rom      =$c000         ; first rom address
9
+;
10
+lrf      =$80   ; last record flag
11
+dyfile   =$40   ; dirty flag for rr file
12
+ovrflo   =$20   ; rr print overflow
13
+nssl     =6     ; # of side-sector links
14
+ssioff   =4+nssl+nssl   ; offset into ss for data block ptrs
15
+nssp     =120   ; # of ptrs in ss
16
+mxchns   =6     ; max # channels in system
17
+maxsa    =18    ; max sa # +1
18
+vererr   =7     ; controller verify error
19
+cr       =$0d   ;  carriage return
20
+bfcnt    =5     ; available  buffer count
21
+cbptr    =bfcnt+bfcnt   ; command buffer ptr
22
+errchn   =mxchns-1      ; error channel #
23
+errsa    =16    ; error channel sa #
24
+cmdchn   =mxchns-2      ; command channel #
25
+lxint    =%00001111     ; power up linuse (logical index usage
26
+blindx   =6     ; bam lindx for floating bams
27
+cmdsa    =15    ; command channel sa #
28
+apmode   =2     ; open append mode
29
+mdmode   =3     ; open modify mode
30
+rdmode   =0     ; open read mode
31
+wtmode   =1     ; open write mode
32
+reltyp   =4     ; open relative type
33
+dirtyp   =7     ; open direct type
34
+seqtyp   =1     ; open sequential type
35
+prgtyp   =2     ; open program type
36
+usrtyp   =3     ; open user type
37
+typmsk   =7     ; mask for type bits
38
+irsa     =17    ; internal read sa #
39
+iwsa     =18    ; internal write sa #
40
+dosver   =2     ; dos version
41
+fm2030   =$42   ; 2030 format version
42
+fm4040   =$41   ; 4040 format version
43
+
44
+;controller job types
45
+
46
+mxfils   =5     ;  max # filenames in string
47
+dirlen   =24    ; directory length used
48
+nbsiz    =27    ; nambuf text size
49
+cmdlen   =41    ; length of command buffer

+ 416
- 0
DOS_1551/erp.src View File

@@ -0,0 +1,416 @@
1
+;11/28/83 ds
2
+; error processing 
3
+
4
+; controller errors
5
+;  0  (1)  no error
6
+; 20  (2)  can't find block header
7
+; 21  (3)  no synch character
8
+; 22  (4)  data block not present
9
+; 23  (5)  checksum error in data
10
+; 24  (16) byte decoding error
11
+; 25  (7)  write-verify error
12
+; 26  (8)  write w/ write protect on
13
+; 27  (9)  checksum error in header
14
+; 28  (10) data extends into next block
15
+; 29  (11) disk i.d. mismatch
16
+
17
+; command errors
18
+; 30  general syntax
19
+; 31  invalid command
20
+; 32  long line
21
+; 33  invalid filname
22
+; 34  no file given
23
+; 39  command file not found
24
+
25
+; 50  record not present
26
+; 51  overflow in record
27
+; 52  file too large
28
+
29
+; 60  file open for write
30
+; 61  file not open
31
+; 62  file not found
32
+; 63  file exists
33
+; 64  file type mismatch
34
+; 65  no block
35
+; 66  illegal track or sector
36
+; 67  illegal system t or s
37
+
38
+; 70  no channels available
39
+; 71  directory error
40
+; 72  disk full
41
+; 73  cbm dos v2.6 tdisk
42
+; 74  drive not ready
43
+
44
+;  1  files scratched response
45
+
46
+badsyn   =$30    
47
+badcmd   =$31    
48
+longln   =$32    
49
+badfn    =$33    
50
+nofile   =$34    
51
+nocfil   =$39    
52
+norec    =$50    
53
+recovf   =$51    
54
+bigfil   =$52    
55
+filopn   =$60    
56
+filnop   =$61    
57
+flntfd   =$62    
58
+flexst   =$63    
59
+mistyp   =$64    
60
+noblk    =$65    
61
+badts    =$66    
62
+systs    =$67    
63
+nochnl   =$70    
64
+direrr   =$71    
65
+dskful   =$72    
66
+cbmv2    =$73    
67
+nodriv   =$74    
68
+        .page    
69
+; error message table
70
+;   leading errror numbers,
71
+;   text with 1st & last chars 
72
+;   or'ed with $80,
73
+;   tokens for key words are
74
+;   less than $10 (and'ed w/ $80)
75
+
76
+errtab          ; " ok"
77
+	.byte    0,$a0,'O',$cb   
78
+;"read error"
79
+	.byte    $20,$21,$22,$23,$24,$27         
80
+	.byte    $d2,'EAD',$89   
81
+;" file too large"
82
+	.byte    $52,$83,' TOO LARG',$c5       
83
+;" record not present"
84
+	.byte    $50,$8b,6,' PRESEN',$d4        
85
+;"overflow in record"
86
+	.byte    $51,$cf,'VERFLOW '     
87
+	.byte    'IN',$8b        
88
+;" write error"
89
+	.byte    $25,$28,$8a,$89         
90
+;" write protect on"
91
+	.byte    $26,$8a,' PROTECT O',$ce      
92
+;" disk id mismatch"
93
+	.byte    $29,$88,' ID',$85      
94
+;"syntax error"
95
+	.byte    $30,$31,$32,$33,$34     
96
+	.byte    $d3,'YNTAX',$89         
97
+;" write file open"
98
+	.byte    $60,$8a,3,$84   
99
+;" file exists"
100
+	.byte    $63,$83,' EXIST',$d3   
101
+;" file type mismatch"
102
+	.byte    $64,$83,' TYPE',$85    
103
+;"no block"
104
+	.byte    $65,$ce,'O BLOC',$cb   
105
+;"illegal track or sector"
106
+	.byte    $66,$67,$c9,'LLEGAL TRACK'     
107
+	.byte    ' OR SECTO',$d2       
108
+;" file not open"
109
+	.byte    $61,$83,6,$84   
110
+;" file not found"
111
+	.byte    $39,$62,$83,6,$87       
112
+;" files scratched"
113
+	.byte    1,$83,'S SCRATCHE',$c4         
114
+;"no channel"
115
+	.byte    $70,$ce,'O CHANNE',$cc         
116
+;"dir error"
117
+	.byte    $71,$c4,'IR',$89        
118
+;" disk full"
119
+	.byte    $72,$88,' FUL',$cc     
120
+;"cbm dos v2.6 tdisk" !!!!!
121
+	.byte    $73,$c3,'BM DOS V2.6 TDIS',$cb       
122
+;"drive not ready"
123
+	.byte    $74,$c4,'RIVE',6,' READ',$d9   
124
+
125
+; error token key words
126
+;   words used more than once
127
+;"error"
128
+	.byte    9,$c5,'RRO',$d2         
129
+;"write"
130
+	.byte    $a,$d7,'RIT',$c5        
131
+;"file"
132
+	.byte    3,$c6,'IL',$c5          
133
+;"open"
134
+	.byte    4,$cf,'PE',$ce          
135
+;"mismatch"
136
+	.byte    5,$cd,'ISMATC',$c8      
137
+;"not"
138
+	.byte    6,$ce,'O',$d4   
139
+;"found"
140
+	.byte    7,$c6,'OUN',$c4         
141
+;"disk"
142
+	.byte    8,$c4,'IS',$cb          
143
+;"record"
144
+	.byte    $b,$d2,'ECOR',$c4       
145
+etend    =*      
146
+        .page    
147
+; controller error entry
148
+;   .a= error #
149
+;   .x= job #
150
+error   pha      
151
+        stx  jobnum      
152
+        txa      
153
+        asl  a   
154
+        tax      
155
+        lda  hdrs,x     ; 4/12*****;recall track,sector
156
+        sta  track       
157
+        lda  hdrs+1,x   ; 4/12*********
158
+        sta  sector      
159
+
160
+        pla      
161
+        and  #$f        ; convert controller...
162
+        beq  err1       ; ...errors to dos errors
163
+        cmp  #$f        ; check nodrive error
164
+        bne  err2        
165
+;
166
+        lda  #nodriv     
167
+        bne  err3       ; bra
168
+err1             
169
+        lda  #6         ; code=16-->14
170
+err2    ora  #$20        
171
+        tax      
172
+        dex      
173
+        dex      
174
+        txa      
175
+err3             
176
+        pha      
177
+        lda  cmdnum      
178
+        cmp  #val        
179
+        bne  err4        
180
+        lda  #$ff        
181
+        sta  cmdnum      
182
+        pla      
183
+        jsr  errmsg      
184
+        jsr  initdr     ; init for validate
185
+        jmp  cmder3      
186
+err4             
187
+        pla      
188
+cmder2           
189
+        jsr  errmsg      
190
+cmder3           
191
+        jsr  clrcb      ; clear cmdbuf
192
+        lda  #0          
193
+        sta  wbam       ; clear after error
194
+        jsr  erron      ; set error led
195
+        jsr  freich     ; free internal channel
196
+        lda  #0         ; clear pointers
197
+        sta  buftab+cbptr        
198
+        ldx  #topwrt     
199
+        txs     ;  purge stack
200
+        lda  orgsa       
201
+        and  #$f         
202
+        sta  sa          
203
+        cmp  #$f         
204
+        beq  err10       
205
+        lda  lsnact      
206
+        bne  lsnerr      
207
+        lda  tlkact      
208
+        bne  tlkerr      
209
+;
210
+        ldx  sa          
211
+        lda  lintab,x    
212
+        cmp  #$ff        
213
+        beq  err10       
214
+        and  #$f         
215
+        sta  lindx       
216
+        jmp  tlerr       
217
+;
218
+
219
+; talker error recovery
220
+;  if command channel, release dav
221
+;  if data channel, force not ready
222
+;   and release channel
223
+tlkerr           
224
+        jsr  fndrch      
225
+        jsr  xflsh       
226
+        jmp  tlerr      ; finish
227
+
228
+; listener error recovery
229
+;  if command channel, release rfd
230
+;  if data channel, force not ready
231
+;   and release channel
232
+lsnerr           
233
+        jsr  fndwch      
234
+        jsr  ilerr       
235
+tlerr            
236
+        jsr  typfil      
237
+        cmp  #reltyp     
238
+        bcs  err10       
239
+        jsr  frechn      
240
+err10            
241
+        ldx  #topwrt     
242
+        txs      
243
+        jmp  idle        
244
+        .page    
245
+; convert hex to bcd
246
+hexdec  tax      
247
+        lda  #0          
248
+        sed      
249
+hex0    cpx  #0          
250
+        beq  hex5        
251
+        clc      
252
+        adc  #1          
253
+        dex      
254
+        jmp  hex0        
255
+hex5    cld      
256
+
257
+; convert bcd to ascii dec
258
+;  return bcd in .x
259
+;  store ascii in (temp),y
260
+bcddec  tax      
261
+        lsr  a   
262
+        lsr  a   
263
+        lsr  a   
264
+        lsr  a   
265
+        jsr  bcd2        
266
+        txa      
267
+bcd2             
268
+        and  #$f         
269
+        ora  #$30        
270
+        sta  (cb+2),y    
271
+        iny      
272
+        rts      
273
+
274
+; transfer error message to
275
+;  error buffer
276
+;
277
+okerr            
278
+        jsr  erroff      
279
+        lda  #0          
280
+errts0           
281
+        ldy  #0          
282
+        sty  track       
283
+        sty  sector      
284
+;
285
+errmsg           
286
+        ldy  #0          
287
+        ldx  #<errbuf    
288
+        stx  cb+2        
289
+        ldx  #>errbuf    
290
+        stx  cb+3        
291
+        jsr  bcddec     ; convert error #
292
+        lda  #',         
293
+        sta  (cb+2),y    
294
+        iny      
295
+        lda  errbuf      
296
+        sta  chndat+errchn       
297
+        txa     ; error # in .x
298
+        jsr  ermove     ; move message
299
+
300
+ermsg2  lda  #',         
301
+        sta  (cb+2),y    
302
+        iny      
303
+        lda  track       
304
+        jsr  hexdec     ; convert track #
305
+        lda  #',         
306
+        sta  (cb+2),y    
307
+        iny      
308
+        lda  sector     ; convert sector #
309
+        jsr  hexdec      
310
+        dey      
311
+        tya      
312
+        clc      
313
+        adc  #<errbuf    
314
+        sta  lstchr+errchn      ; set last char
315
+        inc  cb+2        
316
+        lda  #rdytlk     
317
+        sta  chnrdy+errchn       
318
+        rts      
319
+;
320
+;**********************************;
321
+;*    ermove - move error message *;
322
+;*      from errtab to errbuf.    *;
323
+;*      fully recursive for token *;
324
+;*      word prosessing.          *;
325
+;*   input: .a= bcd error number  *;
326
+;**********************************;
327
+;
328
+ermove           
329
+        tax     ; save .a
330
+        lda  r0         ; save r0,r0+1
331
+        pha      
332
+        lda  r0+1        
333
+        pha      
334
+        lda  #<errtab   ; set pointer to table
335
+        sta  r0          
336
+        lda  #>errtab    
337
+        sta  r0+1        
338
+        txa     ; restore .a
339
+        ldx  #0         ; .x=0 for indirect
340
+e10              
341
+        cmp  (r0,x)     ; ?error # = table entry?
342
+        beq  e50        ; yes, send message
343
+;
344
+        pha     ; save error #
345
+        jsr  eadv2      ; check & advance ptr
346
+        bcc  e30        ; more #'s to check
347
+e20              
348
+        jsr  eadv2      ; advance past this message
349
+        bcc  e20         
350
+e30              
351
+        lda  r0+1       ; check ptr
352
+        cmp  #>etend     
353
+        bcc  e40        ; <, continue
354
+        bne  e45        ; >, quit
355
+;
356
+        lda  #<etend     
357
+        cmp  r0          
358
+        bcc  e45        ; past end of table
359
+e40              
360
+        pla     ; restor error #
361
+        jmp  e10        ; check next entry
362
+e45              
363
+        pla     ; pop error #
364
+        jmp  e90        ; go quit
365
+;
366
+e50             ; the number has been located
367
+        jsr  eadv1       
368
+        bcc  e50        ; advance past other #'s
369
+e55