Home | History | Annotate | Line # | Download | only in dev
grfabs_cc.c revision 1.1
      1  1.1  chopps /*
      2  1.1  chopps  * Copyright (c) 1994 Christian E. Hopps
      3  1.1  chopps  * All rights reserved.
      4  1.1  chopps  *
      5  1.1  chopps  * Redistribution and use in source and binary forms, with or without
      6  1.1  chopps  * modification, are permitted provided that the following conditions
      7  1.1  chopps  * are met:
      8  1.1  chopps  * 1. Redistributions of source code must retain the above copyright
      9  1.1  chopps  *    notice, this list of conditions and the following disclaimer.
     10  1.1  chopps  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1  chopps  *    notice, this list of conditions and the following disclaimer in the
     12  1.1  chopps  *    documentation and/or other materials provided with the distribution.
     13  1.1  chopps  * 3. All advertising materials mentioning features or use of this software
     14  1.1  chopps  *    must display the following acknowledgement:
     15  1.1  chopps  *      This product includes software developed by Christian E. Hopps.
     16  1.1  chopps  * 4. The name of the author may not be used to endorse or promote products
     17  1.1  chopps  *    derived from this software without specific prior written permission
     18  1.1  chopps  *
     19  1.1  chopps  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  1.1  chopps  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  1.1  chopps  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  1.1  chopps  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  1.1  chopps  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  1.1  chopps  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  1.1  chopps  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  1.1  chopps  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  1.1  chopps  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  1.1  chopps  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  1.1  chopps  *
     30  1.1  chopps  *	$Id: grfabs_cc.c,v 1.1 1994/02/13 21:10:31 chopps Exp $
     31  1.1  chopps  *
     32  1.1  chopps  *  abstract interface for custom chips to the amiga abstract graphics driver.
     33  1.1  chopps  *
     34  1.1  chopps  */
     35  1.1  chopps 
     36  1.1  chopps #include <sys/param.h>
     37  1.1  chopps #include <sys/errno.h>
     38  1.1  chopps #include <sys/cdefs.h>
     39  1.1  chopps 
     40  1.1  chopps #include <amiga/amiga/custom.h>
     41  1.1  chopps #include <amiga/amiga/dlists.h>
     42  1.1  chopps #include <amiga/amiga/cc.h>
     43  1.1  chopps 
     44  1.1  chopps #include <amiga/dev/grfabs_reg.h>
     45  1.1  chopps #include <amiga/dev/grfabs_ccreg.h>
     46  1.1  chopps 
     47  1.1  chopps monitor_t *m_this;
     48  1.1  chopps mdata_t *m_this_data;
     49  1.1  chopps char   *monitor_name = "CCMONITOR";
     50  1.1  chopps monitor_t monitor;
     51  1.1  chopps mdata_t monitor_data;
     52  1.1  chopps cop_t  *null_mode_copper_list;
     53  1.1  chopps 
     54  1.1  chopps extern dll_list_t *monitors;
     55  1.1  chopps 
     56  1.1  chopps #if defined (GRF_PAL)
     57  1.1  chopps #  if defined (GRF_A2024)
     58  1.1  chopps dmode_t pal_a2024_mode;
     59  1.1  chopps dmdata_t pal_a2024_mode_data;
     60  1.1  chopps cop_t  *pal_a2024_frames[F_QD_TOTAL];
     61  1.1  chopps u_char *hedley_init;		/* init bitplane. */
     62  1.1  chopps dmode_t *p24_this;
     63  1.1  chopps dmdata_t *p24_this_data;
     64  1.1  chopps 
     65  1.1  chopps dmode_t pal_hires_dlace_mode;
     66  1.1  chopps dmdata_t pal_hires_dlace_mode_data;
     67  1.1  chopps cop_t  *pal_hires_dlace_frames[F_LACE_TOTAL];
     68  1.1  chopps dmode_t *phdl_this;
     69  1.1  chopps dmdata_t *phdl_this_data;
     70  1.1  chopps #  endif /* GRF_A2024 */
     71  1.1  chopps 
     72  1.1  chopps dmode_t pal_hires_lace_mode;
     73  1.1  chopps dmdata_t pal_hires_lace_mode_data;
     74  1.1  chopps cop_t  *pal_hires_lace_frames[F_LACE_TOTAL];
     75  1.1  chopps dmode_t *phl_this;
     76  1.1  chopps dmdata_t *phl_this_data;
     77  1.1  chopps 
     78  1.1  chopps dmode_t pal_hires_mode;
     79  1.1  chopps dmdata_t pal_hires_mode_data;
     80  1.1  chopps cop_t  *pal_hires_frames[F_TOTAL];
     81  1.1  chopps dmode_t *ph_this;
     82  1.1  chopps dmdata_t *ph_this_data;
     83  1.1  chopps #endif /* PAL */
     84  1.1  chopps 
     85  1.1  chopps #if defined (GRF_NTSC)
     86  1.1  chopps #  if defined (GRF_A2024)
     87  1.1  chopps dmode_t a2024_mode;
     88  1.1  chopps dmdata_t a2024_mode_data;
     89  1.1  chopps cop_t  *a2024_frames[F_QD_TOTAL];
     90  1.1  chopps u_char *hedley_init;		/* init bitplane. */
     91  1.1  chopps dmode_t *a24_this;
     92  1.1  chopps dmdata_t *a24_this_data;
     93  1.1  chopps 
     94  1.1  chopps dmode_t hires_dlace_mode;
     95  1.1  chopps dmdata_t hires_dlace_mode_data;
     96  1.1  chopps cop_t  *hires_dlace_frames[F_LACE_TOTAL];
     97  1.1  chopps dmode_t *hdl_this;
     98  1.1  chopps dmdata_t *hdl_this_data;
     99  1.1  chopps #  endif /* GRF_A2024 */
    100  1.1  chopps 
    101  1.1  chopps dmode_t hires_lace_mode;
    102  1.1  chopps dmdata_t hires_lace_mode_data;
    103  1.1  chopps cop_t  *hires_lace_frames[F_LACE_TOTAL];
    104  1.1  chopps dmode_t *hl_this;
    105  1.1  chopps dmdata_t *hl_this_data;
    106  1.1  chopps 
    107  1.1  chopps void    display_hires_view(view_t * v);
    108  1.1  chopps dmode_t hires_mode;
    109  1.1  chopps dmdata_t hires_mode_data;
    110  1.1  chopps cop_t  *hires_frames[F_TOTAL];
    111  1.1  chopps dmode_t *h_this;
    112  1.1  chopps dmdata_t *h_this_data;
    113  1.1  chopps #endif /* GRF_NTSC */
    114  1.1  chopps 
    115  1.1  chopps 
    116  1.1  chopps /* monitor functions. */
    117  1.1  chopps monitor_t *
    118  1.1  chopps cc_init_monitor()
    119  1.1  chopps {
    120  1.1  chopps 	if (!m_this) {
    121  1.1  chopps 		cop_t  *cp;
    122  1.1  chopps 		cc_monitor = m_this = &monitor;
    123  1.1  chopps 
    124  1.1  chopps 		/* turn sprite DMA off. we don't support them yet. */
    125  1.1  chopps 		custom.dmacon = DMAF_SPRITE;
    126  1.1  chopps 
    127  1.1  chopps 		m_this->node.next = m_this->node.prev = NULL;
    128  1.1  chopps 		m_this->name = monitor_name;
    129  1.1  chopps 		m_this_data = m_this->data = &monitor_data;
    130  1.1  chopps 
    131  1.1  chopps 		m_this->get_current_mode = get_current_mode;
    132  1.1  chopps 		m_this->vbl_handler = (vbl_handler_func *) monitor_vbl_handler;
    133  1.1  chopps 		m_this->get_next_mode = get_next_mode;
    134  1.1  chopps 		m_this->get_best_mode = get_best_mode;
    135  1.1  chopps 
    136  1.1  chopps 		m_this->alloc_bitmap = alloc_bitmap;
    137  1.1  chopps 		m_this->free_bitmap = free_bitmap;
    138  1.1  chopps 
    139  1.1  chopps 		m_this_data->current_mode = NULL;
    140  1.1  chopps 		dinit_list(&m_this_data->modes);
    141  1.1  chopps 
    142  1.1  chopps 		cp = null_mode_copper_list = alloc_chipmem(sizeof(cop_t) * 4);
    143  1.1  chopps 		if (!cp) {
    144  1.1  chopps 			panic("no chipmem for grf.");
    145  1.1  chopps 		}
    146  1.1  chopps 		CMOVE(cp, R_COLOR00, 0x0000);	/* background is black */
    147  1.1  chopps 		CMOVE(cp, R_BPLCON0, 0x0000);	/* no planes to fetch from */
    148  1.1  chopps 		CWAIT(cp, 255, 255);	/* COPEND */
    149  1.1  chopps 		CWAIT(cp, 255, 255);	/* COPEND really */
    150  1.1  chopps 
    151  1.1  chopps 		/* install m_this list and turn DMA on */
    152  1.1  chopps 		custom.cop1lc = PREP_DMA_MEM(null_mode_copper_list);
    153  1.1  chopps 		custom.copjmp1 = 0;
    154  1.1  chopps 		custom.dmacon = DMAF_SETCLR | DMAF_MASTER | DMAF_RASTER \
    155  1.1  chopps 		    |DMAF_COPPER;
    156  1.1  chopps 
    157  1.1  chopps 		cc_init_modes();
    158  1.1  chopps 		dadd_tail(monitors, &m_this->node);
    159  1.1  chopps 	}
    160  1.1  chopps 	return (m_this);
    161  1.1  chopps }
    162  1.1  chopps 
    163  1.1  chopps void
    164  1.1  chopps monitor_vbl_handler(m)
    165  1.1  chopps 	monitor_t *m;
    166  1.1  chopps {
    167  1.1  chopps 	if (m_this_data->current_mode) {
    168  1.1  chopps 		DMDATA(m_this_data->current_mode)->vbl_handler(m_this_data->current_mode);
    169  1.1  chopps 	}
    170  1.1  chopps }
    171  1.1  chopps 
    172  1.1  chopps dmode_t *
    173  1.1  chopps get_current_mode()
    174  1.1  chopps {
    175  1.1  chopps 	if (m_this_data->current_mode) {
    176  1.1  chopps 		return (m_this_data->current_mode);
    177  1.1  chopps 	} else {
    178  1.1  chopps 		return (NULL);
    179  1.1  chopps 	}
    180  1.1  chopps }
    181  1.1  chopps 
    182  1.1  chopps dmode_t *
    183  1.1  chopps get_next_mode(d)
    184  1.1  chopps 	dmode_t *d;
    185  1.1  chopps {
    186  1.1  chopps 	if (d) {
    187  1.1  chopps 		if (d->node.next->next) {
    188  1.1  chopps 			return ((dmode_t *) d->node.next);
    189  1.1  chopps 		}
    190  1.1  chopps 	} else
    191  1.1  chopps 		if (m_this_data->modes.head->next) {
    192  1.1  chopps 			return ((dmode_t *) m_this_data->modes.head);
    193  1.1  chopps 		} else {
    194  1.1  chopps 			return (NULL);
    195  1.1  chopps 		}
    196  1.1  chopps }
    197  1.1  chopps 
    198  1.1  chopps /* XXX needs to have more control attributes */
    199  1.1  chopps dmode_t *
    200  1.1  chopps get_best_mode(size, depth)
    201  1.1  chopps 	dimen_t *size;
    202  1.1  chopps 	u_char depth;
    203  1.1  chopps {
    204  1.1  chopps 	dmode_t *save = NULL;
    205  1.1  chopps 	dmode_t *m = (dmode_t *) m_this_data->modes.head;
    206  1.1  chopps 	long    dt;
    207  1.1  chopps 
    208  1.1  chopps 	while (m->node.next) {
    209  1.1  chopps 		long    dx, dy, ct;
    210  1.1  chopps 		dmdata_t *dmd = m->data;
    211  1.1  chopps 
    212  1.1  chopps 		if (depth > dmd->max_depth || depth < dmd->min_depth) {
    213  1.1  chopps 			m = (dmode_t *) m->node.next;
    214  1.1  chopps 			continue;
    215  1.1  chopps 		}
    216  1.1  chopps 		if (size->width > dmd->max_size.width ||
    217  1.1  chopps 		    size->height > dmd->max_size.height) {
    218  1.1  chopps 			m = (dmode_t *) m->node.next;
    219  1.1  chopps 			continue;
    220  1.1  chopps 		}
    221  1.1  chopps 		if (size->width < dmd->min_size.width ||
    222  1.1  chopps 		    size->height < dmd->min_size.height) {
    223  1.1  chopps 			m = (dmode_t *) m->node.next;
    224  1.1  chopps 			continue;
    225  1.1  chopps 		}
    226  1.1  chopps 		dx = abs(m->nominal_size.width - size->width);
    227  1.1  chopps 		dy = abs(m->nominal_size.height - size->height);
    228  1.1  chopps 		ct = dx + dy;
    229  1.1  chopps 
    230  1.1  chopps 		if (ct < dt || save == NULL) {
    231  1.1  chopps 			save = m;
    232  1.1  chopps 			dt = ct;
    233  1.1  chopps 		}
    234  1.1  chopps 		m = (dmode_t *) m->node.next;
    235  1.1  chopps 	}
    236  1.1  chopps 	return (save);
    237  1.1  chopps }
    238  1.1  chopps /* bitmap functions */
    239  1.1  chopps bmap_t *
    240  1.1  chopps alloc_bitmap(width, height, depth, flags)
    241  1.1  chopps 	u_short width, height, depth, flags;
    242  1.1  chopps {
    243  1.1  chopps 	int     i;
    244  1.1  chopps 	u_long  total_size;
    245  1.1  chopps 	u_short lwpr = (width + 31) / 32;
    246  1.1  chopps 	u_short wpr = lwpr << 1;
    247  1.1  chopps 	u_short bpr = wpr << 1;
    248  1.1  chopps 	u_short array_size = sizeof(u_char *) * depth;
    249  1.1  chopps 	u_long  plane_size = bpr * height;
    250  1.1  chopps 	u_short temp_size = bpr + sizeof(u_long);
    251  1.1  chopps 	bmap_t *bm;
    252  1.1  chopps 
    253  1.1  chopps 	/* note the next allocation will give everything, also note that all
    254  1.1  chopps 	 * the stuff we want (including bitmaps) will be long short aligned.
    255  1.1  chopps 	 * M_This is a function of the data being allocated and the fact that
    256  1.1  chopps 	 * alloc_chipmem() returns long short aligned data. note also that
    257  1.1  chopps 	 * each row of the bitmap is long word aligned and made of exactly n
    258  1.1  chopps 	 * longwords. -ch */
    259  1.1  chopps 
    260  1.1  chopps 	/* Sigh, it seems for mapping to work we need the bitplane data to 1:
    261  1.1  chopps 	 * be aligned on a page boundry. 2: be n pages large.
    262  1.1  chopps 	 *
    263  1.1  chopps 	 * why? becuase the user gets a page aligned address, if m_this is before
    264  1.1  chopps 	 * your allocation, too bad.  Also it seems that the mapping routines
    265  1.1  chopps 	 * do not watch to closely to the allowable length. so if you go over
    266  1.1  chopps 	 * n pages by less than another page, the user gets to write all over
    267  1.1  chopps 	 * the entire page.  Since you did not allocate up to a page boundry
    268  1.1  chopps 	 * (or more) the user writes into someone elses memory. -ch */
    269  1.1  chopps 	total_size = amiga_round_page(plane_size * depth) +	/* for length */
    270  1.1  chopps 	    (temp_size) + (array_size) + sizeof(bmap_t) +
    271  1.1  chopps 	    NBPG;		/* for alignment */
    272  1.1  chopps 	bm = alloc_chipmem(total_size);
    273  1.1  chopps 	if (bm) {
    274  1.1  chopps 		if (flags & BMF_CLEAR) {
    275  1.1  chopps 			bzero(bm, total_size);
    276  1.1  chopps 		}
    277  1.1  chopps 		bm->bytes_per_row = bpr;
    278  1.1  chopps 		bm->rows = height;
    279  1.1  chopps 		bm->depth = depth;
    280  1.1  chopps 		bm->flags = flags;
    281  1.1  chopps 		bm->plane = (u_char **) & bm[1];
    282  1.1  chopps 		bm->blit_temp = ((u_char *) bm->plane) + array_size;
    283  1.1  chopps 		bm->plane[0] = (u_char *) amiga_round_page((u_long) (bm->blit_temp + temp_size));
    284  1.1  chopps 		if (flags & BMF_INTERLEAVED) {
    285  1.1  chopps 			bm->row_mod = bm->bytes_per_row * (depth - 1);
    286  1.1  chopps 			for (i = 1; i < depth; i++) {
    287  1.1  chopps 				bm->plane[i] = bm->plane[i - 1] + bpr;
    288  1.1  chopps 			}
    289  1.1  chopps 		} else {
    290  1.1  chopps 			bm->row_mod = 0;
    291  1.1  chopps 			for (i = 1; i < depth; i++) {
    292  1.1  chopps 				bm->plane[i] = bm->plane[i - 1] + plane_size;
    293  1.1  chopps 			}
    294  1.1  chopps 		}
    295  1.1  chopps 		bm->hardware_address = PREP_DMA_MEM(bm->plane[0]);
    296  1.1  chopps 		return (bm);
    297  1.1  chopps 	}
    298  1.1  chopps 	return (NULL);
    299  1.1  chopps }
    300  1.1  chopps 
    301  1.1  chopps 
    302  1.1  chopps void
    303  1.1  chopps free_bitmap(bm)
    304  1.1  chopps 	bmap_t *bm;
    305  1.1  chopps {
    306  1.1  chopps 	if (bm)
    307  1.1  chopps 		free_chipmem(bm);
    308  1.1  chopps }
    309  1.1  chopps /* load a new mode into the current display, if NULL shut display off. */
    310  1.1  chopps void
    311  1.1  chopps cc_load_mode(d)
    312  1.1  chopps 	dmode_t *d;
    313  1.1  chopps {
    314  1.1  chopps 	if (d) {
    315  1.1  chopps 		m_this_data->current_mode = d;
    316  1.1  chopps 		return;
    317  1.1  chopps 	}
    318  1.1  chopps 	/* turn off display */
    319  1.1  chopps 	m_this_data->current_mode = NULL;
    320  1.1  chopps 	wait_tof();
    321  1.1  chopps 	wait_tof();
    322  1.1  chopps 	custom.cop1lc = PREP_DMA_MEM(null_mode_copper_list);
    323  1.1  chopps }
    324  1.1  chopps /*
    325  1.1  chopps  * CC Mode Stuff.
    326  1.1  chopps  */
    327  1.1  chopps 
    328  1.1  chopps dmode_t *(*mode_init_funcs[]) (void) = {
    329  1.1  chopps #if defined (GRF_NTSC)
    330  1.1  chopps #if defined (GRF_A2024)
    331  1.1  chopps 	cc_init_ntsc_a2024,
    332  1.1  chopps 	cc_init_ntsc_hires_dlace,
    333  1.1  chopps #endif /* GRF_A2024 */
    334  1.1  chopps 	cc_init_ntsc_hires_lace,
    335  1.1  chopps 	cc_init_ntsc_hires,
    336  1.1  chopps #endif /* GRF_NTSC */
    337  1.1  chopps #if defined (GRF_PAL)
    338  1.1  chopps #if defined (GRF_A2024)
    339  1.1  chopps 	cc_init_pal_a2024,
    340  1.1  chopps 	cc_init_pal_hires_dlace,
    341  1.1  chopps #endif /* GRF_A2024 */
    342  1.1  chopps 	cc_init_pal_hires_lace,
    343  1.1  chopps 	cc_init_pal_hires,
    344  1.1  chopps #endif /* GRF_PAL */
    345  1.1  chopps 	NULL
    346  1.1  chopps };
    347  1.1  chopps 
    348  1.1  chopps int
    349  1.1  chopps cc_init_modes()
    350  1.1  chopps {
    351  1.1  chopps 	int     i = 0;
    352  1.1  chopps 	int     error = 0;
    353  1.1  chopps 	while (mode_init_funcs[i]) {
    354  1.1  chopps 		mode_init_funcs[i] ();
    355  1.1  chopps 		i++;
    356  1.1  chopps 	}
    357  1.1  chopps 	return (error);
    358  1.1  chopps }
    359  1.1  chopps 
    360  1.1  chopps monitor_t *
    361  1.1  chopps cc_get_monitor(d)
    362  1.1  chopps 	dmode_t *d;
    363  1.1  chopps {
    364  1.1  chopps 	return (DMDATA(d)->monitor);
    365  1.1  chopps }
    366  1.1  chopps 
    367  1.1  chopps view_t *
    368  1.1  chopps cc_get_current_view(d)
    369  1.1  chopps 	dmode_t *d;
    370  1.1  chopps {
    371  1.1  chopps 	return (DMDATA(d)->current_view);
    372  1.1  chopps }
    373  1.1  chopps 
    374  1.1  chopps 
    375  1.1  chopps view_t *
    376  1.1  chopps cc_alloc_view(mode, dim, depth)
    377  1.1  chopps 	dmode_t *mode;
    378  1.1  chopps 	dimen_t *dim;
    379  1.1  chopps 	u_char   depth;
    380  1.1  chopps {
    381  1.1  chopps 	view_t *v = alloc_chipmem(sizeof(*v) + sizeof(vdata_t));
    382  1.1  chopps 	if (v) {
    383  1.1  chopps 		bmap_t *bm = cc_monitor->alloc_bitmap(dim->width, dim->height, depth, BMF_CLEAR);
    384  1.1  chopps 		if (bm) {
    385  1.1  chopps 			int     i;
    386  1.1  chopps 			box_t   box;
    387  1.1  chopps 
    388  1.1  chopps 			v->data = &v[1];	/* at the end of view */
    389  1.1  chopps 			VDATA(v)->colormap = DMDATA(mode)->alloc_colormap(depth);
    390  1.1  chopps 			if (VDATA(v)->colormap) {
    391  1.1  chopps 				INIT_BOX(&box, 0, 0, dim->width, dim->height);
    392  1.1  chopps 				cc_init_view(v, bm, mode, &box);
    393  1.1  chopps 				return (v);
    394  1.1  chopps 			}
    395  1.1  chopps 			cc_monitor->free_bitmap(bm);
    396  1.1  chopps 		}
    397  1.1  chopps 		free_chipmem(v);
    398  1.1  chopps 	}
    399  1.1  chopps 	return (NULL);
    400  1.1  chopps }
    401  1.1  chopps 
    402  1.1  chopps colormap_t *
    403  1.1  chopps cc_alloc_colormap(depth)
    404  1.1  chopps 	int depth;
    405  1.1  chopps {
    406  1.1  chopps 	u_long  size = 1U << depth, i;
    407  1.1  chopps 	colormap_t *cm = alloc_chipmem(sizeof(u_long) * size + sizeof(*cm));
    408  1.1  chopps 
    409  1.1  chopps 	if (cm) {
    410  1.1  chopps 		cm->type = CM_COLOR;
    411  1.1  chopps 		cm->red_mask = 0x0F;
    412  1.1  chopps 		cm->green_mask = 0x0F;
    413  1.1  chopps 		cm->blue_mask = 0x0F;
    414  1.1  chopps 		cm->first = 0;
    415  1.1  chopps 		cm->size = size;
    416  1.1  chopps 		cm->entry = (u_long *) & cm[1];	/* table directly after. */
    417  1.1  chopps 		for (i = 0; i < min(size, 32); i++) {
    418  1.1  chopps 			cm->entry[i] = CM_WTOL(cc_default_colors[i]);
    419  1.1  chopps 		}
    420  1.1  chopps 		return (cm);
    421  1.1  chopps 	}
    422  1.1  chopps 	return (NULL);
    423  1.1  chopps }
    424  1.1  chopps 
    425  1.1  chopps int
    426  1.1  chopps cc_colormap_checkvals(vcm, cm, use)
    427  1.1  chopps 	colormap_t *vcm, *cm;
    428  1.1  chopps 	int         use;
    429  1.1  chopps {
    430  1.1  chopps 	if (use) {
    431  1.1  chopps 		/* check to see if its the view's colormap, if so just do
    432  1.1  chopps 		 * update. */
    433  1.1  chopps 		if (vcm != cm) {
    434  1.1  chopps 			if (cm->first >= vcm->size || (cm->first + cm->size) > (cm->first + vcm->size) ||
    435  1.1  chopps 			    cm->type != vcm->type) {
    436  1.1  chopps 				return (0);
    437  1.1  chopps 			}
    438  1.1  chopps 			switch (vcm->type) {
    439  1.1  chopps 			case CM_COLOR:
    440  1.1  chopps 				if (cm->red_mask != vcm->red_mask ||
    441  1.1  chopps 				    cm->green_mask != vcm->green_mask ||
    442  1.1  chopps 				    cm->blue_mask != vcm->blue_mask) {
    443  1.1  chopps 					return (0);
    444  1.1  chopps 				}
    445  1.1  chopps 				break;
    446  1.1  chopps 			case CM_GREYSCALE:
    447  1.1  chopps 				if (cm->grey_mask != vcm->grey_mask) {
    448  1.1  chopps 					return (0);
    449  1.1  chopps 				}
    450  1.1  chopps 				break;
    451  1.1  chopps 			}
    452  1.1  chopps 		}
    453  1.1  chopps 	} else {
    454  1.1  chopps 		if (cm->first >= vcm->size || (cm->first + cm->size) > (cm->first + vcm->size)) {
    455  1.1  chopps 			return (0);
    456  1.1  chopps 		}
    457  1.1  chopps 	}
    458  1.1  chopps 	return (1);
    459  1.1  chopps }
    460  1.1  chopps /* does sanity check on values */
    461  1.1  chopps int
    462  1.1  chopps cc_get_colormap(v, cm)
    463  1.1  chopps 	view_t *v;
    464  1.1  chopps 	colormap_t *cm;
    465  1.1  chopps {
    466  1.1  chopps 	colormap_t *vcm = VDATA(v)->colormap;
    467  1.1  chopps 	int     i;
    468  1.1  chopps 
    469  1.1  chopps 	if (!cc_colormap_checkvals(vcm, cm, 0)) {
    470  1.1  chopps 		return (EINVAL);
    471  1.1  chopps 	}
    472  1.1  chopps 	cm->type = vcm->type;
    473  1.1  chopps 
    474  1.1  chopps 	switch (vcm->type) {
    475  1.1  chopps 	case CM_COLOR:
    476  1.1  chopps 		cm->red_mask = vcm->red_mask;
    477  1.1  chopps 		cm->green_mask = vcm->green_mask;
    478  1.1  chopps 		cm->blue_mask = vcm->blue_mask;
    479  1.1  chopps 		break;
    480  1.1  chopps 	case CM_GREYSCALE:
    481  1.1  chopps 		cm->grey_mask = vcm->grey_mask;
    482  1.1  chopps 		break;
    483  1.1  chopps 	}
    484  1.1  chopps 
    485  1.1  chopps 	/* copy entries into colormap. */
    486  1.1  chopps 	for (i = cm->first; i < (cm->first + cm->size); i++) {
    487  1.1  chopps 		cm->entry[i] = vcm->entry[i];
    488  1.1  chopps 	}
    489  1.1  chopps 	return (0);
    490  1.1  chopps }
    491  1.1  chopps 
    492  1.1  chopps /* does sanity check on values */
    493  1.1  chopps int
    494  1.1  chopps cc_use_colormap(v, cm)
    495  1.1  chopps 	view_t *v;
    496  1.1  chopps 	colormap_t *cm;
    497  1.1  chopps {
    498  1.1  chopps 	colormap_t *vcm = VDATA(v)->colormap;
    499  1.1  chopps 	int     s, i;
    500  1.1  chopps 
    501  1.1  chopps 	if (!cc_colormap_checkvals(vcm, cm, 1)) {
    502  1.1  chopps 		return (EINVAL);
    503  1.1  chopps 	}
    504  1.1  chopps 	/* check to see if its the view's colormap, if so just do update. */
    505  1.1  chopps 	if (vcm != cm) {
    506  1.1  chopps 		/* copy entries into colormap. */
    507  1.1  chopps 		for (i = cm->first; i < (cm->first + cm->size); i++) {
    508  1.1  chopps 			vcm->entry[i] = cm->entry[i];
    509  1.1  chopps 		}
    510  1.1  chopps 	}
    511  1.1  chopps 	s = spltty();
    512  1.1  chopps 
    513  1.1  chopps 	/* is view currently being displayed? */
    514  1.1  chopps 	if (VDATA(v)->flags & VF_DISPLAY) {
    515  1.1  chopps 		/* yes, update the copper lists */
    516  1.1  chopps 		cop_t  *tmp, *cp;
    517  1.1  chopps 		int     nframes = 1, j;
    518  1.1  chopps 
    519  1.1  chopps 		if (DMDATA(VDATA(v)->mode)->flags & DMF_INTERLACE) {
    520  1.1  chopps 			nframes = 2;
    521  1.1  chopps 		}
    522  1.1  chopps 		for (i = 0; i < nframes; i++) {
    523  1.1  chopps 			cp = DMDATA(VDATA(v)->mode)->frames[i];
    524  1.1  chopps 
    525  1.1  chopps 			tmp = find_copper_inst(cp, CI_MOVE(R_COLOR07));
    526  1.1  chopps 			tmp -= 7;
    527  1.1  chopps 
    528  1.1  chopps 			for (j = 0; j < 16; j++) {
    529  1.1  chopps 				CMOVE(tmp, R_COLOR00 + (j << 1), CM_LTOW(vcm->entry[j]));
    530  1.1  chopps 			}
    531  1.1  chopps 		}
    532  1.1  chopps 	}
    533  1.1  chopps 	splx(s);
    534  1.1  chopps 	return (0);
    535  1.1  chopps }
    536  1.1  chopps #if defined (GRF_A2024)
    537  1.1  chopps colormap_t *
    538  1.1  chopps cc_a2024_alloc_colormap(depth)
    539  1.1  chopps 	int depth;
    540  1.1  chopps {
    541  1.1  chopps 	u_long  size = 1U << depth, i;
    542  1.1  chopps 	colormap_t *cm = alloc_chipmem(sizeof(u_long) * size + sizeof(*cm));
    543  1.1  chopps 
    544  1.1  chopps 	if (cm) {
    545  1.1  chopps 		cm->type = CM_GREYSCALE;
    546  1.1  chopps 		cm->grey_mask = 0x03;
    547  1.1  chopps 		cm->first = 0;
    548  1.1  chopps 		cm->size = size;
    549  1.1  chopps 		cm->entry = (u_long *) & cm[1];	/* table directly after. */
    550  1.1  chopps 		for (i = 0; i < size; i++) {
    551  1.1  chopps 			cm->entry[i] = CM_WTOL(cc_a2024_default_colors[i]);
    552  1.1  chopps 		}
    553  1.1  chopps 		return (cm);
    554  1.1  chopps 	}
    555  1.1  chopps 	return (NULL);
    556  1.1  chopps }
    557  1.1  chopps 
    558  1.1  chopps int
    559  1.1  chopps cc_a2024_get_colormap(v, cm)
    560  1.1  chopps 	view_t *v;
    561  1.1  chopps 	colormap_t *cm;
    562  1.1  chopps {
    563  1.1  chopps 	/* there are no differences (yet) in the way the cm's are stored */
    564  1.1  chopps 	return (cc_get_colormap(v, cm));
    565  1.1  chopps }
    566  1.1  chopps 
    567  1.1  chopps int
    568  1.1  chopps cc_a2024_use_colormap(v, cm)
    569  1.1  chopps 	view_t *v;
    570  1.1  chopps 	colormap_t *cm;
    571  1.1  chopps {
    572  1.1  chopps 	colormap_t *vcm = VDATA(v)->colormap;
    573  1.1  chopps 	int     s, i;
    574  1.1  chopps 
    575  1.1  chopps 	if (!cc_colormap_checkvals(vcm, cm, 1)) {
    576  1.1  chopps 		return (EINVAL);
    577  1.1  chopps 	}
    578  1.1  chopps 	/* check to see if its the view's colormap, if so just do update. */
    579  1.1  chopps 	if (vcm != cm) {
    580  1.1  chopps 		/* copy entries into colormap. */
    581  1.1  chopps 		for (i = cm->first; i < (cm->first + cm->size); i++) {
    582  1.1  chopps 			vcm->entry[i] = cm->entry[i];
    583  1.1  chopps 		}
    584  1.1  chopps 	}
    585  1.1  chopps 	s = spltty();
    586  1.1  chopps 
    587  1.1  chopps 	/* is view currently being displayed? */
    588  1.1  chopps 	if (VDATA(v)->flags & VF_DISPLAY) {
    589  1.1  chopps 		/* yes, update the copper lists */
    590  1.1  chopps 		cop_t  *tmp, *cp;
    591  1.1  chopps 		int     nframes = 2, nregs = cm->size == 4 ? 16 : 8, j;
    592  1.1  chopps 
    593  1.1  chopps 		if (DMDATA(VDATA(v)->mode)->flags & DMF_HEDLEY_EXP) {
    594  1.1  chopps 			nframes = 4;
    595  1.1  chopps 		}
    596  1.1  chopps 		for (i = 0; i < nframes; i++) {
    597  1.1  chopps 			cp = DMDATA(VDATA(v)->mode)->frames[i];
    598  1.1  chopps 
    599  1.1  chopps 			tmp = find_copper_inst(cp, CI_MOVE(R_COLOR07));
    600  1.1  chopps 			tmp -= 7;
    601  1.1  chopps 
    602  1.1  chopps 			for (j = 0; j < nregs; j++) {
    603  1.1  chopps 				CMOVE(tmp, R_COLOR00 + (j << 1), A2024_CM_TO_CR(vcm, j));
    604  1.1  chopps 			}
    605  1.1  chopps 		}
    606  1.1  chopps 	}
    607  1.1  chopps 	splx(s);
    608  1.1  chopps 	return (0);
    609  1.1  chopps }
    610  1.1  chopps #endif /* GRF_A2024 */
    611  1.1  chopps 
    612  1.1  chopps 
    613  1.1  chopps /*
    614  1.1  chopps  * CC View stuff.
    615  1.1  chopps  */
    616  1.1  chopps 
    617  1.1  chopps void
    618  1.1  chopps cc_init_view(v, bm, mode, dbox)
    619  1.1  chopps 	view_t *v;
    620  1.1  chopps 	bmap_t *bm;
    621  1.1  chopps 	dmode_t *mode;
    622  1.1  chopps 	box_t *dbox;
    623  1.1  chopps {
    624  1.1  chopps 	vdata_t *vd = VDATA(v);
    625  1.1  chopps 	v->bitmap = bm;
    626  1.1  chopps 	vd->mode = mode;
    627  1.1  chopps 	bcopy(dbox, &v->display, sizeof(box_t));
    628  1.1  chopps 
    629  1.1  chopps 	v->display_view = DMDATA(vd->mode)->display_view;
    630  1.1  chopps 	v->use_colormap = DMDATA(vd->mode)->use_colormap;
    631  1.1  chopps 	v->get_colormap = DMDATA(vd->mode)->get_colormap;
    632  1.1  chopps 	v->free_view = cc_free_view;
    633  1.1  chopps 	v->get_display_mode = cc_get_display_mode;
    634  1.1  chopps 	v->remove_view = cc_remove_view;
    635  1.1  chopps }
    636  1.1  chopps 
    637  1.1  chopps void
    638  1.1  chopps cc_free_view(v)
    639  1.1  chopps 	view_t *v;
    640  1.1  chopps {
    641  1.1  chopps 	if (v) {
    642  1.1  chopps 		vdata_t *vd = VDATA(v);
    643  1.1  chopps 		dmode_t *md = vd->mode;
    644  1.1  chopps 		v->remove_view(v);
    645  1.1  chopps 		cc_monitor->free_bitmap(v->bitmap);
    646  1.1  chopps 		free_chipmem(v);
    647  1.1  chopps 	}
    648  1.1  chopps }
    649  1.1  chopps 
    650  1.1  chopps void
    651  1.1  chopps cc_remove_view(v)
    652  1.1  chopps 	view_t *v;
    653  1.1  chopps {
    654  1.1  chopps 	dmode_t *mode = VDATA(v)->mode;
    655  1.1  chopps 
    656  1.1  chopps 	if (MDATA(cc_monitor)->current_mode == mode) {
    657  1.1  chopps 		if (DMDATA(mode)->current_view == v) {
    658  1.1  chopps 			cc_load_mode(NULL);
    659  1.1  chopps 		}
    660  1.1  chopps 	}
    661  1.1  chopps 	if (DMDATA(mode)->current_view == v) {
    662  1.1  chopps 		DMDATA(mode)->current_view = NULL;
    663  1.1  chopps 	}
    664  1.1  chopps 	VDATA(v)->flags &= ~VF_DISPLAY;
    665  1.1  chopps }
    666  1.1  chopps 
    667  1.1  chopps dmode_t *
    668  1.1  chopps cc_get_display_mode(v)
    669  1.1  chopps 	view_t *v;
    670  1.1  chopps {
    671  1.1  chopps 	return (VDATA(v)->mode);
    672  1.1  chopps }
    673  1.1  chopps 
    674  1.1  chopps void
    675  1.1  chopps cc_mode_vbl_handler(d)
    676  1.1  chopps 	dmode_t *d;
    677  1.1  chopps {
    678  1.1  chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
    679  1.1  chopps 
    680  1.1  chopps 	if (vp < 12) {
    681  1.1  chopps 		custom.cop1lc = PREP_DMA_MEM(h_this_data->frames[F_LONG]);
    682  1.1  chopps 		custom.copjmp1 = 0;
    683  1.1  chopps 	}
    684  1.1  chopps }
    685  1.1  chopps 
    686  1.1  chopps void
    687  1.1  chopps cc_lace_mode_vbl_handler(d)
    688  1.1  chopps 	dmode_t *d;
    689  1.1  chopps {
    690  1.1  chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
    691  1.1  chopps 
    692  1.1  chopps 	if (vp < 12) {
    693  1.1  chopps 		if (custom.vposr & 0x8000) {
    694  1.1  chopps 			custom.cop1lc = PREP_DMA_MEM(DMDATA(d)->frames[F_LACE_LONG]);
    695  1.1  chopps 		} else {
    696  1.1  chopps 			custom.cop1lc = PREP_DMA_MEM(DMDATA(d)->frames[F_LACE_SHORT]);
    697  1.1  chopps 		}
    698  1.1  chopps 		custom.copjmp1 = 0;
    699  1.1  chopps 	}
    700  1.1  chopps }
    701  1.1  chopps 
    702  1.1  chopps /*
    703  1.1  chopps  * Modes. (ick)
    704  1.1  chopps  */
    705  1.1  chopps 
    706  1.1  chopps /*
    707  1.1  chopps  * NTSC Modes
    708  1.1  chopps  */
    709  1.1  chopps 
    710  1.1  chopps #if defined (GRF_NTSC)
    711  1.1  chopps 
    712  1.1  chopps dmode_t *
    713  1.1  chopps cc_init_ntsc_hires()
    714  1.1  chopps {
    715  1.1  chopps 	/* h_this function should only be called once. */
    716  1.1  chopps 	if (!h_this) {
    717  1.1  chopps 		u_short len = std_copper_list_len;
    718  1.1  chopps 		cop_t  *cp;
    719  1.1  chopps 
    720  1.1  chopps 		h_this = &hires_mode;
    721  1.1  chopps 		h_this_data = &hires_mode_data;
    722  1.1  chopps 		bzero(h_this, sizeof(dmode_t));
    723  1.1  chopps 		bzero(h_this_data, sizeof(dmdata_t));
    724  1.1  chopps 
    725  1.1  chopps 		h_this->name = "ntsc: hires interlace";
    726  1.1  chopps 		h_this->nominal_size.width = 640;
    727  1.1  chopps 		h_this->nominal_size.height = 200;
    728  1.1  chopps 		h_this_data->max_size.width = 724;
    729  1.1  chopps 		h_this_data->max_size.height = 242;
    730  1.1  chopps 		h_this_data->min_size.width = 320;
    731  1.1  chopps 		h_this_data->min_size.height = 100;
    732  1.1  chopps 		h_this_data->min_depth = 1;
    733  1.1  chopps 		h_this_data->max_depth = 4;
    734  1.1  chopps 		h_this->data = h_this_data;
    735  1.1  chopps 
    736  1.1  chopps 		h_this->get_monitor = cc_get_monitor;
    737  1.1  chopps 		h_this->alloc_view = cc_alloc_view;
    738  1.1  chopps 		h_this->get_current_view = cc_get_current_view;
    739  1.1  chopps 
    740  1.1  chopps 		h_this_data->use_colormap = cc_use_colormap;
    741  1.1  chopps 		h_this_data->get_colormap = cc_get_colormap;
    742  1.1  chopps 		h_this_data->alloc_colormap = cc_alloc_colormap;
    743  1.1  chopps 		h_this_data->display_view = display_hires_view;
    744  1.1  chopps 		h_this_data->monitor = cc_monitor;
    745  1.1  chopps 
    746  1.1  chopps 		h_this_data->frames = hires_frames;
    747  1.1  chopps 		h_this_data->frames[F_LONG] = alloc_chipmem(std_copper_list_size * F_TOTAL);
    748  1.1  chopps 		if (!h_this_data->frames[F_LONG]) {
    749  1.1  chopps 			panic("couldn't get chipmem for copper list");
    750  1.1  chopps 		}
    751  1.1  chopps 		h_this_data->frames[F_STORE_LONG] = &h_this_data->frames[F_LONG][len];
    752  1.1  chopps 
    753  1.1  chopps 		bcopy(std_copper_list, h_this_data->frames[F_STORE_LONG], std_copper_list_size);
    754  1.1  chopps 		bcopy(std_copper_list, h_this_data->frames[F_LONG], std_copper_list_size);
    755  1.1  chopps 
    756  1.1  chopps 		h_this_data->bplcon0 = 0x8200 | USE_CON3;	/* hires, color
    757  1.1  chopps 								 * composite enable,
    758  1.1  chopps 								 * lace. */
    759  1.1  chopps 		h_this_data->std_start_x = STANDARD_VIEW_X;
    760  1.1  chopps 		h_this_data->std_start_y = STANDARD_VIEW_Y;
    761  1.1  chopps 		h_this_data->vbl_handler = (vbl_handler_func *) cc_mode_vbl_handler;
    762  1.1  chopps #if defined (GRF_ECS)
    763  1.1  chopps 		h_this_data->beamcon0 = STANDARD_NTSC_BEAMCON;
    764  1.1  chopps #endif
    765  1.1  chopps 
    766  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &h_this->node);
    767  1.1  chopps 	}
    768  1.1  chopps 	return (h_this);
    769  1.1  chopps }
    770  1.1  chopps 
    771  1.1  chopps void
    772  1.1  chopps display_hires_view(v)
    773  1.1  chopps 	view_t *v;
    774  1.1  chopps {
    775  1.1  chopps 	if (h_this_data->current_view != v) {
    776  1.1  chopps 		vdata_t *vd = VDATA(v);
    777  1.1  chopps 		monitor_t *monitor = h_this_data->monitor;
    778  1.1  chopps 		cop_t  *cp = h_this_data->frames[F_STORE_LONG], *tmp;
    779  1.1  chopps 		int     depth = v->bitmap->depth, i;
    780  1.1  chopps 		int     hstart, hstop, vstart, vstop, j;
    781  1.1  chopps 		int     x, y, w = v->display.width, h = v->display.height;
    782  1.1  chopps 		u_short ddfstart, ddfwidth, con1;
    783  1.1  chopps 
    784  1.1  chopps 		/* round down to nearest even width */
    785  1.1  chopps 		/* w &= 0xfffe; */
    786  1.1  chopps 
    787  1.1  chopps 
    788  1.1  chopps 		/* calculate datafetch width. */
    789  1.1  chopps 
    790  1.1  chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
    791  1.1  chopps 
    792  1.1  chopps 		/* H_This will center the any overscanned display */
    793  1.1  chopps 		/* and allow user to modify. */
    794  1.1  chopps 		x = v->display.x + h_this_data->std_start_x - ((w - 640) >> 2);
    795  1.1  chopps 		y = v->display.y + h_this_data->std_start_y - ((h - 200) >> 1);
    796  1.1  chopps 
    797  1.1  chopps 		if (y & 1)
    798  1.1  chopps 			y--;
    799  1.1  chopps 
    800  1.1  chopps 		if (!(x & 1))
    801  1.1  chopps 			x--;
    802  1.1  chopps 
    803  1.1  chopps 		hstart = x;
    804  1.1  chopps 		hstop = x + (w >> 1);
    805  1.1  chopps 		vstart = y;
    806  1.1  chopps 		vstop = y + h;
    807  1.1  chopps 		ddfstart = (hstart - 9) >> 1;
    808  1.1  chopps 
    809  1.1  chopps 		/* check for hardware limits, AGA may allow more..? */
    810  1.1  chopps 		/* anyone got a 4000 I can borrow :^) -ch */
    811  1.1  chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
    812  1.1  chopps 			int     d = 0;
    813  1.1  chopps 
    814  1.1  chopps 			/* XXX anyone know the equality properties of
    815  1.1  chopps 			 * intermixed logial AND's */
    816  1.1  chopps 			/* XXX and arithmetic operators? */
    817  1.1  chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
    818  1.1  chopps 				d++;
    819  1.1  chopps 			}
    820  1.1  chopps 
    821  1.1  chopps 			ddfstart -= d;
    822  1.1  chopps 			hstart -= d << 1;
    823  1.1  chopps 			hstop -= d << 1;
    824  1.1  chopps 		}
    825  1.1  chopps 		/* correct the datafetch to proper limits. */
    826  1.1  chopps 		/* delay the actual display of the data until we need it. */
    827  1.1  chopps 		ddfstart &= 0xfffc;
    828  1.1  chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
    829  1.1  chopps 
    830  1.1  chopps 		if (h_this_data->current_view) {
    831  1.1  chopps 			VDATA(h_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
    832  1.1  chopps 			/* displayed. */
    833  1.1  chopps 		}
    834  1.1  chopps 		h_this_data->current_view = v;
    835  1.1  chopps 
    836  1.1  chopps 		cp = h_this_data->frames[F_STORE_LONG];
    837  1.1  chopps #if defined GRF_ECS
    838  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
    839  1.1  chopps 		tmp->cp.inst.operand = h_this_data->beamcon0;
    840  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
    841  1.1  chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
    842  1.1  chopps #endif /* ECS */
    843  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
    844  1.1  chopps 		tmp->cp.inst.operand = h_this_data->bplcon0 | ((depth & 0x7) << 12);
    845  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
    846  1.1  chopps 		tmp->cp.inst.operand = con1;
    847  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
    848  1.1  chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
    849  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
    850  1.1  chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
    851  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
    852  1.1  chopps 		tmp->cp.inst.operand = ddfstart;
    853  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
    854  1.1  chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
    855  1.1  chopps 
    856  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
    857  1.1  chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
    858  1.1  chopps 			/* update the plane pointers */
    859  1.1  chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
    860  1.1  chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
    861  1.1  chopps 		}
    862  1.1  chopps 
    863  1.1  chopps 		/* set mods correctly. */
    864  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
    865  1.1  chopps 		tmp[0].cp.inst.operand = v->bitmap->row_mod;
    866  1.1  chopps 		tmp[1].cp.inst.operand = v->bitmap->row_mod;
    867  1.1  chopps 
    868  1.1  chopps 		/* set next pointers correctly */
    869  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
    870  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(h_this_data->frames[F_STORE_LONG]));
    871  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(h_this_data->frames[F_STORE_LONG]));
    872  1.1  chopps 
    873  1.1  chopps 		cp = h_this_data->frames[F_LONG];
    874  1.1  chopps 		h_this_data->frames[F_LONG] = h_this_data->frames[F_STORE_LONG];
    875  1.1  chopps 		h_this_data->frames[F_STORE_LONG] = cp;
    876  1.1  chopps 
    877  1.1  chopps 		vd->flags |= VF_DISPLAY;
    878  1.1  chopps 
    879  1.1  chopps 		cc_use_colormap(v, vd->colormap);
    880  1.1  chopps 	}
    881  1.1  chopps 	cc_load_mode(h_this);
    882  1.1  chopps }
    883  1.1  chopps 
    884  1.1  chopps dmode_t *
    885  1.1  chopps cc_init_ntsc_hires_lace()
    886  1.1  chopps {
    887  1.1  chopps 	/* hl_this function should only be called once. */
    888  1.1  chopps 	if (!hl_this) {
    889  1.1  chopps 		u_short len = std_copper_list_len;
    890  1.1  chopps 		cop_t  *cp;
    891  1.1  chopps 
    892  1.1  chopps 		hl_this = &hires_lace_mode;
    893  1.1  chopps 		hl_this_data = &hires_lace_mode_data;
    894  1.1  chopps 		bzero(hl_this, sizeof(dmode_t));
    895  1.1  chopps 		bzero(hl_this_data, sizeof(dmdata_t));
    896  1.1  chopps 
    897  1.1  chopps 		hl_this->name = "ntsc: hires interlace";
    898  1.1  chopps 		hl_this->nominal_size.width = 640;
    899  1.1  chopps 		hl_this->nominal_size.height = 400;
    900  1.1  chopps 		hl_this_data->max_size.width = 724;
    901  1.1  chopps 		hl_this_data->max_size.height = 482;
    902  1.1  chopps 		hl_this_data->min_size.width = 320;
    903  1.1  chopps 		hl_this_data->min_size.height = 200;
    904  1.1  chopps 		hl_this_data->min_depth = 1;
    905  1.1  chopps 		hl_this_data->max_depth = 4;
    906  1.1  chopps 		hl_this->data = hl_this_data;
    907  1.1  chopps 
    908  1.1  chopps 		hl_this->get_monitor = cc_get_monitor;
    909  1.1  chopps 		hl_this->alloc_view = cc_alloc_view;
    910  1.1  chopps 		hl_this->get_current_view = cc_get_current_view;
    911  1.1  chopps 
    912  1.1  chopps 		hl_this_data->use_colormap = cc_use_colormap;
    913  1.1  chopps 		hl_this_data->get_colormap = cc_get_colormap;
    914  1.1  chopps 		hl_this_data->alloc_colormap = cc_alloc_colormap;
    915  1.1  chopps 		hl_this_data->display_view = display_hires_lace_view;
    916  1.1  chopps 		hl_this_data->monitor = cc_monitor;
    917  1.1  chopps 
    918  1.1  chopps 		hl_this_data->flags |= DMF_INTERLACE;
    919  1.1  chopps 
    920  1.1  chopps 		hl_this_data->frames = hires_lace_frames;
    921  1.1  chopps 		hl_this_data->frames[F_LACE_LONG] = alloc_chipmem(std_copper_list_size * F_LACE_TOTAL);
    922  1.1  chopps 		if (!hl_this_data->frames[F_LACE_LONG]) {
    923  1.1  chopps 			panic("couldn't get chipmem for copper list");
    924  1.1  chopps 		}
    925  1.1  chopps 		hl_this_data->frames[F_LACE_SHORT] = &hl_this_data->frames[F_LACE_LONG][len];
    926  1.1  chopps 		hl_this_data->frames[F_LACE_STORE_LONG] = &hl_this_data->frames[F_LACE_SHORT][len];
    927  1.1  chopps 		hl_this_data->frames[F_LACE_STORE_SHORT] = &hl_this_data->frames[F_LACE_STORE_LONG][len];
    928  1.1  chopps 
    929  1.1  chopps 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_STORE_LONG], std_copper_list_size);
    930  1.1  chopps 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_STORE_SHORT], std_copper_list_size);
    931  1.1  chopps 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_LONG], std_copper_list_size);
    932  1.1  chopps 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_SHORT], std_copper_list_size);
    933  1.1  chopps 
    934  1.1  chopps 		hl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
    935  1.1  chopps 								 * composite enable,
    936  1.1  chopps 								 * lace. */
    937  1.1  chopps 		hl_this_data->std_start_x = STANDARD_VIEW_X;
    938  1.1  chopps 		hl_this_data->std_start_y = STANDARD_VIEW_Y;
    939  1.1  chopps 		hl_this_data->vbl_handler = (vbl_handler_func *) cc_lace_mode_vbl_handler;
    940  1.1  chopps #if defined (GRF_ECS)
    941  1.1  chopps 		hl_this_data->beamcon0 = STANDARD_NTSC_BEAMCON;
    942  1.1  chopps #endif
    943  1.1  chopps 
    944  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &hl_this->node);
    945  1.1  chopps 	}
    946  1.1  chopps 	return (hl_this);
    947  1.1  chopps }
    948  1.1  chopps 
    949  1.1  chopps void
    950  1.1  chopps display_hires_lace_view(v)
    951  1.1  chopps 	view_t *v;
    952  1.1  chopps {
    953  1.1  chopps 	if (hl_this_data->current_view != v) {
    954  1.1  chopps 		vdata_t *vd = VDATA(v);
    955  1.1  chopps 		monitor_t *monitor = hl_this_data->monitor;
    956  1.1  chopps 		cop_t  *cp = hl_this_data->frames[F_LACE_STORE_LONG], *tmp;
    957  1.1  chopps 		int     depth = v->bitmap->depth, i;
    958  1.1  chopps 		int     hstart, hstop, vstart, vstop, j;
    959  1.1  chopps 		int     x, y, w = v->display.width, h = v->display.height;
    960  1.1  chopps 		u_short ddfstart, ddfwidth, con1;
    961  1.1  chopps 
    962  1.1  chopps 		/* round down to nearest even width */
    963  1.1  chopps 		/* w &= 0xfffe; */
    964  1.1  chopps 
    965  1.1  chopps 
    966  1.1  chopps 		/* calculate datafetch width. */
    967  1.1  chopps 
    968  1.1  chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
    969  1.1  chopps 
    970  1.1  chopps 		/* Hl_This will center the any overscanned display */
    971  1.1  chopps 		/* and allow user to modify. */
    972  1.1  chopps 		x = v->display.x + hl_this_data->std_start_x - ((w - 640) >> 2);
    973  1.1  chopps 		y = v->display.y + hl_this_data->std_start_y - ((h - 400) >> 2);
    974  1.1  chopps 
    975  1.1  chopps 		if (y & 1)
    976  1.1  chopps 			y--;
    977  1.1  chopps 
    978  1.1  chopps 		if (!(x & 1))
    979  1.1  chopps 			x--;
    980  1.1  chopps 
    981  1.1  chopps 		hstart = x;
    982  1.1  chopps 		hstop = x + (w >> 1);
    983  1.1  chopps 		vstart = y;
    984  1.1  chopps 		vstop = y + (h >> 1);
    985  1.1  chopps 		ddfstart = (hstart - 9) >> 1;
    986  1.1  chopps 
    987  1.1  chopps 		/* check for hardware limits, AGA may allow more..? */
    988  1.1  chopps 		/* anyone got a 4000 I can borrow :^) -ch */
    989  1.1  chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
    990  1.1  chopps 			int     d = 0;
    991  1.1  chopps 
    992  1.1  chopps 			/* XXX anyone know the equality properties of
    993  1.1  chopps 			 * intermixed logial AND's */
    994  1.1  chopps 			/* XXX and arithmetic operators? */
    995  1.1  chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
    996  1.1  chopps 				d++;
    997  1.1  chopps 			}
    998  1.1  chopps 
    999  1.1  chopps 			ddfstart -= d;
   1000  1.1  chopps 			hstart -= d << 1;
   1001  1.1  chopps 			hstop -= d << 1;
   1002  1.1  chopps 		}
   1003  1.1  chopps 		/* correct the datafetch to proper limits. */
   1004  1.1  chopps 		/* delay the actual display of the data until we need it. */
   1005  1.1  chopps 		ddfstart &= 0xfffc;
   1006  1.1  chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   1007  1.1  chopps 
   1008  1.1  chopps 		if (hl_this_data->current_view) {
   1009  1.1  chopps 			VDATA(hl_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   1010  1.1  chopps 			/* displayed. */
   1011  1.1  chopps 		}
   1012  1.1  chopps 		hl_this_data->current_view = v;
   1013  1.1  chopps 
   1014  1.1  chopps 		cp = hl_this_data->frames[F_LACE_STORE_LONG];
   1015  1.1  chopps #if defined GRF_ECS
   1016  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   1017  1.1  chopps 		tmp->cp.inst.operand = hl_this_data->beamcon0;
   1018  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   1019  1.1  chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   1020  1.1  chopps #endif /* ECS */
   1021  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   1022  1.1  chopps 		tmp->cp.inst.operand = hl_this_data->bplcon0 | ((depth & 0x7) << 12);
   1023  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   1024  1.1  chopps 		tmp->cp.inst.operand = con1;
   1025  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   1026  1.1  chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   1027  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   1028  1.1  chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   1029  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   1030  1.1  chopps 		tmp->cp.inst.operand = ddfstart;
   1031  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   1032  1.1  chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   1033  1.1  chopps 
   1034  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1035  1.1  chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   1036  1.1  chopps 			/* update the plane pointers */
   1037  1.1  chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1038  1.1  chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1039  1.1  chopps 		}
   1040  1.1  chopps 
   1041  1.1  chopps 		/* set mods correctly. */
   1042  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   1043  1.1  chopps 		tmp[0].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1044  1.1  chopps 		tmp[1].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1045  1.1  chopps 
   1046  1.1  chopps 		/* set next pointers correctly */
   1047  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1048  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_SHORT]));
   1049  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_SHORT]));
   1050  1.1  chopps 
   1051  1.1  chopps 
   1052  1.1  chopps 		bcopy(hl_this_data->frames[F_LACE_STORE_LONG], hl_this_data->frames[F_LACE_STORE_SHORT], std_copper_list_size);
   1053  1.1  chopps 
   1054  1.1  chopps 		/* these are the only ones that are different from long frame. */
   1055  1.1  chopps 		cp = hl_this_data->frames[F_LACE_STORE_SHORT];
   1056  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1057  1.1  chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   1058  1.1  chopps 			u_short mod = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1059  1.1  chopps 			/* update plane pointers. high and low. */
   1060  1.1  chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   1061  1.1  chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   1062  1.1  chopps 		}
   1063  1.1  chopps 
   1064  1.1  chopps 		/* set next pointers correctly */
   1065  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1066  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_LONG]));
   1067  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_LONG]));
   1068  1.1  chopps 
   1069  1.1  chopps 
   1070  1.1  chopps 		cp = hl_this_data->frames[F_LACE_LONG];
   1071  1.1  chopps 		hl_this_data->frames[F_LACE_LONG] = hl_this_data->frames[F_LACE_STORE_LONG];
   1072  1.1  chopps 		hl_this_data->frames[F_LACE_STORE_LONG] = cp;
   1073  1.1  chopps 
   1074  1.1  chopps 		cp = hl_this_data->frames[F_LACE_SHORT];
   1075  1.1  chopps 		hl_this_data->frames[F_LACE_SHORT] = hl_this_data->frames[F_LACE_STORE_SHORT];
   1076  1.1  chopps 		hl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   1077  1.1  chopps 
   1078  1.1  chopps 		vd->flags |= VF_DISPLAY;
   1079  1.1  chopps 
   1080  1.1  chopps 		cc_use_colormap(v, vd->colormap);
   1081  1.1  chopps 	}
   1082  1.1  chopps 	cc_load_mode(hl_this);
   1083  1.1  chopps }
   1084  1.1  chopps #if defined (GRF_A2024)
   1085  1.1  chopps 
   1086  1.1  chopps dmode_t *
   1087  1.1  chopps cc_init_ntsc_hires_dlace()
   1088  1.1  chopps {
   1089  1.1  chopps 	/* hdl_this function should only be called once. */
   1090  1.1  chopps 	if (!hdl_this) {
   1091  1.1  chopps 		u_short len = std_dlace_copper_list_len;
   1092  1.1  chopps 		cop_t  *cp;
   1093  1.1  chopps 
   1094  1.1  chopps 		hdl_this = &hires_dlace_mode;
   1095  1.1  chopps 		hdl_this_data = &hires_dlace_mode_data;
   1096  1.1  chopps 		bzero(hdl_this, sizeof(dmode_t));
   1097  1.1  chopps 		bzero(hdl_this_data, sizeof(dmdata_t));
   1098  1.1  chopps 
   1099  1.1  chopps 		hdl_this->name = "ntsc: hires double interlace";
   1100  1.1  chopps 		hdl_this->nominal_size.width = 640;
   1101  1.1  chopps 		hdl_this->nominal_size.height = 800;
   1102  1.1  chopps 		hdl_this_data->max_size.width = 724;
   1103  1.1  chopps 		hdl_this_data->max_size.height = 800;
   1104  1.1  chopps 		hdl_this_data->min_size.width = 320;
   1105  1.1  chopps 		hdl_this_data->min_size.height = 400;
   1106  1.1  chopps 		hdl_this_data->min_depth = 1;
   1107  1.1  chopps 		hdl_this_data->max_depth = 2;
   1108  1.1  chopps 		hdl_this->data = hdl_this_data;
   1109  1.1  chopps 
   1110  1.1  chopps 		hdl_this->get_monitor = cc_get_monitor;
   1111  1.1  chopps 		hdl_this->alloc_view = cc_alloc_view;
   1112  1.1  chopps 		hdl_this->get_current_view = cc_get_current_view;
   1113  1.1  chopps 
   1114  1.1  chopps 		hdl_this_data->use_colormap = cc_a2024_use_colormap;
   1115  1.1  chopps 		hdl_this_data->get_colormap = cc_a2024_get_colormap;
   1116  1.1  chopps 		hdl_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   1117  1.1  chopps 		hdl_this_data->display_view = display_hires_dlace_view;
   1118  1.1  chopps 		hdl_this_data->monitor = cc_monitor;
   1119  1.1  chopps 
   1120  1.1  chopps 		hdl_this_data->flags |= DMF_INTERLACE;
   1121  1.1  chopps 
   1122  1.1  chopps 		hdl_this_data->frames = hires_dlace_frames;
   1123  1.1  chopps 		hdl_this_data->frames[F_LACE_LONG] = alloc_chipmem(std_dlace_copper_list_size * F_LACE_TOTAL);
   1124  1.1  chopps 		if (!hdl_this_data->frames[F_LACE_LONG]) {
   1125  1.1  chopps 			panic("couldn't get chipmem for copper list");
   1126  1.1  chopps 		}
   1127  1.1  chopps 		hdl_this_data->frames[F_LACE_SHORT] = &hdl_this_data->frames[F_LACE_LONG][len];
   1128  1.1  chopps 		hdl_this_data->frames[F_LACE_STORE_LONG] = &hdl_this_data->frames[F_LACE_SHORT][len];
   1129  1.1  chopps 		hdl_this_data->frames[F_LACE_STORE_SHORT] = &hdl_this_data->frames[F_LACE_STORE_LONG][len];
   1130  1.1  chopps 
   1131  1.1  chopps 		bcopy(std_dlace_copper_list, hdl_this_data->frames[F_LACE_STORE_LONG], std_dlace_copper_list_size);
   1132  1.1  chopps 		bcopy(std_dlace_copper_list, hdl_this_data->frames[F_LACE_STORE_SHORT], std_dlace_copper_list_size);
   1133  1.1  chopps 		bcopy(std_dlace_copper_list, hdl_this_data->frames[F_LACE_LONG], std_dlace_copper_list_size);
   1134  1.1  chopps 		bcopy(std_dlace_copper_list, hdl_this_data->frames[F_LACE_SHORT], std_dlace_copper_list_size);
   1135  1.1  chopps 
   1136  1.1  chopps 		hdl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
   1137  1.1  chopps 								 * composite enable,
   1138  1.1  chopps 								 * dlace. */
   1139  1.1  chopps 		hdl_this_data->std_start_x = STANDARD_VIEW_X;
   1140  1.1  chopps 		hdl_this_data->std_start_y = STANDARD_VIEW_Y;
   1141  1.1  chopps 		hdl_this_data->vbl_handler = (vbl_handler_func *) cc_lace_mode_vbl_handler;
   1142  1.1  chopps #if defined (GRF_ECS)
   1143  1.1  chopps 		hdl_this_data->beamcon0 = STANDARD_NTSC_BEAMCON;
   1144  1.1  chopps #endif
   1145  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &hdl_this->node);
   1146  1.1  chopps 	}
   1147  1.1  chopps 	return (hdl_this);
   1148  1.1  chopps }
   1149  1.1  chopps 
   1150  1.1  chopps void
   1151  1.1  chopps display_hires_dlace_view(v)
   1152  1.1  chopps 	view_t *v;
   1153  1.1  chopps {
   1154  1.1  chopps 	if (hdl_this_data->current_view != v) {
   1155  1.1  chopps 		vdata_t *vd = VDATA(v);
   1156  1.1  chopps 		monitor_t *monitor = hdl_this_data->monitor;
   1157  1.1  chopps 		cop_t  *cp = hdl_this_data->frames[F_LACE_STORE_LONG], *tmp;
   1158  1.1  chopps 		int     depth = v->bitmap->depth, i;
   1159  1.1  chopps 		int     hstart, hstop, vstart, vstop, j;
   1160  1.1  chopps 		int     x, y, w = v->display.width, h = v->display.height;
   1161  1.1  chopps 		u_short ddfstart, ddfwidth, con1;
   1162  1.1  chopps 		u_short mod1l, mod2l;
   1163  1.1  chopps 
   1164  1.1  chopps 		/* round down to nearest even width */
   1165  1.1  chopps 		/* w &= 0xfffe; */
   1166  1.1  chopps 
   1167  1.1  chopps 		/* calculate datafetch width. */
   1168  1.1  chopps 
   1169  1.1  chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   1170  1.1  chopps 
   1171  1.1  chopps 		/* Hdl_This will center the any overscanned display */
   1172  1.1  chopps 		/* and allow user to modify. */
   1173  1.1  chopps 		x = v->display.x + hdl_this_data->std_start_x - ((w - 640) >> 2);
   1174  1.1  chopps 		y = v->display.y + hdl_this_data->std_start_y - ((h - 800) >> 3);
   1175  1.1  chopps 
   1176  1.1  chopps 		if (y & 1)
   1177  1.1  chopps 			y--;
   1178  1.1  chopps 
   1179  1.1  chopps 		if (!(x & 1))
   1180  1.1  chopps 			x--;
   1181  1.1  chopps 
   1182  1.1  chopps 		hstart = x;
   1183  1.1  chopps 		hstop = x + (w >> 1);
   1184  1.1  chopps 		vstart = y;
   1185  1.1  chopps 		vstop = y + (h >> 2);
   1186  1.1  chopps 
   1187  1.1  chopps 		ddfstart = (hstart - 9) >> 1;
   1188  1.1  chopps 
   1189  1.1  chopps 		/* check for hardware limits, AGA may allow more..? */
   1190  1.1  chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   1191  1.1  chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   1192  1.1  chopps 			int     d = 0;
   1193  1.1  chopps 
   1194  1.1  chopps 			/* XXX anyone know the equality properties of
   1195  1.1  chopps 			 * intermixed logial AND's */
   1196  1.1  chopps 			/* XXX and arithmetic operators? */
   1197  1.1  chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   1198  1.1  chopps 				d++;
   1199  1.1  chopps 			}
   1200  1.1  chopps 
   1201  1.1  chopps 			ddfstart -= d;
   1202  1.1  chopps 			hstart -= d << 1;
   1203  1.1  chopps 			hstop -= d << 1;
   1204  1.1  chopps 		}
   1205  1.1  chopps 		/* correct the datafetch to proper limits. */
   1206  1.1  chopps 		/* delay the actual display of the data until we need it. */
   1207  1.1  chopps 		ddfstart &= 0xfffc;
   1208  1.1  chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   1209  1.1  chopps 
   1210  1.1  chopps 		if (hdl_this_data->current_view) {
   1211  1.1  chopps 			VDATA(hdl_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   1212  1.1  chopps 			/* displayed. */
   1213  1.1  chopps 		}
   1214  1.1  chopps 		hdl_this_data->current_view = v;
   1215  1.1  chopps 
   1216  1.1  chopps 		cp = hdl_this_data->frames[F_LACE_STORE_LONG];
   1217  1.1  chopps #if defined GRF_ECS
   1218  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   1219  1.1  chopps 		tmp->cp.inst.operand = hdl_this_data->beamcon0;
   1220  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   1221  1.1  chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   1222  1.1  chopps #endif /* ECS */
   1223  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   1224  1.1  chopps 		tmp->cp.inst.operand = hdl_this_data->bplcon0 | ((depth & 0x7) << 13);	/* times two. */
   1225  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   1226  1.1  chopps 		tmp->cp.inst.operand = con1;
   1227  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   1228  1.1  chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   1229  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   1230  1.1  chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   1231  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   1232  1.1  chopps 		tmp->cp.inst.operand = ddfstart;
   1233  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   1234  1.1  chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   1235  1.1  chopps 
   1236  1.1  chopps 		mod1l = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1237  1.1  chopps 		mod2l = mod1l << 1;
   1238  1.1  chopps 
   1239  1.1  chopps 		/* update plane pointers. */
   1240  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1241  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));
   1242  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));
   1243  1.1  chopps 		tmp[2].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));
   1244  1.1  chopps 		tmp[3].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));
   1245  1.1  chopps 		if (depth == 2) {
   1246  1.1  chopps 			tmp[4].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));
   1247  1.1  chopps 			tmp[5].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));
   1248  1.1  chopps 			tmp[6].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));
   1249  1.1  chopps 			tmp[7].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));
   1250  1.1  chopps 		}
   1251  1.1  chopps 		/* set modulos. */
   1252  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   1253  1.1  chopps 		tmp[0].cp.inst.operand = mod2l + mod1l;
   1254  1.1  chopps 		tmp[1].cp.inst.operand = mod2l + mod1l;
   1255  1.1  chopps 
   1256  1.1  chopps 
   1257  1.1  chopps 		/* set next coper list pointers */
   1258  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1259  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_SHORT]));
   1260  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_SHORT]));
   1261  1.1  chopps 
   1262  1.1  chopps 		bcopy(hdl_this_data->frames[F_LACE_STORE_LONG], hdl_this_data->frames[F_LACE_STORE_SHORT],
   1263  1.1  chopps 		    std_dlace_copper_list_size);
   1264  1.1  chopps 
   1265  1.1  chopps 		/* these are the only ones that are different from long frame. */
   1266  1.1  chopps 		cp = hdl_this_data->frames[F_LACE_STORE_SHORT];
   1267  1.1  chopps 		/* update plane pointers. */
   1268  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1269  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));
   1270  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));
   1271  1.1  chopps 		tmp[2].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));
   1272  1.1  chopps 		tmp[3].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));
   1273  1.1  chopps 		if (depth == 2) {
   1274  1.1  chopps 			tmp[4].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));
   1275  1.1  chopps 			tmp[5].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));
   1276  1.1  chopps 			tmp[6].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));
   1277  1.1  chopps 			tmp[7].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));
   1278  1.1  chopps 		}
   1279  1.1  chopps 		/* set next copper list pointers */
   1280  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1281  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_LONG]));
   1282  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_LONG]));
   1283  1.1  chopps 
   1284  1.1  chopps 		cp = hdl_this_data->frames[F_LACE_LONG];
   1285  1.1  chopps 		hdl_this_data->frames[F_LACE_LONG] = hdl_this_data->frames[F_LACE_STORE_LONG];
   1286  1.1  chopps 		hdl_this_data->frames[F_LACE_STORE_LONG] = cp;
   1287  1.1  chopps 
   1288  1.1  chopps 		cp = hdl_this_data->frames[F_LACE_SHORT];
   1289  1.1  chopps 		hdl_this_data->frames[F_LACE_SHORT] = hdl_this_data->frames[F_LACE_STORE_SHORT];
   1290  1.1  chopps 		hdl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   1291  1.1  chopps 
   1292  1.1  chopps 		vd->flags |= VF_DISPLAY;
   1293  1.1  chopps 		cc_a2024_use_colormap(v, vd->colormap);
   1294  1.1  chopps 	}
   1295  1.1  chopps 	cc_load_mode(hdl_this);
   1296  1.1  chopps }
   1297  1.1  chopps 
   1298  1.1  chopps 
   1299  1.1  chopps dmode_t *
   1300  1.1  chopps cc_init_ntsc_a2024()
   1301  1.1  chopps {
   1302  1.1  chopps 	/* a24_this function should only be called once. */
   1303  1.1  chopps 	if (!a24_this) {
   1304  1.1  chopps 		int     i;
   1305  1.1  chopps 		u_short len = std_a2024_copper_list_len;
   1306  1.1  chopps 		cop_t  *cp;
   1307  1.1  chopps 
   1308  1.1  chopps 		a24_this = &a2024_mode;
   1309  1.1  chopps 		a24_this_data = &a2024_mode_data;
   1310  1.1  chopps 		bzero(a24_this, sizeof(dmode_t));
   1311  1.1  chopps 		bzero(a24_this_data, sizeof(dmdata_t));
   1312  1.1  chopps 
   1313  1.1  chopps 		a24_this->name = "ntsc: A2024 15khz";
   1314  1.1  chopps 		a24_this->nominal_size.width = 1024;
   1315  1.1  chopps 		a24_this->nominal_size.height = 800;
   1316  1.1  chopps 		a24_this_data->max_size.width = 1024;
   1317  1.1  chopps 		a24_this_data->max_size.height = 800;
   1318  1.1  chopps 		a24_this_data->min_size.width = 1024;
   1319  1.1  chopps 		a24_this_data->min_size.height = 800;
   1320  1.1  chopps 		a24_this_data->min_depth = 1;
   1321  1.1  chopps 		a24_this_data->max_depth = 2;
   1322  1.1  chopps 		a24_this->data = a24_this_data;
   1323  1.1  chopps 
   1324  1.1  chopps 		a24_this->get_monitor = cc_get_monitor;
   1325  1.1  chopps 		a24_this->alloc_view = cc_alloc_view;
   1326  1.1  chopps 		a24_this->get_current_view = cc_get_current_view;
   1327  1.1  chopps 
   1328  1.1  chopps 		a24_this_data->use_colormap = cc_a2024_use_colormap;
   1329  1.1  chopps 		a24_this_data->get_colormap = cc_a2024_get_colormap;
   1330  1.1  chopps 		a24_this_data->display_view = display_a2024_view;
   1331  1.1  chopps 		a24_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   1332  1.1  chopps 		a24_this_data->monitor = cc_monitor;
   1333  1.1  chopps 
   1334  1.1  chopps 		a24_this_data->flags |= DMF_HEDLEY_EXP;
   1335  1.1  chopps 
   1336  1.1  chopps 		a24_this_data->frames = a2024_frames;
   1337  1.1  chopps 		a24_this_data->frames[F_QD_QUAD0] = alloc_chipmem(std_a2024_copper_list_size * F_QD_TOTAL);
   1338  1.1  chopps 		if (!a24_this_data->frames[F_QD_QUAD0]) {
   1339  1.1  chopps 			panic("couldn't get chipmem for copper list");
   1340  1.1  chopps 		}
   1341  1.1  chopps 		/* setup the hedley init bitplane. */
   1342  1.1  chopps 		hedley_init = alloc_chipmem(128);
   1343  1.1  chopps 		if (!hedley_init) {
   1344  1.1  chopps 			panic("couldn't get chipmem for hedley init bitplane");
   1345  1.1  chopps 		}
   1346  1.1  chopps 		for (i = 1; i < 128; i++)
   1347  1.1  chopps 			hedley_init[i] = 0xff;
   1348  1.1  chopps 		hedley_init[0] = 0x03;
   1349  1.1  chopps 
   1350  1.1  chopps 		/* copy image of standard copper list. */
   1351  1.1  chopps 		bcopy(std_a2024_copper_list, a24_this_data->frames[0], std_a2024_copper_list_size);
   1352  1.1  chopps 
   1353  1.1  chopps 		/* set the init plane pointer. */
   1354  1.1  chopps 		cp = find_copper_inst(a24_this_data->frames[F_QD_QUAD0], CI_MOVE(R_BPL0PTH));
   1355  1.1  chopps 		cp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hedley_init));
   1356  1.1  chopps 		cp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hedley_init));
   1357  1.1  chopps 
   1358  1.1  chopps 		for (i = 1; i < F_QD_TOTAL; i++) {
   1359  1.1  chopps 			a24_this_data->frames[i] = &a24_this_data->frames[i - 1][len];
   1360  1.1  chopps 			bcopy(a24_this_data->frames[0], a24_this_data->frames[i], std_a2024_copper_list_size);
   1361  1.1  chopps 		}
   1362  1.1  chopps 
   1363  1.1  chopps 		a24_this_data->bplcon0 = 0x8200;	/* hires */
   1364  1.1  chopps 		a24_this_data->vbl_handler = (vbl_handler_func *) a2024_mode_vbl_handler;
   1365  1.1  chopps 
   1366  1.1  chopps 
   1367  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &a24_this->node);
   1368  1.1  chopps 	}
   1369  1.1  chopps 	return (a24_this);
   1370  1.1  chopps }
   1371  1.1  chopps 
   1372  1.1  chopps void
   1373  1.1  chopps display_a2024_view(v)
   1374  1.1  chopps 	view_t *v;
   1375  1.1  chopps {
   1376  1.1  chopps 	if (a24_this_data->current_view != v) {
   1377  1.1  chopps 		vdata_t *vd = VDATA(v);
   1378  1.1  chopps 		monitor_t *monitor = a24_this_data->monitor;
   1379  1.1  chopps 		cop_t  *cp, *tmp;
   1380  1.1  chopps 		u_char *inst_plane[2];
   1381  1.1  chopps 		u_char **plane = inst_plane;
   1382  1.1  chopps 		u_long  full_line = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1383  1.1  chopps 		u_long  half_plane = full_line * v->bitmap->rows / 2;
   1384  1.1  chopps 
   1385  1.1  chopps 		int     line_mod = 0xbc;	/* standard 2024 15khz mod. */
   1386  1.1  chopps 		int     depth = v->bitmap->depth, i, j;
   1387  1.1  chopps 
   1388  1.1  chopps 		plane[0] = v->bitmap->plane[0];
   1389  1.1  chopps 		if (depth == 2) {
   1390  1.1  chopps 			plane[1] = v->bitmap->plane[1];
   1391  1.1  chopps 		}
   1392  1.1  chopps 		if (a24_this_data->current_view) {
   1393  1.1  chopps 			VDATA(a24_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer
   1394  1.1  chopps 											 * displayed. */
   1395  1.1  chopps 		}
   1396  1.1  chopps 		cp = a24_this_data->frames[F_QD_STORE_QUAD0];
   1397  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COLOR1F));
   1398  1.1  chopps 		tmp = find_copper_inst(tmp, CI_MOVE(R_BPLCON0));	/* grab third one. */
   1399  1.1  chopps 		tmp->cp.inst.operand = a24_this_data->bplcon0 | ((depth & 0x7) << 13);	/* times 2 */
   1400  1.1  chopps 
   1401  1.1  chopps 		bcopy(a24_this_data->frames[F_QD_STORE_QUAD0], a24_this_data->frames[F_QD_STORE_QUAD1], std_a2024_copper_list_size);
   1402  1.1  chopps 		bcopy(a24_this_data->frames[F_QD_STORE_QUAD0], a24_this_data->frames[F_QD_STORE_QUAD2], std_a2024_copper_list_size);
   1403  1.1  chopps 		bcopy(a24_this_data->frames[F_QD_STORE_QUAD0], a24_this_data->frames[F_QD_STORE_QUAD3], std_a2024_copper_list_size);
   1404  1.1  chopps 
   1405  1.1  chopps 		/*
   1406  1.1  chopps 		 * Mark Id's
   1407  1.1  chopps 		 */
   1408  1.1  chopps 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD1], CI_WAIT(126, 21));
   1409  1.1  chopps 		CBUMP(tmp);
   1410  1.1  chopps 		CMOVE(tmp, R_COLOR01, QUAD1_ID);
   1411  1.1  chopps 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD2], CI_WAIT(126, 21));
   1412  1.1  chopps 		CBUMP(tmp);
   1413  1.1  chopps 		CMOVE(tmp, R_COLOR01, QUAD2_ID);
   1414  1.1  chopps 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD3], CI_WAIT(126, 21));
   1415  1.1  chopps 		CBUMP(tmp);
   1416  1.1  chopps 		CMOVE(tmp, R_COLOR01, QUAD3_ID);
   1417  1.1  chopps 
   1418  1.1  chopps 		plane[0]--;
   1419  1.1  chopps 		plane[0]--;
   1420  1.1  chopps 		if (depth == 2) {
   1421  1.1  chopps 			plane[1]--;
   1422  1.1  chopps 			plane[1]--;
   1423  1.1  chopps 		}
   1424  1.1  chopps 		/*
   1425  1.1  chopps 		 * Set bitplane pointers.
   1426  1.1  chopps 		 */
   1427  1.1  chopps 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD0], CI_MOVE(R_BPLMOD2));
   1428  1.1  chopps 		CBUMP(tmp);
   1429  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][0])));
   1430  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][0])));
   1431  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][full_line])));
   1432  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][full_line])));
   1433  1.1  chopps 		if (depth == 2) {
   1434  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][0])));
   1435  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][0])));
   1436  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][full_line])));
   1437  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][full_line])));
   1438  1.1  chopps 		}
   1439  1.1  chopps #if defined (GRF_ECS)
   1440  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1441  1.1  chopps #endif
   1442  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD1])));
   1443  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD1])));
   1444  1.1  chopps 		CEND(tmp);
   1445  1.1  chopps 		CEND(tmp);
   1446  1.1  chopps 
   1447  1.1  chopps 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD1], CI_MOVE(R_BPLMOD2));
   1448  1.1  chopps 		CBUMP(tmp);
   1449  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   1450  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   1451  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   1452  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   1453  1.1  chopps 		if (depth == 2) {
   1454  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   1455  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   1456  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   1457  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   1458  1.1  chopps 		}
   1459  1.1  chopps #if defined (GRF_ECS)
   1460  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1461  1.1  chopps #endif
   1462  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD2])));
   1463  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD2])));
   1464  1.1  chopps 		CEND(tmp);
   1465  1.1  chopps 		CEND(tmp);
   1466  1.1  chopps 
   1467  1.1  chopps 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD2], CI_MOVE(R_BPLMOD2));
   1468  1.1  chopps 		CBUMP(tmp);
   1469  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   1470  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   1471  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   1472  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   1473  1.1  chopps 		if (depth == 2) {
   1474  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   1475  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   1476  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   1477  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   1478  1.1  chopps 		}
   1479  1.1  chopps #if defined (GRF_ECS)
   1480  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1481  1.1  chopps #endif
   1482  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD3])));
   1483  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD3])));
   1484  1.1  chopps 		CEND(tmp);
   1485  1.1  chopps 		CEND(tmp);
   1486  1.1  chopps 
   1487  1.1  chopps 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD3], CI_MOVE(R_BPLMOD2));
   1488  1.1  chopps 		CBUMP(tmp);
   1489  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + HALF_2024_LINE])));
   1490  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + HALF_2024_LINE])));
   1491  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line + HALF_2024_LINE])));
   1492  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line + HALF_2024_LINE])));
   1493  1.1  chopps 		if (depth == 2) {
   1494  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + HALF_2024_LINE])));
   1495  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + HALF_2024_LINE])));
   1496  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line + HALF_2024_LINE])));
   1497  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line + HALF_2024_LINE])));
   1498  1.1  chopps 		}
   1499  1.1  chopps #if defined (GRF_ECS)
   1500  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1501  1.1  chopps #endif
   1502  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD0])));
   1503  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD0])));
   1504  1.1  chopps 		CEND(tmp);
   1505  1.1  chopps 		CEND(tmp);
   1506  1.1  chopps 
   1507  1.1  chopps 		/* swap new pointers in. */
   1508  1.1  chopps 		for (i = F_QD_STORE_QUAD0, j = F_QD_QUAD0;
   1509  1.1  chopps 		    i <= F_QD_STORE_QUAD3; i++, j++) {
   1510  1.1  chopps 			cp = a24_this_data->frames[j];
   1511  1.1  chopps 			a24_this_data->frames[j] = a24_this_data->frames[i];
   1512  1.1  chopps 			a24_this_data->frames[i] = cp;
   1513  1.1  chopps 		}
   1514  1.1  chopps 
   1515  1.1  chopps 		a24_this_data->current_view = v;
   1516  1.1  chopps 		vd->flags |= VF_DISPLAY;
   1517  1.1  chopps 
   1518  1.1  chopps 		cc_a2024_use_colormap(v, vd->colormap);
   1519  1.1  chopps 	}
   1520  1.1  chopps 	cc_load_mode(a24_this);
   1521  1.1  chopps }
   1522  1.1  chopps 
   1523  1.1  chopps void
   1524  1.1  chopps a2024_mode_vbl_handler(d)
   1525  1.1  chopps 	dmode_t *d;
   1526  1.1  chopps {
   1527  1.1  chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
   1528  1.1  chopps 
   1529  1.1  chopps 	if (vp < 12) {
   1530  1.1  chopps 		custom.cop1lc = PREP_DMA_MEM(a24_this_data->frames[a24_this_data->hedley_current]);
   1531  1.1  chopps 		custom.copjmp1 = 0;
   1532  1.1  chopps 	}
   1533  1.1  chopps 	a24_this_data->hedley_current++;
   1534  1.1  chopps 	a24_this_data->hedley_current &= 0x3;	/* if 4 then 0. */
   1535  1.1  chopps }
   1536  1.1  chopps #endif /* GRF_A2024 */
   1537  1.1  chopps #endif /* GRF_NTSC */
   1538  1.1  chopps 
   1539  1.1  chopps /*
   1540  1.1  chopps  * PAL modes.
   1541  1.1  chopps  */
   1542  1.1  chopps 
   1543  1.1  chopps #if defined (GRF_PAL)
   1544  1.1  chopps 
   1545  1.1  chopps dmode_t *
   1546  1.1  chopps cc_init_pal_hires()
   1547  1.1  chopps {
   1548  1.1  chopps 	/* ph_this function should only be called once. */
   1549  1.1  chopps 	if (!ph_this) {
   1550  1.1  chopps 		u_short len = std_copper_list_len;
   1551  1.1  chopps 		cop_t  *cp;
   1552  1.1  chopps 
   1553  1.1  chopps 		ph_this = &pal_hires_mode;
   1554  1.1  chopps 		ph_this_data = &pal_hires_mode_data;
   1555  1.1  chopps 		bzero(ph_this, sizeof(dmode_t));
   1556  1.1  chopps 		bzero(ph_this_data, sizeof(dmdata_t));
   1557  1.1  chopps 
   1558  1.1  chopps 		ph_this->name = "pal: pal_hires interlace";
   1559  1.1  chopps 		ph_this->nominal_size.width = 640;
   1560  1.1  chopps 		ph_this->nominal_size.height = 256;
   1561  1.1  chopps 		ph_this_data->max_size.width = 724;
   1562  1.1  chopps 		ph_this_data->max_size.height = 289;
   1563  1.1  chopps 		ph_this_data->min_size.width = 320;
   1564  1.1  chopps 		ph_this_data->min_size.height = 244;
   1565  1.1  chopps 		ph_this_data->min_depth = 1;
   1566  1.1  chopps 		ph_this_data->max_depth = 4;
   1567  1.1  chopps 		ph_this->data = ph_this_data;
   1568  1.1  chopps 
   1569  1.1  chopps 		ph_this->get_monitor = cc_get_monitor;
   1570  1.1  chopps 		ph_this->alloc_view = cc_alloc_view;
   1571  1.1  chopps 		ph_this->get_current_view = cc_get_current_view;
   1572  1.1  chopps 
   1573  1.1  chopps 		ph_this_data->use_colormap = cc_use_colormap;
   1574  1.1  chopps 		ph_this_data->get_colormap = cc_get_colormap;
   1575  1.1  chopps 		ph_this_data->alloc_colormap = cc_alloc_colormap;
   1576  1.1  chopps 		ph_this_data->display_view = display_pal_hires_view;
   1577  1.1  chopps 		ph_this_data->monitor = cc_monitor;
   1578  1.1  chopps 
   1579  1.1  chopps 		ph_this_data->frames = pal_hires_frames;
   1580  1.1  chopps 		ph_this_data->frames[F_LONG] = alloc_chipmem(std_copper_list_size * F_TOTAL);
   1581  1.1  chopps 		if (!ph_this_data->frames[F_LONG]) {
   1582  1.1  chopps 			panic("couldn't get chipmem for copper list");
   1583  1.1  chopps 		}
   1584  1.1  chopps 		ph_this_data->frames[F_STORE_LONG] = &ph_this_data->frames[F_LONG][len];
   1585  1.1  chopps 
   1586  1.1  chopps 		bcopy(std_copper_list, ph_this_data->frames[F_STORE_LONG], std_copper_list_size);
   1587  1.1  chopps 		bcopy(std_copper_list, ph_this_data->frames[F_LONG], std_copper_list_size);
   1588  1.1  chopps 
   1589  1.1  chopps 		ph_this_data->bplcon0 = 0x8200 | USE_CON3;	/* pal_hires, color
   1590  1.1  chopps 								 * composite enable,
   1591  1.1  chopps 								 * lace. */
   1592  1.1  chopps 		ph_this_data->std_start_x = STANDARD_VIEW_X;
   1593  1.1  chopps 		ph_this_data->std_start_y = STANDARD_VIEW_Y;
   1594  1.1  chopps 		ph_this_data->vbl_handler = (vbl_handler_func *) cc_mode_vbl_handler;
   1595  1.1  chopps #if defined (GRF_ECS)
   1596  1.1  chopps 		ph_this_data->beamcon0 = STANDARD_PAL_BEAMCON;
   1597  1.1  chopps #endif
   1598  1.1  chopps 
   1599  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &ph_this->node);
   1600  1.1  chopps 	}
   1601  1.1  chopps 	return (ph_this);
   1602  1.1  chopps }
   1603  1.1  chopps 
   1604  1.1  chopps void
   1605  1.1  chopps display_pal_hires_view(v)
   1606  1.1  chopps 	view_t *v;
   1607  1.1  chopps {
   1608  1.1  chopps 	if (ph_this_data->current_view != v) {
   1609  1.1  chopps 		vdata_t *vd = VDATA(v);
   1610  1.1  chopps 		monitor_t *monitor = ph_this_data->monitor;
   1611  1.1  chopps 		cop_t  *cp = ph_this_data->frames[F_STORE_LONG], *tmp;
   1612  1.1  chopps 		int     depth = v->bitmap->depth, i;
   1613  1.1  chopps 		int     hstart, hstop, vstart, vstop, j;
   1614  1.1  chopps 		int     x, y, w = v->display.width, h = v->display.height;
   1615  1.1  chopps 		u_short ddfstart, ddfwidth, con1;
   1616  1.1  chopps 
   1617  1.1  chopps 		/* round down to nearest even width */
   1618  1.1  chopps 		/* w &= 0xfffe; */
   1619  1.1  chopps 
   1620  1.1  chopps 		/* calculate datafetch width. */
   1621  1.1  chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   1622  1.1  chopps 
   1623  1.1  chopps 		/* Ph_This will center the any overscanned display */
   1624  1.1  chopps 		/* and allow user to modify. */
   1625  1.1  chopps 		x = v->display.x + ph_this_data->std_start_x - ((w - 640) >> 2);
   1626  1.1  chopps 		y = v->display.y + ph_this_data->std_start_y - ((h - 256) >> 1);
   1627  1.1  chopps 
   1628  1.1  chopps 		if (y & 1)
   1629  1.1  chopps 			y--;
   1630  1.1  chopps 
   1631  1.1  chopps 		if (!(x & 1))
   1632  1.1  chopps 			x--;
   1633  1.1  chopps 
   1634  1.1  chopps 		hstart = x;
   1635  1.1  chopps 		hstop = x + (w >> 1);
   1636  1.1  chopps 		vstart = y;
   1637  1.1  chopps 		vstop = y + h;
   1638  1.1  chopps 		ddfstart = (hstart - 9) >> 1;
   1639  1.1  chopps 		/* check for hardware limits, AGA may allow more..? */
   1640  1.1  chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   1641  1.1  chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   1642  1.1  chopps 			int     d = 0;
   1643  1.1  chopps 
   1644  1.1  chopps 			/* XXX anyone know the equality properties of
   1645  1.1  chopps 			 * intermixed logial AND's */
   1646  1.1  chopps 			/* XXX and arithmetic operators? */
   1647  1.1  chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   1648  1.1  chopps 				d++;
   1649  1.1  chopps 			}
   1650  1.1  chopps 
   1651  1.1  chopps 			ddfstart -= d;
   1652  1.1  chopps 			hstart -= d << 1;
   1653  1.1  chopps 			hstop -= d << 1;
   1654  1.1  chopps 		}
   1655  1.1  chopps 		/* correct the datafetch to proper limits. */
   1656  1.1  chopps 		/* delay the actual display of the data until we need it. */
   1657  1.1  chopps 		ddfstart &= 0xfffc;
   1658  1.1  chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   1659  1.1  chopps 
   1660  1.1  chopps 		if (ph_this_data->current_view) {
   1661  1.1  chopps 			VDATA(ph_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   1662  1.1  chopps 			/* displayed. */
   1663  1.1  chopps 		}
   1664  1.1  chopps 		ph_this_data->current_view = v;
   1665  1.1  chopps 
   1666  1.1  chopps 		cp = ph_this_data->frames[F_STORE_LONG];
   1667  1.1  chopps #if defined GRF_ECS
   1668  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   1669  1.1  chopps 		tmp->cp.inst.operand = ph_this_data->beamcon0;
   1670  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   1671  1.1  chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   1672  1.1  chopps #endif /* ECS */
   1673  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   1674  1.1  chopps 		tmp->cp.inst.operand = ph_this_data->bplcon0 | ((depth & 0x7) << 12);
   1675  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   1676  1.1  chopps 		tmp->cp.inst.operand = con1;
   1677  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   1678  1.1  chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   1679  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   1680  1.1  chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   1681  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   1682  1.1  chopps 		tmp->cp.inst.operand = ddfstart;
   1683  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   1684  1.1  chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   1685  1.1  chopps 
   1686  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1687  1.1  chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   1688  1.1  chopps 			/* update the plane pointers */
   1689  1.1  chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1690  1.1  chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1691  1.1  chopps 		}
   1692  1.1  chopps 
   1693  1.1  chopps 		/* set mods correctly. */
   1694  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   1695  1.1  chopps 		tmp[0].cp.inst.operand = v->bitmap->row_mod;
   1696  1.1  chopps 		tmp[1].cp.inst.operand = v->bitmap->row_mod;
   1697  1.1  chopps 
   1698  1.1  chopps 		/* set next pointers correctly */
   1699  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1700  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(ph_this_data->frames[F_STORE_LONG]));
   1701  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(ph_this_data->frames[F_STORE_LONG]));
   1702  1.1  chopps 
   1703  1.1  chopps 		cp = ph_this_data->frames[F_LONG];
   1704  1.1  chopps 		ph_this_data->frames[F_LONG] = ph_this_data->frames[F_STORE_LONG];
   1705  1.1  chopps 		ph_this_data->frames[F_STORE_LONG] = cp;
   1706  1.1  chopps 
   1707  1.1  chopps 		vd->flags |= VF_DISPLAY;
   1708  1.1  chopps 		cc_use_colormap(v, vd->colormap);
   1709  1.1  chopps 	}
   1710  1.1  chopps 	cc_load_mode(ph_this);
   1711  1.1  chopps }
   1712  1.1  chopps 
   1713  1.1  chopps dmode_t *
   1714  1.1  chopps cc_init_pal_hires_lace()
   1715  1.1  chopps {
   1716  1.1  chopps 	/* phl_this function should only be called once. */
   1717  1.1  chopps 	if (!phl_this) {
   1718  1.1  chopps 		u_short len = std_copper_list_len;
   1719  1.1  chopps 		cop_t  *cp;
   1720  1.1  chopps 
   1721  1.1  chopps 		phl_this = &pal_hires_lace_mode;
   1722  1.1  chopps 		phl_this_data = &pal_hires_lace_mode_data;
   1723  1.1  chopps 		bzero(phl_this, sizeof(dmode_t));
   1724  1.1  chopps 		bzero(phl_this_data, sizeof(dmdata_t));
   1725  1.1  chopps 
   1726  1.1  chopps 		phl_this->name = "pal: hires interlace";
   1727  1.1  chopps 		phl_this->nominal_size.width = 640;
   1728  1.1  chopps 		phl_this->nominal_size.height = 512;
   1729  1.1  chopps 		phl_this_data->max_size.width = 724;
   1730  1.1  chopps 		phl_this_data->max_size.height = 578;
   1731  1.1  chopps 		phl_this_data->min_size.width = 320;
   1732  1.1  chopps 		phl_this_data->min_size.height = 484;
   1733  1.1  chopps 		phl_this_data->min_depth = 1;
   1734  1.1  chopps 		phl_this_data->max_depth = 4;
   1735  1.1  chopps 		phl_this->data = phl_this_data;
   1736  1.1  chopps 
   1737  1.1  chopps 		phl_this->get_monitor = cc_get_monitor;
   1738  1.1  chopps 		phl_this->alloc_view = cc_alloc_view;
   1739  1.1  chopps 		phl_this->get_current_view = cc_get_current_view;
   1740  1.1  chopps 
   1741  1.1  chopps 		phl_this_data->use_colormap = cc_use_colormap;
   1742  1.1  chopps 		phl_this_data->get_colormap = cc_get_colormap;
   1743  1.1  chopps 		phl_this_data->alloc_colormap = cc_alloc_colormap;
   1744  1.1  chopps 		phl_this_data->display_view = display_pal_hires_lace_view;
   1745  1.1  chopps 		phl_this_data->monitor = cc_monitor;
   1746  1.1  chopps 
   1747  1.1  chopps 		phl_this_data->flags |= DMF_INTERLACE;
   1748  1.1  chopps 
   1749  1.1  chopps 		phl_this_data->frames = pal_hires_lace_frames;
   1750  1.1  chopps 		phl_this_data->frames[F_LACE_LONG] = alloc_chipmem(std_copper_list_size * F_LACE_TOTAL);
   1751  1.1  chopps 		if (!phl_this_data->frames[F_LACE_LONG]) {
   1752  1.1  chopps 			panic("couldn't get chipmem for copper list");
   1753  1.1  chopps 		}
   1754  1.1  chopps 		phl_this_data->frames[F_LACE_SHORT] = &phl_this_data->frames[F_LACE_LONG][len];
   1755  1.1  chopps 		phl_this_data->frames[F_LACE_STORE_LONG] = &phl_this_data->frames[F_LACE_SHORT][len];
   1756  1.1  chopps 		phl_this_data->frames[F_LACE_STORE_SHORT] = &phl_this_data->frames[F_LACE_STORE_LONG][len];
   1757  1.1  chopps 
   1758  1.1  chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_STORE_LONG], std_copper_list_size);
   1759  1.1  chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_STORE_SHORT], std_copper_list_size);
   1760  1.1  chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_LONG], std_copper_list_size);
   1761  1.1  chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_SHORT], std_copper_list_size);
   1762  1.1  chopps 
   1763  1.1  chopps 		phl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
   1764  1.1  chopps 								 * composite enable,
   1765  1.1  chopps 								 * lace. */
   1766  1.1  chopps 		phl_this_data->std_start_x = STANDARD_VIEW_X;
   1767  1.1  chopps 		phl_this_data->std_start_y = STANDARD_VIEW_Y;
   1768  1.1  chopps 		phl_this_data->vbl_handler = (vbl_handler_func *) cc_lace_mode_vbl_handler;
   1769  1.1  chopps #if defined (GRF_ECS)
   1770  1.1  chopps 		phl_this_data->beamcon0 = STANDARD_PAL_BEAMCON;
   1771  1.1  chopps #endif
   1772  1.1  chopps 
   1773  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &phl_this->node);
   1774  1.1  chopps 	}
   1775  1.1  chopps 	return (phl_this);
   1776  1.1  chopps }
   1777  1.1  chopps 
   1778  1.1  chopps void
   1779  1.1  chopps display_pal_hires_lace_view(v)
   1780  1.1  chopps 	view_t *v;
   1781  1.1  chopps {
   1782  1.1  chopps 	if (phl_this_data->current_view != v) {
   1783  1.1  chopps 		vdata_t *vd = VDATA(v);
   1784  1.1  chopps 		monitor_t *monitor = phl_this_data->monitor;
   1785  1.1  chopps 		cop_t  *cp = phl_this_data->frames[F_LACE_STORE_LONG], *tmp;
   1786  1.1  chopps 		int     depth = v->bitmap->depth, i;
   1787  1.1  chopps 		int     hstart, hstop, vstart, vstop, j;
   1788  1.1  chopps 		int     x, y, w = v->display.width, h = v->display.height;
   1789  1.1  chopps 		u_short ddfstart, ddfwidth, con1;
   1790  1.1  chopps 
   1791  1.1  chopps 		/* round down to nearest even width */
   1792  1.1  chopps 		/* w &= 0xfffe; */
   1793  1.1  chopps 
   1794  1.1  chopps 		/* calculate datafetch width. */
   1795  1.1  chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   1796  1.1  chopps 
   1797  1.1  chopps 		/* Phl_This will center the any overscanned display */
   1798  1.1  chopps 		/* and allow user to modify. */
   1799  1.1  chopps 		x = v->display.x + phl_this_data->std_start_x - ((w - 640) >> 2);
   1800  1.1  chopps 		y = v->display.y + phl_this_data->std_start_y - ((h - 512) >> 2);
   1801  1.1  chopps 
   1802  1.1  chopps 		if (y & 1)
   1803  1.1  chopps 			y--;
   1804  1.1  chopps 
   1805  1.1  chopps 		if (!(x & 1))
   1806  1.1  chopps 			x--;
   1807  1.1  chopps 
   1808  1.1  chopps 		hstart = x;
   1809  1.1  chopps 		hstop = x + (w >> 1);
   1810  1.1  chopps 		vstart = y;
   1811  1.1  chopps 		vstop = y + (h >> 1);
   1812  1.1  chopps 		ddfstart = (hstart - 9) >> 1;
   1813  1.1  chopps 
   1814  1.1  chopps 		/* check for hardware limits, AGA may allow more..? */
   1815  1.1  chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   1816  1.1  chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   1817  1.1  chopps 			int     d = 0;
   1818  1.1  chopps 
   1819  1.1  chopps 			/* XXX anyone know the equality properties of
   1820  1.1  chopps 			 * intermixed logial AND's */
   1821  1.1  chopps 			/* XXX and arithmetic operators? */
   1822  1.1  chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   1823  1.1  chopps 				d++;
   1824  1.1  chopps 			}
   1825  1.1  chopps 
   1826  1.1  chopps 			ddfstart -= d;
   1827  1.1  chopps 			hstart -= d << 1;
   1828  1.1  chopps 			hstop -= d << 1;
   1829  1.1  chopps 		}
   1830  1.1  chopps 		/* correct the datafetch to proper limits. */
   1831  1.1  chopps 		/* delay the actual display of the data until we need it. */
   1832  1.1  chopps 		ddfstart &= 0xfffc;
   1833  1.1  chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   1834  1.1  chopps 
   1835  1.1  chopps 		if (phl_this_data->current_view) {
   1836  1.1  chopps 			VDATA(phl_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   1837  1.1  chopps 			/* displayed. */
   1838  1.1  chopps 		}
   1839  1.1  chopps 		phl_this_data->current_view = v;
   1840  1.1  chopps 
   1841  1.1  chopps 		cp = phl_this_data->frames[F_LACE_STORE_LONG];
   1842  1.1  chopps #if defined GRF_ECS
   1843  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   1844  1.1  chopps 		tmp->cp.inst.operand = phl_this_data->beamcon0;
   1845  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   1846  1.1  chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   1847  1.1  chopps #endif /* ECS */
   1848  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   1849  1.1  chopps 		tmp->cp.inst.operand = phl_this_data->bplcon0 | ((depth & 0x7) << 12);
   1850  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   1851  1.1  chopps 		tmp->cp.inst.operand = con1;
   1852  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   1853  1.1  chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   1854  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   1855  1.1  chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   1856  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   1857  1.1  chopps 		tmp->cp.inst.operand = ddfstart;
   1858  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   1859  1.1  chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   1860  1.1  chopps 
   1861  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1862  1.1  chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   1863  1.1  chopps 			/* update the plane pointers */
   1864  1.1  chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1865  1.1  chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1866  1.1  chopps 		}
   1867  1.1  chopps 
   1868  1.1  chopps 		/* set mods correctly. */
   1869  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   1870  1.1  chopps 		tmp[0].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1871  1.1  chopps 		tmp[1].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1872  1.1  chopps 
   1873  1.1  chopps 		/* set next pointers correctly */
   1874  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1875  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_SHORT]));
   1876  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_SHORT]));
   1877  1.1  chopps 
   1878  1.1  chopps 
   1879  1.1  chopps 		bcopy(phl_this_data->frames[F_LACE_STORE_LONG], phl_this_data->frames[F_LACE_STORE_SHORT], std_copper_list_size);
   1880  1.1  chopps 
   1881  1.1  chopps 		/* these are the only ones that are different from long frame. */
   1882  1.1  chopps 		cp = phl_this_data->frames[F_LACE_STORE_SHORT];
   1883  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1884  1.1  chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   1885  1.1  chopps 			u_short mod = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1886  1.1  chopps 			/* update plane pointers. high and low. */
   1887  1.1  chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   1888  1.1  chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   1889  1.1  chopps 		}
   1890  1.1  chopps 
   1891  1.1  chopps 		/* set next pointers correctly */
   1892  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1893  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_LONG]));
   1894  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_LONG]));
   1895  1.1  chopps 
   1896  1.1  chopps 
   1897  1.1  chopps 		cp = phl_this_data->frames[F_LACE_LONG];
   1898  1.1  chopps 		phl_this_data->frames[F_LACE_LONG] = phl_this_data->frames[F_LACE_STORE_LONG];
   1899  1.1  chopps 		phl_this_data->frames[F_LACE_STORE_LONG] = cp;
   1900  1.1  chopps 
   1901  1.1  chopps 		cp = phl_this_data->frames[F_LACE_SHORT];
   1902  1.1  chopps 		phl_this_data->frames[F_LACE_SHORT] = phl_this_data->frames[F_LACE_STORE_SHORT];
   1903  1.1  chopps 		phl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   1904  1.1  chopps 
   1905  1.1  chopps 		vd->flags |= VF_DISPLAY;
   1906  1.1  chopps 		cc_use_colormap(v, vd->colormap);
   1907  1.1  chopps 	}
   1908  1.1  chopps 	cc_load_mode(phl_this);
   1909  1.1  chopps }
   1910  1.1  chopps #if defined (GRF_A2024)
   1911  1.1  chopps 
   1912  1.1  chopps dmode_t *
   1913  1.1  chopps cc_init_pal_hires_dlace()
   1914  1.1  chopps {
   1915  1.1  chopps 	/* phdl_this function should only be called once. */
   1916  1.1  chopps 	if (!phdl_this) {
   1917  1.1  chopps 		u_short len = std_dlace_copper_list_len;
   1918  1.1  chopps 		cop_t  *cp;
   1919  1.1  chopps 
   1920  1.1  chopps 		phdl_this = &pal_hires_dlace_mode;
   1921  1.1  chopps 		phdl_this_data = &pal_hires_dlace_mode_data;
   1922  1.1  chopps 		bzero(phdl_this, sizeof(dmode_t));
   1923  1.1  chopps 		bzero(phdl_this_data, sizeof(dmdata_t));
   1924  1.1  chopps 
   1925  1.1  chopps 		phdl_this->name = "pal: hires double interlace";
   1926  1.1  chopps 		phdl_this->nominal_size.width = 640;
   1927  1.1  chopps 		phdl_this->nominal_size.height = 1024;
   1928  1.1  chopps 		phdl_this_data->max_size.width = 724;
   1929  1.1  chopps 		phdl_this_data->max_size.height = 1024;
   1930  1.1  chopps 		phdl_this_data->min_size.width = 320;
   1931  1.1  chopps 		phdl_this_data->min_size.height = 512;
   1932  1.1  chopps 		phdl_this_data->min_depth = 1;
   1933  1.1  chopps 		phdl_this_data->max_depth = 2;
   1934  1.1  chopps 		phdl_this->data = phdl_this_data;
   1935  1.1  chopps 
   1936  1.1  chopps 		phdl_this->get_monitor = cc_get_monitor;
   1937  1.1  chopps 		phdl_this->alloc_view = cc_alloc_view;
   1938  1.1  chopps 		phdl_this->get_current_view = cc_get_current_view;
   1939  1.1  chopps 
   1940  1.1  chopps 		phdl_this_data->use_colormap = cc_a2024_use_colormap;
   1941  1.1  chopps 		phdl_this_data->get_colormap = cc_a2024_get_colormap;
   1942  1.1  chopps 		phdl_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   1943  1.1  chopps 		phdl_this_data->display_view = display_pal_hires_dlace_view;
   1944  1.1  chopps 		phdl_this_data->monitor = cc_monitor;
   1945  1.1  chopps 
   1946  1.1  chopps 		phdl_this_data->flags |= DMF_INTERLACE;
   1947  1.1  chopps 
   1948  1.1  chopps 		phdl_this_data->frames = pal_hires_dlace_frames;
   1949  1.1  chopps 		phdl_this_data->frames[F_LACE_LONG] = alloc_chipmem(std_dlace_copper_list_size * F_LACE_TOTAL);
   1950  1.1  chopps 		if (!phdl_this_data->frames[F_LACE_LONG]) {
   1951  1.1  chopps 			panic("couldn't get chipmem for copper list");
   1952  1.1  chopps 		}
   1953  1.1  chopps 		phdl_this_data->frames[F_LACE_SHORT] = &phdl_this_data->frames[F_LACE_LONG][len];
   1954  1.1  chopps 		phdl_this_data->frames[F_LACE_STORE_LONG] = &phdl_this_data->frames[F_LACE_SHORT][len];
   1955  1.1  chopps 		phdl_this_data->frames[F_LACE_STORE_SHORT] = &phdl_this_data->frames[F_LACE_STORE_LONG][len];
   1956  1.1  chopps 
   1957  1.1  chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_STORE_LONG], std_dlace_copper_list_size);
   1958  1.1  chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_STORE_SHORT], std_dlace_copper_list_size);
   1959  1.1  chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_LONG], std_dlace_copper_list_size);
   1960  1.1  chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_SHORT], std_dlace_copper_list_size);
   1961  1.1  chopps 
   1962  1.1  chopps 		phdl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
   1963  1.1  chopps 								 * composite enable,
   1964  1.1  chopps 								 * dlace. */
   1965  1.1  chopps 		phdl_this_data->std_start_x = STANDARD_VIEW_X;
   1966  1.1  chopps 		phdl_this_data->std_start_y = STANDARD_VIEW_Y;
   1967  1.1  chopps 		phdl_this_data->vbl_handler = (vbl_handler_func *) cc_lace_mode_vbl_handler;
   1968  1.1  chopps #if defined (GRF_ECS)
   1969  1.1  chopps 		phdl_this_data->beamcon0 = STANDARD_PAL_BEAMCON;
   1970  1.1  chopps #endif
   1971  1.1  chopps 
   1972  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &phdl_this->node);
   1973  1.1  chopps 	}
   1974  1.1  chopps 	return (phdl_this);
   1975  1.1  chopps }
   1976  1.1  chopps 
   1977  1.1  chopps void
   1978  1.1  chopps display_pal_hires_dlace_view(v)
   1979  1.1  chopps 	view_t *v;
   1980  1.1  chopps {
   1981  1.1  chopps 	if (phdl_this_data->current_view != v) {
   1982  1.1  chopps 		vdata_t *vd = VDATA(v);
   1983  1.1  chopps 		monitor_t *monitor = phdl_this_data->monitor;
   1984  1.1  chopps 		cop_t  *cp = phdl_this_data->frames[F_LACE_STORE_LONG], *tmp;
   1985  1.1  chopps 		int     depth = v->bitmap->depth, i;
   1986  1.1  chopps 		int     hstart, hstop, vstart, vstop, j;
   1987  1.1  chopps 		int     x, y, w = v->display.width, h = v->display.height;
   1988  1.1  chopps 		u_short ddfstart, ddfwidth, con1;
   1989  1.1  chopps 		u_short mod1l, mod2l;
   1990  1.1  chopps 
   1991  1.1  chopps 		/* round down to nearest even width */
   1992  1.1  chopps 		/* w &= 0xfffe; */
   1993  1.1  chopps 
   1994  1.1  chopps 		/* calculate datafetch width. */
   1995  1.1  chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   1996  1.1  chopps 
   1997  1.1  chopps 		/* Phdl_This will center the any overscanned display */
   1998  1.1  chopps 		/* and allow user to modify. */
   1999  1.1  chopps 		x = v->display.x + phdl_this_data->std_start_x - ((w - 640) >> 2);
   2000  1.1  chopps 		y = v->display.y + phdl_this_data->std_start_y - ((h - 1024) >> 3);
   2001  1.1  chopps 
   2002  1.1  chopps 		if (y & 1)
   2003  1.1  chopps 			y--;
   2004  1.1  chopps 
   2005  1.1  chopps 		if (!(x & 1))
   2006  1.1  chopps 			x--;
   2007  1.1  chopps 
   2008  1.1  chopps 		hstart = x;
   2009  1.1  chopps 		hstop = x + (w >> 1);
   2010  1.1  chopps 		vstart = y;
   2011  1.1  chopps 		vstop = y + (h >> 2);
   2012  1.1  chopps 		ddfstart = (hstart - 9) >> 1;
   2013  1.1  chopps 
   2014  1.1  chopps 		/* check for hardware limits, AGA may allow more..? */
   2015  1.1  chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   2016  1.1  chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   2017  1.1  chopps 			int     d = 0;
   2018  1.1  chopps 
   2019  1.1  chopps 			/* XXX anyone know the equality properties of
   2020  1.1  chopps 			 * intermixed logial AND's */
   2021  1.1  chopps 			/* XXX and arithmetic operators? */
   2022  1.1  chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   2023  1.1  chopps 				d++;
   2024  1.1  chopps 			}
   2025  1.1  chopps 
   2026  1.1  chopps 			ddfstart -= d;
   2027  1.1  chopps 			hstart -= d << 1;
   2028  1.1  chopps 			hstop -= d << 1;
   2029  1.1  chopps 		}
   2030  1.1  chopps 		/* correct the datafetch to proper limits. */
   2031  1.1  chopps 		/* delay the actual display of the data until we need it. */
   2032  1.1  chopps 		ddfstart &= 0xfffc;
   2033  1.1  chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   2034  1.1  chopps 
   2035  1.1  chopps 		if (phdl_this_data->current_view) {
   2036  1.1  chopps 			VDATA(phdl_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   2037  1.1  chopps 			/* displayed. */
   2038  1.1  chopps 		}
   2039  1.1  chopps 		phdl_this_data->current_view = v;
   2040  1.1  chopps 
   2041  1.1  chopps 		cp = phdl_this_data->frames[F_LACE_STORE_LONG];
   2042  1.1  chopps #if defined GRF_ECS
   2043  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   2044  1.1  chopps 		tmp->cp.inst.operand = phdl_this_data->beamcon0;
   2045  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   2046  1.1  chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   2047  1.1  chopps #endif /* ECS */
   2048  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   2049  1.1  chopps 		tmp->cp.inst.operand = phdl_this_data->bplcon0 | ((depth & 0x7) << 13);	/* times two. */
   2050  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   2051  1.1  chopps 		tmp->cp.inst.operand = con1;
   2052  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   2053  1.1  chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   2054  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   2055  1.1  chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   2056  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   2057  1.1  chopps 		tmp->cp.inst.operand = ddfstart;
   2058  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   2059  1.1  chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   2060  1.1  chopps 
   2061  1.1  chopps 		mod1l = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   2062  1.1  chopps 		mod2l = mod1l << 1;
   2063  1.1  chopps 
   2064  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2065  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));	/* update plane
   2066  1.1  chopps 											 * pointers. */
   2067  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));	/* high and low. */
   2068  1.1  chopps 		tmp[2].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));	/* update plane
   2069  1.1  chopps 												 * pointers. */
   2070  1.1  chopps 		tmp[3].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));	/* high and low. */
   2071  1.1  chopps 		if (depth == 2) {
   2072  1.1  chopps 			tmp[4].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));	/* update plane
   2073  1.1  chopps 												 * pointers. */
   2074  1.1  chopps 			tmp[5].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));	/* high and low. */
   2075  1.1  chopps 			tmp[6].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));	/* update plane
   2076  1.1  chopps 													 * pointers. */
   2077  1.1  chopps 			tmp[7].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));	/* high and low. */
   2078  1.1  chopps 		}
   2079  1.1  chopps 		/* set mods correctly. */
   2080  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   2081  1.1  chopps 		tmp[0].cp.inst.operand = mod2l + mod1l;
   2082  1.1  chopps 		tmp[1].cp.inst.operand = mod2l + mod1l;
   2083  1.1  chopps 
   2084  1.1  chopps 		/* set next pointers correctly */
   2085  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2086  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_SHORT]));
   2087  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_SHORT]));
   2088  1.1  chopps 
   2089  1.1  chopps 		bcopy(phdl_this_data->frames[F_LACE_STORE_LONG], phdl_this_data->frames[F_LACE_STORE_SHORT], std_dlace_copper_list_size);
   2090  1.1  chopps 
   2091  1.1  chopps 		/* these are the only ones that are different from long frame. */
   2092  1.1  chopps 		cp = phdl_this_data->frames[F_LACE_STORE_SHORT];
   2093  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2094  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));	/* update plane
   2095  1.1  chopps 												 * pointers. */
   2096  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));	/* high and low. */
   2097  1.1  chopps 		tmp[2].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));	/* update plane
   2098  1.1  chopps 													 * pointers. */
   2099  1.1  chopps 		tmp[3].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));	/* high and low. */
   2100  1.1  chopps 		if (depth == 2) {
   2101  1.1  chopps 			tmp[4].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));	/* update plane
   2102  1.1  chopps 													 * pointers. */
   2103  1.1  chopps 			tmp[5].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));	/* high and low. */
   2104  1.1  chopps 			tmp[6].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));	/* update plane
   2105  1.1  chopps 														 * pointers. */
   2106  1.1  chopps 			tmp[7].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));	/* high and low. */
   2107  1.1  chopps 		}
   2108  1.1  chopps 		/* set next pointers correctly */
   2109  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2110  1.1  chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_LONG]));
   2111  1.1  chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_LONG]));
   2112  1.1  chopps 
   2113  1.1  chopps 		cp = phdl_this_data->frames[F_LACE_LONG];
   2114  1.1  chopps 		phdl_this_data->frames[F_LACE_LONG] = phdl_this_data->frames[F_LACE_STORE_LONG];
   2115  1.1  chopps 		phdl_this_data->frames[F_LACE_STORE_LONG] = cp;
   2116  1.1  chopps 
   2117  1.1  chopps 		cp = phdl_this_data->frames[F_LACE_SHORT];
   2118  1.1  chopps 		phdl_this_data->frames[F_LACE_SHORT] = phdl_this_data->frames[F_LACE_STORE_SHORT];
   2119  1.1  chopps 		phdl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   2120  1.1  chopps 
   2121  1.1  chopps 		vd->flags |= VF_DISPLAY;
   2122  1.1  chopps 
   2123  1.1  chopps 		cc_a2024_use_colormap(v, vd->colormap);
   2124  1.1  chopps 	}
   2125  1.1  chopps 	cc_load_mode(phdl_this);
   2126  1.1  chopps }
   2127  1.1  chopps 
   2128  1.1  chopps dmode_t *
   2129  1.1  chopps cc_init_pal_a2024()
   2130  1.1  chopps {
   2131  1.1  chopps 	/* p24_this function should only be called once. */
   2132  1.1  chopps 	if (!p24_this) {
   2133  1.1  chopps 		int     i;
   2134  1.1  chopps 		u_short len = std_pal_a2024_copper_list_len;
   2135  1.1  chopps 		cop_t  *cp;
   2136  1.1  chopps 
   2137  1.1  chopps 		p24_this = &pal_a2024_mode;
   2138  1.1  chopps 		p24_this_data = &pal_a2024_mode_data;
   2139  1.1  chopps 		bzero(p24_this, sizeof(dmode_t));
   2140  1.1  chopps 		bzero(p24_this_data, sizeof(dmdata_t));
   2141  1.1  chopps 
   2142  1.1  chopps 		p24_this->name = "pal: A2024 15khz";
   2143  1.1  chopps 		p24_this->nominal_size.width = 1024;
   2144  1.1  chopps 		p24_this->nominal_size.height = 1024;
   2145  1.1  chopps 		p24_this_data->max_size.width = 1024;
   2146  1.1  chopps 		p24_this_data->max_size.height = 1024;
   2147  1.1  chopps 		p24_this_data->min_size.width = 1024;
   2148  1.1  chopps 		p24_this_data->min_size.height = 1024;
   2149  1.1  chopps 		p24_this_data->min_depth = 1;
   2150  1.1  chopps 		p24_this_data->max_depth = 2;
   2151  1.1  chopps 		p24_this->data = p24_this_data;
   2152  1.1  chopps 
   2153  1.1  chopps 		p24_this->get_monitor = cc_get_monitor;
   2154  1.1  chopps 		p24_this->alloc_view = cc_alloc_view;
   2155  1.1  chopps 		p24_this->get_current_view = cc_get_current_view;
   2156  1.1  chopps 
   2157  1.1  chopps 		p24_this_data->use_colormap = cc_a2024_use_colormap;
   2158  1.1  chopps 		p24_this_data->get_colormap = cc_a2024_get_colormap;
   2159  1.1  chopps 		p24_this_data->display_view = display_pal_a2024_view;
   2160  1.1  chopps 		p24_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   2161  1.1  chopps 		p24_this_data->monitor = cc_monitor;
   2162  1.1  chopps 
   2163  1.1  chopps 		p24_this_data->flags |= DMF_HEDLEY_EXP;
   2164  1.1  chopps 
   2165  1.1  chopps 		p24_this_data->frames = pal_a2024_frames;
   2166  1.1  chopps 		p24_this_data->frames[F_QD_QUAD0] = alloc_chipmem(std_pal_a2024_copper_list_size * F_QD_TOTAL);
   2167  1.1  chopps 		if (!p24_this_data->frames[F_QD_QUAD0]) {
   2168  1.1  chopps 			panic("couldn't get chipmem for copper list");
   2169  1.1  chopps 		}
   2170  1.1  chopps 		/* setup the hedley init bitplane. */
   2171  1.1  chopps 		hedley_init = alloc_chipmem(128);
   2172  1.1  chopps 		if (!hedley_init) {
   2173  1.1  chopps 			panic("couldn't get chipmem for hedley init bitplane");
   2174  1.1  chopps 		}
   2175  1.1  chopps 		for (i = 1; i < 128; i++)
   2176  1.1  chopps 			hedley_init[i] = 0xff;
   2177  1.1  chopps 		hedley_init[0] = 0x03;
   2178  1.1  chopps 
   2179  1.1  chopps 		/* copy image of standard copper list. */
   2180  1.1  chopps 		bcopy(std_pal_a2024_copper_list, p24_this_data->frames[0], std_pal_a2024_copper_list_size);
   2181  1.1  chopps 
   2182  1.1  chopps 		/* set the init plane pointer. */
   2183  1.1  chopps 		cp = find_copper_inst(p24_this_data->frames[F_QD_QUAD0], CI_MOVE(R_BPL0PTH));
   2184  1.1  chopps 		cp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hedley_init));
   2185  1.1  chopps 		cp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hedley_init));
   2186  1.1  chopps 
   2187  1.1  chopps 		for (i = 1; i < F_QD_TOTAL; i++) {
   2188  1.1  chopps 			p24_this_data->frames[i] = &p24_this_data->frames[i - 1][len];
   2189  1.1  chopps 			bcopy(p24_this_data->frames[0], p24_this_data->frames[i], std_pal_a2024_copper_list_size);
   2190  1.1  chopps 		}
   2191  1.1  chopps 
   2192  1.1  chopps 		p24_this_data->bplcon0 = 0x8200;	/* hires */
   2193  1.1  chopps 		p24_this_data->vbl_handler = (vbl_handler_func *) pal_a2024_mode_vbl_handler;
   2194  1.1  chopps 
   2195  1.1  chopps 
   2196  1.1  chopps 		dadd_head(&MDATA(cc_monitor)->modes, &p24_this->node);
   2197  1.1  chopps 	}
   2198  1.1  chopps 	return (p24_this);
   2199  1.1  chopps }
   2200  1.1  chopps 
   2201  1.1  chopps void
   2202  1.1  chopps display_pal_a2024_view(v)
   2203  1.1  chopps 	view_t *v;
   2204  1.1  chopps {
   2205  1.1  chopps 	if (p24_this_data->current_view != v) {
   2206  1.1  chopps 		vdata_t *vd = VDATA(v);
   2207  1.1  chopps 		monitor_t *monitor = p24_this_data->monitor;
   2208  1.1  chopps 		cop_t  *cp, *tmp;
   2209  1.1  chopps 		u_char *inst_plane[2];
   2210  1.1  chopps 		u_char **plane = inst_plane;
   2211  1.1  chopps 		u_long  full_line = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   2212  1.1  chopps 		u_long  half_plane = full_line * v->bitmap->rows / 2;
   2213  1.1  chopps 
   2214  1.1  chopps 		int     line_mod = 0xbc;	/* standard 2024 15khz mod. */
   2215  1.1  chopps 		int     depth = v->bitmap->depth, i, j;
   2216  1.1  chopps 
   2217  1.1  chopps 		plane[0] = v->bitmap->plane[0];
   2218  1.1  chopps 		if (depth == 2) {
   2219  1.1  chopps 			plane[1] = v->bitmap->plane[1];
   2220  1.1  chopps 		}
   2221  1.1  chopps 		if (p24_this_data->current_view) {
   2222  1.1  chopps 			VDATA(p24_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer
   2223  1.1  chopps 											 * displayed. */
   2224  1.1  chopps 		}
   2225  1.1  chopps 		cp = p24_this_data->frames[F_QD_STORE_QUAD0];
   2226  1.1  chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COLOR1F));
   2227  1.1  chopps 		tmp = find_copper_inst(tmp, CI_MOVE(R_BPLCON0));	/* grab third one. */
   2228  1.1  chopps 		tmp->cp.inst.operand = p24_this_data->bplcon0 | ((depth & 0x7) << 13);	/* times 2 */
   2229  1.1  chopps 
   2230  1.1  chopps 		bcopy(p24_this_data->frames[F_QD_STORE_QUAD0], p24_this_data->frames[F_QD_STORE_QUAD1], std_pal_a2024_copper_list_size);
   2231  1.1  chopps 		bcopy(p24_this_data->frames[F_QD_STORE_QUAD0], p24_this_data->frames[F_QD_STORE_QUAD2], std_pal_a2024_copper_list_size);
   2232  1.1  chopps 		bcopy(p24_this_data->frames[F_QD_STORE_QUAD0], p24_this_data->frames[F_QD_STORE_QUAD3], std_pal_a2024_copper_list_size);
   2233  1.1  chopps 
   2234  1.1  chopps 		/*
   2235  1.1  chopps 		 * Mark Id's
   2236  1.1  chopps 		 */
   2237  1.1  chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD1], CI_WAIT(126, 29));
   2238  1.1  chopps 		CBUMP(tmp);
   2239  1.1  chopps 		CMOVE(tmp, R_COLOR01, QUAD1_ID);
   2240  1.1  chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD2], CI_WAIT(126, 29));
   2241  1.1  chopps 		CBUMP(tmp);
   2242  1.1  chopps 		CMOVE(tmp, R_COLOR01, QUAD2_ID);
   2243  1.1  chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD3], CI_WAIT(126, 29));
   2244  1.1  chopps 		CBUMP(tmp);
   2245  1.1  chopps 		CMOVE(tmp, R_COLOR01, QUAD3_ID);
   2246  1.1  chopps 
   2247  1.1  chopps 		plane[0]--;
   2248  1.1  chopps 		plane[0]--;
   2249  1.1  chopps 		if (depth == 2) {
   2250  1.1  chopps 			plane[1]--;
   2251  1.1  chopps 			plane[1]--;
   2252  1.1  chopps 		}
   2253  1.1  chopps 		/*
   2254  1.1  chopps 		 * Set bitplane pointers.
   2255  1.1  chopps 		 */
   2256  1.1  chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD0], CI_MOVE(R_BPLMOD2));
   2257  1.1  chopps 		CBUMP(tmp);
   2258  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][0])));
   2259  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][0])));
   2260  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][full_line])));
   2261  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][full_line])));
   2262  1.1  chopps 		if (depth == 2) {
   2263  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][0])));
   2264  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][0])));
   2265  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][full_line])));
   2266  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][full_line])));
   2267  1.1  chopps 		}
   2268  1.1  chopps #if defined (GRF_ECS)
   2269  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   2270  1.1  chopps #endif
   2271  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD1])));
   2272  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD1])));
   2273  1.1  chopps 		CEND(tmp);
   2274  1.1  chopps 		CEND(tmp);
   2275  1.1  chopps 
   2276  1.1  chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD1], CI_MOVE(R_BPLMOD2));
   2277  1.1  chopps 		CBUMP(tmp);
   2278  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   2279  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   2280  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   2281  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   2282  1.1  chopps 		if (depth == 2) {
   2283  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   2284  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   2285  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   2286  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   2287  1.1  chopps 		}
   2288  1.1  chopps #if defined (GRF_ECS)
   2289  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   2290  1.1  chopps #endif
   2291  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD2])));
   2292  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD2])));
   2293  1.1  chopps 		CEND(tmp);
   2294  1.1  chopps 		CEND(tmp);
   2295  1.1  chopps 
   2296  1.1  chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD2], CI_MOVE(R_BPLMOD2));
   2297  1.1  chopps 		CBUMP(tmp);
   2298  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   2299  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   2300  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   2301  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   2302  1.1  chopps 		if (depth == 2) {
   2303  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   2304  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   2305  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   2306  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   2307  1.1  chopps 		}
   2308  1.1  chopps #if defined (GRF_ECS)
   2309  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   2310  1.1  chopps #endif
   2311  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD3])));
   2312  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD3])));
   2313  1.1  chopps 		CEND(tmp);
   2314  1.1  chopps 		CEND(tmp);
   2315  1.1  chopps 
   2316  1.1  chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD3], CI_MOVE(R_BPLMOD2));
   2317  1.1  chopps 		CBUMP(tmp);
   2318  1.1  chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + HALF_2024_LINE])));
   2319  1.1  chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + HALF_2024_LINE])));
   2320  1.1  chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line + HALF_2024_LINE])));
   2321  1.1  chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line + HALF_2024_LINE])));
   2322  1.1  chopps 		if (depth == 2) {
   2323  1.1  chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + HALF_2024_LINE])));
   2324  1.1  chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + HALF_2024_LINE])));
   2325  1.1  chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line + HALF_2024_LINE])));
   2326  1.1  chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line + HALF_2024_LINE])));
   2327  1.1  chopps 		}
   2328  1.1  chopps #if defined (GRF_ECS)
   2329  1.1  chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   2330  1.1  chopps #endif
   2331  1.1  chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD0])));
   2332  1.1  chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD0])));
   2333  1.1  chopps 		CEND(tmp);
   2334  1.1  chopps 		CEND(tmp);
   2335  1.1  chopps 
   2336  1.1  chopps 		/* swap new pointers in. */
   2337  1.1  chopps 		for (i = F_QD_STORE_QUAD0, j = F_QD_QUAD0;
   2338  1.1  chopps 		    i <= F_QD_STORE_QUAD3; i++, j++) {
   2339  1.1  chopps 			cp = p24_this_data->frames[j];
   2340  1.1  chopps 			p24_this_data->frames[j] = p24_this_data->frames[i];
   2341  1.1  chopps 			p24_this_data->frames[i] = cp;
   2342  1.1  chopps 		}
   2343  1.1  chopps 
   2344  1.1  chopps 		p24_this_data->current_view = v;
   2345  1.1  chopps 		vd->flags |= VF_DISPLAY;
   2346  1.1  chopps 
   2347  1.1  chopps 		cc_a2024_use_colormap(v, vd->colormap);
   2348  1.1  chopps 	}
   2349  1.1  chopps 	cc_load_mode(p24_this);
   2350  1.1  chopps }
   2351  1.1  chopps 
   2352  1.1  chopps void
   2353  1.1  chopps pal_a2024_mode_vbl_handler(d)
   2354  1.1  chopps 	dmode_t *d;
   2355  1.1  chopps {
   2356  1.1  chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
   2357  1.1  chopps 
   2358  1.1  chopps 	if (vp < 20) {
   2359  1.1  chopps 		custom.cop1lc = PREP_DMA_MEM(p24_this_data->frames[p24_this_data->hedley_current]);
   2360  1.1  chopps 		custom.copjmp1 = 0;
   2361  1.1  chopps 	}
   2362  1.1  chopps 	p24_this_data->hedley_current++;
   2363  1.1  chopps 	p24_this_data->hedley_current &= 0x3;	/* if 4 then 0. */
   2364  1.1  chopps }
   2365  1.1  chopps #endif /* GRF_PAL */
   2366  1.1  chopps #endif /* GRF_A2024 */
   2367