NEW
  AUTO 3,1
*--------------------------------------
FON.Init		>LDYA L.SYSX7
				jsr .1
				bcs .9

				stx hSYSFON

				>LDYA L.SYSX7B
				jsr .1
				bcs .9

				stx hSYSFONB

*				ldy #S.FON.PixH
*				>SYSCALL2 GetStkObjProp

				lda #7
				sta SYSFON.H
				inc
				sta SYSFON.Hp1
				inc
				sta SYSFON.Hp2

.9				rts

.1				>PUSHYA
				>PUSHBI	O.RDONLY
				>PUSHBI S.FI.T.FON
				>PUSHWZ					Aux type
				>SYSCALL LoadStkObj
				rts
*--------------------------------------
FON.GetTextSize	>STYA CB.Cache+S.CB.TxtPtr
				stx CB.Cache+S.CB.hFont

				lda #S.CB.CMD.GETTEXTSIZE+S.CB.CMD.OSD
				sta CB.Cache+S.CB.CMD
				ldx #0					Select CB.Cache
				jmp CB.GFXWriteX
*--------------------------------------
FON.GetTextSize2
				>STYA ZPPtr1
				stx CB.Cache+S.CB.hFont

				lda #S.CB.CMD.GETTEXTSIZE+S.CB.CMD.OSD
				sta CB.Cache+S.CB.CMD

				jsr FON.GetBuf
				bcs .9

				stz DX
				stz DX+1
				stz DY
				stz DY+1

.1				jsr FON.GetLine
				beq .8

				ldx #0					Select CB.Cache
				jsr CB.GFXWriteX

				ldx CB.Cache+S.CB.SrcW
				cpx DX
				lda CB.Cache+S.CB.SrcW+1
				tay
				sbc DX+1
				bcc .2

				stx DX
				sty DX+1

.2				lda CB.Cache+S.CB.SrcH
				clc
				adc DY
				sta DY

				lda CB.Cache+S.CB.SrcH+1
				adc DY+1
				sta DY+1

				lda (ZPPtr1)
				bne .1

.8				>LDYA ZPPtr2
				>SYSCALL2 Free

.9				rts
*--------------------------------------
FON.DrawText2	>STYA ZPPtr1
				stx CB.Cache+S.CB.hFont

				lda #S.CB.OP.XOR
				sta CB.Cache+S.CB.OP

				lda #S.CB.M.MONO
				sta CB.Cache+S.CB.M

				jsr CB.ResetSrcXY

				jsr FON.GetBuf
				bcs .9

				jsr PTR.Disable
*			>DEBUG
.1				jsr FON.GetLine
				beq .8

				lda #S.CB.CMD.DRAWTEXT+S.CB.CMD.OSD
				sta CB.Cache+S.CB.CMD

				ldx #0
				jsr CB.GFXWriteX
				bcs .9
				
*				ldx #0
*				jsr CB.GFXWriteX			Clip

				jsr CB.GFXWriteClip

				lda CB.Cache+S.CB.SrcPtr
				>SYSCALL2 FreeStkObj
				
				lda CB.Cache+S.CB.SrcH
				clc
				adc CB.Cache+S.CB.Y1
				sta CB.Cache+S.CB.Y1
				bcc .1
				
				inc CB.Cache+S.CB.Y1+1
				
				bra .1

.8				>LDYA ZPPtr2
				>SYSCALL2 Free
				
				jmp PTR.Enable

.9				rts
*--------------------------------------
FON.GetBuf		>LDYAI 256
				>SYSCALL2 GetMem
				bcs .9

				>STYA ZPPtr2
				>STYA CB.Cache+S.CB.TxtPtr

.9				rts
*--------------------------------------
FON.GetLine		ldy #0

.1				lda (ZPPtr1)
				beq .8

.2				cmp #C.SPACE
				bcs .3

				eor #C.CR
				beq .7
				bne .4

.3				sta (ZPPtr2),y
				iny

.4				inc ZPPtr1
				bne .1

				inc ZPPtr1+1
				bra .1

.7				inc ZPPtr1
				bne .8

				inc ZPPtr1+1

.8				sta (ZPPtr2),y
				tya						set Z flag

				rts
*--------------------------------------
MAN
SAVE usr/src/lib/libgui.s.fon
LOAD usr/src/lib/libgui.s
ASM
