2017-11-29 16:28:13 +00:00
|
|
|
|
NEW
|
2018-01-10 16:34:57 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
|
|
|
|
AUTO 4,1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2017-11-30 16:33:33 +00:00
|
|
|
|
* CLIPPING Functions:
|
|
|
|
|
* In:
|
|
|
|
|
* Graphic Context in GC.Cache
|
2017-12-01 15:53:29 +00:00
|
|
|
|
* YA = Control Block
|
|
|
|
|
* Out:
|
|
|
|
|
* CC : CB.Cache clipped & visible
|
|
|
|
|
* CS : CB.Cache invisible
|
2017-11-30 16:33:33 +00:00
|
|
|
|
*--------------------------------------
|
2017-12-04 16:42:08 +00:00
|
|
|
|
CLIP.YA jsr CB.Get
|
|
|
|
|
ldx CB.Cache+S.CB.CMD
|
2017-12-05 16:33:06 +00:00
|
|
|
|
CLIP.X jmp (J.CLIP,x)
|
2017-12-01 15:53:29 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CLIP.Point
|
|
|
|
|
CLIP.HLine
|
|
|
|
|
CLIP.VLine
|
|
|
|
|
|
|
|
|
|
CLIP.Rect
|
2017-12-30 22:14:05 +00:00
|
|
|
|
CLIP.Text
|
2017-12-01 15:53:29 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-12-04 07:18:24 +00:00
|
|
|
|
CLIP.BitBlt.9 pla
|
|
|
|
|
CLIP.BitBlt.99 sec
|
|
|
|
|
rts
|
|
|
|
|
|
2017-12-05 16:33:06 +00:00
|
|
|
|
CLIP.BitBlt lda CB.Cache+S.CB.DstX
|
|
|
|
|
ldx CB.Cache+S.CB.DstX+1
|
2017-12-01 15:53:29 +00:00
|
|
|
|
pha
|
2017-12-04 16:42:08 +00:00
|
|
|
|
|
|
|
|
|
>SCMPAX GC.Cache+S.GC.X2
|
|
|
|
|
bpl CLIP.BitBlt.9 DestX after X2....exit
|
2017-12-01 15:53:29 +00:00
|
|
|
|
|
|
|
|
|
pla
|
2017-12-04 16:42:08 +00:00
|
|
|
|
>SCMPAX GC.Cache+S.GC.X1
|
|
|
|
|
bpl .1 DestX Inside X1-X2, go check if X1+W fit in
|
2017-12-01 15:53:29 +00:00
|
|
|
|
|
2017-12-06 07:28:30 +00:00
|
|
|
|
* S.CB.DstX before S.GC.X1: D=S.GC.X1-S.CB.DstX, S.CB.SrcW-=D, S.CB.DstX=+=D, S.CB.X1+=D
|
2017-12-04 07:18:24 +00:00
|
|
|
|
|
|
|
|
|
lda GC.Cache+S.GC.X1 Compute D....
|
|
|
|
|
sec
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstX
|
2017-12-04 07:18:24 +00:00
|
|
|
|
sta D
|
|
|
|
|
lda GC.Cache+S.GC.X1+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstX+1
|
2017-12-04 07:18:24 +00:00
|
|
|
|
sta D+1 ....always positive
|
|
|
|
|
|
2017-12-04 16:42:08 +00:00
|
|
|
|
lda CB.Cache+S.CB.SrcW S.CB.SrcW-=D
|
2017-12-04 07:18:24 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc D
|
2017-12-04 16:42:08 +00:00
|
|
|
|
sta CB.Cache+S.CB.SrcW
|
|
|
|
|
lda CB.Cache+S.CB.SrcW+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc D+1
|
2017-12-04 16:42:08 +00:00
|
|
|
|
sta CB.Cache+S.CB.SrcW+1
|
2017-12-04 07:18:24 +00:00
|
|
|
|
bcc CLIP.BitBlt.99 Negative!!!! nothing to do,exit...
|
2017-12-01 15:53:29 +00:00
|
|
|
|
|
2017-12-06 16:26:36 +00:00
|
|
|
|
lda CB.Cache+S.CB.DstX S.CB.DstX+=D
|
2017-12-05 16:33:06 +00:00
|
|
|
|
clc
|
|
|
|
|
adc D
|
|
|
|
|
sta CB.Cache+S.CB.DstX
|
|
|
|
|
lda CB.Cache+S.CB.DstX+1
|
|
|
|
|
adc D+1
|
|
|
|
|
sta CB.Cache+S.CB.DstX+1
|
2017-12-01 15:53:29 +00:00
|
|
|
|
|
2017-12-04 16:42:08 +00:00
|
|
|
|
lda CB.Cache+S.CB.X1 S.CB.X1+=D
|
2017-12-04 07:18:24 +00:00
|
|
|
|
clc
|
|
|
|
|
adc D
|
2017-12-04 16:42:08 +00:00
|
|
|
|
sta CB.Cache+S.CB.X1
|
|
|
|
|
lda CB.Cache+S.CB.X1+1
|
2017-12-04 07:18:24 +00:00
|
|
|
|
adc D+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sta CB.Cache+S.CB.X1+1 S.CB.DstX=0, new between S.GC.X1 & S.GC.X2....
|
2017-12-04 07:18:24 +00:00
|
|
|
|
|
2017-12-07 07:42:58 +00:00
|
|
|
|
* S.CB.DstX between S.GC.X1 & S.GC.X2: D=(S.GC.X2+1)-S.CB.DstX
|
2017-12-04 16:42:08 +00:00
|
|
|
|
|
2017-12-07 07:42:58 +00:00
|
|
|
|
.1 lda GC.Cache+S.GC.X2 Compute D in X,Y
|
2017-12-04 07:18:24 +00:00
|
|
|
|
sec
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstX
|
2017-12-07 07:42:58 +00:00
|
|
|
|
tax
|
2017-12-04 16:42:08 +00:00
|
|
|
|
lda GC.Cache+S.GC.X2+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstX+1
|
2017-12-04 07:18:24 +00:00
|
|
|
|
|
2017-12-07 07:42:58 +00:00
|
|
|
|
inx
|
|
|
|
|
bne .2
|
|
|
|
|
inc
|
|
|
|
|
|
|
|
|
|
.2 tay
|
|
|
|
|
|
2017-12-05 16:33:06 +00:00
|
|
|
|
cpx CB.Cache+S.CB.SrcW
|
2017-12-04 16:42:08 +00:00
|
|
|
|
sbc CB.Cache+S.CB.SrcW+1
|
2017-12-04 07:18:24 +00:00
|
|
|
|
bcs CLIP.BitBlt.Y D >= SrcW....nothing to clip
|
2017-12-05 16:33:06 +00:00
|
|
|
|
|
|
|
|
|
stx CB.Cache+S.CB.SrcW SrcW < D, make SrcW=D
|
2017-12-07 07:42:58 +00:00
|
|
|
|
sty CB.Cache+S.CB.SrcW+1
|
2017-12-04 07:18:24 +00:00
|
|
|
|
|
2017-12-05 16:33:06 +00:00
|
|
|
|
CLIP.BitBlt.Y lda CB.Cache+S.CB.DstY
|
|
|
|
|
ldx CB.Cache+S.CB.DstY+1
|
2017-12-04 07:18:24 +00:00
|
|
|
|
pha
|
|
|
|
|
>SCMPAX GC.Cache+S.GC.Y2 DestY after Y2....exit
|
2017-12-05 07:09:16 +00:00
|
|
|
|
bmi .10
|
2017-12-06 07:28:30 +00:00
|
|
|
|
pla
|
2017-12-05 07:09:16 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-12-01 15:53:29 +00:00
|
|
|
|
|
2017-12-05 07:09:16 +00:00
|
|
|
|
.10 pla
|
2017-12-04 16:42:08 +00:00
|
|
|
|
>SCMPAX GC.Cache+S.GC.Y1
|
|
|
|
|
bpl .1 DestY Inside Y1-Y2, go check if Y1+H fit in
|
|
|
|
|
|
2017-12-05 16:33:06 +00:00
|
|
|
|
* S.CB.DstY above S.GC.Y1: D=S.GC.Y1-S.CB.DstY, S.CB.SrcH-=D, S.CB.DstY=0, S.CB.Y1+=D
|
|
|
|
|
|
2017-12-05 07:09:16 +00:00
|
|
|
|
lda GC.Cache+S.GC.Y1 Compute D....
|
|
|
|
|
sec
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstY
|
2017-12-05 07:09:16 +00:00
|
|
|
|
sta D
|
|
|
|
|
lda GC.Cache+S.GC.Y1+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstY+1
|
2017-12-05 07:09:16 +00:00
|
|
|
|
sta D+1 ....always positive
|
|
|
|
|
|
|
|
|
|
lda CB.Cache+S.CB.SrcH S.CB.SrcH-=D
|
|
|
|
|
sec
|
|
|
|
|
sbc D
|
|
|
|
|
sta CB.Cache+S.CB.SrcH
|
|
|
|
|
lda CB.Cache+S.CB.SrcH+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc D+1
|
2017-12-05 07:09:16 +00:00
|
|
|
|
sta CB.Cache+S.CB.SrcH+1
|
|
|
|
|
bcc .99 Negative!!!! nothing to do,exit...
|
|
|
|
|
|
2017-12-05 16:33:06 +00:00
|
|
|
|
lda CB.Cache+S.CB.DstY Dst.Y+=D
|
|
|
|
|
clc
|
|
|
|
|
adc D
|
|
|
|
|
sta CB.Cache+S.CB.DstY
|
|
|
|
|
lda CB.Cache+S.CB.DstY+1
|
|
|
|
|
adc D+1
|
|
|
|
|
sta CB.Cache+S.CB.DstY+1
|
2017-12-05 07:09:16 +00:00
|
|
|
|
|
|
|
|
|
lda CB.Cache+S.CB.Y1 S.CB.Y1+=D
|
|
|
|
|
clc
|
|
|
|
|
adc D
|
|
|
|
|
sta CB.Cache+S.CB.Y1
|
|
|
|
|
lda CB.Cache+S.CB.Y1+1
|
|
|
|
|
adc D+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sta CB.Cache+S.CB.Y1+1 S.CB.DstY=0, new between S.GC.Y1 & S.GC.Y2....
|
2017-12-05 07:09:16 +00:00
|
|
|
|
|
2017-12-07 07:42:58 +00:00
|
|
|
|
* S.CB.DstY between S.GC.Y1 & S.GC.Y2: D=(S.GC.Y2+1)-S.CB.DstY
|
2017-12-04 16:42:08 +00:00
|
|
|
|
|
2017-12-07 07:42:58 +00:00
|
|
|
|
.1 lda GC.Cache+S.GC.Y2 Compute D in X,Y
|
2017-12-05 07:09:16 +00:00
|
|
|
|
sec
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstY
|
2017-12-07 07:42:58 +00:00
|
|
|
|
tax
|
2017-12-05 07:09:16 +00:00
|
|
|
|
lda GC.Cache+S.GC.Y2+1
|
2017-12-05 16:33:06 +00:00
|
|
|
|
sbc CB.Cache+S.CB.DstY+1
|
2017-12-07 07:42:58 +00:00
|
|
|
|
|
|
|
|
|
inx
|
|
|
|
|
bne .2
|
|
|
|
|
inc
|
|
|
|
|
|
|
|
|
|
.2 tay
|
2017-12-05 07:09:16 +00:00
|
|
|
|
|
2017-12-05 16:33:06 +00:00
|
|
|
|
cpx CB.Cache+S.CB.SrcH
|
2017-12-05 07:09:16 +00:00
|
|
|
|
sbc CB.Cache+S.CB.SrcH+1
|
|
|
|
|
bcs .8 D >= SrcH....nothing to clip
|
2017-12-05 16:33:06 +00:00
|
|
|
|
|
|
|
|
|
stx CB.Cache+S.CB.SrcH SrcH < D, make SrcH=D
|
2017-12-07 07:42:58 +00:00
|
|
|
|
sty CB.Cache+S.CB.SrcH+1
|
2017-12-05 07:09:16 +00:00
|
|
|
|
|
|
|
|
|
.8 clc
|
2017-12-01 15:53:29 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 pla
|
2017-12-04 07:18:24 +00:00
|
|
|
|
.99 sec
|
2017-12-01 15:53:29 +00:00
|
|
|
|
rts
|
2017-11-30 16:33:33 +00:00
|
|
|
|
*--------------------------------------
|
2017-12-01 15:53:29 +00:00
|
|
|
|
CLIP.Line.LEFT .EQ 1
|
|
|
|
|
CLIP.Line.RIGHT .EQ 2
|
|
|
|
|
CLIP.Line.BOTTOM .EQ 4
|
|
|
|
|
CLIP.Line.TOP .EQ 8
|
2017-11-29 16:28:13 +00:00
|
|
|
|
*--------------------------------------
|
2017-12-01 15:53:29 +00:00
|
|
|
|
CLIP.Line jsr CLIP.Line.EncodeP1
|
|
|
|
|
jsr CLIP.Line.EncodeP2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
.1 lda CLIP.Line.P1
|
|
|
|
|
ora CLIP.Line.P2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .88
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
lda CLIP.Line.P1
|
|
|
|
|
and CLIP.Line.P2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bne .99
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
lda CLIP.Line.P1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .5
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
bit #CLIP.Line.TOP
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .2
|
|
|
|
|
* Y1 is above S.CB.Y1....
|
|
|
|
|
* DY=Y2-Y1;
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
.2 bit #CLIP.Line.BOTTOM
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .3
|
|
|
|
|
* Y1 is below S.CB.Y2....
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
.3 bit #CLIP.Line.RIGHT
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .4
|
|
|
|
|
* X1 is after S.CB.X2....
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
* X1 is before S.CB.X1....
|
|
|
|
|
.4
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
* P2
|
2017-12-01 15:53:29 +00:00
|
|
|
|
.5 lda CLIP.Line.P2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
bit #CLIP.Line.TOP
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .6
|
|
|
|
|
* Y2 is above S.CB.Y1....
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
.6 bit #CLIP.Line.BOTTOM
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .7
|
|
|
|
|
* Y2 is below S.CB.Y2....
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
.7 bit #CLIP.Line.RIGHT
|
2017-11-29 16:28:13 +00:00
|
|
|
|
beq .8
|
|
|
|
|
* X2 is after S.CB.X2....
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
* X2 is before S.CB.X1....
|
|
|
|
|
.8
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeP2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.88 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.99 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-12-01 15:53:29 +00:00
|
|
|
|
CLIP.Line.EncodeP1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
lda CB.Cache+S.CB.X1
|
|
|
|
|
ldx CB.Cache+S.CB.X1+1
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeX.AX
|
2017-11-29 16:28:13 +00:00
|
|
|
|
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
lda CB.Cache+S.CB.Y1
|
|
|
|
|
ldx CB.Cache+S.CB.Y1+1
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeY.AX
|
2017-11-29 16:28:13 +00:00
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
sta CLIP.Line.P1
|
2017-11-29 16:28:13 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-12-01 15:53:29 +00:00
|
|
|
|
CLIP.Line.EncodeP2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
lda CB.Cache+S.CB.X2
|
|
|
|
|
ldx CB.Cache+S.CB.X2+1
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeX.AX
|
2017-11-29 16:28:13 +00:00
|
|
|
|
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
lda CB.Cache+S.CB.Y2
|
|
|
|
|
ldx CB.Cache+S.CB.Y2+1
|
2017-12-01 15:53:29 +00:00
|
|
|
|
jsr CLIP.Line.EncodeY.AX
|
2017-11-29 16:28:13 +00:00
|
|
|
|
|
2017-12-01 15:53:29 +00:00
|
|
|
|
sta CLIP.Line.P2
|
2017-11-29 16:28:13 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-12-01 15:53:29 +00:00
|
|
|
|
CLIP.Line.EncodeX.AX
|
2017-11-29 16:28:13 +00:00
|
|
|
|
pha
|
|
|
|
|
>SCMPAX GC.Cache+S.GC.X1
|
|
|
|
|
bmi .1
|
|
|
|
|
tya
|
2017-12-01 15:53:29 +00:00
|
|
|
|
ora #CLIP.Line.LEFT
|
2017-11-29 16:28:13 +00:00
|
|
|
|
plx
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 pla
|
|
|
|
|
>SCMPAX GC.Cache+S.GC.X1
|
|
|
|
|
bpl .8
|
|
|
|
|
tya
|
2017-12-01 15:53:29 +00:00
|
|
|
|
ora #CLIP.Line.RIGHT
|
2017-11-29 16:28:13 +00:00
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2017-12-01 15:53:29 +00:00
|
|
|
|
CLIP.Line.EncodeY.AX
|
2017-11-29 16:28:13 +00:00
|
|
|
|
pha
|
|
|
|
|
>SCMPAX GC.Cache+S.GC.Y1
|
|
|
|
|
bmi .1
|
|
|
|
|
tya
|
2017-12-01 15:53:29 +00:00
|
|
|
|
ora #CLIP.Line.TOP
|
2017-11-29 16:28:13 +00:00
|
|
|
|
plx
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 pla
|
|
|
|
|
>SCMPAX GC.Cache+S.GC.Y1
|
|
|
|
|
bpl .8
|
|
|
|
|
tya
|
2017-12-01 15:53:29 +00:00
|
|
|
|
ora #CLIP.Line.BOTTOM
|
2017-11-29 16:28:13 +00:00
|
|
|
|
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE /A2OSX.SRC/LIB/LIBGUI.S.CLIP
|
|
|
|
|
LOAD /A2OSX.SRC/LIB/LIBGUI.S
|
|
|
|
|
ASM
|