I was trying to put double buffering into my VGA dos program but it seems that there is a problem when I use the memcpy function.
I'm sure that I allocate the required memory but it doesn't seem to work.
Here is the program:
#include <dos.h>
#include <string.h>
unsigned char* doublebuffer;
unsigned char far* VGA = (unsigned char far*) 0xA0000000L;
void setmode(int mode)
{
union REGS regs;
regs.h.ah = 0x0;
regs.h.al = mode;
int86(0x10, ®s, ®s);
}
void main()
{
doublebuffer =(unsigned char *) malloc(320*200);
setmode(0x13);
VGA[9*320+11] = 0x41;
doublebuffer[9*320+10] = 15;
if(doublebuffer[9*320+10] != 15)
{
exit(1);
}
memcpy(VGA, doublebuffer, 320*200);
getch();
}
malloc
works since the program doesn't crash and the buffer accepts the color but memcpy doesn't seem to work since there is nothing on the screen.
When I write into the VGA address directly it works. there would be a pink pixel on (11, 9) but no white pixel in (10, 9)