-
Notifications
You must be signed in to change notification settings - Fork 84
/
tapefile
202 lines (202 loc) · 3.27 KB
/
tapefile
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
.PAG 'TAPE FILES'
;FAH -- FIND ANY HEADER
;
;READS TAPE DEVICE UNTIL ONE OF FOLLOWING
;BLOCK TYPES FOUND: BDFH--BASIC DATA
;FILE HEADER, BLF--BASIC LOAD FILE
;FOR SUCCESS CARRY IS CLEAR ON RETURN.
;FOR FAILURE CARRY IS SET ON RETURN.
;IN ADDITION ACCUMULATOR IS 0 IF STOP
;KEY WAS PRESSED.
;
FAH LDA VERCK ;SAVE OLD VERIFY
PHA
JSR RBLK ;READ TAPE BLOCK
PLA
STA VERCK ;RESTORE VERIFY FLAG
BCS FAH40 ;READ TERMINATED
;
LDY #0
LDA (TAPE1)Y ;GET HEADER TYPE
;
CMP #EOT ;CHECK END OF TAPE?
BEQ FAH40 ;YES...FAILURE
;
CMP #BLF ;BASIC LOAD FILE?
BEQ FAH50 ;YES...SUCCESS
;
CMP #PLF ;FIXED LOAD FILE?
BEQ FAH50 ;YES...SUCCESS
;
CMP #BDFH ;BASIC DATA FILE?
BNE FAH ;NO...KEEP TRYING
;
FAH50 TAX ;RETURN FILE TYPE IN .X
BIT MSGFLG ;PRINTING MESSAGES?
BPL FAH45 ;NO...
;
LDY #MS17-MS1 ;PRINT "FOUND"
JSR MSG
;
;OUTPUT COMPLETE FILE NAME
;
LDY #5
FAH55 LDA (TAPE1)Y
JSR BSOUT
INY
CPY #21
BNE FAH55
;
FAH56 LDA TIME+1 ;SET UP FOR TIME OUT...
JSR FPATCH ;GOTO PATCH...
NOP
;
FAH45 CLC ;SUCCESS FLAG
DEY ;MAKE NONZERO FOR OKAY RETURN
;
FAH40 RTS
.SKI 5
;TAPEH--WRITE TAPE HEADER
;ERROR IF TAPE BUFFER DE-ALLOCATED
;CARRY CLEAR IF O.K.
;
TAPEH STA T1
;
;DETERMINE ADDRESS OF BUFFER
;
JSR ZZZ
BCC TH40 ;BUFFER WAS DE-ALLOCATED
;
;PRESERVE START AND END ADDRESSES
;FOR CASE OF HEADER FOR LOAD FILE
;
LDA STAH
PHA
LDA STAL
PHA
LDA EAH
PHA
LDA EAL
PHA
;
;PUT BLANKS IN TAPE BUFFER
;
LDY #BUFSZ-1
LDA #'
BLNK2 STA (TAPE1)Y
DEY
BNE BLNK2
;
;PUT BLOCK TYPE IN HEADER
;
LDA T1
STA (TAPE1)Y
;
;PUT START LOAD ADDRESS IN HEADER
;
INY
LDA STAL
STA (TAPE1)Y
INY
LDA STAH
STA (TAPE1)Y
;
;PUT END LOAD ADDRESS IN HEADER
;
INY
LDA EAL
STA (TAPE1)Y
INY
LDA EAH
STA (TAPE1)Y
;
;PUT FILE NAME IN HEADER
;
INY
STY T2
LDY #0
STY T1
TH20 LDY T1
CPY FNLEN
BEQ TH30
LDA (FNADR)Y
LDY T2
STA (TAPE1)Y
INC T1
INC T2
BNE TH20
;
;SET UP START AND END ADDRESS OF HEADER
;
TH30 JSR LDAD1
;
;SET UP TIME FOR LEADER
;
LDA #$69
STA SHCNH
;
JSR TWRT2 ;WRITE HEADER ON TAPE
;
;RESTORE START AND END ADDRESS OF
;LOAD FILE.
;
TAY ;SAVE ERROR CODE IN .Y
PLA
STA EAL
PLA
STA EAH
PLA
STA STAL
PLA
STA STAH
TYA ;RESTORE ERROR CODE FOR RETURN
;
TH40 RTS
.SKI 5
;FUNCTION TO RETURN TAPE BUFFER
;ADDRESS IN TAPE1
;
ZZZ LDX TAPE1 ;ASSUME TAPE1
LDY TAPE1+1
CPY #>BUF ;CHECK FOR ALLOCATION...
;...[TAPE1+1]=0 OR 1 MEANS DEALLOCATED
;...C CLR => DEALLOCATED
RTS
.SKI 5
LDAD1 JSR ZZZ ;GET PTR TO CASSETTE
TXA
STA STAL ;SAVE START LOW
CLC
ADC #BUFSZ ;COMPUTE POINTER TO END
STA EAL ;SAVE END LOW
TYA
STA STAH ;SAVE START HIGH
ADC #0 ;COMPUTE POINTER TO END
STA EAH ;SAVE END HIGH
RTS
.SKI 5
FAF JSR FAH ;FIND ANY HEADER
BCS FAF40 ;FAILED
;
;SUCCESS...SEE IF RIGHT NAME
;
LDY #5 ;OFFSET INTO TAPE HEADER
STY T2
LDY #0 ;OFFSET INTO FILE NAME
STY T1
FAF20 CPY FNLEN ;COMPARE THIS MANY
BEQ FAF30 ;DONE
;
LDA (FNADR)Y
LDY T2
CMP (TAPE1)Y
BNE FAF ;MISMATCH--TRY NEXT HEADER
INC T1
INC T2
LDY T1
BNE FAF20 ;BRANCH ALWAYS
;
FAF30 CLC ;SUCCESS FLAG
FAF40 RTS
.END
; RSR 4/10/82 ADD KEY DOWN TEST IN FAH...