Label misc field effects

This commit is contained in:
GriffinR 2021-03-21 01:22:42 -04:00 committed by huderlem
parent 4077c53338
commit 1cc0a3506f
5 changed files with 60 additions and 61 deletions

View File

@ -357,40 +357,42 @@ static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame
} }
} }
enum #define tFramesHi data[0]
{ #define tFramesLo data[1]
TD_FRAMELIST = 0, #define tGfxHi data[2]
TD_GFX = 2, #define tGfxLo data[3]
TD_FRAME = 4, #define tFrameId data[4]
TD_COUNTER, #define tCounter data[5]
TD_X, #define tX data[6]
TD_Y #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) if (tCounter == 0)
DrawDoor(gfx, &frames[taskData[TD_FRAME]], taskData[TD_X], taskData[TD_Y]); DrawDoor(gfx, &frames[tFrameId], tX, tY);
if (taskData[TD_COUNTER] == frames[taskData[TD_FRAME]].time)
if (tCounter == frames[tFrameId].time)
{ {
taskData[TD_COUNTER] = 0; tCounter = 0;
taskData[TD_FRAME]++; tFrameId++;
if (frames[taskData[TD_FRAME]].time == 0) if (frames[tFrameId].time == 0)
return FALSE; return FALSE;
else else
return TRUE; return TRUE;
} }
taskData[TD_COUNTER]++; tCounter++;
return TRUE; return TRUE;
} }
static void Task_AnimateDoor(u8 taskId) static void Task_AnimateDoor(u8 taskId)
{ {
u16 *taskData = gTasks[taskId].data; u16 *data = gTasks[taskId].data;
struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(taskData[TD_FRAMELIST] << 16 | taskData[TD_FRAMELIST + 1]); struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(tFramesHi << 16 | tFramesLo);
struct DoorGraphics *gfx = (struct DoorGraphics *)(taskData[TD_GFX] << 16 | taskData[TD_GFX + 1]); struct DoorGraphics *gfx = (struct DoorGraphics *)(tGfxHi << 16 | tGfxLo);
if (sub_808A5F0(gfx, frames, taskData) == FALSE) if (AnimateDoorFrame(gfx, frames, data) == FALSE)
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -419,16 +421,16 @@ static s8 StartDoorAnimationTask(const struct DoorGraphics *gfx, const struct Do
else else
{ {
u8 taskId = CreateTask(Task_AnimateDoor, 0x50); u8 taskId = CreateTask(Task_AnimateDoor, 0x50);
s16 *taskData = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
taskData[TD_X] = x; tX = x;
taskData[TD_Y] = y; tY = y;
taskData[TD_FRAMELIST + 1] = (u32)frames; tFramesLo = (u32)frames;
taskData[TD_FRAMELIST] = (u32)frames >> 16; tFramesHi = (u32)frames >> 16;
taskData[TD_GFX + 1] = (u32)gfx; tGfxLo = (u32)gfx;
taskData[TD_GFX] = (u32)gfx >> 16; tGfxHi = (u32)gfx >> 16;
return taskId; return taskId;
} }

View File

@ -480,13 +480,13 @@ static const struct Subsprite sSubsprites_HofMonitorBig[] =
static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(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_FRAME(.imageValue = 0, .duration = 1),
ANIMCMD_JUMP(0) ANIMCMD_JUMP(0)
}; };
const union AnimCmd gSpriteAnim_855C2D4[] = const union AnimCmd sAnim_Flicker[] =
{ {
ANIMCMD_FRAME(.imageValue = 0, .duration = 16), ANIMCMD_FRAME(.imageValue = 0, .duration = 16),
ANIMCMD_FRAME(.imageValue = 1, .duration = 16), ANIMCMD_FRAME(.imageValue = 1, .duration = 16),
@ -499,15 +499,16 @@ const union AnimCmd gSpriteAnim_855C2D4[] =
ANIMCMD_END 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, sAnim_Static,
gSpriteAnim_855C2D4 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 = static const struct SpriteTemplate sSpriteTemplate_PokeballGlow =
@ -515,7 +516,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokeballGlow =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_POKEBALL_GLOW, .paletteTag = FLDEFF_PAL_TAG_POKEBALL_GLOW,
.oam = &sOam_8x8, .oam = &sOam_8x8,
.anims = gSpriteAnimTable_855C2F8, .anims = sAnims_Flicker,
.images = sPicTable_PokeballGlow, .images = sPicTable_PokeballGlow,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_PokeballGlow .callback = SpriteCB_PokeballGlow
@ -526,7 +527,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokecenterMonitor =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_GENERAL_0, .paletteTag = FLDEFF_PAL_TAG_GENERAL_0,
.oam = &sOam_16x16, .oam = &sOam_16x16,
.anims = gSpriteAnimTable_855C2F8, .anims = sAnims_Flicker,
.images = sPicTable_PokecenterMonitor, .images = sPicTable_PokecenterMonitor,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_PokecenterMonitor .callback = SpriteCB_PokecenterMonitor
@ -537,7 +538,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorBig =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR,
.oam = &sOam_16x16, .oam = &sOam_16x16,
.anims = sAnimTable_HofMonitor, .anims = sAnims_HofMonitor,
.images = sPicTable_HofMonitorBig, .images = sPicTable_HofMonitorBig,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_HallOfFameMonitor .callback = SpriteCB_HallOfFameMonitor
@ -548,7 +549,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorSmall =
.tileTag = 0xFFFF, .tileTag = 0xFFFF,
.paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR, .paletteTag = FLDEFF_PAL_TAG_HOF_MONITOR,
.oam = &sOam_32x16, .oam = &sOam_32x16,
.anims = sAnimTable_HofMonitor, .anims = sAnims_HofMonitor,
.images = sPicTable_HofMonitorSmall, .images = sPicTable_HofMonitorSmall,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_HallOfFameMonitor .callback = SpriteCB_HallOfFameMonitor

View File

@ -16,7 +16,6 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/map_types.h" #include "constants/map_types.h"
// structures
struct FlashStruct struct FlashStruct
{ {
u8 fromType; u8 fromType;
@ -26,7 +25,6 @@ struct FlashStruct
void (*func)(void); void (*func)(void);
}; };
// static functions
static void FieldCallback_Flash(void); static void FieldCallback_Flash(void);
static void FldEff_UseFlash(void); static void FldEff_UseFlash(void);
static bool8 TryDoMapTransition(void); static bool8 TryDoMapTransition(void);
@ -42,7 +40,6 @@ static void Task_EnterCaveTransition2(u8 taskId);
static void Task_EnterCaveTransition3(u8 taskId); static void Task_EnterCaveTransition3(u8 taskId);
static void Task_EnterCaveTransition4(u8 taskId); static void Task_EnterCaveTransition4(u8 taskId);
// rodata
static const struct FlashStruct sTransitionTypes[] = static const struct FlashStruct sTransitionTypes[] =
{ {
{MAP_TYPE_TOWN, MAP_TYPE_UNDERGROUND, TRUE, FALSE, DoEnterCaveTransition}, {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 sCaveTransitionPalette_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_Black[] = INCBIN_U16("graphics/misc/cave_transition_black.gbapal");
static const u16 gUnknown_085B2890[] = INCBIN_U16("graphics/misc/85B2890.gbapal"); static const u16 sCaveTransitionPalette_Enter[] = INCBIN_U16("graphics/misc/cave_transition_enter.gbapal");
static const u16 gUnknown_085B28A0[] = INCBIN_U16("graphics/misc/85B28A0.gbapal"); static const u16 sCaveTransitionPalette_Exit[] = INCBIN_U16("graphics/misc/cave_transition_exit.gbapal");
static const u32 gCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz"); static const u32 sCaveTransitionTilemap[] = INCBIN_U32("graphics/misc/cave_transition_map.bin.lz");
static const u32 gCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz"); static const u32 sCaveTransitionTiles[] = INCBIN_U32("graphics/misc/cave_transition.4bpp.lz");
// text
bool8 SetUpFieldMove_Flash(void) bool8 SetUpFieldMove_Flash(void)
{ {
// In Ruby and Sapphire, Registeel's tomb is opened by using Fly. In Emerald, // 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) static void Task_ExitCaveTransition2(u8 taskId)
{ {
SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_DISPCNT, 0);
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20);
LoadPalette(gUnknown_085B28A0, 0xE0, 0x10); LoadPalette(sCaveTransitionPalette_Exit, 0xE0, 0x10);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0
| BLDCNT_EFFECT_BLEND | BLDCNT_EFFECT_BLEND
| BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG1
@ -274,11 +270,11 @@ static void Task_ExitCaveTransition4(u8 taskId)
if (count < 8) if (count < 8)
{ {
gTasks[taskId].data[2]++; gTasks[taskId].data[2]++;
LoadPalette(&gUnknown_085B28A0[count], 0xE0, 16 - 2 * count); LoadPalette(&sCaveTransitionPalette_Exit[count], 0xE0, 16 - 2 * count);
} }
else else
{ {
LoadPalette(gCaveTransitionPalette_White, 0, 0x20); LoadPalette(sCaveTransitionPalette_White, 0, 0x20);
gTasks[taskId].func = Task_ExitCaveTransition5; gTasks[taskId].func = Task_ExitCaveTransition5;
gTasks[taskId].data[2] = 8; gTasks[taskId].data[2] = 8;
} }
@ -305,8 +301,8 @@ static void Task_EnterCaveTransition1(u8 taskId)
static void Task_EnterCaveTransition2(u8 taskId) static void Task_EnterCaveTransition2(u8 taskId)
{ {
SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_DISPCNT, 0);
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000)); LZ77UnCompVram(sCaveTransitionTiles, (void *)(VRAM + 0xC000));
LZ77UnCompVram(gCaveTransitionTilemap, (void *)(VRAM + 0xF800)); LZ77UnCompVram(sCaveTransitionTilemap, (void *)(VRAM + 0xF800));
SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDY, 0);
@ -319,8 +315,8 @@ static void Task_EnterCaveTransition2(u8 taskId)
| DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_1D_MAP
| DISPCNT_BG0_ON | DISPCNT_BG0_ON
| DISPCNT_OBJ_ON); | DISPCNT_OBJ_ON);
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20); LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20);
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); LoadPalette(sCaveTransitionPalette_Black, 0, 0x20);
gTasks[taskId].func = Task_EnterCaveTransition3; gTasks[taskId].func = Task_EnterCaveTransition3;
gTasks[taskId].data[0] = 16; gTasks[taskId].data[0] = 16;
gTasks[taskId].data[1] = 0; gTasks[taskId].data[1] = 0;
@ -335,7 +331,7 @@ static void Task_EnterCaveTransition3(u8 taskId)
{ {
gTasks[taskId].data[2]++; gTasks[taskId].data[2]++;
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 else
{ {
@ -363,7 +359,7 @@ static void Task_EnterCaveTransition4(u8 taskId)
} }
else else
{ {
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20); LoadPalette(sCaveTransitionPalette_Black, 0, 0x20);
SetMainCallback2(gMain.savedCallback); SetMainCallback2(gMain.savedCallback);
} }
} }