Merge branch 'master' into contest
This commit is contained in:
@@ -394,7 +394,7 @@ static void DoStandardWildBattle(void)
|
||||
gBattleTypeFlags = 0;
|
||||
if (InBattlePyramid())
|
||||
{
|
||||
VarSet(VAR_0x400E, 0);
|
||||
VarSet(VAR_TEMP_E, 0);
|
||||
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
|
||||
}
|
||||
CreateBattleStartTask(GetWildBattleTransition(), 0);
|
||||
@@ -1258,7 +1258,7 @@ void BattleSetup_StartTrainerBattle(void)
|
||||
|
||||
if (InBattlePyramid())
|
||||
{
|
||||
VarSet(VAR_0x400E, 0);
|
||||
VarSet(VAR_TEMP_E, 0);
|
||||
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
|
||||
|
||||
if (gNoOfApproachingTrainers == 2)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "pokemon.h"
|
||||
#include "battle.h"
|
||||
#include "daycare.h"
|
||||
#include "string_util.h"
|
||||
#include "constants/species.h"
|
||||
@@ -22,8 +23,6 @@
|
||||
#define EGG_MOVES_ARRAY_COUNT 10
|
||||
#define EGG_LVL_UP_MOVES_ARRAY_COUNT 50
|
||||
|
||||
extern u16 gMoveToLearn;
|
||||
|
||||
// text
|
||||
extern const u8 gText_MaleSymbol4[];
|
||||
extern const u8 gText_FemaleSymbol4[];
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "list_menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "menu.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "sound.h"
|
||||
#include "event_scripts.h"
|
||||
#include "event_data.h"
|
||||
|
||||
@@ -353,7 +353,7 @@ static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u
|
||||
return slot;
|
||||
}
|
||||
#else
|
||||
static __attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId)
|
||||
static NAKED u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId)
|
||||
{
|
||||
asm_unified("\tpush {r4-r7,lr}\n"
|
||||
"\tmov r7, r9\n"
|
||||
|
||||
776
src/field_tasks.c
Normal file
776
src/field_tasks.c
Normal file
@@ -0,0 +1,776 @@
|
||||
#include "global.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "constants/vars.h"
|
||||
#include "bike.h"
|
||||
#include "item.h"
|
||||
#include "constants/items.h"
|
||||
#include "event_data.h"
|
||||
#include "overworld.h"
|
||||
#include "clock.h"
|
||||
#include "script.h"
|
||||
#include "field_special_scene.h"
|
||||
#include "field_effect_helpers.h"
|
||||
#include "secret_base.h"
|
||||
#include "metatile_behavior.h"
|
||||
#include "fieldmap.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "field_camera.h"
|
||||
#include "constants/songs.h"
|
||||
#include "sound.h"
|
||||
#include "field_tasks.h"
|
||||
|
||||
struct MetatileOffset
|
||||
{
|
||||
s8 x;
|
||||
s8 y;
|
||||
u16 tileId;
|
||||
};
|
||||
|
||||
// this file's functions
|
||||
static void DummyPerStepCallback(u8 taskId);
|
||||
static void PerStepCallback_8069F64(u8 taskId);
|
||||
static void PerStepCallback_8069AA0(u8 taskId);
|
||||
static void PerStepCallback_8069864(u8 taskId);
|
||||
static void PerStepCallback_8069DD4(u8 taskId);
|
||||
static void PerStepCallback_806A07C(u8 taskId);
|
||||
static void Task_MuddySlope(u8 taskId);
|
||||
|
||||
// const rom data
|
||||
static void (*const gUnknown_08510348[])(u8) =
|
||||
{
|
||||
DummyPerStepCallback,
|
||||
PerStepCallback_8069F64,
|
||||
PerStepCallback_8069AA0,
|
||||
PerStepCallback_8069864,
|
||||
PerStepCallback_8069DD4,
|
||||
EndTruckSequence,
|
||||
sub_80EA3E4,
|
||||
PerStepCallback_806A07C
|
||||
};
|
||||
|
||||
// they are in pairs but declared as 1D array
|
||||
static const struct MetatileOffset gUnknown_08510368[] =
|
||||
{
|
||||
{ 0, 0,0x259}, { 0, 1,0x261},
|
||||
{ 0, -1,0x259}, { 0, 0,0x261},
|
||||
{ 0, 0,0x252}, { 1, 0,0x253},
|
||||
{ -1, 0,0x252}, { 0, 0,0x253}
|
||||
};
|
||||
|
||||
static const struct MetatileOffset gUnknown_08510388[] =
|
||||
{
|
||||
{ 0, 0,0x25A}, { 0, 1,0x262},
|
||||
{ 0, -1,0x25A}, { 0, 0,0x262},
|
||||
{ 0, 0,0x254}, { 1, 0,0x255},
|
||||
{ -1, 0,0x254}, { 0, 0,0x255}
|
||||
};
|
||||
|
||||
static const struct MetatileOffset gUnknown_085103A8[] =
|
||||
{
|
||||
{ 0, 0,0x258}, { 0, 1,0x260},
|
||||
{ 0, -1,0x258}, { 0, 0,0x260},
|
||||
{ 0, 0,0x250}, { 1, 0,0x251},
|
||||
{ -1, 0,0x250}, { 0, 0,0x251}
|
||||
};
|
||||
|
||||
static const u16 gUnknown_085103C8[] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
VAR_TEMP_1,
|
||||
VAR_TEMP_2,
|
||||
VAR_TEMP_3,
|
||||
VAR_TEMP_4,
|
||||
0,
|
||||
0,
|
||||
VAR_TEMP_5,
|
||||
VAR_TEMP_6,
|
||||
VAR_TEMP_7,
|
||||
0,
|
||||
0,
|
||||
VAR_TEMP_8,
|
||||
VAR_TEMP_9,
|
||||
VAR_TEMP_A,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
static const u16 gUnknown_085103FC[] = {0xe8, 0xeb, 0xea, 0xe9};
|
||||
|
||||
// code
|
||||
static void Task_RunPerStepCallback(u8 taskId)
|
||||
{
|
||||
int idx = gTasks[taskId].data[0];
|
||||
gUnknown_08510348[idx](taskId);
|
||||
}
|
||||
|
||||
#define tState data[0]
|
||||
#define tAmbientCryState data[1]
|
||||
#define tAmbientCryDelay data[2]
|
||||
|
||||
static void RunTimeBasedEvents(s16 *data)
|
||||
{
|
||||
switch (tState)
|
||||
{
|
||||
case 0:
|
||||
if (gMain.vblankCounter1 & 0x1000)
|
||||
{
|
||||
DoTimeBasedEvents();
|
||||
tState++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (!(gMain.vblankCounter1 & 0x1000))
|
||||
{
|
||||
tState--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_RunTimeBasedEvents(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
{
|
||||
RunTimeBasedEvents(data);
|
||||
UpdateAmbientCry(&tAmbientCryState, &tAmbientCryDelay);
|
||||
}
|
||||
}
|
||||
|
||||
#undef tState
|
||||
#undef tAmbientCryState
|
||||
#undef tAmbientCryDelay
|
||||
|
||||
void SetUpFieldTasks(void)
|
||||
{
|
||||
if (!FuncIsActiveTask(Task_RunPerStepCallback))
|
||||
{
|
||||
u8 taskId = CreateTask(Task_RunPerStepCallback, 0x50);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
}
|
||||
if (!FuncIsActiveTask(Task_MuddySlope))
|
||||
{
|
||||
CreateTask(Task_MuddySlope, 0x50);
|
||||
}
|
||||
if (!FuncIsActiveTask(Task_RunTimeBasedEvents))
|
||||
{
|
||||
CreateTask(Task_RunTimeBasedEvents, 0x50);
|
||||
}
|
||||
}
|
||||
|
||||
void ActivatePerStepCallback(u8 callbackId)
|
||||
{
|
||||
u8 taskId = FindTaskIdByFunc(Task_RunPerStepCallback);
|
||||
if (taskId != 0xff)
|
||||
{
|
||||
s32 i;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
data[i] = 0;
|
||||
|
||||
if (callbackId >= ARRAY_COUNT(gUnknown_08510348))
|
||||
{
|
||||
data[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
data[0] = callbackId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResetFieldTasksArgs(void)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
|
||||
taskId = FindTaskIdByFunc(Task_RunPerStepCallback);
|
||||
if (taskId != 0xff)
|
||||
{
|
||||
data = gTasks[taskId].data;
|
||||
}
|
||||
taskId = FindTaskIdByFunc(Task_RunTimeBasedEvents);
|
||||
if (taskId != 0xff)
|
||||
{
|
||||
data = gTasks[taskId].data;
|
||||
data[1] = 0;
|
||||
data[2] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void DummyPerStepCallback(u8 taskId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static const struct MetatileOffset *sub_809DA30(const struct MetatileOffset *offsets, u16 metatileBehavior)
|
||||
{
|
||||
if (MetatileBehavior_IsPacifilogVerticalLog1(metatileBehavior))
|
||||
return &offsets[0 * 2];
|
||||
else if (MetatileBehavior_IsPacifilogVerticalLog2(metatileBehavior))
|
||||
return &offsets[1 * 2];
|
||||
else if (MetatileBehavior_IsPacifilogHorizontalLog1(metatileBehavior))
|
||||
return &offsets[2 * 2];
|
||||
else if (MetatileBehavior_IsPacifilogHorizontalLog2(metatileBehavior))
|
||||
return &offsets[3 * 2];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sub_809DA88(const struct MetatileOffset *offsets, s16 x, s16 y, bool32 flag)
|
||||
{
|
||||
offsets = sub_809DA30(offsets, MapGridGetMetatileBehaviorAt(x, y));
|
||||
|
||||
if (offsets != NULL)
|
||||
{
|
||||
MapGridSetMetatileIdAt(x + offsets[0].x, y + offsets[0].y, offsets[0].tileId);
|
||||
if (flag)
|
||||
CurrentMapDrawMetatileAt(x + offsets[0].x, y + offsets[0].y);
|
||||
|
||||
MapGridSetMetatileIdAt(x + offsets[1].x, y + offsets[1].y, offsets[1].tileId);
|
||||
if (flag)
|
||||
CurrentMapDrawMetatileAt(x + offsets[1].x, y + offsets[1].y);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809DB10(s16 x, s16 y, bool32 flag)
|
||||
{
|
||||
sub_809DA88(gUnknown_08510368, x, y, flag);
|
||||
}
|
||||
|
||||
static void sub_809DB34(s16 x, s16 y, bool32 flag)
|
||||
{
|
||||
sub_809DA88(gUnknown_08510388, x, y, flag);
|
||||
}
|
||||
|
||||
static void sub_809DB58(s16 x, s16 y, bool32 flag)
|
||||
{
|
||||
sub_809DA88(gUnknown_085103A8, x, y, flag);
|
||||
}
|
||||
|
||||
static bool32 sub_809DB7C(s16 x1, s16 y1, s16 x2, s16 y2)
|
||||
{
|
||||
u16 metatileBehavior = MapGridGetMetatileBehaviorAt(x2, y2);
|
||||
|
||||
if (MetatileBehavior_IsPacifilogVerticalLog1(metatileBehavior))
|
||||
{
|
||||
if (y1 > y2)
|
||||
return FALSE;
|
||||
}
|
||||
else if (MetatileBehavior_IsPacifilogVerticalLog2(metatileBehavior))
|
||||
{
|
||||
if (y1 < y2)
|
||||
return FALSE;
|
||||
}
|
||||
else if (MetatileBehavior_IsPacifilogHorizontalLog1(metatileBehavior))
|
||||
{
|
||||
if (x1 > x2)
|
||||
return FALSE;
|
||||
}
|
||||
else if (MetatileBehavior_IsPacifilogHorizontalLog2(metatileBehavior))
|
||||
{
|
||||
if (x1 < x2)
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 sub_809DC18(s16 x1, s16 y1, s16 x2, s16 y2)
|
||||
{
|
||||
u16 metatileBehavior = MapGridGetMetatileBehaviorAt(x1, y1);
|
||||
|
||||
if (MetatileBehavior_IsPacifilogVerticalLog1(metatileBehavior))
|
||||
{
|
||||
if (y1 < y2)
|
||||
return FALSE;
|
||||
}
|
||||
else if (MetatileBehavior_IsPacifilogVerticalLog2(metatileBehavior))
|
||||
{
|
||||
if (y1 > y2)
|
||||
return FALSE;
|
||||
}
|
||||
else if (MetatileBehavior_IsPacifilogHorizontalLog1(metatileBehavior))
|
||||
{
|
||||
if (x1 < x2)
|
||||
return FALSE;
|
||||
}
|
||||
else if (MetatileBehavior_IsPacifilogHorizontalLog2(metatileBehavior))
|
||||
{
|
||||
if (x1 > x2)
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void PerStepCallback_8069864(u8 taskId)
|
||||
{
|
||||
s16 *data;
|
||||
s16 x, y;
|
||||
data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
switch (data[1])
|
||||
{
|
||||
case 0:
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
sub_809DB34(x, y, TRUE);
|
||||
data[1] = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (x != data[2] || y != data[3])
|
||||
{
|
||||
if (sub_809DB7C(x, y, data[2], data[3]))
|
||||
{
|
||||
sub_809DB10(data[2], data[3], TRUE);
|
||||
sub_809DB58(data[2], data[3], FALSE);
|
||||
data[4] = data[2];
|
||||
data[5] = data[3];
|
||||
data[1] = 2;
|
||||
data[6] = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
data[4] = -1;
|
||||
data[5] = -1;
|
||||
}
|
||||
if (sub_809DC18(x, y, data[2], data[3]))
|
||||
{
|
||||
sub_809DB10(x, y, TRUE);
|
||||
data[1] = 2;
|
||||
data[6] = 8;
|
||||
}
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
if (MetatileBehavior_IsPacifidlogLog(MapGridGetMetatileBehaviorAt(x, y)))
|
||||
{
|
||||
PlaySE(SE_MIZU);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ((--data[6]) == 0)
|
||||
{
|
||||
sub_809DB34(x, y, TRUE);
|
||||
if (data[4] != -1 && data[5] != -1)
|
||||
{
|
||||
sub_809DB58(data[4], data[5], TRUE);
|
||||
}
|
||||
data[1] = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809DE28(s16 x, s16 y)
|
||||
{
|
||||
u8 z = PlayerGetZCoord();
|
||||
if (!(z & 0x01))
|
||||
{
|
||||
switch (MapGridGetMetatileIdAt(x, y))
|
||||
{
|
||||
case 0x24e:
|
||||
MapGridSetMetatileIdAt(x, y, 0x24f);
|
||||
break;
|
||||
case 0x256:
|
||||
MapGridSetMetatileIdAt(x, y, 0x257);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809DE8C(s16 x, s16 y)
|
||||
{
|
||||
u8 z = PlayerGetZCoord();
|
||||
if (!(z & 0x01))
|
||||
{
|
||||
switch (MapGridGetMetatileIdAt(x, y))
|
||||
{
|
||||
case 0x24f:
|
||||
MapGridSetMetatileIdAt(x, y, 0x24e);
|
||||
break;
|
||||
case 0x257:
|
||||
MapGridSetMetatileIdAt(x, y, 0x256);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PerStepCallback_8069AA0(u8 taskId)
|
||||
{
|
||||
bool8 isFortreeBridgeCur;
|
||||
bool8 isFortreeBridgePrev;
|
||||
u8 z, flag;
|
||||
s16 x, y, x2, y2;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
switch (data[1])
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case 0:
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
if (MetatileBehavior_IsFortreeBridge(MapGridGetMetatileBehaviorAt(x, y)))
|
||||
{
|
||||
sub_809DE28(x, y);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
}
|
||||
data[1] = 1;
|
||||
break;
|
||||
case 1:
|
||||
x2 = data[2];
|
||||
y2 = data[3];
|
||||
if (x == x2 && y == y2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
isFortreeBridgeCur = MetatileBehavior_IsFortreeBridge(MapGridGetMetatileBehaviorAt(x, y));
|
||||
isFortreeBridgePrev = MetatileBehavior_IsFortreeBridge(MapGridGetMetatileBehaviorAt(x2, y2));
|
||||
z = PlayerGetZCoord();
|
||||
flag = 0;
|
||||
if ((u8)(z & 1) == 0)
|
||||
{
|
||||
flag = 1;
|
||||
}
|
||||
if (flag && (isFortreeBridgeCur == 1 || isFortreeBridgePrev == 1))
|
||||
{
|
||||
PlaySE(SE_HASHI);
|
||||
}
|
||||
if (isFortreeBridgePrev)
|
||||
{
|
||||
sub_809DE8C(x2, y2);
|
||||
CurrentMapDrawMetatileAt(x2, y2);
|
||||
sub_809DE28(x, y);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
}
|
||||
data[4] = x2;
|
||||
data[5] = y2;
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
if (!isFortreeBridgePrev)
|
||||
{
|
||||
break;
|
||||
}
|
||||
data[6] = 16;
|
||||
data[1] = 2;
|
||||
// fallthrough
|
||||
case 2:
|
||||
data[6]--;
|
||||
x2 = data[4];
|
||||
y2 = data[5];
|
||||
switch (data[6] % 7)
|
||||
{
|
||||
case 0:
|
||||
CurrentMapDrawMetatileAt(x2, y2);
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
sub_809DE28(x2, y2);
|
||||
CurrentMapDrawMetatileAt(x2, y2);
|
||||
sub_809DE8C(x2, y2);
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
break;
|
||||
}
|
||||
if (data[6] == 0)
|
||||
{
|
||||
data[1] = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool32 sub_809E108(s16 x, s16 y)
|
||||
{
|
||||
if ((u16)(x - 3) < 11 && (u16)(y - 6) < 14 && gUnknown_085103C8[y])
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void sub_809E14C(s16 x, s16 y)
|
||||
{
|
||||
if (sub_809E108(x, y))
|
||||
*GetVarPointer(gUnknown_085103C8[y]) |= (1 << (x - 3));
|
||||
}
|
||||
|
||||
static bool32 sub_809E184(s16 x, s16 y)
|
||||
{
|
||||
u32 var;
|
||||
if (!sub_809E108(x, y))
|
||||
return FALSE;
|
||||
|
||||
var = VarGet(gUnknown_085103C8[y]) << 16;
|
||||
if (((1 << 16) << (x - 3)) & var) // TODO: fix that if
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void SetSootopolisGymCrackedIceMetatiles(void)
|
||||
{
|
||||
s32 x, y;
|
||||
s32 width = gMapHeader.mapData->width;
|
||||
s32 height = gMapHeader.mapData->height;
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
if (sub_809E184(x, y) == TRUE)
|
||||
{
|
||||
MapGridSetMetatileIdAt(x + 7, y + 7, 0x20e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PerStepCallback_8069DD4(u8 taskId)
|
||||
{
|
||||
s16 x, y;
|
||||
u16 tileBehavior;
|
||||
u16 *var;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
switch (data[1])
|
||||
{
|
||||
case 0:
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
data[1] = 1;
|
||||
break;
|
||||
case 1:
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
if (x != data[2] || y != data[3])
|
||||
{
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
|
||||
var = GetVarPointer(VAR_ICE_STEP_COUNT);
|
||||
if (MetatileBehavior_IsThinIce(tileBehavior) == TRUE)
|
||||
{
|
||||
(*var)++;
|
||||
data[6] = 4;
|
||||
data[1] = 2;
|
||||
data[4] = x;
|
||||
data[5] = y;
|
||||
}
|
||||
else if (MetatileBehavior_IsCrackedIce(tileBehavior) == TRUE)
|
||||
{
|
||||
*var = 0;
|
||||
data[6] = 4;
|
||||
data[1] = 3;
|
||||
data[4] = x;
|
||||
data[5] = y;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (data[6] != 0)
|
||||
{
|
||||
data[6]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = data[4];
|
||||
y = data[5];
|
||||
PlaySE(SE_RU_BARI);
|
||||
MapGridSetMetatileIdAt(x, y, 0x20e);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
sub_809E14C(x - 7, y - 7);
|
||||
data[1] = 1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (data[6] != 0)
|
||||
{
|
||||
data[6]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = data[4];
|
||||
y = data[5];
|
||||
PlaySE(SE_RU_GASYAN);
|
||||
MapGridSetMetatileIdAt(x, y, 0x206);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
data[1] = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void PerStepCallback_8069F64(u8 taskId)
|
||||
{
|
||||
s16 x, y;
|
||||
u16 *var;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
if (x != data[1] || y != data[2])
|
||||
{
|
||||
data[1] = x;
|
||||
data[2] = y;
|
||||
if (MetatileBehavior_IsAsh(MapGridGetMetatileBehaviorAt(x, y)))
|
||||
{
|
||||
if (MapGridGetMetatileIdAt(x, y) == 0x20a)
|
||||
{
|
||||
ash(x, y, 0x212, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
ash(x, y, 0x206, 4);
|
||||
}
|
||||
if (CheckBagHasItem(ITEM_SOOT_SACK, 1))
|
||||
{
|
||||
var = GetVarPointer(VAR_ASH_GATHER_COUNT);
|
||||
if (*var < 9999)
|
||||
{
|
||||
(*var)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809E490(s16 x, s16 y)
|
||||
{
|
||||
MapGridSetMetatileIdAt(x, y, MapGridGetMetatileIdAt(x, y) == 0x22f ? 0x206 : 0x237);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
}
|
||||
|
||||
static void PerStepCallback_806A07C(u8 taskId)
|
||||
{
|
||||
s16 x, y;
|
||||
u16 behavior;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
behavior = MapGridGetMetatileBehaviorAt(x, y);
|
||||
if (data[4] != 0 && (--data[4]) == 0)
|
||||
{
|
||||
sub_809E490(data[5], data[6]);
|
||||
}
|
||||
if (data[7] != 0 && (--data[7]) == 0)
|
||||
{
|
||||
sub_809E490(data[8], data[9]);
|
||||
}
|
||||
if (MetatileBehavior_IsCrackedFloorHole(behavior))
|
||||
{
|
||||
VarSet(VAR_ICE_STEP_COUNT, 0); // this var does double duty
|
||||
}
|
||||
if ((x != data[2] || y != data[3]))
|
||||
{
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
if (MetatileBehavior_IsCrackedFloor(behavior))
|
||||
{
|
||||
if (GetPlayerSpeed() != 4)
|
||||
{
|
||||
VarSet(VAR_ICE_STEP_COUNT, 0); // this var does double duty
|
||||
}
|
||||
if (data[4] == 0)
|
||||
{
|
||||
data[4] = 3;
|
||||
data[5] = x;
|
||||
data[6] = y;
|
||||
}
|
||||
else if (data[7] == 0)
|
||||
{
|
||||
data[7] = 3;
|
||||
data[8] = x;
|
||||
data[9] = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809E5DC(s16 *data, s16 x, s16 y)
|
||||
{
|
||||
u16 tile;
|
||||
if ((--data[0]) == 0)
|
||||
{
|
||||
tile = 0xe8;
|
||||
}
|
||||
else
|
||||
{
|
||||
tile = gUnknown_085103FC[data[0] / 8];
|
||||
}
|
||||
MapGridSetMetatileIdAt(x, y, tile);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
MapGridSetMetatileIdAt(x, y, 0xe8);
|
||||
}
|
||||
|
||||
static void Task_MuddySlope(u8 taskId)
|
||||
{
|
||||
s16 x, y, x2, y2;
|
||||
int i;
|
||||
u16 mapIndices;
|
||||
s16 *data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
mapIndices = (gSaveBlock1Ptr->location.mapGroup << 8) | gSaveBlock1Ptr->location.mapNum;
|
||||
switch (data[1])
|
||||
{
|
||||
case 0:
|
||||
data[0] = mapIndices;
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
data[1] = 1;
|
||||
data[4] = 0;
|
||||
data[7] = 0;
|
||||
data[10] = 0;
|
||||
data[13] = 0;
|
||||
break;
|
||||
case 1:
|
||||
if (data[2] != x || data[3] != y)
|
||||
{
|
||||
data[2] = x;
|
||||
data[3] = y;
|
||||
if (MetatileBehavior_IsMuddySlope(MapGridGetMetatileBehaviorAt(x, y)))
|
||||
{
|
||||
for (i=4; i<14; i+=3)
|
||||
{
|
||||
if (data[i] == 0)
|
||||
{
|
||||
data[i] = 32;
|
||||
data[i + 1] = x;
|
||||
data[i + 2] = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (gCamera.active && mapIndices != data[0])
|
||||
{
|
||||
data[0] = mapIndices;
|
||||
x2 = gCamera.x;
|
||||
y2 = gCamera.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x2 = 0;
|
||||
y2 = 0;
|
||||
}
|
||||
for (i = 4; i < 14; i += 3)
|
||||
{
|
||||
if (data[i])
|
||||
{
|
||||
data[i + 1] -= x2;
|
||||
data[i + 2] -= y2;
|
||||
sub_809E5DC(&data[i], data[i + 1], data[i + 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "malloc.h"
|
||||
#include "map_name_popup.h"
|
||||
#include "menu.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "money.h"
|
||||
#include "overworld.h"
|
||||
#include "palette.h"
|
||||
@@ -265,7 +264,7 @@ struct TempWallyStruct {
|
||||
};
|
||||
|
||||
EWRAM_DATA struct UnkBagStruct *gUnknown_0203CE54 = 0;
|
||||
EWRAM_DATA struct BagStruct gUnknown_0203CE58 = {0, 0, 0, {0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}};
|
||||
EWRAM_DATA struct BagStruct gUnknown_0203CE58 = {0};
|
||||
EWRAM_DATA struct ListBuffer1 *gUnknown_0203CE74 = 0;
|
||||
EWRAM_DATA struct ListBuffer2 *gUnknown_0203CE78 = 0;
|
||||
EWRAM_DATA u16 gSpecialVar_ItemId = 0;
|
||||
@@ -750,7 +749,7 @@ void sub_81AB824(void)
|
||||
void bag_menu_add_list_scroll_arrow_indicators_maybe(void)
|
||||
{
|
||||
if (gUnknown_0203CE54->unk81B != 1 && gUnknown_0203CE54->unk81F == 0xFF)
|
||||
gUnknown_0203CE54->unk81F = AddScrollIndicatorArrowPair(&gUnknown_08614094, gUnknown_0203CE58.unk6);
|
||||
gUnknown_0203CE54->unk81F = AddScrollIndicatorArrowPair(&gUnknown_08614094, &gUnknown_0203CE58.unk6);
|
||||
}
|
||||
|
||||
void sub_81AB89C(void)
|
||||
|
||||
@@ -237,11 +237,11 @@ void sub_818D9C0(void)
|
||||
{
|
||||
LilycoveLady *lilycoveLady;
|
||||
|
||||
VarSet(VAR_0x4010, sUnknown_0860B07E[GetLilycoveLadyId()]);
|
||||
VarSet(VAR_OBJ_GFX_ID_0, sUnknown_0860B07E[GetLilycoveLadyId()]);
|
||||
if (GetLilycoveLadyId() == LILYCOVE_LADY_CONTEST)
|
||||
{
|
||||
lilycoveLady = &gSaveBlock1Ptr->lilycoveLady;
|
||||
VarSet(VAR_0x4011, sUnknown_0860B074[lilycoveLady->contest.category]);
|
||||
VarSet(VAR_OBJ_GFX_ID_1, sUnknown_0860B074[lilycoveLady->contest.category]);
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
else
|
||||
|
||||
832
src/list_menu.c
832
src/list_menu.c
@@ -5,11 +5,16 @@
|
||||
#include "text_window.h"
|
||||
#include "main.h"
|
||||
#include "task.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "trig.h"
|
||||
#include "decompress.h"
|
||||
#include "palette.h"
|
||||
#include "malloc.h"
|
||||
#include "strings.h"
|
||||
#include "sound.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
// This file needs better labels and function names.
|
||||
|
||||
struct UnknownMysteryGiftLinkMenuStruct
|
||||
{
|
||||
s32 field_0;
|
||||
@@ -29,7 +34,71 @@ struct UnknownListMenuPals
|
||||
u8 field_3_7:1;
|
||||
};
|
||||
|
||||
extern struct UnknownMysteryGiftLinkMenuStruct gUnknown_0203CE84;
|
||||
struct UnkIndicatorsStruct
|
||||
{
|
||||
u8 field_0;
|
||||
u16 *field_4;
|
||||
u16 field_8;
|
||||
u16 field_A;
|
||||
u16 field_C;
|
||||
u16 field_E;
|
||||
u8 field_10;
|
||||
u8 field_11;
|
||||
u8 field_12;
|
||||
u8 field_13;
|
||||
u8 field_14_0:4;
|
||||
u8 field_14_1:4;
|
||||
u8 field_15_0:4;
|
||||
u8 field_15_1:4;
|
||||
u8 field_16_0:3;
|
||||
u8 field_16_1:3;
|
||||
u8 field_16_2:2;
|
||||
u8 field_17_0:6;
|
||||
u8 field_17_1:2;
|
||||
};
|
||||
|
||||
struct UnkIndicatorsStruct2
|
||||
{
|
||||
u8 field_0;
|
||||
u16 *field_4;
|
||||
u16 field_8;
|
||||
u16 field_A;
|
||||
u8 field_C;
|
||||
u8 field_D;
|
||||
u16 tileTag;
|
||||
u16 palTag;
|
||||
u16 field_12;
|
||||
u16 field_14;
|
||||
u16 field_16;
|
||||
u16 field_18;
|
||||
u16 field_1A;
|
||||
u16 field_1C;
|
||||
s16 field_1E;
|
||||
};
|
||||
|
||||
struct UnkIndicatorsStruct3
|
||||
{
|
||||
struct SubspriteTable subspriteTable;
|
||||
struct Subsprite *subspritesPtr; // not a const pointer
|
||||
u8 spriteId;
|
||||
u16 tileTag;
|
||||
u16 palTag;
|
||||
};
|
||||
|
||||
struct UnkIndicatorsStruct4
|
||||
{
|
||||
u8 field_0;
|
||||
u16 tileTag;
|
||||
u16 palTag;
|
||||
};
|
||||
|
||||
struct UnkSmallIndicatorsStruct
|
||||
{
|
||||
u8 field_0_0:4;
|
||||
u8 field_0_1:4;
|
||||
u8 field_1;
|
||||
u16 field_2;
|
||||
};
|
||||
|
||||
// this file's functions
|
||||
static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow);
|
||||
@@ -38,11 +107,220 @@ static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOff
|
||||
static void ListMenuDrawCursor(struct ListMenu *list);
|
||||
static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2);
|
||||
static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind);
|
||||
static void Task_ScrollIndicatorArrowPair(u8 taskId);
|
||||
static u8 ListMenuAddRedOutlineCursorObject(struct CursorStruct *cursor);
|
||||
static u8 ListMenuAddRedArrowCursorObject(struct CursorStruct *cursor);
|
||||
static void ListMenuUpdateRedOutlineCursorObject(u8 taskId, u16 x, u16 y);
|
||||
static void ListMenuUpdateRedArrowCursorObject(u8 taskId, u16 x, u16 y);
|
||||
static void ListMenuRemoveRedOutlineCursorObject(u8 taskId);
|
||||
static void ListMenuRemoveRedArrowCursorObject(u8 taskId);
|
||||
static u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorKind);
|
||||
static void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorKind);
|
||||
static void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind);
|
||||
static void sub_81AF264(struct Sprite *sprite);
|
||||
static void ObjectCB_RedArrowCursor(struct Sprite *sprite);
|
||||
|
||||
// EWRAM vars
|
||||
EWRAM_DATA struct UnknownMysteryGiftLinkMenuStruct gUnknown_0203CE84 = {0};
|
||||
EWRAM_DATA struct ArrowStruct gUnknown_0203CE8C = {0};
|
||||
|
||||
// IWRAM common
|
||||
struct UnknownListMenuPals gUnknown_03006300;
|
||||
struct ListMenuTemplate gMultiuseListMenuTemplate;
|
||||
|
||||
// const rom data
|
||||
static const struct UnkSmallIndicatorsStruct gUnknown_086141FC[] =
|
||||
{
|
||||
{0, 0, 2, 8},
|
||||
{1, 0, 2, -8},
|
||||
{2, 1, 2, 8},
|
||||
{3, 1, 2, -8},
|
||||
};
|
||||
|
||||
static const struct OamData sOamData_861420C =
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = 0,
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = 1,
|
||||
.tileNum = 0,
|
||||
.priority = 0,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_8614214[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 30),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_861421C[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 30, 1, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_8614224[] =
|
||||
{
|
||||
ANIMCMD_FRAME(4, 30),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_861422C[] =
|
||||
{
|
||||
ANIMCMD_FRAME(4, 30, 0, 1),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_8614234[] =
|
||||
{
|
||||
sSpriteAnim_8614214,
|
||||
sSpriteAnim_861421C,
|
||||
sSpriteAnim_8614224,
|
||||
sSpriteAnim_861422C
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate gUnknown_08614244 =
|
||||
{
|
||||
.tileTag = 0,
|
||||
.paletteTag = 0,
|
||||
.oam = &sOamData_861420C,
|
||||
.anims = sSpriteAnimTable_8614234,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = sub_81AF264,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_861425C =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 0,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_8614260 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 1,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_8614264 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 2,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_8614268 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 3,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_861426C =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 4,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_8614270 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 5,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_8614274 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 6,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct Subsprite sSubsprite_8614278 =
|
||||
{
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.shape = 0,
|
||||
.size = 0,
|
||||
.tileOffset = 7,
|
||||
.priority = 0,
|
||||
};
|
||||
|
||||
static const struct OamData sOamData_861427C =
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = 0,
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = 1,
|
||||
.tileNum = 0,
|
||||
.priority = 0,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_8614284[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 30),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_861428C[] =
|
||||
{
|
||||
sSpriteAnim_8614284
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate gUnknown_08614290 =
|
||||
{
|
||||
.tileTag = 0,
|
||||
.paletteTag = 0,
|
||||
.oam = &sOamData_861427C,
|
||||
.anims = sSpriteAnimTable_861428C,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = ObjectCB_RedArrowCursor,
|
||||
};
|
||||
|
||||
static const u16 gUnknown_086142A8[] = INCBIN_U16("graphics/interface/red_arrow.gbapal");
|
||||
static const u8 gUnknown_086142C8[] = INCBIN_U8("graphics/interface/red_arrow_other.4bpp.lz");
|
||||
static const u8 gUnknown_08614338[] = INCBIN_U8("graphics/interface/selector_outline.4bpp.lz");
|
||||
static const u8 gUnknown_08614378[] = INCBIN_U8("graphics/interface/red_arrow.4bpp.lz");
|
||||
|
||||
// code
|
||||
static void ListMenuDummyTask(u8 taskId)
|
||||
{
|
||||
@@ -415,9 +693,9 @@ static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind)
|
||||
cursor.unk1 = 0xA0;
|
||||
cursor.unk2 = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8 + 2;
|
||||
cursor.unk4 = GetFontAttribute(list->template.fontId, 1) + 2;
|
||||
cursor.unk6 = 0x4000;
|
||||
cursor.unk8 = 0xFFFF;
|
||||
cursor.unkA = 0xF;
|
||||
cursor.tileTag = 0x4000;
|
||||
cursor.palTag = 0xFFFF;
|
||||
cursor.palNum = 0xF;
|
||||
|
||||
return ListMenuAddCursorObjectInternal(&cursor, cursorKind);
|
||||
}
|
||||
@@ -631,3 +909,547 @@ void sub_81AF078(s32 arg0, u8 arg1, struct ListMenu *list)
|
||||
if (!arg1)
|
||||
PlaySE(SE_SELECT);
|
||||
}
|
||||
|
||||
// unused
|
||||
s32 sub_81AF08C(u8 taskId, u8 field)
|
||||
{
|
||||
struct UnkIndicatorsStruct *data = (void*) gTasks[taskId].data;
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return (s32)(data->field_4);
|
||||
case 2:
|
||||
return data->field_C;
|
||||
case 3:
|
||||
return data->field_E;
|
||||
case 4:
|
||||
return data->field_10;
|
||||
case 5:
|
||||
return data->field_11;
|
||||
case 6:
|
||||
return data->field_12;
|
||||
case 7:
|
||||
return data->field_13;
|
||||
case 8:
|
||||
return data->field_14_0;
|
||||
case 9:
|
||||
return data->field_14_1;
|
||||
case 10:
|
||||
return data->field_15_0;
|
||||
case 11:
|
||||
return data->field_15_1;
|
||||
case 12:
|
||||
return data->field_16_0;
|
||||
case 13:
|
||||
return data->field_16_1;
|
||||
case 14:
|
||||
return data->field_16_2;
|
||||
case 15:
|
||||
return data->field_17_0;
|
||||
case 16:
|
||||
return data->field_17_1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// unused
|
||||
void sub_81AF15C(u8 taskId, u8 field, s32 value)
|
||||
{
|
||||
struct UnkIndicatorsStruct *data = (void*) &gTasks[taskId].data;
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
data->field_4 = (void*)(value);
|
||||
break;
|
||||
case 2:
|
||||
data->field_C = value;
|
||||
break;
|
||||
case 3:
|
||||
data->field_E = value;
|
||||
break;
|
||||
case 4:
|
||||
data->field_10 = value;
|
||||
break;
|
||||
case 5:
|
||||
data->field_11 = value;
|
||||
break;
|
||||
case 6:
|
||||
data->field_12 = value;
|
||||
break;
|
||||
case 7:
|
||||
data->field_13 = value;
|
||||
break;
|
||||
case 8:
|
||||
data->field_14_0 = value;
|
||||
break;
|
||||
case 9:
|
||||
data->field_14_1 = value;
|
||||
break;
|
||||
case 10:
|
||||
data->field_15_0 = value;
|
||||
break;
|
||||
case 11:
|
||||
data->field_15_1 = value;
|
||||
break;
|
||||
case 12:
|
||||
data->field_16_0 = value;
|
||||
break;
|
||||
case 13:
|
||||
data->field_16_1 = value;
|
||||
break;
|
||||
case 14:
|
||||
data->field_16_2 = value;
|
||||
break;
|
||||
case 15:
|
||||
data->field_17_0 = value;
|
||||
break;
|
||||
case 16:
|
||||
data->field_17_1 = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_81AF264(struct Sprite *sprite)
|
||||
{
|
||||
s32 multiplier;
|
||||
|
||||
switch (sprite->data[0])
|
||||
{
|
||||
case 0:
|
||||
StartSpriteAnim(sprite, sprite->data[1]);
|
||||
sprite->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
switch (sprite->data[2])
|
||||
{
|
||||
case 0:
|
||||
multiplier = sprite->data[3];
|
||||
sprite->pos2.x = (gSineTable[(u8)(sprite->data[5])] * multiplier) / 256;
|
||||
break;
|
||||
case 1:
|
||||
multiplier = sprite->data[3];
|
||||
sprite->pos2.y = (gSineTable[(u8)(sprite->data[5])] * multiplier) / 256;
|
||||
break;
|
||||
}
|
||||
sprite->data[5] += sprite->data[4];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static u8 AddScrollIndicatorArrowObject(u8 arg0, u8 x, u8 y, u16 tileTag, u16 palTag)
|
||||
{
|
||||
u8 spriteId;
|
||||
struct SpriteTemplate spriteTemplate;
|
||||
|
||||
spriteTemplate = gUnknown_08614244;
|
||||
spriteTemplate.tileTag = tileTag;
|
||||
spriteTemplate.paletteTag = palTag;
|
||||
|
||||
spriteId = CreateSprite(&spriteTemplate, x, y, 0);
|
||||
gSprites[spriteId].invisible = 1;
|
||||
gSprites[spriteId].data[0] = 0;
|
||||
gSprites[spriteId].data[1] = gUnknown_086141FC[arg0].field_0_0;
|
||||
gSprites[spriteId].data[2] = gUnknown_086141FC[arg0].field_0_1;
|
||||
gSprites[spriteId].data[3] = gUnknown_086141FC[arg0].field_1;
|
||||
gSprites[spriteId].data[4] = gUnknown_086141FC[arg0].field_2;
|
||||
gSprites[spriteId].data[5] = 0;
|
||||
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
u8 AddScrollIndicatorArrowPair(const struct ArrowStruct *arrowInfo, u16 *arg1)
|
||||
{
|
||||
struct CompressedSpriteSheet spriteSheet;
|
||||
struct SpritePalette spritePal;
|
||||
struct UnkIndicatorsStruct2 *data;
|
||||
u8 taskId;
|
||||
|
||||
spriteSheet.data = gUnknown_086142C8;
|
||||
spriteSheet.size = 0x100;
|
||||
spriteSheet.tag = arrowInfo->tileTag;
|
||||
LoadCompressedObjectPic(&spriteSheet);
|
||||
|
||||
if (arrowInfo->palTag == 0xFFFF)
|
||||
{
|
||||
LoadPalette(gUnknown_086142A8, (16 * arrowInfo->palNum) + 0x100, 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
spritePal.data = gUnknown_086142A8;
|
||||
spritePal.tag = arrowInfo->palTag;
|
||||
LoadSpritePalette(&spritePal);
|
||||
}
|
||||
|
||||
taskId = CreateTask(Task_ScrollIndicatorArrowPair, 0);
|
||||
data = (void*) gTasks[taskId].data;
|
||||
|
||||
data->field_0 = 0;
|
||||
data->field_4 = arg1;
|
||||
data->field_8 = arrowInfo->unk6;
|
||||
data->field_A = arrowInfo->unk8;
|
||||
data->tileTag = arrowInfo->tileTag;
|
||||
data->palTag = arrowInfo->palTag;
|
||||
data->field_C = AddScrollIndicatorArrowObject(arrowInfo->unk0, arrowInfo->unk1, arrowInfo->unk2, arrowInfo->tileTag, arrowInfo->palTag);
|
||||
data->field_D = AddScrollIndicatorArrowObject(arrowInfo->unk3, arrowInfo->unk4, arrowInfo->unk5, arrowInfo->tileTag, arrowInfo->palTag);
|
||||
|
||||
if (arrowInfo->palTag == 0xFFFF)
|
||||
{
|
||||
gSprites[data->field_C].oam.paletteNum = arrowInfo->palNum;
|
||||
gSprites[data->field_D].oam.paletteNum = arrowInfo->palNum;
|
||||
}
|
||||
|
||||
return taskId;
|
||||
}
|
||||
|
||||
u8 AddScrollIndicatorArrowPairParametrized(u32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 tileTag, s32 palTag, void *arg7)
|
||||
{
|
||||
if (arg0 == 2 || arg0 == 3)
|
||||
{
|
||||
gUnknown_0203CE8C.unk0 = 2;
|
||||
gUnknown_0203CE8C.unk1 = arg1;
|
||||
gUnknown_0203CE8C.unk2 = arg2;
|
||||
gUnknown_0203CE8C.unk3 = 3;
|
||||
gUnknown_0203CE8C.unk4 = arg1;
|
||||
gUnknown_0203CE8C.unk5 = arg3;
|
||||
}
|
||||
else
|
||||
{
|
||||
gUnknown_0203CE8C.unk0 = 0;
|
||||
gUnknown_0203CE8C.unk1 = arg2;
|
||||
gUnknown_0203CE8C.unk2 = arg1;
|
||||
gUnknown_0203CE8C.unk3 = 1;
|
||||
gUnknown_0203CE8C.unk4 = arg3;
|
||||
gUnknown_0203CE8C.unk5 = arg1;
|
||||
}
|
||||
|
||||
gUnknown_0203CE8C.unk6 = 0;
|
||||
gUnknown_0203CE8C.unk8 = arg4;
|
||||
gUnknown_0203CE8C.tileTag = tileTag;
|
||||
gUnknown_0203CE8C.palTag = palTag;
|
||||
gUnknown_0203CE8C.palNum = 0;
|
||||
|
||||
return AddScrollIndicatorArrowPair(&gUnknown_0203CE8C, arg7);
|
||||
}
|
||||
|
||||
static void Task_ScrollIndicatorArrowPair(u8 taskId)
|
||||
{
|
||||
struct UnkIndicatorsStruct2 *data = (void*) gTasks[taskId].data;
|
||||
u16 var = (*data->field_4);
|
||||
|
||||
if (var == data->field_8 && var != 0xFFFF)
|
||||
gSprites[data->field_C].invisible = 1;
|
||||
else
|
||||
gSprites[data->field_C].invisible = 0;
|
||||
|
||||
if (var == data->field_A)
|
||||
gSprites[data->field_D].invisible = 1;
|
||||
else
|
||||
gSprites[data->field_D].invisible = 0;
|
||||
}
|
||||
|
||||
void Task_ScrollIndicatorArrowPairOnMainMenu(u8 taskId)
|
||||
{
|
||||
struct UnkIndicatorsStruct2 *data = (void*) gTasks[taskId].data;
|
||||
|
||||
if (data->field_1E != 0)
|
||||
{
|
||||
gSprites[data->field_C].invisible = 0;
|
||||
gSprites[data->field_D].invisible = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSprites[data->field_C].invisible = 1;
|
||||
gSprites[data->field_D].invisible = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveScrollIndicatorArrowPair(u8 taskId)
|
||||
{
|
||||
struct UnkIndicatorsStruct2 *data = (void*) gTasks[taskId].data;
|
||||
|
||||
if (data->tileTag != 0xFFFF)
|
||||
FreeSpriteTilesByTag(data->tileTag);
|
||||
if (data->palTag != 0xFFFF)
|
||||
FreeSpritePaletteByTag(data->palTag);
|
||||
|
||||
DestroySprite(&gSprites[data->field_C]);
|
||||
DestroySprite(&gSprites[data->field_D]);
|
||||
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
static u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorKind)
|
||||
{
|
||||
switch (cursorKind)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
return ListMenuAddRedOutlineCursorObject(cursor);
|
||||
case 1:
|
||||
return ListMenuAddRedArrowCursorObject(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
static void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorKind)
|
||||
{
|
||||
switch (cursorKind)
|
||||
{
|
||||
case 0:
|
||||
ListMenuUpdateRedOutlineCursorObject(taskId, x, y);
|
||||
break;
|
||||
case 1:
|
||||
ListMenuUpdateRedArrowCursorObject(taskId, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind)
|
||||
{
|
||||
switch (cursorKind)
|
||||
{
|
||||
case 0:
|
||||
ListMenuRemoveRedOutlineCursorObject(taskId);
|
||||
break;
|
||||
case 1:
|
||||
ListMenuRemoveRedArrowCursorObject(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_RedOutlineCursor(u8 taskId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
u8 ListMenuGetRedOutlineCursorSpriteCount(u16 arg0, u16 arg1)
|
||||
{
|
||||
s32 i;
|
||||
s32 count = 4;
|
||||
|
||||
if (arg0 > 16)
|
||||
{
|
||||
for (i = 8; i < (arg0 - 8); i += 8)
|
||||
count += 2;
|
||||
}
|
||||
if (arg1 > 16)
|
||||
{
|
||||
for (i = 8; i < (arg1 - 8); i += 8)
|
||||
count += 2;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void ListMenuSetUpRedOutlineCursorSpriteOamTable(u16 arg0, u16 arg1, struct Subsprite *subsprites)
|
||||
{
|
||||
s32 i, j, id = 0;
|
||||
|
||||
subsprites[id] = sSubsprite_861425C;
|
||||
subsprites[id].x = 136;
|
||||
subsprites[id].y = 136;
|
||||
id++;
|
||||
|
||||
subsprites[id] = sSubsprite_8614260;
|
||||
subsprites[id].x = arg0 + 128;
|
||||
subsprites[id].y = 136;
|
||||
id++;
|
||||
|
||||
subsprites[id] = sSubsprite_8614274;
|
||||
subsprites[id].x = 136;
|
||||
subsprites[id].y = arg1 + 128;
|
||||
id++;
|
||||
|
||||
subsprites[id] = sSubsprite_8614278;
|
||||
subsprites[id].x = arg0 + 128;
|
||||
subsprites[id].y = arg1 + 128;
|
||||
id++;
|
||||
|
||||
if (arg0 > 16)
|
||||
{
|
||||
for (i = 8; i < arg0 - 8; i += 8)
|
||||
{
|
||||
subsprites[id] = sSubsprite_8614264;
|
||||
subsprites[id].x = i - 120;
|
||||
subsprites[id].y = 136;
|
||||
id++;
|
||||
|
||||
subsprites[id] = sSubsprite_8614270;
|
||||
subsprites[id].x = i - 120;
|
||||
subsprites[id].y = arg1 + 128;
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg1 > 16)
|
||||
{
|
||||
for (j = 8; j < arg1 - 8; j += 8)
|
||||
{
|
||||
subsprites[id] = sSubsprite_8614268;
|
||||
subsprites[id].x = 136;
|
||||
subsprites[id].y = j - 120;
|
||||
id++;
|
||||
|
||||
subsprites[id] = sSubsprite_861426C;
|
||||
subsprites[id].x = arg0 + 128;
|
||||
subsprites[id].y = j - 120;
|
||||
id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static u8 ListMenuAddRedOutlineCursorObject(struct CursorStruct *cursor)
|
||||
{
|
||||
struct CompressedSpriteSheet spriteSheet;
|
||||
struct SpritePalette spritePal;
|
||||
struct UnkIndicatorsStruct3 *data;
|
||||
struct SpriteTemplate spriteTemplate;
|
||||
u8 taskId;
|
||||
|
||||
spriteSheet.data = gUnknown_08614338;
|
||||
spriteSheet.size = 0x100;
|
||||
spriteSheet.tag = cursor->tileTag;
|
||||
LoadCompressedObjectPic(&spriteSheet);
|
||||
|
||||
if (cursor->palTag == 0xFFFF)
|
||||
{
|
||||
LoadPalette(gUnknown_086142A8, (16 * cursor->palNum) + 0x100, 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
spritePal.data = gUnknown_086142A8;
|
||||
spritePal.tag = cursor->palTag;
|
||||
LoadSpritePalette(&spritePal);
|
||||
}
|
||||
|
||||
taskId = CreateTask(Task_RedOutlineCursor, 0);
|
||||
data = (void*) gTasks[taskId].data;
|
||||
|
||||
data->tileTag = cursor->tileTag;
|
||||
data->palTag = cursor->palTag;
|
||||
data->subspriteTable.subspriteCount = ListMenuGetRedOutlineCursorSpriteCount(cursor->unk2, cursor->unk4);
|
||||
data->subspriteTable.subsprites = data->subspritesPtr = Alloc(data->subspriteTable.subspriteCount * 4);
|
||||
ListMenuSetUpRedOutlineCursorSpriteOamTable(cursor->unk2, cursor->unk4, data->subspritesPtr);
|
||||
|
||||
spriteTemplate = gDummySpriteTemplate;
|
||||
spriteTemplate.tileTag = cursor->tileTag;
|
||||
spriteTemplate.paletteTag = cursor->palTag;
|
||||
|
||||
data->spriteId = CreateSprite(&spriteTemplate, cursor->unk0 + 120, cursor->unk1 + 120, 0);
|
||||
SetSubspriteTables(&gSprites[data->spriteId], &data->subspriteTable);
|
||||
gSprites[data->spriteId].oam.priority = 0;
|
||||
gSprites[data->spriteId].subpriority = 0;
|
||||
gSprites[data->spriteId].subspriteTableNum = 0;
|
||||
|
||||
if (cursor->palTag == 0xFFFF)
|
||||
{
|
||||
gSprites[data->spriteId].oam.paletteNum = cursor->palNum;
|
||||
}
|
||||
|
||||
return taskId;
|
||||
}
|
||||
|
||||
static void ListMenuUpdateRedOutlineCursorObject(u8 taskId, u16 x, u16 y)
|
||||
{
|
||||
struct UnkIndicatorsStruct3 *data = (void*) gTasks[taskId].data;
|
||||
|
||||
gSprites[data->spriteId].pos1.x = x + 120;
|
||||
gSprites[data->spriteId].pos1.y = y + 120;
|
||||
}
|
||||
|
||||
static void ListMenuRemoveRedOutlineCursorObject(u8 taskId)
|
||||
{
|
||||
struct UnkIndicatorsStruct3 *data = (void*) gTasks[taskId].data;
|
||||
|
||||
Free(data->subspritesPtr);
|
||||
|
||||
if (data->tileTag != 0xFFFF)
|
||||
FreeSpriteTilesByTag(data->tileTag);
|
||||
if (data->palTag != 0xFFFF)
|
||||
FreeSpritePaletteByTag(data->palTag);
|
||||
|
||||
DestroySprite(&gSprites[data->spriteId]);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
static void ObjectCB_RedArrowCursor(struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos2.x = gSineTable[(u8)(sprite->data[0])] / 64;
|
||||
sprite->data[0] += 8;
|
||||
}
|
||||
|
||||
static void Task_RedArrowCursor(u8 taskId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static u8 ListMenuAddRedArrowCursorObject(struct CursorStruct *cursor)
|
||||
{
|
||||
struct CompressedSpriteSheet spriteSheet;
|
||||
struct SpritePalette spritePal;
|
||||
struct UnkIndicatorsStruct4 *data;
|
||||
struct SpriteTemplate spriteTemplate;
|
||||
u8 taskId;
|
||||
|
||||
spriteSheet.data = gUnknown_08614378;
|
||||
spriteSheet.size = 0x80;
|
||||
spriteSheet.tag = cursor->tileTag;
|
||||
LoadCompressedObjectPic(&spriteSheet);
|
||||
|
||||
if (cursor->palTag == 0xFFFF)
|
||||
{
|
||||
LoadPalette(gUnknown_086142A8, (16 * cursor->palNum) + 0x100, 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
spritePal.data = gUnknown_086142A8;
|
||||
spritePal.tag = cursor->palTag;
|
||||
LoadSpritePalette(&spritePal);
|
||||
}
|
||||
|
||||
taskId = CreateTask(Task_RedArrowCursor, 0);
|
||||
data = (void*) gTasks[taskId].data;
|
||||
|
||||
data->tileTag = cursor->tileTag;
|
||||
data->palTag = cursor->palTag;
|
||||
|
||||
spriteTemplate = gUnknown_08614290;
|
||||
spriteTemplate.tileTag = cursor->tileTag;
|
||||
spriteTemplate.paletteTag = cursor->palTag;
|
||||
|
||||
data->field_0 = CreateSprite(&spriteTemplate, cursor->unk0, cursor->unk1, 0);
|
||||
gSprites[data->field_0].pos2.x = 8;
|
||||
gSprites[data->field_0].pos2.y = 8;
|
||||
|
||||
if (cursor->palTag == 0xFFFF)
|
||||
{
|
||||
gSprites[data->field_0].oam.paletteNum = cursor->palNum;
|
||||
}
|
||||
|
||||
return taskId;
|
||||
}
|
||||
|
||||
static void ListMenuUpdateRedArrowCursorObject(u8 taskId, u16 x, u16 y)
|
||||
{
|
||||
struct UnkIndicatorsStruct4 *data = (void*) gTasks[taskId].data;
|
||||
|
||||
gSprites[data->field_0].pos1.x = x;
|
||||
gSprites[data->field_0].pos1.y = y;
|
||||
}
|
||||
|
||||
static void ListMenuRemoveRedArrowCursorObject(u8 taskId)
|
||||
{
|
||||
struct UnkIndicatorsStruct4 *data = (void*) gTasks[taskId].data;
|
||||
|
||||
if (data->tileTag != 0xFFFF)
|
||||
FreeSpriteTilesByTag(data->tileTag);
|
||||
if (data->palTag != 0xFFFF)
|
||||
FreeSpritePaletteByTag(data->palTag);
|
||||
|
||||
DestroySprite(&gSprites[data->field_0]);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "link.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "list_menu.h"
|
||||
#include "mystery_event_menu.h"
|
||||
#include "naming_screen.h"
|
||||
#include "option_menu.h"
|
||||
|
||||
@@ -673,7 +673,7 @@ static void Task_BardSong(u8 taskId)
|
||||
|
||||
void ScrSpecial_SetMauvilleOldManMapObjGfx(void)
|
||||
{
|
||||
VarSet(VAR_0x4010, MAP_OBJ_GFX_BARD);
|
||||
VarSet(VAR_OBJ_GFX_ID_0, MAP_OBJ_GFX_BARD);
|
||||
}
|
||||
|
||||
// Language fixers?
|
||||
|
||||
@@ -2080,7 +2080,7 @@ void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16
|
||||
}
|
||||
}
|
||||
#else
|
||||
__attribute__((naked))
|
||||
NAKED
|
||||
void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7)
|
||||
{
|
||||
asm("push {r4-r7,lr}\n\
|
||||
|
||||
455
src/menu_helpers.c
Normal file
455
src/menu_helpers.c
Normal file
@@ -0,0 +1,455 @@
|
||||
#include "global.h"
|
||||
#include "task.h"
|
||||
#include "window.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "bg.h"
|
||||
#include "main.h"
|
||||
#include "text.h"
|
||||
#include "link.h"
|
||||
#include "string_util.h"
|
||||
#include "sound.h"
|
||||
#include "mail.h"
|
||||
#include "overworld.h"
|
||||
#include "decompress.h"
|
||||
#include "constants/songs.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/maps.h"
|
||||
|
||||
extern bool32 sub_800B504(void);
|
||||
|
||||
extern const u8 gBagSwapLineGfx[];
|
||||
extern const u8 gBagSwapLinePal[];
|
||||
|
||||
// this file's functions
|
||||
static void Task_ContinueTaskAfterMessagePrints(u8 taskId);
|
||||
static void Task_CallYesOrNoCallback(u8 taskId);
|
||||
|
||||
// EWRAM vars
|
||||
EWRAM_DATA static struct YesNoFuncTable gUnknown_0203A138 = {0};
|
||||
EWRAM_DATA static u8 gUnknown_0203A140 = 0;
|
||||
|
||||
// IWRAM bss vars
|
||||
IWRAM_DATA static TaskFunc gUnknown_0300117C;
|
||||
|
||||
// const rom data
|
||||
static const struct OamData sOamData_859F4E8 =
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = 0,
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = 1,
|
||||
.tileNum = 0,
|
||||
.priority = 0,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_859F4F0[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_859F4F8[] =
|
||||
{
|
||||
ANIMCMD_FRAME(4, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_859F500[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 0, 1, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_859F508[] =
|
||||
{
|
||||
sSpriteAnim_859F4F0,
|
||||
sSpriteAnim_859F4F8,
|
||||
sSpriteAnim_859F500
|
||||
};
|
||||
|
||||
static const struct CompressedSpriteSheet gUnknown_0859F514 =
|
||||
{
|
||||
gBagSwapLineGfx, 0x100, 109
|
||||
};
|
||||
|
||||
static const struct CompressedSpritePalette gUnknown_0859F51C =
|
||||
{
|
||||
gBagSwapLinePal, 109
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate gUnknown_0859F524 =
|
||||
{
|
||||
.tileTag = 109,
|
||||
.paletteTag = 109,
|
||||
.oam = &sOamData_859F4E8,
|
||||
.anims = sSpriteAnimTable_859F508,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCallbackDummy,
|
||||
};
|
||||
|
||||
// code
|
||||
void ResetVramOamAndBgCntRegs(void)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG3CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG2CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0CNT, 0);
|
||||
CpuFill16(0, (void*) VRAM, VRAM_SIZE);
|
||||
CpuFill32(0, (void*) OAM, OAM_SIZE);
|
||||
CpuFill16(0, (void*) PLTT, PLTT_SIZE);
|
||||
}
|
||||
|
||||
void ResetAllBgsCoordinates(void)
|
||||
{
|
||||
ChangeBgX(0, 0, 0);
|
||||
ChangeBgY(0, 0, 0);
|
||||
ChangeBgX(1, 0, 0);
|
||||
ChangeBgY(1, 0, 0);
|
||||
ChangeBgX(2, 0, 0);
|
||||
ChangeBgY(2, 0, 0);
|
||||
ChangeBgX(3, 0, 0);
|
||||
ChangeBgY(3, 0, 0);
|
||||
}
|
||||
|
||||
void SetVBlankHBlankCallbacksToNull(void)
|
||||
{
|
||||
SetVBlankCallback(NULL);
|
||||
SetHBlankCallback(NULL);
|
||||
}
|
||||
|
||||
void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc)
|
||||
{
|
||||
gUnknown_0203A140 = windowId;
|
||||
sub_8197B1C(windowId, TRUE, arg2, arg3);
|
||||
|
||||
if (string != gStringVar4)
|
||||
StringExpandPlaceholders(gStringVar4, string);
|
||||
|
||||
gTextFlags.flag_0 = 1;
|
||||
AddTextPrinterParameterized(windowId, fontId, gStringVar4, textSpeed, NULL, 2, 1, 3);
|
||||
gUnknown_0300117C = taskFunc;
|
||||
gTasks[taskId].func = Task_ContinueTaskAfterMessagePrints;
|
||||
}
|
||||
|
||||
bool16 RunTextPrintersRetIsActive(u8 textPrinterId)
|
||||
{
|
||||
RunTextPrinters();
|
||||
return IsTextPrinterActive(textPrinterId);
|
||||
}
|
||||
|
||||
static void Task_ContinueTaskAfterMessagePrints(u8 taskId)
|
||||
{
|
||||
if (!RunTextPrintersRetIsActive(gUnknown_0203A140))
|
||||
gUnknown_0300117C(taskId);
|
||||
}
|
||||
|
||||
void sub_8121F68(u8 taskId, const struct YesNoFuncTable *data)
|
||||
{
|
||||
gUnknown_0203A138 = *data;
|
||||
gTasks[taskId].func = Task_CallYesOrNoCallback;
|
||||
}
|
||||
|
||||
void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo)
|
||||
{
|
||||
CreateYesNoMenu(template, tileStart, palette, 0);
|
||||
gUnknown_0203A138 = *yesNo;
|
||||
gTasks[taskId].func = Task_CallYesOrNoCallback;
|
||||
}
|
||||
|
||||
static void Task_CallYesOrNoCallback(u8 taskId)
|
||||
{
|
||||
switch (ProcessMenuInputNoWrap_())
|
||||
{
|
||||
case 0:
|
||||
PlaySE(SE_SELECT);
|
||||
gUnknown_0203A138.yesFunc(taskId);
|
||||
break;
|
||||
case 1:
|
||||
case MENU_B_PRESSED:
|
||||
PlaySE(SE_SELECT);
|
||||
gUnknown_0203A138.noFunc(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1)
|
||||
{
|
||||
s16 valBefore = (*arg0);
|
||||
|
||||
if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
|
||||
{
|
||||
(*arg0)++;
|
||||
if ((*arg0) > arg1)
|
||||
(*arg0) = 1;
|
||||
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
|
||||
{
|
||||
(*arg0)--;
|
||||
if ((*arg0) <= 0)
|
||||
(*arg0) = arg1;
|
||||
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT)
|
||||
{
|
||||
(*arg0) += 10;
|
||||
if ((*arg0) > arg1)
|
||||
(*arg0) = arg1;
|
||||
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT)
|
||||
{
|
||||
(*arg0) -= 10;
|
||||
if ((*arg0) <= 0)
|
||||
(*arg0) = 1;
|
||||
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 GetLRKeysState(void)
|
||||
{
|
||||
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
|
||||
{
|
||||
if (gMain.newKeys & L_BUTTON)
|
||||
return 1;
|
||||
if (gMain.newKeys & R_BUTTON)
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 sub_812210C(void)
|
||||
{
|
||||
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
|
||||
{
|
||||
if (gMain.newAndRepeatedKeys & L_BUTTON)
|
||||
return 1;
|
||||
if (gMain.newAndRepeatedKeys & R_BUTTON)
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool8 sub_8122148(u16 itemId)
|
||||
{
|
||||
if (itemId != ITEM_ENIGMA_BERRY)
|
||||
return TRUE;
|
||||
else if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRADE_CENTER) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRADE_CENTER))
|
||||
return FALSE;
|
||||
else if (InUnionRoom() != TRUE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 itemid_80BF6D8_mail_related(u16 itemId)
|
||||
{
|
||||
if (is_c1_link_related_active() != TRUE && InUnionRoom() != TRUE)
|
||||
return TRUE;
|
||||
else if (ItemIsMail(itemId) != TRUE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 sub_81221AC(void)
|
||||
{
|
||||
if (is_c1_link_related_active() == TRUE || gReceivedRemoteLinkPlayers == 1)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81221D0(void)
|
||||
{
|
||||
if (!sub_81221AC())
|
||||
return FALSE;
|
||||
else
|
||||
return sub_8087598();
|
||||
}
|
||||
|
||||
bool8 sub_81221EC(void)
|
||||
{
|
||||
if (sub_81221D0() == TRUE)
|
||||
return TRUE;
|
||||
else if (sub_800B504() != TRUE)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_812220C(struct ItemSlot *slots, u8 count, u8 *arg2, u8 *usedSlotsCount, u8 maxUsedSlotsCount)
|
||||
{
|
||||
u16 i;
|
||||
struct ItemSlot *slots_ = slots;
|
||||
|
||||
(*usedSlotsCount) = 0;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (slots_[i].itemId != ITEM_NONE)
|
||||
(*usedSlotsCount)++;
|
||||
}
|
||||
|
||||
(*usedSlotsCount)++;
|
||||
if ((*usedSlotsCount) > maxUsedSlotsCount)
|
||||
*arg2 = maxUsedSlotsCount;
|
||||
else
|
||||
*arg2 = (*usedSlotsCount);
|
||||
}
|
||||
|
||||
void sub_812225C(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3)
|
||||
{
|
||||
if ((*arg0) != 0 && (*arg0) + arg2 > arg3)
|
||||
(*arg0) = arg3 - arg2;
|
||||
|
||||
if ((*arg0) + (*arg1) >= arg3)
|
||||
{
|
||||
if (arg3 == 0)
|
||||
(*arg1) = 0;
|
||||
else
|
||||
(*arg1) = arg3 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8122298(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3, u8 arg4)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
if (arg4 % 2 != 0)
|
||||
{
|
||||
if ((*arg1) >= arg4 / 2)
|
||||
{
|
||||
for (i = 0; i < (*arg1) - (arg4 / 2); i++)
|
||||
{
|
||||
if ((*arg0) + arg2 == arg3)
|
||||
break;
|
||||
(*arg1)--;
|
||||
(*arg0)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*arg1) >= (arg4 / 2) + 1)
|
||||
{
|
||||
for (i = 0; i <= (*arg1) - (arg4 / 2); i++)
|
||||
{
|
||||
if ((*arg0) + arg2 == arg3)
|
||||
break;
|
||||
(*arg1)--;
|
||||
(*arg0)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoadListMenuArrowsGfx(void)
|
||||
{
|
||||
LoadCompressedObjectPic(&gUnknown_0859F514);
|
||||
LoadCompressedObjectPalette(&gUnknown_0859F51C);
|
||||
}
|
||||
|
||||
void sub_8122344(u8 *spriteIds, u8 count)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
spriteIds[i] = CreateSprite(&gUnknown_0859F524, i * 16, 0, 0);
|
||||
if (i != 0)
|
||||
StartSpriteAnim(&gSprites[spriteIds[i]], 1);
|
||||
|
||||
gSprites[spriteIds[i]].invisible = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81223B0(u8 *spriteIds, u8 count)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (i == count - 1)
|
||||
DestroySpriteAndFreeResources(&gSprites[spriteIds[i]]);
|
||||
else
|
||||
DestroySprite(&gSprites[spriteIds[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81223FC(u8 *spriteIds, u8 count, bool8 invisible)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
gSprites[spriteIds[i]].invisible = invisible;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8122448(u8 *spriteIds, u8 count, s16 x, u16 y)
|
||||
{
|
||||
u8 i;
|
||||
bool8 unknownBit = count & 0x80;
|
||||
count &= ~(0x80);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (i == count - 1 && unknownBit)
|
||||
gSprites[spriteIds[i]].pos2.x = x - 8;
|
||||
else
|
||||
gSprites[spriteIds[i]].pos2.x = x;
|
||||
|
||||
gSprites[spriteIds[i]].pos1.y = 1 + y;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
#include "dma3.h"
|
||||
#include "graphics.h"
|
||||
#include "main.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "window.h"
|
||||
#include "list_menu.h"
|
||||
#include "mon_markings.h"
|
||||
#include "constants/songs.h"
|
||||
#include "sound.h"
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "overworld.h"
|
||||
#include "palette.h"
|
||||
#include "party_menu.h"
|
||||
@@ -43,9 +42,6 @@ struct Struct203BCC4
|
||||
u8 spriteIds[7];
|
||||
};
|
||||
|
||||
// extern offset
|
||||
void (*gFieldCallback)(void);
|
||||
|
||||
// static functions
|
||||
static void InitPlayerPCMenu(u8 taskId);
|
||||
static void PlayerPCProcessMenuInput(u8 taskId);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "constants/songs.h"
|
||||
#include "sound.h"
|
||||
#include "berry.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "event_data.h"
|
||||
#include "battle_message.h"
|
||||
#include "safari_zone.h"
|
||||
|
||||
@@ -1184,7 +1184,7 @@ static void sub_817F9F4(struct Sprite *sprite)
|
||||
}
|
||||
|
||||
#else
|
||||
__attribute__((naked))
|
||||
NAKED
|
||||
static void sub_817F9F4(struct Sprite *sprite)
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
|
||||
@@ -646,7 +646,7 @@ static void RotatingGate_ResetAllGateOrientations(void)
|
||||
s32 i;
|
||||
u8 *ptr;
|
||||
|
||||
ptr = (u8 *)GetVarPointer(VAR_0x4000);
|
||||
ptr = (u8 *)GetVarPointer(VAR_TEMP_0);
|
||||
|
||||
for (i = 0; i < gRotatingGate_PuzzleCount; i++)
|
||||
{
|
||||
@@ -656,12 +656,12 @@ static void RotatingGate_ResetAllGateOrientations(void)
|
||||
|
||||
static s32 RotatingGate_GetGateOrientation(u8 gateId)
|
||||
{
|
||||
return ((u8 *)GetVarPointer(VAR_0x4000))[gateId];
|
||||
return ((u8 *)GetVarPointer(VAR_TEMP_0))[gateId];
|
||||
}
|
||||
|
||||
static void RotatingGate_SetGateOrientation(u8 gateId, u8 orientation)
|
||||
{
|
||||
((u8 *)GetVarPointer(VAR_0x4000))[gateId] = orientation;
|
||||
((u8 *)GetVarPointer(VAR_TEMP_0))[gateId] = orientation;
|
||||
}
|
||||
|
||||
static void RotatingGate_RotateInDirection(u8 gateId, u32 rotationDirection)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "list_menu.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "menu_indicators.h"
|
||||
#include "constants/maps.h"
|
||||
#include "constants/songs.h"
|
||||
#include "constants/species.h"
|
||||
@@ -592,7 +591,7 @@ void sub_80E9578(void)
|
||||
|
||||
void sub_80E95D4(void)
|
||||
{
|
||||
VarSet(VAR_0x401F, gUnknown_0858D060[sub_80EA20C(VarGet(VAR_0x4054))]);
|
||||
VarSet(VAR_OBJ_GFX_ID_F, gUnknown_0858D060[sub_80EA20C(VarGet(VAR_0x4054))]);
|
||||
}
|
||||
|
||||
void sub_80E9608(struct Coords16 *coords, struct MapEvents *events)
|
||||
|
||||
@@ -2341,7 +2341,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
__attribute__((naked))
|
||||
NAKED
|
||||
u16 RenderText(struct TextPrinter *textPrinter)
|
||||
{
|
||||
asm("push {r4-r6,lr}\n\
|
||||
|
||||
16
src/tv.c
16
src/tv.c
@@ -3557,7 +3557,7 @@ void GetMomOrDadStringForTVMessage(void)
|
||||
if (gSaveBlock1Ptr->location.mapNum == MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F))
|
||||
{
|
||||
StringCopy(gStringVar1, gText_Mom);
|
||||
VarSet(VAR_0x4003, 1);
|
||||
VarSet(VAR_TEMP_3, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3565,21 +3565,21 @@ void GetMomOrDadStringForTVMessage(void)
|
||||
if (gSaveBlock1Ptr->location.mapNum == MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F))
|
||||
{
|
||||
StringCopy(gStringVar1, gText_Mom);
|
||||
VarSet(VAR_0x4003, 1);
|
||||
VarSet(VAR_TEMP_3, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (VarGet(VAR_0x4003) == 1)
|
||||
if (VarGet(VAR_TEMP_3) == 1)
|
||||
{
|
||||
StringCopy(gStringVar1, gText_Mom);
|
||||
}
|
||||
else if (VarGet(VAR_0x4003) == 2)
|
||||
else if (VarGet(VAR_TEMP_3) == 2)
|
||||
{
|
||||
StringCopy(gStringVar1, gText_Dad);
|
||||
}
|
||||
else if (VarGet(VAR_0x4003) > 2)
|
||||
else if (VarGet(VAR_TEMP_3) > 2)
|
||||
{
|
||||
if (VarGet(VAR_0x4003) % 2 == 0)
|
||||
if (VarGet(VAR_TEMP_3) % 2 == 0)
|
||||
StringCopy(gStringVar1, gText_Mom);
|
||||
else
|
||||
StringCopy(gStringVar1, gText_Dad);
|
||||
@@ -3589,12 +3589,12 @@ void GetMomOrDadStringForTVMessage(void)
|
||||
if (Random() % 2 != 0)
|
||||
{
|
||||
StringCopy(gStringVar1, gText_Mom);
|
||||
VarSet(VAR_0x4003, 1);
|
||||
VarSet(VAR_TEMP_3, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringCopy(gStringVar1, gText_Dad);
|
||||
VarSet(VAR_0x4003, 2);
|
||||
VarSet(VAR_TEMP_3, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user