void _glfwGetModeIDInfo( ULONG ModeID, int *w, int *h, int *r, int *g,
                        int *b, int *refresh )
{
    struct DimensionInfo dimsInfo;
    struct DisplayInfo   dispInfo;
    struct MonitorInfo   monInfo;

    // Get various display info
    (void) GetDisplayInfoData( NULL,
                               (BYTE*) &dimsInfo,
                               sizeof(struct DimensionInfo),
                               DTAG_DIMS,
                               ModeID );
    (void) GetDisplayInfoData( NULL,
                               (BYTE*) &dispInfo,
                               sizeof(struct DisplayInfo),
                               DTAG_DISP,
                               ModeID );
    (void) GetDisplayInfoData( NULL,
                               (BYTE*) &monInfo,
                               sizeof(struct MonitorInfo),
                               DTAG_MNTR,
                               ModeID );

    // Extract nominal width & height
    if( w != NULL && h != NULL )
    {
        *w = (int) (dimsInfo.Nominal.MaxX - dimsInfo.Nominal.MinX) + 1;
        *h = (int) (dimsInfo.Nominal.MaxY - dimsInfo.Nominal.MinY) + 1;
    }

    // Extract color bits
    if( r != NULL && g != NULL && g != NULL )
    {
        *r = (int) dispInfo.RedBits;
        *g = (int) dispInfo.GreenBits;
        *b = (int) dispInfo.BlueBits;

        // If depth < sum of RGB bits, we're probably not true color,
        // which means that DisplayInfo red/green/blue bits do not refer
        // to actual pixel color depth => use pixel depth info instead
        if( dimsInfo.MaxDepth < (*r + *g + *b) )
        {
            _glfwBPP2RGB( dimsInfo.MaxDepth, r, g, b );
        }
    }

    // Extract refresh rate
    if( refresh != NULL )
    {
        *refresh = (int) (1.0 / ((double) monInfo.TotalRows *
                                 (double) monInfo.TotalColorClocks *
                                 280.0e-9) + 0.5 );
    }
}
// Display mode support
void _config_env_screenmode_init(config_env_data *data,BOOL refresh)
{
	struct NameInfo nameinfo;
	int sel;

	// Get current mode
	switch (data->config->screen_mode)
	{
		case MODE_WORKBENCHUSE:
			stccpy(
				data->mode_name,
				GetString(locale,MSG_ENVIRONMENT_SCREENMODE_WB_USE),
				sizeof(data->mode_name));
			break;

		case MODE_WORKBENCHCLONE:
			stccpy(
				data->mode_name,
				GetString(locale,MSG_ENVIRONMENT_SCREENMODE_WB_CLONE),
				sizeof(data->mode_name));
			break;

		case MODE_PUBLICSCREEN:
			lsprintf(data->mode_name,"%s:%s",
				data->config->pubscreen_name,
				GetString(locale,MSG_USE));
			break;

		default:
			// Get mode name (if available)
			if (GetDisplayInfoData(
				0,
				(char *)&nameinfo,
				sizeof(nameinfo),
				DTAG_NAME,
				data->config->screen_mode))
			{
				stccpy(data->mode_name,nameinfo.Name,sizeof(data->mode_name));
			}
			else
			{
				data->mode_name[0]=0;
			}
			break;
	}

	// Set current mode selection
	if (refresh)
	{
		sel=Att_NodeNumber(data->mode_list,data->mode_name);
		SetGadgetValue(data->option_list,GAD_ENVIRONMENT_SCREENMODE_MODE,sel);
	}

	// Initialise mode data
	_config_env_screenmode_init_mode(data,refresh);
}
Beispiel #3
0
int AMI_ILBM_agaIsSupported()
{
    struct DisplayInfo displayInfo;
    
    if(GetDisplayInfoData(NULL, (UBYTE*)&displayInfo, sizeof(struct DisplayInfo), DTAG_DISP, NULL))
        return (displayInfo.RedBits == 8);
    else
    {
        fprintf(stderr, "WARNING: No display info found! Assuming we have an ECS chipset!\n");
        return FALSE;
    }
}
Beispiel #4
0
// Get information about a screen
ULONG __asm __saveds L_ScreenInfo(register __a0 struct Screen *screen)
{
	ULONG info=0,mode;
	struct DisplayInfo disp;

	// Valid screen?
	if (!screen) return 0;

	// Get display mode
	if ((mode=GetVPModeID(&screen->ViewPort))==INVALID_ID) return 0;

	// Get DisplayInfo
	if (!(GetDisplayInfoData(0,(char *)&disp,sizeof(struct DisplayInfo),DTAG_DISP,mode)))
		return 0;

	// See if screen is lo-res
	if (disp.Resolution.y>=disp.Resolution.x*2)
		info=SCRI_LORES;

	return info;
}
Beispiel #5
0
void ami_font_setdevicedpi(int id)
{
	DisplayInfoHandle dih;
	struct DisplayInfo dinfo;
	ULONG ydpi = option_amiga_ydpi;
	ULONG xdpi = option_amiga_ydpi;

	nscss_screen_dpi = INTTOFIX(option_amiga_ydpi);

	if(id && (option_monitor_aspect_x != 0) && (option_monitor_aspect_y != 0))
	{
		if(dih = FindDisplayInfo(id))
		{
			if(GetDisplayInfoData(dih, &dinfo, sizeof(struct DisplayInfo),
				DTAG_DISP, 0))
			{
				int xres = dinfo.Resolution.x;
				int yres = dinfo.Resolution.y;

				if((option_monitor_aspect_x != 4) || (option_monitor_aspect_y != 3))
				{
					/* AmigaOS sees 4:3 modes as square in the DisplayInfo database,
					 * so we correct other modes to "4:3 equiv" here. */
					xres = (xres * option_monitor_aspect_x) / 4;
					yres = (yres * option_monitor_aspect_y) / 3;
				}

				xdpi = (yres * ydpi) / xres;

				LOG(("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %ld x %ld, corrected %ld x %ld)",
					xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres));
			}
		}
	}

	ami_xdpi = xdpi;
	ami_devicedpi = (xdpi << 16) | ydpi;
}
Beispiel #6
0
/*************
 * DESCRIPTION:   Loads a image with the datatypes.
 * INPUT:         filename    name of picture to load
 * OUTPUT:        FALSE if failed
 *************/
BOOL IMAGE::LoadAsDatatype(char *filename)
{
    struct Library *PictureDTBase;
    BOOL pic24bit;             // TRUE for new 24bit picture.datatype (V43)
    Object *obj;
    struct BitMapHeader *bmhd;
    struct BitMap *bitmap, *tempbitmap;
    int x,y;
    SMALL_COLOR *c;
    UBYTE *colreg, *buffer;
    int color;
    ULONG modeid;
    struct DisplayInfo dispinfo;
    UBYTE r,g,b;
    struct RastPort rp, temprp;
    struct gpBlitPixelArray arg;

    DataTypesBase = OpenLibrary((unsigned char*)"datatypes.library", 39);
    if(!DataTypesBase)
        return FALSE;

    // try to open the 24bit picture datatype
    PictureDTBase = OpenLibrary("datatypes/picture.datatype", 43L);
    if(PictureDTBase)
    {
        // we only need the picture.datatype to test the version, therefore
        // close it now
        CloseLibrary(PictureDTBase);

        pic24bit = TRUE;
    }
    else
        pic24bit = FALSE;

    if(!pic24bit)
    {
        // no 24bit version available
        // get the picture object
        obj = NewDTObject(filename,
                          DTA_SourceType,   DTST_FILE,
                          DTA_GroupID,      GID_PICTURE,
                          PDTA_Remap,       FALSE,
                          TAG_DONE);
        if(!obj)
        {
            CloseLibrary(DataTypesBase);
            return FALSE;
        }
    }
    else
    {
        // get the picture object
        obj = NewDTObject(filename,
                          DTA_SourceType,   DTST_FILE,
                          DTA_GroupID,      GID_PICTURE,
                          PDTA_Remap,       FALSE,
                          PDTA_DestMode,    MODE_V43,
                          TAG_DONE);
        if(!obj)
        {
            CloseLibrary(DataTypesBase);
            return FALSE;
        }
    }

    // get the bitmap header
    if(GetDTAttrs(obj,
                  PDTA_ColorRegisters, &colreg,
                  PDTA_BitMap, &bitmap,
                  PDTA_ModeID, &modeid,
                  PDTA_BitMapHeader, &bmhd,
                  TAG_DONE) != 4)
    {
        DisposeDTObject(obj);
        CloseLibrary(DataTypesBase);
        return FALSE;
    }

    if(!bmhd || !bitmap)
    {
        DisposeDTObject(obj);
        CloseLibrary(DataTypesBase);
        return FALSE;
    }

    width = bmhd->bmh_Width;
    height = bmhd->bmh_Height;

    if(!GetDisplayInfoData(NULL, (UBYTE*)&dispinfo, sizeof(struct DisplayInfo), DTAG_DISP, modeid))
    {
        DisposeDTObject(obj);
        CloseLibrary(DataTypesBase);
        return FALSE;
    }

    colormap = (SMALL_COLOR*)malloc(sizeof(SMALL_COLOR)*width*height);
    if(!colormap)
    {
        DisposeDTObject(obj);
        CloseLibrary(DataTypesBase);
        return FALSE;
    }

    c = colormap;

    if((bmhd->bmh_Depth > 8) && pic24bit)
    {
        // true color picture
        buffer = (UBYTE*)AllocVec(3*width, MEMF_PUBLIC);
        if(!buffer)
        {
            DisposeDTObject(obj);
            CloseLibrary(DataTypesBase);
            return FALSE;
        }

        for(y=0; y<height; y++)
        {
            arg.MethodID = DTM_READPIXELARRAY;
            arg.PixelArray = buffer;
            arg.PixelArrayMode = RECTFMT_RGB;
            arg.PixelArrayMod = 3*width;
            arg.LeftEdge = 0;
            arg.TopEdge = y;
            arg.Width = width;
            arg.Height = 1;
#ifdef __PPC__
            ppc_DoMethodA(obj, (Msg)&arg);
#else
            DoMethodA(obj, (Msg)&arg);
#endif
            for(x=0; x<width; x++)
            {
                c->r = buffer[x*3];
                c->g = buffer[x*3+1];
                c->b = buffer[x*3+2];
                c++;
            }
        }
        FreeVec(buffer);
    }
    else
    {
        // normal picture

        // planar to chunky conversion
        InitRastPort(&rp);
        rp.BitMap = bitmap;

        tempbitmap = AllocBitMap(width, 1, bmhd->bmh_Depth, BMF_CLEAR, NULL);
        if(!tempbitmap)
        {
            DisposeDTObject(obj);
            CloseLibrary(DataTypesBase);
            return FALSE;
        }

        InitRastPort(&temprp);
        temprp.BitMap = tempbitmap;

        buffer = (UBYTE*)AllocVec((width+15)&(~15), MEMF_PUBLIC);
        if(!buffer)
        {
            FreeBitMap(tempbitmap);
            DisposeDTObject(obj);
            CloseLibrary(DataTypesBase);
            return FALSE;
        }

        if(dispinfo.PropertyFlags & DIPF_IS_HAM)
        {
            // Simulate HAM mode
            if(bmhd->bmh_Depth == 8)
            {
                // Super HAM
                for(y=0; y<height; y++)
                {
                    r = g = b = 0;
                    ReadPixelLine8(&rp, 0, y, width, buffer, &temprp);
                    for(x=0; x<width; x++)
                    {
                        color = buffer[x];
                        switch(color & 0xc0)
                        {
                        case 0x00:  // Take it from color registers
                            color *= 3;
                            r = colreg[color];
                            g = colreg[color+1];
                            b = colreg[color+2];
                            break;
                        case 0x40:  // modify blue
                            b = color << 2;
                            break;
                        case 0x80:  // modify red
                            r = color << 2;
                            break;
                        case 0xc0:  // modify green
                            g = color << 2;
                            break;
                        }
                        c->r = r;
                        c->g = g;
                        c->b = b;
                        c++;
                    }
                }
            }
            else
            {
                // Normal HAM
                for(y=0; y<height; y++)
                {
                    r = g = b = 0;
                    ReadPixelLine8(&rp, 0, y, width, buffer, &temprp);
                    for(x=0; x<width; x++)
                    {
                        color = buffer[x];
                        switch(color & 0x30)
                        {
                        case 0x00:  // Take it from color registers
                            color *= 3;
                            r = colreg[color];
                            g = colreg[color+1];
                            b = colreg[color+2];
                            break;
                        case 0x40:  // modify blue
                            b = color << 4;
                            break;
                        case 0x80:  // modify red
                            r = color << 4;
                            break;
                        case 0xc0:  // modify green
                            g = color << 4;
                            break;
                        }
                        c->r = r;
                        c->g = g;
                        c->b = b;
                        c++;
                    }
                }
            }
        }
        else
        {
            for(y=0; y<height; y++)
            {
                ReadPixelLine8(&rp, 0, y, width, buffer, &temprp);
                for(x=0; x<width; x++)
                {
                    color = buffer[x];
                    color *= 3;
                    c->r = colreg[color];
                    c->g = colreg[color+1];
                    c->b = colreg[color+2];
                    c++;
                }
            }
        }
        FreeVec(buffer);
        FreeBitMap(tempbitmap);
    }

    DisposeDTObject(obj);
    CloseLibrary(DataTypesBase);
    return TRUE;
}
Beispiel #7
0
struct WCSScreenMode *ModeList_New(void)
{
struct NameInfo ModeName;
struct DisplayInfo Properties;
struct DimensionInfo Sizes;
struct WCSScreenMode *ModeList, *ThisMode, *Sort, DummyFirst;
ULONG DInfoID;
int Order;

DummyFirst.Next = NULL;

ThisMode = NULL;
ModeList = &DummyFirst;
DInfoID = INVALID_ID;
DInfoID = NextDisplayInfo(DInfoID);
while (DInfoID != INVALID_ID)
 {
 if(!(ModeNotAvailable(DInfoID)))
  {
  if(GetDisplayInfoData(NULL, (UBYTE *)&ModeName, sizeof(ModeName),
   DTAG_NAME, DInfoID))
   {
   if(GetDisplayInfoData(NULL, (UBYTE *)&Sizes, sizeof(Sizes),
    DTAG_DIMS, DInfoID))
    {
    if((Sizes.StdOScan.MaxX - Sizes.StdOScan.MinX + 1 >= 500) &&
     (Sizes.StdOScan.MaxY - Sizes.StdOScan.MinY + 1 >= 300) && (Sizes.MaxDepth >= 4))
     {
     if(ThisMode = get_Memory(sizeof(struct WCSScreenMode), MEMF_CLEAR))
      {
      ThisMode->ModeID = DInfoID;
      strcpy(ThisMode->ModeName, ModeName.Name);
      ThisMode->X  = ThisMode->UX = ThisMode->OX =Sizes.Nominal.MaxX - Sizes.Nominal.MinX + 1;
      ThisMode->Y  = ThisMode->UY = ThisMode->OY =Sizes.Nominal.MaxY - Sizes.Nominal.MinY + 1;
      ThisMode->OScans[0].x = Sizes.TxtOScan.MaxX - Sizes.TxtOScan.MinX + 1;
      ThisMode->OScans[0].y = Sizes.TxtOScan.MaxY - Sizes.TxtOScan.MinY + 1;
      ThisMode->OScans[1].x = Sizes.StdOScan.MaxX - Sizes.StdOScan.MinX + 1;
      ThisMode->OScans[1].y = Sizes.StdOScan.MaxY - Sizes.StdOScan.MinY + 1;
      ThisMode->OScans[2].x = Sizes.MaxOScan.MaxX - Sizes.MaxOScan.MinX + 1;
      ThisMode->OScans[2].y = Sizes.MaxOScan.MaxY - Sizes.MaxOScan.MinY + 1;
      ThisMode->OScans[3].x = Sizes.VideoOScan.MaxX - Sizes.VideoOScan.MinX + 1;
      ThisMode->OScans[3].y = Sizes.VideoOScan.MaxY - Sizes.VideoOScan.MinY + 1;
      ThisMode->MaxX = Sizes.MaxRasterWidth;
      ThisMode->MaxY = Sizes.MaxRasterHeight;
      if(GetDisplayInfoData(NULL, (UBYTE *)&Properties, sizeof(Properties),
       DTAG_DISP, DInfoID))
       {
       ThisMode->PropertyFlags = Properties.PropertyFlags;
       ThisMode->PixelSpeed = Properties.PixelSpeed;
       } /* if */
      for(Sort = ModeList; Sort;)
       {
       if(Sort->Next)
        {
        Order = stricmp(Sort->Next->ModeName, ThisMode->ModeName);
        if (Order > 0)
         {
         ThisMode->Next = Sort->Next;
         Sort->Next = ThisMode;
         Sort = NULL; /* We're done. */
         } /* else */
        else if (Order == 0)
         {
         /* We already have an entry by that name, don't
         ** bother adding a new one. Break out. */
         free_Memory(ThisMode, sizeof(struct WCSScreenMode));
         Sort = NULL;
         } /* else */ 
        } /* if */
       else
        {
/*        ThisMode->Next = NULL; */ /* Unnecessary: MEMF_CLEAR */
        Sort->Next = ThisMode;
        Sort = NULL; /* break out */
        } /* else */
       if(Sort) /* prevent many fine enforcer hits */
        {
        Sort = Sort->Next;
        } /* if */
       } /* for */
      } /* if */
     } /* if */
    } /* if */
   } /* if */
  } /* if */
 
 DInfoID = NextDisplayInfo(DInfoID);
 } /* while */

ModeList = ModeList->Next; /* Pull off DummyFirst */
    
return(ModeList);
} /* ModeList_New() */
int
main( void )
{
  struct RDArgs *rdargs;
  int            rc = RETURN_OK;

  rdargs = ReadArgs( TEMPLATE , (LONG *) &args, NULL );

  if( rdargs != NULL )
  {
    /* Refresh database */

    if( args.refresh && !args.remove )
    {
      OpenAHI();
      
      if( !AHI_LoadModeFile( "DEVS:AudioModes" ) && !args.quiet )
      {
        PrintFault( IoErr(), "DEVS:AudioModes" );
        rc = RETURN_ERROR;
      }
    }

    /* Load mode files */

    if( args.files != NULL && !args.remove )
    {
      int i = 0;

      OpenAHI();

      while( args.files[i] )
      {
        if( !AHI_LoadModeFile( args.files[i] ) && !args.quiet )
        {
          PrintFault( IoErr(), args.files[i] );
          rc = RETURN_ERROR;
        }
        i++;
      }
    }

    /* Remove database */

    if( args.remove )
    {
      if( args.files || args.refresh )
      {
        PutStr( "The REMOVE switch cannot be used together with FILES or REFRESH.\n" );
        rc = RETURN_FAIL;
      }
      else
      {
        ULONG id;

        OpenAHI();

        for( id = AHI_NextAudioID( AHI_INVALID_ID );
             id != AHI_INVALID_ID;
             id = AHI_NextAudioID( AHI_INVALID_ID ) )
        {
          AHI_RemoveAudioMode( id );
        }
      }
    }

    /* Make display mode doublescan (allowing > 28 kHz sample rates) */

    if( args.dblscan )
    {
      ULONG          id;
      ULONG          bestid = INVALID_ID;
      int            minper = MAXINT;
      struct Screen *screen = NULL;

      static const struct ColorSpec colorspecs[] =
      {
        { 0, 0, 0, 0 },
        { 1, 0, 0, 0 },
        {-1, 0, 0, 0 }
      };
      
      union {
        struct MonitorInfo mon;
        struct DisplayInfo dis;
      } buffer;

      for( id = NextDisplayInfo( INVALID_ID );
           id != (ULONG) INVALID_ID;
           id = NextDisplayInfo( id ) )
      {
        int period;

        if( GetDisplayInfoData( NULL, 
                                (UBYTE*) &buffer.dis, sizeof(buffer.dis),
                                DTAG_DISP, id ) )
        {
          if( !(buffer.dis.PropertyFlags & (DIPF_IS_ECS | DIPF_IS_AA ) ) )
          {
            continue;
          }
        }

        if( GetDisplayInfoData( NULL,
                                (UBYTE*) &buffer.mon, sizeof(buffer.mon),
                                DTAG_MNTR, id ) )
        {
          period = buffer.mon.TotalColorClocks * buffer.mon.TotalRows
                   / ( 2 * ( buffer.mon.TotalRows - buffer.mon.MinRow + 1 ) );

          if( period < minper )
          {
            minper = period;
            bestid = id;
          }
        }

      }

      if( bestid != (ULONG) INVALID_ID && minper < 100 )
      {
        screen = OpenScreenTags( NULL,
                                 SA_DisplayID,  bestid,
                                 SA_Colors,    (ULONG) &colorspecs,
                                 TAG_DONE );
      }
      else if( ( GfxBase->ChipRevBits0 & (GFXF_HR_DENISE | GFXF_AA_LISA ) ) != 0 )
      {
        /* No suitable screen mode found, let's bang the hardware...
           Using code from Sebastiano Vigna <*****@*****.**>. */

        extern struct Custom custom;

        custom.bplcon0  = 0x8211;
        custom.ddfstrt  = 0x0018;
        custom.ddfstop  = 0x0058;
        custom.hbstrt   = 0x0009;
        custom.hsstop   = 0x0017;
        custom.hbstop   = 0x0021;
        custom.htotal   = 0x0071;
        custom.vbstrt   = 0x0000;
        custom.vsstrt   = 0x0003;
        custom.vsstop   = 0x0005;
        custom.vbstop   = 0x001D;
        custom.vtotal   = 0x020E;
        custom.beamcon0 = 0x0B88;
        custom.bplcon1  = 0x0000;
        custom.bplcon2  = 0x027F;
        custom.bplcon3  = 0x00A3;
        custom.bplcon4  = 0x0011;
      }

      if( screen != NULL )
      {
        CloseScreen( screen );
      }
    }

    FreeArgs( rdargs );
  }

  cleanup( rc );
}
int
main( void )
{
  struct RDArgs *rdargs;
  int            rc = RETURN_OK;

  GfxBase       = (struct GfxBase *) OpenLibrary( GRAPHICSNAME, 37 );
  IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 37 );
  
  if( GfxBase == NULL )
  {
    Printf( "Unable to open %s version %ld\n", (ULONG) GRAPHICSNAME, 37 );
    cleanup();
    return RETURN_FAIL;
  }

  if( IntuitionBase == NULL )
  {
    Printf( "Unable to open %s version %ld\n", (ULONG) "intuition.library", 37 );
    cleanup();
    return RETURN_FAIL;
  }

  rdargs = ReadArgs( TEMPLATE , (LONG *) &args, NULL );

  if( rdargs != NULL )
  {
    /* Refresh database */

    if( args.refresh && !args.remove )
    {
      ULONG id;

      OpenAHI();

      /* First, empty the database */
      
      for( id = AHI_NextAudioID( AHI_INVALID_ID );
           id != (ULONG) AHI_INVALID_ID;
           id = AHI_NextAudioID( AHI_INVALID_ID ) )
      {
        AHI_RemoveAudioMode( id );
      }

      /* Now add all modes */

      if( !AHI_LoadModeFile( "DEVS:AudioModes" ) )
      {
        if( IS_MORPHOS )
        {
          ULONG res;

          /* Be quiet here. - Piru */
          APTR *windowptr = &((struct Process *) FindTask(NULL))->pr_WindowPtr;
          APTR oldwindowptr = *windowptr;
          *windowptr = (APTR) -1;
          res = AHI_LoadModeFile( "MOSSYS:DEVS/AudioModes" );
          *windowptr = oldwindowptr;

          if( !res )
          {
            if( !args.quiet )
            {
              PrintFault( IoErr(), "AudioModes" );
            }

            rc = RETURN_ERROR;
          }
        }
        else
        {
          if ( !args.quiet )
          {
            PrintFault( IoErr(), "DEVS:AudioModes" );
          }

          rc = RETURN_ERROR;
        }
      }
    }

    /* Load mode files */

    if( args.files != NULL && !args.remove )
    {
      int i = 0;

      OpenAHI();

      while( args.files[i] )
      {
        if( !AHI_LoadModeFile( args.files[i] ) && !args.quiet )
        {
          PrintFault( IoErr(), args.files[i] );
          rc = RETURN_ERROR;
        }
        i++;
      }
    }

    /* Remove database */

    if( args.remove )
    {
      if( args.files || args.refresh )
      {
        PutStr( "The REMOVE switch cannot be used together with FILES or REFRESH.\n" );
        rc = RETURN_FAIL;
      }
      else
      {
        ULONG id;

        OpenAHI();

        for( id = AHI_NextAudioID( AHI_INVALID_ID );
             id != (ULONG) AHI_INVALID_ID;
             id = AHI_NextAudioID( AHI_INVALID_ID ) )
        {
          AHI_RemoveAudioMode( id );
        }
      }
    }

    /* Make display mode doublescan (allowing > 28 kHz sample rates) */

    if( args.dblscan )
    {
      ULONG          id;
      ULONG          bestid = INVALID_ID;
      int            minper = INT_MAX;
      struct Screen *screen = NULL;

      static const struct ColorSpec colorspecs[] =
      {
        { 0, 0, 0, 0 },
        { 1, 0, 0, 0 },
        {-1, 0, 0, 0 }
      };
      
      union {
        struct MonitorInfo mon;
        struct DisplayInfo dis;
      } buffer;

      for( id = NextDisplayInfo( INVALID_ID );
           id != (ULONG) INVALID_ID;
           id = NextDisplayInfo( id ) )
      {
        int period;

        if( GetDisplayInfoData( NULL, 
                                (UBYTE*) &buffer.dis, sizeof(buffer.dis),
                                DTAG_DISP, id ) )
        {
          if( !(buffer.dis.PropertyFlags & (DIPF_IS_ECS | DIPF_IS_AA ) ) )
          {
            continue;
          }
        }

        if( GetDisplayInfoData( NULL,
                                (UBYTE*) &buffer.mon, sizeof(buffer.mon),
                                DTAG_MNTR, id ) )
        {
          period = buffer.mon.TotalColorClocks * buffer.mon.TotalRows
                   / ( 2 * ( buffer.mon.TotalRows - buffer.mon.MinRow + 1 ) );

          if( period < minper )
          {
            minper = period;
            bestid = id;
          }
        }

      }

      if( bestid != (ULONG) INVALID_ID && minper < 100 )
      {
        screen = OpenScreenTags( NULL,
                                 SA_DisplayID,  bestid,
                                 SA_Colors,    (ULONG) &colorspecs,
                                 TAG_DONE );
      }
      else if( ( GfxBase->ChipRevBits0 & (GFXF_HR_DENISE | GFXF_AA_LISA ) ) != 0 )
      {
        /* No suitable screen mode found, let's bang the hardware...
           Using code from Sebastiano Vigna <*****@*****.**>. */

        struct Custom *custom = (struct Custom *) 0xdff000;

        custom->bplcon0  = 0x8211;
        custom->ddfstrt  = 0x0018;
        custom->ddfstop  = 0x0058;
        custom->hbstrt   = 0x0009;
        custom->hsstop   = 0x0017;
        custom->hbstop   = 0x0021;
        custom->htotal   = 0x0071;
        custom->vbstrt   = 0x0000;
        custom->vsstrt   = 0x0003;
        custom->vsstop   = 0x0005;
        custom->vbstop   = 0x001D;
        custom->vtotal   = 0x020E;
        custom->beamcon0 = 0x0B88;
        custom->bplcon1  = 0x0000;
        custom->bplcon2  = 0x027F;
        custom->bplcon3  = 0x00A3;
        custom->bplcon4  = 0x0011;
      }

      if( screen != NULL )
      {
        CloseScreen( screen );
      }
    }

    FreeArgs( rdargs );
  }

  cleanup();
  return rc;
}
Beispiel #10
0
IPTR ScreenModeProperties__OM_SET(Class *CLASS, Object *self, struct opSet *message)
{
    struct ScreenModeProperties_DATA *data = INST_DATA(CLASS, self);    
    const struct TagItem *tags;
    struct TagItem *tag;
    struct TagItem noforward_tags[] =
    {
        {MUIA_Group_Forward , FALSE                       },
        {TAG_MORE           , (IPTR)message->ops_AttrList }
    };
    struct opSet noforward_message = *message;
    noforward_message.ops_AttrList = noforward_tags;
    
    ULONG id        = INVALID_ID;
    IPTR  no_notify = TAG_IGNORE;
    
    for (tags = message->ops_AttrList; (tag = NextTagItem(&tags)); )
    {
        switch (tag->ti_Tag)
        {
	    case MUIA_NoNotify:
	        no_notify = MUIA_NoNotify;
		break;
		
	    case MUIA_ScreenModeProperties_DisplayID:
	    {
	        struct TagItem width_tags[] =
		{
		    { no_notify,            TRUE },
		    { MUIA_Numeric_Min,        0 },
		    { MUIA_Numeric_Max,        0 },
		    { MUIA_Numeric_Default,    0 },
		    { TAG_DONE,                0 }
		};
	        struct TagItem height_tags[] =
		{
		    { no_notify,            TRUE },
		    { MUIA_Numeric_Min,        0 },
		    { MUIA_Numeric_Max,        0 },
		    { MUIA_Numeric_Default,    0 },
		    { TAG_DONE,                0 }
		};
	        struct TagItem depth_tags[] =
		{
		    { no_notify,            TRUE },
		    { MUIA_Numeric_Min,        0 },
		    { MUIA_Numeric_Max,        0 },
		    { MUIA_Numeric_Default,    0 },
		    { TAG_DONE,                0 }
		};
	        
                struct DimensionInfo dim;
		
		BOOL autoscroll;
                
		if (GetDisplayInfoData(NULL, (UBYTE *)&dim, sizeof(dim), DTAG_DIMS, tag->ti_Data))
                {
                    width_tags[1].ti_Data  = dim.MinRasterWidth;
                    height_tags[1].ti_Data = dim.MinRasterHeight;
                    depth_tags[1].ti_Data  = 1;
	    
                    width_tags[2].ti_Data  = dim.MaxRasterWidth;
                    height_tags[2].ti_Data = dim.MaxRasterHeight;
	            depth_tags[2].ti_Data  = dim.MaxDepth;
	    
                    width_tags[3].ti_Data  = dim.Nominal.MaxX - dim.Nominal.MinX + 1;
                    height_tags[3].ti_Data = dim.Nominal.MaxY - dim.Nominal.MinY + 1;
	            depth_tags[3].ti_Data  = dim.MaxDepth;
                    
		    id = tag->ti_Data;		    
		}
		
		/* Enable autoscroll only if the maximum sizes are bigger than 
		   the resolution.  */
		   
		autoscroll = width_tags[2].ti_Data  > width_tags[3].ti_Data  &&
		             height_tags[2].ti_Data > height_tags[3].ti_Data;
    
  	        data->DisplayID = id;
 	        nfset(self, MUIA_Disabled, id == INVALID_ID);
		
		SetAttrsA(data->width,  width_tags);
		SetAttrsA(data->height, height_tags);
		SetAttrsA(data->depth,  depth_tags);
		
		SetAttrs(data->autoscroll, no_notify, TRUE, 
		                           MUIA_Disabled, !autoscroll,
					   MUIA_Selected, autoscroll,
					   TAG_DONE);
                
		break;
	    }
	    
	    case MUIA_ScreenModeProperties_Width:
	        if (id != INVALID_ID)
		{
		    WORD width = tag->ti_Data;
		    if (width != -1)
		        SetAttrs(data->width, no_notify, TRUE, MUIA_Numeric_Value, width, TAG_DONE);
		    else
		        DoMethod(data->width, MUIM_Numeric_SetDefault);
		    
		    nnset(data->def_width, MUIA_Selected, width == -1);
		}
		break;
		
	    case MUIA_ScreenModeProperties_Height:
	        if (id != INVALID_ID)
		{
		    WORD height = tag->ti_Data;
		    if (height != -1)
		        SetAttrs(data->height, no_notify, TRUE, MUIA_Numeric_Value, height, TAG_DONE);
		    else
		        DoMethod(data->height, MUIM_Numeric_SetDefault);
		    
		    nnset(data->def_height, MUIA_Selected, height == -1);
		}
		break;
	    
	    case MUIA_ScreenModeProperties_Depth:
	        if (id != INVALID_ID)
		{
		    WORD depth = tag->ti_Data;
		    if (depth != -1)
		        SetAttrs(data->depth, no_notify, TRUE, MUIA_Numeric_Value, depth, TAG_DONE);
		    else
		        DoMethod(data->depth, MUIM_Numeric_SetDefault);
		}
		break;
	    
	    case MUIA_ScreenModeProperties_Autoscroll:
	        if (id != INVALID_ID && !XGET(data->autoscroll, MUIA_Disabled))
		    SetAttrs(data->autoscroll, no_notify, TRUE, MUIA_Selected, tag->ti_Data != 0);
		break;
	}
    }		    

    return DoSuperMethodA(CLASS, self, (Msg)&noforward_message);	
}
void _config_env_screenmode_init_mode(config_env_data *data,BOOL save_depth)
{
	struct DimensionInfo diminfo;
	char buf[128];
	struct Screen *screen;
	int a;
	ULONG mode_id=0;
	BOOL got_dims=0;

	// Get current screenmode information
	switch (data->config->screen_mode)
	{
		// Existing screen
		case MODE_WORKBENCHUSE:
		case MODE_WORKBENCHCLONE:
		case MODE_PUBLICSCREEN:
			{
				// Strip Use/Clone from mode name
				stccpy(buf,data->mode_name,sizeof(buf));
				for (a=strlen(buf)-1;a>=0;a--)
				{
					if (buf[a]==':')
					{
						buf[a]=0;
						break;
					}
				}

				// Get screen
				if (screen=LockPubScreen(buf))
				{
					// Get screen mode
					mode_id=GetVPModeID(&screen->ViewPort);

					// Get minimum size
					if (data->config->screen_mode==MODE_WORKBENCHCLONE)
					{
						data->mode_size_limit.MinX=screen->Width;
						data->mode_size_limit.MinY=screen->Height;

						// Clone depth
						if (!save_depth)
							data->config->screen_depth=screen->RastPort.BitMap->Depth;
					}
					else
					{
						data->mode_size_limit.MinX=640;
						data->mode_size_limit.MinY=200;
					}

					// Get maximum size
					data->mode_size_limit.MaxX=screen->Width;
					data->mode_size_limit.MaxY=screen->Height;

					// Get default size
					data->mode_size_default.MaxX=screen->Width;
					data->mode_size_default.MaxY=screen->Height;

					// Got dimensions
					got_dims=1;

					// Release screen
					UnlockPubScreen(0,screen);
				}
			}
			break;


		// Real screen mode
		default:
			mode_id=data->config->screen_mode;
			break;
	}

	// Get mode info (if available)
	if (!(ModeNotAvailable(mode_id)) &&
		(GetDisplayInfoData(0,(char *)&diminfo,sizeof(diminfo),DTAG_DIMS,mode_id)))
	{
		// Not already got dimensions?
		if (!got_dims)
		{
			// Get minimum size
			data->mode_size_limit.MinX=diminfo.MinRasterWidth;
			data->mode_size_limit.MinY=diminfo.MinRasterHeight;

			// Get maximum size
			data->mode_size_limit.MaxX=diminfo.MaxRasterWidth;
			data->mode_size_limit.MaxY=diminfo.MaxRasterHeight;

			// Get default size
			data->mode_size_default.MaxX=diminfo.TxtOScan.MaxX+1;
			data->mode_size_default.MaxY=diminfo.TxtOScan.MaxY+1;
		}

		// Get maximum colours
		data->mode_max_colours=diminfo.MaxDepth;
	}

	// Check settings
	if (data->mode_size_limit.MinX<640)
		data->mode_size_limit.MinX=640;
	if (data->mode_size_limit.MinY<200)
		data->mode_size_limit.MinY=200;
	if (data->mode_size_limit.MaxX<data->mode_size_limit.MinX)
		data->mode_size_limit.MaxX=data->mode_size_limit.MinX;
	if (data->mode_size_limit.MaxY<data->mode_size_limit.MinY)
		data->mode_size_limit.MaxY=data->mode_size_limit.MinY;
	if (data->mode_size_default.MaxX<data->mode_size_limit.MinX)
		data->mode_size_default.MaxX=data->mode_size_limit.MinX;
	else
	if (data->mode_size_default.MaxX>data->mode_size_limit.MaxX)
		data->mode_size_default.MaxX=data->mode_size_limit.MaxX;
	if (data->mode_size_default.MaxY<data->mode_size_limit.MinY)
		data->mode_size_default.MaxY=data->mode_size_limit.MinY;
	else
	if (data->mode_size_default.MaxY>data->mode_size_limit.MaxY)
		data->mode_size_default.MaxY=data->mode_size_limit.MaxY;
	if (data->mode_max_colours<1) data->mode_max_colours=1;

	// Fix gadgets
	_config_env_screenmode_fix_gadgets(data);
}