예제 #1
0
LONG FracBlank( struct Screen *Scr, UWORD Wid, UWORD Hei )
{
	float x = 0, y = 0, xx, yy, a, b, c;
	LONG i, xe, ye, flg_end = OK, mod = ( 1L << Scr->BitMap.Depth ) - 1;
	struct RastPort *Rast = &( Scr->RastPort );
	
	SetRast( Rast, 0 );
	ScreenToFront( Scr );
	
	a = (float)RangeRand( 1000 ) / 10 - 50.0;
	do
		b = (float)RangeRand( 1000 ) / 10 - 50.0;
	while( b == 0.0 );
	c = (float)RangeRand( 1000 ) / 10 - 50.0;
	
	for( i = 0; i < 50000 && flg_end == OK; i++ )
	{
		if(!( i % 50 ))
		{
			ScreenToFront( Scr );
			flg_end = ContinueBlanking();
		}
		
		if( x < 0 )
			xx = y + sqrt( fabs( b * x - c ));
		else
			xx = y - sqrt( fabs( b * x - c ));
		yy = a - x;
		xe = Wid / 2 + (SHORT)x;
		ye = Hei / 2 + (SHORT)y;
		
		if(( xe >= 0 )&&( ye >= 0 )&&( xe < Wid )&&( ye < Hei ))
		{
			SetAPen( Rast, ( ReadPixel( Rast, xe, ye ) + 1 ) % mod + 1 );
			WritePixel( Rast, xe, ye );
		}
		
		x = xx;
		y = yy;
	}

	return flg_end;
}
예제 #2
0
static void resizeWindow(FrameworkWindow *window) {
  if(window->gadgets) {
    RemoveGList(window->intuitionWindow, window->gadgets->glist, -1);
    (*window->kind->freeGadgets)(window->gadgets);
    SetRast(window->intuitionWindow->RPort, 0);
    window->gadgets = (*window->kind->buildGadgets)(window->intuitionWindow->Width, window->intuitionWindow->Height, window->data);
    if(!window->gadgets) {
      fprintf(stderr, "resizeWindow: couldn't create gadgets\n");
      goto error;
    }
    AddGList(window->intuitionWindow, window->gadgets->glist, (UWORD)~0, -1, NULL);
    RefreshWindowFrame(window->intuitionWindow);
    RefreshGList(window->gadgets->glist, window->intuitionWindow, NULL, -1);
    GT_RefreshWindow(window->intuitionWindow, NULL);
  }

  return;

error:
  return;
}
예제 #3
0
LONG Dragon( struct Screen *Scr, SHORT Wid, SHORT Hei )
{
	LONG Color = 1, mod = (( 1L << Scr->BitMap.Depth ) - 1 ) * 5;
	LONG i, RetVal = OK, xd, yd;
	float a = PI-(( float )RangeRand( 100 )+10.0)/5000, xx, yy, x = 0, y = 0;
	struct RastPort *RP = &( Scr->RastPort );
	
	SetRast( RP, 0 );
	ScreenToFront( Scr );
	
	for( i = 0; i < 1000000 && RetVal == OK; i++ )
	{
		if(!( i % 100 ))
		{
			RetVal = ContinueBlanking();
			ScreenToFront( Scr );
		}
		
		xx = y - sin( x );
		yy = a - x;
		
		xd = Wid / 2 + (SHORT)( 2.0 * x );
		yd = Hei / 2 + (SHORT)( 2.0 * y );

		Color = ( Color + 1 ) % mod;

		if(( xd >= 0 )&&( yd >= 0 )&&( xd < Wid )&&( yd < Hei ))
		{
			SetAPen( RP, Color/5 + 1 );
			WritePixel( RP, xd, yd );
		}

		x = xx;
		y = yy;
	}

	return RetVal;
}
예제 #4
0
파일: requesters.c 프로젝트: michalsc/AROS
/* render a standard requester */
void render_requester(struct Requester *requester, struct IntuitionBase *IntuitionBase)
{
    struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
    struct RastPort *rp = requester->ReqLayer->rp;

    if ((requester->Flags & NOREQBACKFILL) == 0)
        SetRast(rp, requester->BackFill);

    if (requester->ImageBMap && requester->Flags & PREDRAWN)
        BltBitMapRastPort(requester->ImageBMap, 0, 0,
                          rp, 0, 0, requester->Width, requester->Height, 0xc0);

    if (requester->ReqImage && requester->Flags & USEREQIMAGE)
        DrawImage(rp, requester->ReqImage, 0, 0);

    if (requester->ReqBorder)
        DrawBorder(rp, requester->ReqBorder, 0, 0);

    if (requester->ReqGadget)
        RefreshGList(requester->ReqGadget, requester->RWindow, requester, -1);

    if (requester->ReqText)
        PrintIText(rp, requester->ReqText, 0, 0);
}
예제 #5
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;
}
예제 #6
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;
}
예제 #7
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;
}
예제 #8
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;
}
예제 #9
0
// Load a backfill pattern; pattern must be locked exclusively
void GetPattern(PatternData *pattern,struct Screen *screen,ULONG border_col)
{
	// Initially make invalid
	pattern->valid=FALSE;
	pattern->border_pen=0;

	// Set screen pointer
	pattern->screen=screen;

	// Check for invalid data
	if (!pattern->data)
	{
		// Update border pen
		GetPatternBorder(pattern,screen,border_col);
		return;
	}

	// Bitmap pattern?
	if (pattern->prefs.wbp_Flags&WBPF_PATTERN)
	{
		UWORD *ptr,*planes[MAXDEPTH];
		short num,row,col,pen;

		// Get plane pointers
		for (num=0;num<pattern->prefs.wbp_Depth;num++)
		{
			planes[num]=((UWORD *)pattern->data)+(PAT_HEIGHT*num);
		}
		pattern->fill_plane_key=0;

		// Clear fill initially
		for (num=0,ptr=pattern->fill[0];num<128;num++,ptr++)
			*ptr=0;

		// Under 37 use fill pattern as supplied
		if (((struct Library *)GfxBase)->lib_Version<39)
		{
			for (num=0;num<pattern->prefs.wbp_Depth;num++)
			{
				CopyMem(
					(char *)planes[num],
					(char *)pattern->fill[num],
					PAT_HEIGHT*sizeof(UWORD));
			}
			pattern->fill_plane_key=pattern->prefs.wbp_Depth;
		}

		// Otherwise, we need to remap
		else
		{
			// Go through pattern rows
			for (row=0;row<PAT_HEIGHT;row++)
			{
				// Go through bits
				for (col=0;col<PAT_WIDTH;col++)
				{
					// Clear pen
					pen=0;

					// Calculate pixel colour
					for (num=0;num<pattern->prefs.wbp_Depth;num++)
					{
						// Is bit set in this bitplane?
						if (planes[num][row]&(1<<col)) pen|=(1<<num);
					}

					// Pixel set?
					if (pen)
					{
						// Map pens 4-7 to top four colours
						if (pen>=4 && screen->RastPort.BitMap->Depth<=8)
						{
							pen=(1<<screen->RastPort.BitMap->Depth)-(8-pen);
						}

						// Remap
						for (num=0;num<8;num++)
						{
							// Want this bit?
							if (pen&(1<<num))
							{
								// Set bit
								pattern->fill[num][row]|=1<<col;
								if (num>=pattern->fill_plane_key)
									pattern->fill_plane_key=num+1;
							}
						}
					}
				}
			}
		}

		// Any data?
		if (pattern->fill_plane_key>0)
		{
			short depth;

			// Get depth for bitmap
			if (((struct Library *)GfxBase)->lib_Version>=39)
				depth=GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH);
			else
				depth=screen->RastPort.BitMap->Depth;

			// Check its not too deep
			if (depth>8) depth=8;

			// Allocate bitmap for pattern
			if ((pattern->pattern_bitmap=
				NewBitMap(
					PATTILE_SIZE,
					PATTILE_SIZE,
					depth,
					BMF_CLEAR,
					0)))
			{
				struct RastPort rp;
				struct BitMap *bitmap;

				// Initialise dummy rastport
				InitRastPort(&rp);
				rp.BitMap=pattern->pattern_bitmap;

				// Set fill pattern
				SetAfPt(&rp,pattern->fill[0],-4);

				// Fill bitmap
				SetRast(&rp,0);
				RectFill(&rp,0,0,PATTILE_SIZE-1,PATTILE_SIZE-1);

				// Is the screen a non-standard bitmap?
				if (((struct Library *)GfxBase)->lib_Version>=39 &&
					!(GetBitMapAttr(screen->RastPort.BitMap,BMA_FLAGS)&BMF_STANDARD))
				{
					// Try and allocate friend bitmap
					if ((bitmap=
						NewBitMap(
							PATTILE_SIZE,
							PATTILE_SIZE,
							depth,
							BMF_CLEAR,
							screen->RastPort.BitMap)))
					{
						// Copy to friend bitmap
						BltBitMap(
							pattern->pattern_bitmap,0,0,
							bitmap,0,0,
							PATTILE_SIZE,PATTILE_SIZE,
							0xc0,0xff,0);

						// Free original bitmap
						DisposeBitMap(pattern->pattern_bitmap);

						// Use new bitmap pointer
						pattern->pattern_bitmap=bitmap;
					}
				}

				// Get bitmap pointer
				pattern->bitmap=pattern->pattern_bitmap;

				// Get pattern size
				pattern->width=PATTILE_SIZE;
				pattern->height=PATTILE_SIZE;
			}
		}
	}

	// Picture; must have datatypes
	else
	if (DataTypesBase)
	{
		short len;
		BOOL remap=1;
		long precision=PRECISION_IMAGE;
		char name[256];
		long ver=0;
		struct Library *pdt;
#ifdef PATCH_OK
		APTR patchhandle=0;
#endif

		// Check picture datatype version
		if ((pdt=OpenLibrary("sys:classes/datatypes/picture.datatype",0)) ||
			(pdt=OpenLibrary("picture.datatype",0)))
		{
			// Get version
			ver=pdt->lib_Version;
			CloseLibrary(pdt);
		}

		// No remap?
		if ((len=strlen(pattern->data))>8 &&
			stricmp(pattern->data+len-8,".noremap")==0) remap=0;

		// Precision?
		if (len>6 && stricmp(pattern->data+len-6,".exact")==0)
			precision=PRECISION_EXACT;

		// Specified in prefs?
		else
		if (pattern->precision)
		{
			if (pattern->precision==-1) remap=0;
			else
			if (pattern->precision==1) precision=PRECISION_ICON;
			else
			if (pattern->precision==2) precision=PRECISION_GUI;
			else
			if (pattern->precision==3) precision=PRECISION_EXACT;
		}

#ifdef PATCH_OK
		// If we've got v43 of the datatype, we don't need the fastram patch
		if (ver<43)
		{
			// Add this task to the patchlist for allocbitmap
			patchhandle=AddAllocBitmapPatch(FindTask(0),screen);
		}
#endif

		// Turn back on requesters
		((struct Process *)FindTask(0))->pr_WindowPtr=GUI->window;

		// Check for random pictures, and then load picture
		if (pattern_check_random(pattern,name) &&
			(pattern->object=
				NewDTObject(name,
					DTA_GroupID,GID_PICTURE,
					PDTA_Screen,screen,
					PDTA_FreeSourceBitMap,TRUE,
					(ver>42)?PDTA_DestMode:TAG_IGNORE,MODE_V43,
					(ver>42)?PDTA_UseFriendBitMap:TAG_IGNORE,TRUE,
					TAG_END)))
		{
			struct BitMapHeader *header;
			struct BitMap *bitmap;
			D_S(struct FileInfoBlock, fib)

			// Get file information
			if (GetFileInfo(name,fib) && strnicmp(fib->fib_Comment,"dopus ",6)==0)
			{
				char *args=fib->fib_Comment+6;
				short val;
				rexx_skip_space(&args);
				while ((val=rexx_match_keyword(&args,background_key,0))!=-1)
				{
					// Tile/center/stretch
					if (val==3)
						pattern->flags&=~(PATF_CENTER|PATF_STRETCH);
					else
					if (val==4)
					{
						pattern->flags|=PATF_CENTER;
						pattern->flags&=~PATF_STRETCH;
					}
					else
					if (val==5 && pattern->prefs.wbp_Which==0)
					{
						pattern->flags|=PATF_STRETCH;
						pattern->flags&=~PATF_CENTER;
					}

					// Precision
					else
					if (val==6)
					{
						// Get precision
						rexx_skip_space(&args);
						if ((val=rexx_match_keyword(&args,precision_key,0))>-1)
						{
							if (val==0)
								remap=0;
							else
							if (val==1)
								precision=PRECISION_GUI;
							else
							if (val==2)
								precision=PRECISION_ICON;
							else
							if (val==3)
								precision=PRECISION_IMAGE;
							else
							if (val==4)
								precision=PRECISION_EXACT;
						}
					}

					// Border
					else
					if (val==8)
					{
						// Off?
						rexx_skip_space(&args);
						if (rexx_match_keyword(&args,on_off_strings2,0)==0)
							border_col&=~ENVBF_USE_COLOUR;
						else
						{
							border_col=ENVBF_USE_COLOUR;
							border_col|=Atoh(args,-1)<<8;
						}
					}
				}
			}

			// Layout picture (should check for success)
			SetDTAttrs(pattern->object,0,0,
				OBP_Precision,precision,
				PDTA_Remap,remap,
				TAG_END);
			DoMethod(pattern->object,DTM_PROCLAYOUT,0,1);

			// Get bitmap pointer and header
			GetDTAttrs(pattern->object,
				PDTA_BitMap,&bitmap,
				PDTA_DestBitMap,&pattern->bitmap,
				PDTA_BitMapHeader,&header,
				TAG_END);

			// No dest bitmap?
			if (!pattern->bitmap) pattern->bitmap=bitmap;

			// Valid bitmap?
			if (pattern->bitmap)
			{
				// Get width and height
				pattern->width=header->bmh_Width;
				pattern->height=header->bmh_Height;
			}
		}

		// Turn off requesters
		((struct Process *)FindTask(0))->pr_WindowPtr=(APTR)-1;

#ifdef PATCH_OK
		// Remove this task from the patchlist for allocbitmap
		if (patchhandle)
			RemAllocBitmapPatch(patchhandle);
#endif

		// Got bitmap?
		if (pattern->bitmap)
		{
			// Stretch?
			if (pattern->flags&PATF_STRETCH)
			{
				// Not the size of the screen?
				if (pattern->width!=screen->Width ||
					pattern->height!=screen->Height)
				{
					// Allocate a bitmap for the stretched picture
					if ((pattern->pattern_bitmap=
							NewBitMap(
								screen->Width,
								screen->Height,
								GetBitMapAttr(pattern->bitmap,BMA_DEPTH),
								BMF_CLEAR,
								screen->RastPort.BitMap)))
					{
						struct BitScaleArgs scale;

						// Scale bitmap
						scale.bsa_SrcX=0;
						scale.bsa_SrcY=0;
						scale.bsa_SrcWidth=pattern->width;
						scale.bsa_SrcHeight=pattern->height;
						scale.bsa_DestX=0;
						scale.bsa_DestY=0;
						scale.bsa_DestWidth=screen->Width;
						scale.bsa_DestHeight=screen->Height;
						scale.bsa_XSrcFactor=scale.bsa_SrcWidth;
						scale.bsa_XDestFactor=scale.bsa_DestWidth;
						scale.bsa_YSrcFactor=scale.bsa_SrcHeight;
						scale.bsa_YDestFactor=scale.bsa_DestHeight;
						scale.bsa_SrcBitMap=pattern->bitmap;
						scale.bsa_DestBitMap=pattern->pattern_bitmap;
						scale.bsa_Flags=0;
						BitMapScale(&scale);

						// Get pointer to scaled bitmap
						pattern->bitmap=pattern->pattern_bitmap;
						pattern->width=screen->Width;
						pattern->height=screen->Height;
					}
				}
			}
		}

		// Update border pen
		GetPatternBorder(pattern,screen,border_col);
	}

	// Pattern ok now
	pattern->valid=TRUE;
}
예제 #10
0
파일: pacgfx.c 프로젝트: spathiwa/pacq
DrawMaze(short drawdots)
{
   short i;

   DisplaySprites(FALSE);

   SetRast(rastport,0);

#if 0
   if (maxx+border >= width || maxy+border >= height)
      return -1; /* Error: Too big */
#endif

   if (maxx+border >= 1023 || maxy+border >= 1023)
      return -1; /* Error: Too big */

   SetDrMd(rastport,JAM1);

   if (drawdots==DOTS_EXCLUDED) /* Called from construction set */
   {
      if (!((mazestatus&GRAPH_LOADED)&&(mazestatus&VARS_LOADED))) return 0;
      SetRast(rastport,0);
      SetMazeColors();
   }

   BoxScreen();

   SetAPen(rastport,OUTLINECOLOR);
   mazedraw=1;                                /* Draw all of the edges */
   MazeDraw1(v_head);
   MazeDraw1(center_box);
   MazeDraw1(ghost_start);
   for(i=0;i<4;i++) MazeDraw1(box_side[i]);
   MazeDraw1(top_box);

   SetAPen(rastport,PATHCOLOR);
   mazedraw=0;                                   /* Clear the pathways */
   MazeDraw1(v_head);
   MazeDraw1(center_box);
   MazeDraw1(ghost_start);
   for(i=0;i<4;i++) MazeDraw1(box_side[i]);
   MazeDraw1(top_box);

   SetAPen(rastport,DOTCOLOR);
   numdots=0;
   DotDraw2(v_head);

   if(drawdots==DOTS_EXCLUDED)
   {
      WireFrameDraw(v_head);
      if (linedrawn)
      {
         DrawConnection(sv,olddir);
         linedrawn=!linedrawn; /* Nullify the effect within DrawConn... */
      }
   }
   DisplaySprites(sprites_on);

#if MYDEBUG
   printf("View->DxOffset=%d \tScreen->LeftEdge=%d\n",
           curr_View->DxOffset,PlayScreen->LeftEdge);
#endif

   return 1; /* 1 signals main module that maze was drawn successfully */
}
예제 #11
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;
}
예제 #12
0
LONG IFS( struct Screen *scr, SHORT width, SHORT height, PrefObject *Prefs )
{
  LONG flg_end = OK;
  int colors = (1L << scr->BitMap.Depth);
    double x,y,			/* the coordinate which gets computed */
           prob;		/* probability for continuing withot Clscr */
    int num,			/* total number of fctns for the current IFS */
        thef;			/* the currently applied function */
    int i,j,k;			/* multi-purpose counters, array indices */
    int wx,wy;			/* window coordinate of current point */
    int tx,ty;			/* # pixels to transpose the Origin (x,y) */

    double aa[FNUM][4],		/* For each f: a 2x2 matrix and */
           vv[FNUM][2],		/*             a transposition vector */
           comp[FNUM],		/* the compression of each function (1/comp[n]
                                 * is the compression of the function) */
           totcomp;		/* sum of all the size factors. The larger this
                                 * is, the longer we should compute */
    double CONTINUEPROBABILITY,CONTPROBDECREASE;
    bool TRANSPOSE,USEPROBABILITY,oncedone;
    int LENGTH,FUNCTIONS;

    struct RastPort *rp = &( scr->RastPort );

    CONTINUEPROBABILITY = ((double)Prefs[PREF_CONTPROB].po_Level)/100.0;
    CONTPROBDECREASE    = ((double)Prefs[PREF_DECREASE].po_Level)/100.0;
    USEPROBABILITY      = !(Prefs[PREF_AREA].po_Level);
    TRANSPOSE           = !(Prefs[PREF_TRANSPOSE].po_Level);
    LENGTH              = Prefs[PREF_ITERATIONS].po_Level;
    FUNCTIONS           = Prefs[PREF_FUNCTIONS].po_Level;
    
    while (1)
      { Move(rp,0,0);
        SetRast(rp,0);
        SetAPen(rp,1);
        ScreenToFront( scr );

        prob = CONTINUEPROBABILITY;
        oncedone = FALSE;
        while (((double)RangeRand(1000))/1000 < prob || !oncedone) {
        oncedone = TRUE;
        prob = prob - CONTPROBDECREASE;
        num = RangeRand(FUNCTIONS-2)+2;
        
        /* Compute the iterated function */
        totcomp = 0;
        { int moverand = RangeRand(4);

          /* select a move factor with the appropriate probability */
          double MOVEFACTOR;
          switch(moverand)
            { case 0: MOVEFACTOR = MOVEFACTORA; break;
              case 1: 
              case 2: MOVEFACTOR = MOVEFACTORB; break;
              case 3: MOVEFACTOR = MOVEFACTORC; break;
              default: MOVEFACTOR = MOVEFACTORB; break; /* should never happen */
            }

          /* compute the functions and their compression */
          for (k=0; k<num; k++)
              { for (i=0; i<2; i++)
                    { vv[k][i] = (FLOATRAND() - 0.5) * MOVEFACTOR;
                    }
                for (i=0; i<4; i++)
                    { aa[k][i] = (FLOATRAND() - 0.5) * SIZEFACTOR;
                    }
                comp[k] = abs(aa[k][0]*aa[k][2]-aa[k][1]*aa[k][3]);
                totcomp = totcomp + comp[k];
              }
        }

        /* and a probability distribution, eg. 
         * 2,3,1,4 -> 0.2, 0.3, 0.1, 0.4 -> 0.2, 0.5, 0.6, 1.0 */
        for (k=0; k<num; k++)
            { comp[k] = comp[k]/totcomp;
              if (k>0)
                 { comp[k] = comp[k]+comp[k-1];
                 }
            }

        comp[num-1] = 1.1; /* just to be safe of numerical errors, we increment
                            * the final probability a bit */

        /* Initialize the transpositions of the origin */
        if (TRANSPOSE)
          {
            tx = (int)(RangeRand(width/2))-width/4;
            ty = (int)(RangeRand(height/2))-height/4;
          }
        else
          { tx = ty = 0;
          }


        /* set the color for the function */
        SetAPen(rp,(int)(RangeRand(colors-1)+1));

        /* and now: compute the IFS. We do this using several iterations
         * instead of just one big step. This gives a picture which looks
         * a bit more structured. */
        for (i=0; i<(int)(LENGTH*totcomp); i++)
            { x=y=0;
              for (j=0; j<ITER; j++)
                  { double xx;

                    /* Find a function to use */
                    if (USEPROBABILITY)
                       { double p;
                         p = FLOATRAND();
                         thef = 0;
                         while (comp[thef] < p)
                           { thef++;
                           }
                       }
                    else
                       { thef = RangeRand(num);
                       }

                    /* compute (x,y) = (x,y)*aa + vv */
                    xx = (x*aa[thef][0]+y*aa[thef][1])+vv[thef][0];
                    y = (x*aa[thef][2]+y*aa[thef][3])+vv[thef][1];
                    x = xx;
                    
                    /* Convert it to a window coordinate and plot it */
                    wx = WINCO(x,width);
                    wy = WINCO(y,height);
                   
                    /* And transpose it, if necessary */
		    wx = wx + tx;
		    wy = wy + ty;
		    
		    if (wx > 0 && wx < width && wy > 0 && wy < height)
                       WritePixel(rp,wx,wy);
                  }
              ScreenToFront( scr );
              flg_end = ContinueBlanking();
              if (flg_end != OK)
		{ return flg_end;
		}
            }
        }
      }
    return flg_end;
}