static int txt_splash(video_adapter_t *adp, const int on) { sc_softc_t *sc; scr_stat *scp; sc = sc_find_softc(adp, NULL); if (sc == NULL) return (EAGAIN); scp = sc->cur_scp; if (on) { if (!splash_on) { if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return EAGAIN; /* Clear screen and set border colour. */ sc_vtb_clear(&scp->scr, sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1); sc_set_border(scp, 0); splash_on = TRUE; /* Display the splash screen. */ draw_text_splash(sc); } return (0); } else { /* The video mode will be restored by the caller. */ splash_on = FALSE; return (0); } }
int sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) { scr_stat *scp; int error; switch (cmd) { case CONS_HISTORY: /* set history size */ scp = SC_STAT(tp); if (*(int *)data <= 0) return EINVAL; if (scp->status & BUFFER_SAVED) return EBUSY; DPRINTF(5, ("lines:%d, ysize:%d, pool:%d\n", *(int *)data, scp->ysize, extra_history_size)); error = sc_alloc_history_buffer(scp, imax(*(int *)data, scp->ysize), scp->ysize, TRUE); DPRINTF(5, ("error:%d, rows:%d, pool:%d\n", error, sc_vtb_rows(scp->history), extra_history_size)); return error; case CONS_CLRHIST: scp = SC_STAT(tp); sc_vtb_clear(scp->history, scp->sc->scr_map[0x20], SC_NORM_ATTR << 8); return 0; } return ENOIOCTL; }
static void scteken_clear(scr_stat *scp) { sc_move_cursor(scp, 0, 0); sc_vtb_clear(&scp->vtb, scp->sc->scr_map[0x20], SC_NORM_ATTR << 8); mark_all(scp); }
/* * Alternate saver that got its inspiration from a well known utility * package for an inferior^H^H^H^H^H^Hfamous OS. */ static int star_saver(video_adapter_t *adp, int blank) { sc_softc_t *sc; scr_stat *scp; int cell, i; static u_char pattern[] = {"...........++++*** "}; static char color16[] = {FG_DARKGREY, FG_LIGHTGREY, FG_WHITE, FG_LIGHTCYAN}; static char color8[] = {FG_BLUE, FG_BROWN, FG_LIGHTGREY, FG_CYAN}; static char *colors; static u_short stars[NUM_STARS][2]; sc = sc_find_softc(adp, NULL); if (sc == NULL) return EAGAIN; scp = sc->cur_scp; if (blank) { if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return EAGAIN; if (!blanked) { switch (adp->va_mode) { case M_PC98_80x25: case M_PC98_80x30: colors = color8; break; default: colors = color16; break; } /* clear the screen and set the border color */ sc_vtb_clear(&scp->scr, sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); vidd_set_hw_cursor(adp, -1, -1); sc_set_border(scp, 0); blanked = TRUE; for(i=0; i<NUM_STARS; i++) { stars[i][0] = random() % (scp->xsize*scp->ysize); stars[i][1] = 0; } } cell = random() % NUM_STARS; sc_vtb_putc(&scp->scr, stars[cell][0], sc->scr_map[pattern[stars[cell][1]]], colors[random()%sizeof(color16)] << 8); if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) { stars[cell][0] = random() % (scp->xsize*scp->ysize); stars[cell][1] = 0; } } else blanked = FALSE; return 0; }
/* allocate a history buffer */ int sc_alloc_history_buffer(scr_stat *scp, int lines, int prev_ysize, int wait) { /* * syscons unconditionally allocates buffers up to * SC_HISTORY_SIZE lines or scp->ysize lines, whichever * is larger. A value greater than that is allowed, * subject to extra_history_size. */ sc_vtb_t *history; sc_vtb_t *prev_history; int cur_lines; /* current buffer size */ int min_lines; /* guaranteed buffer size */ int delta; /* lines to put back */ if (lines <= 0) lines = SC_HISTORY_SIZE; /* use the default value */ /* make it at least as large as the screen size */ lines = imax(lines, scp->ysize); /* remove the history buffer while we update it */ history = prev_history = scp->history; scp->history = NULL; /* calculate the amount of lines to put back to extra_history_size */ delta = 0; if (prev_history) { cur_lines = sc_vtb_rows(history); min_lines = imax(SC_HISTORY_SIZE, prev_ysize); if (cur_lines > min_lines) delta = cur_lines - min_lines; } /* lines up to min_lines are always allowed. */ min_lines = imax(SC_HISTORY_SIZE, scp->ysize); if (lines > min_lines) { if (lines - min_lines > extra_history_size + delta) { /* too many lines are requested */ scp->history = prev_history; return EINVAL; } } /* allocate a new buffer */ history = (sc_vtb_t *)malloc(sizeof(*history), M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT); if (history != NULL) { if (lines > min_lines) extra_history_size -= lines - min_lines; /* XXX error check? */ sc_vtb_init(history, VTB_RINGBUFFER, scp->xsize, lines, NULL, wait); /* FIXME: XXX no good? */ sc_vtb_clear(history, scp->sc->scr_map[0x20], SC_NORM_ATTR << 8); if (prev_history != NULL) copy_history(prev_history, history); scp->history_pos = sc_vtb_tail(history); } else { scp->history_pos = 0; } /* destroy the previous buffer */ if (prev_history != NULL) { extra_history_size += delta; sc_vtb_destroy(prev_history); free(prev_history, M_DEVBUF); } scp->history = history; return 0; }
static int snake_saver(video_adapter_t *adp, int blank) { static int dirx, diry; int f; sc_softc_t *sc; scr_stat *scp; /* XXX hack for minimal changes. */ #define save message #define savs messagep sc = sc_find_softc(adp, NULL); if (sc == NULL) return EAGAIN; scp = sc->cur_scp; if (blank) { if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return EAGAIN; if (blanked <= 0) { #ifdef PC98 if (epson_machine_id == 0x20) { outb(0x43f, 0x42); outb(0x0c17, inb(0xc17) & ~0x08); outb(0x43f, 0x40); } #endif /* PC98 */ sc_vtb_clear(&scp->scr, sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1); sc_set_border(scp, 0); dirx = (scp->xpos ? 1 : -1); diry = (scp->ypos ? scp->xsize : -scp->xsize); for (f=0; f< messagelen; f++) savs[f] = scp->xpos + scp->ypos*scp->xsize; sc_vtb_putc(&scp->scr, savs[0], sc->scr_map[*save], (FG_LIGHTGREY | BG_BLACK) << 8); blanked = 1; } if (blanked++ < 4) return 0; blanked = 1; sc_vtb_putc(&scp->scr, savs[messagelen - 1], sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); for (f=messagelen-1; f > 0; f--) savs[f] = savs[f-1]; f = savs[0]; if ((f % scp->xsize) == 0 || (f % scp->xsize) == scp->xsize - 1 || (random() % 50) == 0) dirx = -dirx; if ((f / scp->xsize) == 0 || (f / scp->xsize) == scp->ysize - 1 || (random() % 20) == 0) diry = -diry; savs[0] += dirx + diry; for (f=messagelen-1; f>=0; f--) sc_vtb_putc(&scp->scr, savs[f], sc->scr_map[save[f]], (FG_LIGHTGREY | BG_BLACK) << 8); } else { #ifdef PC98 if (epson_machine_id == 0x20) { outb(0x43f, 0x42); outb(0x0c17, inb(0xc17) | 0x08); outb(0x43f, 0x40); } #endif /* PC98 */ blanked = 0; } return 0; }
/* * Alternate saver that got its inspiration from a well known utility * package for an inferior^H^H^H^H^H^Hfamous OS. */ static int star_saver(video_adapter_t *adp, int blank) { sc_softc_t *sc; scr_stat *scp; int cell, i; static u_char pattern[] = {"...........++++*** "}; #ifndef PC98 static char colors[] = {FG_DARKGREY, FG_LIGHTGREY, FG_WHITE, FG_LIGHTCYAN}; #else static char colors[] = {FG_BLUE, FG_LIGHTGREY, FG_LIGHTGREY, FG_CYAN}; #endif /* PC98 */ static u_short stars[NUM_STARS][2]; sc = sc_find_softc(adp, NULL); if (sc == NULL) return EAGAIN; scp = sc->cur_scp; if (blank) { if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return EAGAIN; if (!blanked) { #ifdef PC98 if (epson_machine_id == 0x20) { outb(0x43f, 0x42); outb(0x0c17, inb(0xc17) & ~0x08); outb(0x43f, 0x40); } #endif /* PC98 */ /* clear the screen and set the border color */ sc_vtb_clear(&scp->scr, sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1); sc_set_border(scp, 0); blanked = TRUE; for(i=0; i<NUM_STARS; i++) { stars[i][0] = random() % (scp->xsize*scp->ysize); stars[i][1] = 0; } } cell = random() % NUM_STARS; sc_vtb_putc(&scp->scr, stars[cell][0], sc->scr_map[pattern[stars[cell][1]]], colors[random()%sizeof(colors)] << 8); if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) { stars[cell][0] = random() % (scp->xsize*scp->ysize); stars[cell][1] = 0; } } else { #ifdef PC98 if (epson_machine_id == 0x20) { outb(0x43f, 0x42); outb(0x0c17, inb(0xc17) | 0x08); outb(0x43f, 0x40); } #endif /* PC98 */ blanked = FALSE; } return 0; }
static int daemon_saver(video_adapter_t *adp, int blank) { static int txpos = 10, typos = 10; static int txdir = -1, tydir = -1; static int dxpos = 0, dypos = 0; static int dxdir = 1, dydir = 1; static int moved_daemon = 0; static int xoff, yoff, toff; static int xlen, ylen, tlen; sc_softc_t *sc; scr_stat *scp; int min, max; sc = sc_find_softc(adp, NULL); if (sc == NULL) return EAGAIN; scp = sc->cur_scp; if (blank) { if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return EAGAIN; if (blanked == 0) { /* clear the screen and set the border color */ sc_vtb_clear(&scp->scr, sc->scr_map[0x20], ATTR(FG_LIGHTGREY | BG_BLACK)); vidd_set_hw_cursor(adp, -1, -1); sc_set_border(scp, 0); xlen = ylen = tlen = 0; } if (blanked++ < 2) return 0; blanked = 1; clear_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); clear_string(sc, txpos, typos, toff, message, tlen); if (++moved_daemon) { /* * The daemon picture may be off the screen, if * screen size is chagened while the screen * saver is inactive. Make sure the origin of * the picture is between min and max. */ if (scp->xsize <= DAEMON_MAX_WIDTH) { /* * If the screen width is too narrow, we * allow part of the picture go off * the screen so that the daemon won't * flip too often. */ min = scp->xsize - DAEMON_MAX_WIDTH - 10; max = 10; } else { min = 0; max = scp->xsize - DAEMON_MAX_WIDTH; } if (dxpos <= min) { dxpos = min; dxdir = 1; } else if (dxpos >= max) { dxpos = max; dxdir = -1; } if (scp->ysize <= DAEMON_MAX_HEIGHT) { min = scp->ysize - DAEMON_MAX_HEIGHT - 10; max = 10; } else { min = 0; max = scp->ysize - DAEMON_MAX_HEIGHT; } if (dypos <= min) { dypos = min; dydir = 1; } else if (dypos >= max) { dypos = max; dydir = -1; } moved_daemon = -1; dxpos += dxdir; dypos += dydir; /* clip the picture */ xoff = 0; xlen = DAEMON_MAX_WIDTH; if (dxpos + xlen <= 0) xlen = 0; else if (dxpos < 0) xoff = -dxpos; if (dxpos >= scp->xsize) xlen = 0; else if (dxpos + xlen > scp->xsize) xlen = scp->xsize - dxpos; yoff = 0; ylen = DAEMON_MAX_HEIGHT; if (dypos + ylen <= 0) ylen = 0; else if (dypos < 0) yoff = -dypos; if (dypos >= scp->ysize) ylen = 0; else if (dypos + ylen > scp->ysize) ylen = scp->ysize - dypos; } if (scp->xsize <= messagelen) { min = scp->xsize - messagelen - 10; max = 10; } else { min = 0; max = scp->xsize - messagelen; } if (txpos <= min) { txpos = min; txdir = 1; } else if (txpos >= max) { txpos = max; txdir = -1; } if (typos <= 0) { typos = 0; tydir = 1; } else if (typos >= scp->ysize - 1) { typos = scp->ysize - 1; tydir = -1; } txpos += txdir; typos += tydir; toff = 0; tlen = messagelen; if (txpos + tlen <= 0) tlen = 0; else if (txpos < 0) toff = -txpos; if (txpos >= scp->xsize) tlen = 0; else if (txpos + tlen > scp->xsize) tlen = scp->xsize - txpos; draw_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen); draw_string(sc, txpos, typos, toff, message, tlen); } else blanked = 0; return 0; }