vidcontrol.c revision 39287
12089Ssos/*-
216565Ssos * Copyright (c) 1994-1996 S�ren Schmidt
32089Ssos * All rights reserved.
42089Ssos *
52089Ssos * Redistribution and use in source and binary forms, with or without
62089Ssos * modification, are permitted provided that the following conditions
72089Ssos * are met:
82089Ssos * 1. Redistributions of source code must retain the above copyright
95994Ssos *    notice, this list of conditions and the following disclaimer,
105994Ssos *    in this position and unchanged.
112089Ssos * 2. Redistributions in binary form must reproduce the above copyright
122089Ssos *    notice, this list of conditions and the following disclaimer in the
132089Ssos *    documentation and/or other materials provided with the distribution.
142089Ssos * 3. The name of the author may not be used to endorse or promote products
152089Ssos *    derived from this software withough specific prior written permission
162089Ssos *
172089Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
182089Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
192089Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
202089Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
212089Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
222089Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232089Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242089Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252089Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
262089Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272089Ssos */
282089Ssos
2930764Scharnier#ifndef lint
3030764Scharnierstatic const char rcsid[] =
3139287Ssos	"$Id: vidcontrol.c,v 1.19 1998/07/14 10:32:27 bde Exp $";
3230764Scharnier#endif /* not lint */
3330764Scharnier
342089Ssos#include <ctype.h>
3530764Scharnier#include <err.h>
362089Ssos#include <stdio.h>
3723457Sbrian#include <stdlib.h>
3830764Scharnier#include <string.h>
3923702Speter#include <unistd.h>
402089Ssos#include <machine/console.h>
412089Ssos#include <sys/errno.h>
422089Ssos#include "path.h"
4323457Sbrian#include "decode.h"
442089Ssos
452089Ssoschar 	legal_colors[16][16] = {
462089Ssos	"black", "blue", "green", "cyan",
472089Ssos	"red", "magenta", "brown", "white",
482089Ssos	"grey", "lightblue", "lightgreen", "lightcyan",
492089Ssos	"lightred", "lightmagenta", "yellow", "lightwhite"
506628Ssos};
512089Ssosint 	hex = 0;
526047Ssosint 	number;
532089Ssoschar 	letter;
542089Ssosstruct 	vid_info info;
552089Ssos
562089Ssos
5730764Scharnierstatic void
586628Ssosusage()
596628Ssos{
6030764Scharnier	fprintf(stderr, "%s\n%s\n%s\n",
6130764Scharnier"usage: vidcontrol [-r fg bg] [-b color] [-c appearance] [-d] [-l scrmap]",
6230764Scharnier"                  [-L] [-m on|off] [-f size file] [-s number] [-t N|off]",
6330764Scharnier"                  [-x] [mode] [fgcol [bgcol]] [show]");
6430764Scharnier	exit(1);
656628Ssos}
666628Ssos
672089Ssoschar *
682089Ssosnextarg(int ac, char **av, int *indp, int oc)
692089Ssos{
702089Ssos	if (*indp < ac)
712089Ssos		return(av[(*indp)++]);
7230764Scharnier	errx(1, "option requires two arguments -- %c", oc);
732089Ssos	return("");
742089Ssos}
752089Ssos
762089Ssoschar *
772089Ssosmkfullname(const char *s1, const char *s2, const char *s3)
782089Ssos{
796628Ssos	static char *buf = NULL;
806628Ssos	static int bufl = 0;
816628Ssos	int f;
822089Ssos
832089Ssos	f = strlen(s1) + strlen(s2) + strlen(s3) + 1;
842089Ssos	if (f > bufl)
852089Ssos		if (buf)
862089Ssos			buf = (char *)realloc(buf, f);
872089Ssos		else
882089Ssos			buf = (char *)malloc(f);
892089Ssos	if (!buf) {
902089Ssos		bufl = 0;
912089Ssos		return(NULL);
922089Ssos	}
932089Ssos
942089Ssos	bufl = f;
952089Ssos	strcpy(buf, s1);
962089Ssos	strcat(buf, s2);
972089Ssos	strcat(buf, s3);
982089Ssos	return(buf);
992089Ssos}
1002089Ssos
1012089Ssosvoid
1022089Ssosload_scrnmap(char *filename)
1032089Ssos{
10423457Sbrian	FILE *fd = 0;
1052089Ssos	int i, size;
1062089Ssos	char *name;
1072089Ssos	scrmap_t scrnmap;
1082089Ssos	char *prefix[]  = {"", "", SCRNMAP_PATH, SCRNMAP_PATH, NULL};
1092089Ssos	char *postfix[] = {"", ".scm", "", ".scm"};
1102089Ssos
1112089Ssos	for (i=0; prefix[i]; i++) {
1122089Ssos		name = mkfullname(prefix[i], filename, postfix[i]);
11323457Sbrian		fd = fopen(name, "r");
11423457Sbrian		if (fd)
1152089Ssos			break;
1162089Ssos	}
1172089Ssos	if (fd == NULL) {
11830764Scharnier		warn("screenmap file not found");
1192089Ssos		return;
1202089Ssos	}
1212089Ssos	size = sizeof(scrnmap);
12223457Sbrian	if (decode(fd, (char *)&scrnmap) != size) {
1232089Ssos		rewind(fd);
1242089Ssos		if (fread(&scrnmap, 1, size, fd) != size) {
12530764Scharnier			warnx("bad screenmap file");
12623457Sbrian			fclose(fd);
1272089Ssos			return;
1282089Ssos		}
1292089Ssos	}
1302089Ssos	if (ioctl(0, PIO_SCRNMAP, &scrnmap) < 0)
13130764Scharnier		warn("can't load screenmap");
13223457Sbrian	fclose(fd);
1332089Ssos}
1342089Ssos
1352089Ssosvoid
1362089Ssosload_default_scrnmap()
1372089Ssos{
1386628Ssos	scrmap_t scrnmap;
1392089Ssos	int i;
1402089Ssos
1412089Ssos	for (i=0; i<256; i++)
1422089Ssos		*((char*)&scrnmap + i) = i;
1432089Ssos	if (ioctl(0, PIO_SCRNMAP, &scrnmap) < 0)
14430764Scharnier		warn("can't load default screenmap");
1452089Ssos}
1462089Ssos
1472089Ssosvoid
1482089Ssosprint_scrnmap()
1492089Ssos{
1502089Ssos	unsigned char map[256];
1512089Ssos	int i;
1522089Ssos
1532089Ssos	if (ioctl(0, GIO_SCRNMAP, &map) < 0) {
15430764Scharnier		warn("getting screenmap");
1552089Ssos		return;
1562089Ssos	}
1572089Ssos	for (i=0; i<sizeof(map); i++) {
1582089Ssos		if (i > 0 && i % 16 == 0)
1592089Ssos			fprintf(stdout, "\n");
1602089Ssos		if (hex)
1618857Srgrimes			fprintf(stdout, " %02x", map[i]);
1622089Ssos		else
1632089Ssos			fprintf(stdout, " %03d", map[i]);
1642089Ssos	}
1652089Ssos	fprintf(stdout, "\n");
1662089Ssos
1672089Ssos}
1682089Ssos
1698857Srgrimesvoid
1702089Ssosload_font(char *type, char *filename)
1712089Ssos{
17223457Sbrian	FILE	*fd = 0;
17337636Sbde	int	i, size;
17437636Sbde	unsigned long io;
1752089Ssos	char	*name, *fontmap;
1762089Ssos	char	*prefix[]  = {"", "", FONT_PATH, FONT_PATH, NULL};
1772089Ssos	char	*postfix[] = {"", ".fnt", "", ".fnt"};
1782089Ssos
1792089Ssos	for (i=0; prefix[i]; i++) {
1802089Ssos		name = mkfullname(prefix[i], filename, postfix[i]);
18123457Sbrian		fd = fopen(name, "r");
18223457Sbrian		if (fd)
1832089Ssos			break;
1842089Ssos	}
1852089Ssos	if (fd == NULL) {
18630764Scharnier		warn("font file not found");
1872089Ssos		return;
1882089Ssos	}
1892089Ssos	if (!strcmp(type, "8x8")) {
1902089Ssos		size = 8*256;
1912089Ssos		io = PIO_FONT8x8;
1922089Ssos	}
1932089Ssos	else if (!strcmp(type, "8x14")) {
1942089Ssos		size = 14*256;
1952089Ssos		io = PIO_FONT8x14;
1962089Ssos	}
1972089Ssos	else if (!strcmp(type, "8x16")) {
1982089Ssos		size = 16*256;
1992089Ssos		io = PIO_FONT8x16;
2002089Ssos	}
2012089Ssos	else {
20230764Scharnier		warn("bad font size specification");
20323457Sbrian		fclose(fd);
2042089Ssos		return;
2052089Ssos	}
2062089Ssos	fontmap = (char*) malloc(size);
2072089Ssos	if (decode(fd, fontmap) != size) {
2082089Ssos		rewind(fd);
2092089Ssos		if (fread(fontmap, 1, size, fd) != size) {
21030764Scharnier			warnx("bad font file");
21123457Sbrian			fclose(fd);
2122089Ssos			free(fontmap);
2132089Ssos			return;
2142089Ssos		}
2152089Ssos	}
2162089Ssos	if (ioctl(0, io, fontmap) < 0)
21730764Scharnier		warn("can't load font");
21823457Sbrian	fclose(fd);
2192089Ssos	free(fontmap);
2202089Ssos}
2212089Ssos
2222089Ssosvoid
2232089Ssosset_screensaver_timeout(char *arg)
2242089Ssos{
2252089Ssos	int nsec;
2262089Ssos
2272089Ssos	if (!strcmp(arg, "off"))
2282089Ssos		nsec = 0;
2292089Ssos	else {
2302089Ssos		nsec = atoi(arg);
2312089Ssos		if ((*arg == '\0') || (nsec < 1)) {
23230764Scharnier			warnx("argument must be a positive number");
2332089Ssos			return;
2342089Ssos		}
2352089Ssos	}
2362089Ssos	if (ioctl(0, CONS_BLANKTIME, &nsec) == -1)
23730764Scharnier		warn("setting screensaver period");
2382089Ssos}
2392089Ssos
2402089Ssosvoid
2415536Ssosset_cursor_type(char *appearence)
2422089Ssos{
2435536Ssos	int type;
2442089Ssos
2456230Ssos	if (!strcmp(appearence, "normal"))
2466230Ssos		type = 0;
2476230Ssos	else if (!strcmp(appearence, "blink"))
2485536Ssos		type = 1;
2496230Ssos	else if (!strcmp(appearence, "destructive"))
2506230Ssos		type = 3;
2515536Ssos	else {
25230764Scharnier		warnx("argument to -c must be normal, blink or destructive");
2532089Ssos		return;
2542089Ssos	}
2555536Ssos	ioctl(0, CONS_CURSORTYPE, &type);
2562089Ssos}
2572089Ssos
25823457Sbrianvoid
2592089Ssosvideo_mode(int argc, char **argv, int *index)
2602089Ssos{
26137636Sbde	unsigned long mode;
26239287Ssos	int size[3];
2632089Ssos
2642089Ssos	if (*index < argc) {
2652784Ssos		if (!strcmp(argv[*index], "VGA_40x25"))
2662784Ssos			mode = SW_VGA_C40x25;
2672784Ssos		else if (!strcmp(argv[*index], "VGA_80x25"))
2682784Ssos			mode = SW_VGA_C80x25;
2695536Ssos		else if (!strcmp(argv[*index], "VGA_80x30"))
2705536Ssos			mode = SW_VGA_C80x30;
2712784Ssos		else if (!strcmp(argv[*index], "VGA_80x50"))
2722784Ssos			mode = SW_VGA_C80x50;
2735536Ssos		else if (!strcmp(argv[*index], "VGA_80x60"))
2745536Ssos			mode = SW_VGA_C80x60;
2752784Ssos		else if (!strcmp(argv[*index], "VGA_320x200"))
2762784Ssos			mode = SW_VGA_CG320;
2772784Ssos		else if (!strcmp(argv[*index], "EGA_80x25"))
2782784Ssos			mode = SW_ENH_C80x25;
2792784Ssos		else if (!strcmp(argv[*index], "EGA_80x43"))
2802784Ssos			mode = SW_ENH_C80x43;
28139287Ssos		else if (!strcmp(argv[*index], "VESA_132x25"))
28239287Ssos			mode = SW_VESA_C132x25;
28339287Ssos		else if (!strcmp(argv[*index], "VESA_132x43"))
28439287Ssos			mode = SW_VESA_C132x43;
28539287Ssos		else if (!strcmp(argv[*index], "VESA_132x50"))
28639287Ssos			mode = SW_VESA_C132x50;
28739287Ssos		else if (!strcmp(argv[*index], "VESA_132x60"))
28839287Ssos			mode = SW_VESA_C132x60;
28939287Ssos		else if (!strcmp(argv[*index], "VESA_800x600"))
29039287Ssos			mode = SW_VESA_800x600;
2912089Ssos		else
2922089Ssos			return;
2932089Ssos		if (ioctl(0, mode, NULL) < 0)
29430764Scharnier			warn("cannot set videomode");
29539287Ssos		if (mode == SW_VESA_800x600) {
29639287Ssos			size[0] = 80;	/* columns */
29739287Ssos			size[1] = 25;	/* rows */
29839287Ssos			size[2] = 16;	/* font size */
29939287Ssos			if (ioctl(0, KDRASTER, size))
30039287Ssos				warn("cannot activate raster display");
30139287Ssos		}
3022089Ssos		(*index)++;
3032089Ssos	}
3042089Ssos	return;
3052089Ssos}
3068857Srgrimes
3072089Ssosint
3082089Ssosget_color_number(char *color)
3092089Ssos{
3102089Ssos	int i;
3112089Ssos
3122089Ssos	for (i=0; i<16; i++)
3132089Ssos		if (!strcmp(color, legal_colors[i]))
3142089Ssos			return i;
3152089Ssos	return -1;
3162089Ssos}
3172089Ssos
31823457Sbrianvoid
3192089Ssosset_normal_colors(int argc, char **argv, int *index)
3202089Ssos{
3212089Ssos	int color;
3222089Ssos
3232089Ssos	if (*index < argc && (color = get_color_number(argv[*index])) != -1) {
3242089Ssos		(*index)++;
3252089Ssos		fprintf(stderr, "[=%dF", color);
3268857Srgrimes		if (*index < argc
3278857Srgrimes		    && (color = get_color_number(argv[*index])) != -1
3282089Ssos		    && color < 8) {
3292089Ssos			(*index)++;
3302089Ssos			fprintf(stderr, "[=%dG", color);
3312089Ssos		}
3322089Ssos	}
3332089Ssos}
3342089Ssos
33523457Sbrianvoid
3362089Ssosset_reverse_colors(int argc, char **argv, int *index)
3372089Ssos{
3382089Ssos	int color;
3392089Ssos
3402089Ssos	if ((color = get_color_number(argv[*(index)-1])) != -1) {
3412089Ssos		fprintf(stderr, "[=%dH", color);
3428857Srgrimes		if (*index < argc
3438857Srgrimes		    && (color = get_color_number(argv[*index])) != -1
3442089Ssos		    && color < 8) {
3452089Ssos			(*index)++;
3462089Ssos			fprintf(stderr, "[=%dI", color);
3472089Ssos		}
3482089Ssos	}
3492089Ssos}
3502089Ssos
35123457Sbrianvoid
35223457Sbrianset_console(char *arg)
35323457Sbrian{
35423457Sbrian	int n;
35523457Sbrian
35623457Sbrian	if( !arg || strspn(arg,"0123456789") != strlen(arg)) {
35730764Scharnier		warnx("bad console number");
35823457Sbrian		return;
35923457Sbrian	}
36023457Sbrian
36123457Sbrian	n = atoi(arg);
36223457Sbrian	if (n < 1 || n > 12) {
36330764Scharnier		warnx("console number out of range");
36423457Sbrian	} else if (ioctl(0,VT_ACTIVATE,(char *)n) == -1)
36530764Scharnier		warn("ioctl(VT_ACTIVATE)");
36623457Sbrian}
36723457Sbrian
36823457Sbrianvoid
3692089Ssosset_border_color(char *arg)
3702089Ssos{
3712089Ssos	int color;
3722089Ssos
3732089Ssos	if ((color = get_color_number(arg)) != -1) {
3742089Ssos		fprintf(stderr, "[=%dA", color);
3752089Ssos	}
3762089Ssos	else
3778857Srgrimes		usage();
3782089Ssos}
3792089Ssos
38016565Ssosvoid
38116565Ssosset_mouse(char *arg)
38216565Ssos{
38316565Ssos	struct mouse_info mouse;
38416565Ssos
38516565Ssos	if (!strcmp(arg, "on"))
38616565Ssos		mouse.operation = MOUSE_SHOW;
38716565Ssos	else if (!strcmp(arg, "off"))
38816565Ssos		mouse.operation = MOUSE_HIDE;
38916565Ssos	else {
39030764Scharnier		warnx("argument to -m must either on or off");
39116565Ssos		return;
39216565Ssos	}
39316565Ssos	ioctl(0, CONS_MOUSECTL, &mouse);
39416565Ssos}
39516565Ssos
39639287Ssosstatic char
39739287Ssos*adapter_name(int type)
39839287Ssos{
39939287Ssos    static struct {
40039287Ssos	int type;
40139287Ssos	char *name;
40239287Ssos    } names[] = {
40339287Ssos	{ KD_MONO,	"MDA" },
40439287Ssos	{ KD_HERCULES,	"Hercules" },
40539287Ssos	{ KD_CGA,	"CGA" },
40639287Ssos	{ KD_EGA,	"EGA" },
40739287Ssos	{ KD_VGA,	"VGA" },
40839287Ssos	{ KD_PC98,	"PC-98xx" },
40939287Ssos	{ -1,		"Unknown" },
41039287Ssos    };
41139287Ssos    int i;
41239287Ssos
41339287Ssos    for (i = 0; names[i].type != -1; ++i)
41439287Ssos	if (names[i].type == type)
41539287Ssos	    break;
41639287Ssos    return names[i].name;
41739287Ssos}
41839287Ssos
41923457Sbrianvoid
42039287Ssosshow_adapter_info(void)
42139287Ssos{
42239287Ssos	struct video_adapter ad;
42339287Ssos
42439287Ssos	ad.va_index = 0;
42539287Ssos	if (ioctl(0, CONS_ADPINFO, &ad)) {
42639287Ssos		warn("failed to obtain adapter information");
42739287Ssos		return;
42839287Ssos	}
42939287Ssos
43039287Ssos	printf("adapter %d:\n", ad.va_index);
43139287Ssos	printf("    type:%s%s (%d), flags:0x%08x, CRTC:0x%x\n",
43239287Ssos	       (ad.va_flags & V_ADP_VESA) ? "VESA " : "",
43339287Ssos	       adapter_name(ad.va_type), ad.va_type,
43439287Ssos	       ad.va_flags, ad.va_crtc_addr);
43539287Ssos	printf("    initial mode:%d, current mode:%d, BIOS mode:%d\n",
43639287Ssos	       ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
43739287Ssos}
43839287Ssos
43939287Ssosvoid
44039287Ssosshow_mode_info(void)
44139287Ssos{
44239287Ssos	struct video_info info;
44339287Ssos	char buf[80];
44439287Ssos	int mode;
44539287Ssos	int c;
44639287Ssos
44739287Ssos	printf("    mode#     flags   type    size       "
44839287Ssos	       "font      window      linear buffer\n");
44939287Ssos	printf("---------------------------------------"
45039287Ssos	       "---------------------------------------\n");
45139287Ssos	for (mode = 0; mode < M_VESA_MODE_MAX; ++mode) {
45239287Ssos		info.vi_mode = mode;
45339287Ssos		if (ioctl(0, CONS_MODEINFO, &info))
45439287Ssos			continue;
45539287Ssos
45639287Ssos		printf("%3d (0x%03x)", mode, mode);
45739287Ssos    		printf(" 0x%08x", info.vi_flags);
45839287Ssos		if (info.vi_flags & V_INFO_GRAPHICS) {
45939287Ssos			c = 'G';
46039287Ssos			snprintf(buf, sizeof(buf), "%dx%dx%d %d",
46139287Ssos				 info.vi_width, info.vi_height,
46239287Ssos				 info.vi_depth, info.vi_planes);
46339287Ssos		} else {
46439287Ssos			c = 'T';
46539287Ssos			snprintf(buf, sizeof(buf), "%dx%d",
46639287Ssos				 info.vi_width, info.vi_height);
46739287Ssos		}
46839287Ssos		printf(" %c %-15s", c, buf);
46939287Ssos		snprintf(buf, sizeof(buf), "%dx%d",
47039287Ssos			 info.vi_cwidth, info.vi_cheight);
47139287Ssos		printf(" %-5s", buf);
47239287Ssos    		printf(" 0x%05x %2dk %2dk",
47339287Ssos		       info.vi_window, info.vi_window_size,
47439287Ssos		       info.vi_window_gran);
47539287Ssos    		printf(" 0x%08x %2dk\n",
47639287Ssos		       info.vi_buffer, info.vi_buffer_size);
47739287Ssos	}
47839287Ssos}
47939287Ssos
48039287Ssosvoid
48139287Ssosshow_info(char *arg)
48239287Ssos{
48339287Ssos	if (!strcmp(arg, "adapter"))
48439287Ssos		show_adapter_info();
48539287Ssos	else if (!strcmp(arg, "mode"))
48639287Ssos		show_mode_info();
48739287Ssos	else {
48839287Ssos		warnx("argument to -i must either adapter or mode");
48939287Ssos		return;
49039287Ssos	}
49139287Ssos}
49239287Ssos
49339287Ssosvoid
4942089Ssostest_frame()
4952089Ssos{
4962089Ssos	int i;
4972089Ssos
4982089Ssos	fprintf(stdout, "[=0G\n\n");
4992089Ssos	for (i=0; i<8; i++) {
5002089Ssos		fprintf(stdout, "[=15F[=0G        %2d [=%dF%-16s"
5012089Ssos				"[=15F[=0G        %2d [=%dF%-16s        "
5022089Ssos				"[=15F %2d [=%dGBACKGROUND[=0G\n",
5038857Srgrimes			i, i, legal_colors[i], i+8, i+8,
5048857Srgrimes			legal_colors[i+8], i, i);
5052089Ssos	}
5062089Ssos	fprintf(stdout, "[=%dF[=%dG[=%dH[=%dI\n",
5078857Srgrimes		info.mv_norm.fore, info.mv_norm.back,
5082089Ssos		info.mv_rev.fore, info.mv_rev.back);
5092089Ssos}
5102089Ssos
51123457Sbrianint
5122089Ssosmain(int argc, char **argv)
5132089Ssos{
5142089Ssos	int		opt;
5152089Ssos
5168857Srgrimes
5172089Ssos	info.size = sizeof(info);
51830764Scharnier	if (ioctl(0, CONS_GETINFO, &info) < 0)
51930764Scharnier		err(1, "must be on a virtual console");
52039287Ssos	while((opt = getopt(argc, argv, "b:c:df:i:l:Lm:r:s:t:x")) != -1)
5212089Ssos		switch(opt) {
52216565Ssos			case 'b':
52316565Ssos				set_border_color(optarg);
52416565Ssos				break;
5252089Ssos			case 'c':
5265536Ssos				set_cursor_type(optarg);
5272089Ssos				break;
5282089Ssos			case 'd':
5292089Ssos				print_scrnmap();
5302089Ssos				break;
5312089Ssos			case 'f':
5322089Ssos				load_font(optarg,
5332089Ssos					nextarg(argc, argv, &optind, 'f'));
5342089Ssos				break;
53539287Ssos			case 'i':
53639287Ssos				show_info(optarg);
53739287Ssos				break;
5382089Ssos			case 'l':
5392089Ssos				load_scrnmap(optarg);
5402089Ssos				break;
5412089Ssos			case 'L':
5422089Ssos				load_default_scrnmap();
5432089Ssos				break;
54416565Ssos			case 'm':
54516565Ssos				set_mouse(optarg);
54616565Ssos				break;
5472089Ssos			case 'r':
5482089Ssos				set_reverse_colors(argc, argv, &optind);
5492089Ssos				break;
55023457Sbrian			case 's':
55123457Sbrian				set_console(optarg);
55223457Sbrian				break;
5532089Ssos			case 't':
5542089Ssos				set_screensaver_timeout(optarg);
5552089Ssos				break;
5562089Ssos			case 'x':
5572089Ssos				hex = 1;
5582089Ssos				break;
5592089Ssos			default:
5602089Ssos				usage();
5612089Ssos		}
56223457Sbrian	video_mode(argc, argv, &optind);
56323457Sbrian	set_normal_colors(argc, argv, &optind);
5642089Ssos	if (optind < argc && !strcmp(argv[optind], "show")) {
5652089Ssos		test_frame();
5662089Ssos		optind++;
5672089Ssos	}
56830764Scharnier	if ((optind != argc) || (argc == 1))
5692089Ssos		usage();
57023457Sbrian	return 0;
5712089Ssos}
5722089Ssos
573