NEW
  AUTO 3,1
				.LIST OFF
				.OP	65C02
				.OR	$2000
				.TF sbin/gui
*--------------------------------------
				.INB inc/io.i
				.INB inc/macros.i
				.INB inc/a2osx.i
				.INB inc/gfx.i
				.INB inc/libgui.i
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
				.DUMMY
				.OR ZPBIN
ZS.START
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
				.DA #0
				.DA CS.END-CS.START		Code Size (without Constants)
				.DA DS.END-DS.START		Data SegmentSize
				.DA #64					Stack Size
				.DA #ZS.END-ZS.START	Zero Page Size
				.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1				.DA CS.INIT
				.DA CS.RUN
				.DA CS.DOEVENT
				.DA	CS.QUIT
L.LIBGUI		.DA LIBGUI
L.ABOUT.T		.DA ABOUT.T
L.ABOUT.M       .DA ABOUT.M
L.GUITEST1		.DA GUITEST1
L.GUITEST2		.DA GUITEST2
L.MSG			.DA MSG
				.DA 0
*--------------------------------------
CS.INIT			>LDYA L.LIBGUI
				>SYSCALL LoadLib
				bcs .9

				sta hLIBGUI

*				clc

.9				rts
*--------------------------------------
CS.RUN			>SLEEP
	
				>PUSHW L.MSG
				>LIBCALL hLIBGUI,LIBGUI.MSG.Get
				bcs CS.RUN

				lda MSG+S.MSG.T
				cmp #S.MSG.T.ID
				bne CS.RUN

				lda MSG+S.MSG.ID
				cmp #2
				bne .1

				jsr CS.RUN.MsgBox
				bra CS.RUN

.1				cmp #42
				bne .2

				>LDYA L.GUITEST1
				jsr CS.RUN.Exec
				bra CS.RUN

.2				cmp #44
				bne CS.RUN

				>LDYA L.GUITEST2
				jsr CS.RUN.Exec
				bra CS.RUN
*--------------------------------------
CS.RUN.MsgBox	>PUSHW L.ABOUT.T
                >PUSHWI BM.ID.INFO
				>PUSHW L.ABOUT.M
				>PUSHBI 63				BUT.ID.OK
				>LIBCALL hLIBGUI,LIBGUI.MBOX.MsgBox
				rts
*--------------------------------------
CS.RUN.Exec		>PUSHYA
				>PUSHBI 0
				>SYSCALL ExecL
				rts
*--------------------------------------
CS.DOEVENT		lda (pEvent)
				bpl .9

				>LIBCALL hLIBGUI,LIBGUI.PTR.Update

.9				sec
				rts
*--------------------------------------
CS.QUIT			lda hLIBGUI
				beq .8
				
				>SYSCALL UnloadLib

.8				clc
				rts
*--------------------------------------
CS.END
LIBGUI			.AZ "libgui"
hLIBGUI			.BS 1
ABOUT.T			.AZ "About GUI"
ABOUT.M			.CS "MsgBox demo with all possible buttons.\r\n"
				.CS "...Line 2...\r\n"
				.CZ "...Line 3.\r\n"
GUITEST1		.AZ "${ROOT}root/asmtest/testgui"
GUITEST2		.AZ "${ROOT}root/ctest/testgui"
*--------------------------------------
MSG				.BS S.MSG
*--------------------------------------
				.DUMMY
				.OR 0
DS.START

DS.END			.ED
MAN
SAVE usr/src/sbin/gui.s
ASM
