A2osX/LIB/LIBGUI.S.MBAR.txt
2022-10-27 17:14:06 +02:00

400 lines
6.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*--------------------------------------
* Y,A = MBAR definition
*--------------------------------------
MBAR.New >STYA ZPPtr1 MBAR definition
>STYA ZPObjPtr for pass #2
jsr MBAR.GetSize
>SYSCALL2 GetMem
bcs .9
>STYA ZPMENUPtr
phx hMBAR
lda #S.OBJ.T.MBAR
sta (ZPMENUPtr) S.OBJ.T
lda #0
ldy #S.MBAR.Items-1
.1 sta (ZPMENUPtr),y
dey
bne .1
>LDYA ZPObjPtr
>STYA ZPPtr1 MENU definition
jsr MBAR.GetData
pla hMBAR
clc
.9 rts
*--------------------------------------
* ZPPtr1 = defintion
*--------------------------------------
MBAR.GetSize lda #S.MBAR.Items+1 Ending\0
sta Counter
stz Counter+1
.1 lda (ZPPtr1)
beq .8
ldy #$ff
.2 iny
lda (ZPPtr1),y
bne .2
tya
sec text Ending\0
inc
inc skip pMENU
jsr SkipAPtr1
lda #S.MBITEM
clc
adc Counter
sta Counter
bcc .1
inc Counter+1
bra .1
.8 >LDYA Counter
rts
*--------------------------------------
* ZPPtr1 = defintion
* ZPMENUPtr = DstBuf
*--------------------------------------
MBAR.GetData lda ZPMENUPtr
clc
adc #S.MBAR.Items
sta ZPMENUPtr
bcc .1
inc ZPMENUPtr+1
.1 lda (ZPPtr1)
beq .8
lda #S.MBITEM.T.SUBMENU
jsr MBAR.AddByte
lda #0 S.MBITEM.S
jsr MBAR.AddByte
>LDYA ZPPtr1 pTEXT
ldx hSYSFON
jsr FON.GetTextSize
lda PREFS.MBarXMargin
asl x2
clc
adc CB.CACHE+S.CB.SrcW
tay
lda #0
adc CB.CACHE+S.CB.SrcW+1
jsr MBAR.AddWord S.MBITEM.W
>LDYA ZPPtr1 pTEXT
jsr MBAR.AddWord
jsr SkipStrZPtr1 skip "TEXT\0"
lda (ZPPtr1)
jsr MBAR.AddByte pMENU
ldy #1
lda (ZPPtr1),y
jsr MBAR.AddByte pMENU+1
lda #2
jsr SkipAPtr1 stkip pMENU
bra .1
.8 sta (ZPMENUPtr)
rts
*--------------------------------------
MBAR.AddWord pha
tya
jsr MBAR.AddByte
pla
MBAR.AddByte sta (ZPMENUPtr)
inc ZPMENUPtr
bne .8
inc ZPMENUPtr+1
.8 rts
*--------------------------------------
* ZPWNDPtr parent WND
* MSG.X1, MSG.Y1
*--------------------------------------
MBAR.Enter ldy #S.WND.pMBAR
lda (ZPWNDPtr),y
>SYSCALL2 GetMemPtr
>STYA ZPMENUPtr pMBAR
stz ZPPtr2
stz ZPPtr2+1
ldy #S.OBJ.X1
ldx #S.CB.X1
jsr CB.GetWndYCacheX
jsr MBAR.GetMBItems
.1 lda (ZPPtr1)
beq .3
jsr MBAR.SetX2
lda MSG+S.MSG.X1
cmp CB.Cache+S.CB.X1
lda MSG+S.MSG.X1+1
sbc CB.Cache+S.CB.X1+1
bcc .2
lda CB.Cache+S.CB.X2
cmp MSG+S.MSG.X1
lda CB.Cache+S.CB.X2+1
sbc MSG+S.MSG.X1+1
bcc .2
ldy #S.MBITEM.S in RECT....
lda (ZPPtr1),y
bmi .8 Already Selected, nothing to do
>LDYA ZPPtr1
>STYA ZPPtr2 save MBITEM to activate
.2 jsr MBAR.NextMBItem
bra .1
.3 lda ZPPtr2
ora ZPPtr2+1
bne MBAR.Set
.8 clc
.9 rts
*--------------------------------------
* ZPMENUPtr = MBAR
* ZPPtr2 = Item to activate
*--------------------------------------
MBAR.Reset stz ZPPtr2
stz ZPPtr2+1
MBAR.Set jsr MENU.DestroyAll
ldy #S.OBJ.X1
ldx #S.CB.X1
jsr CB.GetWndYCacheX
jsr MBAR.GetMBItems
jsr CB.GetBuf
bcs .9
.4 lda (ZPPtr1)
beq .7
jsr MBAR.SetX2 set X2 = X1 + W
ldy #S.MBITEM.S
lda (ZPPtr1),y
bmi .5
ldx ZPPtr1
cpx ZPPtr2
bne .6
ldx ZPPtr1+1
cpx ZPPtr2+1
bne .6
ldx CB.Cache+S.CB.X1
stx Counter
ldx CB.Cache+S.CB.X1+1
stx Counter+1
.5 eor #S.MBITEM.S.SELECTED
sta (ZPPtr1),y
jsr MBAR.DrawMBItem
bcs .9
.6 jsr MBAR.NextMBItem set X1 = X2
bra .4
.7 >LDYA L.WND.Screen
jsr CB.FlushBufToYA
bcs .9
>LDYA Counter
>STYA DX
ldy #S.WND.MBarY2
lda (ZPWNDPtr),y
sta DY
iny
lda (ZPWNDPtr),y
sta DY+1
ldy #S.MBITEM.pMENU
lda (ZPPtr2),y
pha
iny
lda (ZPPtr2),y
ply
jsr MENU.New.I
bcs .9
jmp MENU.Draw
.9 rts
*--------------------------------------
* ZPWNDPtr = parent WND
*--------------------------------------
MBAR.Draw >SYSCALL2 GetMemPtr
>STYA ZPMENUPtr pMBAR
ldy #S.OBJ.X1
ldx #S.CB.X1
jsr CB.GetWndYCacheX
jsr MBAR.GetMBItems
.1 lda (ZPPtr1)
beq .8
jsr MBAR.SetX2 set X2 = X1 + W
jsr MBAR.DrawMBItem
bcs .9
jsr MBAR.NextMBItem
bra .1
.8 lda CB.Cache+S.CB.X2
sta CB.Cache+S.CB.X1
lda CB.Cache+S.CB.X2+1
sta CB.Cache+S.CB.X1+1
ldy #S.OBJ.X2
ldx #S.CB.X2
jsr CB.GetWndYCacheX
jsr MBAR.SetY1Y2
lda PREFS.MBarColor
jsr CB.FillRectMonoA
jmp CB.Cache2CBBuf
.9 rts
*--------------------------------------
MBAR.DrawMBItem ldy #S.MBITEM.S
lda (ZPPtr1),y
asl
lda PREFS.MBarColor
bcc .1
eor #$ff
.1 jsr CB.FillRectMonoA
jsr MBAR.SetY1Y2
jsr CB.Cache2CBBuf
lda PREFS.MBarXMargin
clc
adc CB.Cache+S.CB.X1
sta CB.Cache+S.CB.X1
bcc .10
inc CB.Cache+S.CB.X1+1
.10 inc CB.Cache+S.CB.Y1
bne .11
inc CB.Cache+S.CB.Y1+1
.11 ldy #S.MBITEM.S
lda (ZPPtr1),y
asl
ldy #S.MBITEM.pTEXT
lda (ZPPtr1),y
pha
iny
lda (ZPPtr1),y
ply
ldx hSYSFON
jsr DRAW.YAText
jmp CB.Cache2CBBuf
*--------------------------------------
MBAR.GetMBItems lda ZPMENUPtr
clc
adc #S.MBAR.Items
sta ZPPtr1
lda ZPMENUPtr+1
adc /S.MBAR.Items
sta ZPPtr1+1
rts
*--------------------------------------
MBAR.NextMBItem lda CB.Cache+S.CB.X2
sta CB.Cache+S.CB.X1
lda CB.Cache+S.CB.X2+1
sta CB.Cache+S.CB.X1+1
lda #S.MBITEM
jmp SkipAPtr1
*--------------------------------------
MBAR.SetX2 lda CB.Cache+S.CB.X1
clc
ldy #S.MBITEM.W
adc (ZPPtr1),y
sta CB.Cache+S.CB.X2
lda CB.Cache+S.CB.X1+1
iny
adc (ZPPtr1),y
sta CB.Cache+S.CB.X2+1
rts
*--------------------------------------
MBAR.SetY1Y2 ldy #S.WND.MBarY1
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y1
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y1+1
ldy #S.WND.MBarY2
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y2
iny
lda (ZPWNDPtr),y
sta CB.Cache+S.CB.Y2+1
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libgui.s.mbar
LOAD usr/src/lib/libgui.s
ASM