Jump to content

How to display all 64 EGA colors on a VGA display in C?

- - - - -

  • Please log in to reply
7 replies to this topic

#1
mircea2011

mircea2011

    Newbie

  • Members
  • Pip
  • 8 posts
Hy,
Try to make a program to display all 64 EGA colors, but when I compil it, I receive the next error : graph.h : No such file or directory.
Understand that i must link that library. Way i have made : build options -> linker settings -> Add -> C::B -> lib ....
I dont find that library.
Thank you.


#define xsize 27

#define ysize 14

#include <graph.h>                                   /* link with GRAPHICS.LIB */

#include <dos.h>

main()

{

  int i, R,G,B;

  _setvideomode(0x13);                             /* set 256-color mode */

  for (i=0; i<=64; i++) {                             /* assign EGA colors to VGA registers */

      if ((i & 32) == 32) R=21; else R=0;

      if ((i & 16) == 16) G=21; else G=0;

      if ((i &  8) ==  8) B=21; else B=0;

      if ((i &  4) ==  4) R+=42;

      if ((i &  2) ==  2) G+=42;

      if ((i &  1) ==  1) B+=42;

      vgacolor(i,R,G,B);

  }

  showcolor();

  getche();    

  _setvideomode(0x3); /* reset video mode for text mode */

}

vgacolor(registr,red,green,blue)

int registr, red, green, blue;

{

  union REGS inreg, outreg;    

  inreg.x.ax = 0x1010;      	

  inreg.x.bx = registr;     	

  inreg.h.dh = red;         	

  inreg.h.ch = green;       	

  inreg.h.cl = blue;        	

  int86(0x10, &inreg, &outreg);

}

showcolor()

{

  int o, color, x,y;

  for (o=0, y=-4, color=0; o < 8; o++)

    for (x=4, y+=(ysize+7); x < 320; x+=(xsize+13)) {

     _setcolor(247);     _rectangle(_GFILLINTERIOR,x+3,y+3,x+xsize+3,y+ysize+3);

     _setcolor(color++); _rectangle(_GFILLINTERIOR,x,y,x+xsize,y+ysize);

  }

}

Edited by Alyn, 30 October 2011 - 04:27 AM.
added code tag


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
What compiler are you using on what system?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
mircea2011

mircea2011

    Newbie

  • Members
  • Pip
  • 8 posts
I use enviroment Code::Blocks with compiler GNU GCC Compiler.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
graph.h and dos.h are non-standard libraries, so might not be included with MinGW (if you are on Windows XX). If you're using GCC on linux, I can almost guarantee they don't exist at all. So, what operating system are you on?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
mircea2011

mircea2011

    Newbie

  • Members
  • Pip
  • 8 posts
windows 7

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Doing some searches, it looks like you are in trouble. graph.h is OLD. People were trying to track it down in 2004. The library is from 16-bit DOS days. It raises the question: why are you trying to do any of this?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
mircea2011

mircea2011

    Newbie

  • Members
  • Pip
  • 8 posts
I am just curios. That its all.
Anyway thank you for your interest.

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
You're going to have to use a modern graphics library like OpenGL to do this. In Windows XP and older versions you could use interrupts to change video modes and stuff (with some restrictions) but starting with Vista, that capability was removed. If you want to do real-mode programming, then​ you can do that sort of thing and I can easily help you.
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users