Home | History | Annotate | Line # | Download | only in dev
grfabs_cc.c revision 1.20.8.1
      1  1.20.8.1  jdolecek /*	$NetBSD: grfabs_cc.c,v 1.20.8.1 2002/02/11 20:06:57 jdolecek Exp $ */
      2       1.6       cgd 
      3       1.1    chopps /*
      4       1.1    chopps  * Copyright (c) 1994 Christian E. Hopps
      5       1.1    chopps  * All rights reserved.
      6       1.1    chopps  *
      7       1.1    chopps  * Redistribution and use in source and binary forms, with or without
      8       1.1    chopps  * modification, are permitted provided that the following conditions
      9       1.1    chopps  * are met:
     10       1.1    chopps  * 1. Redistributions of source code must retain the above copyright
     11       1.1    chopps  *    notice, this list of conditions and the following disclaimer.
     12       1.1    chopps  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1    chopps  *    notice, this list of conditions and the following disclaimer in the
     14       1.1    chopps  *    documentation and/or other materials provided with the distribution.
     15       1.1    chopps  * 3. All advertising materials mentioning features or use of this software
     16       1.1    chopps  *    must display the following acknowledgement:
     17       1.1    chopps  *      This product includes software developed by Christian E. Hopps.
     18       1.1    chopps  * 4. The name of the author may not be used to endorse or promote products
     19       1.1    chopps  *    derived from this software without specific prior written permission
     20       1.1    chopps  *
     21       1.1    chopps  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22       1.1    chopps  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23       1.1    chopps  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24       1.1    chopps  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25       1.1    chopps  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26       1.1    chopps  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27       1.1    chopps  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28       1.1    chopps  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29       1.1    chopps  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30       1.1    chopps  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.6       cgd  */
     32       1.6       cgd 
     33       1.6       cgd /*
     34       1.1    chopps  *  abstract interface for custom chips to the amiga abstract graphics driver.
     35       1.1    chopps  *
     36       1.1    chopps  */
     37      1.19        is 
     38      1.19        is #include "opt_amigaccgrf.h"
     39       1.1    chopps 
     40  1.20.8.1  jdolecek #include <sys/cdefs.h>
     41  1.20.8.1  jdolecek __KERNEL_RCSID(0, "$NetBSD: grfabs_cc.c,v 1.20.8.1 2002/02/11 20:06:57 jdolecek Exp $");
     42  1.20.8.1  jdolecek 
     43       1.1    chopps #include <sys/param.h>
     44       1.9    chopps #include <sys/systm.h>
     45       1.1    chopps #include <sys/errno.h>
     46       1.3    chopps #include <sys/queue.h>
     47       1.1    chopps 
     48       1.1    chopps #include <amiga/amiga/custom.h>
     49       1.1    chopps #include <amiga/amiga/cc.h>
     50       1.1    chopps 
     51       1.1    chopps #include <amiga/dev/grfabs_reg.h>
     52       1.1    chopps #include <amiga/dev/grfabs_ccreg.h>
     53       1.1    chopps 
     54       1.1    chopps monitor_t *m_this;
     55       1.1    chopps mdata_t *m_this_data;
     56       1.1    chopps char   *monitor_name = "CCMONITOR";
     57       1.1    chopps monitor_t monitor;
     58       1.1    chopps mdata_t monitor_data;
     59       1.1    chopps cop_t  *null_mode_copper_list;
     60       1.1    chopps 
     61       1.1    chopps #if defined (GRF_PAL)
     62       1.1    chopps #  if defined (GRF_A2024)
     63       1.1    chopps dmode_t pal_a2024_mode;
     64       1.1    chopps dmdata_t pal_a2024_mode_data;
     65       1.1    chopps cop_t  *pal_a2024_frames[F_QD_TOTAL];
     66       1.1    chopps u_char *hedley_init;		/* init bitplane. */
     67       1.1    chopps dmode_t *p24_this;
     68       1.1    chopps dmdata_t *p24_this_data;
     69       1.1    chopps 
     70       1.1    chopps dmode_t pal_hires_dlace_mode;
     71       1.1    chopps dmdata_t pal_hires_dlace_mode_data;
     72       1.1    chopps cop_t  *pal_hires_dlace_frames[F_LACE_TOTAL];
     73       1.1    chopps dmode_t *phdl_this;
     74       1.1    chopps dmdata_t *phdl_this_data;
     75       1.1    chopps #  endif /* GRF_A2024 */
     76       1.1    chopps 
     77       1.7    chopps #  if defined (GRF_AGA)
     78       1.7    chopps dmode_t paga_mode;
     79       1.7    chopps dmdata_t paga_mode_data;
     80       1.7    chopps cop_t *paga_frames[F_TOTAL];
     81       1.7    chopps dmode_t *paga_this;
     82       1.7    chopps dmdata_t *paga_this_data;
     83      1.17    mhitch 
     84       1.7    chopps #  endif /* GRF_AGA */
     85       1.7    chopps 
     86       1.1    chopps dmode_t pal_hires_lace_mode;
     87       1.1    chopps dmdata_t pal_hires_lace_mode_data;
     88       1.1    chopps cop_t  *pal_hires_lace_frames[F_LACE_TOTAL];
     89       1.1    chopps dmode_t *phl_this;
     90       1.1    chopps dmdata_t *phl_this_data;
     91       1.1    chopps 
     92       1.1    chopps dmode_t pal_hires_mode;
     93       1.1    chopps dmdata_t pal_hires_mode_data;
     94       1.1    chopps cop_t  *pal_hires_frames[F_TOTAL];
     95       1.1    chopps dmode_t *ph_this;
     96       1.1    chopps dmdata_t *ph_this_data;
     97       1.1    chopps #endif /* PAL */
     98       1.1    chopps 
     99       1.1    chopps #if defined (GRF_NTSC)
    100       1.1    chopps #  if defined (GRF_A2024)
    101       1.1    chopps dmode_t a2024_mode;
    102       1.1    chopps dmdata_t a2024_mode_data;
    103       1.1    chopps cop_t  *a2024_frames[F_QD_TOTAL];
    104       1.1    chopps u_char *hedley_init;		/* init bitplane. */
    105       1.1    chopps dmode_t *a24_this;
    106       1.1    chopps dmdata_t *a24_this_data;
    107       1.1    chopps 
    108       1.1    chopps dmode_t hires_dlace_mode;
    109       1.1    chopps dmdata_t hires_dlace_mode_data;
    110       1.1    chopps cop_t  *hires_dlace_frames[F_LACE_TOTAL];
    111       1.1    chopps dmode_t *hdl_this;
    112       1.1    chopps dmdata_t *hdl_this_data;
    113       1.1    chopps #  endif /* GRF_A2024 */
    114       1.1    chopps 
    115       1.4    chopps #  if defined (GRF_AGA)
    116       1.4    chopps dmode_t aga_mode;
    117       1.4    chopps dmdata_t aga_mode_data;
    118       1.4    chopps cop_t *aga_frames[F_TOTAL];
    119       1.4    chopps dmode_t *aga_this;
    120       1.4    chopps dmdata_t *aga_this_data;
    121      1.17    mhitch 
    122      1.17    mhitch #if defined (GRF_SUPER72)
    123      1.17    mhitch dmode_t super72_mode;
    124      1.17    mhitch dmdata_t super72_mode_data;
    125      1.17    mhitch cop_t *super72_frames[F_LACE_TOTAL];
    126      1.17    mhitch dmode_t *super72_this;
    127      1.17    mhitch dmdata_t *super72_this_data;
    128      1.17    mhitch #endif /* GRF_SUPER72 */
    129      1.17    mhitch 
    130       1.4    chopps #  endif /* GRF_AGA */
    131       1.4    chopps 
    132       1.1    chopps dmode_t hires_lace_mode;
    133       1.1    chopps dmdata_t hires_lace_mode_data;
    134       1.1    chopps cop_t  *hires_lace_frames[F_LACE_TOTAL];
    135       1.1    chopps dmode_t *hl_this;
    136       1.1    chopps dmdata_t *hl_this_data;
    137       1.1    chopps 
    138       1.1    chopps void    display_hires_view(view_t * v);
    139       1.1    chopps dmode_t hires_mode;
    140       1.1    chopps dmdata_t hires_mode_data;
    141       1.1    chopps cop_t  *hires_frames[F_TOTAL];
    142       1.1    chopps dmode_t *h_this;
    143       1.1    chopps dmdata_t *h_this_data;
    144       1.1    chopps #endif /* GRF_NTSC */
    145       1.1    chopps 
    146       1.4    chopps #ifdef GRF_AGA
    147       1.4    chopps #define	AGA_ENABLE	0x0001
    148       1.4    chopps #define	AGA_ENABLE2	0x0002
    149       1.4    chopps #define AGA_TRACE	0x0004
    150       1.4    chopps #define AGA_TRACE2	0x0008
    151       1.4    chopps #define AGA_VGAONLY	0x0010
    152       1.4    chopps #define AGA_VGA31KHZ	0x0020
    153       1.4    chopps 
    154       1.4    chopps int aga_enable = 0;	/* set by start_c(), or can be patched */
    155  1.20.8.1  jdolecek colormap_t *cc_alloc_aga_colormap(int);
    156  1.20.8.1  jdolecek int cc_use_aga_colormap(view_t *, colormap_t *);
    157       1.4    chopps #endif
    158       1.1    chopps 
    159       1.1    chopps /* monitor functions. */
    160       1.1    chopps monitor_t *
    161  1.20.8.1  jdolecek cc_init_monitor(void)
    162       1.1    chopps {
    163       1.3    chopps 	cop_t  *cp;
    164  1.20.8.1  jdolecek 
    165       1.3    chopps 	if (m_this)
    166       1.3    chopps 		return(m_this);
    167       1.3    chopps 
    168       1.3    chopps 	cc_monitor = m_this = &monitor;
    169       1.3    chopps 	/* turn sprite DMA off. we don't support them yet. */
    170       1.3    chopps 	custom.dmacon = DMAF_SPRITE;
    171       1.8    chopps 
    172       1.8    chopps 	/* makre sure sprite data registers are clear as well */
    173       1.8    chopps 	custom.spr[0].data = 0;
    174       1.8    chopps 	custom.spr[0].datb = 0;
    175       1.3    chopps 
    176       1.3    chopps 	m_this->name = monitor_name;
    177       1.3    chopps 	m_this_data = m_this->data = &monitor_data;
    178       1.3    chopps 
    179       1.3    chopps 	m_this->get_current_mode = get_current_mode;
    180       1.3    chopps 	m_this->vbl_handler = (vbl_handler_func *) monitor_vbl_handler;
    181       1.3    chopps 	m_this->get_next_mode = get_next_mode;
    182       1.3    chopps 	m_this->get_best_mode = get_best_mode;
    183       1.1    chopps 
    184       1.3    chopps 	m_this->alloc_bitmap = alloc_bitmap;
    185       1.3    chopps 	m_this->free_bitmap = free_bitmap;
    186       1.1    chopps 
    187       1.3    chopps 	m_this_data->current_mode = NULL;
    188       1.3    chopps 	LIST_INIT(&m_this_data->modes);
    189       1.1    chopps 
    190       1.3    chopps 	cp = null_mode_copper_list = alloc_chipmem(sizeof(cop_t) * 4);
    191       1.3    chopps 	if (!cp)
    192       1.3    chopps 		panic("no chipmem for grf.");
    193       1.3    chopps 
    194       1.3    chopps 	CMOVE(cp, R_COLOR00, 0x0000);	/* background is black */
    195       1.3    chopps 	CMOVE(cp, R_BPLCON0, 0x0000);	/* no planes to fetch from */
    196       1.3    chopps 	CWAIT(cp, 255, 255);	/* COPEND */
    197       1.3    chopps 	CWAIT(cp, 255, 255);	/* COPEND really */
    198       1.1    chopps 
    199       1.4    chopps 	/* install this list and turn DMA on */
    200       1.3    chopps 	custom.cop1lc = PREP_DMA_MEM(null_mode_copper_list);
    201       1.3    chopps 	custom.copjmp1 = 0;
    202       1.3    chopps 	custom.dmacon = DMAF_SETCLR | DMAF_MASTER | DMAF_RASTER \
    203       1.3    chopps 	    |DMAF_COPPER;
    204       1.1    chopps 
    205       1.3    chopps 	cc_init_modes();
    206       1.3    chopps 	LIST_INSERT_HEAD(monitors, m_this, link);
    207       1.1    chopps 	return (m_this);
    208       1.1    chopps }
    209       1.1    chopps 
    210       1.1    chopps void
    211  1.20.8.1  jdolecek monitor_vbl_handler(monitor_t *m)
    212       1.1    chopps {
    213       1.3    chopps 	dmdata_t *dmd;
    214       1.3    chopps 
    215       1.3    chopps 	if (m_this_data->current_mode == NULL)
    216       1.3    chopps 		return;
    217       1.3    chopps 
    218       1.3    chopps 	dmd = DMDATA(m_this_data->current_mode);
    219       1.3    chopps 	if (dmd)
    220       1.3    chopps 		dmd->vbl_handler(m_this_data->current_mode);
    221       1.1    chopps }
    222       1.1    chopps 
    223       1.1    chopps dmode_t *
    224  1.20.8.1  jdolecek get_current_mode(void)
    225       1.1    chopps {
    226       1.3    chopps 	if (m_this_data->current_mode)
    227       1.3    chopps 		return(m_this_data->current_mode);
    228       1.3    chopps 	else
    229       1.3    chopps 		return(NULL);
    230       1.1    chopps }
    231       1.1    chopps 
    232       1.1    chopps dmode_t *
    233  1.20.8.1  jdolecek get_next_mode(dmode_t *d)
    234       1.1    chopps {
    235       1.3    chopps 	if (d)
    236       1.3    chopps 		return(d->link.le_next);
    237       1.3    chopps 	return(m_this_data->modes.lh_first);
    238       1.1    chopps }
    239       1.1    chopps 
    240       1.1    chopps /* XXX needs to have more control attributes */
    241       1.1    chopps dmode_t *
    242  1.20.8.1  jdolecek get_best_mode(dimen_t *size, u_char depth)
    243       1.1    chopps {
    244       1.3    chopps 	dmode_t *save;
    245       1.3    chopps 	dmode_t *dm;
    246      1.11     veego 	long    dt = 0, dx, dy, ct;
    247       1.3    chopps 	dmdata_t *dmd;
    248       1.3    chopps 
    249       1.3    chopps 	save = NULL;
    250       1.3    chopps 	dm = m_this_data->modes.lh_first;
    251       1.3    chopps 	while (dm != NULL) {
    252       1.3    chopps 		dmd = dm->data;
    253       1.1    chopps 		if (depth > dmd->max_depth || depth < dmd->min_depth) {
    254       1.3    chopps 			dm = dm->link.le_next;
    255       1.1    chopps 			continue;
    256       1.3    chopps 		} else if (size->width > dmd->max_size.width ||
    257       1.1    chopps 		    size->height > dmd->max_size.height) {
    258       1.3    chopps 			dm = dm->link.le_next;
    259       1.1    chopps 			continue;
    260       1.3    chopps 		} else if (size->width < dmd->min_size.width ||
    261       1.1    chopps 		    size->height < dmd->min_size.height) {
    262       1.3    chopps 			dm = dm->link.le_next;
    263       1.1    chopps 			continue;
    264       1.1    chopps 		}
    265       1.3    chopps 		dx = abs(dm->nominal_size.width - size->width);
    266       1.3    chopps 		dy = abs(dm->nominal_size.height - size->height);
    267       1.1    chopps 		ct = dx + dy;
    268       1.1    chopps 
    269       1.1    chopps 		if (ct < dt || save == NULL) {
    270       1.3    chopps 			save = dm;
    271       1.1    chopps 			dt = ct;
    272       1.1    chopps 		}
    273       1.3    chopps 		dm = dm->link.le_next;
    274       1.1    chopps 	}
    275       1.1    chopps 	return (save);
    276       1.1    chopps }
    277       1.1    chopps /* bitmap functions */
    278       1.1    chopps bmap_t *
    279  1.20.8.1  jdolecek alloc_bitmap(u_short width, u_short height, u_short depth, u_short flags)
    280       1.1    chopps {
    281       1.1    chopps 	int     i;
    282       1.1    chopps 	u_long  total_size;
    283       1.4    chopps #ifdef GRF_AGA
    284       1.4    chopps 	u_short lwpr = (flags & BMF_ALIGN64) ? ((width + 63) / 64) * 2 :
    285       1.4    chopps 	    (width + 31) / 32;			/* AGA needs 64 bit align */
    286       1.4    chopps #else
    287       1.1    chopps 	u_short lwpr = (width + 31) / 32;
    288       1.4    chopps #endif
    289       1.1    chopps 	u_short wpr = lwpr << 1;
    290       1.1    chopps 	u_short bpr = wpr << 1;
    291       1.1    chopps 	u_short array_size = sizeof(u_char *) * depth;
    292       1.1    chopps 	u_long  plane_size = bpr * height;
    293       1.1    chopps 	u_short temp_size = bpr + sizeof(u_long);
    294       1.1    chopps 	bmap_t *bm;
    295       1.1    chopps 
    296       1.1    chopps 	/* note the next allocation will give everything, also note that all
    297       1.1    chopps 	 * the stuff we want (including bitmaps) will be long short aligned.
    298       1.4    chopps 	 * This is a function of the data being allocated and the fact that
    299       1.1    chopps 	 * alloc_chipmem() returns long short aligned data. note also that
    300       1.1    chopps 	 * each row of the bitmap is long word aligned and made of exactly n
    301       1.1    chopps 	 * longwords. -ch */
    302       1.1    chopps 
    303       1.1    chopps 	/* Sigh, it seems for mapping to work we need the bitplane data to 1:
    304       1.1    chopps 	 * be aligned on a page boundry. 2: be n pages large.
    305  1.20.8.1  jdolecek 	 *
    306       1.4    chopps 	 * why? becuase the user gets a page aligned address, if this is before
    307       1.1    chopps 	 * your allocation, too bad.  Also it seems that the mapping routines
    308       1.1    chopps 	 * do not watch to closely to the allowable length. so if you go over
    309       1.1    chopps 	 * n pages by less than another page, the user gets to write all over
    310       1.1    chopps 	 * the entire page.  Since you did not allocate up to a page boundry
    311       1.1    chopps 	 * (or more) the user writes into someone elses memory. -ch */
    312      1.20        is #ifdef __powerpc__
    313      1.20        is #define m68k_round_page(x)	((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
    314      1.20        is #endif
    315      1.16     veego 	total_size = m68k_round_page(plane_size * depth) +	/* for length */
    316       1.1    chopps 	    (temp_size) + (array_size) + sizeof(bmap_t) +
    317       1.1    chopps 	    NBPG;		/* for alignment */
    318       1.1    chopps 	bm = alloc_chipmem(total_size);
    319       1.1    chopps 	if (bm) {
    320       1.1    chopps 		if (flags & BMF_CLEAR) {
    321       1.1    chopps 			bzero(bm, total_size);
    322       1.1    chopps 		}
    323       1.1    chopps 		bm->bytes_per_row = bpr;
    324       1.1    chopps 		bm->rows = height;
    325       1.1    chopps 		bm->depth = depth;
    326       1.1    chopps 		bm->flags = flags;
    327       1.1    chopps 		bm->plane = (u_char **) & bm[1];
    328       1.1    chopps 		bm->blit_temp = ((u_char *) bm->plane) + array_size;
    329      1.16     veego 		bm->plane[0] = (u_char *) m68k_round_page((u_long)
    330      1.11     veego 						(bm->blit_temp + temp_size));
    331       1.1    chopps 		if (flags & BMF_INTERLEAVED) {
    332       1.1    chopps 			bm->row_mod = bm->bytes_per_row * (depth - 1);
    333       1.1    chopps 			for (i = 1; i < depth; i++) {
    334       1.1    chopps 				bm->plane[i] = bm->plane[i - 1] + bpr;
    335       1.1    chopps 			}
    336       1.1    chopps 		} else {
    337       1.1    chopps 			bm->row_mod = 0;
    338       1.1    chopps 			for (i = 1; i < depth; i++) {
    339       1.1    chopps 				bm->plane[i] = bm->plane[i - 1] + plane_size;
    340       1.1    chopps 			}
    341       1.1    chopps 		}
    342       1.1    chopps 		bm->hardware_address = PREP_DMA_MEM(bm->plane[0]);
    343       1.1    chopps 		return (bm);
    344       1.1    chopps 	}
    345       1.1    chopps 	return (NULL);
    346       1.1    chopps }
    347       1.1    chopps 
    348       1.1    chopps 
    349       1.1    chopps void
    350  1.20.8.1  jdolecek free_bitmap(bmap_t *bm)
    351       1.1    chopps {
    352  1.20.8.1  jdolecek 	if (bm)
    353       1.1    chopps 		free_chipmem(bm);
    354       1.1    chopps }
    355       1.1    chopps /* load a new mode into the current display, if NULL shut display off. */
    356       1.1    chopps void
    357  1.20.8.1  jdolecek cc_load_mode(dmode_t *d)
    358       1.1    chopps {
    359       1.1    chopps 	if (d) {
    360       1.1    chopps 		m_this_data->current_mode = d;
    361      1.20        is #ifdef __powerpc__	/* XXX ???? */
    362      1.20        is 		custom.cop1lc = PREP_DMA_MEM(DMDATA(d)->frames[F_LONG]);
    363      1.20        is 		custom.copjmp1 = 0;
    364      1.20        is #endif
    365       1.1    chopps 		return;
    366       1.1    chopps 	}
    367       1.1    chopps 	/* turn off display */
    368       1.1    chopps 	m_this_data->current_mode = NULL;
    369       1.1    chopps 	wait_tof();
    370       1.1    chopps 	wait_tof();
    371       1.1    chopps 	custom.cop1lc = PREP_DMA_MEM(null_mode_copper_list);
    372       1.1    chopps }
    373       1.1    chopps /*
    374       1.1    chopps  * CC Mode Stuff.
    375       1.1    chopps  */
    376       1.1    chopps 
    377       1.1    chopps dmode_t *(*mode_init_funcs[]) (void) = {
    378       1.1    chopps #if defined (GRF_NTSC)
    379       1.1    chopps #if defined (GRF_A2024)
    380       1.1    chopps 	cc_init_ntsc_a2024,
    381       1.1    chopps 	cc_init_ntsc_hires_dlace,
    382       1.1    chopps #endif /* GRF_A2024 */
    383       1.1    chopps 	cc_init_ntsc_hires_lace,
    384       1.1    chopps 	cc_init_ntsc_hires,
    385       1.4    chopps #if defined (GRF_AGA)
    386       1.4    chopps 	cc_init_ntsc_aga,
    387      1.17    mhitch #if defined (GRF_SUPER72)
    388      1.17    mhitch 	cc_init_super72,
    389      1.17    mhitch #endif /* GRF_SUPER72 */
    390       1.4    chopps #endif /* GRF_AGA */
    391       1.1    chopps #endif /* GRF_NTSC */
    392       1.1    chopps #if defined (GRF_PAL)
    393       1.1    chopps #if defined (GRF_A2024)
    394       1.1    chopps 	cc_init_pal_a2024,
    395       1.1    chopps 	cc_init_pal_hires_dlace,
    396       1.1    chopps #endif /* GRF_A2024 */
    397       1.1    chopps 	cc_init_pal_hires_lace,
    398       1.1    chopps 	cc_init_pal_hires,
    399       1.7    chopps #if defined (GRF_AGA)
    400       1.7    chopps 	cc_init_pal_aga,
    401       1.7    chopps #endif /* GRF_AGA */
    402       1.1    chopps #endif /* GRF_PAL */
    403       1.1    chopps 	NULL
    404       1.1    chopps };
    405       1.1    chopps 
    406       1.1    chopps int
    407  1.20.8.1  jdolecek cc_init_modes(void)
    408       1.1    chopps {
    409       1.1    chopps 	int     i = 0;
    410       1.1    chopps 	int     error = 0;
    411       1.1    chopps 	while (mode_init_funcs[i]) {
    412       1.1    chopps 		mode_init_funcs[i] ();
    413       1.1    chopps 		i++;
    414       1.1    chopps 	}
    415       1.1    chopps 	return (error);
    416       1.1    chopps }
    417       1.1    chopps 
    418       1.1    chopps monitor_t *
    419  1.20.8.1  jdolecek cc_get_monitor(dmode_t *d)
    420       1.1    chopps {
    421       1.1    chopps 	return (DMDATA(d)->monitor);
    422       1.1    chopps }
    423       1.1    chopps 
    424       1.1    chopps view_t *
    425  1.20.8.1  jdolecek cc_get_current_view(dmode_t *d)
    426       1.1    chopps {
    427       1.1    chopps 	return (DMDATA(d)->current_view);
    428       1.1    chopps }
    429       1.1    chopps 
    430       1.1    chopps 
    431       1.1    chopps view_t *
    432  1.20.8.1  jdolecek cc_alloc_view(dmode_t *mode, dimen_t *dim, u_char depth)
    433       1.1    chopps {
    434       1.1    chopps 	view_t *v = alloc_chipmem(sizeof(*v) + sizeof(vdata_t));
    435       1.1    chopps 	if (v) {
    436       1.4    chopps 		bmap_t *bm = cc_monitor->alloc_bitmap(dim->width, dim->height,
    437       1.4    chopps 		    depth, BMF_CLEAR | (DMDATA(mode)->max_depth == 8 ? BMF_ALIGN64 : 0));
    438       1.1    chopps 		if (bm) {
    439       1.1    chopps 			box_t   box;
    440       1.1    chopps 
    441       1.1    chopps 			v->data = &v[1];	/* at the end of view */
    442       1.1    chopps 			VDATA(v)->colormap = DMDATA(mode)->alloc_colormap(depth);
    443       1.1    chopps 			if (VDATA(v)->colormap) {
    444       1.1    chopps 				INIT_BOX(&box, 0, 0, dim->width, dim->height);
    445       1.1    chopps 				cc_init_view(v, bm, mode, &box);
    446       1.1    chopps 				return (v);
    447       1.1    chopps 			}
    448       1.1    chopps 			cc_monitor->free_bitmap(bm);
    449       1.1    chopps 		}
    450       1.1    chopps 		free_chipmem(v);
    451       1.1    chopps 	}
    452       1.1    chopps 	return (NULL);
    453       1.1    chopps }
    454       1.1    chopps 
    455       1.1    chopps colormap_t *
    456  1.20.8.1  jdolecek cc_alloc_colormap(int depth)
    457       1.1    chopps {
    458       1.1    chopps 	u_long  size = 1U << depth, i;
    459       1.1    chopps 	colormap_t *cm = alloc_chipmem(sizeof(u_long) * size + sizeof(*cm));
    460       1.1    chopps 
    461       1.1    chopps 	if (cm) {
    462       1.1    chopps 		cm->type = CM_COLOR;
    463       1.1    chopps 		cm->red_mask = 0x0F;
    464       1.1    chopps 		cm->green_mask = 0x0F;
    465       1.1    chopps 		cm->blue_mask = 0x0F;
    466       1.1    chopps 		cm->first = 0;
    467       1.1    chopps 		cm->size = size;
    468       1.1    chopps 		cm->entry = (u_long *) & cm[1];	/* table directly after. */
    469       1.4    chopps 		for (i = 0; i < size; i++) {
    470       1.4    chopps 			cm->entry[i] = CM_WTOL(cc_default_colors[i&31]);
    471       1.4    chopps 		}
    472       1.4    chopps 		return (cm);
    473       1.4    chopps 	}
    474       1.4    chopps 	return (NULL);
    475       1.4    chopps }
    476       1.4    chopps 
    477       1.4    chopps #ifdef GRF_AGA
    478       1.4    chopps colormap_t *
    479  1.20.8.1  jdolecek cc_alloc_aga_colormap(int depth)
    480       1.4    chopps {
    481       1.4    chopps 	u_long  size = 1U << depth, i;
    482       1.4    chopps 	colormap_t *cm = alloc_chipmem(sizeof(u_long) * size + sizeof(*cm));
    483       1.4    chopps 
    484       1.4    chopps 	if (cm) {
    485       1.4    chopps 		cm->type = CM_COLOR;
    486       1.4    chopps 		cm->red_mask = 0x0FF;
    487       1.4    chopps 		cm->green_mask = 0x0FF;
    488       1.4    chopps 		cm->blue_mask = 0x0FF;
    489       1.4    chopps 		cm->first = 0;
    490       1.4    chopps 		cm->size = size;
    491       1.4    chopps 		cm->entry = (u_long *) & cm[1];	/* table directly after. */
    492       1.4    chopps 		for (i = 0; i < size; i++) {
    493       1.4    chopps 			cm->entry[i] = CM_WTOL(cc_default_colors[i&31]) |
    494       1.4    chopps 			    (CM_WTOL(cc_default_colors[i&31]) << 4);
    495       1.1    chopps 		}
    496       1.1    chopps 		return (cm);
    497       1.1    chopps 	}
    498       1.1    chopps 	return (NULL);
    499       1.1    chopps }
    500       1.4    chopps #endif
    501       1.1    chopps 
    502       1.1    chopps int
    503  1.20.8.1  jdolecek cc_colormap_checkvals(colormap_t *vcm, colormap_t *cm, int use)
    504       1.1    chopps {
    505       1.1    chopps 	if (use) {
    506       1.1    chopps 		/* check to see if its the view's colormap, if so just do
    507       1.1    chopps 		 * update. */
    508       1.1    chopps 		if (vcm != cm) {
    509      1.11     veego 			if (cm->first >= vcm->size ||
    510      1.11     veego 			   (cm->first + cm->size) > (cm->first + vcm->size) ||
    511       1.1    chopps 			    cm->type != vcm->type) {
    512       1.1    chopps 				return (0);
    513       1.1    chopps 			}
    514       1.1    chopps 			switch (vcm->type) {
    515       1.1    chopps 			case CM_COLOR:
    516       1.1    chopps 				if (cm->red_mask != vcm->red_mask ||
    517       1.1    chopps 				    cm->green_mask != vcm->green_mask ||
    518       1.1    chopps 				    cm->blue_mask != vcm->blue_mask) {
    519       1.1    chopps 					return (0);
    520       1.1    chopps 				}
    521       1.1    chopps 				break;
    522       1.1    chopps 			case CM_GREYSCALE:
    523       1.1    chopps 				if (cm->grey_mask != vcm->grey_mask) {
    524       1.1    chopps 					return (0);
    525       1.1    chopps 				}
    526       1.1    chopps 				break;
    527       1.1    chopps 			}
    528       1.1    chopps 		}
    529       1.1    chopps 	} else {
    530      1.11     veego 		if (cm->first >= vcm->size ||
    531      1.11     veego 		   (cm->first + cm->size) > (cm->first + vcm->size)) {
    532       1.1    chopps 			return (0);
    533       1.1    chopps 		}
    534       1.1    chopps 	}
    535       1.1    chopps 	return (1);
    536       1.1    chopps }
    537  1.20.8.1  jdolecek 
    538       1.1    chopps /* does sanity check on values */
    539       1.1    chopps int
    540  1.20.8.1  jdolecek cc_get_colormap(view_t *v, colormap_t *cm)
    541       1.1    chopps {
    542       1.1    chopps 	colormap_t *vcm = VDATA(v)->colormap;
    543       1.1    chopps 	int     i;
    544       1.1    chopps 
    545       1.1    chopps 	if (!cc_colormap_checkvals(vcm, cm, 0)) {
    546       1.1    chopps 		return (EINVAL);
    547       1.1    chopps 	}
    548       1.1    chopps 	cm->type = vcm->type;
    549       1.1    chopps 
    550       1.1    chopps 	switch (vcm->type) {
    551       1.1    chopps 	case CM_COLOR:
    552       1.1    chopps 		cm->red_mask = vcm->red_mask;
    553       1.1    chopps 		cm->green_mask = vcm->green_mask;
    554       1.1    chopps 		cm->blue_mask = vcm->blue_mask;
    555       1.1    chopps 		break;
    556       1.1    chopps 	case CM_GREYSCALE:
    557       1.1    chopps 		cm->grey_mask = vcm->grey_mask;
    558       1.1    chopps 		break;
    559       1.1    chopps 	}
    560       1.1    chopps 
    561       1.1    chopps 	/* copy entries into colormap. */
    562       1.1    chopps 	for (i = cm->first; i < (cm->first + cm->size); i++) {
    563       1.1    chopps 		cm->entry[i] = vcm->entry[i];
    564       1.1    chopps 	}
    565       1.1    chopps 	return (0);
    566       1.1    chopps }
    567       1.1    chopps 
    568       1.1    chopps /* does sanity check on values */
    569       1.1    chopps int
    570  1.20.8.1  jdolecek cc_use_colormap(view_t *v, colormap_t *cm)
    571       1.1    chopps {
    572       1.1    chopps 	colormap_t *vcm = VDATA(v)->colormap;
    573       1.1    chopps 	int     s, i;
    574       1.1    chopps 
    575       1.1    chopps 	if (!cc_colormap_checkvals(vcm, cm, 1)) {
    576       1.1    chopps 		return (EINVAL);
    577       1.1    chopps 	}
    578       1.1    chopps 	/* check to see if its the view's colormap, if so just do update. */
    579       1.1    chopps 	if (vcm != cm) {
    580       1.1    chopps 		/* copy entries into colormap. */
    581       1.1    chopps 		for (i = cm->first; i < (cm->first + cm->size); i++) {
    582       1.1    chopps 			vcm->entry[i] = cm->entry[i];
    583       1.1    chopps 		}
    584       1.1    chopps 	}
    585       1.1    chopps 	s = spltty();
    586       1.1    chopps 
    587       1.1    chopps 	/* is view currently being displayed? */
    588       1.1    chopps 	if (VDATA(v)->flags & VF_DISPLAY) {
    589       1.1    chopps 		/* yes, update the copper lists */
    590       1.1    chopps 		cop_t  *tmp, *cp;
    591       1.1    chopps 		int     nframes = 1, j;
    592       1.1    chopps 
    593       1.1    chopps 		if (DMDATA(VDATA(v)->mode)->flags & DMF_INTERLACE) {
    594       1.1    chopps 			nframes = 2;
    595       1.1    chopps 		}
    596       1.1    chopps 		for (i = 0; i < nframes; i++) {
    597       1.1    chopps 			cp = DMDATA(VDATA(v)->mode)->frames[i];
    598       1.1    chopps 
    599       1.1    chopps 			tmp = find_copper_inst(cp, CI_MOVE(R_COLOR07));
    600       1.1    chopps 			tmp -= 7;
    601       1.1    chopps 
    602       1.4    chopps 			for (j = 0; j < 32; j++) {
    603      1.11     veego 				CMOVE(tmp, (R_COLOR00 + (j << 1)),
    604      1.11     veego 					CM_LTOW(vcm->entry[j]));
    605       1.1    chopps 			}
    606       1.1    chopps 		}
    607       1.1    chopps 	}
    608       1.1    chopps 	splx(s);
    609       1.1    chopps 	return (0);
    610       1.1    chopps }
    611       1.4    chopps 
    612       1.4    chopps #ifdef GRF_AGA
    613       1.4    chopps /* does sanity check on values */
    614       1.4    chopps int
    615  1.20.8.1  jdolecek cc_use_aga_colormap(view_t *v, colormap_t *cm)
    616       1.4    chopps {
    617       1.4    chopps 	colormap_t *vcm = VDATA(v)->colormap;
    618       1.4    chopps 	int     s, i;
    619       1.4    chopps 
    620       1.4    chopps 	if (!cc_colormap_checkvals(vcm, cm, 1)) {
    621       1.4    chopps 		return (EINVAL);
    622       1.4    chopps 	}
    623       1.4    chopps 	/* check to see if its the view's colormap, if so just do update. */
    624       1.4    chopps 	if (vcm != cm) {
    625       1.4    chopps 		/* copy entries into colormap. */
    626       1.4    chopps 		for (i = cm->first; i < (cm->first + cm->size); i++) {
    627       1.4    chopps 			vcm->entry[i] = cm->entry[i];
    628       1.4    chopps 		}
    629       1.4    chopps 	}
    630       1.4    chopps 	s = spltty();
    631       1.4    chopps 
    632       1.4    chopps 	/* is view currently being displayed? */
    633       1.4    chopps 	if (VDATA(v)->flags & VF_DISPLAY) {
    634       1.4    chopps 		/* yes, update the copper lists */
    635       1.4    chopps 		cop_t  *tmp, *cp;
    636       1.4    chopps 		int     nframes = 1, j;
    637       1.4    chopps 
    638       1.4    chopps 		if (DMDATA(VDATA(v)->mode)->flags & DMF_INTERLACE) {
    639       1.4    chopps 			nframes = 2;
    640       1.4    chopps 		}
    641       1.4    chopps 		for (i = 0; i < nframes; i++) {
    642       1.4    chopps 			cp = DMDATA(VDATA(v)->mode)->frames[i];
    643       1.4    chopps 
    644       1.5    chopps 			tmp = find_copper_inst(cp, CI_MOVE(R_COLOR00));
    645       1.4    chopps 			for (j = 0; j < vcm->size; j += 32) {
    646       1.4    chopps 				int k;
    647       1.4    chopps 
    648       1.4    chopps 				for (k = 0; k < 32; k++) {
    649       1.4    chopps 					int ce = vcm->entry[j + k] >> 4;
    650      1.11     veego 					CMOVE(tmp, (R_COLOR00 + (k << 1)),
    651      1.11     veego 						CM_LTOW(ce));
    652       1.4    chopps 				}
    653       1.5    chopps 				tmp++;
    654       1.4    chopps 				for (k = 0; k < 32; k++) {
    655       1.4    chopps 					int ce =vcm->entry[j + k];
    656      1.11     veego 					CMOVE(tmp, (R_COLOR00 + (k << 1)),
    657      1.11     veego 						CM_LTOW(ce));
    658       1.4    chopps 				}
    659       1.5    chopps 				tmp++;
    660       1.4    chopps 			}
    661       1.4    chopps 		}
    662       1.4    chopps 	}
    663       1.4    chopps 	splx(s);
    664       1.4    chopps 	return (0);
    665       1.4    chopps }
    666       1.4    chopps #endif
    667       1.4    chopps 
    668       1.1    chopps #if defined (GRF_A2024)
    669       1.1    chopps colormap_t *
    670  1.20.8.1  jdolecek cc_a2024_alloc_colormap(int depth)
    671       1.1    chopps {
    672       1.1    chopps 	u_long  size = 1U << depth, i;
    673       1.1    chopps 	colormap_t *cm = alloc_chipmem(sizeof(u_long) * size + sizeof(*cm));
    674       1.1    chopps 
    675       1.1    chopps 	if (cm) {
    676       1.1    chopps 		cm->type = CM_GREYSCALE;
    677       1.1    chopps 		cm->grey_mask = 0x03;
    678       1.1    chopps 		cm->first = 0;
    679       1.1    chopps 		cm->size = size;
    680       1.1    chopps 		cm->entry = (u_long *) & cm[1];	/* table directly after. */
    681       1.1    chopps 		for (i = 0; i < size; i++) {
    682       1.1    chopps 			cm->entry[i] = CM_WTOL(cc_a2024_default_colors[i]);
    683       1.1    chopps 		}
    684       1.1    chopps 		return (cm);
    685       1.1    chopps 	}
    686       1.1    chopps 	return (NULL);
    687       1.1    chopps }
    688       1.1    chopps 
    689       1.1    chopps int
    690  1.20.8.1  jdolecek cc_a2024_get_colormap(view_t *v, colormap_t *cm)
    691       1.1    chopps {
    692       1.1    chopps 	/* there are no differences (yet) in the way the cm's are stored */
    693       1.1    chopps 	return (cc_get_colormap(v, cm));
    694       1.1    chopps }
    695       1.1    chopps 
    696       1.1    chopps int
    697  1.20.8.1  jdolecek cc_a2024_use_colormap(view_t *v, colormap_t *cm)
    698       1.1    chopps {
    699       1.1    chopps 	colormap_t *vcm = VDATA(v)->colormap;
    700       1.1    chopps 	int     s, i;
    701       1.1    chopps 
    702       1.1    chopps 	if (!cc_colormap_checkvals(vcm, cm, 1)) {
    703       1.1    chopps 		return (EINVAL);
    704       1.1    chopps 	}
    705       1.1    chopps 	/* check to see if its the view's colormap, if so just do update. */
    706       1.1    chopps 	if (vcm != cm) {
    707       1.1    chopps 		/* copy entries into colormap. */
    708       1.1    chopps 		for (i = cm->first; i < (cm->first + cm->size); i++) {
    709       1.1    chopps 			vcm->entry[i] = cm->entry[i];
    710       1.1    chopps 		}
    711       1.1    chopps 	}
    712       1.1    chopps 	s = spltty();
    713       1.1    chopps 
    714       1.1    chopps 	/* is view currently being displayed? */
    715       1.1    chopps 	if (VDATA(v)->flags & VF_DISPLAY) {
    716       1.1    chopps 		/* yes, update the copper lists */
    717       1.1    chopps 		cop_t  *tmp, *cp;
    718       1.1    chopps 		int     nframes = 2, nregs = cm->size == 4 ? 16 : 8, j;
    719       1.1    chopps 
    720       1.1    chopps 		if (DMDATA(VDATA(v)->mode)->flags & DMF_HEDLEY_EXP) {
    721       1.1    chopps 			nframes = 4;
    722       1.1    chopps 		}
    723       1.1    chopps 		for (i = 0; i < nframes; i++) {
    724       1.1    chopps 			cp = DMDATA(VDATA(v)->mode)->frames[i];
    725       1.1    chopps 
    726       1.1    chopps 			tmp = find_copper_inst(cp, CI_MOVE(R_COLOR07));
    727       1.1    chopps 			tmp -= 7;
    728       1.1    chopps 
    729       1.1    chopps 			for (j = 0; j < nregs; j++) {
    730      1.11     veego 				CMOVE(tmp, (R_COLOR00 + (j << 1)),
    731      1.11     veego 					A2024_CM_TO_CR(vcm, j));
    732       1.1    chopps 			}
    733       1.1    chopps 		}
    734       1.1    chopps 	}
    735       1.1    chopps 	splx(s);
    736       1.1    chopps 	return (0);
    737       1.1    chopps }
    738       1.1    chopps #endif /* GRF_A2024 */
    739       1.1    chopps 
    740       1.1    chopps 
    741       1.1    chopps /*
    742       1.1    chopps  * CC View stuff.
    743       1.1    chopps  */
    744       1.1    chopps 
    745       1.1    chopps void
    746  1.20.8.1  jdolecek cc_init_view(view_t *v, bmap_t *bm, dmode_t *mode, box_t *dbox)
    747       1.1    chopps {
    748       1.1    chopps 	vdata_t *vd = VDATA(v);
    749       1.1    chopps 	v->bitmap = bm;
    750       1.1    chopps 	vd->mode = mode;
    751       1.1    chopps 	bcopy(dbox, &v->display, sizeof(box_t));
    752       1.1    chopps 
    753       1.1    chopps 	v->display_view = DMDATA(vd->mode)->display_view;
    754       1.1    chopps 	v->use_colormap = DMDATA(vd->mode)->use_colormap;
    755       1.1    chopps 	v->get_colormap = DMDATA(vd->mode)->get_colormap;
    756       1.1    chopps 	v->free_view = cc_free_view;
    757       1.1    chopps 	v->get_display_mode = cc_get_display_mode;
    758       1.1    chopps 	v->remove_view = cc_remove_view;
    759       1.1    chopps }
    760       1.1    chopps 
    761       1.1    chopps void
    762  1.20.8.1  jdolecek cc_free_view(view_t *v)
    763       1.1    chopps {
    764       1.1    chopps 	if (v) {
    765       1.1    chopps 		v->remove_view(v);
    766       1.4    chopps 		free_chipmem(VDATA(v)->colormap);
    767       1.1    chopps 		cc_monitor->free_bitmap(v->bitmap);
    768       1.1    chopps 		free_chipmem(v);
    769       1.1    chopps 	}
    770       1.1    chopps }
    771       1.1    chopps 
    772       1.1    chopps void
    773  1.20.8.1  jdolecek cc_remove_view(view_t *v)
    774       1.1    chopps {
    775       1.1    chopps 	dmode_t *mode = VDATA(v)->mode;
    776       1.1    chopps 
    777       1.1    chopps 	if (MDATA(cc_monitor)->current_mode == mode) {
    778       1.1    chopps 		if (DMDATA(mode)->current_view == v) {
    779       1.1    chopps 			cc_load_mode(NULL);
    780       1.1    chopps 		}
    781       1.1    chopps 	}
    782       1.1    chopps 	if (DMDATA(mode)->current_view == v) {
    783       1.1    chopps 		DMDATA(mode)->current_view = NULL;
    784       1.1    chopps 	}
    785       1.1    chopps 	VDATA(v)->flags &= ~VF_DISPLAY;
    786       1.1    chopps }
    787       1.1    chopps 
    788       1.1    chopps dmode_t *
    789  1.20.8.1  jdolecek cc_get_display_mode(view_t *v)
    790       1.1    chopps {
    791       1.1    chopps 	return (VDATA(v)->mode);
    792       1.1    chopps }
    793       1.1    chopps 
    794       1.1    chopps void
    795  1.20.8.1  jdolecek cc_mode_vbl_handler(dmode_t *d)
    796       1.1    chopps {
    797       1.1    chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
    798       1.1    chopps 
    799       1.1    chopps 	if (vp < 12) {
    800       1.2    chopps 		custom.cop1lc = PREP_DMA_MEM(DMDATA(d)->frames[F_LONG]);
    801       1.1    chopps 		custom.copjmp1 = 0;
    802       1.1    chopps 	}
    803       1.1    chopps }
    804       1.1    chopps 
    805       1.1    chopps void
    806  1.20.8.1  jdolecek cc_lace_mode_vbl_handler(dmode_t *d)
    807       1.1    chopps {
    808       1.1    chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
    809       1.1    chopps 
    810       1.1    chopps 	if (vp < 12) {
    811       1.1    chopps 		if (custom.vposr & 0x8000) {
    812       1.1    chopps 			custom.cop1lc = PREP_DMA_MEM(DMDATA(d)->frames[F_LACE_LONG]);
    813       1.1    chopps 		} else {
    814       1.1    chopps 			custom.cop1lc = PREP_DMA_MEM(DMDATA(d)->frames[F_LACE_SHORT]);
    815       1.1    chopps 		}
    816       1.1    chopps 		custom.copjmp1 = 0;
    817       1.1    chopps 	}
    818       1.1    chopps }
    819       1.1    chopps 
    820       1.1    chopps /*
    821       1.1    chopps  * Modes. (ick)
    822       1.1    chopps  */
    823       1.1    chopps 
    824       1.1    chopps /*
    825       1.1    chopps  * NTSC Modes
    826       1.1    chopps  */
    827       1.1    chopps 
    828       1.1    chopps #if defined (GRF_NTSC)
    829       1.1    chopps 
    830       1.1    chopps dmode_t *
    831  1.20.8.1  jdolecek cc_init_ntsc_hires(void)
    832       1.1    chopps {
    833       1.4    chopps 	/* this function should only be called once. */
    834       1.1    chopps 	if (!h_this) {
    835       1.1    chopps 		u_short len = std_copper_list_len;
    836       1.1    chopps 
    837       1.1    chopps 		h_this = &hires_mode;
    838       1.1    chopps 		h_this_data = &hires_mode_data;
    839       1.1    chopps 		bzero(h_this, sizeof(dmode_t));
    840       1.1    chopps 		bzero(h_this_data, sizeof(dmdata_t));
    841       1.1    chopps 
    842       1.4    chopps 		h_this->name = "ntsc: hires";
    843       1.1    chopps 		h_this->nominal_size.width = 640;
    844       1.1    chopps 		h_this->nominal_size.height = 200;
    845       1.1    chopps 		h_this_data->max_size.width = 724;
    846       1.1    chopps 		h_this_data->max_size.height = 242;
    847       1.1    chopps 		h_this_data->min_size.width = 320;
    848       1.1    chopps 		h_this_data->min_size.height = 100;
    849       1.1    chopps 		h_this_data->min_depth = 1;
    850       1.1    chopps 		h_this_data->max_depth = 4;
    851       1.1    chopps 		h_this->data = h_this_data;
    852       1.1    chopps 
    853       1.1    chopps 		h_this->get_monitor = cc_get_monitor;
    854       1.1    chopps 		h_this->alloc_view = cc_alloc_view;
    855       1.1    chopps 		h_this->get_current_view = cc_get_current_view;
    856       1.1    chopps 
    857       1.1    chopps 		h_this_data->use_colormap = cc_use_colormap;
    858       1.1    chopps 		h_this_data->get_colormap = cc_get_colormap;
    859       1.1    chopps 		h_this_data->alloc_colormap = cc_alloc_colormap;
    860       1.1    chopps 		h_this_data->display_view = display_hires_view;
    861       1.1    chopps 		h_this_data->monitor = cc_monitor;
    862       1.1    chopps 
    863       1.1    chopps 		h_this_data->frames = hires_frames;
    864      1.11     veego 		h_this_data->frames[F_LONG] =
    865      1.11     veego 			alloc_chipmem(std_copper_list_size * F_TOTAL);
    866       1.1    chopps 		if (!h_this_data->frames[F_LONG]) {
    867       1.1    chopps 			panic("couldn't get chipmem for copper list");
    868       1.1    chopps 		}
    869      1.11     veego 		h_this_data->frames[F_STORE_LONG] =
    870      1.11     veego 			&h_this_data->frames[F_LONG][len];
    871       1.1    chopps 
    872      1.11     veego 		bcopy(std_copper_list, h_this_data->frames[F_STORE_LONG],
    873      1.11     veego 			std_copper_list_size);
    874      1.11     veego 		bcopy(std_copper_list, h_this_data->frames[F_LONG],
    875      1.11     veego 			std_copper_list_size);
    876       1.1    chopps 
    877       1.1    chopps 		h_this_data->bplcon0 = 0x8200 | USE_CON3;	/* hires, color
    878       1.4    chopps 								 * composite enable */
    879       1.1    chopps 		h_this_data->std_start_x = STANDARD_VIEW_X;
    880       1.1    chopps 		h_this_data->std_start_y = STANDARD_VIEW_Y;
    881      1.11     veego 		h_this_data->vbl_handler =
    882      1.11     veego 			(vbl_handler_func *) cc_mode_vbl_handler;
    883      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
    884       1.1    chopps 		h_this_data->beamcon0 = STANDARD_NTSC_BEAMCON;
    885       1.1    chopps #endif
    886       1.1    chopps 
    887       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, h_this, link);
    888       1.1    chopps 	}
    889       1.1    chopps 	return (h_this);
    890       1.1    chopps }
    891       1.1    chopps 
    892       1.1    chopps void
    893  1.20.8.1  jdolecek display_hires_view(view_t *v)
    894       1.1    chopps {
    895       1.1    chopps 	if (h_this_data->current_view != v) {
    896       1.1    chopps 		vdata_t *vd = VDATA(v);
    897       1.1    chopps 		cop_t  *cp = h_this_data->frames[F_STORE_LONG], *tmp;
    898       1.1    chopps 		int     depth = v->bitmap->depth, i;
    899       1.1    chopps 		int     hstart, hstop, vstart, vstop, j;
    900       1.1    chopps 		int     x, y, w = v->display.width, h = v->display.height;
    901       1.1    chopps 		u_short ddfstart, ddfwidth, con1;
    902       1.1    chopps 
    903       1.1    chopps 		/* round down to nearest even width */
    904       1.1    chopps 		/* w &= 0xfffe; */
    905       1.1    chopps 		/* calculate datafetch width. */
    906       1.1    chopps 
    907       1.1    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
    908       1.1    chopps 
    909       1.4    chopps 		/* This will center the any overscanned display */
    910       1.1    chopps 		/* and allow user to modify. */
    911       1.1    chopps 		x = v->display.x + h_this_data->std_start_x - ((w - 640) >> 2);
    912       1.1    chopps 		y = v->display.y + h_this_data->std_start_y - ((h - 200) >> 1);
    913       1.1    chopps 
    914       1.1    chopps 		if (y & 1)
    915       1.1    chopps 			y--;
    916       1.1    chopps 
    917       1.1    chopps 		if (!(x & 1))
    918       1.1    chopps 			x--;
    919       1.1    chopps 
    920       1.1    chopps 		hstart = x;
    921       1.1    chopps 		hstop = x + (w >> 1);
    922       1.1    chopps 		vstart = y;
    923       1.1    chopps 		vstop = y + h;
    924       1.1    chopps 		ddfstart = (hstart - 9) >> 1;
    925       1.1    chopps 
    926       1.1    chopps 		/* check for hardware limits, AGA may allow more..? */
    927       1.1    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
    928       1.1    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
    929       1.1    chopps 			int     d = 0;
    930       1.1    chopps 
    931       1.1    chopps 			/* XXX anyone know the equality properties of
    932       1.1    chopps 			 * intermixed logial AND's */
    933       1.1    chopps 			/* XXX and arithmetic operators? */
    934       1.1    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
    935       1.1    chopps 				d++;
    936       1.1    chopps 			}
    937       1.1    chopps 
    938       1.1    chopps 			ddfstart -= d;
    939       1.1    chopps 			hstart -= d << 1;
    940       1.1    chopps 			hstop -= d << 1;
    941       1.1    chopps 		}
    942       1.1    chopps 		/* correct the datafetch to proper limits. */
    943       1.1    chopps 		/* delay the actual display of the data until we need it. */
    944       1.1    chopps 		ddfstart &= 0xfffc;
    945      1.11     veego 		con1 = ((hstart - 9) - (ddfstart << 1)) |
    946      1.11     veego 			(((hstart - 9) - (ddfstart << 1)) << 4);
    947       1.1    chopps 
    948       1.1    chopps 		if (h_this_data->current_view) {
    949      1.11     veego 			VDATA(h_this_data->current_view)->flags &=
    950      1.11     veego 				~VF_DISPLAY;	/* mark as no longer displayed. */
    951       1.1    chopps 		}
    952       1.1    chopps 		h_this_data->current_view = v;
    953       1.1    chopps 
    954       1.1    chopps 		cp = h_this_data->frames[F_STORE_LONG];
    955      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
    956       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON3));
    957       1.4    chopps 		tmp->cp.inst.operand = 0x0020;
    958       1.4    chopps #if defined GRF_AGA
    959       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
    960       1.4    chopps 		tmp->cp.inst.operand = 0;
    961       1.4    chopps #endif
    962       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
    963       1.1    chopps 		tmp->cp.inst.operand = h_this_data->beamcon0;
    964       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
    965       1.1    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
    966       1.1    chopps #endif /* ECS */
    967       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
    968       1.1    chopps 		tmp->cp.inst.operand = h_this_data->bplcon0 | ((depth & 0x7) << 12);
    969       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
    970       1.1    chopps 		tmp->cp.inst.operand = con1;
    971       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
    972       1.1    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
    973       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
    974       1.1    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
    975       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
    976       1.1    chopps 		tmp->cp.inst.operand = ddfstart;
    977       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
    978       1.1    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
    979       1.1    chopps 
    980       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
    981       1.1    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
    982       1.1    chopps 			/* update the plane pointers */
    983      1.11     veego 			tmp[j].cp.inst.operand =
    984      1.11     veego 				HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
    985      1.11     veego 			tmp[j + 1].cp.inst.operand =
    986      1.11     veego 				LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
    987       1.1    chopps 		}
    988       1.1    chopps 
    989       1.1    chopps 		/* set mods correctly. */
    990       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
    991       1.1    chopps 		tmp[0].cp.inst.operand = v->bitmap->row_mod;
    992       1.1    chopps 		tmp[1].cp.inst.operand = v->bitmap->row_mod;
    993       1.1    chopps 
    994       1.1    chopps 		/* set next pointers correctly */
    995       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
    996      1.11     veego 		tmp[0].cp.inst.operand =
    997      1.11     veego 				HIADDR(PREP_DMA_MEM(h_this_data->frames[F_STORE_LONG]));
    998      1.11     veego 		tmp[1].cp.inst.operand =
    999      1.11     veego 				LOADDR(PREP_DMA_MEM(h_this_data->frames[F_STORE_LONG]));
   1000       1.1    chopps 
   1001       1.1    chopps 		cp = h_this_data->frames[F_LONG];
   1002       1.1    chopps 		h_this_data->frames[F_LONG] = h_this_data->frames[F_STORE_LONG];
   1003       1.1    chopps 		h_this_data->frames[F_STORE_LONG] = cp;
   1004       1.1    chopps 
   1005       1.1    chopps 		vd->flags |= VF_DISPLAY;
   1006       1.1    chopps 
   1007       1.1    chopps 		cc_use_colormap(v, vd->colormap);
   1008       1.1    chopps 	}
   1009       1.1    chopps 	cc_load_mode(h_this);
   1010       1.1    chopps }
   1011       1.1    chopps 
   1012       1.1    chopps dmode_t *
   1013  1.20.8.1  jdolecek cc_init_ntsc_hires_lace(void)
   1014       1.1    chopps {
   1015       1.4    chopps 	/* this function should only be called once. */
   1016       1.1    chopps 	if (!hl_this) {
   1017       1.1    chopps 		u_short len = std_copper_list_len;
   1018       1.1    chopps 
   1019       1.1    chopps 		hl_this = &hires_lace_mode;
   1020       1.1    chopps 		hl_this_data = &hires_lace_mode_data;
   1021       1.1    chopps 		bzero(hl_this, sizeof(dmode_t));
   1022       1.1    chopps 		bzero(hl_this_data, sizeof(dmdata_t));
   1023       1.1    chopps 
   1024       1.1    chopps 		hl_this->name = "ntsc: hires interlace";
   1025       1.1    chopps 		hl_this->nominal_size.width = 640;
   1026       1.1    chopps 		hl_this->nominal_size.height = 400;
   1027       1.1    chopps 		hl_this_data->max_size.width = 724;
   1028       1.1    chopps 		hl_this_data->max_size.height = 482;
   1029       1.1    chopps 		hl_this_data->min_size.width = 320;
   1030       1.1    chopps 		hl_this_data->min_size.height = 200;
   1031       1.1    chopps 		hl_this_data->min_depth = 1;
   1032       1.1    chopps 		hl_this_data->max_depth = 4;
   1033       1.1    chopps 		hl_this->data = hl_this_data;
   1034       1.1    chopps 
   1035       1.1    chopps 		hl_this->get_monitor = cc_get_monitor;
   1036       1.1    chopps 		hl_this->alloc_view = cc_alloc_view;
   1037       1.1    chopps 		hl_this->get_current_view = cc_get_current_view;
   1038       1.1    chopps 
   1039       1.1    chopps 		hl_this_data->use_colormap = cc_use_colormap;
   1040       1.1    chopps 		hl_this_data->get_colormap = cc_get_colormap;
   1041       1.1    chopps 		hl_this_data->alloc_colormap = cc_alloc_colormap;
   1042       1.1    chopps 		hl_this_data->display_view = display_hires_lace_view;
   1043       1.1    chopps 		hl_this_data->monitor = cc_monitor;
   1044       1.1    chopps 
   1045       1.1    chopps 		hl_this_data->flags |= DMF_INTERLACE;
   1046       1.1    chopps 
   1047       1.1    chopps 		hl_this_data->frames = hires_lace_frames;
   1048      1.11     veego 		hl_this_data->frames[F_LACE_LONG] =
   1049      1.11     veego 				alloc_chipmem(std_copper_list_size * F_LACE_TOTAL);
   1050       1.1    chopps 		if (!hl_this_data->frames[F_LACE_LONG]) {
   1051       1.1    chopps 			panic("couldn't get chipmem for copper list");
   1052       1.1    chopps 		}
   1053      1.11     veego 		hl_this_data->frames[F_LACE_SHORT] =
   1054      1.11     veego 				&hl_this_data->frames[F_LACE_LONG][len];
   1055      1.11     veego 		hl_this_data->frames[F_LACE_STORE_LONG] =
   1056      1.11     veego 				&hl_this_data->frames[F_LACE_SHORT][len];
   1057      1.11     veego 		hl_this_data->frames[F_LACE_STORE_SHORT] =
   1058      1.11     veego 				&hl_this_data->frames[F_LACE_STORE_LONG][len];
   1059      1.11     veego 
   1060      1.11     veego 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_STORE_LONG],
   1061      1.11     veego 			std_copper_list_size);
   1062      1.11     veego 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_STORE_SHORT],
   1063      1.11     veego 			std_copper_list_size);
   1064      1.11     veego 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_LONG],
   1065      1.11     veego 			std_copper_list_size);
   1066      1.11     veego 		bcopy(std_copper_list, hl_this_data->frames[F_LACE_SHORT],
   1067      1.11     veego 			std_copper_list_size);
   1068       1.1    chopps 
   1069       1.1    chopps 		hl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
   1070       1.1    chopps 								 * composite enable,
   1071       1.1    chopps 								 * lace. */
   1072       1.1    chopps 		hl_this_data->std_start_x = STANDARD_VIEW_X;
   1073       1.1    chopps 		hl_this_data->std_start_y = STANDARD_VIEW_Y;
   1074      1.11     veego 		hl_this_data->vbl_handler =
   1075      1.11     veego 			(vbl_handler_func *) cc_lace_mode_vbl_handler;
   1076      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1077       1.1    chopps 		hl_this_data->beamcon0 = STANDARD_NTSC_BEAMCON;
   1078       1.1    chopps #endif
   1079       1.1    chopps 
   1080       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, hl_this, link);
   1081       1.1    chopps 	}
   1082       1.1    chopps 	return (hl_this);
   1083       1.1    chopps }
   1084       1.1    chopps 
   1085       1.1    chopps void
   1086  1.20.8.1  jdolecek display_hires_lace_view(view_t *v)
   1087       1.1    chopps {
   1088       1.1    chopps 	if (hl_this_data->current_view != v) {
   1089       1.1    chopps 		vdata_t *vd = VDATA(v);
   1090       1.1    chopps 		cop_t  *cp = hl_this_data->frames[F_LACE_STORE_LONG], *tmp;
   1091       1.1    chopps 		int     depth = v->bitmap->depth, i;
   1092       1.1    chopps 		int     hstart, hstop, vstart, vstop, j;
   1093       1.1    chopps 		int     x, y, w = v->display.width, h = v->display.height;
   1094       1.1    chopps 		u_short ddfstart, ddfwidth, con1;
   1095       1.1    chopps 
   1096       1.1    chopps 		/* round down to nearest even width */
   1097       1.1    chopps 		/* w &= 0xfffe; */
   1098       1.1    chopps 
   1099       1.1    chopps 
   1100       1.1    chopps 		/* calculate datafetch width. */
   1101       1.1    chopps 
   1102       1.1    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   1103       1.1    chopps 
   1104       1.4    chopps 		/* This will center the any overscanned display */
   1105       1.1    chopps 		/* and allow user to modify. */
   1106       1.1    chopps 		x = v->display.x + hl_this_data->std_start_x - ((w - 640) >> 2);
   1107       1.1    chopps 		y = v->display.y + hl_this_data->std_start_y - ((h - 400) >> 2);
   1108       1.1    chopps 
   1109       1.1    chopps 		if (y & 1)
   1110       1.1    chopps 			y--;
   1111       1.1    chopps 
   1112       1.1    chopps 		if (!(x & 1))
   1113       1.1    chopps 			x--;
   1114       1.1    chopps 
   1115       1.1    chopps 		hstart = x;
   1116       1.1    chopps 		hstop = x + (w >> 1);
   1117       1.1    chopps 		vstart = y;
   1118       1.1    chopps 		vstop = y + (h >> 1);
   1119       1.1    chopps 		ddfstart = (hstart - 9) >> 1;
   1120       1.1    chopps 
   1121       1.1    chopps 		/* check for hardware limits, AGA may allow more..? */
   1122       1.1    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   1123       1.1    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   1124       1.1    chopps 			int     d = 0;
   1125       1.1    chopps 
   1126       1.1    chopps 			/* XXX anyone know the equality properties of
   1127       1.1    chopps 			 * intermixed logial AND's */
   1128       1.1    chopps 			/* XXX and arithmetic operators? */
   1129       1.1    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   1130       1.1    chopps 				d++;
   1131       1.1    chopps 			}
   1132       1.1    chopps 
   1133       1.1    chopps 			ddfstart -= d;
   1134       1.1    chopps 			hstart -= d << 1;
   1135       1.1    chopps 			hstop -= d << 1;
   1136       1.1    chopps 		}
   1137       1.1    chopps 		/* correct the datafetch to proper limits. */
   1138       1.1    chopps 		/* delay the actual display of the data until we need it. */
   1139       1.1    chopps 		ddfstart &= 0xfffc;
   1140      1.11     veego 		con1 = ((hstart - 9) - (ddfstart << 1)) |
   1141      1.11     veego 				(((hstart - 9) - (ddfstart << 1)) << 4);
   1142       1.1    chopps 
   1143       1.1    chopps 		if (hl_this_data->current_view) {
   1144      1.11     veego 			VDATA(hl_this_data->current_view)->flags &=
   1145      1.11     veego 				~VF_DISPLAY;	/* mark as no longer displayed. */
   1146       1.1    chopps 		}
   1147       1.1    chopps 		hl_this_data->current_view = v;
   1148       1.1    chopps 
   1149       1.1    chopps 		cp = hl_this_data->frames[F_LACE_STORE_LONG];
   1150      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1151       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON3));
   1152       1.4    chopps 		tmp->cp.inst.operand = 0x0020;
   1153       1.4    chopps #if defined GRF_AGA
   1154       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   1155       1.4    chopps 		tmp->cp.inst.operand = 0;
   1156       1.4    chopps #endif
   1157       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   1158       1.1    chopps 		tmp->cp.inst.operand = hl_this_data->beamcon0;
   1159       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   1160       1.1    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   1161       1.1    chopps #endif /* ECS */
   1162       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   1163       1.1    chopps 		tmp->cp.inst.operand = hl_this_data->bplcon0 | ((depth & 0x7) << 12);
   1164       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   1165       1.1    chopps 		tmp->cp.inst.operand = con1;
   1166       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   1167       1.1    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   1168       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   1169       1.1    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   1170       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   1171       1.1    chopps 		tmp->cp.inst.operand = ddfstart;
   1172       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   1173       1.1    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   1174       1.1    chopps 
   1175       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1176       1.1    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   1177       1.1    chopps 			/* update the plane pointers */
   1178      1.11     veego 			tmp[j].cp.inst.operand =
   1179      1.11     veego 				HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1180      1.11     veego 			tmp[j + 1].cp.inst.operand =
   1181      1.11     veego 				LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   1182       1.1    chopps 		}
   1183       1.1    chopps 
   1184       1.1    chopps 		/* set mods correctly. */
   1185       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   1186       1.1    chopps 		tmp[0].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1187       1.1    chopps 		tmp[1].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1188       1.1    chopps 
   1189       1.1    chopps 		/* set next pointers correctly */
   1190       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1191      1.11     veego 		tmp[0].cp.inst.operand =
   1192      1.11     veego 			HIADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_SHORT]));
   1193      1.11     veego 		tmp[1].cp.inst.operand =
   1194      1.11     veego 			LOADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_SHORT]));
   1195       1.1    chopps 
   1196       1.1    chopps 
   1197      1.11     veego 		bcopy(hl_this_data->frames[F_LACE_STORE_LONG],
   1198      1.11     veego 			hl_this_data->frames[F_LACE_STORE_SHORT], std_copper_list_size);
   1199       1.1    chopps 
   1200       1.1    chopps 		/* these are the only ones that are different from long frame. */
   1201       1.1    chopps 		cp = hl_this_data->frames[F_LACE_STORE_SHORT];
   1202       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1203       1.1    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   1204       1.1    chopps 			u_short mod = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1205       1.1    chopps 			/* update plane pointers. high and low. */
   1206      1.11     veego 			tmp[j].cp.inst.operand =
   1207      1.11     veego 				HIADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   1208      1.11     veego 			tmp[j + 1].cp.inst.operand =
   1209      1.11     veego 				LOADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   1210       1.1    chopps 		}
   1211       1.1    chopps 
   1212       1.1    chopps 		/* set next pointers correctly */
   1213       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1214      1.11     veego 		tmp[0].cp.inst.operand =
   1215      1.11     veego 			HIADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_LONG]));
   1216      1.11     veego 		tmp[1].cp.inst.operand =
   1217      1.11     veego 			LOADDR(PREP_DMA_MEM(hl_this_data->frames[F_LACE_STORE_LONG]));
   1218       1.1    chopps 
   1219       1.1    chopps 
   1220       1.1    chopps 		cp = hl_this_data->frames[F_LACE_LONG];
   1221      1.11     veego 		hl_this_data->frames[F_LACE_LONG] =
   1222      1.11     veego 			hl_this_data->frames[F_LACE_STORE_LONG];
   1223       1.1    chopps 		hl_this_data->frames[F_LACE_STORE_LONG] = cp;
   1224       1.1    chopps 
   1225       1.1    chopps 		cp = hl_this_data->frames[F_LACE_SHORT];
   1226      1.11     veego 		hl_this_data->frames[F_LACE_SHORT] =
   1227      1.11     veego 			hl_this_data->frames[F_LACE_STORE_SHORT];
   1228       1.1    chopps 		hl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   1229       1.1    chopps 
   1230       1.1    chopps 		vd->flags |= VF_DISPLAY;
   1231       1.1    chopps 
   1232       1.1    chopps 		cc_use_colormap(v, vd->colormap);
   1233       1.1    chopps 	}
   1234       1.1    chopps 	cc_load_mode(hl_this);
   1235       1.1    chopps }
   1236       1.1    chopps #if defined (GRF_A2024)
   1237       1.1    chopps 
   1238       1.1    chopps dmode_t *
   1239  1.20.8.1  jdolecek cc_init_ntsc_hires_dlace(void)
   1240       1.1    chopps {
   1241       1.4    chopps 	/* this function should only be called once. */
   1242       1.1    chopps 	if (!hdl_this) {
   1243       1.1    chopps 		u_short len = std_dlace_copper_list_len;
   1244       1.1    chopps 
   1245       1.1    chopps 		hdl_this = &hires_dlace_mode;
   1246       1.1    chopps 		hdl_this_data = &hires_dlace_mode_data;
   1247       1.1    chopps 		bzero(hdl_this, sizeof(dmode_t));
   1248       1.1    chopps 		bzero(hdl_this_data, sizeof(dmdata_t));
   1249       1.1    chopps 
   1250       1.1    chopps 		hdl_this->name = "ntsc: hires double interlace";
   1251       1.1    chopps 		hdl_this->nominal_size.width = 640;
   1252       1.1    chopps 		hdl_this->nominal_size.height = 800;
   1253       1.1    chopps 		hdl_this_data->max_size.width = 724;
   1254       1.1    chopps 		hdl_this_data->max_size.height = 800;
   1255       1.1    chopps 		hdl_this_data->min_size.width = 320;
   1256       1.1    chopps 		hdl_this_data->min_size.height = 400;
   1257       1.1    chopps 		hdl_this_data->min_depth = 1;
   1258       1.1    chopps 		hdl_this_data->max_depth = 2;
   1259       1.1    chopps 		hdl_this->data = hdl_this_data;
   1260       1.1    chopps 
   1261       1.1    chopps 		hdl_this->get_monitor = cc_get_monitor;
   1262       1.1    chopps 		hdl_this->alloc_view = cc_alloc_view;
   1263       1.1    chopps 		hdl_this->get_current_view = cc_get_current_view;
   1264       1.1    chopps 
   1265       1.1    chopps 		hdl_this_data->use_colormap = cc_a2024_use_colormap;
   1266       1.1    chopps 		hdl_this_data->get_colormap = cc_a2024_get_colormap;
   1267       1.1    chopps 		hdl_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   1268       1.1    chopps 		hdl_this_data->display_view = display_hires_dlace_view;
   1269       1.1    chopps 		hdl_this_data->monitor = cc_monitor;
   1270       1.1    chopps 
   1271       1.1    chopps 		hdl_this_data->flags |= DMF_INTERLACE;
   1272       1.1    chopps 
   1273       1.1    chopps 		hdl_this_data->frames = hires_dlace_frames;
   1274      1.11     veego 		hdl_this_data->frames[F_LACE_LONG] =
   1275      1.11     veego 			alloc_chipmem(std_dlace_copper_list_size * F_LACE_TOTAL);
   1276       1.1    chopps 		if (!hdl_this_data->frames[F_LACE_LONG]) {
   1277       1.1    chopps 			panic("couldn't get chipmem for copper list");
   1278       1.1    chopps 		}
   1279      1.11     veego 		hdl_this_data->frames[F_LACE_SHORT] =
   1280      1.11     veego 			&hdl_this_data->frames[F_LACE_LONG][len];
   1281      1.11     veego 		hdl_this_data->frames[F_LACE_STORE_LONG] =
   1282      1.11     veego 			&hdl_this_data->frames[F_LACE_SHORT][len];
   1283      1.11     veego 		hdl_this_data->frames[F_LACE_STORE_SHORT] =
   1284      1.11     veego 			&hdl_this_data->frames[F_LACE_STORE_LONG][len];
   1285      1.11     veego 
   1286      1.11     veego 		bcopy(std_dlace_copper_list,
   1287      1.11     veego 			hdl_this_data->frames[F_LACE_STORE_LONG],
   1288      1.11     veego 			std_dlace_copper_list_size);
   1289      1.11     veego 		bcopy(std_dlace_copper_list,
   1290      1.11     veego 			hdl_this_data->frames[F_LACE_STORE_SHORT],
   1291      1.11     veego 			std_dlace_copper_list_size);
   1292      1.11     veego 		bcopy(std_dlace_copper_list,
   1293      1.11     veego 			hdl_this_data->frames[F_LACE_LONG],
   1294      1.11     veego 			std_dlace_copper_list_size);
   1295      1.11     veego 		bcopy(std_dlace_copper_list,
   1296      1.11     veego 			hdl_this_data->frames[F_LACE_SHORT],
   1297      1.11     veego 			std_dlace_copper_list_size);
   1298       1.1    chopps 
   1299       1.1    chopps 		hdl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
   1300       1.1    chopps 								 * composite enable,
   1301       1.1    chopps 								 * dlace. */
   1302       1.1    chopps 		hdl_this_data->std_start_x = STANDARD_VIEW_X;
   1303       1.1    chopps 		hdl_this_data->std_start_y = STANDARD_VIEW_Y;
   1304      1.11     veego 		hdl_this_data->vbl_handler =
   1305      1.11     veego 			(vbl_handler_func *) cc_lace_mode_vbl_handler;
   1306      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1307       1.1    chopps 		hdl_this_data->beamcon0 = STANDARD_NTSC_BEAMCON;
   1308       1.1    chopps #endif
   1309       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, hdl_this, link);
   1310       1.1    chopps 	}
   1311       1.1    chopps 	return (hdl_this);
   1312       1.1    chopps }
   1313       1.1    chopps 
   1314       1.1    chopps void
   1315  1.20.8.1  jdolecek display_hires_dlace_view(view_t *v)
   1316       1.1    chopps {
   1317       1.1    chopps 	if (hdl_this_data->current_view != v) {
   1318       1.1    chopps 		vdata_t *vd = VDATA(v);
   1319       1.1    chopps 		cop_t  *cp = hdl_this_data->frames[F_LACE_STORE_LONG], *tmp;
   1320      1.11     veego 		int     depth = v->bitmap->depth;
   1321      1.11     veego 		int     hstart, hstop, vstart, vstop;
   1322       1.1    chopps 		int     x, y, w = v->display.width, h = v->display.height;
   1323       1.1    chopps 		u_short ddfstart, ddfwidth, con1;
   1324       1.1    chopps 		u_short mod1l, mod2l;
   1325       1.1    chopps 
   1326       1.1    chopps 		/* round down to nearest even width */
   1327       1.1    chopps 		/* w &= 0xfffe; */
   1328       1.1    chopps 
   1329       1.1    chopps 		/* calculate datafetch width. */
   1330       1.1    chopps 
   1331       1.1    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   1332       1.1    chopps 
   1333       1.4    chopps 		/* This will center the any overscanned display */
   1334       1.1    chopps 		/* and allow user to modify. */
   1335       1.1    chopps 		x = v->display.x + hdl_this_data->std_start_x - ((w - 640) >> 2);
   1336       1.1    chopps 		y = v->display.y + hdl_this_data->std_start_y - ((h - 800) >> 3);
   1337       1.1    chopps 
   1338       1.1    chopps 		if (y & 1)
   1339       1.1    chopps 			y--;
   1340       1.1    chopps 
   1341       1.1    chopps 		if (!(x & 1))
   1342       1.1    chopps 			x--;
   1343       1.1    chopps 
   1344       1.1    chopps 		hstart = x;
   1345       1.1    chopps 		hstop = x + (w >> 1);
   1346       1.1    chopps 		vstart = y;
   1347       1.1    chopps 		vstop = y + (h >> 2);
   1348       1.1    chopps 
   1349       1.1    chopps 		ddfstart = (hstart - 9) >> 1;
   1350       1.1    chopps 
   1351       1.1    chopps 		/* check for hardware limits, AGA may allow more..? */
   1352       1.1    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   1353       1.1    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   1354       1.1    chopps 			int     d = 0;
   1355       1.1    chopps 
   1356       1.1    chopps 			/* XXX anyone know the equality properties of
   1357       1.1    chopps 			 * intermixed logial AND's */
   1358       1.1    chopps 			/* XXX and arithmetic operators? */
   1359       1.1    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   1360       1.1    chopps 				d++;
   1361       1.1    chopps 			}
   1362       1.1    chopps 
   1363       1.1    chopps 			ddfstart -= d;
   1364       1.1    chopps 			hstart -= d << 1;
   1365       1.1    chopps 			hstop -= d << 1;
   1366       1.1    chopps 		}
   1367       1.1    chopps 		/* correct the datafetch to proper limits. */
   1368       1.1    chopps 		/* delay the actual display of the data until we need it. */
   1369       1.1    chopps 		ddfstart &= 0xfffc;
   1370      1.11     veego 		con1 = ((hstart - 9) - (ddfstart << 1)) |
   1371      1.11     veego 			(((hstart - 9) - (ddfstart << 1)) << 4);
   1372       1.1    chopps 
   1373       1.1    chopps 		if (hdl_this_data->current_view) {
   1374      1.11     veego 			VDATA(hdl_this_data->current_view)->flags &=
   1375      1.11     veego 				~VF_DISPLAY;	/* mark as no longer displayed. */
   1376       1.1    chopps 		}
   1377       1.1    chopps 		hdl_this_data->current_view = v;
   1378       1.1    chopps 
   1379       1.1    chopps 		cp = hdl_this_data->frames[F_LACE_STORE_LONG];
   1380      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1381       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON3));
   1382       1.4    chopps 		tmp->cp.inst.operand = 0x0020;
   1383       1.4    chopps #if defined GRF_AGA
   1384       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   1385       1.4    chopps 		tmp->cp.inst.operand = 0;
   1386       1.4    chopps #endif
   1387       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   1388       1.1    chopps 		tmp->cp.inst.operand = hdl_this_data->beamcon0;
   1389       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   1390       1.1    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   1391       1.1    chopps #endif /* ECS */
   1392       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   1393      1.11     veego 		tmp->cp.inst.operand =
   1394      1.11     veego 			hdl_this_data->bplcon0 | ((depth & 0x7) << 13);	/* times two. */
   1395       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   1396       1.1    chopps 		tmp->cp.inst.operand = con1;
   1397       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   1398       1.1    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   1399       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   1400       1.1    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   1401       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   1402       1.1    chopps 		tmp->cp.inst.operand = ddfstart;
   1403       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   1404       1.1    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   1405       1.1    chopps 
   1406       1.1    chopps 		mod1l = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1407       1.1    chopps 		mod2l = mod1l << 1;
   1408       1.1    chopps 
   1409       1.1    chopps 		/* update plane pointers. */
   1410       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1411      1.11     veego 		tmp[0].cp.inst.operand =
   1412      1.11     veego 			HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));
   1413      1.11     veego 		tmp[1].cp.inst.operand =
   1414      1.11     veego 			LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));
   1415      1.11     veego 		tmp[2].cp.inst.operand =
   1416      1.11     veego 			HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));
   1417      1.11     veego 		tmp[3].cp.inst.operand =
   1418      1.11     veego 			LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));
   1419       1.1    chopps 		if (depth == 2) {
   1420      1.11     veego 			tmp[4].cp.inst.operand =
   1421      1.11     veego 				HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));
   1422      1.11     veego 			tmp[5].cp.inst.operand =
   1423      1.11     veego 				LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));
   1424      1.11     veego 			tmp[6].cp.inst.operand =
   1425      1.11     veego 				HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));
   1426      1.11     veego 			tmp[7].cp.inst.operand =
   1427      1.11     veego 				LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));
   1428       1.1    chopps 		}
   1429       1.1    chopps 		/* set modulos. */
   1430       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   1431       1.1    chopps 		tmp[0].cp.inst.operand = mod2l + mod1l;
   1432       1.1    chopps 		tmp[1].cp.inst.operand = mod2l + mod1l;
   1433       1.1    chopps 
   1434       1.1    chopps 
   1435       1.1    chopps 		/* set next coper list pointers */
   1436       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1437      1.11     veego 		tmp[0].cp.inst.operand =
   1438      1.11     veego 			HIADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_SHORT]));
   1439      1.11     veego 		tmp[1].cp.inst.operand =
   1440      1.11     veego 			LOADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_SHORT]));
   1441      1.11     veego 
   1442      1.11     veego 		bcopy(hdl_this_data->frames[F_LACE_STORE_LONG],
   1443      1.11     veego 			hdl_this_data->frames[F_LACE_STORE_SHORT],
   1444      1.11     veego 			std_dlace_copper_list_size);
   1445       1.1    chopps 
   1446       1.1    chopps 		/* these are the only ones that are different from long frame. */
   1447       1.1    chopps 		cp = hdl_this_data->frames[F_LACE_STORE_SHORT];
   1448       1.1    chopps 		/* update plane pointers. */
   1449       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   1450      1.11     veego 		tmp[0].cp.inst.operand =
   1451      1.11     veego 			HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));
   1452      1.11     veego 		tmp[1].cp.inst.operand =
   1453      1.11     veego 			LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));
   1454      1.11     veego 		tmp[2].cp.inst.operand =
   1455      1.11     veego 			HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));
   1456      1.11     veego 		tmp[3].cp.inst.operand =
   1457      1.11     veego 			LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));
   1458       1.1    chopps 		if (depth == 2) {
   1459      1.11     veego 			tmp[4].cp.inst.operand =
   1460      1.11     veego 				HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));
   1461      1.11     veego 			tmp[5].cp.inst.operand =
   1462      1.11     veego 				LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));
   1463      1.11     veego 			tmp[6].cp.inst.operand =
   1464      1.11     veego 				HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));
   1465      1.11     veego 			tmp[7].cp.inst.operand =
   1466      1.11     veego 				LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));
   1467       1.1    chopps 		}
   1468       1.1    chopps 		/* set next copper list pointers */
   1469       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   1470      1.11     veego 		tmp[0].cp.inst.operand =
   1471      1.11     veego 			HIADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_LONG]));
   1472      1.11     veego 		tmp[1].cp.inst.operand =
   1473      1.11     veego 			LOADDR(PREP_DMA_MEM(hdl_this_data->frames[F_LACE_STORE_LONG]));
   1474       1.1    chopps 
   1475       1.1    chopps 		cp = hdl_this_data->frames[F_LACE_LONG];
   1476      1.11     veego 		hdl_this_data->frames[F_LACE_LONG] =
   1477      1.11     veego 			hdl_this_data->frames[F_LACE_STORE_LONG];
   1478       1.1    chopps 		hdl_this_data->frames[F_LACE_STORE_LONG] = cp;
   1479       1.1    chopps 
   1480       1.1    chopps 		cp = hdl_this_data->frames[F_LACE_SHORT];
   1481      1.11     veego 		hdl_this_data->frames[F_LACE_SHORT] =
   1482      1.11     veego 			hdl_this_data->frames[F_LACE_STORE_SHORT];
   1483       1.1    chopps 		hdl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   1484       1.1    chopps 
   1485       1.1    chopps 		vd->flags |= VF_DISPLAY;
   1486       1.1    chopps 		cc_a2024_use_colormap(v, vd->colormap);
   1487       1.1    chopps 	}
   1488       1.1    chopps 	cc_load_mode(hdl_this);
   1489       1.1    chopps }
   1490       1.1    chopps 
   1491       1.1    chopps 
   1492       1.1    chopps dmode_t *
   1493  1.20.8.1  jdolecek cc_init_ntsc_a2024(void)
   1494       1.1    chopps {
   1495       1.4    chopps 	/* this function should only be called once. */
   1496       1.1    chopps 	if (!a24_this) {
   1497       1.1    chopps 		int     i;
   1498       1.1    chopps 		u_short len = std_a2024_copper_list_len;
   1499       1.1    chopps 		cop_t  *cp;
   1500       1.1    chopps 
   1501       1.1    chopps 		a24_this = &a2024_mode;
   1502       1.1    chopps 		a24_this_data = &a2024_mode_data;
   1503       1.1    chopps 		bzero(a24_this, sizeof(dmode_t));
   1504       1.1    chopps 		bzero(a24_this_data, sizeof(dmdata_t));
   1505       1.1    chopps 
   1506       1.1    chopps 		a24_this->name = "ntsc: A2024 15khz";
   1507       1.1    chopps 		a24_this->nominal_size.width = 1024;
   1508       1.1    chopps 		a24_this->nominal_size.height = 800;
   1509       1.1    chopps 		a24_this_data->max_size.width = 1024;
   1510       1.1    chopps 		a24_this_data->max_size.height = 800;
   1511       1.1    chopps 		a24_this_data->min_size.width = 1024;
   1512       1.1    chopps 		a24_this_data->min_size.height = 800;
   1513       1.1    chopps 		a24_this_data->min_depth = 1;
   1514       1.1    chopps 		a24_this_data->max_depth = 2;
   1515       1.1    chopps 		a24_this->data = a24_this_data;
   1516       1.1    chopps 
   1517       1.1    chopps 		a24_this->get_monitor = cc_get_monitor;
   1518       1.1    chopps 		a24_this->alloc_view = cc_alloc_view;
   1519       1.1    chopps 		a24_this->get_current_view = cc_get_current_view;
   1520       1.1    chopps 
   1521       1.1    chopps 		a24_this_data->use_colormap = cc_a2024_use_colormap;
   1522       1.1    chopps 		a24_this_data->get_colormap = cc_a2024_get_colormap;
   1523       1.1    chopps 		a24_this_data->display_view = display_a2024_view;
   1524       1.1    chopps 		a24_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   1525       1.1    chopps 		a24_this_data->monitor = cc_monitor;
   1526       1.1    chopps 
   1527       1.1    chopps 		a24_this_data->flags |= DMF_HEDLEY_EXP;
   1528       1.1    chopps 
   1529       1.1    chopps 		a24_this_data->frames = a2024_frames;
   1530      1.11     veego 		a24_this_data->frames[F_QD_QUAD0] =
   1531      1.11     veego 			alloc_chipmem(std_a2024_copper_list_size * F_QD_TOTAL);
   1532       1.1    chopps 		if (!a24_this_data->frames[F_QD_QUAD0]) {
   1533       1.1    chopps 			panic("couldn't get chipmem for copper list");
   1534       1.1    chopps 		}
   1535       1.1    chopps 		/* setup the hedley init bitplane. */
   1536       1.1    chopps 		hedley_init = alloc_chipmem(128);
   1537       1.1    chopps 		if (!hedley_init) {
   1538       1.1    chopps 			panic("couldn't get chipmem for hedley init bitplane");
   1539       1.1    chopps 		}
   1540       1.1    chopps 		for (i = 1; i < 128; i++)
   1541       1.1    chopps 			hedley_init[i] = 0xff;
   1542       1.1    chopps 		hedley_init[0] = 0x03;
   1543       1.1    chopps 
   1544       1.1    chopps 		/* copy image of standard copper list. */
   1545      1.11     veego 		bcopy(std_a2024_copper_list, a24_this_data->frames[0],
   1546      1.11     veego 			std_a2024_copper_list_size);
   1547       1.1    chopps 
   1548       1.1    chopps 		/* set the init plane pointer. */
   1549      1.11     veego 		cp = find_copper_inst(a24_this_data->frames[F_QD_QUAD0],
   1550      1.11     veego 					CI_MOVE(R_BPL0PTH));
   1551       1.1    chopps 		cp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hedley_init));
   1552       1.1    chopps 		cp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hedley_init));
   1553       1.1    chopps 
   1554       1.1    chopps 		for (i = 1; i < F_QD_TOTAL; i++) {
   1555       1.1    chopps 			a24_this_data->frames[i] = &a24_this_data->frames[i - 1][len];
   1556      1.11     veego 			bcopy(a24_this_data->frames[0],
   1557      1.11     veego 				a24_this_data->frames[i],
   1558      1.11     veego 				std_a2024_copper_list_size);
   1559       1.1    chopps 		}
   1560       1.1    chopps 
   1561       1.1    chopps 		a24_this_data->bplcon0 = 0x8200;	/* hires */
   1562      1.11     veego 		a24_this_data->vbl_handler =
   1563      1.11     veego 			(vbl_handler_func *) a2024_mode_vbl_handler;
   1564       1.1    chopps 
   1565       1.1    chopps 
   1566       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, a24_this, link);
   1567       1.1    chopps 	}
   1568       1.1    chopps 	return (a24_this);
   1569       1.1    chopps }
   1570       1.1    chopps 
   1571       1.1    chopps void
   1572  1.20.8.1  jdolecek display_a2024_view(view_t *v)
   1573       1.1    chopps {
   1574       1.1    chopps 	if (a24_this_data->current_view != v) {
   1575       1.1    chopps 		vdata_t *vd = VDATA(v);
   1576       1.1    chopps 		cop_t  *cp, *tmp;
   1577       1.1    chopps 		u_char *inst_plane[2];
   1578       1.1    chopps 		u_char **plane = inst_plane;
   1579       1.1    chopps 		u_long  full_line = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   1580       1.1    chopps 		u_long  half_plane = full_line * v->bitmap->rows / 2;
   1581       1.1    chopps 
   1582       1.1    chopps 		int     depth = v->bitmap->depth, i, j;
   1583       1.1    chopps 
   1584       1.1    chopps 		plane[0] = v->bitmap->plane[0];
   1585       1.1    chopps 		if (depth == 2) {
   1586       1.1    chopps 			plane[1] = v->bitmap->plane[1];
   1587       1.1    chopps 		}
   1588       1.1    chopps 		if (a24_this_data->current_view) {
   1589      1.11     veego 			VDATA(a24_this_data->current_view)->flags &=
   1590      1.11     veego 				~VF_DISPLAY;	/* mark as no longer displayed. */
   1591       1.1    chopps 		}
   1592       1.1    chopps 		cp = a24_this_data->frames[F_QD_STORE_QUAD0];
   1593       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COLOR1F));
   1594      1.11     veego 		tmp = find_copper_inst(tmp, CI_MOVE(R_BPLCON0)); /* grab third one. */
   1595      1.11     veego 		tmp->cp.inst.operand = a24_this_data->bplcon0 |
   1596      1.11     veego 					((depth & 0x7) << 13);	/* times 2 */
   1597      1.11     veego 
   1598      1.11     veego 		bcopy(a24_this_data->frames[F_QD_STORE_QUAD0],
   1599      1.11     veego 			a24_this_data->frames[F_QD_STORE_QUAD1],
   1600      1.11     veego 			std_a2024_copper_list_size);
   1601      1.11     veego 		bcopy(a24_this_data->frames[F_QD_STORE_QUAD0],
   1602      1.11     veego 			a24_this_data->frames[F_QD_STORE_QUAD2],
   1603      1.11     veego 			std_a2024_copper_list_size);
   1604      1.11     veego 		bcopy(a24_this_data->frames[F_QD_STORE_QUAD0],
   1605      1.11     veego 			a24_this_data->frames[F_QD_STORE_QUAD3],
   1606      1.11     veego 			std_a2024_copper_list_size);
   1607       1.1    chopps 
   1608       1.1    chopps 		/*
   1609       1.1    chopps 		 * Mark Id's
   1610       1.1    chopps 		 */
   1611      1.11     veego 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD1],
   1612      1.11     veego 			CI_WAIT(126, 21));
   1613       1.1    chopps 		CBUMP(tmp);
   1614       1.1    chopps 		CMOVE(tmp, R_COLOR01, QUAD1_ID);
   1615      1.11     veego 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD2],
   1616      1.11     veego 			CI_WAIT(126, 21));
   1617       1.1    chopps 		CBUMP(tmp);
   1618       1.1    chopps 		CMOVE(tmp, R_COLOR01, QUAD2_ID);
   1619      1.11     veego 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD3],
   1620      1.11     veego 			CI_WAIT(126, 21));
   1621       1.1    chopps 		CBUMP(tmp);
   1622       1.1    chopps 		CMOVE(tmp, R_COLOR01, QUAD3_ID);
   1623       1.1    chopps 
   1624       1.1    chopps 		plane[0]--;
   1625       1.1    chopps 		plane[0]--;
   1626       1.1    chopps 		if (depth == 2) {
   1627       1.1    chopps 			plane[1]--;
   1628       1.1    chopps 			plane[1]--;
   1629       1.1    chopps 		}
   1630       1.1    chopps 		/*
   1631       1.1    chopps 		 * Set bitplane pointers.
   1632       1.1    chopps 		 */
   1633      1.11     veego 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD0],
   1634      1.11     veego 			CI_MOVE(R_BPLMOD2));
   1635       1.1    chopps 		CBUMP(tmp);
   1636       1.1    chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][0])));
   1637       1.1    chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][0])));
   1638       1.1    chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][full_line])));
   1639       1.1    chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][full_line])));
   1640       1.1    chopps 		if (depth == 2) {
   1641       1.1    chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][0])));
   1642       1.1    chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][0])));
   1643       1.1    chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][full_line])));
   1644       1.1    chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][full_line])));
   1645       1.1    chopps 		}
   1646      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1647       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1648       1.1    chopps #endif
   1649      1.11     veego 		CMOVE(tmp, R_COP1LCH,
   1650      1.11     veego 			HIADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD1])));
   1651      1.11     veego 		CMOVE(tmp, R_COP1LCL,
   1652      1.11     veego 			LOADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD1])));
   1653       1.1    chopps 		CEND(tmp);
   1654       1.1    chopps 		CEND(tmp);
   1655       1.1    chopps 
   1656      1.11     veego 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD1],
   1657      1.11     veego 					CI_MOVE(R_BPLMOD2));
   1658       1.1    chopps 		CBUMP(tmp);
   1659      1.11     veego 		CMOVE(tmp, R_BPL0PTH,
   1660      1.11     veego 			HIADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   1661      1.11     veego 		CMOVE(tmp, R_BPL0PTL,
   1662      1.11     veego 			LOADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   1663      1.11     veego 		CMOVE(tmp, R_BPL1PTH,
   1664      1.11     veego 			HIADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   1665      1.11     veego 		CMOVE(tmp, R_BPL1PTL,
   1666      1.11     veego 			LOADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   1667       1.1    chopps 		if (depth == 2) {
   1668      1.11     veego 			CMOVE(tmp, R_BPL2PTH,
   1669      1.11     veego 				HIADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   1670      1.11     veego 			CMOVE(tmp, R_BPL2PTL,
   1671      1.11     veego 				LOADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   1672      1.11     veego 			CMOVE(tmp, R_BPL3PTH,
   1673      1.11     veego 				HIADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   1674      1.11     veego 			CMOVE(tmp, R_BPL3PTL,
   1675      1.11     veego 				LOADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   1676       1.1    chopps 		}
   1677      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1678       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1679       1.1    chopps #endif
   1680      1.11     veego 		CMOVE(tmp, R_COP1LCH,
   1681      1.11     veego 			HIADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD2])));
   1682      1.11     veego 		CMOVE(tmp, R_COP1LCL,
   1683      1.11     veego 			LOADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD2])));
   1684       1.1    chopps 		CEND(tmp);
   1685       1.1    chopps 		CEND(tmp);
   1686       1.1    chopps 
   1687      1.11     veego 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD2],
   1688      1.11     veego 					CI_MOVE(R_BPLMOD2));
   1689       1.1    chopps 		CBUMP(tmp);
   1690      1.11     veego 		CMOVE(tmp, R_BPL0PTH,
   1691      1.11     veego 			HIADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   1692      1.11     veego 		CMOVE(tmp, R_BPL0PTL,
   1693      1.11     veego 			LOADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   1694      1.11     veego 		CMOVE(tmp, R_BPL1PTH,
   1695      1.11     veego 			HIADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   1696      1.11     veego 		CMOVE(tmp, R_BPL1PTL,
   1697      1.11     veego 			LOADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   1698       1.1    chopps 		if (depth == 2) {
   1699      1.11     veego 			CMOVE(tmp, R_BPL2PTH,
   1700      1.11     veego 				HIADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   1701      1.11     veego 			CMOVE(tmp, R_BPL2PTL,
   1702      1.11     veego 				LOADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   1703      1.11     veego 			CMOVE(tmp, R_BPL3PTH,
   1704      1.11     veego 				HIADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   1705      1.11     veego 			CMOVE(tmp, R_BPL3PTL,
   1706      1.11     veego 				LOADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   1707       1.1    chopps 		}
   1708      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1709       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1710       1.1    chopps #endif
   1711      1.11     veego 		CMOVE(tmp, R_COP1LCH,
   1712      1.11     veego 			HIADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD3])));
   1713      1.11     veego 		CMOVE(tmp, R_COP1LCL,
   1714      1.11     veego 			LOADDR(PREP_DMA_MEM(a24_this_data->frames[F_QD_STORE_QUAD3])));
   1715       1.1    chopps 		CEND(tmp);
   1716       1.1    chopps 		CEND(tmp);
   1717       1.1    chopps 
   1718      1.11     veego 		tmp = find_copper_inst(a24_this_data->frames[F_QD_STORE_QUAD3],
   1719      1.11     veego 					CI_MOVE(R_BPLMOD2));
   1720       1.1    chopps 		CBUMP(tmp);
   1721      1.11     veego 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(
   1722      1.11     veego 			&plane[0][half_plane + HALF_2024_LINE])));
   1723      1.11     veego 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(
   1724      1.11     veego 			&plane[0][half_plane + HALF_2024_LINE])));
   1725      1.11     veego 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(
   1726      1.11     veego 			&plane[0][half_plane + full_line + HALF_2024_LINE])));
   1727      1.11     veego 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(
   1728      1.11     veego 			&plane[0][half_plane + full_line + HALF_2024_LINE])));
   1729       1.1    chopps 		if (depth == 2) {
   1730      1.11     veego 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(
   1731      1.11     veego 				&plane[1][half_plane + HALF_2024_LINE])));
   1732      1.11     veego 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(
   1733      1.11     veego 				&plane[1][half_plane + HALF_2024_LINE])));
   1734      1.11     veego 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(
   1735      1.11     veego 				&plane[1][half_plane + full_line + HALF_2024_LINE])));
   1736      1.11     veego 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(
   1737      1.11     veego 				&plane[1][half_plane + full_line + HALF_2024_LINE])));
   1738       1.1    chopps 		}
   1739      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   1740       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2000);
   1741       1.1    chopps #endif
   1742      1.11     veego 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(
   1743      1.11     veego 				a24_this_data->frames[F_QD_STORE_QUAD0])));
   1744      1.11     veego 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(
   1745      1.11     veego 				a24_this_data->frames[F_QD_STORE_QUAD0])));
   1746       1.1    chopps 		CEND(tmp);
   1747       1.1    chopps 		CEND(tmp);
   1748       1.1    chopps 
   1749       1.1    chopps 		/* swap new pointers in. */
   1750       1.1    chopps 		for (i = F_QD_STORE_QUAD0, j = F_QD_QUAD0;
   1751       1.1    chopps 		    i <= F_QD_STORE_QUAD3; i++, j++) {
   1752       1.1    chopps 			cp = a24_this_data->frames[j];
   1753       1.1    chopps 			a24_this_data->frames[j] = a24_this_data->frames[i];
   1754       1.1    chopps 			a24_this_data->frames[i] = cp;
   1755       1.1    chopps 		}
   1756       1.1    chopps 
   1757       1.1    chopps 		a24_this_data->current_view = v;
   1758       1.1    chopps 		vd->flags |= VF_DISPLAY;
   1759       1.1    chopps 
   1760       1.1    chopps 		cc_a2024_use_colormap(v, vd->colormap);
   1761       1.1    chopps 	}
   1762       1.1    chopps 	cc_load_mode(a24_this);
   1763       1.1    chopps }
   1764       1.1    chopps 
   1765       1.1    chopps void
   1766  1.20.8.1  jdolecek a2024_mode_vbl_handler(dmode_t *d)
   1767       1.1    chopps {
   1768       1.1    chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
   1769       1.1    chopps 
   1770       1.1    chopps 	if (vp < 12) {
   1771      1.11     veego 		custom.cop1lc =
   1772      1.11     veego 		  PREP_DMA_MEM(a24_this_data->frames[a24_this_data->hedley_current]);
   1773       1.1    chopps 		custom.copjmp1 = 0;
   1774       1.1    chopps 	}
   1775       1.1    chopps 	a24_this_data->hedley_current++;
   1776       1.1    chopps 	a24_this_data->hedley_current &= 0x3;	/* if 4 then 0. */
   1777       1.1    chopps }
   1778       1.1    chopps #endif /* GRF_A2024 */
   1779       1.4    chopps 
   1780       1.4    chopps #if defined (GRF_AGA)
   1781       1.4    chopps 
   1782       1.4    chopps dmode_t *
   1783  1.20.8.1  jdolecek cc_init_ntsc_aga(void)
   1784       1.4    chopps {
   1785       1.4    chopps 	/* this function should only be called once. */
   1786       1.4    chopps 	if (!aga_this && (custom.deniseid & 0xff) == 0xf8 &&
   1787       1.4    chopps 	    aga_enable & AGA_ENABLE) {
   1788       1.4    chopps 		u_short len = aga_copper_list_len;
   1789       1.4    chopps 
   1790       1.4    chopps 		aga_this = &aga_mode;
   1791       1.4    chopps 		aga_this_data = &aga_mode_data;
   1792       1.4    chopps 		bzero(aga_this, sizeof(dmode_t));
   1793       1.4    chopps 		bzero(aga_this_data, sizeof(dmdata_t));
   1794       1.4    chopps 
   1795       1.4    chopps 		aga_this->name = "ntsc: AGA dbl";
   1796       1.4    chopps 		aga_this->nominal_size.width = 640;
   1797       1.4    chopps 		aga_this->nominal_size.height = 400;
   1798       1.4    chopps 		aga_this_data->max_size.width = 724;
   1799       1.4    chopps 		aga_this_data->max_size.height = 482;
   1800       1.4    chopps 		aga_this_data->min_size.width = 320;
   1801       1.4    chopps 		aga_this_data->min_size.height = 200;
   1802       1.4    chopps 		aga_this_data->min_depth = 1;
   1803       1.4    chopps 		aga_this_data->max_depth = 8;
   1804       1.4    chopps 		aga_this->data = aga_this_data;
   1805       1.4    chopps 
   1806       1.4    chopps 		aga_this->get_monitor = cc_get_monitor;
   1807       1.4    chopps 		aga_this->alloc_view = cc_alloc_view;
   1808       1.4    chopps 		aga_this->get_current_view = cc_get_current_view;
   1809       1.4    chopps 
   1810       1.4    chopps 		aga_this_data->use_colormap = cc_use_aga_colormap;
   1811       1.4    chopps 		aga_this_data->get_colormap = cc_get_colormap;
   1812       1.4    chopps 		aga_this_data->alloc_colormap = cc_alloc_aga_colormap;
   1813       1.4    chopps 		aga_this_data->display_view = display_aga_view;
   1814       1.4    chopps 		aga_this_data->monitor = cc_monitor;
   1815       1.4    chopps 
   1816       1.4    chopps 		aga_this_data->frames = aga_frames;
   1817       1.4    chopps 		aga_this_data->frames[F_LONG] = alloc_chipmem(aga_copper_list_size * F_TOTAL);
   1818       1.4    chopps 		if (!aga_this_data->frames[F_LONG]) {
   1819       1.4    chopps 			panic("couldn't get chipmem for copper list");
   1820       1.4    chopps 		}
   1821       1.4    chopps 		aga_this_data->frames[F_STORE_LONG] = &aga_this_data->frames[F_LONG][len];
   1822       1.4    chopps 
   1823       1.4    chopps 		bcopy(aga_copper_list, aga_this_data->frames[F_STORE_LONG], aga_copper_list_size);
   1824       1.4    chopps 		bcopy(aga_copper_list, aga_this_data->frames[F_LONG], aga_copper_list_size);
   1825       1.4    chopps 
   1826       1.4    chopps 		aga_this_data->bplcon0 = 0x0240 | USE_CON3;	/* color composite
   1827       1.4    chopps 								 * enable,
   1828       1.4    chopps 								 * shres. */
   1829      1.13   thorpej #ifdef GRF_AGA_VGA
   1830      1.12     veego 		aga_this_data->std_start_x = 0x40 /*STANDARD_VIEW_X*/;
   1831  1.20.8.1  jdolecek #else
   1832      1.13   thorpej 		aga_this_data->std_start_x = 0x4f /*STANDARD_VIEW_X*/;
   1833  1.20.8.1  jdolecek #endif
   1834       1.4    chopps 		aga_this_data->std_start_y = 0x2b /*STANDARD_VIEW_Y*/;
   1835       1.4    chopps 		aga_this_data->vbl_handler = (vbl_handler_func *) cc_mode_vbl_handler;
   1836       1.4    chopps 		aga_this_data->beamcon0 = SPECIAL_BEAMCON ^ VSYNCTRUE;
   1837       1.4    chopps 
   1838       1.4    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes,
   1839       1.4    chopps 		    aga_this, link);
   1840       1.4    chopps 	}
   1841       1.4    chopps 	return (aga_this);
   1842       1.4    chopps }
   1843       1.4    chopps 
   1844       1.4    chopps /* static, so I can patch and play */
   1845       1.4    chopps 
   1846      1.13   thorpej #ifdef GRF_AGA_VGA
   1847      1.12     veego int	AGA_htotal = 0x71;
   1848      1.12     veego int	AGA_hsstrt = 0xc;
   1849      1.12     veego int	AGA_hsstop = 0x16;
   1850      1.12     veego int	AGA_hbstrt = 0x5;
   1851      1.18        is int	AGA_vtotal = 0x1c1;
   1852  1.20.8.1  jdolecek #else
   1853      1.13   thorpej int	AGA_htotal = 0x79;
   1854      1.13   thorpej int	AGA_hsstrt = 0xe;
   1855      1.13   thorpej int	AGA_hsstop = 0x1c;
   1856      1.13   thorpej int	AGA_hbstrt = 0x8;
   1857      1.18        is int	AGA_vtotal = 0x1ec;
   1858  1.20.8.1  jdolecek #endif
   1859       1.4    chopps int	AGA_hbstop = 0x1e;
   1860       1.4    chopps int	AGA_vsstrt = 0x3;
   1861       1.4    chopps int	AGA_vsstop = 0x6;
   1862       1.4    chopps int	AGA_vbstrt = 0x0;
   1863       1.4    chopps int	AGA_vbstop = 0x19;
   1864       1.4    chopps int	AGA_hcenter = 0x4a;
   1865       1.4    chopps 
   1866       1.4    chopps void
   1867  1.20.8.1  jdolecek display_aga_view(view_t *v)
   1868       1.4    chopps {
   1869       1.4    chopps 	if (aga_this_data->current_view != v) {
   1870       1.4    chopps 		vdata_t *vd = VDATA(v);
   1871       1.4    chopps 		cop_t  *cp = aga_this_data->frames[F_STORE_LONG], *tmp;
   1872       1.4    chopps 		int     depth = v->bitmap->depth, i;
   1873       1.4    chopps 		int     hstart, hstop, vstart, vstop, j;
   1874       1.4    chopps 		int     x, y, w = v->display.width, h = v->display.height;
   1875       1.4    chopps 		u_short ddfstart, ddfwidth, con1;
   1876       1.4    chopps 
   1877       1.4    chopps #ifdef DEBUG
   1878       1.4    chopps 		if (aga_enable & AGA_TRACE)
   1879      1.15  christos 			printf("display_aga_view(%dx%dx%d) %p\n", w, h,
   1880       1.4    chopps 			    depth, v);
   1881       1.4    chopps #endif
   1882       1.4    chopps 		/* round down to nearest even width */
   1883       1.4    chopps 		/* w &= 0xfffe; */
   1884       1.4    chopps 		/* calculate datafetch width. */
   1885       1.4    chopps 
   1886       1.4    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 4) << 1;
   1887       1.4    chopps 
   1888       1.4    chopps 		/* this will center the any overscanned display */
   1889       1.4    chopps 		/* and allow user to modify. */
   1890       1.4    chopps 		x = v->display.x + aga_this_data->std_start_x - ((w - 640) >> 3);
   1891       1.4    chopps 		y = v->display.y + aga_this_data->std_start_y - ((h - 400) >> 1);
   1892       1.4    chopps 
   1893       1.4    chopps 		if (y & 1)
   1894       1.4    chopps 			y--;
   1895       1.4    chopps 
   1896       1.4    chopps 		if (!(x & 1))
   1897       1.4    chopps 			x--;
   1898       1.4    chopps 
   1899       1.4    chopps 		hstart = x;
   1900       1.4    chopps 		hstop = x + (w >> 2);
   1901       1.4    chopps 		vstart = y;
   1902       1.4    chopps 		vstop = y + (h >> 0);
   1903       1.4    chopps 		ddfstart = (hstart >> 1) - 8;
   1904       1.4    chopps 
   1905       1.4    chopps #ifdef DEBUG
   1906       1.4    chopps 		if (aga_enable & AGA_TRACE2) {
   1907      1.15  christos 			printf ("  ddfwidth %04x x %04x y %04x", ddfwidth,
   1908       1.4    chopps 			    x, y);
   1909      1.15  christos 			printf (" hstart %04x hstop %04x vstart %04x vstop %04x ddfstart %04x\n",
   1910       1.4    chopps 			    hstart, hstop, vstart, vstop, ddfstart);
   1911       1.4    chopps 		}
   1912       1.4    chopps #endif
   1913       1.4    chopps 		/* check for hardware limits, AGA may allow more..? */
   1914       1.4    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   1915       1.4    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   1916       1.4    chopps 			int     d = 0;
   1917       1.4    chopps 
   1918       1.4    chopps 			/* XXX anyone know the equality properties of
   1919       1.4    chopps 			 * intermixed logial AND's */
   1920       1.4    chopps 			/* XXX and arithmetic operators? */
   1921       1.4    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   1922       1.4    chopps 				d++;
   1923       1.4    chopps 			}
   1924       1.4    chopps 
   1925       1.4    chopps 			ddfstart -= d;
   1926       1.4    chopps 			hstart -= d << 1;
   1927       1.4    chopps 			hstop -= d << 1;
   1928       1.4    chopps 		}
   1929       1.4    chopps 		/* correct the datafetch to proper limits. */
   1930       1.4    chopps 		/* delay the actual display of the data until we need it. */
   1931       1.4    chopps 		ddfstart &= 0xfffc;
   1932       1.4    chopps #ifdef DEBUG
   1933       1.4    chopps 		if (aga_enable & AGA_TRACE2) {
   1934      1.15  christos 			printf ("  ddfwidth %04x x %04x y %04x", ddfwidth,
   1935       1.4    chopps 			    x, y);
   1936      1.15  christos 			printf (" hstart %04x hstop %04x vstart %04x vstop %04x ddfstart %04x\n",
   1937       1.4    chopps 			    hstart, hstop, vstart, vstop, ddfstart);
   1938       1.4    chopps 		}
   1939       1.4    chopps #endif
   1940       1.4    chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   1941       1.4    chopps 
   1942       1.4    chopps 		if (aga_this_data->current_view) {
   1943       1.4    chopps 			VDATA(aga_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   1944       1.4    chopps 			/* displayed. */
   1945       1.4    chopps 		}
   1946       1.4    chopps 		aga_this_data->current_view = v;
   1947       1.4    chopps 
   1948       1.4    chopps 		cp = aga_this_data->frames[F_STORE_LONG];
   1949       1.4    chopps 		tmp = cp;
   1950       1.4    chopps 		for (i = 0; i < 8; ++i) {
   1951       1.4    chopps 			if (tmp == NULL)
   1952       1.4    chopps 				break;
   1953       1.4    chopps 			tmp = find_copper_inst(tmp + 1, CI_MOVE(R_BPLCON3));
   1954       1.4    chopps 			if (tmp == NULL)
   1955       1.4    chopps 				break;
   1956       1.4    chopps 			tmp->cp.inst.operand = 0x0ca1 | (i << 13);
   1957       1.4    chopps 			tmp = find_copper_inst(tmp + 1, CI_MOVE(R_BPLCON3));
   1958       1.4    chopps 			if (tmp == NULL)
   1959       1.4    chopps 				break;
   1960       1.4    chopps 			tmp->cp.inst.operand = 0x0ea1 | (i << 13);
   1961       1.4    chopps 		}
   1962       1.4    chopps 		if (tmp)
   1963       1.4    chopps 			tmp = find_copper_inst(tmp + 1, CI_MOVE(R_BPLCON3));
   1964       1.4    chopps 		if (tmp)
   1965       1.4    chopps 			tmp->cp.inst.operand = 0x0ca1;
   1966       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   1967       1.4    chopps 		tmp->cp.inst.operand = 0x8003;
   1968       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HTOTAL));
   1969       1.4    chopps 		tmp->cp.inst.operand = AGA_htotal; /* 81/71/73/79? */
   1970       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HBSTRT));
   1971       1.4    chopps 		tmp->cp.inst.operand = AGA_hbstrt; /* 0x0008 */
   1972       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HSSTRT));
   1973       1.4    chopps 		tmp->cp.inst.operand = AGA_hsstrt; /* 0x000e */
   1974       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HSSTOP));
   1975       1.4    chopps 		tmp->cp.inst.operand = AGA_hsstop; /* 0x001c */
   1976       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HBSTOP));
   1977       1.4    chopps 		tmp->cp.inst.operand = AGA_hsstop; /* 0x001e */
   1978       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HCENTER));
   1979       1.4    chopps 		tmp->cp.inst.operand = AGA_hcenter; /*AGA_htotal / 2 + AGA_hsstrt */
   1980       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VBSTRT));
   1981       1.4    chopps 		tmp->cp.inst.operand = AGA_vbstrt; /* 0x0000 */
   1982       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VSSTRT));
   1983       1.4    chopps 		tmp->cp.inst.operand = AGA_vsstrt; /* 0x016b / AGA_htotal */
   1984       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VSSTOP));
   1985       1.4    chopps 		tmp->cp.inst.operand = AGA_vsstop; /* 0x02d6 / AGA_htotal */
   1986       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VBSTOP));
   1987       1.4    chopps 		tmp->cp.inst.operand = AGA_vbstop; /* 0x0bd1 / AGA_htotal */
   1988       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VTOTAL));
   1989       1.4    chopps 		tmp->cp.inst.operand = AGA_vtotal;
   1990       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   1991       1.4    chopps 		tmp->cp.inst.operand = aga_this_data->beamcon0;
   1992       1.4    chopps #ifdef DEBUG
   1993       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   1994      1.15  christos 			printf("  beamcon0 %04x", tmp->cp.inst.operand);
   1995       1.4    chopps #endif
   1996       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   1997       1.4    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   1998       1.4    chopps #ifdef DEBUG
   1999       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2000      1.15  christos 			printf(" diwhigh %04x>", tmp->cp.inst.operand);
   2001       1.4    chopps #endif
   2002       1.4    chopps #if 0
   2003       1.4    chopps 		tmp->cp.inst.operand = (vstop & 0x0700) | ((hstop & 0x0100) << 5);
   2004       1.4    chopps #endif
   2005       1.4    chopps #ifdef DEBUG
   2006       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2007      1.15  christos 			printf("%04x", tmp->cp.inst.operand);
   2008       1.4    chopps #endif
   2009       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   2010       1.4    chopps 		tmp->cp.inst.operand = aga_this_data->bplcon0 |
   2011       1.4    chopps 		    ((depth & 0x7) << 12) | ((depth & 0x8) << 1);
   2012       1.4    chopps #ifdef DEBUG
   2013       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2014      1.15  christos 			printf(" bplcon0 %04x", tmp->cp.inst.operand);
   2015       1.4    chopps #endif
   2016       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   2017       1.4    chopps 		tmp->cp.inst.operand = con1;
   2018       1.4    chopps #ifdef DEBUG
   2019       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2020      1.15  christos 			printf(" bplcon1 %04x>0000\n", con1);
   2021       1.4    chopps #endif
   2022       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   2023       1.4    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   2024       1.4    chopps #ifdef DEBUG
   2025       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2026      1.15  christos 			printf("  diwstart %04x", tmp->cp.inst.operand);
   2027       1.4    chopps #endif
   2028       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   2029       1.4    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   2030       1.4    chopps #ifdef DEBUG
   2031       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2032      1.15  christos 			printf(" diwstop %04x", tmp->cp.inst.operand);
   2033       1.4    chopps #endif
   2034       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   2035       1.4    chopps 		tmp->cp.inst.operand = ddfstart;
   2036       1.4    chopps #ifdef DEBUG
   2037       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2038      1.15  christos 			printf(" ddfstart %04x", tmp->cp.inst.operand);
   2039       1.4    chopps #endif
   2040       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   2041       1.4    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   2042       1.4    chopps #ifdef DEBUG
   2043       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2044      1.15  christos 			printf(" ddfstop %04x", tmp->cp.inst.operand);
   2045       1.4    chopps #endif
   2046       1.4    chopps 
   2047       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2048       1.4    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   2049       1.4    chopps 			/* update the plane pointers */
   2050       1.4    chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2051       1.4    chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2052       1.4    chopps #ifdef DEBUG
   2053       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2054      1.15  christos 			printf (" bpl%dpth %p", i, v->bitmap->plane[i]);
   2055       1.4    chopps #endif
   2056       1.4    chopps 		}
   2057       1.4    chopps 
   2058       1.4    chopps 		/* set mods correctly. */
   2059       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   2060       1.4    chopps 		tmp[0].cp.inst.operand = v->bitmap->row_mod;
   2061       1.4    chopps 		tmp[1].cp.inst.operand = v->bitmap->row_mod;
   2062       1.4    chopps #ifdef DEBUG
   2063       1.4    chopps 		if (aga_enable & AGA_TRACE2)
   2064      1.15  christos 			printf(" bplxmod %04x\n", v->bitmap->row_mod);
   2065       1.4    chopps #endif
   2066       1.4    chopps 
   2067       1.4    chopps 		/* set next pointers correctly */
   2068       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2069       1.4    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(aga_this_data->frames[F_STORE_LONG]));
   2070       1.4    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(aga_this_data->frames[F_STORE_LONG]));
   2071       1.4    chopps 
   2072       1.4    chopps 		cp = aga_this_data->frames[F_LONG];
   2073       1.4    chopps 		aga_this_data->frames[F_LONG] = aga_this_data->frames[F_STORE_LONG];
   2074       1.4    chopps 		aga_this_data->frames[F_STORE_LONG] = cp;
   2075       1.4    chopps 
   2076       1.4    chopps 		vd->flags |= VF_DISPLAY;
   2077       1.4    chopps 
   2078       1.5    chopps 		cc_use_aga_colormap(v, vd->colormap);
   2079       1.4    chopps 	}
   2080       1.4    chopps 	cc_load_mode(aga_this);
   2081       1.4    chopps #ifdef DEBUG
   2082       1.4    chopps 	if (aga_enable & AGA_TRACE)
   2083       1.4    chopps 		aga_enable |= AGA_TRACE2;	/* XXXX */
   2084       1.4    chopps #endif
   2085       1.4    chopps }
   2086      1.17    mhitch 
   2087      1.17    mhitch /*
   2088      1.17    mhitch  * SUPER72 Mode
   2089      1.17    mhitch  */
   2090      1.17    mhitch 
   2091      1.17    mhitch #if defined (GRF_SUPER72)
   2092      1.17    mhitch dmode_t *
   2093  1.20.8.1  jdolecek cc_init_super72(void)
   2094      1.17    mhitch {
   2095      1.17    mhitch 	/* this function should only be called once. */
   2096      1.17    mhitch 	if (!super72_this && (custom.deniseid & 0xff) == 0xf8) {
   2097      1.17    mhitch 		u_short len = aga_copper_list_len;
   2098      1.17    mhitch 
   2099      1.17    mhitch 		super72_this = &super72_mode;
   2100      1.17    mhitch 		super72_this_data = &super72_mode_data;
   2101      1.17    mhitch 		bzero(super72_this, sizeof(dmode_t));
   2102      1.17    mhitch 		bzero(super72_this_data, sizeof(dmdata_t));
   2103      1.17    mhitch 
   2104      1.17    mhitch 		super72_this->name = "super72: superhires interlace";
   2105      1.17    mhitch 		super72_this->nominal_size.width = 800;
   2106      1.17    mhitch 		super72_this->nominal_size.height = 600;
   2107      1.17    mhitch 		super72_this_data->max_size.width = 848;
   2108      1.17    mhitch 		super72_this_data->max_size.height = 614;
   2109      1.17    mhitch 		super72_this_data->min_size.width = 320;
   2110      1.17    mhitch 		super72_this_data->min_size.height = 484;
   2111      1.17    mhitch 		super72_this_data->min_depth = 1;
   2112      1.17    mhitch 		super72_this_data->max_depth = 8;
   2113      1.17    mhitch 		super72_this->data = super72_this_data;
   2114      1.17    mhitch 
   2115      1.17    mhitch 		super72_this->get_monitor = cc_get_monitor;
   2116      1.17    mhitch 		super72_this->alloc_view = cc_alloc_view;
   2117      1.17    mhitch 		super72_this->get_current_view = cc_get_current_view;
   2118      1.17    mhitch 
   2119      1.17    mhitch 		super72_this_data->use_colormap = cc_use_aga_colormap;
   2120      1.17    mhitch 		super72_this_data->get_colormap = cc_get_colormap;
   2121      1.17    mhitch 		super72_this_data->alloc_colormap = cc_alloc_aga_colormap;
   2122      1.17    mhitch 		super72_this_data->display_view = display_super72_view;
   2123      1.17    mhitch 		super72_this_data->monitor = cc_monitor;
   2124      1.17    mhitch 
   2125      1.17    mhitch 		super72_this_data->flags |= DMF_INTERLACE;
   2126      1.17    mhitch 
   2127      1.17    mhitch 		super72_this_data->frames = super72_frames;	/* MAY NEED TO CHANGE COPLIST */
   2128      1.17    mhitch 		super72_this_data->frames[F_LACE_LONG] =
   2129      1.17    mhitch 		    alloc_chipmem(aga_copper_list_size * F_LACE_TOTAL);
   2130      1.17    mhitch 		if (!super72_this_data->frames[F_LACE_LONG]) {
   2131      1.17    mhitch 			panic("couldn't get chipmem for copper list");
   2132      1.17    mhitch 		}
   2133      1.17    mhitch 		super72_this_data->frames[F_LACE_SHORT] =
   2134      1.17    mhitch 		    &super72_this_data->frames[F_LACE_LONG][len];
   2135      1.17    mhitch 		super72_this_data->frames[F_LACE_STORE_LONG] =
   2136      1.17    mhitch 		    &super72_this_data->frames[F_LACE_SHORT][len];
   2137      1.17    mhitch 		super72_this_data->frames[F_LACE_STORE_SHORT] =
   2138      1.17    mhitch 		    &super72_this_data->frames[F_LACE_STORE_LONG][len];
   2139      1.17    mhitch 
   2140      1.17    mhitch 		bcopy(aga_copper_list,
   2141      1.17    mhitch 		    super72_this_data->frames[F_LACE_STORE_LONG],
   2142      1.17    mhitch 		    aga_copper_list_size);
   2143      1.17    mhitch 		bcopy(aga_copper_list,
   2144      1.17    mhitch 		    super72_this_data->frames[F_LACE_STORE_SHORT],
   2145      1.17    mhitch 		    aga_copper_list_size);
   2146      1.17    mhitch 		bcopy(aga_copper_list,
   2147      1.17    mhitch 		    super72_this_data->frames[F_LACE_LONG],
   2148      1.17    mhitch 		    aga_copper_list_size);
   2149      1.17    mhitch 		bcopy(aga_copper_list,
   2150      1.17    mhitch 		    super72_this_data->frames[F_LACE_SHORT],
   2151      1.17    mhitch 		    aga_copper_list_size);
   2152      1.17    mhitch 
   2153      1.17    mhitch 		super72_this_data->bplcon0 = 0x0244 | USE_CON3;	/* color
   2154      1.17    mhitch 								 * composite enable,
   2155      1.17    mhitch 								 * shres
   2156      1.17    mhitch 								 * lace. */
   2157      1.17    mhitch #if 0	/* patchable variables for testing */
   2158      1.17    mhitch 		super72_this_data->std_start_x = 0x6c;
   2159      1.17    mhitch 		super72_this_data->std_start_y = 0x1b;
   2160      1.17    mhitch #endif
   2161      1.17    mhitch 		super72_this_data->vbl_handler =
   2162      1.17    mhitch 		    (vbl_handler_func *) cc_lace_mode_vbl_handler;
   2163      1.17    mhitch 		super72_this_data->beamcon0 = (SPECIAL_BEAMCON ^ VSYNCTRUE) |
   2164      1.17    mhitch 		    DISPLAYPAL | 0x4000;
   2165      1.17    mhitch 		super72_this_data->beamcon0 = 0x5bb0;
   2166      1.17    mhitch 
   2167      1.17    mhitch 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, super72_this, link);
   2168      1.17    mhitch 	}
   2169      1.17    mhitch 	return (super72_this);
   2170      1.17    mhitch }
   2171      1.17    mhitch 
   2172      1.17    mhitch /* Super72 83Hz hack monitor values */
   2173      1.17    mhitch /*int	super72_htotal = 0x083;
   2174      1.17    mhitch int	super72_hsstrt = 0x00d;
   2175      1.17    mhitch int	super72_hsstop = 0x01b;
   2176      1.17    mhitch int	super72_hbstrt = 0x001;
   2177      1.17    mhitch int	super72_hbstop = 0x021;
   2178      1.17    mhitch int	super72_vtotal = 0x148;
   2179      1.17    mhitch int	super72_vsstrt = 0x2d5;
   2180      1.17    mhitch int	super72_vsstop = 0x3ca;
   2181      1.17    mhitch int	super72_vbstrt = 0x000;
   2182      1.17    mhitch int	super72_vbstop = 0xfdc;
   2183      1.17    mhitch int	super72_hcenter = 0x04e;
   2184      1.17    mhitch */
   2185      1.17    mhitch 
   2186      1.17    mhitch /* Super72 standard monitor values */
   2187      1.17    mhitch int	super72_htotal = 154;	/* 0x099*/
   2188      1.17    mhitch int	super72_hsstrt = 17;	/* 0x01c*/
   2189      1.17    mhitch int	super72_hsstop = 27;	/* 0x038*/
   2190      1.17    mhitch int	super72_hbstrt = 154;	/* 0x008*/
   2191      1.17    mhitch int	super72_hbstop = 55;	/* 0x01e*/
   2192      1.17    mhitch int	super72_vtotal = 328;	/* 0x147*/
   2193      1.17    mhitch int	super72_vsstrt = 11;	/* 0x030*/
   2194      1.17    mhitch int	super72_vsstop = 18;	/* 0x033*/
   2195      1.17    mhitch int	super72_vbstrt = 327;	/* 0x000*/
   2196      1.17    mhitch int	super72_vbstop = 27;	/* 0x019*/
   2197      1.17    mhitch int	super72_hcenter = 94;	/* 0x057*/
   2198      1.17    mhitch int	super72_startx = 100;
   2199      1.17    mhitch int	super72_starty = 27;
   2200      1.17    mhitch 
   2201      1.17    mhitch void
   2202  1.20.8.1  jdolecek display_super72_view(view_t *v)
   2203      1.17    mhitch {
   2204      1.17    mhitch 	if (super72_this_data->current_view != v) {
   2205      1.17    mhitch 		vdata_t *vd = VDATA(v);
   2206      1.17    mhitch 		cop_t  *cp = super72_this_data->frames[F_LACE_STORE_LONG], *tmp;
   2207      1.17    mhitch 		int     depth = v->bitmap->depth, i;
   2208      1.17    mhitch 		int     hstart, hstop, vstart, vstop, j;
   2209      1.17    mhitch 		int     x, y, w = v->display.width, h = v->display.height;
   2210      1.17    mhitch 		u_short ddfstart, ddfwidth, con1;
   2211      1.17    mhitch 
   2212      1.17    mhitch 		/* round down to nearest even width */
   2213      1.17    mhitch 		/* w &= 0xfffe; */
   2214      1.17    mhitch 
   2215      1.17    mhitch 		/* calculate datafetch width. */
   2216      1.17    mhitch 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 4) << 1;
   2217      1.17    mhitch 
   2218      1.17    mhitch 		/* This will center any overscanned display */
   2219      1.17    mhitch 		/* and allow user to modify. */
   2220      1.17    mhitch 		x = (v->display.x >> 1) + super72_startx - ((w - 800) >> 3);
   2221      1.17    mhitch 		y = v->display.y + super72_starty - ((h - 600) >> 2);
   2222      1.17    mhitch 
   2223      1.17    mhitch 		hstart = x;
   2224      1.17    mhitch 		hstop = x + (w >> 2);
   2225      1.17    mhitch 		vstart = y;
   2226      1.17    mhitch 		vstop = y + (h >> 1);
   2227      1.17    mhitch 		ddfstart = (hstart >> 1) - 16;
   2228      1.17    mhitch 
   2229      1.17    mhitch 		ddfstart = (hstart << 2) - 4;
   2230      1.17    mhitch 		con1 = ddfstart & 63;
   2231      1.17    mhitch 		ddfstart = (ddfstart & -64) - 64;
   2232      1.17    mhitch 		ddfwidth = ((w + 64 - 1) & -64) - 64;
   2233      1.17    mhitch 		ddfwidth = ddfwidth >> 3;
   2234      1.17    mhitch 		ddfstart = ddfstart >> 3;
   2235      1.17    mhitch 		super72_hbstrt = ((x << 2) + w + 4) >> 3;
   2236      1.17    mhitch 		super72_hbstop = (hstart + 1) >> 1;
   2237      1.17    mhitch 		super72_vbstrt = vstop;
   2238      1.17    mhitch 		super72_vbstop = vstart - 2;
   2239      1.17    mhitch 
   2240      1.17    mhitch 		if ((hstop >> 1) > super72_htotal) {
   2241      1.17    mhitch 			int     d;
   2242      1.17    mhitch 
   2243      1.17    mhitch 			d = (hstop >> 1) - super72_htotal;
   2244      1.17    mhitch 			ddfstart -= d;
   2245      1.17    mhitch 			hstart -= d << 1;
   2246      1.17    mhitch 			hstop -= d << 1;
   2247      1.17    mhitch 		}
   2248      1.17    mhitch 		if (vstop >= super72_vtotal) {
   2249      1.17    mhitch 			int	d;
   2250      1.17    mhitch 			d = (vstop - super72_vtotal + 1);
   2251      1.17    mhitch 			vstart -= d;
   2252      1.17    mhitch 			vstop -= d;
   2253      1.17    mhitch 		}
   2254      1.17    mhitch 		con1 = ((con1 >> 2) & 0x000f) |		/* PF1H2-PF1H5 */
   2255      1.17    mhitch 		       ((con1 << 8) & 0x0300) |		/* PF1H0-PF1H2 */
   2256      1.17    mhitch 		       ((con1 << 4) & 0x0c00);		/* PF1H6-PF1H7 */
   2257      1.17    mhitch 		con1 |= con1 << 4;			/* PF2H2-PF2H7 */
   2258      1.17    mhitch 
   2259      1.17    mhitch 		if (super72_this_data->current_view) {
   2260      1.17    mhitch 			VDATA(super72_this_data->current_view)->flags &=
   2261      1.17    mhitch 			    ~VF_DISPLAY;	/* mark as no longer */
   2262      1.17    mhitch 						/* displayed. */
   2263      1.17    mhitch 		}
   2264      1.17    mhitch 		super72_this_data->current_view = v;
   2265      1.17    mhitch 
   2266      1.17    mhitch 		cp = super72_this_data->frames[F_LACE_STORE_LONG];
   2267      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   2268      1.17    mhitch 		tmp->cp.inst.operand = 0x8003;
   2269      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_HTOTAL));
   2270  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_htotal;
   2271      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_HBSTRT));
   2272  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_hbstrt;
   2273      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_HSSTRT));
   2274  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_hsstrt;
   2275      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_HSSTOP));
   2276  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_hsstop;
   2277      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_HBSTOP));
   2278  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_hbstop;
   2279      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_HCENTER));
   2280      1.17    mhitch 		tmp->cp.inst.operand = super72_hcenter;
   2281      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_VBSTRT));
   2282  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_vbstrt;
   2283      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_VSSTRT));
   2284  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_vsstrt;
   2285      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_VSSTOP));
   2286  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_vsstop;
   2287      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_VBSTOP));
   2288  1.20.8.1  jdolecek 		tmp->cp.inst.operand = super72_vbstop;
   2289      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_VTOTAL));
   2290      1.17    mhitch 		tmp->cp.inst.operand = super72_vtotal;
   2291      1.17    mhitch 
   2292      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   2293      1.17    mhitch 		tmp->cp.inst.operand = super72_this_data->beamcon0;
   2294      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   2295      1.17    mhitch 		tmp->cp.inst.operand =
   2296      1.17    mhitch 		    CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   2297      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   2298      1.17    mhitch 		tmp->cp.inst.operand = super72_this_data->bplcon0 |
   2299      1.17    mhitch 		    ((depth & 0x7) << 12) | ((depth & 0x8) << 1);
   2300      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   2301      1.17    mhitch 		tmp->cp.inst.operand = con1;
   2302      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   2303      1.17    mhitch 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   2304      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   2305      1.17    mhitch 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   2306      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   2307      1.17    mhitch 		tmp->cp.inst.operand = ddfstart;
   2308      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   2309      1.17    mhitch 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   2310      1.17    mhitch 
   2311      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2312      1.17    mhitch 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   2313      1.17    mhitch 			/* update the plane pointers */
   2314      1.17    mhitch 			tmp[j].cp.inst.operand =
   2315      1.17    mhitch 			    HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2316      1.17    mhitch 			tmp[j + 1].cp.inst.operand =
   2317      1.17    mhitch 			    LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2318      1.17    mhitch 		}
   2319      1.17    mhitch 
   2320      1.17    mhitch 		/* set mods correctly. */
   2321      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   2322      1.17    mhitch 		tmp[0].cp.inst.operand = v->bitmap->bytes_per_row +
   2323      1.17    mhitch 		    v->bitmap->row_mod;
   2324      1.17    mhitch 		tmp[1].cp.inst.operand = v->bitmap->bytes_per_row +
   2325      1.17    mhitch 		    v->bitmap->row_mod;
   2326      1.17    mhitch 
   2327      1.17    mhitch 		/* set next pointers correctly */
   2328      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2329      1.17    mhitch 		tmp[0].cp.inst.operand =
   2330      1.17    mhitch 		    HIADDR(PREP_DMA_MEM(super72_this_data->frames[F_LACE_STORE_SHORT]));
   2331      1.17    mhitch 		tmp[1].cp.inst.operand =
   2332      1.17    mhitch 		    LOADDR(PREP_DMA_MEM(super72_this_data->frames[F_LACE_STORE_SHORT]));
   2333      1.17    mhitch 
   2334      1.17    mhitch 		bcopy(super72_this_data->frames[F_LACE_STORE_LONG],
   2335      1.17    mhitch 		    super72_this_data->frames[F_LACE_STORE_SHORT],
   2336      1.17    mhitch 		    aga_copper_list_size);
   2337      1.17    mhitch 
   2338      1.17    mhitch 		/* these are the only ones that are different from long frame. */
   2339      1.17    mhitch 		cp = super72_this_data->frames[F_LACE_STORE_SHORT];
   2340      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2341      1.17    mhitch 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   2342      1.17    mhitch 			u_short mod = v->bitmap->bytes_per_row +
   2343      1.17    mhitch 			    v->bitmap->row_mod;
   2344      1.17    mhitch 			/* update plane pointers. high and low. */
   2345      1.17    mhitch 			tmp[j].cp.inst.operand =
   2346      1.17    mhitch 			    HIADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   2347      1.17    mhitch 			tmp[j + 1].cp.inst.operand =
   2348      1.17    mhitch 			    LOADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   2349      1.17    mhitch 		}
   2350      1.17    mhitch 
   2351      1.17    mhitch 		/* set next pointers correctly */
   2352      1.17    mhitch 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2353      1.17    mhitch 		tmp[0].cp.inst.operand =
   2354      1.17    mhitch 		    HIADDR(PREP_DMA_MEM(super72_this_data->frames[F_LACE_STORE_LONG]));
   2355      1.17    mhitch 		tmp[1].cp.inst.operand =
   2356      1.17    mhitch 		     LOADDR(PREP_DMA_MEM(super72_this_data->frames[F_LACE_STORE_LONG]));
   2357      1.17    mhitch 
   2358      1.17    mhitch 		cp = super72_this_data->frames[F_LACE_LONG];
   2359      1.17    mhitch 		super72_this_data->frames[F_LACE_LONG] =
   2360      1.17    mhitch 		    super72_this_data->frames[F_LACE_STORE_LONG];
   2361      1.17    mhitch 		super72_this_data->frames[F_LACE_STORE_LONG] = cp;
   2362      1.17    mhitch 
   2363      1.17    mhitch 		cp = super72_this_data->frames[F_LACE_SHORT];
   2364      1.17    mhitch 		super72_this_data->frames[F_LACE_SHORT] =
   2365      1.17    mhitch 		    super72_this_data->frames[F_LACE_STORE_SHORT];
   2366      1.17    mhitch 		super72_this_data->frames[F_LACE_STORE_SHORT] = cp;
   2367      1.17    mhitch 
   2368      1.17    mhitch 		vd->flags |= VF_DISPLAY;
   2369      1.17    mhitch 		cc_use_aga_colormap(v, vd->colormap);
   2370      1.17    mhitch 	}
   2371      1.17    mhitch 	cc_load_mode(super72_this);
   2372      1.17    mhitch }
   2373      1.17    mhitch #endif /* GRF_SUPER72 */
   2374       1.4    chopps 
   2375       1.4    chopps #endif /* GRF_AGA */
   2376       1.1    chopps #endif /* GRF_NTSC */
   2377       1.1    chopps 
   2378       1.1    chopps /*
   2379       1.1    chopps  * PAL modes.
   2380       1.1    chopps  */
   2381       1.1    chopps 
   2382       1.1    chopps #if defined (GRF_PAL)
   2383       1.1    chopps 
   2384       1.1    chopps dmode_t *
   2385  1.20.8.1  jdolecek cc_init_pal_hires(void)
   2386       1.1    chopps {
   2387       1.4    chopps 	/* this function should only be called once. */
   2388       1.1    chopps 	if (!ph_this) {
   2389       1.1    chopps 		u_short len = std_copper_list_len;
   2390       1.1    chopps 
   2391       1.1    chopps 		ph_this = &pal_hires_mode;
   2392       1.1    chopps 		ph_this_data = &pal_hires_mode_data;
   2393       1.1    chopps 		bzero(ph_this, sizeof(dmode_t));
   2394       1.1    chopps 		bzero(ph_this_data, sizeof(dmdata_t));
   2395       1.1    chopps 
   2396       1.7    chopps 		ph_this->name = "pal: hires";
   2397       1.1    chopps 		ph_this->nominal_size.width = 640;
   2398       1.1    chopps 		ph_this->nominal_size.height = 256;
   2399       1.1    chopps 		ph_this_data->max_size.width = 724;
   2400       1.1    chopps 		ph_this_data->max_size.height = 289;
   2401       1.1    chopps 		ph_this_data->min_size.width = 320;
   2402       1.1    chopps 		ph_this_data->min_size.height = 244;
   2403       1.1    chopps 		ph_this_data->min_depth = 1;
   2404       1.1    chopps 		ph_this_data->max_depth = 4;
   2405       1.1    chopps 		ph_this->data = ph_this_data;
   2406       1.1    chopps 
   2407       1.1    chopps 		ph_this->get_monitor = cc_get_monitor;
   2408       1.1    chopps 		ph_this->alloc_view = cc_alloc_view;
   2409       1.1    chopps 		ph_this->get_current_view = cc_get_current_view;
   2410       1.1    chopps 
   2411       1.1    chopps 		ph_this_data->use_colormap = cc_use_colormap;
   2412       1.1    chopps 		ph_this_data->get_colormap = cc_get_colormap;
   2413       1.1    chopps 		ph_this_data->alloc_colormap = cc_alloc_colormap;
   2414       1.1    chopps 		ph_this_data->display_view = display_pal_hires_view;
   2415       1.1    chopps 		ph_this_data->monitor = cc_monitor;
   2416       1.1    chopps 
   2417       1.1    chopps 		ph_this_data->frames = pal_hires_frames;
   2418       1.1    chopps 		ph_this_data->frames[F_LONG] = alloc_chipmem(std_copper_list_size * F_TOTAL);
   2419       1.1    chopps 		if (!ph_this_data->frames[F_LONG]) {
   2420       1.1    chopps 			panic("couldn't get chipmem for copper list");
   2421       1.1    chopps 		}
   2422       1.1    chopps 		ph_this_data->frames[F_STORE_LONG] = &ph_this_data->frames[F_LONG][len];
   2423       1.1    chopps 
   2424       1.1    chopps 		bcopy(std_copper_list, ph_this_data->frames[F_STORE_LONG], std_copper_list_size);
   2425       1.1    chopps 		bcopy(std_copper_list, ph_this_data->frames[F_LONG], std_copper_list_size);
   2426       1.1    chopps 
   2427       1.1    chopps 		ph_this_data->bplcon0 = 0x8200 | USE_CON3;	/* pal_hires, color
   2428       1.1    chopps 								 * composite enable,
   2429       1.1    chopps 								 * lace. */
   2430       1.1    chopps 		ph_this_data->std_start_x = STANDARD_VIEW_X;
   2431       1.1    chopps 		ph_this_data->std_start_y = STANDARD_VIEW_Y;
   2432       1.1    chopps 		ph_this_data->vbl_handler = (vbl_handler_func *) cc_mode_vbl_handler;
   2433      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   2434       1.1    chopps 		ph_this_data->beamcon0 = STANDARD_PAL_BEAMCON;
   2435       1.1    chopps #endif
   2436       1.1    chopps 
   2437       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, ph_this, link);
   2438       1.1    chopps 	}
   2439       1.1    chopps 	return (ph_this);
   2440       1.1    chopps }
   2441       1.1    chopps 
   2442       1.1    chopps void
   2443  1.20.8.1  jdolecek display_pal_hires_view(view_t *v)
   2444       1.1    chopps {
   2445       1.1    chopps 	if (ph_this_data->current_view != v) {
   2446       1.1    chopps 		vdata_t *vd = VDATA(v);
   2447       1.1    chopps 		cop_t  *cp = ph_this_data->frames[F_STORE_LONG], *tmp;
   2448       1.1    chopps 		int     depth = v->bitmap->depth, i;
   2449       1.1    chopps 		int     hstart, hstop, vstart, vstop, j;
   2450       1.1    chopps 		int     x, y, w = v->display.width, h = v->display.height;
   2451       1.1    chopps 		u_short ddfstart, ddfwidth, con1;
   2452       1.1    chopps 
   2453       1.1    chopps 		/* round down to nearest even width */
   2454       1.1    chopps 		/* w &= 0xfffe; */
   2455       1.1    chopps 
   2456       1.1    chopps 		/* calculate datafetch width. */
   2457       1.1    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   2458       1.1    chopps 
   2459       1.4    chopps 		/* This will center the any overscanned display */
   2460       1.1    chopps 		/* and allow user to modify. */
   2461       1.1    chopps 		x = v->display.x + ph_this_data->std_start_x - ((w - 640) >> 2);
   2462       1.1    chopps 		y = v->display.y + ph_this_data->std_start_y - ((h - 256) >> 1);
   2463       1.1    chopps 
   2464       1.1    chopps 		if (y & 1)
   2465       1.1    chopps 			y--;
   2466       1.1    chopps 
   2467       1.1    chopps 		if (!(x & 1))
   2468       1.1    chopps 			x--;
   2469       1.1    chopps 
   2470       1.1    chopps 		hstart = x;
   2471       1.1    chopps 		hstop = x + (w >> 1);
   2472       1.1    chopps 		vstart = y;
   2473       1.1    chopps 		vstop = y + h;
   2474       1.1    chopps 		ddfstart = (hstart - 9) >> 1;
   2475       1.1    chopps 		/* check for hardware limits, AGA may allow more..? */
   2476       1.1    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   2477       1.1    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   2478       1.1    chopps 			int     d = 0;
   2479       1.1    chopps 
   2480       1.1    chopps 			/* XXX anyone know the equality properties of
   2481       1.1    chopps 			 * intermixed logial AND's */
   2482       1.1    chopps 			/* XXX and arithmetic operators? */
   2483       1.1    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   2484       1.1    chopps 				d++;
   2485       1.1    chopps 			}
   2486       1.1    chopps 
   2487       1.1    chopps 			ddfstart -= d;
   2488       1.1    chopps 			hstart -= d << 1;
   2489       1.1    chopps 			hstop -= d << 1;
   2490       1.1    chopps 		}
   2491       1.1    chopps 		/* correct the datafetch to proper limits. */
   2492       1.1    chopps 		/* delay the actual display of the data until we need it. */
   2493       1.1    chopps 		ddfstart &= 0xfffc;
   2494       1.1    chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   2495       1.1    chopps 
   2496       1.1    chopps 		if (ph_this_data->current_view) {
   2497       1.1    chopps 			VDATA(ph_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   2498       1.1    chopps 			/* displayed. */
   2499       1.1    chopps 		}
   2500       1.1    chopps 		ph_this_data->current_view = v;
   2501       1.1    chopps 
   2502       1.1    chopps 		cp = ph_this_data->frames[F_STORE_LONG];
   2503      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   2504       1.4    chopps #if defined GRF_AGA
   2505       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   2506       1.4    chopps 		tmp->cp.inst.operand = 0;
   2507       1.4    chopps #endif
   2508       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   2509       1.1    chopps 		tmp->cp.inst.operand = ph_this_data->beamcon0;
   2510       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   2511       1.1    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   2512       1.1    chopps #endif /* ECS */
   2513       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   2514       1.1    chopps 		tmp->cp.inst.operand = ph_this_data->bplcon0 | ((depth & 0x7) << 12);
   2515       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   2516       1.1    chopps 		tmp->cp.inst.operand = con1;
   2517       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   2518       1.1    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   2519       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   2520       1.1    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   2521       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   2522       1.1    chopps 		tmp->cp.inst.operand = ddfstart;
   2523       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   2524       1.1    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   2525       1.1    chopps 
   2526       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2527       1.1    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   2528       1.1    chopps 			/* update the plane pointers */
   2529       1.1    chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2530       1.1    chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2531       1.1    chopps 		}
   2532       1.1    chopps 
   2533       1.1    chopps 		/* set mods correctly. */
   2534       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   2535       1.1    chopps 		tmp[0].cp.inst.operand = v->bitmap->row_mod;
   2536       1.1    chopps 		tmp[1].cp.inst.operand = v->bitmap->row_mod;
   2537       1.1    chopps 
   2538       1.1    chopps 		/* set next pointers correctly */
   2539       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2540       1.1    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(ph_this_data->frames[F_STORE_LONG]));
   2541       1.1    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(ph_this_data->frames[F_STORE_LONG]));
   2542       1.1    chopps 
   2543       1.1    chopps 		cp = ph_this_data->frames[F_LONG];
   2544       1.1    chopps 		ph_this_data->frames[F_LONG] = ph_this_data->frames[F_STORE_LONG];
   2545       1.1    chopps 		ph_this_data->frames[F_STORE_LONG] = cp;
   2546       1.1    chopps 
   2547       1.1    chopps 		vd->flags |= VF_DISPLAY;
   2548       1.1    chopps 		cc_use_colormap(v, vd->colormap);
   2549       1.1    chopps 	}
   2550       1.1    chopps 	cc_load_mode(ph_this);
   2551       1.1    chopps }
   2552       1.1    chopps 
   2553       1.1    chopps dmode_t *
   2554  1.20.8.1  jdolecek cc_init_pal_hires_lace(void)
   2555       1.1    chopps {
   2556       1.4    chopps 	/* this function should only be called once. */
   2557       1.1    chopps 	if (!phl_this) {
   2558       1.1    chopps 		u_short len = std_copper_list_len;
   2559       1.1    chopps 
   2560       1.1    chopps 		phl_this = &pal_hires_lace_mode;
   2561       1.1    chopps 		phl_this_data = &pal_hires_lace_mode_data;
   2562       1.1    chopps 		bzero(phl_this, sizeof(dmode_t));
   2563       1.1    chopps 		bzero(phl_this_data, sizeof(dmdata_t));
   2564       1.1    chopps 
   2565       1.1    chopps 		phl_this->name = "pal: hires interlace";
   2566       1.1    chopps 		phl_this->nominal_size.width = 640;
   2567       1.1    chopps 		phl_this->nominal_size.height = 512;
   2568       1.1    chopps 		phl_this_data->max_size.width = 724;
   2569       1.1    chopps 		phl_this_data->max_size.height = 578;
   2570       1.1    chopps 		phl_this_data->min_size.width = 320;
   2571       1.1    chopps 		phl_this_data->min_size.height = 484;
   2572       1.1    chopps 		phl_this_data->min_depth = 1;
   2573       1.1    chopps 		phl_this_data->max_depth = 4;
   2574       1.1    chopps 		phl_this->data = phl_this_data;
   2575       1.1    chopps 
   2576       1.1    chopps 		phl_this->get_monitor = cc_get_monitor;
   2577       1.1    chopps 		phl_this->alloc_view = cc_alloc_view;
   2578       1.1    chopps 		phl_this->get_current_view = cc_get_current_view;
   2579       1.1    chopps 
   2580       1.1    chopps 		phl_this_data->use_colormap = cc_use_colormap;
   2581       1.1    chopps 		phl_this_data->get_colormap = cc_get_colormap;
   2582       1.1    chopps 		phl_this_data->alloc_colormap = cc_alloc_colormap;
   2583       1.1    chopps 		phl_this_data->display_view = display_pal_hires_lace_view;
   2584       1.1    chopps 		phl_this_data->monitor = cc_monitor;
   2585       1.1    chopps 
   2586       1.1    chopps 		phl_this_data->flags |= DMF_INTERLACE;
   2587       1.1    chopps 
   2588       1.1    chopps 		phl_this_data->frames = pal_hires_lace_frames;
   2589       1.1    chopps 		phl_this_data->frames[F_LACE_LONG] = alloc_chipmem(std_copper_list_size * F_LACE_TOTAL);
   2590       1.1    chopps 		if (!phl_this_data->frames[F_LACE_LONG]) {
   2591       1.1    chopps 			panic("couldn't get chipmem for copper list");
   2592       1.1    chopps 		}
   2593       1.1    chopps 		phl_this_data->frames[F_LACE_SHORT] = &phl_this_data->frames[F_LACE_LONG][len];
   2594       1.1    chopps 		phl_this_data->frames[F_LACE_STORE_LONG] = &phl_this_data->frames[F_LACE_SHORT][len];
   2595       1.1    chopps 		phl_this_data->frames[F_LACE_STORE_SHORT] = &phl_this_data->frames[F_LACE_STORE_LONG][len];
   2596       1.1    chopps 
   2597       1.1    chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_STORE_LONG], std_copper_list_size);
   2598       1.1    chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_STORE_SHORT], std_copper_list_size);
   2599       1.1    chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_LONG], std_copper_list_size);
   2600       1.1    chopps 		bcopy(std_copper_list, phl_this_data->frames[F_LACE_SHORT], std_copper_list_size);
   2601       1.1    chopps 
   2602       1.1    chopps 		phl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
   2603       1.1    chopps 								 * composite enable,
   2604       1.1    chopps 								 * lace. */
   2605       1.1    chopps 		phl_this_data->std_start_x = STANDARD_VIEW_X;
   2606       1.1    chopps 		phl_this_data->std_start_y = STANDARD_VIEW_Y;
   2607       1.1    chopps 		phl_this_data->vbl_handler = (vbl_handler_func *) cc_lace_mode_vbl_handler;
   2608      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   2609       1.1    chopps 		phl_this_data->beamcon0 = STANDARD_PAL_BEAMCON;
   2610       1.1    chopps #endif
   2611       1.1    chopps 
   2612       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, phl_this, link);
   2613       1.1    chopps 	}
   2614       1.1    chopps 	return (phl_this);
   2615       1.1    chopps }
   2616       1.1    chopps 
   2617       1.1    chopps void
   2618  1.20.8.1  jdolecek display_pal_hires_lace_view(view_t *v)
   2619       1.1    chopps {
   2620       1.1    chopps 	if (phl_this_data->current_view != v) {
   2621       1.1    chopps 		vdata_t *vd = VDATA(v);
   2622       1.1    chopps 		cop_t  *cp = phl_this_data->frames[F_LACE_STORE_LONG], *tmp;
   2623       1.1    chopps 		int     depth = v->bitmap->depth, i;
   2624       1.1    chopps 		int     hstart, hstop, vstart, vstop, j;
   2625       1.1    chopps 		int     x, y, w = v->display.width, h = v->display.height;
   2626       1.1    chopps 		u_short ddfstart, ddfwidth, con1;
   2627       1.1    chopps 
   2628       1.1    chopps 		/* round down to nearest even width */
   2629       1.1    chopps 		/* w &= 0xfffe; */
   2630       1.1    chopps 
   2631       1.1    chopps 		/* calculate datafetch width. */
   2632       1.1    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   2633       1.1    chopps 
   2634       1.4    chopps 		/* This will center the any overscanned display */
   2635       1.1    chopps 		/* and allow user to modify. */
   2636       1.1    chopps 		x = v->display.x + phl_this_data->std_start_x - ((w - 640) >> 2);
   2637       1.1    chopps 		y = v->display.y + phl_this_data->std_start_y - ((h - 512) >> 2);
   2638       1.1    chopps 
   2639       1.1    chopps 		if (y & 1)
   2640       1.1    chopps 			y--;
   2641       1.1    chopps 
   2642       1.1    chopps 		if (!(x & 1))
   2643       1.1    chopps 			x--;
   2644       1.1    chopps 
   2645       1.1    chopps 		hstart = x;
   2646       1.1    chopps 		hstop = x + (w >> 1);
   2647       1.1    chopps 		vstart = y;
   2648       1.1    chopps 		vstop = y + (h >> 1);
   2649       1.1    chopps 		ddfstart = (hstart - 9) >> 1;
   2650       1.1    chopps 
   2651       1.1    chopps 		/* check for hardware limits, AGA may allow more..? */
   2652       1.1    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   2653       1.1    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   2654       1.1    chopps 			int     d = 0;
   2655       1.1    chopps 
   2656       1.1    chopps 			/* XXX anyone know the equality properties of
   2657       1.1    chopps 			 * intermixed logial AND's */
   2658       1.1    chopps 			/* XXX and arithmetic operators? */
   2659       1.1    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   2660       1.1    chopps 				d++;
   2661       1.1    chopps 			}
   2662       1.1    chopps 
   2663       1.1    chopps 			ddfstart -= d;
   2664       1.1    chopps 			hstart -= d << 1;
   2665       1.1    chopps 			hstop -= d << 1;
   2666       1.1    chopps 		}
   2667       1.1    chopps 		/* correct the datafetch to proper limits. */
   2668       1.1    chopps 		/* delay the actual display of the data until we need it. */
   2669       1.1    chopps 		ddfstart &= 0xfffc;
   2670       1.1    chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   2671       1.1    chopps 
   2672       1.1    chopps 		if (phl_this_data->current_view) {
   2673       1.1    chopps 			VDATA(phl_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   2674       1.1    chopps 			/* displayed. */
   2675       1.1    chopps 		}
   2676       1.1    chopps 		phl_this_data->current_view = v;
   2677       1.1    chopps 
   2678       1.1    chopps 		cp = phl_this_data->frames[F_LACE_STORE_LONG];
   2679      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   2680       1.4    chopps #if defined GRF_AGA
   2681       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   2682       1.4    chopps 		tmp->cp.inst.operand = 0;
   2683       1.4    chopps #endif
   2684       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   2685       1.1    chopps 		tmp->cp.inst.operand = phl_this_data->beamcon0;
   2686       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   2687       1.1    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   2688       1.1    chopps #endif /* ECS */
   2689       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   2690       1.1    chopps 		tmp->cp.inst.operand = phl_this_data->bplcon0 | ((depth & 0x7) << 12);
   2691       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   2692       1.1    chopps 		tmp->cp.inst.operand = con1;
   2693       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   2694       1.1    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   2695       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   2696       1.1    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   2697       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   2698       1.1    chopps 		tmp->cp.inst.operand = ddfstart;
   2699       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   2700       1.1    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   2701       1.1    chopps 
   2702       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2703       1.1    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   2704       1.1    chopps 			/* update the plane pointers */
   2705       1.1    chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2706       1.1    chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   2707       1.1    chopps 		}
   2708       1.1    chopps 
   2709       1.1    chopps 		/* set mods correctly. */
   2710       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   2711       1.1    chopps 		tmp[0].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   2712       1.1    chopps 		tmp[1].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   2713       1.1    chopps 
   2714       1.1    chopps 		/* set next pointers correctly */
   2715       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2716       1.1    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_SHORT]));
   2717       1.1    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_SHORT]));
   2718       1.1    chopps 
   2719       1.1    chopps 
   2720       1.1    chopps 		bcopy(phl_this_data->frames[F_LACE_STORE_LONG], phl_this_data->frames[F_LACE_STORE_SHORT], std_copper_list_size);
   2721       1.1    chopps 
   2722       1.1    chopps 		/* these are the only ones that are different from long frame. */
   2723       1.1    chopps 		cp = phl_this_data->frames[F_LACE_STORE_SHORT];
   2724       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2725       1.1    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   2726       1.1    chopps 			u_short mod = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   2727       1.1    chopps 			/* update plane pointers. high and low. */
   2728       1.1    chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   2729       1.1    chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[i][mod]));
   2730       1.1    chopps 		}
   2731       1.1    chopps 
   2732       1.1    chopps 		/* set next pointers correctly */
   2733       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2734       1.1    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_LONG]));
   2735       1.1    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phl_this_data->frames[F_LACE_STORE_LONG]));
   2736       1.1    chopps 
   2737       1.1    chopps 
   2738       1.1    chopps 		cp = phl_this_data->frames[F_LACE_LONG];
   2739       1.1    chopps 		phl_this_data->frames[F_LACE_LONG] = phl_this_data->frames[F_LACE_STORE_LONG];
   2740       1.1    chopps 		phl_this_data->frames[F_LACE_STORE_LONG] = cp;
   2741       1.1    chopps 
   2742       1.1    chopps 		cp = phl_this_data->frames[F_LACE_SHORT];
   2743       1.1    chopps 		phl_this_data->frames[F_LACE_SHORT] = phl_this_data->frames[F_LACE_STORE_SHORT];
   2744       1.1    chopps 		phl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   2745       1.1    chopps 
   2746       1.1    chopps 		vd->flags |= VF_DISPLAY;
   2747       1.1    chopps 		cc_use_colormap(v, vd->colormap);
   2748       1.1    chopps 	}
   2749       1.1    chopps 	cc_load_mode(phl_this);
   2750       1.1    chopps }
   2751       1.1    chopps #if defined (GRF_A2024)
   2752       1.1    chopps 
   2753       1.1    chopps dmode_t *
   2754  1.20.8.1  jdolecek cc_init_pal_hires_dlace(void)
   2755       1.1    chopps {
   2756       1.4    chopps 	/* this function should only be called once. */
   2757       1.1    chopps 	if (!phdl_this) {
   2758       1.1    chopps 		u_short len = std_dlace_copper_list_len;
   2759       1.1    chopps 
   2760       1.1    chopps 		phdl_this = &pal_hires_dlace_mode;
   2761       1.1    chopps 		phdl_this_data = &pal_hires_dlace_mode_data;
   2762       1.1    chopps 		bzero(phdl_this, sizeof(dmode_t));
   2763       1.1    chopps 		bzero(phdl_this_data, sizeof(dmdata_t));
   2764       1.1    chopps 
   2765       1.1    chopps 		phdl_this->name = "pal: hires double interlace";
   2766       1.1    chopps 		phdl_this->nominal_size.width = 640;
   2767       1.1    chopps 		phdl_this->nominal_size.height = 1024;
   2768       1.1    chopps 		phdl_this_data->max_size.width = 724;
   2769       1.1    chopps 		phdl_this_data->max_size.height = 1024;
   2770       1.1    chopps 		phdl_this_data->min_size.width = 320;
   2771       1.1    chopps 		phdl_this_data->min_size.height = 512;
   2772       1.1    chopps 		phdl_this_data->min_depth = 1;
   2773       1.1    chopps 		phdl_this_data->max_depth = 2;
   2774       1.1    chopps 		phdl_this->data = phdl_this_data;
   2775       1.1    chopps 
   2776       1.1    chopps 		phdl_this->get_monitor = cc_get_monitor;
   2777       1.1    chopps 		phdl_this->alloc_view = cc_alloc_view;
   2778       1.1    chopps 		phdl_this->get_current_view = cc_get_current_view;
   2779       1.1    chopps 
   2780       1.1    chopps 		phdl_this_data->use_colormap = cc_a2024_use_colormap;
   2781       1.1    chopps 		phdl_this_data->get_colormap = cc_a2024_get_colormap;
   2782       1.1    chopps 		phdl_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   2783       1.1    chopps 		phdl_this_data->display_view = display_pal_hires_dlace_view;
   2784       1.1    chopps 		phdl_this_data->monitor = cc_monitor;
   2785       1.1    chopps 
   2786       1.1    chopps 		phdl_this_data->flags |= DMF_INTERLACE;
   2787       1.1    chopps 
   2788       1.1    chopps 		phdl_this_data->frames = pal_hires_dlace_frames;
   2789       1.1    chopps 		phdl_this_data->frames[F_LACE_LONG] = alloc_chipmem(std_dlace_copper_list_size * F_LACE_TOTAL);
   2790       1.1    chopps 		if (!phdl_this_data->frames[F_LACE_LONG]) {
   2791       1.1    chopps 			panic("couldn't get chipmem for copper list");
   2792       1.1    chopps 		}
   2793       1.1    chopps 		phdl_this_data->frames[F_LACE_SHORT] = &phdl_this_data->frames[F_LACE_LONG][len];
   2794       1.1    chopps 		phdl_this_data->frames[F_LACE_STORE_LONG] = &phdl_this_data->frames[F_LACE_SHORT][len];
   2795       1.1    chopps 		phdl_this_data->frames[F_LACE_STORE_SHORT] = &phdl_this_data->frames[F_LACE_STORE_LONG][len];
   2796       1.1    chopps 
   2797       1.1    chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_STORE_LONG], std_dlace_copper_list_size);
   2798       1.1    chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_STORE_SHORT], std_dlace_copper_list_size);
   2799       1.1    chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_LONG], std_dlace_copper_list_size);
   2800       1.1    chopps 		bcopy(std_dlace_copper_list, phdl_this_data->frames[F_LACE_SHORT], std_dlace_copper_list_size);
   2801       1.1    chopps 
   2802       1.1    chopps 		phdl_this_data->bplcon0 = 0x8204 | USE_CON3;	/* hires, color
   2803       1.1    chopps 								 * composite enable,
   2804       1.1    chopps 								 * dlace. */
   2805       1.1    chopps 		phdl_this_data->std_start_x = STANDARD_VIEW_X;
   2806       1.1    chopps 		phdl_this_data->std_start_y = STANDARD_VIEW_Y;
   2807       1.1    chopps 		phdl_this_data->vbl_handler = (vbl_handler_func *) cc_lace_mode_vbl_handler;
   2808      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   2809       1.1    chopps 		phdl_this_data->beamcon0 = STANDARD_PAL_BEAMCON;
   2810       1.1    chopps #endif
   2811       1.1    chopps 
   2812       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, phdl_this, link);
   2813       1.1    chopps 	}
   2814       1.1    chopps 	return (phdl_this);
   2815       1.1    chopps }
   2816       1.1    chopps 
   2817       1.1    chopps void
   2818  1.20.8.1  jdolecek display_pal_hires_dlace_view(view_t *v)
   2819       1.1    chopps {
   2820       1.1    chopps 	if (phdl_this_data->current_view != v) {
   2821       1.1    chopps 		vdata_t *vd = VDATA(v);
   2822       1.1    chopps 		cop_t  *cp = phdl_this_data->frames[F_LACE_STORE_LONG], *tmp;
   2823      1.11     veego 		int     depth = v->bitmap->depth;
   2824      1.11     veego 		int     hstart, hstop, vstart, vstop;
   2825       1.1    chopps 		int     x, y, w = v->display.width, h = v->display.height;
   2826       1.1    chopps 		u_short ddfstart, ddfwidth, con1;
   2827       1.1    chopps 		u_short mod1l, mod2l;
   2828       1.1    chopps 
   2829       1.1    chopps 		/* round down to nearest even width */
   2830       1.1    chopps 		/* w &= 0xfffe; */
   2831       1.1    chopps 
   2832       1.1    chopps 		/* calculate datafetch width. */
   2833       1.1    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 2) << 2;
   2834       1.1    chopps 
   2835       1.4    chopps 		/* This will center the any overscanned display */
   2836       1.1    chopps 		/* and allow user to modify. */
   2837       1.1    chopps 		x = v->display.x + phdl_this_data->std_start_x - ((w - 640) >> 2);
   2838       1.1    chopps 		y = v->display.y + phdl_this_data->std_start_y - ((h - 1024) >> 3);
   2839       1.1    chopps 
   2840       1.1    chopps 		if (y & 1)
   2841       1.1    chopps 			y--;
   2842       1.1    chopps 
   2843       1.1    chopps 		if (!(x & 1))
   2844       1.1    chopps 			x--;
   2845       1.1    chopps 
   2846       1.1    chopps 		hstart = x;
   2847       1.1    chopps 		hstop = x + (w >> 1);
   2848       1.1    chopps 		vstart = y;
   2849       1.1    chopps 		vstop = y + (h >> 2);
   2850       1.1    chopps 		ddfstart = (hstart - 9) >> 1;
   2851       1.1    chopps 
   2852       1.1    chopps 		/* check for hardware limits, AGA may allow more..? */
   2853       1.1    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   2854       1.1    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   2855       1.1    chopps 			int     d = 0;
   2856       1.1    chopps 
   2857       1.1    chopps 			/* XXX anyone know the equality properties of
   2858       1.1    chopps 			 * intermixed logial AND's */
   2859       1.1    chopps 			/* XXX and arithmetic operators? */
   2860       1.1    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   2861       1.1    chopps 				d++;
   2862       1.1    chopps 			}
   2863       1.1    chopps 
   2864       1.1    chopps 			ddfstart -= d;
   2865       1.1    chopps 			hstart -= d << 1;
   2866       1.1    chopps 			hstop -= d << 1;
   2867       1.1    chopps 		}
   2868       1.1    chopps 		/* correct the datafetch to proper limits. */
   2869       1.1    chopps 		/* delay the actual display of the data until we need it. */
   2870       1.1    chopps 		ddfstart &= 0xfffc;
   2871       1.1    chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   2872       1.1    chopps 
   2873       1.1    chopps 		if (phdl_this_data->current_view) {
   2874       1.1    chopps 			VDATA(phdl_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   2875       1.1    chopps 			/* displayed. */
   2876       1.1    chopps 		}
   2877       1.1    chopps 		phdl_this_data->current_view = v;
   2878       1.1    chopps 
   2879       1.1    chopps 		cp = phdl_this_data->frames[F_LACE_STORE_LONG];
   2880      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   2881       1.4    chopps #if defined GRF_AGA
   2882       1.4    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   2883       1.4    chopps 		tmp->cp.inst.operand = 0;
   2884       1.4    chopps #endif
   2885       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   2886       1.1    chopps 		tmp->cp.inst.operand = phdl_this_data->beamcon0;
   2887       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   2888       1.1    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   2889       1.1    chopps #endif /* ECS */
   2890       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   2891       1.1    chopps 		tmp->cp.inst.operand = phdl_this_data->bplcon0 | ((depth & 0x7) << 13);	/* times two. */
   2892       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   2893       1.1    chopps 		tmp->cp.inst.operand = con1;
   2894       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   2895       1.1    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   2896       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   2897       1.1    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   2898       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   2899       1.1    chopps 		tmp->cp.inst.operand = ddfstart;
   2900       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   2901       1.1    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   2902       1.1    chopps 
   2903       1.1    chopps 		mod1l = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   2904       1.1    chopps 		mod2l = mod1l << 1;
   2905       1.1    chopps 
   2906       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2907       1.1    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));	/* update plane
   2908       1.1    chopps 											 * pointers. */
   2909       1.1    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][0]));	/* high and low. */
   2910       1.1    chopps 		tmp[2].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));	/* update plane
   2911       1.1    chopps 												 * pointers. */
   2912       1.1    chopps 		tmp[3].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod1l]));	/* high and low. */
   2913       1.1    chopps 		if (depth == 2) {
   2914       1.1    chopps 			tmp[4].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));	/* update plane
   2915       1.1    chopps 												 * pointers. */
   2916       1.1    chopps 			tmp[5].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][0]));	/* high and low. */
   2917       1.1    chopps 			tmp[6].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));	/* update plane
   2918       1.1    chopps 													 * pointers. */
   2919       1.1    chopps 			tmp[7].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod1l]));	/* high and low. */
   2920       1.1    chopps 		}
   2921       1.1    chopps 		/* set mods correctly. */
   2922       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   2923       1.1    chopps 		tmp[0].cp.inst.operand = mod2l + mod1l;
   2924       1.1    chopps 		tmp[1].cp.inst.operand = mod2l + mod1l;
   2925       1.1    chopps 
   2926       1.1    chopps 		/* set next pointers correctly */
   2927       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2928       1.1    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_SHORT]));
   2929       1.1    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_SHORT]));
   2930       1.1    chopps 
   2931       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);
   2932       1.1    chopps 
   2933       1.1    chopps 		/* these are the only ones that are different from long frame. */
   2934       1.1    chopps 		cp = phdl_this_data->frames[F_LACE_STORE_SHORT];
   2935       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   2936       1.1    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));	/* update plane
   2937       1.1    chopps 												 * pointers. */
   2938       1.1    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l]));	/* high and low. */
   2939       1.1    chopps 		tmp[2].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));	/* update plane
   2940       1.1    chopps 													 * pointers. */
   2941       1.1    chopps 		tmp[3].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[0][mod2l + mod1l]));	/* high and low. */
   2942       1.1    chopps 		if (depth == 2) {
   2943       1.1    chopps 			tmp[4].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));	/* update plane
   2944       1.1    chopps 													 * pointers. */
   2945       1.1    chopps 			tmp[5].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l]));	/* high and low. */
   2946       1.1    chopps 			tmp[6].cp.inst.operand = HIADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));	/* update plane
   2947       1.1    chopps 														 * pointers. */
   2948       1.1    chopps 			tmp[7].cp.inst.operand = LOADDR(PREP_DMA_MEM(&v->bitmap->plane[1][mod2l + mod1l]));	/* high and low. */
   2949       1.1    chopps 		}
   2950       1.1    chopps 		/* set next pointers correctly */
   2951       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   2952       1.1    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_LONG]));
   2953       1.1    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(phdl_this_data->frames[F_LACE_STORE_LONG]));
   2954       1.1    chopps 
   2955       1.1    chopps 		cp = phdl_this_data->frames[F_LACE_LONG];
   2956       1.1    chopps 		phdl_this_data->frames[F_LACE_LONG] = phdl_this_data->frames[F_LACE_STORE_LONG];
   2957       1.1    chopps 		phdl_this_data->frames[F_LACE_STORE_LONG] = cp;
   2958       1.1    chopps 
   2959       1.1    chopps 		cp = phdl_this_data->frames[F_LACE_SHORT];
   2960       1.1    chopps 		phdl_this_data->frames[F_LACE_SHORT] = phdl_this_data->frames[F_LACE_STORE_SHORT];
   2961       1.1    chopps 		phdl_this_data->frames[F_LACE_STORE_SHORT] = cp;
   2962       1.1    chopps 
   2963       1.1    chopps 		vd->flags |= VF_DISPLAY;
   2964       1.1    chopps 
   2965       1.1    chopps 		cc_a2024_use_colormap(v, vd->colormap);
   2966       1.1    chopps 	}
   2967       1.1    chopps 	cc_load_mode(phdl_this);
   2968       1.1    chopps }
   2969       1.1    chopps 
   2970       1.1    chopps dmode_t *
   2971  1.20.8.1  jdolecek cc_init_pal_a2024(void)
   2972       1.1    chopps {
   2973       1.4    chopps 	/* this function should only be called once. */
   2974       1.1    chopps 	if (!p24_this) {
   2975       1.1    chopps 		int     i;
   2976       1.1    chopps 		u_short len = std_pal_a2024_copper_list_len;
   2977       1.1    chopps 		cop_t  *cp;
   2978       1.1    chopps 
   2979       1.1    chopps 		p24_this = &pal_a2024_mode;
   2980       1.1    chopps 		p24_this_data = &pal_a2024_mode_data;
   2981       1.1    chopps 		bzero(p24_this, sizeof(dmode_t));
   2982       1.1    chopps 		bzero(p24_this_data, sizeof(dmdata_t));
   2983       1.1    chopps 
   2984       1.1    chopps 		p24_this->name = "pal: A2024 15khz";
   2985       1.1    chopps 		p24_this->nominal_size.width = 1024;
   2986       1.1    chopps 		p24_this->nominal_size.height = 1024;
   2987       1.1    chopps 		p24_this_data->max_size.width = 1024;
   2988       1.1    chopps 		p24_this_data->max_size.height = 1024;
   2989       1.1    chopps 		p24_this_data->min_size.width = 1024;
   2990       1.1    chopps 		p24_this_data->min_size.height = 1024;
   2991       1.1    chopps 		p24_this_data->min_depth = 1;
   2992       1.1    chopps 		p24_this_data->max_depth = 2;
   2993       1.1    chopps 		p24_this->data = p24_this_data;
   2994       1.1    chopps 
   2995       1.1    chopps 		p24_this->get_monitor = cc_get_monitor;
   2996       1.1    chopps 		p24_this->alloc_view = cc_alloc_view;
   2997       1.1    chopps 		p24_this->get_current_view = cc_get_current_view;
   2998       1.1    chopps 
   2999       1.1    chopps 		p24_this_data->use_colormap = cc_a2024_use_colormap;
   3000       1.1    chopps 		p24_this_data->get_colormap = cc_a2024_get_colormap;
   3001       1.1    chopps 		p24_this_data->display_view = display_pal_a2024_view;
   3002       1.1    chopps 		p24_this_data->alloc_colormap = cc_a2024_alloc_colormap;
   3003       1.1    chopps 		p24_this_data->monitor = cc_monitor;
   3004       1.1    chopps 
   3005       1.1    chopps 		p24_this_data->flags |= DMF_HEDLEY_EXP;
   3006       1.1    chopps 
   3007       1.1    chopps 		p24_this_data->frames = pal_a2024_frames;
   3008       1.1    chopps 		p24_this_data->frames[F_QD_QUAD0] = alloc_chipmem(std_pal_a2024_copper_list_size * F_QD_TOTAL);
   3009       1.1    chopps 		if (!p24_this_data->frames[F_QD_QUAD0]) {
   3010       1.1    chopps 			panic("couldn't get chipmem for copper list");
   3011       1.1    chopps 		}
   3012       1.1    chopps 		/* setup the hedley init bitplane. */
   3013       1.1    chopps 		hedley_init = alloc_chipmem(128);
   3014       1.1    chopps 		if (!hedley_init) {
   3015       1.1    chopps 			panic("couldn't get chipmem for hedley init bitplane");
   3016       1.1    chopps 		}
   3017       1.1    chopps 		for (i = 1; i < 128; i++)
   3018       1.1    chopps 			hedley_init[i] = 0xff;
   3019       1.1    chopps 		hedley_init[0] = 0x03;
   3020       1.1    chopps 
   3021       1.1    chopps 		/* copy image of standard copper list. */
   3022       1.1    chopps 		bcopy(std_pal_a2024_copper_list, p24_this_data->frames[0], std_pal_a2024_copper_list_size);
   3023       1.1    chopps 
   3024       1.1    chopps 		/* set the init plane pointer. */
   3025       1.1    chopps 		cp = find_copper_inst(p24_this_data->frames[F_QD_QUAD0], CI_MOVE(R_BPL0PTH));
   3026       1.1    chopps 		cp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(hedley_init));
   3027       1.1    chopps 		cp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(hedley_init));
   3028       1.1    chopps 
   3029       1.1    chopps 		for (i = 1; i < F_QD_TOTAL; i++) {
   3030       1.1    chopps 			p24_this_data->frames[i] = &p24_this_data->frames[i - 1][len];
   3031       1.1    chopps 			bcopy(p24_this_data->frames[0], p24_this_data->frames[i], std_pal_a2024_copper_list_size);
   3032       1.1    chopps 		}
   3033       1.1    chopps 
   3034       1.1    chopps 		p24_this_data->bplcon0 = 0x8200;	/* hires */
   3035       1.1    chopps 		p24_this_data->vbl_handler = (vbl_handler_func *) pal_a2024_mode_vbl_handler;
   3036       1.1    chopps 
   3037       1.1    chopps 
   3038       1.3    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes, p24_this, link);
   3039       1.1    chopps 	}
   3040       1.1    chopps 	return (p24_this);
   3041       1.1    chopps }
   3042       1.1    chopps 
   3043       1.1    chopps void
   3044  1.20.8.1  jdolecek display_pal_a2024_view(view_t *v)
   3045       1.1    chopps {
   3046       1.1    chopps 	if (p24_this_data->current_view != v) {
   3047       1.1    chopps 		vdata_t *vd = VDATA(v);
   3048       1.1    chopps 		cop_t  *cp, *tmp;
   3049       1.1    chopps 		u_char *inst_plane[2];
   3050       1.1    chopps 		u_char **plane = inst_plane;
   3051       1.1    chopps 		u_long  full_line = v->bitmap->bytes_per_row + v->bitmap->row_mod;
   3052       1.1    chopps 		u_long  half_plane = full_line * v->bitmap->rows / 2;
   3053       1.1    chopps 
   3054       1.1    chopps 		int     depth = v->bitmap->depth, i, j;
   3055       1.1    chopps 
   3056       1.1    chopps 		plane[0] = v->bitmap->plane[0];
   3057       1.1    chopps 		if (depth == 2) {
   3058       1.1    chopps 			plane[1] = v->bitmap->plane[1];
   3059       1.1    chopps 		}
   3060       1.1    chopps 		if (p24_this_data->current_view) {
   3061       1.1    chopps 			VDATA(p24_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer
   3062       1.1    chopps 											 * displayed. */
   3063       1.1    chopps 		}
   3064       1.1    chopps 		cp = p24_this_data->frames[F_QD_STORE_QUAD0];
   3065       1.1    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COLOR1F));
   3066       1.1    chopps 		tmp = find_copper_inst(tmp, CI_MOVE(R_BPLCON0));	/* grab third one. */
   3067       1.1    chopps 		tmp->cp.inst.operand = p24_this_data->bplcon0 | ((depth & 0x7) << 13);	/* times 2 */
   3068       1.1    chopps 
   3069       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);
   3070       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);
   3071       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);
   3072       1.1    chopps 
   3073       1.1    chopps 		/*
   3074       1.1    chopps 		 * Mark Id's
   3075       1.1    chopps 		 */
   3076       1.1    chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD1], CI_WAIT(126, 29));
   3077       1.1    chopps 		CBUMP(tmp);
   3078       1.1    chopps 		CMOVE(tmp, R_COLOR01, QUAD1_ID);
   3079       1.1    chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD2], CI_WAIT(126, 29));
   3080       1.1    chopps 		CBUMP(tmp);
   3081       1.1    chopps 		CMOVE(tmp, R_COLOR01, QUAD2_ID);
   3082       1.1    chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD3], CI_WAIT(126, 29));
   3083       1.1    chopps 		CBUMP(tmp);
   3084       1.1    chopps 		CMOVE(tmp, R_COLOR01, QUAD3_ID);
   3085       1.1    chopps 
   3086       1.1    chopps 		plane[0]--;
   3087       1.1    chopps 		plane[0]--;
   3088       1.1    chopps 		if (depth == 2) {
   3089       1.1    chopps 			plane[1]--;
   3090       1.1    chopps 			plane[1]--;
   3091       1.1    chopps 		}
   3092       1.1    chopps 		/*
   3093       1.1    chopps 		 * Set bitplane pointers.
   3094       1.1    chopps 		 */
   3095       1.1    chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD0], CI_MOVE(R_BPLMOD2));
   3096       1.1    chopps 		CBUMP(tmp);
   3097       1.1    chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][0])));
   3098       1.1    chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][0])));
   3099       1.1    chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][full_line])));
   3100       1.1    chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][full_line])));
   3101       1.1    chopps 		if (depth == 2) {
   3102       1.1    chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][0])));
   3103       1.1    chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][0])));
   3104       1.1    chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][full_line])));
   3105       1.1    chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][full_line])));
   3106       1.1    chopps 		}
   3107      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   3108       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   3109       1.1    chopps #endif
   3110       1.1    chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD1])));
   3111       1.1    chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD1])));
   3112       1.1    chopps 		CEND(tmp);
   3113       1.1    chopps 		CEND(tmp);
   3114       1.1    chopps 
   3115       1.1    chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD1], CI_MOVE(R_BPLMOD2));
   3116       1.1    chopps 		CBUMP(tmp);
   3117       1.1    chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   3118       1.1    chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][HALF_2024_LINE])));
   3119       1.1    chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   3120       1.1    chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][full_line + HALF_2024_LINE])));
   3121       1.1    chopps 		if (depth == 2) {
   3122       1.1    chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   3123       1.1    chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][HALF_2024_LINE])));
   3124       1.1    chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   3125       1.1    chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][full_line + HALF_2024_LINE])));
   3126       1.1    chopps 		}
   3127      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   3128       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   3129       1.1    chopps #endif
   3130       1.1    chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD2])));
   3131       1.1    chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD2])));
   3132       1.1    chopps 		CEND(tmp);
   3133       1.1    chopps 		CEND(tmp);
   3134       1.1    chopps 
   3135       1.1    chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD2], CI_MOVE(R_BPLMOD2));
   3136       1.1    chopps 		CBUMP(tmp);
   3137       1.1    chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   3138       1.1    chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane])));
   3139       1.1    chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   3140       1.1    chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line])));
   3141       1.1    chopps 		if (depth == 2) {
   3142       1.1    chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   3143       1.1    chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane])));
   3144       1.1    chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   3145       1.1    chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line])));
   3146       1.1    chopps 		}
   3147      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   3148       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   3149       1.1    chopps #endif
   3150       1.1    chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD3])));
   3151       1.1    chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD3])));
   3152       1.1    chopps 		CEND(tmp);
   3153       1.1    chopps 		CEND(tmp);
   3154       1.1    chopps 
   3155       1.1    chopps 		tmp = find_copper_inst(p24_this_data->frames[F_QD_STORE_QUAD3], CI_MOVE(R_BPLMOD2));
   3156       1.1    chopps 		CBUMP(tmp);
   3157       1.1    chopps 		CMOVE(tmp, R_BPL0PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + HALF_2024_LINE])));
   3158       1.1    chopps 		CMOVE(tmp, R_BPL0PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + HALF_2024_LINE])));
   3159       1.1    chopps 		CMOVE(tmp, R_BPL1PTH, HIADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line + HALF_2024_LINE])));
   3160       1.1    chopps 		CMOVE(tmp, R_BPL1PTL, LOADDR(PREP_DMA_MEM(&plane[0][half_plane + full_line + HALF_2024_LINE])));
   3161       1.1    chopps 		if (depth == 2) {
   3162       1.1    chopps 			CMOVE(tmp, R_BPL2PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + HALF_2024_LINE])));
   3163       1.1    chopps 			CMOVE(tmp, R_BPL2PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + HALF_2024_LINE])));
   3164       1.1    chopps 			CMOVE(tmp, R_BPL3PTH, HIADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line + HALF_2024_LINE])));
   3165       1.1    chopps 			CMOVE(tmp, R_BPL3PTL, LOADDR(PREP_DMA_MEM(&plane[1][half_plane + full_line + HALF_2024_LINE])));
   3166       1.1    chopps 		}
   3167      1.10    chopps #if defined (GRF_ECS) || defined (GRF_AGA)
   3168       1.1    chopps 		CMOVE(tmp, R_DIWHIGH, 0x2100);
   3169       1.1    chopps #endif
   3170       1.1    chopps 		CMOVE(tmp, R_COP1LCH, HIADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD0])));
   3171       1.1    chopps 		CMOVE(tmp, R_COP1LCL, LOADDR(PREP_DMA_MEM(p24_this_data->frames[F_QD_STORE_QUAD0])));
   3172       1.1    chopps 		CEND(tmp);
   3173       1.1    chopps 		CEND(tmp);
   3174       1.1    chopps 
   3175       1.1    chopps 		/* swap new pointers in. */
   3176       1.1    chopps 		for (i = F_QD_STORE_QUAD0, j = F_QD_QUAD0;
   3177       1.1    chopps 		    i <= F_QD_STORE_QUAD3; i++, j++) {
   3178       1.1    chopps 			cp = p24_this_data->frames[j];
   3179       1.1    chopps 			p24_this_data->frames[j] = p24_this_data->frames[i];
   3180       1.1    chopps 			p24_this_data->frames[i] = cp;
   3181       1.1    chopps 		}
   3182       1.1    chopps 
   3183       1.1    chopps 		p24_this_data->current_view = v;
   3184       1.1    chopps 		vd->flags |= VF_DISPLAY;
   3185       1.1    chopps 
   3186       1.1    chopps 		cc_a2024_use_colormap(v, vd->colormap);
   3187       1.1    chopps 	}
   3188       1.1    chopps 	cc_load_mode(p24_this);
   3189       1.1    chopps }
   3190       1.1    chopps 
   3191       1.1    chopps void
   3192  1.20.8.1  jdolecek pal_a2024_mode_vbl_handler(dmode_t *d)
   3193       1.1    chopps {
   3194       1.1    chopps 	u_short vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8);
   3195       1.1    chopps 
   3196       1.1    chopps 	if (vp < 20) {
   3197       1.1    chopps 		custom.cop1lc = PREP_DMA_MEM(p24_this_data->frames[p24_this_data->hedley_current]);
   3198       1.1    chopps 		custom.copjmp1 = 0;
   3199       1.1    chopps 	}
   3200       1.1    chopps 	p24_this_data->hedley_current++;
   3201       1.1    chopps 	p24_this_data->hedley_current &= 0x3;	/* if 4 then 0. */
   3202       1.1    chopps }
   3203       1.7    chopps #endif /* GRF_A2024 */
   3204       1.7    chopps 
   3205       1.7    chopps #if defined (GRF_AGA)
   3206       1.7    chopps 
   3207       1.7    chopps dmode_t *
   3208  1.20.8.1  jdolecek cc_init_pal_aga(void)
   3209       1.7    chopps {
   3210       1.7    chopps 	/* this function should only be called once. */
   3211       1.7    chopps 	if (!paga_this && (custom.deniseid & 0xff) == 0xf8 &&
   3212       1.7    chopps 	    aga_enable & AGA_ENABLE) {
   3213       1.7    chopps 		u_short len = aga_copper_list_len;
   3214       1.7    chopps 
   3215       1.7    chopps 		paga_this = &paga_mode;
   3216       1.7    chopps 		paga_this_data = &paga_mode_data;
   3217       1.7    chopps 		bzero(paga_this, sizeof(dmode_t));
   3218       1.7    chopps 		bzero(paga_this_data, sizeof(dmdata_t));
   3219       1.7    chopps 
   3220       1.7    chopps 		paga_this->name = "pal: AGA dbl";
   3221       1.7    chopps 		paga_this->nominal_size.width = 640;
   3222       1.7    chopps 		paga_this->nominal_size.height = 512;
   3223       1.7    chopps 		paga_this_data->max_size.width = 720;
   3224       1.7    chopps 		paga_this_data->max_size.height = 564;
   3225       1.7    chopps 		paga_this_data->min_size.width = 320;
   3226       1.7    chopps 		paga_this_data->min_size.height = 200;
   3227       1.7    chopps 		paga_this_data->min_depth = 1;
   3228       1.7    chopps 		paga_this_data->max_depth = 8;
   3229       1.7    chopps 		paga_this->data = paga_this_data;
   3230       1.7    chopps 
   3231       1.7    chopps 		paga_this->get_monitor = cc_get_monitor;
   3232       1.7    chopps 		paga_this->alloc_view = cc_alloc_view;
   3233       1.7    chopps 		paga_this->get_current_view = cc_get_current_view;
   3234       1.7    chopps 
   3235       1.7    chopps 		paga_this_data->use_colormap = cc_use_aga_colormap;
   3236       1.7    chopps 		paga_this_data->get_colormap = cc_get_colormap;
   3237       1.7    chopps 		paga_this_data->alloc_colormap = cc_alloc_aga_colormap;
   3238       1.7    chopps 		paga_this_data->display_view = display_pal_aga_view;
   3239       1.7    chopps 		paga_this_data->monitor = cc_monitor;
   3240       1.7    chopps 
   3241       1.7    chopps 		paga_this_data->frames = paga_frames;
   3242       1.7    chopps 		paga_this_data->frames[F_LONG] = alloc_chipmem(aga_copper_list_size * F_TOTAL);
   3243       1.7    chopps 		if (!paga_this_data->frames[F_LONG]) {
   3244       1.7    chopps 			panic("couldn't get chipmem for copper list");
   3245       1.7    chopps 		}
   3246       1.7    chopps 		paga_this_data->frames[F_STORE_LONG] = &paga_this_data->frames[F_LONG][len];
   3247       1.7    chopps 
   3248       1.7    chopps 		bcopy(aga_copper_list, paga_this_data->frames[F_STORE_LONG], aga_copper_list_size);
   3249       1.7    chopps 		bcopy(aga_copper_list, paga_this_data->frames[F_LONG], aga_copper_list_size);
   3250       1.7    chopps 
   3251       1.7    chopps 		paga_this_data->bplcon0 = 0x0240 | USE_CON3;	/* color composite
   3252       1.7    chopps 								 * enable,
   3253       1.7    chopps 								 * shres. */
   3254       1.7    chopps 		paga_this_data->std_start_x = 0x4f /*STANDARD_VIEW_X*/;
   3255       1.7    chopps 		paga_this_data->std_start_y = 0x2b /*STANDARD_VIEW_Y*/;
   3256       1.7    chopps 		paga_this_data->vbl_handler = (vbl_handler_func *) cc_mode_vbl_handler;
   3257       1.7    chopps 		paga_this_data->beamcon0 = STANDARD_PAL_BEAMCON | (SPECIAL_BEAMCON ^ VSYNCTRUE);
   3258       1.7    chopps 
   3259       1.7    chopps 		LIST_INSERT_HEAD(&MDATA(cc_monitor)->modes,
   3260       1.7    chopps 		    paga_this, link);
   3261       1.7    chopps 	}
   3262       1.7    chopps 	return (paga_this);
   3263       1.7    chopps }
   3264       1.7    chopps 
   3265      1.18        is /* static, so I can patch and play */
   3266       1.7    chopps 
   3267      1.18        is #ifdef GRF_AGA_VGA
   3268      1.18        is int	pAGA_htotal  = 0x079;
   3269      1.18        is int	pAGA_vtotal  = 0x24d;
   3270      1.18        is int	pAGA_vbstop  = 0x019;
   3271      1.18        is int	pAGA_hcenter = 0x04b;
   3272      1.18        is #else
   3273      1.18        is int	pAGA_htotal  = 0x081;
   3274      1.18        is int	pAGA_vtotal  = 0x23d;
   3275      1.18        is int	pAGA_vbstop  = 0x017;
   3276      1.18        is int	pAGA_hcenter = 0x04f;
   3277      1.18        is #endif
   3278      1.18        is int	pAGA_hsstrt  = 0x00f;
   3279      1.18        is int	pAGA_hsstop  = 0x019;
   3280      1.18        is int	pAGA_hbstrt  = 0x001;
   3281      1.18        is int	pAGA_hbstop  = 0x021;
   3282      1.18        is int	pAGA_vsstrt  = 0x001;
   3283      1.18        is int	pAGA_vsstop  = 0x008;
   3284      1.18        is int	pAGA_vbstrt  = 0x000;
   3285       1.7    chopps 
   3286       1.7    chopps void
   3287  1.20.8.1  jdolecek display_pal_aga_view(view_t *v)
   3288       1.7    chopps {
   3289       1.7    chopps 	if (paga_this_data->current_view != v) {
   3290       1.7    chopps 		vdata_t *vd = VDATA(v);
   3291       1.7    chopps 		cop_t  *cp = paga_this_data->frames[F_STORE_LONG], *tmp;
   3292       1.7    chopps 		int     depth = v->bitmap->depth, i;
   3293       1.7    chopps 		int     hstart, hstop, vstart, vstop, j;
   3294       1.7    chopps 		int     x, y, w = v->display.width, h = v->display.height;
   3295       1.7    chopps 		u_short ddfstart, ddfwidth, con1;
   3296       1.7    chopps 
   3297       1.7    chopps #ifdef DEBUG
   3298       1.7    chopps 		if (aga_enable & AGA_TRACE)
   3299      1.15  christos 			printf("display_aga_view(%dx%dx%d) %p\n", w, h,
   3300       1.7    chopps 			    depth, v);
   3301       1.7    chopps #endif
   3302       1.7    chopps 		/* round down to nearest even width */
   3303       1.7    chopps 		/* w &= 0xfffe; */
   3304       1.7    chopps 		/* calculate datafetch width. */
   3305       1.7    chopps 
   3306       1.7    chopps 		ddfwidth = ((v->bitmap->bytes_per_row >> 1) - 4) << 1;
   3307       1.7    chopps 
   3308       1.7    chopps 		/* this will center the any overscanned display */
   3309       1.7    chopps 		/* and allow user to modify. */
   3310       1.7    chopps 		x = v->display.x + paga_this_data->std_start_x - ((w - 640) >> 3);
   3311       1.7    chopps 		y = v->display.y + paga_this_data->std_start_y - ((h - 512) >> 1);
   3312       1.7    chopps 
   3313       1.7    chopps 		if (y & 1)
   3314       1.7    chopps 			y--;
   3315       1.7    chopps 
   3316       1.7    chopps 		if (!(x & 1))
   3317       1.7    chopps 			x--;
   3318       1.7    chopps 
   3319       1.7    chopps 		hstart = x;
   3320       1.7    chopps 		hstop = x + (w >> 2);
   3321       1.7    chopps 		vstart = y;
   3322       1.7    chopps 		vstop = y + (h >> 0);
   3323       1.7    chopps 		ddfstart = (hstart >> 1) - 8;
   3324       1.7    chopps 
   3325       1.7    chopps #ifdef DEBUG
   3326       1.7    chopps 		if (aga_enable & AGA_TRACE2) {
   3327      1.15  christos 			printf ("  ddfwidth %04x x %04x y %04x", ddfwidth,
   3328       1.7    chopps 			    x, y);
   3329      1.15  christos 			printf (" hstart %04x hstop %04x vstart %04x vstop %04x ddfstart %04x\n",
   3330       1.7    chopps 			    hstart, hstop, vstart, vstop, ddfstart);
   3331       1.7    chopps 		}
   3332       1.7    chopps #endif
   3333       1.7    chopps 		/* check for hardware limits, AGA may allow more..? */
   3334       1.7    chopps 		/* anyone got a 4000 I can borrow :^) -ch */
   3335       1.7    chopps 		if ((ddfstart & 0xfffc) + ddfwidth > 0xd8) {
   3336       1.7    chopps 			int     d = 0;
   3337       1.7    chopps 
   3338       1.7    chopps 			/* XXX anyone know the equality properties of
   3339       1.7    chopps 			 * intermixed logial AND's */
   3340       1.7    chopps 			/* XXX and arithmetic operators? */
   3341       1.7    chopps 			while (((ddfstart & 0xfffc) + ddfwidth - d) > 0xd8) {
   3342       1.7    chopps 				d++;
   3343       1.7    chopps 			}
   3344       1.7    chopps 
   3345       1.7    chopps 			ddfstart -= d;
   3346       1.7    chopps 			hstart -= d << 1;
   3347       1.7    chopps 			hstop -= d << 1;
   3348       1.7    chopps 		}
   3349       1.7    chopps 		/* correct the datafetch to proper limits. */
   3350       1.7    chopps 		/* delay the actual display of the data until we need it. */
   3351       1.7    chopps 		ddfstart &= 0xfffc;
   3352       1.7    chopps #ifdef DEBUG
   3353       1.7    chopps 		if (aga_enable & AGA_TRACE2) {
   3354      1.15  christos 			printf ("  ddfwidth %04x x %04x y %04x", ddfwidth,
   3355       1.7    chopps 			    x, y);
   3356      1.15  christos 			printf (" hstart %04x hstop %04x vstart %04x vstop %04x ddfstart %04x\n",
   3357       1.7    chopps 			    hstart, hstop, vstart, vstop, ddfstart);
   3358       1.7    chopps 		}
   3359       1.7    chopps #endif
   3360       1.7    chopps 		con1 = ((hstart - 9) - (ddfstart << 1)) | (((hstart - 9) - (ddfstart << 1)) << 4);
   3361       1.7    chopps 
   3362       1.7    chopps 		if (paga_this_data->current_view) {
   3363       1.7    chopps 			VDATA(paga_this_data->current_view)->flags &= ~VF_DISPLAY;	/* mark as no longer */
   3364       1.7    chopps 			/* displayed. */
   3365       1.7    chopps 		}
   3366       1.7    chopps 		paga_this_data->current_view = v;
   3367       1.7    chopps 
   3368       1.7    chopps 		cp = paga_this_data->frames[F_STORE_LONG];
   3369       1.7    chopps 		tmp = cp;
   3370       1.7    chopps 		for (i = 0; i < 8; ++i) {
   3371       1.7    chopps 			if (tmp == NULL)
   3372       1.7    chopps 				break;
   3373       1.7    chopps 			tmp = find_copper_inst(tmp + 1, CI_MOVE(R_BPLCON3));
   3374       1.7    chopps 			if (tmp == NULL)
   3375       1.7    chopps 				break;
   3376       1.7    chopps 			tmp->cp.inst.operand = 0x0ca1 | (i << 13);
   3377       1.7    chopps 			tmp = find_copper_inst(tmp + 1, CI_MOVE(R_BPLCON3));
   3378       1.7    chopps 			if (tmp == NULL)
   3379       1.7    chopps 				break;
   3380       1.7    chopps 			tmp->cp.inst.operand = 0x0ea1 | (i << 13);
   3381       1.7    chopps 		}
   3382       1.7    chopps 		if (tmp)
   3383       1.7    chopps 			tmp = find_copper_inst(tmp + 1, CI_MOVE(R_BPLCON3));
   3384       1.7    chopps 		if (tmp)
   3385       1.7    chopps 			tmp->cp.inst.operand = 0x0ca1;
   3386       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_FMODE));
   3387       1.7    chopps 		tmp->cp.inst.operand = 0x8003;
   3388       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HTOTAL));
   3389       1.7    chopps 		tmp->cp.inst.operand = pAGA_htotal; /* 81/71/73/79? */
   3390       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HBSTRT));
   3391       1.7    chopps 		tmp->cp.inst.operand = pAGA_hbstrt; /* 0x0008 */
   3392       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HSSTRT));
   3393       1.7    chopps 		tmp->cp.inst.operand = pAGA_hsstrt; /* 0x000e */
   3394       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HSSTOP));
   3395       1.7    chopps 		tmp->cp.inst.operand = pAGA_hsstop; /* 0x001c */
   3396       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HBSTOP));
   3397       1.7    chopps 		tmp->cp.inst.operand = pAGA_hsstop; /* 0x001e */
   3398       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_HCENTER));
   3399       1.7    chopps 		tmp->cp.inst.operand = pAGA_hcenter; /*AGA_htotal / 2 + AGA_hsstrt */
   3400       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VBSTRT));
   3401       1.7    chopps 		tmp->cp.inst.operand = pAGA_vbstrt; /* 0x0000 */
   3402       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VSSTRT));
   3403       1.7    chopps 		tmp->cp.inst.operand = pAGA_vsstrt; /* 0x016b / AGA_htotal */
   3404       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VSSTOP));
   3405       1.7    chopps 		tmp->cp.inst.operand = pAGA_vsstop; /* 0x02d6 / AGA_htotal */
   3406       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VBSTOP));
   3407       1.7    chopps 		tmp->cp.inst.operand = pAGA_vbstop; /* 0x0bd1 / AGA_htotal */
   3408       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_VTOTAL));
   3409       1.7    chopps 		tmp->cp.inst.operand = pAGA_vtotal;
   3410       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BEAMCON0));
   3411       1.7    chopps 		tmp->cp.inst.operand = paga_this_data->beamcon0;
   3412       1.7    chopps #ifdef DEBUG
   3413       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3414      1.15  christos 			printf("  beamcon0 %04x", tmp->cp.inst.operand);
   3415       1.7    chopps #endif
   3416       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWHIGH));
   3417       1.7    chopps 		tmp->cp.inst.operand = CALC_DIWHIGH(hstart, vstart, hstop, vstop);
   3418       1.7    chopps #ifdef DEBUG
   3419       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3420      1.15  christos 			printf(" diwhigh %04x>", tmp->cp.inst.operand);
   3421       1.7    chopps #endif
   3422       1.7    chopps #if 0
   3423       1.7    chopps 		tmp->cp.inst.operand = (vstop & 0x0700) | ((hstop & 0x0100) << 5);
   3424       1.7    chopps #endif
   3425       1.7    chopps #ifdef DEBUG
   3426       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3427      1.15  christos 			printf("%04x", tmp->cp.inst.operand);
   3428       1.7    chopps #endif
   3429       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON0));
   3430       1.7    chopps 		tmp->cp.inst.operand = paga_this_data->bplcon0 |
   3431       1.7    chopps 		    ((depth & 0x7) << 12) | ((depth & 0x8) << 1);
   3432       1.7    chopps #ifdef DEBUG
   3433       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3434      1.15  christos 			printf(" bplcon0 %04x", tmp->cp.inst.operand);
   3435       1.7    chopps #endif
   3436       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPLCON1));
   3437       1.7    chopps 		tmp->cp.inst.operand = con1;
   3438       1.7    chopps #ifdef DEBUG
   3439       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3440      1.15  christos 			printf(" bplcon1 %04x>0000\n", con1);
   3441       1.7    chopps #endif
   3442       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTART));
   3443       1.7    chopps 		tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff);
   3444       1.7    chopps #ifdef DEBUG
   3445       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3446      1.15  christos 			printf("  diwstart %04x", tmp->cp.inst.operand);
   3447       1.7    chopps #endif
   3448       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DIWSTOP));
   3449       1.7    chopps 		tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff);
   3450       1.7    chopps #ifdef DEBUG
   3451       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3452      1.15  christos 			printf(" diwstop %04x", tmp->cp.inst.operand);
   3453       1.7    chopps #endif
   3454       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTART));
   3455       1.7    chopps 		tmp->cp.inst.operand = ddfstart;
   3456       1.7    chopps #ifdef DEBUG
   3457       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3458      1.15  christos 			printf(" ddfstart %04x", tmp->cp.inst.operand);
   3459       1.7    chopps #endif
   3460       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_DDFSTOP));
   3461       1.7    chopps 		tmp->cp.inst.operand = ddfstart + ddfwidth;
   3462       1.7    chopps #ifdef DEBUG
   3463       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3464      1.15  christos 			printf(" ddfstop %04x", tmp->cp.inst.operand);
   3465       1.7    chopps #endif
   3466       1.7    chopps 
   3467       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL0PTH));
   3468       1.7    chopps 		for (i = 0, j = 0; i < depth; j += 2, i++) {
   3469       1.7    chopps 			/* update the plane pointers */
   3470       1.7    chopps 			tmp[j].cp.inst.operand = HIADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   3471       1.7    chopps 			tmp[j + 1].cp.inst.operand = LOADDR(PREP_DMA_MEM(v->bitmap->plane[i]));
   3472       1.7    chopps #ifdef DEBUG
   3473       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3474      1.15  christos 			printf (" bpl%dpth %p", i, v->bitmap->plane[i]);
   3475       1.7    chopps #endif
   3476       1.7    chopps 		}
   3477       1.7    chopps 
   3478       1.7    chopps 		/* set mods correctly. */
   3479       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_BPL1MOD));
   3480       1.7    chopps 		tmp[0].cp.inst.operand = v->bitmap->row_mod;
   3481       1.7    chopps 		tmp[1].cp.inst.operand = v->bitmap->row_mod;
   3482       1.7    chopps #ifdef DEBUG
   3483       1.7    chopps 		if (aga_enable & AGA_TRACE2)
   3484      1.15  christos 			printf(" bplxmod %04x\n", v->bitmap->row_mod);
   3485       1.7    chopps #endif
   3486       1.7    chopps 
   3487       1.7    chopps 		/* set next pointers correctly */
   3488       1.7    chopps 		tmp = find_copper_inst(cp, CI_MOVE(R_COP1LCH));
   3489       1.7    chopps 		tmp[0].cp.inst.operand = HIADDR(PREP_DMA_MEM(paga_this_data->frames[F_STORE_LONG]));
   3490       1.7    chopps 		tmp[1].cp.inst.operand = LOADDR(PREP_DMA_MEM(paga_this_data->frames[F_STORE_LONG]));
   3491       1.7    chopps 
   3492       1.7    chopps 		cp = paga_this_data->frames[F_LONG];
   3493       1.7    chopps 		paga_this_data->frames[F_LONG] = paga_this_data->frames[F_STORE_LONG];
   3494       1.7    chopps 		paga_this_data->frames[F_STORE_LONG] = cp;
   3495       1.7    chopps 
   3496       1.7    chopps 		vd->flags |= VF_DISPLAY;
   3497       1.7    chopps 
   3498       1.7    chopps 		cc_use_aga_colormap(v, vd->colormap);
   3499       1.7    chopps 	}
   3500       1.7    chopps 	cc_load_mode(paga_this);
   3501       1.7    chopps #ifdef DEBUG
   3502       1.7    chopps 	if (aga_enable & AGA_TRACE)
   3503       1.7    chopps 		aga_enable |= AGA_TRACE2;	/* XXXX */
   3504       1.7    chopps #endif
   3505       1.7    chopps }
   3506       1.7    chopps 
   3507       1.7    chopps #endif /* GRF_AGA */
   3508       1.1    chopps #endif /* GRF_PAL */
   3509