diff --git a/data/maps/SealedChamber_InnerRoom/scripts.inc b/data/maps/SealedChamber_InnerRoom/scripts.inc index f81e5f9fd..8c45c81ca 100644 --- a/data/maps/SealedChamber_InnerRoom/scripts.inc +++ b/data/maps/SealedChamber_InnerRoom/scripts.inc @@ -12,18 +12,18 @@ SealedChamber_InnerRoom_EventScript_BrailleBackWall:: goto_if_eq SealedChamber_InnerRoom_EventScript_NoEffect fadeoutbgm 0 playse SE_TRUCK_MOVE - special DoSealedChamberShakingEffect1 + special DoSealedChamberShakingEffect_Long waitstate delay 40 - special DoSealedChamberShakingEffect2 + special DoSealedChamberShakingEffect_Short waitstate playse SE_DOOR delay 40 - special DoSealedChamberShakingEffect2 + special DoSealedChamberShakingEffect_Short waitstate playse SE_DOOR delay 40 - special DoSealedChamberShakingEffect2 + special DoSealedChamberShakingEffect_Short waitstate playse SE_DOOR delay 40 diff --git a/data/specials.inc b/data/specials.inc index 82eacbac0..a863b6e13 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -315,7 +315,7 @@ gSpecials:: def_special IsStarterInParty def_special CopyCurSecretBaseOwnerName_StrVar1 def_special ScriptCheckFreePokemonStorageSpace - def_special DoSealedChamberShakingEffect1 + def_special DoSealedChamberShakingEffect_Long def_special ShowDeptStoreElevatorFloorSelect def_special InteractWithShieldOrTVDecoration def_special IsPokerusInParty @@ -325,7 +325,7 @@ gSpecials:: def_special BattleSetup_StartLegendaryBattle def_special StartRegiBattle def_special SetTrainerFacingDirection - def_special DoSealedChamberShakingEffect2 + def_special DoSealedChamberShakingEffect_Short def_special FoundBlackGlasses def_special StartDroughtWeatherBlend def_special DoDiveWarp diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index d8410988d..61fab39e2 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -13,16 +13,9 @@ #include "party_menu.h" #include "fldeff.h" -// why do this, GF? -enum -{ - REGIROCK_PUZZLE, - REGISTEEL_PUZZLE -}; +EWRAM_DATA static bool8 sIsRegisteelPuzzle = 0; -EWRAM_DATA static u8 sBraillePuzzleCallbackFlag = 0; - -static const u8 gRegicePathCoords[][2] = +static const u8 sRegicePathCoords[][2] = { {4, 21}, {5, 21}, @@ -62,9 +55,9 @@ static const u8 gRegicePathCoords[][2] = {4, 22}, }; -void SealedChamberShakingEffect(u8); -void DoBrailleRegirockEffect(void); -void DoBrailleRegisteelEffect(void); +static void Task_SealedChamberShakingEffect(u8); +static void DoBrailleRegirockEffect(void); +static void DoBrailleRegisteelEffect(void); bool8 ShouldDoBrailleDigEffect(void) { @@ -116,43 +109,48 @@ void ShouldDoBrailleRegirockEffectOld(void) { } -void DoSealedChamberShakingEffect1(void) -{ - u8 taskId = CreateTask(SealedChamberShakingEffect, 9); +#define tDelayCounter data[1] +#define tShakeCounter data[2] +#define tVerticalPan data[4] +#define tDelay data[5] +#define tNumShakes data[6] - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[4] = 2; - gTasks[taskId].data[5] = 5; - gTasks[taskId].data[6] = 50; +void DoSealedChamberShakingEffect_Long(void) +{ + u8 taskId = CreateTask(Task_SealedChamberShakingEffect, 9); + + gTasks[taskId].tDelayCounter = 0; + gTasks[taskId].tShakeCounter = 0; + gTasks[taskId].tVerticalPan = 2; + gTasks[taskId].tDelay = 5; + gTasks[taskId].tNumShakes = 50; SetCameraPanningCallback(0); } -void DoSealedChamberShakingEffect2(void) +void DoSealedChamberShakingEffect_Short(void) { - u8 taskId = CreateTask(SealedChamberShakingEffect, 9); + u8 taskId = CreateTask(Task_SealedChamberShakingEffect, 9); - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[4] = 3; - gTasks[taskId].data[5] = 5; - gTasks[taskId].data[6] = 2; + gTasks[taskId].tDelayCounter = 0; + gTasks[taskId].tShakeCounter = 0; + gTasks[taskId].tVerticalPan = 3; + gTasks[taskId].tDelay = 5; + gTasks[taskId].tNumShakes = 2; SetCameraPanningCallback(0); } -void SealedChamberShakingEffect(u8 taskId) +static void Task_SealedChamberShakingEffect(u8 taskId) { struct Task *task = &gTasks[taskId]; - task->data[1]++; - - if (!(task->data[1] % task->data[5])) + task->tDelayCounter++; + if (task->tDelayCounter % task->tDelay == 0) { - task->data[1] = 0; - task->data[2]++; - task->data[4] = -task->data[4]; - SetCameraPanning(0, task->data[4]); - if (task->data[2] == task->data[6]) + task->tDelayCounter = 0; + task->tShakeCounter++; + task->tVerticalPan = -task->tVerticalPan; + SetCameraPanning(0, task->tVerticalPan); + if (task->tShakeCounter == task->tNumShakes) { DestroyTask(taskId); EnableBothScriptContexts(); @@ -161,7 +159,12 @@ void SealedChamberShakingEffect(u8 taskId) } } -// moved later in the function because it was rewritten. +#undef tDelayCounter +#undef tShakeCounter +#undef tVerticalPan +#undef tDelay +#undef tNumShakes + bool8 ShouldDoBrailleRegirockEffect(void) { if (!FlagGet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED) @@ -170,17 +173,17 @@ bool8 ShouldDoBrailleRegirockEffect(void) { if (gSaveBlock1Ptr->pos.x == 6 && gSaveBlock1Ptr->pos.y == 23) { - sBraillePuzzleCallbackFlag = REGIROCK_PUZZLE; + sIsRegisteelPuzzle = FALSE; return TRUE; } else if (gSaveBlock1Ptr->pos.x == 5 && gSaveBlock1Ptr->pos.y == 23) { - sBraillePuzzleCallbackFlag = REGIROCK_PUZZLE; + sIsRegisteelPuzzle = FALSE; return TRUE; } else if (gSaveBlock1Ptr->pos.x == 7 && gSaveBlock1Ptr->pos.y == 23) { - sBraillePuzzleCallbackFlag = REGIROCK_PUZZLE; + sIsRegisteelPuzzle = FALSE; return TRUE; } } @@ -200,7 +203,7 @@ void UseRegirockHm_Callback(void) DoBrailleRegirockEffect(); } -void DoBrailleRegirockEffect(void) +static void DoBrailleRegirockEffect(void) { MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); @@ -220,7 +223,7 @@ bool8 ShouldDoBrailleRegisteelEffect(void) { if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 25) { - sBraillePuzzleCallbackFlag = REGISTEEL_PUZZLE; + sIsRegisteelPuzzle = TRUE; return TRUE; } } @@ -239,7 +242,7 @@ void UseRegisteelHm_Callback(void) DoBrailleRegisteelEffect(); } -void DoBrailleRegisteelEffect(void) +static void DoBrailleRegisteelEffect(void) { MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); @@ -254,7 +257,7 @@ void DoBrailleRegisteelEffect(void) } // theory: another commented out DoBrailleWait and Task_BrailleWait. -void DoBrailleWait(void) +static void DoBrailleWait(void) { } @@ -263,7 +266,7 @@ bool8 FldEff_UsePuzzleEffect(void) { u8 taskId = CreateFieldMoveTask(); - if (sBraillePuzzleCallbackFlag == REGISTEEL_PUZZLE) + if (sIsRegisteelPuzzle == TRUE) { gTasks[taskId].data[8] = (u32)UseRegisteelHm_Callback >> 16; gTasks[taskId].data[9] = (u32)UseRegisteelHm_Callback; @@ -290,10 +293,10 @@ bool8 ShouldDoBrailleRegicePuzzle(void) if (FlagGet(FLAG_TEMP_3) == TRUE) return FALSE; - for (i = 0; i < 36; i++) + for (i = 0; i < ARRAY_COUNT(sRegicePathCoords); i++) { - u8 xPos = gRegicePathCoords[i][0]; - u8 yPos = gRegicePathCoords[i][1]; + u8 xPos = sRegicePathCoords[i][0]; + u8 yPos = sRegicePathCoords[i][1]; if (gSaveBlock1Ptr->pos.x == xPos && gSaveBlock1Ptr->pos.y == yPos) { u16 varValue;