NEW
  AUTO 3,1
				.LIST OFF
				.OP	65C02
				.OR	$2000
				.TF root/asmtest/testgui
*--------------------------------------
				.INB inc/macros.i
				.INB inc/a2osx.i
				.INB inc/mli.i
				.INB inc/gfx.i
				.INB inc/libgui.i
*--------------------------------------
				.DUMMY
				.OR ZPBIN
ZS.START
hLogo			.BS 2					00xx
hWND			.BS 1
hMBAR			.BS 1
TmpWord			.BS 2
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 #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.LIBGUI		.DA LIBGUI
L.LOGOFILE		.DA LOGOFILE
L.WND.TITLE		.DA WND.TITLE
L.WND.MBAR		.DA WND.MBAR
L.WND.STATUS	.DA WND.STATUS
L.WND.Test.fPaint	.DA WND.Test.fPaint
L.MENU.FILE		.DA MENU.FILE
L.MENU.EDIT		.DA MENU.EDIT
L.MENU.OPTIONS	.DA MENU.OPTIONS
L.MENU.HELP		.DA MENU.HELP
L.MENU.SUBMENU	.DA MENU.SUBMENU

				.DA 0
*--------------------------------------
CS.INIT			>LDYA L.LIBGUI
				>SYSCALL LoadLib
				bcs .9

				sta hLIBGUI

*				clc
.9				rts
*--------------------------------------
CS.RUN			>PUSHW L.LOGOFILE
				>PUSHBI	O.RDONLY
				>PUSHBI S.FI.T.PIX
				>PUSHWZ					Aux type
				>SYSCALL LoadStkObj
				bcs .9

				stx hLogo

				jsr WND.Test
				bcs .9

.1				>SLEEP


				bra .1

				clc

.9				rts
*--------------------------------------
CS.DOEVENT		lda (pEvent)
				bpl .9


.9				sec						never discard TIME event
				rts
*--------------------------------------
CS.QUIT			clc
CS.QUIT.RTS		rts
*--------------------------------------
WND.Test		>PUSHBI S.WND.F.RESIZE+S.WND.F.MOVE+S.WND.F.CLOSE+S.WND.F.MAX+S.WND.F.MIN

				>PUSHWI 40
				>PUSHWI 40
				>PUSHWI 400
				>PUSHWI 120
				>LIBCALL hLIBGUI,LIBGUI.WND.New
				bcs CS.QUIT.RTS
				sta hWND

				>PUSHA					A = hWND
				>PUSHBI S.WND.BGCOLOR
				>PUSHWI C.WHITE
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

*				>PUSHB hWND
*				>PUSHBI S.WND.BGBM
*				>PUSHW hLogo
*				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

				>PUSHB hWND
				>PUSHBI S.WND.hPTR
				>PUSHWI PTR.T.WAIT
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp
	
				>PUSHB hWND
				>PUSHBI S.WND.pTITLE
				>PUSHW L.WND.TITLE
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

				>LDYA L.MENU.FILE
				>STYA WND.MBAR.1
				>LDYA L.MENU.EDIT
				>STYA WND.MBAR.2
				>LDYA L.MENU.OPTIONS
				>STYA WND.MBAR.3
				>LDYA L.MENU.HELP
				>STYA WND.MBAR.4
				>LDYA L.MENU.SUBMENU
				>STYA MENU.OPTIONS.2

				>PUSHB hWND
				>PUSHW L.WND.MBAR
				>LIBCALL hLIBGUI,LIBGUI.WND.SetMBar

				>PUSHB hWND
				>PUSHBI S.WND.pSTATUS
				>PUSHW L.WND.STATUS
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp

				>PUSHB hWND
				>PUSHBI S.WND.fPaint
				>PUSHW L.WND.Test.fPaint
				>LIBCALL hLIBGUI,LIBGUI.OBJ.SetProp
				>STYA WND.Test.fPaint1+1

				lda hWND
				>LIBCALL hLIBGUI,LIBGUI.WND.Show

				rts
*--------------------------------------
WND.Test.fPaint	sta hWND

WND.Test.fPaint1
				jsr $ffff				Default WND.fPaint

.1				jsr WND.Test.1
				>PUSHW TmpWord
				>PUSHWI 0
				jsr WND.Test.2
	
				jsr WND.Test.1
				>PUSHW TmpWord
				>PUSHWI 94
				jsr WND.Test.2

				jsr WND.Test.3

				lda TmpWord
				cmp #400
				lda TmpWord+1
				sbc /400
				bcc .1

				stz TmpWord
				stz TmpWord+1
				
.3
				jsr WND.Test.1
				>PUSHWI 0
				>PUSHW TmpWord
				jsr WND.Test.2

				jsr WND.Test.1
				>PUSHWI 399
				>PUSHW TmpWord
				jsr WND.Test.2

				jsr WND.Test.4

				lda TmpWord
				cmp #94
				lda TmpWord+1
				sbc /94
				bcc .3
				
				clc
				rts
*--------------------------------------
WND.Test.1		>PUSHB hWND
				>PUSHBI S.CB.OP.SET		+S.CB.OP.COLOR
				>PUSHBI C.BLACK				C16.D.GREEN
				rts
				
WND.Test.2		>PUSHWI 240
				>PUSHWI 60
				>LIBCALL hLIBGUI,LIBGUI.DRAW.Line
				rts

WND.Test.3		lda TmpWord
				clc
				adc #4
				sta TmpWord
				bcc .1
				
				inc TmpWord+1
				
.1				rts

WND.Test.4		lda TmpWord
				clc
				adc #4
				sta TmpWord
				bcc .1
				
				inc TmpWord+1
				
.1				rts
*--------------------------------------
CS.END
LIBGUI			.AZ "libgui"
hLIBGUI			.BS 1
*--------------------------------------
LOGOFILE		.AZ "${ROOT}A2osX.logo"
WND.TITLE		.AZ "Libgui ASM API test"
WND.STATUS		.AZ "Window status bar message"
*--------------------------------------
WND.MBAR		.AZ "File"
WND.MBAR.1		.DA MENU.FILE
				.AZ "Edit"
WND.MBAR.2		.DA MENU.EDIT
				.AZ "Options"
WND.MBAR.3		.DA MENU.OPTIONS
				.AZ "?"
WND.MBAR.4		.DA MENU.HELP
				.DA #0
*--------------------------------------
MENU.FILE		.DA #S.MITEM.T.ITEM
				.DA #02					ID
				.DA #KEYMOD.CTRL,#'N'
				.DA 0					pICON
				.AZ "New"

				.DA #S.MITEM.T.ITEM
				.DA #04					ID
				.DA #KEYMOD.CTRL,#'O'
				.DA 0					pICON
				.AZ "Open..."

				.DA #S.MITEM.T.ITEM
				.DA #06					ID
				.DA #KEYMOD.CTRL,#'S'
				.DA 0					pICON
				.AZ "Save"

				.DA #S.MITEM.T.ITEM
				.DA #08					ID
				.DA #KEYMOD.OA+KEYMOD.CTRL,#'S'
				.DA 0					pICON
				.AZ "Save As..."

				.DA #S.MITEM.T.ITEM
				.DA #10					ID
				.DA #KEYMOD.CTRL,#'Q'
				.DA 0					pICON
				.AZ "Quit"

				.DA #0
*--------------------------------------
MENU.EDIT		.DA #S.MITEM.T.ITEM
				.DA #12					ID
				.DA #KEYMOD.CTRL,#'X'
				.DA 0					pICON
				.AZ "Cut"

				.DA #S.MITEM.T.ITEM
				.DA #14					ID
				.DA #KEYMOD.CTRL,#'C'
				.DA 0					pICON
				.AZ "Copy"

				.DA #S.MITEM.T.ITEM
				.DA #16					ID
				.DA #KEYMOD.CTRL,#'V'
				.DA 0					pICON
				.AZ "Paste"

				.DA #0
*--------------------------------------
MENU.OPTIONS	.DA #S.MITEM.T.ITEM
				.DA #18					ID
				.DA #0,#0
				.DA 0					pICON
				.AZ "Check Me"

				.DA #S.MITEM.T.SEP

				.DA #S.MITEM.T.SUBMENU
MENU.OPTIONS.2	.DA MENU.SUBMENU
				.DA 0					pICON
				.AZ "Sub Menu"

				.DA #0
*--------------------------------------
MENU.HELP		.DA #S.MITEM.T.ITEM
				.DA #20					ID
				.DA #0,#0
				.DA 0					pICON
				.AZ "About..."

				.DA #0
*--------------------------------------
MENU.SUBMENU	.DA #S.MITEM.T.ITEM
				.DA #18					ID
				.DA #0,#0
				.DA 0					pICON
				.AZ "Sub 1"

				.DA #S.MITEM.T.ITEM
				.DA #18					ID
				.DA #0,#0
				.DA 0					pICON
				.AZ "Sub 2"

				.DA #S.MITEM.T.ITEM
				.DA #18					ID
				.DA #0,#0
				.DA 0					pICON
				.AZ "Sub 3"

				.DA #0
*--------------------------------------
				.DUMMY
				.OR 0
DS.START
DS.END			.ED
*--------------------------------------
MAN
SAVE root/asmtest/testgui.s
ASM
