Here is a diff to mode.c
Not tested. and doesn't work yet.

John
--- mode.c.original     Fri Jun 22 00:46:21 2001
+++ mode.c      Fri Jun 22 01:07:52 2001
@@ -69,7 +69,6 @@
        return ret;
 }
 
-#if 0
 int GGI_svga_setorigin(ggi_visual *vis,int x,int y)
 {
        if (x != 0 || y<0 || y> LIBGGI_MODE(vis)->virt.y )
@@ -83,7 +82,6 @@
        
        return 0;
 }
-#endif
 
 int GGI_svga_flush(ggi_visual *vis, int x, int y, int w, int h, int tryflag)
 {
@@ -124,20 +122,11 @@
        return -1;
 }
 
-int GGI_svga_setmode(ggi_visual *vis, ggi_mode *tm)
-{ 
-       struct svga_priv *priv = LIBGGI_PRIVATE(vis);
-       char modestr[64], *colors;
-       int modenum;
-       vga_modeinfo *modeinfo;
-       int err = 0;
-       int id;
-       char sugname[256];
-       char args[256];
+static int *GGI_svga_make_modeline(ggi_mode *tm)
+{
+       char modestr[64];
+       char *colors;
 
-       err = GGI_svga_checkmode(vis, tm);
-       if (err) return err;
-       
        /* See GGI_svga_checkmode() for details... */
        switch(tm->graphtype) {
        case GT_1BIT : colors = "2"; break;
@@ -152,8 +141,27 @@
 
        /* Form a SVGAlib mode number */
        sprintf(modestr, "G%dx%dx%s", tm->visible.x, tm->visible.y, colors);
+
        modenum = vga_getmodenumber(modestr);
-       GGIDPRINT("Setting SVGAlib mode %d: %s\n", modenum, modestr);
+
+       return modenum;
+}
+
+int GGI_svga_setmode(ggi_visual *vis, ggi_mode *tm)
+{ 
+       struct svga_priv *priv = LIBGGI_PRIVATE(vis);
+       int modenum;
+       vga_modeinfo *modeinfo;
+       int err = 0;
+       int id;
+       char sugname[256];
+       char args[256];
+
+       err = GGI_svga_checkmode(vis, tm);
+       if (err) return err;
+       
+       modenum = GGI_svga_make_modeline(tm);
+       GGIDPRINT("Setting SVGAlib mode %d: %s\n", modenum);
 
        if (_ggi_svgalib_setmode(modenum) != 0) return GGI_EFATAL;
 
@@ -216,6 +224,12 @@
                LIBGGI_APPBUFS(vis)[0]->buffer.plb.stride = modeinfo->linewidth;
                LIBGGI_APPBUFS(vis)[0]->buffer.plb.pixelformat
                        = LIBGGI_PIXFMT(vis);
+               ret = vga_claimvideomemory(modeinfo->bpp * tm->virt.x * tm->virt.y * 
+tm->frames);
+               if (ret)
+               {
+                       fprintf(Stderr, "display-svga: Can't allocate enough display 
+memory: %d bytes.\n", modeinfo->bpp * tm->virt.x tm->virt.y * tm->frames);
+                       return GGI_EFATAL;
+               }
        }
 
 /* virt.x != visible.x should be possible with this,
@@ -240,8 +254,7 @@
                }
        }
 
-       /* Doesn't work correct */
-       /*vis->opdraw->setorigin=GGIsetorigin;*/
+       vis->opdraw->setorigin = GGI_svga_setorigin;
        
        if (priv->ismodex) {
                vis->opdraw->putpixel_nc        = GGI_svga_putpixel_nc;
@@ -276,12 +289,16 @@
 int GGI_svga_checkmode(ggi_visual *vis,ggi_mode *tm)
 {
        svga_priv *priv = LIBGGI_PRIVATE(vis);
+       vga_modeinfo *vmi = NULL;
+       int mode = 0;
+
 
        int ret, err = 0;
 
        if (vis==NULL || tm==NULL)
                return -1;
        
+
        if (tm->visible.x == GGI_AUTO)
                tm->visible.x = tm->virt.x;
        if (tm->visible.y == GGI_AUTO)
@@ -300,6 +317,9 @@
        if(tm->virt.x==GGI_AUTO) tm->virt.x = tm->visible.x;
        if(tm->virt.y==GGI_AUTO) tm->virt.y = tm->visible.y;
 
+       mode = GGI_svga_make_modeinfo(tm);
+       vmi = vga_getmodeinfo(mode);
+
        /* SVGAlib doesn't seem to support virtual dimensions
           Force them to be the same as visible size */
        if(tm->virt.x != tm->visible.x) {
@@ -312,10 +332,20 @@
        }
  
        /* Multiple frames are not implemented yet... */
+       /*
        if (tm->frames != 1 && tm->frames != GGI_AUTO) {
                err = -1;
        }
        tm->frames = 1;
+       */
+
+       /* Only support frames when we can support linear access 
+        * and we have enough video memory */
+       if (!(vmi->flags & CAPABLE_LINEAR)
+                       && (vmi->memory < (vmi->bpp * tm->virt.x * tm->virt.y * 
+tm->frames)))
+       {
+               tm->frames = 1;
+       }
 
        if ((tm->dpp.x != 1 && tm->dpp.x != GGI_AUTO) ||
            (tm->dpp.y != 1 && tm->dpp.y != GGI_AUTO)) {

Reply via email to