-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathclose.src
154 lines (138 loc) · 3.39 KB
/
close.src
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
.page
.subttl 'close'
;***************************************
;* close -- close logical file *
;* *
;* 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
ror wrbase ;save serial close flag
jsr jltlk ;look file up
beq jx050 ;open...
clc ;else return
rts
jx050
jsr jz100 ;extract table data
txa ;save table index
pha
lda fa ;check device number
beq jx150 ;is keyboard...done
cmp #3
beq jx150 ;is screen...done
bcs jx120 ;is serial address it
cmp #2 ;rs232?
bne jx115 ;no, was tape
;
; rs232 close ;...by brute force
;
php ;!mutex
sei
jsr ainit ;reset pointers, variables, & acia
plp ;!mutex
beq jx150 ;always
;
; close tape data file
;
jx115
lda sa ;was it a tape read?
and #$f
beq jx150 ;yes
ldy tptr ;else a write
cpy #bufmax
bcc jx116 ;buf not full
jsr wfblok ;else write out a full block first
bcs jx117 ;write exception
lda #bdf ;setup new block
sta type
ldy #0
sty tptr
jx116
lda #0
sta (tapebs),y
jsr wfblok ;write out final block
bcc jx118 ;ok
jx117
pla ;get index off stack
lda #0 ;error exit (stop key pressed)
rts
jx118
lda sa ;write eot-block?
cmp #$62
bne jx150 ;no
jsr wreot ;yes
jmp jx150
;
; close a serial file
;
jx120
bit wrbase ;do a real close?
bpl ropen ;yep
lda fa ;no if a disk & sa=$f
cmp #8
bcc ropen ;>8 ==>not a disk, do real close
lda sa
and #$f
cmp #$f
beq jx150 ;sa=$f, no real close
ropen
jsr clsei ;else do a real close
; entry to remove a give logical file
; from table of logical, primary,
; and secondary addresses
jx150
pla ;get table index off stack
tax
dec ldtnd
cpx ldtnd ;is deleted file at end?
beq jx170 ;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
jx170
clc ;close exit
jx175
rts
; lookup tablized logical file data
;
lookup
lda #0
sta status
txa
jltlk
ldx ldtnd
jx600
dex
bmi jz101
cmp lat,x
bne jx600
rts
;
; routine to fetch table entries
;
jz100
lda lat,x
sta la
lda sat,x
sta sa
lda fat,x ;must return w/.a=fa & flags set!
sta fa
jz101
rts
;rsr 5/12/82 - modify for cln232
;end