Browse Source

added DOS_1551

master
Michael Steil 6 months 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 @@
;11/28/83 ds
; add file to directory

addfil lda sa ; save variables
pha
lda lindx
pha
lda sector
pha
lda track
pha
lda #irsa
sta sa
jsr curblk ; use last accessed search
lda type
pha
lda fildrv
and #1
sta drvnum
ldx jobnum
eor lstjob,x
lsr a
bcc af08 ; same drive as required

ldx #1
stx delind ; look for deleted entry
jsr srchst
beq af15 ; all full, new sector
bne af20 ; found one

af08 lda delsec
beq af10 ; deleted entry not located
cmp sector
beq af20 ; sector is resident
sta sector
jsr drtrd ; read sector in
jmp af20

af10 lda #1 ; find deleted entry
sta delind
jsr search
bne af20
af15 jsr nxdrbk ; all full, new sector
lda sector
sta delsec
lda #2
sta delind
af20 lda delind
jsr setpnt
pla
sta type ; set type
cmp #reltyp
bne af25
ora #$80
af25
jsr putbyt
pla
sta filtrk ; ...table & entry
jsr putbyt
pla
sta filsec ; set sector link in...
jsr putbyt ; ...table & entry
jsr getact
tay
lda filtbl
tax
lda #16
jsr trname ; transfer name
ldy #16
lda #0 ; clear # of blocks &...
af30 sta (dirbuf),y ; ...& replace links
iny
cpy #27
bcc af30
lda type ; a relative file ?
cmp #reltyp
bne af50 ; no
ldy #16 ; yes
lda trkss ; get ss track
sta (dirbuf),y ; put in directory
iny
lda secss ; get ss sector
sta (dirbuf),y ; put in
iny
lda rec ; get record size
sta (dirbuf),y
af50 jsr drtwrt ; write it out
pla
sta lindx
tax
pla
sta sa
lda delsec
sta entsec
sta dsec,x
lda delind
sta entind
sta dind,x
lda type
sta pattyp
lda drvnum
sta fildrv
rts

+ 177
- 0
DOS_1551/adr.src View File

@@ -0,0 +1,177 @@
;11/28/83 ds
;*********************************
;* addrel: add blocks to relative*
;* file. *
;* vars: *
;* regs: *
;* *
;*********************************
;
addrel
jsr setdrn
jsr ssend ; set up end of file
jsr posbuf
jsr dbset
lda ssind
sta r1 ; save ss index
lda ssnum
sta r0 ; save ss number
lda #0
sta r2 ; clear flag for one block
;
lda #0 ; clear for calculation...
sta recptr ; ...to 1st byte in record
jsr fndrel ; calc ss ptrs
addr1 ; entry for rel record fix
jsr numfre ; calc available...
;
ldy lindx ; record span?
ldx rs,y
dex
txa
clc
adc relptr
bcc ar10 ; no span
;
inc ssind ; inc ss ptrs & check
inc ssind ; inc ss ptrs & check
bne ar10
inc ssnum
lda #ssioff
sta ssind
ar10
lda r1
clc
adc #2
jsr setssp
;
lda ssnum
cmp #nssl
bcc ar25 ; valid range
;
ar20
lda #bigfil
jsr cmderr ; too many ss's
ar25
lda ssind ; calc # blocks needed...
sec ; ...& check against avail.
sbc r1
bcs ar30
sbc #ssioff-1
clc
ar30
sta t3 ; # ss indices
lda ssnum
sbc r0
sta t4 ; # ss needed
;
ldx #0 ; clear accum.
stx t1
stx t2
tax ; .x=# ss
jsr sscalc ; calc # of blocks needed
;
lda t2
bne ar35
ldx t1
dex
bne ar35
;
inc r2
ar35
cmp nbtemp+1
bcc ar40 ; ok!!
bne ar20
lda nbtemp
cmp t1
bcc ar20 ; not enuf blocks
ar40
lda #1
jsr drdbyt ; look at sector link
clc
adc #1 ; +1 is nr
ldx lindx
sta nr,x
jsr nxtts ; get next block...
jsr setlnk ; ...& set link.
lda r2
bne ar50 ; add one block
;
jsr wrtout ; write current last rec
ar45
jsr dblbuf ; switch bufs
jsr sethdr ; set hdr from t & s
jsr nxtts ; get another
jsr setlnk ; set up link
jsr nulbuf ; clean it out
jmp ar55
ar50
jsr dblbuf ; switch bufs
jsr sethdr ; set hdr from t & s
jsr nulbuf ; clean buffer
jsr nullnk ; last block =0,lstchr
ar55
jsr wrtout ; write buffer
jsr getlnk ; get t&s from link
lda track
pha ; save 'em
lda sector
pha
jsr gethdr ; now get hdr t&s
lda sector
pha ; save 'em
lda track
pha
jsr gsspnt ; check ss ptr
tax
bne ar60
;
jsr newss ; need another ss
lda #ssioff
jsr setssp ; .a=bt val
inc r0 ; advance ss count
ar60
pla
jsr putss ; record t&s...
pla
jsr putss ; ...in ss.
pla ; get t&s from link
sta sector
pla
sta track
beq ar65 ; t=0: that's all!!
;
lda r0
cmp ssnum
bne ar45 ; not even done yet
;
jsr gsspnt
cmp ssind
bcc ar45 ; almost done
beq ar50 ; one more block left
ar65
jsr gsspnt
pha
lda #0
jsr ssdir
lda #0
tay
sta (dirbuf),y
iny
pla
sec
sbc #1
sta (dirbuf),y
jsr wrtss ; write ss
jsr watjob
jsr mapout
jsr fndrel
jsr dblbuf ; get back to leading buffer
jsr sspos
bvs ar70
jmp positn
ar70
lda #lrf
jsr setflg
lda #norec
jsr cmderr

+ 17
- 0
DOS_1551/all.src View File

@@ -0,0 +1,17 @@
;11/28/83 ds
;
; set up subroutine
;
pups1 lda #0
sta rec
sta drvcnt
sta filtrk
sta filtrk+1
lda fildrv+1 ; get drive number
and #1 ; only
sta drvnum
ora #1
sta delsec ; nonzero
lda filtbl+1 ; fn1=fn2
sta filtbl
rts

+ 255
- 0
DOS_1551/bin.src View File

@@ -0,0 +1,255 @@
; 08/17/83 ds
;
;
put4bg lda #0 ; clear table
sta gtab+1
sta gtab+4
;
ldy gcrpnt
;
lda btab
and #$f0
lsr a
lsr a
lsr a
lsr a
tax
lda bgtab,x
;
asl a
asl a
asl a
sta gtab
;
lda btab
and #$0f
tax
lda bgtab,x
;
ror a
ror gtab+1
ror a
ror gtab+1
;
and #$07
ora gtab
sta (bufpnt),y
;
iny
;
lda btab+1
and #$f0
lsr a
lsr a
lsr a
lsr a
tax
lda bgtab,x
;
asl a
ora gtab+1
sta gtab+1
;
;
lda btab+1
and #$0f
tax
lda bgtab,x
;
rol a
rol a
rol a
rol a
sta gtab+2
;
rol a
and #1
ora gtab+1
sta (bufpnt),y
;
iny
;
lda btab+2
and #$f0
lsr a
lsr a
lsr a
lsr a
tax
lda bgtab,x
;
clc
ror a
ora gtab+2
sta (bufpnt),y
iny
;
ror a
and #$80
sta gtab+3
;
lda btab+2
and #$0f
tax
lda bgtab,x
asl a
asl a
and #$7c
ora gtab+3
sta gtab+3
;
lda btab+3
and #$f0
lsr a
lsr a
lsr a
lsr a
tax
lda bgtab,x
;
ror a
ror gtab+4
ror a
ror gtab+4
ror a
ror gtab+4
;
and #$03
ora gtab+3
sta (bufpnt),y
iny
bne bing35
;
lda savpnt+1
sta bufpnt+1
lda #$00
sta bufpnt
;
;
bing35 lda btab+3
and #$0f
tax
lda bgtab,x
ora gtab+4
sta (bufpnt),y
iny
sty gcrpnt
rts
;
;
;
bgtab .byte $0a
.byte $0b
.byte $12
.byte $13
.byte $0e
.byte $0f
.byte $16
.byte $17
.byte $09
.byte $19
.byte $1a
.byte $1b
.byte $0d
.byte $1d
.byte $1e
.byte $15
;
;
;
;******************************
;*
;*
;* binary to gcr conversion
;*
;*
;* does inplace conversion of
;* buffer to gcr using overflow
;* block
;*
;*
;* creates write image
;*
;* 1 block id char
;* 256 data bytes
;* 1 check sum
;* 2 off bytes
;* ---
;* 260 binary bytes
;*
;* 260 binary bytes >> 325 gcr
;*
;* 325 = 256 + 69 overflow
;*
;*
;********************************
;*
bingcr lda #0 ; init pointers
sta savpnt
sta bytcnt
;
lda #$60
sta bufpnt
;
lda #$bb ; overflow buff offset
sta gcrpnt ; start saving gcr here
;
sta gcrflg ; buffer converted flag
;
lda bufpnt+1 ; save buffer pointer
sta savpnt+1
;
lda #$00 ; point at (msb $00)+(lsb $60 + offset $bb)
sta bufpnt+1
;
lda #dbid ; store data block id
sta btab ; and next 3 data bytes
;
ldy bytcnt
;
lda (savpnt),y
sta btab+1
iny
;
lda (savpnt),y
sta btab+2
iny
;
lda (savpnt),y
sta btab+3
iny
;
bing07 sty bytcnt ; next byte to get
;
jsr put4bg ; convert and store
;
ldy bytcnt
;
lda (savpnt),y
sta btab
iny
beq bing20
;
lda (savpnt),y
sta btab+1
iny
;
lda (savpnt),y
sta btab+2
iny
;
lda (savpnt),y
sta btab+3
iny
;
bne bing07 ; jmp
;
;
bing20 lda chksum ; store chksum
sta btab+1
;
lda #0 ; store 0 off byte
sta btab+2
sta btab+3
;
jmp put4bg ; convert and store and return

+ 422
- 0
DOS_1551/blo.src View File

@@ -0,0 +1,422 @@
.page 'block'
;08/22/84 ds
; rom 1.1 additions
; user commands

user ldy cmdbuf+1
cpy #'0
bne us10 ; 0 resets pntr

usrint lda #<ublock ; set default block add
sta usrjmp
lda #>ublock
sta usrjmp+1
rts

us10 jsr usrexc ; execute code by table
jmp endcmd

usrexc dey ; entry is(((index-1)and$f)*2)
tya
and #$f
asl a
tay
lda (usrjmp),y
sta ip
iny
lda (usrjmp),y
sta ip+1
jmp (ip)
.page 'block commands'
; open direct access buffer
; from open "#"

opnblk lda lstdrv
sta drvnum
lda sa ; sa is destroyed by this patch
pha
jsr autoi ; init disk for proper channel assignment
pla ; restore sa
sta sa
ldx cmdsiz
dex
bne ob10

lda #1 ; get any buffer
jsr getrch
jmp ob30

ob05 lda #nochnl
jmp cmderr

ob10 ldy #1 ; buffer # is requested
jsr bp05
ldx filsec
cpx #bfcnt ; must be less than 5
bcs ob05

lda #0
sta temp
sta temp+1
sec

ob15
rol temp
rol temp+1
dex
bpl ob15

lda temp
and bufuse
bne ob05 ; buffer is used
lda temp+1
and bufuse+1
bne ob05 ; buf is used

lda temp
ora bufuse ; set buffer as used
sta bufuse
lda temp+1
ora bufuse+1
sta bufuse+1

lda #0 ; set up channel
jsr getrch
ldx lindx
lda filsec
sta buf0,x
tax
lda drvnum
sta jobs,x
sta lstjob,x

ob30 ldx sa
lda lintab,x ; set lindx table
ora #$40
sta lintab,x

ldy lindx
lda #$ff
sta lstchr,y

lda #rndrdy
sta chnrdy,y ; set channel ready

lda buf0,y
sta chndat,y ; buffer # as 1st char
asl a
tax
lda #1
sta buftab,x
lda #dirtyp+dirtyp
sta filtyp,y ; set direct file type
jmp endcmd
.page
; block commands
block ldy #0
ldx #0
lda #'- ; "-" separates cmd from subcmd
jsr parse ; locate sub-cmd
bne blk40

blk10 lda #badcmd
jmp cmderr

blk30 lda #badsyn
jmp cmderr

blk40 txa
bne blk30

ldx #nbcmds-1 ; find command
lda cmdbuf,y
blk50 cmp bctab,x
beq blk60
dex
bpl blk50
bmi blk10

blk60
txa
ora #$80
sta cmdnum
jsr blkpar ; parse parms

lda cmdnum
asl a
tax
lda bcjmp+1,x
sta temp+1
lda bcjmp,x
sta temp

jmp (temp) ; goto command

bctab .byte 'AFRWEP'
nbcmds =*-bctab

bcjmp .word blkalc ; block-allocate
.word blkfre ; block-free
.word blkrd ; block-read
.word blkwt ; block-write
.word blkexc ; block-execute
.word blkptr ; block-pointer

blkpar ldy #0 ; parse block parms
ldx #0
lda #':
jsr parse
bne bp05 ; found ":"

ldy #3 ; else char #3 is beginning
bp05 lda cmdbuf,y
cmp #'
beq bp10

cmp #29 ; skip character
beq bp10

cmp #',
bne bp20

bp10 iny
cpy cmdsiz
bcc bp05

rts ; that's all

bp20 jsr aschex
inc f1cnt
ldy f2ptr
cpx #mxfils-1
bcc bp10

bcs blk30 ; bad syntax

; convert ascii to hex (binary)
; & store conversion in tables
; .y= ptr into cmdbuf
aschex lda #0
sta temp
sta temp+1
sta temp+3

ldx #$ff
ah10 lda cmdbuf,y ; test for dec #
cmp #$40
bcs ah20 ; non-numeric terminates
cmp #$30
bcc ah20 ; non-numeric

and #$f
pha
lda temp+1 ; shift digits (*10)
sta temp+2
lda temp
sta temp+1
pla
sta temp
iny
cpy cmdsiz
bcc ah10 ; still in string

ah20 sty f2ptr ; convert digits to...
clc ; ...binary by dec table
lda #0

ah30 inx
cpx #3
bcs ah40

ldy temp,x
ah35 dey
bmi ah30

adc dectab,x
bcc ah35

clc
inc temp+3
bne ah35

ah40 pha
ldx f1cnt
lda temp+3
sta filtrk,x ; store result in table
pla
sta filsec,x
rts

dectab .byte 1,10,100 ; decimal table

;block-free
blkfre jsr blktst
jsr frets
jmp endcmd

;block-allocate
lda #1
sta wbam
blkalc
jsr blktst

ba10
lda sector
pha
jsr getsec
beq ba15 ; none greater on this track
pla
cmp sector
bne ba30 ; requested sector not avail
jsr wused
jmp endcmd
;
ba15
pla ; pop stack
ba20
lda #0
sta sector
inc track
lda track
cmp maxtrk
bcs ba40 ; gone all the way
;
jsr getsec
beq ba20
ba30
lda #noblk
jsr cmder2
ba40
lda #noblk
jsr cmderr ; t=0,s=0 :none left
;

; block read subs
blkrd2 jsr bkotst ; test parms
jmp drtrd

getsim jsr getpre ; get byte w/o inc
lda (buftab,x)
rts

; block read
blkrd3 jsr blkrd2
lda #0
jsr setpnt
jsr getsim ; y=lindx

sta lstchr,y
lda #rndrdy
sta chnrdy,y
rts
blkrd
jsr blkrd3
jsr rnget1
jmp endcmd

;user direct read, lstchr=$ff
ublkrd
jsr blkpar
jsr blkrd3
lda lstchr,y
sta chndat,y
lda #$ff
sta lstchr,y
jmp endcmd ; (rts)

;block-write
blkwt jsr bkotst

jsr getpnt
tay
dey
cmp #2
bcs bw10
ldy #1

bw10 lda #0 ; set record size
jsr setpnt
tya
jsr putbyt
txa
pha

bw20 jsr drtwrt ; write block
pla
tax
ldy lindx ; 08/22/84 ds fix
jsr rnget2
jmp endcmd

;user dirct write, no lstchr
ublkwt jsr blkpar
jsr bkotst
jsr drtwrt
jmp endcmd


;block-execute
blkexc
jsr blkrd2 ; read block & execute
lda #0

be05 sta temp
ldx jobnum
lda bufind,x
sta temp+1
jsr be10 ; indirect jsr
jmp endcmd

be10 jmp (temp)

;buffer-pointer, set buffer pointer
blkptr jsr buftst
lda jobnum
asl a
tax
lda filsec+1
sta buftab,x
jsr getpre
jsr rnget2 ; set up get
jmp endcmd

;test for allocated buffer..
; ..related to sa
buftst ldx f1ptr
inc f1ptr
lda filsec,x
tay
dey
dey
cpy #$c ; set limit to # of sas
bcc bt20

bt15 lda #nochnl
jmp cmderr

bt20 sta sa
jsr fndrch
bcs bt15
jsr getact
sta jobnum
rts

;test block operation parms
bkotst jsr buftst
;
;test for legal block &..
; ..set up drv, trk, sec
blktst ldx f1ptr
lda filsec,x
and #1
sta drvnum
lda filsec+2,x
sta sector
lda filsec+1,x
sta track
bt05
jsr tschk
rts

; rsr 1/19/80 add autoi to #cmd

+ 221
- 0
DOS_1551/clo.src View File

@@ -0,0 +1,221 @@
;11/28/83 ds
; close the file associated with sa
;
close
lda #0
sta wbam
lda sa
bne cls10 ; directory close
lda #0
sta dirlst ; clear dir list
jsr frechn
cls05
jmp freich
cls10
cmp #$f
beq clsall ; close cmd chanl
jsr clschn ; close channel
lda sa
cmp #2
bcc cls05
;
lda erword
bne cls15 ; last command had an error
jmp endcmd
cls15
jmp scren1
;
clsall
lda #14
sta sa
cls20
jsr clschn
dec sa
bpl cls20
lda erword
bne cls25 ; last command had an error
jmp endcmd
cls25
jmp scren1
;
clschn
ldx sa
lda lintab,x
cmp #$ff
bne clsc28
rts
clsc28
and #$f
sta lindx
;
jsr typfil
cmp #dirtyp
beq clsc30 ; direct channel
cmp #reltyp
beq clsrel
;
jsr fndwch ; look for write channel
bcs clsc31
;
jsr clswrt ; close seq write
jsr clsdir ; close directory
clsc30
jsr mapout ; write bam
clsc31
jmp frechn
;
clsrel
jsr scrub
jsr dblbuf
jsr ssend
ldx ssnum
stx t4
inc t4
lda #0
sta t1
sta t2
lda ssind
sec
sbc #ssioff-2
sta t3
jsr sscalc
ldx lindx
lda t1
sta nbkl,x
lda t2
sta nbkh,x
lda #dyfile
jsr tstflg
beq clsr1
jsr clsdir
clsr1 jmp frechn
;
; close a write chanl
;
clswrt ; close seq write file
ldx lindx
lda nbkl,x
ora nbkh,x
bne clsw10 ; at least 1 block written
;
jsr getpnt
cmp #2
bne clsw10 ; at least 1 byte written
;
lda #cr
jsr putbyt
clsw10
jsr getpnt
cmp #2
bne clsw20 ; not mt buffer
;
jsr dblbuf ; switch bufs
;
ldx lindx
lda nbkl,x
bne clsw15
dec nbkh,x
clsw15
dec nbkl,x
;
lda #0
clsw20
sec
sbc #1 ; back up 1
pha ; save it
lda #0
jsr setpnt
jsr putbyt ; tlink=0
pla ; lstchr count
jsr putbyt
;
jsr wrtbuf ; write out last buffer
jsr watjob ; finish job up
jmp dblbuf ; make sure both bufs ok
;rts
;
; directory close on open write file
;
clsdir ldx lindx ; save lindx
stx wlindx ; &sa
lda sa
pha
lda dsec,x ; get directory sector
sta sector
lda dind,x ; get sector offset
sta index
lda filtyp,x ; drv # in filtyp
and #1
sta drvnum
lda dirtrk
sta track
jsr getact ; allocate a buffer
pha
sta jobnum
jsr drtrd ; read directory sector
ldy #0
lda bufind,x ; .x is job#
sta r0+1
lda index
sta r0
lda (r0),y
and #$20
beq clsd5
jsr typfil
cmp #reltyp
beq clsd6
;
lda (r0),y
and #$8f ; replace file
sta (r0),y
iny
lda (r0),y
sta track
sty temp+2
ldy #27 ; extract replacement link
lda (r0),y ; to last sector
pha
dey
lda (r0),y
bne clsd4
sta track
pla
sta sector
lda #$67
jsr cmder2
clsd4
pha
lda #0
sta (r0),y
iny
sta (r0),y
pla
ldy temp+2
sta (r0),y
iny
lda (r0),y
sta sector
pla
sta (r0),y
jsr delfil ; delete old file
jmp clsd6 ; set close bit
clsd5
lda (r0),y
and #$f
ora #$80
sta (r0),y
clsd6 ldx wlindx
ldy #28 ; set # of blocks
lda nbkl,x
sta (r0),y
iny
lda nbkh,x
sta (r0),y
pla
tax
lda #write ; write directory sector
ora drvnum
jsr doit
pla
sta sa
jmp fndwch ; restore lindx

+ 215
- 0
DOS_1551/cnt.src View File

@@ -0,0 +1,215 @@
;08/22/84 ds
;
;
; *contrl
;
; main controller loop
;
; scans job que for jobs
;
; finds job on current track
; if it exists
;
sysirq pha
txa
pha
tya
pha
tsx ; save current stack pointer
stx savsp ; *
;
top ldy #numjob-1 ; pointer into job que
;
;
cont10
lda jobs,y ; find a job (msb set)
bmi cont30 ; branch if there is a job
dey
bpl cont10
;
lda joberr ; are we to blink?
bne cont22 ; br, we are
;
; check for open files
;
cont11 lda dskcnt ; load in port
ora #8 ; set mask to turn off led(x)
ldy bthdrv ; check to see if drv#(x) has an open file
beq cont21 ; br, it does not
and #$f7 ; else mask led#(x) on
cont21 sta dskcnt
jmp cont25 ;
;
; blink appropriate led
;
cont22
dec errcnt
bpl cont25
lda #30 ; 30*6ms blink rate
sta errcnt
lda dskcnt
eor #$08
sta dskcnt
;
cont25 jmp end
;
cont30
and #drvmsk ; get drive #
tax
cmp cdrive ; test if current drive
beq cont40
;
sta cdrive
and #01
sta drviof ; drive i/o offset 0 or 1
ror a
ror a
ror a ; into msb's
sta work
lda portc ; set in portc
and #%00111111 ; mask
ora work ; set bits
sta portc
jsr turnon ; turn drive on
jmp end ; go clean up
;
;
cont40 lda drvst ; test if motor up to speed
bmi cont50
;
asl a ; test if stepping
bpl que ; not stepping
;
cont50 jmp end
;
;
que lda #$20 ; status=running
sta drvst
;
lda dskcnt ; turn on activity led
and #$f7
sta dskcnt
que9 ldy #numjob-1
sty jobn
;
que10 jsr setjb
bmi que20
;
que05 dec jobn
bpl que10
;
;
ldy nxtjob
jsr setjb1
;
lda nxtrk
sta steps
asl steps ; steps*2
;
lda #$60 ; set status=stepping
sta drvst
;
;
;
lda (hdrpnt),y ; get dest track #
sta drvtrk
fin jmp end
;
;
que20 and #drvmsk ; test if same drive
cmp cdrive
bne que05 ; test if current drive
;
lda drvtrk
beq gotu ; uninit. track #
;
sec ; calc distance to track
lda (hdrpnt),y
sbc drvtrk
beq gotu ; on track
;
sta nxtrk
lda jobn ; save job# and dist to track
sta nxtjob
;
jmp que05
;
;
;
;
gotu ldx #4 ; set track and sectr
lda (hdrpnt),y
sta tracc
;
gotu10 cmp trknum-1,x
;
dex
bcs gotu10
;
lda numsec,x
sta sectr
;
txa ; set density
asl a
asl a
asl a
asl a
asl a ; to high order
sta work
;
lda dskcnt
and #$9f ; clear density bits
ora work
sta dskcnt ; set density bits
;
;
lda job ; yes, go do the job
cmp #bump-$80 ; test for bump
beq bmp
;
;
;
cmp #frmt-$80 ; is it a format code
beq fmt
;
jmp seak ; do a sector seek
fmt jmp formt ; do the format
;
;
bmp
lda dskcnt
and #$ff-$03 ; set phase a
sta dskcnt
lda #$60 ; set status=stepping
sta drvst
;
lda #256-92 ; step back 45 traks
sta steps
lda #1 ; drvtrk now 1
sta drvtrk
jmp errr
;
setjb ldy jobn
setjb1 lda jobs,y
pha
bpl setj10 ; no job here
;
and #$78
sta job
tya
asl a
adc #<hdrs ; hdrpnt,trk,sec for job
sta hdrpnt
lda #>hdrs
sta hdrpnt+1
tya ; point at buffer
clc
adc #>bufs
sta bufpnt+1
;
;
setj10 ldy #0
sty bufpnt
;
pla
rts

+ 47
- 0
DOS_1551/com.src View File

@@ -0,0 +1,47 @@
;**********************************************
;* *
;* commodore business machines software *
;* *
;**********************************************
;* *
;* 4 88888888 1 *
;* 4 4 8 8 1 1 *
;* 4 4 88888888 1 *
;* 4444444 8 8 1 *
;* 4 8 8 1 *
;* 4 88888888 1111111 *
;* *
;* *
;**********************************************
;* *
;* disk operating system and controller *
;* routines. *
;* *
;* copyright (c) 1984 by *
;* commodore business machines (cbm) ds *
;* *
;**********************************************
;
; 01/23/84 :: 01/23/84 ::: 01/23/84
;
;**********************************************
;* this software is furnished for use in *
;* the double/single tedisk floppy disk unit.*
;* *
;* copies thereof may not be provided or *
;* made available for use on any other *
;* system. *
;* *
;* the information in this document is *
;* subject to change without notice. *
;* *
;* no responsibility is assumed for *
;* reliability of this software. *
;* *
;**********************************************
.page 'dos version 011684'
;
;
;
; .end
;

+ 53
- 0
DOS_1551/con.src View File

@@ -0,0 +1,53 @@
; 08/26/83 ds
;
;
; *conhdr
;
; convert header
; into gcr search image
; and place in stab
;
; image contains :
;
; 00 id id tr sc cs hbid
;
;
conhdr lda bufpnt+1 ; save buffer pointer
sta savpnt+1
;
lda #>ovroff
sta bufpnt+1
;
lda #$11 ; store in staboff @$0111
sta gcrpnt
;
lda #hbid
sta btab
;
lda header+4
sta btab+1
;
lda header+3
sta btab+2
;
lda header+2
sta btab+3
;
jsr put4bg
;
lda header+1
sta btab
;
lda header
sta btab+1
;
lda #0
sta btab+2
sta btab+3
;
jsr put4bg
;
lda savpnt+1 ; restore buffer pointer
sta bufpnt+1
;
rts

+ 35
- 0
DOS_1551/cop.src View File

@@ -0,0 +1,35 @@
;11/28/83 ds
;
; dskcpy check for type
; and parses special case
;
dskcpy
lda #$e0 ; kill bam buffer
sta bufuse
jsr clnbam ; clr tbam
jsr bam2x ; get bam lindx in .x
lda #$ff
sta buf0,x ; mark bam out-of-memory
lda #$0f
sta linuse ; free all lindxs
jsr prscln ; find ":"
bne dx0000
jmp duplct ; bad command error, cx=x not allowed
;
dx0000 jsr tc30 ; normal parse
dx0005 jsr alldrs ; put drv's in filtbl
lda image ; get parse image
and #%01010101 ; val for patt copy
bne dx0020 ; must be concat or normal
ldx filtbl ; chk for *
lda cmdbuf,x
cmp #'*
bne dx0020
;
dx0010 lda #badsyn ; syntax error
jmp cmderr
dx0020 lda image ; chk for normal
and #%11011001
bne dx0010
jmp copy
; .end

+ 74
- 0
DOS_1551/d1551.src View File

@@ -0,0 +1,74 @@
.nam "1551 DOS"
.include com
.include var
.include dos
.include equ
.include io
.include iod
.include ram
.include it2
.include trp
.include dnm
.include par
.include drv
.include lup
.include trn
.include scr
.include dup
.include cop
.include all
.include ren
.include mem
.include blo
.include fnd
.include ts2
.include ts3
.include ts4
.include job
.include add
.include ope
.include clo
.include opc
.include tst
.include tsu
.include ssu
.include sst
.include get
.include rl1
.include rl2
.include rl3
.include rl4
.include sse
.include rec
.include nul
.include adr
.include nes
.include erp
.include utl
.include dsk
.include idl
.include lst
.include ver
.include new
.include maw
.include fre
.include tfn
.include rom
.include vec
.include dis
.include ini
.include cnt
.include see
.include con
.include led
.include red
.include wrt
.include gcr
.include bin
.include gbn
.include uti
.include fin
.include fm2
.include fm3
.include fm4
.end

+ 32
- 0
DOS_1551/dis.src View File

@@ -0,0 +1,32 @@
;**********************************************
;* *
;* commodore business machines software *
;* *
;**********************************************
;
;**********************************************
;* *
;* disk controller routines *
;* copyright (c) 1984 by *
;* commodore business machines (cbm) *
;* ds *
;* *
;**********************************************
;
;
;
;**********************************************
;* this software is furnished for use in *
;* ted disk unit only. *
;* *
;* copies thereof may not be provided or *
;* made available for use on any other *
;* system. *
;* *
;* the information in this document is *
;* subject to change without notice. *
;* *
;* no responsibility is assumed for *
;* reliability of this software. *
;* ds *
;**********************************************

+ 56
- 0
DOS_1551/dnm.src View File

@@ -0,0 +1,56 @@
;08/22/84 ds
;********************************
;** change device number util.**
;** & sector increment util. **
;********************************
;
chgdnm
ldx cmdsiz ; check for drive number after command
dex
beq chgtgl ; if none then toggle what you have
lda cmdbuf+1
tay ; save
cmp #'R ; is it "r" if so then goto cmd section
beq cmdsec
cmp #'S ; is it "s" if so then goto cmd section
beq cmdsec
cmp #'9 ; is it "9"
beq donine
cmp #'8 ; * * * "8"
bne chgerr
doeght
ldx #$08
bne donchg
chgtgl lda tedrv ; toggle what you have
cmp #$08
beq donine
bne doeght
chgerr
lda #badcmd ; invalid drive number or syntax
jmp cmderr
donine
ldx #$09
donchg
stx tedrv
txa
adjdrv asl a
asl a ; shft into bit 2
and #%00000100
eor #%00000100 ; $fef0 = 1, $fec0 = 0
sta tdstat
lda portc
and #%11111011 ; clear bit 2
ora tdstat ; or in dev#
sta portc
rts
;
cmdsec dex
beq chgerr ; br, error
ldx #$01 ; just in case
lda cmdbuf+2 ; retrieve
cpy #'R ; br, retry w/ x=1
beq rtyok
dex ; x=0
rtyok sta secinc,x ; change sector interleave or retry
rts
; .end

+ 40
- 0
DOS_1551/dos.src View File

@@ -0,0 +1,40 @@
.page 'dos.var'
; 09/02/83 ds
;
;
;
c3po2 *=*+1 ; extra byte buffered flag
bsour2 *=*+1 ; extra byte buffered
xspsv *=*+1 ; stack pointer save area
tlkact *=*+1 ; active talker flag
lsnact *=*+1 ; active listen flag
;
;
; for par interface stuff
;
;
dskver *=*+2 ; disk version
;
;
; constants
;
jmpc =$50 ; jump command
bumpc =$40 ; bump command
execd =$60 ; execute command
bufs =$0300 ; start of buffers
tolong =$2 ; format errors
tomany =$3
tobig =$4
tosmal =$5
notfnd =$6
skip2 =$2c ; bit abs
topwrt =255 ; top of stack
gap2 = 4 ; gap after data block min size
rdmax = 6 ; sector distance wait
wrtmin = 9
disbf = $80
wrtmax = 12
tim =58 ; irq rate for 15ms
;
;
; .end

+ 114
- 0
DOS_1551/drv.src View File

@@ -0,0 +1,114 @@
;12/06/83 ds
;set 1st drive and table pointers
onedrv lda f2cnt
sta f1cnt
lda #1
sta f2cnt
sta f2ptr

;set up all drives from f2cnt
alldrs ldy lstdrv ; set up drive #'s...
ldx #0 ; ...into file entry table...
ad10 stx f1ptr ; ...on sector ptr byte
lda filtbl,x
jsr setdrv
ldx f1ptr
sta filtbl,x ; incr ptr past ":"
tya ; bits rep drives
sta fildrv,x ; bit7: default
inx ; bit0: drive #
cpx f2cnt
bcc ad10
rts

;set drive number
; determines drive # from text or
; uses default (-d)
; a: in,out: index, cmdbuf
; y: in: default drive!!!!!!!!!!!!!!!!!!!!!!!!!!!!
; out: drive number, - if default

setdrv tax ; x= cmdbuf index
ldy #0 ; set default drive to zero!!!!!!!!!!!!!!!!!!!!!
lda #':
cmp cmdbuf+1,x ; for xxx:file
beq sd40 ; ~
cmp cmdbuf,x ; for xxx:file
bne sd20 ; ~
inx ; found ":", so...
sd20 tya ; drive= default
sd22 and #1 ; convert to numeric
sd24 tay ; restore drive
txa ; a=index & xxxxfile
rts ; ~

sd40 lda cmdbuf,x
inx ; xxx:file
inx ; --~
cmp #'0 ; for xx0:file
beq sd22 ; ~
cmp #'1 ; for xx1:file
beq t0v2 ; ~ error !!!!!!!!!!
bne sd20 ; cmd:file or xx,:file
sd50 =* ; ~ ~
tya ; for xxx,file or xx=file
ora #$80 ; ~ ~
and #$81 ; drive= -default
bne sd24 ; finish testing

;set drive from any config.
setany lda #0
sta image
ldy filtbl
sa05 lda (cb),y
jsr tst0v1
bpl sa20
iny
cpy cmdsiz
bcs sa10
ldy cmdsiz
dey
bne sa05
sa10 dec image
lda #0
;default to zero!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sa20 and #1
sta drvnum
rts
;toggle drvnum
togdrv lda drvnum
eor #1
and #1
sta drvnum
rts

;set ptrs to one file stream & chk type
fs1set ldy #0
lda f1cnt
cmp f2cnt
beq fs15
dec f2cnt
ldy f2cnt
lda filtbl,y
tay
lda (cb),y
ldy #ntypes-1
fs10 cmp typlst,y
beq fs15
dey
bne fs10
fs15 tya
sta typflg
rts

;test char in accum for "0" or "1"
tst0v1 cmp #'0
beq t0v1
cmp #'1
beq t0v2
ora #$80
t0v1 and #$81
rts

t0v2 lda #badcmd
jmp cmderr

+ 256
- 0
DOS_1551/dsk.src View File

@@ -0,0 +1,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

+ 48
- 0
DOS_1551/dup.src View File

@@ -0,0 +1,48 @@
;08/22/84 ds