[Rpcemu] Screen modes

Alex Waugh alex at alexwaugh.com
Wed Sep 19 21:59:11 BST 2007


Hi,

Attached is a patch to support arbitrarily large screen modes, rather
than the previously hardcoded maximum of 1024x768. It has had only
minimal testing (on Linux), but if people like it I'll continue and tidy
things up some more, and try adding support for toggling to and from
full screen.

Alex

-- 
Alex Waugh                                           alex at alexwaugh.com

PHP, Roots, Subversion, WebJames and more from http://www.alexwaugh.com/
-------------- next part --------------
Index: src/vidc20.c
===================================================================
--- src/vidc20.c	(revision 76)
+++ src/vidc20.c	(working copy)
@@ -114,18 +115,21 @@
 
 void closevideo();
 
+#define DEFAULT_W 640
+#define DEFAULT_H 480
+
 void initvideo()
 {
         int depth;
-//        int tempo=0;
+
 #ifdef FULLSCREENALWAYS
        depth=16;
        set_color_depth(16);
-       if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,640,480,0,0))
+       if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,DEFAULT_W,DEFAULT_H,0,0))
        {
                 set_color_depth(15);
                 depth=15;
-                if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,640,480,0,0))
+                if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,DEFAULT_W,DEFAULT_H,0,0))
                 {
                         printf("Failed to set video mode 640x480x16\n");
                         exit(-1);
@@ -137,19 +141,19 @@
         if (depth==16 || depth==15)
         {
                 set_color_depth(15);
-				depth=15;
-                if (set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0))
+                depth=15;
+                if (set_gfx_mode(GFX_AUTODETECT_WINDOWED,DEFAULT_W,DEFAULT_H,0,0))
                 {
                         set_color_depth(16);
                         depth=16;
-                        set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0);
+                        set_gfx_mode(GFX_AUTODETECT_WINDOWED,DEFAULT_W,DEFAULT_H,0,0);
                 }
                 drawcode=16;
         }
         else if (depth==32)
         {
                 set_color_depth(depth);
-                set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0);
+                set_gfx_mode(GFX_AUTODETECT_WINDOWED,DEFAULT_W,DEFAULT_H,0,0);
                 drawcode=32;
         }
         else
@@ -158,19 +162,16 @@
                 exit(0);
         }
 #endif
-//        set_color_depth(8);
-//        if (depth!=15) set_color_depth(16);
-//        else           set_color_depth(15);
 
 #ifdef HARDWAREBLIT
-bs=create_video_bitmap(1024,768);
-        b=create_video_bitmap(1024,768);
+bs=create_video_bitmap(DEFAULT_W,DEFAULT_H);
+        b=create_video_bitmap(DEFAULT_W,DEFAULT_H);
         if (!b) /*Video bitmaps unavailable for some reason*/
 #endif
-           b=create_bitmap(1024,768);
-//        b2=create_video_bitmap(1024,768);
+           b=create_bitmap(DEFAULT_W,DEFAULT_H);
+//        b2=create_video_bitmap(DEFAULT_W,DEFAULT_H);
 //        if (!b2) /*Video bitmaps unavailable for some reason*/
-//           b2=create_bitmap(1024,768);
+//           b2=create_bitmap(DEFAULT_W,DEFAULT_H);
         oldsx=64;
         oldsy=48;
 //        atexit(closevideo);
@@ -221,16 +222,6 @@
         #endif
         if (x<16) x=16;
         if (y<16) y=16;
-        if (fullscreen)
-        {
-                if (x>1280) x=1280;
-                if (y>1024) y=1024;
-        }
-        else
-        {
-                if (x>1024) x=1024;
-                if (y>768) y=768;
-        }
         oldsx=x;
         oldsy=y;
         while (inblit || blitready) sleep(1);
@@ -288,7 +279,7 @@
         }
         else
         {
-                if (lastfullscreen) destroy_bitmap(b);
+                destroy_bitmap(b);
                 if (lastfullscreen)
                 {
                         destroy_bitmap(bs);
@@ -296,14 +287,12 @@
                         destroy_bitmap(bs3);
                         destroy_bitmap(bs4);
                 }
-                if (lastfullscreen) set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
+                if (lastfullscreen) set_gfx_mode(GFX_AUTODETECT_WINDOWED,x,y,0,0);
                 updatewindowsize(x,y);
-                if (lastfullscreen) bs=create_video_bitmap(1024,768);
-#ifdef HARDWAREBLIT
-                if (lastfullscreen) b=create_video_bitmap(1024,768);
-#endif
-                if (!b && lastfullscreen) /*Video bitmaps unavailable for some reason*/
-                   b=create_bitmap(1024,768);
+                if (lastfullscreen) bs=create_video_bitmap(x,y);
+                b=create_video_bitmap(x,y);
+                if (!b) /*Video bitmaps unavailable for some reason*/
+                   b=create_bitmap(x,y);
                 lastfullscreen=0;
         }
         resetbuffer();
@@ -411,16 +400,6 @@
                 doublesize|=2;
         }
         #endif
-        if (fullscreen)
-        {
-                if (ys>1024) ys=1024;
-                if (xs>1280) xs=1280;
-        }
-        else
-        {
-                if (ys>768) ys=768;
-                if (xs>1024) xs=1024;
-        }
         if (ys!=oldsy || xs!=oldsx) resizedisplay(xs,ys);
         if (!(iomd.vidcr&0x20) || vdsr>vder)
         {


More information about the Rpcemu mailing list