Beispiel #1
0
void DrawReels( void )
{
//  	int n;
//  	for( n = 0; n < NUM_REELS; n++ )
//        DrawReel( n );
   UpdateDisplayPortion( g.render, REEL_OFSX, REEL_OFSY, REEL_STEPX*(g.nReels-1) + REEL_WIDTH, REEL_HEIGHT );
}
Beispiel #2
0
	void flush( void )
	{
		if( _wd && _ht )
		{
			//Log4( WIDE("Flushing update to display... %d,%d - %d,%d"), _x, _y, _wd, _ht );
         if( pDisplay )
				UpdateDisplayPortion( pDisplay, _x, _y, _wd, _ht );
			else
            SmudgeCommon( pControl );
		}
		_wd = 0;
		_ht = 0;
	}
Beispiel #3
0
int CPROC MouseMethod( uintptr_t psv, int32_t x, int32_t y, uint32_t b )
{
	if( !g.flags.bSpinning )
	{
		if( !b  )
		{
			g.ofs = -7;
			DrawReels();

		}
		else if( b == 1 )
		{
			if( g.ofs == -7 )
			{
				int n;
				if( !g.flags.bBackgroundInitialized)
				{
					ClearImageTo( g.backgroundsurface, BASE_COLOR_BLACK );
					BlotImage( g.backgroundsurface, g.background, 0, 0 );
					g.flags.bBackgroundInitialized = 1;
				}
				for( n = 0; n < NUM_REELS; n++ )
				{
               g.bReelSpinning[n] = 1;
				}
				g.flags.bSpinning = 1;

            if( 0 )//yucky. real cheesey.
				{
					int n, i;
					for( n = 0; n < g.nReels; n++ )
						for( i = 0; i < NUM_PICS+2; i++ )
						{
							g.reel[n][i] = g.images[rand()%10];
						}
				}
				DrawSpinningReels(TRUE);
			}
		}
	}
	else
	{
		if( b )
		{
			int reel = (x - REEL_OFSX) / REEL_STEPX;
			if( reel >= 0 && reel < NUM_REELS )
			{
				if( g.bReelSpinning[reel] )
				{
					g.bReelSpinning[reel] = 0;
					g.ofs = -32;
//    					DrawReel(reel);
					UpdateDisplayPortion( g.render
											  , REEL_OFSX
											  , REEL_OFSY
											  , REEL_STEPX*(reel)
											  , REEL_WIDTH );
					g.ofs = 7;
//  					DrawReel(reel);
					UpdateDisplayPortion( g.render
											  , REEL_OFSX
											  , REEL_OFSY
											  , REEL_STEPX*(reel)
											  , REEL_WIDTH );
					WakeableSleep( 100 );
					g.ofs = 0;
//  					DrawReel(reel);
					UpdateDisplayPortion( g.render
											  , REEL_OFSX
											  , REEL_OFSY
											  , REEL_STEPX*(reel)
											  , REEL_WIDTH );
					{
						int n;
						for( n = 0; n < NUM_REELS; n++ )
							if( g.bReelSpinning[n] )
								break;
						if( n == NUM_REELS )
						{
							g.flags.bSpinning = 0;
                     SyncRender( g.render);
//  							SetReelSpeedStep();

						}
					}
				}
			}
		}
	}
   return 1;
}
Beispiel #4
0
void DrawSpinningReels( LOGICAL init )
{
//Real sorry about all the static variables.  It does look silly, but
//it is preferable to maintain the static-ly declared variables within this scope.
//could move them to the global, but right now it suits the task.
//Remember, this function is called 4 times a second, and it is only this function
//that uses these variables, so oh well.  Call a spade a spade....they're static to
//keep persistent data.
	int n;
	static LOGICAL bInit[NUM_REELS];  //static to maintain state.
	static uint32_t effectcount = 0;  //static to maintain state.
	static LOGICAL bPlaying = FALSE;  //static to maintain state.
	static int iBobble[5] = {0,-54,32,0,0}; //no need to declare this over and over 4 times a second.
   static INDEX idxBobbleCount[NUM_REELS]; //static to maintain state.
	uint32_t uiSmartYOffset = ( ( NUM_PICS - NUM_PICS_IN_WINDOW ) / 2 );
	static uint32_t bBobbling[NUM_REELS];

//  	xlprintf(LOG_NOISE)("DrawSpinningReels, init is %s   g.flags.bSpinning is %d"
//  							 , (init?"TRUE":"FALSE")
//  							 , g.flags.bSpinning
//    							 );
	for( n = 0; n < g.nReels; n++ )
	{
		if( init )
		{
			bInit[n] = TRUE;
			if( !bPlaying )
			{
				SetReelSpeedStep();
				bPlaying = TRUE;
				BlotScaledImageSizedTo( g.statussurface
											 , g.playing
											 , 0, 0
											 , 140,  68
											 );
			}
		}

		if( g.bReelSpinning[n] )
		{
         //uiStartStep is each reel's random starting order.
			if (  g.uiStartStep[n] )
			{
				g.uiStartStep[n]--;
			}
			else
			{
				{
               //uiSpeedStep demonstrates speed of reel movement (FAST, medium, and ....slllowwww). And stop.stutter.stop.
					if( g.uiSpeedStep[n] == 0 )
					{
  						BlotImageSizedTo( g.subsurface[n]
  											 , g.dodges[rand()%NUM_BLURS]
  											 , 0, 0
  											 , 0, 0, 96,  (96 * NUM_PICS_IN_WINDOW)
											 );
                  //effectcount is how long reels should be speedy-blurry, and normal-blurry.
						if( effectcount < (NUM_ITERATIONS / 2 ) )
						  effectcount++;
						else
						{
							effectcount = 0;
							g.uiSpeedStep[n]++;
						}
					}
					else if( g.uiSpeedStep[n] == 1 )
					{

						BlotImageSizedTo( g.subsurface[n]
  											 , g.blurs[rand()%NUM_BLURS]
											 ,  0 ,0
											 , 0, 0, 96,  (96 * NUM_PICS_IN_WINDOW)
											 );

						if( effectcount < (NUM_ITERATIONS / 2 ) )
						  effectcount++;
						else
						{
							effectcount = 0;
							g.uiSpeedStep[n]++;
						}
					}

					else if( g.uiSpeedStep[n] == 2 )
					{
						if(  g.uiSpeedCounter[n] == 0 )
						{
// could move this entire declaration into the global, and control the init process differently, but for now
// declaring static variable arrays suit the task.  the reason why these arrays are static is that
// state needs to be maintained every time the function is entered and exited, and these variables are
// not really global (that is, this scope is the only scope that counts).

// count[n] counts the number of times the reel has spun before it begins to stop.
// iteration[n] determines the maximum number of times the reel must spin before it begins to stop.
// last[y][x] maintains what the last pic was in that position, and is later incremented to demonstrate movement.
							static INDEX count[NUM_REELS], iteration[NUM_REELS];
							static INDEX last[NUM_REELS][NUM_PICS];

							if( bInit[n] )
							{
								int y;
								idxBobbleCount[n] = uiSmartYOffset;
                        bBobbling[n] = 0;
								for( y = 0; y < NUM_REELS; y++ )
								{
									last[y][0] = GetPositionIndex( TRUE, n );
									last[y][1] = last[y][0] + 1;
									last[y][2] = last[y][1] + 1;
									last[y][3] = last[y][2] + 1;
									last[y][4] = last[y][3] + 1;
								}

												  //this doesn't work yet....or does it?
								{

									IMAGE_RECTANGLE rect;
									rect.x = 0;//REEL_OFSX + REEL_STEPX * n;
									rect.y = 0;//REEL_OFSY;
									rect.width = REEL_WIDTH;
									rect.height = REEL_HEIGHT;
									//FixImagePosition( g.subsurface[n] );
									//SetImageBound( g.subsurface[n], &rect );
								}
								bInit[n] = FALSE;
								count[n] = 0;
								iteration[n] = (rand()%NUM_ITERATIONS) + ITERATIONS_OFFSET;
							}

							{
                        INDEX idx;
								int x;

  								for( x = uiSmartYOffset; x <  ( NUM_PICS_IN_WINDOW + uiSmartYOffset) ; x++)
  								{
									idx = last[n][x];
									DrawPosition( n, idx, x,  0);
								}
//--- This is just quality assurance.--------
//  								for( x = 0; x < NUM_PICS; x++ )
//  								{
//                               idx = last[n][x];
//  									  BlotImageSizedTo( g.testsurface[n]
//  															, g.images[idx]
//  															, 0, ( 96 * x )
//  															, 0, 0, REEL_WIDTH, ( 96 *  NUM_PICS )
//  															);
//  								}
//--- This is just quality assurance.--------

							}

							if( idxBobbleCount[n] == uiSmartYOffset )
							{
//  								xlprintf(LOG_NOISE)("Well, %d is shifting"
//  										  , n
//  										  );
								last[n][4] = last[n][3];
								last[n][3] = last[n][2];
								last[n][2] = last[n][1];
								last[n][1] = last[n][0];
								last[n][0] = GetPositionIndex( FALSE, n );
								count[n]++;
							}
							if(count[n] == (iteration[n] + 2 ) )
							{
								uint32_t x;
								for( x = uiSmartYOffset; x <  ( NUM_PICS_IN_WINDOW + uiSmartYOffset) ; x++)
								{
									DrawPosition( n, last[n][x], x,  iBobble[idxBobbleCount[n]]);
								}
								if( idxBobbleCount[n] >= ( NUM_PICS_IN_WINDOW + uiSmartYOffset) )
								{
                           xlprintf(LOG_NOISE)("Bobbling");
									g.uiSpeedStep[n] = DO_NOT_SPIN;
														  //g.bReelSpinning[n] = 0;
                           bBobbling[n] = 1;
									g.uiSpeedCounter[n] = 0;
                           g.ofs = -7; //might figure out if this is even necessary to maintain later.
									{
										int m;
										for( m = 0; m < NUM_REELS; m++ )
//  											if( g.bReelSpinning[m] )
											if( !bBobbling[m] )
											{
//  												xlprintf(LOG_NOISE)(" %d is * still *  spinning."
//  																		 , m
//  																		 );
												break;
											}
											else
											{
												idxBobbleCount[m] = uiSmartYOffset + 1;
											}

										if( m == NUM_REELS )
										{
											g.flags.bSpinning = 0;
											{
                                    //reset the bobbleness.
												int z;
												for( z = 0; z < NUM_REELS; z++)
												{
													g.bReelSpinning[z] = 0;
													idxBobbleCount[z] = uiSmartYOffset;
												}

											}
											if( bPlaying )
											{
												BlotScaledImageSizedTo( g.statussurface
																			 , g.playagain
																			 , 0 , 0  //490, 10
																			 , 140,  68
																			 );
												UpdateDisplay(g.render);
												bPlaying = FALSE;
											}
										}
									}
								}
								else
								{
									idxBobbleCount[n]++;
								}
							}
							else if( count[n] > iteration[n] )
							{
								g.uiSpeedCounter[n] = count[n] - iteration[n]  ;
							}
						}
						else
                     g.uiSpeedCounter[n]--;
					}
				}
			}
		}
   }
	UpdateDisplayPortion( g.render, REEL_OFSX, REEL_OFSY, REEL_STEPX*(g.nReels-1) + REEL_WIDTH,  REEL_HEIGHT   );
}