From 1cc0a3506f6a3d8e75ed70299f770cdb7a01a74f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 21 Mar 2021 01:22:42 -0400 Subject: [PATCH] Label misc field effects --- ...{85B2890.pal => cave_transition_enter.pal} | 0 .../{85B28A0.pal => cave_transition_exit.pal} | 0 src/field_door.c | 58 ++++++++++--------- src/field_effect.c | 23 ++++---- src/fldeff_flash.c | 40 ++++++------- 5 files changed, 60 insertions(+), 61 deletions(-) rename graphics/misc/{85B2890.pal => cave_transition_enter.pal} (100%) rename graphics/misc/{85B28A0.pal => cave_transition_exit.pal} (100%) diff --git a/graphics/misc/85B2890.pal b/graphics/misc/cave_transition_enter.pal similarity index 100% rename from graphics/misc/85B2890.pal rename to graphics/misc/cave_transition_enter.pal diff --git a/graphics/misc/85B28A0.pal b/graphics/misc/cave_transition_exit.pal similarity index 100% rename from graphics/misc/85B28A0.pal rename to graphics/misc/cave_transition_exit.pal diff --git a/src/field_door.c b/src/field_door.c index 4dcb07cca..8aeb1d491 100644 --- a/src/field_door.c +++ b/src/field_door.c @@ -357,40 +357,42 @@ static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame } } -enum -{ - TD_FRAMELIST = 0, - TD_GFX = 2, - TD_FRAME = 4, - TD_COUNTER, - TD_X, - TD_Y -}; +#define tFramesHi data[0] +#define tFramesLo data[1] +#define tGfxHi data[2] +#define tGfxLo data[3] +#define tFrameId data[4] +#define tCounter data[5] +#define tX data[6] +#define tY data[7] -static bool32 sub_808A5F0(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *taskData) +// Draws a single frame of the door animation, or skips drawing to wait between frames. +// Returns FALSE when the final frame has been reached +static bool32 AnimateDoorFrame(struct DoorGraphics *gfx, struct DoorAnimFrame *frames, s16 *data) { - if (taskData[TD_COUNTER] == 0) - DrawDoor(gfx, &frames[taskData[TD_FRAME]], taskData[TD_X], taskData[TD_Y]); - if (taskData[TD_COUNTER] == frames[taskData[TD_FRAME]].time) + if (tCounter == 0) + DrawDoor(gfx, &frames[tFrameId], tX, tY); + + if (tCounter == frames[tFrameId].time) { - taskData[TD_COUNTER] = 0; - taskData[TD_FRAME]++; - if (frames[taskData[TD_FRAME]].time == 0) + tCounter = 0; + tFrameId++; + if (frames[tFrameId].time == 0) return FALSE; else return TRUE; } - taskData[TD_COUNTER]++; + tCounter++; return TRUE; } static void Task_AnimateDoor(u8 taskId) { - u16 *taskData = gTasks[taskId].data; - struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(taskData[TD_FRAMELIST] << 16 | taskData[TD_FRAMELIST + 1]); - struct DoorGraphics *gfx = (struct DoorGraphics *)(taskData[TD_GFX] << 16 | taskData[TD_GFX + 1]); + u16 *data = gTasks[taskId].data; + struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(tFramesHi << 16 | tFramesLo); + struct DoorGraphics *gfx = (struct DoorGraphics *)(tGfxHi << 16 | tGfxLo); - if (sub_808A5F0(gfx, frames, taskData) == FALSE) + if (AnimateDoorFrame(gfx, frames, data) == FALSE) DestroyTask(taskId); } @@ -419,16 +421,16 @@ static s8 StartDoorAnimationTask(const struct DoorGraphics *gfx, const struct Do else { u8 taskId = CreateTask(Task_AnimateDoor, 0x50); - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; - taskData[TD_X] = x; - taskData[TD_Y] = y; + tX = x; + tY = y; - taskData[TD_FRAMELIST + 1] = (u32)frames; - taskData[TD_FRAMELIST] = (u32)frames >> 16; + tFramesLo = (u32)frames; + tFramesHi = (u32)frames >> 16; - taskData[TD_GFX + 1] = (u32)gfx; - taskData[TD_GFX] = (u32)gfx >> 16; + tGfxLo = (u32)gfx; + tGfxHi = (u32)gfx >> 16; return taskId; } diff --git a/src/field_effect.c b/src/field_effect.c index a70ef2892..445827390 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -480,13 +480,13 @@ static const struct Subsprite sSubsprites_HofMonitorBig[] = static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(sSubsprites_HofMonitorBig); -const union AnimCmd gSpriteAnim_855C2CC[] = +const union AnimCmd sAnim_Static[] = { ANIMCMD_FRAME(.imageValue = 0, .duration = 1), ANIMCMD_JUMP(0) }; -const union AnimCmd gSpriteAnim_855C2D4[] = +const union AnimCmd sAnim_Flicker[] = { ANIMCMD_FRAME(.imageValue = 0, .duration = 16), ANIMCMD_FRAME(.imageValue = 1, .duration = 16), @@ -499,15 +499,16 @@ const union AnimCmd gSpriteAnim_855C2D4[] = ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_855C2F8[] = +// Flicker on and off, for the Pokéballs / monitors during the PokéCenter heal effect +const union AnimCmd *const sAnims_Flicker[] = { - gSpriteAnim_855C2CC, - gSpriteAnim_855C2D4 + sAnim_Static, + sAnim_Flicker }; -static const union AnimCmd *const sAnimTable_HofMonitor[] = +static const union AnimCmd *const sAnims_HofMonitor[] = { - gSpriteAnim_855C2CC + sAnim_Static }; static const struct SpriteTemplate sSpriteTemplate_PokeballGlow = @@ -515,7 +516,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokeballGlow = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_POKEBALL_GLOW, .oam = &sOam_8x8, - .anims = gSpriteAnimTable_855C2F8, + .anims = sAnims_Flicker, .images = sPicTable_PokeballGlow, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_PokeballGlow @@ -526,7 +527,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokecenterMonitor = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_GENERAL_0, .oam = &sOam_16x16, - .anims = gSpriteAnimTable_855C2F8, + .anims = sAnims_Flicker, .images = sPicTable_PokecenterMonitor, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_PokecenterMonitor @@ -537,7 +538,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorBig = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .oam = &sOam_16x16, - .anims = sAnimTable_HofMonitor, + .anims = sAnims_HofMonitor, .images = sPicTable_HofMonitorBig, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_HallOfFameMonitor @@ -548,7 +549,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorSmall = .tileTag = 0xFFFF, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .oam = &sOam_32x16, - .anims = sAnimTable_HofMonitor, + .anims = sAnims_HofMonitor, .images = sPicTable_HofMonitorSmall, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_HallOfFameMonitor diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index b2ddf3180..9c166d008 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -16,7 +16,6 @@ #include "constants/songs.h" #include "constants/map_types.h" -// structures struct FlashStruct { u8 fromType; @@ -26,7 +25,6 @@ struct FlashStruct void (*func)(void); }; -// static functions static void FieldCallback_Flash(void); static void FldEff_UseFlash(void); static bool8 TryDoMapTransition(void); @@ -42,7 +40,6 @@ static void Task_EnterCaveTransition2(u8 taskId); static void Task_EnterCaveTransition3(u8 taskId); static void Task_EnterCaveTransition4(u8 taskId); -// rodata static const struct FlashStruct sTransitionTypes[] = { {MAP_TYPE_TOWN, MAP_TYPE_UNDERGROUND, TRUE, FALSE, DoEnterCaveTransition}, @@ -64,15 +61,14 @@ static const struct FlashStruct sTransitionTypes[] = {}, }; -static const u16 gCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal"); -static const u16 gCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal"); +static const u16 sCaveTransitionPalette_White[] = INCBIN_U16("graphics/misc/cave_transition_white.gbapal"); +static const u16 sCaveTransitionPalette_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal"); -static const u16 gUnknown_085B2890[] = INCBIN_U16("graphics/misc/85B2890.gbapal"); -static const u16 gUnknown_085B28A0[] = INCBIN_U16("graphics/misc/85B28A0.gbapal"); -static const u32 gCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz"); -static const u32 gCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz"); +static const u16 sCaveTransitionPalette_Enter[] = INCBIN_U16("graphics/misc/cave_transition_enter.gbapal"); +static const u16 sCaveTransitionPalette_Exit[] = INCBIN_U16("graphics/misc/cave_transition_exit.gbapal"); +static const u32 sCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz"); +static const u32 sCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz"); -// text bool8 SetUpFieldMove_Flash(void) { // In Ruby and Sapphire, Registeel's tomb is opened by using Fly. In Emerald, @@ -220,10 +216,10 @@ static void Task_ExitCaveTransition1(u8 taskId) static void Task_ExitCaveTransition2(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); - LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); - LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); - LoadPalette(gUnknown_085B28A0, 0xE0, 0x10); + LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000)); + LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800)); + LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20); + LoadPalette(sCaveTransitionPalette_Exit, 0xE0, 0x10); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 @@ -274,11 +270,11 @@ static void Task_ExitCaveTransition4(u8 taskId) if (count < 8) { gTasks[taskId].data[2]++; - LoadPalette(&gUnknown_085B28A0[count], 0xE0, 16 - 2 * count); + LoadPalette(&sCaveTransitionPalette_Exit[count], 0xE0, 16 - 2 * count); } else { - LoadPalette(gCaveTransitionPalette_White, 0, 0x20); + LoadPalette(sCaveTransitionPalette_White, 0, 0x20); gTasks[taskId].func = Task_ExitCaveTransition5; gTasks[taskId].data[2] = 8; } @@ -305,8 +301,8 @@ static void Task_EnterCaveTransition1(u8 taskId) static void Task_EnterCaveTransition2(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); - LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); + LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000)); + LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800)); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); @@ -319,8 +315,8 @@ static void Task_EnterCaveTransition2(u8 taskId) | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON); - LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); - LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); + LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20); + LoadPalette(sCaveTransitionPalette_Black, 0, 0x20); gTasks[taskId].func = Task_EnterCaveTransition3; gTasks[taskId].data[0] = 16; gTasks[taskId].data[1] = 0; @@ -335,7 +331,7 @@ static void Task_EnterCaveTransition3(u8 taskId) { gTasks[taskId].data[2]++; gTasks[taskId].data[2]++; - LoadPalette(&gUnknown_085B2890[15 - count], 0xE0, 2 * (count + 1)); + LoadPalette(&sCaveTransitionPalette_Enter[15 - count], 0xE0, 2 * (count + 1)); } else { @@ -363,7 +359,7 @@ static void Task_EnterCaveTransition4(u8 taskId) } else { - LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); + LoadPalette(sCaveTransitionPalette_Black, 0, 0x20); SetMainCallback2(gMain.savedCallback); } }