head     56.3;
access   paws bayes jws quist brad dew jwh;
symbols  ;
locks    ; strict;
comment  @# @;


56.3
date     93.01.27.13.27.05;  author jwh;  state Exp;
branches ;
next     56.2;

56.2
date     93.01.27.12.05.22;  author jwh;  state Exp;
branches ;
next     56.1;

56.1
date     91.11.05.09.47.45;  author jwh;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.24.25;  author jwh;  state Exp;
branches ;
next     54.1;

54.1
date     91.03.18.15.27.47;  author jwh;  state Exp;
branches ;
next     53.1;

53.1
date     91.03.11.19.28.31;  author jwh;  state Exp;
branches ;
next     52.1;

52.1
date     91.02.19.09.12.30;  author jwh;  state Exp;
branches ;
next     51.1;

51.1
date     91.01.30.16.12.18;  author jwh;  state Exp;
branches ;
next     50.1;

50.1
date     90.10.29.16.26.56;  author jwh;  state Exp;
branches ;
next     49.1;

49.1
date     90.08.14.14.11.11;  author jwh;  state Exp;
branches ;
next     48.1;

48.1
date     90.07.26.11.17.24;  author jwh;  state Exp;
branches ;
next     47.1;

47.1
date     90.05.14.11.00.26;  author dew;  state Exp;
branches ;
next     46.1;

46.1
date     90.05.07.08.47.38;  author jwh;  state Exp;
branches ;
next     45.1;

45.1
date     90.04.19.15.55.34;  author jwh;  state Exp;
branches ;
next     44.1;

44.1
date     90.04.01.22.12.34;  author jwh;  state Exp;
branches ;
next     43.1;

43.1
date     90.03.20.14.04.33;  author jwh;  state Exp;
branches ;
next     42.1;

42.1
date     90.01.23.17.49.22;  author jwh;  state Exp;
branches ;
next     41.1;

41.1
date     89.12.22.11.31.19;  author jwh;  state Exp;
branches ;
next     40.1;

40.1
date     89.09.29.11.53.11;  author jwh;  state Exp;
branches ;
next     39.1;

39.1
date     89.09.26.16.37.24;  author dew;  state Exp;
branches ;
next     38.1;

38.1
date     89.08.29.11.29.29;  author jwh;  state Exp;
branches ;
next     37.1;

37.1
date     89.05.12.11.41.59;  author dew;  state Exp;
branches ;
next     36.1;

36.1
date     89.02.06.10.20.17;  author dew;  state Exp;
branches ;
next     35.1;

35.1
date     89.02.02.13.35.23;  author dew;  state Exp;
branches ;
next     34.1;

34.1
date     89.01.23.16.10.32;  author jwh;  state Exp;
branches ;
next     33.1;

33.1
date     89.01.16.11.42.17;  author dew;  state Exp;
branches ;
next     32.1;

32.1
date     89.01.10.11.51.05;  author bayes;  state Exp;
branches ;
next     31.1;

31.1
date     88.12.14.18.12.12;  author bayes;  state Exp;
branches ;
next     30.1;

30.1
date     88.12.09.13.49.02;  author dew;  state Exp;
branches ;
next     29.1;

29.1
date     88.10.31.15.34.04;  author bayes;  state Exp;
branches ;
next     28.1;

28.1
date     88.10.06.11.00.40;  author dew;  state Exp;
branches ;
next     27.1;

27.1
date     88.09.29.11.37.25;  author bayes;  state Exp;
branches ;
next     26.1;

26.1
date     88.09.28.13.16.17;  author bayes;  state Exp;
branches ;
next     25.2;

25.2
date     88.03.30.09.01.57;  author bayes;  state Exp;
branches ;
next     25.1;

25.1
date     88.03.02.09.32.45;  author bayes;  state Exp;
branches ;
next     24.1;

24.1
date     87.08.31.09.53.49;  author jws;  state Exp;
branches ;
next     23.1;

23.1
date     87.08.26.10.32.22;  author bayes;  state Exp;
branches ;
next     22.1;

22.1
date     87.08.17.11.18.01;  author bayes;  state Exp;
branches ;
next     21.1;

21.1
date     87.08.12.14.00.30;  author bayes;  state Exp;
branches ;
next     20.1;

20.1
date     87.07.30.11.13.28;  author bayes;  state Exp;
branches ;
next     19.1;

19.1
date     87.06.01.08.28.34;  author jws;  state Exp;
branches ;
next     18.1;

18.1
date     87.05.20.15.28.51;  author bayes;  state Exp;
branches ;
next     17.1;

17.1
date     87.04.30.10.39.24;  author jws;  state Exp;
branches ;
next     16.1;

16.1
date     87.04.26.15.51.11;  author jws;  state Exp;
branches ;
next     15.1;

15.1
date     87.04.13.09.27.04;  author jws;  state Exp;
branches ;
next     14.1;

14.1
date     87.04.01.15.32.44;  author jws;  state Exp;
branches ;
next     13.1;

13.1
date     87.02.28.18.36.10;  author jws;  state Exp;
branches ;
next     12.1;

12.1
date     87.02.02.13.27.07;  author jws;  state Exp;
branches ;
next     11.1;

11.1
date     87.01.19.09.53.46;  author jws;  state Exp;
branches ;
next     10.1;

10.1
date     86.12.24.11.02.43;  author jws;  state Exp;
branches ;
next     9.1;

9.1
date     86.12.12.14.45.03;  author bayes;  state Exp;
branches ;
next     8.1;

8.1
date     86.11.27.12.00.49;  author jws;  state Exp;
branches ;
next     7.1;

7.1
date     86.11.20.13.51.42;  author hal;  state Exp;
branches ;
next     6.1;

6.1
date     86.11.04.18.03.10;  author paws;  state Exp;
branches ;
next     5.1;

5.1
date     86.10.28.16.52.12;  author hal;  state Exp;
branches ;
next     4.1;

4.1
date     86.09.30.19.51.23;  author hal;  state Exp;
branches ;
next     3.1;

3.1
date     86.09.01.12.01.27;  author hal;  state Exp;
branches ;
next     2.1;

2.1
date     86.07.30.14.48.53;  author hal;  state Exp;
branches ;
next     1.1;

1.1
date     86.06.30.15.24.32;  author danm;  state tmp;
branches ;
next     ;


desc
@Base file for PWS 3.2 release.

@


56.3
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@*  Graphics Low End
*
*  Module    = Software clipping
*  Programer = BJS
*  Date      = 10-5-82
*
*  Purpose : To provide software clipping routines.
*
*  Rev history
*
*    Created    - 10- 5-82
*    Modified   - 11-23-82    Removed test for static links on proc calls
*
*
*     (c) Copyright Hewlett-Packard Company, 1985.
*     All rights are reserved.  Copying or other
*     reproduction of this program except for archival
*     purposes is prohibited without the prior
*     written consent of Hewlett-Packard Company.
*
*
*                RESTRICTED RIGHTS LEGEND
*
*     Use, duplication, or disclosure by the Government
*     is subject to restrictions as set forth in
*     paragraph (b) (3) (B) of the Rights in Technical
*     Data and Computer Software clause in
*     DAR 7-104.9(a).
*
*     HEWLETT-PACKARD COMPANY
*     Fort Collins, Colorado
*
*
      mname GLE_ASCLIP

	src module GLE_ASCLIP;
	src import GLE_TYPES;
	src export
	src procedure gle_soft_clip_move ( gcb : graphics_control_block_ptr );
	src procedure gle_soft_clip_draw ( gcb : graphics_control_block_ptr );
	src end;


      nosyms
*
*
*  Define entry points
*
      rorg 0

      def GLE_ASCLIP_GLE_SOFT_CLIP_MOVE
      def GLE_ASCLIP_GLE_SOFT_CLIP_DRAW
      def GLE_ASCLIP_CLIPPING
      def GLE_ASCLIP_GLE_ASCLIP
*
*    Set up globals
*
GCB equ a4

X0 equ d4
Y0 equ d5
X1 equ d6
Y1 equ d7
clip_xmin equ a0
clip_xmax equ a1
clip_ymin equ a2
clip_ymax equ a3

     INCLUDE ASM_TYPES

*
*****************************************************************************
*
GLE_ASCLIP_GLE_SOFT_CLIP_MOVE equ *

      link      a6,#0
      movea.l   8(a6),gcb                  { A4 }

      move.l    end_x(gcb),-(sp)           { save ending point, this will }
      move.l    end_y(gcb),-(sp)           { become the new cp            }

      bsr clip                             { returns clipped points in }
*                                          { (d4,d5) and (d6,d7), d0 is}
*                                          { the clipped state opcode  }

      cmp.w     #2,d0                      {ck for total clip}
      beq.s     move_complete

      move.l    d6,end_x(gcb)              { pass clipped point }
      move.l    d7,end_y(gcb)

      move.l    gcb,-(sp)                  { save copy of gcb on stack }
      move.l    gcb,-(sp)                  { call move routine }
      movea.l   unclipped_move(gcb),a0     { no static links }
      jsr       (a0)
      movea.l   (sp)+,gcb                  { get gcb back off stack }

move_complete equ *
      move.l    (sp)+,current_pos_y(gcb)   { set cp to saved end_x, end_y }
      move.l    (sp)+,current_pos_x(gcb)   { saved on stack.  Note that   }
*                                          { the CP is saved in an unclipped }
*                                          { form                            }

      unlk      a6
      move.l    (sp)+,(sp)
      rts

******************************************************************************

GLE_ASCLIP_GLE_SOFT_CLIP_DRAW equ *

      link      a6,#0

      movea.l   8(a6),gcb                  { A4 }
      move.l    end_x(gcb),-(sp)           { save ending point, this will }
      move.l    end_y(gcb),-(sp)           { become the new cp            }

      bsr clip                             { returns clipped points in }
*                                          { (d4,d5) and (d6,d7), d0 is}
*                                          { the clipped state opcode  }

      tst.w      d0                        { ck for no clipping needed }
      beq.s     draw_it

      cmp.w     #2,d0                   {ck for line outside clipping bounds}
      beq.s     draw_complete

      cmp.l     current_pos_x(gcb),d4      { ck to see if cp changed after }
      bne.s     move_first                 { clipping                      }
      cmp.l     current_pos_y(gcb),d5
      beq.s     draw_it

move_first equ *
      move.l    d6,-(sp)                   { save end point on stack }
      move.l    d7,-(sp)

      move.l    d4,end_x(gcb)              { pass clipped point }
      move.l    d5,end_y(gcb)

      move.l    gcb,-(sp)                  { save a copy of gcb pointer }
      move.l    gcb,-(sp)                  { call move routine }
      movea.l   unclipped_move(gcb),a0     { no static links }
      jsr       (a0)
      movea.l   (sp)+,gcb                  { get gcb pointer back }

      move.l    (sp)+,d7                   { pass clipped point }
      move.l    (sp)+,d6

draw_it equ *

      move.l    d6,end_x(gcb)
      move.l    d7,end_y(gcb)

      move.l    gcb,-(sp)                  { save copy of gcb on stack }
      move.l    gcb,-(sp)
      movea.l   unclipped_draw(gcb),a0     { no static links }
      jsr       (a0)
      movea.l   (sp)+,gcb                  { get gcb back }

draw_complete equ *

      move.l    (sp)+,current_pos_y(gcb)   { set cp to saved end_x, end_y }
      move.l    (sp)+,current_pos_x(gcb)   { saved on stack.  Note that   }
*                                          { the CP is saved in an unclipped }
*                                          { form                            }

      unlk      a6
      move.l    (sp)+,(sp)
      rts
****************************************************************************
*
*
*  ASM clipping entry point is GLE_ASCLIP_CLIPPING
*
*  Regs = a0 - clip_xmin    d4 - x0
*         a1 - clip_ymin    d5 - y0
*         a2 - clip_xmax    d6 - x1
*         a3 - clip_ymax    d7 - y1
*
*         a4 - GLE_GCB
*
****************************************************************************
*
*       clip
*
*       d4=x0   a0=clip_xmin
*       d5=y0   a1=clip_ymin
*       d6=x1   a2=clip_xmax
*       d7=y1   a3=clip_ymax
*
*       Returns clipped points (x0,y0) and (x1,y1)
*       Returns opcode in d0 : 0 - not clipped
*                              1 - clipped but some part visible
*                              2 - all clipped
*
clip    equ *

	movem.l current_pos_x(gcb),d4-d7  { get x0,y0 x1,y1 }
	movem.l clip_limits_xmin(gcb),a0-a3

	cmp.l   clip_xmin,x0          fast check to find in bounds line
	blt.s   clip_it
	cmp.l   clip_xmax,x0
	bgt.s   clip_it
	cmp.l   clip_ymin,y0
	blt.s   clip_it
	cmp.l   clip_ymax,y0
	bgt.s   clip_it

	cmp.l   clip_xmin,x1
	blt.s   clip_it
	cmp.l   clip_xmax,x1
	bgt.s   clip_it
	cmp.l   clip_ymin,y1
	blt.s   clip_it
	cmp.l   clip_ymax,y1
	bgt.s   clip_it

clipallin  equ *
	moveq #0,d0               no clipping performed, set return opcode
	rts

GLE_ASCLIP_CLIPPING equ *
clip_it move.l  a5,-(sp)          {save global base, and free up a5}
	clr.w   soft_clip_switch(gcb)
	cmp.l   y1,y0             check for horizontal lines
	beq     clip_horizontal

	blt.s   clip1             force y0 < y1
	exg     x0,x1
	exg     y0,y1
	bchg    #0,soft_clip_switch(gcb)

clip1   cmp.l   clip_ymax,y0      ck for both y above
	bgt     clip_out
	cmp.l   clip_ymin,y1      ck for both y below
	blt     clip_out

	cmp.l   x1,x0             check for vertical lines
	beq     clip_vertical

	blt.s   clip2             now force x0 < x1
	exg     x0,x1
	exg     y0,y1
	bchg    #0,soft_clip_switch(gcb)

clip2   cmp.l   clip_xmax,x0      ck for both x left
	bgt     clip_out
	cmp.l   clip_xmin,x1      ck for both x right
	blt     clip_out

*
* At this point, a diagonal line exists with one or two ends
* outside the current clipping limits.  This line is reduced by replacing
* its end points with window intersections.  Intersections are found
* by using the midpoint clipping procedure (Newman&Sproull)
*
solv_x1 move.l  x0,soft_clip_savex0(gcb)  save original points
	move.l  y0,soft_clip_savey0(gcb)
	move.l  x1,soft_clip_savex1(gcb)
	move.l  y1,soft_clip_savey1(gcb)

	cmp.l   clip_xmin,x0      is x0 inside?
	bge.s   solv_xr

solv_xl movea.l  clip_xmin,a5      solve for y at (x = xmin)
	move.l  x0,d0             pass parms to solve
	move.l  y0,d1             (note: x0 = d4, y0 = d5)
	move.l  y0,d3   (lefty)
	move.l  x0,d2   (leftx)
	move.l  y1,d5   (righty)
	move.l  x1,d4   (rightx)
	bsr     solve
	move.l  d0,x0
	move.l  d1,y0

	move.l  x0,soft_clip_savex0(gcb)
	move.l  y0,soft_clip_savey0(gcb)


solv_xr cmp.l   clip_xmax,x1      is x1 inside?
	ble.s   intsct3

	movea.l  clip_xmax,a5         solve for y at (x = xmax)
	move.l  x1,d0                pass parms to solve
	move.l  y1,d1                (note: x0 = d4, y0 = d5)
	move.l  x0,x1                free up d4, d5 (x1, an y1 are now free)
	move.l  y0,y1
	move.l  soft_clip_savey1(gcb),d5
	move.l  soft_clip_savex1(gcb),d4
	move.l  soft_clip_savey0(gcb),d3
	move.l  soft_clip_savex0(gcb),d2
	bsr     solve
	move.l  x1,x0                restore x0,y0
	move.l  y1,y0
	move.l  d0,x1
	move.l  d1,y1

	move.l x1,soft_clip_savex1(gcb)
	move.l y1,soft_clip_savey1(gcb)


intsct3 cmp.l   y1,y0             force y2 > y1
	blt.s   intsct4

	exg     x0,x1
	exg     y0,y1
	move.l  soft_clip_savex0(gcb),d0             swap saved copies as well
	move.l  soft_clip_savex1(gcb),soft_clip_savex0(gcb)
	move.l  d0,soft_clip_savex1(gcb)
	move.l  soft_clip_savey0(gcb),d0
	move.l  soft_clip_savey1(gcb),soft_clip_savey0(gcb)
	move.l  d0,soft_clip_savey1(gcb)
	bchg    #0,soft_clip_switch(gcb)

intsct4 cmp.l   clip_ymax,y0
	bgt     clip_out
	cmp.l   clip_ymin,y1
	blt     clip_out

solv_yu cmp.l   clip_ymin,y0
	bge.s   solv_yd

	movea.l  clip_ymin,a5          solve for x at (y = ymin)
	move.l  soft_clip_savex0(gcb),d3      Pass parms to solve
	move.l  soft_clip_savey0(gcb),d2
	move.l  soft_clip_savey0(gcb),d0
	move.l  soft_clip_savex0(gcb),d1
	move.l  soft_clip_savex1(gcb),d5
	move.l  soft_clip_savey1(gcb),d4
	bsr     solve
	move.l  d0,y0
	move.l  d1,x0

	move.l  y0,soft_clip_savey0(gcb)
	move.l  x0,soft_clip_savex0(gcb)

solv_yd cmp.l   clip_ymax,y1
	ble     clip_in

	movea.l clip_ymax,a5          solve for x at (y = ymin)
	move.l  x0,x1                 (save x0,y0 in x1,y1 which is free)
	move.l  y0,y1
	move.l  soft_clip_savex1(gcb),d5
	move.l  soft_clip_savey1(gcb),d4
	move.l  soft_clip_savex0(gcb),d3
	move.l  soft_clip_savey0(gcb),d2
	move.l  soft_clip_savey1(gcb),d0
	move.l  soft_clip_savex1(gcb),d1
	bsr     solve
	move.l  x1,x0                 restore x0,y0
	move.l  y1,y0
	move.l  d0,y1
	move.l  d1,x1

clip_in equ *
	btst    #0,soft_clip_switch(gcb)
	beq.s   clipin
	exg     x0,x1             restore org direction
	exg     y0,y1
clipin  equ *
	moveq   #1,d0               clipping one or more points
	movea.l (sp)+,a5                   {restore global base}
	rts

clip_all_in equ *
	movea.l (sp)+,a5                   {restore global base}
	btst    #0,soft_clip_switch(gcb)
	beq     clipallin
	exg     x0,x1             restore org direction
	exg     y0,y1
	bra     clipallin

clip_out equ *
	moveq   #2,d0               all clipped, set up return opcode
	movea.l (sp)+,a5                   {restore global base}
	rts

clip_horizontal equ *
	cmp.l   clip_ymax,y1      ck for y out of clip limits
	bgt     clip_out
	cmp.l   clip_ymin,y1
	blt     clip_out

	cmp.l   x1,x0
	beq     clip_dot
	blt.s   clip_h1
	exg     x0,x1
	bchg    #0,soft_clip_switch(gcb)
clip_h1 cmp.l   clip_xmax,x0      x0 < x1
	bgt     clip_out
	cmp.l   clip_xmin,x1
	blt     clip_out
	cmp.l   clip_xmax,x1
	ble.s   clip_h2
	move.l  clip_xmax,x1
clip_h2 cmp.l   clip_xmin,x0
	bge.s   clip_in
	move.l  clip_xmin,x0
	bra.s   clip_in

clip_vertical equ *

	cmp.l   clip_xmax,x1
	bgt     clip_out
	cmp.l   clip_xmin,x1
	blt     clip_out
	cmp.l   clip_ymax,y1          assumes y0 < y1
	ble.s   clip_v1
	move.l  clip_ymax,y1
clip_v1 cmp.l   clip_ymin,y0
	bge     clip_in
	move.l  clip_ymin,y0
	bra     clip_in

clip_dot      equ *
	cmp.l   clip_xmax,x0
	bgt     clip_out
	cmp.l   clip_xmin,x0
	blt     clip_out
	bra     clip_in

* routine to find intersections.  D0 will be driven to the value supplied
* as val_x.  D1 will contain the corresponding value.  "left" and "right"
* contain the original starting points.  "X" and "Y" are only reletive
* to the current use of this routine, not the physical bounds of the
* display
*
solve   equ *

val_x   equ a5
right_y equ d5
right_x equ d4
left_y  equ d3
left_x  equ d2

solve_s cmp.l   val_x,d0
	beq.s   solve_e
	blt.s   solve_l

solve_r move.l  d0,right_x
	move.l  d1,right_y
	add.l   left_x,d0
	bvs.s   force_exit        check for overflow
	add.l   left_y,d1
	bvs.s   force_exit        check for overflow
	bra.s   round

solve_l move.l  d0,left_x
	move.l  d1,left_y
	add.l   right_x,d0
	bvs.s   force_exit        check for overflow
	addq.l  #1,d0
	bvs.s   force_exit        check for overflow
	add.l   right_y,d1
	bvs.s   force_exit        check for overflow
	addq.l  #1,d1
	bvs.s   force_exit        check for overflow

round   asr.l   #1,d0
	asr.l   #1,d1
	bra.s   solve_s

force_exit trapv                  let system process

solve_e rts

gle_asclip_gle_asclip  rts

@


56.2
log
@
pws2rcs automatic delta on Wed Jan 27 11:57:27 MST 1993
@
text
@d1 469
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 469
*  Graphics Low End
*
*  Module    = Software clipping
*  Programer = BJS
*  Date      = 10-5-82
*
*  Purpose : To provide software clipping routines.
*
*  Rev history
*
*    Created    - 10- 5-82
*    Modified   - 11-23-82    Removed test for static links on proc calls
*
*
*     (c) Copyright Hewlett-Packard Company, 1985.
*     All rights are reserved.  Copying or other
*     reproduction of this program except for archival
*     purposes is prohibited without the prior
*     written consent of Hewlett-Packard Company.
*
*
*                RESTRICTED RIGHTS LEGEND
*
*     Use, duplication, or disclosure by the Government
*     is subject to restrictions as set forth in
*     paragraph (b) (3) (B) of the Rights in Technical
*     Data and Computer Software clause in
*     DAR 7-104.9(a).
*
*     HEWLETT-PACKARD COMPANY
*     Fort Collins, Colorado
*
*
      mname GLE_ASCLIP

	src module GLE_ASCLIP;
	src import GLE_TYPES;
	src export
	src procedure gle_soft_clip_move ( gcb : graphics_control_block_ptr );
	src procedure gle_soft_clip_draw ( gcb : graphics_control_block_ptr );
	src end;


      nosyms
*
*
*  Define entry points
*
      rorg 0

      def GLE_ASCLIP_GLE_SOFT_CLIP_MOVE
      def GLE_ASCLIP_GLE_SOFT_CLIP_DRAW
      def GLE_ASCLIP_CLIPPING
      def GLE_ASCLIP_GLE_ASCLIP
*
*    Set up globals
*
GCB equ a4

X0 equ d4
Y0 equ d5
X1 equ d6
Y1 equ d7
clip_xmin equ a0
clip_xmax equ a1
clip_ymin equ a2
clip_ymax equ a3

     INCLUDE ASM_TYPES

*
*****************************************************************************
*
GLE_ASCLIP_GLE_SOFT_CLIP_MOVE equ *

      link      a6,#0
      movea.l   8(a6),gcb                  { A4 }

      move.l    end_x(gcb),-(sp)           { save ending point, this will }
      move.l    end_y(gcb),-(sp)           { become the new cp            }

      bsr clip                             { returns clipped points in }
*                                          { (d4,d5) and (d6,d7), d0 is}
*                                          { the clipped state opcode  }

      cmp.w     #2,d0                      {ck for total clip}
      beq.s     move_complete

      move.l    d6,end_x(gcb)              { pass clipped point }
      move.l    d7,end_y(gcb)

      move.l    gcb,-(sp)                  { save copy of gcb on stack }
      move.l    gcb,-(sp)                  { call move routine }
      movea.l   unclipped_move(gcb),a0     { no static links }
      jsr       (a0)
      movea.l   (sp)+,gcb                  { get gcb back off stack }

move_complete equ *
      move.l    (sp)+,current_pos_y(gcb)   { set cp to saved end_x, end_y }
      move.l    (sp)+,current_pos_x(gcb)   { saved on stack.  Note that   }
*                                          { the CP is saved in an unclipped }
*                                          { form                            }

      unlk      a6
      move.l    (sp)+,(sp)
      rts

******************************************************************************

GLE_ASCLIP_GLE_SOFT_CLIP_DRAW equ *

      link      a6,#0

      movea.l   8(a6),gcb                  { A4 }
      move.l    end_x(gcb),-(sp)           { save ending point, this will }
      move.l    end_y(gcb),-(sp)           { become the new cp            }

      bsr clip                             { returns clipped points in }
*                                          { (d4,d5) and (d6,d7), d0 is}
*                                          { the clipped state opcode  }

      tst.w      d0                        { ck for no clipping needed }
      beq.s     draw_it

      cmp.w     #2,d0                   {ck for line outside clipping bounds}
      beq.s     draw_complete

      cmp.l     current_pos_x(gcb),d4      { ck to see if cp changed after }
      bne.s     move_first                 { clipping                      }
      cmp.l     current_pos_y(gcb),d5
      beq.s     draw_it

move_first equ *
      move.l    d6,-(sp)                   { save end point on stack }
      move.l    d7,-(sp)

      move.l    d4,end_x(gcb)              { pass clipped point }
      move.l    d5,end_y(gcb)

      move.l    gcb,-(sp)                  { save a copy of gcb pointer }
      move.l    gcb,-(sp)                  { call move routine }
      movea.l   unclipped_move(gcb),a0     { no static links }
      jsr       (a0)
      movea.l   (sp)+,gcb                  { get gcb pointer back }

      move.l    (sp)+,d7                   { pass clipped point }
      move.l    (sp)+,d6

draw_it equ *

      move.l    d6,end_x(gcb)
      move.l    d7,end_y(gcb)

      move.l    gcb,-(sp)                  { save copy of gcb on stack }
      move.l    gcb,-(sp)
      movea.l   unclipped_draw(gcb),a0     { no static links }
      jsr       (a0)
      movea.l   (sp)+,gcb                  { get gcb back }

draw_complete equ *

      move.l    (sp)+,current_pos_y(gcb)   { set cp to saved end_x, end_y }
      move.l    (sp)+,current_pos_x(gcb)   { saved on stack.  Note that   }
*                                          { the CP is saved in an unclipped }
*                                          { form                            }

      unlk      a6
      move.l    (sp)+,(sp)
      rts
****************************************************************************
*
*
*  ASM clipping entry point is GLE_ASCLIP_CLIPPING
*
*  Regs = a0 - clip_xmin    d4 - x0
*         a1 - clip_ymin    d5 - y0
*         a2 - clip_xmax    d6 - x1
*         a3 - clip_ymax    d7 - y1
*
*         a4 - GLE_GCB
*
****************************************************************************
*
*       clip
*
*       d4=x0   a0=clip_xmin
*       d5=y0   a1=clip_ymin
*       d6=x1   a2=clip_xmax
*       d7=y1   a3=clip_ymax
*
*       Returns clipped points (x0,y0) and (x1,y1)
*       Returns opcode in d0 : 0 - not clipped
*                              1 - clipped but some part visible
*                              2 - all clipped
*
clip    equ *

	movem.l current_pos_x(gcb),d4-d7  { get x0,y0 x1,y1 }
	movem.l clip_limits_xmin(gcb),a0-a3

	cmp.l   clip_xmin,x0          fast check to find in bounds line
	blt.s   clip_it
	cmp.l   clip_xmax,x0
	bgt.s   clip_it
	cmp.l   clip_ymin,y0
	blt.s   clip_it
	cmp.l   clip_ymax,y0
	bgt.s   clip_it

	cmp.l   clip_xmin,x1
	blt.s   clip_it
	cmp.l   clip_xmax,x1
	bgt.s   clip_it
	cmp.l   clip_ymin,y1
	blt.s   clip_it
	cmp.l   clip_ymax,y1
	bgt.s   clip_it

clipallin  equ *
	moveq #0,d0               no clipping performed, set return opcode
	rts

GLE_ASCLIP_CLIPPING equ *
clip_it move.l  a5,-(sp)          {save global base, and free up a5}
	clr.w   soft_clip_switch(gcb)
	cmp.l   y1,y0             check for horizontal lines
	beq     clip_horizontal

	blt.s   clip1             force y0 < y1
	exg     x0,x1
	exg     y0,y1
	bchg    #0,soft_clip_switch(gcb)

clip1   cmp.l   clip_ymax,y0      ck for both y above
	bgt     clip_out
	cmp.l   clip_ymin,y1      ck for both y below
	blt     clip_out

	cmp.l   x1,x0             check for vertical lines
	beq     clip_vertical

	blt.s   clip2             now force x0 < x1
	exg     x0,x1
	exg     y0,y1
	bchg    #0,soft_clip_switch(gcb)

clip2   cmp.l   clip_xmax,x0      ck for both x left
	bgt     clip_out
	cmp.l   clip_xmin,x1      ck for both x right
	blt     clip_out

*
* At this point, a diagonal line exists with one or two ends
* outside the current clipping limits.  This line is reduced by replacing
* its end points with window intersections.  Intersections are found
* by using the midpoint clipping procedure (Newman&Sproull)
*
solv_x1 move.l  x0,soft_clip_savex0(gcb)  save original points
	move.l  y0,soft_clip_savey0(gcb)
	move.l  x1,soft_clip_savex1(gcb)
	move.l  y1,soft_clip_savey1(gcb)

	cmp.l   clip_xmin,x0      is x0 inside?
	bge.s   solv_xr

solv_xl movea.l  clip_xmin,a5      solve for y at (x = xmin)
	move.l  x0,d0             pass parms to solve
	move.l  y0,d1             (note: x0 = d4, y0 = d5)
	move.l  y0,d3   (lefty)
	move.l  x0,d2   (leftx)
	move.l  y1,d5   (righty)
	move.l  x1,d4   (rightx)
	bsr     solve
	move.l  d0,x0
	move.l  d1,y0

	move.l  x0,soft_clip_savex0(gcb)
	move.l  y0,soft_clip_savey0(gcb)


solv_xr cmp.l   clip_xmax,x1      is x1 inside?
	ble.s   intsct3

	movea.l  clip_xmax,a5         solve for y at (x = xmax)
	move.l  x1,d0                pass parms to solve
	move.l  y1,d1                (note: x0 = d4, y0 = d5)
	move.l  x0,x1                free up d4, d5 (x1, an y1 are now free)
	move.l  y0,y1
	move.l  soft_clip_savey1(gcb),d5
	move.l  soft_clip_savex1(gcb),d4
	move.l  soft_clip_savey0(gcb),d3
	move.l  soft_clip_savex0(gcb),d2
	bsr     solve
	move.l  x1,x0                restore x0,y0
	move.l  y1,y0
	move.l  d0,x1
	move.l  d1,y1

	move.l x1,soft_clip_savex1(gcb)
	move.l y1,soft_clip_savey1(gcb)


intsct3 cmp.l   y1,y0             force y2 > y1
	blt.s   intsct4

	exg     x0,x1
	exg     y0,y1
	move.l  soft_clip_savex0(gcb),d0             swap saved copies as well
	move.l  soft_clip_savex1(gcb),soft_clip_savex0(gcb)
	move.l  d0,soft_clip_savex1(gcb)
	move.l  soft_clip_savey0(gcb),d0
	move.l  soft_clip_savey1(gcb),soft_clip_savey0(gcb)
	move.l  d0,soft_clip_savey1(gcb)
	bchg    #0,soft_clip_switch(gcb)

intsct4 cmp.l   clip_ymax,y0
	bgt     clip_out
	cmp.l   clip_ymin,y1
	blt     clip_out

solv_yu cmp.l   clip_ymin,y0
	bge.s   solv_yd

	movea.l  clip_ymin,a5          solve for x at (y = ymin)
	move.l  soft_clip_savex0(gcb),d3      Pass parms to solve
	move.l  soft_clip_savey0(gcb),d2
	move.l  soft_clip_savey0(gcb),d0
	move.l  soft_clip_savex0(gcb),d1
	move.l  soft_clip_savex1(gcb),d5
	move.l  soft_clip_savey1(gcb),d4
	bsr     solve
	move.l  d0,y0
	move.l  d1,x0

	move.l  y0,soft_clip_savey0(gcb)
	move.l  x0,soft_clip_savex0(gcb)

solv_yd cmp.l   clip_ymax,y1
	ble     clip_in

	movea.l clip_ymax,a5          solve for x at (y = ymin)
	move.l  x0,x1                 (save x0,y0 in x1,y1 which is free)
	move.l  y0,y1
	move.l  soft_clip_savex1(gcb),d5
	move.l  soft_clip_savey1(gcb),d4
	move.l  soft_clip_savex0(gcb),d3
	move.l  soft_clip_savey0(gcb),d2
	move.l  soft_clip_savey1(gcb),d0
	move.l  soft_clip_savex1(gcb),d1
	bsr     solve
	move.l  x1,x0                 restore x0,y0
	move.l  y1,y0
	move.l  d0,y1
	move.l  d1,x1

clip_in equ *
	btst    #0,soft_clip_switch(gcb)
	beq.s   clipin
	exg     x0,x1             restore org direction
	exg     y0,y1
clipin  equ *
	moveq   #1,d0               clipping one or more points
	movea.l (sp)+,a5                   {restore global base}
	rts

clip_all_in equ *
	movea.l (sp)+,a5                   {restore global base}
	btst    #0,soft_clip_switch(gcb)
	beq     clipallin
	exg     x0,x1             restore org direction
	exg     y0,y1
	bra     clipallin

clip_out equ *
	moveq   #2,d0               all clipped, set up return opcode
	movea.l (sp)+,a5                   {restore global base}
	rts

clip_horizontal equ *
	cmp.l   clip_ymax,y1      ck for y out of clip limits
	bgt     clip_out
	cmp.l   clip_ymin,y1
	blt     clip_out

	cmp.l   x1,x0
	beq     clip_dot
	blt.s   clip_h1
	exg     x0,x1
	bchg    #0,soft_clip_switch(gcb)
clip_h1 cmp.l   clip_xmax,x0      x0 < x1
	bgt     clip_out
	cmp.l   clip_xmin,x1
	blt     clip_out
	cmp.l   clip_xmax,x1
	ble.s   clip_h2
	move.l  clip_xmax,x1
clip_h2 cmp.l   clip_xmin,x0
	bge.s   clip_in
	move.l  clip_xmin,x0
	bra.s   clip_in

clip_vertical equ *

	cmp.l   clip_xmax,x1
	bgt     clip_out
	cmp.l   clip_xmin,x1
	blt     clip_out
	cmp.l   clip_ymax,y1          assumes y0 < y1
	ble.s   clip_v1
	move.l  clip_ymax,y1
clip_v1 cmp.l   clip_ymin,y0
	bge     clip_in
	move.l  clip_ymin,y0
	bra     clip_in

clip_dot      equ *
	cmp.l   clip_xmax,x0
	bgt     clip_out
	cmp.l   clip_xmin,x0
	blt     clip_out
	bra     clip_in

* routine to find intersections.  D0 will be driven to the value supplied
* as val_x.  D1 will contain the corresponding value.  "left" and "right"
* contain the original starting points.  "X" and "Y" are only reletive
* to the current use of this routine, not the physical bounds of the
* display
*
solve   equ *

val_x   equ a5
right_y equ d5
right_x equ d4
left_y  equ d3
left_x  equ d2

solve_s cmp.l   val_x,d0
	beq.s   solve_e
	blt.s   solve_l

solve_r move.l  d0,right_x
	move.l  d1,right_y
	add.l   left_x,d0
	bvs.s   force_exit        check for overflow
	add.l   left_y,d1
	bvs.s   force_exit        check for overflow
	bra.s   round

solve_l move.l  d0,left_x
	move.l  d1,left_y
	add.l   right_x,d0
	bvs.s   force_exit        check for overflow
	addq.l  #1,d0
	bvs.s   force_exit        check for overflow
	add.l   right_y,d1
	bvs.s   force_exit        check for overflow
	addq.l  #1,d1
	bvs.s   force_exit        check for overflow

round   asr.l   #1,d0
	asr.l   #1,d1
	bra.s   solve_s

force_exit trapv                  let system process

solve_e rts

gle_asclip_gle_asclip  rts

@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@@


53.1
log
@Automatic bump of revision number for PWS version 3.24B
@
text
@@


52.1
log
@Automatic bump of revision number for PWS version 3.24A
@
text
@@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@@


50.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


49.1
log
@Automatic bump of revision number for PWS version 3.24b
@
text
@@


48.1
log
@Automatic bump of revision number for PWS version 3.24a
@
text
@@


47.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


46.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


45.1
log
@Automatic bump of revision number for PWS version 3.23C
@
text
@@


44.1
log
@Automatic bump of revision number for PWS version 3.23B
@
text
@@


43.1
log
@Automatic bump of revision number for PWS version 3.23aA
@
text
@@


42.1
log
@Automatic bump of revision number for PWS version 3.23e
@
text
@@


41.1
log
@Automatic bump of revision number for PWS version 3.23d
@
text
@@


40.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


39.1
log
@Automatic bump of revision number for PWS version 3.23b
@
text
@@


38.1
log
@Automatic bump of revision number for PWS version 3.23a
@
text
@@


37.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


36.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


35.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


34.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


33.1
log
@Automatic bump of revision number for PWS version 3.22D
@
text
@@


32.1
log
@Automatic bump of revision number for PWS version 3.22C
@
text
@@


31.1
log
@Automatic bump of revision number for PWS version 3.22B
@
text
@@


30.1
log
@Automatic bump of revision number for PWS version 3.22A
@
text
@@


29.1
log
@Automatic bump of revision number for PWS version 3.22b
@
text
@@


28.1
log
@Automatic bump of revision number for PWS version 3.3b
@
text
@@


27.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


26.1
log
@Automatic bump of revision number for PWS version 3.3 Synch
@
text
@@


25.2
log
@For CATSEYE support
@
text
@@


25.1
log
@Automatic bump of revision number for PWS version 3.2Y
@
text
@@


24.1
log
@Automatic bump of revision number for PWS version 3.2
@
text
@@


23.1
log
@Automatic bump of revision number for PWS version 3.2P
@
text
@@


22.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@@


21.1
log
@Automatic bump of revision number for PWS version 3.2M
@
text
@@


20.1
log
@Automatic bump of revision number for PWS version 3.2L
@
text
@@


19.1
log
@Automatic bump of revision number for PWS version 3.2K
@
text
@@


18.1
log
@Automatic bump of revision number for PWS version 3.2J
@
text
@@


17.1
log
@Automatic bump of revision number for PWS version 3.2I+
@
text
@@


16.1
log
@Automatic bump of revision number for PWS version 3.2I
@
text
@@


15.1
log
@Automatic bump of revision number for PWS version 3.2H
@
text
@@


14.1
log
@Automatic bump of revision number for PWS version 3.2G
@
text
@@


13.1
log
@Automatic bump of revision number for PWS version 3.2F
@
text
@@


12.1
log
@Automatic bump of revision number for PWS version 3.2E
@
text
@@


11.1
log
@Automatic bump of revision number for PWS version 3.2D
@
text
@@


10.1
log
@Automatic bump of revision number for PWS version 3.2C
@
text
@@


9.1
log
@Automatic bump of revision number for PWS version 3.2B
@
text
@@


8.1
log
@Automatic bump of revision number for PWS version 3.2A
@
text
@@


7.1
log
@Automatic bump of revision number for PWS version 3.2l
@
text
@@


6.1
log
@Automatic bump of revision number for PWS version 3.2k
@
text
@@


5.1
log
@Automatic bump of revision number for PWS version 3.2j
@
text
@@


4.1
log
@Automatic bump of revision number for PWS version 3.2i
@
text
@@


3.1
log
@Automatic bump of revision number for PWS version 3.2h
@
text
@@


2.1
log
@Auto bump rev number to 2.1 for sys 3.2e.
@
text
@@


1.1
log
@Initial revision
@
text
@@
