예제 #1
0
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);
	}
}
예제 #2
0
파일: star_saver.c 프로젝트: 2asoft/freebsd
/*
 * 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;
}
예제 #3
0
int
sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
{
    scr_stat *scp;
    video_adapter_t *adp;
    video_info_t info;
    video_adapter_info_t adp_info;
    int error;
    int s;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    int ival;
#endif

    scp = SC_STAT(tp);
    if (scp == NULL)		/* tp == SC_MOUSE */
        return ENOIOCTL;
    adp = scp->sc->adp;
    if (adp == NULL)		/* shouldn't happen??? */
        return ENODEV;

    switch (cmd) {

    case CONS_CURRENTADP:	/* get current adapter index */
    case FBIO_ADAPTER:
        return fb_ioctl(adp, FBIO_ADAPTER, data);

    case CONS_CURRENT:  	/* get current adapter type */
    case FBIO_ADPTYPE:
        return fb_ioctl(adp, FBIO_ADPTYPE, data);

    case OLD_CONS_ADPINFO:	/* adapter information (old interface) */
        if (((old_video_adapter_t *)data)->va_index >= 0) {
            adp = vid_get_adapter(((old_video_adapter_t *)data)->va_index);
            if (adp == NULL)
                return ENODEV;
        }
        ((old_video_adapter_t *)data)->va_index = adp->va_index;
        ((old_video_adapter_t *)data)->va_type = adp->va_type;
        ((old_video_adapter_t *)data)->va_flags = adp->va_flags;
        ((old_video_adapter_t *)data)->va_crtc_addr = adp->va_crtc_addr;
        ((old_video_adapter_t *)data)->va_window = adp->va_window;
        ((old_video_adapter_t *)data)->va_window_size = adp->va_window_size;
        ((old_video_adapter_t *)data)->va_window_gran = adp->va_window_gran;
        ((old_video_adapter_t *)data)->va_buffer = adp->va_buffer;
        ((old_video_adapter_t *)data)->va_buffer_size = adp->va_buffer_size;
        ((old_video_adapter_t *)data)->va_mode = adp->va_mode;
        ((old_video_adapter_t *)data)->va_initial_mode = adp->va_initial_mode;
        ((old_video_adapter_t *)data)->va_initial_bios_mode
            = adp->va_initial_bios_mode;
        return 0;

    case OLD_CONS_ADPINFO2:	/* adapter information (yet another old I/F) */
        adp_info.va_index = ((old_video_adapter_info_t *)data)->va_index;
        if (adp_info.va_index >= 0) {
            adp = vid_get_adapter(adp_info.va_index);
            if (adp == NULL)
                return ENODEV;
        }
        error = fb_ioctl(adp, FBIO_ADPINFO, &adp_info);
        if (error == 0)
            bcopy(&adp_info, data, sizeof(old_video_adapter_info_t));
        return error;

    case CONS_ADPINFO:		/* adapter information */
    case FBIO_ADPINFO:
        if (((video_adapter_info_t *)data)->va_index >= 0) {
            adp = vid_get_adapter(((video_adapter_info_t *)data)->va_index);
            if (adp == NULL)
                return ENODEV;
        }
        return fb_ioctl(adp, FBIO_ADPINFO, data);

    case CONS_GET:      	/* get current video mode */
    case FBIO_GETMODE:
        *(int *)data = scp->mode;
        return 0;

#ifndef SC_NO_MODE_CHANGE
    case FBIO_SETMODE:		/* set video mode */
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        info.vi_mode = *(int *)data;
        error = fb_ioctl(adp, FBIO_MODEINFO, &info);
        if (error)
            return error;
        if (info.vi_flags & V_INFO_GRAPHICS)
            return sc_set_graphics_mode(scp, tp, *(int *)data);
        else
            return sc_set_text_mode(scp, tp, *(int *)data, 0, 0, 0, 0);
#endif /* SC_NO_MODE_CHANGE */

    case OLD_CONS_MODEINFO:	/* get mode information (old infterface) */
        info.vi_mode = ((old_video_info_t *)data)->vi_mode;
        error = fb_ioctl(adp, FBIO_MODEINFO, &info);
        if (error == 0)
            bcopy(&info, (old_video_info_t *)data, sizeof(old_video_info_t));
        return error;

    case CONS_MODEINFO:		/* get mode information */
    case FBIO_MODEINFO:
        return fb_ioctl(adp, FBIO_MODEINFO, data);

    case OLD_CONS_FINDMODE:	/* find a matching video mode (old interface) */
        bzero(&info, sizeof(info));
        bcopy((old_video_info_t *)data, &info, sizeof(old_video_info_t));
        error = fb_ioctl(adp, FBIO_FINDMODE, &info);
        if (error == 0)
            bcopy(&info, (old_video_info_t *)data, sizeof(old_video_info_t));
        return error;

    case CONS_FINDMODE:		/* find a matching video mode */
    case FBIO_FINDMODE:
        return fb_ioctl(adp, FBIO_FINDMODE, data);

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    case _IO('c', 104):
        ival = IOCPARM_IVAL(data);
        data = (caddr_t)&ival;
        /* FALLTHROUGH */
#endif
    case CONS_SETWINORG:	/* set frame buffer window origin */
    case FBIO_SETWINORG:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, FBIO_SETWINORG, data);

    case FBIO_GETWINORG:	/* get frame buffer window origin */
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, FBIO_GETWINORG, data);

    case FBIO_GETDISPSTART:
    case FBIO_SETDISPSTART:
    case FBIO_GETLINEWIDTH:
    case FBIO_SETLINEWIDTH:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

    case FBIO_GETPALETTE:
    case FBIO_SETPALETTE:
    case FBIOPUTCMAP:
    case FBIOGETCMAP:
    case FBIOGTYPE:
    case FBIOGATTR:
    case FBIOSVIDEO:
    case FBIOGVIDEO:
    case FBIOSCURSOR:
    case FBIOGCURSOR:
    case FBIOSCURPOS:
    case FBIOGCURPOS:
    case FBIOGCURMAX:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

    case FBIO_BLANK:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

#ifndef SC_NO_MODE_CHANGE
    /* generic text modes */
    case SW_TEXT_80x25:
    case SW_TEXT_80x30:
    case SW_TEXT_80x43:
    case SW_TEXT_80x50:
    case SW_TEXT_80x60:
    /* FALLTHROUGH */

    /* VGA TEXT MODES */
    case SW_VGA_C40x25:
    case SW_VGA_C80x25:
    case SW_VGA_M80x25:
    case SW_VGA_C80x30:
    case SW_VGA_M80x30:
    case SW_VGA_C80x50:
    case SW_VGA_M80x50:
    case SW_VGA_C80x60:
    case SW_VGA_M80x60:
    case SW_VGA_C90x25:
    case SW_VGA_M90x25:
    case SW_VGA_C90x30:
    case SW_VGA_M90x30:
    case SW_VGA_C90x43:
    case SW_VGA_M90x43:
    case SW_VGA_C90x50:
    case SW_VGA_M90x50:
    case SW_VGA_C90x60:
    case SW_VGA_M90x60:
    case SW_B40x25:
    case SW_C40x25:
    case SW_B80x25:
    case SW_C80x25:
    case SW_ENH_B40x25:
    case SW_ENH_C40x25:
    case SW_ENH_B80x25:
    case SW_ENH_C80x25:
    case SW_ENH_B80x43:
    case SW_ENH_C80x43:
    case SW_EGAMONO80x25:

#ifdef PC98
    /* PC98 TEXT MODES */
    case SW_PC98_80x25:
    case SW_PC98_80x30:
#endif
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0, 0);

    /* GRAPHICS MODES */
    case SW_BG320:
    case SW_BG640:
    case SW_CG320:
    case SW_CG320_D:
    case SW_CG640_E:
    case SW_CG640x350:
    case SW_ENH_CG640:
    case SW_BG640x480:
    case SW_CG640x480:
    case SW_VGA_CG320:
    case SW_VGA_MODEX:
#ifdef PC98
    /* PC98 GRAPHICS MODES */
    case SW_PC98_EGC640x400:
    case SW_PC98_PEGC640x400:
    case SW_PC98_PEGC640x480:
#endif
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        return sc_set_graphics_mode(scp, tp, cmd & 0xff);
#endif /* SC_NO_MODE_CHANGE */

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    case _IO('K', 10):
        ival = IOCPARM_IVAL(data);
        data = (caddr_t)&ival;
        /* FALLTHROUGH */
#endif
    case KDSETMODE:     	/* set current mode of this (virtual) console */
        switch (*(int *)data) {
        case KD_TEXT:   	/* switch to TEXT (known) mode */
            /*
             * If scp->mode is of graphics modes, we don't know which
             * text mode to switch back to...
             */
            if (scp->status & GRAPHICS_MODE)
                return EINVAL;
            /* restore fonts & palette ! */
#if 0
#ifndef SC_NO_FONT_LOADING
            if (ISFONTAVAIL(adp->va_flags)
                    && !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
                /*
                 * FONT KLUDGE
                 * Don't load fonts for now... XXX
                 */
                if (scp->sc->fonts_loaded & FONT_8)
                    sc_load_font(scp, 0, 8, 8, scp->sc->font_8, 0, 256);
            if (scp->sc->fonts_loaded & FONT_14)
                sc_load_font(scp, 0, 14, 8, scp->sc->font_14, 0, 256);
            if (scp->sc->fonts_loaded & FONT_16)
                sc_load_font(scp, 0, 16, 8, scp->sc->font_16, 0, 256);
        }
#endif /* SC_NO_FONT_LOADING */
#endif

#ifndef SC_NO_PALETTE_LOADING
        vidd_load_palette(adp, scp->sc->palette);
#endif

#ifndef PC98
        /* move hardware cursor out of the way */
        vidd_set_hw_cursor(adp, -1, -1);
#endif

    /* FALLTHROUGH */

    case KD_TEXT1:  	/* switch to TEXT (known) mode */
        /*
         * If scp->mode is of graphics modes, we don't know which
         * text/pixel mode to switch back to...
         */
        if (scp->status & GRAPHICS_MODE)
            return EINVAL;
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
#ifndef PC98
        scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
        splx(s);
        /* no restore fonts & palette */
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
        sc_clear_screen(scp);
        scp->status &= ~UNKNOWN_MODE;
#else /* PC98 */
        scp->status &= ~UNKNOWN_MODE;
        /* no restore fonts & palette */
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
        sc_clear_screen(scp);
        splx(s);
#endif /* PC98 */
        return 0;

#ifdef SC_PIXEL_MODE
    case KD_PIXEL:		/* pixel (raster) display */
        if (!(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
            return EINVAL;
        if (scp->status & GRAPHICS_MODE)
            return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
                                     scp->font_size, scp->font_width);
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
        scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
        splx(s);
        if (scp == scp->sc->cur_scp) {
            set_mode(scp);
#ifndef SC_NO_PALETTE_LOADING
            vidd_load_palette(adp, scp->sc->palette);
#endif
        }
        sc_clear_screen(scp);
        scp->status &= ~UNKNOWN_MODE;
        return 0;
#endif /* SC_PIXEL_MODE */

    case KD_GRAPHICS:	/* switch to GRAPHICS (unknown) mode */
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
        scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
        splx(s);
#ifdef PC98
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
#endif
        return 0;

    default:
        return EINVAL;
    }
    /* NOT REACHED */

#ifdef SC_PIXEL_MODE
case KDRASTER:		/* set pixel (raster) display mode */
    if (ISUNKNOWNSC(scp) || ISTEXTSC(scp))
        return ENODEV;
    return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
                             ((int *)data)[2], 8);
#endif /* SC_PIXEL_MODE */

case KDGETMODE:     	/* get current mode of this (virtual) console */
    /*
     * From the user program's point of view, KD_PIXEL is the same
     * as KD_TEXT...
     */
    *data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
    return 0;

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 13):
    ival = IOCPARM_IVAL(data);
    data = (caddr_t)&ival;
    /* FALLTHROUGH */
#endif
case KDSBORDER:     	/* set border color of this (virtual) console */
    scp->border = *(int *)data;
    if (scp == scp->sc->cur_scp)
        sc_set_border(scp, scp->border);
    return 0;
}
예제 #4
0
int
sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
                  int fontsize, int fontwidth)
{
#ifndef SC_PIXEL_MODE
    return ENODEV;
#else
    video_info_t info;
    u_char *font;
    int prev_ysize;
    int error;
    int s;

    if (vidd_get_info(scp->sc->adp, scp->mode, &info))
        return ENODEV;		/* this shouldn't happen */

    /* adjust argument values */
    if (fontsize <= 0)
        fontsize = info.vi_cheight;
    if (fontsize < 14) {
        fontsize = 8;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_8))
            return EINVAL;
        font = scp->sc->font_8;
#else
        font = NULL;
#endif
    } else if (fontsize >= 16) {
        fontsize = 16;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_16))
            return EINVAL;
        font = scp->sc->font_16;
#else
        font = NULL;
#endif
    } else {
        fontsize = 14;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_14))
            return EINVAL;
        font = scp->sc->font_14;
#else
        font = NULL;
#endif
    }
    if (xsize <= 0)
        xsize = info.vi_width/8;
    if (ysize <= 0)
        ysize = info.vi_height/fontsize;

    if ((info.vi_width < xsize*8) || (info.vi_height < ysize*fontsize))
        return EINVAL;

    /*
     * We currently support the following graphic modes:
     *
     * - 4 bpp planar modes whose memory size does not exceed 64K
     * - 15, 16, 24 and 32 bpp linear modes
     */

    if (info.vi_mem_model == V_INFO_MM_PLANAR) {
        if (info.vi_planes != 4)
            return ENODEV;

        /*
         * A memory size >64K requires bank switching to access the entire
         * screen. XXX
         */

        if (info.vi_width * info.vi_height / 8 > info.vi_window_size)
            return ENODEV;
    } else if (info.vi_mem_model == V_INFO_MM_DIRECT) {
        if (!(info.vi_flags & V_INFO_LINEAR) &&
                (info.vi_depth != 15) && (info.vi_depth != 16) &&
                (info.vi_depth != 24) && (info.vi_depth != 32))
            return ENODEV;
    } else
        return ENODEV;

    /* stop screen saver, etc */
    s = spltty();
    if ((error = sc_clean_up(scp))) {
        splx(s);
        return error;
    }

    if (sc_render_match(scp, scp->sc->adp->va_name, PIXEL_MODE) == NULL) {
        splx(s);
        return ENODEV;
    }

#if 0
    if (scp->tsw)
        (*scp->tsw->te_term)(scp, scp->ts);
    scp->tsw = NULL;
    scp->ts = NULL;
#endif

    /* set up scp */
#ifndef SC_NO_HISTORY
    if (scp->history != NULL)
        sc_hist_save(scp);
#endif
    prev_ysize = scp->ysize;
    scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
    scp->status &= ~(GRAPHICS_MODE | MOUSE_VISIBLE);
    scp->xsize = xsize;
    scp->ysize = ysize;
    scp->xoff = (scp->xpixel/8 - xsize)/2;
    scp->yoff = (scp->ypixel/fontsize - ysize)/2;
    scp->font = font;
    scp->font_size = fontsize;
    scp->font_width = fontwidth;

    /* allocate buffers */
    sc_alloc_scr_buffer(scp, TRUE, TRUE);
    sc_init_emulator(scp, NULL);
#ifndef SC_NO_CUTPASTE
    sc_alloc_cut_buffer(scp, FALSE);
#endif
#ifndef SC_NO_HISTORY
    sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
#endif
    splx(s);

    if (scp == scp->sc->cur_scp) {
        sc_set_border(scp, scp->border);
        sc_set_cursor_image(scp);
    }

    scp->status &= ~UNKNOWN_MODE;

    if (tp == NULL)
        return 0;
    if (tp->t_winsize.ws_col != scp->xsize
            || tp->t_winsize.ws_row != scp->ysize) {
        tp->t_winsize.ws_col = scp->xsize;
        tp->t_winsize.ws_row = scp->ysize;
        if (tp->t_pgrp != NULL) {
            PGRP_LOCK(tp->t_pgrp);
            pgsignal(tp->t_pgrp, SIGWINCH, 1);
            PGRP_UNLOCK(tp->t_pgrp);
        }
    }

    return 0;
#endif /* SC_PIXEL_MODE */
}
예제 #5
0
파일: snake_saver.c 프로젝트: MarginC/kame
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;
}
예제 #6
0
int
sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize, 
		  int fontsize, int fontwidth)
{
#ifndef SC_PIXEL_MODE
    return ENODEV;
#else
    video_info_t info;
    ksiginfo_t ksi;
    u_char *font;
    int prev_ysize;
    int error;
    int s;

    if (vidd_get_info(scp->sc->adp, scp->mode, &info))
	return ENODEV;		/* this shouldn't happen */

    /* adjust argument values */
    if (fontsize <= 0)
	fontsize = info.vi_cheight;
    if (fontsize < 14)
	fontsize = 8;
    else if (fontsize >= 16)
	fontsize = 16;
    else
	fontsize = 14;
#ifndef SC_NO_FONT_LOADING
    switch (fontsize) {
    case 8:
	if ((scp->sc->fonts_loaded & FONT_8) == 0)
	    return (EINVAL);
	font = scp->sc->font_8;
	break;
    case 14:
	if ((scp->sc->fonts_loaded & FONT_14) == 0)
	    return (EINVAL);
	font = scp->sc->font_14;
	break;
    case 16:
	if ((scp->sc->fonts_loaded & FONT_16) == 0)
	    return (EINVAL);
	font = scp->sc->font_16;
	break;
    }
#else
    font = NULL;
#endif
    if (xsize <= 0)
	xsize = info.vi_width/8;
    if (ysize <= 0)
	ysize = info.vi_height/fontsize;

    if ((info.vi_width < xsize*8) || (info.vi_height < ysize*fontsize))
	return EINVAL;

    if (!sc_support_pixel_mode(&info))
	return ENODEV;

    /* stop screen saver, etc */
    s = spltty();
    if ((error = sc_clean_up(scp))) {
	splx(s);
	return error;
    }

    if (sc_render_match(scp, scp->sc->adp->va_name, PIXEL_MODE) == NULL) {
	splx(s);
	return ENODEV;
    }

#if 0
    if (scp->tsw)
	(*scp->tsw->te_term)(scp, scp->ts);
    scp->tsw = NULL;
    scp->ts = NULL;
#endif

    /* set up scp */
#ifndef SC_NO_HISTORY
    if (scp->history != NULL)
	sc_hist_save(scp);
#endif
    prev_ysize = scp->ysize;
    scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
    scp->status &= ~(GRAPHICS_MODE | MOUSE_VISIBLE);
    scp->xsize = xsize;
    scp->ysize = ysize;
    scp->xoff = (scp->xpixel/8 - xsize)/2;
    scp->yoff = (scp->ypixel/fontsize - ysize)/2;
    scp->font = font;
    scp->font_size = fontsize;
    scp->font_width = fontwidth;

    /* allocate buffers */
    sc_alloc_scr_buffer(scp, TRUE, TRUE);
    sc_init_emulator(scp, NULL);
#ifndef SC_NO_CUTPASTE
    sc_alloc_cut_buffer(scp, FALSE);
#endif
#ifndef SC_NO_HISTORY
    sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
#endif
    splx(s);

    if (scp == scp->sc->cur_scp) {
	sc_set_border(scp, scp->border);
	sc_set_cursor_image(scp);
    }

    scp->status &= ~UNKNOWN_MODE;

    if (tp == NULL)
	return 0;
    if (tp->t_winsize.ws_col != scp->xsize
	|| tp->t_winsize.ws_row != scp->ysize) {
	tp->t_winsize.ws_col = scp->xsize;
	tp->t_winsize.ws_row = scp->ysize;
	if (tp->t_pgrp != NULL) {
	    ksiginfo_init(&ksi);
	    ksi.ksi_signo = SIGWINCH;
	    ksi.ksi_code = SI_KERNEL;
	    PGRP_LOCK(tp->t_pgrp);
	    pgsignal(tp->t_pgrp, SIGWINCH, 1, &ksi);
	    PGRP_UNLOCK(tp->t_pgrp);
	}
    }

    return 0;
#endif /* SC_PIXEL_MODE */
}
예제 #7
0
파일: star_saver.c 프로젝트: MarginC/kame
/*
 * 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;
}
예제 #8
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;
}