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