Date: Tue, 13 Jul 93 11:32:29 -0400 From: max AT maya DOT cs DOT nyu DOT edu (David Max) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Animation using page flipping with LIBGRX Joe Clark's recent question about page flipping got me experimenting a bit. The following code will animate using page flipping: #include #include #include GrContext *page0, *page1; unsigned char screenpage; void pageflip(void) { union REGS reg; union REGS reg2; if (screenpage) { screenpage = 0; GrSetContext(page1); } else { screenpage = 1; GrSetContext(page0); } reg.h.al=screenpage; reg.h.ah=0x05; int86(0x10,®,®2); } void main(int argc, char **argv) { GrSetMode(GR_width_height_color_graphics,320,200,16); page0 = GrSaveContext(page0); page1 = GrSaveContext(page1); page1->gc_baseaddr += 0x2000; /* offset to next page for 320x200 */ screenpage = 0; pageflip(); loop { draw_something_that_depends_on_loop_variable(); pageflip(); } GrSetMode(GR_default_text); exit(0); } ...however, there are some problems with this method: 1) You can only flip pages in graphics modes that support pages in the VGA BIOS. In other words, standard VGA cards let you do pages in modes up to 640x350x16, and the interrupt doesn't seem to do the right thing in other modes even though I've got a whole 1 meg on my graphics card. 2) There is flickering. The problem results from page flipping while the screen is being drawn. The solution is to trap the vertical retrace period and flip the page then. Here's where I need help: How can I specify the start address of the frame buffer on the graphics card so that I can use all the memory on the card? In other words, how can I make this work with SVGA? How do I trap the vertical retrace? A routine should do something like: 1) Enable an interrupt for the vertical retrace. 2) When the interrupt happens, do the following. a. disable other interrupts b. flip the video pages c. clear the vertical retrace interrupt d. reenable other interrupts