cont...256 colors in C...

tom hand TTH102 at psuvm.psu.edu
Sat Sep 1 01:17:20 AEST 1990


Sorry about this continuation, I accidentally posted the original
artical before it was finished...

The program is actually rather simple, atleast from where dos
interupt calls are concerned. It starts out by initiallizing
mode 13h using int 10h.
Then I have a function which will put a display a pixel in
whatever color I want using mode 0C. Well here is the function...

dot(int x,int y)
{
        union REGS a,b;
        a.h.ah = 0x0C;
        a.h.al = color;    (global var.)
        a.h.bh = 0;
        a.h.cl = x;
        a.h.dl = y;
        int86(0x10, &a, &b);
}

What the program does is display the "Rose Function" aka "Clover Funcion"
repeatedly on the screen in different colors (256 of them).
Here is Where I ran into trouble.

I compiled and ran the program, and it worked wonderfully only as long as
stayed outside turboc's integrated environment. But as soon as I tried
running it from inside the editor, the function would skip whole sections
of the screen, leaving them blank, and then countinue to draw on the
other side of the blank spot. I got even more interesting results when I
took that same program and ran it on a different machine. The function
would not come out smoothly, but would be scrambled on the screen. As if
somehow it would randomly pick a place to start drawing.

So I compiled the same program on that machine (IBM ps/2 mod 50), ran it
and got the same results (scramble).

What am I doing wrong? Since Dos is suposed to keep track of Graphics as
well as everything else, why isn't my program portable?
-------------------------------------------------------------------
       Thomas Hand (TTH102 at psuvm)...
-------------------------------------------------------------------
  Note: The opinions expressed here are those of the author,
        and may not be shared by faculty or students of PSU...
-------------------------------------------------------------------



More information about the Comp.lang.c mailing list