diff src/video/photon/SDL_ph_modes.c @ 821:30168104389f

Date: Sat, 14 Feb 2004 14:52:40 +0200 From: "Mike Gorchak" Subject: Batch of the QNX6 fixes for the SDL 1. Updated readme.QNX 2. Fixed crashes during intensive window updating under fast machines (got over 200 rectangles for update). 3. Fixed double-buffered fullscreen modes, now it works as needed. 4. Fixed Photon detection algorithm. 5. Fixed HWSURFACE update function. 6. Added SDL_PHOTON_FULLSCREEN_REFRESH environment variable support for control refresh rates under Photon. 7. Added 640x400 fullscreen mode emulation via 640x480 (if videodriver not supports original 640x400 mode of course) shifted by 40 vertical pixels from begin, to center it. It's needed for some old DOS games which ran in doubled 320x200 mode. 8. Added available video ram amount support. 8. Added hardware surface allocation/deallocation support if current videomode and videodriver supports it. 9. Added hardware filling support. 10. Added hardware blits support (simple and colorkeyed). And I've added to testvidinfo test color-keyed blits benchmark (maybe need to add alpha blits benchmark too ?). Currently Photon not supporting any alpha hardware blittings (all drivers lack of alpha blitting code support, only software alpha blitting exist in photon, which is hundreds times slowest than the SDL's one). So I've not added the alpha support. I suppose new QNX 6.3 will have the hardware alpha support, so when it will be done, I'll add alpha support.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 14 Feb 2004 20:22:21 +0000
parents b8d311d90021
children 4ab6d1fd028f
line wrap: on
line diff
--- a/src/video/photon/SDL_ph_modes.c	Sat Feb 14 10:12:27 2004 +0000
+++ b/src/video/photon/SDL_ph_modes.c	Sat Feb 14 20:22:21 2004 +0000
@@ -80,7 +80,7 @@
         SDL_modearray[i]=&SDL_modelist[i];
     }
 
-    if (PgGetVideoModeList( &mode_list ) < 0)
+    if (PgGetVideoModeList(&mode_list) < 0)
     {
        SDL_SetError("ph_ListModes(): PgGetVideoModeList() function failed !\n");
        return NULL;
@@ -109,10 +109,10 @@
 
     for(i=0; i<j; i++)
     {
-        SDL_modelist[i].w = Amodelist[j - i -1].w;
-        SDL_modelist[i].h = Amodelist[j - i -1].h;
-        SDL_modelist[i].x = Amodelist[j - i -1].x;
-        SDL_modelist[i].y = Amodelist[j - i -1].y;
+        SDL_modelist[i].w = Amodelist[j - i - 1].w;
+        SDL_modelist[i].h = Amodelist[j - i - 1].h;
+        SDL_modelist[i].x = Amodelist[j - i - 1].x;
+        SDL_modelist[i].y = Amodelist[j - i - 1].y;
     }
     SDL_modearray[j]=NULL;
 	
@@ -129,32 +129,54 @@
 int ph_GetVideoMode(int width, int height, int bpp)
 {
     int i;
+    int modestage=0;
+    int closestmode=0;
 
     if (PgGetVideoModeList(&mode_list) < 0)
     {
         return -1;
     }
 
+    /* special case for the double-sized 320x200 mode */
+    if ((width==640) && (height==400))
+    {
+       modestage=1;
+    }
+
     /* search list for exact match */
-    for (i=0;i<mode_list.num_modes;i++)
+    for (i=0; i<mode_list.num_modes; i++)
     {
         if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
         {
             return 0;
         }
 
-        if ((mode_info.width == width) && 
-            (mode_info.height == height) && 
+        if ((mode_info.width == width) && (mode_info.height == height) && 
             (mode_info.bits_per_pixel == bpp))
         {
             return mode_list.modes[i];
         }
+        else
+        {
+           if ((modestage) && (mode_info.width == width) && (mode_info.height == height+80) && 
+               (mode_info.bits_per_pixel == bpp))
+           {
+              modestage=2;
+              closestmode=mode_list.modes[i];
+           }
+        }
+    }
+
+    /* if we are here, then no 640x400xbpp mode found and we'll emulate it via 640x480xbpp mode */
+    if (modestage==2)
+    {
+       return closestmode;
     }
 
     return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
 }
 
-/* return the mode associated with width, height and bpp */
+/* return the mode associated with width, height and bpp               */
 /* if requested bpp is not found the mode with closest bpp is returned */
 int get_mode_any_format(int width, int height, int bpp)
 {
@@ -235,6 +257,8 @@
 {
     PgDisplaySettings_t settings;
     int mode;
+    char* refreshrate;
+    int refreshratenum;
 
     if (!currently_fullscreen)
     {
@@ -254,6 +278,22 @@
                 SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n");
                 return 0;
             }
+            if (PgGetVideoModeInfo(mode, &mode_info) < 0)
+            {
+                SDL_SetError("ph_EnterFullScreen(): can't get video mode capabilities !\n");
+                return 0;
+            }
+            if (mode_info.height != screen->h)
+            {
+               if ((mode_info.height==480) && (screen->h==400))
+               {
+                  videomode_emulatemode=1;
+               }
+            }
+            else
+            {
+               videomode_emulatemode=0;
+            }
         }
 
         /* save old video mode caps */
@@ -266,6 +306,15 @@
         settings.refresh = 0;
         settings.flags = 0;
 
+        refreshrate=getenv("SDL_PHOTON_FULLSCREEN_REFRESH");
+        if (refreshrate!=NULL)
+        {
+           if (sscanf(refreshrate, "%d", &refreshratenum)==1)
+           {
+               settings.refresh = refreshratenum;
+           }
+        }
+
         if (PgSetVideoMode(&settings) < 0)
         {
             SDL_SetError("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n");