diff options
Diffstat (limited to 'Source/EndAnimation.c')
| -rw-r--r-- | Source/EndAnimation.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/Source/EndAnimation.c b/Source/EndAnimation.c index 3907d6e..c60bf30 100644 --- a/Source/EndAnimation.c +++ b/Source/EndAnimation.c @@ -18,18 +18,18 @@ enum { END_ANIMATION_FADEOUT_STEP = 8, - + END_ANIMATION_LINE_STEP = 2, - + END_ANIMATION_SQUARES_SIZE_BITSHIFT = 5, END_ANIMATION_SQUARES_SIZE = 32, END_ANIMATION_SQUARES_PER_COLUMN = 8, END_ANIMATION_SQUARES_PER_ROW = 12, END_ANIMATION_SQUARES_TOTAL = END_ANIMATION_SQUARES_PER_COLUMN * END_ANIMATION_SQUARES_PER_ROW, - + END_ANIMATION_SQUARES_TOTAL_MAX_INDEX = END_ANIMATION_SQUARES_TOTAL - 1, - + END_ANIMATION_SQUARES = 0, END_ANIMATION_FADEOUT, END_ANIMATION_LINE, @@ -54,11 +54,11 @@ static GsSprite EndAnimationDisplay; void EndAnimation(void) { uint8_t randIndex = 0; - + GfxSaveDisplayData(&EndAnimationDisplay); - + GfxSetGlobalLuminance(NORMAL_LUMINANCE); - + if (SystemIsRandSeedSet() == false) { // Set default end animation @@ -67,25 +67,25 @@ void EndAnimation(void) else { randIndex = rand() % (END_ANIMATION_MAX_RAND_VALUE + 1); - + switch(randIndex) { case END_ANIMATION_SQUARES: EndAnimationSquares(); break; - + case END_ANIMATION_FADEOUT: EndAnimationFadeOut(); break; - + case END_ANIMATION_LINE: EndAnimationLine(); break; - + default: break; } - + SfxStopMusic(); } } @@ -93,26 +93,26 @@ void EndAnimation(void) void EndAnimationFadeOut(void) { uint8_t i; - + while (1) { if ( GfxGetGlobalLuminance() > 0) { GfxSetGlobalLuminance(GfxGetGlobalLuminance() - END_ANIMATION_FADEOUT_STEP); - + GfxSortSprite(&EndAnimationDisplay);; GfxDrawScene_Slow(); } else { GsSortCls(0,0,0); - + for (i = 0 ; i < 2 ; i++) { // Draw two frames to ensure black display GfxDrawScene_Slow(); } - + break; } } @@ -121,35 +121,35 @@ void EndAnimationFadeOut(void) void EndAnimationLine(void) { short rectIndex = 0; - + do { GfxSortSprite(&EndAnimationDisplay); - + // Draw upper half rectangle - + EndAnimationRect.x = 0; EndAnimationRect.y = 0; - + EndAnimationRect.w = X_SCREEN_RESOLUTION; EndAnimationRect.h = rectIndex; - + GsSortRectangle(&EndAnimationRect); - + EndAnimationRect.x = 0; EndAnimationRect.y = Y_SCREEN_RESOLUTION - rectIndex; - + EndAnimationRect.w = X_SCREEN_RESOLUTION; EndAnimationRect.h = rectIndex; - + GsSortRectangle(&EndAnimationRect); - + GfxDrawScene_Slow(); - + rectIndex += END_ANIMATION_LINE_STEP; - + }while (rectIndex <= (X_SCREEN_RESOLUTION >> 1) ); - + } void EndAnimationSquares(void) @@ -159,38 +159,38 @@ void EndAnimationSquares(void) bool sqPos[END_ANIMATION_SQUARES_TOTAL]; uint16_t sqCounter = END_ANIMATION_SQUARES_TOTAL; uint16_t maxIndex = END_ANIMATION_SQUARES_TOTAL_MAX_INDEX; - + EndAnimationRect.w = END_ANIMATION_SQUARES_SIZE; EndAnimationRect.h = END_ANIMATION_SQUARES_SIZE; - + EndAnimationRect.r = 0; EndAnimationRect.g = 0; EndAnimationRect.b = 0; - + memset(sqPos, false , END_ANIMATION_SQUARES_TOTAL); - + for (i = 0; i < END_ANIMATION_SQUARES_TOTAL ; i++) { - + do { randInd = SystemRand(0,maxIndex); - + /*Serial_printf("randInd = %d\t",randInd); Serial_printf("sqPos[randInd] = %d\n", sqPos[randInd]);*/ - + if (sqPos[randInd] == false) { sqPos[randInd] = true; sqCounter--; - + while (sqPos[maxIndex] == true) { // Lower maximum value for rand() so that it's // easier to spot new empty index on next iteration. maxIndex--; } - + break; } else @@ -200,11 +200,11 @@ void EndAnimationSquares(void) break; } } - + }while (1); - + GfxSortSprite(&EndAnimationDisplay); - + if (sqCounter != 0) { for (j = 0; j < END_ANIMATION_SQUARES_TOTAL ; j++) @@ -214,10 +214,10 @@ void EndAnimationSquares(void) EndAnimationRect.x = ((j) << END_ANIMATION_SQUARES_SIZE_BITSHIFT) - (short)( (j / END_ANIMATION_SQUARES_PER_ROW) * X_SCREEN_RESOLUTION); - + EndAnimationRect.y = (short) (j/ END_ANIMATION_SQUARES_PER_ROW) << END_ANIMATION_SQUARES_SIZE_BITSHIFT; - + GsSortRectangle(&EndAnimationRect); } } |
