changeset 2686:44ff6b5c7cea

Double buffering support
author nick
date Sun, 04 Nov 2001 16:20:58 +0000
parents 0ce577c9b641
children 8c75a9a639c1
files libvo/vo_vesa.c linux/vbelib.c
diffstat 2 files changed, 62 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_vesa.c	Sun Nov 04 15:04:32 2001 +0000
+++ b/libvo/vo_vesa.c	Sun Nov 04 16:20:58 2001 +0000
@@ -147,9 +147,9 @@
   if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK)
   {
     show_err:
+    vesa_term();
     PRINT_VBE_ERR("vbeSetWindow",err);
     printf("vo_vesa: Fatal error occured! Can't continue\n");
-    vesa_term();
     exit(-1);
   }
   win.low = new_offset * gran;
@@ -313,14 +313,19 @@
     if(!HAS_DGA()) __vbeCopyData(dga_buffer);
     flip_trigger = 0;
   }
-#if 0
   if(vo_doublebuffering && multi_size > 1)
   {
-   vbeSetDisplayStart(multi_buff[multi_idx],1);
-   multi_idx = multi_idx ? 0 : 1;
-   win.ptr = dga_buffer = video_base + multi_buff[multi_idx];
+    int err;
+    if((err=vbeSetDisplayStart(multi_buff[multi_idx],1)) != VBE_OK)
+    {
+      vesa_term();
+      PRINT_VBE_ERR("vbeSetDispayStart",err);
+      printf("vo_vesa: Fatal error occured! Can't continue\n");
+      exit(EXIT_FAILURE);
+    }
+    multi_idx = multi_idx ? 0 : 1;
+    win.ptr = dga_buffer = video_base + multi_buff[multi_idx];
   }
-#endif
 /*
   else
   if(tripple_buffering)
@@ -418,6 +423,34 @@
   }
 }
 
+static void paintBkGnd( void )
+{
+    int x_res = video_mode_info.XResolution;
+    int y_res = video_mode_info.YResolution;
+    int x, y;
+
+    for (y = 0; y < y_res; ++y)
+    {
+	for (x = 0; x < x_res; ++x)
+	{
+	    int r, g, b;
+	    if ((x & 16) ^ (y & 16))
+	    {
+		r = x * 255 / x_res;
+		g = y * 255 / y_res;
+		b = 255 - x * 255 / x_res;
+	    }
+	    else
+	    {
+		r = 255 - x * 255 / x_res;
+		g = y * 255 / y_res;
+		b = 255 - y * 255 / y_res;
+	    }
+	    __vbeSetPixel(x, y, r, g, b);
+	}
+    }
+}
+
 static char *model2str(unsigned char type)
 {
   char *retval;
@@ -796,42 +829,24 @@
 	  printf("vo_vesa: VESA initialization complete\n");
 	  fflush(stdout);
 	}
-	if(verbose)
+	if(HAS_DGA())
 	{
-		int x_res = video_mode_info.XResolution;
-		int y_res = video_mode_info.YResolution;
-		int x, y;
-
-		for (y = 0; y < y_res; ++y)
-			{
-			for (x = 0; x < x_res; ++x)
-				{
-				int r, g, b;
-				if ((x & 16) ^ (y & 16))
-					{
-					r = x * 255 / x_res;
-					g = y * 255 / y_res;
-					b = 255 - x * 255 / x_res;
-					}
-				else
-					{
-					r = 255 - x * 255 / x_res;
-					g = y * 255 / y_res;
-					b = 255 - y * 255 / y_res;
-					}
-
-				__vbeSetPixel(x, y, r, g, b);
-				}
-			}
+	    int y = 0;
+	    for(i=0;i<MAX_BUFFERS;i++)
+	    {
+		win.ptr = dga_buffer = video_base + multi_buff[i];
+		if(verbose) paintBkGnd();
+	    }
 	}
-	/*if(1)*/
+	else
 	{
-	  int x;
-	  x = video_mode_info.XCharSize ?
-	      (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2 :
-	      0;
-	  if(x < 0) x = 0;
-	  vbeWriteString(x,0,7,title);
+	    if(verbose) paintBkGnd();
+	    {
+	        int x;
+	        x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2;
+	        if(x < 0) x = 0;
+	        vbeWriteString(x,0,7,title);
+	    }
 	}
 	return 0;
 }
@@ -847,9 +862,9 @@
 static void
 uninit(void)
 {
+    vesa_term();
     if(verbose > 2)
         printf("vo_vesa: uninit was called\n");
-	vesa_term();
 }
 
 
--- a/linux/vbelib.c	Sun Nov 04 15:04:32 2001 +0000
+++ b/linux/vbelib.c	Sun Nov 04 16:20:58 2001 +0000
@@ -539,25 +539,29 @@
 	"pushl	%%ebx\n"
 	"movl	%1, %%ebx\n"
 	::"a"(0x4f07),"S"(vsync ? 0x80 : 0),
-	  "c"(offset & 0xffff),"d"((offset>>16)&0xffff):"memory");
+	  "c"((offset>>2) & 0xffff),"d"((offset>>18)&0xffff):"memory");
     (*vbe_pm_info.SetDisplayStart)();
     __asm __volatile("popl	%%ebx":::"memory");
     retval = VBE_OK;
   }
   else
   {
+#if 0
+    /* Something wrong here */
     struct LRMI_regs r;
     unsigned long pixel_num;
     memset(&r,0,sizeof(struct LRMI_regs));
+    pixel_num = offset%(unsigned long)curr_mode_info.BytesPerScanLine;
+    if(pixel_num*(unsigned long)curr_mode_info.BytesPerScanLine!=offset) pixel_num++;
     r.eax = 0x4f07;
     r.ebx = vsync ? 0x80 : 0;
-    pixel_num = offset%(unsigned long)curr_mode_info.BytesPerScanLine;
-    if(pixel_num*(unsigned long)curr_mode_info.BytesPerScanLine!=offset) pixel_num++;
     r.ecx = pixel_num;
     r.edx = offset/(unsigned long)curr_mode_info.BytesPerScanLine;
     if(!VBE_LRMI_int(0x10,&r)) return VBE_VM86_FAIL;
     retval = r.eax & 0xffff;
     if(retval == 0x4f) retval = VBE_OK;
+#endif
+    retval = VBE_BROKEN_BIOS;
   }
   return retval;
 }