[comp.os.msdos.programmer] Accessing full VGA colour/Grey scale in C preferably

david@kessner.denver.co.us (David Kessner) (06/06/91)

In article <1017@macuni.mqcc.mq.oz> rees@suna.mqcc.mq.oz.au (Rees Griffiths) writes:
>      Could somebody please provide me with some pointers to the
>necessary code to access the full 256 colours that VGA has to offer.
>Most languages only provide built in support for 16 colours (Turbo C).
>  Any books/source code that are available would be most appreciated.

>rees@suna.mqcc.mq.oz.au

Here is the simple way of using the 320x200x256 mode of VGA:

	Set video mode to 0x13 via BIOS call INT 10
	Draw at the video memory starting at A000:0
	When done, reset to the normal video mode (0x03 I think).

To plot a pixel:

	void set_pixel( int x, int y, unsigned char color)
	{
	unsigned offset;
	static unsigned char far *video_mem=0xA0000000;

	offset = y*320 + x;
	*(video_mem + offset) = color;	
	}

That's not the cleanest way of doing it, but it should be enough to get you
started.  As you probably noticed, I avoided talking about the SVGA modes
that allow anything from 640x400x256 to 1024x768x256.  These modes are
different for each video adapter, so I cannot list all the ways here (as
if I know them). 

I reccomend the book:

	Programmers Guide to PC and PS/2 Video Systems
	published by Microsoft Press.

There is another book writen on the Super-VGA modes-- but I forgot the
name.  It is hard to miss since it is the only book with SVGA in the
title...

These two will get you going on programming VGA cards.  There are other
books that you will need that cover the basics of computer graphics:  Line
drawing, circles, bit-blocks, polygons, 3-D displays, animation, etc.  Again,
I forgot the name of the book, but you cannot miss it:  It is a thick, white,
hardback published by Addision Wesley and runs about $65 (I have a previous
version of this book that goes by a different name).  

I hope that helps-- VGA programming can be a confusing issue.  

-- 
David Kessner - david@kessner.denver.co.us            |
1135 Fairfax, Denver CO  80220  (303) 377-1801 (p.m.) | Reunite PANGEA!
Compuserve?  Isn't that some sort of FIDO BBS?        |

samkho@athena.mit.edu (Samuel P Kho) (06/07/91)

In article <1991Jun6.083037.21366@kessner.denver.co.us> david@kessner.denver.co.us (David Kessner) writes:
>In article <1017@macuni.mqcc.mq.oz> rees@suna.mqcc.mq.oz.au (Rees Griffiths) writes:
>>      Could somebody please provide me with some pointers to the
>>necessary code to access the full 256 colours that VGA has to offer.
>>Most languages only provide built in support for 16 colours (Turbo C).
>>  Any books/source code that are available would be most appreciated.
>
>These two will get you going on programming VGA cards.  There are other
>books that you will need that cover the basics of computer graphics:  Line
>drawing, circles, bit-blocks, polygons, 3-D displays, animation, etc.  Again,
>I forgot the name of the book, but you cannot miss it:  It is a thick, white,
>hardback published by Addision Wesley and runs about $65 (I have a previous
>version of this book that goes by a different name).  

	I believe you're referring to:
	
	Fundamentals of Interactive Computer Graphics, 2nd Edition
	Foley and Van Dam (with 2 other authors in 2nd ed)

another good book is:

	Principles of Interactive Computer Graphics
	Newmann and Sproull

	- sam -