-
Notifications
You must be signed in to change notification settings - Fork 82
/
lcc.fmt1
220 lines (220 loc) · 3.34 KB
/
lcc.fmt1
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
.PAGE 'LCC.FMT1'
;
FMTVAR =$620 ; PUT FORMAT VARS IN JUMP BUFFER
CNT = FMTVAR
NUM = FMTVAR+1
TRYS = FMTVAR+3
TRAL = FMTVAR+4
DTRCK= FMTVAR+6
REMDR= FMTVAR+7
SECT = FMTVAR+8
;
;
;
;* FORMAT ROUTINE FOR LCC
;*
;*
;*
;
;
;
CODE
FORMT LDA FTNUM ; TEST IF FORMATTING BEGUN
BPL L213 ; YES
;
LDX DRIVE ; NO,START UP BY BUMPING
LDA #$60 ; STATUS=STEPPING
STA DRVST,X
;
LDA #1 ; DRIVE TRACK =1
STA DRVTRK,X
STA FTNUM ; START ON TRACK 1
;
LDA #256-92 ; BUMP BACK 45 STEPS
STA STEPS
;
LDA DSKCNT ;SET PHASE A
AND #$FF-$03
STA DSKCNT
;
;
LDA #10 ; 10 ERRORS ALLOWED
STA CNT
;
LDA #<4000 ; FIRST GUESS AT TRACK SIZE
STA NUM
LDA #>4000
STA NUM+1
;
JMP END ; BACK TO CONTROLLER
;
;
;
L213 LDY #0 ; TEST IF ON RIGHT TRACK NUMBER
CMP (HDRPNT),Y
BEQ L214
;
STA (HDRPNT),Y ; GOTO RIGHT TRACK
JMP END
;
;
L214 LDA DSKCNT ; TEST FOR WRITE PROTECT
AND #$10
BNE TOPP ; ITS OK
;
LDA #8 ; WRITE PROTECT ERROR
JMP FMTERR
;
TOPP JSR SYNCLR ; ERASE TRACK WITH SYNC
;
JSR WRTNUM ; WRITE OUT NUM SYNCS
;
LDA #$55 ; WRITE OUT NUM NON SYNC
STA DATA2
;
JSR WRTNUM
;
JSR KILL ; KILL WRITE
;
JSR SYNC ; FIND SYNC
;
LDA #$40 ; SET TIMER MODE
ORA ACR1
STA ACR1
;
LDA #100-2 ; SET UP 100US TIMER
STA T1LL1 ; CONT MODE TIMER
LDA #0
STA T1HL1 ; HI LATCH
STA T1HC1 ; GET ATTENTION OF '22
;
;
;
LDY #0 ; TIME THE SYNC AND NONSYNC SEGMENTS
LDX #0
;
FWAIT BIT DSKCNT ; WAIT FOR SYNC
BMI FWAIT
;
FWAIT2 BIT DSKCNT ; WAIT FOR NO SYNC
BPL FWAIT2
;
F000 LDA T1LC1 ; RESET IFR
;
F001 BIT DSKCNT ; TIME NONSYNC AREA
BPL F005 ; TIME UNTIL SYNC FOUND
;
LDA IFR1 ; TEST FOR TIME OUT
ASL A
BPL F001 ; NOT YET
;
INX ; .X IS LSB
BNE F000
INY ; .Y IS MSB
BNE F000
;
LDA #TOLONG ; CANT FIND SYNC
JMP FMTERR
;
F005 STX T2 ; SAVE TIME
STY T2+1
;
LDX #0 ; TIME SYNC AREA
LDY #0
;
F006 LDA T1LC1 ; RESET IFR
;
F007 BIT DSKCNT ; TEST FOR NO SYNC
BMI F009
;
LDA IFR1 ; TEST FOR TIME OUT
ASL A
BPL F007
;
INX ; COUNT UP ANOTHER 100US
BNE F006
INY ; MSB
BNE F006
;
LDA #TOLONG ; CANT BE THIS LONG
JMP FMTERR
;
;
;* NOW CALC THE DIFFERENCE BETWEEN
;* SYNC AND NONSYNC AND ADJUST
;* NUM ACCORDINGLY
;
F009 SEC ; T1-T2
TXA
SBC T2
TAX
STA T1
;
TYA
SBC T2+1
TAY
STA T1+1
;
BPL F013 ; GET ABS(T1-T2)
;
EOR #$FF ; MAKE +
TAY
TXA
EOR #$FF
TAX
INX
BNE F013
INY
;
F013 TYA ; TEST IF ABS(T1-T2)<4, THAT IS CLOSE ENOUGH
BNE F014 ; MSB MUST BE 0
;
CPX #4 ; TEST LSB < 4
BCC COUNT ; ITS THERE
;
F014 ASL T1 ; NUM=NUM+(DIFF/2)
ROL T1+1
;
CLC
LDA T1
ADC NUM
STA NUM
;
LDA T1+1
ADC NUM+1
STA NUM+1
;
JMP TOPP ; TRY AGAIN SAM
;
;
COUNT LDX #0 ; NOW COUNT #BYTES IN DATA SEGMENT
LDY #0
CLV
;
CNT10 LDA DSKCNT ; TEST FOR SYNC
BPL CNT20 ; FOUND SYNC
BVC CNT10 ; TEST IF BYTE TIME
;
CLV ; YES, COUNT IT
INX
BNE CNT10 ; KEEP COUNTING
INY
BNE CNT10 ; TO MANY ?
;
LDA #TOMANY ; TOMANY COUNTS
JMP FMTERR
;
CNT20 TXA ; #BYTES=COUNT*2
ASL A
STA TRAL+1
;
TYA
ROL A
STA TRAL
;
LDA #$FF-$40 ; CLEAR CONT MODE
AND ACR1
STA ACR1
;
;
.END