Browse Source

added KERNAL_TED_04

master
Michael Steil 5 months ago
parent
commit
670c3b8a34
77 changed files with 8614 additions and 1 deletions
  1. 0
    0
      KERNAL_TED_04/assem.src
  2. 0
    0
      KERNAL_TED_04/banking.src
  3. 0
    0
      KERNAL_TED_04/channelio.src
  4. 0
    0
      KERNAL_TED_04/clall.src
  5. 0
    0
      KERNAL_TED_04/close.src
  6. 0
    0
      KERNAL_TED_04/cmds1.src
  7. 0
    0
      KERNAL_TED_04/cmds2.src
  8. 806
    0
      KERNAL_TED_04/declare.src
  9. 0
    0
      KERNAL_TED_04/disasm.src
  10. 0
    0
      KERNAL_TED_04/disclaim.src
  11. 417
    0
      KERNAL_TED_04/ed1.src
  12. 0
    0
      KERNAL_TED_04/ed2.src
  13. 0
    0
      KERNAL_TED_04/ed3.src
  14. 0
    0
      KERNAL_TED_04/ed4.src
  15. 0
    0
      KERNAL_TED_04/ed5.src
  16. 0
    0
      KERNAL_TED_04/ed6.src
  17. 0
    0
      KERNAL_TED_04/ed7.src
  18. 0
    0
      KERNAL_TED_04/errorhdlr.src
  19. 0
    0
      KERNAL_TED_04/init.src
  20. 0
    0
      KERNAL_TED_04/interrupt.src
  21. 0
    0
      KERNAL_TED_04/kernal.src
  22. 0
    0
      KERNAL_TED_04/load.src
  23. 0
    0
      KERNAL_TED_04/messages.src
  24. 0
    0
      KERNAL_TED_04/music.src
  25. 0
    0
      KERNAL_TED_04/open.src
  26. 264
    0
      KERNAL_TED_04/openchanl.src
  27. 0
    0
      KERNAL_TED_04/overflow.src
  28. 0
    0
      KERNAL_TED_04/patches.src
  29. 0
    0
      KERNAL_TED_04/rs232.src
  30. 0
    0
      KERNAL_TED_04/save.src
  31. 0
    0
      KERNAL_TED_04/serial.src
  32. 0
    0
      KERNAL_TED_04/split.src
  33. 0
    0
      KERNAL_TED_04/tapred.src
  34. 0
    0
      KERNAL_TED_04/tapsup.src
  35. 0
    0
      KERNAL_TED_04/tapwrt.src
  36. 0
    0
      KERNAL_TED_04/time.src
  37. 0
    0
      KERNAL_TED_04/util.src
  38. 69
    0
      KERNAL_TED_04/vectors.src
  39. 254
    0
      KERNAL_TED_05/assem.src
  40. 198
    0
      KERNAL_TED_05/banking.src
  41. 255
    0
      KERNAL_TED_05/channelio.src
  42. 75
    0
      KERNAL_TED_05/clall.src
  43. 154
    0
      KERNAL_TED_05/close.src
  44. 307
    0
      KERNAL_TED_05/cmds1.src
  45. 167
    0
      KERNAL_TED_05/cmds2.src
  46. 0
    0
      KERNAL_TED_05/declare.src
  47. 258
    0
      KERNAL_TED_05/disasm.src
  48. 45
    0
      KERNAL_TED_05/disclaim.src
  49. 0
    0
      KERNAL_TED_05/ed1.src
  50. 144
    0
      KERNAL_TED_05/ed2.src
  51. 199
    0
      KERNAL_TED_05/ed3.src
  52. 323
    0
      KERNAL_TED_05/ed4.src
  53. 266
    0
      KERNAL_TED_05/ed5.src
  54. 200
    0
      KERNAL_TED_05/ed6.src
  55. 344
    0
      KERNAL_TED_05/ed7.src
  56. 68
    0
      KERNAL_TED_05/errorhdlr.src
  57. 325
    0
      KERNAL_TED_05/init.src
  58. 72
    0
      KERNAL_TED_05/interrupt.src
  59. 49
    0
      KERNAL_TED_05/kernal.src
  60. 255
    0
      KERNAL_TED_05/load.src
  61. 30
    0
      KERNAL_TED_05/messages.src
  62. 27
    0
      KERNAL_TED_05/music.src
  63. 195
    0
      KERNAL_TED_05/open.src
  64. 0
    0
      KERNAL_TED_05/openchanl.src
  65. 25
    0
      KERNAL_TED_05/overflow.src
  66. 119
    0
      KERNAL_TED_05/patches.src
  67. 206
    0
      KERNAL_TED_05/rs232.src
  68. 154
    0
      KERNAL_TED_05/save.src
  69. 396
    0
      KERNAL_TED_05/serial.src
  70. 82
    0
      KERNAL_TED_05/split.src
  71. 890
    0
      KERNAL_TED_05/tapred.src
  72. 187
    0
      KERNAL_TED_05/tapsup.src
  73. 377
    0
      KERNAL_TED_05/tapwrt.src
  74. 81
    0
      KERNAL_TED_05/time.src
  75. 327
    0
      KERNAL_TED_05/util.src
  76. 0
    0
      KERNAL_TED_05/vectors.src
  77. 4
    1
      README.md

KERNAL_TED/assem.src → KERNAL_TED_04/assem.src View File


KERNAL_TED/banking.src → KERNAL_TED_04/banking.src View File


KERNAL_TED/channelio.src → KERNAL_TED_04/channelio.src View File


KERNAL_TED/clall.src → KERNAL_TED_04/clall.src View File


KERNAL_TED/close.src → KERNAL_TED_04/close.src View File


KERNAL_TED/cmds1.src → KERNAL_TED_04/cmds1.src View File


KERNAL_TED/cmds2.src → KERNAL_TED_04/cmds2.src View File


+ 806
- 0
KERNAL_TED_04/declare.src View File

@@ -0,0 +1,806 @@
.page
.subttl 'declare 06/05/84'
dclver =$0605 ;************keep current mmdd

; assignments

addprc =1
lenfor =18 ;length of a 'for' entry in the run-time stack
lengos =5 ;length of a 'gosub'....
buflen =89 ;ted input buffer size
bufpag =2
stkend =507
clmwid =10 ;print window 10 chars
pi =255
numlev =23
strsiz =3
sperr =$10
maxchr =80
nwrap =2 ;max # of physical lines per logical line
.page
; i/o devices
;

acia =$fd00 ;6551 acia

xport =$fd10 ;6529 port

bnksel =$fdd0 ;switch paragraph for banking cartridges

ted =$ff00

timr1l =ted+0 ;timer 1 is used to write to tape
timr1h =ted+1
timr2l =ted+2 ;timer 2 used by serial(timeout)
timr2h =ted+3 ;dipole hunter
timr3l =ted+4 ;timer 3 used to read data bits
timr3h =ted+5
tedvcr =ted+6 ;ted's video control register
keybrd =ted+8
tedirq =ted+9
tedicr =ted+10
tedcrh =ted+12 ;high byte of ted cursor register
tedcrl =ted+13 ;low byte of ted cursor register
tedmlo =ted+14 ;start of ls bytes of sound freq. values
tedmhi =ted+16 ;start of ms 2 bits of sound freq. values
tedvoi =ted+17 ;ls nybble is vol, ms nybble is voice on/off bits
tedcbr =ted+19 ;character base
romon =ted+62
romoff =ted+63
cbrlsb =$04 ;lsb of character base in char. base reg


; screen editor constants
;
llen =40 ;single line 40 columns
nlines =25 ;25 rows on screen
cr =$0d ;carriage return
lf =$0a ;line feed
.page
; basic zp storage
;

*=0

pdir *=*+1 ;6510 port data dir reg
port *=*+1 ;6510 internal i/o port
srchtk *=*+1 ;token 'search' looks for (run-time stack)
zpvec1 *=*+2 ;temp (renumber)
zpvec2 *=*+2 ;temp (renumber)
integr
charac *=*+1
endchr *=*+1
trmpos *=*+1
verck *=*+1
count *=*+1
dimflg *=*+1
valtyp *=*+1
intflg *=*+1
garbfl
dores *=*+1
subflg *=*+1
inpflg *=*+1
domask
tansgn *=*+1
channl *=*+1
poker
linnum *=*+2
temppt *=*+1
lastpt *=*+2
tempst *=*+9
index
index1 *=*+2
index2 *=*+2
resho *=*+1
resmoh *=*+1
addend
resmo *=*+1
reslo *=*+1
*=*+1
txttab *=*+2
vartab *=*+2
arytab *=*+2
strend *=*+2
fretop *=*+2
frespc *=*+2
memsiz *=*+2
curlin *=*+2
txtptr *=*+2 ;pointer to basic text used by chrget,etc.
form ;used by print using
fndpnt *=*+2 ;pointer to item found by search
datlin *=*+2
datptr *=*+2
inpptr *=*+2
varnam *=*+2
fdecpt
varpnt *=*+2
lstpnt
andmsk
forpnt *=*+2
eormsk =forpnt+1
vartxt
opptr *=*+2
opmask *=*+1
grbpnt
tempf3
defpnt *=*+2
dscpnt *=*+2
*=*+1
helper *=*+1 ;flags 'help' or 'list'
jmper *=*+1
size *=*+1
oldov *=*+1

tempf1 *=*+1
ptarg1 =tempf1 ;multiply defined for instr
ptarg2 =tempf1+2
str1 =tempf1+4
str2 =tempf1+7
positn =tempf1+10
match =tempf1+11

temp =tempf1 ;multiply defined for graphic subs

arypnt
highds *=*+2
hightr *=*+2
tempf2
*=*+1
deccnt
lowds *=*+2
grbtop
dptflg
lowtr *=*+1
expsgn *=*+1
tenexp =lowds+1
dsctmp
fac
facexp *=*+1
facho *=*+1
facmoh *=*+1
indice
facmo *=*+1
faclo *=*+1
facsgn *=*+1
degree
sgnflg *=*+1
bits *=*+1
argexp *=*+1
argho *=*+1
argmoh *=*+1
argmo *=*+1
arglo *=*+1
argsgn *=*+1
strng1
arisgn *=*+1
facov *=*+1

strng2
polypt
curtol
fbufpt *=*+2

autinc *=*+2 ;inc. val for auto (0=off)
mvdflg *=*+1 ;flag if 10k hires allocated

noze ;using's leading zero counter
keynum *=*+1

hulp ;counter
keysiz *=*+1

syntmp *=*+1 ;used as temp for indirect loads
dsdesc *=*+3 ;descriptor for ds$
tos *=*+2 ;top of run time stack
tmpton *=*+2 ;temps used by music (tone & vol)
voicno *=*+1
runmod *=*+1 ;flags run/direct mode

parsts ;dos parser status word
point *=*+1 ;using's pointer to dec.pt



; graphic zp storage

graphm *=*+1 ;current graphic mode
colsel *=*+1 ;current color selected
mc1 *=*+1 ;multicolor1
fg *=*+1 ;foreground color
scxmax *=*+1 ;maximum # of columns
scymax *=*+1 ;maximum # of rows
ltflag *=*+1 ;paint-left flag
rtflag *=*+1 ;paint-right flag
stopnb *=*+1 ;stop paint if not background/not same color
grapnt *=*+2
vtemp1 *=*+1
vtemp2 *=*+1



; kernal zp storage
;
*=$90
status *=*+1 ;i/o operation status byte
stkey *=*+1 ;stop key flag
spverr *=*+1 ;temporary
verfck *=*+1 ;load or verify flag
c3p0 *=*+1 ;ieee buffered char flag
bsour *=*+1 ;char buffer for ieee
xsav *=*+1 ;temp for basin
ldtnd *=*+1 ;index to logical file
dfltn *=*+1 ;default input device #
dflto *=*+1 ;default output device #
msgflg *=*+1 ;os message flag
sal *=*+1
sah *=*+1
eal *=*+1
eah *=*+1
t1 *=*+2 ;temporary 1
t2 *=*+2 ;temporary 2
time *=*+3 ;24 hour clock in 1/60th seconds
r2d2 *=*+1 ;serial bus usage
tpbyte *=*+1 ;byte to be written/read on/off tape
bsour1 *=*+1 ;temp used by serial routine
sedeal ;temp. for scrolling
fpverr *=*+1
dcount *=*+1
fnlen *=*+1 ;length current file n str
la *=*+1 ;current file logical addr
sa *=*+1 ;current file 2nd addr
fa *=*+1 ;current file primary addr
fnadr *=*+2 ;addr current file name str
errsum *=*+1
tmp0
stal *=*+1
stah *=*+1
memuss *=*+2 ;load ram base
tapebs *=*+2 ;base pointer to cass buffer
tmp2 *=*+2
wrbase *=*+2 ;pointer to data for tape writes
imparm *=*+2 ;pointer to immediate string for primm
fetptr *=*+2 ;pointer to byte to be fetched in banking fetchl routine

; variables for screen editor
;
sedsal *=*+2 ;temp. for scrolling
rvs *=*+1 ;rvs field on flag
indx *=*+1
lsxp *=*+1 ;x pos at start
lstp *=*+1
sfdx *=*+1 ;shift mode on print
crsw *=*+1 ;input vs get flag
pnt *=*+2 ;pointer to row
pntr *=*+1 ;pointer to column
qtsw *=*+1 ;quote switch
sedt1 *=*+1 ;editor temp. use
tblx *=*+1
datax *=*+1
insrt *=*+1 ;insert mode flag

*=*+25 ;area for use by banking software
cirseg *=*+1 ;degrees/circle-segment
user *=*+2 ;screen editor color ip
keytab *=*+2 ;keyscan table indirect
tmpkey *=*+1
ndx *=*+1 ;index to keyboard q
stpflg *=*+1 ;pause flag

; monitor zp storage
;
t0 *=*+2
chrptr *=*+1
bufend *=*+1



chksum *=*+1 ;temp for checksum calc
length *=*+1
pass *=*+1 ;which pass we're doing str
type *=*+1 ;what type of block we're dealing with
usekdy *=*+1 ;(b.7=1)=> use for wr, (b.6=1)=> use for rd
xstop *=*+1 ;save x reg for quick stopkey test



curbnk *=*+1 ;current bank configuration
xon *=*+1 ;char to send for an x-on
xoff *=*+1 ;char to send for an x-off
sedt2 *=*+1 ;editor temp. use



*=$ff
lofbuf *=*+1
fbuffr *=*+16

savea *=*+1 ;temp locations
savey *=*+1 ;...for save & restore
savex *=*+1 ;...for save & restore
colkey *=*+16 ;default color/luminance table
sysstk ;bottom of system stack
.page
*=$200
buf *=*+buflen ;basic/monitor buffer
oldlin *=*+2 ;basic storage
oldtxt *=*+2 ;basic storage

; basic/dos interface vars
;
xcnt *=*+1 ;dos loop counter

fnbufr *=*+16 ;area for filename
dosf1l *=*+1 ;dos filename 1 len
dosds1 *=*+1 ;dos disk drive 1
dosf1a *=*+2 ;dos filename 1 addr

dosf2l *=*+1 ;dos filename 2 len
dosds2 *=*+1 ;dos disk drive 2
dosf2a *=*+2 ;dos filename 2 addr

dosla *=*+1 ;dos logical addr
dosfa *=*+1 ;dos phys addr
dossa *=*+1 ;dos sec. addr

dosdid *=*+2 ;dos dsk identif.
didchk *=*+1 ;dos did flg

dosstr *=*+1 ;dos output str. buf
dosspc =*-fnbufr ;space used by dos rout.
*=*+48 ;area to build dos string
.page
vwork ;graphics vars

xypos
xpos *=*+2 ;current x position
ypos *=*+2 ;current y position
dest
xdest *=*+2 ;x-coordinate destination
ydest *=*+2 ;y-coordinate destination

; line drawing variables
;
xyabs
xabs *=*+2
yabs *=*+2
xysgn
xsgn *=*+2
ysgn *=*+2
fct
fct1 *=*+2
fct2 *=*+2
errval *=*+2
lesser *=*+1
greatr *=*+1

; angle routine variables
;
angsgn *=*+1 ;sign of angle
sinval *=*+2 ;sine of value of angle
cosval *=*+2 ;cosine of value of angle
angcnt *=*+2 ;temps for angle distance routines
.page
; the following 24 bytes are multiply defined, beginning on this
; page, and continuing for the next 4 pages.

params =*
*=*+1 ;placeholder
bnr *=*+1 ;pointer to begin. no.
enr *=*+1 ;pointer to end no.
dolr *=*+1 ;dollar flag
flag *=*+1 ;comma flag
swe *=*+1 ;counter
usgn *=*+1 ;sign exponent
uexp *=*+1 ;pointer to exponent
vn *=*+1 ;# of digits before decimal point
chsn *=*+1 ;justify flag
vf *=*+1 ;# of pos before decimal point (field)
nf *=*+1 ;# of pos after decimal point (field)
posp *=*+1 ;+/- flag (field)
fesp *=*+1 ;exponent flag (field)
etof *=*+1 ;switch
cform *=*+1 ;char counter (field)
sno *=*+1 ;sign no
blfd *=*+1 ;blank/star flag
begfd *=*+1 ;pointer to begin of field
lfor *=*+1 ;length of format
endfd *=*+1 ;pointer to end of field
*=*+3 ;placeholder
parend =*
.page
; general use parameters. (multiply defined with print using)

*=params

xcentr *=*+2
ycentr *=*+2
xdist1 *=*+2
ydist1 *=*+2
xdist2 *=*+2
ydist2 *=*+2
disend
*=*+2 ;placeholder
colcnt *=*+1 ;char's col. counter
rowcnt *=*+1
strcnt *=*+1


; box drawing variables. (multiply defined with print using)

*=params

xcord1 *=*+2 ;point 1 x-coord.
ycord1 *=*+2 ;point 1 y-coord.
boxang *=*+2 ;rotation angle
xcount *=*+2
ycount *=*+2
bxleng *=*+2 ;length of a side
xcord2 *=*+2
ycord2 *=*+2


; circle drawing variables. (multiply defined with print using)

*=params

xcircl *=*+2 ;circle center, x coordinate
ycircl *=*+2 ;circle center, y coordinate
xradus *=*+2 ;x radius
yradus *=*+2 ;y radius
rotang *=*+4 ;rotation angle
angbeg *=*+2 ;arc angle start
angend *=*+2 ;arc angle end
xrcos *=*+2 ;x radius * cos(rotation angle)
yrsin *=*+2 ;y radius * sin(rotation angle)
xrsin *=*+2 ;x radius * sin(rotation angle)
yrcos *=*+2 ;y radius * cos(rotation angle)
.page
; shape and move-shape variables (multiply defined with print using)

*=params

*=*+1 ;placeholder
keylen *=*+1
keynxt *=*+1
strsz *=*+1 ;string len
gettyp *=*+1 ;replace shape mode
strptr *=*+1 ;string pos'n counter
oldbyt *=*+1 ;old bit map byte
newbyt *=*+1 ;new string or bit map byte
*=*+1 ;placeholder
xsize *=*+2 ;shape column length
ysize *=*+2 ;shape row length
xsave *=*+2 ;temp for column length
stradr *=*+2 ;save shape string descriptor
bitidx *=*+1 ;bit index into byte
savsiz *=*+4 ;temp work locations


*=parend

; graphic variables
;
chrpag *=*+1 ;high byte of address of char rom for 'char' command
bitcnt *=*+1 ;temp for gshape
scalem *=*+1 ;scale mode flag
width *=*+1 ;double width flag
filflg *=*+1 ;box fill flag
bitmsk *=*+1 ;temp for bit mask
numcnt *=*+1
trcflg *=*+1 ;flags trace mode


t3 *=*+1
t4 *=*+2
vtemp3 *=*+1 ;graphic temp storage
vtemp4 *=*+1
vtemp5 *=*+1


adray1 *=*+2 ;ptr to routine: convert float -> integer
adray2 *=*+2 ;ptr to routine: convert integer -> float
.page
*=$2fe

bnkvec *=*+2 ;vector for function cart. users
ierror *=*+2 ;indirect error (output error in .x)
imain *=*+2 ;indirect main (system direct loop)
icrnch *=*+2 ;indirect crunch (tokenization routine)
iqplop *=*+2 ;indirect list (char list)
igone *=*+2 ;indirect gone (char dispatch)
ieval *=*+2 ;indirect eval (symbol evaluation)
iesclk *=*+2 ;escape token crunch,
iescpr *=*+2 ;..list,
iescex *=*+2 ;..and execute
itime *=*+2 ;60 hz interrupt vector (before jiffy)
cinv *=*+2 ;irq ram vector
cbinv *=*+2 ;brk instr ram vector
iopen *=*+2 ;indirects for code
iclose *=*+2 ;conforms to kernal spec 8/19/80
ichkin *=*+2
ickout *=*+2
iclrch *=*+2
ibasin *=*+2
ibsout *=*+2
istop *=*+2
igetin *=*+2
iclall *=*+2
usrcmd *=*+2
iload *=*+2
isave *=*+2 ;savesp

*=*+1 ;*******************************************available


tapbuf *=*+192 ;cassette tape buffer
wrlen *=*+2 ;length in 2's compl. of data to be written to cassette
rdcnt *=*+2 ;length in 2's compl. of data to be read from cassette

inpqln =64 ;length of rs232 input queue
inpque *=*+inpqln
hiwatr =$38 ;x-off trip point
lowatr =$08 ;x-on trip point

estksz =30 ;size of cassette error stack
estakl *=*+estksz ;low addr
estakh *=*+estksz ;high addr

chrget *=*+6
chrgot *=*+12
qnum *=*+15



; indirect load subroutine area
;
indsub *=*+14 ;shared rom fetch sub
zero *=*+3 ;numeric constant for basic, downloaded from rom

indtxt *=*+11 ;txtptr
indin1 *=*+11 ;index & index1
indin2 *=*+11 ;index2
indst1 *=*+11 ;strng1
indlow *=*+11 ;lowtr
indfmo *=*+11 ;facmo



; declarations for print using
;
puchrs
pufill *=*+1 ;print using fill symbol
pucoma *=*+1 ;print using comma symbol
pudot *=*+1 ;print using d.p. symbol
pumony *=*+1 ;print using monetary symbol

tmpdes *=*+4 ;temp for instr

errnum *=*+1 ;used by error trapping routine-last error number
errlin *=*+2 ;line # of last error - ffff if no error
trapno *=*+2 ;line to go to on error.. ffxx if none set
tmptrp *=*+1 ;hold trap # tempor.
errtxt *=*+2
oldstk *=*+1

tmptxt *=*+2 ;used by do-loop. could be mult. assigned
tmplin *=*+2

mtimlo *=*+2 ;table of pending jiffies till turnoff (in 2's comp)
mtimhi *=*+2
usrpok *=*+3
rndx *=*+5

dejavu *=*+1 ;'cold' or 'warm' reset status (must be in page 5!)



; tables for open files
;
lat *=*+10 ;logical file numbers
fat *=*+10 ;primary device numbers
sat *=*+10 ;secondary addresses


; system storage
;
keyd *=*+10 ;irq keyboard buffer
memstr *=*+2 ;start of memory
msiz *=*+2 ;top of memory
timout *=*+1 ;ieee timeout flag


; cassette declarations...
;
filend *=*+1 ;filend reached::=1, 0 otherwise
ctally *=*+1 ;#of chars left in buffer (for r&w)
cbufva *=*+1 ;#of total valid chars in buffer (for r.o.)
tptr *=*+1 ;pointer to next chr in buffer (for r&w)
fltype *=*+1 ;contains type of current cass file
bufmax =191 ;size of the buffer for data entries (excluding type)
;
; tape block types
;
eot =5 ;end of tape
blf =1 ;basic load file
bdf =2 ;basic data file
plf =3 ;fixed program type
bdfh =4 ;basic data file header



; screen editor storage
;
color *=*+1 ;active attribute byte
flash *=*+1 ;character flash flag
*=*+1 ;*******************************************available
hibase *=*+1 ;base location of screen (top)
xmax *=*+1
rptflg *=*+1 ;key repeat flag
kount *=*+1
delay *=*+1
shflag *=*+1 ;shift flag byte
lstshf *=*+1 ;last shift pattern
keylog *=*+2 ;indirect for keyboard table setup
mode *=*+1
autodn *=*+1 ;auto scroll down flag(=0 on,<>0 off)
lintmp *=*+1
rolflg *=*+1



; monitor non-zp storage
;
format *=*+1
msal *=*+3
wrap *=*+1
tmpc *=*+1
diff *=*+1
pch *=*+1
pcl *=*+1
flgs *=*+1
acc *=*+1
xr *=*+1
yr *=*+1
sp *=*+1
invl *=*+1
invh *=*+1
cmpflg *=*+1 ;used by various monitor routines
bad *=*+1

kyndx *=*+1 ;used for programmable keys
keyidx *=*+1
keybuf *=*+8 ;table of p.f. lengths
maxkys =128
pkybuf *=*+maxkys ;p.f. key storage area


; kennedy interface variables...
;
kdata *=*+1 ;temp for data write to kennedy
kdycmd *=*+1 ;select for kennedy rd or wr
kdynum *=*+1 ;kennedy's dev#
kdyprs *=*+1 ;kennedy present::=$ff, else::=$00
kdytyp *=*+1 ;temp stor. for type of open for kdy
;
; and constants...
;
tedrva =$fef0
tedrvb =$fef1
tedrvc =$fef2
drva2 =$fef3
drvb2 =$fef4
drvc2 =$fef5

italk =$40 ;ieee talk
ilstn =$20 ;listen
iutalk =$5f ;untalk
iulstn =$3f ;unlisten

kcmd1 =$81 ;state change
kcmd2 =$82 ;sec. addr
kcmd3 =$83 ;dout
kcmd4 =$84 ;din



savram *=*+256 ;1 page used by banking routines
pat =savram ;physical address table for banking
lngjmp =savram+4 ;long jump address for banking 'long' routine
fetarg =savram+6 ;storage for long jumps
fetxrg =savram+7
fetsrg =savram+8

stktop *=*+196 ;basic run-time stack
stkbot =*


; cassette primitive r&w variables
;
typenb ;doubly defined
wrout *=*+1 ;byte to be written on tape

parity *=*+1 ;temp for parity calc
tt1 *=*+1 ;temp for write-header
tt2 *=*+1 ;temp for write-header
*=*+1 ;*************************************available
rdbits *=*+1 ;local index for readbyte routine
errsp *=*+1 ;pointer to the current entry in the error stack
fperrs *=*+1 ;number of first pass errors
;
; *** don't ever re-order the following 3 variables !!! ***
;
dsamp1 *=*+2 ;time constant for x cell sample
dsamp2 *=*+2 ;time constant for y cell sample
zcell *=*+2 ;time constant for z cell verify

srecov *=*+1 ;stack marker for stopkey recover
drecov *=*+1 ;stack marker for dropout recover
trsave *=*+4 ;parmeters passed to rdblok
rdetmp *=*+1 ;temp stat save for rdblok
ldrscn *=*+1 ;#consec. shorts to find in leader
cderrm *=*+1 ;#errors fatal in rd countdown
vsave *=*+1 ;temp for verify command
t1pipe *=*+4 ;pipe temp for t1
enext *=*+1 ;read error propagate



; for rs-232...
;
uoutq *=*+1 ;user char to send
uoutfg *=*+1 ;0::=empty, 1::=full
soutq *=*+1 ;system char to send
soutfg *=*+1 ;0::=empty, 1::=full
inqfpt *=*+1 ;ptr to front of input queue
inqrpt *=*+1 ;ptr to rear of input queue
inqcnt *=*+1 ;# of chars in input queue
astat *=*+1 ;temp ststus word for the acia
aintmp *=*+1 ;temp for input routine
alstop *=*+1 ;flg to indicate if we're paused locally
arstop *=*+1 ;flg to indicate if remote is paused
apres *=*+1 ;flg to indicate if acia in system



; indirect routine downloaded here...
;
kludes *=*+12
sinner =kludes+6


scbot *=*+1
sctop *=*+1
sclf *=*+1
scrt *=*+1
scrdis *=*+1
insflg *=*+1
lstchr *=*+1
logscr *=*+1
tcolor *=*+1
bitabl *=*+4


sareg *=*+1 ;reg's for sys command
sxreg *=*+1
syreg *=*+1
spreg *=*+1

lstx *=*+1 ;key scan index
stpdsb *=*+1 ;flag to disable ctl-s pause
ramrom *=*+1 ;msb flags monitor fetches from ram (0) or rom (1)
colsw *=*+1 ;msb flags color/lum. table in ram (0) or rom (1)
ffrmsk *=*+1 ;rom mask (split screen)
vmbmsk *=*+1 ;v.m. base mask (split screen)
lsem *=*+1 ;motor lock semaphore for cassette (**02/08/84)
palcnt *=*+1 ;pal tod (**02/17/84)


tedatr =$0800 ;ted attribute bytes
tedscn =$0c00 ;ted character pointers
basbgn =$1000
grbase =$2000 ;graphic base is the same as basic beginning
bmcolr =$1c00
bmlum =$1800
chrbas =$d000 ;beginning of 'character rom'

;end

KERNAL_TED/disasm.src → KERNAL_TED_04/disasm.src View File


KERNAL_TED/disclaim.src → KERNAL_TED_04/disclaim.src View File


+ 417
- 0
KERNAL_TED_04/ed1.src View File

@@ -0,0 +1,417 @@
.page
.subttl 'ed1 ted 07/10/84'

.byte >dclver,<dclver ;mark declare version

ldtb2 ;screen lines low byte table
.byte <linz0 ;**must** be at $d802...if this is changed, tell basic!
.byte <linz1
.byte <linz2
.byte <linz3
.byte <linz4
.byte <linz5
.byte <linz6
.byte <linz7
.byte <linz8
.byte <linz9
.byte <linz10
.byte <linz11
.byte <linz12
.byte <linz13
.byte <linz14
.byte <linz15
.byte <linz16
.byte <linz17
.byte <linz18
.byte <linz19
.byte <linz20
.byte <linz21
.byte <linz22
.byte <linz23
.byte <linz24
ldtb1 ;screen lines high byte table
.byte >linz0
.byte >linz1
.byte >linz2
.byte >linz3
.byte >linz4
.byte >linz5
.byte >linz6
.byte >linz7
.byte >linz8
.byte >linz9
.byte >linz10
.byte >linz11
.byte >linz12
.byte >linz13
.byte >linz14
.byte >linz15
.byte >linz16
.byte >linz17
.byte >linz18
.byte >linz19
.byte >linz20
.byte >linz21
.byte >linz22
.byte >linz23
.byte >linz24
.page
scrorg ;return max. # rows, cols of screen
ldx #llen
ldy #nlines
rts


plot ;set or read cursor position
bcs plot10
stx tblx ;.c=0 means set it
stx lsxp
sty pntr
sty lstp
jsr sreset ;(in case it's outside window)
jsr stupt
plot10
ldx tblx ;.c=1 means read it
ldy pntr
rts



;****************************************
;
; cint: initialize screen & editor
;
;****************************************

cint
lda #$0c ;set up base of screen
sta hibase

lda #3
sta dflto
lda #0
sta dfltn

sta mode ;always pet mode
sta graphm ;always text mode
sta ndx ;no keys in buffer yet
sta stpflg ;flag 'no ctl-s yet'

lda #<shflog ;set shift logic indirects
sta keylog
lda #>shflog
sta keylog+1
lda #10
sta xmax ;maximum type ahead buffer size
sta rolflg ;flag 'roll ok, if in basic, and if in direct mode'
sta delay
lda #$80
sta rptflg ;make all keys repeat
lda #16 ;init color to gk. blue
sta color
lda #4
sta kount ;delay between key repeats

setbig ;setup full screen window, clear it & clear wrap table
jsr sreset
clsr ;clear screen
jsr home ;start at top of window
cls10
jsr scrset ;point to line
jsr clrln ;clear the line
cpx scbot ;done?
inx
bcc cls10 ;no

home ;home cursor
ldx sctop ;move to top of window
stx tblx
stx lsxp ;(for input after home or clear)
stu10
ldy sclf ;move to left side of window
sty pntr
sty lstp
stupt
ldx tblx ;set pointers to beginning of line

scrset
lda ldtb2,x ;.x=line # to set up
sta pnt
lda ldtb1,x ;pointer to screen ram
sta pnt+1

;pointer to screen ram, fall into 'scolor'
;
scolor
lda pnt ;generate color pointer
sta user
lda pnt+1
and #$03
ora #>tedatr ;address of ted attribute byte area
sta user+1
rts


; remove character from queue
;
lp2
ldy kyndx ;are there any pf keys?
beq lp3 ;branch if not
ldy keyidx ;get index to current char
lda pkybuf,y ;get current byte
dec kyndx ;1 byte down
inc keyidx ;bump index to next char
cli
rts
lp3
ldy keyd ;get key from irq buffer
ldx #0
lp1
lda keyd+1,x
sta keyd,x
inx
cpx ndx
bne lp1
dec ndx
tya
cli
clc ;always good return from keybd!
rts

loop4
jsr print
loop3 ;turn on cursor
jsr scolor ;set up (user) to point to start of current attr bytes row
ldy pntr ;get column
lda (user),y ;get old color
pha ;save it

lda color ;make cursor flash in current color
sta (user),y

tya ;calculate current screen position
clc
adc pnt
sta tedcrl ;point cursor there
lda pnt+1
adc #0 ;(.c will be clear for sbc following!)
sbc #>tedscn-1 ;ted crsr posn. is relative to start of screen
sta tedcrh

waitky
lda ndx ;are there any keys ready?
ora kyndx ;or any in the pf key buffer?
beq waitky ;loop if not

; turn off cursor
;
pla ;get saved color
sta (user),y ;put it in
lda #$ff ;point cursor to cuba
sta tedcrh ;(it's the only way to turn it off)
sta tedcrl
jsr lp2 ;get key input

cmp #$83 ;<shift><run/stop>?
bne lp22
ldx #9
sei ;fill buffer with load/run cmds
stx ndx
lp21
lda runtb-1,x
sta keyd-1,x
dex
bne lp21
lp211
beq loop3

lp22
cmp #cr ;<cr>?
bne loop4
sta crsw ;flag - we pass chars now
jsr fndend ;check nxt line for cont
stx lintmp ;save last line number of sentence
jsr fistrt ;find begining of line
lda #0
sta qtsw ;clear quote mode
ldy sclf ;retrieve from line start if left it
lda lsxp ;input started row
bmi lp80 ;flag we left start line
cmp tblx
bcc lp80
ldy lstp ;input started column
cmp lintmp ;on start line
bne lp70
cpy indx ;past start column
beq lp75 ;ok if the same
lp70
bcs clp2 ;yes - null input
lp75
sta tblx ;start from here on input
lp80
sty pntr
jmp lop5


; input a line until carriage return
;
loop5
tya
pha
txa
pha
lda crsw ;passing chars to input
beq lp211 ;no - buffer on screen (jmp's to loop3)
bpl lop5 ;not done - get next char
clp2
lda #0 ;input done clear flag
sta crsw
jmp clppat ;**patch 01/03/84 fab
nop ;**
lop5
jsr stupt ;set pnt and user
jsr get1ch ;get a screen char
sta datax
and #$3f
asl datax
bit datax
bpl lop54
ora #$80
lop54
bcc lop52
ldx qtsw
bne lop53
lop52
bvs lop53
ora #$40
lop53
jsr qtswc
ldy tblx ;on input end line ?
cpy lintmp
bcc clp00 ;no
ldy pntr ;on input end column ?
cpy indx
bcc clp00 ;no
ror crsw ;c=1 minus flags last char sent
bmi clp1 ;always

clp00
jsr nxtchr ;at next char
clp1
cmp #$de ;a pi ?
bne clp7 ;no
lda #$ff ;translate
clp7
sta datax
pla
tax
pla
tay
lda datax
clc ;**patch 12/22/83 tvr
rts


qtswc
cmp #$22
bne qtswl
lda qtsw
eor #$1
sta qtsw
lda #$22
qtswl
rts


loop2
lda datax
sta lstchr ;save for next escape test
pla
tay
lda insrt
beq lop2
lsr qtsw
lop2
pla
tax
pla
clc ;good return
; cli ;shouldn't be necessary here
rts


nxt33
ora #$40
nxt3
ldx rvs
beq nvs
nc3
ora #$80
nvs
ldx insrt
beq nvsa
dec insrt
nvsa
bit insflg ;are we in auto insert?
bpl nvs1 ;branch if not
pha ;save char.
jsr insert ;make room
ldx #0
stx insrt ;make sure insert flag is off
pla
nvs1
jsr dspp ;fall thru to movchr! (will return to 'loop2')
.page
; movchr - move to next char position
; insert blank line if at end of line
; y = column position
; on exit - carry set = abort - scroll disabled
;
movchr
cpy scrt
bcc movc10 ;easy if not at end of line
ldx tblx
cpx scbot
bcc movc10 ;skip if not last line of screen
bit scrdis
bmi movc30 ;abort if scrolling disabled
movc10
jsr stupt ;set pnt address
jsr nxtchr ;move to next char position
bcc movc30 ;done if not move to new line
jsr getbit ;check if on a continued line
bcs movc20 ;skip ahead if not
sec ;incase we abort
bit scrdis
bvs movc30
jsr scrdwn ;else insert a blank line
movc20
clc ;for clean exit
movc30
rts


; skip to next line
; wrap to top if scroll disabled
;
nxln
ldx tblx
cpx scbot ;of the bottom of window ?
bcc nxln1 ;no
bit scrdis ;what if scrolling is disabled?
bpl doscrl ;branch if scroll is enabled
lda sctop ;wrap to top
sta tblx
bcs nowhop ;always

doscrl
jsr scrup ;scroll it all
clc ;indicate scroll ok
nxln1
inc tblx
nowhop
jmp stupt ;set line base adr

;end
;(07/10/84) tvr & fab: pressing a fct key during a 'getkey' cmd returned
; a error and shouldn't have. code needed a 'clc'.

KERNAL_TED/ed2.src → KERNAL_TED_04/ed2.src View File


KERNAL_TED/ed3.src → KERNAL_TED_04/ed3.src View File


KERNAL_TED/ed4.src → KERNAL_TED_04/ed4.src View File


KERNAL_TED/ed5.src → KERNAL_TED_04/ed5.src View File


KERNAL_TED/ed6.src → KERNAL_TED_04/ed6.src View File


KERNAL_TED/ed7.src → KERNAL_TED_04/ed7.src View File


KERNAL_TED/errorhdlr.src → KERNAL_TED_04/errorhdlr.src View File


KERNAL_TED/init.src → KERNAL_TED_04/init.src View File


KERNAL_TED/interrupt.src → KERNAL_TED_04/interrupt.src View File


KERNAL_TED/kernal.src → KERNAL_TED_04/kernal.src View File


KERNAL_TED/load.src → KERNAL_TED_04/load.src View File


KERNAL_TED/messages.src → KERNAL_TED_04/messages.src View File


KERNAL_TED/music.src → KERNAL_TED_04/music.src View File


KERNAL_TED/open.src → KERNAL_TED_04/open.src View File


+ 264
- 0
KERNAL_TED_04/openchanl.src View File

@@ -0,0 +1,264 @@
.page
.subttl 'openchannel'
;***************************************
;* chkin -- open channel for input *
;* *
;* the number of the logical file to be*
;* opened for input is passed in .x. *
;* chkin searches the logical file *
;* to look up device and command info. *
;* errors are reported if the device *
;* was not opened for input ,(e.g. *
;* cassette write file), or the logical*
;* file has no reference in the tables.*
;* device 0, (keyboard), and device 3 *
;* (screen), require no table entries *
;* and are handled separate. *
;***************************************

nchkin
jsr lookup ;see if file known
beq jx310 ;yup...
jmp error3 ;no...file not open

jx310
jsr jz100 ;extract file info (returns w/.a=fa & flags set)
beq jx320 ;is keyboard...done.
;
; could be screen, keyboard, or serial
;
cmp #3
beq jx320 ;is screen...done.
bcs jx330 ;is serial...address it
cmp #2
bne opcasi ;open cass for input
jsr aready ;open rs-232 for input
bcs excp1 ;carry set if acia not ready
lda fa

jx320
sta dfltn ;all input comes from here
clc ;good exit
excp1
rts
;
; a serial device has to be a talker
;
jx330
tax ;device # for dflto
jsr ttalk ;tell him to talk
bit status ;anybody home? (case of no devices on bus)
bmi dnpci ;no...

lda sa ;a second?
bpl jx340 ;yes...send it
jsr ttkatn ;no...let go
jmp jx350

jx340
jsr ttksa ;send second
jx350
txa ;restore dev#
bit status ;secondary address sent ok?
bpl jx320 ;yep, done
dnpci
jmp error5 ;input channel device not present


opcasi
ldx sa ;open cass for input
cpx #$60 ;is command a read?
beq jx320 ;yes
jmp error6
.page
;***************************************
;* chkout -- open channel for output *
;* *
;* the number of the logical file to be*
;* opened for output is passed in .x. *
;* chkout searches the logical file *
;* to look up device and command info. *
;* errors are reported if the device *
;* was not opened for input ,(e.g. *
;* keyboard), or the logical file has *
;* reference in the tables. *
;* device 0, (keyboard), and device 3 *
;* (screen), require no table entries *
;* and are handled separate. *
;***************************************

nckout
jsr lookup ;is file in table?
beq ck5 ;yes...
jmp error3 ;no...file not open

ck5
jsr jz100 ;extract table info (returns w/.a=fa & flags set)
bne ck10 ;no...something else.
ck20
jmp error7 ;yes...not output file
;
; could be screen, serial, or tape
;
ck10
cmp #3
beq ck30 ;is screen...done
bcs ck40 ;is serial...address it
cmp #2
bne optapo ;open tape for output
jsr aready ;open rs-232 for output
bcs excp2 ;carry set if acia not ready
lda fa

ck30
sta dflto ;all output goes here
clc ;good exit
excp2
rts

ck40
tax ;save device for dflto
jsr tlistn ;tell him to listen
bit status ;anybody home? (case of no devices on bus)
bmi dnpco ;no...

lda sa ;is there a second?
bpl ck50 ;yes...
jsr tscatn ;no...release lines
bne ck60 ;branch always

ck50
jsr tsecnd ;send second...
ck60
txa
bit status ;speaketh ye?
bpl ck30 ;yep, done
dnpco
jmp error5 ;device not present


optapo
ldx sa ;open tape for output
cpx #$60 ;read?
beq ck20 ;yes...bad!
bne ck30 ;always
.page
;***** tedisk support routines... {state transition} *****

tstkdy
pha ;save .a
stx wrbase ;save .x
ldx #$30 ;starting i/o offset
lda fa ;load file address
cmp #8 ;=8?
beq tstok
nok8 cmp #9 ;=9?
bne notprs
ldx #0 ;must be $fec0
tstok lda #$55 ;write a pattern to cmd channel
sta tedrva-48,x
eor tedrva-48,x ;is it the same
bne notprs
lda tedrvb-48,x ;i tied a status bit hi
and #2
bne notprs ;br, he is blown away
stx usekdy ;store offset into i/o slot
clc ;ok
.byte $24
notprs sec ;sorry not home
ldx wrbase ;restore .x
pla ;restore .a
rts ;45 bytes

patchb lda tedrvc-48,x ;wait for rdy ack to go hi
bpl patchb
bmi ptchbb ;bra

patcha lda #0
sta tedrva-48,x ;clear cmd channel
ptchbb lda #$40
sta tedrvc-48,x ;set dav hi
ldx wrbase ;restor .x
pla ;restore .a for ciout, data for acptr
clc ;ok
rts ;*

patchd sta tedrvc
sta drvc2-48
sta tedrvc-48
dex
stx drva2-48
jmp ptchdd

;this is in the patch area:
;ptchdd inx ;.x=0
; stx drvb2-48
; stx tedrva-48
; rts ;x must = 0 on rts !!!
ttalk
jsr tstkdy ;who do we talk to???
bcc kdy1 ;he's out there
jmp talk ;serial dev.

kdy1 pha ;save (a)data
lda #italk
sta kdycmd
lda usekdy
ora #$40 ;write to kdy
sta usekdy
lda #kcmd1
jmp kdy75 ;finish up

ttkatn
bit usekdy ;do an open in with no sa...
bvs kdy5 ;kdy is pres...do nothing
jmp tkatn ;serial

ttksa
bit usekdy ;do an open in with sa...
bvs kdy3 ;kdy is pres
jmp tksa

kdy3
pha ;save (a) data
lda sa
sta kdycmd
lda #kcmd2
jmp kdy75

tlistn
jsr tstkdy ;do an open out with fa...
bcc kdy4 ;he's out there...
jmp listn

kdy4
pha ;save (a) data
lda #ilstn
sta kdycmd
lda usekdy
ora #$80
sta usekdy
lda #kcmd1 ;tell tedisk to listen
jmp kdy75

tscatn
bit usekdy ;do an open out with no sa...
bmi kdy5
jmp scatn

kdy5
rts ;do nothing for kdy

tsecnd
bit usekdy ;do an open out with sa...
bmi kdy6
jmp secnd

kdy6
pha ;save (a) data
sta kdycmd
lda #kcmd2
jmp kdy75

;end

KERNAL_TED/overflow.src → KERNAL_TED_04/overflow.src View File


KERNAL_TED/patches.src → KERNAL_TED_04/patches.src View File


KERNAL_TED/rs232.src → KERNAL_TED_04/rs232.src View File


KERNAL_TED/save.src → KERNAL_TED_04/save.src View File


KERNAL_TED/serial.src → KERNAL_TED_04/serial.src View File


KERNAL_TED/split.src → KERNAL_TED_04/split.src View File


KERNAL_TED/tapred.src → KERNAL_TED_04/tapred.src View File


KERNAL_TED/tapsup.src → KERNAL_TED_04/tapsup.src View File


KERNAL_TED/tapwrt.src → KERNAL_TED_04/tapwrt.src View File


KERNAL_TED/time.src → KERNAL_TED_04/time.src View File


KERNAL_TED/util.src → KERNAL_TED_04/util.src View File


+ 69
- 0
KERNAL_TED_04/vectors.src View File

@@ -0,0 +1,69 @@
.page
.subttl 'vectors 02/17/84'
*=$ff4c
jmp print ;**must be here**... basic needs this jump
jmp primm ;**must be here**... basic needs this jump
jmp entry ;**must be here**... basic needs this jump

*=$ff80
.if palmod
.byte $84 ;release number of ted kernal (msb=1=pal version)
.else
.byte $04 ;release number of ted kernal (msb=0=ntsc version)
.endif

jmp cint
jmp ioinit
jmp ramtas
jmp restor ;restore vectors to initial system
jmp vector ;change vectors for user
jmp setmsg ;control o.s. messages
jmp tsecnd ;send sa after listen /cheap/
jmp ttksa ;send sa after talk /cheap/
jmp memtop ;set/read top of memory
jmp membot ;set/read bottom of memory
jmp scnkey ;scan keyboard
jmp settmo ;set timeout in ieee
jmp tacptr ;handshake ieee byte in /cheap/
jmp tciout ;handshake ieee byte out /cheap/
jmp tuntlk ;send untalk out ieee /cheap/
jmp tunlsn ;send unlisten out ieee /cheap/
jmp tlistn ;send listen out ieee /cheap/
jmp ttalk ;send talk out ieee /cheap/
jmp readss ;return i/o status byte
jmp setlfs ;set la, fa, sa
jmp setnam ;set length and fn adr
open jmp (iopen) ;open logical file
close jmp (iclose) ;close logical file
chkin jmp (ichkin) ;open channel in
ckout jmp (ickout) ;open channel out
clrch jmp (iclrch) ;close i/o channel
basin jmp (ibasin) ;input from channel
bsout jmp (ibsout) ;output to channel
jmp loadsp ;load from file
jmp savesp ;save to file
jmp settim ;set internal clock
jmp rdtim ;read internal clock
stop jmp (istop) ;scan stop key
getin jmp (igetin) ;get char from q
clall jmp (iclall) ;close all files
judtim jmp udtim ;increment clock
jscrog jmp scrorg ;screen org
jplot jmp plot ;read/set x,y coord
jmp iobase
.page
; the following code is necessary to prevent the problem where
; the reset button is pressed while the rom is banked out. since
; the ted chip has no reset pin, the processor will attempt to
; fetch the reset vectors without banking in rom, and will get
; garbage. this code is copied into ram behind the reset vectors,
; and will switch the rom back on before transferring execution
; to the reset routine.

gostrt
sta romon
jmp start
.wor gostrt ;initialization code
.wor puls ;interrupt handler

;end

+ 254
- 0
KERNAL_TED_05/assem.src View File

@@ -0,0 +1,254 @@
.page
.subttl 'assem'
; simple assembler
; syntax: a 1111 lda ($00,x)
; a 1111 dex: (':' = terminator)

assem
bcc as005
jmp error
as005
jsr t0tot2
as010
ldx #0
stx hulp+1 ;clear left mnemonic
as020
jsr gnc ;get a char
bne as025 ;check for eol
cpx #0
bne as025
jmp main ;if eol & no mnemonic, exit cleanly
as025
cmp #$20 ;is it a space ?
beq as010 ;yes - start again
sta msal,x ;no - save char
inx
cpx #3 ;got three chars ?
bne as020 ;no - loop
as030
dex ;squished all three ?
bmi as045 ;yes
lda msal,x ;no - first in last out
sec ;no borrow
sbc #$3f ;normalize
ldy #5 ;set for 5 shift rights
as040
lsr a
ror hulp+1 ;left mnemonic
ror hulp ;right mnemonic
dey ;done 5 shifts?
bne as040 ;no-loop
beq as030 ;always

as045
ldx #2 ;move index past mnemonic
as050
jsr gnc ;get a char
beq as100 ;done if eol
cmp #' ' ;a space
beq as050 ;yes-skip it
jsr chrtst ;a hex #?
bcs as070 ;no-buffer if
jsr rdob2 ;fin a read byte
ldy t0 ;shift t0 to t0+1
sty t0+1
sta t0 ;save byte
lda #'0 ;buffer ascii 0
sta hulp,x
inx
as070
sta hulp,x
inx
cpx #10 ;watch buffer size
bcc as050 ;branch if not full
as100
stx t1 ;save input # of chars
ldx #0
stx wrap ;start trial at zero
as110
ldx #0
stx tmpc ;disa index=0
lda wrap ;get trial byte
jsr dset ;digest it
ldx format ;save format for later
stx t1+1
tax ;index into mnemonic table
lda mnemr,x ;get compressed
jsr tstrx ;mnemonic and test
lda mneml,x
jsr tstrx
ldx #6 ;six format bits
as210
cpx #3
bne as230
ldy length
beq as230 ;skip-single byte instr
as220
lda format
cmp #$e8 ;a relative instr?
lda #'0 ;test zeros
bcs as250 ;no-3 byte
jsr tst2 ;test a byte,2 chars
dey
bne as220
as230
asl format
bcc as240
lda char1-1,x
jsr tstrx ;test syntax
lda char2-1,x
beq as240
jsr tstrx ;test more syntax
as240
dex
bne as210
beq as300
as250
jsr tst2 ;test a word,4 chars
jsr tst2
as300
lda t1 ;check # chars of both
cmp tmpc
beq as310 ;match, skip
jmp tst05 ;fail
as310
ldy length
beq as500 ;if only 1 byte instr skip
lda t1+1 ;get saved format
cmp #$9d ;a relative instr?
bne as400 ;no-skip

lda t0 ;calculate a relative
sbc t2 ;(.c=1 already)
sta diff
lda t0+1
sbc t2+1

bcc as320
bne aerr ;out of range
ldx diff
bmi aerr
bpl as340
as320
tay
iny ;out of range,y=$ff
bne aerr
ldx diff
bpl aerr
as340
dex ;subtract 2 for instr
dex
txa
ldy length ;set index to length
bne as420 ;branch always

as400
lda t0-1,y ;no-put byte out there
as420
sta (t2),y
dey
bne as400
as500
lda wrap ;get good op code
sta (t2),y
jsr cronly ;get ready to overstrike line
ldx #msgasm ;print 'a(sp)'
jsr msgxxx
jsr dis400 ;disassemble one line

inc length
lda length
jsr addt2 ;update address

lda #'a ;set up next line with 'a nnnn ' for convience
sta keyd ;put it in the keyboard buffer
lda #$20
sta keyd+1
sta keyd+6
lda t2+1
jsr makhex
sta keyd+2
stx keyd+3
lda t2
jsr makhex
sta keyd+4
stx keyd+5
lda #7
sta ndx
jmp main



; test char in .a with char in hulp
;
tst2
jsr tstrx ;do two tests
tstrx
stx sxreg
ldx tmpc ;get current position
cmp hulp,x ;same char
beq tst10 ;yes-skip
pla ;pull jsr off stack
pla

tst05
inc wrap ;try next trial
beq aerr ;=0 tried all,sorry
jmp as110

aerr
jmp error

tst10
inx
stx tmpc
ldx sxreg ;restore x
rts



; character test
; test for char between 0-f
; if 0<=char<=f then carry=0
;
chrtst
cmp #'a
bcc chr10 ;must be 0-9
cmp #'g
rts
chr10
cmp #'0
bcc chr20 ;error
cmp #':
rts



rdob2
jsr hexit
asl a
asl a
asl a
asl a
sta bad
jsr gnc
jsr hexit
ora bad
chr20
sec
rts



hexit
cmp #$3a
php
and #$0f
plp
bcc hex09
adc #8
hex09
rts

;end


+ 198
- 0
KERNAL_TED_05/banking.src View File

@@ -0,0 +1,198 @@
.page
.subttl 'banking'
;***********************************************************************
;
; software supporting banking hardware
;
; ******* this code must fit *entirely* between $fc00-$fcff *******
;
;
; set up each of the four possible slots, and test if there is a
; device in that slot. if so, store that devices number in the cor-
; responding entry in the physical address translation (pat) table.
; if a device is found to have a number of '1', it will be logged in the
; table, and a jump to that devices cold-start routine will be performed.
;
;***********************************************************************

poll
ldx #3
stx xsav
lda #0
poll10
sta pat,x ;first zero out all pat entries
dex
bpl poll10

poll20 ;set up and test each bank
ldx xsav
lda dblx,x ;set up both upper & lower banks
tax
sta bnksel,x
ldy #2
poll30
lda $8007,y ;test for 'cbm' (in ascii)
cmp cbmmsg,y
bne poll50 ;no match
dey
bpl poll30 ;keep looking

lda $8006 ;it's 'cbm'...now get device number
ldx xsav
sta pat,x
cmp #1 ;autostart?
bne poll50 ;no
stx curbnk ;yes, give them the bank configuration,
jsr $8000 ;.. then go to cold start routine.

poll50
dec xsav
bpl poll20
rts

cbmmsg .byte 'CBM'
.page
;*************************************************
;
; call every active cartridges cold start routine.
;
;*************************************************

phenix
sei
ldx #3
phen2
lda pat,x
beq phen3 ;no cartridge in this slot if 0

txa
pha
lda dblx,x ;select low and high rom
tax
sta bnksel,x
stx curbnk
jsr $8000 ;call it's cold start routine
pla
tax
phen3
dex
bne phen2 ;do slots 3,2,1 - ext2, ext1, int

sta bnksel ;set up system bank
stx curbnk ;..as current bank
cli
rts

dblx .byte %00000000,%00000101,%00001010,%00001111
.page
;***********************************************
; fetch a byte long
; entry:
; your bank in acc
; target bank in x
; target address in fetptr,fetptr+1
; offset from address in y
;
; return with value in a
;***********************************************

fetchl
sta bnksel,x
tax
lda (fetptr),y
sta bnksel,x
rts
.page
;***********************************************************************
; call a subroutine in another bank
; enter with:
; your bank in acc
; target bank in x
; fetxrg, fetarg, fetsrg loaded with x, a, and s to go into routine
; address in lngjmp, lngjmp+1
;
; return with:
; fetxrg, fetarg, fetsrg loaded with x, a, and s from routine
;***********************************************************************

long
pha ;save return bank combo
stx curbnk ;set up target bank combo
sta bnksel,x
ldx fetxrg
lda fetsrg
pha
lda fetarg
plp
jsr lngrt1
sta fetarg
php
pla
sta fetsrg
stx fetxrg
pla
sta curbnk
tax
sta bnksel,x
rts

lngrt1
jmp (lngjmp)
.page
;***********************************************************************
;
; long irq routine.
; called by a bank which has received an interrupt, and wishes to have
; the system roms (kernal/basic) service the interrupt.
;
; the users irq vector should point to the following routine in his rom:
;
; pha ;save accum.
; txa
; pha ;save x reg
; tya
; pha ;save y reg
; .
; .
; determine if this is an interrupt to be serviced by the kernal.
; if so....
; jmp lngirq
;
; *note* before calling this routine, curbank must contain your bank #
;
;***********************************************************************

puls ;entry for normal irq's
pha
txa
pha
tya
pha

lngirq ;entry for irq's passed from banking cartridges
sta bnksel ;select system roms
jmp krnirq ;kernal irq routine

irqret
ldx curbnk ;restore previous bank
sta bnksel,x
pla
tay
pla
tax
pla
rti
.page
gobvec
ldx curbnk
sta $fdd0,x
jmp (bnkvec)

*=$fcf1 ;jump table for banking routines
jmp gobvec
jmp phenix
jmp fetchl
jmp long
jmp lngirq

;end

+ 255
- 0
KERNAL_TED_05/channelio.src View File

@@ -0,0 +1,255 @@
.page
.subttl 'channelio'
;***************************************
;* getin -- get character from channel *
;* channel is determined by dfltn. *
;* if device is 0, keyboard queue is *
;* examined and a character removed if *
;* available. if queue is empty, z *
;* flag is returned set. devices 1-31 *
;* advance to basin. *
;***************************************

ngetin
lda dfltn ;check device
bne bn10 ;not keyboard

lda ndx ;queue index
ora kyndx
beq gn20 ;nobody there...exit
sei
jmp lp2 ;go remove a character



;***************************************
;* basin-- input character from channel*
;* input differs from get on device *
;* #0 function which is keyboard. the *
;* screen editor makes ready an entire *
;* line which is passed char by char *
;* up to the carriage return. other *
;* devices are: *
;* 0 -- keyboard *
;* 3 -- screen *
;* 1 -- cassette *
;* 2 -- rs-232 *
;* 4-31 -- serial bus *
;***************************************

nbasin
lda dfltn ;check device
bne bn10 ;is not keyboard...
;
; input from keyboard
;
lda pntr ;save current...
sta lstp ;... cursor column
lda tblx ;save current...
sta lsxp ;... line number
jmp loop5 ;blink cursor until return

bn10
cmp #3 ;is input from screen?
bne bn30 ;nope, try cassette, 232 or serial

ora crsw
sta crsw ;fake a carriage return
lda scrt ;say we ended...
sta indx ;...up on this line
jmp loop5 ;pick up characters

casi
jsr savxy
cmp #1
bne rs232i
jsr getcas
jmp rstxy

rs232i
jsr agetch
jmp rstxy
;
; input from serial bus
;
bn30
bcc casi ;<3
lda status ;status from last
beq tacptr ;was good
lda #$0d ;bad...all done
gn20
clc ;valid data, good return
rts



getcas ;get a chr from the cassette buffer
ldy tptr ;test for bufr empty
cpy #bufmax
bcc notmt1 ;-mt
jsr rdblok ;mt, read another block
bcc getcas ;!bra, try again
rts ;bad exit, carry should be set