1*f6330dd7Stsutsui /* $NetBSD: ite_gb.c,v 1.10 2011/02/10 12:46:22 tsutsui Exp $ */
2a0864b3eSthorpej
3a0864b3eSthorpej /*
49b6bd2d9Srmind * Copyright (c) 1988 University of Utah.
5a0864b3eSthorpej * Copyright (c) 1990, 1993
6a0864b3eSthorpej * The Regents of the University of California. All rights reserved.
7a0864b3eSthorpej *
8a0864b3eSthorpej * This code is derived from software contributed to Berkeley by
9a0864b3eSthorpej * the Systems Programming Group of the University of Utah Computer
10a0864b3eSthorpej * Science Department.
11a0864b3eSthorpej *
12a0864b3eSthorpej * Redistribution and use in source and binary forms, with or without
13a0864b3eSthorpej * modification, are permitted provided that the following conditions
14a0864b3eSthorpej * are met:
15a0864b3eSthorpej * 1. Redistributions of source code must retain the above copyright
16a0864b3eSthorpej * notice, this list of conditions and the following disclaimer.
17a0864b3eSthorpej * 2. Redistributions in binary form must reproduce the above copyright
18a0864b3eSthorpej * notice, this list of conditions and the following disclaimer in the
19a0864b3eSthorpej * documentation and/or other materials provided with the distribution.
20aad01611Sagc * 3. Neither the name of the University nor the names of its contributors
21aad01611Sagc * may be used to endorse or promote products derived from this software
22aad01611Sagc * without specific prior written permission.
23aad01611Sagc *
24aad01611Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25aad01611Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26aad01611Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27aad01611Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28aad01611Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29aad01611Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30aad01611Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31aad01611Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32aad01611Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33aad01611Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34aad01611Sagc * SUCH DAMAGE.
35aad01611Sagc *
36aad01611Sagc * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$
37aad01611Sagc *
38aad01611Sagc * @(#)ite_gb.c 8.1 (Berkeley) 6/10/93
39aad01611Sagc */
40a0864b3eSthorpej
41a0864b3eSthorpej #ifdef ITECONSOLE
42a0864b3eSthorpej
43a0864b3eSthorpej #include <sys/param.h>
44a0864b3eSthorpej
4513b242e4Stsutsui #include <hp300/stand/common/itereg.h>
4613b242e4Stsutsui #include <hp300/stand/common/grf_gbreg.h>
47a0864b3eSthorpej
48a0864b3eSthorpej #include <hp300/stand/common/samachdep.h>
49a0864b3eSthorpej #include <hp300/stand/common/itevar.h>
50a0864b3eSthorpej
51212f884fStsutsui void gbox_windowmove(struct ite_data *, int, int, int, int, int, int, int);
52a0864b3eSthorpej
53a0864b3eSthorpej void
gbox_init(struct ite_data * ip)54d3dc0553Stsutsui gbox_init(struct ite_data *ip)
55a0864b3eSthorpej {
56212f884fStsutsui struct gboxfb *regbase = (void *)ip->regbase;
57212f884fStsutsui
58*f6330dd7Stsutsui ip->bmv = gbox_windowmove;
59*f6330dd7Stsutsui
60212f884fStsutsui regbase->write_protect = 0x0;
61212f884fStsutsui regbase->interrupt = 0x4;
62212f884fStsutsui regbase->rep_rule = RR_COPY;
63212f884fStsutsui regbase->blink1 = 0xff;
64212f884fStsutsui regbase->blink2 = 0xff;
65212f884fStsutsui regbase->sec_interrupt = 0x01;
66a0864b3eSthorpej
67a0864b3eSthorpej /*
68a0864b3eSthorpej * Set up the color map entries. We use three entries in the
69a0864b3eSthorpej * color map. The first, is for black, the second is for
70a0864b3eSthorpej * white, and the very last entry is for the inverted cursor.
71a0864b3eSthorpej */
72212f884fStsutsui regbase->creg_select = 0x00;
73212f884fStsutsui regbase->cmap_red = 0x00;
74212f884fStsutsui regbase->cmap_grn = 0x00;
75212f884fStsutsui regbase->cmap_blu = 0x00;
76212f884fStsutsui regbase->cmap_write = 0x00;
77212f884fStsutsui gbcm_waitbusy(regbase);
78a0864b3eSthorpej
79212f884fStsutsui regbase->creg_select = 0x01;
80212f884fStsutsui regbase->cmap_red = 0xFF;
81212f884fStsutsui regbase->cmap_grn = 0xFF;
82212f884fStsutsui regbase->cmap_blu = 0xFF;
83212f884fStsutsui regbase->cmap_write = 0x01;
84212f884fStsutsui gbcm_waitbusy(regbase);
85a0864b3eSthorpej
86212f884fStsutsui regbase->creg_select = 0xFF;
87212f884fStsutsui regbase->cmap_red = 0xFF;
88212f884fStsutsui regbase->cmap_grn = 0xFF;
89212f884fStsutsui regbase->cmap_blu = 0xFF;
90212f884fStsutsui regbase->cmap_write = 0x01;
91212f884fStsutsui gbcm_waitbusy(regbase);
92a0864b3eSthorpej
93a0864b3eSthorpej ite_fontinfo(ip);
9436ac47efStsutsui ite_fontinit8bpp(ip);
95a0864b3eSthorpej
96a0864b3eSthorpej /*
97a0864b3eSthorpej * Clear the display. This used to be before the font unpacking
98a0864b3eSthorpej * but it crashes. Figure it out later.
99a0864b3eSthorpej */
100a0864b3eSthorpej gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
101212f884fStsutsui tile_mover_waitbusy(regbase);
102a0864b3eSthorpej
103a0864b3eSthorpej /*
104a0864b3eSthorpej * Stash the inverted cursor.
105a0864b3eSthorpej */
106a0864b3eSthorpej gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
107a0864b3eSthorpej ip->cblanky, ip->cblankx, ip->ftheight,
108a0864b3eSthorpej ip->ftwidth, RR_COPYINVERTED);
109a0864b3eSthorpej }
110a0864b3eSthorpej
111a0864b3eSthorpej void
gbox_scroll(struct ite_data * ip)112*f6330dd7Stsutsui gbox_scroll(struct ite_data *ip)
113a0864b3eSthorpej {
114212f884fStsutsui struct gboxfb *regbase = (void *)ip->regbase;
115a0864b3eSthorpej
116212f884fStsutsui tile_mover_waitbusy(regbase);
117212f884fStsutsui regbase->write_protect = 0x0;
118a0864b3eSthorpej
119*f6330dd7Stsutsui ite_dio_scroll(ip);
120a0864b3eSthorpej }
121a0864b3eSthorpej
122a0864b3eSthorpej void
gbox_windowmove(struct ite_data * ip,int sy,int sx,int dy,int dx,int h,int w,int mask)123438f912cStsutsui gbox_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx, int h,
124438f912cStsutsui int w, int mask)
125a0864b3eSthorpej {
126212f884fStsutsui struct gboxfb *regbase = (void *)ip->regbase;
127212f884fStsutsui int src, dest;
128a0864b3eSthorpej
129a0864b3eSthorpej src = (sy * 1024) + sx; /* upper left corner in pixels */
130a0864b3eSthorpej dest = (dy * 1024) + dx;
131a0864b3eSthorpej
132212f884fStsutsui tile_mover_waitbusy(regbase);
133212f884fStsutsui regbase->width = -(w / 4);
134212f884fStsutsui regbase->height = -(h / 4);
135a0864b3eSthorpej if (src < dest)
136212f884fStsutsui regbase->rep_rule = MOVE_DOWN_RIGHT|mask;
137a0864b3eSthorpej else {
138212f884fStsutsui regbase->rep_rule = MOVE_UP_LEFT|mask;
139a0864b3eSthorpej /*
140a0864b3eSthorpej * Adjust to top of lower right tile of the block.
141a0864b3eSthorpej */
142a0864b3eSthorpej src = src + ((h - 4) * 1024) + (w - 4);
143a0864b3eSthorpej dest= dest + ((h - 4) * 1024) + (w - 4);
144a0864b3eSthorpej }
145a0864b3eSthorpej FBBASE[dest] = FBBASE[src];
146a0864b3eSthorpej }
147a0864b3eSthorpej #endif
148