From ab3eb6065b5d9942520bbd844bd51991ae225f7f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 1 Jun 2020 16:17:25 +0200 Subject: [PATCH] More transitions documentation --- .../{85BC314.bin => regice.bin} | Bin .../{85BC2B4.pal => regice.pal} | 0 .../{85BD314.bin => regirock.bin} | Bin .../{85BC2F4.pal => regirock.pal} | 0 .../{85BBC14.png => regis.png} | Bin .../{85BCB14.bin => registeel.bin} | Bin .../{85BC2D4.pal => registeel.pal} | 0 include/battle_transition.h | 2 +- src/battle_transition.c | 587 +++++++++--------- src/unk_transition.c | 8 +- 10 files changed, 302 insertions(+), 295 deletions(-) rename graphics/battle_transitions/{85BC314.bin => regice.bin} (100%) rename graphics/battle_transitions/{85BC2B4.pal => regice.pal} (100%) rename graphics/battle_transitions/{85BD314.bin => regirock.bin} (100%) rename graphics/battle_transitions/{85BC2F4.pal => regirock.pal} (100%) rename graphics/battle_transitions/{85BBC14.png => regis.png} (100%) rename graphics/battle_transitions/{85BCB14.bin => registeel.bin} (100%) rename graphics/battle_transitions/{85BC2D4.pal => registeel.pal} (100%) diff --git a/graphics/battle_transitions/85BC314.bin b/graphics/battle_transitions/regice.bin similarity index 100% rename from graphics/battle_transitions/85BC314.bin rename to graphics/battle_transitions/regice.bin diff --git a/graphics/battle_transitions/85BC2B4.pal b/graphics/battle_transitions/regice.pal similarity index 100% rename from graphics/battle_transitions/85BC2B4.pal rename to graphics/battle_transitions/regice.pal diff --git a/graphics/battle_transitions/85BD314.bin b/graphics/battle_transitions/regirock.bin similarity index 100% rename from graphics/battle_transitions/85BD314.bin rename to graphics/battle_transitions/regirock.bin diff --git a/graphics/battle_transitions/85BC2F4.pal b/graphics/battle_transitions/regirock.pal similarity index 100% rename from graphics/battle_transitions/85BC2F4.pal rename to graphics/battle_transitions/regirock.pal diff --git a/graphics/battle_transitions/85BBC14.png b/graphics/battle_transitions/regis.png similarity index 100% rename from graphics/battle_transitions/85BBC14.png rename to graphics/battle_transitions/regis.png diff --git a/graphics/battle_transitions/85BCB14.bin b/graphics/battle_transitions/registeel.bin similarity index 100% rename from graphics/battle_transitions/85BCB14.bin rename to graphics/battle_transitions/registeel.bin diff --git a/graphics/battle_transitions/85BC2D4.pal b/graphics/battle_transitions/registeel.pal similarity index 100% rename from graphics/battle_transitions/85BC2D4.pal rename to graphics/battle_transitions/registeel.pal diff --git a/include/battle_transition.h b/include/battle_transition.h index db06a5638..0f583b101 100644 --- a/include/battle_transition.h +++ b/include/battle_transition.h @@ -7,7 +7,7 @@ void BattleTransition_Start(u8 transitionId); bool8 IsBattleTransitionDone(void); bool8 FldEff_Pokeball(void); void TransitionPhase1_Task_RunFuncs(u8 taskId); -void sub_8149F58(u16 **a0, u16 **a1); +void GetBg0TilesDst(u16 **tilemap, u16 **tileset); extern const struct SpritePalette gFieldEffectObjectPaletteInfo10; diff --git a/src/battle_transition.c b/src/battle_transition.c index 206ea09e5..ea9ac1e89 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -237,29 +237,29 @@ static bool8 Transition_Phase1(struct Task *task); static bool8 Transition_WaitForPhase1(struct Task *task); static bool8 Transition_Phase2(struct Task *task); static bool8 Transition_WaitForPhase2(struct Task *task); -static void sub_8149F08(void); -static void sub_8149F84(void); +static void InitTransitionStructVars(void); +static void FadeScreenBlack(void); static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); static void sub_814A014(u16 *a0, s16 a1, s16 a2, s16 a3); static void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); -static void sub_8149F40(u16 **a0); +static void GetBg0TilemapDst(u16 **tileset); static void sub_814A1AC(s16 *a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6); static bool8 sub_814A228(s16 *a0, bool8 a1, bool8 a2); -static void sub_8148484(s16 spriteId, s16 value); -static void sub_814849C(s16 spriteId); -static s16 sub_81484B8(s16 spriteId); +static void SetTrainerPicSlideTable(s16 spriteId, s16 arrId); +static void IncrementTrainerPicState(s16 spriteId); +static s16 IsTrainerPicSlideDone(s16 spriteId); static bool8 Phase1_TransitionAll_Func1(struct Task *task); static bool8 Phase1_TransitionAll_Func2(struct Task *task); static bool8 IsPhase1Done(void); static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1); static void sub_814713C(struct Sprite *sprite); -static void sub_8148380(struct Sprite *sprite); +static void SpriteCb_TrainerPic(struct Sprite *sprite); static void sub_8149864(struct Sprite *sprite); -static bool8 sub_81483A8(struct Sprite *sprite); -static bool8 sub_81483AC(struct Sprite *sprite); -static bool8 sub_81483F8(struct Sprite *sprite); -static bool8 sub_814842C(struct Sprite *sprite); -static bool8 sub_8148458(struct Sprite *sprite); +static bool8 TrainerPicCb_Nothing(struct Sprite *sprite); +static bool8 TrainerPicCb_SetSlideOffsets(struct Sprite *sprite); +static bool8 TrainerPicCb_Slide1(struct Sprite *sprite); +static bool8 TrainerPicCb_Slide2(struct Sprite *sprite); +static bool8 TrainerPicCb_Slide3(struct Sprite *sprite); // iwram bss vars static s16 sUnusedRectangularSpiralVar; @@ -273,35 +273,35 @@ EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL; // const rom data static const u32 sBigPokeball_Tileset[] = INCBIN_U32("graphics/battle_transitions/big_pokeball.4bpp"); static const u32 sPokeballTrail_Tileset[] = INCBIN_U32("graphics/battle_transitions/pokeball_trail.4bpp"); -static const u8 sSpriteImage_85B98F0[] = INCBIN_U8("graphics/battle_transitions/pokeball.4bpp"); -static const u32 sUnknown_085B9AF0[] = INCBIN_U32("graphics/battle_transitions/elite_four_bg.4bpp"); -static const u8 sSpriteImage_85B9CD0[] = INCBIN_U8("graphics/battle_transitions/unused_brendan.4bpp"); -static const u8 sSpriteImage_85BA4D0[] = INCBIN_U8("graphics/battle_transitions/unused_lass.4bpp"); +static const u8 sPokeball_Gfx[] = INCBIN_U8("graphics/battle_transitions/pokeball.4bpp"); +static const u32 sEliteFour_Tileset[] = INCBIN_U32("graphics/battle_transitions/elite_four_bg.4bpp"); +static const u8 sUnusedBrendan_Gfx[] = INCBIN_U8("graphics/battle_transitions/unused_brendan.4bpp"); +static const u8 sUnusedLass_Gfx[] = INCBIN_U8("graphics/battle_transitions/unused_lass.4bpp"); static const u32 sShrinkingBoxTileset[] = INCBIN_U32("graphics/battle_transitions/shrinking_box.4bpp"); static const u32 sEvilTeam_Palette[] = INCBIN_U32("graphics/battle_transitions/evil_team.gbapal"); static const u32 sTeamAqua_Tileset[] = INCBIN_U32("graphics/battle_transitions/team_aqua.4bpp.lz"); static const u32 sTeamAqua_Tilemap[] = INCBIN_U32("graphics/battle_transitions/team_aqua.bin.lz"); static const u32 sTeamMagma_Tileset[] = INCBIN_U32("graphics/battle_transitions/team_magma.4bpp.lz"); static const u32 sTeamMagma_Tilemap[] = INCBIN_U32("graphics/battle_transitions/team_magma.bin.lz"); -static const u32 gUnknown_085BBC14[] = INCBIN_U32("graphics/battle_transitions/85BBC14.4bpp"); -static const u32 gUnknown_085BC2B4[] = INCBIN_U32("graphics/battle_transitions/85BC2B4.gbapal"); -static const u32 gUnknown_085BC2D4[] = INCBIN_U32("graphics/battle_transitions/85BC2D4.gbapal"); -static const u32 gUnknown_085BC2F4[] = INCBIN_U32("graphics/battle_transitions/85BC2F4.gbapal"); -static const u32 gUnknown_085BC314[] = INCBIN_U32("graphics/battle_transitions/85BC314.bin"); -static const u32 gUnknown_085BCB14[] = INCBIN_U32("graphics/battle_transitions/85BCB14.bin"); -static const u32 gUnknown_085BD314[] = INCBIN_U32("graphics/battle_transitions/85BD314.bin"); +static const u32 sRegis_Tileset[] = INCBIN_U32("graphics/battle_transitions/regis.4bpp"); +static const u32 sRegice_Palette[] = INCBIN_U32("graphics/battle_transitions/regice.gbapal"); +static const u32 sRegisteel_Palette[] = INCBIN_U32("graphics/battle_transitions/registeel.gbapal"); +static const u32 sRegirock_Palette[] = INCBIN_U32("graphics/battle_transitions/regirock.gbapal"); +static const u32 sRegice_Tilemap[] = INCBIN_U32("graphics/battle_transitions/regice.bin"); +static const u32 sRegisteel_Tilemap[] = INCBIN_U32("graphics/battle_transitions/registeel.bin"); +static const u32 sRegirock_Tilemap[] = INCBIN_U32("graphics/battle_transitions/regirock.bin"); static const u16 gUnknown_085BDB14[] = INCBIN_U16("graphics/battle_transitions/85BDB14.gbapal"); -static const u32 gUnknown_085BDB34[] = INCBIN_U32("graphics/battle_transitions/kyogre.4bpp.lz"); -static const u32 gUnknown_085BE1E8[] = INCBIN_U32("graphics/battle_transitions/kyogre.bin.lz"); -static const u32 gUnknown_085BE51C[] = INCBIN_U32("graphics/battle_transitions/groudon.4bpp.lz"); -static const u32 gUnknown_085BEA88[] = INCBIN_U32("graphics/battle_transitions/groudon.bin.lz"); -static const u16 gUnknown_085BEDA0[] = INCBIN_U16("graphics/battle_transitions/kyogre_pt1.gbapal"); -static const u16 gUnknown_085BEEE0[] = INCBIN_U16("graphics/battle_transitions/kyogre_pt2.gbapal"); -static const u16 gUnknown_085BF0A0[] = INCBIN_U16("graphics/battle_transitions/groudon_pt1.gbapal"); -static const u16 gUnknown_085BF2A0[] = INCBIN_U16("graphics/battle_transitions/groudon_pt2.gbapal"); -static const u16 gUnknown_085BF4A0[] = INCBIN_U16("graphics/battle_transitions/rayquaza.gbapal"); -static const u32 gUnknown_085BF6A0[] = INCBIN_U32("graphics/battle_transitions/rayquaza.4bpp"); -static const u32 gUnknown_085C6BE0[] = INCBIN_U32("graphics/battle_transitions/rayquaza.bin"); +static const u32 sKyogre_Tileset[] = INCBIN_U32("graphics/battle_transitions/kyogre.4bpp.lz"); +static const u32 sKyogre_Tilemap[] = INCBIN_U32("graphics/battle_transitions/kyogre.bin.lz"); +static const u32 sGroudon_Tileset[] = INCBIN_U32("graphics/battle_transitions/groudon.4bpp.lz"); +static const u32 sGroudon_Tilemap[] = INCBIN_U32("graphics/battle_transitions/groudon.bin.lz"); +static const u16 sKyogre1_Palette[] = INCBIN_U16("graphics/battle_transitions/kyogre_pt1.gbapal"); +static const u16 sKyogre2_Palette[] = INCBIN_U16("graphics/battle_transitions/kyogre_pt2.gbapal"); +static const u16 sGroudon1_Palette[] = INCBIN_U16("graphics/battle_transitions/groudon_pt1.gbapal"); +static const u16 sGroudon2_Palette[] = INCBIN_U16("graphics/battle_transitions/groudon_pt2.gbapal"); +static const u16 sRayquaza_Palette[] = INCBIN_U16("graphics/battle_transitions/rayquaza.gbapal"); +static const u32 sRayquaza_Tileset[] = INCBIN_U32("graphics/battle_transitions/rayquaza.4bpp"); +static const u32 sRayquaza_Tilemap[] = INCBIN_U32("graphics/battle_transitions/rayquaza.bin"); static const u32 gUnknown_085C7BE0[] = INCBIN_U32("graphics/battle_transitions/frontier_brain.gbapal"); static const u32 gUnknown_085C7C00[] = INCBIN_U32("graphics/battle_transitions/frontier_brain.4bpp.lz"); static const u32 gUnknown_085C828C[] = INCBIN_U32("graphics/battle_transitions/frontier_brain.bin.lz"); @@ -538,19 +538,19 @@ static const s16 sMugshotsOpponentCoords[MUGSHOTS_COUNT][2] = [MUGSHOT_CHAMPION] = {-8, 7}, }; -static const TransitionSpriteCallback sUnknown_085C8C24[] = +static const TransitionSpriteCallback sTrainerPicSpriteCbs[] = { - sub_81483A8, - sub_81483AC, - sub_81483F8, - sub_814842C, - sub_81483A8, - sub_8148458, - sub_81483A8 + TrainerPicCb_Nothing, + TrainerPicCb_SetSlideOffsets, + TrainerPicCb_Slide1, + TrainerPicCb_Slide2, + TrainerPicCb_Nothing, + TrainerPicCb_Slide3, + TrainerPicCb_Nothing }; -static const s16 sUnknown_085C8C40[2] = {12, -12}; -static const s16 sUnknown_085C8C44[2] = {-1, 1}; +static const s16 sTrainerPicSlideOffsets1[2] = {12, -12}; +static const s16 sTrainerPicSlideOffsets2[2] = {-1, 1}; static const TransitionStateFunc sPhase2_Slice_Funcs[] = { @@ -712,52 +712,52 @@ static const TransitionStateFunc sPhase1_TransitionAll_Funcs[] = Phase1_TransitionAll_Func2 }; -static const struct SpriteFrameImage sSpriteImageTable_85C8E2C[] = +static const struct SpriteFrameImage sSpriteImage_Pokeball[] = { - sSpriteImage_85B98F0, 0x200 + sPokeball_Gfx, sizeof(sPokeball_Gfx) }; -static const union AnimCmd sSpriteAnim_85C8E34[] = +static const union AnimCmd sSpriteAnim_Pokeball[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END }; -static const union AnimCmd *const sSpriteAnimTable_85C8E3C[] = +static const union AnimCmd *const sSpriteAnimTable_Pokeball[] = { - sSpriteAnim_85C8E34 + sSpriteAnim_Pokeball }; -static const union AffineAnimCmd sSpriteAffineAnim_85C8E40[] = +static const union AffineAnimCmd sSpriteAffineAnim_Pokeball1[] = { AFFINEANIMCMD_FRAME(0, 0, -4, 1), AFFINEANIMCMD_JUMP(0) }; -static const union AffineAnimCmd sSpriteAffineAnim_85C8E50[] = +static const union AffineAnimCmd sSpriteAffineAnim_Pokeball2[] = { AFFINEANIMCMD_FRAME(0, 0, 4, 1), AFFINEANIMCMD_JUMP(0) }; -static const union AffineAnimCmd *const sSpriteAffineAnimTable_85C8E60[] = +static const union AffineAnimCmd *const sSpriteAffineAnimTable_Pokeball[] = { - sSpriteAffineAnim_85C8E40, - sSpriteAffineAnim_85C8E50 + sSpriteAffineAnim_Pokeball1, + sSpriteAffineAnim_Pokeball2 }; -static const struct SpriteTemplate gUnknown_085C8E68 = +static const struct SpriteTemplate sSpriteTemplate_Pokeball = { .tileTag = 0xFFFF, .paletteTag = 4105, .oam = &gObjectEventBaseOam_32x32, - .anims = sSpriteAnimTable_85C8E3C, - .images = sSpriteImageTable_85C8E2C, - .affineAnims = sSpriteAffineAnimTable_85C8E60, + .anims = sSpriteAnimTable_Pokeball, + .images = sSpriteImage_Pokeball, + .affineAnims = sSpriteAffineAnimTable_Pokeball, .callback = sub_814713C }; -static const struct OamData gOamData_85C8E80 = +static const struct OamData sOam_UnusedBrendanLass = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -774,47 +774,47 @@ static const struct OamData gOamData_85C8E80 = .affineParam = 0, }; -static const struct SpriteFrameImage sSpriteImageTable_85C8E88[] = +static const struct SpriteFrameImage sImageTable_UnusedBrendan[] = { - sSpriteImage_85B9CD0, 0x800 + sUnusedBrendan_Gfx, sizeof(sUnusedBrendan_Gfx) }; -static const struct SpriteFrameImage sSpriteImageTable_85C8E90[] = +static const struct SpriteFrameImage sImageTable_UnusedLass[] = { - sSpriteImage_85BA4D0, 0x800 + sUnusedLass_Gfx, sizeof(sUnusedLass_Gfx) }; -static const union AnimCmd sSpriteAnim_85C8E98[] = +static const union AnimCmd sSpriteAnim_UnusedBrendanLass[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END }; -static const union AnimCmd *const sSpriteAnimTable_85C8EA0[] = +static const union AnimCmd *const sSpriteAnimTable_UnusedBrendanLass[] = { - sSpriteAnim_85C8E98 + sSpriteAnim_UnusedBrendanLass }; -static const struct SpriteTemplate sSpriteTemplate_85C8EA4 = +static const struct SpriteTemplate sSpriteTemplate_UnusedBrendan = { .tileTag = 0xFFFF, .paletteTag = 4106, - .oam = &gOamData_85C8E80, - .anims = sSpriteAnimTable_85C8EA0, - .images = sSpriteImageTable_85C8E88, + .oam = &sOam_UnusedBrendanLass, + .anims = sSpriteAnimTable_UnusedBrendanLass, + .images = sImageTable_UnusedBrendan, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8148380 + .callback = SpriteCb_TrainerPic }; -static const struct SpriteTemplate sSpriteTemplate_85C8EBC = +static const struct SpriteTemplate sSpriteTemplate_UnusedLass = { .tileTag = 0xFFFF, .paletteTag = 4106, - .oam = &gOamData_85C8E80, - .anims = sSpriteAnimTable_85C8EA0, - .images = sSpriteImageTable_85C8E90, + .oam = &sOam_UnusedBrendanLass, + .anims = sSpriteAnimTable_UnusedBrendanLass, + .images = sImageTable_UnusedLass, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8148380 + .callback = SpriteCb_TrainerPic }; static const u16 gFieldEffectObjectPalette10[] = INCBIN_U16("graphics/field_effects/palettes/10.gbapal"); @@ -1102,7 +1102,7 @@ static void Phase2Task_Swirl(u8 taskId) static bool8 Phase2_Swirl_Func1(struct Task *task) { - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, RGB_BLACK); sub_8149F98(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_14, 0, 2, 0, 160); @@ -1156,7 +1156,7 @@ static void Phase2Task_Shuffle(u8 taskId) static bool8 Phase2_Shuffle_Func1(struct Task *task) { - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); BeginNormalPaletteFade(0xFFFFFFFF, 4, 0, 0x10, RGB_BLACK); @@ -1249,7 +1249,7 @@ static void sub_814669C(struct Task *task) { s32 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); task->tData1 = 16; @@ -1273,13 +1273,13 @@ static void sub_814669C(struct Task *task) static bool8 Phase2_Aqua_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; task->tFrames = 60; sub_814669C(task); - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - LZ77UnCompVram(sTeamAqua_Tileset, dst2); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + LZ77UnCompVram(sTeamAqua_Tileset, tileset); LoadPalette(sEvilTeam_Palette, 0xF0, 0x20); task->tState++; @@ -1288,13 +1288,13 @@ static bool8 Phase2_Aqua_Func1(struct Task *task) static bool8 Phase2_Magma_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; task->tFrames = 60; sub_814669C(task); - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - LZ77UnCompVram(sTeamMagma_Tileset, dst2); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + LZ77UnCompVram(sTeamMagma_Tileset, tileset); LoadPalette(sEvilTeam_Palette, 0xF0, 0x20); task->tState++; @@ -1303,13 +1303,13 @@ static bool8 Phase2_Magma_Func1(struct Task *task) static bool8 Phase2_Regi_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; task->tFrames = 60; sub_814669C(task); - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - CpuCopy16(gUnknown_085BBC14, dst2, 0x2000); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + CpuCopy16(sRegis_Tileset, tileset, 0x2000); task->tState++; return FALSE; @@ -1317,12 +1317,12 @@ static bool8 Phase2_Regi_Func1(struct Task *task) static bool8 Phase2_BigPokeball_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; sub_814669C(task); - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - CpuCopy16(sBigPokeball_Tileset, dst2, 0x580); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + CpuCopy16(sBigPokeball_Tileset, tileset, 0x580); LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20); task->tState++; @@ -1332,16 +1332,16 @@ static bool8 Phase2_BigPokeball_Func1(struct Task *task) static bool8 Phase2_BigPokeball_Func2(struct Task *task) { s16 i, j; - u16 *dst1, *dst2; + u16 *tilemap, *tileset; const u16 *BigPokeballMap; - sub_8149F58(&dst1, &dst2); + GetBg0TilesDst(&tilemap, &tileset); BigPokeballMap = sBigPokeball_Tilemap; for (i = 0; i < 20; i++) { for (j = 0; j < 30; j++, BigPokeballMap++) { - dst1[i * 32 + j] = *BigPokeballMap | 0xF000; + tilemap[i * 32 + j] = *BigPokeballMap | 0xF000; } } sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); @@ -1352,10 +1352,10 @@ static bool8 Phase2_BigPokeball_Func2(struct Task *task) static bool8 Phase2_Aqua_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(sTeamAqua_Tilemap, dst1); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(sTeamAqua_Tilemap, tilemap); sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; @@ -1364,10 +1364,10 @@ static bool8 Phase2_Aqua_Func2(struct Task *task) static bool8 Phase2_Magma_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(sTeamMagma_Tilemap, dst1); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(sTeamMagma_Tilemap, tilemap); sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; @@ -1376,11 +1376,11 @@ static bool8 Phase2_Magma_Func2(struct Task *task) static bool8 Phase2_Regice_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LoadPalette(gUnknown_085BC2B4, 0xF0, 0x20); - CpuCopy16(gUnknown_085BC314, dst1, 0x500); + GetBg0TilesDst(&tilemap, &tileset); + LoadPalette(sRegice_Palette, 0xF0, 0x20); + CpuCopy16(sRegice_Tilemap, tilemap, 0x500); sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; @@ -1389,11 +1389,11 @@ static bool8 Phase2_Regice_Func2(struct Task *task) static bool8 Phase2_Registeel_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LoadPalette(gUnknown_085BC2D4, 0xF0, 0x20); - CpuCopy16(gUnknown_085BCB14, dst1, 0x500); + GetBg0TilesDst(&tilemap, &tileset); + LoadPalette(sRegisteel_Palette, 0xF0, 0x20); + CpuCopy16(sRegisteel_Tilemap, tilemap, 0x500); sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; @@ -1402,11 +1402,11 @@ static bool8 Phase2_Registeel_Func2(struct Task *task) static bool8 Phase2_Regirock_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LoadPalette(gUnknown_085BC2F4, 0xF0, 0x20); - CpuCopy16(gUnknown_085BD314, dst1, 0x500); + GetBg0TilesDst(&tilemap, &tileset); + LoadPalette(sRegirock_Palette, 0xF0, 0x20); + CpuCopy16(sRegirock_Tilemap, tilemap, 0x500); sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); task->tState++; @@ -1415,12 +1415,12 @@ static bool8 Phase2_Regirock_Func2(struct Task *task) static bool8 Phase2_Kyogre_Func3(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - LZ77UnCompVram(gUnknown_085BDB34, dst2); - LZ77UnCompVram(gUnknown_085BE1E8, dst1); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + LZ77UnCompVram(sKyogre_Tileset, tileset); + LZ77UnCompVram(sKyogre_Tilemap, tilemap); task->tState++; return FALSE; @@ -1432,7 +1432,7 @@ static bool8 Phase2_Kyogre_Func4(struct Task *task) { u16 var = task->tData1 % 30; var /= 3; - LoadPalette(gUnknown_085BEDA0 + (var * 16), 0xF0, 0x20); + LoadPalette(sKyogre1_Palette + (var * 16), 0xF0, 0x20); } if (++task->tData1 > 58) { @@ -1448,7 +1448,7 @@ static bool8 Phase2_Kyogre_Func5(struct Task *task) if (task->tData1 % 5 == 0) { s16 var = task->tData1 / 5; - LoadPalette(gUnknown_085BEEE0 + (var * 16), 0xF0, 0x20); + LoadPalette(sKyogre2_Palette + (var * 16), 0xF0, 0x20); } if (++task->tData1 > 68) { @@ -1472,7 +1472,7 @@ static bool8 Phase2_WeatherDuo_Func7(struct Task *task) if (!gPaletteFade.active) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); } return FALSE; @@ -1575,7 +1575,7 @@ static bool8 Phase2_BigPokeball_Func6(struct Task *task) { SetVBlankCallback(NULL); DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); } else @@ -1624,11 +1624,11 @@ static void Phase2Task_PokeballsTrail(u8 taskId) static bool8 Phase2_PokeballsTrail_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - CpuSet(sPokeballTrail_Tileset, dst2, 0x20); - CpuFill32(0, dst1, 0x800); + GetBg0TilesDst(&tilemap, &tileset); + CpuSet(sPokeballTrail_Tileset, tileset, 0x20); + CpuFill32(0, tilemap, 0x800); LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20); task->tState++; @@ -1662,7 +1662,7 @@ static bool8 Phase2_PokeballsTrail_Func3(struct Task *task) { if (!FieldEffectActiveListContains(FLDEFF_POKEBALL)) { - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_PokeballsTrail)); } return FALSE; @@ -1670,7 +1670,7 @@ static bool8 Phase2_PokeballsTrail_Func3(struct Task *task) bool8 FldEff_Pokeball(void) { - u8 spriteId = CreateSpriteAtEnd(&gUnknown_085C8E68, gFieldEffectArguments[0], gFieldEffectArguments[1], 0); + u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Pokeball, gFieldEffectArguments[0], gFieldEffectArguments[1], 0); gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].data[0] = gFieldEffectArguments[2]; @@ -1709,7 +1709,7 @@ static void sub_814713C(struct Sprite *sprite) u16 *ptr; sprite->data[2] = posX; - var = (((REG_BG0CNT >> 8) & 0x1F) << 11); // r2 + var = (((REG_BG0CNT >> 8) & 0x1F) << 11); ptr = (u16 *)(VRAM + var); SOME_VRAM_STORE(ptr, posY - 2, posX, 0xF001); @@ -1733,7 +1733,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task) { u16 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 0; @@ -1900,7 +1900,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task) static bool8 Phase2_Clockwise_BlackFade_Func7(struct Task *task) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_Clockwise_BlackFade)); return FALSE; } @@ -1927,7 +1927,7 @@ static bool8 Phase2_Ripple_Func1(struct Task *task) { u8 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); for (i = 0; i < 160; i++) @@ -1962,7 +1962,7 @@ static bool8 Phase2_Ripple_Func2(struct Task *task) for (i = 0; i < 160; i++, r4 += r8) { s16 var = r4 >> 8; - + var++; var--; gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); @@ -2005,7 +2005,7 @@ static bool8 Phase2_Wave_Func1(struct Task *task) { u8 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 63; @@ -2057,7 +2057,7 @@ static bool8 Phase2_Wave_Func2(struct Task *task) static bool8 Phase2_Wave_Func3(struct Task *task) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_Wave)); return FALSE; } @@ -2113,7 +2113,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task *task) { u8 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); Mugshots_CreateOpponentPlayerSprites(task); @@ -2138,20 +2138,20 @@ static bool8 Phase2_Mugshot_Func1(struct Task *task) static bool8 Phase2_Mugshot_Func2(struct Task *task) { s16 i, j; - u16 *dst1, *dst2; - const u16 *MugshotsMap; + u16 *tilemap, *tileset; + const u16 *mugshotsMap; - MugshotsMap = sMugshotsTilemap; - sub_8149F58(&dst1, &dst2); - CpuSet(sUnknown_085B9AF0, dst2, 0xF0); + mugshotsMap = sMugshotsTilemap; + GetBg0TilesDst(&tilemap, &tileset); + CpuSet(sEliteFour_Tileset, tileset, 0xF0); LoadPalette(sOpponentMugshotsPals[task->tMugshotId], 0xF0, 0x20); LoadPalette(sPlayerMugshotsPals[gSaveBlock2Ptr->playerGender], 0xFA, 0xC); for (i = 0; i < 20; i++) { - for (j = 0; j < 32; j++, MugshotsMap++) + for (j = 0; j < 32; j++, mugshotsMap++) { - dst1[i * 32 + j] = *MugshotsMap | 0xF000; + tilemap[i * 32 + j] = *mugshotsMap | 0xF000; } } @@ -2229,9 +2229,9 @@ static bool8 Phase2_Mugshot_Func4(struct Task *task) sTransitionStructPtr->BG0HOFS_1 -= 8; sTransitionStructPtr->BG0HOFS_2 += 8; - sub_8148484(task->tOpponentSpriteId, 0); - sub_8148484(task->tPlayerSpriteId, 1); - sub_814849C(task->tOpponentSpriteId); + SetTrainerPicSlideTable(task->tOpponentSpriteId, 0); + SetTrainerPicSlideTable(task->tPlayerSpriteId, 1); + IncrementTrainerPicState(task->tOpponentSpriteId); PlaySE(SE_BT_START); @@ -2243,10 +2243,10 @@ static bool8 Phase2_Mugshot_Func5(struct Task *task) { sTransitionStructPtr->BG0HOFS_1 -= 8; sTransitionStructPtr->BG0HOFS_2 += 8; - if (sub_81484B8(task->tOpponentSpriteId)) + if (IsTrainerPicSlideDone(task->tOpponentSpriteId)) { task->tState++; - sub_814849C(task->tPlayerSpriteId); + IncrementTrainerPicState(task->tPlayerSpriteId); } return FALSE; } @@ -2255,7 +2255,7 @@ static bool8 Phase2_Mugshot_Func6(struct Task *task) { sTransitionStructPtr->BG0HOFS_1 -= 8; sTransitionStructPtr->BG0HOFS_2 += 8; - if (sub_81484B8(task->tPlayerSpriteId)) + if (IsTrainerPicSlideDone(task->tPlayerSpriteId)) { sTransitionStructPtr->VBlank_DMA = FALSE; SetVBlankCallback(NULL); @@ -2317,7 +2317,7 @@ static bool8 Phase2_Mugshot_Func7(struct Task *task) static bool8 Phase2_Mugshot_Func8(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; - BlendPalettes(-1, 0x10, 0x7FFF); + BlendPalettes(0xFFFFFFFF, 0x10, RGB_WHITE); sTransitionStructPtr->BLDCNT = 0xFF; task->tData3 = 0; @@ -2341,7 +2341,7 @@ static bool8 Phase2_Mugshot_Func9(struct Task *task) static bool8 Phase2_Mugshot_Func10(struct Task *task) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); return FALSE; } @@ -2377,6 +2377,13 @@ static void HBlankCB_Phase2_Mugshots(void) REG_BG0HOFS = sTransitionStructPtr->BG0HOFS_2; } +// data fields for player/opponent sprites in mugshots +#define sState data[0] +#define sOffsetX data[1] +#define sOffsetX2 data[2] +#define sDone data[6] +#define sSlideTableId data[7] + static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) { struct Sprite *opponentSprite, *playerSprite; @@ -2391,8 +2398,8 @@ static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) opponentSprite = &gSprites[task->tOpponentSpriteId]; playerSprite = &gSprites[task->tPlayerSpriteId]; - opponentSprite->callback = sub_8148380; - playerSprite->callback = sub_8148380; + opponentSprite->callback = SpriteCb_TrainerPic; + playerSprite->callback = SpriteCb_TrainerPic; opponentSprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; playerSprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; @@ -2413,77 +2420,86 @@ static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) SetOamMatrixRotationScaling(playerSprite->oam.matrixNum, -512, 512, 0); } -static void sub_8148380(struct Sprite *sprite) +static void SpriteCb_TrainerPic(struct Sprite *sprite) { - while (sUnknown_085C8C24[sprite->data[0]](sprite)); + while (sTrainerPicSpriteCbs[sprite->sState](sprite)); } -static bool8 sub_81483A8(struct Sprite *sprite) +static bool8 TrainerPicCb_Nothing(struct Sprite *sprite) { return FALSE; } -static bool8 sub_81483AC(struct Sprite *sprite) +static bool8 TrainerPicCb_SetSlideOffsets(struct Sprite *sprite) { - s16 arr0[2]; - s16 arr1[2]; + s16 offfsets1[ARRAY_COUNT(sTrainerPicSlideOffsets1)]; + s16 offfsets2[ARRAY_COUNT(sTrainerPicSlideOffsets2)]; - memcpy(arr0, sUnknown_085C8C40, sizeof(sUnknown_085C8C40)); - memcpy(arr1, sUnknown_085C8C44, sizeof(sUnknown_085C8C44)); + memcpy(offfsets1, sTrainerPicSlideOffsets1, sizeof(sTrainerPicSlideOffsets1)); + memcpy(offfsets2, sTrainerPicSlideOffsets2, sizeof(sTrainerPicSlideOffsets2)); - sprite->data[0]++; - sprite->data[1] = arr0[sprite->data[7]]; - sprite->data[2] = arr1[sprite->data[7]]; + sprite->sState++; + sprite->sOffsetX = offfsets1[sprite->sSlideTableId]; + sprite->sOffsetX2 = offfsets2[sprite->sSlideTableId]; return TRUE; } -static bool8 sub_81483F8(struct Sprite *sprite) +// fast slide to around middle screen +static bool8 TrainerPicCb_Slide1(struct Sprite *sprite) { - sprite->pos1.x += sprite->data[1]; - if (sprite->data[7] && sprite->pos1.x < 133) - sprite->data[0]++; - else if (!sprite->data[7] && sprite->pos1.x > 103) - sprite->data[0]++; + sprite->pos1.x += sprite->sOffsetX; + if (sprite->sSlideTableId && sprite->pos1.x < 133) + sprite->sState++; + else if (!sprite->sSlideTableId && sprite->pos1.x > 103) + sprite->sState++; return FALSE; } -static bool8 sub_814842C(struct Sprite *sprite) +// slower but accelerating slide +static bool8 TrainerPicCb_Slide2(struct Sprite *sprite) { - sprite->data[1] += sprite->data[2]; - sprite->pos1.x += sprite->data[1]; - if (sprite->data[1] == 0) + sprite->sOffsetX += sprite->sOffsetX2; + sprite->pos1.x += sprite->sOffsetX; + if (sprite->sOffsetX == 0) { - sprite->data[0]++; - sprite->data[2] = -sprite->data[2]; - sprite->data[6] = 1; + sprite->sState++; + sprite->sOffsetX2 = -sprite->sOffsetX2; + sprite->sDone = TRUE; } return FALSE; } -static bool8 sub_8148458(struct Sprite *sprite) +// Has no practical effect +static bool8 TrainerPicCb_Slide3(struct Sprite *sprite) { - sprite->data[1] += sprite->data[2]; - sprite->pos1.x += sprite->data[1]; + sprite->sOffsetX += sprite->sOffsetX2; + sprite->pos1.x += sprite->sOffsetX; if (sprite->pos1.x < -31 || sprite->pos1.x > 271) - sprite->data[0]++; + sprite->sState++; return FALSE; } -static void sub_8148484(s16 spriteId, s16 value) +static void SetTrainerPicSlideTable(s16 spriteId, s16 arrId) { - gSprites[spriteId].data[7] = value; + gSprites[spriteId].sSlideTableId = arrId; } -static void sub_814849C(s16 spriteId) +static void IncrementTrainerPicState(s16 spriteId) { - gSprites[spriteId].data[0]++; + gSprites[spriteId].sState++; } -static s16 sub_81484B8(s16 spriteId) +static s16 IsTrainerPicSlideDone(s16 spriteId) { - return gSprites[spriteId].data[6]; + return gSprites[spriteId].sDone; } +#undef sState +#undef sOffsetX +#undef sOffsetX2 +#undef sDone +#undef sSlideTableId + static void Phase2Task_Slice(u8 taskId) { while (sPhase2_Slice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -2493,7 +2509,7 @@ static bool8 Phase2_Slice_Func1(struct Task *task) { u16 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); task->tData2 = 256; @@ -2559,7 +2575,7 @@ static bool8 Phase2_Slice_Func2(struct Task *task) static bool8 Phase2_Slice_Func3(struct Task *task) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_Slice)); return FALSE; } @@ -2596,7 +2612,7 @@ static bool8 Phase2_ShredSplit_Func1(struct Task *task) { u16 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 63; @@ -2749,7 +2765,7 @@ static bool8 Phase2_ShredSplit_Func3(struct Task *task) static bool8 Phase2_ShredSplit_Func4(struct Task *task) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_ShredSplit)); return FALSE; } @@ -2768,7 +2784,7 @@ static bool8 Phase2_Blackhole_Func1(struct Task *task) { s32 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 0; @@ -2812,7 +2828,7 @@ static bool8 Phase2_Blackhole1_Func3(struct Task *task) if (task->tData1 == 0xA0) { task->tFuncState = 1; - sub_8149F84(); + FadeScreenBlack(); } else { @@ -2864,7 +2880,7 @@ static bool8 Phase2_Blackhole2_Func2(struct Task *task) if (task->tData1 == 0xA0) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); } @@ -2897,12 +2913,12 @@ static void Phase2Task_RectangularSpiral(u8 taskId) static bool8 Phase2_RectangularSpiral_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - CpuCopy16(sShrinkingBoxTileset, dst2, 0x20); - CpuCopy16(sShrinkingBoxTileset + 0x70, dst2 + 0x20, 0x20); - CpuFill16(0xF000, dst1, 0x800); + GetBg0TilesDst(&tilemap, &tileset); + CpuCopy16(sShrinkingBoxTileset, tileset, 0x20); + CpuCopy16(sShrinkingBoxTileset + 0x70, tileset + 0x20, 0x20); + CpuFill16(0xF000, tilemap, 0x800); LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20); task->tData3 = 1; @@ -2937,12 +2953,12 @@ static bool8 Phase2_RectangularSpiral_Func1(struct Task *task) static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; u8 i; u16 j; bool32 done = TRUE; - sub_8149F58(&dst1, &dst2); + GetBg0TilesDst(&tilemap, &tileset); for (i = 0; i < 2; i++) { @@ -2963,7 +2979,7 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) var2 = var % 32; var3 = var / 32 * 32; - dst1[var3 + var2] = 0xF002; + tilemap[var3 + var2] = 0xF002; } } } @@ -2976,7 +2992,7 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) static bool8 Phase2_RectangularSpiral_Func3(struct Task *task) { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); return FALSE; } @@ -3051,12 +3067,12 @@ static void Phase2Task_Groudon(u8 taskId) static bool8 Phase2_Groudon_Func3(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - LZ77UnCompVram(gUnknown_085BE51C, dst2); - LZ77UnCompVram(gUnknown_085BEA88, dst1); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + LZ77UnCompVram(sGroudon_Tileset, tileset); + LZ77UnCompVram(sGroudon_Tilemap, tilemap); task->tState++; task->tData1 = 0; @@ -3068,7 +3084,7 @@ static bool8 Phase2_Groudon_Func4(struct Task *task) if (task->tData1 % 3 == 0) { u16 var = (task->tData1 % 30) / 3; - LoadPalette(gUnknown_085BF0A0 + (var * 16), 0xF0, 0x20); + LoadPalette(sGroudon1_Palette + (var * 16), 0xF0, 0x20); } if (++task->tData1 > 58) { @@ -3084,7 +3100,7 @@ static bool8 Phase2_Groudon_Func5(struct Task *task) if (task->tData1 % 5 == 0) { s16 var = task->tData1 / 5; - LoadPalette(gUnknown_085BF2A0 + (var * 16), 0xF0, 0x20); + LoadPalette(sGroudon2_Palette + (var * 16), 0xF0, 0x20); } if (++task->tData1 > 68) { @@ -3103,20 +3119,20 @@ static void Phase2Task_Rayquaza(u8 taskId) static bool8 Phase2_Rayquaza_Func3(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; u16 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); SetGpuReg(REG_OFFSET_BG0CNT, 0x9A08); - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - CpuCopy16(gUnknown_085BF6A0, dst2, 0x2000); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + CpuCopy16(sRayquaza_Tileset, tileset, 0x2000); sTransitionStructPtr->field_20 = 0; task->tState++; - LoadPalette(gUnknown_085BF4A0 + 0x50, 0xF0, 0x20); + LoadPalette(sRayquaza_Palette + 0x50, 0xF0, 0x20); for (i = 0; i < 160; i++) { @@ -3130,10 +3146,10 @@ static bool8 Phase2_Rayquaza_Func3(struct Task *task) static bool8 Phase2_Rayquaza_Func4(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - CpuCopy16(gUnknown_085C6BE0, dst1, 0x1000); + GetBg0TilesDst(&tilemap, &tileset); + CpuCopy16(sRayquaza_Tilemap, tilemap, 0x1000); task->tState++; return FALSE; } @@ -3143,7 +3159,7 @@ static bool8 Phase2_Rayquaza_Func5(struct Task *task) if ((task->tData1 % 4) == 0) { u16 value = task->tData1 / 4; - const u16 *palPtr = &gUnknown_085BF4A0[(value + 5) * 16]; + const u16 *palPtr = &sRayquaza_Palette[(value + 5) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } if (++task->tData1 > 40) @@ -3192,7 +3208,7 @@ static bool8 Phase2_Rayquaza_Func9(struct Task *task) if ((task->tData1 % 3) == 0) { u16 value = task->tData1 / 3; - const u16 *palPtr = &gUnknown_085BF4A0[(value + 0) * 16]; + const u16 *palPtr = &sRayquaza_Palette[(value + 0) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } if (++task->tData1 >= 40) @@ -3245,7 +3261,7 @@ static bool8 Phase2_WhiteFade_Func1(struct Task *task) { u16 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); sTransitionStructPtr->BLDCNT = 0xBF; @@ -3322,7 +3338,7 @@ static bool8 Phase2_WhiteFade_Func5(struct Task *task) { if (++sTransitionStructPtr->BLDY > 16) { - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_WhiteFade)); } return FALSE; @@ -3407,11 +3423,11 @@ static void Phase2Task_GridSquares(u8 taskId) static bool8 Phase2_GridSquares_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - CpuSet(sShrinkingBoxTileset, dst2, 0x10); - CpuFill16(0xF000, dst1, 0x800); + GetBg0TilesDst(&tilemap, &tileset); + CpuSet(sShrinkingBoxTileset, tileset, 0x10); + CpuFill16(0xF000, tilemap, 0x800); LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20); task->tState++; @@ -3420,14 +3436,14 @@ static bool8 Phase2_GridSquares_Func1(struct Task *task) static bool8 Phase2_GridSquares_Func2(struct Task *task) { - u16* dst1; + u16* tileset; if (task->tData1 == 0) { - sub_8149F40(&dst1); + GetBg0TilemapDst(&tileset); task->tData1 = 3; task->tData2++; - CpuSet(sShrinkingBoxTileset + (task->tData2 * 8), dst1, 0x10); + CpuSet(sShrinkingBoxTileset + (task->tData2 * 8), tileset, 0x10); if (task->tData2 > 0xD) { task->tState++; @@ -3443,7 +3459,7 @@ static bool8 Phase2_GridSquares_Func3(struct Task *task) { if (--task->tData1 == 0) { - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_GridSquares)); } return FALSE; @@ -3458,7 +3474,7 @@ static bool8 Phase2_Shards_Func1(struct Task *task) { u16 i; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); sTransitionStructPtr->WININ = 0x3F; @@ -3540,7 +3556,7 @@ static bool8 Phase2_Shards_Func4(struct Task *task) else { DmaStop(0); - sub_8149F84(); + FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Phase2Task_Shards)); return FALSE; } @@ -3553,8 +3569,8 @@ static bool8 Phase2_Shards_Func5(struct Task *task) task->tState = 1; return TRUE; } - else - return FALSE; + + return FALSE; } static void VBlankCB_Phase2_Shards(void) @@ -3665,7 +3681,7 @@ static bool8 Phase1_TransitionAll_Func2(struct Task *task) #undef tData6 #undef tData7 -static void sub_8149F08(void) +static void InitTransitionStructVars(void) { memset(sTransitionStructPtr, 0, sizeof(*sTransitionStructPtr)); sub_8089C08(&sTransitionStructPtr->field_14, &sTransitionStructPtr->field_16); @@ -3678,37 +3694,28 @@ static void VBlankCB_BattleTransition(void) TransferPlttBuffer(); } -static void sub_8149F40(u16 **a0) +static void GetBg0TilemapDst(u16 **tileset) { - u16 reg, *vram; - - reg = REG_BG0CNT >> 2; - reg <<= 0xE; - vram = (u16*)(VRAM + reg); - - *a0 = vram; + u16 charBase = REG_BG0CNT >> 2; + charBase <<= 0xE; + *tileset = (u16*)(VRAM + charBase); } -void sub_8149F58(u16 **a0, u16 **a1) +void GetBg0TilesDst(u16 **tilemap, u16 **tileset) { - u16 reg0, reg1, *vram0, *vram1; + u16 screenBase = REG_BG0CNT >> 8; + u16 charBase = REG_BG0CNT >> 2; - reg0 = REG_BG0CNT >> 8; - reg1 = REG_BG0CNT >> 2; + screenBase <<= 0xB; + charBase <<= 0xE; - reg0 <<= 0xB; - reg1 <<= 0xE; - - vram0 = (u16*)(VRAM + reg0); - *a0 = vram0; - - vram1 = (u16*)(VRAM + reg1); - *a1 = vram1; + *tilemap = (u16*)(VRAM + screenBase); + *tileset = (u16*)(VRAM + charBase); } -static void sub_8149F84(void) +static void FadeScreenBlack(void) { - BlendPalettes(-1, 0x10, 0); + BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK); } static void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize) @@ -3851,12 +3858,12 @@ static bool8 sub_814A228(s16 *data, bool8 a1, bool8 a2) static bool8 Phase2_29_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; sub_814669C(task); - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - LZ77UnCompVram(gUnknown_085C7C00, dst2); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + LZ77UnCompVram(gUnknown_085C7C00, tileset); LoadPalette(gUnknown_085C7BE0, 0xF0, 0x20); task->tState++; @@ -3865,10 +3872,10 @@ static bool8 Phase2_29_Func1(struct Task *task) static bool8 Phase2_29_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(gUnknown_085C828C, dst1); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(gUnknown_085C828C, tilemap); sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 0x84, task->tData5, 160); task->tState++; @@ -3887,9 +3894,9 @@ static void Phase2Task_30(u8 taskId) static bool8 Phase2_30_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F08(); + InitTransitionStructVars(); ScanlineEffect_Clear(); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON); task->tData2 = 0x2000; @@ -3901,9 +3908,9 @@ static bool8 Phase2_30_Func1(struct Task *task) sTransitionStructPtr->BLDALPHA = (task->tData6 << 8) | (task->tData5); REG_BLDCNT = sTransitionStructPtr->BLDCNT; REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; - sub_8149F58(&dst1, &dst2); - CpuFill16(0, dst1, 0x800); - LZ77UnCompVram(gUnknown_085C7C00, dst2); + GetBg0TilesDst(&tilemap, &tileset); + CpuFill16(0, tilemap, 0x800); + LZ77UnCompVram(gUnknown_085C7C00, tileset); LoadPalette(gUnknown_085C7BE0, 0xF0, 0x20); sTransitionStructPtr->field_16 = 0; @@ -3913,10 +3920,10 @@ static bool8 Phase2_30_Func1(struct Task *task) static bool8 Phase2_30_Func2(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(gUnknown_085C828C, dst1); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(gUnknown_085C828C, tilemap); task->tState++; return TRUE; @@ -4024,10 +4031,10 @@ static void Phase2Task_32(u8 taskId) static bool8 Phase2_31_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(gUnknown_085C8598, dst2); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(gUnknown_085C8598, tileset); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); @@ -4065,9 +4072,9 @@ static bool8 Phase2_31_Func2(struct Task *task) static bool8 Phase2_31_Func3(struct Task *task) { u8 i; - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); + GetBg0TilesDst(&tilemap, &tileset); if (task->tData6++ >= task->tData7) { switch (task->tData5) @@ -4081,13 +4088,13 @@ static bool8 Phase2_31_Func3(struct Task *task) break; case 1: BlendPalettes(0xFFFF7FFF, 0x10, 0); - LZ77UnCompVram(gUnknown_085C86F4, dst2); + LZ77UnCompVram(gUnknown_085C86F4, tileset); break; case 2: - LZ77UnCompVram(gUnknown_085C87F4, dst2); + LZ77UnCompVram(gUnknown_085C87F4, tileset); break; case 3: - LZ77UnCompVram(gUnknown_085C88A4, dst2); + LZ77UnCompVram(gUnknown_085C88A4, tileset); break; default: FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); @@ -4105,10 +4112,10 @@ static bool8 Phase2_31_Func3(struct Task *task) static bool8 Phase2_33_Func1(struct Task *task) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(gUnknown_085C8598, dst2); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(gUnknown_085C8598, tileset); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); @@ -4221,10 +4228,10 @@ static void sub_814ABE4(u8 taskId) static bool8 Phase2_32_Func1(struct Task *task) { u8 taskId = 0; - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(gUnknown_085C8598, dst2); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(gUnknown_085C8598, tileset); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); CopyBgTilemapBufferToVram(0); LoadPalette(gUnknown_085C8578, 0xF0, 0x20); diff --git a/src/unk_transition.c b/src/unk_transition.c index 09e194be3..b485ef350 100644 --- a/src/unk_transition.c +++ b/src/unk_transition.c @@ -185,11 +185,11 @@ static const TransitionStateFunc sPhase2_41_Funcs[] = // code static void sub_81DA700(void) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - sub_8149F58(&dst1, &dst2); - LZ77UnCompVram(gUnknown_0862AD54, dst2); - LZ77UnCompVram(gUnknown_0862AF30, dst1); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(gUnknown_0862AD54, tileset); + LZ77UnCompVram(gUnknown_0862AF30, tilemap); LoadPalette(gUnknown_0862B53C, 0xF0, 0x20); LoadCompressedSpriteSheet(&sUnknown_0862B724); LoadSpritePalette(&sUnknown_0862B72C);