;SAVE#D:BCALC.PT1
	.OPT NO LIST
	*= 0
PASS	.= PASS+1
	.IF PASS=1
	.INCLUDE #D:BCALC.PT2
	.ENDIF 
;close	;!!!!!!!! INVERSE CHARS !!!!!!!!
;save X & res X in XSAV
	.MACRO CLOSE 
	LDX # <%1*16
	JSR CLOSE
	.ENDM 
;
	.OPT NO LIST
	*= $2000
SCMEM	    40*20
TXTWIN	    160
BF1	    $80
BF2	    $80
STRING	    $80
MDLST	.BYTE $70,$70,$50,$42
	.WORD SCMEM
	.BYTE $90,2,2,2,2,2,2
	.BYTE 2,2,2,2,2,2,2,2
	.BYTE 2,2,2,2,2,$90,$42
WFLP	.WORD TXTWIN
	.BYTE 2,2,2,$41
	.WORD MDLST
;dli	;!!!!!!!! INVERSE CHARS !!!!!!!!
DLI	PHA 
	TXA 
	PHA 
	LDX DLIX
	LDA DLIC,X
	STA WSYNC
	STA COLPF2
	INC DLIX
	PLA 
	TAX 
	PLA 
	RTI 
;
DLIX	.BYTE 0
DLIC	.BYTE $82,$00
;
;vblank	;!!!!!!!! INVERSE CHARS !!!!!!!!
VBI	LDA #0
	STA DLIX
	LDX #4
VB1	LDA COLOR0,X
	STA COLPF0,X
	DEX 
	BPL VB1
	JMP SYSVBV
;title	;!!!!!!!! INVERSE CHARS !!!!!!!!
BEGIN	JSR INIT
	JSR CLRSCN
	JSR DRAWH
	JSR SCRV
	JSR CLRTXT
	LDA # >MDLST
	STA SDLSTL+1
	LDA # <MDLST
	STA SDLSTL
	LDA # <SCMEM
	STA L
	LDA # >SCMEM
	STA L+1
	LDA # >CREDTF
	LDX # <CREDTF
	LDY #0
	JSR DPRINT
	JSR GNKEY
	LDA # >CREDIT
	LDX # <CREDIT
	LDY #0
	JSR DPRINT
	JSR IVCRS
BFLP	JSR CLRTXT
	JSR SHWREF
HINP	JSR CLRSTR
	LDA CONSOL
	CMP #5 	;sel
	BNE TOPT
	JMP COMMODE
TOPT	CMP #3
	BNE TKEY
	JSR SHOWST
	JMP BFLP
TKEY	LDA CH
	CMP #$FF
	BEQ HINP
	JSR GKEY
	LDX #16
	STA DM0
	AND #$7F
TSKY	CMP SPCKEY,X
	BEQ SPCAL
	DEX 
	BPL TSKY
	LDA DM0
	JSR INPUT
	BCS BFLP
	JMP GTIN
SPCAL	LDA SPECL,X
	STA SPJMP+1
	LDA SPECH,X
	STA SPJMP+2
	LDA #$FF
	STA CH
SPJMP	JSR $FFFF
	JSR SHWT2
	JMP BFLP
GTIN	LDA STRING
	CMP #EOL
	BNE GTN1
	JSR SHOCEL
	JMP HINP
GTN1	LDA STR
	BEQ HINP
	LDA FRCTXT
	BNE TRYTX
	LDA STRING
	CMP #'=
	BEQ AFNN
	CMP #'=	;!!!!!!!! INVERSE CHARS !!!!!!!!
	BEQ AFNN
	JMP TRYNU
AFNN	LDA STR
	STA STR2
	JSR LO2UP
	JSR TRYFNC
	BCC HOOK
	LDA #$82 	;error
	BNE FHOK
HOOK	LDA #2
FHOK	STA DTYP
	LDA STR2
	STA STR
	CLC 
	ADC # <STRING
	STA FLPTR
	LDA # >STRING
	ADC #0
	STA FLPTR+1
	LDX #0
	JSR FST0P
	LDA STR
	CLC 
	ADC #6
	STA STR
	TAX 
	LDA #EOL
	STA STRING,X
	JSR INSERT
	JSR CLRSTR
	LDX BF2+1
	JSR STFLPTR
	JSR FLD0P
	JSR NM2STR
	JMP GTR
TRYNU	CMP #'- 	;-,.,0-9
	BCC TRYTX
	BNE H1
	LDA STRING+1 	;nx chr #?
	CMP #':
	BCS TRYTX
	CMP #'/
	BEQ TRYTX
	CMP #'.
	BCC TRYTX
H1	CMP #'/
	BEQ TRYTX
	CMP #':
	BCS TRYTX
	JSR SBNUM
	JMP GTR
TRYTX	LDA #0
	STA DTYP
	STA FRCTXT
	JSR INSERT
GTR	LDA CRSY
	STA VCNT
	LDA SROW
	JSR REFROW
	JSR IVCRS
	LDA DTYP
	JSR SHWTYP
	LDA ONF
	BEQ NORC
	JSR RECALC
NORC	LDA CDIR
	BEQ NOCRS
	JSR MVCRS
NOCRS	JMP BFLP
;move crs rout	;!!!!!!!! INVERSE CHARS !!!!!!!!
MVCRS	CMP #$1F
	BEQ CR
	JMP CLA
CR	LDY SCOL
	CPY #63
	BCS NORT
	LDA CRSEN
	CLC 
	ADC COLW+1,Y
	CMP #41
	BCS SCRRT
	PHA 
	LDA CRSEN
	STA CRSX
	PLA 
	STA CRSEN
	INC SCOL
	LDA CURRW
	STA VCNT
	LDA SROW
	JSR REFROW
EXC1	JSR IVCRS
	LDY SCOL
	LDA FMCOL,Y
	STA FORMAT
NORT	RTS 
SCRRT	INC SCOL
	LDA #2 	;find 1st col
	LDY SCOL
FFLP	CLC 
	ADC COLW,Y
	CMP #40
	BCS FNF
	DEY 
	JMP FFLP
FNF	INY 
	STY FCOL
	JSR DRAWH
	JSR REFSCR
;find st/end of cursor
	LDA #2
	LDY FCOL
	CPY SCOL
	BEQ FSF
FSE	CLC 
	ADC COLW,Y
	INY 
	CPY SCOL
	BNE FSE
FSF	STA CRSX
	CLC 
	ADC COLW,Y
	STA CRSEN
	LDA SCOL
	CMP #63
	BNE FFJ
	LDA CRSX
	CLC 
	ADC COLW+63
	STA CRSEN
FFJ	JMP EXC1
;left	;!!!!!!!! INVERSE CHARS !!!!!!!!
CLA	CMP #$1E
	BNE CUA
CL	LDA CRSX
	CMP #2
	BNE PA
	LDA FCOL
	BNE SCRLL
	RTS 
PA	DEC SCOL
	LDA CURRW
	STA VCNT
	LDA SROW
	JSR REFROW
	LDA CRSX
	PHA 
	SEC 
	LDY SCOL
	SBC COLW,Y
	STA CRSX
	PLA 
	STA CRSEN
	JMP EXC1
SCRLL	DEC SCOL
	LDA SCOL
	STA FCOL
	JSR DRAWH
	JSR REFSCR
	LDA #2
	STA CRSX
	LDY FCOL
	CLC 
	ADC COLW,Y
	STA CRSEN
	JMP EXC1
;up	;!!!!!!!! INVERSE CHARS !!!!!!!!
CUA	CMP #$1C
	BNE CDJ
CU	LDA CURRW
	BNE R3
	LDA FROW
	BNE R4
	RTS 
R3	JSR IVCRS
	DEC CURRW
	DEC CRSY
	DEC SROW
	JMP IVCRS
R4	JSR IVCRS
	DEC FROW
	DEC SROW
;
	LDA # <[SCMEM+720]
	STA JL
	LDA # >[SCMEM+720]
	STA JL+1
	LDA # <[SCMEM+760]
	STA L
	LDA # >[SCMEM+760]
	STA L+1
	LDX #16
MUAG	JSR MOVSCN
	SEC 
	SBC #40
	STA JL
	LDA JL+1
	SBC #0
	STA JL+1
	DEX 
	BPL MUAG
;
	LDX #39
	LDA #0
UU	STA SCMEM+80,X
	DEX 
	BPL UU
	STA VCNT
	LDA #2
	STA SPX
	LDA FROW
	JSR REFROW
	JSR DRCOL
	JMP IVCRS
CDJ	CMP #$1D 	;down	;!!!!!!!! INVERSE CHARS !!!!!!!!
	BEQ CD
	RTS 
CD	LDA FROW
	CLC 
	ADC CURRW
	CMP #63
	BCC R1
	RTS 
R1	LDA CURRW
	CMP #17
	BCS R2
	JSR IVCRS
	INC CURRW
	INC CRSY
	INC SROW
	JMP IVCRS
R2	JSR IVCRS
	INC FROW
	INC SROW
;
	LDA # <[SCMEM+120]
	STA JL
	LDA # >[SCMEM+120]
	STA JL+1
	LDA # <[SCMEM+80]
	STA L
	LDA # >[SCMEM+80]
	STA L+1
	LDX #16
MDAG	JSR MOVSCN
	CLC 
	ADC #40
	STA JL
	LDA JL+1
	ADC #0
	STA JL+1
	DEX 
	BPL MDAG
	LDA #0
	LDX #39
DDZ	STA SCMEM+760,X
	DEX 
	BPL DDZ
	LDA #2
	STA SPX
	LDA #17
	STA VCNT
	CLC 
	ADC FROW
	JSR REFROW
	JSR DRCOL
	JMP IVCRS
;mov scrn	;!!!!!!!! INVERSE CHARS !!!!!!!!
MOVSCN	LDY #39
MS2	LDA (JL),Y
	STA (L),Y
	DEY 
	BPL MS2
	LDA JL+1
	STA L+1
	LDA JL
	STA L
	RTS 
;close	;!!!!!!!! INVERSE CHARS !!!!!!!!
CLOSE	STX XSAV
	LDA #12
	STA ICCOM,X
	JSR CIOV
	LDX XSAV
	RTS 
;draw screen	;!!!!!!!! INVERSE CHARS !!!!!!!!
SCRV	JSR DRCOL
	JMP CLEAR
SCRH	JSR DRAWH
CLEAR	JSR CLRSCN
	RTS 
;printa=h,x=l,y=strt	;!!!!!!!! INVERSE CHARS !!!!!!!!
DPRINT	STA IL+1
	STX IL
DOP	LDA (IL),Y
	CMP #EOL
	BEQ ENDP
	STA (L),Y
	INY 
	BNE DOP
ENDP	RTS 
;draw col#	;!!!!!!!! INVERSE CHARS !!!!!!!!
DRCOL	LDY #0
	STY VCNT
	LDA FROW
	STA BCD1
	INC BCD1
FG	LDA BCD1
	LDX #0
FE	CMP #10
	BCC FF
	SEC 
	SBC #10
	INX 
	BNE FE
FF	PHA 
	TXA 
	PHA 
	LDY VCNT
	LDA Y40L,Y
	STA L
	LDA Y40H,Y
	STA L+1
	PLA 
	ORA #$90
	LDY #0
	STA (L),Y
	PLA 
	INY 
	ORA #$90
	STA (L),Y
	INC BCD1
	INC VCNT
	LDA VCNT
	CMP #18
	BNE FG
	RTS 
;initial	;!!!!!!!! INVERSE CHARS !!!!!!!!
INIT	CLD 
	LDA # <[SCMEM+80]
	STA Y40L
	STA L
	LDA # >[SCMEM+80]
	STA Y40H
	STA L+1
	LDY #1
I1	LDA L
	CLC 
	ADC #40
	STA L
	STA Y40L,Y
	LDA L+1
	ADC #0
	STA L+1
	STA Y40H,Y
	INY 
	CPY #18
	BNE I1
;
	LDA # <DLI
	STA VDSLST
	LDA # >DLI
	STA VDSLST+1
	LDA #2
	STA COLOR4
	LDA #0
	STA COLOR2
	LDA #10
	STA COLOR1
	LDA #6
	LDX # >VBI
	LDY # <VBI
	JSR SETVBV
	LDA #$C0
	STA NMIEN
;
	LDY #63
IJ	LDA #8
	STA COLW,Y
	LDA #$20
	STA FMCOL,Y
	DEY 
	BPL IJ
	STA FORMAT
	LDA #0
	STA SPFLG
	LDX #$D1
ZPLP	STA $00,X
	DEX 
	BMI ZPLP
	STA CRSY
	STA RCFLG
	STA ONF
	LDA #2
	STA CRSX
	CLC 
	ADC COLW
	STA CRSEN
;keybd	;!!!!!!!! INVERSE CHARS !!!!!!!!
	LDA $79
	ORA $7A
	BEQ BUZZ
	LDA $79
	STA GTV+1
	LDA $7A
	STA GTV+2
;
BUZZ	LDA #$7F
	TAY 
	TAX 
KLP	TXA 
	STA AIT,Y
	EOR #$80
	STA AIT+$80,Y
	DEX 
	DEY 
	BMI KD
	CPY #$5F
	BNE KCA
	LDX #$3F
	BNE KLP
KCA	CPY #$1F
	BNE KLP
	LDX #$5F
	BNE KLP
;rad tabl	;!!!!!!!! INVERSE CHARS !!!!!!!!
KD	LDA # <RO1
	STA L
	LDA # >RO1
	STA L+1
	LDY #0
CET	LDA L
	STA RAD,Y
	LDA L+1
	INY 
	STA RAD,Y
	LDA L
	CLC 
	ADC #1
	STA L
	LDA L+1
	ADC #0
	STA L+1
	INY 
	CPY #$80
	BNE CET
	LDY #63
	LDA #$FF
CES	STA RO1,Y
	DEY 
	BPL CES
	LDA # <ENPROG
	STA ENDAT
	LDA # >ENPROG
	STA ENDAT+1
;fp table addresses	;!!!!!!!! INVERSE CHARS !!!!!!!!
	LDA # <FPSTACK
	STA L
	STA STLO
	LDA # >FPSTACK
	STA L+1
	STA STHI
	LDY #1
FPZ	LDA L
	CLC 
	ADC #6
	STA L
	STA STLO,Y
	LDA L+1
	ADC #0
	STA L+1
	STA STHI,Y
	INY 
	CPY #57
	BNE FPZ
	RTS 
;draw hor	;!!!!!!!! INVERSE CHARS !!!!!!!!
DRAWH	LDA # <[SCMEM+40]
	STA L
	LDA # >[SCMEM+40]
	STA L+1
	LDY #39
DH	LDA #$80
	STA (L),Y
	DEY 
	BPL DH
;
	LDA #2
	STA TM
	LDA FCOL
	STA TM1
COA	LDY TM1
	CPY #64
	BEQ CDO
	LDA COLW,Y
	PHA 
	LSR A
	CLC 
	ADC TM
	STA TM3
	DEC TM3
	PLA 
	CLC 
	ADC TM
	STA TM2
	CMP #41
	BCC COK
CDO	RTS 
COK	LDA #33
	STA TM4
	LDA TM1
	CMP #26
	BCC T2
	INC TM4
	SEC 
	SBC #26
	CMP #26
	BCC T2
	INC TM4
	SEC 
	SBC #26
T2	PHA 
	LDY TM3
	LDA TM4
	EOR #$80
	STA (L),Y
	PLA 
	CLC 
	ADC #$21
	EOR #$80
	INY 
	STA (L),Y
	INC TM1
	LDA TM2
	STA TM
	JMP COA
;inverse cursor	;!!!!!!!! INVERSE CHARS !!!!!!!!
IVCRS	JSR LOCCRS
	LDY CRSEN
	DEY 
IVS	LDA (L),Y
	EOR #$80
	STA (L),Y
	DEY 
	CPY CRSX
	BPL IVS
	LDY SCOL
	LDA FMCOL,Y
	STA FORMAT
	JSR SHWCRI
	RTS 
;find crsor	;!!!!!!!! INVERSE CHARS !!!!!!!!
LOCCRS	LDY CRSY
	LDA Y40L,Y
	STA L
	LDA Y40H,Y
	STA L+1
	RTS 
;clrtxt	;!!!!!!!! INVERSE CHARS !!!!!!!!
CLRTXT	LDY #0
	TYA 
CT	STA TXTWIN,Y
	INY 
	CPY #160
	BNE CT
	LDA #$80
	STA TXTWIN+2
	RTS 
;get reg. key	;!!!!!!!! INVERSE CHARS !!!!!!!!
GNKEY	JSR GKEY
	LDX #$FF
	STX CH
	RTS 
;get a key	;!!!!!!!! INVERSE CHARS !!!!!!!!
GKEY	LDA CH
	CMP #$FF
	BEQ GKEY
	STA OLDC
K0	TAY 
	CPY #$C0
	BCC GTV
	LDY #$9A
GTV	LDA $FEFE,Y
	STA OLDAC
KGB	CMP #$82 	;caps
	BNE KII
KIM	LDA CAPS
	EOR #$40
	STA CAPS
KIJ	LDA #$FF
	STA CH
	BNE GKEY
KII	CMP #$81 	;invrs
	BNE K3
	LDA INVFLG
	EOR #$80
	STA INVFLG
	JMP KIJ
K3	CMP #$83 	;shift
	BEQ KIM
	CMP #$84 	;control
	BEQ GKEY
	CMP #$85
	BEQ GKEY
	LDA OLDC
	CMP #$40
	BCS K6
	LDA OLDAC
	CMP #97
	BCC K6
	CMP #123
	BCS K6
	LDA CAPS
	BEQ K6
	ORA OLDC
	JMP K0
K6	LDA OLDAC
	LDX #15
KCMP	CMP SLKEY,X
	BEQ KOUT
	DEX 
	BPL KCMP
	EOR INVFLG
KOUT	RTS 
;twin print	;!!!!!!!! INVERSE CHARS !!!!!!!!
LIN1	LDY #1
	BNE TPS
LIN2	LDY #2
	BNE TPS
LIN3	LDY #3
TPS	LDA TWINL,Y
	STA L
	LDA TWINH,Y
	STA L+1
	LDY #1
	RTS 
;out of memry	;!!!!!!!! INVERSE CHARS !!!!!!!!
MERR	LDY #2
	JSR DSKERR
	JMP HOME
;moveup	;!!!!!!!! INVERSE CHARS !!!!!!!!
MOVUP	LDA ENDAT
	STA MFR+1
	CLC 
	ADC LENG
	STA MTO+1
	LDA ENDAT+1
	STA MFR+2
	ADC #0
	STA MTO+2
	CMP 106
	BCS MERR
	LDA ENDAT
	SEC 
	SBC LL
	STA NBYT
	LDA ENDAT+1
	SBC LL+1
	STA NBYT+1
	LDA ENDAT
	CLC 
	ADC LENG
	STA ENDAT
	LDA ENDAT+1
	ADC #0
	STA ENDAT+1
MAG	JSR MFR
	BCC MM1
	RTS 
MM1	DEC MFR+1
	LDA MFR+1
	CMP #$FF
	BNE MS
	DEC MFR+2
MS	DEC MTO+1
	LDA MTO+1
	CMP #$FF
	BNE MT
	DEC MTO+2
MT	JMP MAG
MFR	LDA $FFFF
MTO	STA $FFFF
MQ	DEC NBYT
	LDA NBYT
	CMP #$FF
	BNE CNR
	DEC NBYT+1
	LDA NBYT+1
	CMP #$FF
	BNE CNR
	SEC 
	RTS 
CNR	CLC 
	RTS 
;move dn	;!!!!!!!! INVERSE CHARS !!!!!!!!
MOVDN	LDA LL
	STA MTO+1
	CLC 
	ADC LENG
	STA MFR+1
	LDA LL+1
	STA MTO+2
	ADC #0
	STA MFR+2
	LDA ENDAT
	SEC 
	SBC MFR+1
	STA NBYT
	LDA ENDAT+1
	SBC MFR+2
	STA NBYT+1
	LDA ENDAT
	SEC 
	SBC LENG
	STA ENDAT
	LDA ENDAT+1
	SBC #0
	STA ENDAT+1
DD1	JSR MFR
	BCC DD4
	RTS 
DD4	INC MFR+1
	BNE DD2
	INC MFR+2
DD2	INC MTO+1
	BNE DD3
	INC MTO+2
DD3	JMP DD1
;as2ic	;!!!!!!!! INVERSE CHARS !!!!!!!!
AS2IC	STX XSAV
	TAX 
	LDA AIT,X
	LDX XSAV
	RTS 
;insert	;!!!!!!!! INVERSE CHARS !!!!!!!!
;b#0 =col # b#1 =format	;!!!!!!!! INVERSE CHARS !!!!!!!!
;b#2 = length b#3 = type	;!!!!!!!! INVERSE CHARS !!!!!!!!
;types:0=text 1 = # 2= function	;!!!!!!!! INVERSE CHARS !!!!!!!!
INSERT	LDA SCOL
	STA COLNU
	LDA FROW
	CLC 
	ADC CURRW
	STA ROWNU
	ASL A
	TAY 
	LDA RAD,Y
	STA LL
	INY 
	LDA RAD,Y
	STA LL+1
IU	LDY #0
	LDA (LL),Y
	BPL FCEL
IS	LDA STR
	CLC 
	ADC #DTLEN
	STA LENG
	JSR MOVUP
	LDY #0
	LDA COLNU
	STA (LL),Y
	LDA FORMAT 	;format
	LDY #1
	STA (LL),Y
	INY 
	LDA STR
	STA (LL),Y
	INY 
	LDA #0 	;flag2
	ORA DTYP
	STA (LL),Y
	JSR ADDDT
	LDY #0
IT	LDA STRING,Y
	STA (LL),Y
	INY 
	CPY STR
	BNE IT
	LDA STR
	CLC 
	ADC #DTLEN
	STA LENG
	LDA ROWNU
	JSR UPRAD
	RTS 
;mv RAD tabl up	;!!!!!!!! INVERSE CHARS !!!!!!!!
UPRAD	ASL A
	TAY 
	INY 
	INY 
	JMP IQ
IR	LDA RAD,Y
	CLC 
	ADC LENG
	STA RAD,Y
	INY 
	LDA RAD,Y
	ADC #0
	STA RAD,Y
	INY 
IQ	CPY #$80
	BNE IR
	RTS 
FCEL	CMP COLNU
	BNE NOD
	LDA ROWNU 	;4 del
	JSR DELTCL
	SEC  	;fall thru
NOD	BCS IS
	LDY #2
	LDA (LL),Y
	CLC 
	ADC LL
	STA LL
	LDA LL+1
	ADC #0
	STA LL+1
	JSR ADDDT
	JMP IU
;delete cell; A=row	;!!!!!!!! INVERSE CHARS !!!!!!!!
DELTCL	PHA 
	LDY #2
	LDA (LL),Y
	CLC 
	ADC #DTLEN
	STA LENG
	JSR MOVDN
	PLA 
	ASL A
	TAY 
	INY 
	INY 
	JMP DQ
DR	LDA RAD,Y
	SEC 
	SBC LENG
	STA RAD,Y
	INY 
	LDA RAD,Y
	SBC #0
	STA RAD,Y
	INY 
DQ	CPY #$80
	BNE DR
	RTS 
;clear screen	;!!!!!!!! INVERSE CHARS !!!!!!!!
CLRSCN	LDX #17
CTD	JSR CLRLIN
	DEX 
	BPL CTD
	RTS 
;enter w/X=row	;!!!!!!!! INVERSE CHARS !!!!!!!!
CLRLIN	LDA Y40L,X
	STA L
	LDA Y40H,X
	STA L+1
	LDA #0
	LDY #2
CSLP	STA (L),Y
	INY 
	CPY #40
	BNE CSLP
	RTS 
;find last col	;!!!!!!!! INVERSE CHARS !!!!!!!!
LSTCOL	LDY FCOL
OB	CLC 
	ADC COLW,Y
	CMP #40
	BCS OA
	INY 
	BNE OB
OA	STY TM2 	;lst col
	RTS 
;refresh screen	;!!!!!!!! INVERSE CHARS !!!!!!!!
REFSCR	LDA #0 	;vert lines
	STA VCNT
	LDA FROW
	STA TM1 	;rows
;
OH	LDA TM1
	JSR REFROW
	INC TM1
	INC VCNT
	LDA VCNT
	CMP #18
	BNE OH
	RTS  	;done
;get RAD	;!!!!!!!! INVERSE CHARS !!!!!!!!
STRAD	ASL A
	TAY 
	LDA RAD,Y
	STA LL
	INY 
	LDA RAD,Y
	STA LL+1
	RTS 
;ref a row enter w/A=row	;!!!!!!!! INVERSE CHARS !!!!!!!!
REFROW	PHA  	;save row
	LDA FCOL
	STA TM 	;col
	LDA #2
	STA SPX
	JSR LSTCOL
	LDX VCNT
	JSR CLRLIN
	PLA 
	JSR STRAD
VE	LDY #0
	LDA (LL),Y
	CMP #$FF
	BEQ VA 	;done w/row
	CMP TM
	BEQ VB 	;got col
	BCC VC
VD	LDY TM 	;next col
	LDA COLW,Y 	;scrn pos
	CLC 
	ADC SPX
	STA SPX
	INC TM
	LDA TM
	CMP TM2 	;last col?
	BCC VE
VA	RTS 
VC	JSR UP1COL 	;inc ll
	JMP VE
VB	LDA LL
	CLC 
	ADC #DTLEN
	STA IL
	LDA LL+1
	ADC #0
	STA IL+1 	;keep LL
	LDY VCNT
	LDA Y40L,Y
	STA JL
	LDA Y40H,Y
	STA JL+1
	LDA SPX
	STA TM3
	LDY #1
	LDA (LL),Y
	STA FORMAT
	LDY #3
	LDA (LL),Y
	BPL NNER
	JMP NUER
NNER	AND #3
	BEQ NNM
	CMP #1
	BEQ ISN 	;a #
	LDY #2 	;a F
	LDA (LL),Y
	SEC 
	SBC #6
	CLC 
	ADC IL
	TAX  	;low
	LDA IL+1
	ADC #0
	TAY 
	JMP ISN2
;put on scrn	;!!!!!!!! INVERSE CHARS !!!!!!!!
NNM	JSR CLRSTR
	LDY #2
	LDA (LL),Y
	TAY 
	LDA #EOL
	STA STRING,Y
	DEY 
YTA	LDA (IL),Y
	STA STRING,Y
	DEY 
	BPL YTA
	LDA # <STRING
	STA IL
	LDA # >STRING
	STA IL+1
	JSR FRMTXT 	;result in IL
;put on screen	;!!!!!!!! INVERSE CHARS !!!!!!!!
NNM1	LDY TM
	LDA COLW,Y
	STA GMX
	LDY #0
	STY TM4
YLP	LDY TM4
	LDA LBUF,Y
	JSR AS2IC
	LDY TM3
	STA (JL),Y
	INC TM4
	INC TM3
	LDA TM4
	CMP GMX
	BNE YLP
	JSR CLRSTR
	JMP VD
;refr #s il has #	;!!!!!!!! INVERSE CHARS !!!!!!!!
ISN	LDX IL 	;strt of #
	LDY IL+1
ISN2	JSR FLD0R
	JSR SETINB
	JSR FASC
	JSR FRMNUM
	JMP NNM1
;numbers	;!!!!!!!! INVERSE CHARS !!!!!!!!
SBNUM	LDA #1
	STA DTYP
	JSR SETFP
	JSR ZFR0
	JSR AFP
	LDX # <STRING
	LDY # >STRING
	JSR FST0R
	LDA #6
	STA STR
	JSR INSERT
	RTS 
;error in cell	;!!!!!!!! INVERSE CHARS !!!!!!!!
NUER	LDX #0
	LDA #5
	STA GMX
	LDY TM
	LDA COLW,Y
	CMP #4
	BNE ADQ
	DEC GMX
ADQ	LDY TM3
ADP	LDA ERMES,X
	STA (JL),Y
	INY 
	INX 
	CPX GMX
	BNE ADP
	JMP VD 	;nx col
;set fp ptrs	;!!!!!!!! INVERSE CHARS !!!!!!!!
SETFP	LDA # >STRING
	STA INBUF+1
	LDA # <STRING
	STA INBUF
	LDA #0
	STA CIX
	RTS 
;set inbuf	;!!!!!!!! INVERSE CHARS !!!!!!!!
SETINB	LDA # >LBUF
	STA INBUF+1
	LDA # <LBUF
	STA INBUF
	LDA #0
	STA CIX
	RTS 
;# to STRING	;!!!!!!!! INVERSE CHARS !!!!!!!!
NM2STR	JSR SETINB
	JSR FASC
	LDY #0
NLP	LDA (INBUF),Y
	BMI NL2
	STA STRING,Y
	INY 
	BNE NLP
NL2	AND #$7F
	STA STRING,Y
	INY 
	STY STR
	CPY #1
	BEQ NRT
	LDA STRING
	CMP #'0
	BNE NRT
	LDY #0
NL3	LDA STRING+1,Y
	STA STRING,Y
	INY 
	CPY STR
	BNE NL3
	DEC STR
NRT	RTS 
;do spec ctrl cmds	;!!!!!!!! INVERSE CHARS !!!!!!!!
;clear STRING for FP	;!!!!!!!! INVERSE CHARS !!!!!!!!
CLRSTR	LDX #$7F
	LDA #$20
CSTL	STA STRING,X
	DEX 
	BPL CSTL
	RTS 
;convert low to upp case	;!!!!!!!! INVERSE CHARS !!!!!!!!
LO2UP	LDY #0
LOLP	LDA STRING,Y
	CMP #EOL
	BEQ LODON
	AND #$7F
	CMP #'z+1
	BCS NLO
	CMP #'a
	BCC NLO
	EOR #$20
NLO	STA STRING,Y
	INY 
	BNE LOLP
LODON	RTS 
	.INCLUDE #D:BCALC.PT3
	.INCLUDE #D:BCALC.PT4
	.INCLUDE #D:BCALC.PT5
	.INCLUDE #D:BCALC.PT6
ENPROG	= *
	*= RUNAD
	.WORD BEGIN
	.END 
