A2osX/LIB/LIBGUI.S.DRAW.txt

280 lines
4.8 KiB
Plaintext
Raw Normal View History

NEW
2019-07-30 08:57:25 +00:00
AUTO 3,1
*--------------------------------------
Draw >PULLW ZPCBPtr Get CB
>PULLYA Get GC
2019-01-10 16:26:58 +00:00
jsr OBJ.Get
.1 >LDYA ZPCBPtr
jsr CB.Get
ldx CB.Cache+S.CB.CMD Get Cmd
beq .8
jsr CLIP.X
bcs .7
ldx CB.Cache+S.CB.CMD
cpx #S.CB.CMD.DRAWLINE
bcc .2 Native DRV Cmd
jsr Draw.Jmp
bra .7
2019-01-10 16:26:58 +00:00
.2 jsr GFXWrite.CB
2017-12-04 07:18:24 +00:00
.7 lda (ZPCBPtr) Get Cmd
tax
lda CB.CmdLen,x
sec
2017-12-04 07:18:24 +00:00
adc ZPCBPtr
sta ZPCBPtr
bcc .1
2017-12-04 07:18:24 +00:00
inc ZPCBPtr+1
bra .1
2019-10-03 06:25:27 +00:00
.8 clc
2020-06-30 15:32:23 +00:00
.9 rts
2019-10-03 06:25:27 +00:00
Draw.Jmp jmp (J.Cmds-S.CB.CMD.DRAWLINE,x)
*--------------------------------------
* In: Control Block in CB.Cache
* CMD
* 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
2019-01-10 16:26:58 +00:00
jmp GFXWrite.CB 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
2019-01-10 16:26:58 +00:00
jmp GFXWrite.CB 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
2019-01-10 16:26:58 +00:00
jsr GFXWrite.CB
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
2019-01-10 16:26:58 +00:00
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
2019-10-03 06:25:27 +00:00
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
2019-01-10 16:26:58 +00:00
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
2019-10-03 06:25:27 +00:00
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
2019-01-10 16:26:58 +00:00
.6 jsr GFXWrite.CB
bra .1
.8 rts
*--------------------------------------
DrawText >LDYA L.CB.Cache
ldx #0
2019-07-30 15:35:42 +00:00
>SYSCALL2 OSD
bcs .9
2019-01-10 16:26:58 +00:00
jsr GFXWrite.CB
lda CB.Cache+S.CB.SrcPtr
2019-05-05 17:15:37 +00:00
>SYSCALL2 FreeStkObj
.9 rts
2017-12-04 07:18:24 +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