mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
571 lines
11 KiB
Plaintext
571 lines
11 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF lib/libgui
|
||
*--------------------------------------
|
||
.INB inc/macros.i
|
||
.INB inc/a2osx.i
|
||
.INB inc/kernel.i
|
||
.INB inc/gfx.i
|
||
.INB inc/libgui.i
|
||
*--------------------------------------
|
||
WND.MAX .EQ 64
|
||
MENU.MAX .EQ 4
|
||
MENU.LMargin .EQ 7
|
||
MENU.RMargin .EQ 8
|
||
*--------------------------------------
|
||
.MA SWAP16
|
||
lda ]1
|
||
ldx ]2
|
||
stx ]1
|
||
sta ]2
|
||
lda ]1+1
|
||
ldx ]2+1
|
||
stx ]1+1
|
||
sta ]2+1
|
||
.EM
|
||
|
||
.MA NOT16
|
||
sec
|
||
lda #0
|
||
sbc ]1
|
||
sta ]1
|
||
lda #0
|
||
sbc ]1+1
|
||
sta ]1+1
|
||
.EM
|
||
|
||
.MA SCMPAX
|
||
sec
|
||
sbc ]1
|
||
txa
|
||
sbc ]1+1
|
||
bvc :1
|
||
eor #$80
|
||
:1 .EQ *
|
||
.EM
|
||
|
||
.MA SCMPYA
|
||
cpy ]1
|
||
sbc ]1+1
|
||
bvc :1
|
||
eor #$80
|
||
:1 .EQ *
|
||
.EM
|
||
|
||
.MA STYAIFGTR
|
||
tax
|
||
>SCMPYA ]1
|
||
bmi :1
|
||
|
||
sty ]1
|
||
stx ]1+1
|
||
:1 .EQ *
|
||
.EM
|
||
|
||
.MA STYAIFLWR
|
||
tax
|
||
>SCMPYA ]1
|
||
bpl :1
|
||
|
||
sty ]1
|
||
stx ]1+1
|
||
:1 .EQ *
|
||
.EM
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR ZPLIB
|
||
ZPCBPtr .BS 2
|
||
ZPObjPtr .BS 2
|
||
ZPWNDPtr .BS 2
|
||
ZPMENUPtr .BS 2
|
||
|
||
ZPBMPtr .BS 2
|
||
ZPRECTPtr .BS 2
|
||
ZPPtr1 .BS 2
|
||
|
||
DX .BS 2
|
||
DY .BS 2
|
||
IE .BS 2
|
||
INE .BS 2
|
||
|
||
D .BS 2
|
||
Counter .BS 2
|
||
|
||
CLIP.Line.P1 .BS 1
|
||
CLIP.Line.P2 .BS 1
|
||
IY .BS 1
|
||
|
||
hCBBuf .BS 1
|
||
ZPCBBufPtr .BS 2
|
||
|
||
.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
|
||
.DA CS.END-CS.START
|
||
.DA 0
|
||
.DA 0
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA LIB.LOAD
|
||
.DA LIB.UNLOAD
|
||
.DA SetCursor
|
||
.DA SetCursorPos
|
||
.DA HideCursor
|
||
.DA ShowCursor
|
||
.DA UpdateCursor
|
||
.DA MOU.ReadMouse
|
||
.DA DrawLine
|
||
.DA OBJ.SetProp
|
||
.DA OBJ.GetProp
|
||
.DA WND.New
|
||
.DA WND.Destroy
|
||
.DA WND.Show
|
||
.DA WND.Paint
|
||
L.WND.fPaint .DA WND.fPaint
|
||
*--------------------------------------
|
||
L.DEVNAME.GFX .DA DEVNAME.GFX
|
||
L.DEVNAME.MOUSE .DA DEVNAME.MOUSE
|
||
L.SYSX7 .DA SYSX7
|
||
L.SYSX7B .DA SYSX7B
|
||
L.IOCTL .DA IOCTL
|
||
L.DCB.GFX .DA DCB.GFX
|
||
L.MouseClamp .DA MouseClamp
|
||
L.MouseData .DA MouseData
|
||
L.CB.PTR .DA CB.PTR
|
||
L.CB.Cache .DA CB.Cache
|
||
L.OBJ.Cache .DA OBJ.Cache
|
||
L.WND.Screen .DA WND.Screen
|
||
L.WND.Desktop .DA WND.Desktop
|
||
L.WND.SysBar .DA WND.SysBar
|
||
L.WND.SysBar.2osX .DA WND.SysBar.2osX
|
||
L.WND.SysBar.Clk .DA WND.SysBar.Clk
|
||
L.RECT.SysBut .DA RECT.SysBut
|
||
L.RECT.SysWNDs .DA RECT.SysWNDs
|
||
L.RECT.SysClk .DA RECT.SysClk
|
||
L.MENU.Sys .DA MENU.Sys
|
||
L.MENU.Sys.Programs .DA MENU.Sys.Programs
|
||
L.MENU.Sys.Settings .DA MENU.Sys.Settings
|
||
*--------------------------------------
|
||
L.BMs .EQ *-2
|
||
L.BM.Apple .DA BM.Apple
|
||
L.BM.Close .DA BM.Close
|
||
L.BM.Max .DA BM.Max
|
||
L.BM.Min .DA BM.Min
|
||
L.BM.Left .DA BM.Left
|
||
L.BM.Right .DA BM.Right
|
||
L.BM.Up .DA BM.Up
|
||
L.BM.Down .DA BM.Down
|
||
*--------------------------------------
|
||
L.CUR.SaveBuf .DA CUR.SaveBuf
|
||
L.Cursors .DA CUR.Arrow
|
||
.DA CUR.Move
|
||
.DA CUR.ResizeX
|
||
.DA CUR.ResizeY
|
||
.DA CUR.ResizeXY1
|
||
.DA CUR.ResizeXY2
|
||
.DA CUR.Cross
|
||
.DA CUR.Text
|
||
.DA CUR.Wait1
|
||
.DA CUR.Wait2
|
||
.DA CUR.Wait3
|
||
.DA CUR.Wait4
|
||
.DA CUR.Wait5
|
||
.DA CUR.Wait6
|
||
J.Clip .DA CLIP.Point SETPIXEL
|
||
.DA CLIP.Point GETPIXEL
|
||
.DA CLIP.HLine HLINE
|
||
.DA CLIP.VLine VLINE
|
||
.DA CLIP.Rect FILLRECT
|
||
.DA CLIP.BitBlt BITBLT
|
||
.DA CLIP.Rect GETRECTBUFSIZE
|
||
.DA CLIP.Text DRAWTEXT
|
||
.DA CLIP.Text GETTEXTSIZE
|
||
.DA CLIP.Line DRAWLINE
|
||
.DA CLIP.BitBlt DRAWTEXT2
|
||
.DA 0
|
||
*--------------------------------------
|
||
LIB.LOAD lda LibCount
|
||
bne .8
|
||
|
||
jsr MOU.Init
|
||
* bcs .9
|
||
|
||
jsr WND.Init
|
||
bcs .9
|
||
|
||
jsr FON.Init
|
||
bcs .9
|
||
|
||
lda hDevMouse
|
||
beq .1
|
||
|
||
jsr MOU.Setup
|
||
|
||
.1 jsr WND.Setup
|
||
|
||
lda #CUR.T.ARROW
|
||
jsr SetCursor
|
||
jsr ShowCursor
|
||
|
||
inc LibCount
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
LIB.UNLOAD dec LibCount
|
||
bne .8
|
||
|
||
jsr MOU.Quit
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CB.InitCacheA sta CB.Cache+S.CB.CMD
|
||
*--------------------------------------
|
||
CB.ClearCache ldx #S.CB-1
|
||
|
||
.1 stz CB.Cache,x
|
||
dex
|
||
bne .1
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CB.GetInCache >STYA .1+1
|
||
|
||
ldx #S.CB-1
|
||
|
||
.1 lda $ffff,x SELF MODIFIED
|
||
sta CB.Cache,x
|
||
dex
|
||
bpl .1
|
||
|
||
rts
|
||
*--------------------------------------
|
||
GetCBBuf clc
|
||
|
||
ldx hCBBuf
|
||
bne .9
|
||
|
||
>LDYAI 512
|
||
>SYSCALL2 GetMem
|
||
bcs .9
|
||
|
||
stx hCBBuf
|
||
>STYA ZPCBPtr
|
||
>STYA ZPCBBufPtr
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
PutCBCache2CBBuf
|
||
lda CB.Cache
|
||
lsr
|
||
tax
|
||
ldy CB.CmdLen-1,x
|
||
|
||
ldx #0
|
||
|
||
.1 lda CB.Cache,x
|
||
sta (ZPCBBufPtr)
|
||
inc ZPCBBufPtr
|
||
bne .2
|
||
|
||
inc ZPCBBufPtr+1
|
||
|
||
.2 inx
|
||
dey
|
||
bpl .1
|
||
|
||
rts
|
||
*--------------------------------------
|
||
GFXWrite.CB >PUSHB WND.Screen+S.OBJ.hPARENT
|
||
>PUSHBI IOCTL.WRITE
|
||
>PUSHW L.CB.Cache
|
||
>SYSCALL2 IOCTL
|
||
rts
|
||
*--------------------------------------
|
||
OBJ.GetInCache >STYA .1+1
|
||
|
||
ldx #S.OBJ-1
|
||
|
||
.1 lda $ffff,x SELF MODIFIED
|
||
sta OBJ.Cache,x
|
||
dex
|
||
bpl .1
|
||
|
||
rts
|
||
*--------------------------------------
|
||
OBJ.SetX2Y2 >STYA ZPPtr1
|
||
|
||
ldy #S.OBJ.W
|
||
lda (ZPPtr1),y
|
||
clc
|
||
sbc #0
|
||
pha
|
||
iny
|
||
lda (ZPPtr1),y
|
||
sbc #0
|
||
tax
|
||
|
||
pla
|
||
clc
|
||
ldy #S.OBJ.X1
|
||
adc (ZPPtr1),y
|
||
pha
|
||
txa
|
||
iny
|
||
adc (ZPPtr1),y
|
||
ldy #S.OBJ.X2+1
|
||
sta (ZPPtr1),y
|
||
dey
|
||
pla
|
||
sta (ZPPtr1),y
|
||
|
||
ldy #S.OBJ.H
|
||
lda (ZPPtr1),y
|
||
clc
|
||
sbc #0
|
||
pha
|
||
iny
|
||
lda (ZPPtr1),y
|
||
sbc #0
|
||
tax
|
||
|
||
pla
|
||
clc
|
||
ldy #S.OBJ.Y1
|
||
adc (ZPPtr1),y
|
||
pha
|
||
txa
|
||
iny
|
||
adc (ZPPtr1),y
|
||
ldy #S.OBJ.Y2+1
|
||
sta (ZPPtr1),y
|
||
dey
|
||
pla
|
||
sta (ZPPtr1),y
|
||
|
||
rts
|
||
*--------------------------------------
|
||
.INB usr/src/lib/libgui.s.bm
|
||
.INB usr/src/lib/libgui.s.but
|
||
.INB usr/src/lib/libgui.s.clip
|
||
.INB usr/src/lib/libgui.s.cur
|
||
.INB usr/src/lib/libgui.s.draw
|
||
.INB usr/src/lib/libgui.s.fon
|
||
.INB usr/src/lib/libgui.s.mbar
|
||
.INB usr/src/lib/libgui.s.menu
|
||
.INB usr/src/lib/libgui.s.mou
|
||
.INB usr/src/lib/libgui.s.obj
|
||
.INB usr/src/lib/libgui.s.pat
|
||
.INB usr/src/lib/libgui.s.sysbar
|
||
.INB usr/src/lib/libgui.s.text
|
||
.INB usr/src/lib/libgui.s.wnd
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
.INB usr/src/lib/libgui.g.bm
|
||
.INB usr/src/lib/libgui.g.cur
|
||
.INB usr/src/lib/libgui.g.fon
|
||
*--------------------------------------
|
||
DEVNAME.GFX .AZ "/dev/gfx"
|
||
DEVNAME.MOUSE .AZ "/dev/mou1"
|
||
*--------------------------------------
|
||
SYSX7 .AZ "${ROOT}sbin/sysx7"
|
||
SYSX7B .AZ "${ROOT}sbin/sysx7b"
|
||
*--------------------------------------
|
||
LibCount .BS 1
|
||
hDevMouse .BS 1
|
||
*--------------------------------------
|
||
CB.CmdLen .DA #S.CB.Y1+1 SETPIXEL
|
||
.DA #S.CB.Y1+1 GETPIXEL
|
||
.DA #S.CB.Y2+1 HLINE
|
||
.DA #S.CB.Y2+1 VLINE
|
||
.DA #S.CB.Y2+1 FILLRECT
|
||
.DA #S.CB.DstPtr+1 BITBLT
|
||
.DA #S.CB.DstPtr+1 GETRECTBUFSIZE
|
||
.DA #S.CB.TxtPtr+1 DRAWTEXT
|
||
.DA #S.CB.TxtPtr+1 GETTEXTSIZE
|
||
.DA #S.CB.Y2+1 DRAWLINE
|
||
.DA #S.CB.TxtPtr+1 DRAWTEXT2
|
||
*--------------------------------------
|
||
PAT.Buf .BS 1 S.BM.F
|
||
.DA #1 S.BM.RowBytes
|
||
.DA 8 S.BM.W
|
||
.DA 8 S.BM.H
|
||
.DA 0 S.BM.MASK.OFS
|
||
.BS 8 (data)
|
||
*--------------------------------------
|
||
IOCTL .BS S.IOCTL
|
||
DCB.GFX .BS S.DCB.GFX
|
||
*--------------------------------------
|
||
MouseClamp .BS 8
|
||
MouseData .BS S.MOUSE
|
||
*--------------------------------------
|
||
CB.PTR .DA #S.CB.CMD.BITBLT
|
||
.BS 1 S.CB.OP
|
||
.DA #S.CB.M.MONO
|
||
.DA #0
|
||
.BS S.CB-4
|
||
*--------------------------------------
|
||
CB.Cache .BS S.CB
|
||
OBJ.Cache .BS S.OBJ
|
||
*--------------------------------------
|
||
MENU.Stack.Top .BS 1
|
||
MENU.Stack .BS MENU.MAX
|
||
*--------------------------------------
|
||
WND.hWND .BS 1
|
||
WND.Stack.Idx .BS 1
|
||
WND.Stack.Top .BS 1
|
||
WND.Stack .BS WND.MAX
|
||
*--------------------------------------
|
||
WND.Screen .DA #S.OBJ.T.WND
|
||
.BS S.WND-1
|
||
*--------------------------------------
|
||
WND.Desktop .DA #S.OBJ.T.WND
|
||
.BS S.WND-1
|
||
*--------------------------------------
|
||
WND.SysBar .DA #S.OBJ.T.WND
|
||
.BS S.WND-1
|
||
WND.SysBar.2osX .AZ "2osX"
|
||
WND.SysBar.Clk .AZ "00:00"
|
||
WND.SysBar.bSysBut .BS 1
|
||
*--------------------------------------
|
||
RECT.SysBut .BS S.RECT
|
||
*--------------------------------------
|
||
RECT.SysWNDs .BS S.RECT
|
||
*--------------------------------------
|
||
RECT.SysClk .BS S.RECT
|
||
*--------------------------------------
|
||
hSysMenu .BS 1
|
||
MENU.Sys
|
||
.1 .DA #.2-* next
|
||
.DA #S.MITEM.F.ITEM F
|
||
.DA #0 S
|
||
.DA #2 ID
|
||
.DA BM.ID.APPLE pICON
|
||
.DA #S.MITEM.KEYMOD.CTRL+S.MITEM.KEYMOD.OA+S.MITEM.KEYMOD.CA
|
||
.DA #'A'
|
||
.DA #.11-.1
|
||
.AZ "About..."
|
||
.11 .AS "Ctrl-"
|
||
.DA #1,#'-',#2,#'-',#'A',#0
|
||
|
||
.2 .DA #.3-* next
|
||
.DA #S.MITEM.F.SEP
|
||
|
||
.3 .DA #.4-* next
|
||
.DA #S.MITEM.F.SUBMENU F
|
||
.DA #0 S
|
||
.DA #4 ID
|
||
.DA 0 pICON
|
||
.DA 0 pMENU
|
||
.DA #0 KEYSTR
|
||
.AZ "Programs"
|
||
|
||
.4 .DA #.5-* next
|
||
.DA #S.MITEM.F.SUBMENU F
|
||
.DA #0 S
|
||
.DA #6 ID
|
||
.DA 0 pICON
|
||
.DA 0 pMENU
|
||
.DA #0 KEYSTR
|
||
.AZ "Settings"
|
||
|
||
.5 .DA #.6-* next
|
||
.DA #S.MITEM.F.SEP
|
||
|
||
.6 .DA #.7-* next
|
||
.DA #S.MITEM.F.ITEM F
|
||
.DA #0 S
|
||
.DA #8 ID
|
||
.DA 0 pICON
|
||
.DA #0
|
||
.DA #0
|
||
.DA #0 KEYSTR
|
||
.AZ "Search..."
|
||
|
||
.7 .DA #.8-* next
|
||
.DA #S.MITEM.F.ITEM F
|
||
.DA #0 S
|
||
.DA #10 ID
|
||
.DA 0 pICON
|
||
.DA #S.MITEM.KEYMOD.CTRL+S.MITEM.KEYMOD.OA
|
||
.DA #'R'
|
||
.DA #.77-.7
|
||
.AZ "Run..."
|
||
.77 .AZ "Ctrl-R"
|
||
.8 .DA #0
|
||
*--------------------------------------
|
||
MENU.Sys.Programs
|
||
.1 .DA #.2-* next
|
||
.DA #S.MITEM.F.ITEM F
|
||
.DA #0 S
|
||
.DA #42 ID
|
||
.DA BM.ID.APPLE pICON
|
||
.DA #0
|
||
.DA #0
|
||
.DA #0 KEYSTR
|
||
.AZ "GUITest1"
|
||
|
||
.2 .DA #.3-* next
|
||
.DA #S.MITEM.F.ITEM F
|
||
.DA #0 S
|
||
.DA #44 ID
|
||
.DA BM.ID.APPLE pICON
|
||
.DA #0
|
||
.DA #0
|
||
.DA #0 KEYSTR
|
||
.AZ "GUITest2"
|
||
|
||
.3 .DA #0
|
||
*--------------------------------------
|
||
MENU.Sys.Settings
|
||
.1 .DA #.2-* next
|
||
.DA #S.MITEM.F.ITEM F
|
||
.DA #0 S
|
||
.DA #62 ID
|
||
.DA 0 pICON
|
||
.DA #0
|
||
.DA #0
|
||
.DA #0 KEYSTR
|
||
.AZ "Colors..."
|
||
|
||
.2 .DA #.3-* next
|
||
.DA #S.MITEM.F.ITEM F
|
||
.DA #0 S
|
||
.DA #64 ID
|
||
.DA 0 pICON
|
||
.DA #0
|
||
.DA #0
|
||
.DA #0 KEYSTR
|
||
.AZ "SubItem2..."
|
||
|
||
.3 .DA #0
|
||
*--------------------------------------
|
||
PREFS.BESTVIEWEDX .DA #$FC
|
||
PREFS.bSYSBARTOP .DA #0
|
||
PREFS.MBARXMARGIN .DA #5
|
||
PREFS.MENUCOLOR .DA #C.WHITE
|
||
PREFS.SYSBARCOLOR .DA #C.WHITE
|
||
PREFS.BORDERCOLOR .DA #C.BLACK
|
||
PREFS.TBARCOLORA .DA #C16.D.BLUE
|
||
PREFS.TBARCOLORI .DA #C16.L.BLUE
|
||
PREFS.MBARCOLOR .DA #C.WHITE
|
||
PREFS.SBARCOLOR .DA #C.WHITE
|
||
PREFS.DESKTOPCOLOR .DA #C16.D.BLUE
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/lib/libgui.s
|
||
ASM
|