sovereignx/src/secret_base.c

120 lines
2.1 KiB
C
Raw Normal View History

2017-10-23 23:35:06 +01:00
// Includes
#include "global.h"
2017-10-23 23:56:18 +01:00
#include "list_menu.h"
2017-10-23 23:35:06 +01:00
#include "decoration.h"
#include "decoration_inventory.h"
2017-10-24 00:29:16 +01:00
#include "fieldmap.h"
#include "field_player_avatar.h"
2017-10-23 23:35:06 +01:00
#include "text.h"
2017-10-23 23:56:18 +01:00
#include "event_data.h"
2017-10-23 23:35:06 +01:00
#include "secret_base.h"
// Static type declarations
2017-10-23 23:56:18 +01:00
struct SecretBaseListMenuBuffer {
struct ListMenuItem items[11];
u8 names[11][32];
};
2017-10-23 23:35:06 +01:00
// Static RAM declarations
2017-10-24 00:21:08 +01:00
EWRAM_DATA u8 sCurSecretBaseId = 0;
2017-10-23 23:56:18 +01:00
EWRAM_DATA u8 gUnknown_0203A01D = 0;
EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL;
2017-10-23 23:35:06 +01:00
// Static ROM declarations
2017-10-24 00:29:16 +01:00
// .rodata
// .text
2017-10-23 23:35:06 +01:00
void sub_80E8AF0(struct SecretBaseRecord *sbr)
{
u16 i;
CpuFastFill16(0, sbr, sizeof(struct SecretBaseRecord));
for (i = 0; i < 7; i ++)
{
sbr->trainerName[i] = EOS;
}
}
2017-10-23 23:56:18 +01:00
void ResetSecretBases(void)
{
u16 i;
for (i = 0; i < 20; i ++)
{
sub_80E8AF0(&gSaveBlock1Ptr->secretBases[i]);
}
}
void sub_80E8B58(void)
{
2017-10-24 00:21:08 +01:00
sCurSecretBaseId = gSpecialVar_0x8004;
}
void sub_80E8B6C(void)
{
u16 i;
gScriptResult = FALSE;
for (i = 0; i < 20; i ++)
{
if (sCurSecretBaseId != gSaveBlock1Ptr->secretBases[i].secretBaseId)
{
continue;
}
gScriptResult = TRUE;
VarSet(VAR_0x4054, i);
break;
}
}
void sub_80E8BC8(void)
{
if (gSaveBlock1Ptr->secretBases[0].secretBaseId != 0)
{
gScriptResult = TRUE;
}
else
{
gScriptResult = FALSE;
}
2017-10-23 23:56:18 +01:00
}
2017-10-24 00:29:16 +01:00
u8 sub_80E8BF8(void)
{
s16 x;
s16 y;
s16 behavior;
2017-10-23 23:35:06 +01:00
2017-10-24 00:29:16 +01:00
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
behavior = MapGridGetMetatileBehaviorAt(x, y) & 0xFFF;
if (behavior == 0x90 || behavior == 0x91)
{
return 1;
}
if (behavior == 0x92 || behavior == 0x93)
{
return 2;
}
if (behavior == 0x9a || behavior == 0x9b)
{
return 3;
}
if (behavior == 0x94 || behavior == 0x95)
{
return 4;
}
if (behavior == 0x96 || behavior == 0x97 || behavior == 0x9c || behavior == 0x9d)
{
return 5;
}
if (behavior == 0x98 || behavior == 0x99)
{
return 6;
}
return 0;
}