daemon_saver.c (43673) | daemon_saver.c (48104) |
---|---|
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 * | 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.14 1999/01/17 14:25:08 yokota Exp $ | 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> | 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> |
|
37 | 39 |
38#include <machine/md_var.h> | |
39#include <machine/pc/display.h> 40 | 40#include <machine/pc/display.h> 41 |
41#include <saver.h> | 42#include <dev/fb/fbreg.h> 43#include <dev/fb/splashreg.h> 44#include <dev/syscons/syscons.h> |
42 | 45 |
43#define CONSOLE_VECT(x, y) \ 44 (window + (y)*cur_console->xsize + (x)) 45 | |
46#define DAEMON_MAX_WIDTH 32 47#define DAEMON_MAX_HEIGHT 19 48 49static char *message; 50static int messagelen; | 46#define DAEMON_MAX_WIDTH 32 47#define DAEMON_MAX_HEIGHT 19 48 49static char *message; 50static int messagelen; |
51static u_short *window; | |
52static int blanked; 53 54/* Who is the author of this ASCII pic? */ 55 56static char *daemon_pic[] = { 57 " , ,", 58 " /( )`", 59 " \\ \\___ / |", --- 54 unchanged lines hidden (view full) --- 114 for (pos = 0; lchars[pos] != '\0'; pos++) 115 if (lchars[pos] == symbol) 116 return rchars[pos]; 117 118 return symbol; 119} 120 121static void | 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 |
122clear_daemon(int xpos, int ypos, int dxdir, int xoff, int yoff, | 121clear_daemon(sc_softc_t *sc, int xpos, int ypos, int dxdir, int xoff, int yoff, |
123 int xlen, int ylen) 124{ 125 int y; 126 127 if (xlen <= 0) 128 return; | 122 int xlen, int ylen) 123{ 124 int y; 125 126 if (xlen <= 0) 127 return; |
129 for (y = yoff; y < ylen; y++) 130 fillw(((FG_LIGHTGREY|BG_BLACK) << 8) | scr_map[0x20], 131 CONSOLE_VECT(xpos + xoff, ypos + y), xlen - xoff); | 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 } |
132} 133 134static void | 134} 135 136static void |
135draw_daemon(int xpos, int ypos, int dxdir, int xoff, int yoff, | 137draw_daemon(sc_softc_t *sc, int xpos, int ypos, int dxdir, int xoff, int yoff, |
136 int xlen, int ylen) 137{ 138 int x, y; 139 int px; 140 int attr; 141 142 for (y = yoff; y < ylen; y++) { 143 if (dxdir < 0) 144 px = xoff; 145 else 146 px = DAEMON_MAX_WIDTH - xlen; 147 if (px >= strlen(daemon_pic[y])) 148 continue; 149 for (x = xoff; (x < xlen) && (daemon_pic[y][px] != '\0'); x++, px++) { 150 switch (daemon_attr[y][px]) { | 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 |
|
151 case 'R': attr = (FG_LIGHTRED|BG_BLACK)<<8; break; 152 case 'Y': attr = (FG_YELLOW|BG_BLACK)<<8; break; 153 case 'B': attr = (FG_LIGHTBLUE|BG_BLACK)<<8; break; 154 case 'W': attr = (FG_LIGHTGREY|BG_BLACK)<<8; break; 155 case 'C': attr = (FG_CYAN|BG_BLACK)<<8; break; 156 default: attr = (FG_WHITE|BG_BLACK)<<8; break; | 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 */ |
|
157 } 158 if (dxdir < 0) { /* Moving left */ | 168 } 169 if (dxdir < 0) { /* Moving left */ |
159 *CONSOLE_VECT(xpos + x, ypos + y) = 160 scr_map[daemon_pic[y][px]]|attr; | 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); |
161 } else { /* Moving right */ | 175 } else { /* Moving right */ |
162 *CONSOLE_VECT(xpos + DAEMON_MAX_WIDTH - px - 1, ypos + y) = 163 scr_map[xflip_symbol(daemon_pic[y][px])]|attr; | 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); |
164 } 165 } 166 } 167} 168 169static void | 182 } 183 } 184 } 185} 186 187static void |
170clear_string(int xpos, int ypos, int xoff, char *s, int len) | 188clear_string(sc_softc_t *sc, int xpos, int ypos, int xoff, char *s, int len) |
171{ 172 if (len <= 0) 173 return; | 189{ 190 if (len <= 0) 191 return; |
174 fillw(((FG_LIGHTGREY|BG_BLACK) << 8) | scr_map[0x20], 175 CONSOLE_VECT(xpos + xoff, ypos), len - xoff); | 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); |
176} 177 178static void | 195} 196 197static void |
179draw_string(int xpos, int ypos, int xoff, char *s, int len) | 198draw_string(sc_softc_t *sc, int xpos, int ypos, int xoff, char *s, int len) |
180{ 181 int x; 182 | 199{ 200 int x; 201 |
183 for (x = xoff; x < len; x++) 184 *CONSOLE_VECT(xpos + x, ypos) = 185 scr_map[s[x]]|(FG_LIGHTGREEN|BG_BLACK)<<8; | 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 } |
186} 187 188static int 189daemon_saver(video_adapter_t *adp, int blank) 190{ 191 static int txpos = 10, typos = 10; 192 static int txdir = -1, tydir = -1; 193 static int dxpos = 0, dypos = 0; 194 static int dxdir = 1, dydir = 1; 195 static int moved_daemon = 0; 196 static int xoff, yoff, toff; 197 static int xlen, ylen, tlen; | 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; |
198 scr_stat *scp = cur_console; | 219 sc_softc_t *sc; 220 scr_stat *scp; |
199 int min, max; 200 | 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 |
|
201 if (blank) { 202 if (adp->va_info.vi_flags & V_INFO_GRAPHICS) 203 return EAGAIN; 204 if (blanked == 0) { | 228 if (blank) { 229 if (adp->va_info.vi_flags & V_INFO_GRAPHICS) 230 return EAGAIN; 231 if (blanked == 0) { |
205 window = (u_short *)adp->va_window; | 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 */ |
206 /* clear the screen and set the border color */ | 239 /* clear the screen and set the border color */ |
207 fillw(((FG_LIGHTGREY|BG_BLACK) << 8) | scr_map[0x20], 208 window, scp->xsize * scp->ysize); | 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); |
209 set_border(scp, 0); 210 xlen = ylen = tlen = 0; 211 } 212 if (blanked++ < 2) 213 return 0; 214 blanked = 1; 215 | 243 set_border(scp, 0); 244 xlen = ylen = tlen = 0; 245 } 246 if (blanked++ < 2) 247 return 0; 248 blanked = 1; 249 |
216 clear_daemon(dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); 217 clear_string(txpos, typos, toff, (char *)message, tlen); | 250 clear_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); 251 clear_string(sc, txpos, typos, toff, (char *)message, tlen); |
218 219 if (++moved_daemon) { 220 /* 221 * The daemon picture may be off the screen, if 222 * screen size is chagened while the screen 223 * saver is inactive. Make sure the origin of 224 * the picture is between min and max. 225 */ --- 88 unchanged lines hidden (view full) --- 314 tlen = 0; 315 else if (txpos < 0) 316 toff = -txpos; 317 if (txpos >= scp->xsize) 318 tlen = 0; 319 else if (txpos + tlen > scp->xsize) 320 tlen = scp->xsize - txpos; 321 | 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 |
322 draw_daemon(dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); 323 draw_string(txpos, typos, toff, (char *)message, tlen); | 356 draw_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); 357 draw_string(sc, txpos, typos, toff, (char *)message, tlen); |
324 } else { | 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 */ |
|
325 blanked = 0; 326 } 327 return 0; 328} 329 330static int 331daemon_init(video_adapter_t *adp) 332{ --- 20 unchanged lines hidden --- | 366 blanked = 0; 367 } 368 return 0; 369} 370 371static int 372daemon_init(video_adapter_t *adp) 373{ --- 20 unchanged lines hidden --- |