Exemplo n.º 1
1
void amiga_init (char *dir)
{
  if ((DefaultPubScreen = LockPubScreen (0)) == 0)
    exit (1);
  screen_ratio (DefaultPubScreen);

  char prog_name[256];
  static char font_name[MAXFONTPATH];
  char *font_desc, *name_ptr;
  static WORD pens[] =
  {-1};
  static struct TextAttr font =
  {NULL, 0, FS_NORMAL, 0};
  int window = 0;

  if (Icon == NULL)
  {
    if (GetProgramName (prog_name, 256))
      Icon = GetDiskObject (prog_name);
  }

  if (Icon)
  {
    if (FindToolType (Icon->do_ToolTypes, "WINDOW"))
      window = 1;
    if (font_desc = FindToolType (Icon->do_ToolTypes, "FONT"))
    {
      strcpy (font_name, font_desc);
      if (name_ptr = strrchr (font_name, '/'))
      {
	font.ta_Name = font_name;
	font.ta_YSize = atoi (name_ptr + 1);
	strcpy (name_ptr, ".font");
      }
    }
    if (font.ta_Name)
      Font = OpenDiskFont (&font);
  }
  if (Font == NULL)
  {
    font.ta_Name = "topaz.font";
    font.ta_YSize = 8;
    Font = OpenFont (&font);
  }

  if (window == 0)
  {
    if ((Screen = OpenScreenTags (0,
				  SA_Pens, pens,
				  SA_DisplayID, GetVPModeID (&DefaultPubScreen->ViewPort),
				  SA_Overscan, OSCAN_TEXT,
				  SA_Depth, 2,
				  SA_Type, CUSTOMSCREEN | AUTOSCROLL,
				  SA_Font, &font,
				  SA_Title, TitleBar, TAG_DONE)) == 0)
      exit (1);
  }

  if ((Window = OpenWindowTags (0,
				WA_Left, 0,
				WA_Top, Screen ? 2 : DefaultPubScreen->BarHeight + 1,
				WA_Width, Screen ? Screen->Width : ScreenWidth,
				WA_Height, Screen ? Screen->Height - 2 : ScreenHeight - DefaultPubScreen->BarHeight - 1,
				WA_SmartRefresh, 1,
				WA_NewLookMenus, 1,
				WA_AutoAdjust, 1,
				WA_Borderless, Screen ? 1 : 0,
				WA_Backdrop, Screen ? 1 : 0,
				WA_Activate, 1,
				WA_CloseGadget, Screen ? 0 : 1,
				WA_DragBar, Screen ? 0 : 1,
				WA_DepthGadget, Screen ? 0 : 1,
				WA_SizeGadget, Screen ? 0 : 1,
				WA_SizeBBottom, Screen ? 0 : 1,
				WA_Title, TitleBar,
				WA_ScreenTitle, TitleBar,
				WA_IDCMP, IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_MENUPICK | IDCMP_CLOSEWINDOW | IDCMP_CHANGEWINDOW,
				Screen ? WA_CustomScreen : WA_PubScreen, Screen ? Screen : DefaultPubScreen,
				TAG_DONE)) == 0)
    exit (1);

  ThisProcess = (struct Process *)FindTask(0);
  OldWindowPtr = ThisProcess->pr_WindowPtr;
  ThisProcess->pr_WindowPtr = Window;

  if ((Visual = GetVisualInfo (Window->WScreen, TAG_DONE)) == 0)
    exit (1);
  if ((Menus = CreateMenus (NewMenus, GTMN_NewLookMenus, TRUE, TAG_DONE)) == 0)
    exit (1);
  LayoutMenus (Menus, Visual, GTMN_NewLookMenus, TRUE, TAG_DONE);
  SetMenuStrip (Window, Menus);

  if ((GameReq = alloc_freq (dir)) == 0)
    exit (1);
  if ((SaveReq = alloc_freq (dir)) == 0)
    exit (1);
  if ((ScriptReq = alloc_freq (dir)) == 0)
    exit (1);

  RastPort = Window->RPort;
  SetDrMd (RastPort, JAM2);
  SetAPen (RastPort, 1);
  SetBPen (RastPort, 0);
  SetFont (RastPort, Font);
  DisplayHeight = ((Window->Height - Window->BorderTop - Window->BorderBottom) / RastPort->TxHeight) - 1;
  PreviousHeight = DisplayHeight;

  reset_cursor ();
}
Exemplo n.º 2
0
struct Screen * openscreen(void)
{
  struct Screen * screen;
  UWORD pens[] = { ~0 };
ULONG patterncoltab[] = { 
    (16L << 16) + 0,	/* 16 colors, loaded at index 0 */
    
    0xB3B3B3B3, 0xB3B3B3B3, 0xB3B3B3B3, /* Grey70	*/
    0x00000000, 0x00000000, 0x00000000, /* Black	*/
    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, /* White	*/
    0x66666666, 0x88888888, 0xBBBBBBBB, /* AMIGA Blue   */
    
    0x00000000, 0x00000000, 0xFFFFFFFF, /* Blue		*/
    0x00000000, 0xFFFFFFFF, 0x00000000, /* Green	*/
    0xFFFFFFFF, 0x00000000, 0x00000000, /* Red		*/
    0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, /* Cyan		*/
    
    0x33333333, 0x33333333, 0x33333333, /* Pattern Col 1 */
    0xcdcdcdcd, 0x6c6c6c6c, 0xc7c7c7c7, /* Pattern Col 2 */
    0x8e8e8e8e, 0x85858585, 0x93939393, /* Pattern Col 3 */
    0x22222222, 0x22222222, 0x22222222, /* Pattern Col 4 */
    
    0x77777777, 0x77777777, 0x77777777, /* Pattern Col 5 */
    0x66666666, 0x66666666, 0x66666666, /* Pattern Col 6 */
    0x55555555, 0x55555555, 0x55555555, /* Pattern Col 7 */
    0x44444444, 0x44444444, 0x44444444, /* Pattern Col 8 */
    
    0L		/* Termination */
};    
   
  printf("Opening screen\n");
  if ((screen = OpenScreenTags(NULL,
                          SA_Width, 	640,
                          SA_Height, 	480,
			  SA_Depth,	24,
			  SA_Title,	"gfx hidd demo",
			  SA_Pens,	pens,
                          TAG_END))) {
  } else {
      screen = OpenScreenTags(NULL,
                          SA_Width, 	640,
                          SA_Height, 	480,
			  SA_Title,	"gfx hidd demo",
			  TAG_END);
  }

  if (screen)
        LoadRGB32(&screen->ViewPort, patterncoltab);

/*  screen->RastPort.longreserved[0] = window->RPort->longreserved[0];

  Draw(&screen->RastPort, 100, 100);
*/
  return screen;
}
Exemplo n.º 3
0
static void set_best_resolution(_THIS, int width, int height)
{
	Uint32 idok;
	int depth=8;

	if(SDL_Display)
		depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);

	idok=BestCModeIDTags(CYBRBIDTG_NominalWidth,width,
				CYBRBIDTG_NominalHeight,height,
				CYBRBIDTG_Depth,depth,
				TAG_DONE);

	if(idok!=INVALID_ID)
	{
		if(SDL_Display)
		{
			if(currently_fullscreen)
				CloseScreen(SDL_Display);
			else
				UnlockPubScreen(NULL,SDL_Display);
		}
		SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height,
											SA_Depth,depth,SA_DisplayID,idok,
											SA_ShowTitle,FALSE,
											TAG_DONE);
	}
}
Exemplo n.º 4
0
LONG Blank( PrefObject *Prefs )
{
	struct Screen *Scr;
	struct Window *Wnd;
	LONG RetVal = OK;
	
	Scr = OpenScreenTags( 0L, SA_DisplayID, Prefs->po_ModeID, SA_Quiet, TRUE,
						 SA_Depth, Prefs->po_Depth, SA_Behind, TRUE,
						 SA_Overscan, OSCAN_STANDARD, TAG_DONE );
	if( Scr )
	{
		Triplet *ColorTable = RainbowPalette( Scr, 0L, 1L, 0L );
		Wnd = BlankMousePointer( Scr );
		
		while( RetVal == OK )
			RetVal = FracBlank( Scr, Scr->Width, Scr->Height );
		
		UnblankMousePointer( Wnd );
		RainbowPalette( 0L, ColorTable, 1L, 0L );
		CloseScreen( Scr );
	}
	else
		RetVal = FAILED;

	return RetVal;
}
Exemplo n.º 5
0
LONG Blank( PrefObject *Prefs )
{
	struct Screen *Scr;
	struct Window *Wnd;
	LONG RetVal;
	
	if( Scr = OpenScreenTags( NULL, SA_Depth, Prefs[0].po_Depth,
							 SA_Quiet, TRUE, SA_DisplayID, Prefs[0].po_ModeID,
							 SA_Behind, TRUE, SA_Overscan, OSCAN_STANDARD,
							 SA_ShowTitle, FALSE, SA_Title, "Garshnescreen",
							 TAG_DONE ))
	{
		SetRGB4(&( Scr->ViewPort ), 0, 0, 0, 0 );
		ColorTable = RainbowPalette( Scr, 0L, 1L, 0L );
		Wnd = BlankMousePointer( Scr );
		
		do
			RetVal = Dragon( Scr, Scr->Width, Scr->Height );
		while( RetVal == OK );
		
		UnblankMousePointer( Wnd );
		RainbowPalette( 0L, ColorTable, 1L, 0L );
		CloseScreen( Scr );
	}
	else
		RetVal = FAILED;
	
	return RetVal;
}
Exemplo n.º 6
0
struct Screen * openscreen(void)
{
  struct Screen * screen;

  screen = OpenScreenTags(NULL,
                          SA_Height, 200,
                          SA_Width, 300,
                          TAG_END);

  Draw(&screen->RastPort, 100, 100);

  return screen;
}
Exemplo n.º 7
0
int _glfwOpenScreen( int *width, int *height, int *r, int *g, int *b,
    int refresh )
{
    int bpp, modeID;

    // Calculate BPP
    bpp = *r + *g + *b;

    // If colorbits < 8 (e.g. 0) or >= 24, default to 24 bpp
    if( bpp < 8 || bpp >= 24 )
    {
        *r = *g = *b = 8;
    }

    // Find best matching video mode
    modeID = _glfwGetClosestVideoMode( width, height, r, g, b, refresh );

    // Open screen
    _glfwWin.Screen = OpenScreenTags(
        NULL,
        SA_Width,     *width,
        SA_Height,    *height,
        SA_DisplayID, modeID,
        SA_Type,      CUSTOMSCREEN,
        SA_SysFont,   1,
        SA_ShowTitle, FALSE,
        TAG_DONE, 0
    );

    // Did we succeed?
    if( !_glfwWin.Screen )
    {
        printf( "Failed to open Amiga screen\n" );
        return GL_FALSE;
    }

    // Remember Mode ID
    _glfwWin.ModeID = modeID;

/*
    // Debugging information
    printf( "Amiga Screen opened:\n" );
    printf( "  ModeID:     0x%08X\n", modeID );
    printf( "  Dimensions: %d x %d\n", *width, *height );
    printf( "  Color bits: %d : %d : %d\n", *r, *g, *b );
*/

    return GL_TRUE;
}
Exemplo n.º 8
0
VOID InternalBlank( VOID )
{
    if( !ServerScr )
    {
        ServerScr = OpenScreenTags( 0L, SA_DisplayID, getTopScreenMode(),
                                   SA_Depth, 1, SA_Behind, 1, SA_Quiet, TRUE,
								   TAG_END );
        if( ServerScr )
        {
            Wnd = BlankMousePointer( ServerScr );
            SetRGB4(&( ServerScr->ViewPort ), 0, 0, 0, 0 );
            SetRGB4(&( ServerScr->ViewPort ), 1, 0, 0, 0 );
            ScreenToFront( ServerScr );
            Blanking = TRUE;
        }
    }
}
Exemplo n.º 9
0
VOID main ()
{
	struct Screen *scr;
	if(scr = OpenScreenTags(NULL, SA_LikeWorkbench, TRUE, TAG_DONE))// LockPubScreen(NULL))
	{
		UBYTE name[64], repeats = 3;

		for(ULONG i = 10; i < 60; i += 10)
		{
			sprintf(name, "%3d windows", i);
			OpenWindows(name, i, repeats, scr);
		}

		CloseScreen(scr);
//		UnlockPubScreen(NULL, scr);
	}
}
Exemplo n.º 10
0
LONG Blank( PrefObject *Prefs )
{
	LONG delay_rate, i, j, counter = 0, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *FTScr;
	struct Window *FTWin;
	struct Window *Wnd;
	
	NumToasters = Prefs[OBJECTS].po_Level;
	delay_rate = 11 - Prefs[SPEED].po_Level;
	
	Toasters = AllocVec( sizeof( Toaster ) * NumToasters, MEMF_CLEAR );
	FTScr = OpenScreenTags( NULL, SA_DisplayID, Prefs[MODE].po_ModeID,
						   SA_Depth, 4, SA_Overscan, OSCAN_STANDARD,
						   SA_Type, CUSTOMSCREEN, SA_Quiet, TRUE,
						   SA_Behind, TRUE, TAG_DONE );
	if( Toasters && FTScr )
	{
		for( i = 0; i < 48; i += 3 )
			if( GfxBase->lib_Version < 39 )
				SetRGB4(&( FTScr->ViewPort ), i/3, ( cmap[i] * 16 ) / 256,
						( cmap[i+1] * 16 ) / 256, ( cmap[i+2] * 16 ) / 256 );
			else
				SetRGB32(&( FTScr->ViewPort ), i/3, cmap[i]<<24, cmap[i+1]<<24,
						 cmap[i+2]<<24 );
		FTWin = OpenWindowTags( 0L, WA_Width, FTScr->Width, WA_Height,
							   FTScr->Height, WA_IDCMP, 0L, WA_Flags,
							   WFLG_SIMPLE_REFRESH|WFLG_BORDERLESS,
							   WA_CustomScreen, FTScr, TAG_DONE );
		if( FTWin )
		{
			Rast = FTWin->RPort;
			SetAPen( Rast, 0 );
			
			for( i = 0; i < NumToasters; i++ )
				if( !FindLaunchPos( i, ( LONG )FTWin->Width,
								   ( LONG )FTWin->Height ))
					Toasters[i].delay = 30;
			
			Wnd = BlankMousePointer( FTScr );
			ScreenToFront( FTScr );
			
			while( RetVal == OK )
			{
				WaitTOF();
				
				if(!( ++counter % 60 ))
					ScreenToFront( FTScr );
				
				if(!( counter % delay_rate ))
				{
					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							Toasters[i].old_x = Toasters[i].x;
							Toasters[i].old_y = Toasters[i].y;
							Toasters[i].x -= Toasters[i].xspeed;
							Toasters[i].y += Toasters[i].yspeed;
							Toasters[i].xcol = -1;
							Toasters[i].ycol = -1;
						}
					}

					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							j = -1;
							while(( j = TestExtent( j+1, i, Toasters[i].x,
												   Toasters[i].y )) >= 0 )
							{
								if( abs( Toasters[j].old_x -
										Toasters[i].old_x ) < IM_WIDBUF )
								{
									if( Toasters[i].y < Toasters[j].y )
										Toasters[i].ycol = j;
									if( Toasters[i].xspeed ==
									   Toasters[j].xspeed )
										Toasters[i].xspeed++;
								}
								else
								{
									if( Toasters[i].x > Toasters[j].x )
										Toasters[i].xcol = j;
									if( Toasters[i].yspeed ==
									   Toasters[j].yspeed )
										Toasters[i].yspeed++;
								}
								if( abs( Toasters[j].old_y -
										Toasters[i].old_y ) < IM_HEIBUF )
								{
									if( Toasters[i].x > Toasters[j].x )
										Toasters[i].xcol = j;
									if( Toasters[i].yspeed ==
									   Toasters[j].yspeed )
										Toasters[i].yspeed++;
								}
							}
						}
					}

					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							Toasters[i].x = Toasters[i].old_x - ActXSpeed( i );
							Toasters[i].y = Toasters[i].old_y + ActYSpeed( i );
						}
					}
					
					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							j = -1;
							while(( j = TestExtent( j+1, i, Toasters[i].x,
												   Toasters[i].y )) >= 0 )
							{
								if( abs( Toasters[j].old_x -
										Toasters[i].old_x ) < IM_WIDBUF )
									if( Toasters[i].x > Toasters[j].x )
										Toasters[i].x = Toasters[i].old_x;
								else
									if( Toasters[i].y < Toasters[j].y )
										Toasters[i].y = Toasters[i].old_y;
								if( abs( Toasters[j].old_y -
										Toasters[i].old_y ) < IM_HEIBUF )
									if( Toasters[i].y < Toasters[j].y )
										Toasters[i].y = Toasters[i].old_y;
							}
						}
					}

					for( i = 0; i < NumToasters; i++ )
					{
						if( !Toasters[i].delay )
						{
							Toasters[i].phase =
								( Toasters[i].phase + 1 ) % IMAGEMAX;
							EraseRect( Rast, Toasters[i].x + IM_WIDTH,
									  Toasters[i].old_y, Toasters[i].x +
									  IM_WIDTH + Toasters[i].xspeed,
									  Toasters[i].old_y + IM_HEIGHT );
							EraseRect( Rast, Toasters[i].old_x,
									  Toasters[i].old_y,
									  Toasters[i].old_x + IM_WIDTH,
									  Toasters[i].old_y + Toasters[i].yspeed );
							DrawImage( Rast, img[Toasters[i].phase],
									  Toasters[i].x, Toasters[i].y );
							if(( Toasters[i].x < -IM_WIDTH-1 )||
							   ( Toasters[i].y > FTWin->Height ))
								Toasters[i].delay = RangeRand( 50 );
						}
						else
							if(!( --Toasters[i].delay ))
								Toasters[i].delay =
									FindLaunchPos( i, ( LONG )FTWin->Width,
												  ( LONG )FTWin->Height )
										? 0 : 30;
					}
				}
				RetVal = ContinueBlanking();
			}

			SetSignal( 0L, SIGBREAKF_CTRL_C );
			UnblankMousePointer( Wnd );
			CloseWindow( FTWin );
		}
		else
			RetVal = FAILED;
		CloseScreen( FTScr );
	}
	else
		RetVal = FAILED;
	
	FreeVec( Toasters );

	return RetVal;
}
Exemplo n.º 11
0
LONG Blank( PrefObject *Prefs )
{
	struct Screen *LScr;
	struct Window *Wnd;
	LONG RetVal = OK,i,goatFlag = 0, ToFrontCount = 0;
	
	if (Prefs[SCREEN].po_Active )
		LScr = cloneTopScreen( FALSE, TRUE );
	else
		LScr = OpenScreenTags( 0l, SA_DisplayID, Prefs[MODE].po_ModeID,
							  SA_Depth, 2, SA_Overscan, OSCAN_STANDARD,
							  SA_ShowTitle, FALSE, SA_Title, "Garshnescreen",
							  SA_Quiet, TRUE, SA_Behind, TRUE, TAG_DONE );
	if( LScr )
	{
		if( GarshnelibBase->lib_Version < 39 || !Prefs[SCREEN].po_Active )
		{
			SetRGB4(&(LScr->ViewPort),0,0x0,0x0,0x0);
			SetRGB4(&(LScr->ViewPort),1,0x8,0x8,0x8);
			SetRGB4(&(LScr->ViewPort),2,0x7,0x4,0x2);
			SetRGB4(&(LScr->ViewPort),3,0x0,0xa,0x0);
			backgroundClr = 0;
			grassClr = GRASS;
			herderClr = HERDER;
			goatClr = GOAT;
		}
		else
		{
			backgroundClr = FindColor( LScr->ViewPort.ColorMap, 0, 0, 0, -1 );
			grassClr = FindColor( LScr->ViewPort.ColorMap, 0, 0x9L<<28, 0,
								 -1 );
			goatClr = FindColor( LScr->ViewPort.ColorMap, 0xAL<<28, 0xAL<<28,
								0xAL<<28, -1 );
			herderClr = FindColor( LScr->ViewPort.ColorMap, 0xBL<<28, 0x2L<<28,
								  0x4L<<28, -1 );
		}
	
		numGoats = Prefs[GOATS].po_Level;
		numHerders = Prefs[HERDERS].po_Level;
		reproduction = Prefs[REPRO].po_Level;
		Width = LScr->Width;
		Height = LScr->Height;
		
		for (i=0;i<numHerders;++i)
			herderQ[i] = 0;
		herderQ[0] = 1;
		herders[0].x = Width/2;
		herders[0].y = Height/2;
		for (i=0;i<numGoats;++i)
			goatQ[i] = 0;
		
		Wnd = BlankMousePointer( LScr );
		ScreenToFront( LScr );
		i = 0;
		while( RetVal == OK )
		{
			WaitTOF();

			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( LScr );
			
			if( !Prefs[DELAY].po_Level ||
			   !( ToFrontCount % Prefs[DELAY].po_Level ))
			{
				myBlank( LScr, LScr->Width, LScr->Height );
				if (!goatFlag && i == 20)
				{
					goatQ[0] = 1;
					goats[0].x = Width/2;
					goats[0].y = Height/2;
					grassEaten[0] = 0;
					goatFlag = 1;
				}
				else
					++i;
			}

			RetVal = ContinueBlanking();
		}

		UnblankMousePointer( Wnd );
		CloseScreen( LScr );
	}
	else
		RetVal = FAILED;
	
	return RetVal;
}
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
int main(int argc, char **argv)
{
	ULONG DisplayID,Depth;
	struct Screen *CyberScreen;
	struct Window *WriteWindow;
	LONG done;
	struct IntuiMessage *IntMsg;
	IMAGE image;
	LONG src_x,src_y, old_src_x,old_src_y;
	ULONG argarray[2];
	struct RDArgs *rdargs;
	char *file;

	rdargs = ReadArgs((STRPTR)arg_template, (LONG*)argarray, NULL);
	if(!rdargs)
		return 20;

	file = (char*)argarray[0];

	IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",39L);
	if(!IntuitionBase)
		return 20;

	CyberGfxBase = OpenLibrary(CYBERGFXNAME,CYBERGFXVERSION);
	if(!CyberGfxBase)
	{
		ErrorF ("Can't open \"%s\" version %ld or newer.",
			CYBERGFXNAME,CYBERGFXVERSION);
		CloseLibrary (&IntuitionBase->LibNode);
		return 10;
	}

	if(!Load(file, &image))
	{
		ErrorF ("Can't load image.");
		FreeArgs(rdargs);
		CloseLibrary (CyberGfxBase);
		CloseLibrary (&IntuitionBase->LibNode);
		return 10;
	}

	/* Let CyberGraphX search a display mode for us! */

	if(argarray[1])
		Depth = 16;
	else
		Depth = 24;

	FreeArgs(rdargs);

	while (Depth)
	{
		DisplayID = BestCModeIDTags(CYBRBIDTG_NominalWidth, image.width,
			CYBRBIDTG_NominalHeight, image.height,
			CYBRBIDTG_Depth, Depth,
			TAG_DONE);
		if(DisplayID != INVALID_ID)
		{
			/* Because older version of the "cybergraphics.library" don't handle */
			/* CYBRBIDTG_Depth properly we query the real depth of the mode.     */
			Depth = GetCyberIDAttr(CYBRIDATTR_DEPTH,DisplayID);
			break;
		}
		/* retry with less bits per pixel */
		Depth = NextDepth(Depth);
	}

	if (Depth < SCREEN_MIN_DEPTH)
	{
		ErrorF ("Can't find suitable display mode for %ldx%ldx.",
			image.width, image.height);
		CloseLibrary (CyberGfxBase);
		CloseLibrary (&IntuitionBase->LibNode);
		Cleanup(&image);
		return 5;
	}

	/* open screen, but let Intuition choose the actual dimensions */

	CyberScreen = OpenScreenTags(
		NULL,
		SA_Title,"RayStorm Image Viewer (C) 1998 Andreas Heumann",
		SA_DisplayID,DisplayID,
		SA_Depth,Depth,
		TAG_DONE);
	if(!CyberScreen)
	{
		ErrorF ("Can't open screen.");
		CloseLibrary (CyberGfxBase);
		CloseLibrary (&IntuitionBase->LibNode);
		Cleanup(&image);
		return 5;
	}

	/* create Write window */

	WriteWindow = OpenWindowTags(
		NULL,
		WA_Title,"Viewer",
		WA_Flags,
			WFLG_ACTIVATE|WFLG_SIMPLE_REFRESH|WFLG_RMBTRAP,
		WA_IDCMP,
			IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS,
		WA_Borderless, TRUE,
		WA_Left, 0,
		WA_Top, 0,
		WA_Width, image.width,
		WA_Height, image.height,
		WA_CustomScreen,CyberScreen,
		TAG_DONE);
	if(!WriteWindow)
	{
		ErrorF ("Can't open write window.");
		CloseScreen (CyberScreen);
		CloseLibrary (CyberGfxBase);
		CloseLibrary (&IntuitionBase->LibNode);
		Cleanup(&image);
		return 5;
	}

	src_x = 0;
	src_y = 0;
	WritePixelArray(
		image.colormap,
		src_x, src_y,
		image.width*sizeof(SMALL_COLOR),
		WriteWindow->RPort,
		0, 0,
		image.width,
		image.height,
		RECTFMT_RGBA);

	/* event loop */

	done = FALSE;
	while (!done)
	{
		(void)Wait(SIGMASK(WriteWindow));

		while (IntMsg=GETIMSG(WriteWindow))
		{
			switch (IntMsg->Class)
			{
				case IDCMP_REFRESHWINDOW:
					BeginRefresh(WriteWindow);
					WritePixelArray(
						image.colormap,
						src_x, src_y,
						image.width*sizeof(SMALL_COLOR),
						WriteWindow->RPort,
						0, 0,
						image.width,
						image.height,
						RECTFMT_RGBA);
					EndRefresh(WriteWindow,TRUE);
					break;
				case IDCMP_VANILLAKEY:
					switch(IntMsg->Qualifier & 0x7fff)
					{
						case 0:
							switch (IntMsg->Code)
							{
								case 27:
									done = TRUE;
									break;
							}
							break;
					}
					break;
				case IDCMP_RAWKEY:
					old_src_x = src_x;
					old_src_y = src_y;
					switch(IntMsg->Code)
					{
						case CURSORRIGHT:
							if(src_x + WriteWindow->Width + WriteWindow->LeftEdge < image.width)
							{
								src_x += 8;
								if(src_x + WriteWindow->Width + WriteWindow->LeftEdge > image.width)
									src_x = image.width - WriteWindow->Width - WriteWindow->LeftEdge;
							}
							break;
						case CURSORLEFT:
							if(src_x > 0)
							{
								src_x -= 8;
								if(src_x < 0)
									src_x = 0;
							}
							break;
						case CURSORDOWN:
							if(src_y + WriteWindow->Height + WriteWindow->TopEdge < image.height)
							{
								src_y += 8;
								if(src_y + WriteWindow->Height + WriteWindow->TopEdge > image.height)
									src_y = image.height - WriteWindow->Height - WriteWindow->TopEdge;
							}
							break;
						case CURSORUP:
							if(src_y > 0)
							{
								src_y -= 8;
								if(src_y < 0)
									src_y = 0;
							}
							break;
					}
					if((old_src_x != src_x) || (old_src_y != src_y))
					{
						if(old_src_x < src_x)
						{
							ClipBlit(
								WriteWindow->RPort,
								src_x - old_src_x,
								0,
								WriteWindow->RPort,
								0,
								0,
								WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x),
								WriteWindow->Height + WriteWindow->TopEdge,
								0xc0);
							WritePixelArray(
								image.colormap,
								old_src_x + WriteWindow->Width + WriteWindow->LeftEdge,
								src_y,
								image.width*sizeof(SMALL_COLOR),
								WriteWindow->RPort,
								WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x),
								0,
								src_x - old_src_x,
								WriteWindow->Height + WriteWindow->TopEdge,
								RECTFMT_RGBA);
						}
						else if(old_src_x > src_x)
						{
							ClipBlit(
								WriteWindow->RPort,
								0,
								0,
								WriteWindow->RPort,
								old_src_x - src_x,
								0,
								WriteWindow->Width + WriteWindow->LeftEdge - (old_src_x - src_x),
								WriteWindow->Height + WriteWindow->TopEdge,
								0xc0);
							WritePixelArray(
								image.colormap,
								src_x,
								src_y,
								image.width*sizeof(SMALL_COLOR),
								WriteWindow->RPort,
								0,
								0,
								old_src_x - src_x,
								WriteWindow->Height + WriteWindow->TopEdge,
								RECTFMT_RGBA);
						}
						else if(old_src_y < src_y)
						{
							ClipBlit(
								WriteWindow->RPort,
								0,
								src_y - old_src_y,
								WriteWindow->RPort,
								0,
								0,
								WriteWindow->Width + WriteWindow->LeftEdge,
								WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y),
								0xc0);
							WritePixelArray(
								image.colormap,
								src_x,
								old_src_y + WriteWindow->Height + WriteWindow->TopEdge,
								image.width*sizeof(SMALL_COLOR),
								WriteWindow->RPort,
								0,
								WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y),
								WriteWindow->Width + WriteWindow->LeftEdge,
								src_y - old_src_y,
								RECTFMT_RGBA);
						}
						else if(old_src_y > src_y)
						{
							ClipBlit(
								WriteWindow->RPort,
								0,
								0,
								WriteWindow->RPort,
								0,
								old_src_y - src_y,
								WriteWindow->Width + WriteWindow->LeftEdge,
								WriteWindow->Height + WriteWindow->TopEdge - (old_src_y - src_y),
								0xc0);
							WritePixelArray(
								image.colormap,
								src_x,
								src_y,
								image.width*sizeof(SMALL_COLOR),
								WriteWindow->RPort,
								0,
								0,
								WriteWindow->Width + WriteWindow->LeftEdge,
								old_src_y - src_y,
								RECTFMT_RGBA);
						}
					}
					break;
				case IDCMP_MOUSEBUTTONS:
					done = TRUE;
					break;
			}

			ReplyMsg (&IntMsg->ExecMessage);
		}
	}

	/* cleanup */

	CloseWindow(WriteWindow);
	CloseScreen(CyberScreen);
	CloseLibrary(CyberGfxBase);
	CloseLibrary(&IntuitionBase->LibNode);
	Cleanup(&image);

	return 0;
}
Exemplo n.º 14
0
LONG Blank( PrefObject *Prefs )
{
	LONG ToFrontCount = 0, Wid, Hei, Drops, x, y, r, i, incr, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *Scr;
	struct Window *Wnd;
	LONG d, xs, ys, rs;
	
	Drops = Prefs[0].po_Level;
	
	Scr = OpenScreenTags( 0L, SA_Depth, Prefs[2].po_Depth, SA_Quiet, TRUE,
						 SA_Overscan, OSCAN_STANDARD, SA_Behind, TRUE,
						 SA_DisplayID, Prefs[2].po_ModeID, SA_ShowTitle, FALSE,
						 SA_Title, "Garshnescreen", TAG_DONE );
	if( Scr )
	{
		Wid = Scr->Width;
		Hei = Scr->Height;
		d = min( Wid, Hei );
		xs = 3 * Wid;
		ys = 4 * Hei;
		
		Rast = &( Scr->RastPort );
		SetRast( Rast, 0 );
		
		for( i = 0; i < 4; i++ )
			SetRGB4(&( Scr->ViewPort ), i, 4 * i, 4 * i, 4 * i );
		
		Wnd = BlankMousePointer( Scr );
		ScreenToFront( Scr );
		
		while( RetVal == OK )
		{
			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( Scr );
			
			if(!( ToFrontCount % Drops ))
				SetRast(&( Scr->RastPort ), 0 );
			
			r = RangeRand( d/13 ) + d/25;
			if( Wid > Hei )
				rs = r * xs / ys;
			else
				rs = r * ys / xs;
			x = RangeRand( Wid - 2*rs ) + rs;
			y = RangeRand( Hei - 2*rs ) + rs;
			
			incr = max( Wid/160, 1 );

			for( i = 0; i < r; i += incr )
			{
				WaitTOF();
				SetAPen( &Scr->RastPort,
						( ULONG )RangeRand(( 1L << Prefs[2].po_Depth ) - 1 )
						+ 1 );
				if( Wid > Hei )
				{
					DrawEllipse(&( Scr->RastPort ), x, y, i * xs / ys, i );
					if( i )
					{
						SetAPen(&( Scr->RastPort ), 0 );
						DrawEllipse(&( Scr->RastPort ), x, y,
									xs * ( i - incr ) / ys, i - incr );
					}
				}
				else
				{
					DrawEllipse(&( Scr->RastPort ), x, y, i, ys * i / xs );
					if( i )
					{
						SetAPen(&( Scr->RastPort ), 0 );
						DrawEllipse(&( Scr->RastPort ), x, y, i - incr,
									( i - incr ) * ys / xs );
					}
				}

			}
			
			RetVal = ContinueBlanking();
		}
		UnblankMousePointer( Wnd );
	}
	else
		RetVal = FAILED;
	
	if( Scr )
		CloseScreen( Scr );
	
	return RetVal;
}
Exemplo n.º 15
0
void *Sys_Video_Open(const char *mode, unsigned int width, unsigned int height, int fullscreen, unsigned char *palette)
{
	struct display *d;
	struct modeinfo modeinfo;
	char monitorname[128];
	char *p;
	int r;
	int i;

	d = AllocVec(sizeof(*d), MEMF_CLEAR);
	if (d)
	{
		if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 74))
		{
			d->gammaenabled = 1;
		}

		TinyGLBase = OpenLibrary("tinygl.library", 0);
		if (TinyGLBase)
		{
			if (fullscreen)
			{
				if (*mode && modeline_to_modeinfo(mode, &modeinfo))
				{
					snprintf(monitorname, sizeof(monitorname), "%s.monitor", modeinfo.monitorname);
					d->screen = OpenScreenTags(0,
						SA_Width, modeinfo.width,
						SA_Height, modeinfo.height,
						SA_Depth, modeinfo.depth,
						SA_MonitorName, monitorname,
						SA_Quiet, TRUE,
						SA_GammaControl, TRUE,
						SA_3DSupport, TRUE,
						TAG_DONE);
				}
				else
				{
					d->screen = OpenScreenTags(0,
						SA_Quiet, TRUE,
						SA_GammaControl, TRUE,
						SA_3DSupport, TRUE,
						TAG_DONE);
				}

				if (d->screen)
				{
					width = d->screen->Width;
					height = d->screen->Height;

					strlcpy(monitorname, "Dunno", sizeof(monitorname));

					if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 53))
					{
						GetAttr(SA_MonitorName, d->screen, &p);
						if (p)
						{
							strlcpy(monitorname, p, sizeof(monitorname));
							p = strstr(monitorname, ".monitor");
							if (p)
								*p = 0;
						}
					}

					snprintf(d->used_mode, sizeof(d->used_mode), "%s,%d,%d,%d", monitorname, width, height, GetBitMapAttr(d->screen->RastPort.BitMap, BMA_DEPTH));

					if (d->gammaenabled)
					{
						d->gammatable = AllocVec(256*3, MEMF_ANY);
						if (d->gammatable == 0)
						{
							CloseScreen(d->screen);
							d->screen = 0;
						}
					}
				}
				else
					fullscreen = 0;
			}

			if (d->screen || !fullscreen)
			{
				d->window = OpenWindowTags(0,
					WA_InnerWidth, width,
					WA_InnerHeight, height,
					WA_Title, "Fodquake",
					WA_DragBar, d->screen?FALSE:TRUE,
					WA_DepthGadget, d->screen?FALSE:TRUE,
					WA_Borderless, d->screen?TRUE:FALSE,
					WA_RMBTrap, TRUE,
					d->screen?WA_PubScreen:TAG_IGNORE, (ULONG)d->screen,
					WA_Activate, TRUE,
					TAG_DONE);

				if (d->window)
				{
					__tglContext = GLInit();
					if (__tglContext)
					{
						if (d->screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4))
						{
							r = glAInitializeContextScreen(d->screen);
						}
						else
						{
							r = glAInitializeContextWindowed(d->window);
						}

						if (r)
						{
							d->pointermem = AllocVec(256, MEMF_ANY|MEMF_CLEAR);
							if (d->pointermem)
							{
								SetPointer(d->window, d->pointermem, 16, 16, 0, 0);

								d->width = width;
								d->height = height;
								d->fullscreen = fullscreen;

								d->inputdata = Sys_Input_Init(d->screen, d->window);
								if (d->inputdata)
								{
									return d;
								}

								FreeVec(d->pointermem);
							}

							if (d->screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4))
								glADestroyContextScreen();
							else
								glADestroyContextWindowed();
						}

						GLClose(__tglContext);
					}

					CloseWindow(d->window);
				}

				if (d->screen)
					CloseScreen(d->screen);
			}

			CloseLibrary(TinyGLBase);
		}

		FreeVec(d);
	}

	return 0;
}
Exemplo n.º 16
0
LONG Blank( PrefObject *Prefs )
{
	LONG ToFrontCount = 0, Wid, Hei, i, x, y, Stars, Speed, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *Scr;
	struct Window *Wnd;
	Coord3D *p;
	Coord2D *p2;
	
	Stars = Prefs[0].po_Level;
	Speed = Prefs[2].po_Level;
	
	Coords = AllocVec( Stars * sizeof( Coord3D ), MEMF_CLEAR );
	OldCoords = AllocVec( Stars * sizeof( Coord2D ), MEMF_CLEAR );
	Scr = OpenScreenTags( 0L, SA_Depth, 2, SA_Overscan, OSCAN_STANDARD,
						 SA_DisplayID, Prefs[4].po_ModeID, SA_Behind, TRUE,
						 SA_Quiet, TRUE, SA_ShowTitle, FALSE, SA_Title,
						 "Garshnescreen", TAG_DONE );

	if( Coords && OldCoords && Scr )
	{
		Wid = Scr->Width;
		Hei = Scr->Height;
		
		Rast = &( Scr->RastPort );
		SetRast( Rast, 0 );
		for( i = 0; i < 4; i++ )
			SetRGB4(&( Scr->ViewPort ), i, 4 * i, 4 * i, 4 * i );
		
		for( i = 0; i < Stars; i++ )
		{
			InitStar( &Coords[i], Speed );
			OldCoords[i].x = 0;
			OldCoords[i].y = 0;
		}
		
		Wnd = BlankMousePointer( Scr );
		ScreenToFront( Scr );
		
		while( RetVal == OK )
		{
			WaitTOF();

			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( Scr );
			
			for( p2 = OldCoords, p = Coords, i = 0;
				i < Stars; i++, p++, p2++ )
			{
				x = p2->x;
				y = p2->y;
				
				SetAPen( Rast, 0 );
				switch( p->z / 200 )
				{
				case 0:
					WritePixel( Rast, x, y+1 );
					WritePixel( Rast, x+1, y+1 );
				case 1:
				case 2:
				case 3:
				case 4:
					WritePixel( Rast, x+1, y );
				default:
					WritePixel( Rast, x, y );
				}

				p->z -= p->speed;
				if( p->z <= -1000 )
					InitStar( p, Speed );
				
				x = Wid/2 + ( 200 * p->x ) / ( p->z + 1000 );
				y = Hei/2 + ( 200 * p->y ) / ( p->z + 1000 );
				
				if(( x < 0 )||( x > Wid-2 )||( y < 0 )||( y > Hei-2 ))
				{
					InitStar( p, Speed );
					p2->x = 0;
					p2->y = 0;
				}
				else
				{
					p2->x = x;
					p2->y = y;
					SetAPen( Rast, 3 );
					/* Warning: This is a little twisted. */
					switch( p->z/200 )
					{
					case 9:
					case 8:
						SetAPen( Rast, 2 );
						break;
					case 0:
						WritePixel( Rast, x, y+1 );
						WritePixel( Rast, x+1, y+1 );
					case 4:
					case 3:
					case 2:
					case 1:
						WritePixel( Rast, x+1, y );
					case 7:
					case 6:
					case 5:
						break;
					default:
						SetAPen( Rast, 1 );
						break;
					}
					WritePixel( Rast, x, y );
				}
			}
			if(!( ToFrontCount % 5 ))
				RetVal = ContinueBlanking();
		}
		UnblankMousePointer( Wnd );
	}
	else
		RetVal = FAILED;

	if( Scr )
		CloseScreen( Scr );
	if( Coords )
		FreeVec( Coords );
	if( OldCoords )
		FreeVec( OldCoords );

	return RetVal;
}
Exemplo n.º 17
0
LONG Blank( PrefObject *Prefs )
{
	struct Screen *Scr;
	struct Window *Wnd;
	LONG ToFrontCount = 0, RetVal = OK;
	
	MaxFires = Prefs[NUMBER].po_Level;
	Power = Prefs[POWER].po_Level;
	Radius = Prefs[RADIUS].po_Level;
	
	FireTable = AllocVec( sizeof( struct Fire ) * ( MAX_FIRE + 1 ),
						 MEMF_CLEAR );
	
	if( FireTable )
	{
		Scr = OpenScreenTags( 0L, SA_Depth, Prefs[MODE].po_Depth,
							 SA_Overscan, OSCAN_STANDARD, SA_Quiet, TRUE,
							 SA_DisplayID, Prefs[MODE].po_ModeID,
							 SA_Behind, TRUE, TAG_DONE );
		if( Scr )
		{
			LastFire = &( FireTable[MAX_FIRE] );
			
			Wid = Scr->Width;
			Hei = Scr->Height;
			
			if( Prefs[MODE].po_Depth < 3 )
				setCopperList( Hei, 1, &( Scr->ViewPort ), &custom );
			
			SetRGB4(&( Scr->ViewPort ), 0, 0, 0, 0 );
			SetRGB4(&( Scr->ViewPort ), 1, 0x0F, 0x0F, 0x0F );
			SetRast(&( Scr->RastPort ), 0 );
			
			NumFires = 0;
			Wnd = BlankMousePointer( Scr );
			ScreenToFront( Scr );
			
			while( RetVal == OK )
			{
				WaitTOF();
				IterateFire(&( Scr->RastPort ));
				if(!( ToFrontCount++ % 60 ))
					ScreenToFront( Scr );
				if(!( ToFrontCount % 5 ))
					RetVal = ContinueBlanking();
			}
			
			UnblankMousePointer( Wnd );
			if( Prefs[MODE].po_Depth < 3 )
				clearCopperList( &Scr->ViewPort );
			CloseScreen( Scr );
		}
		else
			RetVal = FAILED;

		FreeVec( FireTable );
	}
	else
		RetVal = FAILED;
	
	return RetVal;
}
Exemplo n.º 18
0
LONG Blank( PrefObject *Prefs )
{
	LONG ToFrontCount = 0, Wid, Hei, Drops, x, y, r, i, incr, RetVal = OK;
	struct RastPort *Rast;
	struct Screen *Scr;
	struct Window *Wnd;
	
	Drops = Prefs[0].po_Level;
	
	Scr = OpenScreenTags( 0L, SA_Depth, Prefs[2].po_Depth, SA_Quiet, TRUE,
						 SA_Overscan, OSCAN_STANDARD, SA_Behind, TRUE,
						 SA_DisplayID, Prefs[2].po_ModeID, TAG_DONE );
	if( Scr )
	{
		Wid = Scr->Width;
		Hei = Scr->Height;
		
		Rast = &( Scr->RastPort );
		SetRast( Rast, 0 );
		
		for( i = 0; i < 4; i++ )
			SetRGB4(&( Scr->ViewPort ), i, 4 * i, 4 * i, 4 * i );
		
		Wnd = BlankMousePointer( Scr );
		ScreenToFront( Scr );
		
		while( RetVal == OK )
		{
			if(!( ++ToFrontCount % 60 ))
				ScreenToFront( Scr );
			
			if(!( ToFrontCount % Drops ))
				SetRast(&( Scr->RastPort ), 0 );
			
			r = RangeRand( Wid/13 ) + Wid/25;
			x = RangeRand( Wid - 2*r ) + r;
			y = RangeRand( Hei - 2*r ) + r;
			
			incr = max( Wid/160, 1 );

			for( i = 0; i < r; i += incr )
			{
				WaitTOF();
				SetAPen( &Scr->RastPort,
						( ULONG )RangeRand(( 1L << Prefs[2].po_Depth ) - 1 )
						+ 1 );
				DrawEllipse(&( Scr->RastPort ), x, y, i, i );
				if( i )
				{
					SetAPen(&( Scr->RastPort ), 0 );
					DrawEllipse(&( Scr->RastPort ), x, y, i - incr, i - incr );
				}
			}
			
			RetVal = ContinueBlanking();
		}
		UnblankMousePointer( Wnd );
	}
	else
		RetVal = FAILED;
	
	if( Scr )
		CloseScreen( Scr );
	
	return RetVal;
}
Exemplo n.º 19
0
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 );
}
Exemplo n.º 20
0
LONG Blank (PrefObject *Prefs)
{
	LONG Count, ScrToFrontCnt = 0, RetVal = TRUE, Size;
	LONG	Number;
	struct Screen *PatchScreen;

	PatchScreen = OpenScreenTags (NULL,
					SA_Depth, 3,
					SA_Overscan, OSCAN_STANDARD,
					SA_DisplayID, Prefs[MODE].po_ModeID,
					SA_Quiet, TRUE,
					SA_Behind, TRUE,
					TAG_DONE);
	Size = sizeof (LINET) * Prefs[NO_LINES].po_Active;
	Line = (LINET *) AllocVec (Size, 0L);

	if (PatchScreen && Line)
	{
		HalfWidth = PatchScreen->Width / 2;
		HalfHeight = PatchScreen->Height / 2;
		if (HalfWidth < HalfHeight)
		{
			Size = HalfWidth - 1;
		}
		else
		{
			Size = HalfHeight - 1;
		}

		SetRGB4 (&(PatchScreen->ViewPort), 0, 0, 0, 0);
		SetRast (&(PatchScreen->RastPort), 0);
		Colors = (1L << PatchScreen->RastPort.BitMap->Depth) - 1;
		ColorTable = RainbowPalette (PatchScreen, 0L, 1L, 0L);
		ScreenToFront (PatchScreen);
		Count = Prefs[SPEED].po_Level + 1;

		for (Number = 0 ; Number < Prefs[NO_LINES].po_Active ; Number++)
		{
			DrawLine (&(PatchScreen->RastPort), Prefs, Size, Number);
		}
		Number = 0;
		while (RetVal == TRUE)
		{
			WaitTOF();

			if (!(ScrToFrontCnt++ % 60))
			{
				ScreenToFront (PatchScreen);
			}

			if (++Count > MAX_SPEED)
			{
				Count = Prefs[SPEED].po_Level + 1;
				Number++;
				if (Number == Prefs[NO_LINES].po_Active)
				{
					Number = 0;
				}
				KillLine (&(PatchScreen->RastPort), Prefs, Number);
				DrawLine (&(PatchScreen->RastPort), Prefs, Size, Number);
			}
			RetVal = ContinueBlanking();
		}
		CloseScreen (PatchScreen);
	}
	else
	{
		RetVal = FALSE;
	}

	return RetVal;
}
Exemplo n.º 21
0
void *Sys_Video_Open(const char *mode, unsigned int width, unsigned int height, int fullscreen, unsigned char *palette)
{
	struct display *d;
	struct modeinfo modeinfo;
	char monitorname[128];
	int r;
	int i;

	d = AllocVec(sizeof(*d), MEMF_CLEAR);
	if (d)
	{
		MesaBase = OpenLibrary("mesa.library", 0);
		if (MesaBase)
		{
			if (fullscreen)
			{
				if (*mode && modeline_to_modeinfo(mode, &modeinfo))
				{
					snprintf(monitorname, sizeof(monitorname), "%s.monitor", modeinfo.monitorname);
					d->screen = OpenScreenTags(0,
						SA_Width, modeinfo.width,
						SA_Height, modeinfo.height,
						SA_Depth, modeinfo.depth,
#if 0
						SA_MonitorName, monitorname,
#endif
						SA_Quiet, TRUE,
						TAG_DONE);
				}
				else
				{
					d->screen = OpenScreenTags(0,
						SA_Quiet, TRUE,
						TAG_DONE);
				}

				if (d->screen)
				{
					width = d->screen->Width;
					height = d->screen->Height;

					snprintf(d->used_mode, sizeof(d->used_mode), "Dunno,%d,%d,42", width, height);
				}
				else
					fullscreen = 0;
			}

			if (d->screen || !fullscreen)
			{
				d->window = OpenWindowTags(0,
					d->screen?WA_Width:WA_InnerWidth, width,
					d->screen?WA_Height:WA_InnerHeight, height,
					WA_Title, "Fodquake",
					WA_DragBar, d->screen?FALSE:TRUE,
					WA_DepthGadget, d->screen?FALSE:TRUE,
					WA_Borderless, d->screen?TRUE:FALSE,
					WA_RMBTrap, TRUE,
					d->screen?WA_CustomScreen:TAG_IGNORE, (IPTR)d->screen,
					WA_Activate, TRUE,
					TAG_DONE);

				if (d->window)
				{
					d->mesacontext = AROSMesaCreateContextTags(
						AMA_Window, d->window,
						AMA_Left, d->screen?0:d->window->BorderLeft,
						AMA_Top, d->screen?0:d->window->BorderTop,
						AMA_Width, width,
						AMA_Height, height,
						AMA_NoStencil, TRUE,
						AMA_NoAccum, TRUE,
						TAG_DONE);

					if (d->mesacontext)
					{
						AROSMesaMakeCurrent(d->mesacontext);
						
						d->pointermem = AllocVec(256, MEMF_ANY|MEMF_CLEAR);
						if (d->pointermem)
						{
							SetPointer(d->window, d->pointermem, 16, 16, 0, 0);

							d->width = width;
							d->height = height;
							d->fullscreen = fullscreen;

							d->inputdata = Sys_Input_Init(d->screen, d->window);
							if (d->inputdata)
							{
								return d;
							}

							FreeVec(d->pointermem);
						}

						AROSMesaMakeCurrent(0);
						AROSMesaDestroyContext(d->mesacontext);
					}

					CloseWindow(d->window);
				}

				if (d->screen)
					CloseScreen(d->screen);
			}

			CloseLibrary(MesaBase);
		}

		FreeVec(d);
	}

	return 0;
}
Exemplo n.º 22
0
    // TODO desc->SysDefault
    // TODO desc->AutoClose
    // TODO desc->CloseGadget
    // TODO desc->SystemPens
    // TODO desc->Palette
    
    struct Screen *screen = OpenScreenTags(NULL,
	    SA_Type, (IPTR) PUBLICSCREEN,
	    SA_PubName, desc->Name,
	    SA_Title, desc->Title,
	    SA_Font, font,
	    (backfillHook ? SA_BackFill : TAG_IGNORE), backfillHook,
	    SA_DisplayID, (IPTR) desc->DisplayID,
	    SA_Width, (IPTR) desc->DisplayWidth,
	    SA_Height, (IPTR) desc->DisplayHeight,
	    SA_Depth, (IPTR) desc->DisplayDepth,
	    SA_Overscan, (IPTR) desc->OverscanType,
	    SA_AutoScroll, (IPTR) desc->AutoScroll,
	    SA_Draggable, (IPTR) !desc->NoDrag,
	    SA_Exclusive, (IPTR) desc->Exclusive,
	    SA_Interleaved, (IPTR) desc->Interleaved,
	    SA_Behind, (IPTR) desc->Behind,
            TAG_DONE);
    
    if(screen)
    {
	ret = desc->Name;
	struct Node *node;
	ForeachNode(&MUIScreenBase->clients, node)
	{