scgdcrndr.c revision 50477
148187Skato/*- 248516Skato * Copyright (c) 1999 FreeBSD(98) Porting Team. 348516Skato * All rights reserved. 448516Skato * 548516Skato * Redistribution and use in source and binary forms, with or without 648516Skato * modification, are permitted provided that the following conditions 748516Skato * are met: 848516Skato * 1. Redistributions of source code must retain the above copyright 948516Skato * notice, this list of conditions and the following disclaimer as 1048516Skato * the first lines of this file unmodified. 1148516Skato * 2. Redistributions in binary form must reproduce the above copyright 1248516Skato * notice, this list of conditions and the following disclaimer in the 1348516Skato * documentation and/or other materials provided with the distribution. 1448516Skato * 1548516Skato * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 1648516Skato * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1748516Skato * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1848516Skato * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 1948516Skato * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2048516Skato * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2148516Skato * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2248516Skato * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2348516Skato * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2448516Skato * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2548516Skato * 2650477Speter * $FreeBSD: head/sys/pc98/cbus/scgdcrndr.c 50477 1999-08-28 01:08:13Z peter $ 2748187Skato */ 2848187Skato 2948187Skato#include "sc.h" 3048187Skato#include "gdc.h" 3148187Skato#include "opt_syscons.h" 3248187Skato#include "opt_gdc.h" 3348187Skato 3448187Skato#if NSC > 0 && NGDC > 0 3548187Skato 3648187Skato#include <sys/param.h> 3748187Skato#include <sys/systm.h> 3848187Skato#include <sys/kernel.h> 3948187Skato 4048187Skato#include <machine/console.h> 4148187Skato#include <machine/md_var.h> 4248187Skato 4348187Skato#include <pc98/pc98/pc98.h> 4448187Skato#include <pc98/pc98/pc98_machdep.h> 4548187Skato 4648187Skato#include <dev/fb/fbreg.h> 4748187Skato#include <dev/syscons/syscons.h> 4848187Skato 4948187Skato#ifndef SC_RENDER_DEBUG 5048187Skato#define SC_RENDER_DEBUG 0 5148187Skato#endif 5248187Skato 5348187Skatostatic vr_clear_t gdc_txtclear; 5448187Skatostatic vr_draw_border_t gdc_txtborder; 5548187Skatostatic vr_draw_t gdc_txtdraw; 5648187Skatostatic vr_set_cursor_t gdc_txtcursor_shape; 5748187Skatostatic vr_draw_cursor_t gdc_txtcursor; 5848187Skato#ifndef SC_NO_CUTPASTE 5948187Skatostatic vr_draw_mouse_t gdc_txtmouse; 6048187Skato#else 6148187Skato#define gdc_txtmouse (vr_draw_mouse_t *)gdc_nop 6248187Skato#endif 6348187Skato 6448187Skato#ifndef SC_NO_MODE_CHANGE 6548187Skatostatic vr_draw_border_t gdc_grborder; 6648187Skato#endif 6748187Skato 6848187Skatostatic void gdc_nop(scr_stat *scp, ...); 6948187Skato 7048187Skatostatic sc_rndr_sw_t txtrndrsw = { 7148187Skato gdc_txtclear, 7248187Skato gdc_txtborder, 7348187Skato gdc_txtdraw, 7448187Skato gdc_txtcursor_shape, 7548187Skato gdc_txtcursor, 7648187Skato (vr_blink_cursor_t *)gdc_nop, 7748187Skato (vr_set_mouse_t *)gdc_nop, 7848187Skato gdc_txtmouse, 7948187Skato}; 8048187SkatoRENDERER(gdc, 0, txtrndrsw); 8148187Skato 8248187Skato#ifndef SC_NO_MODE_CHANGE 8348187Skatostatic sc_rndr_sw_t grrndrsw = { 8448187Skato (vr_clear_t *)gdc_nop, 8548187Skato gdc_grborder, 8648187Skato (vr_draw_t *)gdc_nop, 8748187Skato (vr_set_cursor_t *)gdc_nop, 8848187Skato (vr_draw_cursor_t *)gdc_nop, 8948187Skato (vr_blink_cursor_t *)gdc_nop, 9048187Skato (vr_set_mouse_t *)gdc_nop, 9148187Skato (vr_draw_mouse_t *)gdc_nop, 9248187Skato}; 9348187SkatoRENDERER(gdc, GRAPHICS_MODE, grrndrsw); 9448187Skato#endif /* SC_NO_MODE_CHANGE */ 9548187Skato 9648187Skatostatic void 9748187Skatogdc_nop(scr_stat *scp, ...) 9848187Skato{ 9948187Skato} 10048187Skato 10148187Skato/* text mode renderer */ 10248187Skato 10348187Skatostatic void 10448187Skatogdc_txtclear(scr_stat *scp, int c, int attr) 10548187Skato{ 10648187Skato sc_vtb_clear(&scp->scr, c, attr); 10748187Skato} 10848187Skato 10948187Skatostatic void 11048187Skatogdc_txtborder(scr_stat *scp, int color) 11148187Skato{ 11248187Skato (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color); 11348187Skato} 11448187Skato 11548187Skatostatic void 11648187Skatogdc_txtdraw(scr_stat *scp, int from, int count, int flip) 11748187Skato{ 11848187Skato vm_offset_t p; 11948187Skato int c; 12048187Skato int a; 12148187Skato 12248187Skato if (from + count > scp->xsize*scp->ysize) 12348187Skato count = scp->xsize*scp->ysize - from; 12448187Skato 12548187Skato if (flip) { 12648187Skato p = sc_vtb_pointer(&scp->scr, from); 12748187Skato for (; count-- > 0; ++from) { 12848187Skato c = sc_vtb_getc(&scp->vtb, from); 12948187Skato a = sc_vtb_geta(&scp->vtb, from) ^ 0x4; 13048187Skato sc_vtb_putchar(&scp->scr, p, c, a); 13148187Skato } 13248187Skato } else { 13348187Skato sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count); 13448187Skato } 13548187Skato} 13648187Skato 13748187Skatostatic void 13848187Skatogdc_txtcursor_shape(scr_stat *scp, int base, int height, int blink) 13948187Skato{ 14048187Skato if (base < 0 || base >= scp->font_size) 14148187Skato return; 14248187Skato /* the caller may set height <= 0 in order to disable the cursor */ 14348187Skato (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp, 14448187Skato base, height, 14548187Skato scp->font_size, blink); 14648187Skato} 14748187Skato 14848187Skatostatic void 14948187Skatogdc_txtcursor(scr_stat *scp, int at, int blink, int on, int flip) 15048187Skato{ 15148187Skato if (on) { 15248187Skato scp->status |= VR_CURSOR_ON; 15348187Skato (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp, 15448187Skato at%scp->xsize, at/scp->xsize); 15548187Skato } else { 15648187Skato if (scp->status & VR_CURSOR_ON) 15748187Skato (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp, 15848187Skato -1, -1); 15948187Skato scp->status &= ~VR_CURSOR_ON; 16048187Skato } 16148187Skato} 16248187Skato 16348187Skato#ifndef SC_NO_CUTPASTE 16448187Skato 16548187Skatostatic void 16648187Skatodraw_txtmouse(scr_stat *scp, int x, int y) 16748187Skato{ 16848187Skato int at; 16948187Skato 17048187Skato at = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff; 17148187Skato sc_vtb_putc(&scp->scr, at, 17248187Skato sc_vtb_getc(&scp->scr, at), 17348187Skato sc_vtb_geta(&scp->scr, at) ^ 0x4); 17448187Skato} 17548187Skato 17648187Skatostatic void 17748187Skatoremove_txtmouse(scr_stat *scp, int x, int y) 17848187Skato{ 17948187Skato} 18048187Skato 18148187Skatostatic void 18248187Skatogdc_txtmouse(scr_stat *scp, int x, int y, int on) 18348187Skato{ 18448187Skato if (on) 18548187Skato draw_txtmouse(scp, x, y); 18648187Skato else 18748187Skato remove_txtmouse(scp, x, y); 18848187Skato} 18948187Skato 19048187Skato#endif /* SC_NO_CUTPASTE */ 19148187Skato 19248187Skato#ifndef SC_NO_MODE_CHANGE 19348187Skato 19448187Skato/* graphics mode renderer */ 19548187Skato 19648187Skatostatic void 19748187Skatogdc_grborder(scr_stat *scp, int color) 19848187Skato{ 19948187Skato (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color); 20048187Skato} 20148187Skato 20248187Skato#endif /* SC_NO_MODE_CHANGE */ 20348187Skato 20448187Skato#endif /* NSC > 0 && NGDC > 0 */ 205