]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/pc98/pc98/scgdcrndr.c
This commit was generated by cvs2svn to compensate for changes in r52744,
[FreeBSD/FreeBSD.git] / sys / pc98 / pc98 / scgdcrndr.c
1 /*-
2  * Copyright (c) 1999 FreeBSD(98) Porting Team.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer as
10  *    the first lines of this file unmodified.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #include "sc.h"
30 #include "gdc.h"
31 #include "opt_syscons.h"
32 #include "opt_gdc.h"
33
34 #if NSC > 0 && NGDC > 0
35
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39
40 #include <machine/console.h>
41 #include <machine/md_var.h>
42
43 #include <pc98/pc98/pc98.h>
44 #include <pc98/pc98/pc98_machdep.h>
45
46 #include <dev/fb/fbreg.h>
47 #include <dev/syscons/syscons.h>
48
49 #ifndef SC_RENDER_DEBUG
50 #define SC_RENDER_DEBUG         0
51 #endif
52
53 static vr_clear_t               gdc_txtclear;
54 static vr_draw_border_t         gdc_txtborder;
55 static vr_draw_t                gdc_txtdraw;
56 static vr_set_cursor_t          gdc_txtcursor_shape;
57 static vr_draw_cursor_t         gdc_txtcursor;
58 #ifndef SC_NO_CUTPASTE
59 static vr_draw_mouse_t          gdc_txtmouse;
60 #else
61 #define gdc_txtmouse            (vr_draw_mouse_t *)gdc_nop
62 #endif
63
64 #ifndef SC_NO_MODE_CHANGE
65 static vr_draw_border_t         gdc_grborder;
66 #endif
67
68 static void                     gdc_nop(scr_stat *scp, ...);
69
70 static sc_rndr_sw_t txtrndrsw = {
71         gdc_txtclear,
72         gdc_txtborder,
73         gdc_txtdraw,    
74         gdc_txtcursor_shape,
75         gdc_txtcursor,
76         (vr_blink_cursor_t *)gdc_nop,
77         (vr_set_mouse_t *)gdc_nop,
78         gdc_txtmouse,
79 };
80 RENDERER(gdc, 0, txtrndrsw);
81
82 #ifndef SC_NO_MODE_CHANGE
83 static sc_rndr_sw_t grrndrsw = {
84         (vr_clear_t *)gdc_nop,
85         gdc_grborder,
86         (vr_draw_t *)gdc_nop,
87         (vr_set_cursor_t *)gdc_nop,
88         (vr_draw_cursor_t *)gdc_nop,
89         (vr_blink_cursor_t *)gdc_nop,
90         (vr_set_mouse_t *)gdc_nop,
91         (vr_draw_mouse_t *)gdc_nop,
92 };
93 RENDERER(gdc, GRAPHICS_MODE, grrndrsw);
94 #endif /* SC_NO_MODE_CHANGE */
95
96 static void
97 gdc_nop(scr_stat *scp, ...)
98 {
99 }
100
101 /* text mode renderer */
102
103 static void
104 gdc_txtclear(scr_stat *scp, int c, int attr)
105 {
106         sc_vtb_clear(&scp->scr, c, attr);
107 }
108
109 static void
110 gdc_txtborder(scr_stat *scp, int color)
111 {
112         (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
113 }
114
115 static void
116 gdc_txtdraw(scr_stat *scp, int from, int count, int flip)
117 {
118         vm_offset_t p;
119         int c;
120         int a;
121
122         if (from + count > scp->xsize*scp->ysize)
123                 count = scp->xsize*scp->ysize - from;
124
125         if (flip) {
126                 p = sc_vtb_pointer(&scp->scr, from);
127                 for (; count-- > 0; ++from) {
128                         c = sc_vtb_getc(&scp->vtb, from);
129                         a = sc_vtb_geta(&scp->vtb, from) ^ 0x4;
130                         sc_vtb_putchar(&scp->scr, p, c, a);
131                 }
132         } else {
133                 sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count);
134         }
135 }
136
137 static void
138 gdc_txtcursor_shape(scr_stat *scp, int base, int height, int blink)
139 {
140         if (base < 0 || base >= scp->font_size)
141                 return;
142         /* the caller may set height <= 0 in order to disable the cursor */
143         (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp,
144                                                         base, height,
145                                                         scp->font_size, blink);
146 }
147
148 static void
149 gdc_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
150 {
151         if (on) {
152                 scp->status |= VR_CURSOR_ON;
153                 (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp,
154                                                  at%scp->xsize, at/scp->xsize); 
155         } else {
156                 if (scp->status & VR_CURSOR_ON)
157                         (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp,
158                                                                   -1, -1);
159                 scp->status &= ~VR_CURSOR_ON;
160         }
161 }
162
163 #ifndef SC_NO_CUTPASTE
164
165 static void
166 draw_txtmouse(scr_stat *scp, int x, int y)
167 {
168         int at;
169
170         at = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
171         sc_vtb_putc(&scp->scr, at,
172                     sc_vtb_getc(&scp->scr, at),
173                     sc_vtb_geta(&scp->scr, at) ^ 0x4);
174 }
175
176 static void
177 remove_txtmouse(scr_stat *scp, int x, int y)
178 {
179 }
180
181 static void 
182 gdc_txtmouse(scr_stat *scp, int x, int y, int on)
183 {
184         if (on)
185                 draw_txtmouse(scp, x, y);
186         else
187                 remove_txtmouse(scp, x, y);
188 }
189
190 #endif /* SC_NO_CUTPASTE */
191
192 #ifndef SC_NO_MODE_CHANGE
193
194 /* graphics mode renderer */
195
196 static void
197 gdc_grborder(scr_stat *scp, int color)
198 {
199         (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
200 }
201
202 #endif /* SC_NO_MODE_CHANGE */
203
204 #endif /* NSC > 0 && NGDC > 0 */