C

The graphic test program of the video terminal was originally written in BASIC. I managed to translate it into C language (Hi-tech 3.09) and build a library to more simply invoke the primitive graphics functions.

The generation of a random number is regulated by the variable “t” type time_t. The time.h library defines the time_t type which represents the amount of time units elapsed, in number of seconds, from January 1, 1970 to the current second. 

You will find libv.lib and libg.lib libraries in the section dedicated to the Hi-tech C compiler. The compilation directive is C -v graphic.c libv.lib libg.lib.

Anyway here the link of graphic.com: https://automatico.freevar.com/dump/graphic.com

#include <stdio.h>
#include <conio.h>
#include <sys.h>
#include <math.h>
#include <stdlib.h>
#include <cpm.h>
#include <time.h>
#include <libv.h>
#include <libg.h>

main()
{
        int c, i;
        int r,g,b;
        int x,y;
        int x1,x2,y1,y2;

        time_t t;

        char buf[32];
        char string[129];
        memset(string,0,sizeof(string));

        srand(time(&amp;amp;amp;t));

        gcursoff();
        gclear();

        /* punti */
        i = 100;
        while(i--)
        {
                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;
                gpen(r,g,b);
                x=1+rand()%640;
                y=1+rand()%480;
                gpixel(x,y);
        }

        i = 120;
        while(i--)
        {
                gscroll(4,4);
        }

        /* linee */
        i = 100;
        while(i--)
        {
                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;
                gpen(r,g,b);
                x1=1+rand()%640;
                y1=1+rand()%480;
                x2=1+rand()%640;
                y2=1+rand()%480;
                gdraw(x1,y1,x2,y2);
        }

        i = 120;
        while(i--)
        {
                gscroll(-4,4);
        }

        /* rettangoli */
        i = 50;
        while(i--)
        {
                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;
                gbrush(r,g,b);
                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;
                gpen(r,g,b);
                x1=1+rand()%640;
                y1=1+rand()%480;
                x2=1+rand()%640;
                y2=1+rand()%480;
                gfillrect(x1,y1,x2,y2);
                grect(x1,y1,x2,y2);
        }
        i = 120;
        while(i--)
        {
                gscroll(4,-4);
        }

        /* ellissi */
        i = 50;
        while(i--)
        {
                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;
                gbrush(r,g,b);

                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;
                gpen(r,g,b);

                x1=1+rand()%640;
                y1=1+rand()%480;

                x2=1+rand()%640;
                y2=1+rand()%480;

                gfillelp(x1,y1,x2,y2);
                gellipse(x1,y1,x2,y2);
        }

        i = 120;
        while(i--)
        {
                gscroll(-4,-4);
        }

        /* poligoni */
        i = 50;

        while(i--)
        {
                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;

                gbrush(r,g,b);

                r=1+rand()%255;
                g=1+rand()%255;
                b=1+rand()%255;

                gpen(r,g,b);

                c = 3 + rand()%4;
                /* minimo 3 massimo 6 coppie di coordinate */
                /* ogni coppia di coordinate occupa 8 caratteri */
                while (c--)
                {
                        x=1+rand()%640;
                        itoa(x,buf,10);
                        strcat(string,buf);
                        strcat(string,";");

                        y=1+rand()%480;
                        itoa(y,buf,10);

                        strcat(string,buf);
                        if (c>0)
                        { strcat(string,";"); }
                }
                strcat(string,"$");

                gfillpth(string);
                gpath(string);

                memset(string,0,sizeof(string));
        }

        i = 120;
        while(i--)
        {
                gscroll(-4,0);
        }

        gclear();
        gclrterm();
        gcurson();
}

Loading

Pages: 1 2