]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/pc98/pc98/scgdcrndr.c
This commit was generated by cvs2svn to compensate for changes in r56101,
[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/kernel.h>
38
39 #include <machine/console.h>
40 #include <machine/md_var.h>
41
42 #include <dev/fb/fbreg.h>
43 #include <dev/syscons/syscons.h>
44
45 #ifndef SC_RENDER_DEBUG
46 #define SC_RENDER_DEBUG         0
47 #endif
48
49 static vr_clear_t               gdc_txtclear;
50 static vr_draw_border_t         gdc_txtborder;
51 static vr_draw_t                gdc_txtdraw;
52 static vr_set_cursor_t          gdc_txtcursor_shape;
53 static vr_draw_cursor_t         gdc_txtcursor;
54 #ifndef SC_NO_CUTPASTE
55 static vr_draw_mouse_t          gdc_txtmouse;
56 #else
57 #define gdc_txtmouse            (vr_draw_mouse_t *)gdc_nop
58 #endif
59
60 #ifndef SC_NO_MODE_CHANGE
61 static vr_draw_border_t         gdc_grborder;
62 #endif
63
64 static void                     gdc_nop(scr_stat *scp, ...);
65
66 static sc_rndr_sw_t txtrndrsw = {
67         gdc_txtclear,
68         gdc_txtborder,
69         gdc_txtdraw,    
70         gdc_txtcursor_shape,
71         gdc_txtcursor,
72         (vr_blink_cursor_t *)gdc_nop,
73         (vr_set_mouse_t *)gdc_nop,
74         gdc_txtmouse,
75 };
76 RENDERER(gdc, 0, txtrndrsw);
77
78 #ifndef SC_NO_MODE_CHANGE
79 static sc_rndr_sw_t grrndrsw = {
80         (vr_clear_t *)gdc_nop,
81         gdc_grborder,
82         (vr_draw_t *)gdc_nop,
83         (vr_set_cursor_t *)gdc_nop,
84         (vr_draw_cursor_t *)gdc_nop,
85         (vr_blink_cursor_t *)gdc_nop,
86         (vr_set_mouse_t *)gdc_nop,
87         (vr_draw_mouse_t *)gdc_nop,
88 };
89 RENDERER(gdc, GRAPHICS_MODE, grrndrsw);
90 #endif /* SC_NO_MODE_CHANGE */
91
92 static void
93 gdc_nop(scr_stat *scp, ...)
94 {
95 }
96
97 /* text mode renderer */
98
99 static void
100 gdc_txtclear(scr_stat *scp, int c, int attr)
101 {
102         sc_vtb_clear(&scp->scr, c, attr);
103 }
104
105 static void
106 gdc_txtborder(scr_stat *scp, int color)
107 {
108         (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
109 }
110
111 static void
112 gdc_txtdraw(scr_stat *scp, int from, int count, int flip)
113 {
114         vm_offset_t p;
115         int c;
116         int a;
117
118         if (from + count > scp->xsize*scp->ysize)
119                 count = scp->xsize*scp->ysize - from;
120
121         if (flip) {
122                 p = sc_vtb_pointer(&scp->scr, from);
123                 for (; count-- > 0; ++from) {
124                         c = sc_vtb_getc(&scp->vtb, from);
125                         a = sc_vtb_geta(&scp->vtb, from) ^ 0x4;
126                         sc_vtb_putchar(&scp->scr, p, c, a);
127                 }
128         } else {
129                 sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count);
130         }
131 }
132
133 static void
134 gdc_txtcursor_shape(scr_stat *scp, int base, int height, int blink)
135 {
136         if (base < 0 || base >= scp->font_size)
137                 return;
138         /* the caller may set height <= 0 in order to disable the cursor */
139         (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp,
140                                                         base, height,
141                                                         scp->font_size, blink);
142 }
143
144 static void
145 gdc_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
146 {
147         if (on) {
148                 scp->status |= VR_CURSOR_ON;
149                 (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp,
150                                                  at%scp->xsize, at/scp->xsize); 
151         } else {
152                 if (scp->status & VR_CURSOR_ON)
153                         (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp,
154                                                                   -1, -1);
155                 scp->status &= ~VR_CURSOR_ON;
156         }
157 }
158
159 #ifndef SC_NO_CUTPASTE
160
161 static void
162 draw_txtmouse(scr_stat *scp, int x, int y)
163 {
164         int at;
165
166         at = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
167         sc_vtb_putc(&scp->scr, at,
168                     sc_vtb_getc(&scp->scr, at),
169                     sc_vtb_geta(&scp->scr, at) ^ 0x4);
170 }
171
172 static void
173 remove_txtmouse(scr_stat *scp, int x, int y)
174 {
175 }
176
177 static void 
178 gdc_txtmouse(scr_stat *scp, int x, int y, int on)
179 {
180         if (on)
181                 draw_txtmouse(scp, x, y);
182         else
183                 remove_txtmouse(scp, x, y);
184 }
185
186 #endif /* SC_NO_CUTPASTE */
187
188 #ifndef SC_NO_MODE_CHANGE
189
190 /* graphics mode renderer */
191
192 static void
193 gdc_grborder(scr_stat *scp, int color)
194 {
195         (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
196 }
197
198 #endif /* SC_NO_MODE_CHANGE */
199
200 #endif /* NSC > 0 && NGDC > 0 */