Deleted Added
full compact
vidcontrol.c (37636) vidcontrol.c (39287)
1/*-
2 * Copyright (c) 1994-1996 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

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
29#ifndef lint
30static const char rcsid[] =
1/*-
2 * Copyright (c) 1994-1996 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

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
29#ifndef lint
30static const char rcsid[] =
31 "$Id: vidcontrol.c,v 1.18 1997/10/27 07:52:10 charnier Exp $";
31 "$Id: vidcontrol.c,v 1.19 1998/07/14 10:32:27 bde Exp $";
32#endif /* not lint */
33
34#include <ctype.h>
35#include <err.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <unistd.h>

--- 214 unchanged lines hidden (view full) ---

254 }
255 ioctl(0, CONS_CURSORTYPE, &type);
256}
257
258void
259video_mode(int argc, char **argv, int *index)
260{
261 unsigned long mode;
32#endif /* not lint */
33
34#include <ctype.h>
35#include <err.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <unistd.h>

--- 214 unchanged lines hidden (view full) ---

254 }
255 ioctl(0, CONS_CURSORTYPE, &type);
256}
257
258void
259video_mode(int argc, char **argv, int *index)
260{
261 unsigned long mode;
262 int size[3];
262
263 if (*index < argc) {
264 if (!strcmp(argv[*index], "VGA_40x25"))
265 mode = SW_VGA_C40x25;
266 else if (!strcmp(argv[*index], "VGA_80x25"))
267 mode = SW_VGA_C80x25;
268 else if (!strcmp(argv[*index], "VGA_80x30"))
269 mode = SW_VGA_C80x30;
270 else if (!strcmp(argv[*index], "VGA_80x50"))
271 mode = SW_VGA_C80x50;
272 else if (!strcmp(argv[*index], "VGA_80x60"))
273 mode = SW_VGA_C80x60;
274 else if (!strcmp(argv[*index], "VGA_320x200"))
275 mode = SW_VGA_CG320;
276 else if (!strcmp(argv[*index], "EGA_80x25"))
277 mode = SW_ENH_C80x25;
278 else if (!strcmp(argv[*index], "EGA_80x43"))
279 mode = SW_ENH_C80x43;
263
264 if (*index < argc) {
265 if (!strcmp(argv[*index], "VGA_40x25"))
266 mode = SW_VGA_C40x25;
267 else if (!strcmp(argv[*index], "VGA_80x25"))
268 mode = SW_VGA_C80x25;
269 else if (!strcmp(argv[*index], "VGA_80x30"))
270 mode = SW_VGA_C80x30;
271 else if (!strcmp(argv[*index], "VGA_80x50"))
272 mode = SW_VGA_C80x50;
273 else if (!strcmp(argv[*index], "VGA_80x60"))
274 mode = SW_VGA_C80x60;
275 else if (!strcmp(argv[*index], "VGA_320x200"))
276 mode = SW_VGA_CG320;
277 else if (!strcmp(argv[*index], "EGA_80x25"))
278 mode = SW_ENH_C80x25;
279 else if (!strcmp(argv[*index], "EGA_80x43"))
280 mode = SW_ENH_C80x43;
281 else if (!strcmp(argv[*index], "VESA_132x25"))
282 mode = SW_VESA_C132x25;
283 else if (!strcmp(argv[*index], "VESA_132x43"))
284 mode = SW_VESA_C132x43;
285 else if (!strcmp(argv[*index], "VESA_132x50"))
286 mode = SW_VESA_C132x50;
287 else if (!strcmp(argv[*index], "VESA_132x60"))
288 mode = SW_VESA_C132x60;
289 else if (!strcmp(argv[*index], "VESA_800x600"))
290 mode = SW_VESA_800x600;
280 else
281 return;
282 if (ioctl(0, mode, NULL) < 0)
283 warn("cannot set videomode");
291 else
292 return;
293 if (ioctl(0, mode, NULL) < 0)
294 warn("cannot set videomode");
295 if (mode == SW_VESA_800x600) {
296 size[0] = 80; /* columns */
297 size[1] = 25; /* rows */
298 size[2] = 16; /* font size */
299 if (ioctl(0, KDRASTER, size))
300 warn("cannot activate raster display");
301 }
284 (*index)++;
285 }
286 return;
287}
288
289int
290get_color_number(char *color)
291{

--- 78 unchanged lines hidden (view full) ---

370 mouse.operation = MOUSE_HIDE;
371 else {
372 warnx("argument to -m must either on or off");
373 return;
374 }
375 ioctl(0, CONS_MOUSECTL, &mouse);
376}
377
302 (*index)++;
303 }
304 return;
305}
306
307int
308get_color_number(char *color)
309{

--- 78 unchanged lines hidden (view full) ---

388 mouse.operation = MOUSE_HIDE;
389 else {
390 warnx("argument to -m must either on or off");
391 return;
392 }
393 ioctl(0, CONS_MOUSECTL, &mouse);
394}
395
396static char
397*adapter_name(int type)
398{
399 static struct {
400 int type;
401 char *name;
402 } names[] = {
403 { KD_MONO, "MDA" },
404 { KD_HERCULES, "Hercules" },
405 { KD_CGA, "CGA" },
406 { KD_EGA, "EGA" },
407 { KD_VGA, "VGA" },
408 { KD_PC98, "PC-98xx" },
409 { -1, "Unknown" },
410 };
411 int i;
412
413 for (i = 0; names[i].type != -1; ++i)
414 if (names[i].type == type)
415 break;
416 return names[i].name;
417}
418
378void
419void
420show_adapter_info(void)
421{
422 struct video_adapter ad;
423
424 ad.va_index = 0;
425 if (ioctl(0, CONS_ADPINFO, &ad)) {
426 warn("failed to obtain adapter information");
427 return;
428 }
429
430 printf("adapter %d:\n", ad.va_index);
431 printf(" type:%s%s (%d), flags:0x%08x, CRTC:0x%x\n",
432 (ad.va_flags & V_ADP_VESA) ? "VESA " : "",
433 adapter_name(ad.va_type), ad.va_type,
434 ad.va_flags, ad.va_crtc_addr);
435 printf(" initial mode:%d, current mode:%d, BIOS mode:%d\n",
436 ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
437}
438
439void
440show_mode_info(void)
441{
442 struct video_info info;
443 char buf[80];
444 int mode;
445 int c;
446
447 printf(" mode# flags type size "
448 "font window linear buffer\n");
449 printf("---------------------------------------"
450 "---------------------------------------\n");
451 for (mode = 0; mode < M_VESA_MODE_MAX; ++mode) {
452 info.vi_mode = mode;
453 if (ioctl(0, CONS_MODEINFO, &info))
454 continue;
455
456 printf("%3d (0x%03x)", mode, mode);
457 printf(" 0x%08x", info.vi_flags);
458 if (info.vi_flags & V_INFO_GRAPHICS) {
459 c = 'G';
460 snprintf(buf, sizeof(buf), "%dx%dx%d %d",
461 info.vi_width, info.vi_height,
462 info.vi_depth, info.vi_planes);
463 } else {
464 c = 'T';
465 snprintf(buf, sizeof(buf), "%dx%d",
466 info.vi_width, info.vi_height);
467 }
468 printf(" %c %-15s", c, buf);
469 snprintf(buf, sizeof(buf), "%dx%d",
470 info.vi_cwidth, info.vi_cheight);
471 printf(" %-5s", buf);
472 printf(" 0x%05x %2dk %2dk",
473 info.vi_window, info.vi_window_size,
474 info.vi_window_gran);
475 printf(" 0x%08x %2dk\n",
476 info.vi_buffer, info.vi_buffer_size);
477 }
478}
479
480void
481show_info(char *arg)
482{
483 if (!strcmp(arg, "adapter"))
484 show_adapter_info();
485 else if (!strcmp(arg, "mode"))
486 show_mode_info();
487 else {
488 warnx("argument to -i must either adapter or mode");
489 return;
490 }
491}
492
493void
379test_frame()
380{
381 int i;
382
383 fprintf(stdout, "[=0G\n\n");
384 for (i=0; i<8; i++) {
385 fprintf(stdout, "[=15F[=0G %2d [=%dF%-16s"
386 "[=15F[=0G %2d [=%dF%-16s "

--- 10 unchanged lines hidden (view full) ---

397main(int argc, char **argv)
398{
399 int opt;
400
401
402 info.size = sizeof(info);
403 if (ioctl(0, CONS_GETINFO, &info) < 0)
404 err(1, "must be on a virtual console");
494test_frame()
495{
496 int i;
497
498 fprintf(stdout, "[=0G\n\n");
499 for (i=0; i<8; i++) {
500 fprintf(stdout, "[=15F[=0G %2d [=%dF%-16s"
501 "[=15F[=0G %2d [=%dF%-16s "

--- 10 unchanged lines hidden (view full) ---

512main(int argc, char **argv)
513{
514 int opt;
515
516
517 info.size = sizeof(info);
518 if (ioctl(0, CONS_GETINFO, &info) < 0)
519 err(1, "must be on a virtual console");
405 while((opt = getopt(argc, argv, "b:c:df:l:Lm:r:s:t:x")) != -1)
520 while((opt = getopt(argc, argv, "b:c:df:i:l:Lm:r:s:t:x")) != -1)
406 switch(opt) {
407 case 'b':
408 set_border_color(optarg);
409 break;
410 case 'c':
411 set_cursor_type(optarg);
412 break;
413 case 'd':
414 print_scrnmap();
415 break;
416 case 'f':
417 load_font(optarg,
418 nextarg(argc, argv, &optind, 'f'));
419 break;
521 switch(opt) {
522 case 'b':
523 set_border_color(optarg);
524 break;
525 case 'c':
526 set_cursor_type(optarg);
527 break;
528 case 'd':
529 print_scrnmap();
530 break;
531 case 'f':
532 load_font(optarg,
533 nextarg(argc, argv, &optind, 'f'));
534 break;
535 case 'i':
536 show_info(optarg);
537 break;
420 case 'l':
421 load_scrnmap(optarg);
422 break;
423 case 'L':
424 load_default_scrnmap();
425 break;
426 case 'm':
427 set_mouse(optarg);

--- 27 unchanged lines hidden ---
538 case 'l':
539 load_scrnmap(optarg);
540 break;
541 case 'L':
542 load_default_scrnmap();
543 break;
544 case 'm':
545 set_mouse(optarg);

--- 27 unchanged lines hidden ---