A2osX/LIB/LIBGUI.S.DRAW.txt
burniouf 9a7d20a7e1 ProDOS 203 / FX:TC mod for year 2022-2026
FORMAT: new switches & checks
SH:BREAK in FOR and WHILE
ASM / S-C MASM: new directives, CString support and .HX
LC / UC:bugfix
DHGR.DRV:bugfix
LIBGUI:wip
CC:wip
2022-12-07 08:02:29 +01:00

430 lines
7.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
*--------------------------------------
* drawline(short int hWND, short int OP, short int COLOR, int X1, int Y1, int X2, int X2)
*--------------------------------------
DRAW.Line jsr CB.PullY2X2Y1X1
>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
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...
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
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
jmp CB.Write
.8 clc
rts
*--------------------------------------
.3 >NOT16 DY set DY=-DY
lda #$ff
sta IY set IY=-1
.4
* jsr CLIP.Line
* bcs .8
jsr PTR.Disable
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
sbc DY+1
bmi DRAW.Line.IncY DY is greater than DX, we will increase on Y axis
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
*--------------------------------------
DRAW.Line.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
ldx #0 Select CB.Cache
jsr CB.GFXWriteX
bra .1
.8 jmp PTR.Enable
*--------------------------------------
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
.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
ldx #0 Select CB.Cache
jsr CB.GFXWriteX
bra .1
.8 jmp PTR.Enable
*--------------------------------------
DRAW.Line.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 ldx #0 Select CB.Cache
jsr CB.GFXWriteX
bra .1
.8 jmp PTR.Enable
*--------------------------------------
* fill (short int hWND, short int OP, short int COLOR, int X1, int Y1, int X2, int Y2)
*--------------------------------------
DRAW.Fill jsr CB.PullY2X2Y1X1
>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
lda #S.CB.CMD.FILLRECT
sta CB.Cache+S.CB.CMD
jmp CB.Write
*--------------------------------------
* drawBitmap (short int hWND, short int OP, short int M, S.BM *bitmap, int X1, int Y1)
*--------------------------------------
DRAW.BitMap jsr CB.PullY1X1
>PULLW CB.Cache+S.CB.SrcPtr
>PULLB CB.Cache+S.CB.M
>PULLB CB.Cache+S.CB.OP
jsr OBJ.PullHWND get dest window at ZPWNDPtr
jsr WND.GetInnerInClip
jsr CB.ToGlobal
lda #S.CB.CMD.BITBLT
sta CB.Cache+S.CB.CMD
jsr CB.ResetSrcXY
jmp CB.Write
*--------------------------------------
* 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
>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
lda #S.CB.CMD.DRAWTEXT2
sta CB.Cache+S.CB.CMD
jmp CB.Write
*--------------------------------------
* private
*--------------------------------------
DRAW.BordersAtX stx IY
jsr CB.BorderLineH
ldy #S.OBJ.X1
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
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
jsr CB.Cache2CBBufG
jsr CB.SwapY1Y2
jsr CB.Cache2CBBuf bottom X1,X2 at Y2
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
jmp CB.Cache2CBBuf
*--------------------------------------
DRAW.YAText >STYA CB.Cache+S.CB.TxtPtr
stx CB.Cache+S.CB.hFont
lda #S.CB.CMD.DRAWTEXT2
sta CB.Cache+S.CB.CMD
lda #S.CB.OP.XOR
sta CB.Cache+S.CB.OP
lda #S.CB.M.MONO
sta CB.Cache+S.CB.M
jsr CB.ResetSrcXY
jmp CB.Cache2CBBuf
*--------------------------------------
MAN
SAVE usr/src/lib/libgui.s.draw
LOAD usr/src/lib/libgui.s
ASM