NEW
  AUTO 3,1
				.LIST OFF	
				.OP	65C02
				.OR	$2000
				.TF BIN/GTEST
*--------------------------------------
				.INB INC/MACROS.I
				.INB INC/A2OSX.I
				.INB INC/KERNEL.I
				.INB INC/GFX.I
*--------------------------------------
				.DUMMY
				.OR ZPBIN
ZS.START
hDevGFX			.BS 1
hFont			.BS 1
hFontB			.BS 1
ZS.END
				.ED
*--------------------------------------
*			File Header (16 Bytes)
*--------------------------------------
CS.START		cld
				jmp (.1,x)
				.DA #$61				6502,Level 1 (65c02)
				.DA #1					BIN Layout Version 1
				.DA #0					#S.PS.F.EVENT		S.PS.F
				.DA #0
				.DA CS.END-CS.START		Code Size (without Constants)
				.DA DS.END-DS.START		Data Segment Size
				.DA #64					Stack Size
				.DA #ZS.END-ZS.START	Zero Page Size
				.DA 0
*--------------------------------------
.1				.DA CS.INIT
				.DA CS.RUN
				.DA CS.DOEVENT
				.DA	CS.QUIT
L.DEVNAME.GFX	.DA DEVNAME.GFX
L.FONTFILE		.DA FONTFILE
L.FONTFILEB		.DA FONTFILEB
L.PIXFILE		.DA PIXFILE
L.CB.RECT		.DA CB.RECT
L.CB.TEXTB		.DA CB.TEXTB
L.CB.TEXT		.DA CB.TEXT
L.CB.PIX		.DA CB.PIX
L.CB.Apple		.DA CB.Apple
L.BM.Apple		.DA BM.Apple
L.MESSAGEB		.DA MESSAGEB
L.MESSAGE		.DA MESSAGE

				.DA 0
*--------------------------------------
CS.INIT			clc
				rts
*--------------------------------------
CS.RUN			jsr GFX.Open
				bcs .9
				jsr LoadResources
				bcs .9
				>LDYA L.CB.RECT
				jsr GFX.Write.YA



				>LDYA L.BM.Apple
				>STYA CB.Apple+S.CB.SrcPtr

				>LDYA L.CB.PIX
				jsr GFX.Write.YA



				>LDYA L.CB.Apple
				jsr GFX.Write.YA



				lda hFontB
				sta CB.TEXTB+S.CB.hFont
				>LDYA L.MESSAGEB
				>STYA CB.TEXTB+S.CB.TxtPtr
				>LDYA L.CB.TEXTB
				>SYSCALL OSD
				bcs .9

				>LDYA L.CB.TEXTB
				jsr GFX.Write.YA



				lda hFont
				sta CB.TEXT+S.CB.hFont

				>LDYA L.MESSAGE
				>STYA CB.TEXT+S.CB.TxtPtr

				>LDYA L.CB.TEXT
				>SYSCALL OSD
				bcs .9

				>LDYA L.CB.TEXT
				jsr GFX.Write.YA

				lda #0
				sec
.9				rts
*--------------------------------------
CS.DOEVENT		clc
				rts
*--------------------------------------
CS.QUIT			lda hFont
				beq .1
				>SYSCALL FreeStkObj
.1				lda hFontB
				beq .2
				>SYSCALL FreeStkObj
.2				lda CB.PIX+S.CB.SrcPtr
				beq .3

				>SYSCALL FreeStkObj

.3
				lda hDevGFX
				beq .8
*			>DEBUG
*				>SYSCALL close
*			>DEBUG
.8	
				clc
				rts
*--------------------------------------
LoadResources	>PUSHWZ					Aux type
				>PUSHBI $CC				Type
				>PUSHBI	O.RDONLY	
				>LDYA L.FONTFILE
				>SYSCALL LoadStkObj
				bcs .9
				stx hFont

				>PUSHWZ					Aux type
				>PUSHBI $CC				Type
				>PUSHBI	O.RDONLY	
				>LDYA L.FONTFILEB
				>SYSCALL LoadStkObj
				bcs .9
				stx hFontb

				>PUSHWZ					Aux type
				>PUSHBI $CB				Type
				>PUSHBI	O.RDONLY	
				>LDYA L.PIXFILE
				>SYSCALL LoadStkObj
				bcs .9
				stx CB.PIX+S.CB.SrcPtr

.9				rts	
*--------------------------------------
GFX.Open		>PUSHBI 0
				>LDYA L.DEVNAME.GFX
				>SYSCALL open
				bcs .9
				sta hDevGFX
.9				rts
*--------------------------------------
GFX.Write.YA	>PUSHYA
				>PUSHBI IOCTL.WRITE
				lda hDevGFX
				>SYSCALL IOCTL
				rts		
*--------------------------------------
CS.END
DEVNAME.GFX		.AZ "/DEV/GFX"
FONTFILE		.AZ "${ROOT}SBIN/GUI/SYSX7"
FONTFILEB		.AZ "${ROOT}SBIN/GUI/SYSX7B"
PIXFILE			.AZ "${ROOT}ROOT/GUITEST/MARILYN"
MESSAGEB		.AZ " DHGR Driver & OSD 'Off-Screen Driver' Test (SYSX7B Font, Inverse) "
MESSAGE			.AZ " 1234567890 abcdefghijklmnopqrstuvwxyz { + - * / } (SYSX7B Font, Normal) "

CB.RECT			.DA #S.CB.CMD.FILLRECT
				.DA #S.CB.OP.SET
				.DA #S.CB.M.C16
				.DA #6					Color
				.DA 20
				.DA 10
				.DA 540
				.DA 182

CB.Apple		.DA #S.CB.CMD.BITBLT
				.DA #S.CB.OP.ORA+S.CB.OP.MASK+S.CB.OP.COLOR
				.DA #S.CB.M.C16
				.DA #0
				.DA 0					X1
				.DA 0					Y1
				.DA 16					SrcW
				.DA 7					SrcH
				.DA 20					DstX
				.DA 184					DstY
				.BS 2					SrcPtr
				.DA 0					DSTPTR

CB.PIX			.DA #S.CB.CMD.BITBLT
				.DA #S.CB.OP.SET+S.CB.OP.COLOR
				.DA #S.CB.M.MONO
				.DA #0
				.DA 10					X1
				.DA 20					Y1
				.DA 120					SrcW
				.DA 100					SrcH
				.DA 60					DstX
				.DA 50					DstY
				.BS 2					SrcPtr
				.DA 0					DSTPTR

CB.TEXTB		.DA #S.CB.CMD.DRAWTEXT
				.DA #S.CB.OP.SET+S.CB.OP.INVERSE
				.DA #S.CB.M.MONO
				.BS 1					hFONT
				.DA 0					X1
				.DA 0					Y1
				.DA 0					X2
				.DA 0					Y2
				.DA 7					DstX
				.DA 1					DstY
				.BS 2					TXTPTR
				.DA 0					DSTPTR

CB.TEXT			.DA #S.CB.CMD.DRAWTEXT
				.DA #S.CB.OP.SET
				.DA #S.CB.M.MONO
				.BS 1					hFONT
				.DA 0					X1
				.DA 0					Y1
				.DA 0					X2
				.DA 0					Y2
				.DA 50					DstX
				.DA 184					DstY
				.BS 2					TXTPTR
				.DA 0					DSTPTR

*--------------------------------------
BM.Apple		.DA #S.BM.F.BBP4
				.DA #2					RowBytes
				.DA 16					W
				.DA 7					H
				.DA BM.Apple.AND-BM.Apple
				.HS 0006				green (8)
				.HS 6006				green (8)
				.HS EEEE				yellow (15)
				.HS	CC0C				orange (14)
				.HS 8808				magenta (10)
				.HS 9999				violet (11)
				.HS 1001				Dark blue (4)
BM.Apple.AND	.HS FFF0
				.HS 0FF0
				.HS 0000
				.HS 00F0
				.HS 00F0
				.HS 0000
				.HS 0FF0
*--------------------------------------
				.DUMMY
				.OR 0
DS.START	
DS.END
				.ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/GTEST.S
ASM
