decompile cable car util which has nothing to do with actual cable car

This commit is contained in:
DizzyEggg
2018-09-15 13:50:23 +02:00
parent b8c9d9a980
commit ff13cb6352
9 changed files with 270 additions and 814 deletions

View File

@@ -29,6 +29,7 @@
#include "menu.h"
#include "trainer_pokemon_sprites.h"
#include "data2.h"
#include "rom_81520A8.h"
struct HallofFameMon
{
@@ -91,13 +92,6 @@ extern void sub_80F9BCC(u16, u16, u8);
extern bool8 sub_80F9C1C(void);
extern void sub_81971D0(void);
extern void sub_8197200(void);
extern void sub_8152254(void);
extern void sub_81525D0(u8);
extern void sub_8152438(u8, void*);
extern void sub_8152474(u8, u8, u8);
extern void sub_81522D4(void);
extern bool32 sub_81521C0(u8);
extern u8 sub_81524C4(const struct OamData *arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, u8 arg5, s16 arg6);
// this file's functions
static void ClearVramOamPltt_LoadHofPal(void);
@@ -1444,53 +1438,28 @@ static void sub_81752C0(void)
FreeSpritePaletteByTag(0x3E9);
}
struct UnknownStruct912B4
static void sub_81752F4(struct UnkStruct_81520A8 *structPtr)
{
s16 field_0;
s16 field_2;
s16 field_4;
s16 field_6;
s16 field_8;
s16 field_A;
s16 field_C;
s16 field_E;
s16 field_10;
s16 field_12;
s16 field_14;
s16 field_16;
s16 field_18;
s16 field_1A;
s16 field_1C;
s16 field_1E;
s16 field_20;
s16 field_22;
s16 field_24;
s16 field_26;
s16 field_28;
};
static void sub_81752F4(struct UnknownStruct912B4 *unkStruct)
{
if (unkStruct->field_E > 110)
if (structPtr->yDelta > 110)
{
gTasks[unkStruct->field_28].data[15]--;
sub_81525D0(unkStruct->field_16);
gTasks[structPtr->data[7]].data[15]--;
sub_81525D0(structPtr->id);
}
else
{
u8 var;
s32 rand;
unkStruct->field_E++;
unkStruct->field_E += unkStruct->field_1C;
structPtr->yDelta++;
structPtr->yDelta += structPtr->data[1];
var = unkStruct->field_1A;
var = structPtr->data[0];
rand = Random();
rand &= 3;
rand += 8;
unkStruct->field_C = (rand) * ((gSineTable[var])) / 256;
structPtr->xDelta = (rand) * ((gSineTable[var])) / 256;
unkStruct->field_1A += 4;
structPtr->data[0] += 4;
}
}

View File

@@ -431,9 +431,9 @@ static bool32 SharesPalWithAnyActive(u32 id)
return FALSE;
}
u8 sub_80355F8(u32 arg0, u32 arg1)
u8 sub_80355F8(u32 shape, u32 size)
{
return gUnknown_082FF1C8[arg0][arg1];
return gUnknown_082FF1C8[shape][size];
}
static void sub_8035608(void)

218
src/rom_81520A8.c Normal file
View File

@@ -0,0 +1,218 @@
#include "global.h"
#include "rom_81520A8.h"
#include "malloc.h"
#include "main.h"
#include "rom_8034C54.h"
static EWRAM_DATA struct
{
u8 count;
struct UnkStruct_81520A8 *unk4;
} *sUnknown_0203ABB8 = NULL;
void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused.
{
u8 i;
u8 j;
u8 x;
u8 y;
for (i = 0, y = top; i < height; i++)
{
for (x = left, j = 0; j < width; j++)
{
*(u16 *)((dest) + (y * 64 + x * 2)) = value;
x = (x + 1) % 32;
}
y = (y + 1) % 32;
}
}
void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
{
u8 i;
u8 j;
u8 x;
u8 y;
const u16 *_src;
for (i = 0, _src = src, y = top; i < height; i++)
{
for (x = left, j = 0; j < width; j++)
{
*(u16 *)((dest) + (y * 64 + x * 2)) = *(_src++);
x = (x + 1) % 32;
}
y = (y + 1) % 32;
}
}
bool32 sub_81521C0(u8 count)
{
u8 i = 0;
if (count == 0)
return FALSE;
if (count > 64)
count = 64;
sUnknown_0203ABB8 = AllocZeroed(sizeof(*sUnknown_0203ABB8));
if (sUnknown_0203ABB8 == NULL)
return FALSE;
sUnknown_0203ABB8->unk4 = AllocZeroed(count * sizeof(struct UnkStruct_81520A8));
if (sUnknown_0203ABB8->unk4 == NULL)
{
FREE_AND_SET_NULL(sUnknown_0203ABB8);
return FALSE;
}
sUnknown_0203ABB8->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;
}
return TRUE;
}
bool32 sub_8152254(void)
{
u8 i = 0;
if (sUnknown_0203ABB8 == NULL)
return FALSE;
for (i = 0; i < sUnknown_0203ABB8->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);
return TRUE;
}
bool32 sub_81522D4(void)
{
u8 i = 0;
if (sUnknown_0203ABB8 == NULL || sUnknown_0203ABB8->unk4 == NULL)
return FALSE;
for (i = 0; i < sUnknown_0203ABB8->count; i++)
{
if (sUnknown_0203ABB8->unk4[i].unk19_0 && sUnknown_0203ABB8->unk4[i].unk19_1)
{
if (sUnknown_0203ABB8->unk4[i].callback != NULL)
sUnknown_0203ABB8->unk4[i].callback(&sUnknown_0203ABB8->unk4[i]);
if (sUnknown_0203ABB8->unk4[i].unk19_2)
{
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));
}
}
}
return TRUE;
}
static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
{
u16 tileStart;
if (structPtr == NULL)
return FALSE;
tileStart = GetSpriteTileStartByTag(structPtr->tileTag);
if (tileStart == 0xFFFF)
return FALSE;
structPtr->unk18 = arg1;
structPtr->tileNum = (sub_80355F8(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart;
return TRUE;
}
u8 sub_8152438(u8 id, void (*func)(struct UnkStruct_81520A8 *))
{
if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
return 0xFF;
else if (!sUnknown_0203ABB8->unk4[id].unk19_0)
return 0xFF;
sUnknown_0203ABB8->unk4[id].callback = func;
return id;
}
u8 sub_8152474(u8 id, u8 dataArrayId, s16 dataValue)
{
if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
return 0xFF;
else if (!sUnknown_0203ABB8->unk4[id].unk19_0 || dataArrayId >= ARRAY_COUNT(sUnknown_0203ABB8->unk4[id].data))
return 0xFF;
sUnknown_0203ABB8->unk4[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)
{
struct UnkStruct_81520A8 *structPtr = NULL;
u8 i;
if (sUnknown_0203ABB8 == NULL || oam == NULL)
return 0xFF;
for (i = 0; i < sUnknown_0203ABB8->count; i++)
{
if (!sUnknown_0203ABB8->unk4[i].unk19_0)
{
structPtr = &sUnknown_0203ABB8->unk4[i];
memset(structPtr, 0, sizeof(*structPtr));
structPtr->id = i;
structPtr->unk19_0 = TRUE;
structPtr->unk19_1 = TRUE;
break;
}
}
if (structPtr == NULL)
return 0xFF;
memcpy(&structPtr->oam, oam, sizeof(*oam));
structPtr->tileTag = tileTag;
structPtr->palTag = palTag;
structPtr->x = x;
structPtr->y = y;
structPtr->oam.paletteNum = IndexOfSpritePaletteTag(palTag);
if (priority < 4)
{
structPtr->priority = priority;
structPtr->oam.priority = priority;
}
sub_81523F4(structPtr, arg5);
return structPtr->id;
}
u8 sub_81525D0(u8 id)
{
if (sUnknown_0203ABB8 == NULL || !sUnknown_0203ABB8->unk4[id].unk19_0)
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;
memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData));
return id;
}