-
Notifications
You must be signed in to change notification settings - Fork 82
/
part.src
199 lines (165 loc) · 3.07 KB
/
part.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
.messg "part"
.subttl "part"
.page
; Partition Routines
;
; USAGE: Create
;"/0:par_name,"+chr$(start-trk)+chr$(start-sector)+chr$(lo-blks)+chr$(hi-blks)+",C"
;
; USAGE: Select
;"/0:par_name"
;
part
jsr autoi ; init drive
lda cmdsiz
cmp #2
bcc 8$ ; select default
lda #1
sta filtbl ; set filename
jsr onedrv ; select drive
jsr lookup ; does it exist
lda filtrk
beq 5$ ; no br, file exists
jsr testlimit
bcc 6$ ; no parms must accept as select partition
lda #flexst ; file exists
.byte skip2
2$ lda #flntfd ; file not found
.byte skip2
3$ lda #badsyn ; bad syntax
.byte skip2
4$ lda #illpar ; illegal partition
jsr cmderr
5$ jsr testlimit
bcc 2$ ; no parms can't create partition
ldx limit
lda cmdbuf+6,x
cmp #'C ; create char
bne 3$ ; syntax error
jmp creatpart ; create partition file
6$ lda pattyp
and #typmsk
cmp #partyp ; partition file?
bne 2$
jsr setparts ; set partition t&s
7$ jsr tschk ; check t&s
jsr calcpar ; calc maxtrk, etc...
bne 7$
bcc 4$ ; carry must be set
ldy #2
lda (dirbuf),y ; get sector
bne 4$ ; must be zero
dey
lda track ; get maxtrk
tax ; save
sbc (dirbuf),y ; sub starting track
cmp #2
beq 4$ ; illegal
bcc 4$ ; illegal
lda (dirbuf),y
sta dirtrk ; set system track
sta startrk ; set starting track
stx maxtrk ; set maxtrk
dex
dex
stx pmaxtrk ; set physical maxtrk
jmp 9$ ; bra
8$ jsr setdef ; set default
9$ jsr clrchn ; clear all channels
jsr initdr ; init directory
lda startrk
sta track ; exit with starting track in track position of OK...
ldy maxtrk ; & last track in sector position
dey
sty sector
lda #2 ; ok partition
ldy #0
jmp partend
scanpart
lda wbam
pha
lda ndbl
pha
lda ndbh ; save
pha
jsr settslim ; set t&s limits
1$ jsr tschk ; check limits
lda track
cmp #systrack ; hard system track?
beq 2$ ; br, error
jsr wused ; allocate it
beq 2$ ; already allocated? then error
jsr frets ; freeit
jsr calcpar ; next
bne 1$
pla
sta ndbh
pla
sta ndbl
pla
sta wbam
rts
2$ pla ; restore
sta ndbh
pla
sta ndbl
pla
sta wbam
lda #systs
jmp cmder2 ; error
testlimit
ldx #1
jsr fndlmt ; find = or ,
lda cmdsiz
sec
sbc limit
cmp #4
rts
settslim
ldy limit
iny
lda cmdbuf,y
sta track
iny
lda cmdbuf,y
sta sector
iny
lda cmdbuf,y
sta lo
iny
lda cmdbuf,y
sta hi
clc
lda lo
adc hi
beq 1$ ; =0?
jmp tschk ; chk parms
1$ lda #illpar
jsr cmderr ; illegal partition
creatpart
jsr scanpart ; test range given
lda #partyp ; open partition
sta type
lda #iwsa ; internal write channel
sta sa
jsr settslim ; set t&s limits
jsr opnwch1 ; open internal write channel
jsr addfil ; addfil to directory
jsr settslim ; set t&s limits
1$ jsr tschk ; check limits
lda track
jsr wused ; allocate it
jsr calcpar ; next
bne 1$
jsr settslim ; set t&s limits
ldx lindx
lda lo
sta nbkl,x ; low blks
lda hi
sta nbkh,x ; high blks
lda #0
jsr putbyt ; write one byte, nil
lda #iwsa
sta sa
jsr clschn ; close channel
jmp endcmd