-
Notifications
You must be signed in to change notification settings - Fork 0
/
LOADER SETUP.1.S
456 lines (404 loc) · 4.66 KB
/
LOADER SETUP.1.S
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
LST OFF
DOSWRM = $3D0
LOCFPL = $3DC
BUFFER = $4000
PTR = $00
BUFP = $02
A1L = $3C
NOTQ JSR TEXT
JSR $FC58
JSR $FE93
JSR $FE89
JSR CATA
JSR LOCFPL
STY PTR
STA PTR+1
LDY #$08 ;FILENAME
LDA #INAME
STA (PTR),Y
INY
LDA #/INAME
STA (PTR),Y
LDY #07 ;FILETYPE
LDA #$04 ;BINARY
STA (PTR),Y
LDX #1 ;OLD FILE
JSR OPEN
BCC INOP
JMP ERR
INOP LDA BUFP
STA IBUFF
LDA BUFP+1
STA IBUFF+1
JSR REWIND
* READ ADDRESS/LENGTH
LDA #4
LDY #$06
STA (PTR),Y
LDA #0
INY
STA (PTR),Y
JSR READ
* CLOSE FILES
EXIT LDA OBUFF
STA BUFF
LDA OBUFF+1
STA BUFF+1
JSR CLOSE
LDA IBUFF
STA BUFP
LDA IBUFF+1
STA BUFP+1
JSR CLOSE
RTS
OPEN LDA DOSWRM+2
STA BUFP+1
LDY #0
STY BUFP
* GET FREE BUFFER
GBUF0 LDA (BUFP),Y
PHA
INY
LDA (BUFP),Y
STA BUFP+1
PLA
STA BUFP
BNE GBUF
LDA BUFP+1
BNE GBUF
LDA #12
PHA
JMP ERR
GBUF LDY #0
LDA (BUFP),Y
BEQ GOTBUF
LDY #36
BNE GBUF0
GOTBUF LDA #1
STA (BUFP),Y
* FINISH COMPLETING OPEN LIST
LDY #$00 ;FMOCOD
LDA #$01 ;FMOCOP
STA (PTR),Y
LDA #0
LDY #$02 ;FMRCLN
STA (PTR),Y
INY
STA (PTR),Y
LDY #$04 ;FMVOL
STA (PTR),Y
JSR $3E3 ;LOCRPL
STY A1L
STA A1L+1
LDY #1
LDA (A1L),Y
LSR
LSR
LSR
LSR
LDY #$06 ;FMSLT
STA (PTR),Y
LDY #2
LDA (A1L),Y
LDY #$05 ;FMDRV
STA (PTR),Y
* INTERFACE TO FM
CALLFM LDY #30
CFMLP1 LDA (BUFP),Y
PHA
INY
CPY #36
BCC CFMLP1
LDY #$11 ;FMBUFF+1
CFMLP2 PLA
STA (PTR),Y
DEY
CPY #$C ;FMFMWA
BCS CFMLP2
JMP $3D6 ;FM
* CLOSE
CLOSE LDY #$00 ;FMOCOD
LDA #$02 ;FMOCCL
STA (PTR),Y
JSR CALLFM
BCC CLOK
JMP ERR
CLOK LDY #0
TYA
STA (BUFP),Y
RTS
REWIND LDY #$02
LDA #0
REWLP STA (PTR),Y
INY
CPY #06
BCC REWLP
LDY #00 ;FMOCOD
LDA #$0A ;FMOCPO
STA (PTR),Y
JSR CALLFM
BCC REWRTS
JMP ERR
REWRTS RTS
READ LDA IBUFF
STA BUFP
LDA IBUFF+1
STA BUFP+1
LDA #$03 ;FMOCRD
BNE DOIO
* WRITE
WRITE LDA OBUFF
STA BUFP
LDA OBUFF+1
STA BUFP+1
LDA #$04 ;WRITE
DOIO LDY #$00 ;FMOCOD
STA (PTR),Y
LDY #$01 ;FMSBCD
LDA #$02 ;FMSBRA
STA (PTR),Y
LDY #$08 ;FMRAAD
LDA #BUFFER
STA (PTR),Y
INY
LDA #/BUFFER
STA (PTR),Y
JSR CALLFM
BCC DOIORT
JMP ERR
DOIORT RTS
ERR LDA #$87
JMP $FDF0
LEN = $D6
DEST = $2FA
LP = $1D
JSR $FF58
TSX
LDA $100,X
STA $01
DEX
LDA $100,X
STA $00
LDX #LEN
LDY #LP
MOVE LDA ($00),Y
STA DEST-LP,Y
INY
DEX
BNE MOVE
JMP DEST
INAME ASC "SCREEN PRINT"
ASC " "
IBUFF DS 02
OBUFF DS 02
TEXT = $FB2F
HOME = $FC58
WAIT = $FCA8
PRNIB = $FDE3
VTAB = $FC22
VTABZ = $FC24
CROUT = $FD8E
RDCHAR = $FD35
CHOUT = $FDF0
PRBL2 = $F94A
* DOS PARM EQUATES
*
DRIVE = $B7EA
VOLM = $B7EB
TRACK = $B7EC
SECTOR = $B7ED
BUFF = $B7F0
PART = $B7F3
COMND = $B7F4
ERCODE = $B7F5
CATBUF = $4000
CH = $24
CV = $25
ZL = $80
ZH = $81
COUNT = $01
STEP = $02
DIR = $03
CCBF = $04
SIC = $06
SSIC = $07
ONSC = $08
EFILE = $09
END = $0A
ADDSUB = $E0
CHOICE = $E1
BOB = $00
OUT = 08
TOP = 04
BOT = 19
MID = 10
LEFTAR = $88
RIGHTAR = $95
CATA LDA $B7F8
STA DRIVE
LDA #$01
STA COMND
LDA #$00
STA VOLM
STA PART
STA CCBF
LDA #$F7
STA END
LDA #$00
STA SSIC
LDA #CATBUF
STA BUFF
STA BOB
LDA #/CATBUF
STA BOB+1
STA BUFF+1
CATALOG LDA #$11
STA TRACK
LDA #$0F
STA SECTOR
CAT1 JSR RWTS
LDY #$01
LDA (BOB),Y
STA TRACK
INY
LDA (BOB),Y
STA SECTOR
ORA TRACK
BEQ DOPRINT
INC BUFF+1
INC BOB+1
JMP CAT1
DOPRINT BIT $C010
JSR PCAT
CKEY LDA $C000
BPL CKEY
CMP #$8D
BNE NRET
JSR $FC58
LDA CHOICE
JSR GFILE
LDY #$03
PPPL LDA (CCBF),Y
STA INAME-3,Y
INY
CPY #33
BCC PPPL
LDA #$00
STA $48
JMP $FD8E
NRET CMP #RIGHTAR
BNE NOTLEFT
LDA #$01
STA ADDSUB
INC SSIC
LDA SSIC
CMP END
BNE DOPRINT
DEC SSIC
JMP DOPRINT
NOTLEFT CMP #LEFTAR
BNE NOTRIGHT
LDA #$FF
STA ADDSUB
DEC SSIC
LDA SSIC
CMP #$F8
BNE DOPRINT
INC SSIC
JMP DOPRINT
NOTRIGHT JMP CKEY
PCAT LDA #$00
STA ONSC
LDA SSIC
STA SIC
LDA #TOP
STA CV
JSR VTAB
NXTFILE LDY #OUT
STY CH
NFILE INC SIC
LDA SIC
CMP #$FA
BCS NOTHIS
JSR GFILE
LDY #00
LDA (CCBF),Y
BPL OKFINE
LDA ONSC
BNE NFILE
LDA ADDSUB
CLC
ADC SSIC
STA SSIC
STA SIC
JMP NFILE
OKFINE LDA (CCBF),Y
BEQ NOTHIS
LDY #$02
LDA (CCBF),Y
AND #$07
TAY
LDA TYPE,Y
JSR CHOUT
INC CH
LDY #32
FLOOP LDA (CCBF),Y
DEY
CMP #$A0
BEQ FLOOP
INY
INY
STY EFILE
LDA CV
CMP #MID
BNE NOTMID
LDA SIC
STA CHOICE
LDA #$3F
PNFILE STA $32
NOTMID LDY #$03
OUTFILE LDA (CCBF),Y
JSR CHOUT
INY
CPY EFILE
BCC OUTFILE
LDA #$FF
STA $32
SEC
LDA #32
SBC EFILE
TAX
BILOP JSR PRBL2
JSR CROUT
INC ONSC
LDA ONSC
CMP #BOT
NXTFILE1 BNE NXTFILE
RTS
NOTHIS LDA CV
CMP #MID+1
BNE PTHSP
LDX SSIC
INX
STX END
PTHSP LDX #30
JMP BILOP
RWTS LDY #$E8
LDA #$B7
JMP $B7B5
GFILE LDX #$FF
DIV7 SEC
SBC #$07
INX
BCS DIV7
ADC #$07
TAY
TXA
CLC
ADC #/CATBUF
STA CCBF+1
LDA FNDFILE,Y
STA CCBF
RTS
FNDFILE HEX 0B2E517497BADD
TYPE ASC "TIABB"