Skip to content

Commit b01114b

Browse files
committed
added BASIC_C128, EDITOR_C128, EDITOR_C128_DIN, KERNAL_C128_05, KERNAL_C128_06, MONITOR_C128
1 parent f92ea6f commit b01114b

File tree

261 files changed

+52303
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+52303
-1
lines changed

BASIC_C128/array.src

+357
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
.page
2+
.subttl Array Routines
3+
4+
;
5+
; format of arrays in core:
6+
;
7+
; descriptor:
8+
; lowbyte = first character.
9+
; high byte = second character (m.s.bit is string flag).
10+
; length of array in core in bytes (includes everything).
11+
; number of dimensions.
12+
; for each dimension starting with the first a list (2 bytes each)
13+
; of the max indice+1
14+
; the values
15+
;
16+
17+
18+
is_array
19+
lda dimflg
20+
ora intflg
21+
pha ;save (dimflg) for recursion.
22+
lda valtyp
23+
pha ;save (valtyp) for recursion.
24+
ldy #0 ;set number of dimensions to zero.
25+
26+
indlop tya ;save number of dims.
27+
pha
28+
lda varnam+1
29+
pha
30+
lda varnam
31+
pha ;save looks.
32+
jsr intidx ;evaluate indice into facmo&lo.
33+
pla
34+
sta varnam
35+
pla
36+
sta varnam+1 ;get back all...we're home.
37+
pla ;(# of units).
38+
tay
39+
tsx
40+
lda 258,x
41+
pha ;push dimflg and valtyp further.
42+
lda 257,x
43+
pha
44+
lda indice ;put indice onto stack.
45+
sta 258,x ;under dimflg and valtyp.
46+
lda indice+1
47+
sta 257,x
48+
iny ;y counts # of subscripts
49+
sty count ;protect y from chrget
50+
jsr chrgot ;get terminating character.
51+
ldy count
52+
cmp #',' ;more subscripts?
53+
beq indlop ;yes.
54+
55+
jsr chkcls ;must be closed paren.
56+
pla
57+
sta valtyp ;get valtyp and
58+
pla
59+
sta intflg
60+
and #$7f
61+
sta dimflg ;dimflg off stack.
62+
ldx arytab ;place to start search.
63+
lda arytab+1
64+
lopfda
65+
stx lowtr
66+
sta lowtr+1
67+
cmp strend+1 ;end of arrays?
68+
bne lopfdv
69+
cpx strend
70+
beq notfdd ;a fine thing! no array!
71+
lopfdv
72+
ldy #0
73+
jsr indlow_ram1 ;get high of name from array bank (ram1)
74+
iny
75+
cmp varnam ;compare high orders.
76+
bne nmary1 ;no way is it this. get the bite outta here.
77+
jsr indlow_ram1
78+
cmp varnam+1 ;low orders?
79+
beq gotary ;well here it is.
80+
nmary1
81+
iny
82+
jsr indlow_ram1 ;get length.
83+
clc
84+
adc lowtr
85+
tax
86+
iny
87+
jsr indlow_ram1
88+
adc lowtr+1
89+
bcc lopfda ;always branches.
90+
bserr ldx #errbs ;get bad sub error number.
91+
.byte $2c
92+
93+
fcerr ldx #errfc ;too big. Illegal Quantity error
94+
errgo3 jmp error
95+
96+
97+
98+
gotary ldx #errdd ;perhaps a "re-dimension" error.
99+
lda dimflg ;test the dimflg.
100+
bne errgo3
101+
jsr fmaptr
102+
ldy #4
103+
jsr indlow_ram1
104+
sta syntmp
105+
lda count ;get number of dims input.
106+
cmp syntmp ;# of dims the same?
107+
bne bserr ;same so get definition.
108+
jmp getdef
109+
.page
110+
;
111+
; here when variable is not found in the array table.
112+
;
113+
; building an entry.
114+
;
115+
; put down the descriptor.
116+
; setup number of dimensions.
117+
; make sure there is room for the new entry.
118+
; remember "varpnt".
119+
; tally=4.
120+
; skip two locs for later fill in of size.
121+
; loop: get an indice
122+
; put down number+1 and increment varptr.
123+
; tally=tally*number+1
124+
; decrement number of dims
125+
; bne loop
126+
; call "reason" with (a,b) reflecting last loc
127+
; of variable
128+
; update strend
129+
; zero all.
130+
; make tally include maxdims and descriptor
131+
; put down tally
132+
; if called by dimension, return.
133+
; otherwise index into the variable as if it
134+
; were found on the initial search.
135+
;
136+
notfdd
137+
jsr fmaptr ;form arypnt.
138+
jsr reason
139+
ldy #0
140+
sty curtol+1
141+
ldx #5
142+
lda varnam
143+
sta sw_rom_ram1 ;point to string/array bank
144+
sta (lowtr),y
145+
bpl notflt
146+
dex
147+
notflt
148+
iny
149+
lda varnam+1
150+
sta (lowtr),y
151+
bpl stomlt
152+
dex
153+
dex
154+
stomlt
155+
stx curtol
156+
lda count
157+
iny
158+
iny
159+
iny
160+
sta (lowtr),y ;save number of dimensions.
161+
loppta
162+
ldx #11 ;default size.
163+
lda #0
164+
bit dimflg
165+
bvc notdim ;not in a dim statement.
166+
pla ;get low order of indice.
167+
clc
168+
adc #1
169+
tax
170+
pla ;get high order of indice.
171+
adc #0
172+
notdim
173+
iny
174+
sta (lowtr),y ;store high part of indice.
175+
iny
176+
txa
177+
sta (lowtr),y ;store low part of indice.
178+
jsr umult ;(a,x)+(curtol)*(lowtr,y).
179+
stx curtol ;save new tally.
180+
sta curtol+1
181+
ldy index
182+
dec count ;any more indices left?
183+
bne loppta ;yes.
184+
adc arypnt+1
185+
bcs omerr1 ;overflow.
186+
sta arypnt+1 ;compute where to zero.
187+
tay
188+
txa
189+
adc arypnt
190+
bcc grease
191+
iny
192+
beq omerr1
193+
grease
194+
jsr reason ;get room.
195+
sta strend
196+
sty strend+1 ;new end of storage.
197+
lda #0 ;storing (acca) is faster than clear.
198+
inc curtol+1
199+
200+
ldy curtol
201+
beq deccur
202+
203+
zerita dey ;zero out new entry
204+
sta (arypnt),y
205+
bne zerita ;no. continue.
206+
deccur
207+
dec arypnt+1
208+
dec curtol+1
209+
bne zerita ;do another block.
210+
inc arypnt+1 ;bump back up. will use later.
211+
sec
212+
lda strend ;restore (acca).
213+
sbc lowtr ;determine length.
214+
ldy #2
215+
sta (lowtr),y ;low.
216+
lda strend+1
217+
iny
218+
sbc lowtr+1
219+
sta (lowtr),y ;high.
220+
lda dimflg ;quit here if this is a dim statement
221+
bne dimrts ;bye!
222+
iny
223+
224+
225+
; At this point (lowtr,y) points beyond the size to the number of dimensions. strategy:
226+
; numdim=number of dimensions.
227+
; curtol=0.
228+
;inlpnm:get a new indice.
229+
; make sure indice is not too big.
230+
; multiply curtol by curmax.
231+
; add indice to curtol.
232+
; numdim=numdim-1.
233+
; bne inlpnm.
234+
; use (curtol)*4 as offset.
235+
236+
getdef jsr indlow_ram1 ;get # of dim's from ram bank 1
237+
sta count ;save a counter.
238+
lda #0 ;zero (curtol).
239+
sta curtol
240+
inlpnm
241+
sta curtol+1
242+
iny
243+
pla ;get low indice.
244+
tax
245+
sta indice
246+
jsr indlow_ram1
247+
sta syntmp
248+
pla ;and the high part.
249+
sta indice+1
250+
cmp syntmp ;compare with max indice.
251+
bcc inlpn2
252+
bne bserr7 ;if greater, "bad subscript" error.
253+
iny
254+
jsr indlow_ram1
255+
sta syntmp
256+
cpx syntmp
257+
bcc inlpn1
258+
259+
bserr7 jmp bserr
260+
261+
omerr1 jmp omerr
262+
263+
inlpn2
264+
iny
265+
inlpn1 lda curtol+1 ;don't multiply if curtol=0.
266+
ora curtol
267+
clc ;prepare to get indice back.
268+
beq addind ;get high part of indice back.
269+
jsr umult ;multiply (curtol) by (5&6,lowtr).
270+
txa
271+
adc indice ;add in (indice).
272+
tax
273+
tya
274+
ldy index1
275+
addind
276+
adc indice+1
277+
stx curtol
278+
dec count ;any more?
279+
bne inlpnm ;yes.
280+
sta curtol+1
281+
ldx #5
282+
lda varnam
283+
bpl notfl1
284+
dex
285+
notfl1
286+
lda varnam+1
287+
bpl 10$
288+
dex
289+
dex
290+
10$ stx addend
291+
lda #0
292+
jsr umultd ;on rts, a & y = hi. x = lo.
293+
txa
294+
adc arypnt
295+
sta varpnt
296+
tya
297+
adc arypnt+1
298+
sta varpnt+1
299+
tay
300+
lda varpnt
301+
dimrts rts
302+
.page
303+
304+
;integer arithmetic routines.
305+
;
306+
;two byte unsigned integer multiply.
307+
;this is for multiply dimensioned arrays.
308+
; (a,b)=(curtol)*(5&6,x).
309+
umult
310+
sty index
311+
jsr indlow_ram1
312+
sta addend ;low, then high.
313+
dey
314+
jsr indlow_ram1 ;put (5&6,lowtr) in faster memory.
315+
umultd
316+
sta addend+1
317+
lda #16
318+
sta deccnt
319+
ldx #0 ;clear the accs.
320+
ldy #0 ;result initially zero.
321+
umultc
322+
txa
323+
asl a ;multiply by two.
324+
tax
325+
tya
326+
rol a
327+
tay
328+
bcs omerr1 ;to much!
329+
asl curtol
330+
rol curtol+1
331+
bcc umlcnt ;nothing in this position to multiply.
332+
clc
333+
txa
334+
adc addend
335+
tax
336+
tya
337+
adc addend+1
338+
tay
339+
bcs omerr1 ;man, just too much!
340+
umlcnt
341+
dec deccnt ;done?
342+
bne umultc ;keep it up.
343+
rts ;yes, all done.
344+
345+
346+
fmaptr lda count
347+
asl a
348+
adc #5 ;point to entries. c cleared by asl.
349+
adc lowtr
350+
ldy lowtr+1
351+
bcc 1$
352+
iny
353+
1$ sta arypnt
354+
sty arypnt+1
355+
rts
356+
357+
;end

BASIC_C128/auto.src

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
.page
3+
.subttl AUTO Command
4+
5+
; auto increment
6+
; syntax : auto {line-number}
7+
; line-number = 0 means turn off
8+
9+
auto
10+
jsr errind
11+
jsr linget
12+
lda linnum
13+
sta autinc
14+
lda linnum+1
15+
sta autinc+1
16+
jmp ready
17+
18+
;end

0 commit comments

Comments
 (0)