Browse Source

added BASIC_VIC and KERNAL_VIC_04

pull/5/head
Simon Rowe 4 years ago committed by GitHub
parent
commit
ea9580c2a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      BASIC_VIC/basic
  2. 173
      BASIC_VIC/code1
  3. 181
      BASIC_VIC/code10
  4. 171
      BASIC_VIC/code11
  5. 154
      BASIC_VIC/code12
  6. 153
      BASIC_VIC/code13
  7. 208
      BASIC_VIC/code14
  8. 158
      BASIC_VIC/code15
  9. 164
      BASIC_VIC/code16
  10. 161
      BASIC_VIC/code17
  11. 126
      BASIC_VIC/code18
  12. 213
      BASIC_VIC/code19
  13. 160
      BASIC_VIC/code2
  14. 144
      BASIC_VIC/code20
  15. 144
      BASIC_VIC/code21
  16. 150
      BASIC_VIC/code22
  17. 82
      BASIC_VIC/code23
  18. 23
      BASIC_VIC/code24
  19. 119
      BASIC_VIC/code25
  20. 242
      BASIC_VIC/code26
  21. 139
      BASIC_VIC/code3
  22. 143
      BASIC_VIC/code4
  23. 149
      BASIC_VIC/code5
  24. 148
      BASIC_VIC/code6
  25. 147
      BASIC_VIC/code7
  26. 146
      BASIC_VIC/code8
  27. 201
      BASIC_VIC/code9
  28. 144
      BASIC_VIC/declare
  29. 46
      BASIC_VIC/disclaimer
  30. 115
      BASIC_VIC/init
  31. 251
      BASIC_VIC/token2
  32. 128
      BASIC_VIC/tokens
  33. 102
      BASIC_VIC/trig
  34. 210
      KERNAL_VIC_04/channelio
  35. 37
      KERNAL_VIC_04/clall
  36. 140
      KERNAL_VIC_04/close
  37. 40
      KERNAL_VIC_04/conkat
  38. 274
      KERNAL_VIC_04/declare
  39. 40
      KERNAL_VIC_04/disclaimer
  40. 646
      KERNAL_VIC_04/editor.1
  41. 435
      KERNAL_VIC_04/editor.2
  42. 198
      KERNAL_VIC_04/editor.3
  43. 63
      KERNAL_VIC_04/errorhandler
  44. 259
      KERNAL_VIC_04/init
  45. 15
      KERNAL_VIC_04/irqfile
  46. 30
      KERNAL_VIC_04/kernal
  47. 238
      KERNAL_VIC_04/load
  48. 29
      KERNAL_VIC_04/messages
  49. 259
      KERNAL_VIC_04/open
  50. 135
      KERNAL_VIC_04/openchannel
  51. 388
      KERNAL_VIC_04/read
  52. 166
      KERNAL_VIC_04/rs232inout
  53. 159
      KERNAL_VIC_04/rs232nmifile
  54. 131
      KERNAL_VIC_04/rs232rcvr
  55. 136
      KERNAL_VIC_04/rs232trans
  56. 118
      KERNAL_VIC_04/save
  57. 306
      KERNAL_VIC_04/serial2.1
  58. 162
      KERNAL_VIC_04/tapecontrol
  59. 195
      KERNAL_VIC_04/tapefile
  60. 124
      KERNAL_VIC_04/time
  61. 44
      KERNAL_VIC_04/vectors
  62. 193
      KERNAL_VIC_04/write
  63. 8
      README.md

33
BASIC_VIC/basic

@ -0,0 +1,33 @@
.LIB DISCLAIMER
.LIB DECLARE
.LIB TOKENS
.LIB TOKEN2
.LIB CODE1
.LIB CODE2
.LIB CODE3
.LIB CODE4
.LIB CODE5
.LIB CODE6
.LIB CODE7
.LIB CODE8
.LIB CODE9
.LIB CODE10
.LIB CODE11
.LIB CODE12
.LIB CODE13
.LIB CODE14
.LIB CODE15
.LIB CODE16
.LIB CODE17
.LIB CODE18
.LIB CODE19
.LIB CODE20
.LIB CODE21
.LIB CODE22
.LIB CODE23
.LIB CODE24
.LIB CODE25
.LIB CODE26
.LIB TRIG
.LIB INIT
.END

173
BASIC_VIC/code1

@ -0,0 +1,173 @@
.PAG 'CODE1'
OMERR LDX #ERROM
ERROR JMP (IERROR)
NERROR TXA
ASL A
TAX
LDA ERRTAB-2,X
STA INDEX1
LDA ERRTAB-1,X
STA INDEX1+1
JSR CLSCHN
LDA #0
STA CHANNL
ERRCRD JSR CRDO
JSR OUTQST
LDY #0
GETERR LDA (INDEX1)Y
PHA
AND #127
JSR OUTDO
INY
PLA
BPL GETERR
JSR STKINI
LDA #<ERR
LDY #>ERR
ERRFIN JSR STROUT
LDY CURLIN+1
INY
BEQ READY
JSR INPRT
.SKI 5
READY LDA #<REDDY
LDY #>REDDY
JSR STROUT
LDA #$80 ;DIRECT MESSAGES ON
JSR SETMSG ;FROM KERNAL
.SKI 5
MAIN JMP (IMAIN)
NMAIN JSR INLIN
STX TXTPTR
STY TXTPTR+1
JSR CHRGET
TAX
BEQ MAIN
LDX #255
STX CURLIN+1
BCC MAIN1
JSR CRUNCH
JMP GONE
MAIN1 JSR LINGET
JSR CRUNCH
STY COUNT
JSR FNDLIN
BCC NODEL
LDY #1
LDA (LOWTR)Y
STA INDEX1+1
LDA VARTAB
STA INDEX1
LDA LOWTR+1
STA INDEX2+1
LDA LOWTR
DEY
SBC (LOWTR)Y
CLC
ADC VARTAB
STA VARTAB
STA INDEX2
LDA VARTAB+1
ADC #255
STA VARTAB+1
SBC LOWTR+1
TAX
SEC
LDA LOWTR
SBC VARTAB
TAY
BCS QDECT1
INX
DEC INDEX2+1
QDECT1 CLC
ADC INDEX1
BCC MLOOP
DEC INDEX1+1
CLC
MLOOP LDA (INDEX1)Y
STA (INDEX2)Y
INY
BNE MLOOP
INC INDEX1+1
INC INDEX2+1
DEX
BNE MLOOP
NODEL JSR RUNC
JSR LNKPRG
LDA BUF
BEQ MAIN
CLC
LDA VARTAB
STA HIGHTR
ADC COUNT
STA HIGHDS
LDY VARTAB+1
STY HIGHTR+1
BCC NODELC
INY
NODELC STY HIGHDS+1
JSR BLTU
LDA LINNUM
LDY LINNUM+1
STA BUF-2
STY BUF-1
LDA STREND
LDY STREND+1
STA VARTAB
STY VARTAB+1
LDY COUNT
DEY
STOLOP LDA BUF-4,Y
STA (LOWTR)Y
DEY
BPL STOLOP
FINI JSR RUNC
JSR LNKPRG
JMP MAIN
LNKPRG LDA TXTTAB
LDY TXTTAB+1
STA INDEX
STY INDEX+1
CLC
CHEAD LDY #1
LDA (INDEX)Y
BEQ LNKRTS
LDY #4
CZLOOP INY
LDA (INDEX)Y
BNE CZLOOP
INY
TYA
ADC INDEX
TAX
LDY #0
STA (INDEX)Y
LDA INDEX+1
ADC #0
INY
STA (INDEX)Y
STX INDEX
STA INDEX+1
BCC CHEAD
LNKRTS RTS
.SKI 5
;FUNCTION TO GET A LINE ONE CHARACTER AT
;A TIME FROM THE INPUT CHANNEL AND
;BUILD IT IN THE INPUT BUFFER.
;
INLIN LDX #0
;
INLINC JSR INCHR
CMP #13 ;A CARRIAGE RETURN?
BEQ FININ1 ;YES...DONE BUILD
;
STA BUF,X ;PUT IT AWAY
INX
CPX #BUFLEN ;MAX CHARACTER LINE?
BCC INLINC ;NO...O.K.
;
LDX #ERRLS ;STRING TOO LONG ERROR
JMP ERROR
;
FININ1 JMP FININL
.END

181
BASIC_VIC/code10

@ -0,0 +1,181 @@
.PAG 'CODE10'
;TEST POINTER TO VARIABLE TO SEE
;IF CONSTANT IS CONTAINED IN BASIC.
;ARRAY VARIABLES HAVE ZEROES PLACED
;IN RAM. UNDEFINED SIMPLE VARIABLES
;HAVE POINTER T ZERO IN BASIC.
;
TSTROM SEC
LDA FACMO
SBC #<ROMLOC
LDA FACLO
SBC #>ROMLOC
BCC TSTR10
;
LDA #<INITAT
SBC FACMO
LDA #>INITAT
SBC FACLO
;
TSTR10 RTS
.SKI 5
ISVAR JSR PTRGET
ISVRET STA FACMO
STY FACMO+1
LDX VARNAM
LDY VARNAM+1
LDA VALTYP
BEQ GOOO
LDA #0
STA FACOV
JSR TSTROM ;SEE IF AN ARRAY
BCC STRRTS ;DON'T TEST ST(I),TI(I)
CPX #'T
BNE STRRTS
CPY #$C9
BNE STRRTS
JSR GETTIM
STY TENEXP
DEY
STY FBUFPT
LDY #6
STY DECCNT
LDY #FDCEND-FOUTBL
JSR FOUTIM
JMP TIMSTR
STRRTS RTS
GOOO BIT INTFLG
BPL GOOOOO
LDY #0
LDA (FACMO)Y
TAX
INY
LDA (FACMO)Y
TAY
TXA
JMP GIVAYF
GOOOOO JSR TSTROM ;SEE IF ARRAY
BCC GOMOVF ;DON'T TEST ST(I),TI(I)
CPX #'T
BNE QSTATV
CPY #'I
BNE GOMOVF
JSR GETTIM
TYA
LDX #160
JMP FLOATB
GETTIM JSR RDTIM
STX FACMO
STY FACMOH
STA FACLO
LDY #0
STY FACHO
RTS
QSTATV CPX #'S
BNE GOMOVF
CPY #'T
BNE GOMOVF
JSR READST
JMP FLOAT
GOMOVF LDA FACMO
LDY FACMO+1
JMP MOVFM
ISFUN ASL A
PHA
TAX
JSR CHRGET
CPX #LASNUM+LASNUM-255
BCC OKNORM
JSR CHKOPN
JSR FRMEVL
JSR CHKCOM
JSR CHKSTR
PLA
TAX
LDA FACMO+1
PHA
LDA FACMO
PHA
TXA
PHA
JSR GETBYT
PLA
TAY
TXA
PHA
JMP FINGO
OKNORM JSR PARCHK
PLA
TAY
FINGO LDA FUNDSP-ONEFUN-ONEFUN+256,Y
STA JMPER+1
LDA FUNDSP-ONEFUN-ONEFUN+257,Y
STA JMPER+2
JSR JMPER
JMP CHKNUM
OROP LDY #255
.BYT $2C
ANDOP LDY #0
STY COUNT
JSR AYINT
LDA FACMO
EOR COUNT
STA INTEGR
LDA FACLO
EOR COUNT
STA INTEGR+1
JSR MOVFA
JSR AYINT
LDA FACLO
EOR COUNT
AND INTEGR+1
EOR COUNT
TAY
LDA FACMO
EOR COUNT
AND INTEGR
EOR COUNT
JMP GIVAYF
DOREL JSR CHKVAL
BCS STRCMP
LDA ARGSGN
ORA #127
AND ARGHO
STA ARGHO
LDA #<ARGEXP
LDY #>ARGEXP
JSR FCOMP
TAX
JMP QCOMP
STRCMP LDA #0
STA VALTYP
DEC OPMASK
JSR FREFAC
STA DSCTMP
STX DSCTMP+1
STY DSCTMP+2
LDA ARGMO
LDY ARGMO+1
JSR FRETMP
STX ARGMO
STY ARGMO+1
TAX
SEC
SBC DSCTMP
BEQ STASGN
LDA #1
BCC STASGN
LDX DSCTMP
LDA #$FF
STASGN STA FACSGN
LDY #255
INX
NXTCMP INY
DEX
BNE GETCMP
LDX FACSGN
QCOMP BMI DOCMP
CLC
BCC DOCMP
GETCMP LDA (ARGMO)Y
.END

171
BASIC_VIC/code11

@ -0,0 +1,171 @@
.PAG 'CODE11'
CMP (DSCTMP+1)Y
BEQ NXTCMP
LDX #$FF
BCS DOCMP
LDX #1
DOCMP INX
TXA
ROL A
AND DOMASK
BEQ GOFLOT
LDA #$FF
GOFLOT JMP FLOAT
DIM3 JSR CHKCOM
DIM TAX
JSR PTRGT1
JSR CHRGOT
BNE DIM3
RTS
PTRGET LDX #0
JSR CHRGOT
PTRGT1 STX DIMFLG
PTRGT2 STA VARNAM
JSR CHRGOT
JSR ISLETC
BCS PTRGT3
INTERR JMP SNERR
PTRGT3 LDX #0
STX VALTYP
STX INTFLG
JSR CHRGET
BCC ISSEC
JSR ISLETC
BCC NOSEC
ISSEC TAX
EATEM JSR CHRGET
BCC EATEM
JSR ISLETC
BCS EATEM
NOSEC CMP #'$
BNE NOTSTR
LDA #$FF
STA VALTYP
BNE TURNON
NOTSTR CMP #'%
BNE STRNAM
LDA SUBFLG
BNE INTERR
LDA #128
STA INTFLG
ORA VARNAM
STA VARNAM
TURNON TXA
ORA #128
TAX
JSR CHRGET
STRNAM STX VARNAM+1
SEC
ORA SUBFLG
SBC #40
BNE *+5
JMP ISARY
LDY #0
STY SUBFLG
LDA VARTAB
LDX VARTAB+1
STXFND STX LOWTR+1
LOPFND STA LOWTR
CPX ARYTAB+1
BNE LOPFN
CMP ARYTAB
BEQ NOTFNS
LOPFN LDA VARNAM
CMP (LOWTR)Y
BNE NOTIT
LDA VARNAM+1
INY
CMP (LOWTR)Y
BEQ FINPTR
DEY
NOTIT CLC
LDA LOWTR
ADC #6+ADDPRC
BCC LOPFND
INX
BNE STXFND
ISLETC CMP #'A
BCC ISLRTS
SBC #$5B
SEC
SBC #@245
ISLRTS RTS
NOTFNS PLA
PHA
ZZ6=ISVRET-1
CMP #<ZZ6
BNE NOTEVL
LDZR LDA #<ZERO
LDY #>ZERO
RTS
NOTEVL LDA VARNAM
LDY VARNAM+1
CMP #'T
BNE QSTAVR
CPY #@311
BEQ LDZR
CPY #@111
BNE QSTAVR
GOBADV JMP SNERR
QSTAVR
CMP #'S
BNE VAROK
CPY #'T
BEQ GOBADV
VAROK LDA ARYTAB
LDY ARYTAB+1
STA LOWTR
STY LOWTR+1
LDA STREND
LDY STREND+1
STA HIGHTR
STY HIGHTR+1
CLC
ADC #6+ADDPRC
BCC NOTEVE
INY
NOTEVE STA HIGHDS
STY HIGHDS+1
JSR BLTU
LDA HIGHDS
LDY HIGHDS+1
INY
STA ARYTAB
STY ARYTAB+1
LDY #0
LDA VARNAM
STA (LOWTR)Y
INY
LDA VARNAM+1
STA (LOWTR)Y
LDA #0
INY
STA (LOWTR)Y
INY
STA (LOWTR)Y
INY
STA (LOWTR)Y
INY
STA (LOWTR)Y
INY
STA (LOWTR)Y
FINPTR LDA LOWTR
CLC
ADC #2
LDY LOWTR+1
BCC FINNOW
INY
FINNOW STA VARPNT
STY VARPNT+1
RTS
FMAPTR LDA COUNT
ASL A
ADC #5
ADC LOWTR
LDY LOWTR+1
BCC JSRGM
INY
JSRGM STA ARYPNT
STY ARYPNT+1
RTS
.END

154
BASIC_VIC/code12

@ -0,0 +1,154 @@
.PAG 'CODE12'
N32768 .BYT 144,128,0,0,0
FLPINT JSR AYINT
LDA FACMO
LDY FACLO
RTS
INTIDX JSR CHRGET
JSR FRMEVL
POSINT JSR CHKNUM
LDA FACSGN
BMI NONONO
AYINT LDA FACEXP
CMP #144
BCC QINTGO
LDA #<N32768
LDY #>N32768
JSR FCOMP
NONONO BNE FCERR
QINTGO JMP QINT
ISARY LDA DIMFLG
ORA INTFLG
PHA
LDA VALTYP
PHA
LDY #0
INDLOP TYA
PHA
LDA VARNAM+1
PHA
LDA VARNAM
PHA
JSR INTIDX
PLA
STA VARNAM
PLA
STA VARNAM+1
PLA
TAY
TSX
LDA 258,X
PHA
LDA 257,X
PHA
LDA INDICE
STA 258,X
LDA INDICE+1
STA 257,X
INY
JSR CHRGOT
CMP #44
BEQ INDLOP
STY COUNT
JSR CHKCLS
PLA
STA VALTYP
PLA
STA INTFLG
AND #127
STA DIMFLG
LDX ARYTAB
LDA ARYTAB+1
LOPFDA STX LOWTR
STA LOWTR+1
CMP STREND+1
BNE LOPFDV
CPX STREND
BEQ NOTFDD
LOPFDV LDY #0
LDA (LOWTR)Y
INY
CMP VARNAM
BNE NMARY1
LDA VARNAM+1
CMP (LOWTR)Y
BEQ GOTARY
NMARY1 INY
LDA (LOWTR)Y
CLC
ADC LOWTR
TAX
INY
LDA (LOWTR)Y
ADC LOWTR+1
BCC LOPFDA
BSERR LDX #ERRBS
.BYT $2C
FCERR LDX #ERRFC
ERRGO3 JMP ERROR
GOTARY LDX #ERRDD
LDA DIMFLG
BNE ERRGO3
JSR FMAPTR
LDA COUNT
LDY #4
CMP (LOWTR)Y
BNE BSERR
JMP GETDEF
NOTFDD JSR FMAPTR
JSR REASON
LDY #0
STY CURTOL+1
LDX #5
LDA VARNAM
STA (LOWTR)Y
BPL NOTFLT
DEX
NOTFLT INY
LDA VARNAM+1
STA (LOWTR)Y
BPL STOMLT
DEX
DEX
STOMLT STX CURTOL
LDA COUNT
INY
INY
INY
STA (LOWTR)Y
LOPPTA LDX #11
LDA #0
BIT DIMFLG
BVC NOTDIM
PLA
CLC
ADC #1
TAX
PLA
ADC #0
NOTDIM INY
STA (LOWTR)Y
INY
TXA
STA (LOWTR)Y
JSR UMULT
STX CURTOL
STA CURTOL+1
LDY INDEX
DEC COUNT
BNE LOPPTA
ADC ARYPNT+1
BCS OMERR1
STA ARYPNT+1
TAY
TXA
ADC ARYPNT
BCC GREASE
INY
BEQ OMERR1
GREASE JSR REASON
STA STREND
STY STREND+1
LDA #0
INC CURTOL+1
.END

153
BASIC_VIC/code13

@ -0,0 +1,153 @@
.PAG 'CODE13'
LDY CURTOL
BEQ DECCUR
ZERITA DEY
STA (ARYPNT)Y
BNE ZERITA
DECCUR DEC ARYPNT+1
DEC CURTOL+1
BNE ZERITA
INC ARYPNT+1
SEC
LDA STREND
SBC LOWTR
LDY #2
STA (LOWTR)Y
LDA STREND+1
INY
SBC LOWTR+1
STA (LOWTR)Y
LDA DIMFLG
BNE DIMRTS
INY
GETDEF LDA (LOWTR)Y
STA COUNT
LDA #0
STA CURTOL
INLPNM STA CURTOL+1
INY
PLA
TAX
STA INDICE
PLA
STA INDICE+1
CMP (LOWTR)Y
BCC INLPN2
BNE BSERR7
INY
TXA
CMP (LOWTR)Y
BCC INLPN1
BSERR7 JMP BSERR
OMERR1 JMP OMERR
INLPN2 INY
INLPN1 LDA CURTOL+1
ORA CURTOL
CLC
BEQ ADDIND
JSR UMULT
TXA
ADC INDICE
TAX
TYA
LDY INDEX1
ADDIND ADC INDICE+1
STX CURTOL
DEC COUNT
BNE INLPNM
STA CURTOL+1
LDX #5
LDA VARNAM
BPL NOTFL1
DEX
NOTFL1 LDA VARNAM+1
BPL STOML1
DEX
DEX
STOML1 STX ADDEND
LDA #0
JSR UMULTD
TXA
ADC ARYPNT
STA VARPNT
TYA
ADC ARYPNT+1
STA VARPNT+1
TAY
LDA VARPNT
DIMRTS RTS
UMULT STY INDEX
LDA (LOWTR)Y
STA ADDEND
DEY
LDA (LOWTR)Y
UMULTD STA ADDEND+1
LDA #16
STA DECCNT
LDX #0
LDY #0
UMULTC TXA
ASL A
TAX
TYA
ROL A
TAY
BCS OMERR1
ASL CURTOL
ROL CURTOL+1
BCC UMLCNT
CLC
TXA
ADC ADDEND
TAX
TYA
ADC ADDEND+1
TAY
BCS OMERR1
UMLCNT DEC DECCNT
BNE UMULTC
UMLRTS RTS
FRE LDA VALTYP
BEQ NOFREF
JSR FREFAC
NOFREF JSR GARBA2
SEC
LDA FRETOP
SBC STREND
TAY
LDA FRETOP+1
SBC STREND+1
GIVAYF LDX #0
STX VALTYP
STA FACHO
STY FACHO+1
LDX #144
JMP FLOATS
POS SEC
JSR PLOT ;GET TAB POS IN .Y
SNGFLT LDA #0
BEQ GIVAYF
ERRDIR LDX CURLIN+1
INX
BNE DIMRTS
LDX #ERRID
.BYT $2C
ERRGUF LDX #ERRUF
JMP ERROR
DEF JSR GETFNM
JSR ERRDIR
JSR CHKOPN
LDA #128
STA SUBFLG
JSR PTRGET
JSR CHKNUM
JSR CHKCLS
LDA #$B2
JSR SYNCHR
PHA
LDA VARPNT+1
PHA
LDA VARPNT
PHA
LDA TXTPTR+1
.END

208
BASIC_VIC/code14

@ -0,0 +1,208 @@
.PAG 'CODE14'
PHA
LDA TXTPTR
PHA
JSR DATA
JMP DEFFIN
GETFNM LDA #FNTK
JSR SYNCHR
ORA #128
STA SUBFLG
JSR PTRGT2
STA DEFPNT
STY DEFPNT+1
JMP CHKNUM
FNDOER JSR GETFNM
LDA DEFPNT+1
PHA
LDA DEFPNT
PHA
JSR PARCHK
JSR CHKNUM
PLA
STA DEFPNT
PLA
STA DEFPNT+1
LDY #2
LDA (DEFPNT)Y
STA VARPNT
TAX
INY
LDA (DEFPNT)Y
BEQ ERRGUF
STA VARPNT+1
INY
DEFSTF LDA (VARPNT)Y
PHA
DEY
BPL DEFSTF
LDY VARPNT+1
JSR MOVMF
LDA TXTPTR+1
PHA
LDA TXTPTR
PHA
LDA (DEFPNT)Y
STA TXTPTR
INY
LDA (DEFPNT)Y
STA TXTPTR+1
LDA VARPNT+1
PHA
LDA VARPNT
PHA
JSR FRMNUM
PLA
STA DEFPNT
PLA
STA DEFPNT+1
JSR CHRGOT
BEQ *+5
JMP SNERR
PLA
STA TXTPTR
PLA
STA TXTPTR+1
DEFFIN LDY #0
PLA
STA (DEFPNT)Y
PLA
INY
STA (DEFPNT)Y
PLA
INY
STA (DEFPNT)Y
PLA
INY
STA (DEFPNT)Y
PLA
INY
STA (DEFPNT)Y
RTS
STRD JSR CHKNUM
LDY #0
JSR FOUTC
PLA
PLA
TIMSTR LDA #<LOFBUF
LDY #>LOFBUF
BEQ STRLIT
STRINI LDX FACMO
LDY FACMO+1
STX DSCPNT
STY DSCPNT+1
STRSPA JSR GETSPA
STX DSCTMP+1
STY DSCTMP+2
STA DSCTMP
RTS
STRLIT LDX #34
STX CHARAC
STX ENDCHR
STRLT2 STA STRNG1
STY STRNG1+1
STA DSCTMP+1
STY DSCTMP+2
LDY #255
STRGET INY
LDA (STRNG1)Y
BEQ STRFI1
CMP CHARAC
BEQ STRFIN
CMP ENDCHR
BNE STRGET
STRFIN CMP #34
BEQ STRFI2
STRFI1 CLC
STRFI2 STY DSCTMP
TYA
ADC STRNG1
STA STRNG2
LDX STRNG1+1
BCC STRST2
INX
STRST2 STX STRNG2+1
LDA STRNG1+1
BEQ STRCP
CMP #BUFPAG
BNE PUTNEW
STRCP TYA
JSR STRINI
LDX STRNG1
LDY STRNG1+1
JSR MOVSTR
PUTNEW LDX TEMPPT
CPX #TEMPST+STRSIZ+STRSIZ+STRSIZ
BNE PUTNW1
LDX #ERRST
ERRGO2 JMP ERROR
PUTNW1 LDA DSCTMP
STA 0,X
LDA DSCTMP+1
STA 1,X
LDA DSCTMP+2
STA 2,X
LDY #0
STX FACMO
STY FACMO+1
STY FACOV
DEY
STY VALTYP
STX LASTPT
INX
INX
INX
STX TEMPPT
RTS
GETSPA LSR GARBFL
TRYAG2 PHA
EOR #255
SEC
ADC FRETOP
LDY FRETOP+1
BCS TRYAG3
DEY
TRYAG3 CPY STREND+1
BCC GARBAG
BNE STRFRE
CMP STREND
BCC GARBAG
STRFRE STA FRETOP
STY FRETOP+1
STA FRESPC
STY FRESPC+1
TAX
PLA
RTS
GARBAG LDX #ERROM
LDA GARBFL
BMI ERRGO2
JSR GARBA2
LDA #128
STA GARBFL
PLA
BNE TRYAG2
GARBA2 LDX MEMSIZ
LDA MEMSIZ+1
FNDVAR STX FRETOP
STA FRETOP+1
LDY #0
STY GRBPNT+1
STY GRBPNT
LDA STREND
LDX STREND+1
STA GRBTOP
STX GRBTOP+1
LDA #<TEMPST
LDX #>TEMPST
STA INDEX1
STX INDEX1+1
TVAR CMP TEMPPT
BEQ SVARS
JSR DVAR
BEQ TVAR
SVARS LDA #6+ADDPRC
STA FOUR6
LDA VARTAB
LDX VARTAB+1
.END

158
BASIC_VIC/code15

@ -0,0 +1,158 @@
.PAG 'CODE15'
STA INDEX1
STX INDEX1+1
SVAR CPX ARYTAB+1
BNE SVARGO
CMP ARYTAB
BEQ ARYVAR
SVARGO JSR DVARS
BEQ SVAR
ARYVAR STA ARYPNT
STX ARYPNT+1
LDA #STRSIZ
STA FOUR6
ARYVA2 LDA ARYPNT
LDX ARYPNT+1
ARYVA3 CPX STREND+1
BNE ARYVGO
CMP STREND
BNE *+5
JMP GRBPAS
ARYVGO STA INDEX1
STX INDEX1+1
LDY #1-ADDPRC
LDA (INDEX1)Y
TAX
INY
LDA (INDEX1)Y
PHP
INY
LDA (INDEX1)Y
ADC ARYPNT
STA ARYPNT
INY
LDA (INDEX1)Y
ADC ARYPNT+1
STA ARYPNT+1
PLP
BPL ARYVA2
TXA
BMI ARYVA2
INY
LDA (INDEX1)Y
LDY #0
ASL A
ADC #5
ADC INDEX1
STA INDEX1
BCC ARYGET
INC INDEX1+1
ARYGET LDX INDEX1+1
ARYSTR CPX ARYPNT+1
BNE GOGO
CMP ARYPNT
BEQ ARYVA3
GOGO JSR DVAR
BEQ ARYSTR
DVARS LDA (INDEX1)Y
BMI DVARTS
INY
LDA (INDEX1)Y
BPL DVARTS
INY
DVAR LDA (INDEX1)Y
BEQ DVARTS
INY
LDA (INDEX1)Y
TAX
INY
LDA (INDEX1)Y
CMP FRETOP+1
BCC DVAR2
BNE DVARTS
CPX FRETOP
BCS DVARTS
DVAR2 CMP GRBTOP+1
BCC DVARTS
BNE DVAR3
CPX GRBTOP
BCC DVARTS
DVAR3 STX GRBTOP
STA GRBTOP+1
LDA INDEX1
LDX INDEX1+1
STA GRBPNT
STX GRBPNT+1
LDA FOUR6
STA SIZE
DVARTS LDA FOUR6
CLC
ADC INDEX1
STA INDEX1
BCC GRBRTS
INC INDEX1+1
GRBRTS LDX INDEX1+1
LDY #0
RTS
GRBPAS LDA GRBPNT+1
ORA GRBPNT
BEQ GRBRTS
LDA SIZE
AND #4
LSR A
TAY
STA SIZE
LDA (GRBPNT)Y
ADC LOWTR
STA HIGHTR
LDA LOWTR+1
ADC #0
STA HIGHTR+1
LDA FRETOP
LDX FRETOP+1
STA HIGHDS
STX HIGHDS+1
JSR BLTUC
LDY SIZE
INY
LDA HIGHDS
STA (GRBPNT)Y
TAX
INC HIGHDS+1
LDA HIGHDS+1
INY
STA (GRBPNT)Y
JMP FNDVAR
CAT LDA FACLO
PHA
LDA FACMO
PHA
JSR EVAL
JSR CHKSTR
PLA
STA STRNG1
PLA
STA STRNG1+1
LDY #0
LDA (STRNG1)Y
CLC
ADC (FACMO)Y
BCC SIZEOK
LDX #ERRLS
JMP ERROR
SIZEOK JSR STRINI
JSR MOVINS
LDA DSCPNT
LDY DSCPNT+1
JSR FRETMP
JSR MOVDO
LDA STRNG1
LDY STRNG1+1
JSR FRETMP
JSR PUTNEW
JMP TSTOP
MOVINS LDY #0
LDA (STRNG1)Y
PHA
INY
.END

164
BASIC_VIC/code16

@ -0,0 +1,164 @@
.PAG 'CODE16'
LDA (STRNG1)Y
TAX
INY
LDA (STRNG1)Y
TAY
PLA
MOVSTR STX INDEX
STY INDEX+1
MOVDO TAY
BEQ MVDONE
PHA
MOVLP DEY
LDA (INDEX)Y
STA (FRESPC)Y
TYA
BNE MOVLP
PLA
MVDONE CLC
ADC FRESPC
STA FRESPC
BCC MVSTRT
INC FRESPC+1
MVSTRT RTS
FRESTR JSR CHKSTR
FREFAC LDA FACMO
LDY FACMO+1
FRETMP STA INDEX
STY INDEX+1
JSR FRETMS
PHP
LDY #0
LDA (INDEX)Y
PHA
INY
LDA (INDEX)Y
TAX
INY
LDA (INDEX)Y
TAY
PLA
PLP
BNE FRETRT
CPY FRETOP+1
BNE FRETRT
CPX FRETOP
BNE FRETRT
PHA
CLC
ADC FRETOP
STA FRETOP
BCC FREPLA
INC FRETOP+1
FREPLA PLA
FRETRT STX INDEX
STY INDEX+1
RTS
FRETMS CPY LASTPT+1
BNE FRERTS
CMP LASTPT
BNE FRERTS
STA TEMPPT
SBC #STRSIZ
STA LASTPT
LDY #0
FRERTS RTS
CHRD JSR CONINT
TXA
PHA
LDA #1
JSR STRSPA
PLA
LDY #0
STA (DSCTMP+1)Y
PLA
PLA
JMP PUTNEW
LEFTD JSR PREAM
CMP (DSCPNT)Y
TYA
RLEFT BCC RLEFT1
LDA (DSCPNT)Y
TAX
TYA
RLEFT1 PHA
RLEFT2 TXA
RLEFT3 PHA
JSR STRSPA
LDA DSCPNT
LDY DSCPNT+1
JSR FRETMP
PLA
TAY
PLA
CLC
ADC INDEX
STA INDEX
BCC PULMOR
INC INDEX+1
PULMOR TYA
JSR MOVDO
JMP PUTNEW
RIGHTD JSR PREAM
CLC
SBC (DSCPNT)Y
EOR #255
JMP RLEFT
MIDD LDA #255
STA FACLO
JSR CHRGOT
CMP #41
BEQ MID2
JSR CHKCOM
JSR GETBYT
MID2 JSR PREAM
BEQ GOFUC
DEX
TXA
PHA
CLC
LDX #0
SBC (DSCPNT)Y
BCS RLEFT2
EOR #255
CMP FACLO
BCC RLEFT3
LDA FACLO
BCS RLEFT3
PREAM JSR CHKCLS
PLA
TAY
PLA
STA JMPER+1
PLA
PLA
PLA
TAX
PLA
STA DSCPNT
PLA
STA DSCPNT+1
LDA JMPER+1
PHA
TYA
PHA
LDY #0
TXA
RTS
LEN JSR LEN1
JMP SNGFLT
LEN1 JSR FRESTR
LDX #0
STX VALTYP
TAY
RTS
ASC JSR LEN1
BEQ GOFUC
LDY #0
LDA (INDEX1)Y
TAY
JMP SNGFLT
GOFUC JMP FCERR
GTBYTC JSR CHRGET
.END

161
BASIC_VIC/code17

@ -0,0 +1,161 @@
.PAG 'CODE17'
GETBYT JSR FRMNUM
CONINT JSR POSINT
LDX FACMO
BNE GOFUC
LDX FACLO
JMP CHRGOT
VAL JSR LEN1
BNE *+5
JMP ZEROFC
LDX TXTPTR
LDY TXTPTR+1
STX STRNG2
STY STRNG2+1
LDX INDEX1
STX TXTPTR
CLC
ADC INDEX1
STA INDEX2
LDX INDEX1+1
STX TXTPTR+1
BCC VAL2
INX
VAL2 STX INDEX2+1
LDY #0
LDA (INDEX2)Y
PHA
TYA ;A=0
STA (INDEX2)Y
JSR CHRGOT
JSR FIN
PLA
LDY #0
STA (INDEX2)Y
ST2TXT LDX STRNG2
LDY STRNG2+1
STX TXTPTR
STY TXTPTR+1
VALRTS RTS
GETNUM JSR FRMNUM
JSR GETADR
COMBYT JSR CHKCOM
JMP GETBYT
GETADR LDA FACSGN
BMI GOFUC
LDA FACEXP
CMP #145
BCS GOFUC
JSR QINT
LDA FACMO
LDY FACMO+1
STY POKER
STA POKER+1
RTS
PEEK LDA POKER+1
PHA
LDA POKER
PHA
JSR GETADR
LDY #0
GETCON LDA (POKER)Y
TAY
DOSGFL PLA
STA POKER
PLA
STA POKER+1
JMP SNGFLT
POKE JSR GETNUM
TXA
LDY #0
STA (POKER)Y
RTS
FNWAIT JSR GETNUM
STX ANDMSK
LDX #0
JSR CHRGOT
BEQ STORDO
JSR COMBYT
STORDO STX EORMSK
LDY #0
WAITER LDA (POKER)Y
EOR EORMSK
AND ANDMSK
BEQ WAITER
ZERRTS RTS
FADDH LDA #<FHALF
LDY #>FHALF
JMP FADD
FSUB JSR CONUPK
FSUBT LDA FACSGN
EOR #@377
STA FACSGN
EOR ARGSGN
STA ARISGN
LDA FACEXP
JMP FADDT
FADD5 JSR SHIFTR
BCC FADD4
FADD JSR CONUPK
FADDT BNE *+5
JMP MOVFA
LDX FACOV
STX OLDOV
LDX #ARGEXP
LDA ARGEXP
FADDC TAY
BEQ ZERRTS
SEC
SBC FACEXP
BEQ FADD4
BCC FADDA
STY FACEXP
LDY ARGSGN
STY FACSGN
EOR #@377
ADC #0
LDY #0
STY OLDOV
LDX #FAC
BNE FADD1
FADDA LDY #0
STY FACOV
FADD1 CMP #$F9
BMI FADD5
TAY
LDA FACOV
LSR 1,X
JSR ROLSHF
FADD4 BIT ARISGN
BPL FADD2
LDY #FACEXP
CPX #ARGEXP
BEQ SUBIT
LDY #ARGEXP
SUBIT SEC
EOR #@377
ADC OLDOV
STA FACOV
LDA 3+ADDPRC,Y
SBC 3+ADDPRC,X
STA FACLO
LDA ADDPRC+2,Y
SBC 2+ADDPRC,X
STA FACMO
LDA 2,Y
SBC 2,X
STA FACMOH
LDA 1,Y
SBC 1,X
STA FACHO
FADFLT BCS NORMAL
JSR NEGFAC
NORMAL LDY #0
TYA
CLC
NORM3 LDX FACHO
BNE NORM1
LDX FACHO+1
STX FACHO
LDX FACMOH+1
.END

126
BASIC_VIC/code18

@ -0,0 +1,126 @@
.PAG 'CODE18'
STX FACMOH
LDX FACMO+1
STX FACMO
LDX FACOV
STX FACLO
STY FACOV
ADC #@10
ADDPR2 =ADDPRC+ADDPRC
ADDPR4 =ADDPR2+ADDPR2
ADDPR8 =ADDPR4+ADDPR4
CMP #@30+ADDPR8
BNE NORM3
ZEROFC LDA #0
ZEROF1 STA FACEXP
ZEROML STA FACSGN
RTS
FADD2 ADC OLDOV
STA FACOV
LDA FACLO
ADC ARGLO
STA FACLO
LDA FACMO
ADC ARGMO
STA FACMO
LDA FACMOH
ADC ARGMOH
STA FACMOH
LDA FACHO
ADC ARGHO
STA FACHO
JMP SQUEEZ
NORM2 ADC #1
ASL FACOV
ROL FACLO
ROL FACMO
ROL FACMOH
ROL FACHO
NORM1 BPL NORM2
SEC
SBC FACEXP
BCS ZEROFC
EOR #@377
ADC #1
STA FACEXP
SQUEEZ BCC RNDRTS
RNDSHF INC FACEXP
BEQ OVERR
ROR FACHO
ROR FACMOH
ROR FACMO
ROR FACLO
ROR FACOV
RNDRTS RTS
NEGFAC LDA FACSGN
EOR #@377
STA FACSGN
NEGFCH LDA FACHO
EOR #@377
STA FACHO
LDA FACMOH
EOR #@377
STA FACMOH
LDA FACMO
EOR #@377
STA FACMO
LDA FACLO
EOR #@377
STA FACLO
LDA FACOV
EOR #@377
STA FACOV
INC FACOV
BNE INCFRT
INCFAC INC FACLO
BNE INCFRT
INC FACMO
BNE INCFRT
INC FACMOH
BNE INCFRT
INC FACHO
INCFRT RTS
OVERR LDX #ERROV
JMP ERROR
MULSHF LDX #RESHO-1
SHFTR2 LDY 3+ADDPRC,X
STY FACOV
LDY 3,X
STY 4,X
LDY 2,X
STY 3,X
LDY 1,X
STY 2,X
LDY BITS
STY 1,X
SHIFTR ADC #@10
BMI SHFTR2
BEQ SHFTR2
SBC #@10
TAY
LDA FACOV
BCS SHFTRT
SHFTR3 ASL 1,X
BCC SHFTR4
INC 1,X
SHFTR4 ROR 1,X
ROR 1,X
ROLSHF ROR 2,X
ROR 3,X
ROR 4,X
ROR A
INY
BNE SHFTR3
SHFTRT CLC
RTS
FONE .BYT @201,0,0,0,0
LOGCN2 .BYT 3,@177,@136,@126
.BYT @313,@171,@200,@23
.BYT @233,@13,@144,@200
.BYT @166,@70,@223,@26
.BYT @202,@70,@252,@73,@40
SQR05 .BYT @200,@65,4,@363,@64
SQR20 .BYT @201,@65,@4,@363,@64
NEGHLF .BYT @200,@200,0,0,0
LOG2 .BYT @200,@61,@162,@27,@370
.END

213
BASIC_VIC/code19

@ -0,0 +1,213 @@
.PAG 'CODE19'
LOG JSR SIGN
BEQ LOGERR
BPL LOG1
LOGERR JMP FCERR
LOG1 LDA FACEXP
SBC #@177
PHA
LDA #@200
STA FACEXP
LDA #<SQR05
LDY #>SQR05
JSR FADD
LDA #<SQR20
LDY #>SQR20
JSR FDIV
LDA #<FONE
LDY #>FONE
JSR FSUB
LDA #<LOGCN2
LDY #>LOGCN2
JSR POLYX
LDA #<NEGHLF
LDY #>NEGHLF
JSR FADD
PLA
JSR FINLOG
LDA #<LOG2
LDY #>LOG2
FMULT JSR CONUPK
FMULTT BNE *+5
JMP MULTRT
JSR MULDIV
LDA #0
STA RESHO
STA RESMOH
STA RESMO
STA RESLO
LDA FACOV
JSR MLTPLY
LDA FACLO
JSR MLTPLY
LDA FACMO
JSR MLTPLY
LDA FACMOH
JSR MLTPLY
LDA FACHO
JSR MLTPL1
JMP MOVFR
MLTPLY BNE *+5
JMP MULSHF
MLTPL1 LSR A
ORA #@200
MLTPL2 TAY
BCC MLTPL3
CLC
LDA RESLO
ADC ARGLO
STA RESLO
LDA RESMO
ADC ARGMO
STA RESMO
LDA RESMOH
ADC ARGMOH
STA RESMOH
LDA RESHO
ADC ARGHO
STA RESHO
MLTPL3 ROR RESHO
ROR RESMOH
ROR RESMO
ROR RESLO
ROR FACOV
TYA
LSR A
BNE MLTPL2
MULTRT RTS
CONUPK STA INDEX1
STY INDEX1+1
LDY #3+ADDPRC
LDA (INDEX1)Y
STA ARGLO
DEY
LDA (INDEX)Y
STA ARGMO
DEY
LDA (INDEX1)Y
STA ARGMOH
DEY
LDA (INDEX1)Y
STA ARGSGN
EOR FACSGN
STA ARISGN
LDA ARGSGN
ORA #@200
STA ARGHO
DEY
LDA (INDEX1)Y
STA ARGEXP
LDA FACEXP
RTS
MULDIV LDA ARGEXP
MLDEXP BEQ ZEREMV
CLC
ADC FACEXP
BCC TRYOFF
BMI GOOVER
CLC
.BYT $2C
TRYOFF BPL ZEREMV
ADC #@200
STA FACEXP
BNE *+5
JMP ZEROML
LDA ARISGN
STA FACSGN
RTS
MLDVEX LDA FACSGN
EOR #@377
BMI GOOVER
ZEREMV PLA
PLA
JMP ZEROFC
GOOVER JMP OVERR
MUL10 JSR MOVAF
TAX
BEQ MUL10R
CLC
ADC #2
BCS GOOVER
FINML6 LDX #0
STX ARISGN
JSR FADDC
INC FACEXP
BEQ GOOVER
MUL10R RTS
TENC .BYT @204,@40,0,0,0
DIV10 JSR MOVAF
LDA #<TENC
LDY #>TENC
LDX #0
FDIVF STX ARISGN
JSR MOVFM
JMP FDIVT
FDIV JSR CONUPK
FDIVT BEQ DV0ERR
JSR ROUND
LDA #0
SEC
SBC FACEXP
STA FACEXP
JSR MULDIV
INC FACEXP
BEQ GOOVER
LDX #253-ADDPRC
LDA #1
DIVIDE LDY ARGHO
CPY FACHO
BNE SAVQUO
LDY ARGMOH
CPY FACMOH
BNE SAVQUO
LDY ARGMO
CPY FACMO
BNE SAVQUO
LDY ARGLO
CPY FACLO
SAVQUO PHP
ROL A
BCC QSHFT
INX
STA RESLO,X
BEQ LD100
BPL DIVNRM
LDA #1
QSHFT PLP
BCS DIVSUB
SHFARG ASL ARGLO
ROL ARGMO
ROL ARGMOH
ROL ARGHO
BCS SAVQUO
BMI DIVIDE
BPL SAVQUO
DIVSUB TAY
LDA ARGLO
SBC FACLO
STA ARGLO
LDA ARGMO
SBC FACMO
STA ARGMO
LDA ARGMOH
SBC FACMOH
STA ARGMOH
LDA ARGHO
SBC FACHO
STA ARGHO
TYA
JMP SHFARG
LD100 LDA #@100
BNE QSHFT
DIVNRM ASL A
ASL A
ASL A
ASL A
ASL A
ASL A
STA FACOV
PLP
JMP MOVFR
DV0ERR LDX #ERRDVO
JMP ERROR
.END

160
BASIC_VIC/code2

@ -0,0 +1,160 @@
.PAG 'CODE2'
BUFOFS =@1000
CRUNCH JMP (ICRNCH)
NCRNCH LDX TXTPTR
LDY #4
STY DORES
KLOOP LDA BUFOFS,X
BPL CMPSPC
CMP #PI
BEQ STUFFH
INX
BNE KLOOP
CMPSPC CMP #'
BEQ STUFFH
STA ENDCHR
CMP #34
BEQ STRNG
BIT DORES
BVS STUFFH
CMP #'?
BNE KLOOP1
LDA #PRINTK
BNE STUFFH
KLOOP1 CMP #'0
BCC MUSTCR
CMP #60
BCC STUFFH
MUSTCR STY BUFPTR
LDY #0
STY COUNT
DEY
STX TXTPTR
DEX
RESER INY
INX
RESCON LDA BUFOFS,X
SEC
SBC RESLST,Y
BEQ RESER
CMP #128
BNE NTHIS
ORA COUNT
GETBPT LDY BUFPTR
STUFFH INX
INY
STA BUF-5,Y
LDA BUF-5,Y
BEQ CRDONE
SEC
SBC #':
BEQ COLIS
CMP #DATATK-$3A
BNE NODATT
COLIS STA DORES
NODATT SEC
SBC #REMTK-$3A
BNE KLOOP
STA ENDCHR
STR1 LDA BUFOFS,X
BEQ STUFFH
CMP ENDCHR
BEQ STUFFH
STRNG INY
STA BUF-5,Y
INX
BNE STR1
NTHIS LDX TXTPTR
INC COUNT
NTHIS1 INY
LDA RESLST-1,Y
BPL NTHIS1
LDA RESLST,Y
BNE RESCON
LDA BUFOFS,X
BPL GETBPT
CRDONE STA BUF-3,Y
DEC TXTPTR+1
ZZ1 =BUF-1
LDA #<ZZ1
STA TXTPTR
RTS
FNDLIN LDA TXTTAB
LDX TXTTAB+1
FNDLNC LDY #1
STA LOWTR
STX LOWTR+1
LDA (LOWTR)Y
BEQ FLINRT
INY
INY
LDA LINNUM+1
CMP (LOWTR)Y
BCC FLNRTS
BEQ FNDLO1
DEY
BNE AFFRTS
FNDLO1 LDA LINNUM
DEY
CMP (LOWTR)Y
BCC FLNRTS
BEQ FLNRTS
AFFRTS DEY
LDA (LOWTR)Y
TAX
DEY
LDA (LOWTR)Y
BCS FNDLNC
FLINRT CLC
FLNRTS RTS
SCRATH BNE FLNRTS
SCRTCH LDA #0
TAY
STA (TXTTAB)Y
INY
STA (TXTTAB)Y
LDA TXTTAB
CLC
ADC #2
STA VARTAB
LDA TXTTAB+1
ADC #0
STA VARTAB+1
RUNC JSR STXTPT
LDA #0
CLEAR BNE STKRTS
CLEARC JSR CCALL ;MOVED FOR V2 ORIG FOR RS-232
CLEART LDA MEMSIZ ;ENTRY FOR OPEN & CLOSE MEMSIZ CHANGES
LDY MEMSIZ+1
STA FRETOP
STY FRETOP+1
LDA VARTAB
LDY VARTAB+1
STA ARYTAB
STY ARYTAB+1
STA STREND
STY STREND+1
FLOAD JSR RESTOR
STKINI LDX #TEMPST
STX TEMPPT
PLA
TAY
PLA
LDX #STKEND-257
TXS
PHA
TYA
PHA
LDA #0
STA OLDTXT+1
STA SUBFLG
STKRTS RTS
STXTPT CLC
LDA TXTTAB
ADC #255
STA TXTPTR
LDA TXTTAB+1
ADC #255
STA TXTPTR+1
RTS
.END

144
BASIC_VIC/code20

@ -0,0 +1,144 @@
.PAG 'CODE20'
MOVFR LDA RESHO
STA FACHO
LDA RESMOH
STA FACMOH
LDA RESMO
STA FACMO
LDA RESLO
STA FACLO
JMP NORMAL
MOVFM STA INDEX1
STY INDEX1+1
LDY #3+ADDPRC
LDA (INDEX1)Y
STA FACLO
DEY
LDA (INDEX1)Y
STA FACMO
DEY
LDA (INDEX1)Y
STA FACMOH
DEY
LDA (INDEX1)Y
STA FACSGN
ORA #@200
STA FACHO
DEY
LDA (INDEX1)Y
STA FACEXP
STY FACOV
RTS
MOV2F LDX #TEMPF2
.BYT $2C
MOV1F LDX #TEMPF1
LDY #0
BEQ MOVMF
MOVVF LDX FORPNT
LDY FORPNT+1
MOVMF JSR ROUND
STX INDEX1
STY INDEX1+1
LDY #3+ADDPRC
LDA FACLO
STA (INDEX)Y
DEY
LDA FACMO
STA (INDEX)Y
DEY
LDA FACMOH
STA (INDEX)Y
DEY
LDA FACSGN
ORA #@177
AND FACHO
STA (INDEX)Y
DEY
LDA FACEXP
STA (INDEX)Y
STY FACOV
RTS
MOVFA LDA ARGSGN
MOVFA1 STA FACSGN
LDX #4+ADDPRC
MOVFAL LDA ARGEXP-1,X
STA FACEXP-1,X
DEX
BNE MOVFAL
STX FACOV
RTS
MOVAF JSR ROUND
MOVEF LDX #5+ADDPRC
MOVAFL LDA FACEXP-1,X
STA ARGEXP-1,X
DEX
BNE MOVAFL
STX FACOV
MOVRTS RTS
ROUND LDA FACEXP
BEQ MOVRTS
ASL FACOV
BCC MOVRTS
INCRND JSR INCFAC
BNE MOVRTS
JMP RNDSHF
SIGN LDA FACEXP
BEQ SIGNRT
FCSIGN LDA FACSGN
FCOMPS ROL A
LDA #$FF
BCS SIGNRT
LDA #1
SIGNRT RTS
SGN JSR SIGN
FLOAT STA FACHO
LDA #0
STA FACHO+1
LDX #@210
FLOATS LDA FACHO
EOR #@377
ROL A
FLOATC LDA #0
STA FACLO
STA FACMO
FLOATB STX FACEXP
STA FACOV
STA FACSGN
JMP FADFLT
ABS LSR FACSGN
RTS
FCOMP STA INDEX2
FCOMPN STY INDEX2+1
LDY #0
LDA (INDEX2)Y
INY
TAX
BEQ SIGN
LDA (INDEX2)Y
EOR FACSGN
BMI FCSIGN
CPX FACEXP
BNE FCOMPC
LDA (INDEX2)Y
ORA #@200
CMP FACHO
BNE FCOMPC
INY
LDA (INDEX2)Y
CMP FACMOH
BNE FCOMPC
INY
LDA (INDEX2)Y
CMP FACMO
BNE FCOMPC
INY
LDA #@177
CMP FACOV
LDA (INDEX2)Y
SBC FACLO
BEQ QINTRT
FCOMPC LDA FACSGN
BCC FCOMPD
EOR #@377
FCOMPD JMP FCOMPS
.END

144
BASIC_VIC/code21

@ -0,0 +1,144 @@
.PAG 'CODE21'
QINT LDA FACEXP
BEQ CLRFAC
SEC
SBC #ADDPR8+@230
BIT FACSGN
BPL QISHFT
TAX
LDA #@377
STA BITS
JSR NEGFCH
TXA
QISHFT LDX #FAC
CMP #$F9
BPL QINT1
JSR SHIFTR
STY BITS
QINTRT RTS
QINT1 TAY
LDA FACSGN
AND #@200
LSR FACHO
ORA FACHO
STA FACHO
JSR ROLSHF
STY BITS
RTS
INT LDA FACEXP
CMP #ADDPR8+@230
BCS INTRTS
JSR QINT
STY FACOV
LDA FACSGN
STY FACSGN
EOR #@200
ROL A
LDA #@230+8
STA FACEXP
LDA FACLO
STA INTEGR
JMP FADFLT
CLRFAC STA FACHO
STA FACMOH
STA FACMO
STA FACLO
TAY
INTRTS RTS
FIN LDY #@0
LDX #@11+ADDPRC
FINZLP STY DECCNT,X
DEX
BPL FINZLP
BCC FINDGQ
CMP #'-
BNE QPLUS
STX SGNFLG
BEQ FINC
QPLUS CMP #'+
BNE FIN1
FINC JSR CHRGET
FINDGQ BCC FINDIG
FIN1 CMP #'.
BEQ FINDP
CMP #'E
BNE FINE
JSR CHRGET
BCC FNEDG1
CMP #MINUTK
BEQ FINEC1
CMP #'-
BEQ FINEC1
CMP #PLUSTK
BEQ FINEC
CMP #'+
BEQ FINEC
BNE FINEC2
FINEC1 ROR EXPSGN
FINEC JSR CHRGET
FNEDG1 BCC FINEDG
FINEC2 BIT EXPSGN
BPL FINE
LDA #0
SEC
SBC TENEXP
JMP FINE1
FINDP ROR DPTFLG
BIT DPTFLG
BVC FINC
FINE LDA TENEXP
FINE1 SEC
SBC DECCNT
STA TENEXP
BEQ FINQNG
BPL FINMUL
FINDIV JSR DIV10
INC TENEXP
BNE FINDIV
BEQ FINQNG
FINMUL JSR MUL10
DEC TENEXP
BNE FINMUL
FINQNG LDA SGNFLG
BMI NEGXQS
RTS
NEGXQS JMP NEGOP
FINDIG PHA
BIT DPTFLG
BPL FINDG1
INC DECCNT
FINDG1 JSR MUL10
PLA
SEC
SBC #'0
JSR FINLOG
JMP FINC
FINLOG PHA
JSR MOVAF
PLA
JSR FLOAT
LDA ARGSGN
EOR FACSGN
STA ARISGN
LDX FACEXP
JMP FADDT
FINEDG LDA TENEXP
CMP #@12
BCC MLEX10
LDA #@144
BIT EXPSGN
BMI MLEXMI
JMP OVERR
MLEX10 ASL A
ASL A
CLC
ADC TENEXP
ASL A
CLC
LDY #0
ADC (TXTPTR)Y
SEC
SBC #'0
MLEXMI STA TENEXP
JMP FINEC
.END

150
BASIC_VIC/code22

@ -0,0 +1,150 @@
.PAG 'CODE22'
N0999 .BYT @233,@76,@274,@37,@375
N9999 .BYT @236,@156,@153,@47,@375
NMIL .BYT @236,@156,@153,@50,0
INPRT LDA #<INTXT
LDY #>INTXT
JSR STROU2
LDA CURLIN+1
LDX CURLIN
LINPRT STA FACHO
STX FACHO+1
LDX #@220
SEC
JSR FLOATC
JSR FOUTC
STROU2 JMP STROUT
FOUT LDY #1
FOUTC LDA #'
BIT FACSGN
BPL FOUT1
LDA #'-
FOUT1 STA FBUFFR-1,Y
STA FACSGN
STY FBUFPT
INY
LDA #'0
LDX FACEXP
BNE *+5
JMP FOUT19
LDA #0
CPX #@200
BEQ FOUT37
BCS FOUT7
FOUT37 LDA #<NMIL
LDY #>NMIL
JSR FMULT
LDA #250-ADDPR2-ADDPRC
FOUT7 STA DECCNT
FOUT4 LDA #<N9999
LDY #>N9999
JSR FCOMP
BEQ BIGGES
BPL FOUT9
FOUT3 LDA #<N0999
LDY #>N0999
JSR FCOMP
BEQ FOUT38
BPL FOUT5
FOUT38 JSR MUL10
DEC DECCNT
BNE FOUT3
FOUT9 JSR DIV10
INC DECCNT
BNE FOUT4
FOUT5 JSR FADDH
BIGGES JSR QINT
LDX #1
LDA DECCNT
CLC
ADC #ADDPR2+ADDPRC+7
BMI FOUTPI
CMP #ADDPR2+ADDPRC+@10
BCS FOUT6
ADC #$FF
TAX
LDA #2
FOUTPI SEC
FOUT6 SBC #2
STA TENEXP
STX DECCNT
TXA
BEQ FOUT39
BPL FOUT8
FOUT39 LDY FBUFPT
LDA #'.
INY
STA FBUFFR-1,Y
TXA
BEQ FOUT16
LDA #'0
INY
STA FBUFFR-1,Y
FOUT16 STY FBUFPT
FOUT8 LDY #0
FOUTIM LDX #@200
FOUT2 LDA FACLO
CLC
ADC FOUTBL+2+ADDPRC,Y
STA FACLO
LDA FACMO
ADC FOUTBL+1+ADDPRC,Y
STA FACMO
LDA FACMOH
ADC FOUTBL+1,Y
STA FACMOH
LDA FACHO
ADC FOUTBL,Y
STA FACHO
INX
BCS FOUT41
BPL FOUT2
BMI FOUT40
FOUT41 BMI FOUT2
FOUT40 TXA
BCC FOUTYP
EOR #@377
ADC #@12
FOUTYP ADC #@57
INY
INY
INY
INY
STY FDECPT
LDY FBUFPT
INY
TAX
AND #@177
STA FBUFFR-1,Y
DEC DECCNT
BNE STXBUF
LDA #'.
INY
STA FBUFFR-1,Y
STXBUF STY FBUFPT
LDY FDECPT
TXA
EOR #@377
AND #@200
TAX
CPY #FDCEND-FOUTBL
BEQ FOULDY
CPY #TIMEND-FOUTBL
BNE FOUT2
FOULDY LDY FBUFPT
FOUT11 LDA FBUFFR-1,Y
DEY
CMP #'0
BEQ FOUT11
CMP #'.
BEQ FOUT12
INY
FOUT12 LDA #'+
LDX TENEXP
BEQ FOUT17
BPL FOUT14
LDA #0
SEC
SBC TENEXP
TAX
.END

82
BASIC_VIC/code23

@ -0,0 +1,82 @@
.PAG 'CODE23'
LDA #'-
FOUT14 STA FBUFFR+1,Y
LDA #'E
STA FBUFFR,Y
TXA
LDX #@57
SEC
FOUT15 INX
SBC #@12
BCS FOUT15
ADC #@72
STA FBUFFR+3,Y
TXA
STA FBUFFR+2,Y
LDA #0
STA FBUFFR+4,Y
BEQ FOUT20
FOUT19 STA FBUFFR-1,Y
FOUT17 LDA #0
STA FBUFFR,Y
FOUT20 LDA #<FBUFFR
LDY #>FBUFFR
RTS
FHALF .BYT @200,0
ZERO .BYT 0,0,0
FOUTBL .BYT @372,@12,@37,0,0
.BYT @230,@226,@200,@377
.BYT @360,@275,@300,0
.BYT 1,@206,@240,@377
.BYT @377,@330,@360,0,0
.BYT 3,@350,@377,@377
.BYT @377,@234,0,0,0,@12
.BYT @377,@377,@377,@377
FDCEND .BYT @377,@337,@12,@200
.BYT 0,3,@113,@300,@377
.BYT @377,@163,@140,0,0
.BYT @16,@20,@377,@377
.BYT @375,@250,0,0,0,@74
TIMEND
;
CKSMC0 *=*+1 ;$C000 8K ROM CHECKSUM ADJ
PATCHS *=*+30 ; PATCH AREA
;
SQR JSR MOVAF
LDA #<FHALF
LDY #>FHALF
JSR MOVFM
FPWRT BEQ EXP
LDA ARGEXP
BNE FPWRT1
JMP ZEROF1
FPWRT1 LDX #<TEMPF3
LDY #>TEMPF3
JSR MOVMF
LDA ARGSGN
BPL FPWR1
JSR INT
LDA #<TEMPF3
LDY #>TEMPF3
JSR FCOMP
BNE FPWR1
TYA
LDY INTEGR
FPWR1 JSR MOVFA1
TYA
PHA
JSR LOG
LDA #<TEMPF3
LDY #>TEMPF3
JSR FMULT
JSR EXP
PLA
LSR A
BCC NEGRTS
NEGOP LDA FACEXP
BEQ NEGRTS
LDA FACSGN
EOR #@377
STA FACSGN
NEGRTS RTS
.END

23
BASIC_VIC/code24

@ -0,0 +1,23 @@
.PAG 'CODE24'
LOGEB2 .BYT @201,@70,@252,@73,@51
EXPCON .BYT 7,@161,@64,@130,@76
.BYT @126,@164,@26,@176
.BYT @263,@33,@167,@57
.BYT @356,@343,@205,@172
.BYT @35,@204,@34,@52
.BYT @174,@143,@131,@130
.BYT @12,@176,@165,@375
.BYT @347,@306,@200,@61
.BYT @162,@30,@20,@201
.BYT 0,0,0,0
;
; START OF KERNAL ROM
;
EXP LDA #<LOGEB2
LDY #>LOGEB2
JSR FMULT
LDA FACOV
ADC #@120
BCC STOLD
JSR INCRND
.END

119
BASIC_VIC/code25

@ -0,0 +1,119 @@
.PAG 'CODE25'
STOLD STA OLDOV
JSR MOVEF
LDA FACEXP
CMP #@210
BCC EXP1
GOMLDV JSR MLDVEX
EXP1 JSR INT
LDA INTEGR
CLC
ADC #@201
BEQ GOMLDV
SEC
SBC #1
PHA
LDX #4+ADDPRC
SWAPLP LDA ARGEXP,X
LDY FACEXP,X
STA FACEXP,X
STY ARGEXP,X
DEX
BPL SWAPLP
LDA OLDOV
STA FACOV
JSR FSUBT
JSR NEGOP
LDA #<EXPCON
LDY #>EXPCON
JSR POLY
LDA #0
STA ARISGN
PLA
JSR MLDEXP
RTS
POLYX STA POLYPT
STY POLYPT+1
JSR MOV1F
LDA #TEMPF1
JSR FMULT
JSR POLY1
LDA #<TEMPF1
LDY #>TEMPF1
JMP FMULT
POLY STA POLYPT
STY POLYPT+1
POLY1 JSR MOV2F
LDA (POLYPT)Y
STA DEGREE
LDY POLYPT
INY
TYA
BNE POLY3
INC POLYPT+1
POLY3 STA POLYPT
LDY POLYPT+1
POLY2 JSR FMULT
LDA POLYPT
LDY POLYPT+1
CLC
ADC #4+ADDPRC
BCC POLY4
INY
POLY4 STA POLYPT
STY POLYPT+1
JSR FADD
LDA #<TEMPF2
LDY #>TEMPF2
DEC DEGREE
BNE POLY2
RTS
RMULC .BYT @230,@65,@104,@172,0
RADDC .BYT @150,@50,@261,@106,0
RND JSR SIGN
BMI RND1
BNE QSETNR
JSR RDBAS
STX INDEX1
STY INDEX1+1
LDY #4
LDA (INDEX1)Y
STA FACHO
INY
LDA (INDEX1)Y
STA FACMO
LDY #8
LDA (INDEX1)Y
STA FACMOH
INY
LDA (INDEX1)Y
STA FACLO
JMP STRNEX
QSETNR LDA #<RNDX
LDY #>RNDX
JSR MOVFM
LDA #<RMULC
LDY #>RMULC
JSR FMULT
LDA #<RADDC
LDY #>RADDC
JSR FADD
RND1 LDX FACLO
LDA FACHO
STA FACLO
STX FACHO
LDX FACMOH
LDA FACMO
STA FACMOH
STX FACMO
STRNEX LDA #0
STA FACSGN
LDA FACEXP
STA FACOV
LDA #@200
STA FACEXP
JSR NORMAL
LDX #<RNDX
LDY #>RNDX
GMOVMF JMP MOVMF
.END

242
BASIC_VIC/code26

@ -0,0 +1,242 @@
.PAG 'CODE26'
;MOST REFERENCES TO KERNAL ARE DEFINED HERE
;
EREXIT CMP #$F0 ;CHECK FOR SPECIAL CASE
BNE EREXIX
; TOP OF MEMORY HAS CHANGED
STY MEMSIZ+1
STX MEMSIZ
JMP CLEART ;ACT AS IF HE TYPED CLEAR
EREXIX TAX ;SET TERMINATION FLAGS
BNE EREXIY
LDX #ERBRK ;BREAK ERROR
EREXIY JMP ERROR ;NORMAL ERROR
.SKI 5
CLSCHN =$FFCC
.SKI 5
OUTCH JSR $FFD2
BCS EREXIT
RTS
.SKI 5
INCHR JSR $FFCF
BCS EREXIT
RTS
.SKI 5
CCALL =$FFE7
.SKI 5
SETTIM =$FFDB
RDTIM =$FFDE
.SKI 5
COOUT JSR $FFC9
BCS EREXIT
RTS
.SKI 5
COIN JSR $FFC6
BCS EREXIT
RTS
.SKI 5
READST =$FFB7
.SKI 5
CGETL JSR $FFE4
BCS EREXIT
RTS
.SKI 5
RDBAS =$FFF3
.SKI 5
SETMSG =$FF90
.SKI 5
PLOT =$FFF0
.SKI 5
CSYS JSR FRMNUM ;EVAL FORMULA
JSR GETADR ;CONVERT TO INT. ADDR
LDA #>CSYSRZ ;PUSH RETURN ADDRESS
PHA
LDA #<CSYSRZ
PHA
LDA SPREG ;STATUS REG
PHA
LDA SAREG ;LOAD 6502 REGS
LDX SXREG
LDY SYREG
PLP ;LOAD 6502 STATUS REG
JMP (LINNUM) ;GO DO IT
CSYSRZ =*-1 ;RETURN TO HERE
PHP ;SAVE STATUS REG
STA SAREG ;SAVE 6502 REGS
STX SXREG
STY SYREG
PLA ;GET STATUS REG
STA SPREG
RTS ;RETURN TO SYSTEM
.SKI 5
CSAVE JSR PLSV ;PARSE PARMS
LDX VARTAB ;END SAVE ADDR
LDY VARTAB+1
LDA #<TXTTAB ;INDIRECT WITH START ADDRESS
JSR $FFD8 ;SAVE IT
BCS EREXIT
RTS
.SKI 5
CVERF LDA #1 ;VERIFY FLAG
.BYT $2C ;SKIP TWO BYTES
.SKI 5
CLOAD LDA #0 ;LOAD FLAG
STA VERCK
JSR PLSV ;PARSE PARAMETERS
;
CLD10 ; JSR $FFE1 ;CHECK RUN/STOP
; CMP #$FF ;DONE YET?
; BNE CLD10 ;STILL BOUNCING
LDA VERCK
LDX TXTTAB ;.X AND .Y HAVE ALT...
LDY TXTTAB+1 ;...LOAD ADDRESS
JSR $FFD5 ;LOAD IT
BCS JERXIT ;PROBLEMS
;
LDA VERCK
BEQ CLD50 ;WAS LOAD
;
;FINISH VERIFY
;
LDX #ERVFY ;ASSUME ERROR
JSR $FFB7 ;READ STATUS
AND #$10 ;CHECK ERROR
BEQ *+5
JMP ERROR
;
;PRINT VERIFY 'OK' IF DIRECT
;
LDA TXTPTR
CMP #BUFPAG
BEQ CLD20
LDA #<OKMSG
LDY #>OKMSG
JMP STROUT
;
CLD20 RTS
.SKI 5
;
;FINISH LOAD
;
CLD50 JSR $FFB7 ;READ STATUS
AND #$FF-$40 ;CLEAR E.O.I.
BEQ CLD60 ;WAS O.K.
LDX #ERLOAD
JMP ERROR
;
CLD60 LDA TXTPTR+1
CMP #BUFPAG ;DIRECT?
BNE CLD70 ;NO...
;
STX VARTAB
STY VARTAB+1 ;END LOAD ADDRESS
LDA #<REDDY
LDY #>REDDY
JSR STROUT
JMP FINI
;
;PROGRAM LOAD
;
CLD70 JSR STXTPT
JMP PLINK ;************PATCH TO LINK OFFSET PROGS*****
.SKI 5
COPEN JSR PAOC ;PARSE STATEMENT
JSR $FFC0 ;OPEN IT
BCS JERXIT ;BAD STUFF OR MEMSIZ CHANGE
RTS ;A.O.K.
.SKI 5
CCLOS JSR PAOC ;PARSE STATEMENT
LDA ANDMSK ;GET LA
JSR $FFC3 ;CLOSE IT
BCC CLD20 ;IT'S OKAY...NO MEMSIZE CHANGE
;
JERXIT JMP EREXIT
.SKI 5
;
;PARSE LOAD AND SAVE COMMANDS
;
PLSV
;DEFAULT FILE NAME
;
LDA #0 ;LENGTH=0
JSR $FFBD
;
;DEFAULT DEVICE #
;
LDX #1 ;DEVICE #1
LDY #0 ;COMMAND 0
JSR $FFBA
;
JSR PAOC20 ;BY-PASS JUNK
JSR PAOC15 ;GET/SET FILE NAME
JSR PAOC20 ;BY-PASS JUNK
JSR PLSV7 ;GET ',FA'
LDY #0 ;COMMAND 0
STX ANDMSK
JSR $FFBA
JSR PAOC20 ;BY-PASS JUNK
JSR PLSV7 ;GET ',SA'
TXA ;NEW COMMAND
TAY
LDX ANDMSK ;DEVICE #
JMP $FFBA
.SKI 5
;LOOK FOR COMMA FOLLOWED BY BYTE
PLSV7 JSR PAOC30
JMP GETBYT
.SKI 5
;SKIP RETURN IF NEXT CHAR IS END
;
PAOC20 JSR CHRGOT
BNE PAOCX
PLA
PLA
PAOCX RTS
.SKI 5
;CHECK FOR COMMA AND GOOD STUFF
;
PAOC30 JSR CHKCOM ;CHECK COMMA
PAOC32 JSR CHRGOT ;GET CURRENT
BNE PAOCX ;IS O.K.
PAOC40 JMP SNERR ;BAD...END OF LINE
.SKI 5
;PARSE OPEN/CLOSE
;
PAOC LDA #0
JSR $FFBD ;DEFAULT FILE NAME
;
JSR PAOC32 ;MUST GOT SOMETHING
JSR GETBYT ;GET LA
STX ANDMSK
TXA
LDX #1 ;DEFAULT DEVICE
LDY #0 ;DEFAULT COMMAND
JSR $FFBA ;STORE IT
JSR PAOC20 ;SKIP JUNK
JSR PLSV7
STX EORMSK
LDY #0 ;DEFAULT COMMAND
LDA ANDMSK ;GET LA
CPX #3
BCC PAOC5
DEY ;DEFAULT IEEE TO $FF
PAOC5 JSR $FFBA ;STORE THEM
JSR PAOC20 ;SKIP JUNK
JSR PLSV7 ;GET SA
TXA
TAY
LDX EORMSK
LDA ANDMSK
JSR $FFBA ;SET UP REAL EVEYTHING
PAOC7 JSR PAOC20
JSR PAOC30
PAOC15 JSR FRMEVL
JSR FRESTR ;LENGTH IN .A
LDX INDEX1
LDY INDEX1+1
JMP $FFBD
.END
; RSR 8/10/80 - CHANGE SYS COMMAND
; RSR 8/26/80 - ADD OPEN&CLOSE MEMSIZ DETECT
; RSR 10/7/80 - CHANGE LOAD (REMOVE RUN WAIT)
; RSR 3/06/81 - FIX PROGRAM LOAD FOR OFFSET PROGRAMS

139
BASIC_VIC/code3

@ -0,0 +1,139 @@
.PAG 'CODE3'
LIST BCC GOLST
BEQ GOLST
CMP #MINUTK
BNE STKRTS
GOLST JSR LINGET
JSR FNDLIN
JSR CHRGOT
BEQ LSTEND
CMP #MINUTK
BNE FLNRTS
JSR CHRGET
JSR LINGET
BNE FLNRTS
LSTEND PLA
PLA
LDA LINNUM
ORA LINNUM+1
BNE LIST4
LDA #255
STA LINNUM
STA LINNUM+1
LIST4 LDY #1
STY DORES
LDA (LOWTR)Y
BEQ GRODY
JSR ISCNTC
JSR CRDO
INY
LDA (LOWTR)Y
TAX
INY
LDA (LOWTR)Y
CMP LINNUM+1
BNE TSTDUN
CPX LINNUM
BEQ TYPLIN
TSTDUN BCS GRODY
TYPLIN STY LSTPNT
JSR LINPRT
LDA #'
PRIT4 LDY LSTPNT
AND #127
PLOOP JSR OUTDO
CMP #34
BNE PLOOP1
LDA DORES
EOR #@377
STA DORES
PLOOP1 INY
BEQ GRODY
LDA (LOWTR)Y
BNE QPLOP
TAY
LDA (LOWTR)Y
TAX
INY
LDA (LOWTR)Y
STX LOWTR
STA LOWTR+1
BNE LIST4
GRODY JMP READY
QPLOP JMP (IQPLOP)
NQPLOP BPL PLOOP
CMP #PI
BEQ PLOOP
BIT DORES
BMI PLOOP
SEC
SBC #127
TAX
STY LSTPNT
LDY #255
RESRCH DEX
BEQ PRIT3
RESCR1 INY
LDA RESLST,Y
BPL RESCR1
BMI RESRCH
PRIT3 INY
LDA RESLST,Y
BMI PRIT4
JSR OUTDO
BNE PRIT3
FOR LDA #128
STA SUBFLG
JSR LET
JSR FNDFOR
BNE NOTOL
TXA
ADC #FORSIZ-3
TAX
TXS
NOTOL PLA
PLA
LDA #8+ADDPRC
JSR GETSTK
JSR DATAN
CLC
TYA
ADC TXTPTR
PHA
LDA TXTPTR+1
ADC #0
PHA
LDA CURLIN+1
PHA
LDA CURLIN
PHA
LDA #TOTK
JSR SYNCHR
JSR CHKNUM
JSR FRMNUM
LDA FACSGN
ORA #127
AND FACHO
STA FACHO
LDA #<LDFONE
LDY #>LDFONE
STA INDEX1
STY INDEX1+1
JMP FORPSH
LDFONE LDA #<FONE
LDY #>FONE
JSR MOVFM
JSR CHRGOT
CMP #STEPTK
BNE ONEON
JSR CHRGET
JSR FRMNUM
ONEON JSR SIGN
JSR PUSHF
LDA FORPNT+1
PHA
LDA FORPNT
PHA
LDA #FORTK
PHA
.END

143
BASIC_VIC/code4

@ -0,0 +1,143 @@
.PAG 'CODE4'
NEWSTT JSR ISCNTC
LDA TXTPTR
LDY TXTPTR+1
CPY #BUFPAG
NOP
BEQ DIRCON
STA OLDTXT
STY OLDTXT+1
DIRCON LDY #0
LDA (TXTPTR)Y
BNE MORSTS
LDY #2
LDA (TXTPTR)Y
CLC
BNE DIRCN1
JMP ENDCON
DIRCN1 INY
LDA (TXTPTR)Y
STA CURLIN
INY
LDA (TXTPTR)Y
STA CURLIN+1
TYA
ADC TXTPTR
STA TXTPTR
BCC GONE
INC TXTPTR+1
GONE JMP (IGONE)
NGONE JSR CHRGET
NGONE1 JSR GONE3
JMP NEWSTT
GONE3 BEQ ISCRTS
GONE2 SBC #ENDTK
BCC GLET
CMP #SCRATK-ENDTK+1
BCS SNERRX
ASL A
TAY
LDA STMDSP+1,Y
PHA
LDA STMDSP,Y
PHA
JMP CHRGET
GLET JMP LET
MORSTS CMP #':
BEQ GONE
SNERR1 JMP SNERR
SNERRX CMP #GOTK-ENDTK
BNE SNERR1
JSR CHRGET
LDA #TOTK
JSR SYNCHR
JMP GOTO
RESTOR SEC
LDA TXTTAB
SBC #1
LDY TXTTAB+1
BCS RESFIN
DEY
RESFIN STA DATPTR
STY DATPTR+1
ISCRTS RTS
ISCNTC JSR $FFE1
STOP BCS STOPC
END CLC
STOPC BNE CONTRT
LDA TXTPTR
LDY TXTPTR+1
LDX CURLIN+1
INX
BEQ DIRIS
STA OLDTXT
STY OLDTXT+1
STPEND LDA CURLIN
LDY CURLIN+1
STA OLDLIN
STY OLDLIN+1
DIRIS PLA
PLA
ENDCON LDA #<BRKTXT
LDY #>BRKTXT
BCC GORDY
JMP ERRFIN
GORDY JMP READY
CONT BNE CONTRT
LDX #ERRCN
LDY OLDTXT+1
BNE *+5
JMP ERROR
LDA OLDTXT
STA TXTPTR
STY TXTPTR+1
LDA OLDLIN
LDY OLDLIN+1
STA CURLIN
STY CURLIN+1
CONTRT RTS
RUN PHP
LDA #0 ;NO KERNAL MESSAGES
JSR SETMSG
PLP
BNE *+5
JMP RUNC
JSR CLEARC
JMP RUNC2
GOSUB LDA #3
JSR GETSTK
LDA TXTPTR+1
PHA
LDA TXTPTR
PHA
LDA CURLIN+1
PHA
LDA CURLIN
PHA
LDA #GOSUTK
PHA
RUNC2 JSR CHRGOT
JSR GOTO
JMP NEWSTT
GOTO JSR LINGET
JSR REMN
SEC
LDA CURLIN
SBC LINNUM
LDA CURLIN+1
SBC LINNUM+1
BCS LUK4IT
TYA
SEC
ADC TXTPTR
LDX TXTPTR+1
BCC LUKALL
INX
BCS LUKALL
LUK4IT LDA TXTTAB
LDX TXTTAB+1
LUKALL JSR FNDLNC
BCC USERR
LDA LOWTR
SBC #1
.END

149
BASIC_VIC/code5

@ -0,0 +1,149 @@
.PAG 'CODE5'
STA TXTPTR
LDA LOWTR+1
SBC #0
STA TXTPTR+1
GORTS RTS
RETURN BNE GORTS
LDA #255
STA FORPNT+1
JSR FNDFOR
TXS
CMP #GOSUTK
BEQ RETU1
LDX #ERRRG
.BYT $2C
USERR LDX #ERRUS
JMP ERROR
SNERR2 JMP SNERR
RETU1 PLA
PLA
STA CURLIN
PLA
STA CURLIN+1
PLA
STA TXTPTR
PLA
STA TXTPTR+1
DATA JSR DATAN
ADDON TYA
CLC
ADC TXTPTR
STA TXTPTR
BCC REMRTS
INC TXTPTR+1
REMRTS RTS
DATAN LDX #':
.BYT $2C
REMN LDX #0
STX CHARAC
LDY #0
STY ENDCHR
EXCHQT LDA ENDCHR
LDX CHARAC
STA CHARAC
STX ENDCHR
REMER LDA (TXTPTR)Y
BEQ REMRTS
CMP ENDCHR
BEQ REMRTS
INY
CMP #34
BNE REMER
BEQ EXCHQT
IF JSR FRMEVL
JSR CHRGOT
CMP #GOTOTK
BEQ OKGOTO
LDA #THENTK
JSR SYNCHR
OKGOTO LDA FACEXP
BNE DOCOND
REM JSR REMN
BEQ ADDON
DOCOND JSR CHRGOT
BCS DOCO
JMP GOTO
DOCO JMP GONE3
ONGOTO JSR GETBYT
PHA
CMP #GOSUTK
BEQ ONGLOP
SNERR3 CMP #GOTOTK
BNE SNERR2
ONGLOP DEC FACLO
BNE ONGLP1
PLA
JMP GONE2
ONGLP1 JSR CHRGET
JSR LINGET
CMP #44
BEQ ONGLOP
PLA
ONGRTS RTS
LINGET LDX #0
STX LINNUM
STX LINNUM+1
MORLIN BCS ONGRTS
SBC #$2F
STA CHARAC
LDA LINNUM+1
STA INDEX
CMP #25
BCS SNERR3
LDA LINNUM
ASL A
ROL INDEX
ASL A
ROL INDEX
ADC LINNUM
STA LINNUM
LDA INDEX
ADC LINNUM+1
STA LINNUM+1
ASL LINNUM
ROL LINNUM+1
LDA LINNUM
ADC CHARAC
STA LINNUM
BCC NXTLGC
INC LINNUM+1
NXTLGC JSR CHRGET
JMP MORLIN
LET JSR PTRGET
STA FORPNT
STY FORPNT+1
LDA #$B2
JSR SYNCHR
LDA INTFLG
PHA
LDA VALTYP
PHA
JSR FRMEVL
PLA
ROL A
JSR CHKVAL
BNE COPSTR
PLA
QINTGR BPL COPFLT
JSR ROUND
JSR AYINT
LDY #0
LDA FACMO
STA (FORPNT)Y
INY
LDA FACLO
STA (FORPNT)Y
RTS
COPFLT JMP MOVVF
COPSTR PLA
INPCOM LDY FORPNT+1
CPY #>ZERO
BNE GETSPT
JSR FREFAC
CMP #6
BNE FCERR2
LDY #0
STY FACEXP
STY FACSGN
.END

148
BASIC_VIC/code6

@ -0,0 +1,148 @@
.PAG 'CODE6'
TIMELP STY FBUFPT
JSR TIMNUM
JSR MUL10
INC FBUFPT
LDY FBUFPT
JSR TIMNUM
JSR MOVAF
TAX
BEQ NOML6
INX
TXA
JSR FINML6
NOML6 LDY FBUFPT
INY
CPY #6
BNE TIMELP
JSR MUL10
JSR QINT
LDX FACMO
LDY FACMOH
LDA FACLO
JMP SETTIM
TIMNUM LDA (INDEX)Y
JSR QNUM
BCC GOTNUM
FCERR2 JMP FCERR
GOTNUM SBC #$2F
JMP FINLOG
GETSPT LDY #2
LDA (FACMO)Y
CMP FRETOP+1
BCC DNTCPY
BNE QVARIA
DEY
LDA (FACMO)Y
CMP FRETOP
BCC DNTCPY
QVARIA LDY FACLO
CPY VARTAB+1
BCC DNTCPY
BNE COPY
LDA FACMO
CMP VARTAB
BCS COPY
DNTCPY LDA FACMO
LDY FACMO+1
JMP COPYC
COPY LDY #0
LDA (FACMO)Y
JSR STRINI
LDA DSCPNT
LDY DSCPNT+1
STA STRNG1
STY STRNG1+1
JSR MOVINS
LDA #<DSCTMP
LDY #>DSCTMP
COPYC STA DSCPNT
STY DSCPNT+1
JSR FRETMS
LDY #0
LDA (DSCPNT)Y
STA (FORPNT)Y
INY
LDA (DSCPNT)Y
STA (FORPNT)Y
INY
LDA (DSCPNT)Y
STA (FORPNT)Y
RTS
PRINTN JSR CMD
JMP IODONE
CMD JSR GETBYT
BEQ SAVEIT
LDA #44
JSR SYNCHR
SAVEIT PHP
STX CHANNL
JSR COOUT
PLP
JMP PRINT
STRDON JSR STRPRT
NEWCHR JSR CHRGOT
PRINT BEQ CRDO
PRINTC BEQ PRTRTS
CMP #TABTK
BEQ TABER
CMP #SPCTK
CLC
BEQ TABER
CMP #44
BEQ COMPRT
CMP #59
BEQ NOTABR
JSR FRMEVL
BIT VALTYP
BMI STRDON
JSR FOUT
JSR STRLIT
JSR STRPRT
JSR OUTSPC
BNE NEWCHR
FININL LDA #0
STA BUF,X
ZZ5=BUF-1
LDX #<ZZ5
LDY #>ZZ5
LDA CHANNL
BNE PRTRTS
CRDO LDA #13
JSR OUTDO
BIT CHANNL
BPL CRFIN
;
LDA #10
JSR OUTDO
CRFIN EOR #255
PRTRTS RTS
COMPRT SEC
JSR PLOT ;GET TAB POSITION IN X
TYA
NCMPOS =@36
SEC
MORCO1 SBC #CLMWID
BCS MORCO1
EOR #255
ADC #1
BNE ASPAC
TABER PHP
SEC
JSR PLOT ;READ TAB POSITION
STY TRMPOS
JSR GTBYTC
CMP #41
BNE SNERR4
PLP
BCC XSPAC
TXA
SBC TRMPOS
BCC NOTABR
ASPAC TAX
XSPAC INX
XSPAC2 DEX
BNE XSPAC1
NOTABR JSR CHRGET
JMP PRINTC
.END

147
BASIC_VIC/code7

@ -0,0 +1,147 @@
.PAG 'CODE7'
XSPAC1 JSR OUTSPC
BNE XSPAC2
STROUT JSR STRLIT
STRPRT JSR FREFAC
TAX
LDY #0
INX
STRPR2 DEX
BEQ PRTRTS
LDA (INDEX)Y
JSR OUTDO
INY
CMP #13
BNE STRPR2
JSR CRFIN
JMP STRPR2
OUTSPC
LDA CHANNL
BEQ CRTSKP
LDA #'
.BYT $2C
CRTSKP LDA #29
.BYT $2C
OUTQST LDA #'?
OUTDO JSR OUTCH
OUTRTS AND #255
RTS
TRMNOK LDA INPFLG
BEQ TRMNO1
BMI GETDTL
LDY #255
BNE STCURL
GETDTL LDA DATLIN
LDY DATLIN+1
STCURL STA CURLIN
STY CURLIN+1
SNERR4 JMP SNERR
TRMNO1 LDA CHANNL
BEQ DOAGIN
LDX #ERRBD
JMP ERROR
DOAGIN LDA #<TRYAGN
LDY #>TRYAGN
JSR STROUT
LDA OLDTXT
LDY OLDTXT+1
STA TXTPTR
STY TXTPTR+1
RTS
GET JSR ERRDIR
CMP #'#
BNE GETTTY
JSR CHRGET
JSR GETBYT
LDA #44
JSR SYNCHR
STX CHANNL
JSR COIN
ZZ2=BUF+1
GETTTY LDX #<ZZ2
ZZ3=BUF+2
LDY #>ZZ3
LDA #0
STA BUF+1
LDA #64
JSR INPCO1
LDX CHANNL
BNE IORELE
RTS
INPUTN JSR GETBYT
LDA #44
JSR SYNCHR
STX CHANNL
JSR COIN
JSR NOTQTI
IODONE LDA CHANNL
IORELE JSR CLSCHN
LDX #0
STX CHANNL
RTS
INPUT CMP #34
BNE NOTQTI
JSR STRTXT
LDA #59
JSR SYNCHR
JSR STRPRT
NOTQTI JSR ERRDIR
LDA #44
STA BUF-1
GETAGN JSR QINLIN
LDA CHANNL
BEQ BUFFUL
JSR READST
AND #2
BEQ BUFFUL
JSR IODONE
JMP DATA
BUFFUL LDA BUF
BNE INPCON
LDA CHANNL
BNE GETAGN
JSR DATAN
JMP ADDON
QINLIN LDA CHANNL
BNE GINLIN
JSR OUTQST
JSR OUTSPC
GINLIN JMP INLIN
READ LDX DATPTR
LDY DATPTR+1
.BYT $A9
TYA
.BYT $2C
INPCON LDA #0
INPCO1 STA INPFLG
STX INPPTR
STY INPPTR+1
INLOOP JSR PTRGET
STA FORPNT
STY FORPNT+1
LDA TXTPTR
LDY TXTPTR+1
STA VARTXT
STY VARTXT+1
LDX INPPTR
LDY INPPTR+1
STX TXTPTR
STY TXTPTR+1
JSR CHRGOT
BNE DATBK1
BIT INPFLG
BVC QDATA
JSR CGETL
STA BUF
ZZ4=BUF-1
LDX #<ZZ4
LDY #>ZZ4
BNE DATBK
QDATA BMI DATLOP
LDA CHANNL
BNE GETNTH
JSR OUTQST
GETNTH JSR QINLIN
DATBK STX TXTPTR
STY TXTPTR+1
.END

146
BASIC_VIC/code8

@ -0,0 +1,146 @@
.PAG 'CODE8'
DATBK1 JSR CHRGET
BIT VALTYP
BPL NUMINS
BIT INPFLG
BVC SETQUT
INX
STX TXTPTR
LDA #0
STA CHARAC
BEQ RESETC
SETQUT STA CHARAC
CMP #34
BEQ NOWGET
LDA #':
STA CHARAC
LDA #44
RESETC CLC
NOWGET STA ENDCHR
LDA TXTPTR
LDY TXTPTR+1
ADC #0
BCC NOWGE1
INY
NOWGE1 JSR STRLT2
JSR ST2TXT
JSR INPCOM
JMP STRDN2
NUMINS JSR FIN
LDA INTFLG
JSR QINTGR
STRDN2 JSR CHRGOT
BEQ TRMOK
CMP #44
BEQ *+5
JMP TRMNOK
TRMOK LDA TXTPTR
LDY TXTPTR+1
STA INPPTR
STY INPPTR+1
LDA VARTXT
LDY VARTXT+1
STA TXTPTR
STY TXTPTR+1
JSR CHRGOT
BEQ VAREND
JSR CHKCOM
JMP INLOOP
DATLOP JSR DATAN
INY
TAX
BNE NOWLIN
LDX #ERROD
INY
LDA (TXTPTR)Y
BEQ ERRGO5
INY
LDA (TXTPTR)Y
STA DATLIN
INY
LDA (TXTPTR)Y
INY
STA DATLIN+1
NOWLIN JSR ADDON ;TXTPTR+.Y
JSR CHRGOT ;SPAN BLANKS
TAX ;USED LATER
CPX #DATATK
BNE DATLOP
JMP DATBK1
VAREND LDA INPPTR
LDY INPPTR+1
LDX INPFLG
BPL VARY0
JMP RESFIN
VARY0 LDY #0
LDA (INPPTR)Y
BEQ INPRTS
LDA CHANNL
BNE INPRTS
LDA #<EXIGNT
LDY #>EXIGNT
JMP STROUT
INPRTS RTS
EXIGNT .BYT '?EXTRA IGNORED'
.BYT $D
.BYT 0
TRYAGN .BYT '?REDO FROM START'
.BYT $D
.BYT 0
NEXT BNE GETFOR
LDY #0
BEQ STXFOR
GETFOR JSR PTRGET
STXFOR STA FORPNT
STY FORPNT+1
JSR FNDFOR
BEQ HAVFOR
LDX #ERRNF
ERRGO5 JMP ERROR ;CHANGE
HAVFOR TXS
TXA
CLC
ADC #4
PHA
ADC #5+ADDPRC
STA INDEX2
PLA
LDY #1
JSR MOVFM
TSX
LDA ADDPRC+264,X
STA FACSGN
LDA FORPNT
LDY FORPNT+1
JSR FADD
JSR MOVVF
LDY #1
JSR FCOMPN
TSX
SEC
SBC ADDPRC+264,X
BEQ LOOPDN
LDA 269+ADDPRC+ADDPRC,X
STA CURLIN
LDA 270+ADDPRC+ADDPRC,X
STA CURLIN+1
LDA 272+ADDPRC+ADDPRC,X
STA TXTPTR
LDA 271+ADDPRC+ADDPRC,X
STA TXTPTR+1
NEWSGO JMP NEWSTT
LOOPDN TXA
ADC #15+ADDPRC+ADDPRC
TAX
TXS
JSR CHRGOT
CMP #44
BNE NEWSGO
JSR CHRGET
JSR GETFOR
FRMNUM JSR FRMEVL
CHKNUM CLC
.BYT $24
CHKSTR SEC
CHKVAL BIT VALTYP
.END

201
BASIC_VIC/code9

@ -0,0 +1,201 @@
.PAG 'CODE9'
BMI DOCSTR
BCS CHKERR
CHKOK RTS
DOCSTR BCS CHKOK
CHKERR LDX #ERRTM
ERRGO4 JMP ERROR
FRMEVL LDX TXTPTR
BNE FRMEV1
DEC TXTPTR+1
FRMEV1 DEC TXTPTR
LDX #0
.BYT $24
LPOPER PHA
TXA
PHA
LDA #1
JSR GETSTK
JSR EVAL
LDA #0
STA OPMASK
TSTOP JSR CHRGOT
LOPREL SEC
SBC #GREATK
BCC ENDREL
CMP #LESSTK-GREATK+1
BCS ENDREL
CMP #1
ROL A
EOR #1
EOR OPMASK
CMP OPMASK
BCC SNERR5
STA OPMASK
JSR CHRGET
JMP LOPREL
ENDREL LDX OPMASK
BNE FINREL
BCS QOP
ADC #GREATK-PLUSTK
BCC QOP
ADC VALTYP
BNE *+5
JMP CAT
ADC #$FF
STA INDEX1
ASL A
ADC INDEX1
TAY
QPREC PLA
CMP OPTAB,Y
BCS QCHNUM
JSR CHKNUM
DOPREC PHA
NEGPRC JSR DOPRE1
PLA
LDY OPPTR
BPL QPREC1
TAX
BEQ QOPGO
BNE PULSTK
FINREL LSR VALTYP
TXA
ROL A
LDX TXTPTR
BNE FINRE2
DEC TXTPTR+1
FINRE2 DEC TXTPTR
LDY #PTDORL-OPTAB
STA OPMASK
BNE QPREC
QPREC1 CMP OPTAB,Y
BCS PULSTK
BCC DOPREC
DOPRE1 LDA OPTAB+2,Y
PHA
LDA OPTAB+1,Y
PHA
JSR PUSHF1
LDA OPMASK
JMP LPOPER
SNERR5 JMP SNERR
PUSHF1 LDA FACSGN
LDX OPTAB,Y
PUSHF TAY
PLA
STA INDEX1
INC INDEX1
PLA
STA INDEX1+1
TYA
PHA
FORPSH JSR ROUND
LDA FACLO
PHA
LDA FACMO
PHA
LDA FACMOH
PHA
LDA FACHO
PHA
LDA FACEXP
PHA
JMP (INDEX1)
QOP LDY #255
PLA
QOPGO BEQ QOPRTS
QCHNUM CMP #100
BEQ UNPSTK
JSR CHKNUM
UNPSTK STY OPPTR
PULSTK PLA
LSR A
STA DOMASK
PLA
STA ARGEXP
PLA
STA ARGHO
PLA
STA ARGMOH
PLA
STA ARGMO
PLA
STA ARGLO
PLA
STA ARGSGN
EOR FACSGN
STA ARISGN
QOPRTS LDA FACEXP
UNPRTS RTS
.SKI 5
EVAL JMP (IEVAL)
NEVAL LDA #0
STA VALTYP
EVAL0 JSR CHRGET
BCS EVAL2
EVAL1 JMP FIN
EVAL2 JSR ISLETC
BCC *+5
JMP ISVAR
CMP #PI
BNE QDOT
LDA #<PIVAL
LDY #>PIVAL
JSR MOVFM
JMP CHRGET
PIVAL .BYT @202
.BYT @111
.BYT @017
.BYT @332
.BYT @241
QDOT CMP #'.
BEQ EVAL1
CMP #MINUTK
BEQ DOMIN
CMP #PLUSTK
BEQ EVAL0
CMP #34
BNE EVAL3
STRTXT LDA TXTPTR
LDY TXTPTR+1
ADC #0
BCC STRTX2
INY
STRTX2 JSR STRLIT
JMP ST2TXT
EVAL3 CMP #NOTTK
BNE EVAL4
LDY #24
BNE GONPRC
NOTOP JSR AYINT
LDA FACLO
EOR #255
TAY
LDA FACMO
EOR #255
JMP GIVAYF
EVAL4 CMP #FNTK
BNE *+5
JMP FNDOER
CMP #ONEFUN
BCC PARCHK
JMP ISFUN
PARCHK JSR CHKOPN
JSR FRMEVL
CHKCLS LDA #41
.BYT $2C
CHKOPN LDA #40
.BYT $2C
CHKCOM LDA #44
SYNCHR LDY #0
CMP (TXTPTR)Y
BNE SNERR
JMP CHRGET
SNERR LDX #ERRSN
JMP ERROR
DOMIN LDY #21
GONPRC PLA
PLA
JMP NEGPRC
.END

144
BASIC_VIC/declare

@ -0,0 +1,144 @@
.PAG 'DECLARATIONS'
ADDPRC =1
ROMLOC =$C000 ;VIXEN ROM
LINLEN =22 ;VIXEN SCREEN SIZE ?WHY?
BUFLEN =89 ;VIXEN BUFFER
BUFPAG =2
BUF =512
STKEND =507
CLMWID =11 ;PRINT WINDOW 11 CHARS
PI =255
NUMLEV =23
STRSIZ =3
*=$0000
USRPOK *=*+3
ADRAY1 *=*+2 ;CONVERT FLOAT->INTEGER
ADRAY2 *=*+2 ;CONVERT INTEGER->FLOAT
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
OLDLIN *=*+2
OLDTXT *=*+2
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
FOUR6 *=*+1
JMPER *=*+1
SIZE *=*+1
OLDOV *=*+1
TEMPF1 *=*+1
ARYPNT
HIGHDS *=*+2
HIGHTR *=*+2
TEMPF2
*=*+1
DECCNT
LOWDS *=*+2
GRBTOP
DPTFLG
LOWTR *=*+1
EXPSGN *=*+1
TENEXP =LOWDS+1
EPSGN =LOWTR+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
STRNGI
ARISGN *=*+1
FACOV *=*+1
BUFPTR
STRNG2
POLYPT
CURTOL
FBUFPT *=*+2
CHRGET *=*+6
CHRGOT *=*+1
TXTPTR *=*+6
QNUM *=*+10
CHRRTS *=*+1
RNDX *=*+5
*=255
LOFBUF *=*+1
FBUFFR *=*+1
STRNG1 =ARISGN
;
*=$0300 ;BASIC INDIRECTS
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)
;TEMP STORAGE UNTILL SYSTEM INTERGRATION
; SYS 6502 REGS
SAREG *=*+1 ;.A REG
SXREG *=*+1 ;.X REG
SYREG *=*+1 ;.Y REG
SPREG *=*+1 ;.P REG
*=$0300+20 ;SYSTEM INDIRECTS FOLLOW
.END

46
BASIC_VIC/disclaimer

@ -0,0 +1,46 @@
.PAGE
;****************************************
;* *
;* BBBBB AAAA SSS IIII CCCC *
;* BB BB AA AA SS S II CC C *
;* BB BB AA AA SS II CC *
;* BBBBB AAAAAA SS II CC *
;* BB BB AA AA SS II CC *
;* BB BB AA AA S SS II CC C *
;* BBBBB AA AA SSS IIII CCCC *
;* *
;****************************************
;
;****************************************
;* *
;* PET BASIC VERSION 2.1 *
;* THIS VERSION OF PET BASIC IS *
;* DESIGNED TO FUNCTION WITH THE KERNAL *
;* PROVIDED IN THE FOLOWING MACHINES: *
;* 2001-4/8 (B/N) *
;* 4016/4032 *
;* 8032 *
;* TOY *
;* VIC-1001/-20 *
;* *
;* COPYRIGHT (C) 1981 BY *
;* COMMODORE BUSINESS MACHINES *
;* *
;****************************************
;****LISTING DATE --1200 06 MARCH 1980***
;****************************************
;* THIS SOFTWARE IS FURNISHED FOR USE IN*
;* THE ABOVE LISTED MACHINES ONLY. *
;* *
;* COPIES THEREOF MAY NOT BE PROVIDED *
;* OR MADE AVAILABLE FOR USE ON ANY *
;* SYSTEM. *
;* *
;* THE INFORMATION IN THIS DOCUMENT IS *
;* SUBJECT TO CHANGE WITHOUT NOTICE. *
;* *
;* NO RESPONSIBILITY IS ASSUMED FOR *
;* RELIABILITY OF THIS SOFTWARE. *
;* *
;****************************************
.END

115
BASIC_VIC/init

@ -0,0 +1,115 @@
.PAG 'INIT'
INIT JSR INITV ;GO INIT VECTORS
JSR INITCZ ;GO INIT CHARGET & Z-PAGE
JSR INITMS ;GO PRINT INITILIZATION MESSAGES
LDX #STKEND-256 ;SET UP END OF STACK
TXS
JMP READY ;GO TO READY
.SKI 6
INITAT INC CHRGET+7
BNE CHDGOT
INC CHRGET+8
CHDGOT LDA 60000
CMP #':
BCS CHDRTS
CMP #'
BEQ INITAT
SEC
SBC #'0
SEC
SBC #$D0
CHDRTS RTS
.BYT 128,79,199,82,88
.SKI 6
INITCZ LDA #76
STA JMPER
STA USRPOK
LDA #<FCERR
LDY #>FCERR
STA USRPOK+1
STY USRPOK+2
LDA #<GIVAYF
LDY #>GIVAYF
STA ADRAY2
STY ADRAY2+1
LDA #<FLPINT
LDY #>FLPINT
STA ADRAY1
STY ADRAY1+1
LDX #INITCZ-INITAT-1
MOVCHG LDA INITAT,X
STA CHRGET,X
DEX
BPL MOVCHG
LDA #STRSIZ
STA FOUR6
LDA #0
STA BITS
STA CHANNL
STA LASTPT+1
LDX #1
STX BUF-3
STX BUF-4
LDX #TEMPST
STX TEMPPT
SEC ;READ BOTTOM OF MEMORY
JSR $FF9C
STX TXTTAB ;NOW TXTAB HAS IT
STY TXTTAB+1
SEC
JSR $FF99 ;READ TOP OF MEMORY
USEDEF STX MEMSIZ
STY MEMSIZ+1
STX FRETOP
STY FRETOP+1
LDY #0
TYA
STA (TXTTAB)Y
INC TXTTAB
BNE INIT20
INC TXTTAB+1
INIT20 RTS
.SKI 6
INITMS LDA TXTTAB
LDY TXTTAB+1
JSR REASON
LDA #<FREMES
LDY #>FREMES
JSR STROUT
LDA MEMSIZ
SEC
SBC TXTTAB
TAX
LDA MEMSIZ+1
SBC TXTTAB+1
JSR LINPRT
LDA #<WORDS
LDY #>WORDS
JSR STROUT
JMP SCRTCH
.SKI 4
WORDS .BYT ' BYTES FREE',13,0
FREMES .BYT 147,'**** CBM BASIC V2 ****',13,0
.SKI 4
BVTRS .WOR NERROR,NMAIN,NCRNCH,NQPLOP,NGONE,NEVAL
;
INITV LDX #INITV-BVTRS-1 ;INIT VECTORS
INITV1 LDA BVTRS,X
STA IERROR,X
DEX
BPL INITV1
RTS
.SKI 4
PANIC JSR CLSCHN ;WARM START BASIC...
LDA #0 ;CLEAR CHANNELS
STA CHANNL
JSR STKINI ;RESTORE STACK
CLI ;ENABLE IRQ'S
JMP READY ;DISPLAY READY ENTRY
CHKE0 .BYT $00
;
;PROGRAM LOAD PATCH
;
PLINK JSR LNKPRG ;GO LINK THE LOADED PROGRAM
JMP FLOAD ;USE NORMAL ENTRY TO KEEP VARIABLES
.END

251
BASIC_VIC/token2

@ -0,0 +1,251 @@
.PAG 'TOKEN2'
.BYT 'TAB',$A8
TABTK =@243
.BYT 'T',$CF
TOTK =@244
.BYT 'F',$CE
FNTK =@245
.BYT 'SPC',$A8
SPCTK =@246
.BYT 'THE',$CE
THENTK =@247
.BYT 'NO',$D4
NOTTK =@250
.BYT 'STE',$D0
STEPTK =@251
.BYT $AB
PLUSTK =@252
.BYT $AD
MINUTK =@253
.BYT $AA
.BYT $AF
.BYT $DE
.BYT 'AN',$C4
.BYT 'O',$D2
.BYT 190
GREATK =@261
.BYT $BD
EQULTK =@262
.BYT 188
LESSTK =@263
.BYT 'SG',$CE
ONEFUN =@264
.BYT 'IN',$D4
.BYT 'AB',$D3
.BYT 'US',$D2
.BYT 'FR',$C5
.BYT 'PO',$D3
.BYT 'SQ',$D2
.BYT 'RN',$C4
.BYT 'LO',$C7
.BYT 'EX',$D0
.BYT 'CO',$D3
.BYT 'SI',$CE
.BYT 'TA',$CE
.BYT 'AT',$CE
.BYT 'PEE',$CB
.BYT 'LE',$CE
.BYT 'STR',$A4
.BYT 'VA',$CC
.BYT 'AS',$C3
.BYT 'CHR',$A4
LASNUM =@307
.BYT 'LEFT',$A4
.BYT 'RIGHT',$A4
.BYT 'MID',$A4
.BYT 'G',$CF
GOTK =@313
.BYT 0
.PAG 'ERROR MESSAGES'
ERR01 .BYT 'TOO MANY FILE',$D3
ERR02 .BYT 'FILE OPE',$CE
ERR03 .BYT 'FILE NOT OPE',$CE
ERR04 .BYT 'FILE NOT FOUN',$C4
ERR05 .BYT 'DEVICE NOT PRESEN',$D4
ERR06 .BYT 'NOT INPUT FIL',$C5
ERR07 .BYT 'NOT OUTPUT FIL',$C5
ERR08 .BYT 'MISSING FILE NAM',$C5
ERR09 .BYT 'ILLEGAL DEVICE NUMBE',$D2
ERR10 .BYT 'NEXT WITHOUT FO',$D2
ERRNF =10
ERR11 .BYT 'SYNTA',$D8
ERRSN =11
ERR12 .BYT 'RETURN WITHOUT GOSU',$C2
ERRRG =12
ERR13 .BYT 'OUT OF DAT',$C1
ERROD =13
ERR14 .BYT 'ILLEGAL QUANTIT',$D9
ERRFC =14
ERR15 .BYT 'OVERFLO',$D7
ERROV =15
ERR16 .BYT 'OUT OF MEMOR',$D9
ERROM =16
ERR17 .BYT 'UNDEF',$27
.BYT 'D STATEMEN',$D4
ERRUS =17
ERR18 .BYT 'BAD SUBSCRIP',$D4
ERRBS =18
ERR19 .BYT 'REDIM',$27,'D ARRA',$D9
ERRDD =19
ERR20 .BYT 'DIVISION BY ZER',$CF
ERRDVO =20
ERR21 .BYT 'ILLEGAL DIREC',$D4
ERRID =21
ERR22 .BYT 'TYPE MISMATC',$C8
ERRTM =22
ERR23 .BYT 'STRING TOO LON',$C7
ERRLS =23
ERR24 .BYT 'FILE DAT',$C1
ERRBD =24
ERR25 .BYT 'FORMULA TOO COMPLE',$D8
ERRST =25
ERR26 .BYT 'CAN',$27,'T CONTINU',$C5
ERRCN =26
ERR27 .BYT 'UNDEF',$27,'D FUNCTIO',$CE
ERRUF =27
ERR28 .BYT 'VERIF',$D9
ERVFY =28
ERR29 .BYT 'LOA',$C4
ERLOAD =29
.PAG 'ERROR MESSAGES'
; TABLE TO TRANSLATE ERROR MESSAGE #
; TO ADDRESS OF STRING CONTAINING MESSAGE
;
ERRTAB .WOR ERR01
.WOR ERR02
.WOR ERR03
.WOR ERR04
.WOR ERR05
.WOR ERR06
.WOR ERR07
.WOR ERR08
.WOR ERR09
.WOR ERR10
.WOR ERR11
.WOR ERR12
.WOR ERR13
.WOR ERR14
.WOR ERR15
.WOR ERR16
.WOR ERR17
.WOR ERR18
.WOR ERR19
.WOR ERR20
.WOR ERR21
.WOR ERR22
.WOR ERR23
.WOR ERR24
.WOR ERR25
.WOR ERR26
.WOR ERR27
.WOR ERR28
.WOR ERR29
.WOR ERR30
OKMSG .BYT $D,'OK',$D,$0
ERR .BYT $D,' ERROR',0 ;ADD A C/R FOR VIXEN SCREEN
INTXT .BYT ' IN ',0
REDDY .BYT $D,$A,'READY.',$D,$A,0
ERBRK =30
BRKTXT .BYT $D,$A
ERR30 .BYT 'BREAK',0,$A0 ;SHIFTED SPACE
.PAG
FORSIZ =@22
FNDFOR TSX
INX
INX
INX
INX
FFLOOP LDA 257,X
CMP #FORTK
BNE FFRTS
LDA FORPNT+1
BNE CMPFOR
LDA 258,X
STA FORPNT
LDA 259,X
STA FORPNT+1
CMPFOR CMP 259,X
BNE ADDFRS
LDA FORPNT
CMP 258,X
BEQ FFRTS
ADDFRS TXA
CLC
ADC #FORSIZ
TAX
BNE FFLOOP
FFRTS RTS
BLTU JSR REASON
STA STREND
STY STREND+1
BLTUC SEC
LDA HIGHTR
SBC LOWTR
STA INDEX
TAY
LDA HIGHTR+1
SBC LOWTR+1
TAX
INX
TYA
BEQ DECBLT
LDA HIGHTR
SEC
SBC INDEX
STA HIGHTR
BCS BLT1
DEC HIGHTR+1
SEC
BLT1 LDA HIGHDS
SBC INDEX
STA HIGHDS
BCS MOREN1
DEC HIGHDS+1
BCC MOREN1
BLTLP LDA (HIGHTR)Y
STA (HIGHDS)Y
MOREN1 DEY
BNE BLTLP
LDA (HIGHTR),Y
STA (HIGHDS),Y
DECBLT DEC HIGHTR+1
DEC HIGHDS+1
DEX
BNE MOREN1
RTS
GETSTK ASL A
ADC #NUMLEV+NUMLEV+16
BCS OMERR
STA INDEX
TSX
CPX INDEX
BCC OMERR
RTS
REASON CPY FRETOP+1
BCC REARTS
BNE TRYMOR
CMP FRETOP
BCC REARTS
TRYMOR PHA
LDX #8+ADDPRC
TYA
REASAV PHA
LDA HIGHDS-1,X
DEX
BPL REASAV
JSR GARBA2
LDX #248-ADDPRC
REASTO PLA
STA HIGHDS+8+ADDPRC,X
INX
BMI REASTO
PLA
TAY
PLA
CPY FRETOP+1
BCC REARTS
BNE OMERR
CMP FRETOP
BCS OMERR
REARTS RTS
.END

128
BASIC_VIC/tokens

@ -0,0 +1,128 @@
.PAGE 'TOKENS'
*=ROMLOC
.WOR INIT ;C000 HARD RESET
.WOR PANIC ;C000 SOFT RESET
.BYT 'CBMBASIC'
STMDSP .WOR END-1
.WOR FOR-1
.WOR NEXT-1
.WOR DATA-1
.WOR INPUTN-1
.WOR INPUT-1
.WOR DIM-1
.WOR READ-1
.WOR LET-1
.WOR GOTO-1
.WOR RUN-1
.WOR IF-1
.WOR RESTOR-1
.WOR GOSUB-1
.WOR RETURN-1
.WOR REM-1
.WOR STOP-1
.WOR ONGOTO-1
.WOR FNWAIT-1
.WOR CLOAD-1
.WOR CSAVE-1
.WOR CVERF-1
.WOR DEF-1
.WOR POKE-1
.WOR PRINTN-1
.WOR PRINT-1
.WOR CONT-1
.WOR LIST-1
.WOR CLEAR-1
.WOR CMD-1
.WOR CSYS-1
.WOR COPEN-1
.WOR CCLOS-1
.WOR GET-1
.WOR SCRATH-1
FUNDSP .WOR SGN
.WOR INT
.WOR ABS
USRLOC .WOR USRPOK
.WOR FRE
.WOR POS
.WOR SQR
.WOR RND
.WOR LOG
.WOR EXP
.WOR COS
.WOR SIN
.WOR TAN
.WOR ATN
.WOR PEEK
.WOR LEN
.WOR STRD
.WOR VAL
.WOR ASC
.WOR CHRD
.WOR LEFTD
.WOR RIGHTD
.WOR MIDD
OPTAB .BYT 121
.WOR FADDT-1
.BYT 121
.WOR FSUBT-1
.BYT 123
.WOR FMULTT-1
.BYT 123
.WOR FDIVT-1
.BYT 127
.WOR FPWRT-1
.BYT 80
.WOR ANDOP-1
.BYT 70
.WOR OROP-1
NEGTAB .BYT 125
.WOR NEGOP-1
NOTTAB .BYT 90
.WOR NOTOP-1
PTDORL .BYT 100
.WOR DOREL-1
Q=128-1
RESLST .BYT 'EN',$C4
ENDTK =@200
.BYT 'FO',$D2
FORTK =@201
.BYT 'NEX',$D4
.BYT 'DAT',$C1
DATATK =@203
.BYT 'INPUT',$A3
.BYT 'INPU',$D4
.BYT 'DI',$CD
.BYT 'REA',$C4
.BYT 'LE',$D4
.BYT 'GOT',$CF
GOTOTK =@211
.BYT 'RU',$CE
.BYT 'I',$C6
.BYT 'RESTOR',$C5
.BYT 'GOSU',$C2
GOSUTK =@215
.BYT 'RETUR',$CE
.BYT 'RE',$CD
REMTK =@217
.BYT 'STO',$D0
.BYT 'O',$CE
.BYT 'WAI',$D4
.BYT 'LOA',$C4
.BYT 'SAV',$C5
.BYT 'VERIF',$D9
.BYT 'DE',$C6
.BYT 'POK',$C5
.BYT 'PRINT',$A3
.BYT 'PRIN',$D4
PRINTK =@231
.BYT 'CON',$D4
.BYT 'LIS',$D4
.BYT 'CL',$D2
.BYT 'CM',$C4
.BYT 'SY',$D3
.BYT 'OPE',$CE
.BYT 'CLOS',$C5
.BYT 'GE',$D4
.BYT 'NE',$D7
SCRATK =@242
.END

102
BASIC_VIC/trig

@ -0,0 +1,102 @@
.PAG 'TRIG FUNCTIONS'
COS LDA #<PI2
LDY #>PI2
JSR FADD
SIN JSR MOVAF
LDA #<TWOPI
LDY #>TWOPI
LDX ARGSGN
JSR FDIVF
JSR MOVAF
JSR INT
LDA #0
STA ARISGN
JSR FSUBT
LDA #<FR4
LDY #>FR4
JSR FSUB
LDA FACSGN
PHA
BPL SIN1
JSR FADDH
LDA FACSGN
BMI SIN2
LDA TANSGN
EOR #$FF
STA TANSGN
SIN1 JSR NEGOP
SIN2 LDA #<FR4
LDY #>FR4
JSR FADD
PLA
BPL SIN3
JSR NEGOP
SIN3 LDA #<SINCON
LDY #>SINCON
JMP POLYX
TAN JSR MOV1F
LDA #0
STA TANSGN
JSR SIN
LDX #<TEMPF3
LDY #>TEMPF3
JSR GMOVMF
LDA #<TEMPF1
LDY #>TEMPF1
JSR MOVFM
LDA #0
STA FACSGN
LDA TANSGN
JSR COSC
LDA #<TEMPF3
LDY #>TEMPF3
JMP FDIV
COSC PHA
JMP SIN1
PI2 .BYT @201,@111,@17,@332,@242
TWOPI .BYT @203,@111,@17,@332,@242
FR4 .BYT @177,0,0,0,0
SINCON .BYT 5,@204,@346,@32,@55
.BYT @33,@206,@50,@7,@373
.BYT @370,@207,@231,@150,@211
.BYT 1,@207,@43,@65,@337,@341
.BYT @206,@245,@135,@347,@50,@203
.BYT @111,@17,@332,@242
ATN LDA FACSGN
PHA
BPL ATN1
JSR NEGOP
ATN1 LDA FACEXP
PHA
CMP #@201
BCC ATN2
LDA #<FONE
LDY #>FONE
JSR FDIV
ATN2 LDA #<ATNCON
LDY #>ATNCON
JSR POLYX
PLA
CMP #@201
BCC ATN3
LDA #<PI2
LDY #>PI2
JSR FSUB
ATN3 PLA
BPL ATN4
JMP NEGOP
ATN4 RTS
ATNCON .BYT @13,@166,@263,@203
.BYT @275,@323,@171,@36,@364
.BYT @246,@365,@173,@203,@374
.BYT @260,@20
.BYT @174,@14,@37,@147,@312
.BYT @174,@336,@123,@313,@301
.BYT @175,@24,@144,@160,@114
.BYT @175,@267,@352,@121,@172
.BYT @175,@143,@60,@210,@176
.BYT @176,@222,@104,@231,@72
.BYT @176,@114,@314,@221,@307
.BYT @177,@252,@252,@252,@23
.BYT @201,0,0,0,0
.END

210
KERNAL_VIC_04/channelio

@ -0,0 +1,210 @@
.PAG 'CHANNEL I/O'
;***************************************
;* 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 GN10 ;NOT KEYBOARD
;
LDA NDX ;QUEUE INDEX
BEQ BN31 ;NOBODY THERE...EXIT
;
SEI
JMP LP2 ;GO REMOVE A CHARACTER
;
GN10 CMP #2 ;IS IT RS-232
BNE BN10 ;NO...USE BASIN
;
GN232 STY XSAV ;SAVE .Y, USED IN RS232
JSR BSI232
LDY XSAV ;RESTORE .Y
CLC ;GOOD RETURN
RTS
.SKI 3
;***************************************
;* 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 *
;* 1 -- CASSETTE #1 *
;* 2 -- RS232 *
;* 3 -- SCREEN *
;* 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 BN20 ;NO...
;
STA CRSW ;FAKE A CARRIAGE RETURN
LDA LNMX ;SAY WE ENDED...
STA INDX ;...UP ON THIS LINE
JMP LOOP5 ;PICK UP CHARACTERS
;
BN20 BCS BN30 ;DEVICES >3
CMP #2 ;RS232?
BEQ BN50
;
;INPUT FROM CASSETTE BUFFERS
;
STX XSAV
JSR JTGET
BCS JTG37 ;STOP KEY/ERROR
PHA
JSR JTGET
BCS JTG36 ;STOP KEY/ERROR
BNE JTG35 ;NOT AN END OF FILE
LDA #64 ;TELL USER EOF
JSR UDST ;IN STATUS
JTG35 DEC BUFPT
LDX XSAV ;.X PRESERVED
PLA ;CHARACTER RETURNED
;C-CLEAR FROM JTGET
RTS ;ALL DONE
;
JTG36 TAX ;SAVE ERROR INFO
PLA ;TOSS DATA
TXA ;RESTORE ERROR
JTG37 LDX XSAV ;RETURN
RTS ;ERROR RETURN C-SET FROM JTGET
.SKI 3
;GET A CHARACTER FROM APPROPRIATE
;CASSETTE BUFFER
;
JTGET JSR JTP20 ;BUFFER POINTER WRAP?
BNE JTG10 ;NO...
JSR RBLK ;YES...READ NEXT BLOCK
BCS BN32 ;STOP KEY PRESSED
LDA #0
STA BUFPT ;POINT TO BEGIN.
BEQ JTGET ;BRANCH ALWAYS
;
JTG10 LDA (TAPE1)Y ;GET CHAR FROM BUF
CLC ;GOOD RETURN
RTS
.SKI 3
;INPUT FROM SERIAL BUS
;
BN30 LDA STATUS ;STATUS FROM LAST
BEQ BN35 ;WAS GOOD
LDA #$D ;BAD...ALL DONE
BN31 CLC ;VALID DATA
BN32 RTS
;
BN35 JMP ACPTR ;GOOD...HANDSHAKE
;
;INPUT FROM RS232
;
BN50 JSR GN232 ;GET INFO
BCS BN52 ;ERROR RETURN
CMP #00
BEQ BN50 ;WAIT FOR VALID DATA
CLC ;GOOD RETURN
BN52 RTS
.PAG 'CHANNEL OUTPUT'
;***************************************
;* BSOUT -- OUT CHARACTER TO CHANNEL *
;* DETERMINED BY VARIABLE DFLTO: *
;* 0 -- INVALID *
;* 1 -- CASSETTE #1 *
;* 2 -- RS232 *
;* 3 -- SCREEN *
;* 4-31 -- SERIAL BUS *
;***************************************
;
NBSOUT PHA ;PRESERVE .A
LDA DFLTO ;CHECK DEVICE
CMP #3 ;IS IT THE SCREEN?
BNE BO10 ;NO...
;
;PRINT TO CRT
;
PLA ;RESTORE DATA
JMP PRT ;PRINT ON CRT
;
BO10
BCC BO20 ;DEVICE 1 OR 2
;
;PRINT TO SERIAL BUS
;
PLA
JMP CIOUT
;
;PRINT TO CASSETTE DEVICES
;
BO20 CMP #2 ;RS232?
BEQ BO50
;
PLA
CASOUT STA T1
;
;PRESERVE REGISTERS
;
PHA
TXA
PHA
TYA
PHA
;
JSR JTP20 ;CHECK BUFFER POINTER
BNE JTP10 ;HAS NOT REACHED END
JSR WBLK ;WRITE FULL BUFFER
BCS RSTOR ;ABORT ON STOP KEY
;
;PUT BUFFER TYPE BYTE
;
LDA #BDF
LDY #0
STA (TAPE1)Y
;
;RESET BUFFER POINTER
;
INY ;MAKE .Y=1
STY BUFPT ;BUFPT=1
;
JTP10 LDA T1
STA (TAPE1)Y ;DATA TO BUFFER
;
;RESTORE .X AND .Y
;
CLC ;GOOD RETURN
RSTOR PLA
TAY
PLA
TAX
PLA ;RESTORE .A
BCC RSTOR1 ;NO ERROR
LDA #00 ;STOP ERROR IF C-SET
RSTOR1 RTS
;
;OUTPUT TO RS232
;
BO50 PLA ;GET DATA
STX XSAV ;PUT IN A TEMP
STY T1
JSR BSO232 ;COULD PUT CODE HERE
LDX XSAV ;GO RESTORE
LDY T1
CLC ;GOOD RETURN
RTS
.END

37
KERNAL_VIC_04/clall

@ -0,0 +1,37 @@
.PAG 'CLOSE ALL FILES'
;***************************************
;* CLALL -- CLOSE ALL LOGICAL FILES *
;* DELETES ALL TABLE ENTRIES AND*
;* RESTORES DEFAULT I/O CHANNELS *
;* AND CLEARS IEEE PORT DEVICES *
;*************************************
;
NCLALL LDA #0
STA LDTND ;FORGET ALL FILES
.SKI 3
;********************************************
;* CLRCH -- CLEAR CHANNELS *
;* UNLISTEN OR UNTALK IEEE DEVICES, BUT *
;* LEAVE OTHERS ALONE. DEFAULT CHANNELS *
;* ARE RESTORED. *
;********************************************
;
NCLRCH LDX #3
CPX DFLTO ;IS OUTPUT CHANNEL IEEE?
BCS JX750 ;NO...
;
JSR UNLSN ;YES...UNLISTEN IT
;
JX750 CPX DFLTN ;IS INPUT CHANNEL IEEE?
BCS CLALL2 ;NO...
;
JSR UNTLK ;YES...UNTALK IT
;
;RESTORE DEFAULT VALUES
;
;
CLALL2 STX DFLTO ;OUTPUT CHAN=3=SCREEN
LDA #0
STA DFLTN ;INPUT CHAN=0=KEYBOARD
RTS
.END

140
KERNAL_VIC_04/close

@ -0,0 +1,140 @@
.PAG '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 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...PROCESS
CMP #2 ;RS232?
BNE JX115 ;NO...
;
; RS-232
;
; REMOVE FILE FROM TABLES
PLA
JSR JXRMV
;
; DISABLE ALL RS-232 NMI'S (CB1 T1 T2)
;
LDA #%01111101
STA D1IER
;
; SEND MARK & ALL LINES HIGH
;
LDA #%00000110
STA D1ORB
LDA #%11101110
STA D1PCR
;
; DEALLOCATE BUFFERS
;
JSR GETTOP ;GET MEMSIZ
LDA RIBUF+1 ;CHECK INPUT ALLOCATION
BEQ CLS010 ;NOT...ALLOCATED
INY
CLS010 LDA ROBUF+1 ;CHECK OUTPUT ALLOCATION
BEQ CLS020
INY
CLS020 LDA #00 ;DEALLOCATE
STA RIBUF+1
STA ROBUF+1
; FLAG TOP OF MEMORY CHANGE
JMP MEMTCF ;GO SET NEW TOP
;
;CLOSE CASSETTE FILE
;
JX115 LDA SA ;WAS IT A TAPE READ?
AND #$F
BEQ JX150 ;YES
;
JSR ZZZ ;NO. . .IT IS WRITE
LDA #0 ;END OF FILE CHARACTER
JSR CASOUT ;PUT IN END OF FILE
JSR WBLK ;EMPTY LAST BUFFER
BCS JX170 ;STOP KEY PRESSED
;
LDA SA
CMP #$62 ;WRITE END OF TAPE BLOCK?
BNE JX150 ;NO...
;
LDA #EOT
JSR TAPEH ;WRITE END OF TAPE BLOCK
JMP JX150
;
;CLOSE AN SERIAL FILE
;
JX120 JSR CLSEI
;
;ENTRY TO REMOVE A GIVE LOGICAL FILE
;FROM TABLE OF LOGICAL, PRIMARY,
;AND SECONDARY ADDRESSES
;
JX150 PLA ;GET TABLE INDEX OFF STACK
;
; JXRMV - ENTRY TO USE AS AN RS-232 SUBROUTINE
;
JXRMV 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
RTS
.SKI 5
;LOOKUP TABLIZED LOGICAL FILE DATA
;
LOOKUP LDA #0
STA STATUS
TXA
JLTLK LDX LDTND
JX600 DEX
BMI JZ101
CMP LAT,X
BNE JX600
RTS
.SKI 5
;ROUTINE TO FETCH TABLE ENTRIES
;
JZ100 LDA LAT,X
STA LA
LDA FAT,X
STA FA
LDA SAT,X
STA SA
JZ101 RTS
.END

40
KERNAL_VIC_04/conkat

@ -0,0 +1,40 @@
.BYT $EF,$A1 ;ALL OF THIS IS AVAILABLE FOR PATCH SPACE
.BYT $DF,$A6
.BYT $E1,$B1
.BYT $E2,$B2
.BYT $E3,$B3
.BYT $E4,$B4
.BYT $E5,$B5
.BYT $E6,$B6
.BYT $E7,$B7
.BYT $E8,$B8
.BYT $E9,$B9
.BYT $FA,$BA
.BYT $FB,$BB
.BYT $FC,$BC
.BYT $EC,$BD
.BYT $FE,$BE
.BYT $84,$BF
.BYT $F7,$C0
.BYT $F8,$DB
.BYT $F9,$DD
.BYT $EA,$DE
UNKAT
.BYT $5E,$E0 ;E0-E2 SPECIAL CONVERSION CODES
.BYT $5B,$E1
.BYT $5D,$E2
.BYT $40,$B0
.BYT $61,$B1 ;UNCONVERSION
.BYT $78,$DB
.BYT $79,$DD
.BYT $66,$B6
.BYT $77,$C0
.BYT $70,$F0
.BYT $71,$F1
.BYT $72,$F2
.BYT $73,$F3
.BYT $74,$F4
.BYT $75,$F5
.BYT $76,$F6
.BYT $7D,$FD
.END

274
KERNAL_VIC_04/declare

@ -0,0 +1,274 @@
.PAG 'DECLARE'
;VIRTUAL REGS FOR MACHINE LANGUAGE MONITOR
*=$0000
PCH *=*+1
PCL *=*+1
FLGS *=*+1
ACC *=*+1
XR *=*+1
YR *=*+1
SP *=*+1
INVH *=*+1 ;USER MODIFIABLE IRQ
INVL *=*+1
* =$90
STATUS *=*+1 ;I/O OPERATION STATUS BYTE
; CRFAC *=*+2 ;CORRECTION FACTOR (UNUSED)
STKEY *=*+1 ;STOP KEY FLAG
SVXT *=*+1 ;TEMPORARY
VERCK *=*+1 ;LOAD OR VERIFY FLAG
C3P0 *=*+1 ;IEEE BUFFERED CHAR FLAG
BSOUR *=*+1 ;CHAR BUFFER FOR IEEE
SYNO *=*+1 ;CASSETTE SYNC #
XSAV *=*+1 ;TEMP FOR BASIN
LDTND *=*+1 ;INDEX TO LOGICAL FILE
DFLTN *=*+1 ;DEFAULT INPUT DEVICE #
DFLTO *=*+1 ;DEFAULT OUTPUT DEVICE #
PRTY *=*+1 ;CASSETTE PARITY
DPSW *=*+1 ;CASSETTE DIPOLE SWITCH
MSGFLG *=*+1 ;OS MESSAGE FLAG
PTR1 ;CASSETTE ERROR PASS1
T1 *=*+1 ;TEMPORARY 1
TMPC
PTR2 ;CASSETTE ERROR PASS2
T2 *=*+1 ;TEMPORARY 2
TIME *=*+3 ;24 HOUR CLOCK IN 1/60TH SECONDS
R2D2 ;SERIAL BUS USAGE
PCNTR *=*+1 ;CASSETTE STUFF
; PTCH *=*+1 (UNUSED)
BSOUR1 ;TEMP USED BY SERIAL ROUTINE
FIRT *=*+1
COUNT ;TEMP USED BY SERIAL ROUTINE
CNTDN *=*+1 ;CASSETTE SYNC COUNTDOWN
BUFPT *=*+1 ;CASSETTE BUFFER POINTER
INBIT ;RS-232 RCVR INPUT BIT STORAGE
SHCNL *=*+1 ;CASSETTE SHORT COUNT
BITCI ;RS-232 RCVR BIT COUNT IN
RER *=*+1 ;CASSETTE READ ERROR
RINONE ;RS-232 RCVR FLAG FOR START BIT CHECK
REZ *=*+1 ;CASSETE READING ZEROES
RIDATA ;RS-232 RCVR BYTE BUFFER
RDFLG *=*+1 ;CASSETTE READ MODE
RIPRTY ;RS-232 RCVR PARITY STORAGE
SHCNH *=*+1 ;CASSETTE SHORT CNT
SAL *=*+1
SAH *=*+1
EAL *=*+1
EAH *=*+1
CMP0 *=*+1
TEMP *=*+1
TAPE1 *=*+2 ;ADDRESS OF TAPE BUFFER #1Y.
BITTS ;RS-232 TRNS BIT COUNT
SNSW1 *=*+1
NXTBIT ;RS-232 TRNS NEXT BIT TO BE SENT
DIFF *=*+1
RODATA ;RS-232 TRNS BYTE BUFFER
PRP *=*+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
ROPRTY ;RS-232 TRNS PARITY BUFFER
OCHAR *=*+1
FSBLK *=*+1 ;CASSETTE READ BLOCK COUNT
MYCH *=*+1
CAS1 *=*+1 ;CASSETTE MANUAL/CONTROLLED SWITCH
TMP0
STAL *=*+1
STAH *=*+1
MEMUSS ;CASSETTE LOAD TEMPS (2 BYTES)
TMP2 *=*+2
;
;VARIABLES FOR SCREEN EDITOR
;
LSTX *=*+1 ;KEY SCAN INDEX
; SFST *=*+1 ;KEYBOARD SHIFT FLAG (UNUSED)
NDX *=*+1 ;INDEX TO KEYBOARD Q
RVS *=*+1 ;RVS FIELD ON FLAG
INDX *=*+1
LSXP *=*+1 ;X POS AT START
LSTP *=*+1
SFDX *=*+1 ;SHIFT MODE ON PRINT
BLNSW *=*+1 ;CURSOR BLINK ENAB
BLNCT *=*+1 ;COUNT TO TOGGLE CUR
GDBLN *=*+1 ;CHAR BEFORE CURSOR
BLNON *=*+1 ;ON/OFF BLINK FLAG
CRSW *=*+1 ;INPUT VS GET FLAG
PNT *=*+2 ;POINTER TO ROW
; POINT *=*+1 (UNUSED)
PNTR *=*+1 ;POINTER TO COLUMN
QTSW *=*+1 ;QUOTE SWITCH
LNMX *=*+1 ;40/80 MAX POSITON
TBLX *=*+1
DATA *=*+1
INSRT *=*+1 ;INSERT MODE FLAG
LDTB1 *=*+25 ;40/80 LINE FLAGS
LINTMP *=*+1 ;TEMPORARY FOR LINE INDEX
USER *=*+2 ;SCREEN EDITOR COLOR IP
KEYTAB *=*+2 ;KEYSCAN TABLE INDIRECT
;RS-232 Z-PAGE
RIBUF *=*+2 ;RS-232 INPUT BUFFER POINTER
ROBUF *=*+2 ;RS-232 OUTPUT BUFFER POINTER
FREKZP *=*+4 ;FREE KERNAL ZERO PAGE 9/24/80
BASZPT *=*+1 ;LOCATION ($00FF) USED BY BASIC
.SKI 3
*=$100
BAD *=*+1
*=$200
BUF *=*+89 ;BASIC/MONITOR BUFFER
; TABLES FOR OPEN FILES
;
LAT *=*+10 ;LOGICAL FILE NUMBERS
FAT *=*+10 ;PRIMARY DEVICE NUMBERS
SAT *=*+10 ;SECONDARY ADDRESSES
.SKI 2
; SYSTEM STORAGE
;
KEYD *=*+10 ;IRQ KEYBOARD BUFFER
MEMSTR *=*+2 ;START OF MEMORY
MEMSIZ *=*+2 ;TOP OF MEMORY
TIMOUT *=*+1 ;IEEE TIMEOUT FLAG
.SKI 2
; SCREEN EDITOR STORAGE
;
COLOR *=*+1 ;ACTIV COLOR NYBBLE
GDCOL *=*+1 ;ORIGINAL COLOR BEFORE CURSOR
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 ;0-PET MODE, 1-CATTACANNA
AUTODN *=*+1 ;AUTO SCROLL DOWN FLAG(=0 ON,<>0 OFF)
.SKI 3
; RS-232 STORAGE
;
M51CTR *=*+1 ;6551 CONTROL REGISTER
M51CDR *=*+1 ;6551 COMMAND REGISTER
M51AJB *=*+2 ;NON STANDARD (BITTIME/2-100)
RSSTAT *=*+1 ; RS-232 STATUS REGISTER
BITNUM *=*+1 ;NUMBER OF BITS TO SEND (FAST RESPONSE)
BAUDOF *=*+2 ;BAUD RATE FULL BIT TIME (CREATED BY OPEN)
;
; RECIEVER STORAGE
;
; INBIT *=*+1 ;INPUT BIT STORAGE
; BITCI *=*+1 ;BIT COUNT IN
; RINONE *=*+1 ;FLAG FOR START BIT CHECK
; RIDATA *=*+1 ;BYTE IN BUFFER
; RIPRTY *=*+1 ;BYTE IN PARITY STORAGE
RIDBE *=*+1 ;INPUT BUFFER INDEX TO END
RIDBS *=*+1 ;INPUT BUFFER POINTER TO START
;
; TRANSMITTER STORAGE
;
; BITTS *=*+1 ;# OF BITS TO BE SENT
; NXTBIT *=*+1 ;NEXT BIT TO BE SENT
; ROPRTY *=*+1 ;PARITY OF BYTE SENT
; RODATA *=*+1 ;BYTE BUFFER OUT
RODBS *=*+1 ;OUTPUT BUFFER INDEX TO START
RODBE *=*+1 ;OUTPUT BUFFER INDEX TO END
;
IRQTMP *=*+2 ;HOLDS IRQ DURING TAPE OPS
;
.SKI 3
*=$0300 ;REM PROGRAM INDIRECTS(10)
*=$0300+20 ;REM KERNAL/OS INDIRECTS(20)
CINV *=*+2 ;IRQ RAM VECTOR
CBINV *=*+2 ;BRK INSTR RAM VECTOR
NMINV *=*+2 ;NMI 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
.SKI 3
*=$0300+60
TBUFFR *=*+192 ;CASSETTE DATA BUFFER
.SKI 3
* =$400 ;RAMLOC
.SKI 3
*=$1000
VICSCN *=*+512 ;VIC SCREEN
.SKI 3
*=$9000
VICREG *=*+16 ;VIC REGISTERS
.PAG 'DECLARE'
; I/O DEVICES
;
*=$9110 ; DEVICE1 6522 (PAGE2 NMI)
D1ORB *=*+1
D1ORAH *=*+1
D1DDRB *=*+1
D1DDRA *=*+1
D1T1L *=*+1
D1T1H *=*+1
D1T1LL *=*+1
D1T1LH *=*+1
D1T2L *=*+1
D1T2H *=*+1
D1SR *=*+1
D1ACR *=*+1
D1PCR *=*+1
D1IFR *=*+1
D1IER *=*+1
D1ORA *=*+1
.SKI 3
*=$9120 ; DEVICE2 6522 (PAGE3 IRQ)
COLM ;KEYBOARD MATRIX
D2ORB *=*+1
ROWS ;KEYBOARD MATRIX
D2ORAH *=*+1
D2DDRB *=*+1
D2DDRA *=*+1
D2T1L *=*+1
D2T1H *=*+1
D2T1LL *=*+1
D2T1LH *=*+1
D2T2L *=*+1
D2T2H *=*+1
D2SR *=*+1
D2ACR *=*+1
D2PCR *=*+1
D2IFR *=*+1
D2IER *=*+1
D2ORA *=*+1
.SKI 3
*=$9400
VICCOL *=*+512 ;VIC COLOR NYBBLES
.PAG 'DECLARE'
;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
BUFSZ =192 ;BUFFER SIZE
;
;SCREEN EDITOR CONSTANTS
;
LLEN =22 ;SINGLE LINE 22 COLUMNS
LLEN2 =44 ;DOUBLE LINE = 44 COLUMNS
NLINES =23 ;23 ROWS ON SCREEN
WHITE =$01 ;WHITE SCREEN COLOR
BLUE =$06 ;BLUE CHAR COLOR
CR =$D ;CARRIAGE RETURN
.END
;RSR 8/3/80 ADD & CHANGE Z-PAGE
;RSR 8/11/80 ADD MEMUSS & PLF TYPE
;RSR 8/22/80 ADD RS-232 ROUTINES
;RSR 8/24/80 ADD OPEN VARIABLES
;RSR 8/29/80 ADD BAUD SPACE MOVE RS232 TO Z-PAGE
;RSR 9/2/80 ADD SCREEN EDITOR VARS&CON

40
KERNAL_VIC_04/disclaimer

@ -0,0 +1,40 @@
.PAG 'DISCLAIMER'
;****************************************
;* *
;* KK K EEEEE RRRR NN N AAA LL *
;* KK KK EE RR R NNN N AA A LL *
;* KKK EE RR R NNN N AA A LL *
;* KKK EEEE RRRR NNNNN AAAAA LL *
;* KK K EE RR R NN NN AA A LL *
;* KK KK EE RR R NN NN AA A LL *
;* KK KK EEEEE RR R NN NN AA A LLLLL *
;* *
;***************************************
;
;***************************************
;* PET KERNAL *
;* MEMORY AND I/O DEPENDENT ROUTINES *
;* DRIVING THE HARDWARE OF THE *
;* FOLLOWING CBM MODELS: *
;* VIXEN *
;* COPYRIGHT (C) 1980 BY *
;* COMMODORE BUSINESS MACHINES (CBM) *
;***************************************
;****LISTING DATE --1200 09 OCT. 1980**
;***************************************
;* THIS SOFTWARE IS FURNISHED FOR USE *
;* USE IN THE MICRO-PET COMPUTER *
;* ONLY. *
;* *
;* COPIES THEREOF MAY NOT BE PROVIDED *
;* OR MADE AVAILABLE FOR USE ON ANY *
;* OTHER SYSTEM. *
;* *
;* THE INFORMATION IN THIS DOCUMENT IS *
;* SUBJECT TO CHANGE WITHOUT NOTICE. *
;* *
;* NO RESPONSIBILITY IS ASSUMED FOR *
;* RELIABILITY OF THIS SOFTWARE. *
;* *
;***************************************
.END

646
KERNAL_VIC_04/editor.1

@ -0,0 +1,646 @@
.PAG 'SCREEN EDITOR'
MAXCHR=88
NWRAP=4 ;MAX NUMBER OF PHYSICAL LINES PER LOGICAL LINE
;UNDEFINED FUNCTION ENTRY
;
; UNDEFD LDX #0
; UNDEF2 LDA UNMSG,X
; JSR PRT
; INX
; CPX #UNMSG2-UNMSG
; BNE UNDEF2
; SEC
; RTS
;
; UNMSG .BYT $D,'?ADVANCED FUNCTION NOT AVAILABLE',$D
; UNMSG2
;
;RETURN ADDRESS OF 6522
;
IOBASE LDX #<D1ORB
LDY #>D1ORB
RTS
;
;RETURN MAX ROWS,COLS OF SCREEN
;
SCRORG LDX #LLEN
LDY #23
RTS
;
;READ/PLOT CURSOR POSITION
;
PLOT BCS PLOT10
STX TBLX
STY PNTR
JSR STUPT
PLOT10 LDX TBLX
LDY PNTR
RTS
.SKI 5
;INITIALIZE I/O
;
CINT
;
; CHECK FOR EXPANSION RAM
; ESTABLISH SCREEN MEMORY
;
JSR PANIC ;SET UP VIC
;
LDA HIBASE ;GET SCREEN BASE
AND #$FD ;GET RID OF .5K BOUNDRY
ASL A ;SET IT UP FOR THE VIC
ASL A
ORA #$80
STA VICREG+5 ;POINT THE VIC AT THE NEW SCREEN
;
LDA HIBASE ;CHECK FOR .5K BOUNDARY
AND #$02
BEQ NOHALF ;BRANCH IF ON 1K BOUNDARY
LDA #$80 ;ELSE SET .5K BIT IN VIC
ORA VICREG+2
STA VICREG+2
NOHALF
LDA #0 ;MAKE SURE WE'RE IN PET MODE
STA MODE
STA BLNON ;WE DONT HAVE A GOOD CHAR FROM THE SCREEN YET
LDA #<SHFLOG ;SET SHIFT LOGIC INDIRECTS
STA KEYLOG
LDA #>SHFLOG
STA KEYLOG+1
LDA #10
STA XMAX ;MAXIMUM TYPE AHEAD BUFFER SIZE
STA DELAY
LDA #BLUE
STA COLOR
LDA #4
STA KOUNT ;DELAY BETWEEN KEY REPEATS
LDA #$C
STA BLNCT
STA BLNSW
CLSR LDA HIBASE ;FILL HI BYTE PTR TABLE
ORA #$80
TAY
LDA #0
TAX
LPS1 STY LDTB1,X
CLC
ADC #LLEN
BCC LPS2
INY ;CARRY BUMP HI BYTE
LPS2 INX
CPX #NLINES+1 ;DONE # OF LINES?
BNE LPS1 ;NO...
LDA #$FF ;TAG END OF LINE TABLE
STA LDTB1,X
LDX #NLINES-1 ;CLEAR FROM THE BOTTOM LINE UP
CLEAR1 JSR CLRLN ;SEE SCROLL ROUTINES
DEX
BPL CLEAR1
.SKI 5
;HOME FUNCTION
;
NXTD LDY #0
STY PNTR ;LEFT COLUMN
STY TBLX ;TOP LINE
;
;MOVE CURSOR TO TBLX,PNTR
;
STUPT
LDX TBLX ;GET CURENT LINE INDEX
LDA PNTR ;GET CHARACTER POINTER
FNDSTR LDY LDTB1,X ;FIND BEGINING OF LINE
BMI STOK ;BRANCH IF START FOUND
CLC
ADC #LLEN ;ADJUST POINTER
STA PNTR
DEX
BPL FNDSTR
;
STOK
LDA LDTB1,X
AND #$03 ;GET RID OF GARBAGE
ORA HIBASE ;OR IN HIGH ORDER BITS
STA PNT+1
LDA LDTB2,X
STA PNT
;
LDA #LLEN-1
INX
FNDEND LDY LDTB1,X
BMI STDONE
CLC
ADC #LLEN
INX
BPL FNDEND
STDONE
STA LNMX
RTS
.SKI 5
;PANIC NMI ENTRY
;
VPAN JSR PANIC ;FIX VIC SCREEN
JMP NXTD ;HOME CURSOR
.SKI 5
PANIC LDA #3 ;RESET DEFAULT I/O
STA DFLTO
LDA #0
STA DFLTN
.SKI 5
;INIT VIC
;
INITV LDX #$10
PX4 LDA TVIC-1,X
STA VICREG-1,X
DEX
BNE PX4
RTS
.SKI 5
;
;REMOVE CHARACTER FROM QUEUE
;
LP2 LDY KEYD
LDX #0
LP1 LDA KEYD+1,X
STA KEYD,X
INX
CPX NDX
BNE LP1
DEC NDX
TYA
CLI
CLC ;GOOD RETURN
RTS
LOOP4 JSR PRT
LOOP3 LDA NDX
STA BLNSW
STA AUTODN ;TURN ON AUTO SCROLL DOWN
BEQ LOOP3
SEI
LDA BLNON
BEQ LP21
LDA GDBLN
LDX GDCOL ;RESTORE ORIGINAL COLOR
LDY #0
STY BLNON
JSR DSPP
LP21 JSR LP2
CMP #$83 ;RUN KEY?
BNE LP22
LDX #9
SEI
STX NDX
LP23 LDA RUNTB-1,X
STA KEYD-1,X
DEX
BNE LP23
BEQ LOOP3
LP22 CMP #$D
BNE LOOP4
LDY LNMX
STY CRSW
CLP5 LDA (PNT)Y
CMP #'
BNE CLP6
DEY
BNE CLP5
CLP6 INY
STY INDX
LDY #0
STY AUTODN ;TURN OFF AUTO SCROLL DOWN
STY PNTR
STY QTSW
LDA LSXP
BMI LOP5
LDX TBLX
JSR FINDST ;FIND 1ST PHYSICAL LINE
CPX LSXP
BNE LOP5
BNE LOP5
LDA LSTP
STA PNTR
CMP INDX
BCC LOP5
BCS CLP2
.SKI 5
;INPUT A LINE UNTIL CARRIAGE RETURN
;
LOOP5 TYA
PHA
TXA
PHA
LDA CRSW
BEQ LOOP3
LOP5 LDY PNTR
LDA (PNT)Y
.BYT $EA,$EA,$EA
.BYT $EA,$EA
.BYT $EA,$EA
.BYT $EA,$EA,$EA
.BYT $EA,$EA
.BYT $EA
.BYT $EA
.BYT $EA,$EA
.BYT $EA,$EA
.BYT $EA,$EA,$EA
.BYT $EA,$EA
NOTONE
STA DATA
LOP51 AND #$3F
ASL DATA
BIT DATA
BPL LOP54
ORA #$80
LOP54 BCC LOP52
LDX QTSW
BNE LOP53
LOP52 BVS LOP53
ORA #$40
LOP53 INC PNTR
JSR QTSWC
CPY INDX
BNE CLP1
CLP2 LDA #0
STA CRSW
LDA #$D
LDX DFLTN ;FIX GETS FROM SCREEN
CPX #3 ;IS IT THE SCREEN?
BEQ CLP2A
LDX DFLTO
CPX #3
BEQ CLP21
CLP2A JSR PRT
CLP21 LDA #$D
CLP1 STA DATA
PLA
TAX
PLA
TAY
LDA DATA
CMP #$DE ;IS IT <PI> ?
BNE CLP7
LDA #$FF
CLP7 CLC
RTS
.SKI 5
QTSWC CMP #$22
BNE QTSWL
LDA QTSW
EOR #$1
STA QTSW
LDA #$22
QTSWL RTS
.SKI 5
NXT33 ORA #$40
NXT3 LDX RVS
BEQ NVS
NC3 ORA #$80
NVS LDX INSRT
BEQ NVS1
DEC INSRT
NVS1 LDX COLOR PUT COLOR ON SCREEN
JSR DSPP
JSR WLOGIC ;CHECK FOR WRAPAROUND
LOOP2 PLA
TAY
LDA INSRT
BEQ LOP2
LSR QTSW
LOP2 PLA
TAX
PLA
CLC ;GOOD RETURN
CLI
RTS
.PAG
WLOGIC
JSR CHKDWN ;MAYBE WE SHOULD WE INCREMENT TBLX
INC PNTR ;BUMP CHARCTER POINTER
LDA LNMX ;
CMP PNTR ;IF LNMX IS LESS THAN PNTR
BCS WLGRTS ;BRANCH IF LNMX>=PNTR
CMP #MAXCHR-1 ;PAST MAX CHARACTERS
BEQ WLOG10 ;BRANCH IF SO
LDA AUTODN ;SHOULD WE AUTO SCROLL DOWN?
BEQ WLOG20 ;BRANCH IF NOT
JMP BMT1 ;ELSE DECIDE WHICH WAY TO SCROLL
.SKIP 3
WLOG20
LDX TBLX ;SEE IF WE SHOULD SCROLL DOWN
CPX #NLINES
BCC WLOG30 ;BRANCH IF NOT
JSR SCROL ;ELSE DO THE SCROL UP
DEC TBLX ;AND ADJUST CURENT LINE#
LDX TBLX
WLOG30 ASL LDTB1,X ;WRAP THE LINE
LSR LDTB1,X
JMP PATCHX ;DO THE FIX FOR RUN MODE WRAP
PATOUT ;PATCH RE-ENTRY POINT
ADC #LLEN
STA LNMX
FINDST
LDA LDTB1,X ;IS THIS THE FIRST LINE?
BMI FINX ;BRANCH IF SO
DEX ;ELSE BACKUP 1
BNE FINDST
FINX
JMP SETPNT ;MAKE SURE PNT IS RIGHT
WLOG10 DEC TBLX
JSR NXLN
LDA #0
STA PNTR ;POINT TO FIRST BYTE
WLGRTS RTS
.PAG
BKLN LDX TBLX
BNE BKLN1
STX PNTR
PLA
PLA
BNE LOOP2
;
BKLN1 DEX
STX TBLX
JSR STUPT
LDY LNMX
STY PNTR
RTS
.SKI 5
;PRINT ROUTINE
;
PRT PHA
STA DATA
TXA
PHA
TYA
PHA
LDA #0
STA CRSW
LDY PNTR
LDA DATA
BPL *+5
JMP NXTX
CMP #$D
BNE NJT1
JMP NXT1
NJT1 CMP #'
BCC NTCN
CMP #$60 ;LOWER CASE?
BCC NJT8 ;NO...
AND #$DF ;YES...MAKE SCREEN LOWER
BNE NJT9 ;ALWAYS
NJT8 AND #$3F
NJT9 JSR QTSWC
JMP NXT3
NTCN LDX INSRT
BEQ CNC3X
JMP NC3
CNC3X CMP #$14
BNE NTCN1
TYA
BNE BAK1UP
JSR BKLN
JMP BK2
BAK1UP JSR CHKBAK ;SHOULD WE DEC TBLX
DEY
STY PNTR
BK1 JSR SCOLOR ;FIX COLOR PTRS
BK15 INY
LDA (PNT)Y
DEY
STA (PNT)Y
INY
LDA (USER)Y
DEY
STA (USER)Y
INY
CPY LNMX
BNE BK15
BK2 LDA #'
STA (PNT)Y
LDA COLOR
STA (USER)Y
BPL JPL3
NTCN1 LDX QTSW
BEQ NC3W
CNC3 JMP NC3
NC3W CMP #$12
BNE NC1
STA RVS
NC1 CMP #$13
BNE NC2
JSR NXTD
NC2 CMP #$1D
BNE NCX2
INY
JSR CHKDWN
STY PNTR
DEY
CPY LNMX
BCC NCZ2
DEC TBLX
JSR NXLN
LDY #0
JPL4 STY PNTR
NCZ2 JMP LOOP2
NCX2 CMP #$11
BNE COLR1
CLC
TYA
ADC #LLEN
TAY
INC TBLX
CMP LNMX
BCC JPL4
BEQ JPL4
DEC TBLX
CURS10 SBC #LLEN
BCC GOTDWN
STA PNTR
BNE CURS10
GOTDWN JSR NXLN
JPL3 JMP LOOP2
COLR1 JSR CHKCOL ;CHECK FOR A COLOR
JMP LOWER ;WAS JMP LOOP2
.SKI 3
;CHECK COLOR
;
.SKI 5
;SHIFTED KEYS
;
NXTX .BYT $EA,$EA,$EA
.BYT $EA,$EA
.BYT $EA,$EA
.BYT $EA,$EA,$EA
.BYT $EA,$EA
.BYT $EA
.BYT $EA
.BYT $EA,$EA
;
.BYT $EA,$EA
;
.BYT $EA,$EA,$EA
KEEPIT
AND #$7F
CMP #$7F
BNE NXTX1
LDA #$5E
NXTX1 .BYT $EA,$EA
.BYT $EA,$EA
.BYT $EA,$EA
NXTXA
CMP #$20 ;IS IT A FUNCTION KEY
BCC UHUH
JMP NXT33
UHUH
CMP #$D
BNE UP5
JMP NXT1
UP5 LDX QTSW
BNE UP6
CMP #$14
BNE UP9
LDY LNMX
LDA (PNT)Y
CMP #'
BNE INS3
CPY PNTR
BNE INS1
INS3 CPY #MAXCHR-1
BEQ INSEXT ;EXIT IF LINE TOO LONG
JSR NEWLIN ;SCROLL DOWN 1
INS1 LDY LNMX
JSR SCOLOR
INS2 DEY
LDA (PNT)Y
INY
STA (PNT)Y
DEY
LDA (USER)Y
INY
STA (USER)Y
DEY
CPY PNTR
BNE INS2
LDA #$20
STA (PNT)Y
LDA COLOR
STA (USER)Y
INC INSRT
INSEXT JMP LOOP2
UP9 LDX INSRT
BEQ UP2
UP6 ORA #$40
JMP NC3
UP2 CMP #$11
BNE NXT2
LDX TBLX
BEQ JPL2
DEC TBLX
LDA PNTR
SEC
SBC #LLEN
BCC UPALIN
STA PNTR
BPL JPL2
UPALIN JSR STUPT
BNE JPL2
NXT2 CMP #$12
BNE NXT6
LDA #0
STA RVS
NXT6 CMP #$1D
BNE NXT61
TYA
BEQ BAKBAK
JSR CHKBAK
DEY
STY PNTR
JMP LOOP2
BAKBAK JSR BKLN
JMP LOOP2
NXT61 CMP #$13
BNE SCCL
JSR CLSR
JPL2 JMP LOOP2
SCCL
ORA #$80 ;MAKE IT UPPER CASE
JSR CHKCOL ;TRY FOR COLOR
JMP UPPER ;WAS JMP LOOP2
;
NXLN LSR LSXP
LDX TBLX
NXLN2 INX
CPX #NLINES ;OFF BOTTOM?
BNE NXLN1 ;NO...
JSR SCROL ;YES...SCROLL
NXLN1 LDA LDTB1,X ;DOUBLE LINE?
BPL NXLN2 ;YES...SCROLL AGAIN
STX TBLX
JMP STUPT
NXT1
LDX #0
STX INSRT
STX RVS
STX QTSW
STX PNTR
JSR NXLN
JPL5 JMP LOOP2
;
;
; CHECK FOR A DECREMENT TBLX
;
CHKBAK LDX #NWRAP
LDA #0
CHKLUP CMP PNTR
BEQ BACK
CLC
ADC #LLEN
DEX
BNE CHKLUP
RTS
;
BACK DEC TBLX
RTS
;
; CHECK FOR INCREMENT TBLX
;
CHKDWN LDX #NWRAP
LDA #LLEN-1
DWNCHK CMP PNTR
BEQ DNLINE
CLC
ADC #LLEN
DEX
BNE DWNCHK
RTS
;
DNLINE LDX TBLX
CPX #NLINES
BEQ DWNBYE
INC TBLX
;
DWNBYE RTS
.SKI2
CHKCOL
LDX #7 ;THERE'S 8 COLORS
CHK1A CMP COLTAB,X
BEQ CHK1B
DEX
BPL CHK1A
RTS
;
CHK1B
STX COLOR ;CHANGE THE COLOR
RTS
COLTAB
;BLK,WHT,RED,CYAN,MAGENTA,GRN,BLUE,YELLOW
.BYT $90,$05,$1C,$9F,$9C,$1E,$1F,$9E
;********************************
; THE FOLLOWING TABLE SERVES TO
; CONVERT TO AND FROM SCREEN CODE
; TO KASCII. IT IS IMPLEMENTED FOR
; TESTING ONLY. IT COULD BE IMPROVED
; TO REDUCE CODE AND SPEED BY AN
; ALGORITHM
;
;*********************************
.END

435
KERNAL_VIC_04/editor.2

@ -0,0 +1,435 @@
.PAG 'EDITOR.2'
;SCREEN SCROLL ROUTINE
;
SCROL LDA SAL
PHA
LDA SAH
PHA
LDA EAL
PHA
LDA EAH
PHA
;
; S C R O L L U P
;
SCRO0 LDX #$FF
DEC TBLX
DEC LSXP
DEC LINTMP
SCR10 INX ;GOTO NEXT LINE
JSR SETPNT ;POINT TO 'TO' LINE
CPX #NLINES-1 ;DONE?
BCS SCR41 ;BRANCH IF SO
;
LDA LDTB2+1,X ;SETUP FROM PNTR
STA SAL
LDA LDTB1+1,X
JSR SCRLIN ;SCROLL THIS LINE UP1
BMI SCR10
;
SCR41
JSR CLRLN
;
LDX #0 ;SCROLL HI BYTE POINTERS
SCRL5 LDA LDTB1,X
AND #$7F
LDY LDTB1+1,X
BPL SCRL3
ORA #$80
SCRL3 STA LDTB1,X
INX
CPX #NLINES-1
BNE SCRL5
;
LDA LDTB1+NLINES-1
ORA #$80
STA LDTB1+NLINES-1
LDA LDTB1 ;DOUBLE LINE?
BPL SCRO0 ;YES...SCROLL AGAIN
;
INC TBLX
INC LINTMP
LDA #$FB ;CHECK FOR CONTROL KEY
STA COLM ;DROP LINE 2 ON PORT B
LDA ROWS
CMP #$FE ;SLOW SCROLL KEY?(CONTROL)
PHP ;SAVE STATUS. RESTORE PORT B
LDA #$F7 ;FOR STOP KEY CHECK
STA COLM
PLP
BNE MLP42
;
LDY #0
MLP4 NOP ;DELAY
DEX
BNE MLP4
DEY
BNE MLP4
STY NDX ;CLEAR KEY QUEUE BUFFER
;
MLP42 LDX TBLX
;
PLA
STA EAH
PLA
STA EAL
PLA
STA SAH
PLA
STA SAL
;
RTS
.PAG
NEWLIN
LDX TBLX
BMT1 INX
LDA LDTB1,X ;FIND LAST DISPLAY LINE OF THIS LINE
BPL BMT1
STX LINTMP ;FOUND IT
;GENERATE A NEW LINE
CPX #NLINES-1 ;IS ONE LINE FROM BOTTOM?
BEQ NEWLX ;YES...JUST CLEAR LAST
BCC NEWLX ;<NLINES...INSERT LINE
JSR SCROL ;SCROLL EVERYTHING
LDX LINTMP
DEX
DEC TBLX
JMP WLOG30
NEWLX LDA SAL
PHA
LDA SAH
PHA
LDA EAL
PHA
LDA EAH
PHA
LDX #NLINES
SCD10 DEX
JSR SETPNT ;SET UP TO ADDR
CPX LINTMP
BCC SCR40
BEQ SCR40 ;BRANCH IF FINISHED
LDA LDTB2-1,X ;SET FROM ADDR
STA SAL
LDA LDTB1-1,X
JSR SCRLIN ;SCROLL THIS LINE DOWN
BMI SCD10
SCR40
JSR CLRLN
LDX #NLINES-2
SCRD21
CPX LINTMP ;DONE?
BCC SCRD22 ;BRANCH IF SO
LDA LDTB1+1,X
AND #$7F
LDY LDTB1,X ;WAS IT CONTINUED
BPL SCRD19 ;BRANCH IF SO
ORA #$80
SCRD19 STA LDTB1+1,X
DEX
BNE SCRD21
SCRD22
LDX LINTMP
JSR WLOG30
;
PLA
STA EAH
PLA
STA EAL
PLA
STA SAH
PLA
STA SAL
RTS
;
; SCROLL LINE FROM SAL TO PNT
; AND COLORS FROM EAL TO USER
;
SCRLIN
AND #$03 ;CLEAR ANY GARBAGE STUFF
ORA HIBASE ;PUT IN HIORDER BITS
STA SAL+1
JSR TOFROM ;COLOR TO & FROM ADDRS
LDY #LLEN-1
SCD20
LDA (SAL)Y
STA (PNT)Y
LDA (EAL)Y
STA (USER)Y
DEY
BPL SCD20
RTS
;
; DO COLOR TO AND FROM ADDRESSES
; FROM CHARACTER TO AND FROM ADRS
;
TOFROM
JSR SCOLOR
LDA SAL ;CHARACTER FROM
STA EAL ;MAKE COLOR FROM
LDA SAL+1
AND #$03
ORA #>VICCOL
STA EAL+1
RTS
;
; SET UP PNT AND Y
; FROM .X
;
SETPNT LDA LDTB2,X
STA PNT
LDA LDTB1,X
AND #$03
ORA HIBASE
STA PNT+1
RTS
;
; CLEAR THE LINE POINTED TO BY .X
;
CLRLN LDY #LLEN-1
JSR SETPNT
JSR SCOLOR
CLR10 LDA #$20
STA (PNT)Y
LDA #WHITE ;DO THE COLOR
STA (USER)Y
DEY
BPL CLR10
RTS
.SKI 5
;
;PUT A CHAR ON THE SCREEN
;
DSPP TAY ;SAVE CHAR
LDA #2
STA BLNCT ;BLINK CURSOR
JSR SCOLOR ;SET COLOR PTR
TYA ;RESTORE COLOR
DSPP2 LDY PNTR ;GET COLUMN
STA (PNT)Y ;CHAR TO SCREEN
TXA
STA (USER)Y ;COLOR TO SCREEN
RTS
.SKI 5
SCOLOR LDA PNT ;GENERATE COLOR PTR
STA USER
LDA PNT+1
AND #$03
ORA #>VICCOL ;VIC COLOR RAM
STA USER+1
RTS
.PAG
KEY JSR $FFEA ;UPDATE JIFFY CLOCK
LDA BLNSW ;BLINKING CRSR ?
BNE KEY4 ;NO
DEC BLNCT ;TIME TO BLINK ?
BNE KEY4 ;NO
LDA #20 ;RESET BLINK COUNTER
REPDO STA BLNCT
LDY PNTR ;CURSOR POSITION
LSR BLNON ;CARRY SET IF ORIGINAL CHAR
LDX GDCOL ;GET CHAR ORIGINAL COLOR
LDA (PNT)Y ;GET CHARACTER
BCS KEY5 ;BRANCH IF NOT NEEDED
;
INC BLNON ;SET TO 1
STA GDBLN ;SAVE ORIGINAL CHAR
JSR SCOLOR
LDA (USER)Y ;GET ORIGINAL COLOR
STA GDCOL ;SAVE IT
LDX COLOR ;BLINK IN THIS COLOR
LDA GDBLN ;WITH ORIGINAL CHARACTER
;
KEY5 EOR #$80 ;BLINK IT
JSR DSPP2 ;DISPLAY IT
;
KEY4 LDA D1ORA ;GET CASSETTE SWITCHES
AND #$40 ;IS SWITHC DOWN
BEQ KEY3 ;BRANCH IF SO
;
LDY #0
STY CAS1 ;CASSETTE OFF SWITCH
;
LDA D1PCR
ORA #$02
BNE KL24 ;BRANCH IF MOTOR IS OFF
;
KEY3 LDA CAS1
BNE KL2
;
LDA D1PCR
AND #$FD ;TURN MOTOR ON
;
KL24 BIT D1IER ;CHECK RS-232 TRANSMITTER ON (T1)
BVS KL2 ;YES...NO MANUAL CASS CONTROLS
STA D1PCR
;
KL2 JSR SCNKEY ;SCAN KEYBOARD
;
KPREND BIT D2T1L ;CLEAR INTERUPT FLAG
PLA ;RESTORE REGISTERS
TAY
PLA
TAX
PLA
RTI ;EXIT FROM IRQ ROUTINES
.SKI 3
; ****** GENERAL KEYBOARD SCAN ******
;
SCNKEY LDA #$00
STA SHFLAG
LDY #64 ;LAST KEY INDEX
STY SFDX ;NULL KEY FOUND
STA COLM ;RAISE ALL LINES
LDX ROWS ;CHECK FOR A KEY DOWN
CPX #$FF ;NO KEYS DOWN?
BEQ SCNOUT ;BRANCH IF NONE
; LDA CRFAC ;CHECK FOR RESTORE BACKGROUND/BOARDER
; BPL DONTRE ;DON'T RESTORE IF PLUS
; LDA CRFAC+1 ;GET OLD VALUE
; STA VICREG+15 ;PUT IT BACK IN VIC
;DONTRE
; LDA #0
; STA CRFAC ;REMEMBER I CHANGED IT BACK
LDA #$FE ;START WITH 1ST COLUMN
STA COLM
LDY #0
LDA #<MODE1
STA KEYTAB
LDA #>MODE1
STA KEYTAB+1
SCN20 LDX #8 ;8 ROW KEYBOARD
LDA ROWS
CMP ROWS ;DEBOUNCE KEYBOARD
BNE SCN20
SCN30 LSR A ;LOOK FOR KEY DOWN
BCS CKIT ;NONE
PHA
LDA (KEYTAB),Y ;GET CHAR CODE
CMP #$05
BCS SPCK2 ;IF NOT SPECIAL KEY GO ON
CMP #$03 ;COULD IT BE A STOP KEY?
BEQ SPCK2 ;BRANCH IF SO
ORA SHFLAG
STA SHFLAG ;PUT SHIFT BIT IN FLAG BYTE
BPL CKUT
SPCK2
STY SFDX ;SAVE KEY NUMBER
CKUT PLA
CKIT INY
CPY #65
BCS CKIT1 ;BRANCH IF FINISHED
DEX
BNE SCN30
SEC
ROL COLM ;NEXT COLUMN ON KEYBOARD
BNE SCN20 ;ALWAYS BRANCH
CKIT1
JMP (KEYLOG) ;EVALUATE SHIFT FUNCTIONS
REKEY LDY SFDX ;GET KEY INDEX
LDA (KEYTAB)Y ;GET CHAR CODE
TAX ;SAVE THE CHAR
CPY LSTX ;SAME AS PREV CHAR INDEX?
BEQ RPT10 ;YES
LDY #$10 ;NO - RESET DELAY BEFORE REPEAT
STY DELAY
BNE CKIT2 ;ALWAYS
RPT10 AND #$7F ;UNSHIFT IT
BIT RPTFLG ;CHECK FOR REPEAT DISABLE
BMI RPT20 ;YES
BVS SCNRTS
CMP #$7F ;NO KEYS ?
SCNOUT BEQ CKIT2 ;YES - GET OUT
CMP #$14 ;AN INST/DEL KEY ?
BEQ RPT20 ;YES - REPEAT IT
CMP #$20 ;A SPACE KEY ?
BEQ RPT20 ;YES
CMP #$1D ;A CRSR LEFT/RIGHT ?
BEQ RPT20 ;YES
CMP #$11 ;A CRSR UP/DWN ?
BNE SCNRTS ;NO - EXIT
RPT20 LDY DELAY ;TIME TO REPEAT ?
BEQ RPT40 ;YES
DEC DELAY
BNE SCNRTS
RPT40 DEC KOUNT ;TIME FOR NEXT REPEAT ?
BNE SCNRTS ;NO
LDY #4 ;YES - RESET CTR
STY KOUNT
LDY NDX ;NO REPEAT IF QUEUE FULL
DEY
BPL SCNRTS
CKIT2
LDY SFDX ;GET INDEX OF KEY
STY LSTX ;SAVE THIS INDEX TO KEY FOUND
LDY SHFLAG ;UPDATE SHIFT STATUS
STY LSTSHF
CKIT3 CPX #$FF ;A NULL KEY OR NO KEY ?
BEQ SCNRTS ;BRANCH IF SO
TXA ;NEED X AS INDEX SO...
LDX NDX ;GET # OF CHARS IN KEY QUEUE
CPX XMAX ;IRQ BUFFER FULL ?
BCS SCNRTS ;YES - NO MORE INSERT
PUTQUE
STA KEYD,X ;PUT RAW DATA HERE
INX
STX NDX ;UPDATE KEY QUEUE COUNT
SCNRTS LDA #$F7 ;SETUP PB3 FOR STOP KEY SENSE
STA COLM
RTS
.PAG
;
; SHIFT LOGIC
;
SHFLOG
LDA SHFLAG
CMP #$03 ;COMMODORE SHIFT COMBINATION?
BNE KEYLG2 ;BRANCH IF NOT
CMP LSTSHF ;DID I DO THIS ALREADY
BEQ SCNRTS ;BRANCH IF SO
LDA MODE
BMI SHFOUT ;DONT SHIFT IF ITS MINUS
.BYT $EA,$EA ;AND #$18 ;WHICH MODE?
.BYT $EA,$EA ;BEQ KATAON ;IF PET MODE TURNON KATAKANA
.BYT $EA,$EA ;LDA #0
.BYT $EA,$EA,$EA;STA MODE ;SET PET MODE
.BYT $EA,$EA,$EA;LDA VICREG+5 ;TURN ON PETSET
.BYT $EA,$EA ;AND #$FD ;CLEAR BIT 1
.BYT $EA,$EA,$EA;STA VICREG+5
.BYT $EA,$EA ;BNE SHFOUT
SWITCH LDA VICREG+5
EOR #$02 ;TURN ON OTHER CASE
STA VICREG+5 ;POINT THE VIC THERE
.BYT $EA,$EA ;LDA #8 ;SET KATAKANA MODE
.BYT $EA,$EA ;STA MODE
JMP SHFOUT
KEYLG2
ASL A
CMP #$08 ;WAS IT A CONTROL KEY
BCC NCTRL ;BRANCH IF NOT
LDA #6 ;ELSE USE TABLE #4
.BYT $EA,$EA ;BNE NOTKAT ;DO THE TABLE SHIFT
;
NCTRL
.BYT $EA,$EA,$EA;LDX MODE
.BYT $EA,$EA ;BEQ NOTKAT
.BYT $EA,$EA,$EA;LDX SHFLAG ;SEE IF CO.KEY
.BYT $EA,$EA ;CPX #2
.BYT $EA,$EA ;BNE NOTKAT ;BRANCH IF NOT
.BYT $EA,$EA,$EA;CPX LSTSHF ;DID I DO THIS LAST TIME?
.BYT $EA,$EA ;BEQ SHFOUT ;BRANCH IF SO
.BYT $EA,$EA,$EA;LDA MODE ;ELSE ...
.BYT $EA,$EA ;EOR #$18 ;SWITCH KATA-EXTENDED
.BYT $EA,$EA,$EA;STA MODE
.BYT $EA,$EA ;BPL SHFOUT
NOTKAT
.BYT $EA,$EA,$EA;ORA MODE ;ADD MODE TABLE OFFSET
.BYT $EA,$EA ;AND #$7F ;CLEAR
TAX
LDA KEYCOD,X
STA KEYTAB
LDA KEYCOD+1,X
STA KEYTAB+1
SHFOUT
JMP REKEY
.END

198
KERNAL_VIC_04/editor.3

@ -0,0 +1,198 @@
.PAG 'KEYBOARD TABLES'
KEYCOD ;KEYBOARD MODE 'DISPATCH'
.WORD MODE1
.WORD MODE2
.WORD MODE3
.WORD CONTRL ;CONTROL KEYS
;
; COTTACONNA MODE
;
.WORD MODE1 ;PET MODE1
.WORD MODE2 ;PET MODE2
.WORD CCTTA3 ;DUMMY WORD
.WORD CONTRL
;
; EXTENDED KATAKANA MODE
;
.WOR CCTTA2 ;KATAKANA CHARACTERS
.WOR CCTTA3 ;LIMITED GRAPHICS
.WOR CCTTA3 ;DUMMY
.WOR CONTRL
.SKI 5
.PAG 'EDITOR.3'
MODE1
;1,3,5,7,9,+,YEN SIGN,DEL
.BYT $31,$33,$35,$37,$39,$2B,$5C,$14
;LFT.ARROW,W,R,Y,I,P,*,RETURN
.BYT $5F,$57,$52,$59,$49,$50,$2A,$0D
;CTRL,A,D,G,J,L,;,RT CRSR
.BYT $04,$41,$44,$47,$4A,$4C,$3B,$1D
;STOP,L.SHIFT,X,V,N,,,/,CRSR DWN
.BYT $03,1,$58,$56,$4E,$2C,$2F,$11
;SPACE,Z,C,B,M,.,R.SHIFTT,F1
.BYT $20,$5A,$43,$42,$4D,$2E,1,$85
;CO.KEY,S,F,H,K,:,=,F2
.BYT $02,$53,$46,$48,$4B,$3A,$3D,$86
;Q,E,T,U,O,@,EXP,F3
.BYT $51,$45,$54,$55,$4F,$40,$5E,$87
;2,4,6,8,0,-,HOME,F4
.BYT $32,$34,$36,$38,$30,$2D,$13,$88
.BYT $FF ;END OF TABLE NULL
.SKI3
MODE2
;!,%,',),+,YEN,INS
.BYT $21,$23,$25,$27,$29,$DB,$A9,$94
;SHIFTED LFT.ARROW,W,R,Y,I,P,*,RETURN
.BYT $5F,$D7,$D2,$D9,$C9,$D0,$C0,$8D
;CTRL,A,D,G,J,L,;,LF.CRSR
.BYT $04,$C1,$C4,$C7,$CA,$CC,$5D,$9D
;RUN,L.SHIFT,X,V,N,,,/,CRSR DWN
.BYT $83,1,$D8,$D6,$CE,$3C,$3F,$91
;SHIFTED SPACE,Z,C,B,M,.,R.SHIFT,F5
.BYT $A0,$DA,$C3,$C2,$CD,$3E,1,$89
;SHIFTEC CO.KEY ,S,F,H,K,:,=,F6
.BYT $02,$D3,$C6,$C8,$CB,$5B,$3D,$8A
;SHIFTED G,E,T,U,O,@,PI,F7
.BYT $D1,$C5,$D4,$D5,$CF,$BA,$DE,$8B
;",$,&,(,
.BYT $22,$24,$26,$28,$30,$DD,$93,$8C
.BYT $FF ;END OF TABLE NULL
MODE3 ;LEFT WINDOW GRAHPICS
;1,3,5,7,9,+,POUND SIGN,INS
.BYT $21,$23,$25,$27,$29,$A6,$A8,$94
;LFT.ARROW,W,R,Y,I,P,*,RETURN
.BYT $5F,$B3,$B2,$B7,$A2,$AF,$DF,$8D
;CTRL,A,D,G,J,L,;,LF.CRSR
.BYT $04,$B0,$AC,$A5,$B5,$B6,$5D,$9D
; RUN,L.SHIFT,X,V,N,,,/,CRSR.UP
.BYT $83,$01,$BD,$BE,$AA,$3C,$3F,$91
;SPACE,Z,C,B,M,.,R.SHIFT,F2
.BYT $A0,$AD,$BC,$BF,$A7,$3E,$01,$89
;CO.KEY,S,F,H,K,:,=,F4
.BYT $02,$AE,$BB,$B4,$A1,$5B,$3D,$8A
;Q,E,T,U,O,@,PI,F6
.BYT $AB,$B1,$A3,$B8,$B9,$A4,$DE,$8B
;",$,&,(,0,-,HOME,F8
.BYT $22,$24,$26,$28,$30,$DC,$93,$8C
.BYT $FF ;END OF TABLE NULL
CCTTA2 ;WAS CCTTA2 IN JAPANESE VERSION
LOWER
CMP #$0E ;DOES HE WANT LOWER CASE?
BNE UPPER ;BRANCH IF NOT
LDA #2 ;ELSE SET VIC TO POINT TO LOWER CASE
ORA VICREG+5
STA VICREG+5
JMP LOOP2
UPPER
CMP #$8E ;DOES HE WANT UPPER CASE
BNE LOCK ;BRANCH IF NOT
LDA #$FD ;MAKE SURE VIC POINT TO UPPER/PET SET
AND VICREG+5
STA VICREG+5
OUTHRE JMP LOOP2
LOCK
CMP #8 ;DOES HE WANT TO LOCK IN THIS MODE?
BNE UNLOCK ;BRANCH IF NOT
LDA #$80 ;ELSE SET LOCK SWITCH ON
ORA MODE ;DON'T HURT ANYTHING - JUST IN CASE
STA MODE
BMI OUTHRE
UNLOCK
CMP #9 ;DOES HE WANT TO UNLOCK THE KEYBOARD?
BNE OUTHRE ;BRANCH IF NOT
LDA #$7F ;CLEAR THE LOCK SWITCH
AND MODE ;DONT HURT ANYTHING
STA MODE
BPL OUTHRE ;GET OUT
PATCHX
INX ;INDEX TO NEXT LINE
LDA LDTB1,X ;GET HIGH ORDER BYTE OF ADDRESS
ORA #$80 ;MAKE IT A NON-CONTINUATION LINE
STA LDTB1,X ;AND PUT IT BACK
DEX GET BACK TO CURENT LINE
LDA LNMX ;CONTINUE THE BYTES I TOOK OUT
CLC
JMP PATOUT ;AND GO BACK TO THE CODE WE PATCHED
CCTTA3
*=$ED72 ;REMAINDER OF CCTTA3 MUST START HERE
.BYT $04,$FF,$FF,$FF,$FF,$FF,$E2,$9D
;RUN-K24-K31
.BYT $83,$01,$FF,$FF,$FF,$FF,$FF,$91
;K32-K39.F5
.BYT $A0,$FF,$FF,$FF,$FF,$EE,$01,$89
;CO.KEY,K40-K47.F6
.BYT $02,$FF,$FF,$FF,$FF,$E1,$FD,$8A
;K48-K55
.BYT $FF,$FF,$FF,$FF,$FF,$B0,$E0,$8B
;K56-K63
.BYT $F2,$F4,$F6,$FF,$F0,$ED,$93,$8C
.BYT $FF ;END OF TABLE NULL
CONTRL
;BLACK,RED,PURPLE,BLUE,RVS ,NULL,NULL,NULL
.BYT $90,$1C,$9C,$1F,$12,$FF,$FF,$FF
;NULL,NULL,REVERSE,NULL,NULL,NULL,NULL,NULL
.BYT $FF,$FF,$12,$FF,$FF,$FF,$FF,$FF
;FIVE LINES OF NULLS
.BYT $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
.BYT $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
.BYT $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
.BYT $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
.BYT $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
;WHITE,CYAN,GREEN,YELLOW,RVS OFF,NULL,NULL,NULL
.BYT $05,$9F,$1E,$9E,$92,$FF,$FF,$FF
.BYT $FF ;END OF TABLE NULL
TVIC
.BYT $05,$19,$16,$2E,$0,$C0,$0,0
.BYT 0,0,0,0,0,0,0,$1B
;
RUNTB .BYT 'LOAD',$D,'RUN',$D
;
LINZ0 = VICSCN
LINZ1 = LINZ0+LLEN
LINZ2 = LINZ1+LLEN
LINZ3 = LINZ2+LLEN
LINZ4 = LINZ3+LLEN
LINZ5 = LINZ4+LLEN
LINZ6 = LINZ5+LLEN
LINZ7 = LINZ6+LLEN
LINZ8 = LINZ7+LLEN
LINZ9 = LINZ8+LLEN
LINZ10 = LINZ9+LLEN
LINZ11 = LINZ10+LLEN
LINZ12 = LINZ11+LLEN
LINZ13 = LINZ12+LLEN
LINZ14 = LINZ13+LLEN
LINZ15 = LINZ14+LLEN
LINZ16 = LINZ15+LLEN
LINZ17 = LINZ16+LLEN
LINZ18 = LINZ17+LLEN
LINZ19 = LINZ18+LLEN
LINZ20 = LINZ19+LLEN
LINZ21 = LINZ20+LLEN
LINZ22 = LINZ21+LLEN
;****** SCREEN LINES LO BYTE TABLE ******
LDTB2
.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
.END

63
KERNAL_VIC_04/errorhandler

@ -0,0 +1,63 @@
.PAG 'ERROR HANDLER'
;***************************************
;* STOP -- CHECK STOP KEY FLAG AND *
;* RETURN Z FLAG SET IF FLAG TRUE. *
;* ALSO CLOSES ACTIVE CHANNELS AND *
;* FLUSHES KEYBOARD QUEUE. *
;* ALSO RETURNS KEY DOWNS FROM LAST *
;* KEYBOARD ROW IN .A. *
;***************************************
NSTOP LDA STKEY ;VALUE OF LAST ROW
CMP #$FE ;CHECK STOP KEY POSITION
BNE STOP2 ;NOT DOWN
PHP
JSR CLRCH ;CLEAR CHANNELS
STA NDX ;FLUSH QUEUE
PLP
STOP2 RTS
.SKI 5
;************************************
;* *
;* ERROR HANDLER *
;* *
;* PRINTS KERNAL ERROR MESSAGE IF *
;* BIT 6 OF MSGFLG SET. RETURNS *
;* WITH ERROR # IN .A AND CARRY. *
;* *
;************************************
;
ERROR1 LDA #1 ;TOO MANY FILES
.BYT $2C
ERROR2 LDA #2 ;FILE OPEN
.BYT $2C
ERROR3 LDA #3 ;FILE NOT OPEN
.BYT $2C
ERROR4 LDA #4 ;FILE NOT FOUND
.BYT $2C
ERROR5 LDA #5 ;DEVICE NOT PRESENT
.BYT $2C
ERROR6 LDA #6 ;NOT INPUT FILE
.BYT $2C
ERROR7 LDA #7 ;NOT OUTPUT FILE
.BYT $2C
ERROR8 LDA #8 ;MISSING FILE NAME
.BYT $2C
ERROR9 LDA #9 ;BAD DEVICE #
;
PHA ;ERROR NUMBER ON STACK
JSR CLRCH ;RESTORE I/O CHANNELS
;
LDY #MS1-MS1
BIT MSGFLG ;ARE WE PRINTING ERROR?
BVC EREXIT ;NO...
;
JSR MSG ;PRINT "CBM I/O ERROR #"
PLA
PHA
ORA #$30 ;MAKE ERROR # ASCII
JSR BSOUT ;PRINT IT
;
EREXIT PLA
SEC
RTS
.END

259
KERNAL_VIC_04/init

@ -0,0 +1,259 @@
.PAGE 'INITIALIZATION'
; START - SYSTEM RESET
; WILL GOTO ROM AT $A000...
; IF LOCS $A004-$A008
; = 'A0CBM'
; ^^^> THESE HAVE MSB SET
; KERNAL EXPECTS...
; $A000- .WORD INITILIZE (HARD START)
; $A002- .WORD PANIC (WARM START)
; ... ELSE BASIC SYSTEM USED
START LDX #$FF
SEI
TXS
CLD
JSR A0INT ;TEST FOR $A0 ROM IN
BNE START1
JMP ($A000) ; GO INIT AS $A000 ROM WANTS
START1 JSR RAMTAS ;GO RAM TEST AND SET
JSR RESTOR ;GO SET UP OS VECTORS
JSR IOINIT ;GO INITILIZE I/O DEVICES
JSR CINT ;GO INITILIZE SCREEN
CLI ;INTERRUPTS OKAY NOW
JMP ($C000) ;GO TO BASIC SYSTEM
.SKI 4
; A0INT - TEST FOR AN $A000 ROM
; RETURNS Z - $A000 IN
;
A0INT LDX #TBLA0E-TBLA0R ;CHECK FOR $A000
A0IN1 LDA TBLA0R-1,X
CMP $A004-1,X
BNE A0IN2
DEX
BNE A0IN1
A0IN2 RTS
;
TBLA0R .BYT 'A0',$C3,$C2,$CD ;..A0CBM..
TBLA0E
.SKI 4
; RESTOR - SET KERNAL INDIRECTS AND VECTORS (SYSTEM)
;
RESTOR LDX #<VECTSS
LDY #>VECTSS
CLC
;
; VECTOR - SET KERNAL INDIRECT AND VECTORS (USER)
;
VECTOR STX TMP2
STY TMP2+1
LDY #VECTSE-VECTSS-1
MOVOS1 LDA CINV,Y ;GET FROM STORAGE
BCS MOVOS2 ;C...WANT STORAGE TO USER
LDA (TMP2)Y ;...WANT USER TO STORAGE
MOVOS2 STA (TMP2)Y ;PUT IN USER
STA CINV,Y ;PUT IN STORAGE
DEY
BPL MOVOS1
RTS
;
VECTSS .WOR KEY,TIMB,NNMI
.WOR NOPEN,NCLOSE,NCHKIN
.WOR NCKOUT,NCLRCH,NBASIN
.WOR NBSOUT,NSTOP,NGETIN
.WOR NCLALL,TIMB ;GOTO BREAK ON A USRCMD JMP
.WOR NLOAD,NSAVE
VECTSE
.PAGE 'INITILIZE CODE'
; RAMTAS - MEMORY SIZE CHECK AND SET
;
RAMTAS LDA #0 ;ZERO LOW MEMORY
TAX ;START AT 00
RAMTZ0 STA $00,X ;ZERO PAGE
STA $200,X ;USER BUFFERS AND VARS
STA $300,X ;SYSTEM SPACE AND USER SPACE
INX
BNE RAMTZ0
;
;ALLOCATE TAPE BUFFERS
;
LDX #<TBUFFR
LDY #>TBUFFR
STX TAPE1
STY TAPE1+1
;
; SET TOP AND BOTTOM OF MEMORY
;
RAMTBT STA TMP0 ;SET LOW INITAL INDEX
STA XSAV ;SET TOP/BOTTOM FLAG
STA MEMSTR ;SET LOW BOTTOM ON A PAGE
TAY ;MOVE ZERO TO .Y
LDA #4 ;SET HIGH INITAL INDEX
STA TMP0+1
;
RAMTZ1 INC TMP0 ;MOVE INDEX THRU MEMORY
BNE RAMTZ2
INC TMP0+1
;
RAMTZ2 JSR CHKMEM ;GO CHECK
LDA XSAV ;TOP/BOTTOM CHECK...
BEQ RAMTZ5 ;...BOTTOM
;
BCS RAMTZ1 ;TOP & STILL GOOD
LDY TMP0+1 ;ELSE FOUND BAD
LDX TMP0
CPY #$20 ;CHECK IF MEMORY GOOD
BCC BADRAM ;NO...BAD SYSTEM RAM
CPY #$21 ;CHECK FOR SCREEN LOCATION
BCS RAMTZ4 ;SCREEN TO BOTTOM
LDY #$1E ;SCREEN TO TOP
STY HIBASE ;SET SYSTEM SCREEN BASE
RAMTZ3 JMP SETTOP ;GO SET TOP OF SYSTEM MEMORY
;
RAMTZ4 LDA #$12 ;SET NEW BOTTOM
STA MEMSTR+1
LDA #$10 ;SCREEN TO BOTTOM
STA HIBASE
BNE RAMTZ3 ;JMP & SAVE A BYTE
;
RAMTZ5 BCC RAMTZ1 ;BOTTOM & STILL BAD
LDA TMP0+1 ;DO THIS WAY SO .Y STILL GOOD
STA MEMSTR+1 ;SET BOTTOM
STA XSAV ;FLAG TO TOP
CMP #$11
BCC RAMTZ1 ;GO FIND TOP IF SYSTEM RAM IS GOOD
;
BADRAM JSR INITV ;INITILIZE VIC RAM IS BAD
JMP BADRAM
.SKI 3
BSIT .WOR WRTZ,WRTN,KEY,READ ;TABLE OF INDIRECTS FOR CASSETTE IRQ'S
.PAG 'INITILIZE CODE'
; IOINIT - INITILIZE IO DEVICES
;
IOINIT LDA #$7F ;KILL IERS
STA D1IER
STA D2IER
LDA #%01000000 ;FREE RUNNING T1 D2
STA D2ACR
LDA #%01000000 ;FREE RUNNING T1 T2 ONESHOT D1
STA D1ACR
LDA #%11111110 ;D1 CA2 HIGH,CB2 HIGH,CA1 NEG,CB1 POS
STA D1PCR
LDA #%11011110 ;D2 CA2 HIGH,CB2 LOW,CA1 NEG,CB1 POS
STA D2PCR
LDX #$00
STX D1DDRB ;USER PORT (NO RS-232)
LDX #%11111111
STX D2DDRB ;KEYBOARD COLS ARE OUTPUTS
LDX #$00
STX D2DDRA ;KEYBOARD ROWS ARE INPUTS
LDX #%10000000 ;SCLK SDATA 4JOY CASSW SATN
STX D1DDRA ;...CASS MOTOR, CASS SWITCH, ACK
LDX #%00000000 ;SATN LOW
STX D1ORA
JSR CLKHI ;CLKHI TO RELEASE SERIAL DEVICE
LDA #$82 ;ENABLE PANIC BUTTON
STA D1IER
JSR CLKLO ;CLKLO TO RESTORE CLOCK LINE
;
IOKEYS LDA #$C0 ;ENABLE T1 INTERRUPTS
STA D2IER
LDA #<SIXTY ;...AT 60 HZ RATE
STA D2T1L
LDA #>SIXTY
STA D2T1H
RTS
;
; SIXTY HERTZ VALUE
;
SIXTY = 17033
.PAGE 'INIT - SYS SUBS'
SETNAM STA FNLEN
STX FNADR
STY FNADR+1
RTS
.SKI 5
SETLFS STA LA
STX FA
STY SA
RTS
.SKI 5
READSS LDA FA ;SEE WHICH DEVICES' TO READ
CMP #2 ;IS IT RS-232?
BNE READST ;NO...READ SERIAL/CASS
LDA RSSTAT ;YES...GET RS-232 UP
LDA #00 ;CLEAR RS232 STATUS WHEN READ
STA RSSTAT
RTS
SETMSG STA MSGFLG
READST LDA STATUS
UDST ORA STATUS
STA STATUS
RTS
.SKI 5
SETTMO STA TIMOUT
RTS
.SKI 5
MEMTOP BCC SETTOP
;
;CARRY SET--READ TOP OF MEMORY
;
GETTOP LDX MEMSIZ
LDY MEMSIZ+1
;
;CARRY CLEAR--SET TOP OF MEMORY
;
SETTOP STX MEMSIZ
STY MEMSIZ+1
RTS
.SKI 5
;MANAGE BOTTOM OF MEMORY
;
MEMBOT BCC SETBOT
;
;CARRY SET--READ BOTTOM OF MEMORY
;
LDX MEMSTR
LDY MEMSTR+1
;
;CARRY CLEAR--SET BOTTOM OF MEMORY
;
SETBOT STX MEMSTR
STY MEMSTR+1
RTS
.SKI 5
;********************************
;
; C H E C K M E M O R Y
;
; CHECK FOR THE EXISTENCE OF
; RAM AT THE LOCATION SPECIFIED
; IN TMP0
;
; C=0 IF THERE IS NO RAM AT TMP0
; C=1 IF THERE IS RAM AT TMP0
;
; (TMP0) IS PRESERVED
;*******************************
;
CHKMEM LDA (TMP0)Y
TAX ;SAVE BYTE AT TEST LOCATION
LDA #$55 ;TEST ALL BITS
STA (TMP0)Y
CMP (TMP0)Y ;DO THEY MATCH
BNE NOMEM ;BRANCH IF NOT
ROR A ;TRY THE OTHER BITS
STA (TMP0)Y
CMP (TMP0)Y ;DO THEY MATCH
BNE NOMEM ;BRANCH IF NOT
.BYT $A9 ;CARRY IS SET SO SKIP
NOMEM CLC ;NO RAM FLAG
TXA ;RESTORE IN CASE OF RAM
STA (TMP0)Y
RTS
.END
; RSR 8/5/80 CHANGE IO STRUCTURE
; RSR 8/15/80 ADD MEMORY TEST
; RSR 8/21/80 CHANGE I/O FOR MOD
; RSR 8/25/80 CHANGE I/O FOR MOD2
; RSR 8/29/80 CHANGE RAMTEST FOR HARDWARE MISTAKE
; RSR 9/22/80 CHANGE SO RAM HANG RS232 STATUS READ

15
KERNAL_VIC_04/irqfile

@ -0,0 +1,15 @@
.PAGE 'IRQFILE - DISPATCHER'
; PULS - CHECKS FOR REAL IRQ'S OR BREAKS
;
PULS PHA
TXA
PHA
TYA
PHA
TSX
LDA $104,X ;GET OLD P STATUS
AND #$10 ;BREAK FLAG?
BEQ PULS1 ;...NO
JMP (CBINV) ;...YES...BREAK INSTR
PULS1 JMP (CINV) ;...IRQ
.END

30
KERNAL_VIC_04/kernal

@ -0,0 +1,30 @@
.LIB DISCLAIMER
.LIB DECLARE
*=$E500 ;START OF VIXEN KERNAL
.LIB EDITOR.1
.LIB CONKAT
.LIB EDITOR.2
.LIB EDITOR.3
.LIB SERIAL2.1
.LIB RS232TRANS
.LIB RS232RCVR
.LIB RS232INOUT
.LIB MESSAGES
.LIB CHANNELIO
.LIB OPENCHANNEL
.LIB CLOSE
.LIB CLALL
.LIB OPEN
.LIB LOAD
.LIB SAVE
.LIB TIME
.LIB ERRORHANDLER
.LIB TAPEFILE
.LIB TAPECONTROL
.LIB READ
.LIB WRITE
.LIB INIT
.LIB RS232NMIFILE
.LIB IRQFILE
.LIB VECTORS
.END

238
KERNAL_VIC_04/load

@ -0,0 +1,238 @@
.PAG 'LOAD FUNCTION'
;**********************************
;* LOAD RAM FUNCTION *
;* *
;* LOADS FROM CASSETTE 1 OR 2, OR *
;* SERIAL BUS DEVICES >=4 TO 31 *
;* AS DETERMINED BY CONTENTS OF *
;* VARIABLE FA. VERIFY FLAG IN .A *
;* *
;* ALT LOAD IF SA=0, NORMAL SA=1 *
;* .X , .Y LOAD ADDRESS IF SA=0 *
;* .A=0 PERFORMS LOAD,<> IS VERIFY*
;* *
;* HIGH LOAD RETURN IN X,Y. *
;* *
;**********************************
.SKI 3
LOADSP STX MEMUSS ;.X HAS LOW ALT START
STY MEMUSS+1
LOAD JMP (ILOAD) ;MONITOR LOAD ENTRY
;
NLOAD STA VERCK ;STORE VERIFY FLAG
LDA #0
STA STATUS
;
LDA FA ;CHECK DEVICE NUMBER
BNE LD20
;
LD10 JMP ERROR9 ;BAD DEVICE #-KEYBOARD
;
LD20 CMP #3
BEQ LD10 ;DISALLOW SCREEN LOAD
BCC LD100 ;HANDLE TAPES DIFFERENT
;
;LOAD FROM CBM IEEE DEVICE
;
LDY FNLEN ;MUST HAVE FILE NAME
BNE LD25 ;YES...OK
;
JMP ERROR8 ;MISSING FILE NAME
;
LD25 JSR PATCH2 ;TELL USER LOOKING
LDA #$60 ;SPECIAL LOAD COMMAND
STA SA
JSR OPENI ;OPEN THE FILE
;
LDA FA
JSR TALK ;ESTABLISH THE CHANNEL
LDA SA
JSR TKSA ;TELL IT TO LOAD
;
JSR ACPTR ;GET FIRST BYTE
STA EAL
;
LDA STATUS ;TEST STATUS FOR ERROR
LSR A
LSR A
BCS LD90 ;FILE NOT FOUND...
JSR ACPTR
STA EAH
;
JSR PATCH3 ;TELL USER LOADING
;
;
LD40 LDA #$FD ;MASK OFF TIMEOUT
AND STATUS
STA STATUS
;
JSR STOP ;STOP KEY?
BNE LD45 ;NO...
;
JMP BREAK ;STOP KEY PRESSED
;
LD45 JSR ACPTR ;GET BYTE OFF IEEE
TAX
LDA STATUS ;WAS THERE A TIMEOUT?
LSR A
LSR A
BCS LD40 ;YES...TRY AGAIN
TXA
LDY VERCK ;PERFORMING VERIFY?
BEQ LD50 ;NO...LOAD
LDY #0
CMP (EAL)Y ;VERIFY IT
BEQ LD60 ;O.K....
LDA #SPERR ;NO GOOD...VERIFY ERROR
JSR UDST ;UPDATE STATUS
.BYT $2C ;SKIP NEXT STORE
;
LD50 STA (EAL)Y
LD60 INC EAL ;INCREMENT STORE ADDR
BNE LD64
INC EAH
LD64 BIT STATUS ;EOI?
BVC LD40 ;NO...CONTINUE LOAD
;
JSR UNTLK ;CLOSE CHANNEL
JSR CLSEI ;CLOSE THE FILE
BCC LD180 ;BRANCH ALWAYS
;
LD90 JMP ERROR4 ;FILE NOT FOUND
;
;LOAD FROM TAPE
;
LD100 CMP #2
BNE LD102
;
JMP RS232
;
LD102 JSR ZZZ ;SET POINTERS AT TAPE
BCS LD104
JMP ERROR9 ;DEALLOCATED...
LD104 JSR CSTE1 ;TELL USER ABOUT BUTTONS
BCS LD190 ;STOP KEY PRESSED?
JSR LUKING ;TELL USER SEARCHING
;
LD112 LDA FNLEN ;IS THERE A NAME?
BEQ LD150 ;NONE...LOAD ANYTHING
JSR FAF ;FIND A FILE ON TAPE
BCC LD170 ;GOT IT!
BEQ LD190 ;STOP KEY PRESSED
BCS LD90 ;NOPE...END OF TAPE
;
LD150 JSR FAH ;FIND ANY HEADER
BEQ LD190 ;STOP KEY PRESSED
BCS LD90 ;NO HEADER
;
LD170 LDA STATUS
AND #SPERR ;MUST GOT HEADER RIGHT
SEC
BNE LD190 ;IS BAD
;
CPX #BLF ;IS IT A MOVABLE PROGRAM...
BEQ LD178 ;YES
;
CPX #PLF ;IS IT A PROGRAM
BNE LD112 ;NO...ITS SOMETHING ELSE
;
LD177 LDY #1 ;FIXED LOAD...
LDA (TAPE1)Y ;...THE ADDRESS IN THE...
STA MEMUSS ;...BUFFER IS THE START ADDRESS
INY
LDA (TAPE1)Y
STA MEMUSS+1
BCS LD179 ;JMP ..CARRY SET BY CPX'S
;
LD178 LDA SA ;CHECK FOR MONITOR LOAD...
BNE LD177 ;...YES WE WANT FIXED TYPE
;
LD179 LDY #3 ;TAPEA - TAPESTA
;CARRY SET BY CPX'S
LDA (TAPE1)Y
LDY #1
SBC (TAPE1)Y
TAX ;LOW TO .X
LDY #4
LDA (TAPE1)Y
LDY #2
SBC (TAPE1)Y
TAY ;HIGH TO .Y
;
CLC ;EA = STA+(TAPEA-TAPESTA)
TXA
ADC MEMUSS ;
STA EAL
TYA
ADC MEMUSS+1
STA EAH
LDA MEMUSS ;SET UP STARTING ADDRESS
STA STAL
LDA MEMUSS+1
STA STAH
JSR LODING ;TELL USER LOADING
JSR TRD ;DO TAPE BLOCK LOAD
.BYT $24 ;CARRY FROM TRD
;
LD180 CLC ;GOOD EXIT
;
; SET UP END LOAD ADDRESS
;
LDX EAL
LDY EAH
;
LD190 RTS
.SKI 5
;SUBROUTINE TO PRINT TO CONSOLE:
;
;SEARCHING [FOR NAME]
;
LUKING LDA MSGFLG ;SUPPOSED TO PRINT?
BPL LD115 ;...NO
LDY #MS5-MS1 ;"SEARCHING"
JSR MSG
LDA FNLEN
BEQ LD115
LDY #MS6-MS1 ;"FOR"
JSR MSG
.SKI 3
;SUBROUTINE TO OUTPUT FILE NAME
;
OUTFN LDY FNLEN ;IS THERE A NAME?
BEQ LD115 ;NO...DONE
LDY #0
LD110 LDA (FNADR)Y
JSR BSOUT
INY
CPY FNLEN
BNE LD110
;
LD115 RTS
.SKI 3
;SUBROUTINE TO PRINT:
;
;LOADING/VERIFING
;
LODING LDY #MS10-MS1 ;ASSUME 'LOADING'
LDA VERCK ;CHECK FLAG
BEQ LD410 ;ARE DOING LOAD
LDY #MS21-MS1 ;ARE 'VERIFYING'
LD410 JMP SPMSG
SKIPBY = *
;
; PATCHES FOR DISK AUTO-OFFSET LOAD
;
*=KSP2 ;KERNAL SPACE FOR PATCH 2
PATCH2 LDX SA ;SAVE SA IN .X
JMP LUKING ;GO TELL USER
PATCH3 TXA ;FIND OUT HOW TO LOAD
BNE PATCH4 ;USE PROGRAMS LOAD ADDRESS
LDA MEMUSS ;ELSE MOVE WHERE I WANT
STA EAL
LDA MEMUSS+1
STA EAH
PATCH4 JMP LODING ;TELL USER LOADING
;
KSP3 = * ;KERNAL SPACE FOR PATCH 3
*=SKIPBY
.END

29
KERNAL_VIC_04/messages

@ -0,0 +1,29 @@
.PAG 'MESSAGES'
MS1 .BYT $D,'I/O ERROR ',$A3
MS5 .BYT $D,'SEARCHING',$A0
MS6 .BYT 'FOR',$A0
MS7 .BYT $D,'PRESS PLAY ON TAP',$C5
MS8 .BYT 'PRESS RECORD & PLAY ON TAP',$C5
MS10 .BYT $D,'LOADIN',$C7
MS11 .BYT $D,'SAVING',$A0
MS21 .BYT $D,'VERIFYIN',$C7
MS17 .BYT $D,'FOUND',$A0
MS18 .BYT $D,'OK',$8D
; MS34 .BYT $D,'MONITOR',$8D
; MS36 .BYT $D,'BREA',$CB
.SKI 5
;PRINT MESSAGE TO SCREEN ONLY IF
;OUTPUT ENABLED
;
SPMSG BIT MSGFLG ;PRINTING MESSAGES?
BPL MSG10 ;NO...
MSG LDA MS1,Y
PHP
AND #$7F
JSR BSOUT
INY
PLP
BPL MSG
MSG10 CLC
RTS
.END

259
KERNAL_VIC_04/open

@ -0,0 +1,259 @@
.PAG 'OPEN FILE'
;***********************************
;* *
;* OPEN FUNCTION *
;* *
;* CREATES AN ENTRY IN THE LOGICAL *
;* FILES TABLES CONSISTING OF *
;* LOGICAL FILE NUMBER--LA, DEVICE *
;* NUMBER--FA, AND SECONDARY CMD-- *
;* SA. *
;* *
;* A FILE NAME DESCRIPTOR, FNADR & *
;* FNLEN ARE PASSED TO THIS ROUTINE*
;* *
;***********************************
;
NOPEN LDX LA ;CHECK FILE #
BNE OP98 ;IS NOT THE KEYBOARD
;
JMP ERROR6 ;NOT INPUT FILE...
;
OP98 JSR LOOKUP ;SEE IF IN TABLE
BNE OP100 ;NOT FOUND...O.K.
;
JMP ERROR2 ;FILE OPEN
;
OP100 LDX LDTND ;LOGICAL DEVICE TABLE END
CPX #10 ;MAXIMUM # OF OPEN FILES
BCC OP110 ;LESS THAN 10...O.K.
;
JMP ERROR1 ;TOO MANY FILES
;
OP110 INC LDTND ;NEW FILE
LDA LA
STA LAT,X ;STORE LOGICAL FILE #
LDA SA
ORA #$60 ;MAKE SA AN SERIAL COMMAND
STA SA
STA SAT,X ;STORE COMMAND #
LDA FA
STA FAT,X ;STORE DEVICE #
;
;PERFORM DEVICE SPECIFIC OPEN TASKS
;
BEQ OP175 ;IS KEYBOARD...DONE.
CMP #3
BEQ OP175 ;IS SCREEN...DONE.
BCC OP150 ;ARE CASSETTES 1 & 2
;
JSR OPENI ;IS ON SERIAL...OPEN IT
BCC OP175 ;BRANCH ALWAYS...DONE
;
;PERFORM TAPE OPEN STUFF
;
OP150 CMP #2
BNE OP152
;
JMP OPN232
;
OP152 JSR ZZZ ;SEE IF TAPE BUFFER
BCS OP155 ;YES
;
JMP ERROR9 ;NO...DEALLOCATED
;
OP155 LDA SA
AND #$F ;MASK OFF COMMAND
BNE OP200 ;NON ZERO IS TAPE WRITE
;
;OPEN CASSETE TAPE FILE TO READ
;
JSR CSTE1 ;TELL "PRESS PLAY"
BCS OP180 ;STOP KEY PRESSED
;
JSR LUKING ;TELL USER "SEARCHING"
;
LDA FNLEN
BEQ OP170 ;LOOKING FOR ANY FILE
;
JSR FAF ;LOOKING FOR NAMED FILE
BCC OP171 ;FOUND IT!!!
BEQ OP180 ;STOP KEY PRESSED
;
OP160 JMP ERROR4 ;FILE NOT FOUND
;
OP170 JSR FAH ;GET ANY OLD HEADER
BEQ OP180 ;STOP KEY PRESSED
BCC OP171 ;ALL O.K.
BCS OP160 ;FILE NOT FOUND...
;
;OPEN CASSETTE TAPE FOR WRITE
;
OP200 JSR CSTE2 ;TELL "PRESS PLAY AND RECORD"
BCS OP180 ;STOP KEY PRESSED
LDA #BDFH ;DATA FILE HEADER TYPE
JSR TAPEH ;WRITE IT
;
;FINISH OPEN FOR TAPE READ/WRITE
;
OP171 LDA #BUFSZ-1 ;ASSUME FORCE READ
;
LDY SA
CPY #$60 ;OPEN FOR READ?
BEQ OP172
;
;SET POINTERS FOR BUFFERING DATA
;
LDY #0
LDA #BDF ;TYPE FLAG FOR BLOCK
STA (TAPE1)Y ;TO BEGIN OF BUFFER
TYA
;
OP172 STA BUFPT ;POINT TO DATA
OP175 CLC ;FLAG GOOD OPEN
OP180 RTS ;EXIT IN PEACE
.SKI 5
OPENI LDA SA
BMI OP50 ;NO SA...DONE
;
LDY FNLEN
BEQ OP50 ;NO FILE NAME...DONE
;
LDA FA
JSR LISTN ;DEVICE LA TO LISTEN
;
LDA SA
ORA #$F0
JSR SECND
;
LDA STATUS ;ANYBODY HOME?
BPL OP35 ;YES...CONTINUE
;
;THIS ROUTINE IS CALLED BY OTHER
;KERNAL ROUTINES WHICH ARE CALLED
;DIRECTLY BY OS. KILL RETURN
;ADDRESS TO RETURN TO OS.
;
PLA
PLA
JMP ERROR5 ;DEVICE NOT PRESENT
;
OP35 LDA FNLEN
BEQ OP45 ;NO NAME...DONE SEQUENCE
;
;SEND FILE NAME OVER SERIAL
;
LDY #0
OP40 LDA (FNADR)Y
JSR CIOUT
INY
CPY FNLEN
BNE OP40
;
OP45 JSR UNLSN
;
OP50 CLC ;NO ERROR
RTS
.PAGE 'OPEN RS232 FILE'
; OPN232 - OPEN AN RS-232 OR PARALLEL PORT FILE
;
; VARIABLES INITILIZED
; BITNUM - # OF BITS TO BE SENT CALC FROM M51CTR
; BAUDOF - BAUD RATE FULL
; RSSTAT - RS-232 STATUS REG
; M51CTR - 6551 CONTROL REG
; M51CDR - 6551 COMMAND REG
; M51AJB - USER TIME ####NOT IMPLEMENTED###
;
OPN232
;
; SET UP DDRB AND CB2 FOR RS-232
;
LDA #%00000110 ;DDRB
STA D1DDRB
STA D1ORB ;DTR,RTS HIGH
LDA #%11101110 ;CASS OFF,TR MARK,CB1 HTL
STA D1PCR
;
; PASS PRAMS TO M51REGS
LDY #00
STY RSSTAT ;CLEAR STATUS
;
OPN020 CPY FNLEN ;CHECK IF AT END OF FILENAME
BEQ OPN025 ;YES...
;
LDA (FNADR)Y ;MOVE DATA
STA M51CTR,Y ;TO M51REGS
INY
CPY #4 ;ONLY 4 POSSIBLE PRAMS
BNE OPN020
;
; CALC # OF BITS
;
OPN025 JSR BITCNT
STX BITNUM
;
; CALC BAUD RATE
;
LDA M51CTR
AND #$0F
BNE OPN010
;
; GET BAUD RATE FROM ELSE WHERE ###NEED CODE###
;
OPN010 ASL A ;GET INDEX INTO BAUDO
TAX
LDA BAUDO-2,X
ASL A ;BAUDO*2+200 IS RATE
TAY
LDA BAUDO-1,X
ROL A
PHA
TYA
ADC #CBIT+CBIT ;TABLE HAS CB1 ADJST OFFSET
STA BAUDOF
PLA
ADC #0 ;GET CARRY IN
STA BAUDOF+1
;
; CHECK FOR 3/X LINE RESPONSE
;
OPN030 LDA M51CDR ;BIT 0 OF M51CDR
LSR A
BCC OPN050 ;...3 LINE
;
; CHECK FOR X LINE PROPER STATES
;
LDA D2ORB
ASL A
BCS OPN050
JMP DSRERR ;NO DATA SET
;
; SET UP BUFFER POINTERS (DBE=DBS)
;
OPN050 LDA RIDBE
STA RIDBS
LDA RODBE
STA RODBS
;
; ALLOCATE BUFFERS
;
OPN055 JSR GETTOP ;GET MEMSIZ
LDA RIBUF+1 ;IN ALLOCATION...
BNE OPN060 ;ALREADY
DEY ;THERE GOES 256 BYTES
STY RIBUF+1
STX RIBUF
OPN060 LDA ROBUF+1 ;OUT ALLOCATION...
BNE MEMTCF ;ALREAY
DEY ;THERE GOES 256 BYTES
STY ROBUF+1
STX ROBUF
MEMTCF SEC ;SIGNAL TOP OF MEMORY CHANGE
LDA #$F0
JMP SETTOP ;TOP CHANGED
.END
; RSR 8/25/80 ADD RS-232 CODE
; RSR 8/26/80 TOP OF MEMORY HANDLER
; RSR 8/29/80 ADD FILENAME TO M51REGS
; RSR 9/2/80 FIX ORDERING OF RS-232 ROUTINES

135
KERNAL_VIC_04/openchannel

@ -0,0 +1,135 @@
.PAG 'OPEN CHANNEL'
;***************************************
;* 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
;
LDA FA
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 ;RS232?
BNE JX315 ;NO...
;
JMP CKI232
;
;SOME EXTRA CHECKS FOR TAPE
;
JX315 LDX SA
CPX #$60 ;IS COMMAND A READ?
BEQ JX320 ;YES...O.K....DONE
;
JMP ERROR6 ;NOT INPUT FILE
;
JX320 STA DFLTN ;ALL INPUT COME FROM HERE
;
CLC ;GOOD EXIT
RTS
;
;AN SERIAL DEVICE HAS TO BE A TALKER
;
JX330 TAX ;DEVICE # FOR DFLTO
JSR TALK ;TELL HIM TO TALK
;
LDA SA ;A SECOND?
BPL JX340 ;YES...SEND IT
JSR TKATN ;NO...LET GO
JMP JX350
;
JX340 JSR TKSA ;SEND SECOND
;
JX350 TXA
BIT STATUS ;DID HE LISTEN?
BPL JX320 ;YES
;
JMP ERROR5 ;DEVICE NOT PRESENT
.PAG 'OPEN CHANNEL OUT'
;***************************************
;* 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
;
LDA FA ;IS IT KEYBOARD?
BNE CK10 ;NO...SOMETHING ELSE.
;
CK20 JMP ERROR7 ;YES...NOT OUTPUT FILE
;
;COULD BE SCREEN,SERIAL,OR TAPES
;
CK10 CMP #3
BEQ CK30 ;IS SCREEN...DONE
BCS CK40 ;IS SERIAL...ADDRESS IT
CMP #2 ;RS232?
BNE CK15
;
JMP CKO232
;
;
;SPECIAL TAPE CHANNEL HANDLING
;
CK15 LDX SA
CPX #$60 ;IS COMMAND READ?
BEQ CK20 ;YES...ERROR
;
CK30 STA DFLTO ;ALL OUTPUT GOES HERE
;
CLC ;GOOD EXIT
RTS
;
CK40 TAX ;SAVE DEVICE FOR DFLTO
JSR LISTN ;TELL HIM TO LISTEN
;
LDA SA ;IS THERE A SECOND?
BPL CK50 ;YES...
;
JSR SCATN ;NO...RELEASE LINES
BNE CK60 ;BRANCH ALWAYS
;
CK50 JSR SECND ;SEND SECOND...
;
CK60 TXA
BIT STATUS ;DID HE LISTEN?
BPL CK30 ;YES...FINISH UP
;
JMP ERROR5 ;NO...DEVICE NOT PRESENT
.END

388
KERNAL_VIC_04/read

@ -0,0 +1,388 @@
.PAGE 'CASSETTE READ'
; VARIABLES USED IN CASSETTE READ ROUTINES
;
; REZ - COUNTS ZEROS (IF Z THEN CORRECT # OF DIPOLES)
; RER - FLAGS ERRORS (IF Z THEN NO ERROR)
; DIFF - USED TO PRESERVE SYNO (OUTSIDE OF BIT ROUTINES)
; SYNO - FLAGS IF WE HAVE BLOCK SYNC (16 ZERO DIPOLES)
; SNSW1 - FLAGS IF WE HAVE BYTE SYNC (A LONGLONG)
; DATA - HOLDS MOST RECENT DIPOLE BIT VALUE
; MYCH - HOLDS INPUT BYTE BEING BUILT
; FIRT - USED TO INDICATE WHICH HALF OF DIPOLE WE'RE IN
; SVXT - TEMP USED TO ADJUST SOFTWARE SERVO
; TEMP - USED TO HOLD DIPOLE TIME DURING TYPE CALCULATIONS
; PRTY - HOLDS CURRENT CALCULATED PARITY BIT
; PRP - HAS COMBINED ERROR VALUES FROM BIT ROUTINES
; FSBLK - INDICATE WHICH BLOCK WE'RE LOOKING AT (0 TO EXIT)
; SHCNL - HOLDS FSBLK, USED TO DIRECT ROUTINES, BECAUSE OF EXIT CASE
; RDFLG - HOLDS FUNCTION MODE
; MI - WAITING FOR BLOCK SYNC
; VS - IN DATA BLOCK READING DATA
; NE - WAITING FOR BYTE SYNC
; SAL - INDIRECT TO DATA STORAGE AREA
; SHCNH - LEFT OVER FROM DEBUGGING
; BAD - STORAGE SPACE FOR BAD READ LOCATIONS (BOTTOM OF STACK)
; PTR1 - COUNT OF READ LOCATIONS IN ERROR (POINTER INTO BAD, MAX 61)
; PTR2 - COUNT OF RE-READ LOCATIONS (POINTER INTO BAD, DURING RE-READ)
; VERCHK - VERIFY OR LOAD FLAG (Z - LOADING)
;
.PAG 'CASSETTE READ'
READ LDX D2T2H ;GET TIME SINCE LAST INTERRUPT
LDY #$FF ;COMPUTE COUNTER DIFFERENCE
TYA
SBC D2T2L
CPX D2T2H ;CHECK FOR TIMER HIGH ROLLOVER...
BNE READ ;...YES THEN RECOMPUTE
STX TEMP
TAX
STY D2T2L ;RELOAD TIMER2 (COUNT DOWN FROM $FFFF)
STY D2T2H
TYA
SBC TEMP ;CALCULATE HIGH
STX TEMP
LSR A ;MOVE TWO BITS FROM HIGH TO TEMP
ROR TEMP
LSR A
ROR TEMP
LDA CMP0 ;CALC MIN PULSE VALUE
CLC
ADC #60
BIT D2ORAH ;CLEAR READ INTERRUPT FLAG
CMP TEMP ;IF PULSE LESS THAN MIN...
BCS RDBK ;...THEN IGNORE AS NOISE
LDX DPSW ;CHECK IF LAST BIT...
BEQ RJDJ ;...NO THEN CONTINUE
JMP RADJ ;...YES THEN GO FINISH BYTE
.SKI 2
RJDJ LDX PCNTR ;IF 9 BITS READ...
BMI JRAD2 ;... THEN GOTO ENDING
LDX #0 ;SET BIT VALUE TO ZERO
ADC #48 ;ADD UP TO HALF WAY BETWEEN...
ADC CMP0 ;...SHORT PULSE AND SYNC PULSE
CMP TEMP ;CHECK FOR SHORT...
BCS RADX2 ;...YES IT'S A SHORT
INX ;SET BIT VALUE TO ONE
ADC #38 ;MOVE TO MIDDLE OF HIGH
ADC CMP0
CMP TEMP ;CHECK FOR ONE...
BCS RADL ;...YES IT'S A ONE
ADC #44 ;MOVE TO LONGLONG
ADC CMP0
CMP TEMP ;CHECK FOR LONGLONG...
BCC SRER ;...GREATER THAN IS ERROR
JRAD2 JMP RAD2 ;...IT'S A LONGLONG
.SKI 2
SRER LDA SNSW1 ;IF NOT SYNCRONIZED...
BEQ RDBK ;...THEN NO ERROR
STA RER ;...ELSE FLAG RER
BNE RDBK ;JMP
.SKI 2
RADX2 INC REZ ;COUNT REZ UP ON ZEROS
BCS RAD5 ;JMP
RADL DEC REZ ;COUNT REZ DOWN ON ONES
RAD5 SEC ;CALC ACTUAL VALUE FOR COMPARE STORE
SBC #19
SBC TEMP ;SUBTRACT INPUT VALUE FROM CONSTANT...
ADC SVXT ;...ADD DIFFERENCE TO TEMP STORAGE...
STA SVXT ;...USED LATER TO ADJUST SOFT SERVO
LDA FIRT ;FLIP DIPOLE FLAG
EOR #1
STA FIRT
BEQ RAD3 ;SECOND HALF OF DIPOLE
STX DATA ;FIRST HALF SO STORE ITS VALUE
.SKI 3
RDBK LDA SNSW1 ;IF NO BYTE START...
BEQ RADBK ;...THEN RETURN
BIT D2IFR ;CHECK TO SEE IF TIMER1 IRQD US...
BVC RADBK ;...NO, SO EXIT
LDA #0 ;...YES, SET DIPOLE FLAG FOR FIRST HALF
STA FIRT
LDA PCNTR ;CHECK WHERE WE ARE IN BYTE...
BPL RAD4 ;...DOING DATA
BMI JRAD2 ;...PROCESS PARITY
.SKI 2
RADP LDX #166 ;SET UP FOR LONGLONG TIMEOUT
JSR STT1
LDA PRTY ;IF PARITY NOT EVEN...
BNE SRER ;...THEN GO SET ERROR
RADBK JMP PREND ;GO RESTORE REGS AND RTI
.SKI 3
RAD3 LDA SVXT ;ADJUST THE SOFTWARE SERVO (CMP0)
BEQ ROUT1 ;NO ADJUST
BMI ROUT2 ;ADJUST FOR MORE BASE TIME
DEC CMP0 ;ADJUST FOR LESS BASE TIME
.BYT $2C ;SKIP TWO BYTES
ROUT2 INC CMP0
ROUT1 LDA #0 ;CLEAR DIFFERENCE VALUE
STA SVXT
;CHECK FOR CONSECUTIVE LIKE VALUES IN DIPOLE...
CPX DATA
BNE RAD4 ;...NO, GO PROCESS INFO
TXA ;...YES SO CHECK THE VALUES...
BNE SRER ;IF THEY WERE ONES THEN ERROR
; CONSECUTIVE ZEROS
LDA REZ ;...CHECK HOW MANY ZEROS HAVE HAPPENED
BMI RDBK ;...IF MANY DON'T CHECK
CMP #16 ;... DO WE HAVE 16 YET?...
BCC RDBK ;....NO SO CONTINUE
STA SYNO ;....YES SO FLAG SYNO (BETWEEN BLOCKS)
BCS RDBK ;JMP
.SKI 3
RAD4 TXA ;MOVE READ DATA TO .A
EOR PRTY ;CALCULATE PARITY
STA PRTY
LDA SNSW1 ;REAL DATA?...
BEQ RADBK ;...NO SO FORGET BY EXITING
DEC PCNTR ;DEC BIT COUNT
BMI RADP ;IF MINUS THEN TIME FOR PARITY
LSR DATA ;SHIFT BIT FROM DATA...
ROR MYCH ;...INTO BYTE STORAGE (MYCH) BUFFER
LDX #218 ;SET UP FOR NEXT DIPOLE
JSR STT1
JMP PREND ;RESTORE REGS AND RTI
.SKI 3
; RAD2 - LONGLONG HANDLER (COULD BE A LONG ONE)
RAD2 LDA SYNO ;HAVE WE GOTTEN BLOCK SYNC...
BEQ RAD2Y ;...NO
LDA SNSW1 ;CHECK IF WE'VE HAD A REAL BYTE START...
BEQ RAD2X ;...NO
RAD2Y LDA PCNTR ;ARE WE AT END OF BYTE...
BPL RADL ;...NO SO TREAT IT AS A LONG ONE READ
.SKI 2
RAD2X LSR TEMP ;ADJUST TIMEOUT FOR...
LDA #147 ;...LONGLONG PULSE VALUE
SEC
SBC TEMP
ADC CMP0
ASL A
TAX ;AND SET TIMEOUT FOR LAST BIT
JSR STT1
INC DPSW ;SET BIT THROW AWAY FLAG
LDA SNSW1 ;IF BYTE SYNCRONIZED....
BNE RADQ2 ;...THEN SKIP TO PASS CHAR
LDA SYNO ;THROWS OUT DATA UNTILL BLOCK SYNC...
BEQ RDBK2 ;...NO BLOCK SYNC
STA RER ;FLAG DATA AS ERROR
LDA #0 ;KILL 16 SYNC FLAG
STA SYNO
LDA #$C0 ;SET UP FOR TIMER1 INTERRUPTS
STA D2IER
STA SNSW1 ;FLAG THAT WE HAVE BYTE SYNCRONIZED
;
RADQ2 LDA SYNO ;SAVE SYNO STATUS
STA DIFF
BEQ RADK ;NO BLOCK SYNC, NO BYTE LOOKING
LDA #0 ;TURN OFF BYTE SYNC SWITCH
STA SNSW1
LDA #$40 ;DISABLE TIMER1 INTERRUPTS
STA D2IER
RADK LDA MYCH ;PASS CHARACTER TO BYTE ROUTINE
STA OCHAR
LDA RER ;COMBINE ERROR VALUES WITH ZERO COUNT...
ORA REZ
STA PRP ;...AND SAVE IN PRP
RDBK2 JMP PREND ;GO BACK AND GET LAST BYTE
.SKI 2
RADJ JSR NEWCH ;FINISH BYTE, CLR FLAGS
STA DPSW ;CLEAR BIT THROW AWAY FLAG
LDX #218 ;INITILIZE FOR NEXT DIPOLE
JSR STT1
LDA FSBLK ;CHECK FOR LAST VALUE
BEQ RD15
STA SHCNL
.PAG 'BYTE HANDLER'
;*************************************************
;* BYTE HANDLER OF CASSETTE READ *
;* *
;* THIS PORTION OF IN LINE CODE IS PASSED THE *
;* BYTE ASSEMBLED FROM READING TAPE IN OCHAR. *
;* RER IS SET IF THE BYTE READ IS IN ERROR. *
;* REZ IS SET IF THE INTERRUPT PROGRAM IS READING*
;* ZEROS. RDFLG TELLS US WHAT WE ARE DOING. *
;* BIT 7 SAYS TO IGNORE BYTES UNTIL REZ IS SET *
;* BIT 6 SAYS TO LOAD THE BYTE. OTHERWISE RDFLG *
;* IS A COUNTDOWN AFTER SYNC. IF VERCK IS SET *
;* WE DO A COMPARE INSTEAD OF A STORE AND SET *
;* STATUS. FSBLK COUNTS THE TWO BLOCKS. PTR1 IS *
;* INDEX TO ERROR TABLE FOR PASS1. PTR2 IS INDEX*
;* TO CORRECTION TABLE FOR PASS2. *
;*************************************************
;
SPERR=16
CKERR=32
SBERR=4
LBERR=8
;
RD15 LDA #$F
;
BIT RDFLG ;TEST FUNCTION MODE
BPL RD20 ;NOT WAITING FOR ZEROS
;
LDA DIFF ;ZEROS YET?
BNE RD12 ;YES...WAIT FOR SYNC
LDX FSBLK ;IS PASS OVER?
DEX ;...IF FSBLK ZERO THEN NO ERROR (FIRST GOOD)
BNE RD10 ;NO...
;
LDA #LBERR
JSR UDST ;YES...LONG BLOCK ERROR
BNE RD10 ;BRANCH ALWAYS
;
RD12 LDA #0
STA RDFLG ;NEW MODE IS WAIT FOR SYNC
RD10 JMP PREND ;EXIT...DONE
;
RD20 BVS RD60 ;WE ARE LOADING
BNE RD200 ;WE ARE SYNCING
;
LDA DIFF ;DO WE HAVE BLOCK SYNC...
BNE RD10 ;...YES, EXIT
LDA PRP ;IF FIRST BYTE HAS ERROR...
BNE RD10 ;...THEN SKIP (EXIT)
LDA SHCNL ;MOVE FSBLK TO CARRY...
LSR A
LDA OCHAR ; SHOULD BE A HEADER COUNT CHAR
BMI RD22 ;IF NEG THEN FIRSTBLOCK DATA
BCC RD40 ;...EXPECTING FIRSTBLOCK DATA...YES
CLC
RD22 BCS RD40 ;EXPECTING SECOND BLOCK?...YES
AND #$F ;MASK OFF HIGH STORE HEADER COUNT...
STA RDFLG ;...IN MODE FLAG (HAVE CORRECT BLOCK)
RD200 DEC RDFLG ;WAIT UNTILL WE GET REAL DATA...
BNE RD10 ;...9876543210 REAL
LDA #$40 ;NEXT UP IS REAL DATA...
STA RDFLG ;...SET DATA MODE
JSR RD300 ;GO SETUP ADDRESS POINTERS
LDA #0 ;DEBUG CODE####################################
STA SHCNH
BEQ RD10 ;JMP TO CONTINUE
.SKI 2
RD40 LDA #$80 ;WE WANT TO...
STA RDFLG ;IGNORE BYTES MODE
BNE RD10 ;JMP
.SKI 2
RD60 LDA DIFF ;CHECK FOR END OF BLOCK...
BEQ RD70 ;...OKAY
;
LDA #SBERR ;SHORT BLOCK ERROR
JSR UDST
LDA #0 ;FORCE RDFLG FOR AN END
JMP RD161
.SKI 2
RD70 JSR CMPSTE ;CHECK FOR END OF STORAGE AREA
BCC *+5 ;NOT DONE YET
JMP RD160
LDX SHCNL ;CHECK WHICH PASS...
DEX
BEQ RD58 ;...SECOND PASS
LDA VERCK ;CHECK IF LOAD OR VERIFY...
BEQ RD80 ;...LOADING
LDY #0 ;...JUST VERIFYING
LDA OCHAR
CMP (SAL)Y ;COMPARE WITH DATA IN PET
BEQ RD80 ;...GOOD SO CONTINUE
LDA #1 ;...BAD SO FLAG...
STA PRP ;...AS AN ERROR
.SKI 1
; STORE BAD LOCATIONS FOR SECOND PASS RE-TRY
RD80 LDA PRP ;CHK FOR ERRORS...
BEQ RD59 ;...NO ERRORS
LDX #61 ;MAX ALLOWED IS 30
CPX PTR1 ;ARE WE AT MAX?...
BCC RD55 ;...YES, FLAG AS SECOND PASS ERROR
LDX PTR1 ;GET INDEX INTO BAD...
LDA SAH ;...AND STORE THE BAD LOCATION
STA BAD+1,X ;...IN BAD TABLE
LDA SAL
STA BAD,X
INX ;ADVANCE POINTER TO NEXT
INX
STX PTR1
JMP RD59 ;GO STORE CHARACTER
.SKI 2
; CHECK BAD TABLE FOR RE-TRY (SECOND PASS)
RD58 LDX PTR2 ;HAVE WE DONE ALL IN THE TABLE?...
CPX PTR1
BEQ RD90 ;...YES
LDA SAL ;SEE IF THIS IS NEXT IN THE TABLE...
CMP BAD,X
BNE RD90 ;...NO
LDA SAH
CMP BAD+1,X
BNE RD90 ;...NO
INC PTR2 ;WE FOUND NEXT ONE, SO ADVANCE POINTER
INC PTR2
LDA VERCK ;DOING A LOAD OR VERIFY?...
BEQ RD52 ;...LOADING
LDA OCHAR ;...VERIFYING, SO CHECK
LDY #0
CMP (SAL)Y
BEQ RD90 ;...OKAY
INY ;MAKE .Y= 1
STY PRP ;FLAG IT AS AN ERROR
.SKI 2
RD52 LDA PRP ;A SECOND PASS ERROR?...
BEQ RD59 ;...NO
;SECOND PASS ERR
RD55 LDA #SPERR
JSR UDST
BNE RD90 ;JMP
.SKI 2
RD59 LDA VERCK ;LOAD OR VERIFY?...
BNE RD90 ;...VERIFY, DON'T STORE
TAY ;MAKE Y ZERO
LDA OCHAR
STA (SAL)Y ;STORE CHARACTER
RD90 JSR INCSAL ;INCREMENT ADDR.
BNE RD180 ;BRANCH ALWAYS
.SKI 3
RD160 LDA #$80 ;SET MODE SKIP NEXT DATA
RD161 STA RDFLG
LDX FSBLK ;DEC FSBLK FOR NEXT PASS...
DEX
BMI RD167 ;WE ARE DONE...FSBLK=0
STX FSBLK ;...ELSE FSBLK=NEXT
RD167 DEC SHCNL ;DEC PASS CALC...
BEQ RD175 ;...ALL DONE
LDA PTR1 ;CHECK FOR FIRST PASS ERRORS...
BNE RD180 ;...YES SO CONTINUE
STA FSBLK ;CLEAR FSBLK IF NO ERRORS...
BEQ RD180 ;JMP TO EXIT
.SKI 2
RD175 JSR TNIF ;READ IT ALL...EXIT
JSR RD300 ;RESTORE SAL & SAH
LDY #0 ;SET SHCNH TO ZERO...
STY SHCNH ;...USED TO CALC PARITY BYTE
;
;COMPUTE PARITY OVER LOAD
;
VPRTY LDA (SAL)Y ;CALC BLOCK BCC
EOR SHCNH
STA SHCNH
JSR INCSAL ;INCREMENT ADDRESS
JSR CMPSTE ;TEST AGAINST END
BCC VPRTY ;NOT DONE YET...
LDA SHCNH ;CHECK FOR BCC CHAR MATCH...
EOR OCHAR
BEQ RD180 ;...YES, EXIT
;CHKSUM ERROR
LDA #CKERR
JSR UDST
RD180 JMP PREND
.SKI 4
RD300 LDA STAH ; RESTORE STARTING ADDRESS...
STA SAH ;...POINTERS (SAH & SAL)
LDA STAL
STA SAL
RTS
.SKI 4
NEWCH LDA #8 ;SET UP FOR 8 BITS+PARITY
STA PCNTR
LDA #0 ;INITILIZE...
STA FIRT ;..DIPOLE COUNTER
STA RER ;..ERROR FLAG
STA PRTY ;..PARITY BIT
STA REZ ;..ZERO COUNT
RTS ;.A=0 ON RETURN
.END
; RSR 7/31/80 ADD COMMENTS

166
KERNAL_VIC_04/rs232inout

@ -0,0 +1,166 @@
.PAG 'RS232 INOUT'
; OUTPUT A FILE OVER USR PORT
; USING RS232
;
CKO232 STA DFLTO ;SET DEFAULT OUT ###TEMP CODE###
LDA M51CDR ;CHECK FOR 3/X LINE
LSR A
BCC CKO100 ;3LINE...NO TURN AROUND
;
;*TURN AROUND LOGIC
;
; CHECK FOR DSR AND RTS
;
LDA #$02 ;BIT RTS IS ON
BIT D1ORB
BPL CKDSRX ;NO DSR...ERROR
BNE CKO100 ;RTS...OUTPUTING OR FULL DUPLEX
;
; CHECK FOR ACTIVE INPUT
; RTS WILL BE LOW IF CURRENTLY INPUTING
;
CKO020 LDA D1IER
AND #$30 ;LOOK AT IER FOR T2 OR CB1
BNE CKO020 ;HANG UNTILL INPUT DONE
;
; WAIT FOR CTS TO BE OFF AS SPEC REQS
;
CKO030 BIT D1ORB
BVS CKO030
;
; TURN ON RTS
;
LDA D1ORB
ORA #$02
STA D1ORB
;
; WAIT FOR CTS TO GO ON
;
CKO040 BIT D1ORB
BVS CKO100 ;DONE...
BMI CKO040 ;WE STILL HAVE DSR
;
CKDSRX JSR DSRERR ;A DATA SET READY ERROR
;
CKO100 CLC ;NO ERROR
RTS
.PAGE 'RS232 INOUT'
; BSO232 - OUTPUT A CHAR RS232
;
; BUFFER HANDLER
;
BSO232 LDY RODBE
INY
CPY RODBS ;CHECK FOR BUFFER FULL
BEQ BSO232 ;HANG IF SO...(MAY NEED TIMEOUT?)
STY RODBE ;INDICATE NEW START
DEY
STA (ROBUF)Y ;STORE DATA
;
; SET UP IF NECESSARY TO OUTPUT
;
BSO100 BIT D1IER ;CHECK FOR A T1 NMI ENABLE
BVC BSO110 ;NONE SO SET UP TIMER
RTS ;ELSE RETURN
;
; SET UP FOR A FIRST BYTE OUT
;
BSO110 LDA BAUDOF ;SET UP TIMER1
STA D1T1L
LDA BAUDOF+1
STA D1T1H
;
; SET UP T1 NMI'S
;
LDA #$C0
STA D1IER
;
JMP RSTBGN ;BEGIN TRANSFER
.PAGE 'RS232 INOUT'
; INPUT A FILE OVER USER PORT
; USING RS232
;
CKI232 STA DFLTN ;SET DEFAULT INPUT
;
LDA M51CDR ;CHECK FOR 3/X LINE
LSR A
BCC CKI100 ;3 LINE...NO HANDSHAKE
;
AND #$08 ;FULL/HALF CHECK (BYTE SHIFTED ABOVE)
BEQ CKI100 ;FULL...NO HANDSHAKE
;
;*TURN AROUND LOGIC
;
; CHECK IF DSR AND NOT RTS
;
LDA #$02 ;BIT RTS IS ON
BIT D1ORB
BPL CKDSRX ;NO DSR...ERROR
BEQ CKI090 ;RTS LOW...IN CORRECT MODE
;
; WAIT FOR ACTIVE OUTPUT TO BE DONE
;
CKI010 BIT D1IER
BVS CKI010
;
; TURN OFF RTS
;
LDA D1ORB
AND #$FF-02
STA D1ORB
;
; WAIT FOR DCD TO GO HIGH (IN SPEC)
;
CKI020 LDA D1ORB
AND #$04
BEQ CKI020
;
; ENABLE CB1 FOR RS232 INPUT
;
CKI080 LDA #$90
STA D1IER
CKI090 CLC ;NO ERROR
RTS
;
; IF NOT 3 LINE HALF THEN...
; SEE IF WE NEED TO TURN ON CB1
;
CKI100 LDA D1IER ;CHECK FOR CB1 OR T2 ACTIVE
AND #$30
BEQ CKI080 ;NO NEED TO TURN ON
CLC ;NO ERROR
RTS
.PAGE 'RS232 INOUT'
; BSI232 - INPUT A CHAR RS232
;
; BUFFER HANDLER
;
BSI232 LDY RIDBS ;GET LAST BYTE ADDRESS
CPY RIDBE ;SEE IF BUFFER EMPTY
BEQ BSI010 ;RETURN A NULL IF NO CHAR
;
LDA (RIBUF)Y ;GET LAST CHAR
INC RIDBS ;INC TO NEXT POS
;
; RECEIVER ALWAYS RUNS
;
RTS
BSI010 LDA #$0 ;RETURN A NULL
RTS
.SKI 4
; RSP232 - PROTECT SERIAL/CASS FROM RS232 NMI'S
;
RSP232 PHA ;SAVE .A
LDA D1IER ;DOES RS232 HAVE ANY ENABLES?
BEQ RSPOK ;NO...
RSPOFF LDA D1IER ;WAIT UNTILL DONE
AND #%01100000 ; WITH T1 & T2
BNE RSPOFF
LDA #%00010000 ; DISABLE CB1 (NEED TO RENABLE IN USER CODE)
STA D1IER
RSPOK PLA ;ALL DONE
RTS
.END
; RSR 8/24/80 ORIGINAL CODE OUT
; RSR 8/25/80 ORIGINAL CODE IN
; RSR 9/22/80 REMOVE PARALLEL REFS & FIX XLINE LOGIC

159
KERNAL_VIC_04/rs232nmifile

@ -0,0 +1,159 @@
.PAGE 'NMI HANDLER'
NMI SEI ;NO IRQ'S ALLOWED...
JMP (NMINV) ;...COULD MESS UP CASSETTES
NNMI PHA ;SAVE 6502 REGS
TXA
PHA
TYA
PHA
NNMI10 LDA D1IFR ;CHECK IF REAL NMI...
BPL NMIRTN ;...NO
;
AND D1IER ;SHOW ONLY ENABLES
TAX ;SAVE IN .X FOR LATTER
AND #$02 ;CHECK IF RESTORE KEY...
BEQ NNMI20 ;...NO
;
NNMI18 JSR A0INT ;CHECK IF $A0 IN...
BNE NNMI19 ;...NO
JMP ($A002) ;...YES
;
; CHECK FOR STOP KEY DOWN
;
NNMI19 BIT D1ORAH ;CLR CA1 FLAG
JSR UDTIM
JSR STOP
BNE NMIRTN ;NO STOP KEY
;
; TIMB - WHERE SYSTEM GOES ON A BRK INSTRUCTION
;
TIMB JSR RESTOR ;RESTORE SYSTEM INDIRECTS
JSR IOINIT ;RESTORE I/O FOR BASIC
JSR CINT ;RESTORE SCREEN FOR BASIC
JMP ($C002) ;...NO, SO BASIC WARM START
.SKI 2
; DISABLE NMI'S UNTILL READY
; SAVE ON STACK
;
NNMI20 LDA D1IER ;SAVE CURRENT ENABLES...
ORA #$80 ;SO WE CAN ENABLE ON RESTORE
PHA
LDA #$7F ;KILL THE REST
STA D1IER
;
;
; T1 NMI CHECK - TRANSMITT A BIT
;
TXA
AND #$40 ;CHECK FOR T1
BEQ NNMI30 ;NO...
;
LDA #$CE ;FIXED PCR HERE
; WILL TURN OFF YOUR CASS MOTOR!
ORA NXTBIT ;LOAD DATA AND...
STA D1PCR ;...SEND IT
;
LDA D1T1L ;KILL REQUEST
;
PLA ;RESTORE NMI'S
STA D1IER ;READY FOR NEXT...
;
JSR RSTRAB ;GO CALC INFO (CODE COULD BE IN LINE)
NMIRTN JMP NMIRTI
;
.SKI 2
; T2 NMI CHECK - RECIEVE A BIT
;
NNMI30 TXA
AND #$20 ;MASK TO T2
BEQ NNMI40 ;NO...
;
LDA D1ORB ;GET DATA IN
AND #01 ;MASK OFF...
STA INBIT ;...SAVE FOR LATTER
;
; UPDATE T2 FOR MID BIT CHECK
; (WORST CASE <255 US TO HERE)
;
LDA D1T2L ;CALC NEW TIME & CLR NMI
SBC #22 ;TIME FOR THIS LOOP
ADC BAUDOF
STA D1T2L
LDA D1T2H
ADC BAUDOF+1
STA D1T2H
;
;
PLA ;RESTORE NMI'S
STA D1IER
;
JSR RSRCVR ;GO SHIFT IN...
JMP NMIRTI
.SKI 2
; CB1 NMI HANDLER - RECIEVE A START BIT
;
NNMI40 TXA ;CHECK FOR EDGE
AND #$10 ;ON CB1...
BEQ NMIRTI ;NO...
;
; CHECK FOR NOISE ?
;
LDA M51CTR ;GET LENGTH TO CHECK FOR
AND #$0F
BNE NNMI42 ;USE TABLES
;
; GET BAUD RATE FROM ELSE WHERE ###NEED CODE###
;
NNMI42 ASL A ;GET DATA FROM BAUD TABLE
TAX
LDA BAUDO-2,X ;MOVE TO TIMER
STA D1T2L
LDA BAUDO-1,X
STA D1T2H
;
LDA D1ORB ;KILL CB1 EDGE NMI
PLA ;RESTORE NMI'S
ORA #$20 ;ENABLE T2 NMI
AND #$EF ;DISABLE EDGE ON CB1
STA D1IER
;
LDX BITNUM ;GET #OF BITS IN
STX BITCI ;PUT IN RCVRCNT
;
.SKI 2
NMIRTI ;RESTORE 6502 REGS
PREND PLA ;BECAUSE OF MISSING SCREEN EDITOR
TAY
PLA
TAX
PLA
RTI
.SKI 4
; BAUDO TABLE CONTAINS VALUES
; FOR 1.023E6/BAUD RATE/2
;
BAUDO .WOR 10230-CBIT ; 50 BAUD
.WOR 6820-CBIT ; 75 BAUD
.WOR 4650-CBIT ; 110 BAUD
.WOR 3800-CBIT ; 134.6 BAUD
.WOR 3410-CBIT ; 150 BAUD
.WOR 1705-CBIT ; 300 BAUD
.WOR 853-CBIT ; 600 BAUD
.WOR 426-CBIT ; 1200 BAUD
.WOR 284-CBIT ; 1800 BAUD
.WOR 213-CBIT ; 2400 BAUD
.WOR 142-CBIT ; 3600 BAUD
;
; CBIT - AN ADJUSTMENT TO MAKE NEXT T2 HIT NEAR CENTER
; OF THE NEXT BIT.
; APROX THE TIME TO SERVICE A CB1 NMI
CBIT = 100 ;US
.END
; RSR 8/2/80 - ROUTINE FOR PANIC
; RSR 8/8/80 - PANIC & STOP KEY
; RSR 8/12/80 - CHANGE FOR A0INT A SUBROUTINE
; RSR 8/19/80 - ADD RS-232 CHECKS
; RSR 8/21/80 - MODIFY RS-232
; RSR 8/29/80 - CHANGE PANIC ORDER FOR JACK
; RSR 8/30/80 - ADD T2
; RSR 9/22/80 - ADD 1800 BAUD OPPS!

131
KERNAL_VIC_04/rs232rcvr

@ -0,0 +1,131 @@
.PAG 'RS-232 RECEIVER'
; RSRCVR - NMI ROUTINE TO COLLECT
; DATA INTO BYTES
;
; RSR 8/18/80
;
; VARIABLES USED
; INBIT - INPUT BIT VALUE
; BITCI - BIT COUNT IN
; RINONE - FLAG FOR START BIT CHECK <>0 START BIT
; RIDATA - BYTE INPUT BUFFER
; RIPRTY - HOLDS BYTE INPUT PARITY
; RIBUF - INDIRECT POINTER TO DATA BUFFER
; RIDBE - INPUT BUFFER INDEX TO END
; RIDBS - INPUT BUFFER POINTER TO START
; IF RIDBE=RIDBS THEN INPUT BUFFER EMPTY
;
RSRCVR LDX RINONE ;CHECK FOR START BIT
BNE RSRTRT ;WAS START BIT
;
DEC BITCI ;CHECK WHERE WE ARE IN INPUT...
BEQ RSR030 ;HAVE A FULL BYTE
BMI RSR020 ;GETTING STOP BITS
;
; CALC PARITY
;
LDA INBIT ;GET DATA UP
EOR RIPRTY ;CALC NEW PARITY
STA RIPRTY
;
; SHIFT DATA BIT IN
;
LSR INBIT ;IN BIT POS 0
ROR RIDATA ;C INTO DATA
;
; EXIT
;
RSREXT RTS
.PAG 'RS-232 RECEIVER'
; HAVE STOP BIT, SO STORE IN BUFFER
;
RSR018 DEC BITCI ;NO PARITY, DEC SO CHECK WORKS
RSR020 LDA INBIT ;GET DATA...
BEQ RSR060 ;...ZERO, AN ERROR?
;
LDA M51CTR ;CHECK FOR CORRECT # OF STOP BITS
ASL A ;CARRY TELL HOW MAY STOP BITS
LDA #01
ADC BITCI
BNE RSREXT ;NO..EXIT
;
; RSRABL - ENABLE TO RECIEVE A BYTE
;
RSRABL LDA #$90 ;ENABLE CB1 FOR NEXT BYTE
STA D1IER
STA RINONE ;FLAG FOR START BIT
;
RSRSXT LDA #$20 ;DISABLE T2
STA D1IER
RTS
.SKI 2
; RECIEVER START BIT CHECK
;
RSRTRT LDA INBIT ;CHECK IF SPACE
BNE RSRABL ;BAD...TRY AGAIN
STA RINONE ;GOOD...DISABLE FLAG
RTS ;AND EXIT
.SKI 4
;
; PUT DATA IN BUFFER (AT PARITY TIME)
;
RSR030 LDY RIDBE ;GET END
INY
CPY RIDBS ;HAVE WE PASSED START?
BEQ RECERR ;YES...ERROR
;
STY RIDBE ;MOVE RIDBE FOWARD
DEY
;
LDA RIDATA ;GET BYTE BUFFER UP
LDX BITNUM ;SHIFT UNTILL FULL BYTE
RSR031 CPX #9 ;ALWAYS 8 BITS
BEQ RSR032
LSR A ;FILL WITH ZEROS
INX
BNE RSR031
;
RSR032 STA (RIBUF)Y ;DATA TO PAGE BUFFER
;
; PARITY CHECKING
;
LDA #$20 ;CHECK 6551 COMMAND REGISTER
BIT M51CDR
BEQ RSR018 ;NO PARITY BIT SO STOP BIT
BMI RSREXT ;NO PARITY CHECK
;
; CHECK CALC PARITY
;
LDA INBIT
EOR RIPRTY ;PUT IN WITH PARITY
BEQ RSR050 ;EVEN PARITY
BVS RSREXT ;ODD...OKAY SO EXIT
.BYT $2C ;SKIP TWO
RSR050 BVC RSREXT ;EVEN...OKAY SO EXIT
;
; ERRORS REPORTED
LDA #1 ;PARITY ERROR
.BYT $2C
RECERR LDA #$4 ;RECIEVER OVERRUN
.BYT $2C
BREAKE LDA #$80 ;BREAK DETECTED
.BYT $2C
FRAMEE LDA #$02 ;FRAME ERROR
ERR232 ORA RSSTAT
STA RSSTAT
JMP RSRABL ;BAD EXIT SO HANG ##????????##
;
; CHECK FOR ERRORS
;
RSR060 LDA RIDATA ;EXPECTING STOP...
BNE FRAMEE ;FRAME ERROR
BEQ BREAKE ;COULD BE A BREAK
;
; RS232 LOAD AND SAVE
;
RS232 JMP ERROR9 ;BAD DEVICE NUMBER
.END
; RSR - 8/21/80 ADD MODS
; RSR - 8/24/80 FIX ERRORS
; RSR - 8/27/80 FIX MAJOR ERRORS
; RSR - 8/30-80 FIX T2 ADJUST

136
KERNAL_VIC_04/rs232trans

@ -0,0 +1,136 @@
.PAGE 'RS-232 TRANSMITT'
; RSTRAB - ENTRY FOR NMI CONTINUE ROUTINE
; RSTBGN - ENTRY FOR START TRANSMITTER
;
; RSR - 8/18/80
;
; VARIABLES USED
; BITTS - # OF BITS TO BE SENT (<>0 NOT DONE)
; NXTBIT - BYTE CONTAINS NEXT BIT TO BE SENT
; ROPRTY - BYTE CONTAINS PARITY BIT CALCULATED
; RODATA - STORES DATA BYTE CURRENTLY BEING TRANSMITTED
; RODBS - OUTPUT BUFFER INDEX START
; RODBE - OUTPUT BUFFER INDEX END
; IF RODBS=RODBE THEN BUFFER EMPTY
; ROBUF - INDIRECT POINTER TO DATA BUFFER
; RSSTAT - RS-232 STATUS BYTE
;
; XXX US - NORMAL BIT PATH
; XXX US - WORST CASE PARITY BIT PATH
; XXX US - STOP BIT PATH
; XXX US - START BIT PATH
;
RSTRAB LDA BITTS ;CHECK FOR PLACE IN BYTE...
BEQ RSTBGN ;...DONE, =0 START NEXT
;
BMI RST050 ;...DOING STOP BITS
;
LSR RODATA ;SHIFT DATA INTO CARRY
LDX #00 ;PREPARE FOR A ZERO
BCC RST005 ;YES...A ZERO
DEX ;NO...MAKE AN $FF
RST005 TXA ;READY TO SEND
;
EOR ROPRTY ;CALC INTO PARITY
STA ROPRTY
;
DEC BITTS ;BIT COUNT DOWN
BEQ RST010 ;WANT A PARITY INSTEAD
;
RSTEXT TXA ;CALC BIT WHOLE TO SEND
AND #$20 ;GOES OUT CB2
STA NXTBIT
RTS
.PAGE 'RS-232 TRANSMITT'
; CALCULATE PARITY
; NXTBIT =0 UPON ENTRY
;
RST010 LDA #$20 ;CHECK 6551 REG BITS
BIT M51CDR
BEQ RSPNO ;...NO PARITY, SEND A STOP
BMI RST040 ;...NOT REAL PARITY
BVS RST030 ;...EVEN PARITY
;
LDA ROPRTY ;CALC ODD PARITY
BNE RSPEXT ;CORRECT GUESS
;
RSWEXT DEX ;WRONG GUESS...ITS A ONE
;
RSPEXT DEC BITTS ;ONE STOP BIT ALWAYS
LDA M51CTR ;CHECK # OF STOP BITS
BPL RSTEXT ;...ONE
DEC BITTS ;...TWO
BNE RSTEXT ;JUMP
;
RSPNO ;LINE TO SEND CANNOT BE PB0
INC BITTS ;COUNTS AS ONE STOP BIT
BNE RSWEXT ;JUMP TO FLIP TO ONE
;
RST030 LDA ROPRTY ;EVEN PARITY
BEQ RSPEXT ;CORRECT GUESS...EXIT
BNE RSWEXT ;WRONG...FLIP AND EXIT
;
RST040 BVS RSPEXT ;WANTED SPACE
BVC RSWEXT ; WANTED MARK
.SKI 3
; STOP BITS
;
RST050 INC BITTS ;STOP BIT COUNT TOWARDS ZERO
LDX #$FF ;SEND STOP BIT
BNE RSTEXT ;JUMP TO EXIT
.PAG 'RS-232 TRANSMITT'
; RSTBGN - ENTRY TO START BYTE TRANS
;
RSTBGN LDA M51CDR ;CHECK FOR 3/X LINE
LSR A
BCC RST060 ;3 LINE...NO CHECK
BIT D2ORB ;CHECK FOR...
BPL DSRERR ;...DSR ERROR
BVC CTSERR ;...CTS ERROR
;
; SET UP TO SEND NEXT BYTE
;
RST060 LDA #0
STA ROPRTY ;ZERO PARITY
STA NXTBIT ;SEND START BIT
LDX BITNUM ;GET # OF BITS
RST070 STX BITTS ;BITTS=#OF BITTS+1
;
RST080 LDY RODBS ;CHECK BUFFER POINTERS
CPY RODBE
BEQ RSODNE ;ALL DONE...
;
LDA (ROBUF)Y ;GET DATA...
STA RODATA ;...INTO BYTE BUFFER
INC RODBS ;MOVE POINTER TO NEXT
RTS
.SKI 3
; SET ERRORS
;
DSRERR LDA #$40 ;DSR GONE ERROR
.BYT $2C
CTSERR LDA #$10 ;CTS GONE ERROR
ORA RSSTAT
STA RSSTAT
;
; ERRORS TURN OFF T1
;
RSODNE LDA #$40 ;KILL T1 NMI
STA D1IER
RTS
.SKI 3
; BITCNT - CAL # OF BITS TO BE SENT
; RETURNS #OF BITS+1
;
BITCNT LDX #9 ;CALC WORD LENGTH
LDA #$20
BIT M51CTR
BEQ BIT010
DEX ;BIT 5 HIGH IS A 7 OR 5
BIT010 BVC BIT020
DEX ;BIT 6 HIGH IS A 6 OR 5
DEX
BIT020 RTS
.END
; RSR 8/24/80 CORRECT SOME MISTAKES
; RSR 8/27/80 CHANGE BITNUM BASE TO #BITS+1

118
KERNAL_VIC_04/save

@ -0,0 +1,118 @@
.PAG 'SAVE FUNCTION'
;***********************************
;* SAVE *
;* *
;* SAVES TO CASSETTE 1 OR 2, OR *
;* IEEE DEVICES 4>=N>=31 AS SELECT-*
;* ED BY VARIABLE FA. *
;* *
;*START OF SAVE IS INDIRECT AT .A *
;*END OF SAVE IS .X,.Y *
;***********************************
.SKI 3
SAVESP STX EAL
STY EAH
TAX ;SET UP START
LDA $00,X
STA STAL
LDA $01,X
STA STAH
;
SAVE JMP (ISAVE)
NSAVE LDA FA ***MONITOR ENTRY
BNE SV20
;
SV10 JMP ERROR9 ;BAD DEVICE #
;
SV20 CMP #3
BEQ SV10
BCC SV100
LDA #$61
STA SA
LDY FNLEN
BNE SV25
;
JMP ERROR8 ;MISSING FILE NAME
;
SV25 JSR OPENI
JSR SAVING
LDA FA
JSR LISTN
LDA SA
JSR SECND
LDY #0
JSR RD300
LDA SAL
JSR CIOUT
LDA SAH
JSR CIOUT
SV30 JSR CMPSTE ;COMPARE START TO END
BCS SV50 ;HAVE REACHED END
LDA (SAL)Y
JSR CIOUT
JSR STOP
BNE SV40
;
BREAK JSR CLSEI
LDA #0
SEC
RTS
;
SV40 JSR INCSAL ;INCREMENT CURRENT ADDR.
BNE SV30
SV50 JSR UNLSN
.SKI 5
CLSEI BIT SA
BMI CLSEI2
LDA FA
JSR LISTN
LDA SA
AND #$EF
ORA #$E0
JSR SECND
JSR UNLSN
;
CLSEI2 CLC
RTS
.SKI 5
SV100 CMP #2
BNE SV102
;
JMP RS232
;
SV102 JSR ZZZ ;GET ADDR OF TAPE
BCC SV10 ;BUFFER IS DEALLOCATED
JSR CSTE2
BCS SV115 ;STOP KEY PRESSED
JSR SAVING ;TELL USER 'SAVING'
SV105 LDX #PLF ;DECIDE TYPE TO SAVE
LDA SA ;1-PLF 0-BLF
AND #01
BNE SV106
LDX #BLF
SV106 TXA
JSR TAPEH
BCS SV115 ;STOP KEY PRESSED
JSR TWRT
BCS SV115 ;STOP KEY PRESSED
LDA SA
AND #2 ;WRITE END OF TAPE?
BEQ SV110 ;NO...
;
LDA #EOT
JSR TAPEH
.BYT $24 ;SKIP 1 BYTE
;
SV110 CLC
SV115 RTS
.SKI 3
;SUBROUTINE TO OUTPUT:
;'SAVING <FILE NAME>'
;
SAVING LDA MSGFLG
BPL SV115 ;NO PRINT
;
LDY #MS11-MS1 ;'SAVING'
JSR MSG
JMP OUTFN ;<FILE NAME>
.END

306
KERNAL_VIC_04/serial2.1

@ -0,0 +1,306 @@
.PAG 'SERIAL ROUTINES'
;COMMAND SERIAL BUS DEVICE TO TALK
;
TALK ORA #$40 ;MAKE A TALK ADR
.BYT $2C ;SKIP TWO BYTES
.SKI 5
;COMMAND SERIAL BUS DEVICE TO LISTEN
;
LISTN ORA #$20 ;MAKE A LISTEN ADR
JSR RSP232 ;PROTECT SELF FROM RS232 NMI'S
LIST1 PHA
;
;
BIT C3P0 ;CHARACTER LEFT IN BUF?
BPL LIST2 ;NO...
;
;SEND BUFFERED CHARACTER
;
SEC ;SET EOI FLAG
ROR R2D2
;
JSR ISOUR ;SEND LAST CHARACTER
;
LSR C3P0 ;BUFFER CLEAR FLAG
LSR R2D2 ;CLEAR EOI FLAG
;
;
LIST2 PLA ;TALK/LISTEN ADDRESS
STA BSOUR
JSR DATAHI
CMP #$3F ;CLKHI ONLY ON UNLISTEN
BNE LIST5
JSR CLKHI
;
LIST5 LDA D1ORA ;ASSERT ATTENTION
ORA #$80
STA D1ORA
;
.SKI 5
ISOURA
JSR CLKLO ;SET CLOCK LINE LOW
JSR DATAHI
JSR W1MS ;DELAY 1 MS
.SKI 5
ISOUR SEI ;NO IRQ'S ALLOWED
JSR DATAHI ;MAKE SURE DATA IS RELEASED
JSR DEBPIA ;DATA SHOULD BE LOW
LSR A
BCS NODEV
JSR CLKHI ;CLOCK LINE HIGH
BIT R2D2 ;EOI FLAG TEST
BPL NOEOI
; DO THE EOI
ISR02 JSR DEBPIA ;WAIT FOR DATA TO GO HIGH
LSR A
BCC ISR02
;
ISR03 JSR DEBPIA ;WAIT FOR DATA TO GO LOW
LSR A
BCS ISR03
;
NOEOI JSR DEBPIA ;WAIT FOR DATA HIGH
LSR A
BCC NOEOI
JSR CLKLO ;SET CLOCK LOW
;
; SET TO SEND DATA
;
LDA #$08 ;COUNT 8 BITS
STA COUNT
;
ISR01
LDA D1ORA ;DEBOUNCE THE BUS
CMP D1ORA
BNE ISR01
LSR A
LSR A
BCC FRMERR ;DATA MUST BE HI
;
ROR BSOUR ;NEXT BIT INTO CARRY
BCS ISRHI
JSR DATALO
BNE ISRCLK
ISRHI JSR DATAHI
ISRCLK JSR CLKHI ;CLOCK HI
NOP
NOP
NOP
NOP
LDA D2PCR
AND #%11011111 ;DATA HIGH
ORA #$02 ;CLOCK LOW
STA D2PCR
DEC COUNT
BNE ISR01
LDA #$04 ;SET TIMER FOR 1MS
STA D2T2H
ISR04 LDA D2IFR
AND #$20
BNE FRMERR
JSR DEBPIA
LSR A
BCS ISR04
CLI ;LET IRQ'S CONTINUE
RTS
;
NODEV ;DEVICE NOT PRESENT ERROR
LDA #$80
.BYT $2C
FRMERR ;FRAMING ERROR
LDA #$03
CSBERR JSR UDST ;COMMODORE SERIAL BUSS ERROR ENTRY
CLI ;IRQ'S WERE OFF...TURN ON
CLC ;MAKE SURE NO KERNAL ERROR RETURNED
BCC DLABYE ;TURN ATN OFF ,RELEASE ALL LINES
;
.SKI 5
;SEND SECONDARY ADDRESS AFTER LISTEN
;
SECND STA BSOUR ;BUFFER CHARACTER
JSR ISOURA ;SEND IT
.SKI 5
;RELEASE ATTENTION AFTER LISTEN
;
SCATN LDA D1ORA
AND #$7F
STA D1ORA ;RELEASE ATTENTION
RTS
.SKI 5
;TALK SECOND ADDRESS
;
TKSA STA BSOUR ;BUFFER CHARACTER
JSR ISOURA ;SEND SECOND ADDR
.SKI 5
TKATN ;SHIFT OVER TO LISTENER
SEI ;NO IRQ'S HERE
JSR DATALO ;DATA LINE LOW
JSR SCATN
JSR CLKHI ;CLOCK LINE HIGH JSR/RTS
TKATN1 JSR DEBPIA ;WAIT FOR CLOCK TO GO LOW
BCS TKATN1
CLI ;IRQ'S OKAY NOW
RTS
.SKI 5
;BUFFERED OUTPUT TO SERIAL BUS
;
CIOUT BIT C3P0 ;BUFFERED CHAR?
BMI CI2 ;YES...SEND LAST
;
SEC ;NO...
ROR C3P0 ;SET BUFFERED CHAR FLAG
BNE CI4 ;BRANCH ALWAYS
;
CI2 PHA ;SAVE CURRENT CHAR
JSR ISOUR ;SEND LAST CHAR
PLA ;RESTORE CURRENT CHAR
CI4 STA BSOUR ;BUFFER CURRENT CHAR
CLC ;CARRY-GOOD EXIT
RTS
.SKI 5
;SEND UNTALK COMMAND ON SERIAL BUS
;
UNTLK JSR CLKLO
LDA D1ORA ;PULL ATN
ORA #$80
STA D1ORA
LDA #$5F ;UNTALK COMMAND
.BYT $2C ;SKIP TWO BYTES
.SKI 5
;SEND UNLISTEN COMMAND ON SERIAL BUS
;
UNLSN LDA #$3F ;UNLISTEN COMMAND
JSR LIST1 ;SEND IT
;
; RELEASE ALL LINES
DLABYE JSR SCATN ;ALWAYS RELEASE ATN
; DELAY THEN RELEASE CLOCK AND DATA
;
DLADLH TXA ;DELAY APPROX 60 US
LDX #11
DLAD00 DEX
BNE DLAD00
TAX
JSR CLKHI
JMP DATAHI
.SKI 5
;INPUT A BYTE FROM SERIAL BUS
;
ACPTR
SEI ;NO IRQ ALLOWED
LDA #$00 ;SET EOI/ERROR FLAG
STA COUNT
JSR CLKHI ;MAKE SURE CLOCK LINE IS RELEASED
ACP00A JSR DEBPIA ;WAIT FOR CLOCK HIGH
BCC ACP00A
JSR DATAHI ;DATA LINE HIGH
;
EOIACP LDA #$01 ;SET TIMER 2 FOR 256US
STA D2T2H
ACP00 LDA D2IFR
AND #$20 ;CHECK THE TIMER
BNE ACP00B ;RAN OUT.....
JSR DEBPIA ;CHECK THE CLOCK LINE
BCS ACP00 ;NO NOT YET
BCC ACP01 ;YES.....
;
ACP00B LDA COUNT ;CHECK FOR ERROR (TWICE THRU TIMEOUTS)
BEQ ACP00C
LDA #2
JMP CSBERR ; ST = 2 READ TIMEOUT
;
; TIMER RAN OUT DO AN EOI THING
;
ACP00C JSR DATALO ;DATA LINE LOW
JSR DLADLH ;DELAY AND THEN SET DATAHI (ALSO CLKHI)
LDA #$40
JSR UDST ;OR AN EOI BIT INTO STATUS
INC COUNT ;GO AROUND AGAIN FOR ERROR CHECK ON EOI
BNE EOIACP
;
; DO THE BYTE TRANSFER
;
ACP01 LDA #08 ;SET UP COUNTER
STA COUNT
;
ACP03 LDA D1ORA ;WAIT FOR CLOCK HIGH
CMP D1ORA ;DEBOUNCE
BNE ACP03
LSR A
BCC ACP03
LSR A ;PUT DATA BIT INTO CARRY
ROR BSOUR1 ;ROTATE DATA IN
;
ACP03A LDA D1ORA ;WAIT FOR CLOCK LOW
CMP D1ORA ;DEBOUNCE
BNE ACP03A
LSR A
BCS ACP03A
DEC COUNT
BNE ACP03 ;MORE BITS.....
;...EXIT...
JSR DATALO ;DATA LOW
LDA STATUS ;CHECK FOR EOI
BEQ ACP04 ;NONE...
;
JSR DLADLH ;DELAY THEN SET DATA HIGH
;
ACP04 LDA BSOUR1
CLI ;IRQ IS OK
CLC ;GOOD EXIT
RTS
;
CLKHI ;SET CLOCK LINE HIGH (INVERTED)
LDA D2PCR
AND #%11111101
STA D2PCR
RTS
;
CLKLO ;SET CLOCK LINE LOW (INVERTED)
LDA D2PCR
ORA #$02
STA D2PCR
RTS
AROUND =*
;
; MOVED BECAUSE OF NEEDED PATCH SPACE
;
*=$E4A0 ;PATCH AREA
DATAHI ;SET DATA LINE HIGH (INVERTED)
LDA D2PCR
AND #%11011111
STA D2PCR
RTS
;
DATALO ;SET DATA LINE LOW (INVERTED)
LDA D2PCR
ORA #$20
STA D2PCR
RTS
;
DEBPIA LDA D1ORA ;DEBPUNCE THE PIA
CMP D1ORA
BNE DEBPIA
LSR A ;SHIFT THE CLOCK BIT INTO THE CARRY
RTS
KSP2 =* ;KERNAL SPACE FOR PATCH 2
*=AROUND
W1MS ;DELAY 1MS USING TIMER 2
LDA #$04
STA D2T2H
W1MS1 ;TIMER WAIT LOOP
LDA D2IFR
AND #$20
BEQ W1MS1
RTS
.END
;*******************************
;WRITTEN 8/11/80 BOB FAIRBAIRN
;TEST SERIAL0.6 8/12/80 RJF
;CHANGE I/O STRUCTURE 8/21/80 RJF
;MORE I/O CHANGES 8/24/80 RJF
;FINAL RELEASE INTO KERNAL 8/26/80 RJF
;SOME CLEAN UP 9/8/80 RSR
;ADD IRQ PROTECT ON ISOUR AND TKATN 9/22/80 RSR
;FIX UNTALK 10/7/80 RSR
;******************************

162
KERNAL_VIC_04/tapecontrol

@ -0,0 +1,162 @@
.PAG 'TAPE CONTROL'
JTP20 JSR ZZZ
INC BUFPT
LDY BUFPT
CPY #BUFSZ
RTS
.SKI 5
;STAYS IN ROUTINE D2T1LL PLAY SWITCH
;
CSTE1 JSR CS10
BEQ CS25
LDY #MS7-MS1 ;"PRESS PLAY..."
CS30 JSR MSG
CS40 JSR TSTOP ;WATCH FOR STOP KEY
JSR CS10 ;WATCH CASSETTE SWITCHES
BNE CS40
LDY #MS18-MS1 ;"OK"
JMP MSG
.SKI 5
;SUBR RETURNS <> FOR CASSETTE SWITCH
;
CS10 LDA #$40 ;CHECK PORT
BIT D1ORA ;CLOSED?...
BNE CS25 ;NO. . .
BIT D1ORA ;CHECK AGAIN TO DEBOUNCE
CS25 CLC ;GOOD RETURN
RTS
.SKI 5
;CHECKS FOR PLAY & RECORD
;
CSTE2 JSR CS10
BEQ CS25
LDY #MS8-MS1 ;"RECORD"
BNE CS30
.SKI 5
;READ HEADER BLOCK ENTRY
;
RBLK LDA #0
STA STATUS
STA VERCK
JSR LDAD1
.SKI 3
;READ LOAD BLOCK ENTRY
;
TRD JSR CSTE1 ;SAY 'PRESS PLAY'
BCS TWRT3 ;STOP KEY PRESSED
SEI
LDA #0 ;CLEAR FLAGS...
STA RDFLG
STA SNSW1
STA CMP0
STA PTR1
STA PTR2
STA DPSW
LDA #$82 ;ENABLE FOR CA1 IRQ...READ LINE
LDX #14 ;POINT IRQ VECTOR TO READ
BNE TAPE ;JMP
.SKI 5
;WRITE HEADER BLOCK ENTRY
;
WBLK JSR LDAD1
;
;WRITE LOAD BLOCK ENTRY
;
TWRT LDA #20 ;BETWEEN BLOCK SHORTS
STA SHCNH
TWRT2 JSR CSTE2 ;SAY 'PRESS PLAY & RECORD'
TWRT3 BCS STOP3 ;STOP KEY PRESSED
SEI
LDA #$A0 ;ENABLE T2 IRQS...WRITE TIME
LDX #8 ;VECTOR IRQ TO WRTZ
.SKI 5
;START TAPE OPERATION ENTRY POINT
;
TAPE LDY #$7F ;KILL UNWANTED IRQ'S
STY D2IER
STA D2IER ;TURN ON WANTED
; WAIT FOR RS-232 TO FINISH
JSR RSP232
; MOVE IRQ TO IRQTEMP FOR CASS OPS
LDA CINV
STA IRQTMP
LDA CINV+1
STA IRQTMP+1
JSR BSIV ;GO CHANGE IRQ VECTOR
LDA #2 ;FSBLK STARTS AT 2
STA FSBLK
JSR NEWCH ;PREP LOCAL COUNTERS AND FLAGS
LDA D1PCR ;TURN MOTOR ON
AND #$FD ;LOW TURNS ON
ORA #$0C ;MAKE SURE
STA D1PCR
STA CAS1 ;FLAG INTERNAL CONTROL OF CASS MOTOR
LDX #$FF ;DELAY BETWEEN BLOCKS
TP32 LDY #$FF
TP35 DEY
BNE TP35
DEX
BNE TP32
STA D2T2H
CLI
TP40 LDA IRQTMP+1 ;CHECK FOR INTERRUPT VECTOR...
CMP CINV+1 ;...POINTING AT KEY ROUTINE
CLC
BEQ STOP3 ;...YES RETURN
JSR TSTOP ;...NO CHECK FOR STOP KEY
LDA D2IFR
AND #$40 ; CHECK FOR T1 IRQ
BEQ TP40 ;...NO
LDA D1T1L ; KILL T1 IRQ REQUEST
JSR UDTIM ; STOP KEY CHECK
JMP TP40 ;STAY IN LOOP UNTILL TAPES ARE DONE
.SKI 5
TSTOP JSR STOP ;STOP KEY DOWN?
CLC ;ASSUME NO STOP
BNE STOP4 ;WE WERE RIGHT
;
;STOP KEY DOWN...
;
JSR TNIF ;TURN OFF CASSETTES
SEC ;FAILURE FLAG
PLA ;BACK ONE SQUARE...
PLA
; LDA #0 ;STOP KEY FLAG
;
STOP3 LDA #0 ;DEALLOCATE IRQTMP
STA IRQTMP+1 ;IF C-SET THEN STOP KEY
STOP4 RTS
.SKI 5
;
; STT1 - SET UP TIMEOUT WATCH FOR NEXT DIPOLE
;
STT1 STX TEMP ;.X HAS CONSTANT FOR TIMEOUT
LDA CMP0 ;CMP0*5
ASL A
ASL A
CLC
ADC CMP0
CLC
ADC TEMP ;ADJUST LONG BYTE COUNT
STA TEMP
LDA #0
BIT CMP0 ;CHECK CMP0 ...
BMI STT2 ;...MINUS, NO ADJUST
ROL A ;...PLUS SO ADJUST POS
STT2 ASL TEMP ;MULTIPLY CORRECTED VALUE BY 4
ROL A
ASL TEMP
ROL A
TAX
STT3 LDA D2T2L ;WATCH OUT FOR D2T2H ROLLOVER...
CMP #21 ;...TIME FOR ROUTINE...!!!...
BCC STT3 ;...TOO CLOSE SO WAIT UND2T1LL PAST
ADC TEMP ;CALCULATE AND...
STA D2T1L ;...STORE ADUSTED TIME COUNT
TXA
ADC D2T2H ;ADJUST FOR HIGH TIME COUNT
STA D2T1H
CLI ;ALLOW FOR RE-ENTRY CODE
RTS
.END
; RSR 8/25/80 MODIFY I/O FOR MOD2 HARDWARE

195
KERNAL_VIC_04/tapefile

@ -0,0 +1,195 @@
.PAG 'TAPE FILES'
;FAH -- FIND ANY HEADER
;
;READS TAPE DEVICE UNTIL ONE OF FOLLOWING
;BLOCK TYPES FOUND: BDFH--BASIC DATA
;FILE HEADER, BLF--BASIC LOAD FILE
;FOR SUCCESS CARRY IS CLEAR ON RETURN.
;FOR FAILURE CARRY IS SET ON RETURN.
;IN ADDITION ACCUMULATOR IS 0 IF STOP
;KEY WAS PRESSED.
FAH LDA VERCK ;SAVE OLD VERIFY
PHA
JSR RBLK ;READ TAPE BLOCK
PLA
STA VERCK ;RESTORE VERIFY FLAG
BCS FAH40 ;READ TERMINATED
;
LDY #0
LDA (TAPE1)Y ;GET HEADER TYPE
;
CMP #EOT ;CHECK END OF TAPE?
BEQ FAH40 ;YES...FAILURE
;
CMP #BLF ;BASIC LOAD FILE?
BEQ FAH50 ;YES...SUCCESS
;
CMP #PLF ;FIXED LOAD FILE?
BEQ FAH50 ;YES...SUCCESS
;
CMP #BDFH ;BASIC DATA FILE?
BNE FAH ;NO...KEEP TRYING
;
FAH50 TAX ;RETURN FILE TYPE IN .X
BIT MSGFLG ;PRINTING MESSAGES?
BPL FAH45 ;NO...
;
LDY #MS17-MS1 ;PRINT "FOUND"
JSR MSG
;
;OUTPUT COMPLETE FILE NAME
;
LDY #5
FAH55 LDA (TAPE1)Y
JSR BSOUT
INY
CPY #21
BNE FAH55
FAH45 CLC ;SUCCESS FLAG
DEY ;MAKE NONZERO FOR OKAY RETURN
;
FAH40 RTS
.SKI 5
;TAPEH--WRITE TAPE HEADER
;ERROR IF TAPE BUFFER DE-ALLOCATED
;CARRY CLEAR IF O.K.
;
TAPEH STA T1
;
;DETERMINE ADDRESS OF BUFFER
;
JSR ZZZ
BCC TH40 ;BUFFER WAS DE-ALLOCATED
;
;PRESERVE START AND END ADDRESSES
;FOR CASE OF HEADER FOR LOAD FILE
;
LDA STAH
PHA
LDA STAL
PHA
LDA EAH
PHA
LDA EAL
PHA
;
;PUT BLANKS IN TAPE BUFFER
;
LDY #BUFSZ-1
LDA #'
BLNK2 STA (TAPE1)Y
DEY
BNE BLNK2
;
;PUT BLOCK TYPE IN HEADER
;
LDA T1
STA (TAPE1)Y
;
;PUT START LOAD ADDRESS IN HEADER
;
INY
LDA STAL
STA (TAPE1)Y
INY
LDA STAH
STA (TAPE1)Y
;
;PUT END LOAD ADDRESS IN HEADER
;
INY
LDA EAL
STA (TAPE1)Y
INY
LDA EAH
STA (TAPE1)Y
;
;PUT FILE NAME IN HEADER
;
INY
STY T2
LDY #0
STY T1
TH20 LDY T1
CPY FNLEN
BEQ TH30
LDA (FNADR)Y
LDY T2
STA (TAPE1)Y
INC T1
INC T2
BNE TH20
;
;SET UP START AND END ADDRESS OF HEADER
;
TH30 JSR LDAD1
;
;SET UP TIME FOR LEADER
;
LDA #$69
STA SHCNH
;
JSR TWRT2 ;WRITE HEADER ON TAPE
;
;RESTORE START AND END ADDRESS OF
;LOAD FILE.
;
TAY ;SAVE ERROR CODE IN .Y
PLA
STA EAL
PLA
STA EAH
PLA
STA STAL
PLA
STA STAH
TYA ;RESTORE ERROR CODE FOR RETURN
;
TH40 RTS
.SKI 5
;FUNCTION TO RETURN TAPE BUFFER
;ADDRESS IN TAPE1
;
ZZZ LDX TAPE1 ;ASSUME TAPE1
LDY TAPE1+1
CPY #>BUF ;CHECK FOR ALLOCATION...
;...[TAPE1+1]=0 OR 1 MEANS DEALLOCATED
;...C CLR => DEALLOCATED
RTS
.SKI 5
LDAD1 JSR ZZZ ;GET PTR TO CASSETTE
TXA
STA STAL ;SAVE START LOW
CLC
ADC #BUFSZ ;COMPUTE POINTER TO END
STA EAL ;SAVE END LOW
TYA
STA STAH ;SAVE START HIGH
ADC #0 ;COMPUTE POINTER TO END
STA EAH ;SAVE END HIGH
RTS
.SKI 5
FAF JSR FAH ;FIND ANY HEADER
BCS FAF40 ;FAILED
;
;SUCCESS...SEE IF RIGHT NAME
;
LDY #5 ;OFFSET INTO TAPE HEADER
STY T2
LDY #0 ;OFFSET INTO FILE NAME
STY T1
FAF20 CPY FNLEN ;COMPARE THIS MANY
BEQ FAF30 ;DONE
;
LDA (FNADR)Y
LDY T2
CMP (TAPE1)Y
BNE FAF ;MISMATCH--TRY NEXT HEADER
INC T1
INC T2
LDY T1
BNE FAF20 ;BRANCH ALWAYS
;
FAF30 CLC ;SUCCESS FLAG
FAF40 RTS
.END

124
KERNAL_VIC_04/time

@ -0,0 +1,124 @@
.PAG 'TIME FUNCTION'
;***********************************
;* *
;* TIME *
;* *
;*CONSISTS OF THREE FUNCTIONS: *
;* (1) UDTIM-- UPDATE TIME. USUALLY*
;* CALLED EVERY 60TH SECOND. *
;* (2) SETTIM-- SET TIME. .Y=MSD, *
;* .X=NEXT SIGNIFICANT,.A=LSD *
;* (3) RDTIM-- READ TIME. .Y=MSD, *
;* .X=NEXT SIGNIFICANT,.A=LSD *
;* *
;***********************************
;INTERRUPTS ARE COMING FROM TV HORIZONTAL
;WHICH IS CLOSE TO 60HZ BUT A LITTLE OVER.
;CRFAC COUNTS UP THEN SKIPS ONE UPDATE
;OF THE TIME REGISTER.
;
UDTIM LDX #0 ;PRE-LOAD FOR LATER
; INC CRFAC
; LDA CRFAC
; BNE UD10
; INC CRFAC+1
; UD10 CMP #$6F
; BNE UD20
; LDA CRFAC+1
; CMP #2
; BEQ UD50
;
;HERE WE PROCEED WITH AN INCREMENT
;OF THE TIME REGISTER.
;
UD20 INC TIME+2
BNE UD30
INC TIME+1
BNE UD30
INC TIME
;
;HERE WE CHECK FOR ROLL-OVER 23:59:59
;AND RESET THE CLOCK TO ZERO IF TRUE
;
;24:00:00 = 5184000 JIFFIES
;=79*65536+26*256+0
;=$4F*65536+$1A*256+$0+CORRECTION
;
;FINAL CORRECTION IS +1/60TH IN
;24 HOURS.
;
UD30 SEC
LDA TIME+2
SBC #$01
LDA TIME+1
SBC #$1A
LDA TIME
SBC #$4F
BCC UD60
;
;TIME HAS ROLLED--ZERO REGISTER
;
STX TIME
STX TIME+1
STX TIME+2
; BCS UD60 ;BRANCH ALWAYS
;
;COR. FACTOR ROLLED--ZERO IT
;
; UD50 STX CRFAC
; STX CRFAC+1
;
;SET STOP KEY FLAG HERE
;
UD60 LDA D2ORA ;WAIT FOR IT TO SETTLE
CMP D2ORA
BNE UD60 ;STILL BOUNCING
JMP STPTCH ;JUMP TO PATCH CHECKING FOR BOTH SHIFT KEYS
;
; THE FOLLOWING 3 BYTES WERE REPLACED WITH THE PRECEEDING JMP
;
; STA STKEY ;SAVE FOR OTHER ROUTINES
; RTS
.SKI 5
RDTIM SEI ;KEEP TIME FROM ROLLING
LDA TIME+2 ;GET LSD
LDX TIME+1 ;GET NEXT MOST SIG.
LDY TIME ;GET MSD
.SKI 5
SETTIM SEI ;KEEP TIME FROM CHANGING
STA TIME+2 ;STORE LSD
STX TIME+1 ;NEXT MOST SIGNIFICANT
STY TIME ;STORE MSD
CLI
RTS
SKIPIT = * ;GO AROUND THIS PATCH
;
;*********************************************************************
;
; PATCH TO CHECK FOR RIGHT SHIFT KEY ON STOP KEY CHECK
;
;*********************************************************************
;
*=KSP3
STPTCH
TAX ;SAVE STOP KEY ROW
SEC
ROL COLM ;LOOK AT NEXT ROW FOR THIS COLUMN
LDA ROWS
ROR COLM ;PUT IT BACK THE WAY IT WAS
AND #$40 ;CHECK RIGHT SHIFT KEY BIT
BEQ ITSSET ;BRANCH IF RIGHT SHIFT IS DOWN
;
STX STKEY ;ELSE LEAVE IT AS IT IS
RTS
;
ITSSET TXA
AND #$FD ;CLEAR THE SHIFT BIT
STA STKEY ;ITS NOT THE STOP KEY ALONE
RTS
;
KSP4 = *
*=SKIPIT
.END
; RSR 8/21/80 REMOVE CRFAC CHANGE STOP
; JM 1/21/80 FIX SO SHIT/STOP GIVE RUN FROM RIGHT

44
KERNAL_VIC_04/vectors

@ -0,0 +1,44 @@
.PAG 'JUMP TABLE/VECTORS'
*=$FF8A ;NEW VECTORS FOR BASIC
JMP RESTOR ;RESTORE VECTORS TO INITIAL SYSTEM
JMP VECTOR ;CHANGE VECTORS FOR USER
* =$FF90
JMP SETMSG ;CONTROL O.S. MESSAGES
JMP SECND ;SEND SA AFTER LISTEN
JMP TKSA ;SEND SA AFTER TALK
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 ACPTR ;HANDSHAKE IEEE BYTE IN
JMP CIOUT ;HANDSHAKE IEEE BYTE OUT
JMP UNTLK ;SEND UNTALK OUT IEEE
JMP UNLSN ;SEND UNLISTEN OUT IEEE
JMP LISTN ;SEND LISTEN OUT IEEE
JMP TALK ;SEND TALK OUT IEEE
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
JMP UDTIM ;INCREMENT CLOCK
JSCROG JMP SCRORG ;SCREEN ORG
JPLOT JMP PLOT ;READ/SET X,Y COORD
JIOBAS JMP IOBASE ;RETURN I/O BASE
*=$FFFA
.WOR NMI ;PROGRAM DEFINEABLE
.WOR START ;INITIALIZATION CODE
.WOR PULS ;INTERRUPT HANDLER
.END

193
KERNAL_VIC_04/write

@ -0,0 +1,193 @@
.PAG 'TAPE WRITE'
; CASSETTE INFO - FSBLK IS BLOCK COUNTER FOR RECORD
; FSBLK = 2 -FIRST HEADER
; = 1 -FIRST DATA
; = 0 -SECOND DATA
;
; WRITE - TOGGLE WRITE BIT ACCORDING TO LSB IN OCHAR
;
WRITE LDA OCHAR ;SHIFT BIT TO WRITE INTO CARRY
LSR A
LDA #96 ;...C CLR WRITE SHORT
BCC WRT1
WRTW LDA #176 ;...C SET WRITE LONG
WRT1 LDX #0 ;SET AND STORE TIME
WRTX STA D2T2L
STX D2T2H
LDA D2ORB ;TOGGLE WRITE BIT
EOR #$08
STA D2ORB
AND #$08 ;LEAVE ONLY WRITE BIT
RTS
;
WRTL3 SEC ;FLAG SAH FOR END OF BLOCK
ROR SAH
BMI WRT3 ; JMP
;
; WRTN - CALLED AT THE END OF EACH BYTE
; TO WRITE A LONG RER REZ
; HHHHHHLLLLLLHHHLLL...
;
WRTN LDA RER ;CHECK FOR ONE LONG
BNE WRTN1
LDA #16 ;WRITE A LONG BIT
LDX #1
JSR WRTX
BNE WRT3
INC RER
LDA SAH ;IF END OF BLOCK(BIT SET BY WRTL3)...
BPL WRT3 ;...NO END CONTINUE
JMP WRNC ;...END ...FINISH OFF
;
WRTN1 LDA REZ ;CHECK FOR A ONE BIT
BNE WRTN2
JSR WRTW
BNE WRT3
INC REZ
BNE WRT3
;
WRTN2 JSR WRITE
BNE WRT3 ;ON BIT LOW EXIT
LDA FIRT ;CHECK FOR FIRST OF DIPOLE
EOR #1
STA FIRT
BEQ WRT2 ;DIPOLE DONE
LDA OCHAR ;FLIPS BIT FOR COMPLEMENTARY RIGHT
EOR #1
STA OCHAR
AND #1 ;TOGGLE PARITY
EOR PRTY
STA PRTY
WRT3 JMP PREND ;RESTORE REGS AND RTI EXIT
;
WRT2 LSR OCHAR ;MOVE TO NEXT BIT
DEC PCNTR ;DEC COUNTER FOR # OF BITS
LDA PCNTR ;CHECK FOR 8 BITS SENT...
BEQ WRT4 ;...IF YES MOVE IN PARITY
BPL WRT3 ;...ELSE SEND REST
;
WRTS JSR NEWCH ;CLEAN UP COUNTERS
CLI ;ALLOW FOR INTERRUPTS TO NEST
LDA CNTDN ;ARE WE WRITING HEADER COUNTERS?...
BEQ WRT6 ;...NO
; WRITE HEADER COUNTERS (9876543210 TO HELP WITH READ)
LDX #0 ;CLEAR BCC
STX DATA
WRTS1 DEC CNTDN
LDX FSBLK ;CHECK FOR FIRST BLOCK HEADER
CPX #2
BNE WRT61 ;...NO
ORA #$80 ;...YES MARK FIRST BLOCK HEADER
WRT61 STA OCHAR ;WRITE CHARACTERS IN HEADER
BNE WRT3
;
WRT6 JSR CMPSTE ;COMPARE START:END
BCC WRT7 ;NOT DONE
BNE WRTL3 ;GO MARK END
INC SAH
LDA DATA ;WRITE OUT BCC
STA OCHAR
BCS WRT3 ;JMP
;
WRT7 LDY #0 ;GET NEXT CHARACTER
LDA (SAL)Y
STA OCHAR ;STORE IN OUTPUT CHARACTER
EOR DATA ;UPDATE BCC
STA DATA
JSR INCSAL ;INCREMENT FETCH ADDRESS
BNE WRT3 ;BRANCH ALWAYS
;
WRT4 LDA PRTY ;MOVE PARITY INTO OCHAR...
EOR #1
STA OCHAR ;...TO BE WRITTEN AS NEXT BIT
WRTBK JMP PREND ;RESTORE REGS AND RTI EXIT
;
WRNC DEC FSBLK ;CHECK FOR END
BNE WREND ;...BLOCK ONLY
JSR TNOF ;...WRITE, SO TURN OFF MOTOR
WREND LDA #80 ;PUT 80 CASSETTE SYNCS AT END
STA SHCNL
LDX #8
SEI
JSR BSIV ;SET VECTOR TO WRITE ZEROS
BNE WRTBK ;JMP
;
WRTZ LDA #120 ;WRITE LEADING ZEROS FOR SYNC
JSR WRT1
BNE WRTBK
DEC SHCNL ;CHECK IF DONE WITH LOW SYNC...
BNE WRTBK ;...NO
JSR NEWCH ;...YES CLEAR UP COUNTERS
DEC SHCNH ;CHECK IF DONE WITH SYNC...
BPL WRTBK ;...NO
LDX #10 ;...YES SO SET VECTOR FOR DATA
JSR BSIV
CLI
INC SHCNH ;ZERO SHCNH
LDA FSBLK ;IF DONE THEN...
BEQ STKY ;...GOTO SYSTEM RESTORE
JSR RD300
LDX #9 ;SET UP FOR HEADER COUNT
STX CNTDN
BNE WRTS ;JMP
;
TNIF PHP ;CLEAN UP INTERRUPTS AND RESTORE PIA'S
SEI
JSR TNOF ;TURN OFF MOTOR
LDA #$7F ;CLEAR INTERRUPTS
STA D2IER
LDA #$F7 ;RESTORE KEYBOARD COL FOR STOP CHECK
STA D2ORB
LDA #%01000000 ;D2ACR=FREE RUNNING T1, T2 ONE SHOT...
STA D2ACR ;...SHIFT DISABLED, AND NO LATCHING
JSR IOKEYS ;RESTORE KEYBOARD IRQ FROM TIMMER1
LDA IRQTMP+1 ;RESTORE KEYBOARD INTERRUPT VECTOR
BEQ TNIQ ;NO IRQ (IRQ VECTOR CANNOT BE Z-PAGE)
STA CINV+1
LDA IRQTMP
STA CINV
TNIQ PLP
RTS
;
STKY JSR TNIF ;GO RESTORE SYSTEM INTERRUPTS
BEQ WRTBK ;CAME FOR CASSETTE IRQ SO RTI
;
; BSIV - SUBROUTINE TO CHANGE IRQ VECTORS
; ENTRYS - .X = 8 WRITE ZEROS TO TAPE
; .X = 10 WRITE DATA TO TAPE
; .X = 12 RESTORE TO KEYSCAN
; .X = 14 READ DATA FROM TAPE
;
BSIV LDA BSIT-8,X ;MOVE IRQ VECTORS, TABLE TO INDIRECT
STA CINV
LDA BSIT+1-8,X
STA CINV+1
RTS
;
TNOF LDA D1PCR ;TURN OFF CASSETTE MOTOR
ORA #$0E ;...ON CA2
STA D1PCR
RTS
.SKI 3
;COMPARE START AND END LOAD/SAVE
;ADDRESSES. SUBROUTINE CALLED BY
;TAPE READ, SAVE, TAPE WRITE
;
CMPSTE SEC
LDA SAL
SBC EAL
LDA SAH
SBC EAH
RTS
.SKI 3
;INCREMENT ADDRESS POINTER SAL
;
INCSAL INC SAL
BNE INCR
INC SAH
INCR RTS
.END
; RSR 7/28/80 ADD COMMENTS
; RSR 8/4/80 CHANGED I/O FOR VIXEN
; RSR 8/21/80 CHANGED I/O FOR VIXEN MOD
; RSR 8/25/80 CHANGED I/O FOR VIXEN MOD2

8
README.md

@ -36,6 +36,14 @@ The sources have been verified to build the correct -03 KERNAL binary, but no gu
It does not contain the version byte at $FF80 (which is $AA in the binary) or the "RRBY" signature at $FFF6.
## BASIC_VIC
The Commodore VIC-20 BASIC source (901486-01). Extracted from basic.src from Bo Zimmer's [archive](http://www.zimmers.net/anonftp/pub/cbm/src/vic20/vic_src.tar.gz) and formatted the same as the C64 BASIC source.
## KERNAL_VIC_04
The Commodore VIC-20 KERNAL source, unrelease version (901486-04). Extracted from kernal.src from Bo Zimmer's [archive](http://www.zimmers.net/anonftp/pub/cbm/src/vic20/vic_src.tar.gz) and formatted the same as the C64 KERNAL source.
## BASIC_TED, KERNAL_TED_0{4|5}
The Commodore Plus/4, C16 and C116 BASIC 3.5 and KERNAL source (1984). Source: [ted_kernal_basic_src.tar.gz](http://www.zimmers.net/anonftp/pub/cbm/src/plus4/index.html)

Loading…
Cancel
Save