- printf("avail video pages: %d\n", mode_info->num_img_pages);
- printf("bytes per scanline: %d (%d pixels)\n", vbe_get_scanlen(VBE_SCANLEN_BYTES),
- vbe_get_scanlen(VBE_SCANLEN_PIXELS));
+ curmode = vm;
+ if(nbuf < 1) nbuf = 1;
+ if(nbuf > 2) nbuf = 2;
+ pgcount = nbuf > vm->max_pages + 1 ? vm->max_pages + 1 : nbuf;
+ pgsize = vm->ysz * vm->pitch;
+ fbsize = pgcount * pgsize;
+
+ if(vm->bpp > 8) {
+ printf("rgb mask: %x %x %x\n", (unsigned int)vm->rmask,
+ (unsigned int)vm->gmask, (unsigned int)vm->bmask);
+ printf("rgb shift: %d %d %d\n", vm->rshift, vm->gshift, vm->bshift);
+ }
+ printf("pgcount: %d, pgsize: %d, fbsize: %d\n", pgcount, pgsize, fbsize);
+ if(vm->fb_addr) {
+ printf("phys addr: %p\n", (void*)vm->fb_addr);
+ }
+ fflush(stdout);
+
+ if(vm->fb_addr) {
+ vpgaddr[0] = (void*)dpmi_mmap(vm->fb_addr, fbsize);
+ if(!vpgaddr[0]) {
+ fprintf(stderr, "failed to map framebuffer (phys: %lx, size: %d)\n",
+ (unsigned long)vm->fb_addr, fbsize);
+ set_text_mode();
+ return 0;
+ }
+ memset(vpgaddr[0], 0xaa, pgsize);
+
+ if(pgcount > 1) {
+ vpgaddr[1] = (char*)vpgaddr[0] + pgsize;
+ backidx = 1;
+ page_flip(FLIP_NOW); /* start with the second page visible */
+ } else {
+ frontidx = backidx = 0;
+ vpgaddr[1] = 0;
+ }