mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
466 lines
8.1 KiB
Plaintext
466 lines
8.1 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/LIB/LIBGUI.O
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/INC/LIBGUI.I
|
||
*--------------------------------------
|
||
.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
|
||
*--------------------------------------
|
||
ZPDCPtr .EQ ZPLIB+2
|
||
ZPCmdPtr .EQ ZPLIB+4
|
||
*--------------------------------------
|
||
* 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
|
||
J.Cmds .DA InitGUI.A
|
||
.DA CloseGUI J.Cmds-12 !!!
|
||
.DA Draw
|
||
.DA SetCursor.A
|
||
.DA SetCursorPos
|
||
.DA HideCursor
|
||
.DA ShowCursor
|
||
.DA DrawLine
|
||
L.CB.Cache .DA CB.Cache
|
||
.DA 0
|
||
*--------------------------------------
|
||
LIB.LOAD
|
||
LIB.UNLOAD clc
|
||
rts
|
||
*--------------------------------------
|
||
InitGUI.A sta hDev
|
||
>SYSCALL GetDevByID.A
|
||
>STYA GoDev.Jmp+1
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CloseGUI
|
||
stz hDev
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Draw >PULLW ZPCmdPtr
|
||
|
||
lda (ZPCmdPtr) Get Cmd
|
||
|
||
.1 tax
|
||
cpx #S.CB.CMD.DRAWLINE
|
||
bcc .3 Native DRV Cmd
|
||
|
||
ldy CB.CmdLen,x
|
||
|
||
.2 lda (ZPCmdPtr),y Y=Byte count-1 to cache
|
||
sta CB.Cache,y
|
||
dey
|
||
bpl .2
|
||
|
||
jsr Draw.Jmp
|
||
bra .7
|
||
|
||
.3 >LDYA ZPCmdPtr
|
||
|
||
jsr GoDev.YA
|
||
|
||
.7 lda (ZPCmdPtr) Get Cmd
|
||
tax
|
||
lda CB.CmdLen,x
|
||
sec
|
||
adc ZPCmdPtr
|
||
sta ZPCmdPtr
|
||
bcc .8
|
||
inc ZPCmdPtr+1
|
||
|
||
.8 lda (ZPCmdPtr) Get Cmd
|
||
bne .1
|
||
|
||
clc
|
||
rts
|
||
|
||
Draw.Jmp jmp (J.Cmds,x)
|
||
*--------------------------------------
|
||
SetCursor.A
|
||
*--------------------------------------
|
||
SetCursorPos
|
||
*--------------------------------------
|
||
HideCursor
|
||
*--------------------------------------
|
||
ShowCursor
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* In: Control Block
|
||
* hDC
|
||
* OP
|
||
* MODE
|
||
* COLOR
|
||
* X1
|
||
* Y1
|
||
* X2
|
||
* Y2
|
||
*--------------------------------------
|
||
DrawLine lda CB.Cache+S.CB.X2
|
||
sec
|
||
sbc CB.Cache+S.CB.X1
|
||
sta DX
|
||
|
||
lda CB.Cache+S.CB.X2+1
|
||
sbc CB.Cache+S.CB.X1+1
|
||
sta DX+1 DX% = X2% - X1%
|
||
|
||
bmi .1 DX < 0....
|
||
|
||
ora DX
|
||
bne .2 DX > 0...
|
||
|
||
lda #S.CB.CMD.VLINE
|
||
sta CB.Cache+S.CB.CMD
|
||
jmp GoDev DX=0 : VLIN Y1,Y2 At X1
|
||
|
||
.1 >SWAP16 CB.Cache+S.CB.X1,CB.Cache+S.CB.X2
|
||
* >SWAP16 CB.Cache+S.CB.Y1,CB.Cache+S.CB.Y2
|
||
lda CB.Cache+S.CB.Y1
|
||
ldx CB.Cache+S.CB.Y2
|
||
stx CB.Cache+S.CB.Y1
|
||
sta CB.Cache+S.CB.Y2
|
||
|
||
>NOT16 DX swap X1/X2, Y1/Y2, set DX=-DX (DX positive)
|
||
|
||
.2 lda #1
|
||
sta IY
|
||
|
||
lda CB.Cache+S.CB.Y2
|
||
sec
|
||
sbc CB.Cache+S.CB.Y1
|
||
sta DY
|
||
|
||
* lda CB.Cache+S.CB.Y2+1
|
||
lda #0
|
||
* sbc CB.Cache+S.CB.Y1+1
|
||
sbc #0
|
||
sta DY+1 DY% = Y2% - Y1%
|
||
|
||
bmi .3 DY < 0 ...
|
||
|
||
ora DY
|
||
bne .4
|
||
|
||
lda #S.CB.CMD.HLINE
|
||
sta CB.Cache+S.CB.CMD
|
||
jmp GoDev DY=0 : HLIN X1,X2 At Y1
|
||
|
||
.3 >NOT16 DY set DY=-DY
|
||
lda #$ff
|
||
sta IY set IY=-1
|
||
|
||
.4 lda #S.CB.CMD.SETPIXEL
|
||
sta CB.Cache+S.CB.CMD
|
||
jsr GoDev
|
||
|
||
lda DX
|
||
sec
|
||
sbc DY
|
||
tax
|
||
|
||
lda DX+1
|
||
* sbc DY+1
|
||
sbc #0
|
||
bmi DrawLine.IncY DY is greater than DX, we will increase on Y axis
|
||
|
||
txa
|
||
beq DrawLine.IncXY DX=DY, go inc X & Y
|
||
|
||
jmp DrawLine.IncX DY is lower than DX, we will increase on X axis
|
||
|
||
DrawLine.IncXY lda DX DX=DY
|
||
eor #$ff
|
||
sta Counter
|
||
lda DX+1
|
||
eor #$ff
|
||
sta Counter+1
|
||
|
||
.1 inc Counter
|
||
bne .2
|
||
inc Counter+1
|
||
beq .8
|
||
|
||
.2 inc CB.Cache+S.CB.X1
|
||
bne .3
|
||
inc CB.Cache+S.CB.X1+1
|
||
|
||
.3 lda CB.Cache+S.CB.Y1 Y1=Y1+IY
|
||
clc
|
||
adc IY
|
||
sta CB.Cache+S.CB.Y1
|
||
|
||
jsr GoDev
|
||
bra .1
|
||
|
||
.8 rts
|
||
|
||
DrawLine.IncY lda DY
|
||
eor #$ff
|
||
sta Counter
|
||
lda DY+1
|
||
eor #$ff
|
||
sta Counter+1
|
||
|
||
lda DX IE=2*DX
|
||
asl
|
||
sta IE
|
||
pha
|
||
|
||
lda DX+1
|
||
rol
|
||
sta IE+1
|
||
tax
|
||
|
||
pla D=IE-DY
|
||
sec
|
||
sbc DY
|
||
sta D
|
||
|
||
txa
|
||
sbc DY+1
|
||
sta D+1
|
||
|
||
lda DX INE=2*(DX-DY)
|
||
sec
|
||
sbc DY
|
||
pha
|
||
|
||
lda DX+1
|
||
sbc DY+1
|
||
tax
|
||
|
||
pla
|
||
|
||
asl
|
||
sta INE
|
||
txa
|
||
rol
|
||
sta INE+1
|
||
|
||
.1 inc Counter
|
||
bne .2
|
||
inc Counter+1
|
||
beq .8
|
||
|
||
.2 lda D+1 IF D < 0 ...
|
||
bmi .4
|
||
|
||
lda D D > 0 : D=D+INE
|
||
clc
|
||
adc INE
|
||
sta D
|
||
lda D+1
|
||
adc INE+1
|
||
sta D+1
|
||
|
||
inc CB.Cache+S.CB.X1 X1=X1+1
|
||
bne .5
|
||
inc CB.Cache+S.CB.X1+1
|
||
|
||
bra .5
|
||
|
||
.4 lda D D > 0 : D=D+IE
|
||
clc
|
||
adc IE
|
||
sta D
|
||
lda D+1
|
||
adc IE+1
|
||
sta D+1
|
||
|
||
.5 lda CB.Cache+S.CB.Y1 Y1=Y1+IY
|
||
clc
|
||
adc IY
|
||
sta CB.Cache+S.CB.Y1
|
||
|
||
jsr GoDev
|
||
bra .1
|
||
|
||
.8 rts
|
||
|
||
DrawLine.IncX lda DX
|
||
eor #$ff
|
||
sta Counter
|
||
lda DX+1
|
||
eor #$ff
|
||
sta Counter+1
|
||
|
||
lda DY IE=2*DY
|
||
asl
|
||
sta IE
|
||
pha
|
||
|
||
* lda DY+1
|
||
lda #0
|
||
rol
|
||
sta IE+1
|
||
tax
|
||
|
||
pla D=IE-DX
|
||
sec
|
||
sbc DX
|
||
sta D
|
||
|
||
txa
|
||
sbc DX+1
|
||
sta D+1
|
||
|
||
lda DY INE=2*(DY-DX)
|
||
sec
|
||
sbc DX
|
||
pha
|
||
|
||
* lda DY+1
|
||
lda #0
|
||
sbc DX+1
|
||
tax
|
||
|
||
pla
|
||
asl
|
||
sta INE
|
||
txa
|
||
rol
|
||
sta INE+1
|
||
|
||
.1 inc Counter
|
||
bne .2
|
||
inc Counter+1
|
||
beq .8
|
||
|
||
.2 lda D+1 ID D < 0 ....
|
||
bmi .4
|
||
|
||
lda D D > 0 : D=D+INE
|
||
clc
|
||
adc INE
|
||
sta D
|
||
lda D+1
|
||
adc INE+1
|
||
sta D+1
|
||
|
||
lda CB.Cache+S.CB.Y1 Y1=Y1+IY
|
||
clc
|
||
adc IY
|
||
sta CB.Cache+S.CB.Y1
|
||
|
||
bra .5
|
||
|
||
.4 lda D D < 0 : D=D+IE
|
||
clc
|
||
adc IE
|
||
sta D
|
||
lda D+1
|
||
adc IE+1
|
||
sta D+1
|
||
|
||
.5 inc CB.Cache+S.CB.X1 X1=X1+1
|
||
bne .6
|
||
inc CB.Cache+S.CB.X1+1
|
||
|
||
.6 jsr GoDev
|
||
bra .1
|
||
|
||
.8 rts
|
||
*--------------------------------------
|
||
GoDev >LDYA L.CB.Cache
|
||
GoDev.YA ldx #DEVMGR.WRITE
|
||
GoDev.Jmp jmp $ffff
|
||
*--------------------------------------
|
||
CS.END
|
||
hDev .BS 1
|
||
*--------------------------------------
|
||
DX .BS 2
|
||
DY .BS 2
|
||
IY .BS 1
|
||
IE .BS 2
|
||
D .BS 2
|
||
INE .BS 2
|
||
Counter .BS 2
|
||
*--------------------------------------
|
||
CB.CmdLen .DA S.CB.Y1+1 SETPIXEL
|
||
.DA S.CB.Y1+1 GETPIXEL
|
||
.DA S.CB.X2+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.Y2+1 DRAWLINE
|
||
*--------------------------------------
|
||
CB.Cache .BS S.CB
|
||
*--------------------------------------
|
||
CUR.Arrow .DA #S.BM.F.BBP1
|
||
.DA #2 RowBytes
|
||
.DA 12 W
|
||
.DA 12 H
|
||
.DA CUR.Arrow.MASK-CUR.Arrow
|
||
CUR.Arrow.DATA .DA %00000001.000000000
|
||
.DA %00000011.000000000
|
||
.DA %00000101.000000000
|
||
.DA %00001001.000000000
|
||
.DA %00010001.000000000
|
||
.DA %00100011.000000000
|
||
.DA %01110101.000000000
|
||
.DA %00011000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
CUR.Arrow.MASK .DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000010.000000000
|
||
.DA %00000110.000000000
|
||
.DA %00001110.000000000
|
||
.DA %00011100.000000000
|
||
.DA %00001000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
.DA %00000000.000000000
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/LIB/LIBGUI.S
|
||
ASM
|