1/*- 2 * Copyright (c) 1997 Sandro Sigala, Brescia, Italy. 3 * Copyright (c) 1997 Chris Shenton 4 * Copyright (c) 1995 S ren Schmidt 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $Id: daemon_saver.c,v 1.15 1999/02/05 12:40:15 des Exp $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/module.h> 34#include <sys/malloc.h> 35#include <sys/kernel.h> 36#include <sys/sysctl.h> |
37#include <sys/consio.h> 38#include <sys/fbio.h> |
39 |
40#include <machine/pc/display.h> 41 |
42#include <dev/fb/fbreg.h> 43#include <dev/fb/splashreg.h> 44#include <dev/syscons/syscons.h> |
45 |
46#define DAEMON_MAX_WIDTH 32 47#define DAEMON_MAX_HEIGHT 19 48 49static char *message; 50static int messagelen; |
51static int blanked; 52 53/* Who is the author of this ASCII pic? */ 54 55static char *daemon_pic[] = { 56 " , ,", 57 " /( )`", 58 " \\ \\___ / |", --- 54 unchanged lines hidden (view full) --- 113 for (pos = 0; lchars[pos] != '\0'; pos++) 114 if (lchars[pos] == symbol) 115 return rchars[pos]; 116 117 return symbol; 118} 119 120static void |
121clear_daemon(sc_softc_t *sc, int xpos, int ypos, int dxdir, int xoff, int yoff, |
122 int xlen, int ylen) 123{ 124 int y; 125 126 if (xlen <= 0) 127 return; |
128 for (y = yoff; y < ylen; y++) { 129 sc_vtb_erase(&sc->cur_scp->scr, 130 (ypos + y)*sc->cur_scp->xsize + xpos + xoff, 131 xlen - xoff, 132 sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); 133 } |
134} 135 136static void |
137draw_daemon(sc_softc_t *sc, int xpos, int ypos, int dxdir, int xoff, int yoff, |
138 int xlen, int ylen) 139{ 140 int x, y; 141 int px; 142 int attr; 143 144 for (y = yoff; y < ylen; y++) { 145 if (dxdir < 0) 146 px = xoff; 147 else 148 px = DAEMON_MAX_WIDTH - xlen; 149 if (px >= strlen(daemon_pic[y])) 150 continue; 151 for (x = xoff; (x < xlen) && (daemon_pic[y][px] != '\0'); x++, px++) { 152 switch (daemon_attr[y][px]) { |
153#ifndef PC98 |
154 case 'R': attr = (FG_LIGHTRED|BG_BLACK)<<8; break; 155 case 'Y': attr = (FG_YELLOW|BG_BLACK)<<8; break; 156 case 'B': attr = (FG_LIGHTBLUE|BG_BLACK)<<8; break; 157 case 'W': attr = (FG_LIGHTGREY|BG_BLACK)<<8; break; 158 case 'C': attr = (FG_CYAN|BG_BLACK)<<8; break; 159 default: attr = (FG_WHITE|BG_BLACK)<<8; break; |
160#else /* PC98 */ 161 case 'R': attr = (FG_RED|BG_BLACK)<<8; break; 162 case 'Y': attr = (FG_BROWN|BG_BLACK)<<8; break; 163 case 'B': attr = (FG_BLUE|BG_BLACK)<<8; break; 164 case 'W': attr = (FG_LIGHTGREY|BG_BLACK)<<8; break; 165 case 'C': attr = (FG_CYAN|BG_BLACK)<<8; break; 166 default: attr = (FG_LIGHTGREY|BG_BLACK)<<8; break; 167#endif /* PC98 */ |
168 } 169 if (dxdir < 0) { /* Moving left */ |
170 sc_vtb_putc(&sc->cur_scp->scr, 171 (ypos + y)*sc->cur_scp->xsize 172 + xpos + x, 173 sc->scr_map[daemon_pic[y][px]], 174 attr); |
175 } else { /* Moving right */ |
176 sc_vtb_putc(&sc->cur_scp->scr, 177 (ypos + y)*sc->cur_scp->xsize 178 + xpos + DAEMON_MAX_WIDTH 179 - px - 1, 180 sc->scr_map[xflip_symbol(daemon_pic[y][px])], 181 attr); |
182 } 183 } 184 } 185} 186 187static void |
188clear_string(sc_softc_t *sc, int xpos, int ypos, int xoff, char *s, int len) |
189{ 190 if (len <= 0) 191 return; |
192 sc_vtb_erase(&sc->cur_scp->scr, 193 ypos*sc->cur_scp->xsize + xpos + xoff, len - xoff, 194 sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); |
195} 196 197static void |
198draw_string(sc_softc_t *sc, int xpos, int ypos, int xoff, char *s, int len) |
199{ 200 int x; 201 |
202 for (x = xoff; x < len; x++) { 203 sc_vtb_putc(&sc->cur_scp->scr, 204 ypos*sc->cur_scp->xsize + xpos + x, 205 sc->scr_map[s[x]], (FG_LIGHTGREEN | BG_BLACK) << 8); 206 } |
207} 208 209static int 210daemon_saver(video_adapter_t *adp, int blank) 211{ 212 static int txpos = 10, typos = 10; 213 static int txdir = -1, tydir = -1; 214 static int dxpos = 0, dypos = 0; 215 static int dxdir = 1, dydir = 1; 216 static int moved_daemon = 0; 217 static int xoff, yoff, toff; 218 static int xlen, ylen, tlen; |
219 sc_softc_t *sc; 220 scr_stat *scp; |
221 int min, max; 222 |
223 sc = sc_find_softc(adp, NULL); 224 if (sc == NULL) 225 return EAGAIN; 226 scp = sc->cur_scp; 227 |
228 if (blank) { 229 if (adp->va_info.vi_flags & V_INFO_GRAPHICS) 230 return EAGAIN; 231 if (blanked == 0) { |
232#ifdef PC98 233 if (epson_machine_id == 0x20) { 234 outb(0x43f, 0x42); 235 outb(0x0c17, inb(0xc17) & ~0x08); 236 outb(0x43f, 0x40); 237 } 238#endif /* PC98 */ |
239 /* clear the screen and set the border color */ |
240 sc_vtb_clear(&scp->scr, sc->scr_map[0x20], 241 (FG_LIGHTGREY | BG_BLACK) << 8); 242 (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1); |
243 set_border(scp, 0); 244 xlen = ylen = tlen = 0; 245 } 246 if (blanked++ < 2) 247 return 0; 248 blanked = 1; 249 |
250 clear_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); 251 clear_string(sc, txpos, typos, toff, (char *)message, tlen); |
252 253 if (++moved_daemon) { 254 /* 255 * The daemon picture may be off the screen, if 256 * screen size is chagened while the screen 257 * saver is inactive. Make sure the origin of 258 * the picture is between min and max. 259 */ --- 88 unchanged lines hidden (view full) --- 348 tlen = 0; 349 else if (txpos < 0) 350 toff = -txpos; 351 if (txpos >= scp->xsize) 352 tlen = 0; 353 else if (txpos + tlen > scp->xsize) 354 tlen = scp->xsize - txpos; 355 |
356 draw_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); 357 draw_string(sc, txpos, typos, toff, (char *)message, tlen); |
358 } else { |
359#ifdef PC98 360 if (epson_machine_id == 0x20) { 361 outb(0x43f, 0x42); 362 outb(0x0c17, inb(0xc17) | 0x08); 363 outb(0x43f, 0x40); 364 } 365#endif /* PC98 */ |
366 blanked = 0; 367 } 368 return 0; 369} 370 371static int 372daemon_init(video_adapter_t *adp) 373{ --- 20 unchanged lines hidden --- |