PR#3 PREFIX /A2OSX.BUILD NEW INC 1 AUTO 6 .LIST OFF *-------------------------------------- * CLIPPING Functions: * In: * Graphic Context in GC.Cache * YA = Control Block * Out: * CC : CB.Cache clipped & visible * CS : CB.Cache invisible *-------------------------------------- CLIP.YA >STYA ZPCBPtr lda (ZPCBPtr) tax jmp (J.CLIP,x) *-------------------------------------- CLIP.Point CLIP.HLine CLIP.VLine CLIP.Rect clc rts *-------------------------------------- CLIP.BitBlt.9 pla CLIP.BitBlt.99 sec rts CLIP.BitBlt clc rts >DEBUG ldy #S.CB.DestX+1 lda (ZPCBPtr),y tax dey lda (ZPCBPtr),y pha >SCMPAX GC.Cache+S.GC.X2 DestX after X2....exit bmi CLIP.BitBlt.9 pla >SCMPAX GC.Cache+S.GC.X1 DestX Inside X1-X2, go check if X1+W fit in bpl .1 * S.CB.DestX before S.GC.X1: D=S.GC.X1-S.CB.DestX, S.CB.SrcW-=D, S.CB.DestX=0, S.CB.X1+=D lda GC.Cache+S.GC.X1 Compute D.... sec ldy #S.CB.DestX sbc (ZPCBPtr),y sta D lda GC.Cache+S.GC.X1+1 iny sbc (ZPCBPtr),y sta D+1 ....always positive ldy #S.CB.SrcW S.CB.SrcW-=D lda (ZPCBPtr),y sec sbc D sta (ZPCBPtr),y iny lda (ZPCBPtr),y sbc D sta (ZPCBPtr),y bcc CLIP.BitBlt.99 Negative!!!! nothing to do,exit... lda #0 Dext.X=0 ldy #S.CB.DestX sta (ZPCBPtr),y iny sta (ZPCBPtr),y ldy #S.CB.X1 S.CB.X1+=D lda (ZPCBPtr),y clc adc D sta (ZPCBPtr),y iny lda (ZPCBPtr),y adc D+1 sta (ZPCBPtr),y S.CB.DestX=0, new between S.GC.X1 & S.GC.X2.... * S.CB.DestX between S.GC.X1 & S.GC.X2: D=S.GC.X2-S.CB.DestX .1 lda GC.Cache+S.GC.X2 sec ldy #S.CB.DestY sbc (ZPCBPtr),y sta D iny lda GC.Cache+S.GC.X2 sbc (ZPCBPtr),y sta D+1 Always positive... lda D ldy #S.CB.SrcW cmp (ZPCBPtr),y iny lda D+1 cmp (ZPCBPtr),y bcs CLIP.BitBlt.Y D >= SrcW....nothing to clip lda D+1 SrcW < D, amke SrcW=D sta (ZPCBPtr),y dey lda D sta (ZPCBPtr),y CLIP.BitBlt.Y ldy #S.CB.DestY+1 lda (ZPCBPtr),y tax dey lda (ZPCBPtr),y pha >SCMPAX GC.Cache+S.GC.Y2 DestY after Y2....exit bmi .9 clc rts .9 pla .99 sec rts *-------------------------------------- CLIP.Line.LEFT .EQ 1 CLIP.Line.RIGHT .EQ 2 CLIP.Line.BOTTOM .EQ 4 CLIP.Line.TOP .EQ 8 *-------------------------------------- CLIP.Line jsr CLIP.Line.EncodeP1 jsr CLIP.Line.EncodeP2 .1 lda CLIP.Line.P1 ora CLIP.Line.P2 beq .88 lda CLIP.Line.P1 and CLIP.Line.P2 bne .99 lda CLIP.Line.P1 beq .5 bit #CLIP.Line.TOP beq .2 * Y1 is above S.CB.Y1.... * DY=Y2-Y1; jsr CLIP.Line.EncodeP1 bra .1 .2 bit #CLIP.Line.BOTTOM beq .3 * Y1 is below S.CB.Y2.... jsr CLIP.Line.EncodeP1 bra .1 .3 bit #CLIP.Line.RIGHT beq .4 * X1 is after S.CB.X2.... jsr CLIP.Line.EncodeP1 bra .1 * X1 is before S.CB.X1.... .4 jsr CLIP.Line.EncodeP1 bra .1 * P2 .5 lda CLIP.Line.P2 bit #CLIP.Line.TOP beq .6 * Y2 is above S.CB.Y1.... jsr CLIP.Line.EncodeP2 bra .1 .6 bit #CLIP.Line.BOTTOM beq .7 * Y2 is below S.CB.Y2.... jsr CLIP.Line.EncodeP2 bra .1 .7 bit #CLIP.Line.RIGHT beq .8 * X2 is after S.CB.X2.... jsr CLIP.Line.EncodeP2 bra .1 * X2 is before S.CB.X1.... .8 jsr CLIP.Line.EncodeP2 bra .1 .88 clc rts .99 sec rts *-------------------------------------- CLIP.Line.EncodeP1 ldy #0 lda CB.Cache+S.CB.X1 ldx CB.Cache+S.CB.X1+1 jsr CLIP.Line.EncodeX.AX tay lda CB.Cache+S.CB.Y1 ldx CB.Cache+S.CB.Y1+1 jsr CLIP.Line.EncodeY.AX sta CLIP.Line.P1 rts *-------------------------------------- CLIP.Line.EncodeP2 ldy #0 lda CB.Cache+S.CB.X2 ldx CB.Cache+S.CB.X2+1 jsr CLIP.Line.EncodeX.AX tay lda CB.Cache+S.CB.Y2 ldx CB.Cache+S.CB.Y2+1 jsr CLIP.Line.EncodeY.AX sta CLIP.Line.P2 rts *-------------------------------------- CLIP.Line.EncodeX.AX pha >SCMPAX GC.Cache+S.GC.X1 bmi .1 tya ora #CLIP.Line.LEFT plx rts .1 pla >SCMPAX GC.Cache+S.GC.X1 bpl .8 tya ora #CLIP.Line.RIGHT .8 rts *-------------------------------------- CLIP.Line.EncodeY.AX pha >SCMPAX GC.Cache+S.GC.Y1 bmi .1 tya ora #CLIP.Line.TOP plx rts .1 pla >SCMPAX GC.Cache+S.GC.Y1 bpl .8 tya ora #CLIP.Line.BOTTOM .8 rts *-------------------------------------- MAN SAVE /A2OSX.SRC/LIB/LIBGUI.S.CLIP LOAD /A2OSX.SRC/LIB/LIBGUI.S ASM