Specify confetti util name

This commit is contained in:
GriffinR 2020-06-18 18:14:30 -04:00
parent d2a760afdb
commit 8b462f3f6c
6 changed files with 67 additions and 67 deletions

33
include/confetti_util.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef GUARD_CONFETTI_UTIL_H
#define GUARD_CONFETTI_UTIL_H
struct ConfettiUtil
{
struct OamData oam;
s16 x;
s16 y;
s16 xDelta;
s16 yDelta;
u16 tileTag;
u16 palTag;
u16 tileNum;
u8 id;
u8 filler;
u8 animNum;
u8 active:1;
u8 allowUpdates:1;
u8 dummied:1;
u8 priority:2;
s16 data[8];
void (*callback)(struct ConfettiUtil *);
};
bool32 ConfettiUtil_Init(u8 count);
bool32 ConfettiUtil_Free(void);
bool32 ConfettiUtil_Update(void);
u8 ConfettiUtil_SetCallback(u8 id, void (*func)(struct ConfettiUtil *));
u8 ConfettiUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue);
u8 ConfettiUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority);
u8 ConfettiUtil_Remove(u8 id);
#endif // GUARD_CONFETTI_UTIL_H

View File

@ -1,33 +0,0 @@
#ifndef GUARD_OAM_UTIL_H
#define GUARD_OAM_UTIL_H
struct OamUtil
{
struct OamData oam;
s16 x;
s16 y;
s16 xDelta;
s16 yDelta;
u16 tileTag;
u16 palTag;
u16 tileNum;
u8 id;
u8 filler;
u8 animNum;
u8 active:1;
u8 allowUpdates:1;
u8 dummied:1;
u8 priority:2;
s16 data[8];
void (*callback)(struct OamUtil *);
};
bool32 OamUtil_Init(u8 count);
bool32 OamUtil_Free(void);
bool32 OamUtil_Update(void);
u8 OamUtil_SetCallback(u8 id, void (*func)(struct OamUtil *));
u8 OamUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue);
u8 OamUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority);
u8 OamUtil_Remove(u8 id);
#endif // GUARD_OAM_UTIL_H

View File

@ -237,7 +237,7 @@ SECTIONS {
src/cable_car.o(.text); src/cable_car.o(.text);
src/math_util.o(.text); src/math_util.o(.text);
src/roulette_util.o(.text); src/roulette_util.o(.text);
src/oam_util.o(.text); src/confetti_util.o(.text);
src/save.o(.text); src/save.o(.text);
src/mystery_event_script.o(.text); src/mystery_event_script.o(.text);
src/field_effect_helpers.o(.text); src/field_effect_helpers.o(.text);

View File

@ -1,5 +1,5 @@
#include "global.h" #include "global.h"
#include "oam_util.h" #include "confetti_util.h"
#include "malloc.h" #include "malloc.h"
#include "main.h" #include "main.h"
#include "digit_obj_util.h" #include "digit_obj_util.h"
@ -7,7 +7,7 @@
static EWRAM_DATA struct static EWRAM_DATA struct
{ {
u8 count; u8 count;
struct OamUtil *array; struct ConfettiUtil *array;
} *sWork = NULL; } *sWork = NULL;
static void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused. static void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused.
@ -47,7 +47,7 @@ static void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u
} }
} }
bool32 OamUtil_Init(u8 count) bool32 ConfettiUtil_Init(u8 count)
{ {
u8 i = 0; u8 i = 0;
@ -59,7 +59,7 @@ bool32 OamUtil_Init(u8 count)
sWork = AllocZeroed(sizeof(*sWork)); sWork = AllocZeroed(sizeof(*sWork));
if (sWork == NULL) if (sWork == NULL)
return FALSE; return FALSE;
sWork->array = AllocZeroed(count * sizeof(struct OamUtil)); sWork->array = AllocZeroed(count * sizeof(struct ConfettiUtil));
if (sWork->array == NULL) if (sWork->array == NULL)
{ {
FREE_AND_SET_NULL(sWork); FREE_AND_SET_NULL(sWork);
@ -76,7 +76,7 @@ bool32 OamUtil_Init(u8 count)
return TRUE; return TRUE;
} }
bool32 OamUtil_Free(void) bool32 ConfettiUtil_Free(void)
{ {
u8 i = 0; u8 i = 0;
@ -86,7 +86,7 @@ bool32 OamUtil_Free(void)
for (i = 0; i < sWork->count; i++) for (i = 0; i < sWork->count; i++)
memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData)); memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
memset(sWork->array, 0, sWork->count * sizeof(struct OamUtil)); memset(sWork->array, 0, sWork->count * sizeof(struct ConfettiUtil));
FREE_AND_SET_NULL(sWork->array); FREE_AND_SET_NULL(sWork->array);
memset(sWork, 0, sizeof(*sWork)); memset(sWork, 0, sizeof(*sWork));
FREE_AND_SET_NULL(sWork); FREE_AND_SET_NULL(sWork);
@ -94,7 +94,7 @@ bool32 OamUtil_Free(void)
return TRUE; return TRUE;
} }
bool32 OamUtil_Update(void) bool32 ConfettiUtil_Update(void)
{ {
u8 i = 0; u8 i = 0;
@ -126,7 +126,7 @@ bool32 OamUtil_Update(void)
return TRUE; return TRUE;
} }
static bool32 SetAnimAndTileNum(struct OamUtil *structPtr, u8 animNum) static bool32 SetAnimAndTileNum(struct ConfettiUtil *structPtr, u8 animNum)
{ {
u16 tileStart; u16 tileStart;
@ -142,7 +142,7 @@ static bool32 SetAnimAndTileNum(struct OamUtil *structPtr, u8 animNum)
return TRUE; return TRUE;
} }
u8 OamUtil_SetCallback(u8 id, void (*func)(struct OamUtil *)) u8 ConfettiUtil_SetCallback(u8 id, void (*func)(struct ConfettiUtil *))
{ {
if (sWork == NULL || id >= sWork->count) if (sWork == NULL || id >= sWork->count)
return 0xFF; return 0xFF;
@ -153,7 +153,7 @@ u8 OamUtil_SetCallback(u8 id, void (*func)(struct OamUtil *))
return id; return id;
} }
u8 OamUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue) u8 ConfettiUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue)
{ {
if (sWork == NULL || id >= sWork->count) if (sWork == NULL || id >= sWork->count)
return 0xFF; return 0xFF;
@ -164,9 +164,9 @@ u8 OamUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue)
return id; return id;
} }
u8 OamUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority) u8 ConfettiUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority)
{ {
struct OamUtil *structPtr = NULL; struct ConfettiUtil *structPtr = NULL;
u8 i; u8 i;
if (sWork == NULL || oam == NULL) if (sWork == NULL || oam == NULL)
@ -204,12 +204,12 @@ u8 OamUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16
return structPtr->id; return structPtr->id;
} }
u8 OamUtil_Remove(u8 id) u8 ConfettiUtil_Remove(u8 id)
{ {
if (sWork == NULL || !sWork->array[id].active) if (sWork == NULL || !sWork->array[id].active)
return 0xFF; return 0xFF;
memset(&sWork->array[id], 0, sizeof(struct OamUtil)); memset(&sWork->array[id], 0, sizeof(struct ConfettiUtil));
sWork->array[id].oam.y = 160; sWork->array[id].oam.y = 160;
sWork->array[id].oam.x = 240; sWork->array[id].oam.x = 240;
sWork->array[id].dummied = TRUE; sWork->array[id].dummied = TRUE;

View File

@ -33,7 +33,7 @@
#include "fldeff_misc.h" #include "fldeff_misc.h"
#include "trainer_pokemon_sprites.h" #include "trainer_pokemon_sprites.h"
#include "data.h" #include "data.h"
#include "oam_util.h" #include "confetti_util.h"
#include "constants/rgb.h" #include "constants/rgb.h"
#define HALL_OF_FAME_MAX_TEAMS 50 #define HALL_OF_FAME_MAX_TEAMS 50
@ -1423,7 +1423,7 @@ static bool8 CreateHofConfettiSprite(void)
#define tTimer data[1] #define tTimer data[1]
#define tConfettiCount data[15] #define tConfettiCount data[15]
// Indexes into the data array of the struct OamUtil tracking confetti // Indexes into the data array of the struct ConfettiUtil
#define CONFETTI_SINE_IDX 0 #define CONFETTI_SINE_IDX 0
#define CONFETTI_EXTRA_Y 1 #define CONFETTI_EXTRA_Y 1
#define CONFETTI_TASK_ID 7 #define CONFETTI_TASK_ID 7
@ -1448,18 +1448,18 @@ static void StopDomeConfetti(void)
if ((taskId = FindTaskIdByFunc(Task_DoDomeConfetti)) != 0xFF) if ((taskId = FindTaskIdByFunc(Task_DoDomeConfetti)) != 0xFF)
DestroyTask(taskId); DestroyTask(taskId);
OamUtil_Free(); ConfettiUtil_Free();
FreeSpriteTilesByTag(TAG_CONFETTI); FreeSpriteTilesByTag(TAG_CONFETTI);
FreeSpritePaletteByTag(TAG_CONFETTI); FreeSpritePaletteByTag(TAG_CONFETTI);
} }
static void UpdateDomeConfetti(struct OamUtil *oamUtil) static void UpdateDomeConfetti(struct ConfettiUtil *util)
{ {
if (oamUtil->yDelta > 110) if (util->yDelta > 110)
{ {
// Destroy confetti after it falls far enough // Destroy confetti after it falls far enough
gTasks[oamUtil->data[CONFETTI_TASK_ID]].tConfettiCount--; gTasks[util->data[CONFETTI_TASK_ID]].tConfettiCount--;
OamUtil_Remove(oamUtil->id); ConfettiUtil_Remove(util->id);
} }
else else
{ {
@ -1467,16 +1467,16 @@ static void UpdateDomeConfetti(struct OamUtil *oamUtil)
u8 sineIdx; u8 sineIdx;
s32 rand; s32 rand;
oamUtil->yDelta++; util->yDelta++;
oamUtil->yDelta += oamUtil->data[CONFETTI_EXTRA_Y]; util->yDelta += util->data[CONFETTI_EXTRA_Y];
sineIdx = oamUtil->data[CONFETTI_SINE_IDX]; sineIdx = util->data[CONFETTI_SINE_IDX];
rand = Random(); rand = Random();
rand &= 3; rand &= 3;
rand += 8; rand += 8;
oamUtil->xDelta = (rand) * ((gSineTable[sineIdx])) / 256; util->xDelta = (rand) * ((gSineTable[sineIdx])) / 256;
oamUtil->data[CONFETTI_SINE_IDX] += 4; util->data[CONFETTI_SINE_IDX] += 4;
} }
} }
@ -1488,7 +1488,7 @@ static void Task_DoDomeConfetti(u8 taskId)
switch (tState) switch (tState)
{ {
case 0: case 0:
if (!OamUtil_Init(64)) if (!ConfettiUtil_Init(64))
{ {
// Init failed // Init failed
DestroyTask(taskId); DestroyTask(taskId);
@ -1503,7 +1503,7 @@ static void Task_DoDomeConfetti(u8 taskId)
if (tTimer != 0 && tTimer % 3 == 0) if (tTimer != 0 && tTimer % 3 == 0)
{ {
// Create new confetti every 3 frames // Create new confetti every 3 frames
id = OamUtil_AddNew(&sOamData_Confetti, id = ConfettiUtil_AddNew(&sOamData_Confetti,
TAG_CONFETTI, TAG_CONFETTI,
TAG_CONFETTI, TAG_CONFETTI,
Random() % 240, Random() % 240,
@ -1512,18 +1512,18 @@ static void Task_DoDomeConfetti(u8 taskId)
id); id);
if (id != 0xFF) if (id != 0xFF)
{ {
OamUtil_SetCallback(id, UpdateDomeConfetti); ConfettiUtil_SetCallback(id, UpdateDomeConfetti);
// 1/4 of the confetti move an extra y coord every frame // 1/4 of the confetti move an extra y coord every frame
if ((Random() % 4) == 0) if ((Random() % 4) == 0)
OamUtil_SetData(id, CONFETTI_EXTRA_Y, 1); ConfettiUtil_SetData(id, CONFETTI_EXTRA_Y, 1);
OamUtil_SetData(id, CONFETTI_TASK_ID, taskId); ConfettiUtil_SetData(id, CONFETTI_TASK_ID, taskId);
tConfettiCount++; tConfettiCount++;
} }
} }
OamUtil_Update(); ConfettiUtil_Update();
if (tTimer != 0) if (tTimer != 0)
tTimer--; tTimer--;
else if (tConfettiCount == 0) else if (tConfettiCount == 0)

View File

@ -103,7 +103,7 @@
.include "src/battle_transition.o" .include "src/battle_transition.o"
.include "src/battle_message.o" .include "src/battle_message.o"
.include "src/cable_car.o" .include "src/cable_car.o"
.include "src/oam_util.o" .include "src/confetti_util.o"
.include "src/save.o" .include "src/save.o"
.include "src/mystery_event_script.o" .include "src/mystery_event_script.o"
.include "src/move_relearner.o" .include "src/move_relearner.o"