-
Notifications
You must be signed in to change notification settings - Fork 82
/
addrel.src
180 lines (153 loc) · 2.98 KB
/
addrel.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
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
.page
.subttl addrel
;*********************************
;* addrel: add blocks to relative*
;* file. *
;* vars: *
;* regs: *
;* *
;*********************************
addrel jsr setdrn
jsr ssend ;set up end of file
jsr posbuf
jsr dbset
lda ssind
sta r1 ;save ss index
lda ssnum
sta r0 ;save ss number
lda #0
sta r2 ;clear flag for one block
lda #0 ;clear for calculation...
sta recptr ;...to 1st byte in record
jsr fndrel ;calc ss ptrs
addr1 ; entry for rel record fix
jsr numfre ;calc available...
ldy lindx ;record span?
ldx rs,y
dex
txa
clc
adc relptr
bcc ar10 ;no span
inc ssind ;inc ss ptrs & check
inc ssind ;inc ss ptrs & check
bne ar10
inc ssnum
lda #ssioff
sta ssind
ar10 lda r1
clc
adc #2
jsr setssp
lda ssnum
cmp #nssl
bcc ar25 ;valid range
ar20 lda #bigfil
jsr cmderr ;too many ss's
ar25 lda ssind ;calc # blocks needed...
sec ;...& check against avail.
sbc r1
bcs ar30
sbc #ssioff-1
clc
ar30 sta t3 ;# ss indices
lda ssnum
sbc r0
sta t4 ;# ss needed
ldx #0 ;clear accum.
stx t1
stx t2
tax ;.x=# ss
jsr sscalc ;calc # of blocks needed
lda t2
bne ar35
ldx t1
dex
bne ar35
inc r2
ar35 cmp nbtemp+1
bcc ar40 ;ok!!
bne ar20
lda nbtemp
cmp t1
bcc ar20 ;not enuf blocks
ar40 lda #1
jsr drdbyt ;look at sector link
clc
adc #1 ;+1 is nr
ldx lindx
sta nr,x
jsr nxtts ;get next block...
jsr setlnk ;...& set link.
lda r2
bne ar50 ;add one block
jsr wrtout ;write current last rec
ar45 jsr dblbuf ;switch bufs
jsr sethdr ;set hdr from t & s
jsr nxtts ;get another
jsr setlnk ;set up link
jsr nulbuf ;clean it out
jmp ar55
ar50 jsr dblbuf ;switch bufs
jsr sethdr ;set hdr from t & s
jsr nulbuf ;clean buffer
jsr nullnk ;last block =0,lstchr
ar55 jsr wrtout ;write buffer
jsr getlnk ;get t&s from link
lda track
pha ;save 'em
lda sector
pha
jsr gethdr ;now get hdr t&s
lda sector
pha ;save 'em
lda track
pha
jsr gsspnt ;check ss ptr
tax
bne ar60
jsr newss ;need another ss
lda #ssioff
jsr setssp ;.a=bt val
inc r0 ;advance ss count
ar60 pla
jsr putss ;record t&s...
pla
jsr putss ;...in ss.
pla ;get t&s from link
sta sector
pla
sta track
beq ar65 ;t=0: that's all!!
lda r0
cmp ssnum
bne ar45 ;not even done yet
jsr gsspnt
cmp ssind
bcc ar45 ;almost done
beq ar50 ;one more block left
ar65 jsr gsspnt
pha
lda #0
jsr ssdir
lda #0
tay
sta (dirbuf),y
iny
pla
sec
sbc #1
sta (dirbuf),y
jsr wrtss ;write ss
jsr watjob
jsr mapout
jsr fndrel
jsr dblbuf ;get back to leading buffer
jsr sspos
bvs ar70
jmp positn
ar70 lda #lrf
jsr setflg
lda #norec
jsr cmderr
; .end