Esempio n. 1
0
static int
warp_init(video_adapter_t *adp)
{
	video_info_t info;
	int i;
	
	if (!vidd_get_info(adp, M_VGA_CG320, &info)) {
		scrmode = M_VGA_CG320;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) {
		scrmode = M_PC98_PEGC640x480;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) {
		scrmode = M_PC98_PEGC640x400;
	} else {
		log(LOG_NOTICE,
		    "%s: the console does not support M_VGA_CG320\n",
		    SAVER_NAME);
		return (ENODEV);
	}
	
	scrw = info.vi_width;
	scrh = info.vi_height;

	/* randomize the star field */
	for (i = 0; i < STARS; i++)
		star[i] = random() % (scrw * scrh);
	
	return (0);
}
Esempio n. 2
0
static int
logo_init(video_adapter_t *adp)
{
	video_info_t info;
	
	if (!vidd_get_info(adp, M_VESA_CG800x600, &info)) {
		scrmode = M_VESA_CG800x600;
	} else if (!vidd_get_info(adp, M_VGA_CG320, &info)) {
		scrmode = M_VGA_CG320;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) {
		scrmode = M_PC98_PEGC640x480;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) {
		scrmode = M_PC98_PEGC640x400;
	} else {
		log(LOG_NOTICE,
		    "%s: the console does not support M_VGA_CG320\n",
		    SAVER_NAME);
		return (ENODEV);
	}
	
	scrw = info.vi_width;
	scrh = info.vi_height;
	
	return (0);
}
Esempio n. 3
0
static int
rain_init(video_adapter_t *adp)
{
	video_info_t info;
	int i;
	
	if (!vidd_get_info(adp, M_VGA_CG320, &info)) {
		scrmode = M_VGA_CG320;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) {
		scrmode = M_PC98_PEGC640x480;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) {
		scrmode = M_PC98_PEGC640x400;
	} else {
		log(LOG_NOTICE,
		    "%s: the console does not support M_VGA_CG320\n",
		    SAVER_NAME);
		return (ENODEV);
	}
	
	scrw = info.vi_width;
	scrh = info.vi_height;

	/* intialize the palette */
	for (i = 1; i < MAX; i++)
		rain_pal[BLUE(i)] = rain_pal[BLUE(i - 1)] + INCREMENT;
	
	return (0);
}
Esempio n. 4
0
int
sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
{
#ifdef SC_NO_MODE_CHANGE
    return ENODEV;
#else
    video_info_t info;
    struct winsize wsz;
    int error;
    int s;

    if (vidd_get_info(scp->sc->adp, 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, GRAPHICS_MODE) == NULL) {
	splx(s);
	return ENODEV;
    }

    /* set up scp */
    scp->status |= (UNKNOWN_MODE | GRAPHICS_MODE | MOUSE_HIDDEN);
    scp->status &= ~(PIXEL_MODE | MOUSE_VISIBLE);
    scp->mode = mode;
    /*
     * Don't change xsize and ysize; preserve the previous vty
     * and history buffers.
     */
    scp->xoff = 0;
    scp->yoff = 0;
    scp->xpixel = info.vi_width;
    scp->ypixel = info.vi_height;
    scp->font = NULL;
    scp->font_size = 0;
#ifndef SC_NO_SYSMOUSE
    /* move the mouse cursor at the center of the screen */
    sc_mouse_move(scp, scp->xpixel / 2, scp->ypixel / 2);
#endif
    sc_init_emulator(scp, NULL);
    splx(s);

    if (scp == scp->sc->cur_scp)
	set_mode(scp);
    /* clear_graphics();*/
    scp->status &= ~UNKNOWN_MODE;

    if (tp == NULL)
	return 0;
    wsz.ws_col = scp->xsize;
    wsz.ws_row = scp->ysize;
    tty_set_winsize(tp, &wsz);
    return 0;
#endif /* SC_NO_MODE_CHANGE */
}
Esempio n. 5
0
static int
fire_init(video_adapter_t *adp)
{
	video_info_t info;
	int i, red, green, blue;

	if (!vidd_get_info(adp, M_VGA_CG320, &info)) {
		scrmode = M_VGA_CG320;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) {
		scrmode = M_PC98_PEGC640x480;
	} else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) {
		scrmode = M_PC98_PEGC640x400;
	} else {
		log(LOG_NOTICE,
		    "%s: the console does not support M_VGA_CG320\n",
		    SAVER_NAME);
		return (ENODEV);
	}
    
	scrw = info.vi_width;
	scrh = info.vi_height;

	buf = (u_char *)malloc(scrw * (scrh + 1), M_DEVBUF, M_NOWAIT);
	if (buf) {
		bzero(buf, scrw * (scrh + 1));
	} else {
		log(LOG_NOTICE,
		    "%s: buffer allocation is failed\n",
		    SAVER_NAME);
		return (ENODEV);
	}

	/* intialize the palette */
	red = green = blue = 0;
	for (i = 0; i < 256; i++) {
		red++;
		if (red > 128)
			green += 2;
		fire_pal[RED(i)] = red;
		fire_pal[GREEN(i)] = green;
		fire_pal[BLUE(i)] = blue;
	}

	return (0);
}
Esempio n. 6
0
static int
pcx_start(video_adapter_t *adp)
{
	static int modes[] = {
		M_VGA_CG320,
		M_VESA_CG640x480,
		M_VESA_CG800x600,
		M_VESA_CG1024x768,
		-1,
	};
	video_info_t info;
	int i;

	if (pcx_decoder.data == NULL ||
	    pcx_decoder.data_size <= 0 ||
	    pcx_init(pcx_decoder.data, pcx_decoder.data_size))
		return (ENODEV);

	if (bootverbose)
		printf("splash_pcx: image good:\n"
		    "  width = %d\n"
		    "  height = %d\n"
		    "  depth = %d\n"
		    "  planes = %d\n",
		    pcx_info.width, pcx_info.height,
		    pcx_info.bpp, pcx_info.planes);

	for (i = 0; modes[i] >= 0; ++i) {
		if (vidd_get_info(adp, modes[i], &info) != 0)
			continue;
		if (bootverbose)
			printf("splash_pcx: considering mode %d:\n"
			    "  vi_width = %d\n"
			    "  vi_height = %d\n"
			    "  vi_depth = %d\n"
			    "  vi_planes = %d\n",
			    modes[i],
			    info.vi_width, info.vi_height,
			    info.vi_depth, info.vi_planes);
		if (info.vi_width >= pcx_info.width
		    && info.vi_height >= pcx_info.height
		    && info.vi_depth == pcx_info.bpp
		    && info.vi_planes == pcx_info.planes)
			break;
	}

	splash_mode = modes[i];
	if (splash_mode == -1)
		return (ENODEV);
	if (bootverbose)
		printf("splash_pcx: selecting mode %d\n", splash_mode);
	return (0);
}
static int 
bmp_start(video_adapter_t *adp)
{
    /* currently only 256-color modes are supported XXX */
    static int		modes[] = {
#ifdef PC98
    			/*
			 * As 640x400 doesn't generally look great,
			 * it's least preferred here.
			 */
			M_PC98_PEGC640x400,
			M_PC98_PEGC640x480,
			M_PC98_EGC640x400,
#else
			M_VESA_CG640x480,
			M_VESA_CG800x600,
			M_VESA_CG1024x768,
			M_CG640x480,
    			/*
			 * As 320x200 doesn't generally look great,
			 * it's least preferred here.
			 */
			M_VGA_CG320,
#endif		
			-1,
    };
    video_info_t 	info;
    int			i;

    if ((bmp_decoder.data == NULL) || (bmp_decoder.data_size <= 0)) {
	printf("splash_bmp: No bitmap file found\n");
	return ENODEV;
    }
    for (i = 0; modes[i] >= 0; ++i) {
	if ((vidd_get_info(adp, modes[i], &info) == 0) && 
	    (bmp_Init((u_char *)bmp_decoder.data, info.vi_width,
		      info.vi_height, info.vi_depth) == 0))
	    break;
    }
    splash_mode = modes[i];
    if (splash_mode < 0)
	printf("splash_bmp: No appropriate video mode found\n");
    if (bootverbose)
	printf("bmp_start(): splash_mode:%d\n", splash_mode);
    return ((splash_mode < 0) ? ENODEV : 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 */
}
int
sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
                 int fontsize, int fontwidth)
{
    video_info_t info;
    u_char *font;
    int prev_ysize;
    int error;
    int s;

    if (vidd_get_info(scp->sc->adp, mode, &info))
        return ENODEV;

    /* adjust argument values */
    if (fontwidth <= 0)
        fontwidth = info.vi_cwidth;
    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))
        xsize = info.vi_width;
    if ((ysize <= 0) || (ysize > info.vi_height))
        ysize = info.vi_height;

    /* 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, 0) == NULL) {
        splx(s);
        return ENODEV;
    }

    /* set up scp */
#ifndef SC_NO_HISTORY
    if (scp->history != NULL)
        sc_hist_save(scp);
#endif
    prev_ysize = scp->ysize;
    /*
     * This is a kludge to fend off scrn_update() while we
     * muck around with scp. XXX
     */
    scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
    scp->status &= ~(GRAPHICS_MODE | PIXEL_MODE | MOUSE_VISIBLE);
    scp->mode = mode;
    scp->xsize = xsize;
    scp->ysize = ysize;
    scp->xoff = 0;
    scp->yoff = 0;
    scp->xpixel = scp->xsize*8;
    scp->ypixel = scp->ysize*fontsize;
    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)
        set_mode(scp);
    scp->status &= ~UNKNOWN_MODE;

    if (tp == NULL)
        return 0;
    DPRINTF(5, ("ws_*size (%d,%d), size (%d,%d)\n",
                tp->t_winsize.ws_col, tp->t_winsize.ws_row, scp->xsize, scp->ysize));
    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;

        tty_signal_pgrp(tp, SIGWINCH);
    }

    return 0;
}
Esempio n. 10
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 */
}