KC> Hi, I want to know how the write directly on the
KC> vga video memory in 640*480*16 mode.
Yuck... That is a slow video mode!
You have to use bit manipulation and switch planes.
But if your heart is set upon it, then enjoy...
This is Borland flavored code, though it should work as
well with Visual C++, since the original code was in
Quick C 2.5 and I just adapted it to C++.
You could, most likely, improve on it and optimize it
for speed and make it much better than it is.
It would still be comparitively slow, however.
The VESA mode for 640x480x256 is actually MUCH faster.
/*_|_| MODE12H.CPP PUBLIC DOMAIN ( part 1 of 4 )
_|_|_| Simple demonstration of pixel manipulation
_|_|_| in 640x480x16 video mode 12h.
_|_|_| Kurt Kuzba (5/13/1998)*/
#include
#include
#include
// global arrays for Mode12h::PutPixel
int g_iPix[8] = { 128, 64, 32, 16, 8, 4, 2, 1 };
int g_iPox[8] = { 127, 191, 223, 239, 247, 251, 253, 254 };
// class definition for Mode12h
class Mode12h {
public:
Mode12h();
~Mode12h();
void PutPixel(int, int, int);
void Line(int, int, int, int, int);
private:
void vidmode(char);
};
// Mode12h Private functions
void Mode12h::vidmode(char mode)
{
_asm{
mov ah, 00h
mov al, mode
int 10h
}
}
// Mode12h Public functions
Mode12h::Mode12h()
{
vidmode(0x12);
}
Mode12h::~Mode12h()
{
vidmode(0x03);
}
/*_|_| end MODE12H.CPP PUBLIC DOMAIN ( part 1 of 4 )*/
> ] A man has got to know his limits. [ Harry Callahan ] ......
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
|