-
Notifications
You must be signed in to change notification settings - Fork 84
/
record
151 lines (151 loc) · 2.48 KB
/
record
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
.PAGE 'RECORD'
;*********************************
;* RECORD: POSITION RELATIVE *
;* POINTERS TO GIVEN *
;* RECORD NUMBER OR TO *
;* LAST RECORD IF OUT OF *
;* RANGE. *
;*********************************
;
RECORD
JSR CMDSET ;INIT TABLES, PTRS
LDA CMDBUF+1
STA SA
JSR FNDRCH
BCC R20 ;GOT CHANNEL'S LINDEX
;
LDA #NOCHNL ;NO VALID CHANNEL
JSR CMDERR
R20
LDA #LRF+GETFLG+OVRFLO
JSR CLRFLG
JSR TYPFIL ;GET FILE TYPE
BEQ R30 ;IT IS RELATIVE FILE
;
LDA #MISTYP ;WRONG TYPE
JSR CMDERR
R30
LDA FILTYP,X
AND #1
STA DRVNUM
LDA CMDBUF+2
STA RECL,X ;GET RECORD #
LDA CMDBUF+3
STA RECH,X
LDX LINDX ;CLEAR CHNRDY TO RNDRDY
LDA #RNDRDY
STA CHNRDY,X
;
LDA CMDBUF+4 ;GET OFFSET
BEQ R40
SEC
SBC #1
BEQ R40
CMP RS,X
BCC R35
;
LDA #RECOVF
STA ERWORD
LDA #0
R35
R40
STA RECPTR ;SET OFFSET
JSR FNDREL ;CALC SS STUFF
JSR SSPOS ;SET SS PTRS
BVC R50
;
LDA #LRF ;BEYOND THE END
JSR SETFLG ;SET LAST REC FLAG
JMP RD05
R50
JSR POSITN ;POSITION TO RECORD
LDA #LRF
JSR TSTFLG
BEQ R60
JMP RD05
R60
JMP ENDCMD ;THAT'S ALL
;
;*********************************
;* POSITN: POSITION RELATIVE *
;* DATA BLOCK INTO ACTIVE*
;* BUFFER & NEXT BLOCK *
;* INTO INACTIVE BUFFER. *
;*********************************
;
POSITN
; JSR RESTOR ;RESTORE BUFFER AREAS
JSR POSBUF ;POSITION BUFFERS
LDA RELPTR
JSR SETPNT ;SET PTR FROM FNDREL
;
LDX LINDX
LDA RS,X
SEC ;CALC THE OFFSET
SBC RECPTR
BCS P2
JMP BREAK ;SHOULD NOT BE NEEDED
P2
CLC
ADC RELPTR
BCC P30
ADC #1
SEC
P30
JSR NXOUT ;SET NR
JMP RD15
;*********************************
;* POSBUF: POSITION PROPER DATA *
;* BLOCKS INTO BUFFERS *
;*********************************
;
POSBUF
LDA DIRBUF
STA R3
LDA DIRBUF+1
STA R4
JSR BHERE ;IS BUFFER IN?
BEQ P20 ;YES!
;
JSR SCRUB ;CLEAN BUFFER
JSR GETLNK
LDA TRACK
BEQ P80
JSR DBLBUF ;TRY INACTIVE BUFFER
JSR BHERE ;IS IT THIS BUFFER?
BNE P80 ;NO!
;
JSR GETLNK
LDA TRACK
BEQ P20
;
JSR DBLBUF
JSR RDAB ;READ IN NEXT BUFFER
JSR DBLBUF
P20
RTS
;
P80
LDY #0 ;GET PROPER BLOCK
LDA (R3)Y
STA TRACK
INY
LDA (R3)Y
STA SECTOR
JMP STRDBL ;GET NEXT BLOCK, TOO.
;RTS
;
BHERE
JSR GETHDR ;GET THE HEADER
LDY #0
LDA (R3)Y
CMP TRACK
BEQ BH10 ;TEST SECTOR, TOO.
RTS
BH10
INY
LDA (R3)Y
CMP SECTOR ;SET .Z
RTS
;
.END