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


56.4
date     93.01.27.13.30.26;  author jwh;  state Exp;
branches ;
next     56.3;

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

56.2
date     91.12.03.12.18.20;  author cfb;  state Exp;
branches ;
next     56.1;

56.1
date     91.11.05.09.52.00;  author jwh;  state Exp;
branches ;
next     55.5;

55.5
date     91.11.04.15.23.29;  author jwh;  state Exp;
branches ;
next     55.4;

55.4
date     91.10.16.13.53.22;  author cfb;  state Exp;
branches ;
next     55.3;

55.3
date     91.10.11.11.22.26;  author cfb;  state Exp;
branches ;
next     55.2;

55.2
date     91.10.10.09.00.21;  author cfb;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.27.26;  author jwh;  state Exp;
branches ;
next     54.7;

54.7
date     91.08.21.13.22.45;  author jwh;  state Exp;
branches ;
next     54.6;

54.6
date     91.07.24.10.49.47;  author cfb;  state Exp;
branches ;
next     54.5;

54.5
date     91.07.24.10.47.03;  author cfb;  state Exp;
branches ;
next     54.4;

54.4
date     91.07.23.10.26.54;  author cfb;  state Exp;
branches ;
next     54.3;

54.3
date     91.07.11.08.58.03;  author cfb;  state Exp;
branches ;
next     54.2;

54.2
date     91.07.09.09.47.12;  author cfb;  state Exp;
branches ;
next     54.1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

6.1
date     86.11.04.18.15.55;  author paws;  state Exp;
branches ;
next     5.2;

5.2
date     86.10.29.14.55.39;  author geli;  state Exp;
branches ;
next     5.1;

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

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

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

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

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


desc
@Base file for PWS 3.2 release.

@


56.4
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@*
*  Graphics Low End
*
*  Module    = Gle_aras_out
*  Programer = DAC, BJS
*  Date      = 9-30-82
*
*  Purpose : To provide low-level raster routines.
*
*  Rev history
*
*    Created    - 9-30-82
*    Modified   - 6-28-83  BJS  Changed module name to not conflict with
*                               the pascal name
*               -12-07-83  BDS  Added fixes for cursor bug
*               -01-30-84  BJS  Speedup fix for set_color, set_line_style
*               -02-17-84  BDS  Added support for gator for Pascal 3.0
*               -05-01-85  SFB  Added support for bobcat/gatorbox
*               -05-29-91  CFB  Added support for WOODCUT
*
*     (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
*
* Change error routine err_esc for every OS transport
*
       nosyms
       mname gle_aras_out

       src module GLE_ARAS_OUT;
       src import GLE_TYPES;
       src export
       src procedure  rgcbinit ( GCB : graphics_control_block_ptr );
       src procedure  rgraphics_on_off ( GCB : graphics_control_block_ptr );
       src procedure  rclear ( GCB : graphics_control_block_ptr );
       src procedure  rmove ( GCB : graphics_control_block_ptr );
       src procedure  rdraw  ( GCB : graphics_control_block_ptr );
       src procedure  rdefine_drawing_mode ( GCB : graphics_control_block_ptr);
       src procedure  rlinestyle ( GCB : graphics_control_block_ptr);
       src procedure  rcursor ( GCB : graphics_control_block_ptr);
       src procedure  rset_color ( GCB : graphics_control_block_ptr);
       src procedure  rpolygon ( GCB : graphics_control_block_ptr );
       src procedure  rget_p1p2 ( GCB : graphics_control_block_ptr );
       src procedure  rget_raster ( GCB : graphics_control_block_ptr );
       src procedure  rfill_index_color ( GCB : graphics_control_block_ptr );
       src procedure  rawait_blanking ( GCB : graphics_control_block_ptr );
       src procedure  store_dit ( GCB : graphics_control_block_ptr );
       src procedure  set_6845s ( GCB : graphics_control_block_ptr );
       src procedure  setgboxcmap( GCB : graphics_control_block_ptr);
       src procedure  set_nereid( GCB : graphics_control_block_ptr);
       src procedure  set_wood_cmap( GCB : graphics_control_block_ptr);
       src procedure  dither_to_pattregs( GCB : graphics_control_block_ptr);
       src end;

       rorg 0

       refa sysglobals
       refa sysdevs
       refa gle_asclip_clipping
       refa gle_types
       refa delay_timer
       refa asm_flush_icache            {3/25/85 SFB}

       lmode sysglobals
       lmode sysdevs
       lmode gle_asclip_clipping
       lmode gle_types
       lmode delay_timer
       lmode asm_flush_icache           {3/25/85 SFB}

       def  gle_aras_out_rgcbinit
       def  gle_aras_out_rgraphics_on_off
       def  gle_aras_out_rclear
       def  gle_aras_out_rmove
       def  gle_aras_out_rdraw
       def  gle_aras_out_rdefine_drawing_mode
       def  gle_aras_out_rset_color
       def  gle_aras_out_rlinestyle
       def  gle_aras_out_rpolygon
       def  gle_aras_out_rget_raster
       def  gle_aras_out_rcursor
       def  gle_aras_out_rfill_index_color
       def  gle_aras_out_rget_p1p2
       def  gle_aras_out_rawait_blanking
       def  gle_aras_out_store_dit
       def  gle_aras_out_set_6845s
       def  gle_aras_out_setgboxcmap
       def  gle_aras_out_set_nereid
       def  gle_aras_out_set_wood_cmap                               CFB 12JUN91
       def  gle_aras_out_dither_to_pattregs     SFB 3/8/88

       def  gle_aras_out_gle_aras_out

       def  fgator                             for debug only
       def  hv50                                "
       def  hv52                                "
       DEF  FBOBCAT                             "
       DEF  VEC6
       DEF  BUILD_PEN
       DEF  SET_PEN

*
*      def  gdump_exp
*      def  gload_proc
*      def  gstore_proc
*

ADDR1            equ 0
ADDR2            equ 4
ADDR3            equ 8
AREA_DRAW_MODE   equ 74
BLU_INTENSITY    equ 52
BYTESPERLINE     equ 42
CMAP_ADDRESS     equ 1890
CPEN             equ 82
CURSOR_X         equ 70
CURSOR_Y         equ 72
DEVICEADDRESS    equ 16
DEVICETYPE       equ 14
DITHER_PATTERN   equ 54
GRN_INTENSITY    equ 50
GSPACING         equ 40
HARD_XMAX        equ 44
HARD_YMAX        equ 46
INDEX            equ 110
LINEPATTERN      equ 78
MONITORTYPE      equ 20
N3               equ 12
N_GLINES         equ 38
OLDPATTERN       equ 84
PEN_DRAW_MODE    equ 76
* PEN_NUMBER       equ 80       SEE PEN_NUM
PEN_NUM          equ 80
PLANE1_ADDR      equ 22
PLANE1_OFFSET    equ 26
PLANE2_OFFSET    equ 30
PLANE3_OFFSET    equ 34
RED_INTENSITY    equ 48
REPEATCOUNT      equ 108
REPEATRATE       equ 106
RGLTEMP1         equ 86
RGLTEMP2         equ 90
RGLTEMP3         equ 94
RGLTEMP4         equ 98
RGLTEMP5         equ 102
SOFTVEC          equ 114
SYSTEM_CMAP      equ 354

* addr1           equ    0                    integer
* addr2           equ   addr1+4               integer
* addr3           equ   addr2+4               integer

* n3              equ   addr3+4               shortint

* devicetype      equ   n3+2                  shortint
* deviceaddress   equ   devicetype+2          integer     only used on moonunit
* monitortype     equ   deviceaddress+4       shortint       ""   ""

* plane1_addr     equ   monitortype+2         integer
* plane1_offset   equ   plane1_addr+4         integer
* plane2_offset   equ   plane1_offset+4       integer
* plane3_offset   equ   plane2_offset+4       integer
* n_glines        equ   plane3_offset+4       shortint

* gspacing        equ   n_glines+2            shortint
* bytesperline    equ   gspacing+2            shortint

* hard_xmax       equ   bytesperline+2        shortint
* hard_ymax       equ   hard_xmax+2           shortint

* red_intensity   equ   hard_ymax+2           shortint
* grn_intensity   equ   red_intensity+2       shortint
* blu_intensity   equ   grn_intensity+2       shortint
* dither_pattern  equ   blu_intensity+2       16 bytes

* cursor_x        equ   dither_pattern+16     shortint
* cursor_y        equ   cursor_x+2            shortint

* area_draw_mode  equ   cursor_y+2            shortint
* pen_draw_mode   equ   area_draw_mode+2      shortint
* linepattern     equ   pen_draw_mode+2       shortint
* pen_num         equ   linepattern+2         shortint
* cpen            equ   pen_num+2             shortint
* oldpattern      equ   cpen+2                shortint
* rgltemp1        equ   oldpattern+2          integer
* rgltemp2        equ   rgltemp1+4            integer
* rgltemp3        equ   rgltemp2+4            integer
* rgltemp4        equ   rgltemp3+4            integer
* rgltemp5        equ   rgltemp4+4            integer
* repeatrate      equ   rgltemp5+4            shortint
* repeatcount     equ   repeatrate+2          shortint
* index           equ   repeatcount+2         integer
* softvec         equ   index+4               240 bytes of instructions
* system_cmap     equ   softvec+240
* * brightness_seq  equ   system_cmap+1536    removed for 3.1 implementation
* * count           equ   brightness_seq+512  SFB 12/14/84
* cmap_address    equ   system_cmap+1536      count+512

rule            equ   gle_types-4
window          equ   gle_types-8
status          equ   gle_types-20
stat            equ   $4001

charcount       equ   rgltemp1
t1              equ   rgltemp1
t2              equ   rgltemp2
t3              equ   rgltemp3
t4              equ   rgltemp4
t5              equ   rgltemp5

gle_gcb         equ   a4
rgl_gcb         equ   a6

zero            equ   d0
one             equ   d1
no              equ   d0
yes             equ   d1

packed_pixel_odd_byte_display equ 0
packed_pixel_display          equ 1
packed_pixel_3_plane_display  equ 2
byte_per_pixel_display        equ 3
gator_display                 equ 4
gatorbox_display              equ 5
bobcat_display                equ 6
bobcat_lores_display          equ 7
catseye_display               equ 8
catseye_hrx_display           equ 9
woodcut_vga_display           equ 10                               CFB - 31MAY91
woodcut_med_display           equ 11                               CFB - 31MAY91
woodcut_hrx_display           equ 12                               CFB - 31MAY91
woodcut_vgam_display          equ 13                               CFB - 30JUL91
woodcut_hrxm_display          equ 14                               CFB - 30JUL91

rrcopy                        equ sysdevs-92    gle_types global replrulecopy
wwcopy                        equ sysdevs-94    gle_types global widthcopy
writecopy                     equ sysdevs-96    gle_types global writeprotect
controladdr                   equ gle_types-30  gle_types global ID ROM base

hrm_tertiary                  equ 7             unique to CATSEYE HRM   {SFB}

tert_off                      equ $15           within ID ROM
initoffset                    equ $23           within ID ROM
cmapidoff                     equ $57           within ID ROM
cmapinitoff                   equ $3F           within ID ROM
blinkrega                     equ $6001         gatorbox
blinkregb                     equ $6005         gatorbox
writereg                      equ $6008         gatorbox
sox                           equ $40f2         bobcat source x
soy                           equ $40f6         bobcat source y
dox                           equ $40fa         bobcat dest x
doy                           equ $40fe         bobcat dest y
bobh                          equ $4106         bobcat height
bobw                          equ $4102         bobcat width
bobwr                         equ $40ee         bobcat window repl rule
bobwm                         equ $409c         bobcat window move start
curson                        equ $40ac         bobcat cursor enable SFB 6/11/85

pattregs                      equ $4400        CATSEYE pattern register base SFB
fben1                         equ $4500    frame buffer enable in upper byte SFB
trr                           equ $450c   upper byte=Three Operand Repl Rule SFB
trr_enable                    equ $4512        bit 8 of word selects trr/wrr SFB
catseye_status                equ $4800         catseye status in lower byte SFB

* unique WOODCUT register definitions                                CFB 10JUN91
blueregimage                  equ $00060610
dacimagewrite                 equ $00060202

	    include ASM_TYPES
*
*
	     page
*
*  utility subroutines
*
	    rorg    0
rts         movem.l old_a5(gle_gcb),a5-a6
	    rts

err_esc     movem.l old_a5(gle_gcb),a5-a6
	    move    d0,sysglobals-2(a5)
	    trap    #10

int_ovflow  move    #-4,d0                   integer overflow
	    bra     err_esc

	    page
*
*  procedure gcbinit(gcb: graphics_control_block_ptr);
*
gle_aras_out_rgcbinit equ *
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = ptr to device rec

	    move.l  info_ptr1(gle_gcb),plane1_addr(rgl_gcb)
	    move.l  info_ptr2(gle_gcb),plane1_offset(rgl_gcb)

	    moveq   #0,d0
	    moveq   #1,d1
	    move.w  yes,complement_support(gle_gcb)  complement := true
	    move.w  yes,non_dominant_support(gle_gcb)
	    move.w  yes,erase_support(gle_gcb)
	    move.w  yes,dither_support(gle_gcb)
	    move.w  yes,polygon_support(gle_gcb)
	    move.w  yes,polygon_fill_factor(gle_gcb)
	    move.w  yes,polygon_solid_fill(gle_gcb)
	    move.w  yes,background(gle_gcb)
	    move.w  #-1,cont_linestyles(gle_gcb)
	    move.w  zero,vect_linestyles(gle_gcb)
	    move.w  one,linewidths(gle_gcb)
	    move.w  #-1,char_sizes(gle_gcb)
	    move.l  zero,current_pos_x(gle_gcb)
	    move.l  zero,current_pos_y(gle_gcb)
	    move.w  no,current_drawing_mode(gle_gcb)
	    move.w  #-1,current_linestyle_pattern(gle_gcb)
	    move.w  zero,current_cursor_state(gle_gcb)
	    move.l  zero,current_cursor_x(gle_gcb)
	    move.l  zero,current_cursor_y(gle_gcb)

*           cmpi.w  #3,info1+2(gle_gcb)             ck for device
*           blt.s   init16                          9816 or 9826
*           beq.s   init36                          9836A
*           cmpi.w  #5,info1+2(gle_gcb)
*           blt     init36c                         9836C
*           bgt.s   initGatbw                       Gator BW

	    move.w  info1+2(gle_gcb),d2             compute jump table entry
	    asl.w   #1,d2                           for dev dep initialize
	    move.w  base_rgl(d2),d2
	    jmp     init_rgl(d2)                    jump to dev dep initialize

base_rgl    equ     *-2                          "virtual" entry #0 of table
init_rgl    equ     *                            dev dep initialize jump table
	    dc.w    init16-init_rgl
	    dc.w    init16-init_rgl
	    dc.w    init36-init_rgl
	    dc.w    init36c-init_rgl
	    dc.w    init27A-init_rgl
	    dc.w    initGatbw-init_rgl
	    dc.w    initgbox-init_rgl
	    dc.w    initbobcat-init_rgl
	    dc.w    initbobcatlores-init_rgl
	    dc.w    initcatseye-init_rgl
	    dc.w    initcatseye_hrx-init_rgl
	    dc.w    initwoodcut_vga-init_rgl                       CFB - 31MAY91
	    dc.w    initwoodcut_med-init_rgl                       CFB - 31MAY91
	    dc.w    initwoodcut_hrx-init_rgl                       CFB - 31MAY91
	    dc.w    initwoodcut_vgam-init_rgl                      CFB - 30JUL91
	    dc.w    initwoodcut_hrxm-init_rgl                      CFB - 30JUL91

init27A     move.w  #packed_pixel_3_plane_display,devicetype(rgl_gcb) 98627a
	    move.w  info3+2(gle_gcb),monitortype(rgl_gcb)
	    move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
	    move.w  no,color_map_support(gle_gcb)
	    move.w  yes,redef_background(gle_gcb)
	    move.l  #7,pallette(gle_gcb)
	    move.l  #7,gamut(gle_gcb)
	    bra     gen_init

init16      move.w  #packed_pixel_odd_byte_display,devicetype(rgl_gcb)
	    bra     initcom

initGatbw   move.w  #gator_display,devicetype(rgl_gcb)
	    bra     initcom

init36      move.w  #packed_pixel_display,devicetype(rgl_gcb)
initcom     move.w  no,color_map_support(gle_gcb)
	    move.w  yes,redef_background(gle_gcb)
	    move.l  one,pallette(gle_gcb)
	    move.l  one,gamut(gle_gcb)       redone for bobcat B/W in GLE_RGL
	    bra     gen_init

initgbox    move.w  #gatorbox_display,devicetype(rgl_gcb)
	    move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
initcmapinfo equ    *
	    move.w  yes,color_map_support(gle_gcb)
	    move.w  yes,redef_background(gle_gcb)
	    move.l  #16777216,pallette(gle_gcb) R,G,B each have 8 bits
* can't find gamut in rgcbinit for gatorbox or bobcat; done in setup routine
* in GLE_RGL !!!!!!!
	    cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB -  9AUG91
	    ble     gen_init                                       CFB -  9AUG91
	    move.l  #256,pallette(gle_gcb)     G only has 8 bits   CFB -  9AUG91
	    bra     gen_init

initwoodcut_vga equ     *                                          CFB - 31MAY91
	    move.w  #woodcut_vga_display,devicetype(rgl_gcb)       CFB - 31MAY91
	    bra.s   initwoodcutgen                                 CFB - 31MAY91

initwoodcut_med equ     *                                          CFB - 31MAY91
	    move.w  #woodcut_med_display,devicetype(rgl_gcb)       CFB - 31MAY91
	    bra.s   initwoodcutgen                                 CFB - 31MAY91

initwoodcut_hrx equ     *                                          CFB - 31MAY91
	    move.w  #woodcut_hrx_display,devicetype(rgl_gcb)       CFB - 31MAY91
	    bra.s   initwoodcutgen                                 CFB - 31MAY91

initwoodcut_vgam equ    *                                          CFB - 30JUL91
	    move.w  #woodcut_vgam_display,devicetype(rgl_gcb)      CFB - 30JUL91
	    bra.s   initwoodcutgen                                 CFB - 30JUL91

initwoodcut_hrxm equ    *                                          CFB - 30JUL91
	    move.w  #woodcut_hrxm_display,devicetype(rgl_gcb)      CFB - 30JUL91
	    bra.s   initwoodcutgen                                 CFB - 30JUL91

initcatseye equ     *
	    move.w  #catseye_display,devicetype(rgl_gcb)
	    bra.s   initbobcatgen

initcatseye_hrx equ     *
	    move.w  #catseye_hrx_display,devicetype(rgl_gcb)
	    bra.s   initbobcatgen

initbobcatlores equ *
	    move.w  #bobcat_lores_display,devicetype(rgl_gcb)
	    bra.s   initbobcatgen

initbobcat  equ     *
	    move.w  #bobcat_display,devicetype(rgl_gcb)

* {SFB} hacked to allow HRM CATSEYE to be known as mono disply to DGL,
* and initialize GCB for same HRM CATSEYE IS "mono" but has cmap other
* CATSEYE/BOBCAT are color or have no cmap signal "mono" for HRM, and send
* back to gle_rgl

initbobcatgen equ   *
	    movea.l info2(gle_gcb),a0
	    move.l  a0,deviceaddress(rgl_gcb)
	    cmpi.b  #hrm_tertiary,tert_off(a0)
	    bne.s   get_cmap_info
	    move.l  #0,info3(gle_gcb)

get_cmap_info equ   *
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
	    beq     initcom
	    bra     initcmapinfo

initwoodcutgen equ   *
	    movea.l info2(gle_gcb),a0
	    move.l  a0,deviceaddress(rgl_gcb)
	    move.l  #0,info3(gle_gcb)
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
	    bra     initcmapinfo

init36c     move.w  #byte_per_pixel_display,devicetype(rgl_gcb)
	    move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
	    move.w  yes,color_map_support(gle_gcb)
	    move.w  yes,redef_background(gle_gcb)
	    move.l  #4095,pallette(gle_gcb)
	    move.l  #15,gamut(gle_gcb)

gen_init    move    devicetype(rgl_gcb),d0     choose frame buf info init block
	    move    d0,d2
	    cmpi.w  #7,devicetype(rgl_gcb)     ck for bobcatlores
	    bne.s   ckbitmap
	    move    #5,d0                      bobcatlores init block is #5
	    bra.s   gen1

ckbitmap    equ     *
	    cmpi.w  #6,info1+2(gle_gcb)        ck for Gator/gbox/bobcathires
	    blt.s   gen1

	    cmpi.w  #11,info1+2(gle_gcb)       ck for Catseye_hrx
	    beq.s   adjust_catseye_hrx

	    cmpi.w  #10,devicetype(rgl_gcb)    ck for WOODCUT      CFB - 24JUL91
	    bge.s   adjust_woodcut                                 CFB - 31MAY91

	    move    #4,d0               use initialize block 4 for Bobcat clones
	    bra.s   gen1

adjust_woodcut equ  *                                              CFB - 31MAY91
	    move    devicetype(rgl_gcb),d0                         CFB - 31MAY91
	    subq    #3,d0                     convert 10-12 to 7-9 CFB - 31MAY91
	    cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB - 30JUL91
	    ble.s   gen1                                           CFB - 30JUL91
	    subq    #3,d0                     convert 13-14 to 7-8 CFB - 30JUL91
	    cmpi.w  #7,d0                      VGA?                CFB - 11OCT91
	    beq.s   gen1                                           CFB - 11OCT91
	    addq    #1,d0                     Hrx? convert 8 to 9  CFB - 11OCT91
	    bra.s   gen1                                           CFB - 31MAY91

adjust_catseye_hrx equ  *
	    move    #6,d0                      hrx block index
*                                              except LCC
*                                              of gator/gatorbox/bobcathires
*           cmpi.w  #7,info1+2(gle_gcb)        ck for Gator Color
*           bne.s   gen1
*           move    #5,d0

gen1        mulu    #init1-init_table,d0       calc offset into init_table
	    movea.l d0,a0
	    lea     init_table(a0),a0
	    lea     plane2_offset(rgl_gcb),a1
	    move.l  (a0)+,(a1)+                and offsets to display table
	    move.l  (a0)+,(a1)+
	    moveq   #4,d1
*           cmp     #2,d2
	    bra     initloop

init_table  dc.l       0   plane2_offset       ( not used )      {9816A}
	    dc.l       0   plane3_offset       ( not used )
	    dc       300   n_glines
	    dc         2   gspacing
	    dc       100   bytesperline
	    dc       399   hard_xmax
	    dc       299   hard_ymax

init1       dc.l       0   plane2_offset       ( not used )      {9836a}
	    dc.l       0   plane3_offset       ( not used )
	    dc       390   n_glines
	    dc         1   gspacing
	    dc        64   bytesperline
	    dc       511   hard_xmax
	    dc       389   hard_ymax

init2       dc.l   $8000   plane2_offset                         {Moonunit}
	    dc.l  $10000   plane3_offset
	    dc       390   n_glines
	    dc         1   gspacing
	    dc        64   bytesperline
	    dc       511   hard_xmax
	    dc       389   hard_ymax

init3       dc.l       0   not used                              {9836c}
	    dc.l       0   not used
	    dc       390   n_glines
	    dc         1   gspacing
	    dc       512   bytesperline
	    dc       511   hard_xmax
	    dc       389   hard_ymax

init4       dc.l       0   not used               {Gator/gatorbox/bobcathires}
	    dc.l       0   not used
	    dc       752   n_glines
	    dc         1   gspacing
	    dc      1024   bytesperline
	    dc      1023   hard_xmax
	    dc       751   hard_ymax

init5       dc.l       0   not used               {bobcat lores block}
	    dc.l       0   not used
	    dc       385   n_glines
	    dc         1   gspacing
	    dc      1024   bytesperline
	    dc       511   hard_xmax
	    dc       384   hard_ymax

init6       dc.l       0   not used               {catseye_hrx block}
	    dc.l       0   not used
	    dc      1000   n_glines     only 1000 because we use 50 alpha lines
*                                       at 10 scan lines each, and don't offset
*                                       alpha the 4 "wasted" pixels as we do on
*                                       low-res Bobcat
	    dc         1   gspacing
	    dc      2048   bytesperline
	    dc      1279   hard_xmax
	    dc       999   hard_ymax

init7       dc.l       0   not used            {woodcut_vga block} CFB - 31MAY91
	    dc.l       0   not used                                CFB - 31MAY91
	    dc       464   n_glines                                CFB - 31MAY91
	    dc         1   gspacing                                CFB - 31MAY91
	    dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
	    dc       639   hard_xmax                               CFB - 31MAY91
	    dc       463   hard_ymax                               CFB - 31MAY91

init8       dc.l       0   not used            {woodcut_med block} CFB - 31MAY91
	    dc.l       0   not used                                CFB - 31MAY91
	    dc       752   n_glines                                CFB - 31MAY91
	    dc         1   gspacing                                CFB - 31MAY91
	    dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
	    dc      1023   hard_xmax                               CFB - 31MAY91
	    dc       751   hard_ymax                               CFB - 31MAY91

init9       dc.l       0   not used            {woodcut_hrx block} CFB - 31MAY91
	    dc.l       0   not used                                CFB - 31MAY91
	    dc      1000   n_glines                                CFB - 31MAY91
	    dc         1   gspacing                                CFB - 31MAY91
	    dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
	    dc      1279   hard_xmax                               CFB - 31MAY91
	    dc       999   hard_ymax                               CFB - 31MAY91

initloop    move    (a0)+,(a1)+                copy some stuff from init_table
	    dbra    d1,initloop
	    moveq   #16,d0
	    move    d0,(a1)+                   set default fill colors
	    move    d0,(a1)+
	    move    d0,(a1)+
	    move    #$FFFF,current_linestyle_pattern(gle_gcb)
	    clr     oldpattern(rgl_gcb)
	    move    #1,repeatcount(rgl_gcb)
	    move    #1,repeatrate(rgl_gcb)

	    bsr     build_pen                  | create 1st vec template

*  if the device is a 98627 or 98627 gload image, n_glines must be
*  calculated.  if monitor type = (1,2,6) then n_glines and the
*  other parameters associated with variable height (hard_ymax,
*  etc) are already correct.

	    cmpi.b  #2,devicetype+1(rgl_gcb)
	    bne     set_pen                    not a 98627 style image
	    cmpi    #3,monitortype(rgl_gcb)
	    blt     init_regs                  n_glines is already set up
	    beq.s   init474
	    cmpi    #6,monitortype(rgl_gcb)
	    bge     init_regs                  n_glines is already set up
init512     move   #512,n_glines(rgl_gcb)
	    move   #511,hard_ymax(rgl_gcb)
	    bra    init_regs
init474     move   #474,n_glines(rgl_gcb)
	    move   #473,hard_ymax(rgl_gcb)

init_regs   move    monitortype(rgl_gcb),d0
	    cmp     #1,d0
	    blt     set_pen                    make sure 1 <= monitortype <= 6
	    cmp     #6,d0                      to prevent hardware damage
	    bgt     set_pen
	    lsl     #4,d0                      calculate offset into
	    lea     usstd(d0),a0               setup table for 6845
	    movea.l deviceaddress(rgl_gcb),a1
	    moveq   #15,d0
setuploop   move.b  d0,$10(a1)                 select a register
	    move.b  -(a0),$12(a1)              write a value
	    dbra    d0,setuploop
	    bra     set_pen

usstd       dc.b    41     horizontal total
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    50     vertical total
	    dc.b     5     vertical total adjust
	    dc.b    49     vertical displayed
	    dc.b    49     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)

eurostd     dc.b    41     horizontal total
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    61     vertical total
	    dc.b     0     vertical total adjust
	    dc.b    49     vertical displayed
	    dc.b    55     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)

ustv        dc.b    39     horizontal total
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    31     vertical total
	    dc.b     6     vertical total adjust
	    dc.b    30     vertical displayed
	    dc.b    30     vertical sync position
	    dc.b     3     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)

eurotv      dc.b    39     horizontal total
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    38     vertical total
	    dc.b     0     vertical total adjust
	    dc.b    32     vertical displayed
	    dc.b    35     vertical sync position
	    dc.b     3     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)

hires       dc.b    41     horizontal total
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    65     vertical total
	    dc.b     5     vertical total adjust
	    dc.b    64     vertical displayed
	    dc.b    64     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)

jvc         dc.b    44     horizontal total
	    dc.b    32     horizontal displayed
	    dc.b    36     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    56     vertical total
	    dc.b     5     vertical total adjust
	    dc.b    49     vertical displayed
	    dc.b    49     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)
	    page

*
*  procedure store_dit(gcb:anyptr);
*
gle_aras_out_store_dit   equ *
	    movea.l 4(sp),gle_gcb                   a4 = addr of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec_ptr

loopstA     movea.l status(a5),a0
	    btst    #7,1(a0)
	    beq.s   loopstA
	    moveq   #3,d0
	    move.w  d0,rrcopy(a5)                   update current repl. rule
	    movea.l rule(a5),a0                     setup repl. rule
	    move.w  d0,(a0)
	    movea.l plane1_addr(rgl_gcb),a1         ptr to address
	    movea.l (a1),a1
	    adda.l  plane1_offset(rgl_gcb),a1       upper right display address
	    adda.l  #$0FF000,a1                     a1 points to 3rd to last line
	    move.l  dither_pattern(rgl_gcb),(a1)
	    move.l  dither_pattern+4(rgl_gcb),$400(a1)
	    move.l  dither_pattern+8(rgl_gcb),$800(a1)
	    move.l  dither_pattern+12(rgl_gcb),$C00(a1)

loopstB     movea.l status(a5),a0
	    btst    #7,1(a0)
	    beq.s   loopstB
	    moveq   #$83,d0
	    move.w  d0,rrcopy(a5)                   update current repl. rule
	    movea.l rule(a5),a0                     set up replacement rule
	    move.w  d0,(a0)
	    moveq   #3,d0
loopst1     moveq   #4,d1
loopst2     move    d1,d2

loopstC     movea.l status(a5),a0
	    btst    #7,1(a0)
	    beq.s   loopstC
	    neg     d2
	    move.w  d2,wwcopy(a5)                   update current window width
	    movea.l window(a5),a0                   set window width
	    move.w  d2,(a0)

	    move.b (a1),0(a1,d1)                    move some bytes

	    lsl     #1,d1                           d1=2*d1
loopst3     movea.l status(a5),a0
	    btst    #7,1(a0)
	    beq.s   loopst3
	    cmpi    #512,d1
	    ble.s   loopst2
	    adda    #$400,a1                        bump a1 to next line
	    dbra    d0,loopst1
loopst4     movea.l status(a5),a0
	    btst    #7,1(a0)
	    beq.s   loopst4
	    moveq   #3,d0                           Restore rep rule
	    move.w  d0,rrcopy(a5)                   update current repl. rule
	    movea.l rule(a5),a0                     set up replacement rule
	    bra     rts

*
*  procedure set_6845s(gcb:anyptr);
*   set up gator 6845's from Gator ROM
*

gle_aras_out_set_6845s   equ *
	    movea.l  4(sp),gle_gcb                   a4 = addr of pointer to gcb
	    move.l   (sp)+,(sp)                      stack return address
	    movem.l  a5-a6,old_a5(gle_gcb)
	    movea.l  dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec_ptr
	    cmpi.b   #5,devicetype+1(rgl_gcb)   gatorbox/bobcat both use std
	    bge      std_graphics_rom           graphics ID ROM

gator_rom   equ      *
	    movea.l  controladdr(a5),a0    get pointer to ROM start
	    moveq    #0,d0
	    moveq    #0,d1
	    move.b   stat(a0),d0            get status reg again
	    lsr.b    #2,d0                  get monitor type bits
	    and.b    #12,d0
	    move.b   initoffset(a0,d0.w),d1  get MSB of info addr offset
	    lsl.w    #8,d1
	    move.b   initoffset+2(a0,d0.w),d1  get LSB of info addr offset
	    movea.l  a0,a1                  make copy of ROM start addr
	    adda     d1,a1                  a1 points to init info now
	    jsr      ginitblock             call the initialization routine
	    bra      rts                    that's all for gator

* ginitblock is common code for both gator ROM, and gatorbox/bobcat ROM
ginitblock  moveq    #0,d1                  clear some regs
	    moveq    #0,d0
	    move.b   2(a1),d0               get word count to initialize
	    movep    4(a1),d1               form destination offset
	    add.l    a0,d1                  d1 points to dest addr
	    lea      8(a1),a2               a2 points to first data byte
	    movea.l  d1,a3                  a3 points to destination
	    btst     #0,(a1)                added for bit_test SFB 3 Mar '88
	    bne.s    bit_test             see new Graphics ID ROM definition SFB
ginitloop   movep    0(a2),d1                form a data word in d1
	    move.w   d1,(a3)+               move data to the destination addr
	    btst     #6,(a1)                increment data pointer
	    bne.s    ginit1                 based on control byte
	    addq     #4,a2
ginit1      dbra     d0,ginitloop           loop till word count exhausted
	    btst     #7,(a1)                was this last block?
	    bne.s    ginitdone              yes -- go return
	    btst     #6,(a1)                adjust data pointer
	    beq.s    ginit2                 to point to next init block
finish_block equ     *                      point to next block SFB
	    addq     #4,a2
ginit2      movea.l  a2,a1                  a1 points to new init block
	    bra      ginitblock             do the initialize

bit_test    move.b   2(a2),d2               bit number to test SFB
	    and.b    #$0f,d2                ensure bitnum #0..#15 SFB
	    tst.b    (a2)                   compare bit to 0 or to 1? SFB
	    bne      test_for_1             SFB
test_for_0  equ      *                      wait for 0 in bit d2 of d3 SFB
	    move.w   (a3),d3                status word to test SFB
	    btst     d2,d3                  ready? SFB
	    bne      test_for_0
	    bra      finish_block           and got to next block SFB
test_for_1  equ      *                      wait for 0 in bit d2 of d3 SFB
	    move.w   (a3),d3                status word to test SFB
	    btst     d2,d3                  ready? SFB
	    beq      test_for_1
	    bra      finish_block           and got to next block SFB
ginitdone   rts                             3.1E BUGFIX SFB 6/13/85

std_graphics_rom equ *
	    movea.l  controladdr(a5),a0     get pointer to ROM start
	    movep    initoffset(a0),d1      form pointer to init block 0
	    movea.l  a0,a1                  make copy of ROM start addr
	    adda     d1,a1                  a1 points to init info now

* bobcat CURSON save/restore added SFB 6/11/85
	    cmpi.b   #6,devicetype+1(rgl_gcb)  for bobcat save CURSON register
	    blt.s    do_ginit
	    move.b   curson(a0),rgltemp1(rgl_gcb) save value of CURSON
do_ginit    jsr      ginitblock             call the initialization routine
	    cmpi.b   #6,devicetype+1(rgl_gcb) for bobcat restore CURSON
	    blt.s    init_cmapstuff
	    move.b   rgltemp1(rgl_gcb),curson(a0) restore value of CURSON
init_cmapstuff equ *    SFB 6/11/85

*  DO NOT DO CMAP INIT TRAVERSAL, AS IT RESETS COLORS
*  0,1,254,255. WILL SET TCOL (NEREID) IN GLE_RGL      SFB 6/25/85
*           movep    cmapidoff(a0),d0       get ptr to color map id reg
*           tst      d0                     if ptr = 0 then no color map
*           beq.s    std_rom_done
*           move.b   0(a0,d0),d1            get cmap id into d1
*           and      #3,d1                  look at least sig bits
*           lsl      #2,d1
*           move.b   cmapinitoff(a0,d1.w),d2  form cmap init block addr
*           lsl      #8,d2
*           move.b   cmapinitoff+2(a0,d1.w),d2
*           movea.l  a0,a1
*           adda     d2,a1                  a1 points to cmap init block
*           jsr      ginitblock

std_rom_done equ     *
	    bra      rts

*
*  procedure graphics_on_off ( gcb : graphics_control_block_ptr )
*
gle_aras_out_rgraphics_on_off equ *
*
	    movea.l 4(sp),gle_gcb              a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                 stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
	    move.w  devicetype(rgl_gcb),d0
	    cmp.w   #2,d0                      moonunit is only device that
	    beq.s   on_off_tst                 supports this call
	    bra rts

on_off_tst  add.w   d0,d0
	    tst.l   info1(gle_gcb)             { info1 = 0 is goff }
	    beq.s   goff_98627

gon_98627   movea.l deviceaddress(rgl_gcb),a0
	    move.b  #$80,1(a0)
	    bra rts

goff_98627  movea.l deviceaddress(rgl_gcb),a0
	    move.b  #0,1(a0)
	    bra rts
	    page
************************************************************************
*
moon_map2   dc.b    0             0
	    dc.b    7             1  white
	    dc.b    4             2  red
	    dc.b    6             3  yellow
	    dc.b    2             4  green
	    dc.b    3             5  cyan
	    dc.b    1             6  blue
	    dc.b    5             7  magenta

****************************************************************************
*
*  procedure clear ( gcb : graphics_control_block_ptr )
*
*    INFO1 = Plane clear information
*    INFO2 = Plane select information
*
gle_aras_out_rclear   equ *
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
	    move.l  info1(gle_gcb),d7               clear ? plane word
	    bne.s   gclr0
	    move.l  #-1,d7
gclr0       movea.l plane1_addr(rgl_gcb),a0         ptr to address
	    movea.l (a0),a0
	    adda.l  plane1_offset(rgl_gcb),a0       upper right display address
gclr1       cmpi.b  #3,devicetype+1(rgl_gcb)
	    beq     gclr36c

	    movea.l a0,a1
	    movea.l a0,a2
	    adda.l  plane2_offset(rgl_gcb),a1
	    adda.l  plane3_offset(rgl_gcb),a2

	    moveq   #0,d3
	    move.b  info2+3(gle_gcb),d3
	    cmpi.w  #2,devicetype(rgl_gcb)   ck for moonunit
	    bne.s   g0
	    move.b  moon_map2(d3),d3         remap for moonunit

g0          moveq   #0,d0
	    btst    #0,d3
	    beq.s   g1
	    moveq   #-1,d0

g1          moveq   #0,d1
	    btst    #1,d3
	    beq.s   g2
	    moveq   #-1,d1

g2          moveq   #0,d2
	    btst    #2,d3
	    beq.s   g3
	    moveq   #-1,d2

g3          move    n_glines(rgl_gcb),d6
	    cmpi.b  #2,devicetype+1(rgl_gcb)   if it's color, we have to clear
	    bne.s   gclr1a                     everything.
	    move    #512,d6
gclr1a      mulu    bytesperline(rgl_gcb),d6
gclr4       lsr.l   #2,d6                      d6 = # of long words to clear
	    ror.l   #3,d6                      do them in groups of 8 longwords
	    cmpi.b  #2,devicetype+1(rgl_gcb)
	    beq.s   gclrloop
	    and.b   #$1,d7                     mask off green and red for b&w

gclrloop    btst    #0,d7                      alter plane1 ?
	    beq.s   gclrloop1
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
gclrloop1   btst    #1,d7                      alter plane2 ?
	    beq.s   gclrloop2
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
gclrloop2   btst    #2,d7                      alter plane3 ?
	    beq.s   gclrloop3
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
gclrloop3   subq    #1,d6
	    bne     gclrloop                   Changed from bgt - CFB 2DEC91
	    rol.l   #3,d6
	    beq     rts

*  loop to finish any left-over words

gclrlp      btst    #0,d7                      alter plane1 ?
	    blt.s   gclrlp1
	    move.l  d0,(a0)+
gclrlp1     btst    #1,d7                      alter plane2 ?
	    blt.s   gclrlp2
	    move.l  d1,(a1)+
gclrlp2     btst    #2,d7                      alter plane3 ?
	    blt.s   gclrlp3
	    move.l  d2,(a2)+
gclrlp3     subq    #1,d6
	    bgt     gclrlp
	    bra     rts

gclr36c     move    n_glines(rgl_gcb),d0
	    mulu    bytesperline(rgl_gcb),d0
	    adda.l  d0,a0

	    and.l   #15,d7
	    cmpi.b  #15,d7
	    beq.s   gclr36c_all

	    move.l  d7,d2
	    asl.l   #8,d2
	    add.l   d7,d2
	    asl.l   #8,d2
	    add.l   d7,d2
	    asl.l   #8,d2
	    add.l   d7,d2
	    not.l   d2

	    lsr.l   #4,d0              div by 16
	    subq.l  #1,d0

g36c_ploop  equ *
	    and.l   d2,-(a0)
	    and.l   d2,-(a0)
	    and.l   d2,-(a0)
	    and.l   d2,-(a0)
	    dbra    d0,g36c_ploop
	    bra     rts


gclr36c_all equ *
	    divu    #192,d0                    clear 48 long words at a time
	    subq    #1,d0
	    ext.l   d0
	    moveq   #0,d1
	    move.l  d1,d2
	    move.l  d1,d3
	    move.l  d1,d4
	    move.l  d1,d5
	    move.l  d1,d6
	    move.l  d1,d7
	    movea.l d1,a1
	    movea.l a1,a2
	    movea.l a1,a3
	    movea.l a1,a5
	    movea.l a1,a6
gclrloop36  movem.l d1-d7/a1-a3/a5/a6,-(a0)
	    movem.l d1-d7/a1-a3/a5/a6,-(a0)
	    movem.l d1-d7/a1-a3/a5/a6,-(a0)
	    movem.l d1-d7/a1-a3/a5/a6,-(a0)
	    dbra    d0,gclrloop36
	    bra     rts
*****************************************************************************
*
*  procedure move (gcb: graphics_control_block_ptr);
*
gle_aras_out_rmove    movea.l 4(sp),gle_gcb      a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                 stack return address
	    move.l  end_x(gle_gcb),d4
	    move.l  end_y(gle_gcb),d5
	    move.l  d4,current_pos_x(gle_gcb)
	    move.l  d5,current_pos_y(gle_gcb)
	    rts
	    page

*****************************************************************************
*
clip_draw   equ *
	    exg     d5,d6
	    jsr     gle_asclip_clipping
	    exg     d5,d6
	    cmpi.b  #1,d0
	    ble.s   vector1
	    bra     rts

*****************************************************************************
*
clip_xmin equ a0
clip_xmax equ a1
clip_ymin equ a2
clip_ymax equ a3
*
*  procedure draw (gcb: graphics_control_block_ptr);
*
gle_aras_out_rdraw    movea.l 4(sp),gle_gcb      a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                 stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb

	    move.l  current_pos_x(gle_gcb),d4
	    move.l  current_pos_y(gle_gcb),d6
	    move.l  end_x(gle_gcb),d5
	    move.l  end_y(gle_gcb),d7
	    move.l  d5,current_pos_x(gle_gcb)
	    move.l  d7,current_pos_y(gle_gcb)

	    movem.l clip_limits_xmin(gle_gcb),a0-a3
	    cmp.l   clip_xmin,d4                      x0 < clip_xmin
	    blt.s   clip_draw
	    cmp.l   clip_xmax,d4                      x0 > clip_xmax
	    bgt.s   clip_draw
	    cmp.l   clip_ymin,d6                      y0 < clip_ymin
	    blt.s   clip_draw
	    cmp.l   clip_ymax,d6                      y0 > clip_ymax
	    bgt.s   clip_draw
	    cmp.l   clip_xmin,d5                      x1 < clip_xmin
	    blt.s   clip_draw
	    cmp.l   clip_xmax,d5                      x1 > clip_xmax
	    bgt.s   clip_draw
	    cmp.l   clip_ymin,d7                      y1 < clip_ymin
	    blt.s   clip_draw
	    cmp.l   clip_ymax,d7                      y1 > clip_ymax
	    bgt.s   clip_draw

vector1     movea.l plane1_addr(rgl_gcb),a0
	    movea.l (a0),a0                        get address
	    adda.l  plane1_offset(rgl_gcb),a0      upper right display address
	    movem.l plane2_offset(rgl_gcb),a2/a3
	    move    gspacing(rgl_gcb),d0
	    subq    #1,d0
	    adda.w  d0,a0                        adjust for 16/26 odd addressing
	    move    current_linestyle_pattern(gle_gcb),oldpattern(rgl_gcb)

	    movea.l status(a5),a1      prepare to check line/block mover ready
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
	    bne.s   checkgbox
loopstg     btst    #7,1(a1)           wait for gator line mover
	    beq.s   loopstg
	    bra.s   setvec_rr
checkgbox   cmpi.b  #gatorbox_display,devicetype+1(rgl_gcb)
	    bne.s   checkbobcat
waitgboxbm  btst    #4,(a1)            wait for gatorbox tile mover
	    bne     waitgboxbm
	    bra.s   setvec_rr
checkbobcat cmpi.b  #bobcat_display,devicetype+1(rgl_gcb)
	    blt.s   vec1                bugfix 3.1C SFB 5/23/85
checkwoodcut cmpi.b  #catseye_hrx_display,devicetype+1(rgl_gcb)      CFB 10JUN91
	    bgt.s   vec1                                             CFB 10JUN91
* don't need to wait for window mover to change bobcat pixel repl rule !!!
	    move.w  #$300,d3                       special case for bobcat
	    bra.s   do_set_rr                      repl rule 3 in msb of word

setvec_rr   moveq   #3,d3                          generic repl rule 3
do_set_rr   movea.l rule(a5),a1
	    move.w  d3,(a1)                        and set (pixel) repl rule

vec1        cmp     d6,d7                          if y1=y2
	    bne.s   vec2                           and if solid line
	    cmpi    #-1,current_linestyle_pattern(gle_gcb)
	    bne.s   vec2
	    move    pen_draw_mode(rgl_gcb),d0      and if draw mode is dominant
	    bne.s   vec2
	    bra     horiz_vec                      then draw horizontal vector
vec2        moveq   #0,d0                          clear  'y1:y2 swapped'  flag
	    move    d7,d2
	    sub     d6,d2                      d2 = y2 - y1
	    bge.s   d2plus                     y2 was > y1
	    neg     d2                         make y2 > y1
	    exg     d4,d5
	    exg     d6,d7                      d6 = smaller y
	    moveq   #1,d0                      set [y1:y2 swapped] flag
d2plus      sub     d4,d5                      d5 = x2-x1
	    move    current_linestyle_pattern(gle_gcb),d3
	    cmp     #-1,d3
	    beq.s   vec6                       solid line : all is well
	    move    d5,d1                      d1 = x2-x1
	    bge.s   vec3
	    neg     d1                         d1 = abs(x2-x1)
vec3        cmp     d1,d2                      d1 = # of pixels in vector
	    blt.s   vec4
	    move    d2,d1
vec4        move    current_linestyle_pattern(gle_gcb),d3
*
* Non-trivial fixup of the repeat pattern based on repeatcount
* and repeatrate:  The final current_linestyle_pattern and repeatcount are
* calculated before the vector loop is entered.  This prevents a messy
* self-modification section in the vector generator itself, and limits all self
* modifying code to subroutine 'buildpen'.  If the line must be drawn backwards
* (i.e. the passed y2 was less than y1), the final current_linestyle_pattern and
* repeatcount calculated here are used as the starting point.
*
* Of course, all of this is skipped for solid lines
*

	    move    repeatcount(rgl_gcb),t4(rgl_gcb)
	    cmp     repeatcount(rgl_gcb),d1
	    blt.s   smallvec
	    sub     repeatcount(rgl_gcb),d1
	    ext.l   d1
	    divu    repeatrate(rgl_gcb),d1
	    addq    #1,d1                      Q=Q+1
	    rol     d1,d3                      rotate the current_linestyle_pattern
	    swap    d1                         d1 = R
	    neg     d1
	    add     repeatrate(rgl_gcb),d1          d1=repeatrate-R
	    move    d1,repeatcount(rgl_gcb)
	    bra.s   vec5

smallvec    sub     d1,repeatcount(rgl_gcb)

vec5        move    d3,oldpattern(rgl_gcb)          update oldpattern for next pass
	    tst     d0
	    beq.s   vec6
	    lsl.b   #1,d3                      swap the 16 bits in d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    ror     #1,d3
	    move    d3,current_linestyle_pattern(gle_gcb)      start with last pattern
	    move    repeatrate(rgl_gcb),d0
	    sub     repeatcount(rgl_gcb),d0
	    addq    #1,d0
	    move    d0,t4(rgl_gcb)

vec6        movea   bytesperline(rgl_gcb),a1
	    not     d6                         d6 = -y-1
	    add     n_glines(rgl_gcb),d6            d6 = (n_glines-1)-y
	    mulu    bytesperline(rgl_gcb),d6
	    adda.l  d6,a0                      a0 = addr of line with 1st pixel
	    cmpi.b  #3,devicetype+1(rgl_gcb)   if 36c/gatorgatorbox/bobcat
	    blt.s   not36c                     then do 36c stuff

* compute address of first pixel for byte/pixel frame buffer
	    adda    d4,a0                      add x1 to start address
	    move    cpen(rgl_gcb),d0           d0 = pen (or not pen if erase)
	    cmpi.b  #7,devicetype+1(rgl_gcb)   bobcatlores ?
	    bne     vecready
	    mulu    #257,d0                    yes, dup pen value in both bytes
	    adda    d4,a0                      and double x1 for "real" pixels
	    bra.s   vecready

* compute address and bit position of first pixel for bit/pixel frame buffer
not36c      move    gspacing(rgl_gcb),d0
	    move    d0,d6
	    subq    #1,d0
	    move    d4,d1                      d1 = starting x
	    lsr     #3,d1
	    lsl     d0,d1
	    adda    d1,a0                      a0 points to first byte to alter
	    and     #7,d4                      d4 = bit number of first pixel
	    moveq   #$80,d0                    d0 = bit pattern to rotate
	    ror.b   d4,d0                      align it for starting position
	    move    d0,d1
	    not     d1                         use d1 for the 'and' mask
vecready    move    #$8000,d3                  sum = 0.50000
	    move    current_linestyle_pattern(gle_gcb),d4
	    movea   repeatrate(rgl_gcb),a5
	    move    t4(rgl_gcb),d7

	    jsr     softvec(rgl_gcb)

	    move    oldpattern(rgl_gcb),current_linestyle_pattern(gle_gcb)
	    bra     rts

horiz_vec   cmp     d4,d5
	    bge.s   hv10
	    exg     d4,d5
hv10        not     d6                         d6 = -y-1
	    add     n_glines(rgl_gcb),d6       d6 = (n_glines-1)-y
	    mulu    bytesperline(rgl_gcb),d6
	    adda.l  d6,a0                      a0 = addr of line with 1st pixel
	    move    d4,d2                      d2=d4=x1
	    move    d5,d3                      d3=d5=x2
	    cmpi.b  #3,devicetype+1(rgl_gcb)
	    bge     hv50                       36C/gator/gatorbox/bobcat
*           bgt     hvgat
	    lsr     #3,d2                      d2=x1 div 8
	    lsr     #3,d3                      d3=x2 div 8
	    and     #7,d4                      d4=x1 mod 8
	    and     #7,d5                      d5=x2 mod 8
	    sub     d2,d3                      d3=# of bytes to do - 1
	    addq    #1,d5
	    adda    d2,a0                      a0 points to 1st byte to modify
	    movea   gspacing(rgl_gcb),a1
	    tst     devicetype(rgl_gcb)        9816 or 9826 ?
	    bne.s   hv20
	    adda    d2,a0                      on 9826 & 9816 add it twice
hv20        moveq   #-1,d2
	    btst    #1,devicetype+1(rgl_gcb)   is this color ?
	    beq.s   hv30                       no
	    adda.l  a0,a2                      a2 points to green plane
	    adda.l  a0,a3                      a3 points to red plane
	    move    d3,d6                      save the byte count (d1)
	    moveq   #-1,d2
	    btst    #2,pen_num+1(rgl_gcb)
	    bne.s   hv22
	    moveq   #0,d2
hv22        bsr.s   hv40                       draw the blue plane
	    move    d6,d3                      restore the byte count
	    movea.l a2,a0                      a0 points to green plane
	    moveq   #-1,d2
	    btst    #1,pen_num+1(rgl_gcb)
	    bne.s   hv24
	    moveq   #0,d2
hv24        bsr.s   hv40                       draw the green plane
	    move    d6,d3                      restore byte count
	    movea.l a3,a0                      a0 points to red plane
	    moveq   #-1,d2
	    btst    #0,pen_num+1(rgl_gcb)
	    bne.s   hv30
	    moveq   #0,d2
hv30        bsr.s   hv40
	    bra     rts

hv40        tst     d3                         how many bytes are effected ?
	    bne.s   hv41                       more than one
	    move.b  (a0),d2                    g->mask.b
	    rol.b   d5,d2
	    rol     d4,d2
	    ror     d5,d2                      ror.w x2b-x1b+1,mask
	    ror.b   d4,d2
	    move.b  d2,(a0)                    mask->g
	    rts

hv41        move.b  (a0),d0
	    rol     d4,d0
	    move.b  d2,d0
	    rol.b   d4,d0
	    ror     d4,d0
	    move.b  d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d3
	    blt.s   hv43
hv42        move.b  d2,(a0)
	    adda.l  a1,a0
	    dbra    d3,hv42
hv43        rol     d5,d2
	    move.b  (a0),d2
	    rol.b   d5,d2
	    ror     d5,d2
	    move.b  d2,(a0)
	    rts

hv50        cmpi.b  #7,devicetype+1(rgl_gcb)   bobcatlores ?
	    bne.s   hv50_a                     NO
	    asl     #1,d2                      double x1 for "real" pixel
	    asl     #1,d3                      double x2 for "real" pixel
	    addq    #1,d3                      and fill to end (SFB 7/8/85}
	    asl     #1,d4                      double x1 for "real" pixel
	    asl     #1,d5                      double x2 for "real" pixel
	    addq    #1,d5                      and fill to end (SFB 7/8/85}
hv50_a      equ     *
	    and     #3,d4                      x1 mod 4
	    and     #3,d5                      x2 mod 4
	    lsl     #2,d4                      (x1 mod 4)*4  mask index
	    lsl     #2,d5                      (x2 mod 4)*4  mask index
	    and     #$fffc,d2                  x1 div 4
	    adda    d2,a0                      (a0) first long w that changes
	    lsr     #2,d2                      # of nibbles to x1
	    lsr     #2,d3                      # of nibbles to x2
	    sub     d2,d3                      # of nibbles to do -1
	    move    cpen(rgl_gcb),d0
	    move    d0,d1
	    lsl     #8,d0
	    move.b  d1,d0
	    move    d0,d1
	    swap    d0
	    move    d1,d0
	    move.l  d0,d1
	    move.l  hvmask1(d4),d4
	    tst     d3
	    bne.s   hv52
hv51        and.l   hvmask2(d5),d4
	    moveq   #0,d3
hv52        and.l   d4,d1
	    not.l   d4
	    and.l   d4,(a0)
	    or.l    d1,(a0)+
	    dbra    d3,hv53
	    bra     rts
hv53        moveq   #-1,d4
	    move.l  d0,d1
	    tst     d3
	    beq.s   hv51
	    subq    #1,d3
hv54        move.l  d0,(a0)+
	    dbra    d3,hv54
	    bra.s   hv51


hvmask1     dc.l   $ffffffff
	    dc.l   $00ffffff
	    dc.l   $0000ffff
	    dc.l   $000000ff

hvmask2     dc.l   $ff000000
	    dc.l   $ffff0000
	    dc.l   $ffffff00
	    dc.l   $ffffffff


	    page
****************************************************************************
*
* DEFINE_DRAWING_MODE ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*   Modes are:
*     INFO1 = 0 - Dominant
*           = 1 - Erase
*           = 2 - Non-dominant
*           = 3 - Complement
*
gle_aras_out_rdefine_drawing_mode equ *
*
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep_gcb

	    move.l  info1(gle_gcb),d0               d0 = new drawing mode
	    move.w  d0,current_drawing_mode(gle_gcb)
	    bra     set_pen

****************************************************************************
*
* SET_COLOR ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*   Color index is in INFO1
*
*   Note:  Colors are assigned as follows on non-color map units:
*          INFO1 = 0 - Undefined
*                  1 - White
*                  2 - Red
*                  3 - Yellow
*                  4 - Green
*                  5 - Cyan
*                  6 - Blue
*                  7 - Magenta
*
*          On color map units, the pen number is the index to the CMAP
*
gle_aras_out_rset_color equ *
*
	    movea.l 4(sp),gle_gcb                 a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb

	    move.w  info1+2(gle_gcb),current_color_index(gle_gcb)

	    bra     set_pen

****************************************************************************
*
* LINESTYLE ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*   INFO1 = Linestyle index (saved only by raster devices)
*   INFO2 = Pattern length, % of min and max display values
*   INFO3 = Linestyle mode  (saved only by these devices)
*   INFO4 = Raster pattern  (16 bit value)
*
gle_aras_out_rlinestyle equ *
*
	    movea.l 4(sp),gle_gcb                      a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb     a6 = dev_dep_gcb

	    move.w  info1+2(gle_gcb),current_linestyle(gle_gcb)

	    move.w  info2+2(gle_gcb),d0
	    move.w  d0,current_pattern_length(gle_gcb)
	    muls    hard_xmax(rgl_gcb),d0
	    divs    #1600,d0
	    bgt.s   ls_1
	    moveq   #1,d0
ls_1        move.w  d0,repeatrate(rgl_gcb)

	    move.w  info3+2(gle_gcb),current_linestyle_mode(gle_gcb)
	    move.w  info4+2(gle_gcb),current_linestyle_pattern(gle_gcb)

	    bsr     build_pen
	    bra     set_pen

************************************************************************
*
moon_map    dc.b    0             0
	    dc.b    7             1  white
	    dc.b    1             2  red
	    dc.b    3             3  yellow
	    dc.b    2             4  green
	    dc.b    6             5  cyan
	    dc.b    4             6  blue
	    dc.b    5             7  magenta

***********************************************************************
*
*    build_pen
*
*    This procedure takes devicetype, and linestyle and generates
*    the 68000 instructions for the vector generator.  The code
*    space for the vector generator is in the GCB, so that nothing
*    in this segment will modify itself.
*

build_pen   equ *                              | build first template
c_set2      move.w  #0,pen_draw_mode(rgl_gcb)
	    move.w  #1,pen_num(rgl_gcb)
	    move    devicetype(rgl_gcb),d0
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
*           bne.s   skip_notgat
	    blt.s   skip_notgat
	    move    #3,d0         gator/gatorbox/bobcat -- reset d0 like 36c
skip_notgat lsl     #2,d0
	    cmpi    #-1,current_linestyle_pattern(gle_gcb)  ck linestyle
	    bne.s   fixpatternx1
	    bra.s   fixpattern1                | else create solid vec gen.

ztable      dc.w    template1-ztable
	    dc.w    template2-ztable
	    dc.w    template1-ztable
	    dc.w    template2-ztable
	    dc.w    template3-ztable
	    dc.w    template4-ztable
	    dc.w    template5-ztable
	    dc.w    template6-ztable

*                                          d0 = 0 9826 (bit/pixel odd bytes)
*                                               4 9836A (bit/pixel all bytes)
*                                               8 98627A (multi-plane)
*                                              12 9836C (byte-per-pixel)

fixpatternx1 addq   #2,d0
fixpattern1 movea   ztable(d0),a0          a0 = offset ptable to template
	    lea     ztable(a0),a0          a0 = address of template
	    lea     softvec(rgl_gcb),a1    a1 = address of ram area
	    moveq   #12,d1                 d1 = counter

* copy the template vector generator into ram.

loadtmplt   move.l  (a0)+,(a1)+
	    move.l  (a0)+,(a1)+
	    move.l  (a0)+,(a1)+
	    move.l  (a0)+,(a1)+
	    move.l  (a0)+,(a1)+
	    subq    #1,d1
	    bgt     loadtmplt
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    rts
******************************************************************************
*
*    set_pen
*
*    This procedure takes devicetype, current_linestyle_pattern, pen_num
*    and drawing_mode and modifies the current vector generator code.
*    The code space for the vector generator is in the GCB, so that
*    nothing in this segment will modify itself.

*    If the current pen color matches the previous pen color,
*    this routine will just rts.  If you want to make sure
*    this routine builds something in the softvec area, put a 0
*    in oldpattern.
*
set_pen     equ *
	    move.w  current_drawing_mode(gle_gcb),d0
	    move.w  current_color_index(gle_gcb),d1

	    cmpi.w  #2,devicetype(rgl_gcb)   ck for moonunit
	    bne.s   c_set1s
	    move.b  moon_map(d1),d1          remap for moonunit
c_set1s     tst.b   d1                       ck for color 0
	    bne.s   c_set2s
	    moveq   #1,d0                    force drawing mode to erase
	    move.l  gamut(gle_gcb),d1        set pen number to max
c_set2s     move.w  d0,pen_draw_mode(rgl_gcb)
	    move.w  d1,pen_num(rgl_gcb)
	    move    d0,d3
	    add     d3,d3
	    move    devicetype(rgl_gcb),d0
*cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
*bne.s   ckbitmap2
*move    #4,d0
*bra.s   skip_nogat
*ckbitmap2   equ     *
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
	    blt.s   skip_nogat
	    move    #3,d0          gator/gatorbox/bobcat -- reset d0 like 36c
skip_nogat  lsl     #2,d0
	    cmpi    #-1,current_linestyle_pattern(gle_gcb)
	    beq.s   fixpatterns
	    addq    #2,d0

fixpatterns equ *
fixcolor    add     d0,d0
	    jmp     fixc(d0)
fixc        jmp     fixc1
	    jmp     fixc2
	    jmp     fixc1
	    jmp     fixc2
	    jmp     fixc3
	    jmp     fixc4
	    jmp     fixc5
	    jmp     fixc6

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


***********************************************
*
* patch up bw solid vector generator
*
***********************************************

fixc1       move    fixc1table(d3),d1
	    move    d1,softvec+26(rgl_gcb)
	    move    d1,softvec+56(rgl_gcb)
	    move    d1,softvec+92(rgl_gcb)
	    move    d1,softvec+122(rgl_gcb)
	    moveq   #$64,d1                    bcc instruction
	    move    #$4e71,softvec(rgl_gcb)         nop instruction
	    subq    #2,d3
	    bne.s   fixd1
	    moveq   #$65,d1
	    move    #$4600,softvec(rgl_gcb)         not d0 instruction
fixd1       move.b  d1,softvec+34(rgl_gcb)
	    move.b  d1,softvec+70(rgl_gcb)
	    move.b  d1,softvec+100(rgl_gcb)
	    move.b  d1,softvec+136(rgl_gcb)
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts

fixc1table  or.b    d0,(a0)                    dominant
	    and.b   d0,(a0)                    erase
	    or.b    d0,(a0)                    non-dominant (same)
	    eor.b   d0,(a0)                    compliment

***********************************************
*
* fix up bw dashed generator
*
***********************************************

fixc2       move    fixc1table(d3),d1
	    move    d1,softvec+30(rgl_gcb)
	    move    d1,softvec+72(rgl_gcb)
	    move    d1,softvec+120(rgl_gcb)
	    move    d1,softvec+162(rgl_gcb)
	    moveq   #$64,d1                    bcc instruction
	    move    #$4e71,softvec(rgl_gcb)         nop instruction
	    subq    #2,d3
	    bne.s   fixd2
	    moveq   #$65,d1                    bcs instruction
	    move    #$4600,softvec(rgl_gcb)         not d0 instruction
fixd2       move.b  d1,softvec+46(rgl_gcb)
	    move.b  d1,softvec+94(rgl_gcb)
	    move.b  d1,softvec+136(rgl_gcb)
	    move.b  d1,softvec+184(rgl_gcb)
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts

***********************************************
*
* fix up moon solid vector generator
*
***********************************************

fixc3       move    cblu(d3),d0
	    btst    #2,pen_num+1(rgl_gcb)
	    bne.s   fx3_10
	    move    cblu+8,d0
	    tst     d3
	    bne.s   fx3_10
	    move    cblu+2,d0
fx3_10      add     d3,d3
	    move.l  cgrn(d3),d1
	    move.l  cred(d3),d2
	    btst    #1,pen_num+1(rgl_gcb)
	    bne.s   fx3_20
	    move.l  cgrn+16,d1
	    tst     d3
	    bne.s   fx3_20
	    move.l  cgrn+4,d1
fx3_20      btst    #0,pen_num+1(rgl_gcb)
	    bne.s   fx3_30
	    move.l  cred+16,d2
	    tst     d3
	    bne.s   fx3_30
	    move.l  cred+4,d2
fx3_30      lea     softvec+24(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+64(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+110(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+150(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts

cblu        or.b    d0,(a0)                    dominant
	    and.b   d1,(a0)                    erase
	    or.b    d0,(a0)                    non-dominant
	    eor.b   d0,(a0)                    compliment
	    nop

cgrn        or.b    d0,0(a0,a2.l)
	    and.b   d1,0(a0,a2.l)
	    or.b    d0,0(a0,a2.l)
	    eor.b   d0,0(a0,a2.l)
	    nop
	    nop

cred        or.b    d0,0(a0,a3.l)
	    and.b   d1,0(a0,a3.l)
	    or.b    d0,0(a0,a3.l)
	    eor.b   d0,0(a0,a3.l)
	    nop
	    nop

***********************************************
*
* fix up moon dashed generator
*
***********************************************

fixc4       move    cblu(d3),d0
	    btst    #2,pen_num+1(rgl_gcb)
	    bne.s   fx4_10
	    move    cblu+8,d0
	    tst     d3
	    bne.s   fx4_10
	    move    cblu+2,d0
fx4_10      add     d3,d3
	    move.l  cgrn(d3),d1
	    move.l  cred(d3),d2
	    btst    #1,pen_num+1(rgl_gcb)
	    bne.s   fx4_20
	    move.l  cgrn+16,d1
	    tst     d3
	    bne.s   fx4_20
	    move.l  cgrn+4,d1
fx4_20      btst    #0,pen_num+1(rgl_gcb)
	    bne.s   fx4_30
	    move.l  cred+16,d2
	    tst     d3
	    bne.s   fx4_30
	    move.l  cred+4,d2
fx4_30      lea     softvec+28(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+80(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+138(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+190(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts

***********************************************
*
*  fix up 9836c solid lines (also gatorbox and bobcats)
*
***********************************************

fixc5       move    pen_num(rgl_gcb),d0
	    cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
	    bne     fixc5_a
	    addq    #8,d3       move pointer down to bobcat lores opcodes
	    move.w  addq2,softvec+24(rgl_gcb)  adjust address inc/dec opcodes
	    move.w  subq2,softvec+66(rgl_gcb)
	    move.w  addq2,softvec+126(rgl_gcb)
fixc5_a     equ     *
	    move    color36c(d3),d2
	    move    d2,softvec+52(rgl_gcb)
	    move    d2,softvec+112(rgl_gcb)
	    move    color36c2(d3),d2
	    move    d2,softvec+26(rgl_gcb)
	    move    color36c3(d3),d2
	    move    d2,softvec+86(rgl_gcb)
	    cmpi    #1,pen_draw_mode(rgl_gcb)
	    bne     fx5_10
	    not.b   d0
fx5_10      move    d0,cpen(rgl_gcb)
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts

color36c    move.b  d0,(a0)
	    and.b   d0,(a0)
	    or.b    d0,(a0)
	    eor.b   d0,(a0)
	    move.w  d0,(a0)     bobcat lores opcode
	    and.w   d0,(a0)     bobcat lores opcode
	    or.w    d0,(a0)     bobcat lores opcode
	    eor.w   d0,(a0)     bobcat lores opcode

color36c2   move.b  d0,-(a0)
	    and.b   d0,-(a0)
	    or.b    d0,-(a0)
	    eor.b   d0,-(a0)
	    move.w  d0,-(a0)     bobcat lores opcode
	    and.w   d0,-(a0)     bobcat lores opcode
	    or.w    d0,-(a0)     bobcat lores opcode
	    eor.w   d0,-(a0)     bobcat lores opcode

color36c3   move.b  d0,(a0)+
	    and.b   d0,(a0)+
	    or.b    d0,(a0)+
	    eor.b   d0,(a0)+
	    move.w  d0,(a0)+     bobcat lores opcode
	    and.w   d0,(a0)+     bobcat lores opcode
	    or.w    d0,(a0)+     bobcat lores opcode
	    eor.w   d0,(a0)+     bobcat lores opcode

addq2       addq    #2,a0        opcode is addq #2,a0
subq2       subq    #2,a0        opcode is subq #2,a0

***********************************************
*
*  fix up 9836c dashed lines (also gatorbox and bobcats)
*
***********************************************

fixc6       move    pen_num(rgl_gcb),d0
	    cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
	    bne     fixc6_a
	    addq    #8,d3       move pointer down to bobcat lores opcodes
	    move.w  subq2,softvec+42(rgl_gcb)  adjust address inc/dec opcodes
	    move.w  subq2,softvec+86(rgl_gcb)
	    move.w  addq2,softvec+124(rgl_gcb)  3.1C BUGFIX 5/22/85--SFB
	    move.w  addq2,softvec+168(rgl_gcb)
fixc6_a     equ     *
	    move    color36c(d3),d2
	    move    d2,softvec+28(rgl_gcb)
	    move    d2,softvec+66(rgl_gcb)
	    move    d2,softvec+110(rgl_gcb)
	    move    d2,softvec+148(rgl_gcb)
	    cmpi    #1,pen_draw_mode(rgl_gcb)       if erase then
	    bne     fx6_10
	    not.b   d0                         invert pen number
fx6_10      move    d0,cpen(rgl_gcb)
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts
	    page

************************************************************************
*
* these are the 6 templates for vector generators.  the six cases are:
*
*    template1 - monochrome / solid line
*    template2 - monochrome / dashed line
*    template3 - moonunit   / solid line
*    template4 - moonunit   / dashed line
*    template5 - 9836C      / solid line
*    template6 - 9836C      / dashed line
*
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 1 - bw / solid line                                     *
*                                                                      *
************************************************************************
************************************************************************

template1   nop                                                0
	    tst     d5         tst (x2-x1)                     2
	    bgt.s   incx1                                      4
	    neg     d5         d5 = abs(x2-x1)                 6
	    cmp     d5,d2      x major or y major ?            8
	    bgt.s   case13     y major/decrement x            10
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case14      tst     d5                                        12
	    beq.s   loop14                                    14
	    swap    d2         d2 = [(y2-y1) :    0 ]         16
	    clr     d2                                        18
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           20
	    bvc.s   loop14                                    22
	    moveq   #-1,d2                                    24
loop14      or.b    d0,(a0)  .................................26
	    subq    #1,d5                                     28
	    blt.s   endvec1                                   30
	    rol.b   #1,d0    .................................32
	    bcc.s   next14   .................................34
	    suba    d6,a0                                     36
next14      add     d2,d3      sum = sum + frac               38
	    bcc     loop14                                    40
	    suba    a1,a0      inc y                          42
	    bra     loop14                                    44
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case13      swap    d5                                        46
	    clr     d5                                        48
	    divu    d2,d5      d5=frac=(x2-x1)/(y2-y1)        50
	    bvc.s   loop13                                    52
	    moveq   #-1,d5                                    54
loop13      or.b    d0,(a0)    ...............................56
	    subq    #1,d2      pixel_count = pixel_count - 1  58
	    blt.s   endvec1    if pixel_count<0 ; goto endvec 60
	    suba    a1,a0      increment y                    62
	    add     d5,d3      sum = sum + frac               64
	    bcc     loop13     if sum < 1 then goto loop3     66
	    rol.b   #1,d0      ...............................68
	    bcc     loop13     ...............................70
	    suba    d6,a0                                     72
	    bra     loop13                                    74
endvec1     rts                                               76
incx1       cmp     d5,d2                                     78
	    bgt.s   case11                                    80
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case12      swap    d2                                        82
	    clr     d2                                        84
	    divu    d5,d2      d2 = frac                      86
	    bvc.s   loop12                                    88
	    moveq   #-1,d2                                    90
loop12      or.b    d0,(a0)   ................................92
	    subq    #1,d5                                     94
	    blt.s   endvec1                                   96
	    ror.b   #1,d0     ................................98
	    bcc.s   next12    ...............................100
	    adda    d6,a0                                    102
next12      add     d2,d3      sum = sum + frac              104
	    bcc     loop12                                   106
	    suba    a1,a0                                    108
	    bra     loop12                                   110
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case11      swap    d5                                       112
	    clr     d5                                       114
	    divu    d2,d5                                    116
	    bvc.s   loop11                                   118
	    moveq   #-1,d5                                   120
loop11      or.b    d0,(a0)  ................................122
	    subq    #1,d2                                    124
	    blt.s   endvec1                                  126
	    suba    a1,a0                                    128
	    add     d5,d3                                    130
	    bcc     loop11                                   132
	    ror.b   #1,d0                                    134
	    bcc     loop11   ................................136
	    adda    d6,a0                                    138
	    bra     loop11                                   140
	    page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 2 - bw / dashed line                                    *
*                                                                      *
************************************************************************
************************************************************************

template2   nop                                                0
	    tst     d5         tst (x2-x1)                     2
	    bgt.s   incx2                                      4
	    neg     d5         d5 = abs(x2-x1)                 6
	    cmp     d5,d2      x major or y major ?            8
	    bgt.s   case23     y major/decrement x            10
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case24      tst     d5                                        12
	    beq.s   loop24                                    14
	    swap    d2         d2 = [(y2-y1) :    0 ]         16
	    clr     d2                                        18
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           20
	    bvc.s   loop24                                    22
	    moveq   #-1,d2                                    24
loop24      tst     d4         if bit 7 of pattern is set     26
	    bpl.s   skip24       then skip - the pen is up    28
	    or.b    d0,(a0)      else draw - the pen is down  30
skip24      subq    #1,d5      pixel_count := pixel_count-1   32
	    blt.s   endvec2                                   34
	    subq    #1,d7      decrement repeatcount          36
	    bne.s   ok24                                      38
	    move    a5,d7                                     40
	    rol     #1,d4                                     42
ok24        rol.b   #1,d0                                     44
	    bcc.s   next24     ...............................46
	    suba    d6,a0                                     48
next24      add     d2,d3      sum = sum + frac               50
	    bcc     loop24                                    52
	    suba    a1,a0      inc y                          54
	    bra     loop24                                    56
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case23      swap    d5                                        58
	    clr     d5                                        60
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    62
	    bvc.s   loop23                                    64
	    moveq   #-1,d5                                    66
loop23      tst     d4         if bit 7 of pattern is set     68
	    bpl.s   skip23                                    70
	    or.b    d0,(a0)    turn on pixel (x,y)            72
skip23      subq    #1,d2      pixel_count = pixel_count - 1  74
	    blt.s   endvec2    if pixel_count<0 ;goto endvec  76
	    subq    #1,d7      decrement repeatcount          78
	    bne.s   ok23                                      80
	    move    a5,d7                                     82
	    rol     #1,d4                                     84
ok23        suba    a1,a0      increment y                    86
	    add     d5,d3      sum = sum + frac               88
	    bcc     loop23     if sum < 1 then goto loop3     90
	    rol.b   #1,d0      x = x - 1                      92
	    bcc     loop23     ...............................94
	    suba    d6,a0                                     96
	    bra     loop23                                    98
endvec2     rts                                              100
incx2       cmp     d5,d2                                    102
	    bgt.s   case21                                   104
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case22      swap    d2                                       106
	    clr     d2                                       108
	    divu    d5,d2      d2 = frac                     110
	    bvc.s   loop22                                   112
	    moveq   #-1,d2                                   114
loop22      tst     d4                                       116
	    bpl.s   skip22                                   118
	    or.b    d0,(a0)    ..............................120
skip22      subq    #1,d5                                    122
	    blt.s   endvec2                                  124
	    subq    #1,d7      decrement repeatcount         126
	    bne.s   ok22                                     128
	    move    a5,d7                                    130
	    rol     #1,d4                                    132
ok22        ror.b   #1,d0                                    134
	    bcc.s   next22     ..............................136
	    adda    d6,a0                                    138
next22      add     d2,d3      sum = sum + frac              140
	    bcc     loop22                                   142
	    suba    a1,a0                                    144
	    bra     loop22                                   146
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case21      swap    d5                                       148
	    clr     d5                                       150
	    divu    d2,d5                                    152
	    bvc.s   loop21                                   154
	    moveq   #-1,d5                                   156
loop21      tst     d4                                       158
	    bpl.s   skip21                                   160
	    or.b    d0,(a0)    ..............................162
skip21      subq    #1,d2                                    164
	    blt.s   endvec2                                  166
	    subq    #1,d7      decrement repeatcount         168
	    bne.s   ok21                                     170
	    move    a5,d7                                    172
	    rol     #1,d4                                    174
ok21        suba    a1,a0                                    176
	    add     d5,d3                                    178
	    bcc     loop21                                   180
	    ror.b   #1,d0                                    182
	    bcc     loop21     ..............................184
	    adda    d6,a0                                    186
	    bra     loop21                                   188
	    page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 3 - moonunit / solid line                               *
*                                                                      *
************************************************************************
************************************************************************

template3   tst     d5         tst (x2-x1)                     0
	    bgt.s   incx3                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case33     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case34      tst     d5                                        10
	    beq.s   loop34                                    12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   loop34                                    20
	    moveq   #-1,d2                                    22
loop34      or.b    d0,(a0)       ............................24
	    or.b    d0,0(a0,a2.l) ............................26
	    or.b    d0,0(a0,a3.l) ............................30
	    subq    #1,d5                                     34
	    blt.s   endvec3                                   36
	    rol.b   #1,d1                                     38
	    rol.b   #1,d0                                     40
	    bcc.s   next34                                    42
	    suba    d6,a0                                     44
next34      add     d2,d3      sum = sum + frac               46
	    bcc     loop34                                    48
	    suba    a1,a0      inc y                          50
	    bra     loop34                                    52
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case33      swap    d5                                        54
	    clr     d5                                        56
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    58
	    bvc.s   loop33                                    60
	    moveq   #-1,d5                                    62
loop33      or.b    d0,(a0)    turn on pixel (x,y)............64
	    or.b    d0,0(a0,a2.l) ............................66
	    or.b    d0,0(a0,a3.l) ............................70
	    subq    #1,d2      pixel_count = pixel_count - 1  74
	    blt.s   endvec3    if pixel_count<0 ; goto endvec 76
	    suba    a1,a0      increment y                    78
	    add     d5,d3      sum = sum + frac               80
	    bcc     loop33     if sum < 1 then goto loop3     82
	    rol.b   #1,d1                                     84
	    rol.b   #1,d0      x = x - 1                      86
	    bcc     loop33                                    88
	    suba    d6,a0                                     90
	    bra     loop33                                    92
endvec3     rts                                               94
incx3       cmp     d5,d2                                     96
	    bgt.s   case31                                    98

* x major / inc x

* rule: always increment x / maybe increment y

case32      swap    d2                                       100
	    clr     d2                                       102
	    divu    d5,d2      d2 = frac                     104
	    bvc.s   loop32                                   106
	    moveq   #-1,d2                                   108
loop32      or.b    d0,(a0)       ...........................110
	    or.b    d0,0(a0,a2.l) ...........................112
	    or.b    d0,0(a0,a3.l) ...........................116
	    subq    #1,d5                                    120
	    blt.s   endvec3                                  122
	    ror.b   #1,d1                                    124
	    ror.b   #1,d0                                    126
	    bcc.s   next32                                   128
	    adda    d6,a0                                    130
next32      add     d2,d3      sum = sum + frac              132
	    bcc     loop32                                   134
	    suba    a1,a0                                    136
	    bra     loop32                                   138
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case31      swap    d5                                       140
	    clr     d5                                       142
	    divu    d2,d5                                    144
	    bvc.s   loop31                                   146
	    moveq   #-1,d5                                   148
loop31      or.b    d0,(a0)       ...........................150
	    or.b    d0,0(a0,a2.l) ...........................152
	    or.b    d0,0(a0,a3.l) ...........................156
	    subq    #1,d2                                    160
	    blt.s   endvec3                                  162
	    suba    a1,a0                                    164
	    add     d5,d3                                    166
	    bcc     loop31                                   168
	    ror.b   #1,d1                                    170
	    ror.b   #1,d0                                    172
	    bcc     loop31                                   174
	    adda    d6,a0                                    176
	    bra     loop31                                   178
	    page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 4 - moonunit / dashed lines                             *
*                                                                      *
************************************************************************
************************************************************************

template4   tst     d5         tst (x2-x1)                     0
	    bgt.s   incx4                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case43     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case44      tst     d5                                        10
	    beq.s   loop44                                    12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   loop44                                    20
	    moveq   #-1,d2                                    22
loop44      tst     d4                                        24
	    bpl.s   skip44                                    26
	    or.b    d0,(a0)       ............................28
	    or.b    d0,0(a0,a2.l) ............................30
	    or.b    d0,0(a0,a3.l) ............................34
skip44      subq    #1,d5                                     38
	    blt.s   endvec4                                   40
	    subq    #1,d7                                     42
	    bne.s   ok44                                      44
	    move    a5,d7                                     46
	    rol     #1,d4                                     48
ok44        rol.b   #1,d1                                     50
	    rol.b   #1,d0                                     52
	    bcc.s   next44                                    54
	    suba    d6,a0                                     56
next44      add     d2,d3      sum = sum + frac               58
	    bcc     loop44                                    60
	    suba    a1,a0      inc y                          62
	    bra     loop44                                    64
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case43      swap    d5                                        66
	    clr     d5                                        68
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    70
	    bvc.s   loop43                                    72
	    moveq   #-1,d5                                    74
loop43      tst     d4                                        76
	    bpl.s   skip43                                    78
	    or.b    d0,(a0)    turn on pixel (x,y) ...........80
	    or.b    d0,0(a0,a2.l) ............................82
	    or.b    d0,0(a0,a3.l) ............................86
skip43      subq    #1,d2      pixel_count = pixel_count - 1  90
	    blt.s   endvec4    if pixel_count<0 ;goto endvec  92
	    subq    #1,d7                                     94
	    bne.s   ok43                                      96
	    move    a5,d7                                     98
	    rol     #1,d4                                    100
ok43        suba    a1,a0      increment y                   102
	    add     d5,d3      sum = sum + frac              104
	    bcc     loop43     if sum < 1 then goto loop3    106
	    rol.b   #1,d1                                    108
	    rol.b   #1,d0      x = x - 1                     110
	    bcc     loop43                                   112
	    suba    d6,a0                                    114
	    bra     loop43                                   116
endvec4     rts                                              118
incx4       cmp     d5,d2                                    120
	    bgt.s   case41                                   122
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case42      swap    d2                                       124
	    clr     d2                                       126
	    divu    d5,d2      d2 = frac                     128
	    bvc.s   loop42                                   130
	    moveq   #-1,d2                                   132
loop42      tst     d4                                       134
	    bpl.s   skip42                                   136
	    or.b    d0,(a0)     .............................138
	    or.b    d0,0(a0,a2.l)                            140
	    or.b    d0,0(a0,a3.l)                            144
skip42      subq    #1,d5                                    148
	    blt.s   endvec4                                  150
	    subq    #1,d7                                    152
	    bne.s   ok42                                     154
	    move    a5,d7                                    156
	    rol     #1,d4                                    158
ok42        ror.b   #1,d1                                    160
	    ror.b   #1,d0                                    162
	    bcc.s   next42                                   164
	    adda    d6,a0                                    166
next42      add     d2,d3      sum = sum + frac              168
	    bcc     loop42                                   170
	    suba    a1,a0                                    172
	    bra     loop42                                   174
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case41      swap    d5                                       176
	    clr     d5                                       178
	    divu    d2,d5                                    180
	    bvc.s   loop41                                   182
	    moveq   #-1,d5                                   184
loop41      tst     d4                                       186
	    bpl.s   skip41                                   188
	    or.b    d0,(a0)       ...........................190
	    or.b    d0,0(a0,a2.l) ...........................192
	    or.b    d0,0(a0,a3.l) ...........................196
skip41      subq    #1,d2                                    200
	    blt.s   endvec4                                  202
	    subq    #1,d7                                    204
	    bne.s   ok41                                     206
	    move    a5,d7                                    208
	    rol     #1,d4                                    210
ok41        suba    a1,a0                                    212
	    add     d5,d3                                    214
	    bcc     loop41                                   216
	    ror.b   #1,d1                                    218
	    ror.b   #1,d0                                    220
	    bcc     loop41                                   222
	    adda    d6,a0                                    224
	    bra     loop41                                   226

	    page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 5 - 9836C / solid line                                  *
*                                                                      *
************************************************************************
************************************************************************

template5   tst     d5         tst (x2-x1)                     0
	    bgt.s   incx5                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case53     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case54      tst     d5                                        10
	    beq.s   before54                                  12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   before54                                  20
	    moveq   #-1,d2                                    22
before54    addq    #1,a0                                     24
loop54      move.b  d0,-(a0) .................................26
	    dbra    d5,next54                                 28
	    bra.s   endvec5                                   32
next54      add     d2,d3      sum = sum + frac               34
	    bcc     loop54                                    36
	    suba    a1,a0      inc y                          38
	    bra     loop54                                    40
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case53      swap    d5                                        42
	    clr     d5                                        44
	    divu    d2,d5      d5=frac=(x2-x1)/(y2-y1)        46
	    bvc.s   loop53                                    48
	    moveq   #-1,d5                                    50
loop53      move.b  d0,(a0)    ...............................52
	    dbra    d2,next53  pixel_count = pixel_count - 1  54
	    bra.s   endvec5    if pixel_count<0 ; goto endvec 58
next53      suba    a1,a0      increment y                    60
	    add     d5,d3      sum = sum + frac               62
	    bcc     loop53     if sum < 1 then goto loop3     64
	    subq    #1,a0                                     66
	    bra     loop53                                    68
endvec5     rts                                               70
incx5       cmp     d5,d2                                     72
	    bgt.s   case51                                    74
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case52      swap    d2                                        76
	    clr     d2                                        78
	    divu    d5,d2      d2 = frac                      80
	    bvc.s   loop52                                    82
	    moveq   #-1,d2                                    84
loop52      move.b  d0,(a0)+  ................................86
	    dbra    d5,next52                                 88
	    bra.s   endvec5                                   92
next52      add     d2,d3      sum = sum + frac               94
	    bcc     loop52                                    96
	    suba    a1,a0                                     98
	    bra     loop52                                   100
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case51      swap    d5                                       102
	    clr     d5                                       104
	    divu    d2,d5                                    106
	    bvc.s   loop51                                   108
	    moveq   #-1,d5                                   110
loop51      move.b  d0,(a0)  ................................112
	    dbra    d2,next51                                114
	    bra.s   endvec5                                  118
next51      suba    a1,a0                                    120
	    add     d5,d3                                    122
	    bcc     loop51                                   124
	    addq    #1,a0                                    126
	    bra     loop51                                   128
	    page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 6 - 9836C / dashed line                                 *
*                                                                      *
************************************************************************
************************************************************************

template6   tst     d5         tst (x2-x1)                     0
	    bgt.s   incx6                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case63     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case64      tst     d5                                        10
	    beq.s   loop64                                    12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   loop64                                    20
	    moveq   #-1,d2                                    22
loop64      tst     d4         if bit 7 of pattern is set     24
	    bpl.s   skip64       then skip                    26
	    move.b  d0,(a0)      else draw ...................28
skip64      subq    #1,d5      pixel_count := pixel_count-1   30
	    blt.s   endvec6                                   32
	    subq    #1,d7      decrement repeatcount          34
	    bne.s   ok64                                      36
	    move    a5,d7                                     38
	    rol     #1,d4                                     40
ok64        subq    #1,a0                                     42
next64      add     d2,d3      sum = sum + frac               44
	    bcc     loop64                                    46
	    suba    a1,a0      inc y                          48
	    bra     loop64                                    50
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case63      swap    d5                                        52
	    clr     d5                                        54
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    56
	    bvc.s   loop63                                    58
	    moveq   #-1,d5                                    60
loop63      tst     d4         if bit 7 of pattern is set     62
	    bpl.s   skip63                                    64
	    move.b  d0,(a0)    turn on pixel (x,y) ...........66
skip63      subq    #1,d2      pixel_count = pixel_count - 1  68
	    blt.s   endvec6    if pixel_count<0 ;goto endvec  70
	    subq    #1,d7      decrement repeatcount          72
	    bne.s   ok63                                      74
	    move    a5,d7                                     76
	    rol     #1,d4                                     78
ok63        suba    a1,a0      increment y                    80
	    add     d5,d3      sum = sum + frac               82
	    bcc     loop63     if sum < 1 then goto loop3     84
	    subq    #1,a0                                     86
	    bra     loop63                                    88
endvec6     rts                                               90
incx6       cmp     d5,d2                                     92
	    bgt.s   case61                                    94
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case62      swap    d2                                        96
	    clr     d2                                        98
	    divu    d5,d2      d2 = frac                     100
	    bvc.s   loop62                                   102
	    moveq   #-1,d2                                   104
loop62      tst     d4                                       106
	    bpl.s   skip62                                   108
	    move.b  d0,(a0)    ..............................110
skip62      subq    #1,d5                                    112
	    blt.s   endvec6                                  114
	    subq    #1,d7      decrement repeatcount         116
	    bne.s   ok62                                     118
	    move    a5,d7                                    120
	    rol     #1,d4                                    122
ok62        addq    #1,a0                                    124
next62      add     d2,d3      sum = sum + frac              126
	    bcc     loop62                                   128
	    suba    a1,a0                                    130
	    bra     loop62                                   132
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case61      swap    d5                                       134
	    clr     d5                                       136
	    divu    d2,d5                                    138
	    bvc.s   loop61                                   140
	    moveq   #-1,d5                                   142
loop61      tst     d4                                       144
	    bpl.s   skip61                                   146
	    move.b  d0,(a0)    ..............................148
skip61      subq    #1,d2                                    150
	    blt.s   endvec6                                  152
	    subq    #1,d7      decrement repeatcount         154
	    bne.s   ok61                                     156
	    move    a5,d7                                    158
	    rol     #1,d4                                    160
ok61        suba    a1,a0                                    162
	    add     d5,d3                                    164
	    bcc     loop61                                   166
	    addq    #1,a0                                    168
	    bra     loop61                                   170
	    page


waitcatready equ    *           assumes a0=deviceaddress        SFB
	    btst    #0,catseye_status+1(a0)                     SFB
	    bne     waitcatready
	    rts
*
*  procedure area_fill(gcb:anyptr);
*

*
*  local temporaries
*
ybegin      equ     rgltemp1
yend        equ     rgltemp2
left_side   equ     addr3
ptable      equ     addr1
stable      equ     addr2
n           equ     n3

gle_aras_out_rpolygon equ *
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec ptr

	    move.l  info2(gle_gcb),d0               ck for solid fill
	    cmp     polygon_solid_fill(gle_gcb),d0  ignor call if not solid
	    bne     rts

	    move.l  info_ptr1(gle_gcb),addr1(rgl_gcb)
	    move.l  info_ptr2(gle_gcb),addr2(rgl_gcb)

	    move    clip_limits_ymin+2(gle_gcb),d0    make sure clip limits
	    cmp     clip_limits_ymax+2(gle_gcb),d0    allow something
	    bgt     rts

	    move    clip_limits_xmin+2(gle_gcb),d0
	    cmp     clip_limits_xmax+2(gle_gcb),d0
	    bgt     rts

	    move    area_draw_mode(rgl_gcb),d0
	    lsl     #3,d0
	    cmpi.b  #3,devicetype+1(rgl_gcb)            ck for 36c
	    beq.s   afc
	    blt.s   af_packed

	    cmpi.b  #5,devicetype+1(rgl_gcb)            ck for gatorbox
	    beq.s   afc

	    cmpi.b  #10,devicetype+1(rgl_gcb)       ck for WOODCUT CFB - 24JUL91
	    bge.s   afc                                            CFB - 24JUL91

	    bra.s   af_com                          Gator, don't do anything

af_packed   jmp     pickamode1(d0)
pickamode1  lea     fill_dom,a5
	    bra     af2
	    lea     fill_erase,a5
	    bra     af2
	    lea     fill_ndom,a5
	    bra     af2
	    lea     fill_erase,a5
	    bra.s   af2

afc         jmp     pickamode2(d0)
pickamode2  lea     f36c_dom,a5
	    bra     af2
	    lea     f36c_erase,a5
	    bra     af2
	    lea     f36c_ndom,a5
	    bra     af2
	    lea     f36c_erase,a5

af_com      equ *
af2         movea.l ptable(rgl_gcb),a0         a0 = address of end points
	    movea.l stable(rgl_gcb),a1         a1 = address of work area
	    movea   #32767,a3                  a3 = minimum y
	    moveq   #-1,d7                     d7 = maximum y
	    clr     n(rgl_gcb)
segmentloop move.l  (a0)+,d0                   d0 = n for this segment
	    add     d0,n(rgl_gcb)                   add this n to ntotal
	    movea.l a0,a2
buildloop   move.l  (a0)+,d2
	    move.l  (a0)+,d3                   (d2,d3) = (xi,yi)
	    subq    #1,d0                       decrement # of points
	    bne.s   buildnorm                  last point ?
	    exg     a0,a2                      yes: wrap around to x1,y1
buildnorm   move.l  (a0),d4
	    movea.l d4,a6
	    cmpa    a6,a6
	    bne     int_ovflow
	    move.l  4(a0),d5
	    movea.l d5,a6
	    cmpa    a6,a6
	    bne     int_ovflow
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  restore a6
	    cmp     d3,d5                      is y1 <= y2 ?
	    bge.s   y2big
	    exg     d3,d5
	    exg     d2,d4                      (d2,d3) = point with smaller y
y2big       cmp     clip_limits_ymin+2(gle_gcb),d3
	    bge.s   no_clip
	    cmp     clip_limits_ymin+2(gle_gcb),d5
	    blt.s   divok                      y is out of range: build entry
	    move    d4,d1                      d1 = x2
	    sub     d2,d1                      d1=x2-x1
	    bvs     int_ovflow
	    move    d3,d6                      d6 = y1
	    sub     clip_limits_ymin+2(gle_gcb),d6    d6 = ymin-y1
	    bvs     int_ovflow
	    neg     d6
	    muls    d6,d1                      d5=(x2-x1)(ymin-y1)
	    move    d5,d6                      d6=y2
	    sub     d3,d6                      d6=y2-y1
	    bvs     int_ovflow
	    divs    d6,d1                      d1=(x2-x1)(ymin-y1)/(y2-y1)
	    add     d1,d2                      d1=x1+(x2-x1)(ymin-y1)/(y2-y1)
	    move    clip_limits_ymin+2(gle_gcb),d3    y1=ymin
no_clip     cmp     a3,d3                      a3 = min(y1,ymin)
	    bge.s   buildm
	    movea   d3,a3
buildm      cmp     d5,d7                      d7 = max(y2,ymax)
	    bge.s   buildn
	    move    d5,d7
buildn      moveq   #0,d1                      d1 = flag
	    sub     d3,d5                      d5 = y2-y1
	    bvs     int_ovflow
	    sub     d2,d4                      d4 = x2-x1
	    bvs     int_ovflow
	    bge.s   x2big
	    neg     d4                         d4=abs(x2-x1)
	    addq    #2,d1                      set "dec x" bit in flag
x2big       cmp     d4,d5                      if |x2-x1|>=|y2-y1|;use y major
	    blt.s   xmajor                     otherwise use x major
	    addq    #1,d1                      set "y major" bit in flag
	    exg     d4,d5                      d4=max(dx,dy), d5=min(dx,dy)
xmajor      tst     d4
	    beq.s   div2                       dx=dy=0
	    swap    d5                         d5.l = min(dx,dy):0
	    clr     d5
	    divu    d4,d5                      d5 = frac
	    bvc.s   divok
div2        moveq   #-1,d5                     if ovflow or div by 0,d5=.99999
divok       move    d3,(a1)+                   stack y1
	    move    d2,(a1)+                   stack x1
	    move    d4,(a1)+                   stack m,# of pixels in vector
	    addq    #2,a1                      skip  x2
	    move    d5,(a1)+                   stack frac
	    move    #$8000,(a1)+               stack sum=.5000000
	    move    d1,(a1)+                   stack flag
	    tst     d0                         n=0 ?
	    bne     buildloop                  no: build next vector

	    movea.l a2,a0                      a0 points to next n
	    tst.l   (a0)                       test size of next segment
	    bgt     segmentloop                if > 0 then get next segment

	    move    a3,ybegin(rgl_gcb)
	    cmp     clip_limits_ymax+2(gle_gcb),d7
	    ble.s   saved7
	    move    clip_limits_ymax+2(gle_gcb),d7

saved7      move    d7,yend(rgl_gcb)
*
*  at this point, stable has been constructed, and the procedure is
*  ready to begin area filling.
*
	    move    ybegin(rgl_gcb),d1
	    cmp     clip_limits_ymax+2(gle_gcb),d1
	    bgt     rts
	    move    n_glines(rgl_gcb),d0
	    subq    #1,d0
	    sub     d1,d0
	    mulu    bytesperline(rgl_gcb),d0
	    movea.l plane1_addr(rgl_gcb),a0        ptr to addr
	    movea.l (a0),a0
	    adda.l  plane1_offset(rgl_gcb),a0      upper right display address
	    move    gspacing(rgl_gcb),d5
	    subq    #1,d5
	    adda.w  d5,a0                     adjust for 16/26 odd addressing
	    add.l   a0,d0
	    move.l  d0,left_side(rgl_gcb)
	    page
*
*  generate the x1---x2 pairs for each vector
*
*
new_line    equ     *
build_x     movea.l stable(rgl_gcb),a0
	    movea.l a0,a1
	    move    n(rgl_gcb),d5
*
*     a0=a1=beginning of this entry
bxy_loop    move    (a0)+,d0                   d0 = y1
	    cmp     ybegin(rgl_gcb),d0
	    beq.s   l10
	    adda    #12,a0                     skip rest of entry is stable
	    movea.l a0,a1
	    bra.s   nextv

l10         move    (a0)+,d0                   d0 = x1
	    move    (a0)+,d1                   d1 = m = # of pixels left - 1
	    addq    #2,a0                      skip x2 (it's trash right now)
	    move    (a0)+,d2                   d2 = frac
	    move    (a0)+,d3                   d3 = sum
	    move    (a0)+,d4                   d4 = flag
	    and     #3,d4                      mask xmaj/ymaj and inc/decx bits
	    add     d4,d4                      make it an offset
	    jmp     bumpxy(d4)
bumpxy      bra.s   majx_incx
	    bra.s   nextvector
	    bra.s   majx_decx
	    bra.s   nextvector

majx_incx   add     d2,d3                      sum = frac+sum
	    bcs.s   mxdix                      if sum overflowed: bump y
	    addq    #1,d0                      inc x2
	    subq    #1,d1                      dec m
	    bge     majx_incx
	    subq    #1,d0                      un-do the last increment
	    bra.s   nextvector

majx_decx   add     d2,d3                      sum = frac+sum
	    bcs.s   mxdix
	    subq    #1,d0                      dec x2
	    subq    #1,d1                      dec m
	    bge     majx_decx
	    addq    #1,d0                      un-do the last decrement
	    bra.s   nextvector

mxdix       sub     d2,d3                      undo the add which caused carry
nextvector  subq    #1,d1                      dec m ; m<0 all pixels filled
	    addq    #4,a1                      skip over y1,x1 in stable
	    move    d1,(a1)+                   stack m
	    move    d0,(a1)+                   stack x2
	    addq    #2,a1                      skip over frac
	    move    d3,(a1)+                   stack new sum
	    lsr     #1,d4                      set flag active bit true (0)
	    move    d4,(a1)+                   stack flag
nextv       subq    #1,d5                      n=n-1
	    bgt     bxy_loop
	    page
*
*  mvdw_loop  this section takes the (x1,x2) pairs for each vector
*             and uses them to fill the line.  the rule is:
*              (1) move to odd vectors
*              (2) draw to even vectors
*              (3) ignore the last y of every vector when performing
*                  rules (1) and (2)
*              (4) for all vectors which end on the current y,
*                  fill in the vector itself.
*
mvdw_loop   bsr     find_min      d5,d6 = x1,x2 of leftmost active vector
*                                 the vector is marked dead by find_min
	    beq.s   fill_point    if no points were active, then finish line
	    move    d5,d7         save minimum x in d7
	    movea   d6,a2
	    bsr     find_min      d5,d6 = x1,x2 of leftmost active vector
	    beq.s   fill_point
	    move    d7,d0         d0 = x to start filling at
	    move    a2,d1
	    cmp     d6,d1         d1 = x to end filling at
	    bgt.s   mvdw1
	    move    d6,d1
mvdw1       bsr     fill          fill the area between the two vectors
	    bra     mvdw_loop

* when the segments between all vector pairs have been filled, fill
* the vector itself if this is the last line on which the vector exists.

fill_point  movea.l stable(rgl_gcb),a3
	    move    n(rgl_gcb),d7      d7 = number of vectors
fill_ptlp   move    (a3),d2       d2 = y for this vector
	    cmp     ybegin(rgl_gcb),d2 is this vector active ?
	    bne.s   next_ptlp     no
	    tst     4(a3)         did the vector expire on this y ?
	    bge.s   next_ptlp     no
	    move    2(a3),d0      d0 = x1
	    move    6(a3),d1      d1 = x2
	    cmp     d0,d1         order them: d0=min x, d1=max x
	    bge.s   fp01
	    exg     d0,d1

fp01        bsr     fill

next_ptlp   adda    #14,a3        a3 points to next vector in table
	    subq    #1,d7         dec n
	    bgt     fill_ptlp
*
*  end of line processing
*
	    move    ybegin(rgl_gcb),d0
	    cmp     yend(rgl_gcb),d0   done ?
*           bge     rts            replaced to allow catseye trr disable SFB
	    blt     eol_proc       SFB
	    cmpi.b  #catseye_hrx_display,devicetype+1(rgl_gcb)       CFB 10JUN91
	    bgt     rts                                              CFB 10JUN91
	    cmpi.b  #catseye_display,devicetype+1(rgl_gcb)              SFB
	    blt     rts                                              CFB 12JUN91
	    movea.l deviceaddress(rgl_gcb),a0 waitcatready assumes this SFB
	    bsr     waitcatready     wait for previous move to complete SFB
	    move.w  #$0,trr_enable(a0)      and restore "not trr"       SFB
	    bra     rts                                                 SFB

eol_proc    movea.l stable(rgl_gcb),a0
	    move    n(rgl_gcb),d7
eol_loop    movem   (a0),d0-d6    d0 = y
*                                 d1 = x1
*                                 d2 = m
*                                 d3 = x2
*                                 d4 = frac
*                                 d5 = sum
*                                 d6 = flag
	    cmp     ybegin(rgl_gcb),d0
	    bne.s   next_eol
	    tst     d2            did y expire ?
	    blt.s   next_eol      yes, leave y hanging
	    addq    #1,d0         inc y
	    and     #3,d6         mask of inc/dec bit and x/y major bit
	    add     d6,d6
	    add     d4,d5         sum=frac+sum (sets condition codes)
	    jmp     eol_p(d6)
eol_p       bra.s   mx_ix
	    bra.s   my_ix
	    bra.s   mx_dx
my_dx       bcc.s   save_eol
mx_dx       subq    #1,d3         dec x
	    bra.s   save_eol
my_ix       bcc.s   save_eol
mx_ix       addq    #1,d3         inc x
save_eol    move    d3,d1         put new x into x1
	    movem   d0-d5,(a0)    put stuff back in table
next_eol    adda    #14,a0        point a0 to next entry in table
	    subq    #1,d7         dec n
	    bgt     eol_loop
	    addq    #1,ybegin(rgl_gcb)
	    movea.l left_side(rgl_gcb),a0
	    suba    bytesperline(rgl_gcb),a0
	    move.l  a0,left_side(rgl_gcb)
	    bra     new_line
	    page
*
*  find_min
*
find_min    movea.l stable(rgl_gcb),a0
	    move    n(rgl_gcb),d0
	    moveq   #0,d1         d1=flag for found anything
	    move    ybegin(rgl_gcb),d2
	    move    #32767,d5     d5=xmin
find_loop   cmp     (a0),d2
	    bne.s   next_find     ignore vectors whose y does not match
	    tst     4(a0)         check m for an expired vector
	    blt.s   next_find     ignore expired vectors
	    tst     12(a0)
	    blt.s   next_find     ignore "dead" vectors
	    move    2(a0),d3      d3=x1
	    move    6(a0),d4      d4=x2
	    cmp     d3,d4         put smaller x in d3
	    bgt.s   find_1
	    exg     d3,d4
find_1      cmp     d5,d3
	    bgt.s   next_find     new x is not <= than xmin
*                                 (note: it is important to use blt
*                                 instead of ble to prevent missing a point)
	    movea.l a0,a1         remember where this vector was
	    move    d3,d5
	    move    d4,d6         (d5,d6) are the minx line
	    addq    #1,d1         set found flag
next_find   adda    #14,a0        a0 points to next entry in stable
	    subq    #1,d0         dec n
	    bgt     find_loop
	    tst     d1            set condition codes to indicate whether
*                                 or not a vector was found.  z=0 means
*                                 nothing found.
	    beq.s   fm_rts
	    ori     #$8000,12(a1) set "dead" flag.  this instruction also
*                                 sets the z condition code to indicate
*                                 a non-zero result.
fm_rts      rts
	    page
*
*  fill
*
*  description: this routine fills the area between the points x1 and x2.
*               the fill is accomplished using a dither pattern, selected
*               by red_intensity, green_intensity, and blue_intensity.
*
*  entry:       d0.w            = x1
*               d1.w            = x2 (must be >= x1)
*               gle_gcb         = gcb_ptr
*               left_side       = address of left margin of graphics memory
*               ybegin          = y associated with left_side
*               red_intensity   = mode/color of fill
*               green_intensity
*               blue_intensity
*               gspacing        = 1 for all graphics except 9826a
*                               = 2 for 9826a internal screen
*               devicetype      = 0 for 9826a
*                                 1 for 9836a
*                                 2 for 98627a
*                                 3 for 9836c
*                                 4 for gator_bw
*                                 5 for gatorbox     - SFB NOV 84
*                                 6 for bobcat       - SFB NOV 84
*                                 7 for bobcatlores  - SFB NOV 84
*                                 8 for catseye_lcc  - SFB MAR 88
*                                 9 for catseye_hrx  - SFB MAR 88
*                                10 for woodcut_vga  - CFB - 31MAY91
*                                11 for woodcut_med  - CFB - 31MAY91
*                                12 for woodcut_hrx  - CFB - 31MAY91
*                                13 for woodcut_vgam - CFB - 30JUL91
*                                14 for woodcut_hrxm - CFB - 30JUL91
*               clip_limits_xmin+2(gcb) = clip boundary for left side of screen
*               clip_limits_xmax+2(gcb) = clip boundary for right side of screen
*
*  exit:        graphics memory is updated
*
*  registers:   a0-a2,d0-d5
*               no others may be used !
*
fill        cmp     clip_limits_xmin+2(gle_gcb),d0  clip x1
	    bge.s   fill10
	    move    clip_limits_xmin+2(gle_gcb),d0
fill10      cmp     clip_limits_xmax+2(gle_gcb),d1
	    ble.s   fill20
	    move    clip_limits_xmax+2(gle_gcb),d1
fill20      cmp     d0,d1
	    blt     fm_rts

	    cmpi.b  #10,devicetype+1(rgl_gcb)   WOODCUT doesn't look like BOBCAT
	    bge     fill30                                         CFB - 24JUL91

	    cmpi.b  #6,devicetype+1(rgl_gcb)
	    bge     fbobcat

fill30      move    blu_intensity(rgl_gcb),d2
	    movea.l left_side(rgl_gcb),a0
	    move    d0,d3
	    move    d1,d4
	    ext.l   d0
	    ext.l   d1

	    cmpi.b  #3,devicetype+1(rgl_gcb)
	    beq     f36c

	    cmpi.b  #4,devicetype+1(rgl_gcb)   gator - use bitmover
	    beq     fgator

	    cmpi.b  #5,devicetype+1(rgl_gcb)  check gatorbox
*     can't use tiler for gatorbox (sigh)
	    beq     f36c

	    cmpi.b  #10,devicetype+1(rgl_gcb)                        CFB 10JUN91
	    bge     f36c               WOODCUT has no window mover   CFB 10JUN91

* HOW CAN THIS EVER BE TRUE ??????? - CFB
	    cmpi.b  #6,devicetype+1(rgl_gcb)   bobcat - use windowmover
*     but CAN use windowmover (height = 1 pixel) for bobcat
	    bge     fbobcat

*     9826a/16a,36a,98627a all come here
	    lsr     #3,d0
	    lsr     #3,d1
	    and     #7,d3
	    and     #7,d4
	    sub     d0,d1                  d0=# of bytes to do - 1
	    addq    #1,d4
	    adda    d0,a0                  a0 points to first byte to modify
	    tst     devicetype(rgl_gcb)         9816 or 9826 ?
	    bne.s   fill40
	    adda    d0,a0                  on 9826 & 9816 have to add it twice
fill40      btst    #1,devicetype+1(rgl_gcb)    is this color ?
	    beq.s   f26a36a                no

f27a        movea.l a0,a1
	    movea.l a0,a2                  a0/a1/a2 point to blue plane
	    adda.l  plane2_offset(rgl_gcb),a1   a1 points to green plane
	    adda.l  plane3_offset(rgl_gcb),a2   a2 points to red plane
	    move.l  a1,-(sp)               save a1 for later
	    move    d1,-(sp)               save the byte count (d1)
	    bsr.s   fill_plane             fill the blue plane
	    move    (sp)+,d1               restore the byte count
	    move    grn_intensity(rgl_gcb),d2
	    movea.l (sp)+,a0               a0 points to green plane
	    move    d1,-(sp)
	    bsr.s   fill_plane
	    move    (sp)+,d1
	    move    red_intensity(rgl_gcb),d2
	    movea.l a2,a0                  a0 points to red plane
	    bra.s   fill_plane             fill the red plane (fill_p does rts)

f26a36a     cmp     grn_intensity(rgl_gcb),d2   find maximum fill color
	    bgt.s   f26a36a10
	    move    grn_intensity(rgl_gcb),d2
f26a36a10   cmp     red_intensity(rgl_gcb),d2
	    bgt.s   fill_plane
	    move    red_intensity(rgl_gcb),d2
	    bra.s   fill_plane


dither_table dc.l   $00000000   0
	     dc.l   $88000000   1
	     dc.l   $88002200   2
	     dc.l   $8800aa00   3
	     dc.l   $aa00aa00   4
	     dc.l   $aa44aa00   5
	     dc.l   $aa44aa11   6
	     dc.l   $aa44aa55   7
	     dc.l   $aa55aa55   8
	     dc.l   $aaddaa55   9
	     dc.l   $aaddaa77  10
	     dc.l   $aaddaaff  11
	     dc.l   $aaffaaff  12
	     dc.l   $eeffaaff  13
	     dc.l   $eeffbbff  14
	     dc.l   $eeffffff  15
	     dc.l   $ffffffff  16


fill_plane  and     #$1f,d2
	    lsl     #2,d2
	    move    ybegin(rgl_gcb),d5
	    and     #3,d5                  mask off right two bits
	    add     d5,d2
	    move.b  dither_table(d2),d2
	    jmp     (a5)

fill_dom    tst     d1                     how many bytes are effected ?
	    bne.s   fd10                   more than one
	    rol     d4,d2                  rol.w x2b+1,mask
	    move.b  (a0),d2                g->mask.b
	    rol.b   d4,d2
	    rol     d3,d2
	    ror     d4,d2                  ror.w x2b-x1b+1,mask
	    ror.b   d3,d2
	    move.b  d2,(a0)                mask->g
	    rts

fd10        movea   gspacing(rgl_gcb),a1
	    move.b  (a0),d0
	    rol     d3,d0
	    move.b  d2,d0
	    rol.b   d3,d0
	    ror     d3,d0
	    move.b  d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d1
	    blt.s   fd30
fd20        move.b  d2,(a0)
	    adda.l  a1,a0
	    dbra    d1,fd20
fd30        rol     d4,d2
	    move.b  (a0),d2
	    rol.b   d4,d2
	    ror     d4,d2
	    move.b  d2,(a0)
	    rts


fill_ndom   tst     d1                     how many bytes are effected ?
	    bne.s   fn10                   more than one
	    rol     d4,d2                  rol.w x2b+1,mask
	    move.b  (a0),d2                g->mask.b
	    rol.b   d4,d2
	    rol     d3,d2
	    ror     d4,d2                  ror.w x2b-x1b+1,mask
	    ror.b   d3,d2
	    or.b    d2,(a0)                mask->g
	    rts

fn10        movea   gspacing(rgl_gcb),a1
	    move.b  (a0),d0
	    rol     d3,d0
	    move.b  d2,d0
	    rol.b   d3,d0
	    ror     d3,d0
	    or.b    d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d1
	    blt.s   fn30
fn20        or.b    d2,(a0)
	    adda.l  a1,a0
	    dbra    d1,fn20
fn30        rol     d4,d2
	    move.b  (a0),d2
	    rol.b   d4,d2
	    ror     d4,d2
	    or.b    d2,(a0)
	    rts


fill_erase  not.b   d2
	    tst     d1                     how many bytes are effected ?
	    bne.s   fe10                   more than one
	    rol     d4,d2                  rol.w x2b+1,mask
	    move.b  (a0),d2                g->mask.b
	    rol.b   d4,d2
	    rol     d3,d2
	    ror     d4,d2                  ror.w x2b-x1b+1,mask
	    ror.b   d3,d2
	    and.b   d2,(a0)                mask->g
	    rts

fe10        movea   gspacing(rgl_gcb),a1
	    move.b  (a0),d0
	    rol     d3,d0
	    move.b  d2,d0
	    rol.b   d3,d0
	    ror     d3,d0
	    and.b   d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d1
	    blt.s   fe30
fe20        and.b   d2,(a0)
	    adda.l  a1,a0
	    dbra    d1,fe20
fe30        rol     d4,d2
	    move.b  (a0),d2
	    rol.b   d4,d2
	    ror     d4,d2
	    and.b   d2,(a0)
	    rts


f36c        and     #3,d0             x1 mod 4
	    and     #3,d1             x2 mod 4
	    lsl     #2,d0            (x1 mod 4)*4   # of bytes to jump in mask
	    lsl     #2,d1            (x2 mod 4)*4   # of bytes to jump in mask
	    and     #$fffc,d3         x1 div 4
	    adda    d3,a0             a0 points to first nibble that changes
	    lsr     #2,d3             # of nibbles to x1
	    lsr     #2,d4             # of nibbles to x2
	    sub     d3,d4             # of nibbles to do -1
	    move    d4,d3
	    move    ybegin(rgl_gcb),d5
	    and.l   #3,d5
	    lsl     #2,d5
	    move.l  dither_pattern(rgl_gcb,d5),d2
	    move.l  d2,d5
	    move.l  mask1(d0),d4
	    jmp     (a5)

mask1       dc.l   $ffffffff
	    dc.l   $00ffffff
	    dc.l   $0000ffff
	    dc.l   $000000ff

mask2       dc.l   $ff000000
	    dc.l   $ffff0000
	    dc.l   $ffffff00
	    dc.l   $ffffffff


f36c_dom    tst     d3
	    bne.s   fcd10
fcd05       and.l   mask2(d1),d4
	    moveq   #0,d3
fcd10       and.l   d4,d5
	    not.l   d4
	    and.l   d4,(a0)
	    or.l    d5,(a0)+
	    dbra    d3,fcd20
	    rts
fcd20       moveq   #-1,d4
	    move.l  d2,d5
	    tst     d3
	    beq.s   fcd05
	    subq    #1,d3
fcd30       move.l  d2,(a0)+
	    dbra    d3,fcd30
	    bra.s   fcd05

f36c_ndom   tst     d3
	    bne.s   fcn10
fcn05       and.l   mask2(d1),d4
	    moveq   #0,d3
fcn10       and.l   d2,d4
	    or.l    d4,(a0)+
	    dbra    d3,fcn20
	    rts
fcn20       moveq   #-1,d4
	    tst     d3
	    beq.s   fcn05
	    subq    #1,d3
fcn30       or.l    d2,(a0)+
	    dbra    d3,fcn30
	    bra.s   fcn05

f36c_erase  not.l   d2
	    tst     d3
	    bne.s   fce10
fce05       and.l   mask2(d1),d4
	    moveq   #0,d3
fce10       and.l   d5,d4
	    not.l   d4
	    and.l   d4,(a0)+
	    dbra    d3,fce20
	    rts
fce20       moveq   #-1,d4
	    tst     d3
	    beq.s   fce05
	    subq    #1,d3
fce30       and.l   d2,(a0)+
	    dbra    d3,fce30
	    bra.s   fce05


*fill_comp  tst     d3
*           bne.s   fc10
*fc05       and.l   mask2(d1),d4
*fc10       and.l   d4,d5
*           eor.l   d5,(a0)+
*           dbra    d3,fc20
*           rts
*fc20       move.l  mask1,d4
*           move.l  d2,d5
*fc30       tst     d3
*           beq.s   fc05
*           eor.l   d2,(a0)+
*           dbra    d3,fc30
*           rts
	    page


fgator      movea.l plane1_addr(rgl_gcb),a2
	    movea.l (a2),a2
	    adda.l  plane1_offset(rgl_gcb),a2       upper right display address
	    adda.l  #$0ff000,a2
	    move    ybegin(rgl_gcb),d5
	    and     #3,d5                           y mod 4
	    lsl     #5,d5
	    lsl     #5,d5                           1024*(y mod 4)
	    adda    d5,a2                           a2 points to dither pat.
	    sub     d4,d3                           -(number of pixels)-1
	    subq    #1,d3                           -(number of pixels)
fgat10      movea.l old_a5(gle_gcb),a1
	    movea.l status(a1),a1
	    btst    #7,1(a1)
	    beq.s   fgat10
	    movea.l old_a5(gle_gcb),a1
	    move.w  d3,wwcopy(a1)                   update current window width
	    movea.l window(a1),a1                   set window width
	    move.w  d3,(a1)
	    move.w  #$83,d3
	    movea.l old_a5(gle_gcb),a1
	    move.w  d3,rrcopy(a1)
	    movea.l rule(a1),a1
	    move.w  d3,(a1)

	    move.b  0(a2,d0),0(a0,d0)               move line

fgat11      movea.l old_a5(gle_gcb),a1
	    movea.l status(a1),a1
	    btst    #7,1(a1)
	    beq.s   fgat11
	    move.w  #$3,d3
	    movea.l old_a5(gle_gcb),a1
	    move.w  d3,rrcopy(a1)
	    movea.l rule(a1),a1
	    move.w  d3,(a1)

	    rts

fbobcat     equ     *            SFB FEB '85
	    movea.l old_a5(gle_gcb),a1          access to globals
	    movea.l status(a1),a1               windowmover status reg

* now fill the scanline segment by moving a section of the fill pattern stored
* in bottom 4 lines of (offscreen) frame buffer to displayed line segment
* to be filled. The source segment is computed mod 4 because we use a 4x4
* dither cell. The window mover is set to 1 pixel high, so we can treat it
* like a gator line mover.

	    cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
	    bne.s   waitbobmover
	    add.w   d0,d0                       double startx for "real" pixels
	    add.w   d1,d1                       double endx for "real" pixels
	    addq    #1,d1 {3.1E BUG SFB 6/14/85}and go to right edge of pixel

waitbobmover equ    *
	    move.w  (a1),d5
	    lsr     #8,d5                       status in even byte
*           IS THIS A BUG ???? SFB
*           and.w   gamut(gle_gcb),d5           check only loaded topcats
	    and.w   gamut+2(gle_gcb),d5         check only loaded topcats
	    beq.s   bobmover_done
	    move.l  #1,-(sp)                    not ready, so wait before
	    jsr     delay_timer                 testing mover status again
	    bra.s   waitbobmover

bobmover_done equ   *
	    movea.l deviceaddress(rgl_gcb),a1   base for graphics control
	    move.w  d0,sox(a1)                  source x
	    move.w  d0,dox(a1)                  destination x
	    move.w  ybegin(rgl_gcb),d5
	    move.w  hard_ymax(rgl_gcb),d2       prepare to reverse sign of y
	    sub.w   d5,d2                       convert ybegin to pixelline
	    move.w  d2,doy(a1)                  destination y
	    and.w   #3,d5                       dest y mod 4
	    movep.w $9(a1),d2                   height of visible buffer (ROM)
	    sub.w   #4,d2                       move up 4 lines from bottom
	    add.w   d2,d5                       access one of last 4 lines
	    move.w  d5,soy(a1)                  source y (within fill pattern)
	    move.w  #1,bobh(a1)                 height (1 pixel)
	    sub.w   d0,d1                       width-1 (real pixels)
	    addq    #1,d1                       width (real pixels)
	    move.w  d1,bobw(a1)                 width
	    move.l  gamut(gle_gcb),d5           move all planes
	    lsl     #8,d5
	    cmpi.b  #catseye_display,devicetype+1(rgl_gcb)      SFB
	    bge.s   fcatseye                                    SFB
	    move.w  #3,bobwr(a1)                windowmove replacement rule
move_scanline equ    *
	    move.w  d5,bobwm(a1)
	    rts                                 DONE-don't wait for it to
*                                               complete (DGL owns the
*                                               bobcat windowmover resource)
fcatseye    equ     *
	    move.w  #$100,trr_enable(a1)      select Three Operand Repl Rule SFB
	    move.w  #$f000,trr(a1)            choose "Pattern Reg" rule      SFB
	    move.w  d5,fben1(a1)              enable all loaded planes       SFB
	    bra     move_scanline                                            SFB

	    page
****************************************************************************
*
* cursor ( gcb : graphics_control_block_ptr )
*
*   INFO1 - X location
*   INFO2 - Y location
*   INFO3 - Mode  ( 0 = off, 1 = on )
*
gle_aras_out_rcursor equ *
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep_gcb

	    cmpi.w  #1,current_cursor_state(gle_gcb)
	    bne.s   curs1

	    move.w  current_cursor_x+2(gle_gcb),cursor_x(rgl_gcb) remove current cusor
	    move.w  current_cursor_y+2(gle_gcb),cursor_y(rgl_gcb)
	    bsr.s   cursor_p

curs1       equ *
	    cmpi.l  #1,info3(gle_gcb)
	    bne.s   curs2

	    move.w  info1+2(gle_gcb),cursor_x(rgl_gcb)    draw new cursor
	    move.w  info2+2(gle_gcb),cursor_y(rgl_gcb)
	    bsr.s   cursor_p

curs2       equ *
	    move.l  info1(gle_gcb),current_cursor_x(gle_gcb)
	    move.l  info2(gle_gcb),current_cursor_y(gle_gcb)
	    move.w  info3+2(gle_gcb),current_cursor_state(gle_gcb)

	    bra     rts
*
*
* the cursor_x and cursor_y will be in system
* units, ie., from 0..hard_xmax and
* 0..hard_ymax.  the set_x routine changes
* to actual hardware addresses.
*
cursor_p    equ *
	    movea.l plane2_offset(rgl_gcb),a2        green plane
	    movea.l plane3_offset(rgl_gcb),a3        red plane
	    movea.l plane1_addr(rgl_gcb),a1          blue plane
	    movea.l (a1),a1
	    adda.l  plane1_offset(rgl_gcb),a1        upper right display address
	    move    devicetype(rgl_gcb),d6
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)  gator/box/bobcat
*           bne.s   skp_notgat                            -- reset d6 like 36c
	    blt.s   skp_notgat
	    move    #3,d6
skp_notgat  tst     d6
	    bne.s   cp1
	    adda.l  #1,a1                            9826/16 inc
cp1         move    bytesperline(rgl_gcb),d5
	    move    hard_ymax(rgl_gcb),d3
	    muls    d5,d3
	    adda.l  d3,a1                       address of lower left
	    move    gspacing(rgl_gcb),d7
	    ext.l   d5
	    ext.l   d7
	    clr.l   d3
	    clr.l   d4
* clip the cursor first:
c10         movea.l a1,a5
	    move    cursor_x(rgl_gcb),d0
	    cmpi    #4,d0                   is center <4 from left edge?
	    blt     clip_left
	    move    hard_xmax(rgl_gcb),d1
	    subq    #4,d1
	    cmp     d1,d0                   is center >4 from right edge?
	    bgt     clip_right
	    subq    #4,d0                   if got here, then fix d0 & d3
	    move.b  #8,d3
c20         move    cursor_y(rgl_gcb),d1
	    cmpi    #4,d1                   is center <4 from bottom edge?
	    blt     clip_bottom
	    move    hard_ymax(rgl_gcb),d2
	    subq    #4,d2
	    cmp     d2,d1
	    bgt     clip_top
* if the line is unclipped, i.e., we got here, then draw 9 bits:
	    move.b  #8,d4                   d3 was set to appropriate value
	    move    d1,d2                   above for vertical calculation
	    addq    #4,d2                   +4 above curs_y
*
* at entry:
*       d0 = x
*       d1 = y  for horizontal line
*       d2 = y  for vertical   line
*       d3 = bits to change in horizontal line - 1
*       d4 = bits to change in vertical line - 1
*       d5 = number of bytes/line
*       d6 = crt type  0-9826  1-9836  2-98627  3-9836C/BITMAP
*       d7 = gspacing
*       a1 = lower left corner of graphics memory
*       a2 = plane2_offset
*       a3 = plane3_offset
*
* do the horizontal line first, left to right
*
* | modified to fix cursor bug -- 12/83 BDS
draw_horiz  equ *
	    cmp     hard_ymax(rgl_gcb),d1
	    bgt     draw_vert               If cursor_y > max y, skip to vert
	    tst     d1
	    blt     draw_vert               If cursor_y < 0, skip to vert
	    beq.s   dh20
dh10        mulu    d5,d1
	    suba.l  d1,a1                   gives y address
dh20        bsr     set_x
dh30        btst    #1,d6
	    beq     dh50
	    btst    #0,d6
	    beq     dh40
	    cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
	    beq     dh37        SFB 6/20/85
dh35        not.b   (a1)+
	    dbra    d3,dh35
	    bra.s   draw_vert
dh37        not.w   (a1)+       SFB 6/20/85
	    dbra    d3,dh37     SFB 6/20/85
	    bra.s   draw_vert   SFB 6/20/85
dh40        bchg    d0,0(a1,a2.l)
	    bchg    d0,0(a1,a3.l)
dh50        bchg    d0,(a1)
dh60        dbra    d3,dh65                 d3=no. of bits to change
	    bra.s   draw_vert
dh65        subq.b  #1,d0
	    cmpi.b  #0,d0                   are we at end of byte?
	    bge.s   dh30                    goto dh30 if not
	    adda.l  d7,a1                   increment to next byte
	    moveq   #7,d0                   start changing bit 7 of next byte
dh70        btst    #1,d6
	    beq     dh90
dh80        bchg    d0,0(a1,a2.l)
	    bchg    d0,0(a1,a3.l)
dh90        bchg    d0,(a1)
	    subq.b  #1,d0
	    dbra    d3,dh70
* do vertical line next, top to bottom:
* | modified to fix cursor bug -- 12/83 BDS
draw_vert   equ *
	    move    cursor_x(rgl_gcb),d0           vert. line draw at x=cursor_x
	    blt.s   dv70                   if x < 0, skip vert line
	    cmp     hard_xmax(rgl_gcb),d0
	    bgt.s   dv70                   if x > max x, skip vert line
	    tst     d2
	    beq.s   dv20
dv10        mulu    d5,d2
	    suba.l  d2,a5
dv20        movea.l a5,a1
	    bsr     set_x                   d0=bit
dv30        btst    #1,d6
	    beq     dv50
	    btst    #0,d6
	    beq     dv40
	    cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
	    beq     dv37        SFB 6/20/85
dv35        not.b   (a1)
	    adda.l  d5,a1
	    dbra    d4,dv35
	    rts
dv37        not.w   (a1)        SFB 6/20/85
	    adda.l  d5,a1       SFB 6/20/85
	    dbra    d4,dv37     SFB 6/20/85
	    rts
dv40        bchg    d0,0(a1,a2.l)
	    bchg    d0,0(a1,a3.l)
dv50        bchg    d0,(a1)
dv60        adda.l  d5,a1                   sub n bytes/row from a1
	    dbra    d4,dv30
dv70        rts                             if d4=-1, we are done
*
*
set_x       equ *
	    move    d0,d1
	    cmpi.b  #3,devicetype+1(rgl_gcb)
	    bge.s   sx10
	    lsr     #3,d1
	    tst     devicetype(rgl_gcb)
	    bne.s   sx10
	    lsl     #1,d1
sx10        adda    d1,a1
	    cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
	    bne     sx20
	    adda    d1,a1       "real" pixels   SFB 6/20/85
sx20        andi.l  #7,d0
	    neg     d0
	    addq    #7,d0
	    rts
*
* | modified to fix cursor bug -- 12/83 BDS
clip_left   equ *
* at entry, d0 contains cursor_x
	    move    d0,d3
	    addq    #4,d3                   draw cursor_x + 5 dots
	    bge.s   cl10                    draw no less than 0 dots
	    moveq   #0,d3
cl10        moveq   #0,d0                   new x
	    bra     c20
*
* | modified to fix cursor bug -- 12/83 BDS
clip_right  equ *
* at entry, d1 contains bits_in_y minus 4;
*           d0 contains cursor_x
	    addq    #4,d1                   d1 = hard_xmax
	    move    d1,d3                   d3 = hard_xmax
	    subq    #4,d0                   d0 = cursor_x - 4 (start of line)
	    sub     d0,d3                   d3 = # of dots (xmax-start of line)
	    bge     c20                     if start of line > x max
	    move    d1,d0                           start of line = xmax
	    moveq   #0,d3                           # of dots = 0
	    bra     c20

*
* | modified to fix cursor bug -- 12/83 BDS
clip_bottom equ *
* at entry, d0 contains proper x value for the horizontal line, and
*           d1 contains proper y value for the horizontal line.
	    move    d1,d2
	    addq    #4,d2                   y for vertical line
	    bge.s   cb20                    if y < 0 then
	    moveq   #0,d2                      y = 0
cb20        move    d2,d4                   number of bits to draw = y
	    bra     draw_horiz
*
* | modified to fix cursor bug -- 12/83 BDS
clip_top equ *
* at entry, d0 and d1 contain the proper x and y values for the horizontal,
*           d1 contains cursor_y.
*           d2 contains bits_in_y minus 4.
	    sub     d1,d2                   d2 - curs_y
	    addi    #8,d2                   number of bits to draw
	    bge.s   ct10                    if # of bits < 0 then
	    moveq   #0,d2                      # of bits = 0
ct10        move    d2,d4
	    move    hard_ymax(rgl_gcb),d2        new y
	    bra     draw_horiz
*
*
*  dump graphics expanded
*
*gdump_exp   equ *
*movea.l 4(sp),a0                   a0 = address of pointer to gcb
*move.l  (sp)+,(sp)                 stack return address
*movem.l a5-a6,old__a5(a0)
*movea.l a0,a6                      a6 = address of pointer to gcb
*move    n_glines(rgl_gcb),d3            d3 = number of graphics lines
*subq    #1,d3                      d3 = d3-1
*move    bytesperline(rgl_gcb),d4        d4 = bytes/line
*movea.l lower_left(rgl_gcb),a1          a1 = address of lower left
*movea.l addr1(rgl_gcb),a0               a0 = address of string
*move.l  index(rgl_gcb),d0               d0 = number of line to be dumped
*bsr     set_x
*moveq   #7,d2
*move    devicetype(rgl_gcb),d1
*add     d1,d1
*jmp     getable(d1)
*getable     bra.s   ge26a
*bra.s   ge26a                      36a same as 26a
*bra.s   ge27a
*bra.s   ge36c
*
*ge26a       move.b  (a1),d5
*btst    d0,d5
*beq.s   ge26a10
*bset    d2,(a0)
*subq.b  #1,d2
*bset    d2,(a0)
*subq.b  #1,d2
*bra.s   ge26a20
*ge26a10     bclr    d2,(a0)
*subq.b  #1,d2
*bclr    d2,(a0)
*subq.b  #1,d2
*ge26a20     bge.s   ge26a30
*adda    #1,a0
*moveq   #7,d2
*ge26a30     suba    d4,a1
*dbra    d3,ge26a
*bra     rts
*
*ge27a       bsr     getoffsets
*ge27a10     move.b  (a1),d5
*move.b  (a2),d6
*or.b    d5,d6
*move.b  (a3),d5
*or.b    d5,d6
*btst    d0,d6
*beq.s   ge27a20
*bset    d2,(a0)
*subq.b  #1,d2
*bset    d2,(a0)
*subq.b  #1,d2
*bra.s   ge27a30
*ge27a20     bclr    d2,(a0)
*subq.b  #1,d2
*bclr    d2,(a0)
*subq.b  #1,d2
*ge27a30     bge.s   ge27gle_gcb0
*adda    #1,a0
*moveq   #7,d2
*ge27gle_gcb0     suba    d4,a1
*suba    d4,a2
*suba    d4,a3
*dbra    d3,ge27a10
*bra     rts

*ge36c       cmpi.b  #0,(a1)
*beq.s   ge36c10
*bset    d2,(a0)
*subq.b  #1,d2
*bset    d2,(a0)
*subq.b  #1,d2
*bra.s   ge36c20
*ge36c10     bclr    d2,(a0)
*subq.b  #1,d2
*bclr    d2,(a0)
*subq.b  #1,d2
*ge36c20     bge.s   ge36c30
*adda    #1,a0
*moveq   #7,d2
*ge36c30     suba    d4,a1
*dbra    d3,ge36c
*bra     rts
*
*******************************************************************************
gr26a       moveq   #50,d0             50 bytes/line; 1 dumped at a time
	    move.l  info1(gle_gcb),d5       test for dump flag bit 0 = 1 or
	    beq.s   gr26a20            dump flag = 0
	    btst    #0,d5
	    bne.s   gr26a20
	    moveq   #0,d1
	    bra.s   gr26a20c

gr26a10c    move.b  d1,(a0)+           set to zero's
gr26a20c    dbra    d0,gr26a10c
	    bra     rts

gr26a10     move.b  (a1),(a0)+         dump normal
	    addq    #2,a1
gr26a20     dbra    d0,gr26a10
	    bra     rts

*
*  GET_RASTER ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*    Return formated packed array of char for dump graphics
*
*      INFO_PTR1 = Start of packed array of char
*      INFO1     = Which planes to 'or'
*      INFO2     = Graphics line # to convert (0 = top of crt)
*
gle_aras_out_rget_raster equ *
	    movea.l 4(sp),gle_gcb                    a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb   a6 = dev dep gcb

	    movea.l info_ptr1(gle_gcb),a0            a0 = address of string

	    movea.l plane1_addr(rgl_gcb),a1
	    movea.l (a1),a1
	    adda.l  plane1_offset(rgl_gcb),a1       upper right address
	    move.l  info2(gle_gcb),d0               d0 = row to be dumped
	    mulu    bytesperline(rgl_gcb),d0        d0 = row * bytes/line
	    adda.l  d0,a1                           a1 = address of line dumped
	    move    devicetype(rgl_gcb),d1
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
*           bne.s   skp_notgat2         SFB NOV 84
	    blt.s   skp_notgat2         SFB NOV 84
	    move    #3,d1               gator/gatorbox/bobcat -- set d1 to 36c
skp_notgat2 add     d1,d1
	    jmp     grtable(d1)
grtable     bra.s   gr26a
	    bra.s   gr36a
	    bra.s   gr27a
	    bra.s   gr36c

gr36a       moveq   #16,d0                  64 bytes/line; 4 dumped at a time
	    move.l  info1(gle_gcb),d5       test for dump flag bit 0 = 1 or
	    beq.s   gr36a20                 dump flag = 0
	    btst    #0,d5
	    bne.s   gr36a20
	    moveq   #0,d1
	    bra.s   gr36a20c

gr36a10c    move.l  d1,(a0)+           dump zeros
gr36a20c    dbra    d0,gr36a10c
	    bra     rts

gr36a10     move.l  (a1)+,(a0)+        dump normal
gr36a20     dbra    d0,gr36a10
	    bra     rts

gr27a       bsr     getoffsets
	    moveq   #16,d0                  64 bytes/line; 4 dumped at a time
	    move.l  info1(gle_gcb),d5       get mask
	    bra.s   gr27a20
gr27a10     moveq   #0,d3
	    move.l  (a1)+,d1
	    btst    #0,d5
	    beq.s   gr1
	    move.l  d1,d3
gr1         move.l  (a2)+,d1
	    btst    #1,d5
	    beq.s   gr2
	    or.l    d1,d3
gr2         move.l  (a3)+,d1
	    btst    #2,d5
	    beq.s   gr3
	    or.l    d1,d3
gr3         move.l  d3,(a0)+
gr27a20     dbra    d0,gr27a10
	    bra     rts

gr36c       moveq   #63,d0             64 bytes/line; 1 dumped at a time (-1)
gr36c10     moveq   #7,d1
	    moveq   #0,d2
gr36c20     move.b  (a1)+,d3
	    and.b   info1+3(gle_gcb),d3
	    cmpi.b  #0,d3
	    beq.s   gr36c30
	    bset    d1,d2
gr36c30     dbra    d1,gr36c20
	    move.b  d2,(a0)+
	    dbra    d0,gr36c10
	    bra     rts
*
*
*
*gstore_proc      equ *
*movea.l 4(sp),a0                   a0 = address of pointer to gcb
*move.l  (sp)+,(sp)                 stack return address
*movem.l a5-a6,old__a5(a0)
*movea.l a0,a6                      a6 = address of pointer to gcb
*movea.l addr1(rgl_gcb),a0               a0 = address of array
*move.l  index(rgl_gcb),d0               d0 = size of array in words
*movea.l plane1_addr(rgl_gcb),a1         a1 = ptr to address of plane 1
*movea.l (a1),a1                    a1 = address of plane 1
*adda.l  plane1_offset(rgl_gcb),a1       upper right address
*move    gspacing(rgl_gcb),d1
*subq    #1,d1
*adda.w  d1,a1                      adjust for 16/26 odd adr
*move    devicetype(rgl_gcb),d1
*add     d1,d1
*jmp     gstable(d1)
*gstable     bra.s   gs26a
*bra.s   gs36a
*bra.s   gs27a
*bra.s   gs36c
*
*gs26a       add.l   d0,d0
*bra.s   gs26a20
*gs26a10     move.b  (a1),(a0)+
*addq    #2,a1
*gs26a20     dbra    d0,gs26a10
*bra     rts
*
*gs36a       bra.s   gs36a20
*gs36a10     move    (a1)+,(a0)+
*gs36a20     dbra    d0,gs36a10
*bra     rts
*
*gs27a       divu    #3,d0
*move.l  d0,d1
*swap    d1
*bsr     getoffsets
*bra     gs27a20
*gs27a10     move    (a1)+,(a0)+
*move    (a2)+,(a0)+
*move    (a3)+,(a0)+
*gs27a20     dbra    d0,gs27a10
*sub.b   #1,d1
*blt     rts
*move    (a1)+,(a0)+
*sub.b   #1,d1
*blt     rts
*move    (a2)+,(a0)+
*sub.b   #1,d1
*blt     rts
*move    (a3)+,(a0)+
*bra     rts
*
*gs36c       lsr.l   #1,d0
*bra.s   gs36c20
*gs36c10     move.l  (a1)+,d2
*ror.l   #4,d2
*or.l    (a1)+,d2
*rol.l   #4,d2
*move.l  d2,(a0)+
*gs36c20     dbra    d0,gs36c10
*bra     rts
*
**
**
*
*gload_proc       equ *
*movea.l 4(sp),a0                   a0 = address of pointer to gcb
*move.l  (sp)+,(sp)                 stack return address
*movem.l a5-a6,old__a5(a0)
*movea.l a0,a6                      a6 = address of pointer to gcb
*movea.l addr1(rgl_gcb),a0               a0 = address of array
*move.l  index(rgl_gcb),d0               d0 = size of array in words
*movea.l plane1_addr(rgl_gcb),a1         a1 = ptr to address of plane 1
*movea.l (a1),a1                    a1 = address of plane 1
*adda.l  plane1_offset(rgl_gcb),a1       upper right address
*move    gspacing(rgl_gcb),d1
*subq    #1,d1
*adda.w  d1,a1                      adjust for 16/26 odd adr
*move    devicetype(rgl_gcb),d1
*add     d1,d1
*jmp     gltable(d1)
*gltable     bra.s   gl26a
*bra.s   gl36a
*bra.s   gl27a
*bra     gl36c
*
*gl26a       moveq   #48,d1
*divu    #12,d0
*bra.s   gl26a20
*gl26a10     movem.l (a0)+,d2-d7
*movep.l d2,$0(a1)
*movep.l d3,$8(a1)
*movep.l d4,$10(a1)
*movep.l d5,$18(a1)
*movep.l d6,$20(a1)
*movep.l d7,$28(a1)
*adda    d1,a1
*gl26a20     dbra    d0,gl26a10
*swap    d0
*add     d0,d0
*bra.s   gl26gle_gcb0
*gl26a30     move.b  (a0)+,(a1)
*addq    #2,a1
*gl26gle_gcb0     dbra    d0,gl26a30
*bra     rts
*
*gl36a       moveq   #40,d1
*divu    #20,d0
*bra.s   gl36a20
*gl36a10     movem.l (a0)+,d2-d7/a2-a5
*movem.l d2-d7/a2-a5,(a1)
*adda    d1,a1
*gl36a20     dbra    d0,gl36a10
*swap    d0
*bra.s   gl36gle_gcb0
*gl36a30     move    (a0)+,(a1)+
*gl36gle_gcb0     dbra    d0,gl36a30
*bra     rts
*
*gl27a       divu    #12,d0
*move.l  d0,d1
*swap    d1
*bsr     getoffsets
*bra     gl27a20
*gl27a10     move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*gl27a20     dbra    d0,gl27a10
*gl27a30     sub.b   #1,d1
*blt     rts
*move    (a0)+,(a1)+
*sub.b   #1,d1
*blt     rts
*move    (a0)+,(a2)+
*sub.b   #1,d1
*blt     rts
*move    (a0)+,(a3)+
*bra.s   gl27a30
*
*gl36c       lsr.l   #1,d0
*bra.s   gl36c20
*gl36c10     move.l  (a0)+,d2
*move.l  d2,(a1)+
*ror.l   #4,d2
*move.l  d2,(a1)+
*gl36c20     dbra    d0,gl36c10
*bra     rts
*
**
**
**
getoffsets  movea.l a1,a2
	    movea.l a1,a3
	    adda.l  plane2_offset(rgl_gcb),a2
	    adda.l  plane3_offset(rgl_gcb),a3
	    rts
*
*get_size    equ     *
*cmpi.b  #2,devicetype+1(rgl_gcb)
*beq.s   moon
*move.l  #$6180,t1(rgl_gcb)
*move.l  #$30C,t2(rgl_gcb)
*rts
*
*moon        move.l  #$8000,t1(rgl_gcb)
*move.l  #$400,t2(rgl_gcb)
*rts

rtarg       equ     rgltemp1
ract        equ     rgltemp1+2
gtarg       equ     rgltemp2
gact        equ     rgltemp2+2
btarg       equ     rgltemp3
bact        equ     rgltemp3+2
serrin      equ     rgltemp4
serrout     equ     rgltemp5
red         equ     red_intensity


*************************************************************************
*
* PROCEDURE FILL_INDEX_COLOR ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*  INFO1 = Parameter mode
*            0 - RGB values passed
*            1 - Color map index passed
*
*  INFO2 = Normalized RED value or Color index (based on mode)
*  INFO3 = Normalized GREEN value
*  INFO4 = Normalized Blue value
*
gle_aras_out_rfill_index_color equ *
*
	    movea.l 4(sp),gle_gcb                   a4 = gcb
	    move.l  (sp)+,(sp)
*           lea     -512(a7),a0
*           cmp.l   a0,SYSGLOBALS-14(a5)
*           ble.s   stackok
*           move.w  #-2,SYSGLOBALS-2(a5)
*           trap    #10
* stackok   equ     *
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep gcb

	    tst.l   info1(gle_gcb)                  ck mode
	    beq.s   fill_index2

	    move.l  info2(gle_gcb),d0               get color index
	    move.w  d0,current_polygon_color(gle_gcb)

	    moveq   #0,d1
fill_index1 move.b  d0,dither_pattern(rgl_gcb,d1.l)
	    addq.l  #1,d1
	    cmp     #15,d1
	    ble.s   fill_index1
	    bra     rts


fill_index2 move.w  #-1,current_polygon_color(gle_gcb)
	    move.w  info2+2(gle_gcb),d0                   red
	    move.w  info3+2(gle_gcb),d1                   green
	    move.w  info4+2(gle_gcb),d2                   blue

	    move.w  d0,current_polygon_red(gle_gcb)
	    move.w  d1,current_polygon_green(gle_gcb)
	    move.w  d2,current_polygon_blue(gle_gcb)

*cmpi.w  #1,color_map_support(gle_gcb)      ck for color
	    cmpi.w #3,devicetype(rgl_gcb)
	    beq.s   setup_c_dither
	    cmpi.w #gator_display,devicetype(rgl_gcb)  //// do same for ////
*           beq.s   setup_c_dither                     //// gator for now //
	    bge.s   setup_c_dither                    also for gatorbox/bobcat

	    add.w   #32,d0
	    add.w   #32,d1
	    add.w   #32,d2

	    lsr.w   #6,d0
	    lsr.w   #6,d1
	    lsr.w   #6,d2

	    move.w  d0,red_intensity(rgl_gcb)
	    move.w  d1,grn_intensity(rgl_gcb)
	    move.w  d2,blu_intensity(rgl_gcb)

	    bra rts

*************************************************************************
*
setup_c_dither equ *

	    move.w  d0,red_intensity(rgl_gcb)
	    move.w  d1,grn_intensity(rgl_gcb)
	    move.w  d2,blu_intensity(rgl_gcb)

set_intens  equ *
	    lea     system_cmap(rgl_gcb),a0
	    suba    #768,a7     {SFB 4/12/85}  allocate 768 bytes off stack
	    lea     512(a7),a1                 use 256 bytes for count array
	    lea     0(a7),a5                   and 512 for boolean in/out
	    movem   red(a6),d1-d3
	    lsl     #4,d1                      d1 = 16*red
	    lsl     #4,d2                      d2 = 16*grn
	    lsl     #4,d3                      d3 = 16*blu
	    movea.l a0,a2                      a2 = temp address of syscmap
	    move.l  gamut(gle_gcb),d0          d0 = loop counter
	    moveq   #0,d4                      d4 = zero out upper byte
si10        clr.b   0(a5,d0)                   clear boolean
	    move.w  (a2),d4                    d4 = syscmap.r
	    cmp     d4,d1                      if syscmap.r>16*red
	    blt.s   si20                       then outside
	    move.w  2(a2),d4                   d4 = syscmap.g
	    cmp     d4,d2                      if syscmap.g>16*grn
	    blt.s   si20                       then outside
	    move.w  4(a2),d4                   d4 = syscmap.b
	    cmp     d4,d3                      if syscmap.b>16*blu
	    blt.s   si20                       then outside
	    move.b  #1,0(a5,d0)                inside so set boolean
si20        addq    #6,a2                      increment to next syscmap
	    dbra    d0,si10                    loop
	    clr.l   rtarg(a6)                  clear rtarg and ract
	    clr.l   gtarg(a6)                  clear gtarg and gact
	    clr.l   btarg(a6)                  clear btarg and bact
	    movea.l a1,a3                      a3 = count array pointer
	    move.l  gamut(gle_gcb),d0          loop counter
	    lsr     #2,d0                      divide by 4 for long words
si30        clr.l   (a3)+                      clear count array
	    dbra    d0,si30                    loop
	    moveq   #0,d4                      zero out upper byte of d4
	    moveq   #15,d0                     pixel loop counter
si40        movem   red(a6),d5-d7
	    add     d5,rtarg(a6)               rtarg=rtarg+red
	    add     d6,gtarg(a6)               gtarg=gtarg+grn
	    add     d7,btarg(a6)               btaeg=btarg+blu
	    move.l  #$7fffffff,serrin(a6)      smallest_err_in=maxint
	    move.l  serrin(a6),serrout(a6)     smallest_err_out=maxint
	    movea.l a0,a2                      syscmap array index
	    moveq   #0,d7                      in flag
	    move.l  gamut(gle_gcb),d1          inner loop counter
si50        tst     d7                         if none in so far
	    beq.s   si55                       then got to look for one
	    tst.b   0(a5,d1)                   if this vector is out
	    beq     si100                      then don't do this stuff
si55        move    rtarg(a6),d2
	    sub     ract(a6),d2
	    move.w  (a2),d4                    get syscmap.r
	    sub     d4,d2                      d2=rtarg-ract-syscmap.r
	    muls    d2,d2
si60        move.l  d2,d3
	    move    gtarg(a6),d2
	    sub     gact(a6),d2
	    move.w  2(a2),d4                   get syscmap.g
	    sub     d4,d2                      d2=gtarg-gact-syscmap.g
	    muls    d2,d2
si70        add.l   d2,d3
	    move    btarg(a6),d2
	    sub     bact(a6),d2
	    move.w  4(a2),d4                   get syscmap.b
	    sub     d4,d2                      d2=btarg-bact-syscmap.b
	    muls    d2,d2
si80        add.l   d2,d3
	    tst.b   0(a5,d1)                   if vector not inside
	    beq.s   si90                       then outside
	    cmp.l   serrin(a6),d3              if smallest_err_in<=error
	    bge.s   si100                      then ignore
	    move.l  d3,serrin(a6)              smallest_err_in=error
	    move    d1,d5                      closest_color_in=i
	    moveq   #1,d7                      in flag
	    bra.s   si100
si90        cmp.l   serrout(a6),d3             if smallest_err_out<=error
	    bge.s   si100                      then ignore
	    move.l  d1,serrout(a6)             smallest_err_out=error
	    move    d1,d6                      closest_color_out=i
si100       addq    #6,a2                      increment syscmap pointer
	    dbra    d1,si50                    loop (inner)
	    tst     d7                         if no vectors were in
	    beq.s   si110                      then do out stuff
	    move    d5,d6                      closest_color=closest_color_in
si110       move.l  gamut(gle_gcb),d5          get number of colormap entries
	    sub     d6,d5                      real index= entries-i
	    movea   d5,a3                      a3=closest_color

* following is code originally for 4 byte/color map entry (1 byte each for
* RGB, and 1 byte pad)
*           add     d5,d5
*           movea   d5,a2                      a2=closest_color
*           adda    d5,a2                      a2=4*closest_color
* instead, for 6 byte/color map entry (2 bytes each for RGB), do
	    movea   d5,a2                      a2=closest_color
	    add     d5,d5                      d5=2*closest_color
	    adda    d5,a2                      a2=3*closest_color
	    adda    a2,a2                      a2=6*closest_color

	    adda.l  a0,a2                      pointer to syscmap[closest_c]
	    adda.l  a1,a3                      pointer to count[closest_c]
	    moveq   #0,d5                      zero upper byte
	    moveq   #0,d6                      zero upper byte
	    moveq   #0,d7                      zero upper byte
	    move.w  (a2),d5                    get syscmap[cc].r
	    move.w  2(a2),d6                   get syscmap[cc].g
	    move.w  4(a2),d7                   get syscmap[cc].b
	    add     d5,ract(a6)                ract=ract+syscmap[cc].r
	    add     d6,gact(a6)                gact=gact+syscmap[cc].g
	    add     d7,bact(a6)                bact=bact+syscmap[cc].b
	    addq.b  #1,(a3)                    increment count[cc]
	    dbra    d0,si40                    loop (outer)
	    movea.l a5,a2                      a2 points to scratch array
	    move.l  gamut(gle_gcb),d0          d0= i:loop counter
	    move    d0,d3                      save max pen for later
	    moveq   #0,d1                      num of entries counter
	    moveq   #0,d5                      zero upper byte
	    moveq   #0,d6                      zero upper byte
si120       move.b  0(a1,d0),d2                count[i]
	    beq     si130                      if no count then goto next
	    moveq   #0,d5                      zero upper byte
	    move.b  d0,(a2)+                   store entry in scratch array
	    move.b  d2,(a2)+                   store count in scratch array
	    move    d0,d4                      i
	    add     d4,d4                      2*(i)
	    add     d4,d4                      4*(i)
	    move.w  2(a0,d4),d5                syscmap[i].grn
	    add     d5,d5                      2*grn
	    add     d5,d5                      4*grn
	    move.w  0(a0,d4),d6                syscmap[i].red
	    add     d6,d5                      4*grn+red
	    add     d5,d5                      8*grn+2*red
	    add     d6,d5                      8*grn+3*red
	    move.w  4(a0,d4),d6                syscmap[i].blu
	    add     d6,d5                      8*grn+3*red+blu
	    move    d5,(a2)+                   store brightness in scratch arry
	    addq    #1,d1                      num of entries counter + 1
si130       dbra    d0,si120                   next i
	    subq    #1,d1                      num of entries counter - 1
	    beq     si160                      only one entry then skip
	    add     d1,d1
	    add     d1,d1                      j
	    moveq   #0,d0                      n=0
si140       move    d0,d2                      i=n
si150       addq    #4,d2                      i=i+1
	    move    2(a5,d0),d3                brightness[n]
	    cmp     2(a5,d2),d3                is brightness[i]>brightness[n]
	    bge     si155                      then pull the old switcheroo
	    move.l  0(a5,d2),d4                temp=record[i]
	    move.l  0(a5,d0),0(a5,d2)          record[i]=record[n]
	    move.l  d4,0(a5,d0)                record[n]=temp
si155       cmp     d2,d1                      is i<j
	    bgt     si150
	    addq    #4,d0                      n=n+1
	    cmp     d0,d1                      is n>j
	    bgt     si140
si160       moveq   #0,d0                      pixel=0
	    moveq   #0,d3                      i=0
	    moveq   #0,d4                      zero upper byte
si170       moveq   #0,d2                      n=0
si180       move.b  ditseq(d0),d4
	    move.b  0(a5,d3),dither_pattern(a6,d4)
	    addq    #1,d0
	    addq    #1,d2
	    cmp.b   1(a5,d3),d2                is count[i]<n
	    blt     si180
	    addq    #4,d3                      i=i+1
	    cmp     d3,d1                      is i>j
	    bge     si170
	    adda    #768,a7     {SFB 4/12/85}  return space to stack
	    bra     rts

ditseq      dc.b    0,10,8,2,5,15,13,7,4,14,12,6,1,11,9,3

* here we repartition the dither pattern and place it into the trr pattern rgisters of
* the CATSEYE. Later, in rpolygon, we will use trr to move the required scanline to
* the screen using the "P" trr rule. We do this because there is not enough width
* in offscreen frame buffer on the hrx machines to store a dithered scanline that
* can span the 1280-pixel wide screen. SFB
*
* The dither pattern is a 4x4 array of byte-per-pixel pixels.
* The data in it may be significant in from 1 to 8 planes.
* The pattern registers are a 16x16 by up to 8 plane deep array of bit-per-pixel
* data to combine into the frame buffer. We must replicate the 4x4 dither pattern
* both vertically and horizontally to fill the 16x16 bit x n plane pattern register
* set.

* dither pattern (bytes):

*               (0,0) (0,1) (0,2) (0,3)
*               ...
*               (3,0) (3,1) (3,2) (3,3)

* Pattern regs (bits):

* plane 0       (0,0) (0,1)...(0,15)
*               ...
*               (15,0) (15,1)...(15,15)

* plane 1       (0,0) (0,1)...(0,15)
*               ...
*               (15,0) (15,1)...(15,15)

*               ...

* plane n       (0,0) (0,1)...(0,15)
*               ...
*               (15,0) (15,1)...(15,15)


* Pascal entry point dither_to_pattregs(gcb); called from gator_fill_index_color
* iff display is hrm CATSEYE. SFB

gle_aras_out_dither_to_pattregs equ *           Pascal entry point              SFB
	    movea.l 4(sp),gle_gcb
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
	    movea.l deviceaddress(rgl_gcb),a0
	    lea     pattregs(a0),a0     do this because can't use >127 displacement later
	    move.l  gamut(gle_gcb),d3   d3: how many planes to slice
	    moveq   #0,d1               d1: pattern register index
	    moveq   #0,d2               d2: single bit selector
next_plane  equ     *
	    moveq   #0,d6       d6: indexes columns of dither pattern (0..3)
	    moveq   #3,d4       d4: counts lines of dither pattern (3..0)
next_line   equ     *
	    moveq   #3,d5       d5: counts columns of dither pattern (3..0)
	    moveq   #0,d0       d0: tmp, construct register data here
next_bit    equ     *           next byte of dither pattern cell->next bit of d0
	    btst    d2,dither_pattern(rgl_gcb,d6)
	    beq     not_set
	    bset    d5,d0
not_set     equ     *
	    addq    #1,d6               next row of dither pattern
	    dbra    d5,next_bit
	    mulu    #$1111,d0           replicate 4 bits horizontally
	    move.w  d0,(a0,d1)          move data to pattregs
	    move.w  d0,8(a0,d1)        ditto, replicating vertically
	    move.w  d0,16(a0,d1)        ditto, replicating vertically
	    move.w  d0,24(a0,d1)        ditto, replicating vertically
	    addq    #2,d1               next register (in 4x4 space)
	    dbra    d4,next_line
	    addq    #1,d2        generate next plane mask
	    add     #24,d1       and step to next pattreg block of 16 words
	    lsr     #1,d3        check gamut: are we done yet (no 1 bits left)?
	    bne     next_plane

	    bra     rts

	    page

**************************************************************************
*
*  GET_P1P2 ( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  Returns lower left and upper right points
*
*     INFO1 = XMIN
*     INFO2 = XMAX
*     INFO3 = YMIN
*     INFO4 = YMAX
*
gle_aras_out_rget_p1p2 equ *
	    movea.l 4(sp),gle_gcb                  a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                     stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb a6 = device gcb
	    clr.l   info1(gle_gcb)
	    clr.l   info3(gle_gcb)
	    move.w  hard_xmax(rgl_gcb),d0
	    ext.l   d0
	    move.l  d0,info2(gle_gcb)
	    move.w  hard_ymax(rgl_gcb),d0
	    ext.l   d0
	    move.l  d0,info4(gle_gcb)
	    bra rts

******************************************************************************
*
* AWAIT_BLANKING ( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  loop until vertical blanking starts
*
gle_aras_out_rawait_blanking equ *
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device gcb

	    cmpi.w  #3,devicetype(rgl_gcb)          ck for 9836C
	    bne.s   blankgbox
	    movea.l deviceaddress(rgl_gcb),a2       36c await_blanking
blank1      equ     *                               used to be move.b  (a2),d0
	    btst    #0,(a2)                         used to be btst    #0,d0
	    beq.s   blank1
	    bra.s   noblank

blankgbox   cmpi.w  #5,devicetype(rgl_gcb)          ck for gatorbox
	    bne.s   noblank
	    movea.l cmap_address(rgl_gcb),a2        gatbox await_blanking
	    adda.l  #2,a2
blank3      btst    #0,(a2)
	    bne.s   blank3

noblank     bra rts

******************************************************************************
*
* SETGBOXCMAP( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  set gatorbox color map entry INFO1 to values R,G,B (INFO2, INFO3, INFO4)
*
gle_aras_out_setgboxcmap equ *
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device gcb

	    move.l  info1(gle_gcb),d1
	    move.l  info2(gle_gcb),d2
	    move.l  info3(gle_gcb),d3
	    move.l  info4(gle_gcb),d4

	    movea.l status(a5),a1       set up to check HSYNC in secondary
	    moveq   #1,d0

	    movea.l cmap_address(rgl_gcb),a0
cm00        btst    #2,2(a0)            wait for cmap not busy
	    bne.s   cm00

	    move.w  d1,$b7(a0)          set cmap pointer to correct entry

*  now update cmap color registers by waiting for video ( = not horizontal
*  retrace), then wait for horizontal retrace, then immediately update
*  register. We wait for video first to ensure we don't catch
*  retrace in the middle or near the end. Colormap should be updated during
*  either horizontal or vertical retrace to ensure we don't get snow on
*  the screen during update. We use (a0)+ because it's the fastest to-mem
*  address mode available (the increment happens after cmap update), and we
*  have only a few microsec to update the registers.

	    adda.l  #$1b1,a0            point a0 at RED register
cm10        btst    d0,(a1)             wait for video
	    beq.s   cm10
cm11        btst    d0,(a1)             wait for horizontal
	    bne.s   cm11
	    move.w  d2,(a0)+            update red
cm12        btst    d0,(a1)
	    beq.s   cm12
cm13        btst    d0,(a1)
	    bne.s   cm13
	    move.w  d3,(a0)+            update green
cm14        btst    d0,(a1)
	    beq.s   cm14
cm15        btst    d0,(a1)
	    bne.s   cm15
	    move.w  d4,(a0)+            update blue
	    bra     rts

******************************************************************************
*
* SET_NEREID( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  set NEREID color map entry INFO1 to values R,G,B (INFO2, INFO3, INFO4)
*
gle_aras_out_set_nereid equ *
	    movea.l 4(sp),gle_gcb               a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                  stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb       a6 = device gcb

	    move.l  info1(gle_gcb),d1
	    move.l  info2(gle_gcb),d2
	    move.l  info3(gle_gcb),d3
	    move.l  info4(gle_gcb),d4

	    movea.l cmap_address(rgl_gcb),a0

nereid_cm00 equ     *                              wait for cmap ready
*           NOP                                    SFB 4/18/85 removed 10/03/86 SFB
	    btst    #2,2(a0)
	    bne.s   nereid_cm00

	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b8(a0)                     set cmap index
	    move    0,d0                           delay for nereid SFB
	    move.b  d2,$b2(a0)                     set red
	    move    0,d0                           delay for nereid SFB
	    move.b  d3,$b4(a0)                     set green
	    move    0,d0                           delay for nereid SFB
	    move.b  d4,$b6(a0)                     set blue
	    move    0,d0                           delay for nereid SFB
	    move.b  d0,$f0(a0)                     trigger color map load
	    move    0,d0                           delay for nereid SFB

nereid_cm01 equ     *                              wait for load complete
*           NOP                                    SFB 4/18/85 removed 10/03/86 SFB
	    btst    #2,2(a0)
	    bne.s   nereid_cm01

	    moveq   #0,d1                          set above 4 registers to 0
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b8(a0)                     set cmap index
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b2(a0)                     set red
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b4(a0)                     set green
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b6(a0)                     set blue

	    bra     rts

******************************************************************************
*
* SET_WOOD_CMAP( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  set WOODCUT color map entry INFO1 to values R,G,B (INFO2, INFO3, INFO4)
*
gle_aras_out_set_wood_cmap equ *               added WOODCUT support CFB 10JUN91
	    movea.l 4(sp),gle_gcb               a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                  stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb       a6 = device gcb

	    move.l  info1(gle_gcb),d1
	    move.l  info2(gle_gcb),d2
	    move.l  info3(gle_gcb),d3
	    move.l  info4(gle_gcb),d4

	    move.l  #blueregimage,d5
	    move.l  #dacimagewrite,d6
	    movea.l deviceaddress(rgl_gcb),a0 need control space address

checkblue   btst    #0,2(a0,d5.l)           check for color map busy
	    bne.s   checkblue               loop until bit is clear
	    move.b  d1,0(a0,d6.l)           write the index to the DAC
	    move.b  d2,4(a0,d6.l)           then red to the DAC
	    move.b  d3,4(a0,d6.l)           then green to the DAC
	    move.b  d4,3(a0,d5.l)           then blue to BEECH
	    bra     rts

gle_aras_out_gle_aras_out rts
	    end
@


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


56.2
log
@Found bug when clearing a medium-res 382 with clear_display. Missed it
in QA testing. Change line 1041 from BGT to BNE.     CFB
@
text
@a0 4575
*
*  Graphics Low End
*
*  Module    = Gle_aras_out
*  Programer = DAC, BJS
*  Date      = 9-30-82
*
*  Purpose : To provide low-level raster routines.
*
*  Rev history
*
*    Created    - 9-30-82
*    Modified   - 6-28-83  BJS  Changed module name to not conflict with
*                               the pascal name
*               -12-07-83  BDS  Added fixes for cursor bug
*               -01-30-84  BJS  Speedup fix for set_color, set_line_style
*               -02-17-84  BDS  Added support for gator for Pascal 3.0
*               -05-01-85  SFB  Added support for bobcat/gatorbox
*               -05-29-91  CFB  Added support for WOODCUT
*
*     (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
*
* Change error routine err_esc for every OS transport
*
       nosyms
       mname gle_aras_out

       src module GLE_ARAS_OUT;
       src import GLE_TYPES;
       src export
       src procedure  rgcbinit ( GCB : graphics_control_block_ptr );
       src procedure  rgraphics_on_off ( GCB : graphics_control_block_ptr );
       src procedure  rclear ( GCB : graphics_control_block_ptr );
       src procedure  rmove ( GCB : graphics_control_block_ptr );
       src procedure  rdraw  ( GCB : graphics_control_block_ptr );
       src procedure  rdefine_drawing_mode ( GCB : graphics_control_block_ptr);
       src procedure  rlinestyle ( GCB : graphics_control_block_ptr);
       src procedure  rcursor ( GCB : graphics_control_block_ptr);
       src procedure  rset_color ( GCB : graphics_control_block_ptr);
       src procedure  rpolygon ( GCB : graphics_control_block_ptr );
       src procedure  rget_p1p2 ( GCB : graphics_control_block_ptr );
       src procedure  rget_raster ( GCB : graphics_control_block_ptr );
       src procedure  rfill_index_color ( GCB : graphics_control_block_ptr );
       src procedure  rawait_blanking ( GCB : graphics_control_block_ptr );
       src procedure  store_dit ( GCB : graphics_control_block_ptr );
       src procedure  set_6845s ( GCB : graphics_control_block_ptr );
       src procedure  setgboxcmap( GCB : graphics_control_block_ptr);
       src procedure  set_nereid( GCB : graphics_control_block_ptr);
       src procedure  set_wood_cmap( GCB : graphics_control_block_ptr);
       src procedure  dither_to_pattregs( GCB : graphics_control_block_ptr);
       src end;

       rorg 0

       refa sysglobals
       refa sysdevs
       refa gle_asclip_clipping
       refa gle_types
       refa delay_timer
       refa asm_flush_icache            {3/25/85 SFB}

       lmode sysglobals
       lmode sysdevs
       lmode gle_asclip_clipping
       lmode gle_types
       lmode delay_timer
       lmode asm_flush_icache           {3/25/85 SFB}

       def  gle_aras_out_rgcbinit
       def  gle_aras_out_rgraphics_on_off
       def  gle_aras_out_rclear
       def  gle_aras_out_rmove
       def  gle_aras_out_rdraw
       def  gle_aras_out_rdefine_drawing_mode
       def  gle_aras_out_rset_color
       def  gle_aras_out_rlinestyle
       def  gle_aras_out_rpolygon
       def  gle_aras_out_rget_raster
       def  gle_aras_out_rcursor
       def  gle_aras_out_rfill_index_color
       def  gle_aras_out_rget_p1p2
       def  gle_aras_out_rawait_blanking
       def  gle_aras_out_store_dit
       def  gle_aras_out_set_6845s
       def  gle_aras_out_setgboxcmap
       def  gle_aras_out_set_nereid
       def  gle_aras_out_set_wood_cmap                               CFB 12JUN91
       def  gle_aras_out_dither_to_pattregs     SFB 3/8/88

       def  gle_aras_out_gle_aras_out

       def  fgator                             for debug only
       def  hv50                                "
       def  hv52                                "
       DEF  FBOBCAT                             "
       DEF  VEC6
       DEF  BUILD_PEN
       DEF  SET_PEN

*
*      def  gdump_exp
*      def  gload_proc
*      def  gstore_proc
*

ADDR1            equ 0
ADDR2            equ 4
ADDR3            equ 8
AREA_DRAW_MODE   equ 74
BLU_INTENSITY    equ 52
BYTESPERLINE     equ 42
CMAP_ADDRESS     equ 1890
CPEN             equ 82
CURSOR_X         equ 70
CURSOR_Y         equ 72
DEVICEADDRESS    equ 16
DEVICETYPE       equ 14
DITHER_PATTERN   equ 54
GRN_INTENSITY    equ 50
GSPACING         equ 40
HARD_XMAX        equ 44
HARD_YMAX        equ 46
INDEX            equ 110
LINEPATTERN      equ 78
MONITORTYPE      equ 20
N3               equ 12
N_GLINES         equ 38
OLDPATTERN       equ 84
PEN_DRAW_MODE    equ 76
* PEN_NUMBER       equ 80       SEE PEN_NUM
PEN_NUM          equ 80
PLANE1_ADDR      equ 22
PLANE1_OFFSET    equ 26
PLANE2_OFFSET    equ 30
PLANE3_OFFSET    equ 34
RED_INTENSITY    equ 48
REPEATCOUNT      equ 108
REPEATRATE       equ 106
RGLTEMP1         equ 86
RGLTEMP2         equ 90
RGLTEMP3         equ 94
RGLTEMP4         equ 98
RGLTEMP5         equ 102
SOFTVEC          equ 114
SYSTEM_CMAP      equ 354

* addr1           equ    0                    integer
* addr2           equ   addr1+4               integer
* addr3           equ   addr2+4               integer

* n3              equ   addr3+4               shortint

* devicetype      equ   n3+2                  shortint
* deviceaddress   equ   devicetype+2          integer     only used on moonunit
* monitortype     equ   deviceaddress+4       shortint       ""   ""

* plane1_addr     equ   monitortype+2         integer
* plane1_offset   equ   plane1_addr+4         integer
* plane2_offset   equ   plane1_offset+4       integer
* plane3_offset   equ   plane2_offset+4       integer
* n_glines        equ   plane3_offset+4       shortint

* gspacing        equ   n_glines+2            shortint
* bytesperline    equ   gspacing+2            shortint

* hard_xmax       equ   bytesperline+2        shortint
* hard_ymax       equ   hard_xmax+2           shortint

* red_intensity   equ   hard_ymax+2           shortint
* grn_intensity   equ   red_intensity+2       shortint
* blu_intensity   equ   grn_intensity+2       shortint
* dither_pattern  equ   blu_intensity+2       16 bytes

* cursor_x        equ   dither_pattern+16     shortint
* cursor_y        equ   cursor_x+2            shortint

* area_draw_mode  equ   cursor_y+2            shortint
* pen_draw_mode   equ   area_draw_mode+2      shortint
* linepattern     equ   pen_draw_mode+2       shortint
* pen_num         equ   linepattern+2         shortint
* cpen            equ   pen_num+2             shortint
* oldpattern      equ   cpen+2                shortint
* rgltemp1        equ   oldpattern+2          integer
* rgltemp2        equ   rgltemp1+4            integer
* rgltemp3        equ   rgltemp2+4            integer
* rgltemp4        equ   rgltemp3+4            integer
* rgltemp5        equ   rgltemp4+4            integer
* repeatrate      equ   rgltemp5+4            shortint
* repeatcount     equ   repeatrate+2          shortint
* index           equ   repeatcount+2         integer
* softvec         equ   index+4               240 bytes of instructions
* system_cmap     equ   softvec+240
* * brightness_seq  equ   system_cmap+1536    removed for 3.1 implementation
* * count           equ   brightness_seq+512  SFB 12/14/84
* cmap_address    equ   system_cmap+1536      count+512

rule            equ   gle_types-4
window          equ   gle_types-8
status          equ   gle_types-20
stat            equ   $4001

charcount       equ   rgltemp1
t1              equ   rgltemp1
t2              equ   rgltemp2
t3              equ   rgltemp3
t4              equ   rgltemp4
t5              equ   rgltemp5

gle_gcb         equ   a4
rgl_gcb         equ   a6

zero            equ   d0
one             equ   d1
no              equ   d0
yes             equ   d1

packed_pixel_odd_byte_display equ 0
packed_pixel_display          equ 1
packed_pixel_3_plane_display  equ 2
byte_per_pixel_display        equ 3
gator_display                 equ 4
gatorbox_display              equ 5
bobcat_display                equ 6
bobcat_lores_display          equ 7
catseye_display               equ 8
catseye_hrx_display           equ 9
woodcut_vga_display           equ 10                               CFB - 31MAY91
woodcut_med_display           equ 11                               CFB - 31MAY91
woodcut_hrx_display           equ 12                               CFB - 31MAY91
woodcut_vgam_display          equ 13                               CFB - 30JUL91
woodcut_hrxm_display          equ 14                               CFB - 30JUL91

rrcopy                        equ sysdevs-92    gle_types global replrulecopy
wwcopy                        equ sysdevs-94    gle_types global widthcopy
writecopy                     equ sysdevs-96    gle_types global writeprotect
controladdr                   equ gle_types-30  gle_types global ID ROM base

hrm_tertiary                  equ 7             unique to CATSEYE HRM   {SFB}

tert_off                      equ $15           within ID ROM
initoffset                    equ $23           within ID ROM
cmapidoff                     equ $57           within ID ROM
cmapinitoff                   equ $3F           within ID ROM
blinkrega                     equ $6001         gatorbox
blinkregb                     equ $6005         gatorbox
writereg                      equ $6008         gatorbox
sox                           equ $40f2         bobcat source x
soy                           equ $40f6         bobcat source y
dox                           equ $40fa         bobcat dest x
doy                           equ $40fe         bobcat dest y
bobh                          equ $4106         bobcat height
bobw                          equ $4102         bobcat width
bobwr                         equ $40ee         bobcat window repl rule
bobwm                         equ $409c         bobcat window move start
curson                        equ $40ac         bobcat cursor enable SFB 6/11/85

pattregs                      equ $4400        CATSEYE pattern register base SFB
fben1                         equ $4500    frame buffer enable in upper byte SFB
trr                           equ $450c   upper byte=Three Operand Repl Rule SFB
trr_enable                    equ $4512        bit 8 of word selects trr/wrr SFB
catseye_status                equ $4800         catseye status in lower byte SFB

* unique WOODCUT register definitions                                CFB 10JUN91
blueregimage                  equ $00060610
dacimagewrite                 equ $00060202

            include ASM_TYPES
*
*
             page
*
*  utility subroutines
*
            rorg    0
rts         movem.l old_a5(gle_gcb),a5-a6
            rts

err_esc     movem.l old_a5(gle_gcb),a5-a6
            move    d0,sysglobals-2(a5)
            trap    #10

int_ovflow  move    #-4,d0                   integer overflow
            bra     err_esc

            page
*
*  procedure gcbinit(gcb: graphics_control_block_ptr);
*
gle_aras_out_rgcbinit equ *
            movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                      stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = ptr to device rec

            move.l  info_ptr1(gle_gcb),plane1_addr(rgl_gcb)
            move.l  info_ptr2(gle_gcb),plane1_offset(rgl_gcb)

            moveq   #0,d0
            moveq   #1,d1
            move.w  yes,complement_support(gle_gcb)  complement := true
            move.w  yes,non_dominant_support(gle_gcb)
            move.w  yes,erase_support(gle_gcb)
            move.w  yes,dither_support(gle_gcb)
            move.w  yes,polygon_support(gle_gcb)
            move.w  yes,polygon_fill_factor(gle_gcb)
            move.w  yes,polygon_solid_fill(gle_gcb)
            move.w  yes,background(gle_gcb)
            move.w  #-1,cont_linestyles(gle_gcb)
            move.w  zero,vect_linestyles(gle_gcb)
            move.w  one,linewidths(gle_gcb)
            move.w  #-1,char_sizes(gle_gcb)
            move.l  zero,current_pos_x(gle_gcb)
            move.l  zero,current_pos_y(gle_gcb)
            move.w  no,current_drawing_mode(gle_gcb)
            move.w  #-1,current_linestyle_pattern(gle_gcb)
            move.w  zero,current_cursor_state(gle_gcb)
            move.l  zero,current_cursor_x(gle_gcb)
            move.l  zero,current_cursor_y(gle_gcb)

*           cmpi.w  #3,info1+2(gle_gcb)             ck for device
*           blt.s   init16                          9816 or 9826
*           beq.s   init36                          9836A
*           cmpi.w  #5,info1+2(gle_gcb)
*           blt     init36c                         9836C
*           bgt.s   initGatbw                       Gator BW

            move.w  info1+2(gle_gcb),d2             compute jump table entry
            asl.w   #1,d2                           for dev dep initialize
            move.w  base_rgl(d2),d2
            jmp     init_rgl(d2)                    jump to dev dep initialize

base_rgl    equ     *-2                          "virtual" entry #0 of table
init_rgl    equ     *                            dev dep initialize jump table
            dc.w    init16-init_rgl
            dc.w    init16-init_rgl
            dc.w    init36-init_rgl
            dc.w    init36c-init_rgl
            dc.w    init27A-init_rgl
            dc.w    initGatbw-init_rgl
            dc.w    initgbox-init_rgl
            dc.w    initbobcat-init_rgl
            dc.w    initbobcatlores-init_rgl
            dc.w    initcatseye-init_rgl
            dc.w    initcatseye_hrx-init_rgl
            dc.w    initwoodcut_vga-init_rgl                       CFB - 31MAY91
            dc.w    initwoodcut_med-init_rgl                       CFB - 31MAY91
            dc.w    initwoodcut_hrx-init_rgl                       CFB - 31MAY91
            dc.w    initwoodcut_vgam-init_rgl                      CFB - 30JUL91
            dc.w    initwoodcut_hrxm-init_rgl                      CFB - 30JUL91

init27A     move.w  #packed_pixel_3_plane_display,devicetype(rgl_gcb) 98627a
            move.w  info3+2(gle_gcb),monitortype(rgl_gcb)
            move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
            move.w  no,color_map_support(gle_gcb)
            move.w  yes,redef_background(gle_gcb)
            move.l  #7,pallette(gle_gcb)
            move.l  #7,gamut(gle_gcb)
            bra     gen_init

init16      move.w  #packed_pixel_odd_byte_display,devicetype(rgl_gcb)
            bra     initcom

initGatbw   move.w  #gator_display,devicetype(rgl_gcb)
            bra     initcom

init36      move.w  #packed_pixel_display,devicetype(rgl_gcb)
initcom     move.w  no,color_map_support(gle_gcb)
            move.w  yes,redef_background(gle_gcb)
            move.l  one,pallette(gle_gcb)
            move.l  one,gamut(gle_gcb)       redone for bobcat B/W in GLE_RGL
            bra     gen_init

initgbox    move.w  #gatorbox_display,devicetype(rgl_gcb)
            move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
            move.l  info3(gle_gcb),cmap_address(rgl_gcb)
initcmapinfo equ    *
            move.w  yes,color_map_support(gle_gcb)
            move.w  yes,redef_background(gle_gcb)
            move.l  #16777216,pallette(gle_gcb) R,G,B each have 8 bits
* can't find gamut in rgcbinit for gatorbox or bobcat; done in setup routine
* in GLE_RGL !!!!!!!
            cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB -  9AUG91
            ble     gen_init                                       CFB -  9AUG91
            move.l  #256,pallette(gle_gcb)     G only has 8 bits   CFB -  9AUG91
            bra     gen_init

initwoodcut_vga equ     *                                          CFB - 31MAY91
            move.w  #woodcut_vga_display,devicetype(rgl_gcb)       CFB - 31MAY91
            bra.s   initwoodcutgen                                 CFB - 31MAY91

initwoodcut_med equ     *                                          CFB - 31MAY91
            move.w  #woodcut_med_display,devicetype(rgl_gcb)       CFB - 31MAY91
            bra.s   initwoodcutgen                                 CFB - 31MAY91

initwoodcut_hrx equ     *                                          CFB - 31MAY91
            move.w  #woodcut_hrx_display,devicetype(rgl_gcb)       CFB - 31MAY91
            bra.s   initwoodcutgen                                 CFB - 31MAY91

initwoodcut_vgam equ    *                                          CFB - 30JUL91
            move.w  #woodcut_vgam_display,devicetype(rgl_gcb)      CFB - 30JUL91
            bra.s   initwoodcutgen                                 CFB - 30JUL91

initwoodcut_hrxm equ    *                                          CFB - 30JUL91
            move.w  #woodcut_hrxm_display,devicetype(rgl_gcb)      CFB - 30JUL91
            bra.s   initwoodcutgen                                 CFB - 30JUL91

initcatseye equ     *
            move.w  #catseye_display,devicetype(rgl_gcb)
            bra.s   initbobcatgen

initcatseye_hrx equ     *
            move.w  #catseye_hrx_display,devicetype(rgl_gcb)
            bra.s   initbobcatgen

initbobcatlores equ *
            move.w  #bobcat_lores_display,devicetype(rgl_gcb)
            bra.s   initbobcatgen

initbobcat  equ     *
            move.w  #bobcat_display,devicetype(rgl_gcb)

* {SFB} hacked to allow HRM CATSEYE to be known as mono disply to DGL,
* and initialize GCB for same HRM CATSEYE IS "mono" but has cmap other
* CATSEYE/BOBCAT are color or have no cmap signal "mono" for HRM, and send
* back to gle_rgl

initbobcatgen equ   *
            movea.l info2(gle_gcb),a0
            move.l  a0,deviceaddress(rgl_gcb)
            cmpi.b  #hrm_tertiary,tert_off(a0)
            bne.s   get_cmap_info
            move.l  #0,info3(gle_gcb)

get_cmap_info equ   *
            move.l  info3(gle_gcb),cmap_address(rgl_gcb)
            beq     initcom
            bra     initcmapinfo

initwoodcutgen equ   *
            movea.l info2(gle_gcb),a0
            move.l  a0,deviceaddress(rgl_gcb)
            move.l  #0,info3(gle_gcb)
            move.l  info3(gle_gcb),cmap_address(rgl_gcb)
            bra     initcmapinfo

init36c     move.w  #byte_per_pixel_display,devicetype(rgl_gcb)
            move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
            move.l  info3(gle_gcb),cmap_address(rgl_gcb)
            move.w  yes,color_map_support(gle_gcb)
            move.w  yes,redef_background(gle_gcb)
            move.l  #4095,pallette(gle_gcb)
            move.l  #15,gamut(gle_gcb)

gen_init    move    devicetype(rgl_gcb),d0     choose frame buf info init block
            move    d0,d2
            cmpi.w  #7,devicetype(rgl_gcb)     ck for bobcatlores
            bne.s   ckbitmap
            move    #5,d0                      bobcatlores init block is #5
            bra.s   gen1

ckbitmap    equ     *
            cmpi.w  #6,info1+2(gle_gcb)        ck for Gator/gbox/bobcathires
            blt.s   gen1

            cmpi.w  #11,info1+2(gle_gcb)       ck for Catseye_hrx
            beq.s   adjust_catseye_hrx

            cmpi.w  #10,devicetype(rgl_gcb)    ck for WOODCUT      CFB - 24JUL91
            bge.s   adjust_woodcut                                 CFB - 31MAY91

            move    #4,d0               use initialize block 4 for Bobcat clones
            bra.s   gen1

adjust_woodcut equ  *                                              CFB - 31MAY91
            move    devicetype(rgl_gcb),d0                         CFB - 31MAY91
            subq    #3,d0                     convert 10-12 to 7-9 CFB - 31MAY91
            cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB - 30JUL91
            ble.s   gen1                                           CFB - 30JUL91
            subq    #3,d0                     convert 13-14 to 7-8 CFB - 30JUL91
            cmpi.w  #7,d0                      VGA?                CFB - 11OCT91
            beq.s   gen1                                           CFB - 11OCT91
            addq    #1,d0                     Hrx? convert 8 to 9  CFB - 11OCT91
            bra.s   gen1                                           CFB - 31MAY91

adjust_catseye_hrx equ  *
            move    #6,d0                      hrx block index
*                                              except LCC
*                                              of gator/gatorbox/bobcathires
*           cmpi.w  #7,info1+2(gle_gcb)        ck for Gator Color
*           bne.s   gen1
*           move    #5,d0

gen1        mulu    #init1-init_table,d0       calc offset into init_table
            movea.l d0,a0
            lea     init_table(a0),a0
            lea     plane2_offset(rgl_gcb),a1
            move.l  (a0)+,(a1)+                and offsets to display table
            move.l  (a0)+,(a1)+
            moveq   #4,d1
*           cmp     #2,d2
            bra     initloop

init_table  dc.l       0   plane2_offset       ( not used )      {9816A}
            dc.l       0   plane3_offset       ( not used )
            dc       300   n_glines
            dc         2   gspacing
            dc       100   bytesperline
            dc       399   hard_xmax
            dc       299   hard_ymax

init1       dc.l       0   plane2_offset       ( not used )      {9836a}
            dc.l       0   plane3_offset       ( not used )
            dc       390   n_glines
            dc         1   gspacing
            dc        64   bytesperline
            dc       511   hard_xmax
            dc       389   hard_ymax

init2       dc.l   $8000   plane2_offset                         {Moonunit}
            dc.l  $10000   plane3_offset
            dc       390   n_glines
            dc         1   gspacing
            dc        64   bytesperline
            dc       511   hard_xmax
            dc       389   hard_ymax

init3       dc.l       0   not used                              {9836c}
            dc.l       0   not used
            dc       390   n_glines
            dc         1   gspacing
            dc       512   bytesperline
            dc       511   hard_xmax
            dc       389   hard_ymax

init4       dc.l       0   not used               {Gator/gatorbox/bobcathires}
            dc.l       0   not used
            dc       752   n_glines
            dc         1   gspacing
            dc      1024   bytesperline
            dc      1023   hard_xmax
            dc       751   hard_ymax

init5       dc.l       0   not used               {bobcat lores block}
            dc.l       0   not used
            dc       385   n_glines
            dc         1   gspacing
            dc      1024   bytesperline
            dc       511   hard_xmax
            dc       384   hard_ymax

init6       dc.l       0   not used               {catseye_hrx block}
            dc.l       0   not used
            dc      1000   n_glines     only 1000 because we use 50 alpha lines
*                                       at 10 scan lines each, and don't offset
*                                       alpha the 4 "wasted" pixels as we do on
*                                       low-res Bobcat
            dc         1   gspacing
            dc      2048   bytesperline
            dc      1279   hard_xmax
            dc       999   hard_ymax

init7       dc.l       0   not used            {woodcut_vga block} CFB - 31MAY91
            dc.l       0   not used                                CFB - 31MAY91
            dc       464   n_glines                                CFB - 31MAY91
            dc         1   gspacing                                CFB - 31MAY91
            dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
            dc       639   hard_xmax                               CFB - 31MAY91
            dc       463   hard_ymax                               CFB - 31MAY91

init8       dc.l       0   not used            {woodcut_med block} CFB - 31MAY91
            dc.l       0   not used                                CFB - 31MAY91
            dc       752   n_glines                                CFB - 31MAY91
            dc         1   gspacing                                CFB - 31MAY91
            dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
            dc      1023   hard_xmax                               CFB - 31MAY91
            dc       751   hard_ymax                               CFB - 31MAY91

init9       dc.l       0   not used            {woodcut_hrx block} CFB - 31MAY91
            dc.l       0   not used                                CFB - 31MAY91
            dc      1000   n_glines                                CFB - 31MAY91
            dc         1   gspacing                                CFB - 31MAY91
            dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
            dc      1279   hard_xmax                               CFB - 31MAY91
            dc       999   hard_ymax                               CFB - 31MAY91

initloop    move    (a0)+,(a1)+                copy some stuff from init_table
            dbra    d1,initloop
            moveq   #16,d0
            move    d0,(a1)+                   set default fill colors
            move    d0,(a1)+
            move    d0,(a1)+
            move    #$FFFF,current_linestyle_pattern(gle_gcb)
            clr     oldpattern(rgl_gcb)
            move    #1,repeatcount(rgl_gcb)
            move    #1,repeatrate(rgl_gcb)

            bsr     build_pen                  | create 1st vec template

*  if the device is a 98627 or 98627 gload image, n_glines must be
*  calculated.  if monitor type = (1,2,6) then n_glines and the
*  other parameters associated with variable height (hard_ymax,
*  etc) are already correct.

            cmpi.b  #2,devicetype+1(rgl_gcb)
            bne     set_pen                    not a 98627 style image
            cmpi    #3,monitortype(rgl_gcb)
            blt     init_regs                  n_glines is already set up
            beq.s   init474
            cmpi    #6,monitortype(rgl_gcb)
            bge     init_regs                  n_glines is already set up
init512     move   #512,n_glines(rgl_gcb)
            move   #511,hard_ymax(rgl_gcb)
            bra    init_regs
init474     move   #474,n_glines(rgl_gcb)
            move   #473,hard_ymax(rgl_gcb)

init_regs   move    monitortype(rgl_gcb),d0
            cmp     #1,d0
            blt     set_pen                    make sure 1 <= monitortype <= 6
            cmp     #6,d0                      to prevent hardware damage
            bgt     set_pen
            lsl     #4,d0                      calculate offset into
            lea     usstd(d0),a0               setup table for 6845
            movea.l deviceaddress(rgl_gcb),a1
            moveq   #15,d0
setuploop   move.b  d0,$10(a1)                 select a register
            move.b  -(a0),$12(a1)              write a value
            dbra    d0,setuploop
            bra     set_pen

usstd       dc.b    41     horizontal total
            dc.b    32     horizontal displayed
            dc.b    34     horizontal sync position
            dc.b     3     horizontal sync width
            dc.b    50     vertical total
            dc.b     5     vertical total adjust
            dc.b    49     vertical displayed
            dc.b    49     vertical sync position
            dc.b     0     interlace mode
            dc.b     7     max scan line address
            dc.b     0     cursor start  (don't care)
            dc.b     0     cursor end    (don't care)
            dc.b     0     start address (upper byte)
            dc.b     0     start address (lower byte)
            dc.b     0     cursor h      (don't care)
            dc.b     0     cursor l      (don't care)

eurostd     dc.b    41     horizontal total
            dc.b    32     horizontal displayed
            dc.b    34     horizontal sync position
            dc.b     3     horizontal sync width
            dc.b    61     vertical total
            dc.b     0     vertical total adjust
            dc.b    49     vertical displayed
            dc.b    55     vertical sync position
            dc.b     0     interlace mode
            dc.b     7     max scan line address
            dc.b     0     cursor start  (don't care)
            dc.b     0     cursor end    (don't care)
            dc.b     0     start address (upper byte)
            dc.b     0     start address (lower byte)
            dc.b     0     cursor h      (don't care)
            dc.b     0     cursor l      (don't care)

ustv        dc.b    39     horizontal total
            dc.b    32     horizontal displayed
            dc.b    34     horizontal sync position
            dc.b     3     horizontal sync width
            dc.b    31     vertical total
            dc.b     6     vertical total adjust
            dc.b    30     vertical displayed
            dc.b    30     vertical sync position
            dc.b     3     interlace mode
            dc.b     7     max scan line address
            dc.b     0     cursor start  (don't care)
            dc.b     0     cursor end    (don't care)
            dc.b     0     start address (upper byte)
            dc.b     0     start address (lower byte)
            dc.b     0     cursor h      (don't care)
            dc.b     0     cursor l      (don't care)

eurotv      dc.b    39     horizontal total
            dc.b    32     horizontal displayed
            dc.b    34     horizontal sync position
            dc.b     3     horizontal sync width
            dc.b    38     vertical total
            dc.b     0     vertical total adjust
            dc.b    32     vertical displayed
            dc.b    35     vertical sync position
            dc.b     3     interlace mode
            dc.b     7     max scan line address
            dc.b     0     cursor start  (don't care)
            dc.b     0     cursor end    (don't care)
            dc.b     0     start address (upper byte)
            dc.b     0     start address (lower byte)
            dc.b     0     cursor h      (don't care)
            dc.b     0     cursor l      (don't care)

hires       dc.b    41     horizontal total
            dc.b    32     horizontal displayed
            dc.b    34     horizontal sync position
            dc.b     3     horizontal sync width
            dc.b    65     vertical total
            dc.b     5     vertical total adjust
            dc.b    64     vertical displayed
            dc.b    64     vertical sync position
            dc.b     0     interlace mode
            dc.b     7     max scan line address
            dc.b     0     cursor start  (don't care)
            dc.b     0     cursor end    (don't care)
            dc.b     0     start address (upper byte)
            dc.b     0     start address (lower byte)
            dc.b     0     cursor h      (don't care)
            dc.b     0     cursor l      (don't care)

jvc         dc.b    44     horizontal total
            dc.b    32     horizontal displayed
            dc.b    36     horizontal sync position
            dc.b     3     horizontal sync width
            dc.b    56     vertical total
            dc.b     5     vertical total adjust
            dc.b    49     vertical displayed
            dc.b    49     vertical sync position
            dc.b     0     interlace mode
            dc.b     7     max scan line address
            dc.b     0     cursor start  (don't care)
            dc.b     0     cursor end    (don't care)
            dc.b     0     start address (upper byte)
            dc.b     0     start address (lower byte)
            dc.b     0     cursor h      (don't care)
            dc.b     0     cursor l      (don't care)
            page

*
*  procedure store_dit(gcb:anyptr);
*
gle_aras_out_store_dit   equ *
            movea.l 4(sp),gle_gcb                   a4 = addr of pointer to gcb
            move.l  (sp)+,(sp)                      stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec_ptr

loopstA     movea.l status(a5),a0
            btst    #7,1(a0)
            beq.s   loopstA
            moveq   #3,d0
            move.w  d0,rrcopy(a5)                   update current repl. rule
            movea.l rule(a5),a0                     setup repl. rule
            move.w  d0,(a0)
            movea.l plane1_addr(rgl_gcb),a1         ptr to address
            movea.l (a1),a1
            adda.l  plane1_offset(rgl_gcb),a1       upper right display address
            adda.l  #$0FF000,a1                     a1 points to 3rd to last line
            move.l  dither_pattern(rgl_gcb),(a1)
            move.l  dither_pattern+4(rgl_gcb),$400(a1)
            move.l  dither_pattern+8(rgl_gcb),$800(a1)
            move.l  dither_pattern+12(rgl_gcb),$C00(a1)

loopstB     movea.l status(a5),a0
            btst    #7,1(a0)
            beq.s   loopstB
            moveq   #$83,d0
            move.w  d0,rrcopy(a5)                   update current repl. rule
            movea.l rule(a5),a0                     set up replacement rule
            move.w  d0,(a0)
            moveq   #3,d0
loopst1     moveq   #4,d1
loopst2     move    d1,d2

loopstC     movea.l status(a5),a0
            btst    #7,1(a0)
            beq.s   loopstC
            neg     d2
            move.w  d2,wwcopy(a5)                   update current window width
            movea.l window(a5),a0                   set window width
            move.w  d2,(a0)

            move.b (a1),0(a1,d1)                    move some bytes

            lsl     #1,d1                           d1=2*d1
loopst3     movea.l status(a5),a0
            btst    #7,1(a0)
            beq.s   loopst3
            cmpi    #512,d1
            ble.s   loopst2
            adda    #$400,a1                        bump a1 to next line
            dbra    d0,loopst1
loopst4     movea.l status(a5),a0
            btst    #7,1(a0)
            beq.s   loopst4
            moveq   #3,d0                           Restore rep rule
            move.w  d0,rrcopy(a5)                   update current repl. rule
            movea.l rule(a5),a0                     set up replacement rule
            bra     rts

*
*  procedure set_6845s(gcb:anyptr);
*   set up gator 6845's from Gator ROM
*

gle_aras_out_set_6845s   equ *
            movea.l  4(sp),gle_gcb                   a4 = addr of pointer to gcb
            move.l   (sp)+,(sp)                      stack return address
            movem.l  a5-a6,old_a5(gle_gcb)
            movea.l  dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec_ptr
            cmpi.b   #5,devicetype+1(rgl_gcb)   gatorbox/bobcat both use std
            bge      std_graphics_rom           graphics ID ROM

gator_rom   equ      *
            movea.l  controladdr(a5),a0    get pointer to ROM start
            moveq    #0,d0
            moveq    #0,d1
            move.b   stat(a0),d0            get status reg again
            lsr.b    #2,d0                  get monitor type bits
            and.b    #12,d0
            move.b   initoffset(a0,d0.w),d1  get MSB of info addr offset
            lsl.w    #8,d1
            move.b   initoffset+2(a0,d0.w),d1  get LSB of info addr offset
            movea.l  a0,a1                  make copy of ROM start addr
            adda     d1,a1                  a1 points to init info now
            jsr      ginitblock             call the initialization routine
            bra      rts                    that's all for gator

* ginitblock is common code for both gator ROM, and gatorbox/bobcat ROM
ginitblock  moveq    #0,d1                  clear some regs
            moveq    #0,d0
            move.b   2(a1),d0               get word count to initialize
            movep    4(a1),d1               form destination offset
            add.l    a0,d1                  d1 points to dest addr
            lea      8(a1),a2               a2 points to first data byte
            movea.l  d1,a3                  a3 points to destination
            btst     #0,(a1)                added for bit_test SFB 3 Mar '88
            bne.s    bit_test             see new Graphics ID ROM definition SFB
ginitloop   movep    0(a2),d1                form a data word in d1
            move.w   d1,(a3)+               move data to the destination addr
            btst     #6,(a1)                increment data pointer
            bne.s    ginit1                 based on control byte
            addq     #4,a2
ginit1      dbra     d0,ginitloop           loop till word count exhausted
            btst     #7,(a1)                was this last block?
            bne.s    ginitdone              yes -- go return
            btst     #6,(a1)                adjust data pointer
            beq.s    ginit2                 to point to next init block
finish_block equ     *                      point to next block SFB
            addq     #4,a2
ginit2      movea.l  a2,a1                  a1 points to new init block
            bra      ginitblock             do the initialize

bit_test    move.b   2(a2),d2               bit number to test SFB
            and.b    #$0f,d2                ensure bitnum #0..#15 SFB
            tst.b    (a2)                   compare bit to 0 or to 1? SFB
            bne      test_for_1             SFB
test_for_0  equ      *                      wait for 0 in bit d2 of d3 SFB
            move.w   (a3),d3                status word to test SFB
            btst     d2,d3                  ready? SFB
            bne      test_for_0
            bra      finish_block           and got to next block SFB
test_for_1  equ      *                      wait for 0 in bit d2 of d3 SFB
            move.w   (a3),d3                status word to test SFB
            btst     d2,d3                  ready? SFB
            beq      test_for_1
            bra      finish_block           and got to next block SFB
ginitdone   rts                             3.1E BUGFIX SFB 6/13/85

std_graphics_rom equ *
            movea.l  controladdr(a5),a0     get pointer to ROM start
            movep    initoffset(a0),d1      form pointer to init block 0
            movea.l  a0,a1                  make copy of ROM start addr
            adda     d1,a1                  a1 points to init info now

* bobcat CURSON save/restore added SFB 6/11/85
            cmpi.b   #6,devicetype+1(rgl_gcb)  for bobcat save CURSON register
            blt.s    do_ginit
            move.b   curson(a0),rgltemp1(rgl_gcb) save value of CURSON
do_ginit    jsr      ginitblock             call the initialization routine
            cmpi.b   #6,devicetype+1(rgl_gcb) for bobcat restore CURSON
            blt.s    init_cmapstuff
            move.b   rgltemp1(rgl_gcb),curson(a0) restore value of CURSON
init_cmapstuff equ *    SFB 6/11/85

*  DO NOT DO CMAP INIT TRAVERSAL, AS IT RESETS COLORS
*  0,1,254,255. WILL SET TCOL (NEREID) IN GLE_RGL      SFB 6/25/85
*           movep    cmapidoff(a0),d0       get ptr to color map id reg
*           tst      d0                     if ptr = 0 then no color map
*           beq.s    std_rom_done
*           move.b   0(a0,d0),d1            get cmap id into d1
*           and      #3,d1                  look at least sig bits
*           lsl      #2,d1
*           move.b   cmapinitoff(a0,d1.w),d2  form cmap init block addr
*           lsl      #8,d2
*           move.b   cmapinitoff+2(a0,d1.w),d2
*           movea.l  a0,a1
*           adda     d2,a1                  a1 points to cmap init block
*           jsr      ginitblock

std_rom_done equ     *
            bra      rts

*
*  procedure graphics_on_off ( gcb : graphics_control_block_ptr )
*
gle_aras_out_rgraphics_on_off equ *
*
            movea.l 4(sp),gle_gcb              a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                 stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb
            move.w  devicetype(rgl_gcb),d0
            cmp.w   #2,d0                      moonunit is only device that
            beq.s   on_off_tst                 supports this call
            bra rts

on_off_tst  add.w   d0,d0
            tst.l   info1(gle_gcb)             { info1 = 0 is goff }
            beq.s   goff_98627

gon_98627   movea.l deviceaddress(rgl_gcb),a0
            move.b  #$80,1(a0)
            bra rts

goff_98627  movea.l deviceaddress(rgl_gcb),a0
            move.b  #0,1(a0)
            bra rts
            page
************************************************************************
*
moon_map2   dc.b    0             0
            dc.b    7             1  white
            dc.b    4             2  red
            dc.b    6             3  yellow
            dc.b    2             4  green
            dc.b    3             5  cyan
            dc.b    1             6  blue
            dc.b    5             7  magenta

****************************************************************************
*
*  procedure clear ( gcb : graphics_control_block_ptr )
*
*    INFO1 = Plane clear information
*    INFO2 = Plane select information
*
gle_aras_out_rclear   equ *
            movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                      stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb
            move.l  info1(gle_gcb),d7               clear ? plane word
            bne.s   gclr0
            move.l  #-1,d7
gclr0       movea.l plane1_addr(rgl_gcb),a0         ptr to address
            movea.l (a0),a0
            adda.l  plane1_offset(rgl_gcb),a0       upper right display address
gclr1       cmpi.b  #3,devicetype+1(rgl_gcb)
            beq     gclr36c

            movea.l a0,a1
            movea.l a0,a2
            adda.l  plane2_offset(rgl_gcb),a1
            adda.l  plane3_offset(rgl_gcb),a2

            moveq   #0,d3
            move.b  info2+3(gle_gcb),d3
            cmpi.w  #2,devicetype(rgl_gcb)   ck for moonunit
            bne.s   g0
            move.b  moon_map2(d3),d3         remap for moonunit

g0          moveq   #0,d0
            btst    #0,d3
            beq.s   g1
            moveq   #-1,d0

g1          moveq   #0,d1
            btst    #1,d3
            beq.s   g2
            moveq   #-1,d1

g2          moveq   #0,d2
            btst    #2,d3
            beq.s   g3
            moveq   #-1,d2

g3          move    n_glines(rgl_gcb),d6
            cmpi.b  #2,devicetype+1(rgl_gcb)   if it's color, we have to clear
            bne.s   gclr1a                     everything.
            move    #512,d6
gclr1a      mulu    bytesperline(rgl_gcb),d6
gclr4       lsr.l   #2,d6                      d6 = # of long words to clear
            ror.l   #3,d6                      do them in groups of 8 longwords
            cmpi.b  #2,devicetype+1(rgl_gcb)
            beq.s   gclrloop
            and.b   #$1,d7                     mask off green and red for b&w

gclrloop    btst    #0,d7                      alter plane1 ?
            beq.s   gclrloop1
            move.l  d0,(a0)+
            move.l  d0,(a0)+
            move.l  d0,(a0)+
            move.l  d0,(a0)+
            move.l  d0,(a0)+
            move.l  d0,(a0)+
            move.l  d0,(a0)+
            move.l  d0,(a0)+
gclrloop1   btst    #1,d7                      alter plane2 ?
            beq.s   gclrloop2
            move.l  d1,(a1)+
            move.l  d1,(a1)+
            move.l  d1,(a1)+
            move.l  d1,(a1)+
            move.l  d1,(a1)+
            move.l  d1,(a1)+
            move.l  d1,(a1)+
            move.l  d1,(a1)+
gclrloop2   btst    #2,d7                      alter plane3 ?
            beq.s   gclrloop3
            move.l  d2,(a2)+
            move.l  d2,(a2)+
            move.l  d2,(a2)+
            move.l  d2,(a2)+
            move.l  d2,(a2)+
            move.l  d2,(a2)+
            move.l  d2,(a2)+
            move.l  d2,(a2)+
gclrloop3   subq    #1,d6
            bne     gclrloop                   Changed from bgt - CFB 2DEC91
            rol.l   #3,d6
            beq     rts

*  loop to finish any left-over words

gclrlp      btst    #0,d7                      alter plane1 ?
            blt.s   gclrlp1
            move.l  d0,(a0)+
gclrlp1     btst    #1,d7                      alter plane2 ?
            blt.s   gclrlp2
            move.l  d1,(a1)+
gclrlp2     btst    #2,d7                      alter plane3 ?
            blt.s   gclrlp3
            move.l  d2,(a2)+
gclrlp3     subq    #1,d6
            bgt     gclrlp
            bra     rts

gclr36c     move    n_glines(rgl_gcb),d0
            mulu    bytesperline(rgl_gcb),d0
            adda.l  d0,a0

            and.l   #15,d7
            cmpi.b  #15,d7
            beq.s   gclr36c_all

            move.l  d7,d2
            asl.l   #8,d2
            add.l   d7,d2
            asl.l   #8,d2
            add.l   d7,d2
            asl.l   #8,d2
            add.l   d7,d2
            not.l   d2

            lsr.l   #4,d0              div by 16
            subq.l  #1,d0

g36c_ploop  equ *
            and.l   d2,-(a0)
            and.l   d2,-(a0)
            and.l   d2,-(a0)
            and.l   d2,-(a0)
            dbra    d0,g36c_ploop
            bra     rts


gclr36c_all equ *
            divu    #192,d0                    clear 48 long words at a time
            subq    #1,d0
            ext.l   d0
            moveq   #0,d1
            move.l  d1,d2
            move.l  d1,d3
            move.l  d1,d4
            move.l  d1,d5
            move.l  d1,d6
            move.l  d1,d7
            movea.l d1,a1
            movea.l a1,a2
            movea.l a1,a3
            movea.l a1,a5
            movea.l a1,a6
gclrloop36  movem.l d1-d7/a1-a3/a5/a6,-(a0)
            movem.l d1-d7/a1-a3/a5/a6,-(a0)
            movem.l d1-d7/a1-a3/a5/a6,-(a0)
            movem.l d1-d7/a1-a3/a5/a6,-(a0)
            dbra    d0,gclrloop36
            bra     rts
*****************************************************************************
*
*  procedure move (gcb: graphics_control_block_ptr);
*
gle_aras_out_rmove    movea.l 4(sp),gle_gcb      a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                 stack return address
            move.l  end_x(gle_gcb),d4
            move.l  end_y(gle_gcb),d5
            move.l  d4,current_pos_x(gle_gcb)
            move.l  d5,current_pos_y(gle_gcb)
            rts
            page

*****************************************************************************
*
clip_draw   equ *
            exg     d5,d6
            jsr     gle_asclip_clipping
            exg     d5,d6
            cmpi.b  #1,d0
            ble.s   vector1
            bra     rts

*****************************************************************************
*
clip_xmin equ a0
clip_xmax equ a1
clip_ymin equ a2
clip_ymax equ a3
*
*  procedure draw (gcb: graphics_control_block_ptr);
*
gle_aras_out_rdraw    movea.l 4(sp),gle_gcb      a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                 stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb

            move.l  current_pos_x(gle_gcb),d4
            move.l  current_pos_y(gle_gcb),d6
            move.l  end_x(gle_gcb),d5
            move.l  end_y(gle_gcb),d7
            move.l  d5,current_pos_x(gle_gcb)
            move.l  d7,current_pos_y(gle_gcb)

            movem.l clip_limits_xmin(gle_gcb),a0-a3
            cmp.l   clip_xmin,d4                      x0 < clip_xmin
            blt.s   clip_draw
            cmp.l   clip_xmax,d4                      x0 > clip_xmax
            bgt.s   clip_draw
            cmp.l   clip_ymin,d6                      y0 < clip_ymin
            blt.s   clip_draw
            cmp.l   clip_ymax,d6                      y0 > clip_ymax
            bgt.s   clip_draw
            cmp.l   clip_xmin,d5                      x1 < clip_xmin
            blt.s   clip_draw
            cmp.l   clip_xmax,d5                      x1 > clip_xmax
            bgt.s   clip_draw
            cmp.l   clip_ymin,d7                      y1 < clip_ymin
            blt.s   clip_draw
            cmp.l   clip_ymax,d7                      y1 > clip_ymax
            bgt.s   clip_draw

vector1     movea.l plane1_addr(rgl_gcb),a0
            movea.l (a0),a0                        get address
            adda.l  plane1_offset(rgl_gcb),a0      upper right display address
            movem.l plane2_offset(rgl_gcb),a2/a3
            move    gspacing(rgl_gcb),d0
            subq    #1,d0
            adda.w  d0,a0                        adjust for 16/26 odd addressing
            move    current_linestyle_pattern(gle_gcb),oldpattern(rgl_gcb)

            movea.l status(a5),a1      prepare to check line/block mover ready
            cmpi.b  #gator_display,devicetype+1(rgl_gcb)
            bne.s   checkgbox
loopstg     btst    #7,1(a1)           wait for gator line mover
            beq.s   loopstg
            bra.s   setvec_rr
checkgbox   cmpi.b  #gatorbox_display,devicetype+1(rgl_gcb)
            bne.s   checkbobcat
waitgboxbm  btst    #4,(a1)            wait for gatorbox tile mover
            bne     waitgboxbm
            bra.s   setvec_rr
checkbobcat cmpi.b  #bobcat_display,devicetype+1(rgl_gcb)
            blt.s   vec1                bugfix 3.1C SFB 5/23/85
checkwoodcut cmpi.b  #catseye_hrx_display,devicetype+1(rgl_gcb)      CFB 10JUN91
            bgt.s   vec1                                             CFB 10JUN91
* don't need to wait for window mover to change bobcat pixel repl rule !!!
            move.w  #$300,d3                       special case for bobcat
            bra.s   do_set_rr                      repl rule 3 in msb of word

setvec_rr   moveq   #3,d3                          generic repl rule 3
do_set_rr   movea.l rule(a5),a1
            move.w  d3,(a1)                        and set (pixel) repl rule

vec1        cmp     d6,d7                          if y1=y2
            bne.s   vec2                           and if solid line
            cmpi    #-1,current_linestyle_pattern(gle_gcb)
            bne.s   vec2
            move    pen_draw_mode(rgl_gcb),d0      and if draw mode is dominant
            bne.s   vec2
            bra     horiz_vec                      then draw horizontal vector
vec2        moveq   #0,d0                          clear  'y1:y2 swapped'  flag
            move    d7,d2
            sub     d6,d2                      d2 = y2 - y1
            bge.s   d2plus                     y2 was > y1
            neg     d2                         make y2 > y1
            exg     d4,d5
            exg     d6,d7                      d6 = smaller y
            moveq   #1,d0                      set [y1:y2 swapped] flag
d2plus      sub     d4,d5                      d5 = x2-x1
            move    current_linestyle_pattern(gle_gcb),d3
            cmp     #-1,d3
            beq.s   vec6                       solid line : all is well
            move    d5,d1                      d1 = x2-x1
            bge.s   vec3
            neg     d1                         d1 = abs(x2-x1)
vec3        cmp     d1,d2                      d1 = # of pixels in vector
            blt.s   vec4
            move    d2,d1
vec4        move    current_linestyle_pattern(gle_gcb),d3
*
* Non-trivial fixup of the repeat pattern based on repeatcount
* and repeatrate:  The final current_linestyle_pattern and repeatcount are
* calculated before the vector loop is entered.  This prevents a messy
* self-modification section in the vector generator itself, and limits all self
* modifying code to subroutine 'buildpen'.  If the line must be drawn backwards
* (i.e. the passed y2 was less than y1), the final current_linestyle_pattern and
* repeatcount calculated here are used as the starting point.
*
* Of course, all of this is skipped for solid lines
*

            move    repeatcount(rgl_gcb),t4(rgl_gcb)
            cmp     repeatcount(rgl_gcb),d1
            blt.s   smallvec
            sub     repeatcount(rgl_gcb),d1
            ext.l   d1
            divu    repeatrate(rgl_gcb),d1
            addq    #1,d1                      Q=Q+1
            rol     d1,d3                      rotate the current_linestyle_pattern
            swap    d1                         d1 = R
            neg     d1
            add     repeatrate(rgl_gcb),d1          d1=repeatrate-R
            move    d1,repeatcount(rgl_gcb)
            bra.s   vec5

smallvec    sub     d1,repeatcount(rgl_gcb)

vec5        move    d3,oldpattern(rgl_gcb)          update oldpattern for next pass
            tst     d0
            beq.s   vec6
            lsl.b   #1,d3                      swap the 16 bits in d3
            roxr    #1,d3
            roxl.b  #2,d3
            roxr    #1,d3
            roxl.b  #2,d3
            roxr    #1,d3
            roxl.b  #2,d3
            roxr    #1,d3
            roxl.b  #2,d3
            roxr    #1,d3
            roxl.b  #2,d3
            roxr    #1,d3
            roxl.b  #2,d3
            roxr    #1,d3
            roxl.b  #2,d3
            roxr    #1,d3
            roxl.b  #2,d3
            ror     #1,d3
            move    d3,current_linestyle_pattern(gle_gcb)      start with last pattern
            move    repeatrate(rgl_gcb),d0
            sub     repeatcount(rgl_gcb),d0
            addq    #1,d0
            move    d0,t4(rgl_gcb)

vec6        movea   bytesperline(rgl_gcb),a1
            not     d6                         d6 = -y-1
            add     n_glines(rgl_gcb),d6            d6 = (n_glines-1)-y
            mulu    bytesperline(rgl_gcb),d6
            adda.l  d6,a0                      a0 = addr of line with 1st pixel
            cmpi.b  #3,devicetype+1(rgl_gcb)   if 36c/gatorgatorbox/bobcat
            blt.s   not36c                     then do 36c stuff

* compute address of first pixel for byte/pixel frame buffer
            adda    d4,a0                      add x1 to start address
            move    cpen(rgl_gcb),d0           d0 = pen (or not pen if erase)
            cmpi.b  #7,devicetype+1(rgl_gcb)   bobcatlores ?
            bne     vecready
            mulu    #257,d0                    yes, dup pen value in both bytes
            adda    d4,a0                      and double x1 for "real" pixels
            bra.s   vecready

* compute address and bit position of first pixel for bit/pixel frame buffer
not36c      move    gspacing(rgl_gcb),d0
            move    d0,d6
            subq    #1,d0
            move    d4,d1                      d1 = starting x
            lsr     #3,d1
            lsl     d0,d1
            adda    d1,a0                      a0 points to first byte to alter
            and     #7,d4                      d4 = bit number of first pixel
            moveq   #$80,d0                    d0 = bit pattern to rotate
            ror.b   d4,d0                      align it for starting position
            move    d0,d1
            not     d1                         use d1 for the 'and' mask
vecready    move    #$8000,d3                  sum = 0.50000
            move    current_linestyle_pattern(gle_gcb),d4
            movea   repeatrate(rgl_gcb),a5
            move    t4(rgl_gcb),d7

            jsr     softvec(rgl_gcb)

            move    oldpattern(rgl_gcb),current_linestyle_pattern(gle_gcb)
            bra     rts

horiz_vec   cmp     d4,d5
            bge.s   hv10
            exg     d4,d5
hv10        not     d6                         d6 = -y-1
            add     n_glines(rgl_gcb),d6       d6 = (n_glines-1)-y
            mulu    bytesperline(rgl_gcb),d6
            adda.l  d6,a0                      a0 = addr of line with 1st pixel
            move    d4,d2                      d2=d4=x1
            move    d5,d3                      d3=d5=x2
            cmpi.b  #3,devicetype+1(rgl_gcb)
            bge     hv50                       36C/gator/gatorbox/bobcat
*           bgt     hvgat
            lsr     #3,d2                      d2=x1 div 8
            lsr     #3,d3                      d3=x2 div 8
            and     #7,d4                      d4=x1 mod 8
            and     #7,d5                      d5=x2 mod 8
            sub     d2,d3                      d3=# of bytes to do - 1
            addq    #1,d5
            adda    d2,a0                      a0 points to 1st byte to modify
            movea   gspacing(rgl_gcb),a1
            tst     devicetype(rgl_gcb)        9816 or 9826 ?
            bne.s   hv20
            adda    d2,a0                      on 9826 & 9816 add it twice
hv20        moveq   #-1,d2
            btst    #1,devicetype+1(rgl_gcb)   is this color ?
            beq.s   hv30                       no
            adda.l  a0,a2                      a2 points to green plane
            adda.l  a0,a3                      a3 points to red plane
            move    d3,d6                      save the byte count (d1)
            moveq   #-1,d2
            btst    #2,pen_num+1(rgl_gcb)
            bne.s   hv22
            moveq   #0,d2
hv22        bsr.s   hv40                       draw the blue plane
            move    d6,d3                      restore the byte count
            movea.l a2,a0                      a0 points to green plane
            moveq   #-1,d2
            btst    #1,pen_num+1(rgl_gcb)
            bne.s   hv24
            moveq   #0,d2
hv24        bsr.s   hv40                       draw the green plane
            move    d6,d3                      restore byte count
            movea.l a3,a0                      a0 points to red plane
            moveq   #-1,d2
            btst    #0,pen_num+1(rgl_gcb)
            bne.s   hv30
            moveq   #0,d2
hv30        bsr.s   hv40
            bra     rts

hv40        tst     d3                         how many bytes are effected ?
            bne.s   hv41                       more than one
            move.b  (a0),d2                    g->mask.b
            rol.b   d5,d2
            rol     d4,d2
            ror     d5,d2                      ror.w x2b-x1b+1,mask
            ror.b   d4,d2
            move.b  d2,(a0)                    mask->g
            rts

hv41        move.b  (a0),d0
            rol     d4,d0
            move.b  d2,d0
            rol.b   d4,d0
            ror     d4,d0
            move.b  d0,(a0)
            adda.l  a1,a0
            subq    #2,d3
            blt.s   hv43
hv42        move.b  d2,(a0)
            adda.l  a1,a0
            dbra    d3,hv42
hv43        rol     d5,d2
            move.b  (a0),d2
            rol.b   d5,d2
            ror     d5,d2
            move.b  d2,(a0)
            rts

hv50        cmpi.b  #7,devicetype+1(rgl_gcb)   bobcatlores ?
            bne.s   hv50_a                     NO
            asl     #1,d2                      double x1 for "real" pixel
            asl     #1,d3                      double x2 for "real" pixel
            addq    #1,d3                      and fill to end (SFB 7/8/85}
            asl     #1,d4                      double x1 for "real" pixel
            asl     #1,d5                      double x2 for "real" pixel
            addq    #1,d5                      and fill to end (SFB 7/8/85}
hv50_a      equ     *
            and     #3,d4                      x1 mod 4
            and     #3,d5                      x2 mod 4
            lsl     #2,d4                      (x1 mod 4)*4  mask index
            lsl     #2,d5                      (x2 mod 4)*4  mask index
            and     #$fffc,d2                  x1 div 4
            adda    d2,a0                      (a0) first long w that changes
            lsr     #2,d2                      # of nibbles to x1
            lsr     #2,d3                      # of nibbles to x2
            sub     d2,d3                      # of nibbles to do -1
            move    cpen(rgl_gcb),d0
            move    d0,d1
            lsl     #8,d0
            move.b  d1,d0
            move    d0,d1
            swap    d0
            move    d1,d0
            move.l  d0,d1
            move.l  hvmask1(d4),d4
            tst     d3
            bne.s   hv52
hv51        and.l   hvmask2(d5),d4
            moveq   #0,d3
hv52        and.l   d4,d1
            not.l   d4
            and.l   d4,(a0)
            or.l    d1,(a0)+
            dbra    d3,hv53
            bra     rts
hv53        moveq   #-1,d4
            move.l  d0,d1
            tst     d3
            beq.s   hv51
            subq    #1,d3
hv54        move.l  d0,(a0)+
            dbra    d3,hv54
            bra.s   hv51


hvmask1     dc.l   $ffffffff
            dc.l   $00ffffff
            dc.l   $0000ffff
            dc.l   $000000ff

hvmask2     dc.l   $ff000000
            dc.l   $ffff0000
            dc.l   $ffffff00
            dc.l   $ffffffff


            page
****************************************************************************
*
* DEFINE_DRAWING_MODE ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*   Modes are:
*     INFO1 = 0 - Dominant
*           = 1 - Erase
*           = 2 - Non-dominant
*           = 3 - Complement
*
gle_aras_out_rdefine_drawing_mode equ *
*
            movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
            move.l  (sp)+,(sp)
            movem.l a5/a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep_gcb

            move.l  info1(gle_gcb),d0               d0 = new drawing mode
            move.w  d0,current_drawing_mode(gle_gcb)
            bra     set_pen

****************************************************************************
*
* SET_COLOR ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*   Color index is in INFO1
*
*   Note:  Colors are assigned as follows on non-color map units:
*          INFO1 = 0 - Undefined
*                  1 - White
*                  2 - Red
*                  3 - Yellow
*                  4 - Green
*                  5 - Cyan
*                  6 - Blue
*                  7 - Magenta
*
*          On color map units, the pen number is the index to the CMAP
*
gle_aras_out_rset_color equ *
*
            movea.l 4(sp),gle_gcb                 a4 = address of pointer to gcb
            move.l  (sp)+,(sp)
            movem.l a5/a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb

            move.w  info1+2(gle_gcb),current_color_index(gle_gcb)

            bra     set_pen

****************************************************************************
*
* LINESTYLE ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*   INFO1 = Linestyle index (saved only by raster devices)
*   INFO2 = Pattern length, % of min and max display values
*   INFO3 = Linestyle mode  (saved only by these devices)
*   INFO4 = Raster pattern  (16 bit value)
*
gle_aras_out_rlinestyle equ *
*
            movea.l 4(sp),gle_gcb                      a4 = address of pointer to gcb
            move.l  (sp)+,(sp)
            movem.l a5/a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb     a6 = dev_dep_gcb

            move.w  info1+2(gle_gcb),current_linestyle(gle_gcb)

            move.w  info2+2(gle_gcb),d0
            move.w  d0,current_pattern_length(gle_gcb)
            muls    hard_xmax(rgl_gcb),d0
            divs    #1600,d0
            bgt.s   ls_1
            moveq   #1,d0
ls_1        move.w  d0,repeatrate(rgl_gcb)

            move.w  info3+2(gle_gcb),current_linestyle_mode(gle_gcb)
            move.w  info4+2(gle_gcb),current_linestyle_pattern(gle_gcb)

            bsr     build_pen
            bra     set_pen

************************************************************************
*
moon_map    dc.b    0             0
            dc.b    7             1  white
            dc.b    1             2  red
            dc.b    3             3  yellow
            dc.b    2             4  green
            dc.b    6             5  cyan
            dc.b    4             6  blue
            dc.b    5             7  magenta

***********************************************************************
*
*    build_pen
*
*    This procedure takes devicetype, and linestyle and generates
*    the 68000 instructions for the vector generator.  The code
*    space for the vector generator is in the GCB, so that nothing
*    in this segment will modify itself.
*

build_pen   equ *                              | build first template
c_set2      move.w  #0,pen_draw_mode(rgl_gcb)
            move.w  #1,pen_num(rgl_gcb)
            move    devicetype(rgl_gcb),d0
            cmpi.b  #gator_display,devicetype+1(rgl_gcb)
*           bne.s   skip_notgat
            blt.s   skip_notgat
            move    #3,d0         gator/gatorbox/bobcat -- reset d0 like 36c
skip_notgat lsl     #2,d0
            cmpi    #-1,current_linestyle_pattern(gle_gcb)  ck linestyle
            bne.s   fixpatternx1
            bra.s   fixpattern1                | else create solid vec gen.

ztable      dc.w    template1-ztable
            dc.w    template2-ztable
            dc.w    template1-ztable
            dc.w    template2-ztable
            dc.w    template3-ztable
            dc.w    template4-ztable
            dc.w    template5-ztable
            dc.w    template6-ztable

*                                          d0 = 0 9826 (bit/pixel odd bytes)
*                                               4 9836A (bit/pixel all bytes)
*                                               8 98627A (multi-plane)
*                                              12 9836C (byte-per-pixel)

fixpatternx1 addq   #2,d0
fixpattern1 movea   ztable(d0),a0          a0 = offset ptable to template
            lea     ztable(a0),a0          a0 = address of template
            lea     softvec(rgl_gcb),a1    a1 = address of ram area
            moveq   #12,d1                 d1 = counter

* copy the template vector generator into ram.

loadtmplt   move.l  (a0)+,(a1)+
            move.l  (a0)+,(a1)+
            move.l  (a0)+,(a1)+
            move.l  (a0)+,(a1)+
            move.l  (a0)+,(a1)+
            subq    #1,d1
            bgt     loadtmplt
            jsr     asm_flush_icache           {3/25/85 SFB}
            rts
******************************************************************************
*
*    set_pen
*
*    This procedure takes devicetype, current_linestyle_pattern, pen_num
*    and drawing_mode and modifies the current vector generator code.
*    The code space for the vector generator is in the GCB, so that
*    nothing in this segment will modify itself.

*    If the current pen color matches the previous pen color,
*    this routine will just rts.  If you want to make sure
*    this routine builds something in the softvec area, put a 0
*    in oldpattern.
*
set_pen     equ *
            move.w  current_drawing_mode(gle_gcb),d0
            move.w  current_color_index(gle_gcb),d1

            cmpi.w  #2,devicetype(rgl_gcb)   ck for moonunit
            bne.s   c_set1s
            move.b  moon_map(d1),d1          remap for moonunit
c_set1s     tst.b   d1                       ck for color 0
            bne.s   c_set2s
            moveq   #1,d0                    force drawing mode to erase
            move.l  gamut(gle_gcb),d1        set pen number to max
c_set2s     move.w  d0,pen_draw_mode(rgl_gcb)
            move.w  d1,pen_num(rgl_gcb)
            move    d0,d3
            add     d3,d3
            move    devicetype(rgl_gcb),d0
*cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
*bne.s   ckbitmap2
*move    #4,d0
*bra.s   skip_nogat
*ckbitmap2   equ     *
            cmpi.b  #gator_display,devicetype+1(rgl_gcb)
            blt.s   skip_nogat
            move    #3,d0          gator/gatorbox/bobcat -- reset d0 like 36c
skip_nogat  lsl     #2,d0
            cmpi    #-1,current_linestyle_pattern(gle_gcb)
            beq.s   fixpatterns
            addq    #2,d0

fixpatterns equ *
fixcolor    add     d0,d0
            jmp     fixc(d0)
fixc        jmp     fixc1
            jmp     fixc2
            jmp     fixc1
            jmp     fixc2
            jmp     fixc3
            jmp     fixc4
            jmp     fixc5
            jmp     fixc6

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


***********************************************
*
* patch up bw solid vector generator
*
***********************************************

fixc1       move    fixc1table(d3),d1
            move    d1,softvec+26(rgl_gcb)
            move    d1,softvec+56(rgl_gcb)
            move    d1,softvec+92(rgl_gcb)
            move    d1,softvec+122(rgl_gcb)
            moveq   #$64,d1                    bcc instruction
            move    #$4e71,softvec(rgl_gcb)         nop instruction
            subq    #2,d3
            bne.s   fixd1
            moveq   #$65,d1
            move    #$4600,softvec(rgl_gcb)         not d0 instruction
fixd1       move.b  d1,softvec+34(rgl_gcb)
            move.b  d1,softvec+70(rgl_gcb)
            move.b  d1,softvec+100(rgl_gcb)
            move.b  d1,softvec+136(rgl_gcb)
            jsr     asm_flush_icache           {3/25/85 SFB}
            bra     rts

fixc1table  or.b    d0,(a0)                    dominant
            and.b   d0,(a0)                    erase
            or.b    d0,(a0)                    non-dominant (same)
            eor.b   d0,(a0)                    compliment

***********************************************
*
* fix up bw dashed generator
*
***********************************************

fixc2       move    fixc1table(d3),d1
            move    d1,softvec+30(rgl_gcb)
            move    d1,softvec+72(rgl_gcb)
            move    d1,softvec+120(rgl_gcb)
            move    d1,softvec+162(rgl_gcb)
            moveq   #$64,d1                    bcc instruction
            move    #$4e71,softvec(rgl_gcb)         nop instruction
            subq    #2,d3
            bne.s   fixd2
            moveq   #$65,d1                    bcs instruction
            move    #$4600,softvec(rgl_gcb)         not d0 instruction
fixd2       move.b  d1,softvec+46(rgl_gcb)
            move.b  d1,softvec+94(rgl_gcb)
            move.b  d1,softvec+136(rgl_gcb)
            move.b  d1,softvec+184(rgl_gcb)
            jsr     asm_flush_icache           {3/25/85 SFB}
            bra     rts

***********************************************
*
* fix up moon solid vector generator
*
***********************************************

fixc3       move    cblu(d3),d0
            btst    #2,pen_num+1(rgl_gcb)
            bne.s   fx3_10
            move    cblu+8,d0
            tst     d3
            bne.s   fx3_10
            move    cblu+2,d0
fx3_10      add     d3,d3
            move.l  cgrn(d3),d1
            move.l  cred(d3),d2
            btst    #1,pen_num+1(rgl_gcb)
            bne.s   fx3_20
            move.l  cgrn+16,d1
            tst     d3
            bne.s   fx3_20
            move.l  cgrn+4,d1
fx3_20      btst    #0,pen_num+1(rgl_gcb)
            bne.s   fx3_30
            move.l  cred+16,d2
            tst     d3
            bne.s   fx3_30
            move.l  cred+4,d2
fx3_30      lea     softvec+24(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            lea     softvec+64(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            lea     softvec+110(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            lea     softvec+150(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            jsr     asm_flush_icache           {3/25/85 SFB}
            bra     rts

cblu        or.b    d0,(a0)                    dominant
            and.b   d1,(a0)                    erase
            or.b    d0,(a0)                    non-dominant
            eor.b   d0,(a0)                    compliment
            nop

cgrn        or.b    d0,0(a0,a2.l)
            and.b   d1,0(a0,a2.l)
            or.b    d0,0(a0,a2.l)
            eor.b   d0,0(a0,a2.l)
            nop
            nop

cred        or.b    d0,0(a0,a3.l)
            and.b   d1,0(a0,a3.l)
            or.b    d0,0(a0,a3.l)
            eor.b   d0,0(a0,a3.l)
            nop
            nop

***********************************************
*
* fix up moon dashed generator
*
***********************************************

fixc4       move    cblu(d3),d0
            btst    #2,pen_num+1(rgl_gcb)
            bne.s   fx4_10
            move    cblu+8,d0
            tst     d3
            bne.s   fx4_10
            move    cblu+2,d0
fx4_10      add     d3,d3
            move.l  cgrn(d3),d1
            move.l  cred(d3),d2
            btst    #1,pen_num+1(rgl_gcb)
            bne.s   fx4_20
            move.l  cgrn+16,d1
            tst     d3
            bne.s   fx4_20
            move.l  cgrn+4,d1
fx4_20      btst    #0,pen_num+1(rgl_gcb)
            bne.s   fx4_30
            move.l  cred+16,d2
            tst     d3
            bne.s   fx4_30
            move.l  cred+4,d2
fx4_30      lea     softvec+28(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            lea     softvec+80(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            lea     softvec+138(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            lea     softvec+190(rgl_gcb),a0
            move    d0,(a0)+
            move.l  d1,(a0)+
            move.l  d2,(a0)+
            jsr     asm_flush_icache           {3/25/85 SFB}
            bra     rts

***********************************************
*
*  fix up 9836c solid lines (also gatorbox and bobcats)
*
***********************************************

fixc5       move    pen_num(rgl_gcb),d0
            cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
            bne     fixc5_a
            addq    #8,d3       move pointer down to bobcat lores opcodes
            move.w  addq2,softvec+24(rgl_gcb)  adjust address inc/dec opcodes
            move.w  subq2,softvec+66(rgl_gcb)
            move.w  addq2,softvec+126(rgl_gcb)
fixc5_a     equ     *
            move    color36c(d3),d2
            move    d2,softvec+52(rgl_gcb)
            move    d2,softvec+112(rgl_gcb)
            move    color36c2(d3),d2
            move    d2,softvec+26(rgl_gcb)
            move    color36c3(d3),d2
            move    d2,softvec+86(rgl_gcb)
            cmpi    #1,pen_draw_mode(rgl_gcb)
            bne     fx5_10
            not.b   d0
fx5_10      move    d0,cpen(rgl_gcb)
            jsr     asm_flush_icache           {3/25/85 SFB}
            bra     rts

color36c    move.b  d0,(a0)
            and.b   d0,(a0)
            or.b    d0,(a0)
            eor.b   d0,(a0)
            move.w  d0,(a0)     bobcat lores opcode
            and.w   d0,(a0)     bobcat lores opcode
            or.w    d0,(a0)     bobcat lores opcode
            eor.w   d0,(a0)     bobcat lores opcode

color36c2   move.b  d0,-(a0)
            and.b   d0,-(a0)
            or.b    d0,-(a0)
            eor.b   d0,-(a0)
            move.w  d0,-(a0)     bobcat lores opcode
            and.w   d0,-(a0)     bobcat lores opcode
            or.w    d0,-(a0)     bobcat lores opcode
            eor.w   d0,-(a0)     bobcat lores opcode

color36c3   move.b  d0,(a0)+
            and.b   d0,(a0)+
            or.b    d0,(a0)+
            eor.b   d0,(a0)+
            move.w  d0,(a0)+     bobcat lores opcode
            and.w   d0,(a0)+     bobcat lores opcode
            or.w    d0,(a0)+     bobcat lores opcode
            eor.w   d0,(a0)+     bobcat lores opcode

addq2       addq    #2,a0        opcode is addq #2,a0
subq2       subq    #2,a0        opcode is subq #2,a0

***********************************************
*
*  fix up 9836c dashed lines (also gatorbox and bobcats)
*
***********************************************

fixc6       move    pen_num(rgl_gcb),d0
            cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
            bne     fixc6_a
            addq    #8,d3       move pointer down to bobcat lores opcodes
            move.w  subq2,softvec+42(rgl_gcb)  adjust address inc/dec opcodes
            move.w  subq2,softvec+86(rgl_gcb)
            move.w  addq2,softvec+124(rgl_gcb)  3.1C BUGFIX 5/22/85--SFB
            move.w  addq2,softvec+168(rgl_gcb)
fixc6_a     equ     *
            move    color36c(d3),d2
            move    d2,softvec+28(rgl_gcb)
            move    d2,softvec+66(rgl_gcb)
            move    d2,softvec+110(rgl_gcb)
            move    d2,softvec+148(rgl_gcb)
            cmpi    #1,pen_draw_mode(rgl_gcb)       if erase then
            bne     fx6_10
            not.b   d0                         invert pen number
fx6_10      move    d0,cpen(rgl_gcb)
            jsr     asm_flush_icache           {3/25/85 SFB}
            bra     rts
            page

************************************************************************
*
* these are the 6 templates for vector generators.  the six cases are:
*
*    template1 - monochrome / solid line
*    template2 - monochrome / dashed line
*    template3 - moonunit   / solid line
*    template4 - moonunit   / dashed line
*    template5 - 9836C      / solid line
*    template6 - 9836C      / dashed line
*
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 1 - bw / solid line                                     *
*                                                                      *
************************************************************************
************************************************************************

template1   nop                                                0
            tst     d5         tst (x2-x1)                     2
            bgt.s   incx1                                      4
            neg     d5         d5 = abs(x2-x1)                 6
            cmp     d5,d2      x major or y major ?            8
            bgt.s   case13     y major/decrement x            10
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case14      tst     d5                                        12
            beq.s   loop14                                    14
            swap    d2         d2 = [(y2-y1) :    0 ]         16
            clr     d2                                        18
            divu    d5,d2      d2 = (y2-y1)/(x2-x1)           20
            bvc.s   loop14                                    22
            moveq   #-1,d2                                    24
loop14      or.b    d0,(a0)  .................................26
            subq    #1,d5                                     28
            blt.s   endvec1                                   30
            rol.b   #1,d0    .................................32
            bcc.s   next14   .................................34
            suba    d6,a0                                     36
next14      add     d2,d3      sum = sum + frac               38
            bcc     loop14                                    40
            suba    a1,a0      inc y                          42
            bra     loop14                                    44
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case13      swap    d5                                        46
            clr     d5                                        48
            divu    d2,d5      d5=frac=(x2-x1)/(y2-y1)        50
            bvc.s   loop13                                    52
            moveq   #-1,d5                                    54
loop13      or.b    d0,(a0)    ...............................56
            subq    #1,d2      pixel_count = pixel_count - 1  58
            blt.s   endvec1    if pixel_count<0 ; goto endvec 60
            suba    a1,a0      increment y                    62
            add     d5,d3      sum = sum + frac               64
            bcc     loop13     if sum < 1 then goto loop3     66
            rol.b   #1,d0      ...............................68
            bcc     loop13     ...............................70
            suba    d6,a0                                     72
            bra     loop13                                    74
endvec1     rts                                               76
incx1       cmp     d5,d2                                     78
            bgt.s   case11                                    80
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case12      swap    d2                                        82
            clr     d2                                        84
            divu    d5,d2      d2 = frac                      86
            bvc.s   loop12                                    88
            moveq   #-1,d2                                    90
loop12      or.b    d0,(a0)   ................................92
            subq    #1,d5                                     94
            blt.s   endvec1                                   96
            ror.b   #1,d0     ................................98
            bcc.s   next12    ...............................100
            adda    d6,a0                                    102
next12      add     d2,d3      sum = sum + frac              104
            bcc     loop12                                   106
            suba    a1,a0                                    108
            bra     loop12                                   110
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case11      swap    d5                                       112
            clr     d5                                       114
            divu    d2,d5                                    116
            bvc.s   loop11                                   118
            moveq   #-1,d5                                   120
loop11      or.b    d0,(a0)  ................................122
            subq    #1,d2                                    124
            blt.s   endvec1                                  126
            suba    a1,a0                                    128
            add     d5,d3                                    130
            bcc     loop11                                   132
            ror.b   #1,d0                                    134
            bcc     loop11   ................................136
            adda    d6,a0                                    138
            bra     loop11                                   140
            page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 2 - bw / dashed line                                    *
*                                                                      *
************************************************************************
************************************************************************

template2   nop                                                0
            tst     d5         tst (x2-x1)                     2
            bgt.s   incx2                                      4
            neg     d5         d5 = abs(x2-x1)                 6
            cmp     d5,d2      x major or y major ?            8
            bgt.s   case23     y major/decrement x            10
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case24      tst     d5                                        12
            beq.s   loop24                                    14
            swap    d2         d2 = [(y2-y1) :    0 ]         16
            clr     d2                                        18
            divu    d5,d2      d2 = (y2-y1)/(x2-x1)           20
            bvc.s   loop24                                    22
            moveq   #-1,d2                                    24
loop24      tst     d4         if bit 7 of pattern is set     26
            bpl.s   skip24       then skip - the pen is up    28
            or.b    d0,(a0)      else draw - the pen is down  30
skip24      subq    #1,d5      pixel_count := pixel_count-1   32
            blt.s   endvec2                                   34
            subq    #1,d7      decrement repeatcount          36
            bne.s   ok24                                      38
            move    a5,d7                                     40
            rol     #1,d4                                     42
ok24        rol.b   #1,d0                                     44
            bcc.s   next24     ...............................46
            suba    d6,a0                                     48
next24      add     d2,d3      sum = sum + frac               50
            bcc     loop24                                    52
            suba    a1,a0      inc y                          54
            bra     loop24                                    56
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case23      swap    d5                                        58
            clr     d5                                        60
            divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    62
            bvc.s   loop23                                    64
            moveq   #-1,d5                                    66
loop23      tst     d4         if bit 7 of pattern is set     68
            bpl.s   skip23                                    70
            or.b    d0,(a0)    turn on pixel (x,y)            72
skip23      subq    #1,d2      pixel_count = pixel_count - 1  74
            blt.s   endvec2    if pixel_count<0 ;goto endvec  76
            subq    #1,d7      decrement repeatcount          78
            bne.s   ok23                                      80
            move    a5,d7                                     82
            rol     #1,d4                                     84
ok23        suba    a1,a0      increment y                    86
            add     d5,d3      sum = sum + frac               88
            bcc     loop23     if sum < 1 then goto loop3     90
            rol.b   #1,d0      x = x - 1                      92
            bcc     loop23     ...............................94
            suba    d6,a0                                     96
            bra     loop23                                    98
endvec2     rts                                              100
incx2       cmp     d5,d2                                    102
            bgt.s   case21                                   104
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case22      swap    d2                                       106
            clr     d2                                       108
            divu    d5,d2      d2 = frac                     110
            bvc.s   loop22                                   112
            moveq   #-1,d2                                   114
loop22      tst     d4                                       116
            bpl.s   skip22                                   118
            or.b    d0,(a0)    ..............................120
skip22      subq    #1,d5                                    122
            blt.s   endvec2                                  124
            subq    #1,d7      decrement repeatcount         126
            bne.s   ok22                                     128
            move    a5,d7                                    130
            rol     #1,d4                                    132
ok22        ror.b   #1,d0                                    134
            bcc.s   next22     ..............................136
            adda    d6,a0                                    138
next22      add     d2,d3      sum = sum + frac              140
            bcc     loop22                                   142
            suba    a1,a0                                    144
            bra     loop22                                   146
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case21      swap    d5                                       148
            clr     d5                                       150
            divu    d2,d5                                    152
            bvc.s   loop21                                   154
            moveq   #-1,d5                                   156
loop21      tst     d4                                       158
            bpl.s   skip21                                   160
            or.b    d0,(a0)    ..............................162
skip21      subq    #1,d2                                    164
            blt.s   endvec2                                  166
            subq    #1,d7      decrement repeatcount         168
            bne.s   ok21                                     170
            move    a5,d7                                    172
            rol     #1,d4                                    174
ok21        suba    a1,a0                                    176
            add     d5,d3                                    178
            bcc     loop21                                   180
            ror.b   #1,d0                                    182
            bcc     loop21     ..............................184
            adda    d6,a0                                    186
            bra     loop21                                   188
            page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 3 - moonunit / solid line                               *
*                                                                      *
************************************************************************
************************************************************************

template3   tst     d5         tst (x2-x1)                     0
            bgt.s   incx3                                      2
            neg     d5         d5 = abs(x2-x1)                 4
            cmp     d5,d2      x major or y major ?            6
            bgt.s   case33     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case34      tst     d5                                        10
            beq.s   loop34                                    12
            swap    d2         d2 = [(y2-y1) :    0 ]         14
            clr     d2                                        16
            divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
            bvc.s   loop34                                    20
            moveq   #-1,d2                                    22
loop34      or.b    d0,(a0)       ............................24
            or.b    d0,0(a0,a2.l) ............................26
            or.b    d0,0(a0,a3.l) ............................30
            subq    #1,d5                                     34
            blt.s   endvec3                                   36
            rol.b   #1,d1                                     38
            rol.b   #1,d0                                     40
            bcc.s   next34                                    42
            suba    d6,a0                                     44
next34      add     d2,d3      sum = sum + frac               46
            bcc     loop34                                    48
            suba    a1,a0      inc y                          50
            bra     loop34                                    52
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case33      swap    d5                                        54
            clr     d5                                        56
            divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    58
            bvc.s   loop33                                    60
            moveq   #-1,d5                                    62
loop33      or.b    d0,(a0)    turn on pixel (x,y)............64
            or.b    d0,0(a0,a2.l) ............................66
            or.b    d0,0(a0,a3.l) ............................70
            subq    #1,d2      pixel_count = pixel_count - 1  74
            blt.s   endvec3    if pixel_count<0 ; goto endvec 76
            suba    a1,a0      increment y                    78
            add     d5,d3      sum = sum + frac               80
            bcc     loop33     if sum < 1 then goto loop3     82
            rol.b   #1,d1                                     84
            rol.b   #1,d0      x = x - 1                      86
            bcc     loop33                                    88
            suba    d6,a0                                     90
            bra     loop33                                    92
endvec3     rts                                               94
incx3       cmp     d5,d2                                     96
            bgt.s   case31                                    98

* x major / inc x

* rule: always increment x / maybe increment y

case32      swap    d2                                       100
            clr     d2                                       102
            divu    d5,d2      d2 = frac                     104
            bvc.s   loop32                                   106
            moveq   #-1,d2                                   108
loop32      or.b    d0,(a0)       ...........................110
            or.b    d0,0(a0,a2.l) ...........................112
            or.b    d0,0(a0,a3.l) ...........................116
            subq    #1,d5                                    120
            blt.s   endvec3                                  122
            ror.b   #1,d1                                    124
            ror.b   #1,d0                                    126
            bcc.s   next32                                   128
            adda    d6,a0                                    130
next32      add     d2,d3      sum = sum + frac              132
            bcc     loop32                                   134
            suba    a1,a0                                    136
            bra     loop32                                   138
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case31      swap    d5                                       140
            clr     d5                                       142
            divu    d2,d5                                    144
            bvc.s   loop31                                   146
            moveq   #-1,d5                                   148
loop31      or.b    d0,(a0)       ...........................150
            or.b    d0,0(a0,a2.l) ...........................152
            or.b    d0,0(a0,a3.l) ...........................156
            subq    #1,d2                                    160
            blt.s   endvec3                                  162
            suba    a1,a0                                    164
            add     d5,d3                                    166
            bcc     loop31                                   168
            ror.b   #1,d1                                    170
            ror.b   #1,d0                                    172
            bcc     loop31                                   174
            adda    d6,a0                                    176
            bra     loop31                                   178
            page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 4 - moonunit / dashed lines                             *
*                                                                      *
************************************************************************
************************************************************************

template4   tst     d5         tst (x2-x1)                     0
            bgt.s   incx4                                      2
            neg     d5         d5 = abs(x2-x1)                 4
            cmp     d5,d2      x major or y major ?            6
            bgt.s   case43     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case44      tst     d5                                        10
            beq.s   loop44                                    12
            swap    d2         d2 = [(y2-y1) :    0 ]         14
            clr     d2                                        16
            divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
            bvc.s   loop44                                    20
            moveq   #-1,d2                                    22
loop44      tst     d4                                        24
            bpl.s   skip44                                    26
            or.b    d0,(a0)       ............................28
            or.b    d0,0(a0,a2.l) ............................30
            or.b    d0,0(a0,a3.l) ............................34
skip44      subq    #1,d5                                     38
            blt.s   endvec4                                   40
            subq    #1,d7                                     42
            bne.s   ok44                                      44
            move    a5,d7                                     46
            rol     #1,d4                                     48
ok44        rol.b   #1,d1                                     50
            rol.b   #1,d0                                     52
            bcc.s   next44                                    54
            suba    d6,a0                                     56
next44      add     d2,d3      sum = sum + frac               58
            bcc     loop44                                    60
            suba    a1,a0      inc y                          62
            bra     loop44                                    64
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case43      swap    d5                                        66
            clr     d5                                        68
            divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    70
            bvc.s   loop43                                    72
            moveq   #-1,d5                                    74
loop43      tst     d4                                        76
            bpl.s   skip43                                    78
            or.b    d0,(a0)    turn on pixel (x,y) ...........80
            or.b    d0,0(a0,a2.l) ............................82
            or.b    d0,0(a0,a3.l) ............................86
skip43      subq    #1,d2      pixel_count = pixel_count - 1  90
            blt.s   endvec4    if pixel_count<0 ;goto endvec  92
            subq    #1,d7                                     94
            bne.s   ok43                                      96
            move    a5,d7                                     98
            rol     #1,d4                                    100
ok43        suba    a1,a0      increment y                   102
            add     d5,d3      sum = sum + frac              104
            bcc     loop43     if sum < 1 then goto loop3    106
            rol.b   #1,d1                                    108
            rol.b   #1,d0      x = x - 1                     110
            bcc     loop43                                   112
            suba    d6,a0                                    114
            bra     loop43                                   116
endvec4     rts                                              118
incx4       cmp     d5,d2                                    120
            bgt.s   case41                                   122
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case42      swap    d2                                       124
            clr     d2                                       126
            divu    d5,d2      d2 = frac                     128
            bvc.s   loop42                                   130
            moveq   #-1,d2                                   132
loop42      tst     d4                                       134
            bpl.s   skip42                                   136
            or.b    d0,(a0)     .............................138
            or.b    d0,0(a0,a2.l)                            140
            or.b    d0,0(a0,a3.l)                            144
skip42      subq    #1,d5                                    148
            blt.s   endvec4                                  150
            subq    #1,d7                                    152
            bne.s   ok42                                     154
            move    a5,d7                                    156
            rol     #1,d4                                    158
ok42        ror.b   #1,d1                                    160
            ror.b   #1,d0                                    162
            bcc.s   next42                                   164
            adda    d6,a0                                    166
next42      add     d2,d3      sum = sum + frac              168
            bcc     loop42                                   170
            suba    a1,a0                                    172
            bra     loop42                                   174
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case41      swap    d5                                       176
            clr     d5                                       178
            divu    d2,d5                                    180
            bvc.s   loop41                                   182
            moveq   #-1,d5                                   184
loop41      tst     d4                                       186
            bpl.s   skip41                                   188
            or.b    d0,(a0)       ...........................190
            or.b    d0,0(a0,a2.l) ...........................192
            or.b    d0,0(a0,a3.l) ...........................196
skip41      subq    #1,d2                                    200
            blt.s   endvec4                                  202
            subq    #1,d7                                    204
            bne.s   ok41                                     206
            move    a5,d7                                    208
            rol     #1,d4                                    210
ok41        suba    a1,a0                                    212
            add     d5,d3                                    214
            bcc     loop41                                   216
            ror.b   #1,d1                                    218
            ror.b   #1,d0                                    220
            bcc     loop41                                   222
            adda    d6,a0                                    224
            bra     loop41                                   226

            page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 5 - 9836C / solid line                                  *
*                                                                      *
************************************************************************
************************************************************************

template5   tst     d5         tst (x2-x1)                     0
            bgt.s   incx5                                      2
            neg     d5         d5 = abs(x2-x1)                 4
            cmp     d5,d2      x major or y major ?            6
            bgt.s   case53     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case54      tst     d5                                        10
            beq.s   before54                                  12
            swap    d2         d2 = [(y2-y1) :    0 ]         14
            clr     d2                                        16
            divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
            bvc.s   before54                                  20
            moveq   #-1,d2                                    22
before54    addq    #1,a0                                     24
loop54      move.b  d0,-(a0) .................................26
            dbra    d5,next54                                 28
            bra.s   endvec5                                   32
next54      add     d2,d3      sum = sum + frac               34
            bcc     loop54                                    36
            suba    a1,a0      inc y                          38
            bra     loop54                                    40
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case53      swap    d5                                        42
            clr     d5                                        44
            divu    d2,d5      d5=frac=(x2-x1)/(y2-y1)        46
            bvc.s   loop53                                    48
            moveq   #-1,d5                                    50
loop53      move.b  d0,(a0)    ...............................52
            dbra    d2,next53  pixel_count = pixel_count - 1  54
            bra.s   endvec5    if pixel_count<0 ; goto endvec 58
next53      suba    a1,a0      increment y                    60
            add     d5,d3      sum = sum + frac               62
            bcc     loop53     if sum < 1 then goto loop3     64
            subq    #1,a0                                     66
            bra     loop53                                    68
endvec5     rts                                               70
incx5       cmp     d5,d2                                     72
            bgt.s   case51                                    74
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case52      swap    d2                                        76
            clr     d2                                        78
            divu    d5,d2      d2 = frac                      80
            bvc.s   loop52                                    82
            moveq   #-1,d2                                    84
loop52      move.b  d0,(a0)+  ................................86
            dbra    d5,next52                                 88
            bra.s   endvec5                                   92
next52      add     d2,d3      sum = sum + frac               94
            bcc     loop52                                    96
            suba    a1,a0                                     98
            bra     loop52                                   100
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case51      swap    d5                                       102
            clr     d5                                       104
            divu    d2,d5                                    106
            bvc.s   loop51                                   108
            moveq   #-1,d5                                   110
loop51      move.b  d0,(a0)  ................................112
            dbra    d2,next51                                114
            bra.s   endvec5                                  118
next51      suba    a1,a0                                    120
            add     d5,d3                                    122
            bcc     loop51                                   124
            addq    #1,a0                                    126
            bra     loop51                                   128
            page
************************************************************************
************************************************************************
*                                                                      *
*     TEMPLATE 6 - 9836C / dashed line                                 *
*                                                                      *
************************************************************************
************************************************************************

template6   tst     d5         tst (x2-x1)                     0
            bgt.s   incx6                                      2
            neg     d5         d5 = abs(x2-x1)                 4
            cmp     d5,d2      x major or y major ?            6
            bgt.s   case63     y major/decrement x             8
*
*  x major/dec x
*
*  rule: always decrement x / maybe increment y
*
case64      tst     d5                                        10
            beq.s   loop64                                    12
            swap    d2         d2 = [(y2-y1) :    0 ]         14
            clr     d2                                        16
            divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
            bvc.s   loop64                                    20
            moveq   #-1,d2                                    22
loop64      tst     d4         if bit 7 of pattern is set     24
            bpl.s   skip64       then skip                    26
            move.b  d0,(a0)      else draw ...................28
skip64      subq    #1,d5      pixel_count := pixel_count-1   30
            blt.s   endvec6                                   32
            subq    #1,d7      decrement repeatcount          34
            bne.s   ok64                                      36
            move    a5,d7                                     38
            rol     #1,d4                                     40
ok64        subq    #1,a0                                     42
next64      add     d2,d3      sum = sum + frac               44
            bcc     loop64                                    46
            suba    a1,a0      inc y                          48
            bra     loop64                                    50
*
*  y major / dec x
*
*  rule:  always increment y / maybe decrement x
*
case63      swap    d5                                        52
            clr     d5                                        54
            divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    56
            bvc.s   loop63                                    58
            moveq   #-1,d5                                    60
loop63      tst     d4         if bit 7 of pattern is set     62
            bpl.s   skip63                                    64
            move.b  d0,(a0)    turn on pixel (x,y) ...........66
skip63      subq    #1,d2      pixel_count = pixel_count - 1  68
            blt.s   endvec6    if pixel_count<0 ;goto endvec  70
            subq    #1,d7      decrement repeatcount          72
            bne.s   ok63                                      74
            move    a5,d7                                     76
            rol     #1,d4                                     78
ok63        suba    a1,a0      increment y                    80
            add     d5,d3      sum = sum + frac               82
            bcc     loop63     if sum < 1 then goto loop3     84
            subq    #1,a0                                     86
            bra     loop63                                    88
endvec6     rts                                               90
incx6       cmp     d5,d2                                     92
            bgt.s   case61                                    94
*
* x major / inc x
*
* rule: always increment x / maybe increment y
*
case62      swap    d2                                        96
            clr     d2                                        98
            divu    d5,d2      d2 = frac                     100
            bvc.s   loop62                                   102
            moveq   #-1,d2                                   104
loop62      tst     d4                                       106
            bpl.s   skip62                                   108
            move.b  d0,(a0)    ..............................110
skip62      subq    #1,d5                                    112
            blt.s   endvec6                                  114
            subq    #1,d7      decrement repeatcount         116
            bne.s   ok62                                     118
            move    a5,d7                                    120
            rol     #1,d4                                    122
ok62        addq    #1,a0                                    124
next62      add     d2,d3      sum = sum + frac              126
            bcc     loop62                                   128
            suba    a1,a0                                    130
            bra     loop62                                   132
*
*  y major / inc x
*
* rule: maybe inc x / always inc y
*
case61      swap    d5                                       134
            clr     d5                                       136
            divu    d2,d5                                    138
            bvc.s   loop61                                   140
            moveq   #-1,d5                                   142
loop61      tst     d4                                       144
            bpl.s   skip61                                   146
            move.b  d0,(a0)    ..............................148
skip61      subq    #1,d2                                    150
            blt.s   endvec6                                  152
            subq    #1,d7      decrement repeatcount         154
            bne.s   ok61                                     156
            move    a5,d7                                    158
            rol     #1,d4                                    160
ok61        suba    a1,a0                                    162
            add     d5,d3                                    164
            bcc     loop61                                   166
            addq    #1,a0                                    168
            bra     loop61                                   170
            page


waitcatready equ    *           assumes a0=deviceaddress        SFB
            btst    #0,catseye_status+1(a0)                     SFB
            bne     waitcatready
            rts
*
*  procedure area_fill(gcb:anyptr);
*

*
*  local temporaries
*
ybegin      equ     rgltemp1
yend        equ     rgltemp2
left_side   equ     addr3
ptable      equ     addr1
stable      equ     addr2
n           equ     n3

gle_aras_out_rpolygon equ *
            movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                      stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec ptr

            move.l  info2(gle_gcb),d0               ck for solid fill
            cmp     polygon_solid_fill(gle_gcb),d0  ignor call if not solid
            bne     rts

            move.l  info_ptr1(gle_gcb),addr1(rgl_gcb)
            move.l  info_ptr2(gle_gcb),addr2(rgl_gcb)

            move    clip_limits_ymin+2(gle_gcb),d0    make sure clip limits
            cmp     clip_limits_ymax+2(gle_gcb),d0    allow something
            bgt     rts

            move    clip_limits_xmin+2(gle_gcb),d0
            cmp     clip_limits_xmax+2(gle_gcb),d0
            bgt     rts

            move    area_draw_mode(rgl_gcb),d0
            lsl     #3,d0
            cmpi.b  #3,devicetype+1(rgl_gcb)            ck for 36c
            beq.s   afc
            blt.s   af_packed

            cmpi.b  #5,devicetype+1(rgl_gcb)            ck for gatorbox
            beq.s   afc

            cmpi.b  #10,devicetype+1(rgl_gcb)       ck for WOODCUT CFB - 24JUL91
            bge.s   afc                                            CFB - 24JUL91

            bra.s   af_com                          Gator, don't do anything

af_packed   jmp     pickamode1(d0)
pickamode1  lea     fill_dom,a5
            bra     af2
            lea     fill_erase,a5
            bra     af2
            lea     fill_ndom,a5
            bra     af2
            lea     fill_erase,a5
            bra.s   af2

afc         jmp     pickamode2(d0)
pickamode2  lea     f36c_dom,a5
            bra     af2
            lea     f36c_erase,a5
            bra     af2
            lea     f36c_ndom,a5
            bra     af2
            lea     f36c_erase,a5

af_com      equ *
af2         movea.l ptable(rgl_gcb),a0         a0 = address of end points
            movea.l stable(rgl_gcb),a1         a1 = address of work area
            movea   #32767,a3                  a3 = minimum y
            moveq   #-1,d7                     d7 = maximum y
            clr     n(rgl_gcb)
segmentloop move.l  (a0)+,d0                   d0 = n for this segment
            add     d0,n(rgl_gcb)                   add this n to ntotal
            movea.l a0,a2
buildloop   move.l  (a0)+,d2
            move.l  (a0)+,d3                   (d2,d3) = (xi,yi)
            subq    #1,d0                       decrement # of points
            bne.s   buildnorm                  last point ?
            exg     a0,a2                      yes: wrap around to x1,y1
buildnorm   move.l  (a0),d4
            movea.l d4,a6
            cmpa    a6,a6
            bne     int_ovflow
            move.l  4(a0),d5
            movea.l d5,a6
            cmpa    a6,a6
            bne     int_ovflow
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  restore a6
            cmp     d3,d5                      is y1 <= y2 ?
            bge.s   y2big
            exg     d3,d5
            exg     d2,d4                      (d2,d3) = point with smaller y
y2big       cmp     clip_limits_ymin+2(gle_gcb),d3
            bge.s   no_clip
            cmp     clip_limits_ymin+2(gle_gcb),d5
            blt.s   divok                      y is out of range: build entry
            move    d4,d1                      d1 = x2
            sub     d2,d1                      d1=x2-x1
            bvs     int_ovflow
            move    d3,d6                      d6 = y1
            sub     clip_limits_ymin+2(gle_gcb),d6    d6 = ymin-y1
            bvs     int_ovflow
            neg     d6
            muls    d6,d1                      d5=(x2-x1)(ymin-y1)
            move    d5,d6                      d6=y2
            sub     d3,d6                      d6=y2-y1
            bvs     int_ovflow
            divs    d6,d1                      d1=(x2-x1)(ymin-y1)/(y2-y1)
            add     d1,d2                      d1=x1+(x2-x1)(ymin-y1)/(y2-y1)
            move    clip_limits_ymin+2(gle_gcb),d3    y1=ymin
no_clip     cmp     a3,d3                      a3 = min(y1,ymin)
            bge.s   buildm
            movea   d3,a3
buildm      cmp     d5,d7                      d7 = max(y2,ymax)
            bge.s   buildn
            move    d5,d7
buildn      moveq   #0,d1                      d1 = flag
            sub     d3,d5                      d5 = y2-y1
            bvs     int_ovflow
            sub     d2,d4                      d4 = x2-x1
            bvs     int_ovflow
            bge.s   x2big
            neg     d4                         d4=abs(x2-x1)
            addq    #2,d1                      set "dec x" bit in flag
x2big       cmp     d4,d5                      if |x2-x1|>=|y2-y1|;use y major
            blt.s   xmajor                     otherwise use x major
            addq    #1,d1                      set "y major" bit in flag
            exg     d4,d5                      d4=max(dx,dy), d5=min(dx,dy)
xmajor      tst     d4
            beq.s   div2                       dx=dy=0
            swap    d5                         d5.l = min(dx,dy):0
            clr     d5
            divu    d4,d5                      d5 = frac
            bvc.s   divok
div2        moveq   #-1,d5                     if ovflow or div by 0,d5=.99999
divok       move    d3,(a1)+                   stack y1
            move    d2,(a1)+                   stack x1
            move    d4,(a1)+                   stack m,# of pixels in vector
            addq    #2,a1                      skip  x2
            move    d5,(a1)+                   stack frac
            move    #$8000,(a1)+               stack sum=.5000000
            move    d1,(a1)+                   stack flag
            tst     d0                         n=0 ?
            bne     buildloop                  no: build next vector

            movea.l a2,a0                      a0 points to next n
            tst.l   (a0)                       test size of next segment
            bgt     segmentloop                if > 0 then get next segment

            move    a3,ybegin(rgl_gcb)
            cmp     clip_limits_ymax+2(gle_gcb),d7
            ble.s   saved7
            move    clip_limits_ymax+2(gle_gcb),d7

saved7      move    d7,yend(rgl_gcb)
*
*  at this point, stable has been constructed, and the procedure is
*  ready to begin area filling.
*
            move    ybegin(rgl_gcb),d1
            cmp     clip_limits_ymax+2(gle_gcb),d1
            bgt     rts
            move    n_glines(rgl_gcb),d0
            subq    #1,d0
            sub     d1,d0
            mulu    bytesperline(rgl_gcb),d0
            movea.l plane1_addr(rgl_gcb),a0        ptr to addr
            movea.l (a0),a0
            adda.l  plane1_offset(rgl_gcb),a0      upper right display address
            move    gspacing(rgl_gcb),d5
            subq    #1,d5
            adda.w  d5,a0                     adjust for 16/26 odd addressing
            add.l   a0,d0
            move.l  d0,left_side(rgl_gcb)
            page
*
*  generate the x1---x2 pairs for each vector
*
*
new_line    equ     *
build_x     movea.l stable(rgl_gcb),a0
            movea.l a0,a1
            move    n(rgl_gcb),d5
*
*     a0=a1=beginning of this entry
bxy_loop    move    (a0)+,d0                   d0 = y1
            cmp     ybegin(rgl_gcb),d0
            beq.s   l10
            adda    #12,a0                     skip rest of entry is stable
            movea.l a0,a1
            bra.s   nextv

l10         move    (a0)+,d0                   d0 = x1
            move    (a0)+,d1                   d1 = m = # of pixels left - 1
            addq    #2,a0                      skip x2 (it's trash right now)
            move    (a0)+,d2                   d2 = frac
            move    (a0)+,d3                   d3 = sum
            move    (a0)+,d4                   d4 = flag
            and     #3,d4                      mask xmaj/ymaj and inc/decx bits
            add     d4,d4                      make it an offset
            jmp     bumpxy(d4)
bumpxy      bra.s   majx_incx
            bra.s   nextvector
            bra.s   majx_decx
            bra.s   nextvector

majx_incx   add     d2,d3                      sum = frac+sum
            bcs.s   mxdix                      if sum overflowed: bump y
            addq    #1,d0                      inc x2
            subq    #1,d1                      dec m
            bge     majx_incx
            subq    #1,d0                      un-do the last increment
            bra.s   nextvector

majx_decx   add     d2,d3                      sum = frac+sum
            bcs.s   mxdix
            subq    #1,d0                      dec x2
            subq    #1,d1                      dec m
            bge     majx_decx
            addq    #1,d0                      un-do the last decrement
            bra.s   nextvector

mxdix       sub     d2,d3                      undo the add which caused carry
nextvector  subq    #1,d1                      dec m ; m<0 all pixels filled
            addq    #4,a1                      skip over y1,x1 in stable
            move    d1,(a1)+                   stack m
            move    d0,(a1)+                   stack x2
            addq    #2,a1                      skip over frac
            move    d3,(a1)+                   stack new sum
            lsr     #1,d4                      set flag active bit true (0)
            move    d4,(a1)+                   stack flag
nextv       subq    #1,d5                      n=n-1
            bgt     bxy_loop
            page
*
*  mvdw_loop  this section takes the (x1,x2) pairs for each vector
*             and uses them to fill the line.  the rule is:
*              (1) move to odd vectors
*              (2) draw to even vectors
*              (3) ignore the last y of every vector when performing
*                  rules (1) and (2)
*              (4) for all vectors which end on the current y,
*                  fill in the vector itself.
*
mvdw_loop   bsr     find_min      d5,d6 = x1,x2 of leftmost active vector
*                                 the vector is marked dead by find_min
            beq.s   fill_point    if no points were active, then finish line
            move    d5,d7         save minimum x in d7
            movea   d6,a2
            bsr     find_min      d5,d6 = x1,x2 of leftmost active vector
            beq.s   fill_point
            move    d7,d0         d0 = x to start filling at
            move    a2,d1
            cmp     d6,d1         d1 = x to end filling at
            bgt.s   mvdw1
            move    d6,d1
mvdw1       bsr     fill          fill the area between the two vectors
            bra     mvdw_loop

* when the segments between all vector pairs have been filled, fill
* the vector itself if this is the last line on which the vector exists.

fill_point  movea.l stable(rgl_gcb),a3
            move    n(rgl_gcb),d7      d7 = number of vectors
fill_ptlp   move    (a3),d2       d2 = y for this vector
            cmp     ybegin(rgl_gcb),d2 is this vector active ?
            bne.s   next_ptlp     no
            tst     4(a3)         did the vector expire on this y ?
            bge.s   next_ptlp     no
            move    2(a3),d0      d0 = x1
            move    6(a3),d1      d1 = x2
            cmp     d0,d1         order them: d0=min x, d1=max x
            bge.s   fp01
            exg     d0,d1

fp01        bsr     fill

next_ptlp   adda    #14,a3        a3 points to next vector in table
            subq    #1,d7         dec n
            bgt     fill_ptlp
*
*  end of line processing
*
            move    ybegin(rgl_gcb),d0
            cmp     yend(rgl_gcb),d0   done ?
*           bge     rts            replaced to allow catseye trr disable SFB
            blt     eol_proc       SFB
            cmpi.b  #catseye_hrx_display,devicetype+1(rgl_gcb)       CFB 10JUN91
            bgt     rts                                              CFB 10JUN91
            cmpi.b  #catseye_display,devicetype+1(rgl_gcb)              SFB
            blt     rts                                              CFB 12JUN91
            movea.l deviceaddress(rgl_gcb),a0 waitcatready assumes this SFB
            bsr     waitcatready     wait for previous move to complete SFB
            move.w  #$0,trr_enable(a0)      and restore "not trr"       SFB
            bra     rts                                                 SFB

eol_proc    movea.l stable(rgl_gcb),a0
            move    n(rgl_gcb),d7
eol_loop    movem   (a0),d0-d6    d0 = y
*                                 d1 = x1
*                                 d2 = m
*                                 d3 = x2
*                                 d4 = frac
*                                 d5 = sum
*                                 d6 = flag
            cmp     ybegin(rgl_gcb),d0
            bne.s   next_eol
            tst     d2            did y expire ?
            blt.s   next_eol      yes, leave y hanging
            addq    #1,d0         inc y
            and     #3,d6         mask of inc/dec bit and x/y major bit
            add     d6,d6
            add     d4,d5         sum=frac+sum (sets condition codes)
            jmp     eol_p(d6)
eol_p       bra.s   mx_ix
            bra.s   my_ix
            bra.s   mx_dx
my_dx       bcc.s   save_eol
mx_dx       subq    #1,d3         dec x
            bra.s   save_eol
my_ix       bcc.s   save_eol
mx_ix       addq    #1,d3         inc x
save_eol    move    d3,d1         put new x into x1
            movem   d0-d5,(a0)    put stuff back in table
next_eol    adda    #14,a0        point a0 to next entry in table
            subq    #1,d7         dec n
            bgt     eol_loop
            addq    #1,ybegin(rgl_gcb)
            movea.l left_side(rgl_gcb),a0
            suba    bytesperline(rgl_gcb),a0
            move.l  a0,left_side(rgl_gcb)
            bra     new_line
            page
*
*  find_min
*
find_min    movea.l stable(rgl_gcb),a0
            move    n(rgl_gcb),d0
            moveq   #0,d1         d1=flag for found anything
            move    ybegin(rgl_gcb),d2
            move    #32767,d5     d5=xmin
find_loop   cmp     (a0),d2
            bne.s   next_find     ignore vectors whose y does not match
            tst     4(a0)         check m for an expired vector
            blt.s   next_find     ignore expired vectors
            tst     12(a0)
            blt.s   next_find     ignore "dead" vectors
            move    2(a0),d3      d3=x1
            move    6(a0),d4      d4=x2
            cmp     d3,d4         put smaller x in d3
            bgt.s   find_1
            exg     d3,d4
find_1      cmp     d5,d3
            bgt.s   next_find     new x is not <= than xmin
*                                 (note: it is important to use blt
*                                 instead of ble to prevent missing a point)
            movea.l a0,a1         remember where this vector was
            move    d3,d5
            move    d4,d6         (d5,d6) are the minx line
            addq    #1,d1         set found flag
next_find   adda    #14,a0        a0 points to next entry in stable
            subq    #1,d0         dec n
            bgt     find_loop
            tst     d1            set condition codes to indicate whether
*                                 or not a vector was found.  z=0 means
*                                 nothing found.
            beq.s   fm_rts
            ori     #$8000,12(a1) set "dead" flag.  this instruction also
*                                 sets the z condition code to indicate
*                                 a non-zero result.
fm_rts      rts
            page
*
*  fill
*
*  description: this routine fills the area between the points x1 and x2.
*               the fill is accomplished using a dither pattern, selected
*               by red_intensity, green_intensity, and blue_intensity.
*
*  entry:       d0.w            = x1
*               d1.w            = x2 (must be >= x1)
*               gle_gcb         = gcb_ptr
*               left_side       = address of left margin of graphics memory
*               ybegin          = y associated with left_side
*               red_intensity   = mode/color of fill
*               green_intensity
*               blue_intensity
*               gspacing        = 1 for all graphics except 9826a
*                               = 2 for 9826a internal screen
*               devicetype      = 0 for 9826a
*                                 1 for 9836a
*                                 2 for 98627a
*                                 3 for 9836c
*                                 4 for gator_bw
*                                 5 for gatorbox     - SFB NOV 84
*                                 6 for bobcat       - SFB NOV 84
*                                 7 for bobcatlores  - SFB NOV 84
*                                 8 for catseye_lcc  - SFB MAR 88
*                                 9 for catseye_hrx  - SFB MAR 88
*                                10 for woodcut_vga  - CFB - 31MAY91
*                                11 for woodcut_med  - CFB - 31MAY91
*                                12 for woodcut_hrx  - CFB - 31MAY91
*                                13 for woodcut_vgam - CFB - 30JUL91
*                                14 for woodcut_hrxm - CFB - 30JUL91
*               clip_limits_xmin+2(gcb) = clip boundary for left side of screen
*               clip_limits_xmax+2(gcb) = clip boundary for right side of screen
*
*  exit:        graphics memory is updated
*
*  registers:   a0-a2,d0-d5
*               no others may be used !
*
fill        cmp     clip_limits_xmin+2(gle_gcb),d0  clip x1
            bge.s   fill10
            move    clip_limits_xmin+2(gle_gcb),d0
fill10      cmp     clip_limits_xmax+2(gle_gcb),d1
            ble.s   fill20
            move    clip_limits_xmax+2(gle_gcb),d1
fill20      cmp     d0,d1
            blt     fm_rts

            cmpi.b  #10,devicetype+1(rgl_gcb)   WOODCUT doesn't look like BOBCAT
            bge     fill30                                         CFB - 24JUL91

            cmpi.b  #6,devicetype+1(rgl_gcb)
            bge     fbobcat

fill30      move    blu_intensity(rgl_gcb),d2
            movea.l left_side(rgl_gcb),a0
            move    d0,d3
            move    d1,d4
            ext.l   d0
            ext.l   d1

            cmpi.b  #3,devicetype+1(rgl_gcb)
            beq     f36c

            cmpi.b  #4,devicetype+1(rgl_gcb)   gator - use bitmover
            beq     fgator

            cmpi.b  #5,devicetype+1(rgl_gcb)  check gatorbox
*     can't use tiler for gatorbox (sigh)
            beq     f36c

            cmpi.b  #10,devicetype+1(rgl_gcb)                        CFB 10JUN91
            bge     f36c               WOODCUT has no window mover   CFB 10JUN91

* HOW CAN THIS EVER BE TRUE ??????? - CFB
            cmpi.b  #6,devicetype+1(rgl_gcb)   bobcat - use windowmover
*     but CAN use windowmover (height = 1 pixel) for bobcat
            bge     fbobcat

*     9826a/16a,36a,98627a all come here
            lsr     #3,d0
            lsr     #3,d1
            and     #7,d3
            and     #7,d4
            sub     d0,d1                  d0=# of bytes to do - 1
            addq    #1,d4
            adda    d0,a0                  a0 points to first byte to modify
            tst     devicetype(rgl_gcb)         9816 or 9826 ?
            bne.s   fill40
            adda    d0,a0                  on 9826 & 9816 have to add it twice
fill40      btst    #1,devicetype+1(rgl_gcb)    is this color ?
            beq.s   f26a36a                no

f27a        movea.l a0,a1
            movea.l a0,a2                  a0/a1/a2 point to blue plane
            adda.l  plane2_offset(rgl_gcb),a1   a1 points to green plane
            adda.l  plane3_offset(rgl_gcb),a2   a2 points to red plane
            move.l  a1,-(sp)               save a1 for later
            move    d1,-(sp)               save the byte count (d1)
            bsr.s   fill_plane             fill the blue plane
            move    (sp)+,d1               restore the byte count
            move    grn_intensity(rgl_gcb),d2
            movea.l (sp)+,a0               a0 points to green plane
            move    d1,-(sp)
            bsr.s   fill_plane
            move    (sp)+,d1
            move    red_intensity(rgl_gcb),d2
            movea.l a2,a0                  a0 points to red plane
            bra.s   fill_plane             fill the red plane (fill_p does rts)

f26a36a     cmp     grn_intensity(rgl_gcb),d2   find maximum fill color
            bgt.s   f26a36a10
            move    grn_intensity(rgl_gcb),d2
f26a36a10   cmp     red_intensity(rgl_gcb),d2
            bgt.s   fill_plane
            move    red_intensity(rgl_gcb),d2
            bra.s   fill_plane


dither_table dc.l   $00000000   0
             dc.l   $88000000   1
             dc.l   $88002200   2
             dc.l   $8800aa00   3
             dc.l   $aa00aa00   4
             dc.l   $aa44aa00   5
             dc.l   $aa44aa11   6
             dc.l   $aa44aa55   7
             dc.l   $aa55aa55   8
             dc.l   $aaddaa55   9
             dc.l   $aaddaa77  10
             dc.l   $aaddaaff  11
             dc.l   $aaffaaff  12
             dc.l   $eeffaaff  13
             dc.l   $eeffbbff  14
             dc.l   $eeffffff  15
             dc.l   $ffffffff  16


fill_plane  and     #$1f,d2
            lsl     #2,d2
            move    ybegin(rgl_gcb),d5
            and     #3,d5                  mask off right two bits
            add     d5,d2
            move.b  dither_table(d2),d2
            jmp     (a5)

fill_dom    tst     d1                     how many bytes are effected ?
            bne.s   fd10                   more than one
            rol     d4,d2                  rol.w x2b+1,mask
            move.b  (a0),d2                g->mask.b
            rol.b   d4,d2
            rol     d3,d2
            ror     d4,d2                  ror.w x2b-x1b+1,mask
            ror.b   d3,d2
            move.b  d2,(a0)                mask->g
            rts

fd10        movea   gspacing(rgl_gcb),a1
            move.b  (a0),d0
            rol     d3,d0
            move.b  d2,d0
            rol.b   d3,d0
            ror     d3,d0
            move.b  d0,(a0)
            adda.l  a1,a0
            subq    #2,d1
            blt.s   fd30
fd20        move.b  d2,(a0)
            adda.l  a1,a0
            dbra    d1,fd20
fd30        rol     d4,d2
            move.b  (a0),d2
            rol.b   d4,d2
            ror     d4,d2
            move.b  d2,(a0)
            rts


fill_ndom   tst     d1                     how many bytes are effected ?
            bne.s   fn10                   more than one
            rol     d4,d2                  rol.w x2b+1,mask
            move.b  (a0),d2                g->mask.b
            rol.b   d4,d2
            rol     d3,d2
            ror     d4,d2                  ror.w x2b-x1b+1,mask
            ror.b   d3,d2
            or.b    d2,(a0)                mask->g
            rts

fn10        movea   gspacing(rgl_gcb),a1
            move.b  (a0),d0
            rol     d3,d0
            move.b  d2,d0
            rol.b   d3,d0
            ror     d3,d0
            or.b    d0,(a0)
            adda.l  a1,a0
            subq    #2,d1
            blt.s   fn30
fn20        or.b    d2,(a0)
            adda.l  a1,a0
            dbra    d1,fn20
fn30        rol     d4,d2
            move.b  (a0),d2
            rol.b   d4,d2
            ror     d4,d2
            or.b    d2,(a0)
            rts


fill_erase  not.b   d2
            tst     d1                     how many bytes are effected ?
            bne.s   fe10                   more than one
            rol     d4,d2                  rol.w x2b+1,mask
            move.b  (a0),d2                g->mask.b
            rol.b   d4,d2
            rol     d3,d2
            ror     d4,d2                  ror.w x2b-x1b+1,mask
            ror.b   d3,d2
            and.b   d2,(a0)                mask->g
            rts

fe10        movea   gspacing(rgl_gcb),a1
            move.b  (a0),d0
            rol     d3,d0
            move.b  d2,d0
            rol.b   d3,d0
            ror     d3,d0
            and.b   d0,(a0)
            adda.l  a1,a0
            subq    #2,d1
            blt.s   fe30
fe20        and.b   d2,(a0)
            adda.l  a1,a0
            dbra    d1,fe20
fe30        rol     d4,d2
            move.b  (a0),d2
            rol.b   d4,d2
            ror     d4,d2
            and.b   d2,(a0)
            rts


f36c        and     #3,d0             x1 mod 4
            and     #3,d1             x2 mod 4
            lsl     #2,d0            (x1 mod 4)*4   # of bytes to jump in mask
            lsl     #2,d1            (x2 mod 4)*4   # of bytes to jump in mask
            and     #$fffc,d3         x1 div 4
            adda    d3,a0             a0 points to first nibble that changes
            lsr     #2,d3             # of nibbles to x1
            lsr     #2,d4             # of nibbles to x2
            sub     d3,d4             # of nibbles to do -1
            move    d4,d3
            move    ybegin(rgl_gcb),d5
            and.l   #3,d5
            lsl     #2,d5
            move.l  dither_pattern(rgl_gcb,d5),d2
            move.l  d2,d5
            move.l  mask1(d0),d4
            jmp     (a5)

mask1       dc.l   $ffffffff
            dc.l   $00ffffff
            dc.l   $0000ffff
            dc.l   $000000ff

mask2       dc.l   $ff000000
            dc.l   $ffff0000
            dc.l   $ffffff00
            dc.l   $ffffffff


f36c_dom    tst     d3
            bne.s   fcd10
fcd05       and.l   mask2(d1),d4
            moveq   #0,d3
fcd10       and.l   d4,d5
            not.l   d4
            and.l   d4,(a0)
            or.l    d5,(a0)+
            dbra    d3,fcd20
            rts
fcd20       moveq   #-1,d4
            move.l  d2,d5
            tst     d3
            beq.s   fcd05
            subq    #1,d3
fcd30       move.l  d2,(a0)+
            dbra    d3,fcd30
            bra.s   fcd05

f36c_ndom   tst     d3
            bne.s   fcn10
fcn05       and.l   mask2(d1),d4
            moveq   #0,d3
fcn10       and.l   d2,d4
            or.l    d4,(a0)+
            dbra    d3,fcn20
            rts
fcn20       moveq   #-1,d4
            tst     d3
            beq.s   fcn05
            subq    #1,d3
fcn30       or.l    d2,(a0)+
            dbra    d3,fcn30
            bra.s   fcn05

f36c_erase  not.l   d2
            tst     d3
            bne.s   fce10
fce05       and.l   mask2(d1),d4
            moveq   #0,d3
fce10       and.l   d5,d4
            not.l   d4
            and.l   d4,(a0)+
            dbra    d3,fce20
            rts
fce20       moveq   #-1,d4
            tst     d3
            beq.s   fce05
            subq    #1,d3
fce30       and.l   d2,(a0)+
            dbra    d3,fce30
            bra.s   fce05


*fill_comp  tst     d3
*           bne.s   fc10
*fc05       and.l   mask2(d1),d4
*fc10       and.l   d4,d5
*           eor.l   d5,(a0)+
*           dbra    d3,fc20
*           rts
*fc20       move.l  mask1,d4
*           move.l  d2,d5
*fc30       tst     d3
*           beq.s   fc05
*           eor.l   d2,(a0)+
*           dbra    d3,fc30
*           rts
            page


fgator      movea.l plane1_addr(rgl_gcb),a2
            movea.l (a2),a2
            adda.l  plane1_offset(rgl_gcb),a2       upper right display address
            adda.l  #$0ff000,a2
            move    ybegin(rgl_gcb),d5
            and     #3,d5                           y mod 4
            lsl     #5,d5
            lsl     #5,d5                           1024*(y mod 4)
            adda    d5,a2                           a2 points to dither pat.
            sub     d4,d3                           -(number of pixels)-1
            subq    #1,d3                           -(number of pixels)
fgat10      movea.l old_a5(gle_gcb),a1
            movea.l status(a1),a1
            btst    #7,1(a1)
            beq.s   fgat10
            movea.l old_a5(gle_gcb),a1
            move.w  d3,wwcopy(a1)                   update current window width
            movea.l window(a1),a1                   set window width
            move.w  d3,(a1)
            move.w  #$83,d3
            movea.l old_a5(gle_gcb),a1
            move.w  d3,rrcopy(a1)
            movea.l rule(a1),a1
            move.w  d3,(a1)

            move.b  0(a2,d0),0(a0,d0)               move line

fgat11      movea.l old_a5(gle_gcb),a1
            movea.l status(a1),a1
            btst    #7,1(a1)
            beq.s   fgat11
            move.w  #$3,d3
            movea.l old_a5(gle_gcb),a1
            move.w  d3,rrcopy(a1)
            movea.l rule(a1),a1
            move.w  d3,(a1)

            rts

fbobcat     equ     *            SFB FEB '85
            movea.l old_a5(gle_gcb),a1          access to globals
            movea.l status(a1),a1               windowmover status reg

* now fill the scanline segment by moving a section of the fill pattern stored
* in bottom 4 lines of (offscreen) frame buffer to displayed line segment
* to be filled. The source segment is computed mod 4 because we use a 4x4
* dither cell. The window mover is set to 1 pixel high, so we can treat it
* like a gator line mover.

            cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
            bne.s   waitbobmover
            add.w   d0,d0                       double startx for "real" pixels
            add.w   d1,d1                       double endx for "real" pixels
            addq    #1,d1 {3.1E BUG SFB 6/14/85}and go to right edge of pixel

waitbobmover equ    *
            move.w  (a1),d5
            lsr     #8,d5                       status in even byte
*           IS THIS A BUG ???? SFB
*           and.w   gamut(gle_gcb),d5           check only loaded topcats
            and.w   gamut+2(gle_gcb),d5         check only loaded topcats
            beq.s   bobmover_done
            move.l  #1,-(sp)                    not ready, so wait before
            jsr     delay_timer                 testing mover status again
            bra.s   waitbobmover

bobmover_done equ   *
            movea.l deviceaddress(rgl_gcb),a1   base for graphics control
            move.w  d0,sox(a1)                  source x
            move.w  d0,dox(a1)                  destination x
            move.w  ybegin(rgl_gcb),d5
            move.w  hard_ymax(rgl_gcb),d2       prepare to reverse sign of y
            sub.w   d5,d2                       convert ybegin to pixelline
            move.w  d2,doy(a1)                  destination y
            and.w   #3,d5                       dest y mod 4
            movep.w $9(a1),d2                   height of visible buffer (ROM)
            sub.w   #4,d2                       move up 4 lines from bottom
            add.w   d2,d5                       access one of last 4 lines
            move.w  d5,soy(a1)                  source y (within fill pattern)
            move.w  #1,bobh(a1)                 height (1 pixel)
            sub.w   d0,d1                       width-1 (real pixels)
            addq    #1,d1                       width (real pixels)
            move.w  d1,bobw(a1)                 width
            move.l  gamut(gle_gcb),d5           move all planes
            lsl     #8,d5
            cmpi.b  #catseye_display,devicetype+1(rgl_gcb)      SFB
            bge.s   fcatseye                                    SFB
            move.w  #3,bobwr(a1)                windowmove replacement rule
move_scanline equ    *
            move.w  d5,bobwm(a1)
            rts                                 DONE-don't wait for it to
*                                               complete (DGL owns the
*                                               bobcat windowmover resource)
fcatseye    equ     *
            move.w  #$100,trr_enable(a1)      select Three Operand Repl Rule SFB
            move.w  #$f000,trr(a1)            choose "Pattern Reg" rule      SFB
            move.w  d5,fben1(a1)              enable all loaded planes       SFB
            bra     move_scanline                                            SFB

            page
****************************************************************************
*
* cursor ( gcb : graphics_control_block_ptr )
*
*   INFO1 - X location
*   INFO2 - Y location
*   INFO3 - Mode  ( 0 = off, 1 = on )
*
gle_aras_out_rcursor equ *
            movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
            move.l  (sp)+,(sp)
            movem.l a5/a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep_gcb

            cmpi.w  #1,current_cursor_state(gle_gcb)
            bne.s   curs1

            move.w  current_cursor_x+2(gle_gcb),cursor_x(rgl_gcb) remove current cusor
            move.w  current_cursor_y+2(gle_gcb),cursor_y(rgl_gcb)
            bsr.s   cursor_p

curs1       equ *
            cmpi.l  #1,info3(gle_gcb)
            bne.s   curs2

            move.w  info1+2(gle_gcb),cursor_x(rgl_gcb)    draw new cursor
            move.w  info2+2(gle_gcb),cursor_y(rgl_gcb)
            bsr.s   cursor_p

curs2       equ *
            move.l  info1(gle_gcb),current_cursor_x(gle_gcb)
            move.l  info2(gle_gcb),current_cursor_y(gle_gcb)
            move.w  info3+2(gle_gcb),current_cursor_state(gle_gcb)

            bra     rts
*
*
* the cursor_x and cursor_y will be in system
* units, ie., from 0..hard_xmax and
* 0..hard_ymax.  the set_x routine changes
* to actual hardware addresses.
*
cursor_p    equ *
            movea.l plane2_offset(rgl_gcb),a2        green plane
            movea.l plane3_offset(rgl_gcb),a3        red plane
            movea.l plane1_addr(rgl_gcb),a1          blue plane
            movea.l (a1),a1
            adda.l  plane1_offset(rgl_gcb),a1        upper right display address
            move    devicetype(rgl_gcb),d6
            cmpi.b  #gator_display,devicetype+1(rgl_gcb)  gator/box/bobcat
*           bne.s   skp_notgat                            -- reset d6 like 36c
            blt.s   skp_notgat
            move    #3,d6
skp_notgat  tst     d6
            bne.s   cp1
            adda.l  #1,a1                            9826/16 inc
cp1         move    bytesperline(rgl_gcb),d5
            move    hard_ymax(rgl_gcb),d3
            muls    d5,d3
            adda.l  d3,a1                       address of lower left
            move    gspacing(rgl_gcb),d7
            ext.l   d5
            ext.l   d7
            clr.l   d3
            clr.l   d4
* clip the cursor first:
c10         movea.l a1,a5
            move    cursor_x(rgl_gcb),d0
            cmpi    #4,d0                   is center <4 from left edge?
            blt     clip_left
            move    hard_xmax(rgl_gcb),d1
            subq    #4,d1
            cmp     d1,d0                   is center >4 from right edge?
            bgt     clip_right
            subq    #4,d0                   if got here, then fix d0 & d3
            move.b  #8,d3
c20         move    cursor_y(rgl_gcb),d1
            cmpi    #4,d1                   is center <4 from bottom edge?
            blt     clip_bottom
            move    hard_ymax(rgl_gcb),d2
            subq    #4,d2
            cmp     d2,d1
            bgt     clip_top
* if the line is unclipped, i.e., we got here, then draw 9 bits:
            move.b  #8,d4                   d3 was set to appropriate value
            move    d1,d2                   above for vertical calculation
            addq    #4,d2                   +4 above curs_y
*
* at entry:
*       d0 = x
*       d1 = y  for horizontal line
*       d2 = y  for vertical   line
*       d3 = bits to change in horizontal line - 1
*       d4 = bits to change in vertical line - 1
*       d5 = number of bytes/line
*       d6 = crt type  0-9826  1-9836  2-98627  3-9836C/BITMAP
*       d7 = gspacing
*       a1 = lower left corner of graphics memory
*       a2 = plane2_offset
*       a3 = plane3_offset
*
* do the horizontal line first, left to right
*
* | modified to fix cursor bug -- 12/83 BDS
draw_horiz  equ *
            cmp     hard_ymax(rgl_gcb),d1
            bgt     draw_vert               If cursor_y > max y, skip to vert
            tst     d1
            blt     draw_vert               If cursor_y < 0, skip to vert
            beq.s   dh20
dh10        mulu    d5,d1
            suba.l  d1,a1                   gives y address
dh20        bsr     set_x
dh30        btst    #1,d6
            beq     dh50
            btst    #0,d6
            beq     dh40
            cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
            beq     dh37        SFB 6/20/85
dh35        not.b   (a1)+
            dbra    d3,dh35
            bra.s   draw_vert
dh37        not.w   (a1)+       SFB 6/20/85
            dbra    d3,dh37     SFB 6/20/85
            bra.s   draw_vert   SFB 6/20/85
dh40        bchg    d0,0(a1,a2.l)
            bchg    d0,0(a1,a3.l)
dh50        bchg    d0,(a1)
dh60        dbra    d3,dh65                 d3=no. of bits to change
            bra.s   draw_vert
dh65        subq.b  #1,d0
            cmpi.b  #0,d0                   are we at end of byte?
            bge.s   dh30                    goto dh30 if not
            adda.l  d7,a1                   increment to next byte
            moveq   #7,d0                   start changing bit 7 of next byte
dh70        btst    #1,d6
            beq     dh90
dh80        bchg    d0,0(a1,a2.l)
            bchg    d0,0(a1,a3.l)
dh90        bchg    d0,(a1)
            subq.b  #1,d0
            dbra    d3,dh70
* do vertical line next, top to bottom:
* | modified to fix cursor bug -- 12/83 BDS
draw_vert   equ *
            move    cursor_x(rgl_gcb),d0           vert. line draw at x=cursor_x
            blt.s   dv70                   if x < 0, skip vert line
            cmp     hard_xmax(rgl_gcb),d0
            bgt.s   dv70                   if x > max x, skip vert line
            tst     d2
            beq.s   dv20
dv10        mulu    d5,d2
            suba.l  d2,a5
dv20        movea.l a5,a1
            bsr     set_x                   d0=bit
dv30        btst    #1,d6
            beq     dv50
            btst    #0,d6
            beq     dv40
            cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
            beq     dv37        SFB 6/20/85
dv35        not.b   (a1)
            adda.l  d5,a1
            dbra    d4,dv35
            rts
dv37        not.w   (a1)        SFB 6/20/85
            adda.l  d5,a1       SFB 6/20/85
            dbra    d4,dv37     SFB 6/20/85
            rts
dv40        bchg    d0,0(a1,a2.l)
            bchg    d0,0(a1,a3.l)
dv50        bchg    d0,(a1)
dv60        adda.l  d5,a1                   sub n bytes/row from a1
            dbra    d4,dv30
dv70        rts                             if d4=-1, we are done
*
*
set_x       equ *
            move    d0,d1
            cmpi.b  #3,devicetype+1(rgl_gcb)
            bge.s   sx10
            lsr     #3,d1
            tst     devicetype(rgl_gcb)
            bne.s   sx10
            lsl     #1,d1
sx10        adda    d1,a1
            cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
            bne     sx20
            adda    d1,a1       "real" pixels   SFB 6/20/85
sx20        andi.l  #7,d0
            neg     d0
            addq    #7,d0
            rts
*
* | modified to fix cursor bug -- 12/83 BDS
clip_left   equ *
* at entry, d0 contains cursor_x
            move    d0,d3
            addq    #4,d3                   draw cursor_x + 5 dots
            bge.s   cl10                    draw no less than 0 dots
            moveq   #0,d3
cl10        moveq   #0,d0                   new x
            bra     c20
*
* | modified to fix cursor bug -- 12/83 BDS
clip_right  equ *
* at entry, d1 contains bits_in_y minus 4;
*           d0 contains cursor_x
            addq    #4,d1                   d1 = hard_xmax
            move    d1,d3                   d3 = hard_xmax
            subq    #4,d0                   d0 = cursor_x - 4 (start of line)
            sub     d0,d3                   d3 = # of dots (xmax-start of line)
            bge     c20                     if start of line > x max
            move    d1,d0                           start of line = xmax
            moveq   #0,d3                           # of dots = 0
            bra     c20

*
* | modified to fix cursor bug -- 12/83 BDS
clip_bottom equ *
* at entry, d0 contains proper x value for the horizontal line, and
*           d1 contains proper y value for the horizontal line.
            move    d1,d2
            addq    #4,d2                   y for vertical line
            bge.s   cb20                    if y < 0 then
            moveq   #0,d2                      y = 0
cb20        move    d2,d4                   number of bits to draw = y
            bra     draw_horiz
*
* | modified to fix cursor bug -- 12/83 BDS
clip_top equ *
* at entry, d0 and d1 contain the proper x and y values for the horizontal,
*           d1 contains cursor_y.
*           d2 contains bits_in_y minus 4.
            sub     d1,d2                   d2 - curs_y
            addi    #8,d2                   number of bits to draw
            bge.s   ct10                    if # of bits < 0 then
            moveq   #0,d2                      # of bits = 0
ct10        move    d2,d4
            move    hard_ymax(rgl_gcb),d2        new y
            bra     draw_horiz
*
*
*  dump graphics expanded
*
*gdump_exp   equ *
*movea.l 4(sp),a0                   a0 = address of pointer to gcb
*move.l  (sp)+,(sp)                 stack return address
*movem.l a5-a6,old__a5(a0)
*movea.l a0,a6                      a6 = address of pointer to gcb
*move    n_glines(rgl_gcb),d3            d3 = number of graphics lines
*subq    #1,d3                      d3 = d3-1
*move    bytesperline(rgl_gcb),d4        d4 = bytes/line
*movea.l lower_left(rgl_gcb),a1          a1 = address of lower left
*movea.l addr1(rgl_gcb),a0               a0 = address of string
*move.l  index(rgl_gcb),d0               d0 = number of line to be dumped
*bsr     set_x
*moveq   #7,d2
*move    devicetype(rgl_gcb),d1
*add     d1,d1
*jmp     getable(d1)
*getable     bra.s   ge26a
*bra.s   ge26a                      36a same as 26a
*bra.s   ge27a
*bra.s   ge36c
*
*ge26a       move.b  (a1),d5
*btst    d0,d5
*beq.s   ge26a10
*bset    d2,(a0)
*subq.b  #1,d2
*bset    d2,(a0)
*subq.b  #1,d2
*bra.s   ge26a20
*ge26a10     bclr    d2,(a0)
*subq.b  #1,d2
*bclr    d2,(a0)
*subq.b  #1,d2
*ge26a20     bge.s   ge26a30
*adda    #1,a0
*moveq   #7,d2
*ge26a30     suba    d4,a1
*dbra    d3,ge26a
*bra     rts
*
*ge27a       bsr     getoffsets
*ge27a10     move.b  (a1),d5
*move.b  (a2),d6
*or.b    d5,d6
*move.b  (a3),d5
*or.b    d5,d6
*btst    d0,d6
*beq.s   ge27a20
*bset    d2,(a0)
*subq.b  #1,d2
*bset    d2,(a0)
*subq.b  #1,d2
*bra.s   ge27a30
*ge27a20     bclr    d2,(a0)
*subq.b  #1,d2
*bclr    d2,(a0)
*subq.b  #1,d2
*ge27a30     bge.s   ge27gle_gcb0
*adda    #1,a0
*moveq   #7,d2
*ge27gle_gcb0     suba    d4,a1
*suba    d4,a2
*suba    d4,a3
*dbra    d3,ge27a10
*bra     rts

*ge36c       cmpi.b  #0,(a1)
*beq.s   ge36c10
*bset    d2,(a0)
*subq.b  #1,d2
*bset    d2,(a0)
*subq.b  #1,d2
*bra.s   ge36c20
*ge36c10     bclr    d2,(a0)
*subq.b  #1,d2
*bclr    d2,(a0)
*subq.b  #1,d2
*ge36c20     bge.s   ge36c30
*adda    #1,a0
*moveq   #7,d2
*ge36c30     suba    d4,a1
*dbra    d3,ge36c
*bra     rts
*
*******************************************************************************
gr26a       moveq   #50,d0             50 bytes/line; 1 dumped at a time
            move.l  info1(gle_gcb),d5       test for dump flag bit 0 = 1 or
            beq.s   gr26a20            dump flag = 0
            btst    #0,d5
            bne.s   gr26a20
            moveq   #0,d1
            bra.s   gr26a20c

gr26a10c    move.b  d1,(a0)+           set to zero's
gr26a20c    dbra    d0,gr26a10c
            bra     rts

gr26a10     move.b  (a1),(a0)+         dump normal
            addq    #2,a1
gr26a20     dbra    d0,gr26a10
            bra     rts

*
*  GET_RASTER ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*    Return formated packed array of char for dump graphics
*
*      INFO_PTR1 = Start of packed array of char
*      INFO1     = Which planes to 'or'
*      INFO2     = Graphics line # to convert (0 = top of crt)
*
gle_aras_out_rget_raster equ *
            movea.l 4(sp),gle_gcb                    a4 = address of pointer to gcb
            move.l  (sp)+,(sp)
            movem.l a5/a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb   a6 = dev dep gcb

            movea.l info_ptr1(gle_gcb),a0            a0 = address of string

            movea.l plane1_addr(rgl_gcb),a1
            movea.l (a1),a1
            adda.l  plane1_offset(rgl_gcb),a1       upper right address
            move.l  info2(gle_gcb),d0               d0 = row to be dumped
            mulu    bytesperline(rgl_gcb),d0        d0 = row * bytes/line
            adda.l  d0,a1                           a1 = address of line dumped
            move    devicetype(rgl_gcb),d1
            cmpi.b  #gator_display,devicetype+1(rgl_gcb)
*           bne.s   skp_notgat2         SFB NOV 84
            blt.s   skp_notgat2         SFB NOV 84
            move    #3,d1               gator/gatorbox/bobcat -- set d1 to 36c
skp_notgat2 add     d1,d1
            jmp     grtable(d1)
grtable     bra.s   gr26a
            bra.s   gr36a
            bra.s   gr27a
            bra.s   gr36c

gr36a       moveq   #16,d0                  64 bytes/line; 4 dumped at a time
            move.l  info1(gle_gcb),d5       test for dump flag bit 0 = 1 or
            beq.s   gr36a20                 dump flag = 0
            btst    #0,d5
            bne.s   gr36a20
            moveq   #0,d1
            bra.s   gr36a20c

gr36a10c    move.l  d1,(a0)+           dump zeros
gr36a20c    dbra    d0,gr36a10c
            bra     rts

gr36a10     move.l  (a1)+,(a0)+        dump normal
gr36a20     dbra    d0,gr36a10
            bra     rts

gr27a       bsr     getoffsets
            moveq   #16,d0                  64 bytes/line; 4 dumped at a time
            move.l  info1(gle_gcb),d5       get mask
            bra.s   gr27a20
gr27a10     moveq   #0,d3
            move.l  (a1)+,d1
            btst    #0,d5
            beq.s   gr1
            move.l  d1,d3
gr1         move.l  (a2)+,d1
            btst    #1,d5
            beq.s   gr2
            or.l    d1,d3
gr2         move.l  (a3)+,d1
            btst    #2,d5
            beq.s   gr3
            or.l    d1,d3
gr3         move.l  d3,(a0)+
gr27a20     dbra    d0,gr27a10
            bra     rts

gr36c       moveq   #63,d0             64 bytes/line; 1 dumped at a time (-1)
gr36c10     moveq   #7,d1
            moveq   #0,d2
gr36c20     move.b  (a1)+,d3
            and.b   info1+3(gle_gcb),d3
            cmpi.b  #0,d3
            beq.s   gr36c30
            bset    d1,d2
gr36c30     dbra    d1,gr36c20
            move.b  d2,(a0)+
            dbra    d0,gr36c10
            bra     rts
*
*
*
*gstore_proc      equ *
*movea.l 4(sp),a0                   a0 = address of pointer to gcb
*move.l  (sp)+,(sp)                 stack return address
*movem.l a5-a6,old__a5(a0)
*movea.l a0,a6                      a6 = address of pointer to gcb
*movea.l addr1(rgl_gcb),a0               a0 = address of array
*move.l  index(rgl_gcb),d0               d0 = size of array in words
*movea.l plane1_addr(rgl_gcb),a1         a1 = ptr to address of plane 1
*movea.l (a1),a1                    a1 = address of plane 1
*adda.l  plane1_offset(rgl_gcb),a1       upper right address
*move    gspacing(rgl_gcb),d1
*subq    #1,d1
*adda.w  d1,a1                      adjust for 16/26 odd adr
*move    devicetype(rgl_gcb),d1
*add     d1,d1
*jmp     gstable(d1)
*gstable     bra.s   gs26a
*bra.s   gs36a
*bra.s   gs27a
*bra.s   gs36c
*
*gs26a       add.l   d0,d0
*bra.s   gs26a20
*gs26a10     move.b  (a1),(a0)+
*addq    #2,a1
*gs26a20     dbra    d0,gs26a10
*bra     rts
*
*gs36a       bra.s   gs36a20
*gs36a10     move    (a1)+,(a0)+
*gs36a20     dbra    d0,gs36a10
*bra     rts
*
*gs27a       divu    #3,d0
*move.l  d0,d1
*swap    d1
*bsr     getoffsets
*bra     gs27a20
*gs27a10     move    (a1)+,(a0)+
*move    (a2)+,(a0)+
*move    (a3)+,(a0)+
*gs27a20     dbra    d0,gs27a10
*sub.b   #1,d1
*blt     rts
*move    (a1)+,(a0)+
*sub.b   #1,d1
*blt     rts
*move    (a2)+,(a0)+
*sub.b   #1,d1
*blt     rts
*move    (a3)+,(a0)+
*bra     rts
*
*gs36c       lsr.l   #1,d0
*bra.s   gs36c20
*gs36c10     move.l  (a1)+,d2
*ror.l   #4,d2
*or.l    (a1)+,d2
*rol.l   #4,d2
*move.l  d2,(a0)+
*gs36c20     dbra    d0,gs36c10
*bra     rts
*
**
**
*
*gload_proc       equ *
*movea.l 4(sp),a0                   a0 = address of pointer to gcb
*move.l  (sp)+,(sp)                 stack return address
*movem.l a5-a6,old__a5(a0)
*movea.l a0,a6                      a6 = address of pointer to gcb
*movea.l addr1(rgl_gcb),a0               a0 = address of array
*move.l  index(rgl_gcb),d0               d0 = size of array in words
*movea.l plane1_addr(rgl_gcb),a1         a1 = ptr to address of plane 1
*movea.l (a1),a1                    a1 = address of plane 1
*adda.l  plane1_offset(rgl_gcb),a1       upper right address
*move    gspacing(rgl_gcb),d1
*subq    #1,d1
*adda.w  d1,a1                      adjust for 16/26 odd adr
*move    devicetype(rgl_gcb),d1
*add     d1,d1
*jmp     gltable(d1)
*gltable     bra.s   gl26a
*bra.s   gl36a
*bra.s   gl27a
*bra     gl36c
*
*gl26a       moveq   #48,d1
*divu    #12,d0
*bra.s   gl26a20
*gl26a10     movem.l (a0)+,d2-d7
*movep.l d2,$0(a1)
*movep.l d3,$8(a1)
*movep.l d4,$10(a1)
*movep.l d5,$18(a1)
*movep.l d6,$20(a1)
*movep.l d7,$28(a1)
*adda    d1,a1
*gl26a20     dbra    d0,gl26a10
*swap    d0
*add     d0,d0
*bra.s   gl26gle_gcb0
*gl26a30     move.b  (a0)+,(a1)
*addq    #2,a1
*gl26gle_gcb0     dbra    d0,gl26a30
*bra     rts
*
*gl36a       moveq   #40,d1
*divu    #20,d0
*bra.s   gl36a20
*gl36a10     movem.l (a0)+,d2-d7/a2-a5
*movem.l d2-d7/a2-a5,(a1)
*adda    d1,a1
*gl36a20     dbra    d0,gl36a10
*swap    d0
*bra.s   gl36gle_gcb0
*gl36a30     move    (a0)+,(a1)+
*gl36gle_gcb0     dbra    d0,gl36a30
*bra     rts
*
*gl27a       divu    #12,d0
*move.l  d0,d1
*swap    d1
*bsr     getoffsets
*bra     gl27a20
*gl27a10     move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*move    (a0)+,(a1)+
*move    (a0)+,(a2)+
*move    (a0)+,(a3)+
*gl27a20     dbra    d0,gl27a10
*gl27a30     sub.b   #1,d1
*blt     rts
*move    (a0)+,(a1)+
*sub.b   #1,d1
*blt     rts
*move    (a0)+,(a2)+
*sub.b   #1,d1
*blt     rts
*move    (a0)+,(a3)+
*bra.s   gl27a30
*
*gl36c       lsr.l   #1,d0
*bra.s   gl36c20
*gl36c10     move.l  (a0)+,d2
*move.l  d2,(a1)+
*ror.l   #4,d2
*move.l  d2,(a1)+
*gl36c20     dbra    d0,gl36c10
*bra     rts
*
**
**
**
getoffsets  movea.l a1,a2
            movea.l a1,a3
            adda.l  plane2_offset(rgl_gcb),a2
            adda.l  plane3_offset(rgl_gcb),a3
            rts
*
*get_size    equ     *
*cmpi.b  #2,devicetype+1(rgl_gcb)
*beq.s   moon
*move.l  #$6180,t1(rgl_gcb)
*move.l  #$30C,t2(rgl_gcb)
*rts
*
*moon        move.l  #$8000,t1(rgl_gcb)
*move.l  #$400,t2(rgl_gcb)
*rts

rtarg       equ     rgltemp1
ract        equ     rgltemp1+2
gtarg       equ     rgltemp2
gact        equ     rgltemp2+2
btarg       equ     rgltemp3
bact        equ     rgltemp3+2
serrin      equ     rgltemp4
serrout     equ     rgltemp5
red         equ     red_intensity


*************************************************************************
*
* PROCEDURE FILL_INDEX_COLOR ( GCB : GRAPHICS_CONTROL_BLOCK_PTR );
*
*  INFO1 = Parameter mode
*            0 - RGB values passed
*            1 - Color map index passed
*
*  INFO2 = Normalized RED value or Color index (based on mode)
*  INFO3 = Normalized GREEN value
*  INFO4 = Normalized Blue value
*
gle_aras_out_rfill_index_color equ *
*
            movea.l 4(sp),gle_gcb                   a4 = gcb
            move.l  (sp)+,(sp)
*           lea     -512(a7),a0
*           cmp.l   a0,SYSGLOBALS-14(a5)
*           ble.s   stackok
*           move.w  #-2,SYSGLOBALS-2(a5)
*           trap    #10
* stackok   equ     *
            movem.l a5/a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep gcb

            tst.l   info1(gle_gcb)                  ck mode
            beq.s   fill_index2

            move.l  info2(gle_gcb),d0               get color index
            move.w  d0,current_polygon_color(gle_gcb)

            moveq   #0,d1
fill_index1 move.b  d0,dither_pattern(rgl_gcb,d1.l)
            addq.l  #1,d1
            cmp     #15,d1
            ble.s   fill_index1
            bra     rts


fill_index2 move.w  #-1,current_polygon_color(gle_gcb)
            move.w  info2+2(gle_gcb),d0                   red
            move.w  info3+2(gle_gcb),d1                   green
            move.w  info4+2(gle_gcb),d2                   blue

            move.w  d0,current_polygon_red(gle_gcb)
            move.w  d1,current_polygon_green(gle_gcb)
            move.w  d2,current_polygon_blue(gle_gcb)

*cmpi.w  #1,color_map_support(gle_gcb)      ck for color
            cmpi.w #3,devicetype(rgl_gcb)
            beq.s   setup_c_dither
            cmpi.w #gator_display,devicetype(rgl_gcb)  //// do same for ////
*           beq.s   setup_c_dither                     //// gator for now //
            bge.s   setup_c_dither                    also for gatorbox/bobcat

            add.w   #32,d0
            add.w   #32,d1
            add.w   #32,d2

            lsr.w   #6,d0
            lsr.w   #6,d1
            lsr.w   #6,d2

            move.w  d0,red_intensity(rgl_gcb)
            move.w  d1,grn_intensity(rgl_gcb)
            move.w  d2,blu_intensity(rgl_gcb)

            bra rts

*************************************************************************
*
setup_c_dither equ *

            move.w  d0,red_intensity(rgl_gcb)
            move.w  d1,grn_intensity(rgl_gcb)
            move.w  d2,blu_intensity(rgl_gcb)

set_intens  equ *
            lea     system_cmap(rgl_gcb),a0
            suba    #768,a7     {SFB 4/12/85}  allocate 768 bytes off stack
            lea     512(a7),a1                 use 256 bytes for count array
            lea     0(a7),a5                   and 512 for boolean in/out
            movem   red(a6),d1-d3
            lsl     #4,d1                      d1 = 16*red
            lsl     #4,d2                      d2 = 16*grn
            lsl     #4,d3                      d3 = 16*blu
            movea.l a0,a2                      a2 = temp address of syscmap
            move.l  gamut(gle_gcb),d0          d0 = loop counter
            moveq   #0,d4                      d4 = zero out upper byte
si10        clr.b   0(a5,d0)                   clear boolean
            move.w  (a2),d4                    d4 = syscmap.r
            cmp     d4,d1                      if syscmap.r>16*red
            blt.s   si20                       then outside
            move.w  2(a2),d4                   d4 = syscmap.g
            cmp     d4,d2                      if syscmap.g>16*grn
            blt.s   si20                       then outside
            move.w  4(a2),d4                   d4 = syscmap.b
            cmp     d4,d3                      if syscmap.b>16*blu
            blt.s   si20                       then outside
            move.b  #1,0(a5,d0)                inside so set boolean
si20        addq    #6,a2                      increment to next syscmap
            dbra    d0,si10                    loop
            clr.l   rtarg(a6)                  clear rtarg and ract
            clr.l   gtarg(a6)                  clear gtarg and gact
            clr.l   btarg(a6)                  clear btarg and bact
            movea.l a1,a3                      a3 = count array pointer
            move.l  gamut(gle_gcb),d0          loop counter
            lsr     #2,d0                      divide by 4 for long words
si30        clr.l   (a3)+                      clear count array
            dbra    d0,si30                    loop
            moveq   #0,d4                      zero out upper byte of d4
            moveq   #15,d0                     pixel loop counter
si40        movem   red(a6),d5-d7
            add     d5,rtarg(a6)               rtarg=rtarg+red
            add     d6,gtarg(a6)               gtarg=gtarg+grn
            add     d7,btarg(a6)               btaeg=btarg+blu
            move.l  #$7fffffff,serrin(a6)      smallest_err_in=maxint
            move.l  serrin(a6),serrout(a6)     smallest_err_out=maxint
            movea.l a0,a2                      syscmap array index
            moveq   #0,d7                      in flag
            move.l  gamut(gle_gcb),d1          inner loop counter
si50        tst     d7                         if none in so far
            beq.s   si55                       then got to look for one
            tst.b   0(a5,d1)                   if this vector is out
            beq     si100                      then don't do this stuff
si55        move    rtarg(a6),d2
            sub     ract(a6),d2
            move.w  (a2),d4                    get syscmap.r
            sub     d4,d2                      d2=rtarg-ract-syscmap.r
            muls    d2,d2
si60        move.l  d2,d3
            move    gtarg(a6),d2
            sub     gact(a6),d2
            move.w  2(a2),d4                   get syscmap.g
            sub     d4,d2                      d2=gtarg-gact-syscmap.g
            muls    d2,d2
si70        add.l   d2,d3
            move    btarg(a6),d2
            sub     bact(a6),d2
            move.w  4(a2),d4                   get syscmap.b
            sub     d4,d2                      d2=btarg-bact-syscmap.b
            muls    d2,d2
si80        add.l   d2,d3
            tst.b   0(a5,d1)                   if vector not inside
            beq.s   si90                       then outside
            cmp.l   serrin(a6),d3              if smallest_err_in<=error
            bge.s   si100                      then ignore
            move.l  d3,serrin(a6)              smallest_err_in=error
            move    d1,d5                      closest_color_in=i
            moveq   #1,d7                      in flag
            bra.s   si100
si90        cmp.l   serrout(a6),d3             if smallest_err_out<=error
            bge.s   si100                      then ignore
            move.l  d1,serrout(a6)             smallest_err_out=error
            move    d1,d6                      closest_color_out=i
si100       addq    #6,a2                      increment syscmap pointer
            dbra    d1,si50                    loop (inner)
            tst     d7                         if no vectors were in
            beq.s   si110                      then do out stuff
            move    d5,d6                      closest_color=closest_color_in
si110       move.l  gamut(gle_gcb),d5          get number of colormap entries
            sub     d6,d5                      real index= entries-i
            movea   d5,a3                      a3=closest_color

* following is code originally for 4 byte/color map entry (1 byte each for
* RGB, and 1 byte pad)
*           add     d5,d5
*           movea   d5,a2                      a2=closest_color
*           adda    d5,a2                      a2=4*closest_color
* instead, for 6 byte/color map entry (2 bytes each for RGB), do
            movea   d5,a2                      a2=closest_color
            add     d5,d5                      d5=2*closest_color
            adda    d5,a2                      a2=3*closest_color
            adda    a2,a2                      a2=6*closest_color

            adda.l  a0,a2                      pointer to syscmap[closest_c]
            adda.l  a1,a3                      pointer to count[closest_c]
            moveq   #0,d5                      zero upper byte
            moveq   #0,d6                      zero upper byte
            moveq   #0,d7                      zero upper byte
            move.w  (a2),d5                    get syscmap[cc].r
            move.w  2(a2),d6                   get syscmap[cc].g
            move.w  4(a2),d7                   get syscmap[cc].b
            add     d5,ract(a6)                ract=ract+syscmap[cc].r
            add     d6,gact(a6)                gact=gact+syscmap[cc].g
            add     d7,bact(a6)                bact=bact+syscmap[cc].b
            addq.b  #1,(a3)                    increment count[cc]
            dbra    d0,si40                    loop (outer)
            movea.l a5,a2                      a2 points to scratch array
            move.l  gamut(gle_gcb),d0          d0= i:loop counter
            move    d0,d3                      save max pen for later
            moveq   #0,d1                      num of entries counter
            moveq   #0,d5                      zero upper byte
            moveq   #0,d6                      zero upper byte
si120       move.b  0(a1,d0),d2                count[i]
            beq     si130                      if no count then goto next
            moveq   #0,d5                      zero upper byte
            move.b  d0,(a2)+                   store entry in scratch array
            move.b  d2,(a2)+                   store count in scratch array
            move    d0,d4                      i
            add     d4,d4                      2*(i)
            add     d4,d4                      4*(i)
            move.w  2(a0,d4),d5                syscmap[i].grn
            add     d5,d5                      2*grn
            add     d5,d5                      4*grn
            move.w  0(a0,d4),d6                syscmap[i].red
            add     d6,d5                      4*grn+red
            add     d5,d5                      8*grn+2*red
            add     d6,d5                      8*grn+3*red
            move.w  4(a0,d4),d6                syscmap[i].blu
            add     d6,d5                      8*grn+3*red+blu
            move    d5,(a2)+                   store brightness in scratch arry
            addq    #1,d1                      num of entries counter + 1
si130       dbra    d0,si120                   next i
            subq    #1,d1                      num of entries counter - 1
            beq     si160                      only one entry then skip
            add     d1,d1
            add     d1,d1                      j
            moveq   #0,d0                      n=0
si140       move    d0,d2                      i=n
si150       addq    #4,d2                      i=i+1
            move    2(a5,d0),d3                brightness[n]
            cmp     2(a5,d2),d3                is brightness[i]>brightness[n]
            bge     si155                      then pull the old switcheroo
            move.l  0(a5,d2),d4                temp=record[i]
            move.l  0(a5,d0),0(a5,d2)          record[i]=record[n]
            move.l  d4,0(a5,d0)                record[n]=temp
si155       cmp     d2,d1                      is i<j
            bgt     si150
            addq    #4,d0                      n=n+1
            cmp     d0,d1                      is n>j
            bgt     si140
si160       moveq   #0,d0                      pixel=0
            moveq   #0,d3                      i=0
            moveq   #0,d4                      zero upper byte
si170       moveq   #0,d2                      n=0
si180       move.b  ditseq(d0),d4
            move.b  0(a5,d3),dither_pattern(a6,d4)
            addq    #1,d0
            addq    #1,d2
            cmp.b   1(a5,d3),d2                is count[i]<n
            blt     si180
            addq    #4,d3                      i=i+1
            cmp     d3,d1                      is i>j
            bge     si170
            adda    #768,a7     {SFB 4/12/85}  return space to stack
            bra     rts

ditseq      dc.b    0,10,8,2,5,15,13,7,4,14,12,6,1,11,9,3

* here we repartition the dither pattern and place it into the trr pattern rgisters of
* the CATSEYE. Later, in rpolygon, we will use trr to move the required scanline to
* the screen using the "P" trr rule. We do this because there is not enough width
* in offscreen frame buffer on the hrx machines to store a dithered scanline that
* can span the 1280-pixel wide screen. SFB
*
* The dither pattern is a 4x4 array of byte-per-pixel pixels.
* The data in it may be significant in from 1 to 8 planes.
* The pattern registers are a 16x16 by up to 8 plane deep array of bit-per-pixel
* data to combine into the frame buffer. We must replicate the 4x4 dither pattern
* both vertically and horizontally to fill the 16x16 bit x n plane pattern register
* set.

* dither pattern (bytes):

*               (0,0) (0,1) (0,2) (0,3)
*               ...
*               (3,0) (3,1) (3,2) (3,3)

* Pattern regs (bits):

* plane 0       (0,0) (0,1)...(0,15)
*               ...
*               (15,0) (15,1)...(15,15)

* plane 1       (0,0) (0,1)...(0,15)
*               ...
*               (15,0) (15,1)...(15,15)

*               ...

* plane n       (0,0) (0,1)...(0,15)
*               ...
*               (15,0) (15,1)...(15,15)


* Pascal entry point dither_to_pattregs(gcb); called from gator_fill_index_color
* iff display is hrm CATSEYE. SFB

gle_aras_out_dither_to_pattregs equ *           Pascal entry point              SFB
            movea.l 4(sp),gle_gcb
            movem.l a5/a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb
            movea.l deviceaddress(rgl_gcb),a0
            lea     pattregs(a0),a0     do this because can't use >127 displacement later
            move.l  gamut(gle_gcb),d3   d3: how many planes to slice
            moveq   #0,d1               d1: pattern register index
            moveq   #0,d2               d2: single bit selector
next_plane  equ     *
            moveq   #0,d6       d6: indexes columns of dither pattern (0..3)
            moveq   #3,d4       d4: counts lines of dither pattern (3..0)
next_line   equ     *
            moveq   #3,d5       d5: counts columns of dither pattern (3..0)
            moveq   #0,d0       d0: tmp, construct register data here
next_bit    equ     *           next byte of dither pattern cell->next bit of d0
            btst    d2,dither_pattern(rgl_gcb,d6)
            beq     not_set
            bset    d5,d0
not_set     equ     *
            addq    #1,d6               next row of dither pattern
            dbra    d5,next_bit
            mulu    #$1111,d0           replicate 4 bits horizontally
            move.w  d0,(a0,d1)          move data to pattregs
            move.w  d0,8(a0,d1)        ditto, replicating vertically
            move.w  d0,16(a0,d1)        ditto, replicating vertically
            move.w  d0,24(a0,d1)        ditto, replicating vertically
            addq    #2,d1               next register (in 4x4 space)
            dbra    d4,next_line
            addq    #1,d2        generate next plane mask
            add     #24,d1       and step to next pattreg block of 16 words
            lsr     #1,d3        check gamut: are we done yet (no 1 bits left)?
            bne     next_plane

            bra     rts

            page

**************************************************************************
*
*  GET_P1P2 ( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  Returns lower left and upper right points
*
*     INFO1 = XMIN
*     INFO2 = XMAX
*     INFO3 = YMIN
*     INFO4 = YMAX
*
gle_aras_out_rget_p1p2 equ *
            movea.l 4(sp),gle_gcb                  a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                     stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb a6 = device gcb
            clr.l   info1(gle_gcb)
            clr.l   info3(gle_gcb)
            move.w  hard_xmax(rgl_gcb),d0
            ext.l   d0
            move.l  d0,info2(gle_gcb)
            move.w  hard_ymax(rgl_gcb),d0
            ext.l   d0
            move.l  d0,info4(gle_gcb)
            bra rts

******************************************************************************
*
* AWAIT_BLANKING ( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  loop until vertical blanking starts
*
gle_aras_out_rawait_blanking equ *
            movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                      stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device gcb

            cmpi.w  #3,devicetype(rgl_gcb)          ck for 9836C
            bne.s   blankgbox
            movea.l deviceaddress(rgl_gcb),a2       36c await_blanking
blank1      equ     *                               used to be move.b  (a2),d0
            btst    #0,(a2)                         used to be btst    #0,d0
            beq.s   blank1
            bra.s   noblank

blankgbox   cmpi.w  #5,devicetype(rgl_gcb)          ck for gatorbox
            bne.s   noblank
            movea.l cmap_address(rgl_gcb),a2        gatbox await_blanking
            adda.l  #2,a2
blank3      btst    #0,(a2)
            bne.s   blank3

noblank     bra rts

******************************************************************************
*
* SETGBOXCMAP( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  set gatorbox color map entry INFO1 to values R,G,B (INFO2, INFO3, INFO4)
*
gle_aras_out_setgboxcmap equ *
            movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                      stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device gcb

            move.l  info1(gle_gcb),d1
            move.l  info2(gle_gcb),d2
            move.l  info3(gle_gcb),d3
            move.l  info4(gle_gcb),d4

            movea.l status(a5),a1       set up to check HSYNC in secondary
            moveq   #1,d0

            movea.l cmap_address(rgl_gcb),a0
cm00        btst    #2,2(a0)            wait for cmap not busy
            bne.s   cm00

            move.w  d1,$b7(a0)          set cmap pointer to correct entry

*  now update cmap color registers by waiting for video ( = not horizontal
*  retrace), then wait for horizontal retrace, then immediately update
*  register. We wait for video first to ensure we don't catch
*  retrace in the middle or near the end. Colormap should be updated during
*  either horizontal or vertical retrace to ensure we don't get snow on
*  the screen during update. We use (a0)+ because it's the fastest to-mem
*  address mode available (the increment happens after cmap update), and we
*  have only a few microsec to update the registers.

            adda.l  #$1b1,a0            point a0 at RED register
cm10        btst    d0,(a1)             wait for video
            beq.s   cm10
cm11        btst    d0,(a1)             wait for horizontal
            bne.s   cm11
            move.w  d2,(a0)+            update red
cm12        btst    d0,(a1)
            beq.s   cm12
cm13        btst    d0,(a1)
            bne.s   cm13
            move.w  d3,(a0)+            update green
cm14        btst    d0,(a1)
            beq.s   cm14
cm15        btst    d0,(a1)
            bne.s   cm15
            move.w  d4,(a0)+            update blue
            bra     rts

******************************************************************************
*
* SET_NEREID( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  set NEREID color map entry INFO1 to values R,G,B (INFO2, INFO3, INFO4)
*
gle_aras_out_set_nereid equ *
            movea.l 4(sp),gle_gcb               a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                  stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb       a6 = device gcb

            move.l  info1(gle_gcb),d1
            move.l  info2(gle_gcb),d2
            move.l  info3(gle_gcb),d3
            move.l  info4(gle_gcb),d4

            movea.l cmap_address(rgl_gcb),a0

nereid_cm00 equ     *                              wait for cmap ready
*           NOP                                    SFB 4/18/85 removed 10/03/86 SFB
            btst    #2,2(a0)
            bne.s   nereid_cm00

            move    0,d0                           delay for nereid SFB
            move.b  d1,$b8(a0)                     set cmap index
            move    0,d0                           delay for nereid SFB
            move.b  d2,$b2(a0)                     set red
            move    0,d0                           delay for nereid SFB
            move.b  d3,$b4(a0)                     set green
            move    0,d0                           delay for nereid SFB
            move.b  d4,$b6(a0)                     set blue
            move    0,d0                           delay for nereid SFB
            move.b  d0,$f0(a0)                     trigger color map load
            move    0,d0                           delay for nereid SFB

nereid_cm01 equ     *                              wait for load complete
*           NOP                                    SFB 4/18/85 removed 10/03/86 SFB
            btst    #2,2(a0)
            bne.s   nereid_cm01

            moveq   #0,d1                          set above 4 registers to 0
            move    0,d0                           delay for nereid SFB
            move.b  d1,$b8(a0)                     set cmap index
            move    0,d0                           delay for nereid SFB
            move.b  d1,$b2(a0)                     set red
            move    0,d0                           delay for nereid SFB
            move.b  d1,$b4(a0)                     set green
            move    0,d0                           delay for nereid SFB
            move.b  d1,$b6(a0)                     set blue

            bra     rts

******************************************************************************
*
* SET_WOOD_CMAP( GCB : GRAPHICS_CONTROL_BLOCK_PTR )
*
*  set WOODCUT color map entry INFO1 to values R,G,B (INFO2, INFO3, INFO4)
*
gle_aras_out_set_wood_cmap equ *               added WOODCUT support CFB 10JUN91
            movea.l 4(sp),gle_gcb               a4 = address of pointer to gcb
            move.l  (sp)+,(sp)                  stack return address
            movem.l a5-a6,old_a5(gle_gcb)
            movea.l dev_dep_stuff(gle_gcb),rgl_gcb       a6 = device gcb

            move.l  info1(gle_gcb),d1
            move.l  info2(gle_gcb),d2
            move.l  info3(gle_gcb),d3
            move.l  info4(gle_gcb),d4

            move.l  #blueregimage,d5
            move.l  #dacimagewrite,d6
            movea.l deviceaddress(rgl_gcb),a0 need control space address

checkblue   btst    #0,2(a0,d5.l)           check for color map busy
            bne.s   checkblue               loop until bit is clear
            move.b  d1,0(a0,d6.l)           write the index to the DAC
            move.b  d2,4(a0,d6.l)           then red to the DAC
            move.b  d3,4(a0,d6.l)           then green to the DAC
            move.b  d4,3(a0,d5.l)           then blue to BEECH
            bra     rts

gle_aras_out_gle_aras_out rts
            end
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@d283 1
a283 1
	    include ASM_TYPES
d286 1
a286 1
	     page
d290 1
a290 1
	    rorg    0
d292 1
a292 1
	    rts
d295 2
a296 2
	    move    d0,sysglobals-2(a5)
	    trap    #10
d299 1
a299 1
	    bra     err_esc
d301 1
a301 1
	    page
d306 4
a309 4
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = ptr to device rec
d311 2
a312 2
	    move.l  info_ptr1(gle_gcb),plane1_addr(rgl_gcb)
	    move.l  info_ptr2(gle_gcb),plane1_offset(rgl_gcb)
d314 21
a334 21
	    moveq   #0,d0
	    moveq   #1,d1
	    move.w  yes,complement_support(gle_gcb)  complement := true
	    move.w  yes,non_dominant_support(gle_gcb)
	    move.w  yes,erase_support(gle_gcb)
	    move.w  yes,dither_support(gle_gcb)
	    move.w  yes,polygon_support(gle_gcb)
	    move.w  yes,polygon_fill_factor(gle_gcb)
	    move.w  yes,polygon_solid_fill(gle_gcb)
	    move.w  yes,background(gle_gcb)
	    move.w  #-1,cont_linestyles(gle_gcb)
	    move.w  zero,vect_linestyles(gle_gcb)
	    move.w  one,linewidths(gle_gcb)
	    move.w  #-1,char_sizes(gle_gcb)
	    move.l  zero,current_pos_x(gle_gcb)
	    move.l  zero,current_pos_y(gle_gcb)
	    move.w  no,current_drawing_mode(gle_gcb)
	    move.w  #-1,current_linestyle_pattern(gle_gcb)
	    move.w  zero,current_cursor_state(gle_gcb)
	    move.l  zero,current_cursor_x(gle_gcb)
	    move.l  zero,current_cursor_y(gle_gcb)
d343 4
a346 4
	    move.w  info1+2(gle_gcb),d2             compute jump table entry
	    asl.w   #1,d2                           for dev dep initialize
	    move.w  base_rgl(d2),d2
	    jmp     init_rgl(d2)                    jump to dev dep initialize
d350 16
a365 16
	    dc.w    init16-init_rgl
	    dc.w    init16-init_rgl
	    dc.w    init36-init_rgl
	    dc.w    init36c-init_rgl
	    dc.w    init27A-init_rgl
	    dc.w    initGatbw-init_rgl
	    dc.w    initgbox-init_rgl
	    dc.w    initbobcat-init_rgl
	    dc.w    initbobcatlores-init_rgl
	    dc.w    initcatseye-init_rgl
	    dc.w    initcatseye_hrx-init_rgl
	    dc.w    initwoodcut_vga-init_rgl                       CFB - 31MAY91
	    dc.w    initwoodcut_med-init_rgl                       CFB - 31MAY91
	    dc.w    initwoodcut_hrx-init_rgl                       CFB - 31MAY91
	    dc.w    initwoodcut_vgam-init_rgl                      CFB - 30JUL91
	    dc.w    initwoodcut_hrxm-init_rgl                      CFB - 30JUL91
d368 7
a374 7
	    move.w  info3+2(gle_gcb),monitortype(rgl_gcb)
	    move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
	    move.w  no,color_map_support(gle_gcb)
	    move.w  yes,redef_background(gle_gcb)
	    move.l  #7,pallette(gle_gcb)
	    move.l  #7,gamut(gle_gcb)
	    bra     gen_init
d377 1
a377 1
	    bra     initcom
d380 1
a380 1
	    bra     initcom
d384 4
a387 4
	    move.w  yes,redef_background(gle_gcb)
	    move.l  one,pallette(gle_gcb)
	    move.l  one,gamut(gle_gcb)       redone for bobcat B/W in GLE_RGL
	    bra     gen_init
d390 2
a391 2
	    move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
d393 3
a395 3
	    move.w  yes,color_map_support(gle_gcb)
	    move.w  yes,redef_background(gle_gcb)
	    move.l  #16777216,pallette(gle_gcb) R,G,B each have 8 bits
d398 4
a401 4
	    cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB -  9AUG91
	    ble     gen_init                                       CFB -  9AUG91
	    move.l  #256,pallette(gle_gcb)     G only has 8 bits   CFB -  9AUG91
	    bra     gen_init
d404 2
a405 2
	    move.w  #woodcut_vga_display,devicetype(rgl_gcb)       CFB - 31MAY91
	    bra.s   initwoodcutgen                                 CFB - 31MAY91
d408 2
a409 2
	    move.w  #woodcut_med_display,devicetype(rgl_gcb)       CFB - 31MAY91
	    bra.s   initwoodcutgen                                 CFB - 31MAY91
d412 2
a413 2
	    move.w  #woodcut_hrx_display,devicetype(rgl_gcb)       CFB - 31MAY91
	    bra.s   initwoodcutgen                                 CFB - 31MAY91
d416 2
a417 2
	    move.w  #woodcut_vgam_display,devicetype(rgl_gcb)      CFB - 30JUL91
	    bra.s   initwoodcutgen                                 CFB - 30JUL91
d420 2
a421 2
	    move.w  #woodcut_hrxm_display,devicetype(rgl_gcb)      CFB - 30JUL91
	    bra.s   initwoodcutgen                                 CFB - 30JUL91
d424 2
a425 2
	    move.w  #catseye_display,devicetype(rgl_gcb)
	    bra.s   initbobcatgen
d428 2
a429 2
	    move.w  #catseye_hrx_display,devicetype(rgl_gcb)
	    bra.s   initbobcatgen
d432 2
a433 2
	    move.w  #bobcat_lores_display,devicetype(rgl_gcb)
	    bra.s   initbobcatgen
d436 1
a436 1
	    move.w  #bobcat_display,devicetype(rgl_gcb)
d444 5
a448 5
	    movea.l info2(gle_gcb),a0
	    move.l  a0,deviceaddress(rgl_gcb)
	    cmpi.b  #hrm_tertiary,tert_off(a0)
	    bne.s   get_cmap_info
	    move.l  #0,info3(gle_gcb)
d451 3
a453 3
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
	    beq     initcom
	    bra     initcmapinfo
d456 5
a460 5
	    movea.l info2(gle_gcb),a0
	    move.l  a0,deviceaddress(rgl_gcb)
	    move.l  #0,info3(gle_gcb)
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
	    bra     initcmapinfo
d463 6
a468 6
	    move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
	    move.l  info3(gle_gcb),cmap_address(rgl_gcb)
	    move.w  yes,color_map_support(gle_gcb)
	    move.w  yes,redef_background(gle_gcb)
	    move.l  #4095,pallette(gle_gcb)
	    move.l  #15,gamut(gle_gcb)
d471 5
a475 5
	    move    d0,d2
	    cmpi.w  #7,devicetype(rgl_gcb)     ck for bobcatlores
	    bne.s   ckbitmap
	    move    #5,d0                      bobcatlores init block is #5
	    bra.s   gen1
d478 2
a479 2
	    cmpi.w  #6,info1+2(gle_gcb)        ck for Gator/gbox/bobcathires
	    blt.s   gen1
d481 2
a482 2
	    cmpi.w  #11,info1+2(gle_gcb)       ck for Catseye_hrx
	    beq.s   adjust_catseye_hrx
d484 2
a485 2
	    cmpi.w  #10,devicetype(rgl_gcb)    ck for WOODCUT      CFB - 24JUL91
	    bge.s   adjust_woodcut                                 CFB - 31MAY91
d487 2
a488 2
	    move    #4,d0               use initialize block 4 for Bobcat clones
	    bra.s   gen1
d491 9
a499 9
	    move    devicetype(rgl_gcb),d0                         CFB - 31MAY91
	    subq    #3,d0                     convert 10-12 to 7-9 CFB - 31MAY91
	    cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB - 30JUL91
	    ble.s   gen1                                           CFB - 30JUL91
	    subq    #3,d0                     convert 13-14 to 7-8 CFB - 30JUL91
	    cmpi.w  #7,d0                      VGA?                CFB - 11OCT91
	    beq.s   gen1                                           CFB - 11OCT91
	    addq    #1,d0                     Hrx? convert 8 to 9  CFB - 11OCT91
	    bra.s   gen1                                           CFB - 31MAY91
d502 1
a502 1
	    move    #6,d0                      hrx block index
d510 6
a515 6
	    movea.l d0,a0
	    lea     init_table(a0),a0
	    lea     plane2_offset(rgl_gcb),a1
	    move.l  (a0)+,(a1)+                and offsets to display table
	    move.l  (a0)+,(a1)+
	    moveq   #4,d1
d517 1
a517 1
	    bra     initloop
d520 6
a525 6
	    dc.l       0   plane3_offset       ( not used )
	    dc       300   n_glines
	    dc         2   gspacing
	    dc       100   bytesperline
	    dc       399   hard_xmax
	    dc       299   hard_ymax
d528 6
a533 6
	    dc.l       0   plane3_offset       ( not used )
	    dc       390   n_glines
	    dc         1   gspacing
	    dc        64   bytesperline
	    dc       511   hard_xmax
	    dc       389   hard_ymax
d536 6
a541 6
	    dc.l  $10000   plane3_offset
	    dc       390   n_glines
	    dc         1   gspacing
	    dc        64   bytesperline
	    dc       511   hard_xmax
	    dc       389   hard_ymax
d544 6
a549 6
	    dc.l       0   not used
	    dc       390   n_glines
	    dc         1   gspacing
	    dc       512   bytesperline
	    dc       511   hard_xmax
	    dc       389   hard_ymax
d552 6
a557 6
	    dc.l       0   not used
	    dc       752   n_glines
	    dc         1   gspacing
	    dc      1024   bytesperline
	    dc      1023   hard_xmax
	    dc       751   hard_ymax
d560 6
a565 6
	    dc.l       0   not used
	    dc       385   n_glines
	    dc         1   gspacing
	    dc      1024   bytesperline
	    dc       511   hard_xmax
	    dc       384   hard_ymax
d568 2
a569 2
	    dc.l       0   not used
	    dc      1000   n_glines     only 1000 because we use 50 alpha lines
d573 4
a576 4
	    dc         1   gspacing
	    dc      2048   bytesperline
	    dc      1279   hard_xmax
	    dc       999   hard_ymax
d579 6
a584 6
	    dc.l       0   not used                                CFB - 31MAY91
	    dc       464   n_glines                                CFB - 31MAY91
	    dc         1   gspacing                                CFB - 31MAY91
	    dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
	    dc       639   hard_xmax                               CFB - 31MAY91
	    dc       463   hard_ymax                               CFB - 31MAY91
d587 6
a592 6
	    dc.l       0   not used                                CFB - 31MAY91
	    dc       752   n_glines                                CFB - 31MAY91
	    dc         1   gspacing                                CFB - 31MAY91
	    dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
	    dc      1023   hard_xmax                               CFB - 31MAY91
	    dc       751   hard_ymax                               CFB - 31MAY91
d595 6
a600 6
	    dc.l       0   not used                                CFB - 31MAY91
	    dc      1000   n_glines                                CFB - 31MAY91
	    dc         1   gspacing                                CFB - 31MAY91
	    dc      2048   bytesperline        all WOODCUTS are 2K CFB - 31MAY91
	    dc      1279   hard_xmax                               CFB - 31MAY91
	    dc       999   hard_ymax                               CFB - 31MAY91
d603 9
a611 9
	    dbra    d1,initloop
	    moveq   #16,d0
	    move    d0,(a1)+                   set default fill colors
	    move    d0,(a1)+
	    move    d0,(a1)+
	    move    #$FFFF,current_linestyle_pattern(gle_gcb)
	    clr     oldpattern(rgl_gcb)
	    move    #1,repeatcount(rgl_gcb)
	    move    #1,repeatrate(rgl_gcb)
d613 1
a613 1
	    bsr     build_pen                  | create 1st vec template
d620 7
a626 7
	    cmpi.b  #2,devicetype+1(rgl_gcb)
	    bne     set_pen                    not a 98627 style image
	    cmpi    #3,monitortype(rgl_gcb)
	    blt     init_regs                  n_glines is already set up
	    beq.s   init474
	    cmpi    #6,monitortype(rgl_gcb)
	    bge     init_regs                  n_glines is already set up
d628 2
a629 2
	    move   #511,hard_ymax(rgl_gcb)
	    bra    init_regs
d631 1
a631 1
	    move   #473,hard_ymax(rgl_gcb)
d634 8
a641 8
	    cmp     #1,d0
	    blt     set_pen                    make sure 1 <= monitortype <= 6
	    cmp     #6,d0                      to prevent hardware damage
	    bgt     set_pen
	    lsl     #4,d0                      calculate offset into
	    lea     usstd(d0),a0               setup table for 6845
	    movea.l deviceaddress(rgl_gcb),a1
	    moveq   #15,d0
d643 3
a645 3
	    move.b  -(a0),$12(a1)              write a value
	    dbra    d0,setuploop
	    bra     set_pen
d648 15
a662 15
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    50     vertical total
	    dc.b     5     vertical total adjust
	    dc.b    49     vertical displayed
	    dc.b    49     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)
d665 15
a679 15
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    61     vertical total
	    dc.b     0     vertical total adjust
	    dc.b    49     vertical displayed
	    dc.b    55     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)
d682 15
a696 15
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    31     vertical total
	    dc.b     6     vertical total adjust
	    dc.b    30     vertical displayed
	    dc.b    30     vertical sync position
	    dc.b     3     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)
d699 15
a713 15
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    38     vertical total
	    dc.b     0     vertical total adjust
	    dc.b    32     vertical displayed
	    dc.b    35     vertical sync position
	    dc.b     3     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)
d716 15
a730 15
	    dc.b    32     horizontal displayed
	    dc.b    34     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    65     vertical total
	    dc.b     5     vertical total adjust
	    dc.b    64     vertical displayed
	    dc.b    64     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)
d733 16
a748 16
	    dc.b    32     horizontal displayed
	    dc.b    36     horizontal sync position
	    dc.b     3     horizontal sync width
	    dc.b    56     vertical total
	    dc.b     5     vertical total adjust
	    dc.b    49     vertical displayed
	    dc.b    49     vertical sync position
	    dc.b     0     interlace mode
	    dc.b     7     max scan line address
	    dc.b     0     cursor start  (don't care)
	    dc.b     0     cursor end    (don't care)
	    dc.b     0     start address (upper byte)
	    dc.b     0     start address (lower byte)
	    dc.b     0     cursor h      (don't care)
	    dc.b     0     cursor l      (don't care)
	    page
d754 4
a757 4
	    movea.l 4(sp),gle_gcb                   a4 = addr of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec_ptr
d760 14
a773 14
	    btst    #7,1(a0)
	    beq.s   loopstA
	    moveq   #3,d0
	    move.w  d0,rrcopy(a5)                   update current repl. rule
	    movea.l rule(a5),a0                     setup repl. rule
	    move.w  d0,(a0)
	    movea.l plane1_addr(rgl_gcb),a1         ptr to address
	    movea.l (a1),a1
	    adda.l  plane1_offset(rgl_gcb),a1       upper right display address
	    adda.l  #$0FF000,a1                     a1 points to 3rd to last line
	    move.l  dither_pattern(rgl_gcb),(a1)
	    move.l  dither_pattern+4(rgl_gcb),$400(a1)
	    move.l  dither_pattern+8(rgl_gcb),$800(a1)
	    move.l  dither_pattern+12(rgl_gcb),$C00(a1)
d776 7
a782 7
	    btst    #7,1(a0)
	    beq.s   loopstB
	    moveq   #$83,d0
	    move.w  d0,rrcopy(a5)                   update current repl. rule
	    movea.l rule(a5),a0                     set up replacement rule
	    move.w  d0,(a0)
	    moveq   #3,d0
d787 6
a792 6
	    btst    #7,1(a0)
	    beq.s   loopstC
	    neg     d2
	    move.w  d2,wwcopy(a5)                   update current window width
	    movea.l window(a5),a0                   set window width
	    move.w  d2,(a0)
d794 1
a794 1
	    move.b (a1),0(a1,d1)                    move some bytes
d796 1
a796 1
	    lsl     #1,d1                           d1=2*d1
d798 6
a803 6
	    btst    #7,1(a0)
	    beq.s   loopst3
	    cmpi    #512,d1
	    ble.s   loopst2
	    adda    #$400,a1                        bump a1 to next line
	    dbra    d0,loopst1
d805 6
a810 6
	    btst    #7,1(a0)
	    beq.s   loopst4
	    moveq   #3,d0                           Restore rep rule
	    move.w  d0,rrcopy(a5)                   update current repl. rule
	    movea.l rule(a5),a0                     set up replacement rule
	    bra     rts
d818 6
a823 6
	    movea.l  4(sp),gle_gcb                   a4 = addr of pointer to gcb
	    move.l   (sp)+,(sp)                      stack return address
	    movem.l  a5-a6,old_a5(gle_gcb)
	    movea.l  dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec_ptr
	    cmpi.b   #5,devicetype+1(rgl_gcb)   gatorbox/bobcat both use std
	    bge      std_graphics_rom           graphics ID ROM
d826 13
a838 13
	    movea.l  controladdr(a5),a0    get pointer to ROM start
	    moveq    #0,d0
	    moveq    #0,d1
	    move.b   stat(a0),d0            get status reg again
	    lsr.b    #2,d0                  get monitor type bits
	    and.b    #12,d0
	    move.b   initoffset(a0,d0.w),d1  get MSB of info addr offset
	    lsl.w    #8,d1
	    move.b   initoffset+2(a0,d0.w),d1  get LSB of info addr offset
	    movea.l  a0,a1                  make copy of ROM start addr
	    adda     d1,a1                  a1 points to init info now
	    jsr      ginitblock             call the initialization routine
	    bra      rts                    that's all for gator
d842 8
a849 8
	    moveq    #0,d0
	    move.b   2(a1),d0               get word count to initialize
	    movep    4(a1),d1               form destination offset
	    add.l    a0,d1                  d1 points to dest addr
	    lea      8(a1),a2               a2 points to first data byte
	    movea.l  d1,a3                  a3 points to destination
	    btst     #0,(a1)                added for bit_test SFB 3 Mar '88
	    bne.s    bit_test             see new Graphics ID ROM definition SFB
d851 4
a854 4
	    move.w   d1,(a3)+               move data to the destination addr
	    btst     #6,(a1)                increment data pointer
	    bne.s    ginit1                 based on control byte
	    addq     #4,a2
d856 4
a859 4
	    btst     #7,(a1)                was this last block?
	    bne.s    ginitdone              yes -- go return
	    btst     #6,(a1)                adjust data pointer
	    beq.s    ginit2                 to point to next init block
d861 1
a861 1
	    addq     #4,a2
d863 1
a863 1
	    bra      ginitblock             do the initialize
d866 3
a868 3
	    and.b    #$0f,d2                ensure bitnum #0..#15 SFB
	    tst.b    (a2)                   compare bit to 0 or to 1? SFB
	    bne      test_for_1             SFB
d870 4
a873 4
	    move.w   (a3),d3                status word to test SFB
	    btst     d2,d3                  ready? SFB
	    bne      test_for_0
	    bra      finish_block           and got to next block SFB
d875 4
a878 4
	    move.w   (a3),d3                status word to test SFB
	    btst     d2,d3                  ready? SFB
	    beq      test_for_1
	    bra      finish_block           and got to next block SFB
d882 4
a885 4
	    movea.l  controladdr(a5),a0     get pointer to ROM start
	    movep    initoffset(a0),d1      form pointer to init block 0
	    movea.l  a0,a1                  make copy of ROM start addr
	    adda     d1,a1                  a1 points to init info now
d888 3
a890 3
	    cmpi.b   #6,devicetype+1(rgl_gcb)  for bobcat save CURSON register
	    blt.s    do_ginit
	    move.b   curson(a0),rgltemp1(rgl_gcb) save value of CURSON
d892 3
a894 3
	    cmpi.b   #6,devicetype+1(rgl_gcb) for bobcat restore CURSON
	    blt.s    init_cmapstuff
	    move.b   rgltemp1(rgl_gcb),curson(a0) restore value of CURSON
d913 1
a913 1
	    bra      rts
d920 8
a927 8
	    movea.l 4(sp),gle_gcb              a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                 stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
	    move.w  devicetype(rgl_gcb),d0
	    cmp.w   #2,d0                      moonunit is only device that
	    beq.s   on_off_tst                 supports this call
	    bra rts
d930 2
a931 2
	    tst.l   info1(gle_gcb)             { info1 = 0 is goff }
	    beq.s   goff_98627
d934 2
a935 2
	    move.b  #$80,1(a0)
	    bra rts
d938 3
a940 3
	    move.b  #0,1(a0)
	    bra rts
	    page
d944 7
a950 7
	    dc.b    7             1  white
	    dc.b    4             2  red
	    dc.b    6             3  yellow
	    dc.b    2             4  green
	    dc.b    3             5  cyan
	    dc.b    1             6  blue
	    dc.b    5             7  magenta
d960 7
a966 7
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
	    move.l  info1(gle_gcb),d7               clear ? plane word
	    bne.s   gclr0
	    move.l  #-1,d7
d968 2
a969 2
	    movea.l (a0),a0
	    adda.l  plane1_offset(rgl_gcb),a0       upper right display address
d971 1
a971 1
	    beq     gclr36c
d973 4
a976 4
	    movea.l a0,a1
	    movea.l a0,a2
	    adda.l  plane2_offset(rgl_gcb),a1
	    adda.l  plane3_offset(rgl_gcb),a2
d978 5
a982 5
	    moveq   #0,d3
	    move.b  info2+3(gle_gcb),d3
	    cmpi.w  #2,devicetype(rgl_gcb)   ck for moonunit
	    bne.s   g0
	    move.b  moon_map2(d3),d3         remap for moonunit
d985 3
a987 3
	    btst    #0,d3
	    beq.s   g1
	    moveq   #-1,d0
d990 3
a992 3
	    btst    #1,d3
	    beq.s   g2
	    moveq   #-1,d1
d995 3
a997 3
	    btst    #2,d3
	    beq.s   g3
	    moveq   #-1,d2
d1000 3
a1002 3
	    cmpi.b  #2,devicetype+1(rgl_gcb)   if it's color, we have to clear
	    bne.s   gclr1a                     everything.
	    move    #512,d6
d1005 4
a1008 4
	    ror.l   #3,d6                      do them in groups of 8 longwords
	    cmpi.b  #2,devicetype+1(rgl_gcb)
	    beq.s   gclrloop
	    and.b   #$1,d7                     mask off green and red for b&w
d1011 9
a1019 9
	    beq.s   gclrloop1
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
	    move.l  d0,(a0)+
d1021 9
a1029 9
	    beq.s   gclrloop2
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
	    move.l  d1,(a1)+
d1031 9
a1039 9
	    beq.s   gclrloop3
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
	    move.l  d2,(a2)+
d1041 3
a1043 3
	    bgt     gclrloop
	    rol.l   #3,d6
	    beq     rts
d1048 2
a1049 2
	    blt.s   gclrlp1
	    move.l  d0,(a0)+
d1051 2
a1052 2
	    blt.s   gclrlp2
	    move.l  d1,(a1)+
d1054 2
a1055 2
	    blt.s   gclrlp3
	    move.l  d2,(a2)+
d1057 2
a1058 2
	    bgt     gclrlp
	    bra     rts
d1061 2
a1062 2
	    mulu    bytesperline(rgl_gcb),d0
	    adda.l  d0,a0
d1064 3
a1066 3
	    and.l   #15,d7
	    cmpi.b  #15,d7
	    beq.s   gclr36c_all
d1068 8
a1075 8
	    move.l  d7,d2
	    asl.l   #8,d2
	    add.l   d7,d2
	    asl.l   #8,d2
	    add.l   d7,d2
	    asl.l   #8,d2
	    add.l   d7,d2
	    not.l   d2
d1077 2
a1078 2
	    lsr.l   #4,d0              div by 16
	    subq.l  #1,d0
d1081 6
a1086 6
	    and.l   d2,-(a0)
	    and.l   d2,-(a0)
	    and.l   d2,-(a0)
	    and.l   d2,-(a0)
	    dbra    d0,g36c_ploop
	    bra     rts
d1090 15
a1104 15
	    divu    #192,d0                    clear 48 long words at a time
	    subq    #1,d0
	    ext.l   d0
	    moveq   #0,d1
	    move.l  d1,d2
	    move.l  d1,d3
	    move.l  d1,d4
	    move.l  d1,d5
	    move.l  d1,d6
	    move.l  d1,d7
	    movea.l d1,a1
	    movea.l a1,a2
	    movea.l a1,a3
	    movea.l a1,a5
	    movea.l a1,a6
d1106 5
a1110 5
	    movem.l d1-d7/a1-a3/a5/a6,-(a0)
	    movem.l d1-d7/a1-a3/a5/a6,-(a0)
	    movem.l d1-d7/a1-a3/a5/a6,-(a0)
	    dbra    d0,gclrloop36
	    bra     rts
d1116 7
a1122 7
	    move.l  (sp)+,(sp)                 stack return address
	    move.l  end_x(gle_gcb),d4
	    move.l  end_y(gle_gcb),d5
	    move.l  d4,current_pos_x(gle_gcb)
	    move.l  d5,current_pos_y(gle_gcb)
	    rts
	    page
d1127 6
a1132 6
	    exg     d5,d6
	    jsr     gle_asclip_clipping
	    exg     d5,d6
	    cmpi.b  #1,d0
	    ble.s   vector1
	    bra     rts
d1144 3
a1146 3
	    move.l  (sp)+,(sp)                 stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
d1148 6
a1153 6
	    move.l  current_pos_x(gle_gcb),d4
	    move.l  current_pos_y(gle_gcb),d6
	    move.l  end_x(gle_gcb),d5
	    move.l  end_y(gle_gcb),d7
	    move.l  d5,current_pos_x(gle_gcb)
	    move.l  d7,current_pos_y(gle_gcb)
d1155 17
a1171 17
	    movem.l clip_limits_xmin(gle_gcb),a0-a3
	    cmp.l   clip_xmin,d4                      x0 < clip_xmin
	    blt.s   clip_draw
	    cmp.l   clip_xmax,d4                      x0 > clip_xmax
	    bgt.s   clip_draw
	    cmp.l   clip_ymin,d6                      y0 < clip_ymin
	    blt.s   clip_draw
	    cmp.l   clip_ymax,d6                      y0 > clip_ymax
	    bgt.s   clip_draw
	    cmp.l   clip_xmin,d5                      x1 < clip_xmin
	    blt.s   clip_draw
	    cmp.l   clip_xmax,d5                      x1 > clip_xmax
	    bgt.s   clip_draw
	    cmp.l   clip_ymin,d7                      y1 < clip_ymin
	    blt.s   clip_draw
	    cmp.l   clip_ymax,d7                      y1 > clip_ymax
	    bgt.s   clip_draw
d1174 7
a1180 7
	    movea.l (a0),a0                        get address
	    adda.l  plane1_offset(rgl_gcb),a0      upper right display address
	    movem.l plane2_offset(rgl_gcb),a2/a3
	    move    gspacing(rgl_gcb),d0
	    subq    #1,d0
	    adda.w  d0,a0                        adjust for 16/26 odd addressing
	    move    current_linestyle_pattern(gle_gcb),oldpattern(rgl_gcb)
d1182 3
a1184 3
	    movea.l status(a5),a1      prepare to check line/block mover ready
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
	    bne.s   checkgbox
d1186 2
a1187 2
	    beq.s   loopstg
	    bra.s   setvec_rr
d1189 1
a1189 1
	    bne.s   checkbobcat
d1191 2
a1192 2
	    bne     waitgboxbm
	    bra.s   setvec_rr
d1194 1
a1194 1
	    blt.s   vec1                bugfix 3.1C SFB 5/23/85
d1196 1
a1196 1
	    bgt.s   vec1                                             CFB 10JUN91
d1198 2
a1199 2
	    move.w  #$300,d3                       special case for bobcat
	    bra.s   do_set_rr                      repl rule 3 in msb of word
d1203 1
a1203 1
	    move.w  d3,(a1)                        and set (pixel) repl rule
d1206 6
a1211 6
	    bne.s   vec2                           and if solid line
	    cmpi    #-1,current_linestyle_pattern(gle_gcb)
	    bne.s   vec2
	    move    pen_draw_mode(rgl_gcb),d0      and if draw mode is dominant
	    bne.s   vec2
	    bra     horiz_vec                      then draw horizontal vector
d1213 7
a1219 7
	    move    d7,d2
	    sub     d6,d2                      d2 = y2 - y1
	    bge.s   d2plus                     y2 was > y1
	    neg     d2                         make y2 > y1
	    exg     d4,d5
	    exg     d6,d7                      d6 = smaller y
	    moveq   #1,d0                      set [y1:y2 swapped] flag
d1221 6
a1226 6
	    move    current_linestyle_pattern(gle_gcb),d3
	    cmp     #-1,d3
	    beq.s   vec6                       solid line : all is well
	    move    d5,d1                      d1 = x2-x1
	    bge.s   vec3
	    neg     d1                         d1 = abs(x2-x1)
d1228 2
a1229 2
	    blt.s   vec4
	    move    d2,d1
d1243 13
a1255 13
	    move    repeatcount(rgl_gcb),t4(rgl_gcb)
	    cmp     repeatcount(rgl_gcb),d1
	    blt.s   smallvec
	    sub     repeatcount(rgl_gcb),d1
	    ext.l   d1
	    divu    repeatrate(rgl_gcb),d1
	    addq    #1,d1                      Q=Q+1
	    rol     d1,d3                      rotate the current_linestyle_pattern
	    swap    d1                         d1 = R
	    neg     d1
	    add     repeatrate(rgl_gcb),d1          d1=repeatrate-R
	    move    d1,repeatcount(rgl_gcb)
	    bra.s   vec5
d1260 25
a1284 25
	    tst     d0
	    beq.s   vec6
	    lsl.b   #1,d3                      swap the 16 bits in d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    roxr    #1,d3
	    roxl.b  #2,d3
	    ror     #1,d3
	    move    d3,current_linestyle_pattern(gle_gcb)      start with last pattern
	    move    repeatrate(rgl_gcb),d0
	    sub     repeatcount(rgl_gcb),d0
	    addq    #1,d0
	    move    d0,t4(rgl_gcb)
d1287 6
a1292 6
	    not     d6                         d6 = -y-1
	    add     n_glines(rgl_gcb),d6            d6 = (n_glines-1)-y
	    mulu    bytesperline(rgl_gcb),d6
	    adda.l  d6,a0                      a0 = addr of line with 1st pixel
	    cmpi.b  #3,devicetype+1(rgl_gcb)   if 36c/gatorgatorbox/bobcat
	    blt.s   not36c                     then do 36c stuff
d1295 7
a1301 7
	    adda    d4,a0                      add x1 to start address
	    move    cpen(rgl_gcb),d0           d0 = pen (or not pen if erase)
	    cmpi.b  #7,devicetype+1(rgl_gcb)   bobcatlores ?
	    bne     vecready
	    mulu    #257,d0                    yes, dup pen value in both bytes
	    adda    d4,a0                      and double x1 for "real" pixels
	    bra.s   vecready
d1305 11
a1315 11
	    move    d0,d6
	    subq    #1,d0
	    move    d4,d1                      d1 = starting x
	    lsr     #3,d1
	    lsl     d0,d1
	    adda    d1,a0                      a0 points to first byte to alter
	    and     #7,d4                      d4 = bit number of first pixel
	    moveq   #$80,d0                    d0 = bit pattern to rotate
	    ror.b   d4,d0                      align it for starting position
	    move    d0,d1
	    not     d1                         use d1 for the 'and' mask
d1317 3
a1319 3
	    move    current_linestyle_pattern(gle_gcb),d4
	    movea   repeatrate(rgl_gcb),a5
	    move    t4(rgl_gcb),d7
d1321 1
a1321 1
	    jsr     softvec(rgl_gcb)
d1323 2
a1324 2
	    move    oldpattern(rgl_gcb),current_linestyle_pattern(gle_gcb)
	    bra     rts
d1327 2
a1328 2
	    bge.s   hv10
	    exg     d4,d5
d1330 7
a1336 7
	    add     n_glines(rgl_gcb),d6       d6 = (n_glines-1)-y
	    mulu    bytesperline(rgl_gcb),d6
	    adda.l  d6,a0                      a0 = addr of line with 1st pixel
	    move    d4,d2                      d2=d4=x1
	    move    d5,d3                      d3=d5=x2
	    cmpi.b  #3,devicetype+1(rgl_gcb)
	    bge     hv50                       36C/gator/gatorbox/bobcat
d1338 11
a1348 11
	    lsr     #3,d2                      d2=x1 div 8
	    lsr     #3,d3                      d3=x2 div 8
	    and     #7,d4                      d4=x1 mod 8
	    and     #7,d5                      d5=x2 mod 8
	    sub     d2,d3                      d3=# of bytes to do - 1
	    addq    #1,d5
	    adda    d2,a0                      a0 points to 1st byte to modify
	    movea   gspacing(rgl_gcb),a1
	    tst     devicetype(rgl_gcb)        9816 or 9826 ?
	    bne.s   hv20
	    adda    d2,a0                      on 9826 & 9816 add it twice
d1350 9
a1358 9
	    btst    #1,devicetype+1(rgl_gcb)   is this color ?
	    beq.s   hv30                       no
	    adda.l  a0,a2                      a2 points to green plane
	    adda.l  a0,a3                      a3 points to red plane
	    move    d3,d6                      save the byte count (d1)
	    moveq   #-1,d2
	    btst    #2,pen_num+1(rgl_gcb)
	    bne.s   hv22
	    moveq   #0,d2
d1360 6
a1365 6
	    move    d6,d3                      restore the byte count
	    movea.l a2,a0                      a0 points to green plane
	    moveq   #-1,d2
	    btst    #1,pen_num+1(rgl_gcb)
	    bne.s   hv24
	    moveq   #0,d2
d1367 6
a1372 6
	    move    d6,d3                      restore byte count
	    movea.l a3,a0                      a0 points to red plane
	    moveq   #-1,d2
	    btst    #0,pen_num+1(rgl_gcb)
	    bne.s   hv30
	    moveq   #0,d2
d1374 1
a1374 1
	    bra     rts
d1377 8
a1384 8
	    bne.s   hv41                       more than one
	    move.b  (a0),d2                    g->mask.b
	    rol.b   d5,d2
	    rol     d4,d2
	    ror     d5,d2                      ror.w x2b-x1b+1,mask
	    ror.b   d4,d2
	    move.b  d2,(a0)                    mask->g
	    rts
d1387 8
a1394 8
	    rol     d4,d0
	    move.b  d2,d0
	    rol.b   d4,d0
	    ror     d4,d0
	    move.b  d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d3
	    blt.s   hv43
d1396 2
a1397 2
	    adda.l  a1,a0
	    dbra    d3,hv42
d1399 5
a1403 5
	    move.b  (a0),d2
	    rol.b   d5,d2
	    ror     d5,d2
	    move.b  d2,(a0)
	    rts
d1406 7
a1412 7
	    bne.s   hv50_a                     NO
	    asl     #1,d2                      double x1 for "real" pixel
	    asl     #1,d3                      double x2 for "real" pixel
	    addq    #1,d3                      and fill to end (SFB 7/8/85}
	    asl     #1,d4                      double x1 for "real" pixel
	    asl     #1,d5                      double x2 for "real" pixel
	    addq    #1,d5                      and fill to end (SFB 7/8/85}
d1414 20
a1433 20
	    and     #3,d4                      x1 mod 4
	    and     #3,d5                      x2 mod 4
	    lsl     #2,d4                      (x1 mod 4)*4  mask index
	    lsl     #2,d5                      (x2 mod 4)*4  mask index
	    and     #$fffc,d2                  x1 div 4
	    adda    d2,a0                      (a0) first long w that changes
	    lsr     #2,d2                      # of nibbles to x1
	    lsr     #2,d3                      # of nibbles to x2
	    sub     d2,d3                      # of nibbles to do -1
	    move    cpen(rgl_gcb),d0
	    move    d0,d1
	    lsl     #8,d0
	    move.b  d1,d0
	    move    d0,d1
	    swap    d0
	    move    d1,d0
	    move.l  d0,d1
	    move.l  hvmask1(d4),d4
	    tst     d3
	    bne.s   hv52
d1435 1
a1435 1
	    moveq   #0,d3
d1437 5
a1441 5
	    not.l   d4
	    and.l   d4,(a0)
	    or.l    d1,(a0)+
	    dbra    d3,hv53
	    bra     rts
d1443 4
a1446 4
	    move.l  d0,d1
	    tst     d3
	    beq.s   hv51
	    subq    #1,d3
d1448 2
a1449 2
	    dbra    d3,hv54
	    bra.s   hv51
d1453 3
a1455 3
	    dc.l   $00ffffff
	    dc.l   $0000ffff
	    dc.l   $000000ff
d1458 3
a1460 3
	    dc.l   $ffff0000
	    dc.l   $ffffff00
	    dc.l   $ffffffff
d1463 1
a1463 1
	    page
d1476 4
a1479 4
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep_gcb
d1481 3
a1483 3
	    move.l  info1(gle_gcb),d0               d0 = new drawing mode
	    move.w  d0,current_drawing_mode(gle_gcb)
	    bra     set_pen
d1505 4
a1508 4
	    movea.l 4(sp),gle_gcb                 a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
d1510 1
a1510 1
	    move.w  info1+2(gle_gcb),current_color_index(gle_gcb)
d1512 1
a1512 1
	    bra     set_pen
d1525 4
a1528 4
	    movea.l 4(sp),gle_gcb                      a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb     a6 = dev_dep_gcb
d1530 1
a1530 1
	    move.w  info1+2(gle_gcb),current_linestyle(gle_gcb)
d1532 6
a1537 6
	    move.w  info2+2(gle_gcb),d0
	    move.w  d0,current_pattern_length(gle_gcb)
	    muls    hard_xmax(rgl_gcb),d0
	    divs    #1600,d0
	    bgt.s   ls_1
	    moveq   #1,d0
d1540 2
a1541 2
	    move.w  info3+2(gle_gcb),current_linestyle_mode(gle_gcb)
	    move.w  info4+2(gle_gcb),current_linestyle_pattern(gle_gcb)
d1543 2
a1544 2
	    bsr     build_pen
	    bra     set_pen
d1549 7
a1555 7
	    dc.b    7             1  white
	    dc.b    1             2  red
	    dc.b    3             3  yellow
	    dc.b    2             4  green
	    dc.b    6             5  cyan
	    dc.b    4             6  blue
	    dc.b    5             7  magenta
d1569 3
a1571 3
	    move.w  #1,pen_num(rgl_gcb)
	    move    devicetype(rgl_gcb),d0
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
d1573 2
a1574 2
	    blt.s   skip_notgat
	    move    #3,d0         gator/gatorbox/bobcat -- reset d0 like 36c
d1576 3
a1578 3
	    cmpi    #-1,current_linestyle_pattern(gle_gcb)  ck linestyle
	    bne.s   fixpatternx1
	    bra.s   fixpattern1                | else create solid vec gen.
d1581 7
a1587 7
	    dc.w    template2-ztable
	    dc.w    template1-ztable
	    dc.w    template2-ztable
	    dc.w    template3-ztable
	    dc.w    template4-ztable
	    dc.w    template5-ztable
	    dc.w    template6-ztable
d1596 3
a1598 3
	    lea     ztable(a0),a0          a0 = address of template
	    lea     softvec(rgl_gcb),a1    a1 = address of ram area
	    moveq   #12,d1                 d1 = counter
d1603 8
a1610 8
	    move.l  (a0)+,(a1)+
	    move.l  (a0)+,(a1)+
	    move.l  (a0)+,(a1)+
	    move.l  (a0)+,(a1)+
	    subq    #1,d1
	    bgt     loadtmplt
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    rts
d1626 2
a1627 2
	    move.w  current_drawing_mode(gle_gcb),d0
	    move.w  current_color_index(gle_gcb),d1
d1629 3
a1631 3
	    cmpi.w  #2,devicetype(rgl_gcb)   ck for moonunit
	    bne.s   c_set1s
	    move.b  moon_map(d1),d1          remap for moonunit
d1633 3
a1635 3
	    bne.s   c_set2s
	    moveq   #1,d0                    force drawing mode to erase
	    move.l  gamut(gle_gcb),d1        set pen number to max
d1637 4
a1640 4
	    move.w  d1,pen_num(rgl_gcb)
	    move    d0,d3
	    add     d3,d3
	    move    devicetype(rgl_gcb),d0
d1646 3
a1648 3
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
	    blt.s   skip_nogat
	    move    #3,d0          gator/gatorbox/bobcat -- reset d0 like 36c
d1650 3
a1652 3
	    cmpi    #-1,current_linestyle_pattern(gle_gcb)
	    beq.s   fixpatterns
	    addq    #2,d0
d1656 1
a1656 1
	    jmp     fixc(d0)
d1658 7
a1664 7
	    jmp     fixc2
	    jmp     fixc1
	    jmp     fixc2
	    jmp     fixc3
	    jmp     fixc4
	    jmp     fixc5
	    jmp     fixc6
d1676 10
a1685 10
	    move    d1,softvec+26(rgl_gcb)
	    move    d1,softvec+56(rgl_gcb)
	    move    d1,softvec+92(rgl_gcb)
	    move    d1,softvec+122(rgl_gcb)
	    moveq   #$64,d1                    bcc instruction
	    move    #$4e71,softvec(rgl_gcb)         nop instruction
	    subq    #2,d3
	    bne.s   fixd1
	    moveq   #$65,d1
	    move    #$4600,softvec(rgl_gcb)         not d0 instruction
d1687 5
a1691 5
	    move.b  d1,softvec+70(rgl_gcb)
	    move.b  d1,softvec+100(rgl_gcb)
	    move.b  d1,softvec+136(rgl_gcb)
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts
d1694 3
a1696 3
	    and.b   d0,(a0)                    erase
	    or.b    d0,(a0)                    non-dominant (same)
	    eor.b   d0,(a0)                    compliment
d1705 10
a1714 10
	    move    d1,softvec+30(rgl_gcb)
	    move    d1,softvec+72(rgl_gcb)
	    move    d1,softvec+120(rgl_gcb)
	    move    d1,softvec+162(rgl_gcb)
	    moveq   #$64,d1                    bcc instruction
	    move    #$4e71,softvec(rgl_gcb)         nop instruction
	    subq    #2,d3
	    bne.s   fixd2
	    moveq   #$65,d1                    bcs instruction
	    move    #$4600,softvec(rgl_gcb)         not d0 instruction
d1716 5
a1720 5
	    move.b  d1,softvec+94(rgl_gcb)
	    move.b  d1,softvec+136(rgl_gcb)
	    move.b  d1,softvec+184(rgl_gcb)
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts
d1729 6
a1734 6
	    btst    #2,pen_num+1(rgl_gcb)
	    bne.s   fx3_10
	    move    cblu+8,d0
	    tst     d3
	    bne.s   fx3_10
	    move    cblu+2,d0
d1736 8
a1743 8
	    move.l  cgrn(d3),d1
	    move.l  cred(d3),d2
	    btst    #1,pen_num+1(rgl_gcb)
	    bne.s   fx3_20
	    move.l  cgrn+16,d1
	    tst     d3
	    bne.s   fx3_20
	    move.l  cgrn+4,d1
d1745 5
a1749 5
	    bne.s   fx3_30
	    move.l  cred+16,d2
	    tst     d3
	    bne.s   fx3_30
	    move.l  cred+4,d2
d1751 17
a1767 17
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+64(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+110(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+150(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts
d1770 4
a1773 4
	    and.b   d1,(a0)                    erase
	    or.b    d0,(a0)                    non-dominant
	    eor.b   d0,(a0)                    compliment
	    nop
d1776 5
a1780 5
	    and.b   d1,0(a0,a2.l)
	    or.b    d0,0(a0,a2.l)
	    eor.b   d0,0(a0,a2.l)
	    nop
	    nop
d1783 5
a1787 5
	    and.b   d1,0(a0,a3.l)
	    or.b    d0,0(a0,a3.l)
	    eor.b   d0,0(a0,a3.l)
	    nop
	    nop
d1796 6
a1801 6
	    btst    #2,pen_num+1(rgl_gcb)
	    bne.s   fx4_10
	    move    cblu+8,d0
	    tst     d3
	    bne.s   fx4_10
	    move    cblu+2,d0
d1803 8
a1810 8
	    move.l  cgrn(d3),d1
	    move.l  cred(d3),d2
	    btst    #1,pen_num+1(rgl_gcb)
	    bne.s   fx4_20
	    move.l  cgrn+16,d1
	    tst     d3
	    bne.s   fx4_20
	    move.l  cgrn+4,d1
d1812 5
a1816 5
	    bne.s   fx4_30
	    move.l  cred+16,d2
	    tst     d3
	    bne.s   fx4_30
	    move.l  cred+4,d2
d1818 17
a1834 17
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+80(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+138(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    lea     softvec+190(rgl_gcb),a0
	    move    d0,(a0)+
	    move.l  d1,(a0)+
	    move.l  d2,(a0)+
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts
d1843 6
a1848 6
	    cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
	    bne     fixc5_a
	    addq    #8,d3       move pointer down to bobcat lores opcodes
	    move.w  addq2,softvec+24(rgl_gcb)  adjust address inc/dec opcodes
	    move.w  subq2,softvec+66(rgl_gcb)
	    move.w  addq2,softvec+126(rgl_gcb)
d1850 10
a1859 10
	    move    color36c(d3),d2
	    move    d2,softvec+52(rgl_gcb)
	    move    d2,softvec+112(rgl_gcb)
	    move    color36c2(d3),d2
	    move    d2,softvec+26(rgl_gcb)
	    move    color36c3(d3),d2
	    move    d2,softvec+86(rgl_gcb)
	    cmpi    #1,pen_draw_mode(rgl_gcb)
	    bne     fx5_10
	    not.b   d0
d1861 2
a1862 2
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts
d1865 7
a1871 7
	    and.b   d0,(a0)
	    or.b    d0,(a0)
	    eor.b   d0,(a0)
	    move.w  d0,(a0)     bobcat lores opcode
	    and.w   d0,(a0)     bobcat lores opcode
	    or.w    d0,(a0)     bobcat lores opcode
	    eor.w   d0,(a0)     bobcat lores opcode
d1874 7
a1880 7
	    and.b   d0,-(a0)
	    or.b    d0,-(a0)
	    eor.b   d0,-(a0)
	    move.w  d0,-(a0)     bobcat lores opcode
	    and.w   d0,-(a0)     bobcat lores opcode
	    or.w    d0,-(a0)     bobcat lores opcode
	    eor.w   d0,-(a0)     bobcat lores opcode
d1883 7
a1889 7
	    and.b   d0,(a0)+
	    or.b    d0,(a0)+
	    eor.b   d0,(a0)+
	    move.w  d0,(a0)+     bobcat lores opcode
	    and.w   d0,(a0)+     bobcat lores opcode
	    or.w    d0,(a0)+     bobcat lores opcode
	    eor.w   d0,(a0)+     bobcat lores opcode
d1901 7
a1907 7
	    cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
	    bne     fixc6_a
	    addq    #8,d3       move pointer down to bobcat lores opcodes
	    move.w  subq2,softvec+42(rgl_gcb)  adjust address inc/dec opcodes
	    move.w  subq2,softvec+86(rgl_gcb)
	    move.w  addq2,softvec+124(rgl_gcb)  3.1C BUGFIX 5/22/85--SFB
	    move.w  addq2,softvec+168(rgl_gcb)
d1909 8
a1916 8
	    move    color36c(d3),d2
	    move    d2,softvec+28(rgl_gcb)
	    move    d2,softvec+66(rgl_gcb)
	    move    d2,softvec+110(rgl_gcb)
	    move    d2,softvec+148(rgl_gcb)
	    cmpi    #1,pen_draw_mode(rgl_gcb)       if erase then
	    bne     fx6_10
	    not.b   d0                         invert pen number
d1918 3
a1920 3
	    jsr     asm_flush_icache           {3/25/85 SFB}
	    bra     rts
	    page
d1942 5
a1946 5
	    tst     d5         tst (x2-x1)                     2
	    bgt.s   incx1                                      4
	    neg     d5         d5 = abs(x2-x1)                 6
	    cmp     d5,d2      x major or y major ?            8
	    bgt.s   case13     y major/decrement x            10
d1953 6
a1958 6
	    beq.s   loop14                                    14
	    swap    d2         d2 = [(y2-y1) :    0 ]         16
	    clr     d2                                        18
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           20
	    bvc.s   loop14                                    22
	    moveq   #-1,d2                                    24
d1960 5
a1964 5
	    subq    #1,d5                                     28
	    blt.s   endvec1                                   30
	    rol.b   #1,d0    .................................32
	    bcc.s   next14   .................................34
	    suba    d6,a0                                     36
d1966 3
a1968 3
	    bcc     loop14                                    40
	    suba    a1,a0      inc y                          42
	    bra     loop14                                    44
d1975 4
a1978 4
	    clr     d5                                        48
	    divu    d2,d5      d5=frac=(x2-x1)/(y2-y1)        50
	    bvc.s   loop13                                    52
	    moveq   #-1,d5                                    54
d1980 9
a1988 9
	    subq    #1,d2      pixel_count = pixel_count - 1  58
	    blt.s   endvec1    if pixel_count<0 ; goto endvec 60
	    suba    a1,a0      increment y                    62
	    add     d5,d3      sum = sum + frac               64
	    bcc     loop13     if sum < 1 then goto loop3     66
	    rol.b   #1,d0      ...............................68
	    bcc     loop13     ...............................70
	    suba    d6,a0                                     72
	    bra     loop13                                    74
d1991 1
a1991 1
	    bgt.s   case11                                    80
d1998 4
a2001 4
	    clr     d2                                        84
	    divu    d5,d2      d2 = frac                      86
	    bvc.s   loop12                                    88
	    moveq   #-1,d2                                    90
d2003 5
a2007 5
	    subq    #1,d5                                     94
	    blt.s   endvec1                                   96
	    ror.b   #1,d0     ................................98
	    bcc.s   next12    ...............................100
	    adda    d6,a0                                    102
d2009 3
a2011 3
	    bcc     loop12                                   106
	    suba    a1,a0                                    108
	    bra     loop12                                   110
d2018 4
a2021 4
	    clr     d5                                       114
	    divu    d2,d5                                    116
	    bvc.s   loop11                                   118
	    moveq   #-1,d5                                   120
d2023 10
a2032 10
	    subq    #1,d2                                    124
	    blt.s   endvec1                                  126
	    suba    a1,a0                                    128
	    add     d5,d3                                    130
	    bcc     loop11                                   132
	    ror.b   #1,d0                                    134
	    bcc     loop11   ................................136
	    adda    d6,a0                                    138
	    bra     loop11                                   140
	    page
d2042 5
a2046 5
	    tst     d5         tst (x2-x1)                     2
	    bgt.s   incx2                                      4
	    neg     d5         d5 = abs(x2-x1)                 6
	    cmp     d5,d2      x major or y major ?            8
	    bgt.s   case23     y major/decrement x            10
d2053 6
a2058 6
	    beq.s   loop24                                    14
	    swap    d2         d2 = [(y2-y1) :    0 ]         16
	    clr     d2                                        18
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           20
	    bvc.s   loop24                                    22
	    moveq   #-1,d2                                    24
d2060 2
a2061 2
	    bpl.s   skip24       then skip - the pen is up    28
	    or.b    d0,(a0)      else draw - the pen is down  30
d2063 5
a2067 5
	    blt.s   endvec2                                   34
	    subq    #1,d7      decrement repeatcount          36
	    bne.s   ok24                                      38
	    move    a5,d7                                     40
	    rol     #1,d4                                     42
d2069 2
a2070 2
	    bcc.s   next24     ...............................46
	    suba    d6,a0                                     48
d2072 3
a2074 3
	    bcc     loop24                                    52
	    suba    a1,a0      inc y                          54
	    bra     loop24                                    56
d2081 4
a2084 4
	    clr     d5                                        60
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    62
	    bvc.s   loop23                                    64
	    moveq   #-1,d5                                    66
d2086 2
a2087 2
	    bpl.s   skip23                                    70
	    or.b    d0,(a0)    turn on pixel (x,y)            72
d2089 5
a2093 5
	    blt.s   endvec2    if pixel_count<0 ;goto endvec  76
	    subq    #1,d7      decrement repeatcount          78
	    bne.s   ok23                                      80
	    move    a5,d7                                     82
	    rol     #1,d4                                     84
d2095 6
a2100 6
	    add     d5,d3      sum = sum + frac               88
	    bcc     loop23     if sum < 1 then goto loop3     90
	    rol.b   #1,d0      x = x - 1                      92
	    bcc     loop23     ...............................94
	    suba    d6,a0                                     96
	    bra     loop23                                    98
d2103 1
a2103 1
	    bgt.s   case21                                   104
d2110 4
a2113 4
	    clr     d2                                       108
	    divu    d5,d2      d2 = frac                     110
	    bvc.s   loop22                                   112
	    moveq   #-1,d2                                   114
d2115 2
a2116 2
	    bpl.s   skip22                                   118
	    or.b    d0,(a0)    ..............................120
d2118 5
a2122 5
	    blt.s   endvec2                                  124
	    subq    #1,d7      decrement repeatcount         126
	    bne.s   ok22                                     128
	    move    a5,d7                                    130
	    rol     #1,d4                                    132
d2124 2
a2125 2
	    bcc.s   next22     ..............................136
	    adda    d6,a0                                    138
d2127 3
a2129 3
	    bcc     loop22                                   142
	    suba    a1,a0                                    144
	    bra     loop22                                   146
d2136 4
a2139 4
	    clr     d5                                       150
	    divu    d2,d5                                    152
	    bvc.s   loop21                                   154
	    moveq   #-1,d5                                   156
d2141 2
a2142 2
	    bpl.s   skip21                                   160
	    or.b    d0,(a0)    ..............................162
d2144 5
a2148 5
	    blt.s   endvec2                                  166
	    subq    #1,d7      decrement repeatcount         168
	    bne.s   ok21                                     170
	    move    a5,d7                                    172
	    rol     #1,d4                                    174
d2150 7
a2156 7
	    add     d5,d3                                    178
	    bcc     loop21                                   180
	    ror.b   #1,d0                                    182
	    bcc     loop21     ..............................184
	    adda    d6,a0                                    186
	    bra     loop21                                   188
	    page
d2166 4
a2169 4
	    bgt.s   incx3                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case33     y major/decrement x             8
d2176 6
a2181 6
	    beq.s   loop34                                    12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   loop34                                    20
	    moveq   #-1,d2                                    22
d2183 8
a2190 8
	    or.b    d0,0(a0,a2.l) ............................26
	    or.b    d0,0(a0,a3.l) ............................30
	    subq    #1,d5                                     34
	    blt.s   endvec3                                   36
	    rol.b   #1,d1                                     38
	    rol.b   #1,d0                                     40
	    bcc.s   next34                                    42
	    suba    d6,a0                                     44
d2192 3
a2194 3
	    bcc     loop34                                    48
	    suba    a1,a0      inc y                          50
	    bra     loop34                                    52
d2201 4
a2204 4
	    clr     d5                                        56
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    58
	    bvc.s   loop33                                    60
	    moveq   #-1,d5                                    62
d2206 12
a2217 12
	    or.b    d0,0(a0,a2.l) ............................66
	    or.b    d0,0(a0,a3.l) ............................70
	    subq    #1,d2      pixel_count = pixel_count - 1  74
	    blt.s   endvec3    if pixel_count<0 ; goto endvec 76
	    suba    a1,a0      increment y                    78
	    add     d5,d3      sum = sum + frac               80
	    bcc     loop33     if sum < 1 then goto loop3     82
	    rol.b   #1,d1                                     84
	    rol.b   #1,d0      x = x - 1                      86
	    bcc     loop33                                    88
	    suba    d6,a0                                     90
	    bra     loop33                                    92
d2220 1
a2220 1
	    bgt.s   case31                                    98
d2227 4
a2230 4
	    clr     d2                                       102
	    divu    d5,d2      d2 = frac                     104
	    bvc.s   loop32                                   106
	    moveq   #-1,d2                                   108
d2232 8
a2239 8
	    or.b    d0,0(a0,a2.l) ...........................112
	    or.b    d0,0(a0,a3.l) ...........................116
	    subq    #1,d5                                    120
	    blt.s   endvec3                                  122
	    ror.b   #1,d1                                    124
	    ror.b   #1,d0                                    126
	    bcc.s   next32                                   128
	    adda    d6,a0                                    130
d2241 3
a2243 3
	    bcc     loop32                                   134
	    suba    a1,a0                                    136
	    bra     loop32                                   138
d2250 4
a2253 4
	    clr     d5                                       142
	    divu    d2,d5                                    144
	    bvc.s   loop31                                   146
	    moveq   #-1,d5                                   148
d2255 13
a2267 13
	    or.b    d0,0(a0,a2.l) ...........................152
	    or.b    d0,0(a0,a3.l) ...........................156
	    subq    #1,d2                                    160
	    blt.s   endvec3                                  162
	    suba    a1,a0                                    164
	    add     d5,d3                                    166
	    bcc     loop31                                   168
	    ror.b   #1,d1                                    170
	    ror.b   #1,d0                                    172
	    bcc     loop31                                   174
	    adda    d6,a0                                    176
	    bra     loop31                                   178
	    page
d2277 4
a2280 4
	    bgt.s   incx4                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case43     y major/decrement x             8
d2287 6
a2292 6
	    beq.s   loop44                                    12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   loop44                                    20
	    moveq   #-1,d2                                    22
d2294 4
a2297 4
	    bpl.s   skip44                                    26
	    or.b    d0,(a0)       ............................28
	    or.b    d0,0(a0,a2.l) ............................30
	    or.b    d0,0(a0,a3.l) ............................34
d2299 5
a2303 5
	    blt.s   endvec4                                   40
	    subq    #1,d7                                     42
	    bne.s   ok44                                      44
	    move    a5,d7                                     46
	    rol     #1,d4                                     48
d2305 3
a2307 3
	    rol.b   #1,d0                                     52
	    bcc.s   next44                                    54
	    suba    d6,a0                                     56
d2309 3
a2311 3
	    bcc     loop44                                    60
	    suba    a1,a0      inc y                          62
	    bra     loop44                                    64
d2318 4
a2321 4
	    clr     d5                                        68
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    70
	    bvc.s   loop43                                    72
	    moveq   #-1,d5                                    74
d2323 4
a2326 4
	    bpl.s   skip43                                    78
	    or.b    d0,(a0)    turn on pixel (x,y) ...........80
	    or.b    d0,0(a0,a2.l) ............................82
	    or.b    d0,0(a0,a3.l) ............................86
d2328 5
a2332 5
	    blt.s   endvec4    if pixel_count<0 ;goto endvec  92
	    subq    #1,d7                                     94
	    bne.s   ok43                                      96
	    move    a5,d7                                     98
	    rol     #1,d4                                    100
d2334 7
a2340 7
	    add     d5,d3      sum = sum + frac              104
	    bcc     loop43     if sum < 1 then goto loop3    106
	    rol.b   #1,d1                                    108
	    rol.b   #1,d0      x = x - 1                     110
	    bcc     loop43                                   112
	    suba    d6,a0                                    114
	    bra     loop43                                   116
d2343 1
a2343 1
	    bgt.s   case41                                   122
d2350 4
a2353 4
	    clr     d2                                       126
	    divu    d5,d2      d2 = frac                     128
	    bvc.s   loop42                                   130
	    moveq   #-1,d2                                   132
d2355 4
a2358 4
	    bpl.s   skip42                                   136
	    or.b    d0,(a0)     .............................138
	    or.b    d0,0(a0,a2.l)                            140
	    or.b    d0,0(a0,a3.l)                            144
d2360 5
a2364 5
	    blt.s   endvec4                                  150
	    subq    #1,d7                                    152
	    bne.s   ok42                                     154
	    move    a5,d7                                    156
	    rol     #1,d4                                    158
d2366 3
a2368 3
	    ror.b   #1,d0                                    162
	    bcc.s   next42                                   164
	    adda    d6,a0                                    166
d2370 3
a2372 3
	    bcc     loop42                                   170
	    suba    a1,a0                                    172
	    bra     loop42                                   174
d2379 4
a2382 4
	    clr     d5                                       178
	    divu    d2,d5                                    180
	    bvc.s   loop41                                   182
	    moveq   #-1,d5                                   184
d2384 4
a2387 4
	    bpl.s   skip41                                   188
	    or.b    d0,(a0)       ...........................190
	    or.b    d0,0(a0,a2.l) ...........................192
	    or.b    d0,0(a0,a3.l) ...........................196
d2389 5
a2393 5
	    blt.s   endvec4                                  202
	    subq    #1,d7                                    204
	    bne.s   ok41                                     206
	    move    a5,d7                                    208
	    rol     #1,d4                                    210
d2395 7
a2401 7
	    add     d5,d3                                    214
	    bcc     loop41                                   216
	    ror.b   #1,d1                                    218
	    ror.b   #1,d0                                    220
	    bcc     loop41                                   222
	    adda    d6,a0                                    224
	    bra     loop41                                   226
d2403 1
a2403 1
	    page
d2413 4
a2416 4
	    bgt.s   incx5                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case53     y major/decrement x             8
d2423 6
a2428 6
	    beq.s   before54                                  12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   before54                                  20
	    moveq   #-1,d2                                    22
d2431 2
a2432 2
	    dbra    d5,next54                                 28
	    bra.s   endvec5                                   32
d2434 3
a2436 3
	    bcc     loop54                                    36
	    suba    a1,a0      inc y                          38
	    bra     loop54                                    40
d2443 4
a2446 4
	    clr     d5                                        44
	    divu    d2,d5      d5=frac=(x2-x1)/(y2-y1)        46
	    bvc.s   loop53                                    48
	    moveq   #-1,d5                                    50
d2448 2
a2449 2
	    dbra    d2,next53  pixel_count = pixel_count - 1  54
	    bra.s   endvec5    if pixel_count<0 ; goto endvec 58
d2451 4
a2454 4
	    add     d5,d3      sum = sum + frac               62
	    bcc     loop53     if sum < 1 then goto loop3     64
	    subq    #1,a0                                     66
	    bra     loop53                                    68
d2457 1
a2457 1
	    bgt.s   case51                                    74
d2464 4
a2467 4
	    clr     d2                                        78
	    divu    d5,d2      d2 = frac                      80
	    bvc.s   loop52                                    82
	    moveq   #-1,d2                                    84
d2469 2
a2470 2
	    dbra    d5,next52                                 88
	    bra.s   endvec5                                   92
d2472 3
a2474 3
	    bcc     loop52                                    96
	    suba    a1,a0                                     98
	    bra     loop52                                   100
d2481 4
a2484 4
	    clr     d5                                       104
	    divu    d2,d5                                    106
	    bvc.s   loop51                                   108
	    moveq   #-1,d5                                   110
d2486 2
a2487 2
	    dbra    d2,next51                                114
	    bra.s   endvec5                                  118
d2489 5
a2493 5
	    add     d5,d3                                    122
	    bcc     loop51                                   124
	    addq    #1,a0                                    126
	    bra     loop51                                   128
	    page
d2503 4
a2506 4
	    bgt.s   incx6                                      2
	    neg     d5         d5 = abs(x2-x1)                 4
	    cmp     d5,d2      x major or y major ?            6
	    bgt.s   case63     y major/decrement x             8
d2513 6
a2518 6
	    beq.s   loop64                                    12
	    swap    d2         d2 = [(y2-y1) :    0 ]         14
	    clr     d2                                        16
	    divu    d5,d2      d2 = (y2-y1)/(x2-x1)           18
	    bvc.s   loop64                                    20
	    moveq   #-1,d2                                    22
d2520 2
a2521 2
	    bpl.s   skip64       then skip                    26
	    move.b  d0,(a0)      else draw ...................28
d2523 5
a2527 5
	    blt.s   endvec6                                   32
	    subq    #1,d7      decrement repeatcount          34
	    bne.s   ok64                                      36
	    move    a5,d7                                     38
	    rol     #1,d4                                     40
d2530 3
a2532 3
	    bcc     loop64                                    46
	    suba    a1,a0      inc y                          48
	    bra     loop64                                    50
d2539 4
a2542 4
	    clr     d5                                        54
	    divu    d2,d5      d5 = frac = (x2-x1)/(y2-y1)    56
	    bvc.s   loop63                                    58
	    moveq   #-1,d5                                    60
d2544 2
a2545 2
	    bpl.s   skip63                                    64
	    move.b  d0,(a0)    turn on pixel (x,y) ...........66
d2547 5
a2551 5
	    blt.s   endvec6    if pixel_count<0 ;goto endvec  70
	    subq    #1,d7      decrement repeatcount          72
	    bne.s   ok63                                      74
	    move    a5,d7                                     76
	    rol     #1,d4                                     78
d2553 4
a2556 4
	    add     d5,d3      sum = sum + frac               82
	    bcc     loop63     if sum < 1 then goto loop3     84
	    subq    #1,a0                                     86
	    bra     loop63                                    88
d2559 1
a2559 1
	    bgt.s   case61                                    94
d2566 4
a2569 4
	    clr     d2                                        98
	    divu    d5,d2      d2 = frac                     100
	    bvc.s   loop62                                   102
	    moveq   #-1,d2                                   104
d2571 2
a2572 2
	    bpl.s   skip62                                   108
	    move.b  d0,(a0)    ..............................110
d2574 5
a2578 5
	    blt.s   endvec6                                  114
	    subq    #1,d7      decrement repeatcount         116
	    bne.s   ok62                                     118
	    move    a5,d7                                    120
	    rol     #1,d4                                    122
d2581 3
a2583 3
	    bcc     loop62                                   128
	    suba    a1,a0                                    130
	    bra     loop62                                   132
d2590 4
a2593 4
	    clr     d5                                       136
	    divu    d2,d5                                    138
	    bvc.s   loop61                                   140
	    moveq   #-1,d5                                   142
d2595 2
a2596 2
	    bpl.s   skip61                                   146
	    move.b  d0,(a0)    ..............................148
d2598 5
a2602 5
	    blt.s   endvec6                                  152
	    subq    #1,d7      decrement repeatcount         154
	    bne.s   ok61                                     156
	    move    a5,d7                                    158
	    rol     #1,d4                                    160
d2604 5
a2608 5
	    add     d5,d3                                    164
	    bcc     loop61                                   166
	    addq    #1,a0                                    168
	    bra     loop61                                   170
	    page
d2612 3
a2614 3
	    btst    #0,catseye_status+1(a0)                     SFB
	    bne     waitcatready
	    rts
d2630 4
a2633 4
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device_rec ptr
d2635 3
a2637 3
	    move.l  info2(gle_gcb),d0               ck for solid fill
	    cmp     polygon_solid_fill(gle_gcb),d0  ignor call if not solid
	    bne     rts
d2639 2
a2640 2
	    move.l  info_ptr1(gle_gcb),addr1(rgl_gcb)
	    move.l  info_ptr2(gle_gcb),addr2(rgl_gcb)
d2642 3
a2644 3
	    move    clip_limits_ymin+2(gle_gcb),d0    make sure clip limits
	    cmp     clip_limits_ymax+2(gle_gcb),d0    allow something
	    bgt     rts
d2646 3
a2648 3
	    move    clip_limits_xmin+2(gle_gcb),d0
	    cmp     clip_limits_xmax+2(gle_gcb),d0
	    bgt     rts
d2650 5
a2654 5
	    move    area_draw_mode(rgl_gcb),d0
	    lsl     #3,d0
	    cmpi.b  #3,devicetype+1(rgl_gcb)            ck for 36c
	    beq.s   afc
	    blt.s   af_packed
d2656 2
a2657 2
	    cmpi.b  #5,devicetype+1(rgl_gcb)            ck for gatorbox
	    beq.s   afc
d2659 2
a2660 2
	    cmpi.b  #10,devicetype+1(rgl_gcb)       ck for WOODCUT CFB - 24JUL91
	    bge.s   afc                                            CFB - 24JUL91
d2662 1
a2662 1
	    bra.s   af_com                          Gator, don't do anything
d2666 7
a2672 7
	    bra     af2
	    lea     fill_erase,a5
	    bra     af2
	    lea     fill_ndom,a5
	    bra     af2
	    lea     fill_erase,a5
	    bra.s   af2
d2676 6
a2681 6
	    bra     af2
	    lea     f36c_erase,a5
	    bra     af2
	    lea     f36c_ndom,a5
	    bra     af2
	    lea     f36c_erase,a5
d2685 4
a2688 4
	    movea.l stable(rgl_gcb),a1         a1 = address of work area
	    movea   #32767,a3                  a3 = minimum y
	    moveq   #-1,d7                     d7 = maximum y
	    clr     n(rgl_gcb)
d2690 2
a2691 2
	    add     d0,n(rgl_gcb)                   add this n to ntotal
	    movea.l a0,a2
d2693 4
a2696 4
	    move.l  (a0)+,d3                   (d2,d3) = (xi,yi)
	    subq    #1,d0                       decrement # of points
	    bne.s   buildnorm                  last point ?
	    exg     a0,a2                      yes: wrap around to x1,y1
d2698 12
a2709 12
	    movea.l d4,a6
	    cmpa    a6,a6
	    bne     int_ovflow
	    move.l  4(a0),d5
	    movea.l d5,a6
	    cmpa    a6,a6
	    bne     int_ovflow
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  restore a6
	    cmp     d3,d5                      is y1 <= y2 ?
	    bge.s   y2big
	    exg     d3,d5
	    exg     d2,d4                      (d2,d3) = point with smaller y
d2711 17
a2727 17
	    bge.s   no_clip
	    cmp     clip_limits_ymin+2(gle_gcb),d5
	    blt.s   divok                      y is out of range: build entry
	    move    d4,d1                      d1 = x2
	    sub     d2,d1                      d1=x2-x1
	    bvs     int_ovflow
	    move    d3,d6                      d6 = y1
	    sub     clip_limits_ymin+2(gle_gcb),d6    d6 = ymin-y1
	    bvs     int_ovflow
	    neg     d6
	    muls    d6,d1                      d5=(x2-x1)(ymin-y1)
	    move    d5,d6                      d6=y2
	    sub     d3,d6                      d6=y2-y1
	    bvs     int_ovflow
	    divs    d6,d1                      d1=(x2-x1)(ymin-y1)/(y2-y1)
	    add     d1,d2                      d1=x1+(x2-x1)(ymin-y1)/(y2-y1)
	    move    clip_limits_ymin+2(gle_gcb),d3    y1=ymin
d2729 2
a2730 2
	    bge.s   buildm
	    movea   d3,a3
d2732 2
a2733 2
	    bge.s   buildn
	    move    d5,d7
d2735 7
a2741 7
	    sub     d3,d5                      d5 = y2-y1
	    bvs     int_ovflow
	    sub     d2,d4                      d4 = x2-x1
	    bvs     int_ovflow
	    bge.s   x2big
	    neg     d4                         d4=abs(x2-x1)
	    addq    #2,d1                      set "dec x" bit in flag
d2743 3
a2745 3
	    blt.s   xmajor                     otherwise use x major
	    addq    #1,d1                      set "y major" bit in flag
	    exg     d4,d5                      d4=max(dx,dy), d5=min(dx,dy)
d2747 5
a2751 5
	    beq.s   div2                       dx=dy=0
	    swap    d5                         d5.l = min(dx,dy):0
	    clr     d5
	    divu    d4,d5                      d5 = frac
	    bvc.s   divok
d2754 8
a2761 8
	    move    d2,(a1)+                   stack x1
	    move    d4,(a1)+                   stack m,# of pixels in vector
	    addq    #2,a1                      skip  x2
	    move    d5,(a1)+                   stack frac
	    move    #$8000,(a1)+               stack sum=.5000000
	    move    d1,(a1)+                   stack flag
	    tst     d0                         n=0 ?
	    bne     buildloop                  no: build next vector
d2763 3
a2765 3
	    movea.l a2,a0                      a0 points to next n
	    tst.l   (a0)                       test size of next segment
	    bgt     segmentloop                if > 0 then get next segment
d2767 4
a2770 4
	    move    a3,ybegin(rgl_gcb)
	    cmp     clip_limits_ymax+2(gle_gcb),d7
	    ble.s   saved7
	    move    clip_limits_ymax+2(gle_gcb),d7
d2777 16
a2792 16
	    move    ybegin(rgl_gcb),d1
	    cmp     clip_limits_ymax+2(gle_gcb),d1
	    bgt     rts
	    move    n_glines(rgl_gcb),d0
	    subq    #1,d0
	    sub     d1,d0
	    mulu    bytesperline(rgl_gcb),d0
	    movea.l plane1_addr(rgl_gcb),a0        ptr to addr
	    movea.l (a0),a0
	    adda.l  plane1_offset(rgl_gcb),a0      upper right display address
	    move    gspacing(rgl_gcb),d5
	    subq    #1,d5
	    adda.w  d5,a0                     adjust for 16/26 odd addressing
	    add.l   a0,d0
	    move.l  d0,left_side(rgl_gcb)
	    page
d2799 2
a2800 2
	    movea.l a0,a1
	    move    n(rgl_gcb),d5
d2804 5
a2808 5
	    cmp     ybegin(rgl_gcb),d0
	    beq.s   l10
	    adda    #12,a0                     skip rest of entry is stable
	    movea.l a0,a1
	    bra.s   nextv
d2811 8
a2818 8
	    move    (a0)+,d1                   d1 = m = # of pixels left - 1
	    addq    #2,a0                      skip x2 (it's trash right now)
	    move    (a0)+,d2                   d2 = frac
	    move    (a0)+,d3                   d3 = sum
	    move    (a0)+,d4                   d4 = flag
	    and     #3,d4                      mask xmaj/ymaj and inc/decx bits
	    add     d4,d4                      make it an offset
	    jmp     bumpxy(d4)
d2820 3
a2822 3
	    bra.s   nextvector
	    bra.s   majx_decx
	    bra.s   nextvector
d2825 6
a2830 6
	    bcs.s   mxdix                      if sum overflowed: bump y
	    addq    #1,d0                      inc x2
	    subq    #1,d1                      dec m
	    bge     majx_incx
	    subq    #1,d0                      un-do the last increment
	    bra.s   nextvector
d2833 6
a2838 6
	    bcs.s   mxdix
	    subq    #1,d0                      dec x2
	    subq    #1,d1                      dec m
	    bge     majx_decx
	    addq    #1,d0                      un-do the last decrement
	    bra.s   nextvector
d2842 7
a2848 7
	    addq    #4,a1                      skip over y1,x1 in stable
	    move    d1,(a1)+                   stack m
	    move    d0,(a1)+                   stack x2
	    addq    #2,a1                      skip over frac
	    move    d3,(a1)+                   stack new sum
	    lsr     #1,d4                      set flag active bit true (0)
	    move    d4,(a1)+                   stack flag
d2850 2
a2851 2
	    bgt     bxy_loop
	    page
d2864 10
a2873 10
	    beq.s   fill_point    if no points were active, then finish line
	    move    d5,d7         save minimum x in d7
	    movea   d6,a2
	    bsr     find_min      d5,d6 = x1,x2 of leftmost active vector
	    beq.s   fill_point
	    move    d7,d0         d0 = x to start filling at
	    move    a2,d1
	    cmp     d6,d1         d1 = x to end filling at
	    bgt.s   mvdw1
	    move    d6,d1
d2875 1
a2875 1
	    bra     mvdw_loop
d2881 1
a2881 1
	    move    n(rgl_gcb),d7      d7 = number of vectors
d2883 9
a2891 9
	    cmp     ybegin(rgl_gcb),d2 is this vector active ?
	    bne.s   next_ptlp     no
	    tst     4(a3)         did the vector expire on this y ?
	    bge.s   next_ptlp     no
	    move    2(a3),d0      d0 = x1
	    move    6(a3),d1      d1 = x2
	    cmp     d0,d1         order them: d0=min x, d1=max x
	    bge.s   fp01
	    exg     d0,d1
d2896 2
a2897 2
	    subq    #1,d7         dec n
	    bgt     fill_ptlp
d2901 2
a2902 2
	    move    ybegin(rgl_gcb),d0
	    cmp     yend(rgl_gcb),d0   done ?
d2904 9
a2912 9
	    blt     eol_proc       SFB
	    cmpi.b  #catseye_hrx_display,devicetype+1(rgl_gcb)       CFB 10JUN91
	    bgt     rts                                              CFB 10JUN91
	    cmpi.b  #catseye_display,devicetype+1(rgl_gcb)              SFB
	    blt     rts                                              CFB 12JUN91
	    movea.l deviceaddress(rgl_gcb),a0 waitcatready assumes this SFB
	    bsr     waitcatready     wait for previous move to complete SFB
	    move.w  #$0,trr_enable(a0)      and restore "not trr"       SFB
	    bra     rts                                                 SFB
d2915 1
a2915 1
	    move    n(rgl_gcb),d7
d2923 9
a2931 9
	    cmp     ybegin(rgl_gcb),d0
	    bne.s   next_eol
	    tst     d2            did y expire ?
	    blt.s   next_eol      yes, leave y hanging
	    addq    #1,d0         inc y
	    and     #3,d6         mask of inc/dec bit and x/y major bit
	    add     d6,d6
	    add     d4,d5         sum=frac+sum (sets condition codes)
	    jmp     eol_p(d6)
d2933 2
a2934 2
	    bra.s   my_ix
	    bra.s   mx_dx
d2937 1
a2937 1
	    bra.s   save_eol
d2941 1
a2941 1
	    movem   d0-d5,(a0)    put stuff back in table
d2943 8
a2950 8
	    subq    #1,d7         dec n
	    bgt     eol_loop
	    addq    #1,ybegin(rgl_gcb)
	    movea.l left_side(rgl_gcb),a0
	    suba    bytesperline(rgl_gcb),a0
	    move.l  a0,left_side(rgl_gcb)
	    bra     new_line
	    page
d2955 4
a2958 4
	    move    n(rgl_gcb),d0
	    moveq   #0,d1         d1=flag for found anything
	    move    ybegin(rgl_gcb),d2
	    move    #32767,d5     d5=xmin
d2960 10
a2969 10
	    bne.s   next_find     ignore vectors whose y does not match
	    tst     4(a0)         check m for an expired vector
	    blt.s   next_find     ignore expired vectors
	    tst     12(a0)
	    blt.s   next_find     ignore "dead" vectors
	    move    2(a0),d3      d3=x1
	    move    6(a0),d4      d4=x2
	    cmp     d3,d4         put smaller x in d3
	    bgt.s   find_1
	    exg     d3,d4
d2971 1
a2971 1
	    bgt.s   next_find     new x is not <= than xmin
d2974 4
a2977 4
	    movea.l a0,a1         remember where this vector was
	    move    d3,d5
	    move    d4,d6         (d5,d6) are the minx line
	    addq    #1,d1         set found flag
d2979 3
a2981 3
	    subq    #1,d0         dec n
	    bgt     find_loop
	    tst     d1            set condition codes to indicate whether
d2984 2
a2985 2
	    beq.s   fm_rts
	    ori     #$8000,12(a1) set "dead" flag.  this instruction also
d2989 1
a2989 1
	    page
d3031 2
a3032 2
	    bge.s   fill10
	    move    clip_limits_xmin+2(gle_gcb),d0
d3034 2
a3035 2
	    ble.s   fill20
	    move    clip_limits_xmax+2(gle_gcb),d1
d3037 1
a3037 1
	    blt     fm_rts
d3039 2
a3040 2
	    cmpi.b  #10,devicetype+1(rgl_gcb)   WOODCUT doesn't look like BOBCAT
	    bge     fill30                                         CFB - 24JUL91
d3042 2
a3043 2
	    cmpi.b  #6,devicetype+1(rgl_gcb)
	    bge     fbobcat
d3046 5
a3050 5
	    movea.l left_side(rgl_gcb),a0
	    move    d0,d3
	    move    d1,d4
	    ext.l   d0
	    ext.l   d1
d3052 2
a3053 2
	    cmpi.b  #3,devicetype+1(rgl_gcb)
	    beq     f36c
d3055 2
a3056 2
	    cmpi.b  #4,devicetype+1(rgl_gcb)   gator - use bitmover
	    beq     fgator
d3058 1
a3058 1
	    cmpi.b  #5,devicetype+1(rgl_gcb)  check gatorbox
d3060 1
a3060 1
	    beq     f36c
d3062 2
a3063 2
	    cmpi.b  #10,devicetype+1(rgl_gcb)                        CFB 10JUN91
	    bge     f36c               WOODCUT has no window mover   CFB 10JUN91
d3066 1
a3066 1
	    cmpi.b  #6,devicetype+1(rgl_gcb)   bobcat - use windowmover
d3068 1
a3068 1
	    bge     fbobcat
d3071 10
a3080 10
	    lsr     #3,d0
	    lsr     #3,d1
	    and     #7,d3
	    and     #7,d4
	    sub     d0,d1                  d0=# of bytes to do - 1
	    addq    #1,d4
	    adda    d0,a0                  a0 points to first byte to modify
	    tst     devicetype(rgl_gcb)         9816 or 9826 ?
	    bne.s   fill40
	    adda    d0,a0                  on 9826 & 9816 have to add it twice
d3082 1
a3082 1
	    beq.s   f26a36a                no
d3085 15
a3099 15
	    movea.l a0,a2                  a0/a1/a2 point to blue plane
	    adda.l  plane2_offset(rgl_gcb),a1   a1 points to green plane
	    adda.l  plane3_offset(rgl_gcb),a2   a2 points to red plane
	    move.l  a1,-(sp)               save a1 for later
	    move    d1,-(sp)               save the byte count (d1)
	    bsr.s   fill_plane             fill the blue plane
	    move    (sp)+,d1               restore the byte count
	    move    grn_intensity(rgl_gcb),d2
	    movea.l (sp)+,a0               a0 points to green plane
	    move    d1,-(sp)
	    bsr.s   fill_plane
	    move    (sp)+,d1
	    move    red_intensity(rgl_gcb),d2
	    movea.l a2,a0                  a0 points to red plane
	    bra.s   fill_plane             fill the red plane (fill_p does rts)
d3102 2
a3103 2
	    bgt.s   f26a36a10
	    move    grn_intensity(rgl_gcb),d2
d3105 3
a3107 3
	    bgt.s   fill_plane
	    move    red_intensity(rgl_gcb),d2
	    bra.s   fill_plane
d3111 16
a3126 16
	     dc.l   $88000000   1
	     dc.l   $88002200   2
	     dc.l   $8800aa00   3
	     dc.l   $aa00aa00   4
	     dc.l   $aa44aa00   5
	     dc.l   $aa44aa11   6
	     dc.l   $aa44aa55   7
	     dc.l   $aa55aa55   8
	     dc.l   $aaddaa55   9
	     dc.l   $aaddaa77  10
	     dc.l   $aaddaaff  11
	     dc.l   $aaffaaff  12
	     dc.l   $eeffaaff  13
	     dc.l   $eeffbbff  14
	     dc.l   $eeffffff  15
	     dc.l   $ffffffff  16
d3130 6
a3135 6
	    lsl     #2,d2
	    move    ybegin(rgl_gcb),d5
	    and     #3,d5                  mask off right two bits
	    add     d5,d2
	    move.b  dither_table(d2),d2
	    jmp     (a5)
d3138 9
a3146 9
	    bne.s   fd10                   more than one
	    rol     d4,d2                  rol.w x2b+1,mask
	    move.b  (a0),d2                g->mask.b
	    rol.b   d4,d2
	    rol     d3,d2
	    ror     d4,d2                  ror.w x2b-x1b+1,mask
	    ror.b   d3,d2
	    move.b  d2,(a0)                mask->g
	    rts
d3149 9
a3157 9
	    move.b  (a0),d0
	    rol     d3,d0
	    move.b  d2,d0
	    rol.b   d3,d0
	    ror     d3,d0
	    move.b  d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d1
	    blt.s   fd30
d3159 2
a3160 2
	    adda.l  a1,a0
	    dbra    d1,fd20
d3162 5
a3166 5
	    move.b  (a0),d2
	    rol.b   d4,d2
	    ror     d4,d2
	    move.b  d2,(a0)
	    rts
d3170 9
a3178 9
	    bne.s   fn10                   more than one
	    rol     d4,d2                  rol.w x2b+1,mask
	    move.b  (a0),d2                g->mask.b
	    rol.b   d4,d2
	    rol     d3,d2
	    ror     d4,d2                  ror.w x2b-x1b+1,mask
	    ror.b   d3,d2
	    or.b    d2,(a0)                mask->g
	    rts
d3181 9
a3189 9
	    move.b  (a0),d0
	    rol     d3,d0
	    move.b  d2,d0
	    rol.b   d3,d0
	    ror     d3,d0
	    or.b    d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d1
	    blt.s   fn30
d3191 2
a3192 2
	    adda.l  a1,a0
	    dbra    d1,fn20
d3194 5
a3198 5
	    move.b  (a0),d2
	    rol.b   d4,d2
	    ror     d4,d2
	    or.b    d2,(a0)
	    rts
d3202 10
a3211 10
	    tst     d1                     how many bytes are effected ?
	    bne.s   fe10                   more than one
	    rol     d4,d2                  rol.w x2b+1,mask
	    move.b  (a0),d2                g->mask.b
	    rol.b   d4,d2
	    rol     d3,d2
	    ror     d4,d2                  ror.w x2b-x1b+1,mask
	    ror.b   d3,d2
	    and.b   d2,(a0)                mask->g
	    rts
d3214 9
a3222 9
	    move.b  (a0),d0
	    rol     d3,d0
	    move.b  d2,d0
	    rol.b   d3,d0
	    ror     d3,d0
	    and.b   d0,(a0)
	    adda.l  a1,a0
	    subq    #2,d1
	    blt.s   fe30
d3224 2
a3225 2
	    adda.l  a1,a0
	    dbra    d1,fe20
d3227 5
a3231 5
	    move.b  (a0),d2
	    rol.b   d4,d2
	    ror     d4,d2
	    and.b   d2,(a0)
	    rts
d3235 16
a3250 16
	    and     #3,d1             x2 mod 4
	    lsl     #2,d0            (x1 mod 4)*4   # of bytes to jump in mask
	    lsl     #2,d1            (x2 mod 4)*4   # of bytes to jump in mask
	    and     #$fffc,d3         x1 div 4
	    adda    d3,a0             a0 points to first nibble that changes
	    lsr     #2,d3             # of nibbles to x1
	    lsr     #2,d4             # of nibbles to x2
	    sub     d3,d4             # of nibbles to do -1
	    move    d4,d3
	    move    ybegin(rgl_gcb),d5
	    and.l   #3,d5
	    lsl     #2,d5
	    move.l  dither_pattern(rgl_gcb,d5),d2
	    move.l  d2,d5
	    move.l  mask1(d0),d4
	    jmp     (a5)
d3253 3
a3255 3
	    dc.l   $00ffffff
	    dc.l   $0000ffff
	    dc.l   $000000ff
d3258 3
a3260 3
	    dc.l   $ffff0000
	    dc.l   $ffffff00
	    dc.l   $ffffffff
d3264 1
a3264 1
	    bne.s   fcd10
d3266 1
a3266 1
	    moveq   #0,d3
d3268 5
a3272 5
	    not.l   d4
	    and.l   d4,(a0)
	    or.l    d5,(a0)+
	    dbra    d3,fcd20
	    rts
d3274 4
a3277 4
	    move.l  d2,d5
	    tst     d3
	    beq.s   fcd05
	    subq    #1,d3
d3279 2
a3280 2
	    dbra    d3,fcd30
	    bra.s   fcd05
d3283 1
a3283 1
	    bne.s   fcn10
d3285 1
a3285 1
	    moveq   #0,d3
d3287 3
a3289 3
	    or.l    d4,(a0)+
	    dbra    d3,fcn20
	    rts
d3291 3
a3293 3
	    tst     d3
	    beq.s   fcn05
	    subq    #1,d3
d3295 2
a3296 2
	    dbra    d3,fcn30
	    bra.s   fcn05
d3299 2
a3300 2
	    tst     d3
	    bne.s   fce10
d3302 1
a3302 1
	    moveq   #0,d3
d3304 4
a3307 4
	    not.l   d4
	    and.l   d4,(a0)+
	    dbra    d3,fce20
	    rts
d3309 3
a3311 3
	    tst     d3
	    beq.s   fce05
	    subq    #1,d3
d3313 2
a3314 2
	    dbra    d3,fce30
	    bra.s   fce05
d3331 1
a3331 1
	    page
d3335 10
a3344 10
	    movea.l (a2),a2
	    adda.l  plane1_offset(rgl_gcb),a2       upper right display address
	    adda.l  #$0ff000,a2
	    move    ybegin(rgl_gcb),d5
	    and     #3,d5                           y mod 4
	    lsl     #5,d5
	    lsl     #5,d5                           1024*(y mod 4)
	    adda    d5,a2                           a2 points to dither pat.
	    sub     d4,d3                           -(number of pixels)-1
	    subq    #1,d3                           -(number of pixels)
d3346 12
a3357 12
	    movea.l status(a1),a1
	    btst    #7,1(a1)
	    beq.s   fgat10
	    movea.l old_a5(gle_gcb),a1
	    move.w  d3,wwcopy(a1)                   update current window width
	    movea.l window(a1),a1                   set window width
	    move.w  d3,(a1)
	    move.w  #$83,d3
	    movea.l old_a5(gle_gcb),a1
	    move.w  d3,rrcopy(a1)
	    movea.l rule(a1),a1
	    move.w  d3,(a1)
d3359 1
a3359 1
	    move.b  0(a2,d0),0(a0,d0)               move line
d3362 8
a3369 8
	    movea.l status(a1),a1
	    btst    #7,1(a1)
	    beq.s   fgat11
	    move.w  #$3,d3
	    movea.l old_a5(gle_gcb),a1
	    move.w  d3,rrcopy(a1)
	    movea.l rule(a1),a1
	    move.w  d3,(a1)
d3371 1
a3371 1
	    rts
d3374 2
a3375 2
	    movea.l old_a5(gle_gcb),a1          access to globals
	    movea.l status(a1),a1               windowmover status reg
d3383 5
a3387 5
	    cmpi.b  #bobcat_lores_display,devicetype+1(rgl_gcb)
	    bne.s   waitbobmover
	    add.w   d0,d0                       double startx for "real" pixels
	    add.w   d1,d1                       double endx for "real" pixels
	    addq    #1,d1 {3.1E BUG SFB 6/14/85}and go to right edge of pixel
d3390 2
a3391 2
	    move.w  (a1),d5
	    lsr     #8,d5                       status in even byte
d3394 5
a3398 5
	    and.w   gamut+2(gle_gcb),d5         check only loaded topcats
	    beq.s   bobmover_done
	    move.l  #1,-(sp)                    not ready, so wait before
	    jsr     delay_timer                 testing mover status again
	    bra.s   waitbobmover
d3401 21
a3421 21
	    movea.l deviceaddress(rgl_gcb),a1   base for graphics control
	    move.w  d0,sox(a1)                  source x
	    move.w  d0,dox(a1)                  destination x
	    move.w  ybegin(rgl_gcb),d5
	    move.w  hard_ymax(rgl_gcb),d2       prepare to reverse sign of y
	    sub.w   d5,d2                       convert ybegin to pixelline
	    move.w  d2,doy(a1)                  destination y
	    and.w   #3,d5                       dest y mod 4
	    movep.w $9(a1),d2                   height of visible buffer (ROM)
	    sub.w   #4,d2                       move up 4 lines from bottom
	    add.w   d2,d5                       access one of last 4 lines
	    move.w  d5,soy(a1)                  source y (within fill pattern)
	    move.w  #1,bobh(a1)                 height (1 pixel)
	    sub.w   d0,d1                       width-1 (real pixels)
	    addq    #1,d1                       width (real pixels)
	    move.w  d1,bobw(a1)                 width
	    move.l  gamut(gle_gcb),d5           move all planes
	    lsl     #8,d5
	    cmpi.b  #catseye_display,devicetype+1(rgl_gcb)      SFB
	    bge.s   fcatseye                                    SFB
	    move.w  #3,bobwr(a1)                windowmove replacement rule
d3423 2
a3424 2
	    move.w  d5,bobwm(a1)
	    rts                                 DONE-don't wait for it to
d3428 4
a3431 4
	    move.w  #$100,trr_enable(a1)      select Three Operand Repl Rule SFB
	    move.w  #$f000,trr(a1)            choose "Pattern Reg" rule      SFB
	    move.w  d5,fben1(a1)              enable all loaded planes       SFB
	    bra     move_scanline                                            SFB
d3433 1
a3433 1
	    page
d3443 4
a3446 4
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep_gcb
d3448 2
a3449 2
	    cmpi.w  #1,current_cursor_state(gle_gcb)
	    bne.s   curs1
d3451 3
a3453 3
	    move.w  current_cursor_x+2(gle_gcb),cursor_x(rgl_gcb) remove current cusor
	    move.w  current_cursor_y+2(gle_gcb),cursor_y(rgl_gcb)
	    bsr.s   cursor_p
d3456 2
a3457 2
	    cmpi.l  #1,info3(gle_gcb)
	    bne.s   curs2
d3459 3
a3461 3
	    move.w  info1+2(gle_gcb),cursor_x(rgl_gcb)    draw new cursor
	    move.w  info2+2(gle_gcb),cursor_y(rgl_gcb)
	    bsr.s   cursor_p
d3464 3
a3466 3
	    move.l  info1(gle_gcb),current_cursor_x(gle_gcb)
	    move.l  info2(gle_gcb),current_cursor_y(gle_gcb)
	    move.w  info3+2(gle_gcb),current_cursor_state(gle_gcb)
d3468 1
a3468 1
	    bra     rts
d3477 7
a3483 7
	    movea.l plane2_offset(rgl_gcb),a2        green plane
	    movea.l plane3_offset(rgl_gcb),a3        red plane
	    movea.l plane1_addr(rgl_gcb),a1          blue plane
	    movea.l (a1),a1
	    adda.l  plane1_offset(rgl_gcb),a1        upper right display address
	    move    devicetype(rgl_gcb),d6
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)  gator/box/bobcat
d3485 2
a3486 2
	    blt.s   skp_notgat
	    move    #3,d6
d3488 2
a3489 2
	    bne.s   cp1
	    adda.l  #1,a1                            9826/16 inc
d3491 8
a3498 8
	    move    hard_ymax(rgl_gcb),d3
	    muls    d5,d3
	    adda.l  d3,a1                       address of lower left
	    move    gspacing(rgl_gcb),d7
	    ext.l   d5
	    ext.l   d7
	    clr.l   d3
	    clr.l   d4
d3501 9
a3509 9
	    move    cursor_x(rgl_gcb),d0
	    cmpi    #4,d0                   is center <4 from left edge?
	    blt     clip_left
	    move    hard_xmax(rgl_gcb),d1
	    subq    #4,d1
	    cmp     d1,d0                   is center >4 from right edge?
	    bgt     clip_right
	    subq    #4,d0                   if got here, then fix d0 & d3
	    move.b  #8,d3
d3511 6
a3516 6
	    cmpi    #4,d1                   is center <4 from bottom edge?
	    blt     clip_bottom
	    move    hard_ymax(rgl_gcb),d2
	    subq    #4,d2
	    cmp     d2,d1
	    bgt     clip_top
d3518 3
a3520 3
	    move.b  #8,d4                   d3 was set to appropriate value
	    move    d1,d2                   above for vertical calculation
	    addq    #4,d2                   +4 above curs_y
d3539 5
a3543 5
	    cmp     hard_ymax(rgl_gcb),d1
	    bgt     draw_vert               If cursor_y > max y, skip to vert
	    tst     d1
	    blt     draw_vert               If cursor_y < 0, skip to vert
	    beq.s   dh20
d3545 1
a3545 1
	    suba.l  d1,a1                   gives y address
d3548 5
a3552 5
	    beq     dh50
	    btst    #0,d6
	    beq     dh40
	    cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
	    beq     dh37        SFB 6/20/85
d3554 2
a3555 2
	    dbra    d3,dh35
	    bra.s   draw_vert
d3557 2
a3558 2
	    dbra    d3,dh37     SFB 6/20/85
	    bra.s   draw_vert   SFB 6/20/85
d3560 1
a3560 1
	    bchg    d0,0(a1,a3.l)
d3563 1
a3563 1
	    bra.s   draw_vert
d3565 4
a3568 4
	    cmpi.b  #0,d0                   are we at end of byte?
	    bge.s   dh30                    goto dh30 if not
	    adda.l  d7,a1                   increment to next byte
	    moveq   #7,d0                   start changing bit 7 of next byte
d3570 1
a3570 1
	    beq     dh90
d3572 1
a3572 1
	    bchg    d0,0(a1,a3.l)
d3574 2
a3575 2
	    subq.b  #1,d0
	    dbra    d3,dh70
d3579 6
a3584 6
	    move    cursor_x(rgl_gcb),d0           vert. line draw at x=cursor_x
	    blt.s   dv70                   if x < 0, skip vert line
	    cmp     hard_xmax(rgl_gcb),d0
	    bgt.s   dv70                   if x > max x, skip vert line
	    tst     d2
	    beq.s   dv20
d3586 1
a3586 1
	    suba.l  d2,a5
d3588 1
a3588 1
	    bsr     set_x                   d0=bit
d3590 5
a3594 5
	    beq     dv50
	    btst    #0,d6
	    beq     dv40
	    cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
	    beq     dv37        SFB 6/20/85
d3596 3
a3598 3
	    adda.l  d5,a1
	    dbra    d4,dv35
	    rts
d3600 3
a3602 3
	    adda.l  d5,a1       SFB 6/20/85
	    dbra    d4,dv37     SFB 6/20/85
	    rts
d3604 1
a3604 1
	    bchg    d0,0(a1,a3.l)
d3607 1
a3607 1
	    dbra    d4,dv30
d3612 7
a3618 7
	    move    d0,d1
	    cmpi.b  #3,devicetype+1(rgl_gcb)
	    bge.s   sx10
	    lsr     #3,d1
	    tst     devicetype(rgl_gcb)
	    bne.s   sx10
	    lsl     #1,d1
d3620 3
a3622 3
	    cmpi.b  #7,devicetype+1(rgl_gcb)  SFB 6/20/85
	    bne     sx20
	    adda    d1,a1       "real" pixels   SFB 6/20/85
d3624 3
a3626 3
	    neg     d0
	    addq    #7,d0
	    rts
d3631 4
a3634 4
	    move    d0,d3
	    addq    #4,d3                   draw cursor_x + 5 dots
	    bge.s   cl10                    draw no less than 0 dots
	    moveq   #0,d3
d3636 1
a3636 1
	    bra     c20
d3642 8
a3649 8
	    addq    #4,d1                   d1 = hard_xmax
	    move    d1,d3                   d3 = hard_xmax
	    subq    #4,d0                   d0 = cursor_x - 4 (start of line)
	    sub     d0,d3                   d3 = # of dots (xmax-start of line)
	    bge     c20                     if start of line > x max
	    move    d1,d0                           start of line = xmax
	    moveq   #0,d3                           # of dots = 0
	    bra     c20
d3656 4
a3659 4
	    move    d1,d2
	    addq    #4,d2                   y for vertical line
	    bge.s   cb20                    if y < 0 then
	    moveq   #0,d2                      y = 0
d3661 1
a3661 1
	    bra     draw_horiz
d3668 4
a3671 4
	    sub     d1,d2                   d2 - curs_y
	    addi    #8,d2                   number of bits to draw
	    bge.s   ct10                    if # of bits < 0 then
	    moveq   #0,d2                      # of bits = 0
d3673 2
a3674 2
	    move    hard_ymax(rgl_gcb),d2        new y
	    bra     draw_horiz
d3765 6
a3770 6
	    move.l  info1(gle_gcb),d5       test for dump flag bit 0 = 1 or
	    beq.s   gr26a20            dump flag = 0
	    btst    #0,d5
	    bne.s   gr26a20
	    moveq   #0,d1
	    bra.s   gr26a20c
d3774 1
a3774 1
	    bra     rts
d3777 1
a3777 1
	    addq    #2,a1
d3779 1
a3779 1
	    bra     rts
d3791 4
a3794 4
	    movea.l 4(sp),gle_gcb                    a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb   a6 = dev dep gcb
d3796 1
a3796 1
	    movea.l info_ptr1(gle_gcb),a0            a0 = address of string
d3798 8
a3805 8
	    movea.l plane1_addr(rgl_gcb),a1
	    movea.l (a1),a1
	    adda.l  plane1_offset(rgl_gcb),a1       upper right address
	    move.l  info2(gle_gcb),d0               d0 = row to be dumped
	    mulu    bytesperline(rgl_gcb),d0        d0 = row * bytes/line
	    adda.l  d0,a1                           a1 = address of line dumped
	    move    devicetype(rgl_gcb),d1
	    cmpi.b  #gator_display,devicetype+1(rgl_gcb)
d3807 2
a3808 2
	    blt.s   skp_notgat2         SFB NOV 84
	    move    #3,d1               gator/gatorbox/bobcat -- set d1 to 36c
d3810 1
a3810 1
	    jmp     grtable(d1)
d3812 3
a3814 3
	    bra.s   gr36a
	    bra.s   gr27a
	    bra.s   gr36c
d3817 6
a3822 6
	    move.l  info1(gle_gcb),d5       test for dump flag bit 0 = 1 or
	    beq.s   gr36a20                 dump flag = 0
	    btst    #0,d5
	    bne.s   gr36a20
	    moveq   #0,d1
	    bra.s   gr36a20c
d3826 1
a3826 1
	    bra     rts
d3830 1
a3830 1
	    bra     rts
d3833 3
a3835 3
	    moveq   #16,d0                  64 bytes/line; 4 dumped at a time
	    move.l  info1(gle_gcb),d5       get mask
	    bra.s   gr27a20
d3837 4
a3840 4
	    move.l  (a1)+,d1
	    btst    #0,d5
	    beq.s   gr1
	    move.l  d1,d3
d3842 3
a3844 3
	    btst    #1,d5
	    beq.s   gr2
	    or.l    d1,d3
d3846 3
a3848 3
	    btst    #2,d5
	    beq.s   gr3
	    or.l    d1,d3
d3851 1
a3851 1
	    bra     rts
d3855 1
a3855 1
	    moveq   #0,d2
d3857 4
a3860 4
	    and.b   info1+3(gle_gcb),d3
	    cmpi.b  #0,d3
	    beq.s   gr36c30
	    bset    d1,d2
d3862 3
a3864 3
	    move.b  d2,(a0)+
	    dbra    d0,gr36c10
	    bra     rts
d4030 4
a4033 4
	    movea.l a1,a3
	    adda.l  plane2_offset(rgl_gcb),a2
	    adda.l  plane3_offset(rgl_gcb),a3
	    rts
d4071 2
a4072 2
	    movea.l 4(sp),gle_gcb                   a4 = gcb
	    move.l  (sp)+,(sp)
d4079 2
a4080 2
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = dev_dep gcb
d4082 2
a4083 2
	    tst.l   info1(gle_gcb)                  ck mode
	    beq.s   fill_index2
d4085 2
a4086 2
	    move.l  info2(gle_gcb),d0               get color index
	    move.w  d0,current_polygon_color(gle_gcb)
d4088 1
a4088 1
	    moveq   #0,d1
d4090 4
a4093 4
	    addq.l  #1,d1
	    cmp     #15,d1
	    ble.s   fill_index1
	    bra     rts
d4097 3
a4099 3
	    move.w  info2+2(gle_gcb),d0                   red
	    move.w  info3+2(gle_gcb),d1                   green
	    move.w  info4+2(gle_gcb),d2                   blue
d4101 3
a4103 3
	    move.w  d0,current_polygon_red(gle_gcb)
	    move.w  d1,current_polygon_green(gle_gcb)
	    move.w  d2,current_polygon_blue(gle_gcb)
d4106 3
a4108 3
	    cmpi.w #3,devicetype(rgl_gcb)
	    beq.s   setup_c_dither
	    cmpi.w #gator_display,devicetype(rgl_gcb)  //// do same for ////
d4110 1
a4110 1
	    bge.s   setup_c_dither                    also for gatorbox/bobcat
d4112 3
a4114 3
	    add.w   #32,d0
	    add.w   #32,d1
	    add.w   #32,d2
d4116 3
a4118 3
	    lsr.w   #6,d0
	    lsr.w   #6,d1
	    lsr.w   #6,d2
d4120 3
a4122 3
	    move.w  d0,red_intensity(rgl_gcb)
	    move.w  d1,grn_intensity(rgl_gcb)
	    move.w  d2,blu_intensity(rgl_gcb)
d4124 1
a4124 1
	    bra rts
d4130 3
a4132 3
	    move.w  d0,red_intensity(rgl_gcb)
	    move.w  d1,grn_intensity(rgl_gcb)
	    move.w  d2,blu_intensity(rgl_gcb)
d4135 11
a4145 11
	    lea     system_cmap(rgl_gcb),a0
	    suba    #768,a7     {SFB 4/12/85}  allocate 768 bytes off stack
	    lea     512(a7),a1                 use 256 bytes for count array
	    lea     0(a7),a5                   and 512 for boolean in/out
	    movem   red(a6),d1-d3
	    lsl     #4,d1                      d1 = 16*red
	    lsl     #4,d2                      d2 = 16*grn
	    lsl     #4,d3                      d3 = 16*blu
	    movea.l a0,a2                      a2 = temp address of syscmap
	    move.l  gamut(gle_gcb),d0          d0 = loop counter
	    moveq   #0,d4                      d4 = zero out upper byte
d4147 10
a4156 10
	    move.w  (a2),d4                    d4 = syscmap.r
	    cmp     d4,d1                      if syscmap.r>16*red
	    blt.s   si20                       then outside
	    move.w  2(a2),d4                   d4 = syscmap.g
	    cmp     d4,d2                      if syscmap.g>16*grn
	    blt.s   si20                       then outside
	    move.w  4(a2),d4                   d4 = syscmap.b
	    cmp     d4,d3                      if syscmap.b>16*blu
	    blt.s   si20                       then outside
	    move.b  #1,0(a5,d0)                inside so set boolean
d4158 7
a4164 7
	    dbra    d0,si10                    loop
	    clr.l   rtarg(a6)                  clear rtarg and ract
	    clr.l   gtarg(a6)                  clear gtarg and gact
	    clr.l   btarg(a6)                  clear btarg and bact
	    movea.l a1,a3                      a3 = count array pointer
	    move.l  gamut(gle_gcb),d0          loop counter
	    lsr     #2,d0                      divide by 4 for long words
d4166 3
a4168 3
	    dbra    d0,si30                    loop
	    moveq   #0,d4                      zero out upper byte of d4
	    moveq   #15,d0                     pixel loop counter
d4170 8
a4177 8
	    add     d5,rtarg(a6)               rtarg=rtarg+red
	    add     d6,gtarg(a6)               gtarg=gtarg+grn
	    add     d7,btarg(a6)               btaeg=btarg+blu
	    move.l  #$7fffffff,serrin(a6)      smallest_err_in=maxint
	    move.l  serrin(a6),serrout(a6)     smallest_err_out=maxint
	    movea.l a0,a2                      syscmap array index
	    moveq   #0,d7                      in flag
	    move.l  gamut(gle_gcb),d1          inner loop counter
d4179 3
a4181 3
	    beq.s   si55                       then got to look for one
	    tst.b   0(a5,d1)                   if this vector is out
	    beq     si100                      then don't do this stuff
d4183 4
a4186 4
	    sub     ract(a6),d2
	    move.w  (a2),d4                    get syscmap.r
	    sub     d4,d2                      d2=rtarg-ract-syscmap.r
	    muls    d2,d2
d4188 5
a4192 5
	    move    gtarg(a6),d2
	    sub     gact(a6),d2
	    move.w  2(a2),d4                   get syscmap.g
	    sub     d4,d2                      d2=gtarg-gact-syscmap.g
	    muls    d2,d2
d4194 5
a4198 5
	    move    btarg(a6),d2
	    sub     bact(a6),d2
	    move.w  4(a2),d4                   get syscmap.b
	    sub     d4,d2                      d2=btarg-bact-syscmap.b
	    muls    d2,d2
d4200 8
a4207 8
	    tst.b   0(a5,d1)                   if vector not inside
	    beq.s   si90                       then outside
	    cmp.l   serrin(a6),d3              if smallest_err_in<=error
	    bge.s   si100                      then ignore
	    move.l  d3,serrin(a6)              smallest_err_in=error
	    move    d1,d5                      closest_color_in=i
	    moveq   #1,d7                      in flag
	    bra.s   si100
d4209 3
a4211 3
	    bge.s   si100                      then ignore
	    move.l  d1,serrout(a6)             smallest_err_out=error
	    move    d1,d6                      closest_color_out=i
d4213 4
a4216 4
	    dbra    d1,si50                    loop (inner)
	    tst     d7                         if no vectors were in
	    beq.s   si110                      then do out stuff
	    move    d5,d6                      closest_color=closest_color_in
d4218 2
a4219 2
	    sub     d6,d5                      real index= entries-i
	    movea   d5,a3                      a3=closest_color
d4227 4
a4230 4
	    movea   d5,a2                      a2=closest_color
	    add     d5,d5                      d5=2*closest_color
	    adda    d5,a2                      a2=3*closest_color
	    adda    a2,a2                      a2=6*closest_color
d4232 19
a4250 19
	    adda.l  a0,a2                      pointer to syscmap[closest_c]
	    adda.l  a1,a3                      pointer to count[closest_c]
	    moveq   #0,d5                      zero upper byte
	    moveq   #0,d6                      zero upper byte
	    moveq   #0,d7                      zero upper byte
	    move.w  (a2),d5                    get syscmap[cc].r
	    move.w  2(a2),d6                   get syscmap[cc].g
	    move.w  4(a2),d7                   get syscmap[cc].b
	    add     d5,ract(a6)                ract=ract+syscmap[cc].r
	    add     d6,gact(a6)                gact=gact+syscmap[cc].g
	    add     d7,bact(a6)                bact=bact+syscmap[cc].b
	    addq.b  #1,(a3)                    increment count[cc]
	    dbra    d0,si40                    loop (outer)
	    movea.l a5,a2                      a2 points to scratch array
	    move.l  gamut(gle_gcb),d0          d0= i:loop counter
	    move    d0,d3                      save max pen for later
	    moveq   #0,d1                      num of entries counter
	    moveq   #0,d5                      zero upper byte
	    moveq   #0,d6                      zero upper byte
d4252 18
a4269 18
	    beq     si130                      if no count then goto next
	    moveq   #0,d5                      zero upper byte
	    move.b  d0,(a2)+                   store entry in scratch array
	    move.b  d2,(a2)+                   store count in scratch array
	    move    d0,d4                      i
	    add     d4,d4                      2*(i)
	    add     d4,d4                      4*(i)
	    move.w  2(a0,d4),d5                syscmap[i].grn
	    add     d5,d5                      2*grn
	    add     d5,d5                      4*grn
	    move.w  0(a0,d4),d6                syscmap[i].red
	    add     d6,d5                      4*grn+red
	    add     d5,d5                      8*grn+2*red
	    add     d6,d5                      8*grn+3*red
	    move.w  4(a0,d4),d6                syscmap[i].blu
	    add     d6,d5                      8*grn+3*red+blu
	    move    d5,(a2)+                   store brightness in scratch arry
	    addq    #1,d1                      num of entries counter + 1
d4271 5
a4275 5
	    subq    #1,d1                      num of entries counter - 1
	    beq     si160                      only one entry then skip
	    add     d1,d1
	    add     d1,d1                      j
	    moveq   #0,d0                      n=0
d4278 6
a4283 6
	    move    2(a5,d0),d3                brightness[n]
	    cmp     2(a5,d2),d3                is brightness[i]>brightness[n]
	    bge     si155                      then pull the old switcheroo
	    move.l  0(a5,d2),d4                temp=record[i]
	    move.l  0(a5,d0),0(a5,d2)          record[i]=record[n]
	    move.l  d4,0(a5,d0)                record[n]=temp
d4285 4
a4288 4
	    bgt     si150
	    addq    #4,d0                      n=n+1
	    cmp     d0,d1                      is n>j
	    bgt     si140
d4290 2
a4291 2
	    moveq   #0,d3                      i=0
	    moveq   #0,d4                      zero upper byte
d4294 10
a4303 10
	    move.b  0(a5,d3),dither_pattern(a6,d4)
	    addq    #1,d0
	    addq    #1,d2
	    cmp.b   1(a5,d3),d2                is count[i]<n
	    blt     si180
	    addq    #4,d3                      i=i+1
	    cmp     d3,d1                      is i>j
	    bge     si170
	    adda    #768,a7     {SFB 4/12/85}  return space to stack
	    bra     rts
d4347 8
a4354 8
	    movea.l 4(sp),gle_gcb
	    movem.l a5/a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb
	    movea.l deviceaddress(rgl_gcb),a0
	    lea     pattregs(a0),a0     do this because can't use >127 displacement later
	    move.l  gamut(gle_gcb),d3   d3: how many planes to slice
	    moveq   #0,d1               d1: pattern register index
	    moveq   #0,d2               d2: single bit selector
d4356 2
a4357 2
	    moveq   #0,d6       d6: indexes columns of dither pattern (0..3)
	    moveq   #3,d4       d4: counts lines of dither pattern (3..0)
d4359 2
a4360 2
	    moveq   #3,d5       d5: counts columns of dither pattern (3..0)
	    moveq   #0,d0       d0: tmp, construct register data here
d4362 3
a4364 3
	    btst    d2,dither_pattern(rgl_gcb,d6)
	    beq     not_set
	    bset    d5,d0
d4366 13
a4378 13
	    addq    #1,d6               next row of dither pattern
	    dbra    d5,next_bit
	    mulu    #$1111,d0           replicate 4 bits horizontally
	    move.w  d0,(a0,d1)          move data to pattregs
	    move.w  d0,8(a0,d1)        ditto, replicating vertically
	    move.w  d0,16(a0,d1)        ditto, replicating vertically
	    move.w  d0,24(a0,d1)        ditto, replicating vertically
	    addq    #2,d1               next register (in 4x4 space)
	    dbra    d4,next_line
	    addq    #1,d2        generate next plane mask
	    add     #24,d1       and step to next pattreg block of 16 words
	    lsr     #1,d3        check gamut: are we done yet (no 1 bits left)?
	    bne     next_plane
d4380 1
a4380 1
	    bra     rts
d4382 1
a4382 1
	    page
d4396 13
a4408 13
	    movea.l 4(sp),gle_gcb                  a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                     stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb a6 = device gcb
	    clr.l   info1(gle_gcb)
	    clr.l   info3(gle_gcb)
	    move.w  hard_xmax(rgl_gcb),d0
	    ext.l   d0
	    move.l  d0,info2(gle_gcb)
	    move.w  hard_ymax(rgl_gcb),d0
	    ext.l   d0
	    move.l  d0,info4(gle_gcb)
	    bra rts
d4417 4
a4420 4
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device gcb
d4422 3
a4424 3
	    cmpi.w  #3,devicetype(rgl_gcb)          ck for 9836C
	    bne.s   blankgbox
	    movea.l deviceaddress(rgl_gcb),a2       36c await_blanking
d4426 3
a4428 3
	    btst    #0,(a2)                         used to be btst    #0,d0
	    beq.s   blank1
	    bra.s   noblank
d4431 3
a4433 3
	    bne.s   noblank
	    movea.l cmap_address(rgl_gcb),a2        gatbox await_blanking
	    adda.l  #2,a2
d4435 1
a4435 1
	    bne.s   blank3
d4446 4
a4449 4
	    movea.l 4(sp),gle_gcb                   a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                      stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb  a6 = device gcb
d4451 4
a4454 4
	    move.l  info1(gle_gcb),d1
	    move.l  info2(gle_gcb),d2
	    move.l  info3(gle_gcb),d3
	    move.l  info4(gle_gcb),d4
d4456 2
a4457 2
	    movea.l status(a5),a1       set up to check HSYNC in secondary
	    moveq   #1,d0
d4459 1
a4459 1
	    movea.l cmap_address(rgl_gcb),a0
d4461 1
a4461 1
	    bne.s   cm00
d4463 1
a4463 1
	    move.w  d1,$b7(a0)          set cmap pointer to correct entry
d4474 1
a4474 1
	    adda.l  #$1b1,a0            point a0 at RED register
d4476 1
a4476 1
	    beq.s   cm10
d4478 2
a4479 2
	    bne.s   cm11
	    move.w  d2,(a0)+            update red
d4481 1
a4481 1
	    beq.s   cm12
d4483 2
a4484 2
	    bne.s   cm13
	    move.w  d3,(a0)+            update green
d4486 1
a4486 1
	    beq.s   cm14
d4488 3
a4490 3
	    bne.s   cm15
	    move.w  d4,(a0)+            update blue
	    bra     rts
d4499 4
a4502 4
	    movea.l 4(sp),gle_gcb               a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                  stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb       a6 = device gcb
d4504 4
a4507 4
	    move.l  info1(gle_gcb),d1
	    move.l  info2(gle_gcb),d2
	    move.l  info3(gle_gcb),d3
	    move.l  info4(gle_gcb),d4
d4509 1
a4509 1
	    movea.l cmap_address(rgl_gcb),a0
d4513 2
a4514 2
	    btst    #2,2(a0)
	    bne.s   nereid_cm00
d4516 11
a4526 11
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b8(a0)                     set cmap index
	    move    0,d0                           delay for nereid SFB
	    move.b  d2,$b2(a0)                     set red
	    move    0,d0                           delay for nereid SFB
	    move.b  d3,$b4(a0)                     set green
	    move    0,d0                           delay for nereid SFB
	    move.b  d4,$b6(a0)                     set blue
	    move    0,d0                           delay for nereid SFB
	    move.b  d0,$f0(a0)                     trigger color map load
	    move    0,d0                           delay for nereid SFB
d4530 2
a4531 2
	    btst    #2,2(a0)
	    bne.s   nereid_cm01
d4533 9
a4541 9
	    moveq   #0,d1                          set above 4 registers to 0
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b8(a0)                     set cmap index
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b2(a0)                     set red
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b4(a0)                     set green
	    move    0,d0                           delay for nereid SFB
	    move.b  d1,$b6(a0)                     set blue
d4543 1
a4543 1
	    bra     rts
d4552 4
a4555 4
	    movea.l 4(sp),gle_gcb               a4 = address of pointer to gcb
	    move.l  (sp)+,(sp)                  stack return address
	    movem.l a5-a6,old_a5(gle_gcb)
	    movea.l dev_dep_stuff(gle_gcb),rgl_gcb       a6 = device gcb
d4557 4
a4560 4
	    move.l  info1(gle_gcb),d1
	    move.l  info2(gle_gcb),d2
	    move.l  info3(gle_gcb),d3
	    move.l  info4(gle_gcb),d4
d4562 3
a4564 3
	    move.l  #blueregimage,d5
	    move.l  #dacimagewrite,d6
	    movea.l deviceaddress(rgl_gcb),a0 need control space address
d4567 6
a4572 6
	    bne.s   checkblue               loop until bit is clear
	    move.b  d1,0(a0,d6.l)           write the index to the DAC
	    move.b  d2,4(a0,d6.l)           then red to the DAC
	    move.b  d3,4(a0,d6.l)           then green to the DAC
	    move.b  d4,3(a0,d5.l)           then blue to BEECH
	    bra     rts
d4575 1
a4575 1
	    end
@


55.5
log
@
pws2rcs automatic delta on Mon Nov  4 13:45:04 MST 1991
@
text
@@


55.4
log
@Removed . from ASM_TYPES - CFB
@
text
@d243 5
a247 5
woodcut_vga_display	      equ 10	                           CFB - 31MAY91
woodcut_med_display	      equ 11	                           CFB - 31MAY91
woodcut_hrx_display	      equ 12	                           CFB - 31MAY91
woodcut_vgam_display	      equ 13	                           CFB - 30JUL91
woodcut_hrxm_display	      equ 14	                           CFB - 30JUL91
d398 1
a398 1
            cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB -  9AUG91
d484 1
a484 1
            cmpi.w  #10,devicetype(rgl_gcb)    ck for WOODCUT      CFB - 24JUL91
d490 4
a493 4
adjust_woodcut equ  *						   CFB - 31MAY91
	    move    devicetype(rgl_gcb),d0			   CFB - 31MAY91
	    subq    #3,d0		      convert 10-12 to 7-9 CFB - 31MAY91
            cmpi.w  #12,devicetype(rgl_gcb)    ck for MONO WOODCUT CFB - 30JUL91
d495 5
a499 5
	    subq    #3,d0		      convert 13-14 to 7-8 CFB - 30JUL91
            cmpi.w  #7,d0                      VGA?                CFB - 11OCT91
            beq.s   gen1                                           CFB - 11OCT91
            addq    #1,d0                     Hrx? convert 8 to 9  CFB - 11OCT91
	    bra.s   gen1				           CFB - 31MAY91
d569 4
a572 4
	    dc      1000   n_glines	only 1000 because we use 50 alpha lines
*					at 10 scan lines each, and don't offset
*					alpha the 4 "wasted" pixels as we do on
*					low-res Bobcat
d3039 2
a3040 2
 	    cmpi.b  #10,devicetype+1(rgl_gcb)   WOODCUT doesn't look like BOBCAT
 	    bge     fill30                                         CFB - 24JUL91
d3042 2
a3043 2
 	    cmpi.b  #6,devicetype+1(rgl_gcb)
 	    bge     fbobcat
d3063 1
a3063 1
            bge     f36c               WOODCUT has no window mover   CFB 10JUN91
d3421 1
a3421 1
            move.w  #3,bobwr(a1)                windowmove replacement rule
d4562 2
a4563 2
            move.l  #blueregimage,d5
            move.l  #dacimagewrite,d6
d4567 6
a4572 6
            bne.s   checkblue               loop until bit is clear
            move.b  d1,0(a0,d6.l)           write the index to the DAC
            move.b  d2,4(a0,d6.l)           then red to the DAC
            move.b  d3,4(a0,d6.l)           then green to the DAC
            move.b  d4,3(a0,d5.l)           then blue to BEECH
            bra     rts
@


55.3
log
@Fixed bug with greyscale HRX being initialized as medium-res - CFB
@
text
@d283 1
a283 1
	    include ASM_TYPES.
@


55.2
log
@Added support for High-res and Greyscale - CFB
@
text
@d496 3
@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@d243 5
a247 3
woodcut_vga_display           equ 10                               CFB - 31MAY91
woodcut_med_display           equ 11                               CFB - 31MAY91
woodcut_hrx_display           equ 12                               CFB - 31MAY91
d283 1
a283 1
	    include ASM_TYPES
d364 2
d397 4
a400 1
*  in GLE_RGL !!!!!!!
d415 8
d484 1
a484 1
	    cmpi.w  #10,devicetype(rgl_gcb)    ck for WOODCUT      CFB - 24JUL91
d490 7
a496 4
adjust_woodcut equ  *                                              CFB - 31MAY91
	    move    devicetype(rgl_gcb),d0                         CFB - 31MAY91
	    subq    #3,d0                     convert 10-12 to 7-9 CFB - 31MAY91
	    bra.s   gen1                                           CFB - 31MAY91
d566 4
a569 4
	    dc      1000   n_glines     only 1000 because we use 50 alpha lines
*                                       at 10 scan lines each, and don't offset
*                                       alpha the 4 "wasted" pixels as we do on
*                                       low-res Bobcat
d3017 2
d3036 2
a3037 2
	    cmpi.b  #10,devicetype+1(rgl_gcb)   WOODCUT doesn't look like BOBCAT
	    bge     fill30                                         CFB - 24JUL91
d3039 2
a3040 2
	    cmpi.b  #6,devicetype+1(rgl_gcb)
	    bge     fbobcat
d3060 1
a3060 1
	    bge     f36c               WOODCUT has no window mover   CFB 10JUN91
d3418 1
a3418 1
	    move.w  #3,bobwr(a1)                windowmove replacement rule
d4559 2
a4560 2
	    move.l  #blueregimage,d5
	    move.l  #dacimagewrite,d6
d4564 6
a4569 6
	    bne.s   checkblue               loop until bit is clear
	    move.b  d1,0(a0,d6.l)           write the index to the DAC
	    move.b  d2,4(a0,d6.l)           then red to the DAC
	    move.b  d3,4(a0,d6.l)           then green to the DAC
	    move.b  d4,3(a0,d5.l)           then blue to BEECH
	    bra     rts
@


54.7
log
@
pws2rcs automatic delta on Wed Aug 21 12:59:22 MDT 1991
@
text
@@


54.6
log
@removed '.' from include ASM_TYPES. - CFB
@
text
@d243 3
a245 3
woodcut_vga_display	      equ 10	                           CFB - 31MAY91
woodcut_med_display	      equ 11	                           CFB - 31MAY91
woodcut_hrx_display	      equ 12	                           CFB - 31MAY91
d469 1
a469 1
            cmpi.w  #10,devicetype(rgl_gcb)    ck for WOODCUT      CFB - 24JUL91
d475 4
a478 4
adjust_woodcut equ  *						   CFB - 31MAY91
	    move    devicetype(rgl_gcb),d0			   CFB - 31MAY91
	    subq    #3,d0		      convert 10-12 to 7-9 CFB - 31MAY91
	    bra.s   gen1				           CFB - 31MAY91
d548 4
a551 4
	    dc      1000   n_glines	only 1000 because we use 50 alpha lines
*					at 10 scan lines each, and don't offset
*					alpha the 4 "wasted" pixels as we do on
*					low-res Bobcat
d3016 2
a3017 2
 	    cmpi.b  #10,devicetype+1(rgl_gcb)   WOODCUT doesn't look like BOBCAT
 	    bge     fill30                                         CFB - 24JUL91
d3019 2
a3020 2
 	    cmpi.b  #6,devicetype+1(rgl_gcb)
 	    bge     fbobcat
d3040 1
a3040 1
            bge     f36c               WOODCUT has no window mover   CFB 10JUN91
d3398 1
a3398 1
            move.w  #3,bobwr(a1)                windowmove replacement rule
d4539 2
a4540 2
            move.l  #blueregimage,d5
            move.l  #dacimagewrite,d6
d4544 6
a4549 6
            bne.s   checkblue               loop until bit is clear
            move.b  d1,0(a0,d6.l)           write the index to the DAC
            move.b  d2,4(a0,d6.l)           then red to the DAC
            move.b  d3,4(a0,d6.l)           then green to the DAC
            move.b  d4,3(a0,d5.l)           then blue to BEECH
            bra     rts
@


54.5
log
@fixed polygon fill code.
QA tested on MACE/VGA - PASSED              CFB
@
text
@d281 1
a281 1
	    include ASM_TYPES.
@


54.4
log
@added initwoodcutgen to identify the colormap correctly - CFB
@
text
@d281 1
a281 1
	    include ASM_TYPES
d438 1
a438 1
	    bra.s   initcmapinfo
d441 5
a445 5
            movea.l info2(gle_gcb),a0
            move.l  a0,deviceaddress(rgl_gcb)
            move.l  #0,info3(gle_gcb)
            move.l  info3(gle_gcb),cmap_address(rgl_gcb)
            bra     initcmapinfo
d469 2
a470 2
	    cmpi.w  #13,info1+2(gle_gcb)      ck for WOODCUT video CFB - 31MAY91
	    ble.s   adjust_woodcut                                 CFB - 31MAY91
d1175 1
a1175 1
	    blt.s   vec1                                             CFB 10JUN91
d2638 3
d2885 3
a2887 1
	    blt     rts                                              CFB 10JUN91
a2888 2
	    cmpi.b  #catseye_display,devicetype+1(rgl_gcb)              SFB
	    bge     rts                                              CFB 12JUN91
d3016 2
a3017 2
	    cmpi.b  #6,devicetype+1(rgl_gcb)
	    bge     fbobcat
d3019 4
a3022 1
	    move    blu_intensity(rgl_gcb),d2
d3039 2
a3040 2
	    cmpi.b  #catseye_hrx_display,devicetype+1(rgl_gcb)       CFB 10JUN91
            blt     f36c                           no window mover   CFB 10JUN91
d3042 1
a3408 10

fwoodcut    equ     *



******** NEED TO WRITE THIS CODE *************



            rts
@


54.3
log
@removed . from include file names - CFB
@
text
@d398 1
a398 1
	    bra.s   initbobcatgen                                  CFB - 31MAY91
d402 1
a402 1
	    bra.s   initbobcatgen                                  CFB - 31MAY91
d406 1
a406 1
	    bra.s   initbobcatgen                                  CFB - 31MAY91
d439 7
@


54.2
log
@Added support for WOODCUT graphics hardware - CFB
@
text
@d281 1
a281 1
	    include ASM_TYPES.
@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@d19 1
d65 1
d103 1
d243 3
d271 4
a274 4
pattregs                      equ $4400         CATSEYE pattern register base SFB
fben1                         equ $4500         frame buffer enable in upper byte SFB
trr                           equ $450c         upper byte=Three Operand Repl Rule SFB
trr_enable                    equ $4512         bit 8 of word selects trr/wrr SFB
d277 5
a281 1
	    include ASM_TYPES
d359 3
d373 1
a373 1
	    bra.s   initcom
d376 1
a376 1
	    bra.s   initcom
d394 1
a394 1
	    bra.s   gen_init
d396 12
d411 1
d415 1
d419 1
d422 6
d429 6
a434 5
	    movea.l info2(gle_gcb),a0     {SFB} hacked to allow HRM CATSEYE to be known as
	    move.l  a0,deviceaddress(rgl_gcb)   mono disply to DGL, and initialize GCB for same
	    cmpi.b  #hrm_tertiary,tert_off(a0)  HRM CATSEYE IS "mono" but has cmap
	    bne.s   get_cmap_info               other CATSEYE/BOBCAT are color or have no cmap
	    move.l  #0,info3(gle_gcb)           signal "mono" for HRM, and send back to gle_rgl
d437 1
a437 1
	    beq.s   initcom
d454 1
d458 1
d461 5
a465 1
	    move    #4,d0                      use initialize block 4 for Bobcat clones
d467 6
d541 6
a546 3
	    dc      1000   n_glines             {only 1000 because we use 50 alpha lines at 10
	    dc         1   gspacing             {scan lines each, and don't offset alpha down by
	    dc      2048   bytesperline         {the 4 "wasted" pixels as we do on low-res Bobcat}
d550 24
d821 1
a821 1
	    bne.s    bit_test               see new Graphics ID ROM definition SFB
d1151 1
a1151 1
	    adda.w  d0,a0                          adjust for 16/26 odd addressing
d1167 2
d1205 5
a1209 5
* and repeatrate:  The final current_linestyle_pattern and repeatcount are calculated
* before the vector loop is entered.  This prevents a messy self-modification
* section in the vector generator itself, and limits all self modifying
* code to subroutine 'buildpen'.  If the line must be drawn backwards
* (i.e., the passed y2 was less than y1), the final current_linestyle_pattern and
d1268 1
a1268 1
	    move    cpen(rgl_gcb),d0                d0 = pen (or not pen if erase)
d1302 1
a1302 1
	    add     n_glines(rgl_gcb),d6            d6 = (n_glines-1)-y
d1318 1
a1318 1
	    tst     devicetype(rgl_gcb)             9816 or 9826 ?
d1322 1
a1322 1
	    btst    #1,devicetype+1(rgl_gcb)        is this color ?
d2874 3
d2878 1
a2878 2
	    blt     rts                                                 SFB
	    movea.l deviceaddress(rgl_gcb),a0 waitcatready assumes this SFB
d2968 1
a2968 1
*               gle_gcb              = gcb_ptr
d2986 3
d3026 3
d3384 1
a3384 1
	    move.w  #3,bobwr(a1)                windowmove replacement rule
d3391 4
a3394 4
	    move.w  #$100,trr_enable(a1)        select Three Operand Repl Rule SFB
	    move.w  #$f000,trr(a1)              choose "Pattern Reg" rule      SFB
	    move.w  d5,fben1(a1)                enable all loaded planes       SFB
	    bra     move_scanline                                              SFB
d3396 10
d4329 2
a4330 2
	    moveq   #0,d6               d6: indexes columns of dither pattern (0..3)
	    moveq   #3,d4               d4: counts lines of dither pattern (3..0)
d4332 3
a4334 3
	    moveq   #3,d5               d5: counts columns of dither pattern (3..0)
	    moveq   #0,d0               d0: tmp, construct register data here
next_bit    equ     *                   next byte of dither pattern cell->next bit of d0
d4348 3
a4350 3
	    addq    #1,d2               generate next plane mask
	    add     #24,d1              and step to next pattreg block of 16 words
	    lsr     #1,d3               check gamut: are we done yet (no 1 bits left)?
d4517 29
@


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
@d64 1
d101 1
d104 1
d238 2
d245 4
d265 7
a271 1
	     include ASM_TYPES
d347 2
d383 6
d395 6
a400 1
	    move.l  info2(gle_gcb),deviceaddress(rgl_gcb)
d422 7
a428 1
	    move    #4,d0                      use initialize block 4 for all
d460 1
a460 1
	    dc.l   $8000   plane2_offset                         {Moonunit}
d468 1
a468 1
	    dc.l       0   not used                              {9836c}
d476 1
a476 1
	    dc.l       0   not used               {Gator/gatorbox/bobcathires}
d484 1
a484 1
	    dc.l       0   not used               {bobcat lores block}
d486 1
a486 1
	    dc       385   n_glines               {change when spec is known}
d492 8
d746 2
d751 1
a751 1
	    bne      ginit1                 based on control byte
d758 1
d762 15
d2506 5
d2796 8
a2803 1
	    bge     rts
d2906 2
d3271 3
a3273 1
	    and.w   gamut(gle_gcb),d5           check only loaded topcats
a3295 1
	    move.w  #3,bobwr(a1)                windowmove replacement rule
d3298 4
d3306 5
d4185 75
@


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.2
log
@Changes from Scott Bayes
@
text
@@


5.1
log
@Automatic bump of revision number for PWS version 3.2j
@
text
@d4232 1
a4232 1
	    NOP                                    SFB 4/18/85
d4236 1
d4238 1
d4240 1
d4242 1
d4244 1
d4246 1
d4249 1
a4249 1
	    NOP                                    SFB 4/18/85
d4254 1
d4256 1
d4258 1
d4260 1
@


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
@@
