A2osX/ROOT/asmtest/TESTTUI.S.txt

410 lines
12 KiB
Plaintext
Raw Normal View History

2023-01-23 18:33:37 +00:00
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF root/asmtest/testtui
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/libtui.i
*--------------------------------------
EV.SAVE .EQ $C0
EV.OK .EQ $CE
EV.CANCEL .EQ $CF
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
hCTX .BS 1
hSCRN .BS 1
hTBOX1 .BS 1
hDLGS .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
2023-01-23 18:33:37 +00:00
.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
2023-01-23 18:33:37 +00:00
.DA 0
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTUI .DA LIBTUI
*--------------------------------------
L.SCRN.Title .DA SCRN.Title
L.SCRN.Status .DA SCRN.Status
L.TBOX1.Title .DA TBOX1.Title
L.TBOX1.Status .DA TBOX1.Status
L.LBOX1.List .DA LBOX1.List
L.LABEL.Label .DA LABEL.Label
L.RADIO1.List .DA RADIO1.List
L.CBOX1.Label .DA CBOX1.Label
L.BUTQ.Label .DA BUTQ.Label
L.BUTS.Label .DA BUTS.Label
L.DLGS.Title .DA DLGS.Title
L.BUT.OK .DA BUT.OK
L.BUT.Cancel .DA BUT.Cancel
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTUI
>SYSCALL LoadLib
bcs CS.INIT.RTS
2023-01-23 18:33:37 +00:00
sta hLIBTUI
2023-01-23 18:33:37 +00:00
* clc
2023-01-23 18:33:37 +00:00
CS.INIT.RTS rts
*--------------------------------------
CS.RUN >LIBCALL hLIBTUI,LIBTUI.Init
2023-01-23 18:33:37 +00:00
bcs CS.RUN.RTS
sta hCTX
jsr CS.SCRN.Init
bcs CS.RUN.RTS
2023-01-23 18:33:37 +00:00
jsr CS.TBOX1.Init
bcs CS.RUN.RTS
2023-01-23 18:33:37 +00:00
jsr CS.LBOX1.Init
bcs CS.RUN.RTS
2023-01-23 18:33:37 +00:00
jsr CS.TLINE.Init
bcs CS.RUN.RTS
2023-01-23 18:33:37 +00:00
jsr CS.RADIO.Init
bcs CS.RUN.RTS
2023-01-23 18:33:37 +00:00
jsr CS.CBOX.Init
bcs CS.RUN.RTS
2023-01-23 18:33:37 +00:00
jsr CS.BUT.Init
bcs CS.RUN.RTS
jsr CS.SCRN.Draw Will Call SCRN.Draw
lda hTBOX1
2023-01-23 18:33:37 +00:00
>LIBCALL hLIBTUI,LIBTUI.Activate
*--------------------------------------
CS.RUN.LOOP lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Exec
bcs .9
2023-01-23 18:33:37 +00:00
cmp #EV.RESIZE
bne .1
2023-01-23 18:33:37 +00:00
jsr CS.SCRN.Draw
bcs .9
2023-01-23 18:33:37 +00:00
bra CS.RUN.LOOP
2023-01-23 18:33:37 +00:00
.1 cmp #EV.SAVE
bne .2
jsr CS.RUN.DLGSAVE
bcc CS.RUN.LOOP
2023-01-23 18:33:37 +00:00
.2 cmp #EV.QUIT
bne CS.RUN.LOOP
2023-01-23 18:33:37 +00:00
lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Destroy
lda #0
sec
.9
CS.RUN.RTS rts
*--------------------------------------
CS.SCRN.Init >PUSHB hCTX hParent
2023-01-23 18:33:37 +00:00
>PUSHBI S.OBJ.F.bTitle+S.OBJ.F.bStatus
>LIBCALL hLIBTUI,LIBTUI.NewScrn
bcs .9
2023-01-23 18:33:37 +00:00
sta hSCRN
>PUSHA
>PUSHBI S.OBJ.pTITLE
>PUSHEA.G SCRN.TitleBuf
>LIBCALL hLIBTUI,LIBTUI.SetProp
>PUSHB hSCRN
>PUSHBI S.OBJ.pSTATUS
>PUSHW L.SCRN.Status
>LIBCALL hLIBTUI,LIBTUI.SetProp
2023-01-23 18:33:37 +00:00
.9 rts
*--------------------------------------
CS.TBOX1.Init >LDYAI 1024
>SYSCALL GetMem
bcs CS.RUN.RTS
>STYA ZPPtr1
txa
>STA.G TBOX1.hBuf
lda #0
sta (ZPPtr1)
>PUSHB hSCRN hParent
>PUSHBI 1 X1
>PUSHBI 1 Y1
>PUSHBI 46 W
2023-01-23 18:33:37 +00:00
>PUSHBI 20 H
>PUSHBI S.OBJ.F.bHBorder+S.OBJ.F.bVBorder+S.OBJ.F.bTitle+S.OBJ.F.bStatus+S.OBJ.F.bEdit
2023-01-23 18:33:37 +00:00
>LDA.G TBOX1.hBuf
>SYSCALL GetMemPtr
>PUSHYA
>PUSHWI 1024
>LIBCALL hLIBTUI,LIBTUI.NewTBox
bcs .9
2023-01-23 18:33:37 +00:00
sta hTBOX1
>PUSHA
>PUSHBI S.OBJ.pTITLE
>PUSHW L.TBOX1.Title
>LIBCALL hLIBTUI,LIBTUI.SetProp
>PUSHB hTBOX1
>PUSHBI S.OBJ.pSTATUS
>PUSHW L.TBOX1.Status
>LIBCALL hLIBTUI,LIBTUI.SetProp
2023-01-23 18:33:37 +00:00
.9 rts
*--------------------------------------
CS.LBOX1.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 1 Y1
>PUSHBI 20 W
>PUSHBI 9 H
>PUSHBI S.OBJ.F.bHBorder+S.OBJ.F.bVBorder
>PUSHW L.LBOX1.List
>PUSHEA.G LBOX1.Var
>LIBCALL hLIBTUI,LIBTUI.NewLBox
rts
*--------------------------------------
CS.TLINE.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 11 Y1
>PUSHW L.LABEL.Label
>LIBCALL hLIBTUI,LIBTUI.NewLabel
bcs .9
>PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 12 Y1
>PUSHBI 25 W
>PUSHEA.G TLINE.Buf
>PUSHWI 65 Len
>LIBCALL hLIBTUI,LIBTUI.NewTLine
.9 rts
*--------------------------------------
CS.RADIO.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 14 Y1
>PUSHBI 0
>PUSHBI 0
>PUSHW L.RADIO1.List
>PUSHEA.G RADIO1.Var
>LIBCALL hLIBTUI,LIBTUI.NewRadio
rts
*--------------------------------------
CS.CBOX.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 18 Y1
>PUSHBI 0
>PUSHBI 0
>PUSHW L.CBOX1.Label
>PUSHEA.G CBOX1.Var
>LIBCALL hLIBTUI,LIBTUI.NewCBox
rts
*--------------------------------------
CS.BUT.Init >PUSHB hSCRN hParent
>PUSHBI 50 X1
>PUSHBI 20 Y1
>PUSHBI 19 Ctrl-S
>PUSHBI EV.SAVE
>PUSHW L.BUTS.Label
>LIBCALL hLIBTUI,LIBTUI.NewBut
bcs .9
2023-01-23 18:33:37 +00:00
>PUSHB hSCRN hParent
>PUSHBI 65 X1
>PUSHBI 20 Y1
>PUSHBI 17 Ctrl-Q
>PUSHBI EV.QUIT
>PUSHW L.BUTQ.Label
>LIBCALL hLIBTUI,LIBTUI.NewBut
.9
CS.BUT.Init.RTS rts
*--------------------------------------
CS.RUN.DLGSAVE >PUSHB hCTX hParent
>PUSHBI 70 W
>PUSHBI 11 H
2023-01-23 18:33:37 +00:00
>PUSHW L.DLGS.Title
>LIBCALL hLIBTUI,LIBTUI.NewDlg
bcs CS.BUT.Init.RTS
sta hDLGS
>PUSHB hDLGS hParent
>PUSHBI 50 X1
>PUSHBI 7 Y1
2023-01-23 18:33:37 +00:00
>PUSHBI C.CR
>PUSHBI EV.OK
>PUSHW L.BUT.OK
>LIBCALL hLIBTUI,LIBTUI.NewBut
bcs .9
2023-01-23 18:33:37 +00:00
sta ZPPtr1
>PUSHB hDLGS hParent
>PUSHBI 57 X1
>PUSHBI 7 Y1
>PUSHBI 3 Ctrl-C
2023-01-23 18:33:37 +00:00
>PUSHBI EV.CANCEL
>PUSHW L.BUT.Cancel
>LIBCALL hLIBTUI,LIBTUI.NewBut
bcs .9
2023-01-23 18:33:37 +00:00
lda hDLGS
>LIBCALL hLIBTUI,LIBTUI.Draw
bcs .9
lda ZPPtr1
>LIBCALL hLIBTUI,LIBTUI.Activate
.1 lda hDLGS
>LIBCALL hLIBTUI,LIBTUI.Exec
.9 php
pha
lda hDLGS
>LIBCALL hLIBTUI,LIBTUI.Destroy
lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Draw
pla
plp
rts
*--------------------------------------
CS.DOEVENT sec do not discard TIMER event
2023-01-23 18:33:37 +00:00
rts
*--------------------------------------
CS.QUIT >LDA.G TBOX1.hBuf
beq .1
2023-01-23 18:33:37 +00:00
>SYSCALL FreeMem
.1 lda hCTX
beq .2
>LIBCALL hLIBTUI,LIBTUI.Close
.2 lda hLIBTUI
beq .8
2023-01-23 18:33:37 +00:00
>SYSCALL UnloadLib
2023-01-23 18:33:37 +00:00
.8 clc
rts
*--------------------------------------
CS.SCRN.Draw lda hSCRN
>SYSCALL GetMemPtr
>STYA ZPPtr1
>PUSHEA.G SCRN.TitleBuf
>PUSHW L.SCRN.Title
ldy #S.OBJ.X1
.1 lda (ZPPtr1),y
>PUSHA
iny
cpy #S.OBJ.InnerH+1
bne .1
>PUSHBI 10
>SYSCALL sprintf
lda hSCRN
>LIBCALL hLIBTUI,LIBTUI.Draw
rts
*--------------------------------------
CS.END
*--------------------------------------
LIBTUI .AZ "libtui"
hLIBTUI .BS 1
*--------------------------------------
SCRN.Title .AZ "Window: X1=%d,Y1=%d, W=%d,H=%d, X2=%d,Y2=%d, iX=%d,iY=%d, iW=%d,iH=%d"
SCRN.Status .AZ "Status bar..."
*--------------------------------------
TBOX1.Title .AZ "Text Box Title"
TBOX1.Status .AZ "Text Box Status"
*--------------------------------------
LBOX1.List .AS "Item 1"
.DA #C.CR
.AS "Item 2"
.DA #C.CR
.AS "Item 3"
.DA #C.CR
.AS "Item 4"
.DA #C.CR
.AS "Item 5"
.DA #C.CR
.AS "Item 6 very long line"
.DA #C.CR
.AS "Item 7"
.DA #C.CR
.AS "Item 8"
.DA #C.CR
.AS "Item 9"
.DA #C.CR
.AS "Item 10"
.DA #C.CR
.AS "Item 11"
.DA #C.CR
.AS "Item 12"
.DA #C.CR
.AS "Item 13"
.DA #C.CR
.AS "Item 14 last one"
.DA #0
*--------------------------------------
LABEL.Label .AZ "This is a label."
*--------------------------------------
RADIO1.List .DA #C.ESC
.AS "[91mRed"
.DA #C.CR
.DA #C.ESC
.AS "[92mGreen"
.DA #C.CR
.DA #C.ESC
.AS "[96mBlue"
.DA #0
*--------------------------------------
CBOX1.Label .AZ "Check Me"
*--------------------------------------
BUTS.Label .AZ "(^S)ave..."
BUTQ.Label .AZ "(^Q)uit"
DLGS.Title .AZ "Save As..."
BUT.OK .AZ " OK "
BUT.Cancel .AZ "Cancel"
*--------------------------------------
.DUMMY
.OR 0
DS.START
SCRN.TitleBuf .BS 80
CBOX1.Var .BS 1
TLINE.Buf .BS 65
RADIO1.Var .BS 1
LBOX1.Var .BS 1
TBOX1.hBuf .BS 1
DS.END .ED
*--------------------------------------
MAN
SAVE root/asmtest/testtui.s
ASM