summaryrefslogtreecommitdiff
path: root/src/rom_81520A8.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rom_81520A8.c')
-rw-r--r--src/rom_81520A8.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/src/rom_81520A8.c b/src/rom_81520A8.c
index 8b10d44d0..2c37d7d48 100644
--- a/src/rom_81520A8.c
+++ b/src/rom_81520A8.c
@@ -7,10 +7,10 @@
static EWRAM_DATA struct
{
u8 count;
- struct UnkStruct_81520A8 *unk4;
-} *sUnknown_0203ABB8 = NULL;
+ struct OamUtil *array;
+} *sWork = NULL;
-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.
{
u8 i;
u8 j;
@@ -28,7 +28,7 @@ void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) //
}
}
-void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
+static void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
{
u8 i;
u8 j;
@@ -47,7 +47,7 @@ void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 heigh
}
}
-bool32 sub_81521C0(u8 count)
+bool32 OamUtil_Init(u8 count)
{
u8 i = 0;
@@ -56,69 +56,69 @@ bool32 sub_81521C0(u8 count)
if (count > 64)
count = 64;
- sUnknown_0203ABB8 = AllocZeroed(sizeof(*sUnknown_0203ABB8));
- if (sUnknown_0203ABB8 == NULL)
+ sWork = AllocZeroed(sizeof(*sWork));
+ if (sWork == NULL)
return FALSE;
- sUnknown_0203ABB8->unk4 = AllocZeroed(count * sizeof(struct UnkStruct_81520A8));
- if (sUnknown_0203ABB8->unk4 == NULL)
+ sWork->array = AllocZeroed(count * sizeof(struct OamUtil));
+ if (sWork->array == NULL)
{
- FREE_AND_SET_NULL(sUnknown_0203ABB8);
+ FREE_AND_SET_NULL(sWork);
return FALSE;
}
- sUnknown_0203ABB8->count = count;
+ sWork->count = count;
for (i = 0; i < count; i++)
{
- memcpy(&sUnknown_0203ABB8->unk4[i].oam, &gDummyOamData, sizeof(struct OamData));
- sUnknown_0203ABB8->unk4[i].unk19_2 = TRUE;
+ memcpy(&sWork->array[i].oam, &gDummyOamData, sizeof(struct OamData));
+ sWork->array[i].dummied = TRUE;
}
return TRUE;
}
-bool32 sub_8152254(void)
+bool32 OamUtil_Free(void)
{
u8 i = 0;
- if (sUnknown_0203ABB8 == NULL)
+ if (sWork == NULL)
return FALSE;
- for (i = 0; i < sUnknown_0203ABB8->count; i++)
+ for (i = 0; i < sWork->count; i++)
memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
- memset(sUnknown_0203ABB8->unk4, 0, sUnknown_0203ABB8->count * sizeof(struct UnkStruct_81520A8));
- FREE_AND_SET_NULL(sUnknown_0203ABB8->unk4);
- memset(sUnknown_0203ABB8, 0, sizeof(*sUnknown_0203ABB8));
- FREE_AND_SET_NULL(sUnknown_0203ABB8);
+ memset(sWork->array, 0, sWork->count * sizeof(struct OamUtil));
+ FREE_AND_SET_NULL(sWork->array);
+ memset(sWork, 0, sizeof(*sWork));
+ FREE_AND_SET_NULL(sWork);
return TRUE;
}
-bool32 sub_81522D4(void)
+bool32 OamUtil_Update(void)
{
u8 i = 0;
- if (sUnknown_0203ABB8 == NULL || sUnknown_0203ABB8->unk4 == NULL)
+ if (sWork == NULL || sWork->array == NULL)
return FALSE;
- for (i = 0; i < sUnknown_0203ABB8->count; i++)
+ for (i = 0; i < sWork->count; i++)
{
- if (sUnknown_0203ABB8->unk4[i].unk19_0 && sUnknown_0203ABB8->unk4[i].unk19_1)
+ if (sWork->array[i].active && sWork->array[i].allowUpdates)
{
- if (sUnknown_0203ABB8->unk4[i].callback != NULL)
- sUnknown_0203ABB8->unk4[i].callback(&sUnknown_0203ABB8->unk4[i]);
+ if (sWork->array[i].callback != NULL)
+ sWork->array[i].callback(&sWork->array[i]);
- if (sUnknown_0203ABB8->unk4[i].unk19_2)
+ if (sWork->array[i].dummied)
{
memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
}
else
{
- sUnknown_0203ABB8->unk4[i].oam.y = sUnknown_0203ABB8->unk4[i].y + sUnknown_0203ABB8->unk4[i].yDelta;
- sUnknown_0203ABB8->unk4[i].oam.x = sUnknown_0203ABB8->unk4[i].x + sUnknown_0203ABB8->unk4[i].xDelta;
- sUnknown_0203ABB8->unk4[i].oam.priority = sUnknown_0203ABB8->unk4[i].priority;
- sUnknown_0203ABB8->unk4[i].oam.tileNum = sUnknown_0203ABB8->unk4[i].tileNum;
- memcpy(&gMain.oamBuffer[i + 64], &sUnknown_0203ABB8->unk4[i], sizeof(struct OamData));
+ sWork->array[i].oam.y = sWork->array[i].y + sWork->array[i].yDelta;
+ sWork->array[i].oam.x = sWork->array[i].x + sWork->array[i].xDelta;
+ sWork->array[i].oam.priority = sWork->array[i].priority;
+ sWork->array[i].oam.tileNum = sWork->array[i].tileNum;
+ memcpy(&gMain.oamBuffer[i + 64], &sWork->array[i], sizeof(struct OamData));
}
}
}
@@ -126,7 +126,7 @@ bool32 sub_81522D4(void)
return TRUE;
}
-static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
+static bool32 SetAnimAndTileNum(struct OamUtil *structPtr, u8 animNum)
{
u16 tileStart;
@@ -137,50 +137,50 @@ static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
if (tileStart == 0xFFFF)
return FALSE;
- structPtr->unk18 = arg1;
- structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart;
+ structPtr->animNum = animNum;
+ structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * animNum) + tileStart;
return TRUE;
}
-u8 sub_8152438(u8 id, void (*func)(struct UnkStruct_81520A8 *))
+u8 OamUtil_SetCallback(u8 id, void (*func)(struct OamUtil *))
{
- if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
+ if (sWork == NULL || id >= sWork->count)
return 0xFF;
- else if (!sUnknown_0203ABB8->unk4[id].unk19_0)
+ else if (!sWork->array[id].active)
return 0xFF;
- sUnknown_0203ABB8->unk4[id].callback = func;
+ sWork->array[id].callback = func;
return id;
}
-u8 sub_8152474(u8 id, u8 dataArrayId, s16 dataValue)
+u8 OamUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue)
{
- if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
+ if (sWork == NULL || id >= sWork->count)
return 0xFF;
- else if (!sUnknown_0203ABB8->unk4[id].unk19_0 || dataArrayId >= ARRAY_COUNT(sUnknown_0203ABB8->unk4[id].data))
+ else if (!sWork->array[id].active || dataArrayId > ARRAY_COUNT(sWork->array[id].data) - 1) // - 1 b/c last slot is reserved for taskId
return 0xFF;
- sUnknown_0203ABB8->unk4[id].data[dataArrayId] = dataValue;
+ sWork->array[id].data[dataArrayId] = dataValue;
return id;
}
-u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 arg5, u8 priority)
+u8 OamUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority)
{
- struct UnkStruct_81520A8 *structPtr = NULL;
+ struct OamUtil *structPtr = NULL;
u8 i;
- if (sUnknown_0203ABB8 == NULL || oam == NULL)
+ if (sWork == NULL || oam == NULL)
return 0xFF;
- for (i = 0; i < sUnknown_0203ABB8->count; i++)
+ for (i = 0; i < sWork->count; i++)
{
- if (!sUnknown_0203ABB8->unk4[i].unk19_0)
+ if (!sWork->array[i].active)
{
- structPtr = &sUnknown_0203ABB8->unk4[i];
+ structPtr = &sWork->array[i];
memset(structPtr, 0, sizeof(*structPtr));
structPtr->id = i;
- structPtr->unk19_0 = TRUE;
- structPtr->unk19_1 = TRUE;
+ structPtr->active = TRUE;
+ structPtr->allowUpdates = TRUE;
break;
}
}
@@ -199,20 +199,20 @@ u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y,
structPtr->priority = priority;
structPtr->oam.priority = priority;
}
- sub_81523F4(structPtr, arg5);
+ SetAnimAndTileNum(structPtr, animNum);
return structPtr->id;
}
-u8 sub_81525D0(u8 id)
+u8 OamUtil_Remove(u8 id)
{
- if (sUnknown_0203ABB8 == NULL || !sUnknown_0203ABB8->unk4[id].unk19_0)
+ if (sWork == NULL || !sWork->array[id].active)
return 0xFF;
- memset(&sUnknown_0203ABB8->unk4[id], 0, sizeof(struct UnkStruct_81520A8));
- sUnknown_0203ABB8->unk4[id].oam.y = 160;
- sUnknown_0203ABB8->unk4[id].oam.x = 240;
- sUnknown_0203ABB8->unk4[id].unk19_2 = TRUE;
+ memset(&sWork->array[id], 0, sizeof(struct OamUtil));
+ sWork->array[id].oam.y = 160;
+ sWork->array[id].oam.x = 240;
+ sWork->array[id].dummied = TRUE;
memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData));
return id;
}