NHDT->ANH, nethack->anethack, nhdat->anhdat
[aNetHack.git] / sys / msdos / video.c
blob68b4426194dbb3d618de7a914917bee0119b3c45
1 /* aNetHack 0.0.1 video.c $ANH-Date: 1457207042 2016/03/05 19:44:02 $ $ANH-Branch: chasonr $:$ANH-Revision: 1.11 $ */
2 /* Copyright (c) aNetHack PC Development Team 1993, 1994, 2001 */
3 /* aNetHack may be freely redistributed. See license for details. */
4 /* */
5 /*
6 * video.c - Hardware video support front-ends
8 *Edit History:
9 * Initial Creation M. Allison 1993/04/04
10 * Add djgpp support K. Smolkowski 1993/04/26
11 * Add txt/graphics mode support M. Allison 1993/10/30
12 * Add graphics mode cursor sim. M. Allison 1994/02/19
13 * Add hooks for decals on vga M. Allison 2001/04/07
16 #include "hack.h"
18 #ifndef STUBVIDEO
19 #include "pcvideo.h"
20 #include "pctiles.h"
22 #if defined(_MSC_VER)
23 #if _MSC_VER >= 700
24 #pragma warning(disable : 4018) /* signed/unsigned mismatch */
25 #pragma warning(disable : 4127) /* conditional expression is constant */
26 #pragma warning(disable : 4131) /* old style declarator */
27 #pragma warning(disable : 4305) /* prevents complaints with MK_FP */
28 #pragma warning(disable : 4309) /* initializing */
29 #pragma warning(disable : 4759) /* prevents complaints with MK_FP */
30 #endif
31 #endif
32 /*=========================================================================
33 * General PC Video routines.
35 * The following routines are the video interfacing functions.
36 * In general these make calls to more hardware specific
37 * routines in other source files.
39 * Assumptions (94/04/23):
41 * - Supported defaults.nh file video options:
43 * If OPTIONS=video:autodetect is defined in defaults.nh then
44 * check for a VGA video adapter. If one is detected, then
45 * use the VGA code, otherwise resort to using the 'standard'
46 * video BIOS routines.
48 * If OPTIONS=video:vga is defined in defaults.nh, then use
49 * the VGA code.
51 * If OPTIONS=video:default is defined in defaults.nh use the
52 * 'standard' video BIOS routines (in the overlaid version),
53 * or DJGPPFAST routines (under djgpp). This is equivalent to
54 * having no OPTIONS=video:xxxx entry at all.
56 * Notes (94/04/23):
58 * - The handler for defaults.nh file entry:
60 * OPTIONS=video:xxxxx
62 * has now been added. The handler is in video.c and is called
63 * from options.c.
65 * - Handling of videocolors and videoshades are now done with
66 * OPTIONS= statements. The new syntax separates the colour
67 * values with dashes ('-') rather than spaces (' ').
69 * To Do (94/04/23):
72 *=========================================================================
75 void
76 get_scr_size()
78 #ifdef SCREEN_VGA
79 if (iflags.usevga) {
80 vga_get_scr_size();
81 } else
82 #endif
83 #ifdef SCREEN_VESA
84 if (iflags.usevesa) {
85 vesa_get_scr_size();
86 } else
87 #endif
88 txt_get_scr_size();
92 * --------------------------------------------------------------
93 * The rest of this file is only compiled if NO_TERMS is defined.
94 * --------------------------------------------------------------
97 #ifdef NO_TERMS
99 #include <ctype.h>
100 #include "wintty.h"
102 #ifdef __GO32__
103 #include <pc.h>
104 #include <unistd.h>
105 #if !(__DJGPP__ >= 2)
106 typedef long clock_t;
107 #endif
108 #endif
110 #ifdef __BORLANDC__
111 #include <dos.h> /* needed for delay() */
112 #endif
114 #ifdef SCREEN_DJGPPFAST /* parts of this block may be unecessary now */
115 #define get_cursor(x, y) ScreenGetCursor(y, x)
116 #endif
118 #ifdef SCREEN_BIOS
119 void FDECL(get_cursor, (int *, int *));
120 #endif
122 void FDECL(adjust_cursor_flags, (struct WinDesc *));
123 void FDECL(cmov, (int, int));
124 void FDECL(nocmov, (int, int));
125 STATIC_DCL void NDECL(init_ttycolor);
127 int savevmode; /* store the original video mode in here */
128 int curcol, currow; /* graphics mode current cursor locations */
129 int g_attribute; /* Current attribute to use */
130 int monoflag; /* 0 = not monochrome, else monochrome */
131 int attrib_text_normal; /* text mode normal attribute */
132 int attrib_gr_normal; /* graphics mode normal attribute */
133 int attrib_text_intense; /* text mode intense attribute */
134 int attrib_gr_intense; /* graphics mode intense attribute */
135 boolean traditional = FALSE; /* traditonal TTY character mode */
136 boolean inmap = FALSE; /* in the map window */
137 #ifdef TEXTCOLOR
138 char ttycolors[CLR_MAX]; /* also used/set in options.c */
139 #endif /* TEXTCOLOR */
141 void
142 backsp()
144 if (!iflags.grmode) {
145 txt_backsp();
146 #ifdef SCREEN_VGA
147 } else if (iflags.usevga) {
148 vga_backsp();
149 #endif
150 #ifdef SCREEN_VESA
151 } else if (iflags.usevesa) {
152 vesa_backsp();
153 #endif
157 void
158 clear_screen()
160 if (!iflags.grmode) {
161 txt_clear_screen();
162 #ifdef SCREEN_VGA
163 } else if (iflags.usevga) {
164 vga_clear_screen(BACKGROUND_VGA_COLOR);
165 #endif
166 #ifdef SCREEN_VESA
167 } else if (iflags.usevesa) {
168 vesa_clear_screen(BACKGROUND_VGA_COLOR);
169 #endif
173 void cl_end() /* clear to end of line */
175 int col, row;
177 col = (int) ttyDisplay->curx;
178 row = (int) ttyDisplay->cury;
179 if (!iflags.grmode) {
180 txt_cl_end(col, row);
181 #ifdef SCREEN_VGA
182 } else if (iflags.usevga) {
183 vga_cl_end(col, row);
184 #endif
185 #ifdef SCREEN_VESA
186 } else if (iflags.usevesa) {
187 vesa_cl_end(col, row);
188 #endif
190 tty_curs(BASE_WINDOW, (int) ttyDisplay->curx + 1, (int) ttyDisplay->cury);
193 void cl_eos() /* clear to end of screen */
195 int cy = (int) ttyDisplay->cury + 1;
197 if (!iflags.grmode) {
198 txt_cl_eos();
199 #ifdef SCREEN_VGA
200 } else if (iflags.usevga) {
201 vga_cl_eos(cy);
202 #endif
203 #ifdef SCREEN_VESA
204 } else if (iflags.usevesa) {
205 vesa_cl_eos(cy);
206 #endif
208 tty_curs(BASE_WINDOW, (int) ttyDisplay->curx + 1, (int) ttyDisplay->cury);
211 void
212 cmov(col, row)
213 register int col, row;
215 ttyDisplay->cury = (uchar) row;
216 ttyDisplay->curx = (uchar) col;
217 if (!iflags.grmode) {
218 txt_gotoxy(col, row);
219 #ifdef SCREEN_VGA
220 } else if (iflags.usevga) {
221 vga_gotoloc(col, row);
222 #endif
223 #ifdef SCREEN_VESA
224 } else if (iflags.usevesa) {
225 vesa_gotoloc(col, row);
226 #endif
231 has_color(int color)
233 ++color; /* prevents compiler warning (unref. param) */
234 #ifdef TEXTCOLOR
235 return (monoflag) ? 0 : 1;
236 #else
237 return 0;
238 #endif
241 void
242 home()
244 tty_curs(BASE_WINDOW, 1, 0);
245 ttyDisplay->curx = ttyDisplay->cury = (uchar) 0;
246 if (!iflags.grmode) {
247 txt_gotoxy(0, 0);
248 #ifdef SCREEN_VGA
249 } else if (iflags.usevga) {
250 vga_gotoloc(0, 0);
251 #endif
252 #ifdef SCREEN_VESA
253 } else if (iflags.usevesa) {
254 vesa_gotoloc(0, 0);
255 #endif
259 void
260 nocmov(col, row)
261 int col, row;
263 if (!iflags.grmode) {
264 txt_gotoxy(col, row);
265 #ifdef SCREEN_VGA
266 } else if (iflags.usevga) {
267 vga_gotoloc(col, row);
268 #endif
269 #ifdef SCREEN_VESA
270 } else if (iflags.usevesa) {
271 vesa_gotoloc(col, row);
272 #endif
276 void
277 standoutbeg()
279 g_attribute = iflags.grmode ? attrib_gr_intense : attrib_text_intense;
282 void
283 standoutend()
285 g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
288 void
289 term_end_attr(int attr)
291 switch (attr) {
292 case ATR_ULINE:
293 case ATR_BOLD:
294 case ATR_BLINK:
295 case ATR_INVERSE:
296 default:
297 g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
301 void
302 term_end_color(void)
304 g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
307 void
308 term_end_raw_bold(void)
310 standoutend();
313 void
314 term_start_attr(int attr)
316 switch (attr) {
317 case ATR_ULINE:
318 if (monoflag) {
319 g_attribute = ATTRIB_MONO_UNDERLINE;
320 } else {
321 g_attribute =
322 iflags.grmode ? attrib_gr_intense : attrib_text_intense;
324 break;
325 case ATR_BOLD:
326 g_attribute = iflags.grmode ? attrib_gr_intense : attrib_text_intense;
327 break;
328 case ATR_BLINK:
329 if (monoflag) {
330 g_attribute = ATTRIB_MONO_BLINK;
331 } else {
332 g_attribute =
333 iflags.grmode ? attrib_gr_intense : attrib_text_intense;
335 break;
336 case ATR_INVERSE:
337 if (monoflag) {
338 g_attribute = ATTRIB_MONO_REVERSE;
339 } else {
340 g_attribute =
341 iflags.grmode ? attrib_gr_intense : attrib_text_intense;
343 break;
344 default:
345 g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
346 break;
350 void
351 term_start_color(int color)
353 #ifdef TEXTCOLOR
354 if (monoflag) {
355 g_attribute = attrib_text_normal;
356 } else {
357 if (color >= 0 && color < CLR_MAX) {
358 if (iflags.grmode)
359 g_attribute = color;
360 else
361 g_attribute = ttycolors[color];
364 #endif
367 void
368 term_start_raw_bold(void)
370 standoutbeg();
373 void
374 tty_delay_output()
376 #ifdef TIMED_DELAY
377 if (flags.nap) {
378 (void) fflush(stdout);
379 msleep(50); /* sleep for 50 milliseconds */
380 return;
382 #endif
385 void
386 tty_end_screen()
388 if (!iflags.grmode) {
389 txt_clear_screen();
390 #ifdef PC9800
391 fputs("\033[>1l", stdout);
392 #endif
393 #ifdef SCREEN_VGA
394 } else if (iflags.usevga) {
395 vga_tty_end_screen();
396 #endif
397 #ifdef SCREEN_VESA
398 } else if (iflags.usevesa) {
399 vesa_tty_end_screen();
400 #endif
404 void
405 tty_nhbell()
407 txt_nhbell();
410 void
411 tty_number_pad(state)
412 int state;
414 ++state; /* prevents compiler warning (unref. param) */
417 void
418 tty_startup(wid, hgt)
419 int *wid, *hgt;
421 /* code to sense display adapter is required here - MJA */
423 attrib_text_normal = ATTRIB_NORMAL;
424 attrib_text_intense = ATTRIB_INTENSE;
426 /* These are defaults and may get overridden */
427 attrib_gr_normal = attrib_text_normal;
428 attrib_gr_intense = attrib_text_intense;
429 g_attribute = attrib_text_normal; /* Give it a starting value */
431 #ifdef SCREEN_VGA
432 if (iflags.usevga) {
433 vga_tty_startup(wid, hgt);
434 } else
435 #endif
436 #ifdef SCREEN_VESA
437 if (iflags.usevesa) {
438 vesa_tty_startup(wid, hgt);
439 } else
440 #endif
441 txt_startup(wid, hgt);
443 *wid = CO;
444 *hgt = LI;
446 #ifdef CLIPPING
447 if (CO < COLNO || LI < ROWNO + 3)
448 setclipped();
449 #endif
451 #ifdef TEXTCOLOR
452 init_ttycolor();
453 #endif
455 #ifdef MONO_CHECK
456 monoflag = txt_monoadapt_check();
457 #else
458 monoflag = 0;
459 #endif
462 void
463 tty_start_screen()
465 #ifdef PC9800
466 fputs("\033[>1h", stdout);
467 #endif
468 if (iflags.num_pad)
469 tty_number_pad(1); /* make keypad send digits */
472 void
473 gr_init()
475 #ifdef SCREEN_VGA
476 if (iflags.usevga) {
477 vga_Init();
478 } else
479 #endif
480 #ifdef SCREEN_VESA
481 if (iflags.usevesa) {
482 vesa_Init();
483 } else
484 #endif
485 #ifdef SCREEN_8514
486 if (iflags.use8514) {
487 v8514_Init();
488 } else
489 #endif
493 void
494 gr_finish()
496 if (iflags.grmode) {
497 #ifdef SCREEN_VGA
498 if (iflags.usevga) {
499 vga_Finish();
500 } else
501 #endif
502 #ifdef SCREEN_VESA
503 if (iflags.usevesa) {
504 vesa_Finish();
505 } else
506 #endif
507 #ifdef SCREEN_8514
508 if (iflags.use8514) {
509 v8514_Finish();
510 } else
511 #endif
517 * Screen output routines (these are heavily used).
519 * These are the 3 routines used to place information on the screen
520 * in the NO_TERMS PC tty port of aNetHack. These are the routines
521 * that get called by routines in other aNetHack source files (such
522 * as those in win/tty).
524 * xputs - Writes a c null terminated string at the current location.
525 * Depending on compile options, this could just be a series
526 * of repeated calls to xputc() for each character.
528 * xputc - Writes a single character at the current location. Since
529 * various places in the code assume that control characters
530 * can be used to control, we are forced to interpret some of
531 * the more common ones, in order to keep things looking correct.
533 * xputg - If using a graphics mode display mechanism (such as VGA, this
534 * routine is used to display a graphical representation of a
535 * aNetHack glyph at the current location. For more information on
536 * aNetHack glyphs refer to the comments in include/display.h.
538 * NOTES:
539 * wintty.h uses macros to redefine common output functions
540 * such as puts, putc, putchar, so that they get steered into
541 * either xputs (for strings) or xputc (for single characters).
542 * References to puts, putc, and putchar in other source files
543 * (that include wintty.h) are actually using these routines.
546 void
547 xputs(s)
548 const char *s;
550 int col, row;
552 col = (int) ttyDisplay->curx;
553 row = (int) ttyDisplay->cury;
555 if (!iflags.grmode) {
556 txt_xputs(s, col, row);
557 #ifdef SCREEN_VGA
558 } else if (iflags.usevga) {
559 vga_xputs(s, col, row);
560 #endif
561 #ifdef SCREEN_VESA
562 } else if (iflags.usevesa) {
563 vesa_xputs(s, col, row);
564 #endif
568 void xputc(ch) /* write out character (and attribute) */
569 char ch;
571 int i;
572 char attribute;
574 i = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
576 attribute = (char) ((g_attribute == 0) ? i : g_attribute);
577 if (!iflags.grmode) {
578 txt_xputc(ch, attribute);
579 #ifdef SCREEN_VGA
580 } else if (iflags.usevga) {
581 vga_xputc(ch, attribute);
582 #endif /*SCREEN_VGA*/
583 #ifdef SCREEN_VESA
584 } else if (iflags.usevesa) {
585 vesa_xputc(ch, attribute);
586 #endif /*SCREEN_VESA*/
590 void xputg(glyphnum, ch,
591 special) /* write out a glyph picture at current location */
592 int glyphnum;
593 int ch;
594 unsigned special;
596 if (!iflags.grmode || !iflags.tile_view) {
597 xputc((char) ch);
598 #ifdef SCREEN_VGA
599 } else if (iflags.grmode && iflags.usevga) {
600 vga_xputg(glyphnum, ch, special);
601 #endif
602 #ifdef SCREEN_VESA
603 } else if (iflags.grmode && iflags.usevesa) {
604 vesa_xputg(glyphnum, ch, special);
605 #endif
609 #ifdef POSITIONBAR
610 void
611 video_update_positionbar(posbar)
612 char *posbar;
614 if (!iflags.grmode)
615 return;
616 #ifdef SCREEN_VGA
617 else if (iflags.usevga)
618 vga_update_positionbar(posbar);
619 #endif
620 #ifdef SCREEN_VESA
621 else if (iflags.usevesa)
622 vesa_update_positionbar(posbar);
623 #endif
625 #endif
627 void
628 adjust_cursor_flags(cw)
629 struct WinDesc *cw;
631 #ifdef SIMULATE_CURSOR
632 #if 0
633 if (cw->type == NHW_MAP) cursor_flag = 1;
634 else cursor_flag = 0;
635 #else
636 if (cw->type == NHW_MAP) {
637 inmap = 1;
638 cursor_flag = 1;
639 } else {
640 inmap = 0;
641 cursor_flag = 1;
643 #endif /* 0 */
644 #endif /* SIMULATE_CURSOR */
647 #ifdef SIMULATE_CURSOR
649 /* change the defaults in pcvideo.h, not here */
650 int cursor_type = CURSOR_DEFAULT_STYLE;
651 int cursor_color = CURSOR_DEFAULT_COLOR;
652 int cursor_flag;
654 /* The check for iflags.grmode is made BEFORE calling these. */
655 void
656 DrawCursor()
658 #ifdef SCREEN_VGA
659 if (iflags.usevga)
660 vga_DrawCursor();
661 #endif
662 #ifdef SCREEN_VESA
663 if (iflags.usevesa)
664 vesa_DrawCursor();
665 #endif
668 void
669 HideCursor()
671 #ifdef SCREEN_VGA
672 if (iflags.usevga)
673 vga_HideCursor();
674 #endif
675 #ifdef SCREEN_VESA
676 if (iflags.usevesa)
677 vesa_HideCursor();
678 #endif
681 #endif /* SIMULATE_CURSOR */
683 #ifdef TEXTCOLOR
685 * CLR_BLACK 0
686 * CLR_RED 1
687 * CLR_GREEN 2
688 * CLR_BROWN 3 low-intensity yellow
689 * CLR_BLUE 4
690 * CLR_MAGENTA 5
691 * CLR_CYAN 6
692 * CLR_GRAY 7 low-intensity white
693 * NO_COLOR 8
694 * CLR_ORANGE 9
695 * CLR_BRIGHT_GREEN 10
696 * CLR_YELLOW 11
697 * CLR_BRIGHT_BLUE 12
698 * CLR_BRIGHT_MAGENTA 13
699 * CLR_BRIGHT_CYAN 14
700 * CLR_WHITE 15
701 * CLR_MAX 16
702 * BRIGHT 8
705 #ifdef VIDEOSHADES
706 /* assign_videoshades() is prototyped in extern.h */
707 /* assign_videocolors() is prototyped in extern.h */
708 /* assign_video() is prototyped in extern.h */
710 int shadeflag; /* shades are initialized */
711 int colorflag; /* colors are initialized */
712 char *schoice[3] = { "dark", "normal", "light" };
713 char *shade[3];
714 #endif /* VIDEOSHADES */
716 STATIC_OVL void
717 init_ttycolor()
719 #ifdef VIDEOSHADES
720 if (!shadeflag) {
721 ttycolors[CLR_BLACK] = M_BLACK; /* 8 = dark gray */
722 ttycolors[CLR_WHITE] = M_WHITE; /* 15 = bright white */
723 ttycolors[CLR_GRAY] = M_GRAY; /* 7 = normal white */
724 shade[0] = schoice[0];
725 shade[1] = schoice[1];
726 shade[2] = schoice[2];
728 #else
729 ttycolors[CLR_BLACK] = M_GRAY; /* mapped to white */
730 ttycolors[CLR_WHITE] = M_GRAY; /* mapped to white */
731 ttycolors[CLR_GRAY] = M_GRAY; /* mapped to white */
732 #endif
734 #ifdef VIDEOSHADES
735 if (!colorflag) {
736 #endif
737 ttycolors[CLR_RED] = M_RED;
738 ttycolors[CLR_GREEN] = M_GREEN;
739 ttycolors[CLR_BROWN] = M_BROWN;
740 ttycolors[CLR_BLUE] = M_BLUE;
741 ttycolors[CLR_MAGENTA] = M_MAGENTA;
742 ttycolors[CLR_CYAN] = M_CYAN;
743 ttycolors[BRIGHT] = M_WHITE;
744 ttycolors[CLR_ORANGE] = M_ORANGE;
745 ttycolors[CLR_BRIGHT_GREEN] = M_BRIGHTGREEN;
746 ttycolors[CLR_YELLOW] = M_YELLOW;
747 ttycolors[CLR_BRIGHT_BLUE] = M_BRIGHTBLUE;
748 ttycolors[CLR_BRIGHT_MAGENTA] = M_BRIGHTMAGENTA;
749 ttycolors[CLR_BRIGHT_CYAN] = M_BRIGHTCYAN;
750 #ifdef VIDEOSHADES
752 #endif
755 static int FDECL(convert_uchars, (char *, uchar *, int));
756 #ifdef VIDEOSHADES
758 assign_videoshades(char *choiceptr)
760 char choices[120];
761 char *cptr, *cvalue[3];
762 int i, icolor = CLR_WHITE;
764 strcpy(choices, choiceptr);
765 cvalue[0] = choices;
767 /* find the next ' ' or tab */
768 cptr = index(cvalue[0], '-');
769 if (!cptr)
770 cptr = index(cvalue[0], ' ');
771 if (!cptr)
772 cptr = index(cvalue[0], '\t');
773 if (!cptr)
774 return 0;
775 *cptr = '\0';
776 /* skip whitespace between '=' and value */
777 do {
778 ++cptr;
779 } while (isspace(*cptr) || (*cptr == '-'));
780 cvalue[1] = cptr;
782 cptr = index(cvalue[1], '-');
783 if (!cptr)
784 cptr = index(cvalue[0], ' ');
785 if (!cptr)
786 cptr = index(cvalue[0], '\t');
787 if (!cptr)
788 return 0;
789 *cptr = '\0';
790 do {
791 ++cptr;
792 } while (isspace(*cptr) || (*cptr == '-'));
793 cvalue[2] = cptr;
795 for (i = 0; i < 3; ++i) {
796 switch (i) {
797 case 0:
798 icolor = CLR_BLACK;
799 break;
800 case 1:
801 icolor = CLR_GRAY;
802 break;
803 case 2:
804 icolor = CLR_WHITE;
805 break;
808 shadeflag = 1;
809 if ((strncmpi(cvalue[i], "black", 5) == 0)
810 || (strncmpi(cvalue[i], "dark", 4) == 0)) {
811 shade[i] = schoice[0];
812 ttycolors[icolor] = M_BLACK; /* dark gray */
813 } else if ((strncmpi(cvalue[i], "gray", 4) == 0)
814 || (strncmpi(cvalue[i], "grey", 4) == 0)
815 || (strncmpi(cvalue[i], "medium", 6) == 0)
816 || (strncmpi(cvalue[i], "normal", 6) == 0)) {
817 shade[i] = schoice[1];
818 ttycolors[icolor] = M_GRAY; /* regular gray */
819 } else if ((strncmpi(cvalue[i], "white", 5) == 0)
820 || (strncmpi(cvalue[i], "light", 5) == 0)) {
821 shade[i] = schoice[2];
822 ttycolors[icolor] = M_WHITE; /* bright white */
823 } else {
824 shadeflag = 0;
825 return 0;
828 return 1;
832 * Process defaults.nh OPTIONS=videocolors:xxx
833 * Left to right assignments for:
834 * red green brown blue magenta cyan orange br.green yellow
835 * br.blue br.mag br.cyan
837 * Default Mapping (BIOS): 4-2-6-1-5-3-12-10-14-9-13-11
840 assign_videocolors(char *colorvals)
842 int i, icolor;
843 uchar *tmpcolor;
845 init_ttycolor(); /* in case defaults.nh entry wasn't complete */
846 i = strlen(colorvals);
847 tmpcolor = (uchar *) alloc(i);
848 (void) convert_uchars(colorvals, tmpcolor, i);
849 icolor = CLR_RED;
850 for (i = 0; tmpcolor[i] != 0; ++i) {
851 if (icolor < (CLR_WHITE)) {
852 ttycolors[icolor++] = tmpcolor[i];
853 if ((icolor > CLR_CYAN) && (icolor < CLR_ORANGE)) {
854 icolor = CLR_ORANGE;
858 colorflag = 1;
859 free((genericptr_t) tmpcolor);
860 return 1;
863 static int
864 convert_uchars(bufp, list, size)
865 char *bufp; /* current pointer */
866 uchar *list; /* return list */
867 int size;
869 unsigned int num = 0;
870 int count = 0;
872 while (1) {
873 switch (*bufp) {
874 case ' ':
875 case '\0':
876 case '\t':
877 case '-':
878 case '\n':
879 if (num) {
880 list[count++] = num;
881 num = 0;
883 if ((count == size) || !*bufp)
884 return count;
885 bufp++;
886 break;
888 case '0':
889 case '1':
890 case '2':
891 case '3':
892 case '4':
893 case '5':
894 case '6':
895 case '7':
896 case '8':
897 case '9':
898 num = num * 10 + (*bufp - '0');
899 bufp++;
900 break;
901 return count;
904 /*NOTREACHED*/
907 #endif /* VIDEOSHADES */
908 #endif /* TEXTCOLOR */
911 * Process defaults.nh OPTIONS=video:xxxx
913 * where (current) legitimate values are:
915 * autodetect (attempt to determine the adapter type)
916 * default (force use of the default video method for environment)
917 * vga (use vga adapter code)
920 assign_video(sopt)
921 char *sopt;
924 * debug
926 * printf("video is %s",sopt);
927 * getch();
929 iflags.grmode = 0;
930 iflags.hasvesa = 0;
931 iflags.hasvga = 0;
932 iflags.usevesa = 0;
933 iflags.usevga = 0;
935 if (strncmpi(sopt, "def", 3) == 0) { /* default */
936 /* do nothing - default */
937 #ifdef SCREEN_VGA
938 } else if (strncmpi(sopt, "vga", 3) == 0) { /* vga */
939 iflags.usevga = 1;
940 iflags.hasvga = 1;
941 #endif
942 #ifdef SCREEN_VESA
943 } else if (strncmpi(sopt, "vesa", 4) == 0) { /* vesa */
944 iflags.hasvesa = 1;
945 iflags.usevesa = 1;
946 #endif
947 #ifdef SCREEN_8514
948 } else if (strncmpi(sopt, "8514", 4) == 0) { /* 8514/A */
949 iflags.use8514 = 1;
950 iflags.has8514 = 1;
951 #endif
952 } else if (strncmpi(sopt, "auto", 4) == 0) { /* autodetect */
953 #ifdef SCREEN_VESA
954 if (vesa_detect()) {
955 iflags.hasvesa = 1;
957 #endif
958 #ifdef SCREEN_8514
959 if (v8514_detect()) {
960 iflags.has8514 = 1;
962 #endif
963 #ifdef SCREEN_VGA
964 if (vga_detect()) {
965 iflags.hasvga = 1;
967 #endif
969 * Auto-detect Priorities (arbitrary for now):
970 * VESA, VGA
972 if (iflags.hasvesa) iflags.usevesa = 1;
973 else if (iflags.hasvga) {
974 iflags.usevga = 1;
975 /* VGA depends on BIOS to enable function keys*/
976 iflags.BIOS = 1;
977 iflags.rawio = 1;
979 } else {
980 return 0;
982 return 1;
985 void
986 tileview(enable)
987 boolean enable;
989 #ifdef SCREEN_VGA
990 if (iflags.grmode && iflags.usevga)
991 vga_traditional(enable ? FALSE : TRUE);
992 #endif
993 #ifdef SCREEN_VESA
994 if (iflags.grmode && iflags.usevesa)
995 vesa_traditional(enable ? FALSE : TRUE);
996 #endif
998 #endif /* NO_TERMS */
1000 #else /* STUBVIDEO */
1002 void
1003 tileview(enable)
1004 boolean enable;
1007 #endif /* STUBVIDEO */
1009 /*video.c*/