-
Notifications
You must be signed in to change notification settings - Fork 82
/
close
167 lines (167 loc) · 3.35 KB
/
close
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
.PAG 'CLOSE 2/15/83'
;*************************************
;* NCLOSE -- CLOSE LOGICAL FILE *
;* *
;* ENTER: *
;* CY =1 ,TRANSMIT CLOSE TO DEV- *
;* ICE. *
;* CY =0 ,ONLY REMOVE FROM KERNAL*
;* TABLES. *
;* *
;* THE LOGICAL FILE NUMBER OF THE*
;* FILE TO BE CLOSED IS PASSED IN .A.*
;* KEYBOARD, SCREEN, AND FILES NOT *
;* OPEN PASS STRAIGHT THROUGH. TAPE *
;* FILES OPEN FOR WRITE ARE CLOSED BY*
;* DUMPING THE LAST BUFFER AND *
;* CONDITIONALLY WRITING AN END OF *
;* TAPE BLOCK.SERIAL FILES ARE CLOSED*
;* BY SENDING A CLOSE FILE COMMAND IF*
;* A SECONDARY ADDRESS WAS SPECIFIED *
;* IN ITS OPEN COMMAND. *
;*************************************
;
NCLOSE PHP ;SAVE CY FLAG
JSR JLTLK ;LOOK FILE UP
BEQ JX110 ;WAS OPEN...CONTINUE
PLP
CLC ;WAS NEVER OPEN...NO ERROR
RTS
;
JX110 JSR JZ100 ;EXTRACT TABLE DATA
PLP ;RETRIEVE CY FLAG
TXA ;SAVE TABLE INDEX
PHA
BCC JX150 ;CLOSE OUT TABLE ENTRIES ONLY
;
LDA FA ;CHECK DEVICE NUMBER
BEQ JX150 ;IS KEYBOARD...DONE
CMP #3
BEQ JX150 ;IS SCREEN...DONE
BCS JX120 ;IS IEEE...PROCESS
CMP #2 ;RS232?
BNE JX115 ;NO...
;
; CLOSE RS-232 FILE
;
CLS232 LDA #0
STA ACIA+CDR ;DO A SOFT RESET
BEQ JX150 ;JMP...REMOVE FILE
;
;
;CLOSE CASSETTE FILE
;
.IFN SYSAGE <
JX115 LDA SA ;WAS IT A TAPE READ?
AND #$F
BEQ JX150 ;YES
;
JSR ZZZ ;NO. . .IT IS WRITE
LDA #0 ;END OF FILE CHARACTER
JSR CASOUT ;PUT IN END OF FILE
JSR WBLK ;EMPTY LAST BUFFER
BCS JX200 ;STOP KEY PRESSED
;
LDA SA
CMP #$62 ;WRITE END OF TAPE BLOCK?
BNE JX150 ;NO...
;
LDA #EOT
JSR TAPEH ;WRITE END OF TAPE BLOCK
JMP JX150
>
.IFE SYSAGE <
JX115 PLA ;CASSETTE NOW CLOSES THE CHANNEL...
JSR JX151 ;BEFORE TRANSMITTING OUT THE FINAL DATA
JSR XTAPE ;GOTO TAPE INDIRECT
>
;
;CLOSE AN IEEE FILE
;
JX120 JSR CLSEI
;
;ENTRY TO REMOVE A GIVE LOGICAL FILE
;FROM TABLE OF LOGICAL, PRIMARY,
;AND SECONDARY ADDRESSES
;
JX150 PLA ;GET TABLE INDEX OFF STACK
JX151 TAX ;ENTRY FOR CASSETTE SPECIAL
DEC LDTND
CPX LDTND ;IS DELETED FILE AT END?
BEQ JX160 ;YES...DONE
;
;DELETE ENTRY IN MIDDLE BY MOVING
;LAST ENTRY TO THAT POSITION.
;
LDY LDTND
LDA LAT,Y
STA LAT,X
LDA FAT,Y
STA FAT,X
LDA SAT,Y
STA SAT,X
JX160 CLC
JX170 RTS ;CLOSE EXIT
.IFN SYSAGE <
JX200 TAX ;STOP KEY EXIT
PLA
TXA ;RESTORE ERROR
RTS
>
.SKI 5
;LOOKUP TABLIZED LOGICAL FILE DATA
;
LOOKUP LDA #0
STA STATUS
TXA
JLTLK LDX LDTND
JX600 DEX
BMI LKUPS4
CMP LAT,X
BNE JX600
CLC
RTS
.SKI 5
;ROUTINE TO FETCH TABLE ENTRIES
;
JZ100 LDA LAT,X
STA LA
LDA FAT,X
STA FA
LDA SAT,X
STA SA
JZ101 RTS
.SKI 5
;
;SA IS PASSED IN .Y
;ROUTINE LOOKS FOR MATCH IN TABLES
;CARRY SET IF NOT PRESENT
;CARRY CLEAR:
;.A=LA,.X=FA,.Y=SA
;
LKUPSA TYA
LDX LDTND
LKUPS2 DEX
BMI LKUPS4
CMP SAT,X
BNE LKUPS2
CLC
LKUPS3 JSR JZ100 ;GET TABLE DATA
TAY
LDA LA
LDX FA
RTS
LKUPS4 SEC
RTS ;NOT FOUND EXIT
.SKI 5
;LA IS PASSED IN .A
;ROUTINE LOOKS FOR MATCH IN TABLES
;CARRY SET IF NOT FOUND
;CARRY CLEAR:
;.A=LA,.X=FA,.Y=SA
;
LKUPLA TAX
JSR LOOKUP
BCC LKUPS3
RTS
.END