forked from mist64/cbmsrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addfil.src
115 lines (103 loc) · 2.88 KB
/
addfil.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
.messg "addfil"
.subttl "addfil"
.page
; 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
ldx jobnum
lda fildrv
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
af09 lda #dskful
jsr cmderr ; disk full
af10 lda #1 ; find deleted entry
sta delind
jsr search
bne af20
af15 jsr nxdrbk ; all full, new sector
lda sector
cmp #sysdirsec
bcc af09 ; must be > sysdirsec
sta delsec
lda #2
sta delind
af20 lda delind
jsr setpnt
pla
sta type ; set type
cmp #reltyp
bne af25
ora #$80
.pag
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 #0
sta fildrv
rts