home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * gr_test.c - graphics test program.
- *
- * Purpose: This file contains functions to test the graphics functions.
- * It will test CGA or EGA color adapters.
- *
- * Blackstar C Function Library
- * (c) Copyright 1985 Sterling Castle Software
- *
- *******/
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include "blackstr.h"
- #include "kb_head.h"
- #include "gr_head.h"
- #include "sc_head.h"
- #include "sy_head.h"
- #include "co_head.h"
-
-
- short int *shape;
- short int shape1[] = {1,5,4,15,12,8,6,3,0,0,EOS,EOS};
- char *ptr;
- char *pic;
-
- void main()
- {
- int i;
- pic = malloc(16384);
- shape = (short int *)malloc(5000*sizeof(short int));
-
- /******************************************************
- INITIALIZE SYSTEM AND SCREEN FOR PROPER ADAPTER TYPE
- *******************************************************/
- kb_init(NULL,NULL,NULL);
- sc_init(NUL,NUL,NUL); /* just get current parms */
- switch (sc_adp_) {
- case MON_ADP:
- {
- sc_clr();
- sy_beep();
- sc_puts("\n\rSorry, you need a color adapter to run this demo.\n");
- exit(0);
- }
- break;
-
- case CGA_ADP:
- gr_init(GR320,WHITE,BLUE,gr_cgap1_);
- sc_setcur(5,22);
- sc_puts("Graphics Test Program - 320x200");
- break;
-
- case EGA_ADP:
- gr_init(EGA_10,WHITE,BLUE,NULL);
- sc_setcur(5,22);
- sc_puts("EGA Graphics Test Program - 640x350");
- break;
-
- default:
- sc_setcur(5,20);
- sc_puts("Screen adapter not recognized..\n\r");
- exit(0);
- }
- /************************
- DO A RECTANGLE CLEAR
- *************************/
- sc_setcur(0,23); sc_eeol();
- sc_setcur(2,23);
- sc_puts("Clear a rectangle - 1 pixel at a time");
- gr_windo(0,0,grcols_,grrows_);
-
- gr_setpt(100,100);
-
- for(i=0; i<50; ++i)
- for(int j=0;j<50;++j)
- gr_setpt(i+135,j);
-
- /********************************************
- DRAW SOME LINES ON THE SCREEN IN CYAN
- *********************************************/
- sc_setcur(0,23); sc_eeol();
- sc_setcur(7,23);
- sc_puts("Push any key to draw lines");
- kb_getchar();
- gr_pen(0,LCYAN);
- for (i = 0; i <= 32; i++)
- gr_line(i*10, 0, 160, 170);
-
- /************************
- DRAW AND FILL A BOX
- *************************/
- sc_setcur(0,23); sc_eeol();
- sc_setcur(1,23);
- sc_puts("Push any key to draw a box and fill it");
- kb_getchar();
- gr_windo(8,8,110,110);
- gr_clr();
- gr_box(10,10,100,100);
- gr_box(22,22,50,50);
- gr_box (15,60,88,95);
- gr_fill(50,55);
-
-
- /***************************
- GET AND RESTORE A WINDO
- ****************************/
- sc_setcur(0,23); sc_eeol();
- sc_setcur(6,23);
- sc_puts("Push any key to get windo ");
- kb_getchar();
- ptr = gr_getwin(0,0,100,10);
- sc_setcur(0,23); sc_eeol();
- sc_setcur(6,23);
- sc_puts("push key to re-locate windo ");
- kb_getchar();
- gr_putwin(ptr,200,100,300,110);
- free(ptr);
-
-
- /**************************
- DRAW AND COPY A SHAPE
- ****************************/
- sc_setcur(0,23); sc_eeol();
- sc_setcur(6,23);
- sc_puts("Push any key to draw shape");
- kb_getchar();
- gr_wfull();
- gr_pos(50,110);
- gr_draw(shape1); /* draws shape on screen */
- sc_setcur(0,23); sc_eeol();
- sc_setcur(6,23);
- sc_puts("Push any key to copy shape");
- kb_getchar();
- gr_box(45,90,80,120);
- gr_windo(45,90,80,120);
- gr_scan(shape); /* scan screen to shape */
- gr_wfull();
- gr_pos(100,130);
- gr_draw(shape); /* draw it in new location */
-
-
- /**********************************************
- FOR CGA ADAPTER - DO SCREEN SAVE AND RESTORE
- ***********************************************/
- if(sc_adp_== CGA_ADP) {
- sc_setcur(0,23); sc_eeol();
- sc_setcur(2,23);
- sc_puts("Push any key to save current screen");
- kb_getchar();
- gr_getp(pic); /* save current screen */
- sc_clr();
- gr_wfull();
- sc_setcur(0,23); sc_eeol();
- sc_setcur(0,23);
- sc_puts("Push any key to restore previous screen");
- kb_getchar();
- gr_putp(pic);
- }
-
- /***********************************
- DRAW AND FILL A POLYGON
- ************************************/
- sc_setcur(0,23); sc_eeol();
- sc_setcur(1,23);
- sc_puts("Push any key to draw filled polygon");
- kb_getchar();
- gr_wfull();
-
- gr_windo(70,70,150,150);
- gr_clr();
- gr_pos(80,100);
- gr_scale(shape1,2.75);
- gr_poly(shape1);
- gr_fill(81,101);
-
- sc_setcur(0,23); sc_eeol();
- sc_setcur(9,23);
- sc_puts("Push any key to exit");
- kb_getc();
- co_init(0);
- co_mode(BW80,FWHITE,BBLACK);
- co_clr();
- exit(0);
- }
-
-