A2osX/LIB/LIBGUI.S.DRAW.txt

430 lines
7.6 KiB
Plaintext
Raw Normal View History

NEW
2019-07-30 08:57:25 +00:00
AUTO 3,1
*--------------------------------------
2020-10-26 16:32:51 +00:00
* drawline(short int hWND, short int OP, short int COLOR, int X1, int Y1, int X2, int X2)
*--------------------------------------
DRAW.Line jsr CB.PullY2X2Y1X1
2020-10-26 16:32:51 +00:00
2020-10-02 14:57:05 +00:00
>PULLB CB.Cache+S.CB.COLOR
>PULLB CB.Cache+S.CB.OP
jsr OBJ.PullHWND get dest window at ZPWNDPtr
jsr WND.GetInnerInClip
jsr CB.ToGlobal
2020-10-02 14:57:05 +00:00
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....
2022-11-02 06:54:30 +00:00
ora DX
bne .2 DX > 0...
ldx CB.Cache+S.CB.Y2
cpx CB.Cache+S.CB.Y1
lda CB.Cache+S.CB.Y2+1
sbc CB.Cache+S.CB.Y1+1
bcs .17
>SWAP16 CB.Cache+S.CB.Y1,CB.Cache+S.CB.Y2
.17 lda #S.CB.CMD.VLINE DX=0 : VLINE Y1,Y2 At X1
2020-10-06 06:27:35 +00:00
bra .20
*--------------------------------------
.1 >SWAP16 CB.Cache+S.CB.X1,CB.Cache+S.CB.X2
2020-10-06 06:27:35 +00:00
>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
2020-10-06 06:27:35 +00:00
lda CB.Cache+S.CB.Y2+1
sbc CB.Cache+S.CB.Y1+1
2020-10-26 16:32:51 +00:00
sta DY+1 DY = Y2 - Y1
2020-10-06 06:27:35 +00:00
bmi .3 DY < 0 ...
2020-10-06 06:27:35 +00:00
ora DY
bne .4
2020-10-06 06:27:35 +00:00
lda #S.CB.CMD.HLINE DY=0 : HLINE X1,X2 At Y1
.20 sta CB.Cache+S.CB.CMD
2022-11-03 06:59:03 +00:00
jmp CB.Write
2022-11-02 06:54:30 +00:00
.8 clc
rts
2020-10-06 06:27:35 +00:00
*--------------------------------------
.3 >NOT16 DY set DY=-DY
lda #$ff
sta IY set IY=-1
.4
2022-11-02 06:54:30 +00:00
* jsr CLIP.Line
* bcs .8
2020-10-06 06:27:35 +00:00
2022-11-03 16:21:26 +00:00
jsr PTR.Disable
2020-10-06 06:27:35 +00:00
lda #S.CB.CMD.SETPIXEL
sta CB.Cache+S.CB.CMD
ldx #0 Select CB.Cache
jsr CB.GFXWriteX
lda DX
sec
sbc DY
tax
lda DX+1
2020-10-06 06:27:35 +00:00
sbc DY+1
bmi DRAW.Line.IncY DY is greater than DX, we will increase on Y axis
2020-10-06 06:27:35 +00:00
txa
beq DRAW.Line.IncXY DX=DY, go inc X & Y
jmp DRAW.Line.IncX DY is lower than DX, we will increase on X axis
2020-10-06 06:27:35 +00:00
*--------------------------------------
DRAW.Line.IncXY lda DX DX=DY
eor #$ff
sta Counter
lda DX+1
eor #$ff
sta Counter+1
.1 inc Counter
bne .2
2020-10-06 06:27:35 +00:00
inc Counter+1
beq .8
2020-10-06 06:27:35 +00:00
.2 inc CB.Cache+S.CB.X1
bne .3
2020-10-06 06:27:35 +00:00
inc CB.Cache+S.CB.X1+1
2022-11-02 06:54:30 +00:00
.3 lda CB.Cache+S.CB.Y1 Y1=Y1+IY
clc
adc IY
sta CB.Cache+S.CB.Y1
ldx #0 Select CB.Cache
jsr CB.GFXWriteX
bra .1
2020-10-01 06:08:33 +00:00
2022-11-03 16:21:26 +00:00
.8 jmp PTR.Enable
2020-10-06 06:27:35 +00:00
*--------------------------------------
DRAW.Line.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
2020-10-06 06:27:35 +00:00
.1 inc Counter
bne .2
2020-10-02 14:57:05 +00:00
inc Counter+1
beq .8
.2 lda D+1 IF D < 0 ...
bmi .4
2020-10-02 14:57:05 +00:00
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
2020-10-02 14:57:05 +00:00
inc CB.Cache+S.CB.X1+1
2019-10-03 06:25:27 +00:00
bra .5
2020-10-02 14:57:05 +00:00
.4 lda D D > 0 : D=D+IE
clc
adc IE
sta D
lda D+1
adc IE+1
sta D+1
2020-10-02 14:57:05 +00:00
.5 lda CB.Cache+S.CB.Y1 Y1=Y1+IY
clc
adc IY
sta CB.Cache+S.CB.Y1
ldx #0 Select CB.Cache
jsr CB.GFXWriteX
bra .1
2020-10-02 14:57:05 +00:00
2022-11-03 16:21:26 +00:00
.8 jmp PTR.Enable
2020-10-06 06:27:35 +00:00
*--------------------------------------
DRAW.Line.IncX lda DX
eor #$ff
sta Counter
lda DX+1
eor #$ff
2020-10-26 16:32:51 +00:00
sta Counter+1
2022-11-02 06:54:30 +00:00
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
2020-10-06 06:27:35 +00:00
.1 inc Counter
bne .2
2020-10-02 14:57:05 +00:00
inc Counter+1
beq .8
.2 lda D+1 ID D < 0 ....
bmi .4
2020-10-02 14:57:05 +00:00
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
2019-10-03 06:25:27 +00:00
bra .5
2020-10-02 14:57:05 +00:00
.4 lda D D < 0 : D=D+IE
clc
adc IE
sta D
lda D+1
adc IE+1
sta D+1
2020-10-06 06:27:35 +00:00
.5 inc CB.Cache+S.CB.X1 X1=X1+1
bne .6
2020-10-02 14:57:05 +00:00
inc CB.Cache+S.CB.X1+1
2020-10-02 14:57:05 +00:00
.6 ldx #0 Select CB.Cache
jsr CB.GFXWriteX
bra .1
2020-10-26 16:32:51 +00:00
2022-11-03 16:21:26 +00:00
.8 jmp PTR.Enable
*--------------------------------------
2022-11-02 06:54:30 +00:00
* fill (short int hWND, short int OP, short int COLOR, int X1, int Y1, int X2, int Y2)
2020-10-26 06:38:50 +00:00
*--------------------------------------
DRAW.Fill jsr CB.PullY2X2Y1X1
2020-10-27 16:33:10 +00:00
>PULLB CB.Cache+S.CB.COLOR
>PULLB CB.Cache+S.CB.OP
jsr OBJ.PullHWND get dest window at ZPWNDPtr
jsr WND.GetInnerInClip
2020-10-27 16:33:10 +00:00
jsr CB.ToGlobal
2020-10-27 16:33:10 +00:00
lda #S.CB.CMD.FILLRECT
sta CB.Cache+S.CB.CMD
jmp CB.Write
2020-10-26 06:38:50 +00:00
*--------------------------------------
* drawBitmap (short int hWND, short int OP, short int M, S.BM *bitmap, int X1, int Y1)
2020-10-06 06:27:35 +00:00
*--------------------------------------
DRAW.BitMap jsr CB.PullY1X1
2020-10-27 16:33:10 +00:00
>PULLW CB.Cache+S.CB.SrcPtr
2020-10-27 16:33:10 +00:00
>PULLB CB.Cache+S.CB.M
>PULLB CB.Cache+S.CB.OP
jsr OBJ.PullHWND get dest window at ZPWNDPtr
jsr WND.GetInnerInClip
2020-10-27 16:33:10 +00:00
jsr CB.ToGlobal
2020-10-27 16:33:10 +00:00
lda #S.CB.CMD.BITBLT
sta CB.Cache+S.CB.CMD
2020-10-27 16:33:10 +00:00
jsr CB.ResetSrcXY
jmp CB.Write
2020-10-06 06:27:35 +00:00
*--------------------------------------
2022-11-03 06:59:03 +00:00
* drawtext (short int hWND, short int OP, short int hFONT, int X1, int Y1, char *str)
*--------------------------------------
DRAW.Text >PULLW CB.Cache+S.CB.TxtPtr
jsr CB.PullY1X1
2022-11-03 06:59:03 +00:00
>PULLB CB.Cache+S.CB.hFont
>PULLB CB.Cache+S.CB.OP
jsr OBJ.PullHWND get dest window at ZPWNDPtr
jsr WND.GetInnerInClip
jsr CB.ToGlobal
2022-11-03 06:59:03 +00:00
lda #S.CB.CMD.DRAWTEXT2
sta CB.Cache+S.CB.CMD
2022-11-03 06:59:03 +00:00
jmp CB.Write
2022-11-03 06:59:03 +00:00
*--------------------------------------
* private
*--------------------------------------
DRAW.BordersAtX stx IY
2020-10-20 06:01:04 +00:00
jsr CB.BorderLineH
2022-10-19 15:23:41 +00:00
ldy #S.OBJ.X1
2022-10-19 15:23:41 +00:00
lda (ZPObjPtr),y
sec
sbc IY
sta CB.Cache+S.CB.X1
iny
lda (ZPObjPtr),y
sbc #0
sta CB.Cache+S.CB.X1+1
iny #S.OBJ.Y1
lda (ZPObjPtr),y
sec
sbc IY
sta CB.Cache+S.CB.Y1
iny
lda (ZPObjPtr),y
sbc #0
sta CB.Cache+S.CB.Y1+1
iny #S.OBJ.X2
lda (ZPObjPtr),y
clc
adc IY
sta CB.Cache+S.CB.X2
iny
lda (ZPObjPtr),y
adc #0
sta CB.Cache+S.CB.X2+1 top: X1,X2 at Y1
iny #S.OBJ.Y2
2022-10-19 15:23:41 +00:00
lda (ZPObjPtr),y
clc
adc IY
sta CB.Cache+S.CB.Y2
iny
lda (ZPObjPtr),y
adc #0
sta CB.Cache+S.CB.Y2+1
2020-10-26 16:32:51 +00:00
jsr CB.Cache2CBBufG
2020-10-20 06:01:04 +00:00
jsr CB.SwapY1Y2
2020-10-20 06:01:04 +00:00
jsr CB.Cache2CBBuf bottom X1,X2 at Y2
2020-10-20 06:01:04 +00:00
lda #S.CB.CMD.VLINE
sta CB.Cache+S.CB.CMD
jsr CB.SwapY1Y2
jsr CB.Cache2CBBuf left Y1,Y2 at X1
jsr CB.SwapX1X2
jmp CB.Cache2CBBuf right X2,Y1,X2,Y2
*--------------------------------------
DRAW.xBM >LDYA L.BMs,x
DRAW.yaBM jsr BM.YA2CB.cache
2020-10-20 06:01:04 +00:00
jmp CB.Cache2CBBuf
2020-10-20 06:01:04 +00:00
*--------------------------------------
2022-10-19 15:23:41 +00:00
DRAW.YAText >STYA CB.Cache+S.CB.TxtPtr
stx CB.Cache+S.CB.hFont
2020-10-20 06:01:04 +00:00
2022-11-02 06:54:30 +00:00
lda #S.CB.CMD.DRAWTEXT2
2020-10-20 06:01:04 +00:00
sta CB.Cache+S.CB.CMD
2020-10-26 16:32:51 +00:00
lda #S.CB.OP.XOR
2020-10-20 06:01:04 +00:00
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
jsr CB.ResetSrcXY
2020-10-27 16:33:10 +00:00
jmp CB.Cache2CBBuf
2020-10-27 16:33:10 +00:00
*--------------------------------------
MAN
2020-06-30 15:32:23 +00:00
SAVE usr/src/lib/libgui.s.draw
LOAD usr/src/lib/libgui.s
ASM