wahrhaft avatar wahrhaft committed 80a0a68

Use common resolution and fullscreen settings

Comments (0)

Files changed (5)

     return TRUE;
 }
 
-void Config_ReadScreenSettings(int *width, int *height, int *fullscreen)
+PackedScreenResolution Config_ReadScreenSettings()
 {
-    *width = ConfigGetParamInt(video_general_section, "ScreenWidth");
-    *height = ConfigGetParamInt(video_general_section, "ScreenHeight");
-    *fullscreen = ConfigGetParamBool(video_general_section, "Fullscreen");
+    PackedScreenResolution packedResolution;
+
+    packedResolution.width = ConfigGetParamInt(video_general_section, "ScreenWidth");
+    packedResolution.height = ConfigGetParamInt(video_general_section, "ScreenHeight");
+    packedResolution.fullscreen = ConfigGetParamBool(video_general_section, "Fullscreen");
+    
+    return packedResolution;
 }
 
 int Config_ReadInt(const char *itemname, int def_value, BOOL create)
 #define CONFIG_H
 
 #include "winlnxdefs.h"
+#include "m64p.h"
 
 BOOL Config_Open();
-void Config_ReadScreenSettings(int *width, int *height, int *fullscreen);
+PackedScreenResolution Config_ReadScreenSettings();
 int Config_ReadInt(const char *itemname, int def_value, BOOL create=TRUE);
 
 
   settings.card_id = (BYTE)Config_ReadInt ("card_id", 0);
   
   settings.depth_bias = -Config_ReadInt ("depth_bias", 0);
-  //TODO: use general settings resolution
-  settings.res_data = (DWORD) Config_ReadInt ("resolution", 7);
-  if (settings.res_data >= 24) settings.res_data = 12;
-  settings.scr_res_x = settings.res_x = resolutions[settings.res_data][0];
-  settings.scr_res_y = settings.res_y = resolutions[settings.res_data][1];
+  PackedScreenResolution packedResolution = Config_ReadScreenSettings();
+  settings.res_data = (DWORD) packedResolution.resolution;
+  settings.scr_res_x = settings.res_x = packedResolution.width;
+  settings.scr_res_y = settings.res_y = packedResolution.height;
   settings.autodetect_ucode = (BOOL)Config_ReadInt ("autodetect_ucode", 1);
   settings.ucode = (DWORD)Config_ReadInt ("ucode", 2);
   
     int read_alpha = INI_ReadInt ("fb_read_alpha", -1, 0);
     int depth_clear = INI_ReadInt ("fb_clear", -1, 0);
     //FIXME unused int depth_render = INI_ReadInt ("fb_render", -1, 0);
-    int resolution = (INT)INI_ReadInt ("resolution", -1, 0);
+    //int resolution = (INT)INI_ReadInt ("resolution", -1, 0);
     int cpu_write_hack = (INT)INI_ReadInt ("detect_cpu_write", -1, 0);
     
     if (filtering != -1) settings.filtering = filtering;
     if (read_alpha != -1) settings.fb_read_alpha= read_alpha;
     if (depth_clear != -1) settings.fb_depth_clear = depth_clear;
     if (cpu_write_hack != -1) settings.cpu_write_hack = cpu_write_hack;
+    /*
     if (resolution != -1)
     {
       settings.res_data = (DWORD) resolution;
       settings.scr_res_x = settings.res_x = resolutions[settings.res_data][0];
       settings.scr_res_y = settings.res_y = resolutions[settings.res_data][1];
     }
+    */
   }
   if (settings.fb_depth_render)
     settings.fb_depth_clear = TRUE;
     GRWINOPENEXT grSstWinOpenExt = (GRWINOPENEXT)grGetProcAddress("grSstWinOpenExt");
     if (grSstWinOpenExt)
       gfx_context = grSstWinOpenExt ((FxU32)NULL,
-      settings.res_data | ((evoodoo_using_window)?0x80:0x00),
+      settings.res_data,
       GR_REFRESH_60Hz,
       GR_COLORFORMAT_RGBA,
       GR_ORIGIN_UPPER_LEFT,
   }
   if (!gfx_context)
     gfx_context = grSstWinOpen ((FxU32)NULL,
-    settings.res_data | ((evoodoo_using_window)?0x80:0x00),
+    settings.res_data,
     GR_REFRESH_60Hz,
     GR_COLORFORMAT_RGBA,
     GR_ORIGIN_UPPER_LEFT,
 EXPORT void CALL ChangeWindow (void)
 {
   LOG ("ChangeWindow()\n");
-
+  //TODO: do this better
+  /*
   if (evoodoo)
   {
     if (!ev_fullscreen)
       ReleaseGfx ();
     }
   }
+  */
 }
 
 /******************************************************************
 
 #define LOG(...)
 
+//The Glide API originally used an integer to pick an enumerated resolution.
+//To accomodate arbitrary resolutions, pack it into a 32-bit struct
+//so we don't have to change function signatures
+union PackedScreenResolution
+{
+    struct 
+    {
+        int width : 16;
+        int height : 15;
+        int fullscreen : 1;
+    };
+    int resolution;
+};
+
+
 /* definitions of pointers to Core config functions */
 extern ptr_ConfigOpenSection      ConfigOpenSection;
 extern ptr_ConfigSetParameter     ConfigSetParameter;

src/wrapper/main.cpp

   
     LOG("grSstWinOpen(%d, %d, %d, %d, %d, %d %d)\r\n", hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
 
-    switch ((screen_resolution & ~0x80)&0xFF)
-    {
-    case GR_RESOLUTION_320x200:
-        width = 320;
-        height = 200;
-        break;
-    case GR_RESOLUTION_320x240:
-        width = 320;
-        height = 240;
-        break;
-    case GR_RESOLUTION_400x256:
-        width = 400;
-        height = 256;
-        break;
-    case GR_RESOLUTION_512x384:
-        width = 512;
-        height = 384;
-        break;
-    case GR_RESOLUTION_640x200:
-        width = 640;
-        height = 200;
-        break;
-    case GR_RESOLUTION_640x350:
-        width = 640;
-        height = 350;
-        break;
-    case GR_RESOLUTION_640x400:
-        width = 640;
-        height = 400;
-        break;
-    case GR_RESOLUTION_640x480:
-        width = 640;
-        height = 480;
-        break;
-    case GR_RESOLUTION_800x600:
-        width = 800;
-        height = 600;
-        break;
-    case GR_RESOLUTION_960x720:
-        width = 960;
-        height = 720;
-        break;
-    case GR_RESOLUTION_856x480:
-        width = 856;
-        height = 480;
-        break;
-    case GR_RESOLUTION_512x256:
-        width = 512;
-        height = 256;
-        break;
-    case GR_RESOLUTION_1024x768:
-        width = 1024;
-        height = 768;
-        break;
-    case GR_RESOLUTION_1280x1024:
-        width = 1280;
-        height = 1024;
-        break;
-    case GR_RESOLUTION_1600x1200:
-        width = 1600;
-        height = 1200;
-        break;
-    case GR_RESOLUTION_400x300:
-        width = 400;
-        height = 300;
-        break;
-    default:
-        width = 640;
-        height = 480;
-        display_warning("unknown SstWinOpen resolution : %x", screen_resolution);
-    }
+    PackedScreenResolution packedResolution;
+    packedResolution.resolution = screen_resolution;
+    width = packedResolution.width;
+    height = packedResolution.height;
 
-    m64p_video_mode screen_mode = M64VIDEO_WINDOWED;
-    if (!(screen_resolution & 0x80))
+    m64p_video_mode screen_mode;
+    if (packedResolution.fullscreen)
         screen_mode = M64VIDEO_FULLSCREEN;
+    else
+        screen_mode = M64VIDEO_WINDOWED;
 
     if (CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1) != M64ERR_SUCCESS ||
         CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16) != M64ERR_SUCCESS ||
         return 0;
     }
 
-    CoreVideo_SetCaption("Glide64!");
+    CoreVideo_SetCaption("Glide64");
     fullscreen = 0;
-#if 0
-    //TODO: remove
-
-   // init sdl & gl
-   const SDL_VideoInfo *videoInfo;
-   Uint32 videoFlags = 0;
-   
-   
-   /* Initialize SDL */
-   printf("(II) Initializing SDL video subsystem...\n");
-   if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
-   {
-     printf("(EE) Error initializing SDL video subsystem: %s\n", SDL_GetError());
-     return false;
-   }
-   
-   /* Video Info */
-   printf("(II) Getting video info...\n");
-   if(!(videoInfo = SDL_GetVideoInfo()))
-   {
-     printf("(EE) Video query failed: %s\n", SDL_GetError());
-     SDL_QuitSubSystem(SDL_INIT_VIDEO);
-     return false;
-   }
-   
-   /* Setting the video mode */
-   videoFlags |= SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
-   
-   if(videoInfo->hw_available)
-     videoFlags |= SDL_HWSURFACE;
-   else
-     videoFlags |= SDL_SWSURFACE;
-   
-   if(videoInfo->blit_hw)
-     videoFlags |= SDL_HWACCEL;
-   
-    if(screen_resolution & 0x80)
-      ;
-    else
-    {
-        viewport_offset = 0;
-        videoFlags |= SDL_FULLSCREEN;
-    }
-    viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20;
-
-
-  // ZIGGY not sure, but it might be better to let the system choose
-  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-  SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
-//   SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
-//   SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
-//   SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
-//   SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
-//   SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
-   
-   printf("(II) Setting video mode %dx%d...\n", width, height);
-   if(!(m_pScreen = SDL_SetVideoMode(width, height, 0, videoFlags)))
-     {
-    printf("(EE) Error setting videomode %dx%d: %s\n", width, height, SDL_GetError());
-    SDL_QuitSubSystem(SDL_INIT_VIDEO);
-    return false;
-     }
-   
-   char caption[500];
-# ifdef _DEBUG
-   sprintf(caption, "Glide64 Debug");
-# else // _DEBUG
-   sprintf(caption, "Glide64");
-# endif // _DEBUG
-   SDL_WM_SetCaption(caption, caption);
-#endif
 
    // ZIGGY viewport_offset is WIN32 specific, with SDL just set it to zero
     viewport_offset = 0; //-10 //-20;
     return;
   }
   CoreVideo_GL_SwapBuffers();
-  //TODO: remove
-  //SDL_GL_SwapBuffers();
   for (i = 0; i < nb_fb; i++)
     fbs[i].buff_clear = 1;
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.