;SAVE#D:BCALC.PT3
;home pos.	;!!!!!!!! INVERSE CHARS !!!!!!!!
HOME	JSR CLRSCN
	JSR RSTCRS
HM2	JSR DRAWH
	JSR DRCOL
HM3	JSR REFSCR
	JSR SHWT2
	JMP IVCRS
;reset cursor	;!!!!!!!! INVERSE CHARS !!!!!!!!
RSTCRS	LDA #0
	STA FCOL
	STA FROW
	STA SROW
	STA SCOL
CRS2	STA CURRW
	STA CRSY
	LDA #2
	STA CRSX
	LDY FCOL
	CLC 
	ADC COLW,Y
	STA CRSEN
	RTS 
;show stats	;!!!!!!!! INVERSE CHARS !!!!!!!!
SHOWST	JSR CLRTXT
	LDY #26
SJA	LDA STT,Y
	STA TXTWIN+2,Y
	DEY 
	BPL SJA
	LDY #32
SJN	LDA SEG,Y
	STA TXTWIN+42,Y
	DEY 
	BPL SJN
;free mem	;!!!!!!!! INVERSE CHARS !!!!!!!!
	LDA #0
	SEC 
	SBC ENDAT
	STA FR0
	LDA 106
	SBC ENDAT+1
	STA FR0+1
	JSR IFP
	JSR FASC
	LDY #0
FMLP	LDA (INBUF),Y
	PHA 
	AND #$7F
	JSR AS2IC
	STA TXTWIN+29,Y
	INY 
	PLA 
	BPL FMLP
;file name	;!!!!!!!! INVERSE CHARS !!!!!!!!
	LDY #0
FSLP	LDA FNAME,Y
	CMP #EOL
	BEQ FSLL
	JSR AS2IC
	STA TXTWIN+7,Y
	INY 
	CPY #16
	BNE FSLP
FSLL	JSR GCH
	JMP CLRTXT
;set cross ref	;!!!!!!!! INVERSE CHARS !!!!!!!!
SETREF	JSR ST2BF1
	JSR FINARG
	BCS SO2
	JSR GTCLRW
	BCS SO2
	JSR FINARG
	LDX #0
S9LP	LDA BF1,Y
	STA BF1,X
	CMP #EOL
	BEQ S8P
	INY 
	INX 
	BNE S9LP
S8P	LDX #3
SFR	LDA BF1,X
	JSR AS2IC
	STA REFTAB,X
	DEX 
	BPL SFR
	LDA COLNU
	STA SETCOL
	LDA ROWNU
	STA SETROW
SO2	RTS 
;show refs	;!!!!!!!! INVERSE CHARS !!!!!!!!
SHWREF	JSR CLLIN3
	LDX #1
SWQ	LDA REFTAB+2,X
	STA TXTWIN+141,X
	LDA REFTAB,X
	STA TXTWIN+121,X
	DEX 
	BPL SWQ
	LDA FROW
	CLC 
	ADC CURRW
	JSR STRAD
XRA	LDY #0
	LDA (LL),Y
	CMP #$FF
	BEQ NRF
	CMP SETCOL
	BEQ GRF
	BCC URF
NRF	JMP SO7 	;try col
URF	JSR UP1COL
	JMP XRA
GRF	LDY #3
	LDA (LL),Y
	AND #3
	BEQ TXT 	;text
	CMP #1
	BNE NRF
	JSR LL2FR0
	JSR FASC
	LDY #0
SO6	LDA (INBUF),Y
	PHA 
	AND #$7F
	JSR AS2IC
	STA TXTWIN+124,Y
	PLA 
	BMI SO7
	INY 
	CPY #14
	BNE SO6
TXT	LDY #2
	LDA (LL),Y
	STA ASAV
	JSR ADDDT
	LDY #0
SO8	LDA (LL),Y
	JSR AS2IC
	STA TXTWIN+124,Y
	INY 
	CPY ASAV
	BEQ SO7
	CPY #14
	BNE SO8
;now show col	;!!!!!!!! INVERSE CHARS !!!!!!!!
SO7	LDA SETROW
	JSR STRAD
	LDA SCOL
	STA TM
XCL	LDY #0
	LDA (LL),Y
	CMP #$FF
	BEQ NCOL
	CMP TM
	BEQ GCOL
	BCC UCOL
NCOL	RTS 
UCOL	JSR UP1COL
	JMP XCL
GCOL	LDY #3
	LDA (LL),Y
	AND #3
	BEQ TTX 	;text
	CMP #1
	BNE NCOL
	JSR LL2FR0
	JSR FASC
	LDY #0
SK2	LDA (INBUF),Y
	PHA 
	AND #$7F
	JSR AS2IC
	STA TXTWIN+144,Y
	PLA 
	BMI SK3
	INY 
	CPY #14
	BNE SK2
TTX	LDY #2
	LDA (LL),Y
	STA ASAV
	JSR ADDDT
	LDY #0
SK4	LDA (LL),Y
	JSR AS2IC
	STA TXTWIN+144,Y
	INY 
	CPY ASAV
	BEQ SK3
	CPY #14
	BNE SK4
SK3	RTS 
;show data type	;!!!!!!!! INVERSE CHARS !!!!!!!!
SHWT2	LDX SCOL
	LDA SROW
	JSR LOCCEL
	BCC SKB
	LDA #3
	STA DTYP
	BNE SHWTYP
SKB	LDY #3
	LDA (LL),Y
	AND #3
	STA DTYP
	JMP SHWTYP
;ll # 2 fr0	;!!!!!!!! INVERSE CHARS !!!!!!!!
LL2FR0	JSR ADDDT
	LDX LL
	LDY LL+1
	JMP FLD0R 	;auto ret
;clear line3	;!!!!!!!! INVERSE CHARS !!!!!!!!
CLLIN3	LDY #119
	LDA #0
LP3	STA TXTWIN,Y
	INY 
	CPY #160
	BNE LP3
	RTS 
;show ent. type	;!!!!!!!! INVERSE CHARS !!!!!!!!
;0=t,1=#,2=f
SHWTYP	LDA DTYP
	ASL A
	ASL A
	ASL A
	TAX 
	LDY #31
STG	LDA TEXTYP,X
	STA SCMEM,Y
	INX 
	INY 
	CPY #39
	BNE STG
	RTS 
;drctry	;!!!!!!!! INVERSE CHARS !!!!!!!!
DIR	JSR CLRSCN
	LDA #'1
	STA DIRTXT+1
	JSR ST2BF1
	JSR FINARG
	BCS NDARG
	STA DIRTXT+1
NDARG	  CLOSE 2
	LDA #1
	STA VCNT
	LDA #3
	LDX #$20
	STA ICCOM,X
	LDA # <DIRTXT
	STA ICBAL,X
	LDA # >DIRTXT
	STA ICBAH,X
	LDA #6
	STA AUX1,X
	LDA #0
	STA AUX2,X
	JSR CIOV
	BPL DIROK
GENER	JSR DSKERR 	;error	;!!!!!!!! INVERSE CHARS !!!!!!!!
	JMP HM3
DIROK	LDX #$20
	LDA #5
	STA ICCOM,X
	LDA # <LBUF
	STA ICBAL,X
	LDA # >LBUF
	STA ICBAH,X
	LDA #0
	STA ICBLH,X
	LDA #$14
	STA ICBLL,X
	JSR CIOV
	BPL PRDIR
	JSR GCH
	  CLOSE 2
	JMP HM3
PRDIR	JSR SCNPOS
	LDX #0
	LDY #11
DIRLP	LDA LBUF,X
	CMP #EOL
	BEQ NXDR
	JSR AS2IC
	STA (L),Y
	INY 
	INX 
	JMP DIRLP
NXDR	INC VCNT
	LDA VCNT
	CMP #17
	BNE DIROK
	JSR GCH
	JSR CLRSCN
	LDA #0
	STA VCNT
	BEQ DIROK
;get scrn pos	;!!!!!!!! INVERSE CHARS !!!!!!!!
SCNPOS	LDY VCNT
	LDA Y40L,Y
	STA L
	LDA Y40H,Y
	STA L+1
	RTS 
;save	;!!!!!!!! INVERSE CHARS !!!!!!!!
SAVE	JSR ST2BF1
	JSR FINARG
	JSR GTFILE
	JSR CHKDEV
	BCC FILE?
DEVERR	LDY #165
	JMP GENER
FILE?	JSR FILEXST
	BCC DEVOK
	JMP HOME
DEVOK	LDA #8 	;write
	LDY #11 	;get rec
	BNE DOIT
LOAD	JSR ST2BF1
	JSR FINARG
	JSR GTFILE
	JSR CHKDEV
	BCS DEVERR
	LDA #4 	;read
	LDY #7 	;input
DOIT	STA DM6 	;keep em
	STY DM7
	  CLOSE 2
	LDX #$20
	LDA DM6
	STA AUX1,X
	LDA #3
	STA ICCOM,X
	LDA # <FNAME
	STA ICBAL,X
	LDA # >FNAME
	STA ICBAH,X
	LDA #0
	STA AUX2,X
	JSR CIOV
	BPL RWOK
	JMP GENER 	;error	;!!!!!!!! INVERSE CHARS !!!!!!!!
RWOK	LDX #$20
	LDA DM7
	TAY 
	STA ICCOM,X
	LDA # <COLW
	STA ICBAL,X
	LDA # >COLW
	STA ICBAH,X
	CPY #7 	;inp?
	BNE RITE
	LDA #$FF
	STA ICBLL,X
	STA ICBLH,X
	BNE SINP
RITE	LDA ENDAT
	SEC 
	SBC # <COLW
	STA ICBLL,X
	LDA ENDAT+1
	SBC # >COLW
	STA ICBLH,X
SINP	JSR CIOV
	BPL IOOK
	CPY #136 	;EOF?
	BEQ IOOK
	JMP GENER 	; error	;!!!!!!!! INVERSE CHARS !!!!!!!!
IOOK	  CLOSE 2
	LDA DM6
	CMP #8
	BEQ WRF
	LDX #$20
	LDA # <COLW
	CLC 
	ADC ICBLL,X
	STA ENDAT
	LDA # >COLW
	ADC ICBLH,X
	STA ENDAT+1
WRF	JMP HOME
;goto	;!!!!!!!! INVERSE CHARS !!!!!!!!
GOTO	JSR ST2BF1
	JSR FINARG
	BCS QAB
	JSR GTCLRW
	BCS QAB
	LDA ROWNU
	CMP #47
	BCS QAB
	LDA COLNU
	CMP #55
	BCS QAB
	JSR IVCRS
	JSR CLRSCN
	LDA COLNU
	STA FCOL
	STA SCOL
	LDA ROWNU
	STA FROW
	STA SROW
	LDA #0 	;4 crs2
	JSR CRS2
	JMP HM2
QAB	RTS 
;str2bf1	;!!!!!!!! INVERSE CHARS !!!!!!!!
ST2BF1	LDY #114
SO1	LDA STRING,Y
	STA BF1,Y
	DEY 
	BPL SO1
	RTS 
;recalc now	;!!!!!!!! INVERSE CHARS !!!!!!!!
ARECL	JSR RECALC
	JMP HOME
;force text	;!!!!!!!! INVERSE CHARS !!!!!!!!
FORCE	LDA #1
	STA FRCTXT
	RTS 
;kill cell	;!!!!!!!! INVERSE CHARS !!!!!!!!
KILLCL	LDA SCOL
	TAX 
	LDA FROW
	CLC 
	ADC CURRW
	STA TM
	JSR LOCCEL
	BCC LCELL
	RTS  	;none	;!!!!!!!! INVERSE CHARS !!!!!!!!
LCELL	LDA TM
	JSR DELTCL
	JSR IVCRS
	LDA #2
	STA SPX
	LDA CURRW
	STA VCNT
	LDA SROW
	JSR REFROW
	JSR IVCRS
	RTS 
;find arg	;!!!!!!!! INVERSE CHARS !!!!!!!!
FINARG	LDY #0
F8LP	LDA BF1,Y
	CMP #EOL
	BEQ NOARG
	CMP #$20
	BEQ FSPCE
	INY 
	CPY #$20
	BNE F8LP
NOARG	SEC 
	RTS 
FSPCE	INY 
FARG	LDA BF1,Y
	CMP #EOL
	BEQ NOARG
	CMP #$20 	;spac
	BNE GTARG
	INY 
	CPY #$20
	BNE FARG
	BEQ NOARG
GTARG	CLC 
	RTS 
;get file name	;!!!!!!!! INVERSE CHARS !!!!!!!!
GTFILE	LDX #0
F9LP	LDA BF1,Y
	STA FNAME,X
	CMP #EOL
	BEQ FGD
	INY 
	INX 
	BNE F9LP
FGD	RTS 
;chng col width	;!!!!!!!! INVERSE CHARS !!!!!!!!
WIDTH	JSR ST2BF1
	JSR FINARG
	BCS NOW
	JSR GTCLRW
	BCS NOW
	INC ROWNU
	LDA ROWNU
	CMP #2
	BCC NOW
	CMP #33
	BCS NOW
	LDY COLNU
	STA COLW,Y
	JSR CLRSCN
	JSR DRAWH
	JSR REFSCR
	LDY FCOL
	STY SCOL
	LDA #2
	STA CRSX
	CLC 
	ADC COLW,Y
	STA CRSEN
	JSR IVCRS
NOW	RTS 
;show a cell's content	;!!!!!!!! INVERSE CHARS !!!!!!!!
SHOCEL	LDX SCOL
	LDA SROW
	JSR LOCCEL
	BCC UAA
	RTS  	;none
UAA	LDY #1 	;format
	LDA (LL),Y
	STA $00
	INY  	;length
	LDA (LL),Y
	STA LENG
	INY 
	LDA (LL),Y
	AND #3
	BNE UAB
UAG	JSR ADDDT
	LDY LENG 	;text
	DEY 
UAH	LDA (LL),Y
	STA STRING,Y
	DEY 
	BPL UAH
UAE	LDA #$FF
	STA XPOS
	JSR DRWIN
	RTS  	;done	;!!!!!!!! INVERSE CHARS !!!!!!!!
UAB	CMP #2
	BEQ UAF
	JSR ADDDT
	LDX LL
	LDY LL+1
	JSR FLD0R
	JSR FASC
	LDY #0
UAD	LDA (INBUF),Y
	PHA 
	AND #$7F
	STA STRING,Y
	PLA 
	BMI UAE
	INY 
	BNE UAD
UAF	LDA LENG
	SEC 
	SBC #6
	STA LENG
	JMP UAG
;edit mode	;!!!!!!!! INVERSE CHARS !!!!!!!!
EDITM	LDA #1
	STA EDIT
	JSR SHOCEL
	JSR INPUT2
	PHP 
	LDA #0
	STA EDIT
	PLP 
	BCC EOOK
	RTS 
EOOK	PLA 
	PLA 
	LDA $00
	STA FORMAT
	JMP GTIN
;format a cell or colm	;!!!!!!!! INVERSE CHARS !!!!!!!!
FORM	JSR CLRTXT
	LDY SCOL
	LDA FMCOL,Y
	STA FORMAT
	LDX #18
FPB	DEX 
	BMI FPX
FPA	LDA FMES,X
	STA TXTWIN+2,X
	CPX #5
	BCC FPB
	LDA FMA-5,X
	STA TXTWIN+42,X
	LDA FMB-5,X
	STA TXTWIN+82,X
	LDA FMC-5,X
	STA TXTWIN+122,X
	JMP FPB
FPX	JMP SHOFRM
;
FPC	LDA CH
	CMP #$FF
	BEQ FPC
	LDX #$FF
	STX CH
	CMP #$1C
	BNE FPD
	RTS  	;done	;!!!!!!!! INVERSE CHARS !!!!!!!!
FPD	LDX #2
FPE	CMP JSKEY,X
	BEQ FPF
	DEX 
	BPL FPE
	BMI FPG
FPF	LDA FORMAT
	AND #252
	STA ASAV
	TXA 
	ORA ASAV
	STA FORMAT
	JMP SHOFRM
FPG	CMP #$3A 	;D
	BNE FPH
	LDA FORMAT
	EOR #8
	STA FORMAT
	JMP SHOFRM
FPH	CMP #$20 	;,
	BNE FPJ
	LDA FORMAT
	EOR #4
	STA FORMAT
	JMP SHOFRM
FPJ	LDX #9
FPK	CMP NKEY,X 	;dec places
	BEQ FQD
	DEX 
	BPL FPK
	BMI FPC
FQD	TXA 
	PHA 
	LDA FORMAT
	AND #$0F
	STA FORMAT
	PLA 
	ASL A
	ASL A
	ASL A
	ASL A
	ORA FORMAT
	STA FORMAT
;
SHOFRM	LDA FORMAT
	AND #3
	TAX 
	LDA LCR,X
	STA TXTWIN+19
	LDA FORMAT
	AND #8
	LSR A
	LSR A
	LSR A
	TAX 
	LDA YN,X
	STA TXTWIN+59
	LDA FORMAT
	AND #4
	LSR A
	LSR A
	TAX 
	LDA YN,X
	STA TXTWIN+99
	LDA FORMAT
	AND #$F0
	LSR A
	LSR A
	LSR A
	LSR A
	TAX 
	LDA SDEC,X
	STA TXTWIN+139
	JMP FPC
;global format	;!!!!!!!! INVERSE CHARS !!!!!!!!
GLOBAL	JSR FORM
	LDY SCOL
	LDA FORMAT
	STA FMCOL,Y
	RTS 
;format a cell	;!!!!!!!! INVERSE CHARS !!!!!!!!
FORMC	LDA SROW
	LDX SCOL
	JSR LOCCEL
	BCC ECL
	RTS 
ECL	JSR FORM
	LDY #1
	LDA FORMAT
	STA (LL),Y
	LDX CURRW
	STX VCNT
	LDA SROW
	JSR REFROW
	LDY SCOL 	;restore
	LDA FMCOL,Y 	;glob. formt
	STA FORMAT
	JMP IVCRS
;recalc flag	;!!!!!!!! INVERSE CHARS !!!!!!!!
RONOF	LDA ONF
	EOR #3
	STA ONF
	TAX 
	LDY #0
RPP	LDA ONOFM,X
	STA SEG+7,Y
	INX 
	INY 
	CPY #3
	BNE RPP
	RTS 
;flip row/col flg	;!!!!!!!! INVERSE CHARS !!!!!!!!
RCFLP	LDA RCFLG
	EOR #6
	STA RCFLG
	TAX 
	LDY #0
RHK	LDA RCMES,X
	STA SEG+27,Y
	INX 
	INY 
	CPY #6
	BNE RHK
	RTS 
;disk error	;!!!!!!!! INVERSE CHARS !!!!!!!!
DSKERR	STY YSAV
	  CLOSE 2
	LDY YSAV
	STY FR0
	LDA #0
	STA FR0+1
	JSR IFP
	JSR FASC
	LDY #$FF
ERLPA	INY 
	LDA (INBUF),Y
	PHA 
	AND #$7F
	JSR AS2IC
	STA DERM+6,Y
	PLA 
	BPL ERLPA
	JSR CLLIN3
	LDY #20
ERLPB	LDA DERM,Y
	STA TXTWIN+124,Y
	DEY 
	BPL ERLPB
	LDA #$FF
	STA CH
	JSR GAKEY
	RTS 
;Number Format Subroutine
;for B-CALC
;FORMAT BYTE 1	;!!!!!!!! INVERSE CHARS !!!!!!!!
;bit 4-7: Places after Decimal
;bit 3:   Dollar Sign Flag
;bit 2:   Comma Flag
;bit 0-1: L/C/R Justify
;
FRMNUM	LDY #$FF
:FM0	INY 
	LDA (INBUF),Y
	STA NUMB,Y
	BPL :FM0
	LDY #$7F
	LDA #'0
FN.1	STA STRING,Y
	DEY 
	BPL FN.1
	LDA #'$
	STA STRING
	LDA # <[STRING+1]
	STA IL
	LDA # >[STRING+1]
	STA IL+1
;
	LDA FORMAT 	;get FM byte
	PHA 
	AND #$F0
	LSR A
	LSR A
	LSR A
	LSR A
	STA TORITE
	PLA 
;
	AND #4 	;commas?
	BNE FNCOM 	;yes
	LDY #$FF
:CPL	INY 
	LDA (INBUF),Y
	STA (IL),Y
	BPL :CPL
:FM1	JMP :DSGN
;insert ','s	;!!!!!!!! INVERSE CHARS !!!!!!!!
FNCOM	LDY #$FF
FM:1	INY 
	LDA NUMB,Y
	BMI FM:D
	CMP #'.
	BNE FM:1
	DEY 
FM:D	STY SVY
	LDX #29
:LP1	LDA #2
	STA FCNT
:LP2	LDA NUMB,Y
	AND #$7F
	STA LBUF,X
	DEX 
	DEY 
	BMI :LV
	DEC FCNT
	BPL :LP2
	LDA #',
	STA LBUF,X
	DEX 
	BPL :LP1
:LV	INX 
	LDY #1
:LP3	LDA LBUF,X
	STA STRING,Y
	INY 
	INX 
	CPX #30
	BNE :LP3
	LDX SVY
	LDA NUMB,X
	BPL :NNV
	DEY 
	LDA STRING,Y
	ORA #$80
	STA STRING,Y
	BNE :DSGN
;
:NNV	INX 
	LDA NUMB,X
	STA STRING,Y
	BMI :DSGN
	INY 
	BNE :NNV
;
:DSGN	LDA FORMAT
	AND #8
	BEQ :AFTER
	LDA # <STRING
	STA IL
	LDA # >STRING
	STA IL+1
;handle places after decimal	;!!!!!!!! INVERSE CHARS !!!!!!!!
;search for E	;!!!!!!!! INVERSE CHARS !!!!!!!!
:AFTER	LDA #0
	STA SCI 	;flag
	LDY #$FF
HXA	INY 
	LDA STRING,Y
	BMI :AF2 	;none
	CMP #'E
	BNE HXA 	;kot yet
;got exp
	INC SCI 	;set flg
	DEY  	;invs prev byt
	LDA STRING,Y
	ORA #$80
	STA STRING,Y
	LDX #$FF 	;bck to E
HXB	INX 
	INY 
	LDA STRING,Y
	PHA 
	AND #$7F
	STA SVEX,X
	LDA #'0
	STA STRING,Y
	PLA 
	BPL HXB
;show end
	INX 
	STX SCI
	LDA #EOL
	STA SVEX,X
:AF2	LDY #$FF
:AF	INY 
	LDA STRING,Y
	BPL :TP
	AND #$7F
	STA STRING,Y
	INY 
	LDA #'.
	STA STRING,Y
	STY SVY
	JMP :JM
:TP	CMP #'.
	BNE :AF
	STY SVY
:A2	INY 
	LDA STRING,Y
	BPL :A2
	AND #$7F
	STA STRING,Y
:JM	LDA SVY
	CLC 
	ADC TORITE
	TAY 
	LDA TORITE
	BNE :EL
	DEY 
:EL	LDA #EOL
	STA STRING+1,Y
;chk for E
	LDA SCI
	BEQ CKMIN
	LDX #0
HXC	LDA SVEX,X
	STA STRING+1,Y
	CMP #EOL
	BEQ CKMIN
	INX 
	INY 
	BNE HXC
;chk for $-,	;!!!!!!!! INVERSE CHARS !!!!!!!!
CKMIN	LDA STRING+1
	CMP #'-
	BNE FRMTXT
	LDA STRING+2
	CMP #',
	BNE FRMTXT
	LDY #0
MILP	LDA STRING+3,Y
	STA STRING+2,Y
	CMP #EOL
	BEQ FRMTXT
	INY 
	BNE MILP
;get length of number	;!!!!!!!! INVERSE CHARS !!!!!!!!
FRMTXT	LDY #$FF
:L1	INY 
	LDA (IL),Y
	CMP #EOL
	BNE :L1
	STY SVY
;left/center/right justify	;!!!!!!!! INVERSE CHARS !!!!!!!!
:LCR	LDX #$7F
	LDA #$20
:L2	STA LBUF,X
	DEX 
	BPL :L2
;
	LDA FORMAT
	AND #3
	TAX 
	BEQ :HAV
;right justify	;!!!!!!!! INVERSE CHARS !!!!!!!!
	DEX 
	BNE :CEN
	LDY TM
	LDA COLW,Y
	SEC 
	SBC SVY
	BPL :HV
YUA	LDX #0
	BEQ :LC
;center	;!!!!!!!! INVERSE CHARS !!!!!!!!
:CEN	LDY TM
	LDA COLW,Y
	SEC 
	SBC SVY
	BPL :C1
	EOR #$FF
	LSR A
	TAY 
	JMP YUA
:C1	LSR A
:HV	TAX 
;copy the number	;!!!!!!!! INVERSE CHARS !!!!!!!!
:HAV	LDY #$FF
:LC	INY 
	LDA (IL),Y
	CMP #EOL
	BEQ :LB
	STA LBUF,X
	INX 
	BNE :LC
:LB	LDA # <LBUF
	STA IL
	LDA # >LBUF
	STA IL+1
	RTS 
SCI	.BYTE 0
SVEX	    4
	.BYTE EOL
;check for D:	;!!!!!!!! INVERSE CHARS !!!!!!!!
CHKDEV	LDA FNAME
	CMP #'D
	BNE WRDEV
	LDA FNAME+1
DVNUM	CMP #':
	BEQ AYOK
	CMP #'8
	BEQ MYOK
	CMP #'1
	BCC WRDEV
	CMP #'4
	BCS WRDEV
	BCC MYOK
AYOK	CLC 
	RTS 
WRDEV	SEC 
	RTS 
MYOK	LDA FNAME+2
	CMP #':
	BEQ AYOK
	BNE WRDEV
;check if file exist	;!!!!!!!! INVERSE CHARS !!!!!!!!
FILEXST	LDA #0
	STA TXTWIN+2
	  CLOSE 2
	LDA #36 	;unloc
	STA ICCOM,X
	LDA # >FNAME
	STA ICBAH,X
	LDA # <FNAME
	STA ICBAL,X
	JSR CIOV
	LDA ICCOM+1,X 	;stat?
	PHA 
	  CLOSE 2
	PLA 
	CMP #1
	BEQ FYES
OVWR	CLC 
	RTS 
FYES	LDA # >REPMES
	LDX # <REPMES
	LDY #1
	JSR PRNTTW
YNK	LDA CH
	LDX #$FF
	CMP #$2B 	;yes
	BEQ OVWR
	CMP #$23
	BNE YNK
	STX CH
	SEC  	;no
	RTS 
