
 /* SD_CommonGfxSubs.c
    - Functions for use with various Gfx Formats -
    (c) 1993-94 by Andreas R. Kleinert
    Last changes : 13.02.1994
 */

#include "svdriver.h"

ULONG __saveds __stdargs SVDI_GetBestModeID(long width, long height, long depth);

/* *************************************************** */
/* *						     * */
/* * SVDI_GetBestModeID : (do that)                  * */
/* *						     * */
/* *************************************************** */

ULONG __saveds __stdargs SVDI_GetBestModeID(long width, long height, long depth)
{
 ULONG mode_id = N;

 if(OS_VER > 38)
  {
   mode_id = BestModeID(BIDTAG_NominalWidth,  width,
                        BIDTAG_NominalHeight, height,
                        BIDTAG_DesiredWidth,  width,
                        BIDTAG_DesiredHeight, height,
                        BIDTAG_Depth,         depth,
                        TAG_END);
  }

 if(!mode_id) /* if OS < V39 or BestModeID failed */
  {
   /* Uses OverScan values for checking. */
   /* Assumes an ECS-System.             */

        if(width > 724 && depth < 3)   mode_id = SUPER_KEY;
   else if(width > 362 && depth < 5)   mode_id = HIRES_KEY;
   else                                mode_id = LORES_KEY;

   if(!ModeNotAvailable(mode_id | PAL_MONITOR_ID))    /* for PAL  Systems */
    {
     if(height > 283) mode_id |= LACE;

     mode_id |= PAL_MONITOR_ID;
    }else
    {
     if(!ModeNotAvailable(mode_id | NTSC_MONITOR_ID)) /* for NTSC Systems */
      {
       if(height > 241) mode_id |= LACE;

       mode_id |= NTSC_MONITOR_ID;
      }
    }
  }

 return(mode_id);
}
