Page 1 of 1

Page Flipping in VBE 3.0 (function 07H)

Posted: Thu Feb 28, 2019 8:24 am
by iman
Hi.
I am writing a VESA driver for my OS.
I have VBE 3.0 available, 14 MiB of VRAM, 1024 * 768 * 32 (bpp) mode. All these information have been acquired by calling int 10H functionality in PM mode.

There are two screen buffers. One starts at linear framebuffer address (fb) and the second one starts right after the first one.
I would like to implement page flipping with the use of VBE function 07H.
The code that i used is as follows:

Code: Select all

#define HIGH_WORD(U32) ((uint16_t)(U32>>16))
#define  LOW_WORD(U32) ((uint16_t)(U32&0x0000FFFF))
//+++++++++++++++++++++++++++++++++++++++++++++++++
void page_flip(unsigned long address) {
    regs16_t regs;
    regs.ax = 0x4F07;
    regs.bx = 0x00;
    regs.cx = LOW_WORD(address);
    regs.dx = HIGH_WORD(address);
    int32( 0x10, &regs );
}
//+++++++++++++++++++++++++++++++++++++++++++++++++
void test(unsigned char* fb) {
	unsigned int i, j, k, J = 0;
 	unsigned char * PAGE0  = fb;
	unsigned char * PAGE1  = (unsigned char*)( fb + ( 4096*768 ) ); 
	for(j=0; j<768;j++) {
		J = j*4096;
		for(i=0; i<4096;i+=4) {
                    PAGE0[J + i      ] = 0;
                    PAGE0[J + i + 1] = 0;
                    PAGE0[J + i + 2] = 255;
                    PAGE0[J + i + 3] = 0;

                    PAGE1[J + i      ] = 255;
                    PAGE1[J + i + 1] = 0;
                    PAGE1[J + i + 2] = 0;
                    PAGE1[J + i + 3] = 0;
		}
	}
	for(k=0;k<1000;k++) {
		page_flip((unsigned long)PAGE0);	
		page_flip((unsigned long)PAGE1);
	}
}
The problem is that it never flip the second page. Only for the first time, the PAGE0 is rendered and done!
I would appreciate if anybody can give me a hint that what the source of my issue might be.

For information: the int32 function had been successfully in assembly implemented and have been already utilized a lot for other VBE functionalities.
I personally think the problem comes from the values in CX and DX registers during calling function 07H.

Best.
Iman.

Re: Page Flipping in VBE 3.0 (function 07H)

Posted: Thu Feb 28, 2019 8:53 am
by Octocontrabass
iman wrote:I personally think the problem comes from the values in CX and DX registers during calling function 07H.
Correct. You're supposed to take the offset from the start of display memory and divide by 4, according to page 50 of the VBE Core Functions Standard 3.0.

Re: Page Flipping in VBE 3.0 (function 07H)

Posted: Thu Feb 28, 2019 10:24 am
by iman
Thanks a lot for your reply.
Please correct me if I am wrong. My second page starts at address fb + (1024*768*4). So as you suggested I have to get the offset of the page, divide it by 4 and pass it to CX and DX.
Then it makes:
offset = 1024*768;
CX = LOW_WORD(offset); and DX = HIGH_WORD(offset);

I did as above, but the problem still remains as before.