-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathhdverdir
254 lines (254 loc) · 6.29 KB
/
hdverdir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
; VALIDATE FILES WITH BAM
; CREATE NEW BAM ACCORDING TO
; CONTENTS OF FILES ENTERED IN DIR
.SKIP
VERDIR
LDA #0 ;RESET ERROR FLAG
STA ERSAVE ;*
LDA #<LOGBEG ;SET UP LOG OUT AREA PTR
STA DSTPTR ;*
LDA #>LOGBEG ;*
STA DSTPTR+1 ;*
JSR CLRCHN ;FREE ALL CHANNELS
JSR SIMPRS ;EXTRACT DRIVE #
LDX #>IFM ;SET UP INIT MSG
LDA #<IFM ;*
JSR MOVCHS ;MOVE MSG TO LOG AREA
JSR INITDR ;INIT THE DRIVE FOR NAME, ID
JSR FLAGVL ;FLAG VOL LBL VIP
JSR GETBUF ;GET A BUFFER
BPL VD09 ;BR IF I GOT ONE
LDA #NOCHNL ;ELSE GIVE THE ERROR
JMP CMDERR
VD09
STA HDTMP1 ;SAVE THE BUFFER ADDR
LDX #>RALM ;SET UP RE-ALLOC MSG
LDA #<RALM ;*
JSR MOVCHS ;MOVE TO LOG OUT AREA
JSR HDRAL ;REBUILD BAM <HD>
LDA HDTMP1 ;GET THE BUFFER ADDR
JSR FREBUF ;FREE THE BUFFER
JSR INITDR ;INITIALIZE THE DRIVE
LDA #0
STA DELIND
JSR MDIRM ;MOVE DIRECTORY MSG
JSR SRCHST ;SEARCH FOR FIRST FILE
BEQ VD10 ;NOT FOUND
JMP VD25 ;FOUND ONE
.SKIP
VD10
LDX DRVNUM ;POINT TO FIRST DIR
LDA HDDS,X ;GET SECTOR <HD>
STA SECTOR ;...IN BAM
LDA HDDT,X ;GET TRACK <HD>
STA TRACK
JSR MRKBAM
JSR HDISU ;SET UP IND WORD <HD>
JSR HDWBM ;WRITE OUT BAM <HD>
;BLOCK COUNT
LDX #>CPERM ;COMPRESS ERR MSG
LDA #<CPERM ;*
JSR MOVCHS ;*
LDA ERSAVE ;CHK IF ANY ERRORS
BNE VD10A ;BR IF ERRORS
JSR COMPRS ;COMPRESS DIRECTORY
VD10A
LDX #>VEND ;LOG VALIDATE END
LDA #<VEND ;*
JSR MOVCHS ;*
LDA ERSAVE ;CHK IF ERROR ALONG THE WAY
BEQ VDA ;BR IF NOT
JSR INITDR
LDA ERSAVE ;GIVE PROPER ERROR CODE
JSR ERROR ;ELSE GIVE ERROR NOW
VDA
JSR UNFLAG ;RESET VIP FLAG IN VOL
LDX DRVNUM ;RESET IN MEM FLAG
LDA #255-HDVIP ;*
AND HDDFLG,X ;*
STA HDDFLG,X ;*
JSR INITDR
JMP ENDCMD
.SKIP
VD15 INY
LDA (DIRBUF),Y
PHA ;SAVE TRACK
INY
LDA (DIRBUF),Y
PHA ;SAVE SECTOR
LDX DIRBUF+1 ;GET HIGH ADDR
LDA DIRBUF ;GET LOW
CLC ;ADD DISP TO FILENAME
ADC #03 ;*
JSR MOVCHS ;MOVE FILENAME TO LOG
LDY #19 ;GET SS TRACK
LDA (DIRBUF),Y ;<HD>
STA TRACK ;YES - SAVE TRACK
INY
LDA (DIRBUF),Y ;GET SS SECTOR
STA SECTOR
LDY #0 ;<HD>
LDA (DIRBUF),Y ;CHK IF REL FILE <HD>
AND #7 ;*
CMP #RELTYP ;*
BNE VD17 ;BR IF NOT RELATIVE FILE
JSR MRKBAM ;VALIDATE SS BY LINKS
VD17 PLA
STA SECTOR ;NOW DO DATA BLOCKS
PLA
STA TRACK
JSR MRKBAM ;SET BIT USED IN BAM
VD20
JSR MDIRM ;MOVE IN DIRECTORY MSG
JSR SRRE ;SEARCH FOR MORE
BNE VD25 ;MORE FILES
JMP VD10 ;NO MORE FILES
VD25
LDY #0
LDA (DIRBUF),Y
BMI VD15
JSR MDIRM ;MOVE IN DIRECTORY MSG
JSR DELDIR ;NOT CLOSED DELETE DIR
JMP VD20
.SKIP
MRKBAM ;MARK BAM WITH FILE SECTORS
JSR USEDTS
LDA #IRSA ;OPEN THE READ CHNL
STA SA ;*
LDA #1 ;*
STA TYPE ;*
LDA #2 ;TWO BUFFERS
JSR GETRCH ;GET LINDX & 2 BUFFS
JSR INTPNT ;INITIALIZE POINTERS
MARK1
JSR SETHDR ;SET UP HEADERS
LDA #$FF ;RETURN TO CALLER ON ERRORS
STA JOBRTN ;*
JSR RDBUF ;ISSUE THE READ
JSR WATJOB ;WAIT FOR COMPLETION
CMP #2 ;CHK FOR ERRORS
BCS MARK2 ;JUMP IF ERROR
JSR GETBYT ;GET NEXT SECTOR ADDR
STA SECTOR ;*
JSR GETBYT ;*
STA TRACK ;*
LDA #$FF ;CHK IF END OF CHAIN
CMP SECTOR ;*
BEQ MARK3 ;BR IF EOC
JSR USEDTS ;MARK SECTOR USED
JMP MARK1
MARK2 ;ERROR ON THE READ
STA ERSAVE ;SAVE THE ERROR CODE
JSR ADVANC ;ADV POINTER
MARK3
JMP FRECHN ;RELEASE THE CHANL & RTS
;***************************************
;
; FLAG VOLUME LABEL TO INDICATE VERIFY
; IN PROGRESS
;
;***************************************
FLAGVL
JSR HDORV ;READ VOLUME LABEL
LDY #HDFLAG ;PT TO FLAG BYTE
LDA (HDBMP),Y ;GET FLAG
ORA #HDVIP ;SET VERIFY IN PROGRESS
STA (HDBMP),Y ;PUT FLAG BACK
FLAG1
JSR HDCSUD ;SET UP
ORA #WRITE ;FOR WRITE
JMP DOIT ;WRITE VOL LBL & RETURN
;***************************************
;
; RESET VOLUME LABEL FLAG
;
;***************************************
UNFLAG
JSR HDORV ;READ THE VOLUME LABEL IN
LDY #HDFLAG ;PT TO FLAG BYTE
LDA (HDBMP),Y ;GET IT
AND #$FF-HDVIP ;RESET VIP BIT
STA (HDBMP),Y ;PUT IT BACK
LDY #HDDB1 ;ADDR OF DIR
LDA NDSEC ;NEW DIR SEC ADDR
STA (HDBMP),Y ;TO VOL LBL
INY ;BUMP TO NEXT
LDA NDTRK ;NEW DIR TRK ADDR
STA (HDBMP),Y ;TO VOL LBL
JMP FLAG1 ;GO WRITE VOL TO DISK
;***************************************
;
; MOVE CHAR STRING TO TRACE AREA
;
;***************************************
MOVCHS
LDY #0 ;OFFSET
STA SRCPTR ;SET UP IND WORD
STX SRCPTR+1 ;*
LDX #16 ;NO MORE THAN 16 CHRS
LDA (DSTPTR),Y ;CHK IF OVERFLOW
CMP #$01 ;*
BEQ MOVCH3 ;IF SO EXIT
MOVCH1
LDA (SRCPTR),Y ;GET
STA (DSTPTR),Y ;PUT
BMI MOVCH2 ;BR IF END OF STRING
INY ;BUMP TO NEXT
DEX ;CHK IF MAX YET
BEQ MOVCH2 ;BR IF END
BNE MOVCH1 ;BRA -LOOP TILL DONE-
MOVCH2
LDA #', ;COMMA
STA (DSTPTR),Y ;*
INY ;BUMP TO NEXT
STY POSNXT ;SAVE PTR TO NEXT
LDA #0 ;*
STA (DSTPTR),Y ;*
MOVCH3
RTS ;EXIT TO CALLER
;***************************************
;
; ADVANCE POINTER & CHECK FOR END OF LOG AREA
;
;***************************************
ADVANC
LDA POSNXT ;ADD OFFSET TO POINTER
CLC ;*
ADC DSTPTR ;*
STA DSTPTR ;16 BITS WORTH
LDA DSTPTR+1 ;*
ADC #0 ;*
STA DSTPTR+1 ;*
LDA #>LOGEND ;CHK IF PAST END OF LOG
CMP DSTPTR+1 ;*
BCS ADVAN1 ;BR IF NOT PAST END
LDA #$01 ;SET OVERFLOW
LDY #0 ;OFFSET
STA (DSTPTR),Y ;STORE OVERFLOW FLAG
ADVAN1
RTS ;EXIT TO CALLER
;***************************************
;
; MOVE IN DIRECTORY READ FAILURE MSG
;
;***************************************
MDIRM
LDX #>DFM ;DIR FAIL MSG
LDA #<DFM ;*
JMP MOVCHS ;JSR RETURN
;***************************************
;
; LOG OUT CANNED MSGS
;
;***************************************
IFM
.BYTE 'INIT FAILED',$80
RALM
.BYTE 'REBUILD BAMS NG',$80
DFM
.BYTE 'DIRECTORY FAILED',$80
VEND
.BYTE 'END',$80
CPERM
.BYTE 'COMPRESS ERROR',$80
.END