TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: TIM ESSELENS
from: NIELS JONKER
date: 1997-03-25 01:08:00
subject: Re: Video

 TE> Is there enyone who could help me with the following prob.
 TE> ok, I'm new in c++ but.. Beter late then never :))
 TE> i'd like to make a demo for my bbs,
 TE> but i can't put out one pixel in vga mode...
 TE> (i even don't know how to put the program in vga mode)
 TE> is there someone who could send me like a source code or a manual
 TE> that could help me in my quest ta make a demo ?
Check out the PCGPE - PC Game Programmer Encyclopidia it's got info on this
(and a lot more)
But to keep you busy until then, here are some functions to start with.
Niels...
#include 
#include 
#include 
int setVidMode(int mode)
{
 /* Sets Video mode returns 0 on succes */
	int Status = 0;
	struct REGPACK reg;
	if(mode<=0xFF)  // set VGA video mode
	{
		reg.r_ax = mode; // set up registers
		intr(0x10,®); // call the video interrupt 10h
		reg.r_ax = 0x0F00;  // see if it worked by checking
		intr(0x10,®); //  current video mode
		if((reg.r_ax & 0xFF)!=mode)Status = reg.r_ax & 0xFF;
	}
	else            // set SVGA video mode (VESA)
	{
		reg.r_ax = 0x4F02;
		reg.r_bx = mode;
		intr(0x10,®);
		if(reg.r_ax!=0x004F)Status = reg.r_ax; // function failed
	}
	return Status;
}
void putpixel(int x,int y,unsigned char color)
{
  /* putpixel routine for VGA mode 13h 320x200x256 */
	static unsigned char far *Screen = (unsigned char far*)MK_FP(0xA000,0x0000);
	//Screen[x+y*320] = color;
	Screen[x+(y<<6)+(y<<8)] = color; /* same as above but here the
								 multiplication is replaced with
								 shifts to make it faster */
}
void setPalette(unsigned char color,unsigned char Red,unsigned char Green
			 ,unsigned char Blue)
{
	outportb(0x3c8,color);
	outportb(0x3c9,Red);
	outportb(0x3c9,Green);
	outportb(0x3c9,Blue);
}
int main()
{
	int St;
	if((St = setVidMode(0x13))==0) // set mode 13h
	{
	  // initialized video mode succesfull
		putpixel(160,100,10);  // draw a pixel
		getch();
		setPalette(10,63,0,0); // change pallette color
		getch();
		setVidMode(0x3); // set text mode 3h
	}
	else
	{
		cout << hex << "Failure setting video mode " << St << endl;
		getch();
	}
	return 0;
}
--- GEcho 1.11+
---------------
* Origin: Free sex on Softwareboard 0224-218587 {+} Reg.Only (2:280/112)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.