diff options
Diffstat (limited to 'src/berry_crush.c')
-rwxr-xr-x | src/berry_crush.c | 304 |
1 files changed, 152 insertions, 152 deletions
diff --git a/src/berry_crush.c b/src/berry_crush.c index 5504d05d6..5c571778f 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -171,7 +171,7 @@ enum { #define INPUT_FLAG_MASK ((1 << INPUT_FLAGS_PER_PLAYER) - 1) // Values for the inputState field -enum { +enum { INPUT_STATE_NONE, INPUT_STATE_HIT, // Hit the crusher INPUT_STATE_HIT_SYNC, // Hit the crusher at same time as another player @@ -241,7 +241,7 @@ struct BerryCrushGame_Results }; // playerIdsRanked above has 3 additional elements after the players. -// Only 1 of these 2*3 is ever used, and it stores the id for which +// Only 1 of these 2*3 is ever used, and it stores the id for which // random results page to show. Its define below is for readability. #define randomPageId playerIdsRanked[0][7] @@ -369,33 +369,33 @@ static u32 Cmd_Quit(struct BerryCrushGame *, u8 *); static EWRAM_DATA struct BerryCrushGame *sGame = NULL; -static const u8 sBitTable[] = { - 1 << 0, - 1 << 1, - 1 << 2, - 1 << 3, - 1 << 4, - 1 << 5, - 1 << 6, - 1 << 7 +static const u8 sBitTable[] = { + 1 << 0, + 1 << 1, + 1 << 2, + 1 << 3, + 1 << 4, + 1 << 5, + 1 << 6, + 1 << 7 }; // Additional A presses are counted depending on the number of players // The bonus of 5 is unobtainable static const u8 sSyncPressBonus[MAX_RFU_PLAYERS] = { 0, 1, 2, 3, 5 }; ALIGNED(4) -static const s8 sIntroOutroVibrationData[][7] = +static const s8 sIntroOutroVibrationData[][7] = { - { 4, 1, 0, -1, 0, 0, 0}, - { 4, 2, 0, -1, 0, 0, 0}, - { 4, 2, 0, -2, 0, 0, 0}, - { 6, 3, 1, -1, -3, -1, 0}, + { 4, 1, 0, -1, 0, 0, 0}, + { 4, 2, 0, -1, 0, 0, 0}, + { 4, 2, 0, -2, 0, 0, 0}, + { 6, 3, 1, -1, -3, -1, 0}, { 6, 4, 1, -2, -4, -2, 0}, }; ALIGNED(4) -static const u8 sVibrationData[MAX_RFU_PLAYERS][4] = +static const u8 sVibrationData[MAX_RFU_PLAYERS][4] = { - {3, 2, 1, 0}, + {3, 2, 1, 0}, {3, 3, 1, 0}, {3, 3, 2, 0}, {3, 4, 2, 0}, @@ -433,7 +433,7 @@ static const struct BgTemplate sBgTemplates[4] = .screenSize = 2, .paletteMode = 0, .priority = 1, - .baseTile = 0, + .baseTile = 0, }, { .bg = 2, @@ -442,7 +442,7 @@ static const struct BgTemplate sBgTemplates[4] = .screenSize = 0, .paletteMode = 0, .priority = 2, - .baseTile = 0, + .baseTile = 0, }, { .bg = 3, @@ -451,7 +451,7 @@ static const struct BgTemplate sBgTemplates[4] = .screenSize = 0, .paletteMode = 0, .priority = 3, - .baseTile = 0, + .baseTile = 0, }, }; @@ -468,11 +468,11 @@ static const u8 sTextColorTable[][3] = static const struct WindowTemplate sWindowTemplate_Rankings = { - .bg = 0, - .tilemapLeft = 3, - .tilemapTop = 4, - .width = 24, - .height = 13, + .bg = 0, + .tilemapLeft = 3, + .tilemapTop = 4, + .width = 24, + .height = 13, .paletteNum = 15, .baseBlock = 1 }; @@ -480,48 +480,48 @@ static const struct WindowTemplate sWindowTemplate_Rankings = static const struct WindowTemplate sWindowTemplates_PlayerNames[MAX_RFU_PLAYERS + 1] = { { - .bg = 0, - .tilemapLeft = 0, - .tilemapTop = 0, - .width = 9, - .height = 2, - .paletteNum = 8, + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 0, + .width = 9, + .height = 2, + .paletteNum = 8, .baseBlock = 1005 }, { - .bg = 0, - .tilemapLeft = 0, - .tilemapTop = 3, - .width = 9, - .height = 2, - .paletteNum = 8, + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 3, + .width = 9, + .height = 2, + .paletteNum = 8, .baseBlock = 987 }, { - .bg = 0, - .tilemapLeft = 0, - .tilemapTop = 6, - .width = 9, - .height = 2, - .paletteNum = 8, + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 6, + .width = 9, + .height = 2, + .paletteNum = 8, .baseBlock = 969 }, { - .bg = 0, - .tilemapLeft = 21, - .tilemapTop = 3, - .width = 9, - .height = 2, - .paletteNum = 8, + .bg = 0, + .tilemapLeft = 21, + .tilemapTop = 3, + .width = 9, + .height = 2, + .paletteNum = 8, .baseBlock = 951 }, { - .bg = 0, - .tilemapLeft = 21, - .tilemapTop = 6, - .width = 9, - .height = 2, - .paletteNum = 8, + .bg = 0, + .tilemapLeft = 21, + .tilemapTop = 6, + .width = 9, + .height = 2, + .paletteNum = 8, .baseBlock = 933 }, DUMMY_WIN_TEMPLATE, @@ -530,30 +530,30 @@ static const struct WindowTemplate sWindowTemplates_PlayerNames[MAX_RFU_PLAYERS static const struct WindowTemplate sWindowTemplates_Results[] = { [STATE_RESULTS_PRESSES - RESULTS_STATE_START] = { - .bg = 0, - .tilemapLeft = 5, - .tilemapTop = 2, - .width = 20, - .height = 16, - .paletteNum = 15, + .bg = 0, + .tilemapLeft = 5, + .tilemapTop = 2, + .width = 20, + .height = 16, + .paletteNum = 15, .baseBlock = 1 }, [STATE_RESULTS_RANDOM - RESULTS_STATE_START] = { - .bg = 0, - .tilemapLeft = 5, - .tilemapTop = 2, - .width = 20, - .height = 16, - .paletteNum = 15, + .bg = 0, + .tilemapLeft = 5, + .tilemapTop = 2, + .width = 20, + .height = 16, + .paletteNum = 15, .baseBlock = 1 }, [STATE_RESULTS_CRUSHING - RESULTS_STATE_START] = { - .bg = 0, - .tilemapLeft = 4, - .tilemapTop = 2, - .width = 22, - .height = 16, - .paletteNum = 15, + .bg = 0, + .tilemapLeft = 4, + .tilemapTop = 2, + .width = 22, + .height = 16, + .paletteNum = 15, .baseBlock = 1 }, DUMMY_WIN_TEMPLATE, @@ -567,7 +567,7 @@ static const u8 sResultsWindowHeights[][MAX_RFU_PLAYERS - 1] = {12, 14, 15, 16}, // "Crushing" page }; -static const u32 sPressingSpeedConversionTable[] = +static const u32 sPressingSpeedConversionTable[] = { 50000000, // 50 25000000, // 25 @@ -590,9 +590,9 @@ static const u8 sCrusherTop_Tilemap[] = INCBIN_U8("graphics/berry_crush/crushe static const u8 sContainerCap_Tilemap[] = INCBIN_U8("graphics/berry_crush/container_cap.bin.lz"); static const u8 sBg_Tilemap[] = INCBIN_U8("graphics/berry_crush/bg.bin.lz"); -// Takes the number of players - 2 and a player id and returns the +// Takes the number of players - 2 and a player id and returns the // index into sPlayerCoords where that player should be seated -static const u8 sPlayerIdToPosId[MAX_RFU_PLAYERS - 1][MAX_RFU_PLAYERS] = +static const u8 sPlayerIdToPosId[MAX_RFU_PLAYERS - 1][MAX_RFU_PLAYERS] = { {1, 3}, {0, 1, 3}, @@ -672,18 +672,18 @@ static const s8 sSparkleCoords[][2] = { 40, -16}, }; -static const u16 sPlayerBerrySpriteTags[MAX_RFU_PLAYERS] = +static const u16 sPlayerBerrySpriteTags[MAX_RFU_PLAYERS] = { - TAG_PLAYER1_BERRY, - TAG_PLAYER2_BERRY, - TAG_PLAYER3_BERRY, - TAG_PLAYER4_BERRY, + TAG_PLAYER1_BERRY, + TAG_PLAYER2_BERRY, + TAG_PLAYER3_BERRY, + TAG_PLAYER4_BERRY, TAG_PLAYER5_BERRY }; // sTimerDigits_Gfx is part of this array but is (apparently) uncompressed // It gets cast to raw uncompressed data when used in sDigitObjTemplates -static const struct CompressedSpriteSheet sSpriteSheets[] = +static const struct CompressedSpriteSheet sSpriteSheets[] = { { .data = sCrusherBase_Gfx, .size = 0x800, .tag = TAG_CRUSHER_BASE }, { .data = sImpact_Gfx, .size = 0xE00, .tag = GFXTAG_IMPACT }, @@ -727,23 +727,23 @@ static const union AnimCmd sAnim_Impact_Big[] = static const union AnimCmd sAnim_Sparkle_Small[] = { ANIMCMD_FRAME(0, 2), - ANIMCMD_FRAME(4, 2), + ANIMCMD_FRAME(4, 2), ANIMCMD_FRAME(8, 2), ANIMCMD_FRAME(12, 2), - ANIMCMD_FRAME(16, 2), - ANIMCMD_FRAME(20, 2), + ANIMCMD_FRAME(16, 2), + ANIMCMD_FRAME(20, 2), ANIMCMD_JUMP(0) }; static const union AnimCmd sAnim_Sparkle_Big[] = { - ANIMCMD_FRAME(24, 4), - ANIMCMD_FRAME(28, 4), - ANIMCMD_FRAME(32, 4), + ANIMCMD_FRAME(24, 4), + ANIMCMD_FRAME(28, 4), + ANIMCMD_FRAME(32, 4), ANIMCMD_FRAME(36, 4), - ANIMCMD_FRAME(40, 4), - ANIMCMD_FRAME(44, 4), - ANIMCMD_FRAME(48, 4), + ANIMCMD_FRAME(40, 4), + ANIMCMD_FRAME(44, 4), + ANIMCMD_FRAME(48, 4), ANIMCMD_FRAME(52, 4), ANIMCMD_JUMP(0) }; @@ -756,7 +756,7 @@ static const union AnimCmd sAnim_Timer[] = static const union AnimCmd sAnim_PlayerBerry[] = { - ANIMCMD_FRAME(0, 0), + ANIMCMD_FRAME(0, 0), ANIMCMD_END }; @@ -810,68 +810,68 @@ static const union AffineAnimCmd *const sAffineAnims_PlayerBerry[] = static const struct SpriteTemplate sSpriteTemplate_CrusherBase = { - .tileTag = TAG_CRUSHER_BASE, - .paletteTag = TAG_CRUSHER_BASE, - .oam = &gOamData_AffineOff_ObjNormal_64x64, - .anims = sAnims_CrusherBase, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, + .tileTag = TAG_CRUSHER_BASE, + .paletteTag = TAG_CRUSHER_BASE, + .oam = &gOamData_AffineOff_ObjNormal_64x64, + .anims = sAnims_CrusherBase, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; static const struct SpriteTemplate sSpriteTemplate_Impact = { .tileTag = GFXTAG_IMPACT, - .paletteTag = PALTAG_EFFECT, - .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_Impact, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, + .paletteTag = PALTAG_EFFECT, + .oam = &gOamData_AffineOff_ObjNormal_32x32, + .anims = sAnims_Impact, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_Impact }; static const struct SpriteTemplate sSpriteTemplate_Sparkle = { - .tileTag = GFXTAG_SPARKLE, - .paletteTag = PALTAG_EFFECT, - .oam = &gOamData_AffineOff_ObjNormal_16x16, - .anims = sAnims_Sparkle, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, + .tileTag = GFXTAG_SPARKLE, + .paletteTag = PALTAG_EFFECT, + .oam = &gOamData_AffineOff_ObjNormal_16x16, + .anims = sAnims_Sparkle, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; static const struct SpriteTemplate sSpriteTemplate_Timer = { - .tileTag = TAG_TIMER_DIGITS, - .paletteTag = TAG_TIMER_DIGITS, - .oam = &gOamData_AffineOff_ObjNormal_8x16, - .anims = sAnims_Timer, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, + .tileTag = TAG_TIMER_DIGITS, + .paletteTag = TAG_TIMER_DIGITS, + .oam = &gOamData_AffineOff_ObjNormal_8x16, + .anims = sAnims_Timer, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; static const struct SpriteTemplate sSpriteTemplate_PlayerBerry = { - .tileTag = TAG_PLAYER1_BERRY, - .paletteTag = TAG_PLAYER1_BERRY, - .oam = &gOamData_AffineDouble_ObjNormal_32x32, - .anims = sAnims_PlayerBerry, - .images = NULL, - .affineAnims = sAffineAnims_PlayerBerry, + .tileTag = TAG_PLAYER1_BERRY, + .paletteTag = TAG_PLAYER1_BERRY, + .oam = &gOamData_AffineDouble_ObjNormal_32x32, + .anims = sAnims_PlayerBerry, + .images = NULL, + .affineAnims = sAffineAnims_PlayerBerry, .callback = SpriteCallbackDummy }; -static const struct DigitObjUtilTemplate sDigitObjTemplates[] = +static const struct DigitObjUtilTemplate sDigitObjTemplates[] = { { // Minutes .strConvMode = 1, .shape = 2, .size = 0, .priority = 0, - .oamCount = 2, - .xDelta = 8, + .oamCount = 2, + .xDelta = 8, .x = 156, .y = 0, .spriteSheet = (void*) &sSpriteSheets[3], @@ -882,8 +882,8 @@ static const struct DigitObjUtilTemplate sDigitObjTemplates[] = .shape = 2, .size = 0, .priority = 0, - .oamCount = 2, - .xDelta = 8, + .oamCount = 2, + .xDelta = 8, .x = 180, .y = 0, .spriteSheet = (void*) &sSpriteSheets[3], @@ -894,8 +894,8 @@ static const struct DigitObjUtilTemplate sDigitObjTemplates[] = .shape = 2, .size = 0, .priority = 0, - .oamCount = 2, - .xDelta = 8, + .oamCount = 2, + .xDelta = 8, .x = 204, .y = 0, .spriteSheet = (void*) &sSpriteSheets[3], @@ -944,7 +944,7 @@ static u32 (*const sBerryCrushCommands[])(struct BerryCrushGame * game, u8 * dat [CMD_QUIT] = Cmd_Quit, }; -// Per group size, the number of A presses required to increase the number of sparkles. +// Per group size, the number of A presses required to increase the number of sparkles. static const u8 sSparkleThresholds[MAX_RFU_PLAYERS - 1][4] = { {2, 4, 6, 7}, // 2 players @@ -1472,7 +1472,7 @@ static void UpdateInputEffects(struct BerryCrushGame *game, struct BerryCrushGam numPlayersPressed = 0; linkState = (struct BerryCrushGame_LinkState *)game->recvCmd; - + // Read inputs and update impact effects for (i = 0; i < game->playerCount; i++) { @@ -1698,13 +1698,13 @@ static void PrintCrushingResults(struct BerryCrushGame *game) StringExpandPlaceholders(gStringVar4, gText_StrVar1); x -= GetStringWidth(2, gStringVar4, -1); AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); - + // Print pressing speed text y += 14; AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, 0, y, sTextColorTable[COLORID_GRAY], 0, gText_PressingSpeed); x = 176 - (u8)GetStringWidth(2, gText_TimesPerSec, -1); AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gText_TimesPerSec); - + // Print pressing speed value for (i = 0; i < 8; i++) if (((u8)game->pressingSpeed >> (7 - i)) & 1) @@ -1802,7 +1802,7 @@ static void Task_ShowRankings(u8 taskId) u8 i = 0, j, xPos, yPos; u32 score = 0; s16 *data = gTasks[taskId].data; - + switch (tState) { case 0: @@ -1818,7 +1818,7 @@ static void Task_ShowRankings(u8 taskId) AddTextPrinterParameterized3(tWindowId, 1, xPos, 1, sTextColorTable[COLORID_BLUE], 0, gText_BerryCrush2); xPos = 96 - GetStringWidth(1, gText_PressingSpeedRankings, -1) / 2u; AddTextPrinterParameterized3(tWindowId, 1, xPos, 17, sTextColorTable[COLORID_BLUE], 0, gText_PressingSpeedRankings); - + // Print pressing speed record for each group size, ranked yPos = 41; for (i = 0; i < MAX_RFU_PLAYERS - 1; i++) @@ -1977,7 +1977,7 @@ static void CreateGameSprites(struct BerryCrushGame *game) for (i = 0; i < ARRAY_COUNT(sSpriteSheets) - 1; i++) LoadCompressedSpriteSheet(&sSpriteSheets[i]); LoadSpritePalettes(sSpritePals); - + // Create sprite for crusher base spriteId = CreateSprite(&sSpriteTemplate_CrusherBase, 120, 88, 5); game->gfx.coreSprite = &gSprites[spriteId]; @@ -2372,7 +2372,7 @@ static u32 Cmd_WaitForOthersToPickBerries(struct BerryCrushGame *game, u8 *args) case 2: if (!IsLinkTaskFinished()) return 0; - + // Send player's chosen berry to partners memset(game->sendCmd, 0, sizeof(game->sendCmd)); game->sendCmd[0] = game->players[game->localId].berryId; @@ -2563,13 +2563,13 @@ static void HandlePartnerInput(struct BerryCrushGame *game) for (i = 0; i < game->playerCount; i++) { linkState = (struct BerryCrushGame_LinkState *)gRecvCmds[i]; - + // Skip player if we have not received a packet from them if ((linkState->rfuCmd & 0xFF00) != RFUCMD_SEND_PACKET) continue; if (linkState->sendFlag != SEND_GAME_STATE) continue; - + if (linkState->pushedAButton) { game->localState.playerPressedAFlags |= sBitTable[i]; @@ -2577,10 +2577,10 @@ static void HandlePartnerInput(struct BerryCrushGame *game) game->players[i].numAPresses++; numPlayersPressed++; timeDiff = game->timer - game->players[i].inputTime; - + // If the interval between inputs is regular, the input is considered "neat" // This counts toward the player's neatness score - if (timeDiff >= game->players[i].timeSincePrevInput - 1 + if (timeDiff >= game->players[i].timeSincePrevInput - 1 && timeDiff <= game->players[i].timeSincePrevInput + 1) { // On neat input streak @@ -2595,7 +2595,7 @@ static void HandlePartnerInput(struct BerryCrushGame *game) game->players[i].neatInputStreak = 0; game->players[i].timeSincePrevInput = timeDiff; } - + game->players[i].inputTime = game->timer; game->players[i].inputFlags++; if (game->players[i].inputFlags > F_INPUT_HIT_B) @@ -2637,7 +2637,7 @@ static void HandlePartnerInput(struct BerryCrushGame *game) // Target number of A presses has been reached, game is complete game->newDepth = 32; - game->localState.endGame = TRUE; + game->localState.endGame = TRUE; } // Updates the crusher, input flags, and timer to send to group members @@ -2648,7 +2648,7 @@ static void UpdateLeaderGameState(struct BerryCrushGame *game) u16 flags = 0; u16 temp = 0; u8 i = 0; - + for (i = 0; i < game->playerCount; i++) { if (game->players[i].inputState != INPUT_STATE_NONE) @@ -2727,7 +2727,7 @@ static void HandlePlayerInput(struct BerryCrushGame *game) if (game->localId != 0 && !game->localState.pushedAButton) return; game->localState.sendFlag = SEND_GAME_STATE; - + // Every 30 frames, check whether the sparkles produced should be big, // depending on how many A presses there were in that time if (game->timer % 30 == 0) @@ -2744,7 +2744,7 @@ static void HandlePlayerInput(struct BerryCrushGame *game) game->bigSparkleCounter = 0; game->numBigSparkleChecks++; } - + // Every 15 frames, update the amount of sparkles that should be produced, // depending on how many A presses there were in that time (including the bonus) if (game->timer % 15 == 0) @@ -2787,7 +2787,7 @@ static void HandlePlayerInput(struct BerryCrushGame *game) game->cmdTimer = 0; } } - + } if (game->timer >= MAX_TIME) game->localState.endGame = TRUE; @@ -3056,14 +3056,14 @@ static u32 Cmd_TabulateResults(struct BerryCrushGame *game, u8 *args) game->results.playerIdsRanked[RESULTS_PAGE_RANDOM][i] = i; game->results.stats[RESULTS_PAGE_PRESSES][i] = game->players[i].numAPresses; game->results.totalAPresses += game->results.stats[RESULTS_PAGE_PRESSES][i]; - + // Calculate value for random second results page switch (game->results.randomPageId) { case RESULTS_PAGE_NEATNESS: if (game->players[i].numAPresses != 0) { - // Calculate percentage of inputs that were in largest "neat" streak + // Calculate percentage of inputs that were in largest "neat" streak // "Neat" inputs are those done at a regular interval temp1 = game->players[i].maxNeatInputStreak; temp1 = Q_24_8(temp1); @@ -3129,7 +3129,7 @@ static u32 Cmd_TabulateResults(struct BerryCrushGame *game, u8 *args) // Calculate player rankings for "Number of Presses" by sorting arrays if (game->results.stats[RESULTS_PAGE_PRESSES][j - 1] < game->results.stats[RESULTS_PAGE_PRESSES][j]) { - SWAP(game->results.stats[RESULTS_PAGE_PRESSES][j], + SWAP(game->results.stats[RESULTS_PAGE_PRESSES][j], game->results.stats[RESULTS_PAGE_PRESSES][j - 1], tempStat); SWAP(game->results.playerIdsRanked[RESULTS_PAGE_PRESSES][j], @@ -3139,7 +3139,7 @@ static u32 Cmd_TabulateResults(struct BerryCrushGame *game, u8 *args) // Calculate player rankings for random second results page by sorting arrays if (game->results.stats[RESULTS_PAGE_RANDOM][j - 1] < game->results.stats[RESULTS_PAGE_RANDOM][j]) { - SWAP(game->results.stats[RESULTS_PAGE_RANDOM][j], + SWAP(game->results.stats[RESULTS_PAGE_RANDOM][j], game->results.stats[RESULTS_PAGE_RANDOM][j - 1], tempStat); SWAP(game->results.playerIdsRanked[RESULTS_PAGE_RANDOM][j], @@ -3319,7 +3319,7 @@ static u32 Cmd_CommunicatePlayAgainResponses(struct BerryCrushGame *game, u8 *ar case 1: if (!IsLinkTaskFinished()) return 0; - + // Send player's Yes/No response to partners game->sendCmd[0] = game->playAgainState; game->recvCmd[0] = 0; |