home *** CD-ROM | disk | FTP | other *** search
- /* zoomdemo.c - Demo for scrn_xxx direct screen write functions */
-
-
-
- #include "stdio.h"
- #include "stdlib.h"
- #include "video.h" /* direct screen write definitions */
-
- char *convert(int);
-
- #define LINT_ARGS 1 /* enable type checking of library functions */
-
- #define LEFT 0
- #define RIGHT 79
- #define TOP 0
- #define BOTTOM 21
- #define TYPE 1 /* LINE TYPE */
-
- char mainbuf[4000]; /* to hold initial screen save */
- char scrbuf[4000]; /* to hold all other screen saves */
-
- void main()
- {
- SCRN sc; /* make a struct of type SCRN */
- int color; /* user chioce */
- int row, col; /* to save initial cursor */
- register i; /* for loop */
- char *bits; /* pointer to converted string */
-
- scrn_init(&sc); /* _must_ initialize structure */
- vid_get_cur(&row, &col); /* save real cursor position */
- scrn_save(0, 79, 0, 24, mainbuf, &sc); /* save whole screen */
-
-
- while (1) { /* let's loop like we did last night... */
-
- scrn_pos(23,0, &sc); /* logical cursor position */
- scrn_color(BLUE, WHITE, &sc); /* sets attribute for all subsequent */
- /* screen writes, or until changed */
-
- color = 0; /* make sure nothing strange happens */
- scrn_puts("Type a number: (0 = exit)", &sc);
- vid_set_cur(23,15);
- scanf("%d", &color); /* get user choice */
- bits = convert(color); /* get binary equiv in string bits */
-
- if (!color) { /* exit if color = 0 */
- scrn_restore(0,79,0,24,mainbuf,&sc); /* restore whole screen */
- vid_set_cur(row-1,col); /* and real cursor - 1 */
- return; /* and exit */
- }
-
- scrn_attrib(color, &sc); /* reset color to user choice */
- scrn_wzoom(LEFT, RIGHT, TOP, BOTTOM, scrbuf,TYPE,&sc); /* zoooooommmmm!!! */
-
- for (i = TOP+1; i < BOTTOM; i++) { /* write something interesting */
- scrn_pos(i,10, &sc); /* inside the window */
- scrn_puts("Attribute byte set to ", &sc);
- scrn_puts(bits, &sc);
- }
-
- } /* bottom of loop */
- }
-
-
- char *convert(dec) /* convert a decimal to binary and return in a string */
- int dec;
- {
- char *bits = "000000000000000000000000";
- char *tempstr;
- char itoabuf[20];
- int i;
-
- tempstr = (char *)itoa(dec, itoabuf, 2); /* convert dec to bin */
-
- bits += 8; /* pad it with zeros */
- while (*tempstr)
- *bits++ = *tempstr++;
-
- *bits = NULL; /* null terminate the string */
-
- for (i = 0; i < 8; i++) /* point bits at last 8 digits */
- bits--;
-
- return( bits );
- }
-
-