diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2021-03-17 12:50:25 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2021-03-17 12:50:25 -0400 |
commit | 5add6bc54f0a69cb30a9be4e3785323857cb655b (patch) | |
tree | 7a85f85c6a3689c279677951bb47bf2fd4f04cb2 | |
parent | a172f0064c1936fbac56a02ccb386ce16a4edfb2 (diff) |
Name undocced syms in battle_transition
-rw-r--r-- | include/field_camera.h | 2 | ||||
-rw-r--r-- | include/quest_log.h | 2 | ||||
-rw-r--r-- | src/battle_setup.c | 26 | ||||
-rw-r--r-- | src/battle_transition.c | 260 | ||||
-rw-r--r-- | src/field_camera.c | 6 | ||||
-rw-r--r-- | src/quest_log_events.c | 2 | ||||
-rw-r--r-- | src/teachy_tv.c | 4 |
7 files changed, 152 insertions, 150 deletions
diff --git a/include/field_camera.h b/include/field_camera.h index a3275eb9d..025b85132 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -26,7 +26,7 @@ extern bool8 gBikeCameraAheadPanback; void DrawWholeMapView(void); void CurrentMapDrawMetatileAt(int x, int y); -void sub_805A658(s16 *x, s16 *y); +void FieldCameraGetPixelOffsetAtGround(s16 *x, s16 *y); void SetCameraPanningCallback(void (*cb)(void)); void SetCameraPanning(s16 x, s16 y); void UpdateCameraPanning(void); diff --git a/include/quest_log.h b/include/quest_log.h index 9c50f5f6e..ffe5c2cea 100644 --- a/include/quest_log.h +++ b/include/quest_log.h @@ -49,7 +49,7 @@ void QuestLog_CutRecording(void); u8 sub_8112CAC(void); void ResetDeferredLinkEvent(void); void FinishRecordingQuestLogScene(void); -void sub_81139BC(void); +void QuestLogEvents_HandleEndTrainerBattle(void); void *QuestLogGetFlagOrVarPtr(bool8 isFlag, u16 idx); void QuestLogSetFlagOrVar(bool8 isFlag, u16 idx, u16 value); void SetQuestLogRecordAndPlaybackPointers(void *oldSave); diff --git a/src/battle_setup.c b/src/battle_setup.c index 058573aaf..62df9965d 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -76,18 +76,18 @@ static EWRAM_DATA u16 sRivalBattleFlags = 0; static const u8 sBattleTransitionTable_Wild[][2] = { - B_TRANSITION_SLICED_SCREEN, B_TRANSITION_WHITEFADE_IN_STRIPES, - B_TRANSITION_CLOCKWISE_BLACKFADE, B_TRANSITION_GRID_SQUARES, - B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES, - B_TRANSITION_BLACK_WAVE_TO_RIGHT, B_TRANSITION_FULLSCREEN_WAVE, + { B_TRANSITION_SLICED_SCREEN, B_TRANSITION_WHITEFADE_IN_STRIPES }, + { B_TRANSITION_CLOCKWISE_BLACKFADE, B_TRANSITION_GRID_SQUARES }, + { B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES }, + { B_TRANSITION_BLACK_WAVE_TO_RIGHT, B_TRANSITION_FULLSCREEN_WAVE }, }; static const u8 sBattleTransitionTable_Trainer[][2] = { - B_TRANSITION_SLIDING_POKEBALLS, B_TRANSITION_BLACK_DOODLES, - B_TRANSITION_HORIZONTAL_CORRUGATE, B_TRANSITION_BIG_POKEBALL, - B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES, - B_TRANSITION_DISTORTED_WAVE, B_TRANSITION_FULLSCREEN_WAVE, + { B_TRANSITION_SLIDING_POKEBALLS, B_TRANSITION_BLACK_DOODLES }, + { B_TRANSITION_HORIZONTAL_CORRUGATE, B_TRANSITION_BIG_POKEBALL }, + { B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES }, + { B_TRANSITION_DISTORTED_WAVE, B_TRANSITION_FULLSCREEN_WAVE }, }; static const struct TrainerBattleParameter sOrdinaryBattleParams[] = @@ -646,9 +646,9 @@ u8 BattleSetup_GetBattleTowerBattleTransition(void) u8 playerLevel = GetSumOfPlayerPartyLevel(1); if (enemyLevel < playerLevel) - return 4; + return B_TRANSITION_SLIDING_POKEBALLS; else - return 3; + return B_TRANSITION_BIG_POKEBALL; } static u32 TrainerBattleLoadArg32(const u8 *ptr) @@ -904,14 +904,14 @@ static void CB2_EndTrainerBattle(void) } SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); SetBattledTrainerFlag(); - sub_81139BC(); + QuestLogEvents_HandleEndTrainerBattle(); } else { gSpecialVar_Result = FALSE; SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); SetBattledTrainerFlag(); - sub_81139BC(); + QuestLogEvents_HandleEndTrainerBattle(); } } @@ -929,7 +929,7 @@ static void CB2_EndTrainerBattle(void) { SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); SetBattledTrainerFlag(); - sub_81139BC(); + QuestLogEvents_HandleEndTrainerBattle(); } } } diff --git a/src/battle_transition.c b/src/battle_transition.c index 7fc2d4255..7d117f50f 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -213,24 +213,24 @@ static const TaskFunc sBT_Phase1Tasks[] = static const TaskFunc sBT_Phase2Tasks[] = { - BT_Phase2Blur, - BT_Phase2DistortedWave, - BT_Phase2HorizontalCorrugate, - BT_Phase2BigPokeball, - BT_Phase2SlidingPokeballs, - BT_Phase2ClockwiseBlackFade, - BT_Phase2FullScreenWave, - BT_Phase2BlackWaveToRight, - BT_Phase2SlicedScreen, - BT_Phase2WhiteFadeInStripes, - BT_Phase2GridSquares, - BT_Phase2BlackDoodles, - BT_Phase2StartLoreleiMugshot, - BT_Phase2StartBrunoMugshot, - BT_Phase2StartAgathaMugshot, - BT_Phase2StartLanceMugshot, - BT_Phase2StartBlueMugshot, - BT_Phase2AntiClockwiseSpiral, + [B_TRANSITION_BLUR] = BT_Phase2Blur, + [B_TRANSITION_DISTORTED_WAVE] = BT_Phase2DistortedWave, + [B_TRANSITION_HORIZONTAL_CORRUGATE] = BT_Phase2HorizontalCorrugate, + [B_TRANSITION_BIG_POKEBALL] = BT_Phase2BigPokeball, + [B_TRANSITION_SLIDING_POKEBALLS] = BT_Phase2SlidingPokeballs, + [B_TRANSITION_CLOCKWISE_BLACKFADE] = BT_Phase2ClockwiseBlackFade, + [B_TRANSITION_FULLSCREEN_WAVE] = BT_Phase2FullScreenWave, + [B_TRANSITION_BLACK_WAVE_TO_RIGHT] = BT_Phase2BlackWaveToRight, + [B_TRANSITION_SLICED_SCREEN] = BT_Phase2SlicedScreen, + [B_TRANSITION_WHITEFADE_IN_STRIPES] = BT_Phase2WhiteFadeInStripes, + [B_TRANSITION_GRID_SQUARES] = BT_Phase2GridSquares, + [B_TRANSITION_BLACK_DOODLES] = BT_Phase2BlackDoodles, + [B_TRANSITION_LORELEI] = BT_Phase2StartLoreleiMugshot, + [B_TRANSITION_BRUNO] = BT_Phase2StartBrunoMugshot, + [B_TRANSITION_AGATHA] = BT_Phase2StartAgathaMugshot, + [B_TRANSITION_LANCE] = BT_Phase2StartLanceMugshot, + [B_TRANSITION_BLUE] = BT_Phase2StartBlueMugshot, + [B_TRANSITION_ANTI_CLOCKWISE_SPIRAL] = BT_Phase2AntiClockwiseSpiral, }; static const TransitionStateFunc sBT_MainPhases[] = @@ -1487,174 +1487,176 @@ static void VBCB_BT_Phase2BlackWaveToRight(void) #undef tOffset #undef tTheta +// Unused + static void BT_Phase2AntiClockwiseSpiral(u8 taskId) { while (sBT_Phase2AntiClockwiseSpiralFuncs[gTasks[taskId].tState](&gTasks[taskId])); } -static void sub_80D1F64(s16 a1, s16 a2, u8 a3) +static void BT_AntiClockwiseSpiral_DoUpdateFrame(s16 initRadius, s16 deltaAngleMax, u8 offsetMaybe) { u8 theta = 0; - s16 i, r0, r8; - s16 res1, res2, res3, res4; + s16 i, amplitude1, amplitude2; + s16 y1, x1, y2, x2; for (i = 320; i < 960; ++i) gScanlineEffectRegBuffers[1][i] = 120; - for (i = 0; i < (a2 * 16); ++i, ++theta) + for (i = 0; i < (deltaAngleMax * 16); ++i, ++theta) { - r0 = a1 + (theta >> 3); + amplitude1 = initRadius + (theta >> 3); if ((theta >> 3) != ((theta + 1) >> 3)) { - r8 = r0 + 1; + amplitude2 = amplitude1 + 1; } else { - r8 = r0; + amplitude2 = amplitude1; } - res1 = 80 - Sin(theta, r0); - res2 = Cos(theta, r0) + 120; - res3 = 80 - Sin(theta + 1, r8); - res4 = Cos(theta + 1, r8) + 120; + y1 = 80 - Sin(theta, amplitude1); + x1 = Cos(theta, amplitude1) + 120; + y2 = 80 - Sin(theta + 1, amplitude2); + x2 = Cos(theta + 1, amplitude2) + 120; - if (res1 < 0 && res3 < 0) + if (y1 < 0 && y2 < 0) continue; - if (res1 > 159 && res3 > 159) + if (y1 > 159 && y2 > 159) continue; - if (res1 < 0) - res1 = 0; - if (res1 > 159) - res1 = 159; - if (res2 < 0) - res2 = 0; - if (res2 > 255) - res2 = 255; - if (res3 < 0) - res3 = 0; - if (res3 > 159) - res3 = 159; - if (res4 < 0) - res4 = 0; - if (res4 > 255) - res4 = 255; - - res3 -= res1; + if (y1 < 0) + y1 = 0; + if (y1 > 159) + y1 = 159; + if (x1 < 0) + x1 = 0; + if (x1 > 255) + x1 = 255; + if (y2 < 0) + y2 = 0; + if (y2 > 159) + y2 = 159; + if (x2 < 0) + x2 = 0; + if (x2 > 255) + x2 = 255; + + y2 -= y1; if (theta >= 64 && theta < 192) { - gScanlineEffectRegBuffers[1][res1 + 320] = res2; + gScanlineEffectRegBuffers[1][y1 + 320] = x1; - if (res3 == 0) + if (y2 == 0) continue; - res4 -= res2; - if (res4 < -1 && res2 > 1) - --res2; - else if (res4 > 1 && res2 < 255) - ++res2; + x2 -= x1; + if (x2 < -1 && x1 > 1) + --x1; + else if (x2 > 1 && x1 < 255) + ++x1; - if (res3 < 0) - for (; res3 < 0; res3++) - gScanlineEffectRegBuffers[1][res1 + res3 + 320] = res2; + if (y2 < 0) + for (; y2 < 0; y2++) + gScanlineEffectRegBuffers[1][y1 + y2 + 320] = x1; else - for (; res3 > 0; res3--) - gScanlineEffectRegBuffers[1][res1 + res3 + 320] = res2; + for (; y2 > 0; y2--) + gScanlineEffectRegBuffers[1][y1 + y2 + 320] = x1; } else { - gScanlineEffectRegBuffers[1][res1 + 480] = res2; + gScanlineEffectRegBuffers[1][y1 + 480] = x1; - if (res3 == 0) + if (y2 == 0) continue; - res4 -= res2; - if (res4 < -1 && res2 > 1) - --res2; - else if (res4 > 1 && res2 < 255) - ++res2; + x2 -= x1; + if (x2 < -1 && x1 > 1) + --x1; + else if (x2 > 1 && x1 < 255) + ++x1; - if (res3 < 0) - for (; res3 < 0; res3++) - gScanlineEffectRegBuffers[1][res1 + res3 + 480] = res2; + if (y2 < 0) + for (; y2 < 0; y2++) + gScanlineEffectRegBuffers[1][y1 + y2 + 480] = x1; else - for (; res3 > 0; res3--) - gScanlineEffectRegBuffers[1][res1 + res3 + 480] = res2; + for (; y2 > 0; y2--) + gScanlineEffectRegBuffers[1][y1 + y2 + 480] = x1; } } - if (a3 == 0 || a2 % 4 == 0) + if (offsetMaybe == 0 || deltaAngleMax % 4 == 0) { for (i = 0; i < 160; i++) { - gScanlineEffectRegBuffers[1][i * 2 + a3] = gScanlineEffectRegBuffers[1][i + 320] << 8 | gScanlineEffectRegBuffers[1][i + 480]; + gScanlineEffectRegBuffers[1][i * 2 + offsetMaybe] = gScanlineEffectRegBuffers[1][i + 320] << 8 | gScanlineEffectRegBuffers[1][i + 480]; } return; } - res1 = Sin(a2 * 16, a1 + (a2 << 1)); + y1 = Sin(deltaAngleMax * 16, initRadius + (deltaAngleMax << 1)); - switch (a2 / 4) + switch (deltaAngleMax / 4) { case 0: - if (res1 > 80) - res1 = 80; - for (i = res1; i > 0; i--) + if (y1 > 80) + y1 = 80; + for (i = y1; i > 0; i--) { - sTransitionStructPtr->data[2] = res2 = ((i * gUnknown_83FA444[a2]) >> 8) + 120; - if (res2 < 0 || res2 > 255) + sTransitionStructPtr->data[2] = x1 = ((i * gUnknown_83FA444[deltaAngleMax]) >> 8) + 120; + if (x1 < 0 || x1 > 255) continue; sTransitionStructPtr->bg123HOfs = 400 - i; sTransitionStructPtr->data[10] = gScanlineEffectRegBuffers[1][400 - i]; - if (gScanlineEffectRegBuffers[1][560 - i] < res2) + if (gScanlineEffectRegBuffers[1][560 - i] < x1) gScanlineEffectRegBuffers[1][560 - i] = 120; - else if (gScanlineEffectRegBuffers[1][400 - i] < res2) - gScanlineEffectRegBuffers[1][400 - i] = res2; + else if (gScanlineEffectRegBuffers[1][400 - i] < x1) + gScanlineEffectRegBuffers[1][400 - i] = x1; } break; case 1: - if (res1 > 80) - res1 = 80; - for (i = res1; i > 0; i--) + if (y1 > 80) + y1 = 80; + for (i = y1; i > 0; i--) { - sTransitionStructPtr->data[2] = res2 = ((i * gUnknown_83FA444[a2]) >> 8) + 120; - if (res2 < 0 || res2 > 255) + sTransitionStructPtr->data[2] = x1 = ((i * gUnknown_83FA444[deltaAngleMax]) >> 8) + 120; + if (x1 < 0 || x1 > 255) continue; sTransitionStructPtr->bg123HOfs = 400 - i; sTransitionStructPtr->data[10] = gScanlineEffectRegBuffers[1][400 - i]; - if (gScanlineEffectRegBuffers[1][400 - i] < res2) - gScanlineEffectRegBuffers[1][400 - i] = res2; + if (gScanlineEffectRegBuffers[1][400 - i] < x1) + gScanlineEffectRegBuffers[1][400 - i] = x1; } break; case 2: - if (res1 < -79) - res1 = -79; - for (i = res1; i <= 0; i++) + if (y1 < -79) + y1 = -79; + for (i = y1; i <= 0; i++) { - sTransitionStructPtr->data[2] = res2 = ((i * gUnknown_83FA444[a2]) >> 8) + 120; - if (res2 < 0 || res2 > 255) + sTransitionStructPtr->data[2] = x1 = ((i * gUnknown_83FA444[deltaAngleMax]) >> 8) + 120; + if (x1 < 0 || x1 > 255) continue; sTransitionStructPtr->bg123HOfs = 560 - i; sTransitionStructPtr->data[10] = gScanlineEffectRegBuffers[1][560 - i]; - if (gScanlineEffectRegBuffers[1][400 - i] >= res2) + if (gScanlineEffectRegBuffers[1][400 - i] >= x1) gScanlineEffectRegBuffers[1][400 - i] = 120; - else if (gScanlineEffectRegBuffers[1][560 - i] > res2) - gScanlineEffectRegBuffers[1][560 - i] = res2; + else if (gScanlineEffectRegBuffers[1][560 - i] > x1) + gScanlineEffectRegBuffers[1][560 - i] = x1; } break; case 3: - if (res1 < -79) - res1 = -79; - for (i = res1; i <= 0; i++) + if (y1 < -79) + y1 = -79; + for (i = y1; i <= 0; i++) { - sTransitionStructPtr->data[2] = res2 = ((i * gUnknown_83FA444[a2]) >> 8) + 120; - if (res2 < 0 || res2 > 255) + sTransitionStructPtr->data[2] = x1 = ((i * gUnknown_83FA444[deltaAngleMax]) >> 8) + 120; + if (x1 < 0 || x1 > 255) continue; sTransitionStructPtr->bg123HOfs = 560 - i; sTransitionStructPtr->data[10] = gScanlineEffectRegBuffers[1][560 - i]; - if (gScanlineEffectRegBuffers[1][560 - i] > res2) - gScanlineEffectRegBuffers[1][560 - i] = res2; + if (gScanlineEffectRegBuffers[1][560 - i] > x1) + gScanlineEffectRegBuffers[1][560 - i] = x1; } break; default: @@ -1663,7 +1665,7 @@ static void sub_80D1F64(s16 a1, s16 a2, u8 a3) for (i = 0; i < 160; i++) { - gScanlineEffectRegBuffers[1][i * 2 + a3] = (gScanlineEffectRegBuffers[1][i + 320] << 8) | gScanlineEffectRegBuffers[1][i + 480]; + gScanlineEffectRegBuffers[1][i * 2 + offsetMaybe] = (gScanlineEffectRegBuffers[1][i + 320] << 8) | gScanlineEffectRegBuffers[1][i + 480]; } } @@ -1677,8 +1679,8 @@ static bool8 BT_Phase2AntiClockwiseSpiral_Init(struct Task *task) sTransitionStructPtr->win0V = WIN_RANGE(0x30, 0x70); sTransitionStructPtr->win1V = WIN_RANGE(0x10, 0x90); sTransitionStructPtr->counter = 0; - sub_80D1F64(0, 0, FALSE); - sub_80D1F64(0, 0, TRUE); + BT_AntiClockwiseSpiral_DoUpdateFrame(0, 0, 0); + BT_AntiClockwiseSpiral_DoUpdateFrame(0, 0, 1); DmaCopy16(3, gScanlineEffectRegBuffers[1], gScanlineEffectRegBuffers[0], 640); SetVBlankCallback(VBCB_BT_Phase2AntiClockwiseBlackFade); ++task->tState; @@ -1689,30 +1691,30 @@ static bool8 BT_Phase2AntiClockwiseSpiral_Init(struct Task *task) static bool8 BT_Phase2AntiClockwiseSpiral_Update(struct Task *task) { - s16 v0, v1; + s16 win_top, win_bottom; - sub_80D1F64(task->data[2], task->data[1], TRUE); + BT_AntiClockwiseSpiral_DoUpdateFrame(task->data[2], task->data[1], 1); sTransitionStructPtr->vblankDma |= TRUE; if (++task->data[1] == 17) { - sub_80D1F64(task->data[2], 16, FALSE); - v0 = 48 - task->data[2]; - if (v0 < 0) - v0 = 0; - v1 = task->data[2] + 112; - if (v1 > 255) - v1 = 255; - sTransitionStructPtr->win0V = v0 | v1; + BT_AntiClockwiseSpiral_DoUpdateFrame(task->data[2], 16, 0); + win_top = 48 - task->data[2]; + if (win_top < 0) + win_top = 0; + win_bottom = task->data[2] + 112; + if (win_bottom > 255) + win_bottom = 255; + sTransitionStructPtr->win0V = win_top | win_bottom; // UB: win_top should be shifted task->data[2] += 32; task->data[1] = 0; - sub_80D1F64(task->data[2], 0, TRUE); - v0 = 48 - task->data[2]; - if (v0 < 0) - v0 = 0; - v1 = task->data[2] + 112; - if (v1 > 255) - v1 = 255; - sTransitionStructPtr->win1V = v0 | v1; + BT_AntiClockwiseSpiral_DoUpdateFrame(task->data[2], 0, 1); + win_top = 48 - task->data[2]; + if (win_top < 0) + win_top = 0; + win_bottom = task->data[2] + 112; + if (win_bottom > 255) + win_bottom = 255; + sTransitionStructPtr->win1V = win_top | win_bottom; // UB: win_top should be shifted sTransitionStructPtr->vblankDma |= TRUE; if (task->data[2] > 159) { @@ -2684,7 +2686,7 @@ static bool8 BT_Phase1_FadeIn(struct Task *task) static void BT_InitCtrlBlk(void) { memset(sTransitionStructPtr, 0, sizeof(*sTransitionStructPtr)); - sub_805A658(&sTransitionStructPtr->bg123HOfs, &sTransitionStructPtr->bg123VOfs); + FieldCameraGetPixelOffsetAtGround(&sTransitionStructPtr->bg123HOfs, &sTransitionStructPtr->bg123VOfs); } static void BT_VBSyncOamAndPltt(void) diff --git a/src/field_camera.c b/src/field_camera.c index f383b2a27..37133d68f 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -84,10 +84,10 @@ void FieldUpdateBgTilemapScroll(void) SetGpuReg(REG_OFFSET_BG3VOFS, r4); } -void sub_805A658(s16 *a, s16 *b) +void FieldCameraGetPixelOffsetAtGround(s16 *hofs_p, s16 *vofs_p) { - *a = sFieldCameraOffset.xPixelOffset + sHorizontalCameraPan; - *b = sFieldCameraOffset.yPixelOffset + sVerticalCameraPan + 8; + *hofs_p = sFieldCameraOffset.xPixelOffset + sHorizontalCameraPan; + *vofs_p = sFieldCameraOffset.yPixelOffset + sVerticalCameraPan + 8; } void DrawWholeMapView(void) diff --git a/src/quest_log_events.c b/src/quest_log_events.c index 8eaf331e5..72b8ddfd7 100644 --- a/src/quest_log_events.c +++ b/src/quest_log_events.c @@ -425,7 +425,7 @@ static bool8 TrySetTrainerBattleQuestLogEvent(u16 eventId, const u16 *eventData) return TRUE; } -void sub_81139BC(void) +void QuestLogEvents_HandleEndTrainerBattle(void) { if (sDeferredEvent.id != QL_EVENT_0) { diff --git a/src/teachy_tv.c b/src/teachy_tv.c index d6ce57c3d..3baaa094a 100644 --- a/src/teachy_tv.c +++ b/src/teachy_tv.c @@ -1177,9 +1177,9 @@ static void TeachyTvPrepBattle(u8 taskId) InitPokedudePartyAndOpponent(); PlayMapChosenOrBattleBGM(MUS_DUMMY); if (sStaticResources.whichScript == TTVSCR_BATTLE) - data[6] = 9; + data[6] = B_TRANSITION_WHITEFADE_IN_STRIPES; else - data[6] = 8; + data[6] = B_TRANSITION_SLICED_SCREEN; data[7] = 0; gTasks[taskId].func = TeachyTvPreBattleAnimAndSetBattleCallback; } |