-
Notifications
You must be signed in to change notification settings - Fork 85
/
open
124 lines (124 loc) · 2.95 KB
/
open
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
.PAG 'OPEN FILE'
;***********************************
;* *
;* OPEN FUNCTION *
;* *
;* CREATES AN ENTRY IN THE LOGICAL *
;* FILES TABLES CONSISTING OF *
;* LOGICAL FILE NUMBER--LA, DEVICE *
;* NUMBER--FA, AND SECONDARY CMD-- *
;* SA. *
;* *
;* A FILE NAME DESCRIPTOR, FNADR & *
;* FNLEN ARE PASSED TO THIS ROUTINE*
;* *
;***********************************
;
NOPEN LDX LA ;CHECK FILE #
BNE OP98 ;IS NOT THE KEYBOARD
;
JMP ERROR6 ;NOT INPUT FILE...
;
OP98 JSR LOOKUP ;SEE IF IN TABLE
BNE OP100 ;NOT FOUND...O.K.
;
JMP ERROR2 ;FILE OPEN
;
OP100 LDX LDTND ;LOGICAL DEVICE TABLE END
CPX #10 ;MAXIMUM # OF OPEN FILES
BCC OP110 ;LESS THAN 10...O.K.
;
JMP ERROR1 ;TOO MANY FILES
;
OP110 INC LDTND ;NEW FILE
LDA LA
STA LAT,X ;STORE LOGICAL FILE #
LDA SA
ORA #$60 ;MAKE SA AN SERIAL COMMAND
STA SA
STA SAT,X ;STORE COMMAND #
LDA FA
STA FAT,X ;STORE DEVICE #
;
;PERFORM DEVICE SPECIFIC OPEN TASKS
;
BEQ OP175 ;IS KEYBOARD...DONE.
CMP #3
BEQ OP175 ;IS SCREEN...DONE.
BCC OP150 ;ARE CASSETTES 1 & 2
;
JSR OPENI ;IS ON SERIAL...OPEN IT
BCC OP175 ;BRANCH ALWAYS...DONE
;
;PERFORM TAPE OPEN STUFF
;
OP150 CMP #2
BEQ OP153
;
OP152 JSR ZZZ ;SEE IF TAPE BUFFER
BCS OP155 ;YES
;
OP153 JMP ERROR9 ;NO...DEALLOCATED
;
OP155 LDA SA
AND #$F ;MASK OFF COMMAND
BNE OP200 ;NON ZERO IS TAPE WRITE
;
;OPEN CASSETE TAPE FILE TO READ
;
JSR CSTE1 ;TELL "PRESS PLAY"
BCS OP180 ;STOP KEY PRESSED
;
JSR LUKING ;TELL USER "SEARCHING"
;
LDA FNLEN
BEQ OP170 ;LOOKING FOR ANY FILE
;
JSR FAF ;LOOKING FOR NAMED FILE
BCC OP171 ;FOUND IT!!!
BEQ OP180 ;STOP KEY PRESSED
;
OP160 JMP ERROR4 ;FILE NOT FOUND
;
OP170 JSR FAH ;GET ANY OLD HEADER
BEQ OP180 ;STOP KEY PRESSED
BCC OP171 ;ALL O.K.
BCS OP160 ;FILE NOT FOUND...
;
;OPEN CASSETTE TAPE FOR WRITE
;
OP200 JSR CSTE2 ;TELL "PRESS PLAY AND RECORD"
BCS OP180 ;STOP KEY PRESSED
LDA #BDFH ;DATA FILE HEADER TYPE
JSR TAPEH ;WRITE IT
;
;FINISH OPEN FOR TAPE READ/WRITE
;
OP171 LDA #BUFSZ-1 ;ASSUME FORCE READ
;
LDY SA
CPY #$60 ;OPEN FOR READ?
BEQ OP172
;
;SET POINTERS FOR BUFFERING DATA
;
LDY #0
LDA #BDF ;TYPE FLAG FOR BLOCK
STA (TAPE1)Y ;TO BEGIN OF BUFFER
TYA
;
OP172 STA BUFPT ;POINT TO DATA
OP175 CLC ;FLAG GOOD OPEN
OP180 RTS ;EXIT IN PEACE
.SKI 5
OPENI PLA
PLA
JMP ERROR9 ;BAD DEVICE #
.END
; RSR 8/25/80 - ADD RS-232 CODE
; RSR 8/26/80 - TOP OF MEMORY HANDLER
; RSR 8/29/80 - ADD FILENAME TO M51REGS
; RSR 9/02/80 - FIX ORDERING OF RS-232 ROUTINES
; RSR 12/11/81 - MODIFY FOR VIC-40 I/O
; RSR 2/08/82 - CLEAR STATUS IN OPENI
; RSR 5/12/82 - COMPACT RS232 OPEN/CLOSE CODE