-
Notifications
You must be signed in to change notification settings - Fork 82
/
load
238 lines (238 loc) · 4.91 KB
/
load
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
.PAG 'LOAD FUNCTION'
;**********************************
;* LOAD RAM FUNCTION *
;* *
;* LOADS FROM CASSETTE 1 OR 2, OR *
;* SERIAL BUS DEVICES >=4 TO 31 *
;* AS DETERMINED BY CONTENTS OF *
;* VARIABLE FA. VERIFY FLAG IN .A *
;* *
;* ALT LOAD IF SA=0, NORMAL SA=1 *
;* .X , .Y LOAD ADDRESS IF SA=0 *
;* .A=0 PERFORMS LOAD,<> IS VERIFY*
;* *
;* HIGH LOAD RETURN IN X,Y. *
;* *
;**********************************
.SKI 3
LOADSP STX MEMUSS ;.X HAS LOW ALT START
STY MEMUSS+1
LOAD JMP (ILOAD) ;MONITOR LOAD ENTRY
;
NLOAD STA VERCK ;STORE VERIFY FLAG
LDA #0
STA STATUS
;
LDA FA ;CHECK DEVICE NUMBER
BNE LD20
;
LD10 JMP ERROR9 ;BAD DEVICE #-KEYBOARD
;
LD20 CMP #3
BEQ LD10 ;DISALLOW SCREEN LOAD
BCC LD100 ;HANDLE TAPES DIFFERENT
;
;LOAD FROM CBM IEEE DEVICE
;
LDY FNLEN ;MUST HAVE FILE NAME
BNE LD25 ;YES...OK
;
JMP ERROR8 ;MISSING FILE NAME
;
LD25 JSR PATCH2 ;TELL USER LOOKING
LDA #$60 ;SPECIAL LOAD COMMAND
STA SA
JSR OPENI ;OPEN THE FILE
;
LDA FA
JSR TALK ;ESTABLISH THE CHANNEL
LDA SA
JSR TKSA ;TELL IT TO LOAD
;
JSR ACPTR ;GET FIRST BYTE
STA EAL
;
LDA STATUS ;TEST STATUS FOR ERROR
LSR A
LSR A
BCS LD90 ;FILE NOT FOUND...
JSR ACPTR
STA EAH
;
JSR PATCH3 ;TELL USER LOADING
;
;
LD40 LDA #$FD ;MASK OFF TIMEOUT
AND STATUS
STA STATUS
;
JSR STOP ;STOP KEY?
BNE LD45 ;NO...
;
JMP BREAK ;STOP KEY PRESSED
;
LD45 JSR ACPTR ;GET BYTE OFF IEEE
TAX
LDA STATUS ;WAS THERE A TIMEOUT?
LSR A
LSR A
BCS LD40 ;YES...TRY AGAIN
TXA
LDY VERCK ;PERFORMING VERIFY?
BEQ LD50 ;NO...LOAD
LDY #0
CMP (EAL)Y ;VERIFY IT
BEQ LD60 ;O.K....
LDA #SPERR ;NO GOOD...VERIFY ERROR
JSR UDST ;UPDATE STATUS
.BYT $2C ;SKIP NEXT STORE
;
LD50 STA (EAL)Y
LD60 INC EAL ;INCREMENT STORE ADDR
BNE LD64
INC EAH
LD64 BIT STATUS ;EOI?
BVC LD40 ;NO...CONTINUE LOAD
;
JSR UNTLK ;CLOSE CHANNEL
JSR CLSEI ;CLOSE THE FILE
BCC LD180 ;BRANCH ALWAYS
;
LD90 JMP ERROR4 ;FILE NOT FOUND
;
;LOAD FROM TAPE
;
LD100 CMP #2
BNE LD102
;
JMP RS232
;
LD102 JSR ZZZ ;SET POINTERS AT TAPE
BCS LD104
JMP ERROR9 ;DEALLOCATED...
LD104 JSR CSTE1 ;TELL USER ABOUT BUTTONS
BCS LD190 ;STOP KEY PRESSED?
JSR LUKING ;TELL USER SEARCHING
;
LD112 LDA FNLEN ;IS THERE A NAME?
BEQ LD150 ;NONE...LOAD ANYTHING
JSR FAF ;FIND A FILE ON TAPE
BCC LD170 ;GOT IT!
BEQ LD190 ;STOP KEY PRESSED
BCS LD90 ;NOPE...END OF TAPE
;
LD150 JSR FAH ;FIND ANY HEADER
BEQ LD190 ;STOP KEY PRESSED
BCS LD90 ;NO HEADER
;
LD170 LDA STATUS
AND #SPERR ;MUST GOT HEADER RIGHT
SEC
BNE LD190 ;IS BAD
;
CPX #BLF ;IS IT A MOVABLE PROGRAM...
BEQ LD178 ;YES
;
CPX #PLF ;IS IT A PROGRAM
BNE LD112 ;NO...ITS SOMETHING ELSE
;
LD177 LDY #1 ;FIXED LOAD...
LDA (TAPE1)Y ;...THE ADDRESS IN THE...
STA MEMUSS ;...BUFFER IS THE START ADDRESS
INY
LDA (TAPE1)Y
STA MEMUSS+1
BCS LD179 ;JMP ..CARRY SET BY CPX'S
;
LD178 LDA SA ;CHECK FOR MONITOR LOAD...
BNE LD177 ;...YES WE WANT FIXED TYPE
;
LD179 LDY #3 ;TAPEA - TAPESTA
;CARRY SET BY CPX'S
LDA (TAPE1)Y
LDY #1
SBC (TAPE1)Y
TAX ;LOW TO .X
LDY #4
LDA (TAPE1)Y
LDY #2
SBC (TAPE1)Y
TAY ;HIGH TO .Y
;
CLC ;EA = STA+(TAPEA-TAPESTA)
TXA
ADC MEMUSS ;
STA EAL
TYA
ADC MEMUSS+1
STA EAH
LDA MEMUSS ;SET UP STARTING ADDRESS
STA STAL
LDA MEMUSS+1
STA STAH
JSR LODING ;TELL USER LOADING
JSR TRD ;DO TAPE BLOCK LOAD
.BYT $24 ;CARRY FROM TRD
;
LD180 CLC ;GOOD EXIT
;
; SET UP END LOAD ADDRESS
;
LDX EAL
LDY EAH
;
LD190 RTS
.SKI 5
;SUBROUTINE TO PRINT TO CONSOLE:
;
;SEARCHING [FOR NAME]
;
LUKING LDA MSGFLG ;SUPPOSED TO PRINT?
BPL LD115 ;...NO
LDY #MS5-MS1 ;"SEARCHING"
JSR MSG
LDA FNLEN
BEQ LD115
LDY #MS6-MS1 ;"FOR"
JSR MSG
.SKI 3
;SUBROUTINE TO OUTPUT FILE NAME
;
OUTFN LDY FNLEN ;IS THERE A NAME?
BEQ LD115 ;NO...DONE
LDY #0
LD110 LDA (FNADR)Y
JSR BSOUT
INY
CPY FNLEN
BNE LD110
;
LD115 RTS
.SKI 3
;SUBROUTINE TO PRINT:
;
;LOADING/VERIFING
;
LODING LDY #MS10-MS1 ;ASSUME 'LOADING'
LDA VERCK ;CHECK FLAG
BEQ LD410 ;ARE DOING LOAD
LDY #MS21-MS1 ;ARE 'VERIFYING'
LD410 JMP SPMSG
SKIPBY = *
;
; PATCHES FOR DISK AUTO-OFFSET LOAD
;
*=KSP2 ;KERNAL SPACE FOR PATCH 2
PATCH2 LDX SA ;SAVE SA IN .X
JMP LUKING ;GO TELL USER
PATCH3 TXA ;FIND OUT HOW TO LOAD
BNE PATCH4 ;USE PROGRAMS LOAD ADDRESS
LDA MEMUSS ;ELSE MOVE WHERE I WANT
STA EAL
LDA MEMUSS+1
STA EAH
PATCH4 JMP LODING ;TELL USER LOADING
;
KSP3 = * ;KERNAL SPACE FOR PATCH 3
*=SKIPBY
.END