mirror of
https://github.com/A2osX/A2osX.git
synced 2024-10-31 23:09:33 +00:00
561 lines
9.4 KiB
Plaintext
561 lines
9.4 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*--------------------------------------
|
||
* drawline(short int hWND, short int OP, short int COLOR, int X1, int Y1, int X2, int X2)
|
||
*--------------------------------------
|
||
DrawLine jsr DRAW.PullY2X2Y1X1
|
||
|
||
>PULLB CB.Cache+S.CB.COLOR
|
||
>PULLB CB.Cache+S.CB.OP
|
||
|
||
jsr DRAW.PullWND
|
||
|
||
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 DX=0 : VLINE Y1,Y2 At X1
|
||
bra .20
|
||
*--------------------------------------
|
||
.1 >SWAP16 CB.Cache+S.CB.X1,CB.Cache+S.CB.X2
|
||
>SWAP16 CB.Cache+S.CB.Y1,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
|
||
sbc CB.Cache+S.CB.Y1+1
|
||
sta DY+1 DY = Y2 - Y1
|
||
|
||
bmi .3 DY < 0 ...
|
||
|
||
ora DY
|
||
bne .4
|
||
|
||
lda #S.CB.CMD.HLINE DY=0 : HLINE X1,X2 At Y1
|
||
|
||
.20 sta CB.Cache+S.CB.CMD
|
||
|
||
jsr CLIP.CB.Cache
|
||
bcs .8
|
||
|
||
jmp GFXWrite.CB
|
||
.8 rts
|
||
*--------------------------------------
|
||
.3 >NOT16 DY set DY=-DY
|
||
lda #$ff
|
||
sta IY set IY=-1
|
||
|
||
.4 jsr CLIP.Line
|
||
bcs .8
|
||
|
||
lda #S.CB.CMD.SETPIXEL
|
||
sta CB.Cache+S.CB.CMD
|
||
jsr GFXWrite.CB
|
||
lda DX
|
||
sec
|
||
sbc DY
|
||
tax
|
||
lda DX+1
|
||
sbc DY+1
|
||
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 GFXWrite.CB
|
||
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 GFXWrite.CB
|
||
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 GFXWrite.CB
|
||
bra .1
|
||
|
||
.8 rts
|
||
*--------------------------------------
|
||
* fillrectangle (short int hWND, short int OP, short int COLOR, int X1, int Y1, int X2, int Y2)
|
||
*--------------------------------------
|
||
FillRectangle jsr DRAW.PullY2X2Y1X1
|
||
|
||
>PULLB CB.Cache+S.CB.COLOR
|
||
>PULLB CB.Cache+S.CB.OP
|
||
|
||
jsr DRAW.PullWND
|
||
|
||
lda #S.CB.CMD.FILLRECT
|
||
sta CB.Cache+S.CB.CMD
|
||
|
||
jsr CLIP.CB.Cache
|
||
bcs .8
|
||
|
||
jmp GFXWrite.CB
|
||
|
||
.8 rts
|
||
*--------------------------------------
|
||
* drawbitmap (short int hWND, short int OP, short int M, S.BM *bitmap, int X1, int Y1)
|
||
*--------------------------------------
|
||
DrawBitMap lda #S.CB.CMD.BITBLT
|
||
jsr CB.InitCacheA
|
||
|
||
jsr DRAW.PullY1X1
|
||
|
||
>PULLW CB.Cache+S.CB.SrcPtr
|
||
|
||
>PULLB CB.Cache+S.CB.M
|
||
>PULLB CB.Cache+S.CB.OP
|
||
|
||
jsr DRAW.PullWND
|
||
|
||
jsr CLIP.CB.Cache
|
||
bcs .8
|
||
|
||
jmp GFXWrite.CB
|
||
|
||
.8 rts
|
||
*--------------------------------------
|
||
DRAW.xBMAtDXDY >LDYA L.BMs,x
|
||
DRAW.yaBMAtDXDY >STYA ZPBMPtr Src BM
|
||
|
||
lda #S.CB.CMD.BITBLT
|
||
jsr CB.InitCacheA
|
||
|
||
lda #S.CB.OP.MASK+S.CB.OP.ORA+S.CB.OP.COLOR
|
||
sta CB.Cache+S.CB.OP
|
||
|
||
lda #S.CB.M.C16
|
||
sta CB.Cache+S.CB.M
|
||
|
||
ldx #3
|
||
|
||
.1 lda DX,x
|
||
sta CB.Cache+S.CB.X1,x
|
||
dex
|
||
bpl .1
|
||
|
||
ldx #3
|
||
|
||
ldy #S.BM.W+3
|
||
|
||
.2 lda (ZPBMPtr),y
|
||
sta CB.Cache+S.CB.SrcW,x
|
||
dey
|
||
dex
|
||
bpl .2
|
||
|
||
lda ZPBMPtr
|
||
sta CB.Cache+S.CB.SrcPtr
|
||
|
||
lda ZPBMPtr+1
|
||
sta CB.Cache+S.CB.SrcPtr+1
|
||
|
||
jmp PutCBCache2CBBuf
|
||
*--------------------------------------
|
||
* drawtext (short int hWND, short int OP, short int hFONT, int X1, int Y1, char *str)
|
||
*--------------------------------------
|
||
DrawText lda #S.CB.CMD.DRAWTEXT2
|
||
jsr CB.InitCacheA
|
||
|
||
>PULLW CB.Cache+S.CB.TxtPtr
|
||
|
||
jsr DRAW.PullY1X1
|
||
|
||
>PULLB CB.Cache+S.CB.hFont
|
||
>PULLB CB.Cache+S.CB.OP
|
||
|
||
jsr DRAW.PullWND
|
||
|
||
jsr CLIP.CB.Cache
|
||
bcs .8
|
||
|
||
jmp GFXWrite.CB
|
||
|
||
.8 rts
|
||
*--------------------------------------
|
||
DRAW.YATextAtDXDY
|
||
phx
|
||
jsr CB.ClearCache
|
||
>STYA CB.Cache+S.CB.TxtPtr
|
||
plx
|
||
stx CB.Cache+S.CB.hFont
|
||
|
||
lda #S.CB.CMD.DRAWTEXT2
|
||
sta CB.Cache+S.CB.CMD
|
||
|
||
lda #0
|
||
ror
|
||
eor #S.CB.OP.INVERSE
|
||
ora #S.CB.OP.SET
|
||
|
||
* lda #S.CB.OP.XOR
|
||
sta CB.Cache+S.CB.OP
|
||
|
||
lda #S.CB.M.MONO
|
||
sta CB.Cache+S.CB.M
|
||
|
||
ldx #3
|
||
|
||
.1 lda DX,x DX,DY -> S.CB.X1,S.CB.Y1
|
||
sta CB.Cache+S.CB.X1,x
|
||
dex
|
||
bpl .1
|
||
|
||
jmp PutCBCache2CBBuf
|
||
*--------------------------------------
|
||
DRAW.PullY2X2Y1X1
|
||
ldx #7
|
||
bra DRAW.PullX
|
||
|
||
DRAW.PullY1X1 ldx #3
|
||
|
||
DRAW.PullX >PULLA
|
||
sta CB.Cache+S.CB.X1,x
|
||
dex
|
||
bpl DRAW.PullX
|
||
|
||
rts
|
||
*--------------------------------------
|
||
DRAW.PullWND >PULLA hWND
|
||
>SYSCALL2 GetMemPtr
|
||
>STYA ZPWNDPtr
|
||
|
||
jsr DRAW.ToGlobal set CB.Cache to global coord.
|
||
*--------------------------------------
|
||
DRAW.GetInnerWND
|
||
ldy #S.OBJ.X1
|
||
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.X1
|
||
iny
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.X1+1
|
||
|
||
ldy #S.WND.InnerY1
|
||
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.Y1
|
||
iny
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.Y1+1
|
||
|
||
ldy #S.WND.InnerW
|
||
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.W
|
||
iny
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.W+1
|
||
|
||
iny #S.WND.InnerH
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.H
|
||
iny
|
||
lda (ZPWNDPtr),y
|
||
sta OBJ.Cache+S.OBJ.H+1
|
||
|
||
>LDYA L.OBJ.Cache
|
||
jmp OBJ.SetX2Y2
|
||
*--------------------------------------
|
||
DRAW.ToGlobal >LDYA ZPWNDPtr
|
||
>STYA ZPPtr1
|
||
|
||
.1 ldy #S.OBJ.X1
|
||
ldx #S.CB.X1
|
||
jsr DRAW.AddP1YtoCBX
|
||
|
||
ldy #S.WND.InnerY1
|
||
ldx #S.CB.Y1
|
||
jsr DRAW.AddP1YtoCBX
|
||
|
||
ldy #S.OBJ.X1
|
||
ldx #S.CB.X2
|
||
jsr DRAW.AddP1YtoCBX
|
||
|
||
ldy #S.WND.InnerY1
|
||
ldx #S.CB.Y2
|
||
jsr DRAW.AddP1YtoCBX
|
||
|
||
ldy #S.OBJ.hPARENT+1
|
||
lda (ZPPtr1),y
|
||
beq .8 00xx = hDev
|
||
|
||
tax
|
||
dey
|
||
lda (ZPPtr1),y
|
||
|
||
sta ZPPtr1
|
||
stx ZPPtr1+1
|
||
bra .1
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
DRAW.AddP1YtoCBX
|
||
lda (ZPPtr1),y
|
||
clc
|
||
adc CB.Cache,x
|
||
sta CB.Cache,x
|
||
iny
|
||
lda (ZPPtr1),y
|
||
adc CB.Cache+1,x
|
||
sta CB.Cache+1,x
|
||
rts
|
||
*--------------------------------------
|
||
DrawCBBufToYA pha
|
||
phy
|
||
|
||
bit CUR.bVisible
|
||
bpl .1
|
||
|
||
jsr HideCursor.I
|
||
|
||
.1 lda #0
|
||
sta (ZPCBBufPtr)
|
||
|
||
ply
|
||
pla
|
||
|
||
jsr OBJ.GetInCache
|
||
|
||
.2 lda (ZPCBPtr)
|
||
beq .8
|
||
|
||
>LDYA ZPCBPtr
|
||
jsr CB.GetInCache A = CB.CMD
|
||
|
||
cmp #S.CB.CMD.DRAWTEXT2
|
||
bne .6
|
||
|
||
lda #S.CB.CMD.DRAWTEXT+S.CB.CMD.OSD
|
||
sta CB.Cache+S.CB.CMD
|
||
jsr GFXWrite.CB
|
||
bcs .9
|
||
|
||
jsr CLIP.CB.Cache
|
||
bcs .3
|
||
|
||
jsr GFXWrite.CB
|
||
|
||
.3 lda CB.Cache+S.CB.SrcPtr
|
||
>SYSCALL2 FreeStkObj
|
||
bra .7
|
||
|
||
.6 jsr CLIP.CB.Cache
|
||
bcs .7
|
||
|
||
jsr GFXWrite.CB
|
||
|
||
.7 lda (ZPCBPtr) Get Cmd
|
||
lsr
|
||
tax
|
||
lda CB.CmdLen-1,x
|
||
sec +1
|
||
adc ZPCBPtr
|
||
sta ZPCBPtr
|
||
bcc .2
|
||
|
||
inc ZPCBPtr+1
|
||
bra .2
|
||
|
||
.8 lda hCBBuf
|
||
stz hCBBuf
|
||
>SYSCALL2 FreeMem
|
||
|
||
clc
|
||
|
||
bit CUR.bVisible
|
||
bpl .9
|
||
|
||
jmp ShowCursor.I
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/lib/libgui.s.draw
|
||
LOAD usr/src/lib/libgui.s
|
||
ASM
|