2

I am in dos environment and have a segment memory of 64k(In 16bit dos,begin with:0xA000:0000),mapping directly to the framebuffer of the svga card.

I can manipulate the pixel displayed on the screen by writing data to that segment(and also with the help of a function that selects page so as to access the whole video memory using just 64k).

The putpixel function is something like:

char far* scr = 0xA0000000
addr = (unsigned long)y*((unsigned long)COLS*4)+((unsigned long)x*4);// offset bytes
scr+=addr; // scr will be limited in one segment
if((NewPage=addr>>16)!=OldPage) {  // equal to:addr/65536 
    OldPage = NewPage;
    SelectPage(NewPage);
}


// color--4bytes,store the value of the pixel

*scr++=color;
*scr++=color>>8;
*scr++=color>>16;

The question is,how can I avoid flickering if I need to putpixels and clear them very often on the screen?(For example,I need to make a small piece of image move on the screen fluently).

I have heard about double buffering but in dos,I do not know how to deal with page changing(because you copy 64k to 0xA0000000 directly).

Does anyone has experience of svga programing in dos ? Should I wait for vertical blanking of CRT before calling putpixel?

I have found the document but don't know how to program directly on the register of svga video card:

https://web.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/crtcreg.htm#15

for vga card, a lot of people use this to wait:

    while(!inportb(0x3da)&0x08);

Does anyone know how to do this for svga programing ?(or there may be another way to solve this?)

programforjoy
  • 391
  • 3
  • 12
  • see [EGA/VGA DAC palette IO access](http://stackoverflow.com/a/19642738/2521214) it is written in C++ and it uses inline asm to access IO. If you are really in DOS environment then it should work. Just change the IO Address to the SVGA registers ... If you are in Windows or something (not in emulator) you need to have Kernel mode priviledges so use something like DLL Port IO or any similar driver (but beware it is a security risk). Also backbuffering can be done in normal Memory and then copy the resulting image only to SVGA that should eliminate flicker completely – Spektre Nov 02 '15 at 10:57
  • Also you can wait for synchronization but not at single pixel level !!! that would be SLOOOOOOOOWWWWW. Instead you do this prior to copy/render the whole thing .... – Spektre Nov 02 '15 at 11:45

0 Answers0