Merge branch 'master' of https://github.com/pret/pokefirered into sync-cableclub
This commit is contained in:
@@ -44,13 +44,13 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst);
|
||||
|
||||
static const u8 sText_Empty1[] = _("");
|
||||
static const u8 sText_Trainer1LoseText[] = _("{B_TRAINER1_LOSE_TEXT}");
|
||||
static const u8 sText_Trainer2Class[] = _("{B_TRAINER2_CLASS}");
|
||||
static const u8 sText_Trainer2LoseText[] = _("{B_TRAINER2_LOSE_TEXT}");
|
||||
static const u8 sText_Trainer1RecallPkmn1[] = _("{B_TRAINER1_NAME}: {B_OPPONENT_MON1_NAME}, come back!");
|
||||
static const u8 sText_Trainer1WinText[] = _("{B_TRAINER1_WIN_TEXT}");
|
||||
static const u8 sText_Trainer1RecallPkmn2[] = _("{B_TRAINER1_NAME}: {B_OPPONENT_MON2_NAME}, come back!");
|
||||
static const u8 sText_Trainer1RecallBoth[] = _("{B_TRAINER1_NAME}: {B_OPPONENT_MON1_NAME} and\n{B_OPPONENT_MON2_NAME}, come back!");
|
||||
static const u8 sText_Trainer2Name[] = _("{B_TRAINER2_NAME}");
|
||||
static const u8 sText_PkmnGainedEXP[] = _("{B_BUFF1} gained{B_BUFF2}\n{B_TRAINER2_LOSE_TEXT} EXP. Points!\p");
|
||||
static const u8 sText_Trainer2WinText[] = _("{B_TRAINER2_WIN_TEXT}");
|
||||
static const u8 sText_PkmnGainedEXP[] = _("{B_BUFF1} gained{B_BUFF2}\n{B_BUFF3} EXP. Points!\p");
|
||||
static const u8 sText_EmptyString4[] = _("");
|
||||
static const u8 sText_ABoosted[] = _(" a boosted");
|
||||
static const u8 sText_PkmnGrewToLv[] = _("{B_BUFF1} grew to\nLV. {B_BUFF2}!{WAIT_SE}\p");
|
||||
@@ -878,8 +878,8 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT - BATTLESTRINGS_TABLE_ST
|
||||
[STRINGID_POKEFLUTECATCHY - BATTLESTRINGS_TABLE_START] = sText_PlayedFluteCatchyTune,
|
||||
[STRINGID_POKEFLUTE - BATTLESTRINGS_TABLE_START] = sText_PlayedThe,
|
||||
[STRINGID_MONHEARINGFLUTEAWOKE - BATTLESTRINGS_TABLE_START] = sText_PkmnHearingFluteAwoke,
|
||||
[STRINGID_TRAINER2CLASS - BATTLESTRINGS_TABLE_START] = sText_Trainer2Class,
|
||||
[STRINGID_TRAINER2NAME - BATTLESTRINGS_TABLE_START] = sText_Trainer2Name,
|
||||
[STRINGID_TRAINER2LOSETEXT - BATTLESTRINGS_TABLE_START] = sText_Trainer2LoseText,
|
||||
[STRINGID_TRAINER2WINTEXT - BATTLESTRINGS_TABLE_START] = sText_Trainer2WinText,
|
||||
[STRINGID_PLAYERWHITEDOUT - BATTLESTRINGS_TABLE_START] = sText_PlayerWhiteout2,
|
||||
[STRINGID_MONTOOSCAREDTOMOVE - BATTLESTRINGS_TABLE_START] = sText_TooScaredToMove,
|
||||
[STRINGID_GHOSTGETOUTGETOUT - BATTLESTRINGS_TABLE_START] = sText_GetOutGetOut,
|
||||
@@ -2805,7 +2805,10 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) {
|
||||
|
||||
bool8 BattleStringShouldBeColored(u16 stringId)
|
||||
{
|
||||
if (stringId == STRINGID_TRAINER1LOSETEXT || stringId == STRINGID_TRAINER2CLASS || stringId == STRINGID_TRAINER1WINTEXT || stringId == STRINGID_TRAINER2NAME)
|
||||
if (stringId == STRINGID_TRAINER1LOSETEXT
|
||||
|| stringId == STRINGID_TRAINER2LOSETEXT
|
||||
|| stringId == STRINGID_TRAINER1WINTEXT
|
||||
|| stringId == STRINGID_TRAINER2WINTEXT)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+16
-16
@@ -236,7 +236,7 @@ void StartWildBattle(void)
|
||||
|
||||
static void DoStandardWildBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndWildBattle;
|
||||
@@ -248,7 +248,7 @@ static void DoStandardWildBattle(void)
|
||||
|
||||
void StartRoamerBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndWildBattle;
|
||||
@@ -260,7 +260,7 @@ void StartRoamerBattle(void)
|
||||
|
||||
static void DoSafariBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndSafariBattle;
|
||||
@@ -270,7 +270,7 @@ static void DoSafariBattle(void)
|
||||
|
||||
static void DoGhostBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = CB2_EndWildBattle;
|
||||
@@ -291,7 +291,7 @@ static void DoTrainerBattle(void)
|
||||
void StartOldManTutorialBattle(void)
|
||||
{
|
||||
CreateMaleMon(&gEnemyParty[0], SPECIES_WEEDLE, 5);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_ReturnToFieldContinueScriptPlayMapMusic;
|
||||
gBattleTypeFlags = BATTLE_TYPE_OLD_MAN_TUTORIAL;
|
||||
CreateBattleStartTask(B_TRANSITION_SLICED_SCREEN, 0);
|
||||
@@ -299,7 +299,7 @@ void StartOldManTutorialBattle(void)
|
||||
|
||||
void StartScriptedWildBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_WILD_SCRIPTED;
|
||||
CreateBattleStartTask(GetWildBattleTransition(), 0);
|
||||
@@ -309,7 +309,7 @@ void StartScriptedWildBattle(void)
|
||||
|
||||
void StartMarowakBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndMarowakBattle;
|
||||
if (CheckBagHasItem(ITEM_SILPH_SCOPE, 1))
|
||||
{
|
||||
@@ -328,7 +328,7 @@ void StartMarowakBattle(void)
|
||||
|
||||
void StartSouthernIslandBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY;
|
||||
CreateBattleStartTask(GetWildBattleTransition(), 0);
|
||||
@@ -340,7 +340,7 @@ void StartLegendaryBattle(void)
|
||||
{
|
||||
u16 species;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_LEGENDARY_FRLG;
|
||||
species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES);
|
||||
@@ -369,7 +369,7 @@ void StartLegendaryBattle(void)
|
||||
|
||||
void StartGroudonKyogreBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_KYOGRE_GROUDON;
|
||||
if (gGameVersion == VERSION_FIRE_RED)
|
||||
@@ -382,7 +382,7 @@ void StartGroudonKyogreBattle(void)
|
||||
|
||||
void StartRegiBattle(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||
gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI;
|
||||
CreateBattleStartTask(B_TRANSITION_BLUR, MUS_RS_VS_TRAINER);
|
||||
@@ -400,7 +400,7 @@ static void sub_807FAF8(void)
|
||||
// not used
|
||||
static void sub_807FB08(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
StopPlayerAvatar();
|
||||
gMain.savedCallback = sub_807FAF8;
|
||||
@@ -823,8 +823,8 @@ void ConfigureAndSetUpOneTrainerBattle(u8 trainerEventObjId, const u8 *trainerSc
|
||||
gSelectedObjectEvent = trainerEventObjId;
|
||||
gSpecialVar_LastTalked = gObjectEvents[trainerEventObjId].localId;
|
||||
BattleSetup_ConfigureTrainerBattle(trainerScript + 1);
|
||||
ScriptContext1_SetupScript(EventScript_DoTrainerBattleFromApproach);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_DoTrainerBattleFromApproach);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
bool32 GetTrainerFlagFromScriptPointer(const u8 *data)
|
||||
@@ -889,7 +889,7 @@ void StartTrainerBattle(void)
|
||||
gBattleTypeFlags |= BATTLE_TYPE_FIRST_BATTLE;
|
||||
gMain.savedCallback = CB2_EndTrainerBattle;
|
||||
DoTrainerBattle();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
static void CB2_EndTrainerBattle(void)
|
||||
@@ -964,7 +964,7 @@ void StartRematchBattle(void)
|
||||
gBattleTypeFlags = BATTLE_TYPE_TRAINER;
|
||||
gMain.savedCallback = CB2_EndRematchBattle;
|
||||
DoTrainerBattle();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
void ShowTrainerIntroSpeech(void)
|
||||
|
||||
+3
-3
@@ -3178,8 +3178,8 @@ static void Task_ShowBerryCrushRankings(u8 taskId)
|
||||
ClearWindowTilemap(tWindowId);
|
||||
RemoveWindow(tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Enable();
|
||||
UnlockPlayerFieldControls();
|
||||
tState = 0;
|
||||
return;
|
||||
}
|
||||
@@ -3190,7 +3190,7 @@ void ShowBerryCrushRankings(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
taskId = CreateTask(Task_ShowBerryCrushRankings, 0);
|
||||
gTasks[taskId].tPressingSpeeds(0) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[0];
|
||||
gTasks[taskId].tPressingSpeeds(1) = gSaveBlock2Ptr->berryCrush.pressingSpeeds[1];
|
||||
|
||||
+1
-1
@@ -1258,7 +1258,7 @@ static void Task_ContextMenu_FromPartyGiveMenu(u8 taskId)
|
||||
|
||||
static void Task_ContextMenu_FromPokemonPC(u8 taskId)
|
||||
{
|
||||
sResources->exitCallback = Cb2_ReturnToPSS;
|
||||
sResources->exitCallback = CB2_ReturnToPokeStorage;
|
||||
gTasks[taskId].func = BerryPouch_StartFadeToExitCallback;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "bg.h"
|
||||
#include "box_party_pokemon_dropdown.h"
|
||||
#include "malloc.h"
|
||||
|
||||
struct BPPD_MapRect
|
||||
{
|
||||
s16 destX;
|
||||
s16 destY;
|
||||
u16 width;
|
||||
u16 height;
|
||||
s16 destX2;
|
||||
s16 destY2;
|
||||
};
|
||||
|
||||
struct BPPD_Struct
|
||||
{
|
||||
struct BPPD_MapRect map1Rect;
|
||||
struct BPPD_MapRect map2Rect;
|
||||
const void *src1;
|
||||
const void *src2;
|
||||
u16 src1Height;
|
||||
u16 src1Width;
|
||||
u16 src2Width;
|
||||
u16 src2Height;
|
||||
u16 bytesPerRow;
|
||||
u8 mapSize;
|
||||
u8 bgId;
|
||||
bool8 bgUpdateScheduled;
|
||||
};
|
||||
|
||||
static EWRAM_DATA struct BPPD_Struct * sBoxPartyPokemonDropdownPtr = NULL;
|
||||
static EWRAM_DATA u16 sBoxPartyPokemonDropdownCount = 0;
|
||||
|
||||
static void PushMap1(u8 idx);
|
||||
static void PushMap2(u8 idx);
|
||||
|
||||
static const struct {
|
||||
u16 height;
|
||||
u16 width;
|
||||
} sBGdims[2][4] = {
|
||||
{
|
||||
{0x0100, 0x0100},
|
||||
{0x0200, 0x0100},
|
||||
{0x0100, 0x0200},
|
||||
{0x0200, 0x0200}
|
||||
}, {
|
||||
{0x0080, 0x0080},
|
||||
{0x0100, 0x0100},
|
||||
{0x0200, 0x0200},
|
||||
{0x0400, 0x0400}
|
||||
}
|
||||
};
|
||||
|
||||
void AllocBoxPartyPokemonDropdowns(u8 num)
|
||||
{
|
||||
u16 i;
|
||||
sBoxPartyPokemonDropdownPtr = Alloc(num * sizeof(struct BPPD_Struct));
|
||||
sBoxPartyPokemonDropdownCount = sBoxPartyPokemonDropdownPtr == NULL ? 0 : num;
|
||||
for (i = 0; i < sBoxPartyPokemonDropdownCount; i++)
|
||||
{
|
||||
sBoxPartyPokemonDropdownPtr[i].src1 = NULL;
|
||||
sBoxPartyPokemonDropdownPtr[i].bgUpdateScheduled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void FreeBoxPartyPokemonDropdowns(void)
|
||||
{
|
||||
Free(sBoxPartyPokemonDropdownPtr);
|
||||
}
|
||||
|
||||
void CopyAllBoxPartyPokemonDropdownsToVram(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sBoxPartyPokemonDropdownCount; i++)
|
||||
{
|
||||
if (sBoxPartyPokemonDropdownPtr[i].bgUpdateScheduled == TRUE)
|
||||
CopyBoxPartyPokemonDropdownToBgTilemapBuffer(i);
|
||||
}
|
||||
}
|
||||
|
||||
void SetBoxPartyPokemonDropdownMap2(u8 idx, u8 bgId, const void *src, u16 width, u16 height)
|
||||
{
|
||||
u16 screenSize;
|
||||
u16 bgType;
|
||||
|
||||
if (idx < sBoxPartyPokemonDropdownCount)
|
||||
{
|
||||
sBoxPartyPokemonDropdownPtr[idx].src1 = NULL;
|
||||
sBoxPartyPokemonDropdownPtr[idx].src2 = src;
|
||||
sBoxPartyPokemonDropdownPtr[idx].bgId = bgId;
|
||||
sBoxPartyPokemonDropdownPtr[idx].src2Width = width;
|
||||
sBoxPartyPokemonDropdownPtr[idx].src2Height = height;
|
||||
screenSize = GetBgAttribute(bgId, BG_ATTR_SCREENSIZE);
|
||||
bgType = GetBgAttribute(bgId, BG_ATTR_BGTYPE);
|
||||
sBoxPartyPokemonDropdownPtr[idx].src1Height = sBGdims[bgType][screenSize].height;
|
||||
sBoxPartyPokemonDropdownPtr[idx].src1Width = sBGdims[bgType][screenSize].width;
|
||||
if (bgType != 0)
|
||||
sBoxPartyPokemonDropdownPtr[idx].mapSize = 1;
|
||||
else
|
||||
sBoxPartyPokemonDropdownPtr[idx].mapSize = 2;
|
||||
sBoxPartyPokemonDropdownPtr[idx].bytesPerRow = width * sBoxPartyPokemonDropdownPtr[idx].mapSize;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.width = width;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.height = height;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX = 0;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY = 0;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 = 0;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 = 0;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map1Rect = sBoxPartyPokemonDropdownPtr[idx].map2Rect;
|
||||
sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void SetBoxPartyPokemonDropdownMap1Tiles(u8 idx, const void *src)
|
||||
{
|
||||
if (idx < sBoxPartyPokemonDropdownCount)
|
||||
{
|
||||
sBoxPartyPokemonDropdownPtr[idx].src1 = src;
|
||||
sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void SetBoxPartyPokemonDropdownMap2Pos(u8 idx, u16 x, u16 y)
|
||||
{
|
||||
if (idx < sBoxPartyPokemonDropdownCount)
|
||||
{
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 = x;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 = y;
|
||||
sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void SetBoxPartyPokemonDropdownMap2Rect(u8 idx, u16 x, u16 y, u16 width, u16 height)
|
||||
{
|
||||
if (idx < sBoxPartyPokemonDropdownCount)
|
||||
{
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX = x;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY = y;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.width = width;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.height = height;
|
||||
sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void AdjustBoxPartyPokemonDropdownPos(u8 idx, u8 op, s8 param)
|
||||
{
|
||||
if (idx < sBoxPartyPokemonDropdownCount)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case BPPD_MOVE_INNER_LEFT:
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 += param;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.width -= param;
|
||||
break;
|
||||
case BPPD_MOVE_OUTER_LEFT:
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX += param;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.width += param;
|
||||
break;
|
||||
case BPPD_MOVE_INNER_TOP:
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 += param;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.height -= param;
|
||||
break;
|
||||
case BPPD_MOVE_OUTER_TOP:
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY -= param;
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.height += param;
|
||||
break;
|
||||
case BPPD_MOVE_INNER_X:
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 += param;
|
||||
break;
|
||||
case BPPD_MOVE_INNER_Y:
|
||||
sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 += param;
|
||||
break;
|
||||
}
|
||||
sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void CopyBoxPartyPokemonDropdownToBgTilemapBuffer(u8 idx)
|
||||
{
|
||||
if (idx < sBoxPartyPokemonDropdownCount)
|
||||
{
|
||||
if (sBoxPartyPokemonDropdownPtr[idx].src1 != NULL)
|
||||
PushMap1(idx);
|
||||
PushMap2(idx);
|
||||
sBoxPartyPokemonDropdownPtr[idx].map1Rect = sBoxPartyPokemonDropdownPtr[idx].map2Rect;
|
||||
}
|
||||
}
|
||||
|
||||
static void PushMap1(u8 idx)
|
||||
{
|
||||
int i;
|
||||
int run = sBoxPartyPokemonDropdownPtr[idx].mapSize * sBoxPartyPokemonDropdownPtr[idx].src1Height;
|
||||
const void *addr = sBoxPartyPokemonDropdownPtr[idx].src1 + run * sBoxPartyPokemonDropdownPtr[idx].map1Rect.destY2 + sBoxPartyPokemonDropdownPtr[idx].map1Rect.destX2 * sBoxPartyPokemonDropdownPtr[idx].mapSize;
|
||||
for (i = 0; i < sBoxPartyPokemonDropdownPtr[idx].map1Rect.height; i++)
|
||||
{
|
||||
CopyToBgTilemapBufferRect(sBoxPartyPokemonDropdownPtr[idx].bgId, addr, sBoxPartyPokemonDropdownPtr[idx].map1Rect.destX2, sBoxPartyPokemonDropdownPtr[idx].map1Rect.destY2 + i, sBoxPartyPokemonDropdownPtr[idx].map1Rect.width, 1);
|
||||
addr += run;
|
||||
}
|
||||
}
|
||||
|
||||
static void PushMap2(u8 idx)
|
||||
{
|
||||
int i;
|
||||
int run = sBoxPartyPokemonDropdownPtr[idx].mapSize * sBoxPartyPokemonDropdownPtr[idx].src2Width;
|
||||
const void *addr = sBoxPartyPokemonDropdownPtr[idx].src2 + run * sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX * sBoxPartyPokemonDropdownPtr[idx].mapSize;
|
||||
for (i = 0; i < sBoxPartyPokemonDropdownPtr[idx].map2Rect.height; i++)
|
||||
{
|
||||
CopyToBgTilemapBufferRect(sBoxPartyPokemonDropdownPtr[idx].bgId, addr, sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2, sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 + i, sBoxPartyPokemonDropdownPtr[idx].map2Rect.width, 1);
|
||||
addr += run;
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -441,7 +441,7 @@ static void Task_LinkupAwaitTrainerCardData(u8 taskId)
|
||||
if (gLinkType == LINKTYPE_BERRY_BLENDER_SETUP)
|
||||
*UnusedVarNeededToMatch += 0;
|
||||
ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
@@ -456,7 +456,7 @@ static void Task_StopLinkup(u8 taskId)
|
||||
if (!gReceivedRemoteLinkPlayers)
|
||||
{
|
||||
ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
RemoveWindow(gTasks[taskId].tWindowId);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
@@ -467,7 +467,7 @@ static void Task_LinkupFailed(u8 taskId)
|
||||
gSpecialVar_Result = LINKUP_FAILED;
|
||||
ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
|
||||
HideFieldMessageBox();
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ static void Task_LinkupConnectionError(u8 taskId)
|
||||
gSpecialVar_Result = LINKUP_CONNECTION_ERROR;
|
||||
ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
|
||||
HideFieldMessageBox();
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -860,7 +860,7 @@ static void Task_EnterCableClubSeat(u8 taskId)
|
||||
SetLinkWaitingForScript();
|
||||
EraseFieldMessageBox(TRUE);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -869,7 +869,7 @@ static void CreateTask_EnterCableClubSeat(TaskFunc followUpFunc)
|
||||
{
|
||||
u8 taskId = CreateTask(Task_EnterCableClubSeat, 80);
|
||||
SetTaskFuncWithFollowupFunc(taskId, Task_EnterCableClubSeat, followUpFunc);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
static void Task_StartWiredTrade(u8 taskId)
|
||||
@@ -878,7 +878,7 @@ static void Task_StartWiredTrade(u8 taskId)
|
||||
switch (task->tState)
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeScreen(FADE_TO_BLACK, 0);
|
||||
ClearLinkCallback_2();
|
||||
task->tState++;
|
||||
@@ -910,7 +910,7 @@ static void Task_StartWirelessTrade(u8 taskId)
|
||||
switch (tState)
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeScreen(FADE_TO_BLACK, 0);
|
||||
ClearLinkRfuCallback();
|
||||
tState++;
|
||||
@@ -952,7 +952,7 @@ static void CreateTask_StartWiredTrade(void)
|
||||
void StartWiredCableClubTrade(void)
|
||||
{
|
||||
CreateTask_StartWiredTrade();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
void EnterColosseumPlayerSpot(void)
|
||||
@@ -968,7 +968,7 @@ void EnterColosseumPlayerSpot(void)
|
||||
static void CreateTask_EnterCableClubSeatNoFollowup(void)
|
||||
{
|
||||
CreateTask(Task_EnterCableClubSeat, 80);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
void Script_ShowLinkTrainerCard(void)
|
||||
@@ -1010,7 +1010,7 @@ static void Task_WaitExitToScript(u8 taskId)
|
||||
{
|
||||
if (!gReceivedRemoteLinkPlayers)
|
||||
{
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1515,7 +1515,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
|
||||
ClearStdWindowAndFrame(gTasks[taskId].tWindowId, TRUE);
|
||||
RemoveWindow(gTasks[taskId].tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
else if (gMain.newKeys & B_BUTTON)
|
||||
{
|
||||
@@ -1524,7 +1524,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
|
||||
ClearStdWindowAndFrame(gTasks[taskId].tWindowId, TRUE);
|
||||
RemoveWindow(gTasks[taskId].tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1756,7 +1756,7 @@ static void VBlankCB_EggHatch(void)
|
||||
|
||||
void EggHatch(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_EggHatch, 10);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, 0);
|
||||
HelpSystem_Disable();
|
||||
|
||||
@@ -2984,7 +2984,7 @@ static void Task_ShowDodrioBerryPickingRecords(u8 taskId)
|
||||
{
|
||||
RemoveWindow(tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1690,7 +1690,7 @@ void MakeObjectTemplateFromObjectEventGraphicsInfo(u16 graphicsId, void (*callba
|
||||
|
||||
do
|
||||
{
|
||||
if (ScriptContext1_IsScriptSetUp() != TRUE && sub_8112CAC() == TRUE)
|
||||
if (ScriptContext_IsEnabled() != TRUE && sub_8112CAC() == TRUE)
|
||||
spriteTemplate->callback = sub_811246C;
|
||||
else
|
||||
spriteTemplate->callback = callback;
|
||||
|
||||
+17
-17
@@ -97,7 +97,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
|
||||
u8 tileTransitionState = gPlayerAvatar.tileTransitionState;
|
||||
bool8 forcedMove = MetatileBehavior_IsForcedMovementTile(GetPlayerCurMetatileBehavior());
|
||||
|
||||
if (!ScriptContext1_IsScriptSetUp() && IsQuestLogInputDpad() == TRUE)
|
||||
if (!ScriptContext_IsEnabled() && IsQuestLogInputDpad() == TRUE)
|
||||
{
|
||||
QuestLogOverrideJoyVars(input, &newKeys, &heldKeys);
|
||||
}
|
||||
@@ -300,7 +300,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
|
||||
void FieldInput_HandleCancelSignpost(struct FieldInput * input)
|
||||
{
|
||||
if (ScriptContext1_IsScriptSetUp() == TRUE)
|
||||
if (ScriptContext_IsEnabled() == TRUE)
|
||||
{
|
||||
if (gWalkAwayFromSignInhibitTimer != 0)
|
||||
gWalkAwayFromSignInhibitTimer--;
|
||||
@@ -318,13 +318,13 @@ void FieldInput_HandleCancelSignpost(struct FieldInput * input)
|
||||
RegisterQuestLogInput(QL_INPUT_LEFT);
|
||||
else if (input->dpadDirection == DIR_EAST)
|
||||
RegisterQuestLogInput(QL_INPUT_RIGHT);
|
||||
ScriptContext1_SetupScript(EventScript_CancelMessageBox);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_CancelMessageBox);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
else if (input->pressedStartButton)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_CancelMessageBox);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_CancelMessageBox);
|
||||
LockPlayerFieldControls();
|
||||
if (!FuncIsActiveTask(Task_QuestLogPlayback_OpenStartMenu))
|
||||
CreateTask(Task_QuestLogPlayback_OpenStartMenu, 8);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ void FieldInput_HandleCancelSignpost(struct FieldInput * input)
|
||||
|
||||
static void Task_QuestLogPlayback_OpenStartMenu(u8 taskId)
|
||||
{
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
@@ -379,7 +379,7 @@ static bool8 TryStartInteractionScript(struct MapPosition *position, u16 metatil
|
||||
&& script != EventScript_PC)
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext_SetupScript(script);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ static bool8 TryStartCoordEventScript(struct MapPosition *position)
|
||||
|
||||
if (script == NULL)
|
||||
return FALSE;
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext_SetupScript(script);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -659,18 +659,18 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
|
||||
{
|
||||
if (UpdateVsSeekerStepCounter() == TRUE)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_VsSeekerChargingDone);
|
||||
ScriptContext_SetupScript(EventScript_VsSeekerChargingDone);
|
||||
return TRUE;
|
||||
}
|
||||
else if (UpdatePoisonStepCounter() == TRUE)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_FieldPoison);
|
||||
ScriptContext_SetupScript(EventScript_FieldPoison);
|
||||
return TRUE;
|
||||
}
|
||||
else if (ShouldEggHatch())
|
||||
{
|
||||
IncrementGameStat(GAME_STAT_HATCHED_EGGS);
|
||||
ScriptContext1_SetupScript(EventScript_EggHatch);
|
||||
ScriptContext_SetupScript(EventScript_EggHatch);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -807,7 +807,7 @@ static u8 GetFacingSignpostType(u16 metatileBehavior, u8 playerDirection)
|
||||
static void SetUpWalkIntoSignScript(const u8 *script, u8 playerDirection)
|
||||
{
|
||||
gSpecialVar_Facing = playerDirection;
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext_SetupScript(script);
|
||||
SetWalkingIntoSignVars();
|
||||
MsgSetSignPost();
|
||||
}
|
||||
@@ -889,7 +889,7 @@ static bool8 TryStartWarpEventScript(struct MapPosition *position, u16 metatileB
|
||||
if (MetatileBehavior_IsFallWarp(metatileBehavior) == TRUE)
|
||||
{
|
||||
ResetInitialPlayerAvatarState();
|
||||
ScriptContext1_SetupScript(EventScript_1C1361);
|
||||
ScriptContext_SetupScript(EventScript_1C1361);
|
||||
return TRUE;
|
||||
}
|
||||
DoWarp();
|
||||
@@ -1033,7 +1033,7 @@ static const u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent)
|
||||
}
|
||||
if (coordEvent->trigger == 0)
|
||||
{
|
||||
ScriptContext2_RunNewScript(coordEvent->script);
|
||||
RunScriptImmediately(coordEvent->script);
|
||||
return NULL;
|
||||
}
|
||||
if (VarGet(coordEvent->trigger) == (u8)coordEvent->index)
|
||||
@@ -1086,8 +1086,8 @@ void HandleBoulderActivateVictoryRoadSwitch(u16 x, u16 y)
|
||||
if (events[i].x + 7 == x && events[i].y + 7 == y)
|
||||
{
|
||||
QuestLog_CutRecording();
|
||||
ScriptContext1_SetupScript(events[i].script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(events[i].script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -1071,7 +1071,7 @@ static void FieldCallback_UseFly(void)
|
||||
{
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_UseFly, 0);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
}
|
||||
@@ -1108,7 +1108,7 @@ static void FieldCallback_FlyIntoMap(void)
|
||||
gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE;
|
||||
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
|
||||
ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_WEST);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
}
|
||||
@@ -1126,7 +1126,7 @@ static void Task_FlyIntoMap(u8 taskId)
|
||||
}
|
||||
if (!FieldEffectActiveListContains(FLDEFF_FLY_IN))
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
@@ -1156,7 +1156,7 @@ void FieldCB_FallWarpExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CreateTask(Task_FallWarpFieldEffect, 0);
|
||||
gFieldCallback = NULL;
|
||||
@@ -1274,7 +1274,7 @@ static bool8 FallWarpEffect_7(struct Task *task)
|
||||
{
|
||||
s16 x, y;
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
CameraObjectReset1();
|
||||
UnfreezeObjectEvents();
|
||||
InstallCameraPanAheadCallback();
|
||||
@@ -1459,7 +1459,7 @@ static void FieldCB_EscalatorWarpIn(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CreateTask(Task_EscalatorWarpInFieldEffect, 0);
|
||||
gFieldCallback = NULL;
|
||||
@@ -1576,7 +1576,7 @@ static bool8 EscalatorWarpInEffect_7(struct Task *task)
|
||||
if (ObjectEventClearHeldMovementIfFinished(objectEvent))
|
||||
{
|
||||
CameraObjectReset1();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
ObjectEventSetHeldMovement(objectEvent, GetWalkNormalMovementAction(DIR_EAST));
|
||||
DestroyTask(FindTaskIdByFunc(Task_EscalatorWarpInFieldEffect));
|
||||
@@ -1617,7 +1617,7 @@ static void Task_UseWaterfall(u8 taskId)
|
||||
|
||||
static bool8 waterfall_0_setup(struct Task *task, struct ObjectEvent * playerObj)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->data[0]++;
|
||||
return FALSE;
|
||||
@@ -1625,7 +1625,7 @@ static bool8 waterfall_0_setup(struct Task *task, struct ObjectEvent * playerObj
|
||||
|
||||
static bool8 waterfall_1_do_anim_probably(struct Task *task, struct ObjectEvent * playerObj)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
if (!ObjectEventIsMovementOverridden(playerObj))
|
||||
{
|
||||
ObjectEventClearHeldMovementIfFinished(playerObj);
|
||||
@@ -1660,7 +1660,7 @@ static bool8 waterfall_4_wait_player_move_probably(struct Task *task, struct Obj
|
||||
task->data[0] = 3;
|
||||
return TRUE;
|
||||
}
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
DestroyTask(FindTaskIdByFunc(Task_UseWaterfall));
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_WATERFALL);
|
||||
@@ -1702,7 +1702,7 @@ static bool8 DiveFieldEffect_Init(struct Task *task)
|
||||
|
||||
static bool8 DiveFieldEffect_ShowMon(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldEffectArguments[0] = task->data[15];
|
||||
FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT);
|
||||
task->data[0]++;
|
||||
@@ -1869,7 +1869,7 @@ static void FieldCB_LavaridgeGymB1FWarpExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldCallback = NULL;
|
||||
CreateTask(Task_LavaridgeGymB1FWarpExit, 0);
|
||||
}
|
||||
@@ -1922,7 +1922,7 @@ static bool8 LavaridgeGymB1FWarpExitEffect_4(struct Task *task, struct ObjectEve
|
||||
if (ObjectEventClearHeldMovementIfFinished(objectEvent))
|
||||
{
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(FindTaskIdByFunc(Task_LavaridgeGymB1FWarpExit));
|
||||
}
|
||||
@@ -2084,7 +2084,7 @@ static void (*const sEscapeRopeWarpOutEffectFuncs[])(struct Task *task) =
|
||||
|
||||
void StartEscapeRopeFieldEffect(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CreateTask(Task_EscapeRopeWarpOut, 80);
|
||||
}
|
||||
@@ -2270,7 +2270,7 @@ static void FieldCallback_EscapeRopeExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE;
|
||||
@@ -2311,7 +2311,7 @@ static void EscapeRopeWarpInEffect_Spin(struct Task *task)
|
||||
{
|
||||
playerObj->invisible = FALSE;
|
||||
playerObj->fixedPriority = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(FindTaskIdByFunc(Task_EscapeRopeWarpIn));
|
||||
}
|
||||
@@ -2360,7 +2360,7 @@ static void Task_DoTeleportFieldEffect(u8 taskId)
|
||||
|
||||
static void TeleportFieldEffectTask1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CameraObjectReset2();
|
||||
task->data[15] = GetPlayerFacingDirection();
|
||||
@@ -2447,7 +2447,7 @@ static void FieldCallback_TeleportIn(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gFieldCallback = NULL;
|
||||
gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE;
|
||||
@@ -2528,7 +2528,7 @@ static void TeleportInFieldEffectTask3(struct Task *task)
|
||||
task->data[1] = 8;
|
||||
if ((++task->data[2]) > 4 && task->data[14] == objectEvent->facingDirection)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
CameraObjectReset1();
|
||||
UnfreezeObjectEvents();
|
||||
DestroyTask(FindTaskIdByFunc(Task_DoTeleportInFieldEffect));
|
||||
@@ -2997,7 +2997,7 @@ static void Task_FldEffUseSurf(u8 taskId)
|
||||
|
||||
static void UseSurfEffect_1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_SURFING);
|
||||
@@ -3058,7 +3058,7 @@ static void UseSurfEffect_5(struct Task *task)
|
||||
ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(objectEvent->movementDirection));
|
||||
SetSurfBlob_BobState(objectEvent->fieldEffectSpriteId, BOB_PLAYER_AND_MON);
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_SURF);
|
||||
DestroyTask(FindTaskIdByFunc(Task_FldEffUseSurf));
|
||||
SetHelpContext(HELPCONTEXT_SURFING);
|
||||
@@ -3093,7 +3093,7 @@ static void Task_FldEffUseVsSeeker(u8 taskId)
|
||||
|
||||
static void UseVsSeekerEffect_1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->data[0]++;
|
||||
|
||||
+37
-37
@@ -137,7 +137,7 @@ static void Task_ContinueScriptUnionRoom(u8 taskId)
|
||||
|
||||
void FieldCB_ContinueScriptUnionRoom(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_ContinueScriptUnionRoom, 10);
|
||||
@@ -148,13 +148,13 @@ static void Task_ContinueScript(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
void FieldCB_ContinueScriptHandleMusic(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_ContinueScript, 10);
|
||||
@@ -162,7 +162,7 @@ void FieldCB_ContinueScriptHandleMusic(void)
|
||||
|
||||
void FieldCB_ContinueScript(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_ContinueScript, 10);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ static void Task_ReturnToFieldCableLink(u8 taskId)
|
||||
case 2:
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -195,7 +195,7 @@ static void Task_ReturnToFieldCableLink(u8 taskId)
|
||||
|
||||
void FieldCB_ReturnToFieldCableLink(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
palette_bg_faded_fill_black();
|
||||
CreateTask(Task_ReturnToFieldCableLink, 10);
|
||||
@@ -221,7 +221,7 @@ static void Task_ReturnToFieldRecordMixing(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
StartSendingKeysToLink();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -230,7 +230,7 @@ static void Task_ReturnToFieldRecordMixing(u8 taskId)
|
||||
|
||||
void FieldCB_ReturnToFieldWirelessLink(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
palette_bg_faded_fill_black();
|
||||
CreateTask(Task_ReturnToFieldRecordMixing, 10);
|
||||
@@ -290,7 +290,7 @@ void FieldCB_DefaultWarpExit(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
SetUpWarpExitTask(FALSE);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void FieldCB_WarpExitFadeFromBlack(void)
|
||||
@@ -298,7 +298,7 @@ void FieldCB_WarpExitFadeFromBlack(void)
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
SetUpWarpExitTask(TRUE);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void FieldCB_TeleportWarpIn(void)
|
||||
@@ -308,7 +308,7 @@ static void FieldCB_TeleportWarpIn(void)
|
||||
QuestLog_DrawPreviouslyOnQuestHeaderIfInPlaybackMode();
|
||||
PlaySE(SE_WARP_OUT);
|
||||
CreateTask(Task_TeleportWarpIn, 10);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void Task_ExitDoor(u8 taskId)
|
||||
@@ -393,7 +393,7 @@ static void Task_ExitDoor(u8 taskId)
|
||||
break;
|
||||
case 4:
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ static void Task_ExitNonAnimDoor(u8 taskId)
|
||||
break;
|
||||
case 3:
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
@@ -441,14 +441,14 @@ static void Task_ExitNonDoor(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished())
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -461,7 +461,7 @@ static void Task_TeleportWarpIn(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartTeleportInPlayerAnim();
|
||||
gTasks[taskId].data[0]++;
|
||||
break;
|
||||
@@ -469,7 +469,7 @@ static void Task_TeleportWarpIn(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() && WaitTeleportInPlayerAnim() != TRUE)
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -489,7 +489,7 @@ void FadeTransition_FadeInOnReturnToStartMenu(void)
|
||||
{
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_WaitFadeAndCreateStartMenuTask, 80);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
bool8 FieldCB_ReturnToFieldOpenStartMenu(void)
|
||||
@@ -502,7 +502,7 @@ static void Task_SafariZoneRanOutOfBalls(u8 taskId)
|
||||
{
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
}
|
||||
@@ -510,7 +510,7 @@ static void Task_SafariZoneRanOutOfBalls(u8 taskId)
|
||||
|
||||
void FieldCB_SafariZoneRanOutOfBalls(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
FadeInFromBlack();
|
||||
CreateTask(Task_SafariZoneRanOutOfBalls, 10);
|
||||
@@ -531,7 +531,7 @@ bool32 FieldFadeTransitionBackgroundEffectIsFinished(void)
|
||||
|
||||
void DoWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
WarpFadeOutScreen();
|
||||
PlayRainStoppingSoundEffect();
|
||||
@@ -542,7 +542,7 @@ void DoWarp(void)
|
||||
|
||||
void DoDiveWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
WarpFadeOutScreen();
|
||||
PlayRainStoppingSoundEffect();
|
||||
@@ -560,21 +560,21 @@ void DoStairWarp(u16 metatileBehavior, u16 delay)
|
||||
|
||||
void DoDoorWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_DefaultWarpExit;
|
||||
CreateTask(Task_DoorWarp, 10);
|
||||
}
|
||||
|
||||
void DoTeleport2Warp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_Teleport2Warp, 10);
|
||||
gFieldCallback = FieldCB_TeleportWarpIn;
|
||||
}
|
||||
|
||||
void DoUnionRoomWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_DefaultWarpExit;
|
||||
CreateTask(Task_TeleportWarp, 10);
|
||||
}
|
||||
@@ -587,25 +587,25 @@ void DoFallWarp(void)
|
||||
|
||||
void DoEscalatorWarp(u8 metatileBehavior)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartEscalatorWarp(metatileBehavior, 10);
|
||||
}
|
||||
|
||||
void DoLavaridgeGymB1FWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartLavaridgeGymB1FWarp(10);
|
||||
}
|
||||
|
||||
void DoLavaridgeGym1FWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
StartLavaridgeGym1FWarp(10);
|
||||
}
|
||||
|
||||
void DoTeleportWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
CreateTask(Task_TeleportWarp, 10);
|
||||
gFieldCallback = FieldCB_TeleportWarpIn;
|
||||
@@ -613,7 +613,7 @@ void DoTeleportWarp(void)
|
||||
|
||||
static void DoPortholeWarp(void) // Unused
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
WarpFadeOutScreen();
|
||||
CreateTask(Task_Teleport2Warp, 10);
|
||||
gFieldCallback = nullsub_60;
|
||||
@@ -625,7 +625,7 @@ static void Task_CableClubWarp(u8 taskId)
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -642,7 +642,7 @@ static void Task_CableClubWarp(u8 taskId)
|
||||
|
||||
void DoCableClubWarp(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
TryFadeOutOldMapMusic();
|
||||
WarpFadeOutScreen();
|
||||
PlaySE(SE_EXIT);
|
||||
@@ -691,7 +691,7 @@ static void Task_Teleport2Warp(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -713,7 +713,7 @@ static void Task_TeleportWarp(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
PlaySE(SE_WARP_IN);
|
||||
StartTeleportWarpOutPlayerAnim();
|
||||
task->data[0]++;
|
||||
@@ -796,7 +796,7 @@ static void Task_StairWarp(u8 taskId)
|
||||
switch (data[0])
|
||||
{
|
||||
case 0:
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
CameraObjectReset2();
|
||||
data[0]++;
|
||||
@@ -898,14 +898,14 @@ static void Task_ExitStairs(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
CameraObjectReset1();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
WarpFadeInScreen();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
ExitStairsMovement(&data[1], &data[2], &data[3], &data[4], &data[5]);
|
||||
data[0]++;
|
||||
break;
|
||||
|
||||
+10
-10
@@ -1417,7 +1417,7 @@ static void Task_BumpBoulder(u8 taskId)
|
||||
|
||||
static bool8 DoBoulderInit(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->data[0]++;
|
||||
return FALSE;
|
||||
@@ -1453,7 +1453,7 @@ static bool8 DoBoulderFinish(struct Task *task, struct ObjectEvent *playerObject
|
||||
HandleBoulderFallThroughHole(strengthObject);
|
||||
HandleBoulderActivateVictoryRoadSwitch(strengthObject->currentCoords.x, strengthObject->currentCoords.y);
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(FindTaskIdByFunc(Task_BumpBoulder));
|
||||
}
|
||||
return FALSE;
|
||||
@@ -1518,7 +1518,7 @@ static bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *task, struct Objec
|
||||
task->data[0]++;
|
||||
task->data[1] = objectEvent->movementDirection;
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
PlaySE(SE_WARP_IN);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1564,7 +1564,7 @@ static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct Objec
|
||||
if (ObjectEventClearHeldMovementIfFinished(objectEvent))
|
||||
{
|
||||
QL_TryRecordPlayerStepWithDuration0(objectEvent, GetWalkSlowerMovementAction(GetOppositeDirection(task->data[1])));
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
DestroyTask(FindTaskIdByFunc(PlayerAvatar_DoSecretBaseMatSpin));
|
||||
}
|
||||
@@ -1575,7 +1575,7 @@ static void CreateStopSurfingTask(u8 direction)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
Overworld_ClearSavedMusic();
|
||||
Overworld_ChangeMusicToDefault();
|
||||
@@ -1591,7 +1591,7 @@ void CreateStopSurfingTask_NoMusicChange(u8 direction)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING;
|
||||
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
@@ -1633,7 +1633,7 @@ static void Task_WaitStopSurfing(u8 taskId)
|
||||
ObjectEventSetGraphicsId(playerObjEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_NORMAL));
|
||||
QL_TryRecordPlayerStepWithDuration0(playerObjEvent, GetFaceDirectionMovementAction(playerObjEvent->facingDirection));
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
DestroySprite(&gSprites[playerObjEvent->fieldEffectSpriteId]);
|
||||
DestroyTask(taskId);
|
||||
@@ -1696,7 +1696,7 @@ static void Task_Fishing(u8 taskId)
|
||||
|
||||
static bool8 Fishing1(struct Task *task)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
task->tStep++;
|
||||
return FALSE;
|
||||
@@ -1880,7 +1880,7 @@ static bool8 Fishing11(struct Task *task)
|
||||
if (task->tFrameCounter != 0)
|
||||
{
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
FishingWildEncounter(task->tFishingRod);
|
||||
DestroyTask(FindTaskIdByFunc(Task_Fishing));
|
||||
}
|
||||
@@ -1940,7 +1940,7 @@ static bool8 Fishing16(struct Task *task)
|
||||
if (!IsTextPrinterActive(0))
|
||||
{
|
||||
gPlayerAvatar.preventStep = FALSE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnfreezeObjectEvents();
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
DestroyTask(FindTaskIdByFunc(Task_Fishing));
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId)
|
||||
gSpecialVar_Result = TRUE;
|
||||
else
|
||||
gSpecialVar_Result = FALSE;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId)
|
||||
void TryFieldPoisonWhiteOut(void)
|
||||
{
|
||||
CreateTask(Task_TryFieldPoisonWhiteOut, 80);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
}
|
||||
|
||||
s32 DoPoisonFieldEffect(void)
|
||||
|
||||
@@ -154,7 +154,7 @@ static void sub_807EF7C(u8 taskId)
|
||||
{
|
||||
if (!FuncIsActiveTask(UpdateFlashLevelEffect))
|
||||
{
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ void AnimateFlash(u8 flashLevel)
|
||||
value = TRUE;
|
||||
sub_807EFC8(120, 80, sFlashLevelPixelRadii[curFlashLevel], sFlashLevelPixelRadii[flashLevel], value, 2);
|
||||
sub_807EFA4();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void WriteFlashScanlineEffectBuffer(u8 flashLevel)
|
||||
@@ -221,7 +221,7 @@ static void Task_EnableScriptAfterMusicFade(u8 taskId)
|
||||
if (BGMusicStopped() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,14 +435,14 @@ static void Task_RushInjuredPokemonToCenter(u8 taskId)
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
ScriptContext1_SetupScript(EventScript_AfterWhiteOutHeal);
|
||||
ScriptContext_SetupScript(EventScript_AfterWhiteOutHeal);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
ScriptContext1_SetupScript(EventScript_AfterWhiteOutMomHeal);
|
||||
ScriptContext_SetupScript(EventScript_AfterWhiteOutMomHeal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ void FieldCB_RushInjuredPokemonToCenter(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
palette_bg_faded_fill_black();
|
||||
taskId = CreateTask(Task_RushInjuredPokemonToCenter, 10);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
|
||||
+12
-12
@@ -91,7 +91,7 @@ void ShowDiploma(void)
|
||||
{
|
||||
QuestLog_CutRecording();
|
||||
SetMainCallback2(CB2_ShowDiploma);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void ForcePlayerOntoBike(void)
|
||||
@@ -497,7 +497,7 @@ static void Task_ShakeScreen(u8 taskId)
|
||||
static void Task_EndScreenShake(u8 taskId)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
#undef tYtrans
|
||||
@@ -1083,7 +1083,7 @@ static void Task_ElevatorShake(u8 taskId)
|
||||
{
|
||||
PlaySE(SE_DING_DONG);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
InstallCameraPanAheadCallback();
|
||||
}
|
||||
}
|
||||
@@ -1336,7 +1336,7 @@ static void Task_CreateScriptListMenu(u8 taskId)
|
||||
s32 mwidth;
|
||||
struct Task *task = &gTasks[taskId];
|
||||
u8 windowId;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
if (gSpecialVar_0x8004 == LISTMENU_SILPHCO_FLOORS)
|
||||
sListMenuLastScrollPosition = sElevatorScroll;
|
||||
else
|
||||
@@ -1432,7 +1432,7 @@ static void Task_ListMenuHandleInput(u8 taskId)
|
||||
{
|
||||
Task_ListMenuRemoveScrollIndicatorArrowPair(taskId);
|
||||
task->func = Task_SuspendListMenu;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ static void Task_DestroyListMenu(u8 taskId)
|
||||
CopyWindowToVram(task->data[13], COPYWIN_GFX);
|
||||
RemoveWindow(task->data[13]);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
static void Task_SuspendListMenu(u8 taskId)
|
||||
@@ -1470,14 +1470,14 @@ void ReturnToListMenu(void)
|
||||
{
|
||||
u8 taskId = FindTaskIdByFunc(Task_SuspendListMenu);
|
||||
if (taskId == 0xFF)
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
else
|
||||
gTasks[taskId].data[6]++;
|
||||
}
|
||||
|
||||
static void Task_RedrawScrollArrowsAndWaitInput(u8 taskId)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Task_CreateMenuRemoveScrollIndicatorArrowPair(taskId);
|
||||
gTasks[taskId].func = Task_ListMenuHandleInput;
|
||||
}
|
||||
@@ -2317,7 +2317,7 @@ void CutMoveOpenDottedHoleDoor(void)
|
||||
DrawWholeMapView();
|
||||
PlaySE(SE_BANG);
|
||||
FlagSet(FLAG_USED_CUT_ON_RUIN_VALLEY_BRAILLE);
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static const u16 sDeoxysObjectPals[][16] = {
|
||||
@@ -2373,7 +2373,7 @@ static void Task_DoDeoxysTriangleInteraction(u8 taskId)
|
||||
if (FlagGet(FLAG_SYS_DEOXYS_AWAKENED) == TRUE)
|
||||
{
|
||||
gSpecialVar_Result = 3;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
@@ -2392,7 +2392,7 @@ static void Task_DoDeoxysTriangleInteraction(u8 taskId)
|
||||
{
|
||||
FlagSet(FLAG_SYS_DEOXYS_AWAKENED);
|
||||
gSpecialVar_Result = 2;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
else
|
||||
@@ -2434,7 +2434,7 @@ static void Task_WaitDeoxysFieldEffect(u8 taskId)
|
||||
{
|
||||
if (!FieldEffectActiveListContains(FLDEFF_MOVE_DEOXYS_ROCK))
|
||||
{
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ static void Task_RunTimeBasedEvents(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (!QL_IS_PLAYBACK_STATE)
|
||||
{
|
||||
|
||||
@@ -315,7 +315,7 @@ static void UpdateDroughtBlend(u8 taskId)
|
||||
task->tState++;
|
||||
break;
|
||||
case 4:
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-3
@@ -177,7 +177,7 @@ bool8 FldEff_UseCutOnGrass(void)
|
||||
static void FieldCallback_CutTree(void)
|
||||
{
|
||||
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
||||
ScriptContext1_SetupScript(EventScript_FldEffCut);
|
||||
ScriptContext_SetupScript(EventScript_FldEffCut);
|
||||
}
|
||||
|
||||
bool8 FldEff_UseCutOnTree(void)
|
||||
@@ -284,12 +284,12 @@ static void SpriteCallback_CutGrass_Cleanup(struct Sprite *sprite)
|
||||
FieldEffectStop(&gSprites[sCutGrassSpriteArrayPtr[0]], FLDEFF_CUT_GRASS);
|
||||
Free(sCutGrassSpriteArrayPtr);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void FieldMoveCallback_CutTree(void)
|
||||
{
|
||||
PlaySE(SE_M_CUT);
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_CUT_ON_TREE);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ static void FldEff_UseFlash(void)
|
||||
{
|
||||
PlaySE(SE_M_REFLECT);
|
||||
FlagSet(FLAG_SYS_FLASH_ACTIVE);
|
||||
ScriptContext1_SetupScript(EventScript_FldEffFlash);
|
||||
ScriptContext_SetupScript(EventScript_FldEffFlash);
|
||||
}
|
||||
|
||||
// Map transition animatics
|
||||
|
||||
@@ -46,7 +46,7 @@ static void Task_FieldEffectShowMon_Init(u8 taskId)
|
||||
{
|
||||
u8 mapObjId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
mapObjId = gPlayerAvatar.objectEventId;
|
||||
if (!ObjectEventIsMovementOverridden(&gObjectEvents[mapObjId])
|
||||
@@ -117,7 +117,7 @@ bool8 SetUpFieldMove_RockSmash(void)
|
||||
static void sub_80C9A10(void)
|
||||
{
|
||||
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
||||
ScriptContext1_SetupScript(EventScript_FldEffRockSmash);
|
||||
ScriptContext_SetupScript(EventScript_FldEffRockSmash);
|
||||
}
|
||||
|
||||
bool8 FldEff_UseRockSmash(void)
|
||||
@@ -133,5 +133,5 @@ static void sub_80C9A60(void)
|
||||
{
|
||||
PlaySE(SE_M_ROCK_THROW);
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_ROCK_SMASH);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ bool8 SetUpFieldMove_Strength(void)
|
||||
static void FieldCB_UseStrength(void)
|
||||
{
|
||||
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
||||
ScriptContext1_SetupScript(EventScript_FldEffStrength);
|
||||
ScriptContext_SetupScript(EventScript_FldEffStrength);
|
||||
}
|
||||
|
||||
bool8 FldEff_UseStrength(void)
|
||||
@@ -42,5 +42,5 @@ bool8 FldEff_UseStrength(void)
|
||||
static void ShowMonCB_UseStrength(void)
|
||||
{
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_STRENGTH);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ static void FailSweetScentEncounter(u8 taskId)
|
||||
CpuFastCopy(sPlttBufferBak, gPlttBufferUnfaded, PLTT_SIZE);
|
||||
WeatherProcessingIdle();
|
||||
Free(sPlttBufferBak);
|
||||
ScriptContext1_SetupScript(EventScript_FailSweetScent);
|
||||
ScriptContext_SetupScript(EventScript_FailSweetScent);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-7
@@ -1251,13 +1251,11 @@ const u32 gPokeSummary_StatusAilmentIconTiles[] = INCBIN_U32("graphics/interface
|
||||
const u16 gDexScreen_TopMenuIconPals_AtoZ[] = INCBIN_U16("graphics/pokedex/cat_icon_abc.gbapal");
|
||||
const u32 gDexScreen_TopMenuIconTiles_AtoZ[] = INCBIN_U32("graphics/pokedex/cat_icon_abc.4bpp.lz");
|
||||
|
||||
const u16 gPSSMenu_Pal[] = INCBIN_U16("graphics/interface/box_tiles_pal1.gbapal");
|
||||
const u16 gUnknown_8E9C3F8[] = INCBIN_U16("graphics/interface/box_tiles_pal2.gbapal");
|
||||
const u16 gUnknown_8E9C418[] = INCBIN_U16("graphics/interface/box_tiles_pal3.gbapal");
|
||||
const u32 gPSSMenu_Gfx[] = INCBIN_U32("graphics/interface/box_tiles.4bpp.lz");
|
||||
|
||||
const u32 gUnknown_8E9CAEC[] = INCBIN_U32("graphics/unknown/unknown_E9CAEC.bin.lz");
|
||||
|
||||
const u16 gPokeStoragePartyMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/party_menu.gbapal");
|
||||
const u16 gPokeStorageInterface_Pal[] = INCBIN_U16("graphics/pokemon_storage/interface.gbapal");
|
||||
const u16 gPokeStorageInterface_NoDisplayMon_Pal[] = INCBIN_U16("graphics/pokemon_storage/interface_no_display_mon.gbapal");
|
||||
const u32 gPokeStorageMenu_Gfx[] = INCBIN_U32("graphics/pokemon_storage/menu.4bpp.lz");
|
||||
const u32 gPokeStoragePartyMenu_Tilemap[] = INCBIN_U32("graphics/pokemon_storage/party_menu.bin.lz");
|
||||
const u16 gMonMarkingsMenu_Pal[] = INCBIN_U16("graphics/misc/markings2.gbapal");
|
||||
const u16 gMonMarkingsMenu_Gfx[] = INCBIN_U16("graphics/misc/markings2.4bpp");
|
||||
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ static void Task_WaitFadeAndSetCallback(u8 taskId)
|
||||
void HallOfFamePCBeginFade(void)
|
||||
{
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_WaitFadeAndSetCallback, 0);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ void ReturnFromHallOfFamePC(void)
|
||||
|
||||
static void ReshowPCMenuAfterHallOfFamePC(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
CreatePCMenu();
|
||||
ScriptMenu_DisplayPCStartupPrompt();
|
||||
|
||||
+3
-3
@@ -1784,7 +1784,7 @@ static void GoToBerryPouch_PCBox(void)
|
||||
|
||||
static void ReturnToBagMenuFromSubmenu_PCBox(void)
|
||||
{
|
||||
GoToBagMenu(ITEMMENULOCATION_PCBOX, OPEN_BAG_LAST, Cb2_ReturnToPSS);
|
||||
GoToBagMenu(ITEMMENULOCATION_PCBOX, OPEN_BAG_LAST, CB2_ReturnToPokeStorage);
|
||||
}
|
||||
|
||||
static void Task_ItemContext_Sell(u8 taskId)
|
||||
@@ -2033,7 +2033,7 @@ bool8 UseRegisteredKeyItemOnField(void)
|
||||
{
|
||||
if (CheckBagHasItem(gSaveBlock1Ptr->registeredItem, 1) == TRUE)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjectEvents();
|
||||
HandleEnforcedLookDirectionOnPlayerStopMoving();
|
||||
StopPlayerAvatar();
|
||||
@@ -2044,7 +2044,7 @@ bool8 UseRegisteredKeyItemOnField(void)
|
||||
}
|
||||
gSaveBlock1Ptr->registeredItem = ITEM_NONE;
|
||||
}
|
||||
ScriptContext1_SetupScript(EventScript_BagItemCanBeRegistered);
|
||||
ScriptContext_SetupScript(EventScript_BagItemCanBeRegistered);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -197,7 +197,7 @@ static void Task_ItemUse_CloseMessageBoxAndReturnToField(u8 taskId)
|
||||
ClearDialogWindowAndFrame(0, 1);
|
||||
DestroyTask(taskId);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId)
|
||||
@@ -218,7 +218,7 @@ static void sub_80A1184(void)
|
||||
static bool8 sub_80A1194(void)
|
||||
{
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FadeInFromBlack();
|
||||
CreateTask(sub_80A11C0, 10);
|
||||
gExitStairsMovementDisabled = FALSE;
|
||||
@@ -230,7 +230,7 @@ static void sub_80A11C0(u8 taskId)
|
||||
if (IsWeatherNotFadingIn() == TRUE)
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ static void ItemUseOnFieldCB_Bicycle(u8 taskId)
|
||||
PlaySE(SE_BIKE_BELL);
|
||||
GetOnOffBike(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -151,7 +151,7 @@ static void Task_NoResponse_CleanUp(u8 taskId)
|
||||
{
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ static void Task_ItemfinderResponseCleanUp(u8 taskId)
|
||||
DestroyArrowAndStarTiles();
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
@@ -500,8 +500,8 @@ static void Task_ItemfinderUnderfootDigUpItem(u8 taskId)
|
||||
{
|
||||
DestroyArrowAndStarTiles();
|
||||
DestroyTask(taskId);
|
||||
ScriptContext1_SetupScript(EventScript_ItemfinderDigUpUnderfootItem);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(EventScript_ItemfinderDigUpUnderfootItem);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
#undef tStartSpriteId
|
||||
|
||||
+1
-1
@@ -366,7 +366,7 @@ static void VBlankCB_MoveRelearner(void)
|
||||
|
||||
void DisplayMoveTutorMenu(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_InitMoveRelearnerMenu, 10);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ void MapPreview_StartForestTransition(u8 mapsec)
|
||||
SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR | WININ_WIN1_CLR);
|
||||
SetGpuRegBits(REG_OFFSET_WINOUT, WINOUT_WIN01_CLR);
|
||||
gTasks[taskId].data[11] = MapPreview_CreateMapNameWindow(mapsec);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
u16 MapPreview_CreateMapNameWindow(u8 mapsec)
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ static u32 client_mainseq_4(struct mevent_client * svr)
|
||||
MEvent_ReceiveDistributionMon(svr->recvBuffer);
|
||||
break;
|
||||
case 17:
|
||||
MEventSetRamScript(svr->recvBuffer, 1000);
|
||||
InitRamScript_NoObjectEvent(svr->recvBuffer, 1000);
|
||||
break;
|
||||
case 18:
|
||||
memcpy(&gSaveBlock2Ptr->battleTower.ereaderTrainer, svr->recvBuffer, sizeof(struct BattleTowerEReaderTrainer));
|
||||
|
||||
@@ -145,7 +145,7 @@ bool8 MEScrCmd_setmsg(struct ScriptContext *ctx)
|
||||
bool8 MEScrCmd_runscript(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 *script = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
ScriptContext2_RunNewScript(script);
|
||||
RunScriptImmediately(script);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ void NewGameInitData(void)
|
||||
InitMEventData();
|
||||
SetAllRenewableItemFlags();
|
||||
WarpToPlayersRoom();
|
||||
ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags);
|
||||
RunScriptImmediately(EventScript_ResetAllMapFlags);
|
||||
StringCopy(gSaveBlock1Ptr->rivalName, rivalName);
|
||||
ResetTrainerTowerResults();
|
||||
}
|
||||
|
||||
+40
-40
@@ -243,7 +243,7 @@ static const u16 sWhiteOutMoneyLossBadgeFlagIDs[] = {
|
||||
|
||||
static void DoWhiteOut(void)
|
||||
{
|
||||
ScriptContext2_RunNewScript(EventScript_ResetEliteFourEnd);
|
||||
RunScriptImmediately(EventScript_ResetEliteFourEnd);
|
||||
RemoveMoney(&gSaveBlock1Ptr->money, ComputeWhiteOutMoneyLoss());
|
||||
HealPlayerParty();
|
||||
Overworld_ResetStateAfterWhitingOut();
|
||||
@@ -1394,13 +1394,13 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
|
||||
FieldClearPlayerInput(&fieldInput);
|
||||
FieldGetPlayerInput(&fieldInput, newKeys, heldKeys);
|
||||
FieldInput_HandleCancelSignpost(&fieldInput);
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (ProcessPlayerFieldInput(&fieldInput) == TRUE)
|
||||
{
|
||||
if (gQuestLogPlaybackState == 2)
|
||||
sub_81127F8(&gInputToStoreInQuestLogMaybe);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
DismissMapNamePopup();
|
||||
}
|
||||
else
|
||||
@@ -1421,11 +1421,11 @@ static void DoCB1_Overworld_QuestLogPlayback(void)
|
||||
FieldClearPlayerInput(&fieldInput);
|
||||
fieldInput = gQuestLogFieldInput;
|
||||
FieldInput_HandleCancelSignpost(&fieldInput);
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
if (ProcessPlayerFieldInput(&fieldInput) == TRUE)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
DismissMapNamePopup();
|
||||
}
|
||||
else
|
||||
@@ -1453,7 +1453,7 @@ void CB1_Overworld(void)
|
||||
|
||||
static void OverworldBasic(void)
|
||||
{
|
||||
ScriptContext2_RunScript();
|
||||
ScriptContext_RunScript();
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
CameraUpdate();
|
||||
@@ -1519,8 +1519,8 @@ void CB2_NewGame(void)
|
||||
NewGameInitData();
|
||||
ResetInitialPlayerAvatarState();
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_WarpExitFadeFromBlack;
|
||||
gFieldCallback2 = NULL;
|
||||
DoMapLoadLoop(&gMain.state);
|
||||
@@ -1540,8 +1540,8 @@ void CB2_WhiteOut(void)
|
||||
ResetSafariZoneFlag_();
|
||||
DoWhiteOut();
|
||||
SetInitialPlayerAvatarStateWithDirection(DIR_NORTH);
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback = FieldCB_RushInjuredPokemonToCenter;
|
||||
val = 0;
|
||||
DoMapLoadLoop(&val);
|
||||
@@ -1555,8 +1555,8 @@ void CB2_WhiteOut(void)
|
||||
void CB2_LoadMap(void)
|
||||
{
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
SetMainCallback2(CB2_DoChangeMap);
|
||||
gMain.savedCallback = CB2_LoadMap2;
|
||||
@@ -1635,8 +1635,8 @@ void CB2_ReturnToFieldFromMultiplayer(void)
|
||||
else
|
||||
gFieldCallback = FieldCB_ReturnToFieldCableLink;
|
||||
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
CB2_ReturnToField();
|
||||
}
|
||||
|
||||
@@ -1686,8 +1686,8 @@ void CB2_ContinueSavedGame(void)
|
||||
Overworld_ResetStateOnContinue();
|
||||
InitMapFromSavedGame();
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
gFieldCallback2 = NULL;
|
||||
gExitStairsMovementDisabled = TRUE;
|
||||
if (UseContinueGameWarp() == TRUE)
|
||||
@@ -1761,8 +1761,8 @@ static bool32 LoadMapInStepsLink(u8 *state)
|
||||
{
|
||||
case 0:
|
||||
InitOverworldBgs();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
(*state)++;
|
||||
break;
|
||||
case 1:
|
||||
@@ -2198,8 +2198,8 @@ void CB2_SetUpOverworldForQLPlaybackWithWarpExit(void)
|
||||
{
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
gGlobalFieldTintMode = QL_TINT_GRAYSCALE;
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
SetMainCallback2(CB2_DoChangeMap);
|
||||
gMain.savedCallback = CB2_LoadMapForQLPlayback;
|
||||
@@ -2210,8 +2210,8 @@ void CB2_SetUpOverworldForQLPlayback(void)
|
||||
FieldClearVBlankHBlankCallbacks();
|
||||
gGlobalFieldTintMode = QL_TINT_GRAYSCALE;
|
||||
LoadSaveblockMapHeader();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
SetMainCallback2(CB2_LoadMapForQLPlayback);
|
||||
}
|
||||
@@ -2318,7 +2318,7 @@ void CB2_EnterFieldFromQuestLog(void)
|
||||
Overworld_ResetStateOnContinue();
|
||||
InitMapFromSavedGame();
|
||||
PlayTimeCounter_Start();
|
||||
ScriptContext1_Init();
|
||||
ScriptContext_Init();
|
||||
gExitStairsMovementDisabled = TRUE;
|
||||
if (UseContinueGameWarp() == TRUE)
|
||||
{
|
||||
@@ -2389,8 +2389,8 @@ static bool32 SetUpScrollSceneForCredits(u8 *state, u8 unused)
|
||||
sCreditsOverworld_CmdLength = sCreditsOverworld_Script[sCreditsOverworld_CmdIndex].unk_4;
|
||||
WarpIntoMap();
|
||||
gPaletteFade.bufferTransferDisabled = TRUE;
|
||||
ScriptContext1_Init();
|
||||
ScriptContext2_Disable();
|
||||
ScriptContext_Init();
|
||||
UnlockPlayerFieldControls();
|
||||
SetMainCallback1(NULL);
|
||||
gFieldCallback2 = FieldCB2_Credits_WaitFade;
|
||||
gMain.state = 0;
|
||||
@@ -2846,7 +2846,7 @@ static void ResetPlayerHeldKeys(u16 *keys)
|
||||
|
||||
static u16 KeyInterCB_SelfIdle(u32 key)
|
||||
{
|
||||
if (ScriptContext2_IsEnabled() == TRUE)
|
||||
if (ArePlayerFieldControlsLocked() == TRUE)
|
||||
return LINK_KEY_CODE_EMPTY;
|
||||
if (GetLinkRecvQueueLength() > 4)
|
||||
return LINK_KEY_CODE_HANDLE_RECV_QUEUE;
|
||||
@@ -2866,7 +2866,7 @@ static u16 KeyInterCB_Idle(u32 key)
|
||||
static u16 KeyInterCB_DeferToEventScript(u32 key)
|
||||
{
|
||||
u16 retVal;
|
||||
if (ScriptContext2_IsEnabled() == TRUE)
|
||||
if (ArePlayerFieldControlsLocked() == TRUE)
|
||||
{
|
||||
retVal = LINK_KEY_CODE_EMPTY;
|
||||
}
|
||||
@@ -2889,7 +2889,7 @@ static u16 KeyInterCB_DeferToRecvQueue(u32 key)
|
||||
else
|
||||
{
|
||||
retVal = LINK_KEY_CODE_IDLE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
SetKeyInterceptCallback(KeyInterCB_Idle);
|
||||
}
|
||||
return retVal;
|
||||
@@ -2906,7 +2906,7 @@ static u16 KeyInterCB_DeferToSendQueue(u32 key)
|
||||
else
|
||||
{
|
||||
retVal = LINK_KEY_CODE_IDLE;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
SetKeyInterceptCallback(KeyInterCB_Idle);
|
||||
}
|
||||
return retVal;
|
||||
@@ -2959,7 +2959,7 @@ static u16 KeyInterCB_WaitForPlayersToExit(u32 keyOrPlayerId)
|
||||
CheckRfuKeepAliveTimer();
|
||||
if (AreAllPlayersInLinkState(PLAYER_LINK_STATE_EXITING_ROOM) == TRUE)
|
||||
{
|
||||
ScriptContext1_SetupScript(CableClub_EventScript_DoLinkRoomExit);
|
||||
ScriptContext_SetupScript(CableClub_EventScript_DoLinkRoomExit);
|
||||
SetKeyInterceptCallback(KeyInterCB_SendNothing);
|
||||
}
|
||||
return LINK_KEY_CODE_EMPTY;
|
||||
@@ -3137,41 +3137,41 @@ static u16 GetDirectionForEventScript(const u8 *script)
|
||||
|
||||
static void InitLinkPlayerQueueScript(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void InitLinkRoomStartMenuScript(void)
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ShowStartMenu();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void RunInteractLocalPlayerScript(const u8 *script)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void CreateConfirmLeaveTradeRoomPrompt(void)
|
||||
{
|
||||
PlaySE(SE_WIN_OPEN);
|
||||
ScriptContext1_SetupScript(TradeCenter_ConfirmLeaveRoom);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(TradeCenter_ConfirmLeaveRoom);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void InitMenuBasedScript(const u8 *script)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ScriptContext1_SetupScript(script);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(script);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void RunTerminateLinkScript(void)
|
||||
{
|
||||
ScriptContext1_SetupScript(TradeCenter_TerminateLink);
|
||||
ScriptContext2_Enable();
|
||||
ScriptContext_SetupScript(TradeCenter_TerminateLink);
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
bool32 Overworld_LinkRecvQueueLengthMoreThan2(void)
|
||||
|
||||
+2
-2
@@ -6368,7 +6368,7 @@ static void Task_PartyMenuWaitForFade(u8 taskId)
|
||||
if (IsWeatherNotFadingIn())
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
ScriptContext2_Disable();
|
||||
EnableBothScriptContexts();
|
||||
UnlockPlayerFieldControls();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ void ChoosePartyMon(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
taskId = CreateTask(sub_80BF97C, 10);
|
||||
gTasks[taskId].data[0] = PARTY_MENU_TYPE_CHOOSE_MON;
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
@@ -25,7 +25,7 @@ void SelectMoveTutorMon(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
taskId = CreateTask(sub_80BF97C, 10);
|
||||
gTasks[taskId].data[0] = PARTY_MENU_TYPE_MOVE_RELEARNER;
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
|
||||
|
||||
+2
-2
@@ -257,9 +257,9 @@ static void Task_PlayerPcMailbox(u8 taskId)
|
||||
static void Task_PlayerPcTurnOff(u8 taskId)
|
||||
{
|
||||
if (gPlayerPcMenuManager.notInRoom == FALSE)
|
||||
ScriptContext1_SetupScript(EventScript_PalletTown_PlayersHouse_2F_ShutDownPC);
|
||||
ScriptContext_SetupScript(EventScript_PalletTown_PlayersHouse_2F_ShutDownPC);
|
||||
else
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4535,7 +4535,7 @@ static void Task_ShowPokemonJumpRecords(u8 taskId)
|
||||
{
|
||||
RemoveWindow(tWindowId);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,147 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "gflib.h"
|
||||
#include "menu.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "pokemon_storage_system_internal.h"
|
||||
#include "strings.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
void InitMenu(void)
|
||||
{
|
||||
gPSSData->menuItemsCount = 0;
|
||||
gPSSData->menuWidth = 0;
|
||||
gPSSData->menuWindow.bg = 0;
|
||||
gPSSData->menuWindow.paletteNum = 15;
|
||||
gPSSData->menuWindow.baseBlock = 92;
|
||||
}
|
||||
|
||||
static const u8 *const sMenuTexts[] = {
|
||||
[PC_TEXT_CANCEL] = gPCText_Cancel,
|
||||
[PC_TEXT_STORE] = gPCText_Store,
|
||||
[PC_TEXT_WITHDRAW] = gPCText_Withdraw,
|
||||
[PC_TEXT_MOVE] = gPCText_Move,
|
||||
[PC_TEXT_SHIFT] = gPCText_Shift,
|
||||
[PC_TEXT_PLACE] = gPCText_Place,
|
||||
[PC_TEXT_SUMMARY] = gPCText_Summary,
|
||||
[PC_TEXT_RELEASE] = gPCText_Release,
|
||||
[PC_TEXT_MARK] = gPCText_Mark,
|
||||
[PC_TEXT_JUMP] = gPCText_Jump,
|
||||
[PC_TEXT_WALLPAPER] = gPCText_Wallpaper,
|
||||
[PC_TEXT_NAME] = gPCText_Name,
|
||||
[PC_TEXT_TAKE] = gPCText_Take,
|
||||
[PC_TEXT_GIVE] = gPCText_Give,
|
||||
[PC_TEXT_GIVE2] = gPCText_Give,
|
||||
[PC_TEXT_SWITCH] = gPCText_Switch,
|
||||
[PC_TEXT_BAG] = gPCText_Bag,
|
||||
[PC_TEXT_INFO] = gPCText_Info,
|
||||
[PC_TEXT_SCENERY1] = gPCText_Scenery1,
|
||||
[PC_TEXT_SCENERY2] = gPCText_Scenery2,
|
||||
[PC_TEXT_SCENERY3] = gPCText_Scenery3,
|
||||
[PC_TEXT_ETCETERA] = gPCText_Etcetera,
|
||||
[PC_TEXT_FOREST] = gPCText_Forest,
|
||||
[PC_TEXT_CITY] = gPCText_City,
|
||||
[PC_TEXT_DESERT] = gPCText_Desert,
|
||||
[PC_TEXT_SAVANNA] = gPCText_Savanna,
|
||||
[PC_TEXT_CRAG] = gPCText_Crag,
|
||||
[PC_TEXT_VOLCANO] = gPCText_Volcano,
|
||||
[PC_TEXT_SNOW] = gPCText_Snow,
|
||||
[PC_TEXT_CAVE] = gPCText_Cave,
|
||||
[PC_TEXT_BEACH] = gPCText_Beach,
|
||||
[PC_TEXT_SEAFLOOR] = gPCText_Seafloor,
|
||||
[PC_TEXT_RIVER] = gPCText_River,
|
||||
[PC_TEXT_SKY] = gPCText_Sky,
|
||||
[PC_TEXT_POLKADOT] = gPCText_PolkaDot,
|
||||
[PC_TEXT_POKECENTER] = gPCText_Pokecenter,
|
||||
[PC_TEXT_MACHINE] = gPCText_Machine,
|
||||
[PC_TEXT_SIMPLE] = gPCText_Simple,
|
||||
};
|
||||
|
||||
void SetMenuText(u8 textId)
|
||||
{
|
||||
if (gPSSData->menuItemsCount < ARRAY_COUNT(gPSSData->menuItems))
|
||||
{
|
||||
u8 len;
|
||||
struct StorageMenu *menu = &gPSSData->menuItems[gPSSData->menuItemsCount];
|
||||
|
||||
menu->text = sMenuTexts[textId];
|
||||
menu->textId = textId;
|
||||
len = StringLength(menu->text);
|
||||
if (len > gPSSData->menuWidth)
|
||||
gPSSData->menuWidth = len;
|
||||
|
||||
gPSSData->menuItemsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
s8 sub_8094E50(u8 arg0)
|
||||
{
|
||||
if (arg0 >= gPSSData->menuItemsCount)
|
||||
return -1;
|
||||
else
|
||||
return gPSSData->menuItems[arg0].textId;
|
||||
}
|
||||
|
||||
void AddMenu(void)
|
||||
{
|
||||
gPSSData->menuWindow.width = gPSSData->menuWidth + 2;
|
||||
gPSSData->menuWindow.height = 2 * gPSSData->menuItemsCount;
|
||||
gPSSData->menuWindow.tilemapLeft = 29 - gPSSData->menuWindow.width;
|
||||
gPSSData->menuWindow.tilemapTop = 15 - gPSSData->menuWindow.height;
|
||||
gPSSData->menuWindowId = AddWindow(&gPSSData->menuWindow);
|
||||
ClearWindowTilemap(gPSSData->menuWindowId);
|
||||
DrawStdFrameWithCustomTileAndPalette(gPSSData->menuWindowId, FALSE, 0x00b, 14);
|
||||
PrintTextArray(gPSSData->menuWindowId, FONT_1, 8, 2, 16, gPSSData->menuItemsCount, (void *)gPSSData->menuItems);
|
||||
Menu_InitCursor(gPSSData->menuWindowId, FONT_1, 0, 2, 16, gPSSData->menuItemsCount, 0);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
gPSSData->menuUnusedField = 0;
|
||||
}
|
||||
|
||||
bool8 sub_8094F90(void)
|
||||
{
|
||||
// Some debug flag?
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s16 sub_8094F94(void)
|
||||
{
|
||||
s32 textId = -2;
|
||||
|
||||
do
|
||||
{
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
textId = Menu_GetCursorPos();
|
||||
break;
|
||||
}
|
||||
else if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
textId = -1;
|
||||
}
|
||||
|
||||
if (JOY_NEW(DPAD_UP))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
Menu_MoveCursor(-1);
|
||||
}
|
||||
else if (JOY_NEW(DPAD_DOWN))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
Menu_MoveCursor(1);
|
||||
}
|
||||
} while (0);
|
||||
|
||||
if (textId != -2)
|
||||
sub_8095024();
|
||||
|
||||
if (textId >= 0)
|
||||
textId = gPSSData->menuItems[textId].textId;
|
||||
|
||||
return textId;
|
||||
}
|
||||
|
||||
void sub_8095024(void)
|
||||
{
|
||||
ClearStdWindowAndFrameToTransparent(gPSSData->menuWindowId, TRUE);
|
||||
RemoveWindow(gPSSData->menuWindowId);
|
||||
}
|
||||
@@ -1,586 +0,0 @@
|
||||
#include <stdlib.h> // to declare abs
|
||||
#include "global.h"
|
||||
#include "gflib.h"
|
||||
#include "pokemon_icon.h"
|
||||
#include "pokemon_storage_system_internal.h"
|
||||
#include "text_window.h"
|
||||
|
||||
struct MoveMons
|
||||
{
|
||||
u8 field_0;
|
||||
u8 state;
|
||||
u8 fromRow;
|
||||
u8 fromColumn;
|
||||
u8 toRow;
|
||||
u8 toColumn;
|
||||
u8 field_6;
|
||||
u8 field_7;
|
||||
u8 minRow;
|
||||
u8 minColumn;
|
||||
u8 rowsTotal;
|
||||
u8 columsTotal;
|
||||
u16 bgX;
|
||||
u16 bgY;
|
||||
u16 field_10;
|
||||
struct BoxPokemon boxMons[IN_BOX_COUNT];
|
||||
};
|
||||
|
||||
static EWRAM_DATA struct MoveMons *sMoveMonsPtr = NULL;
|
||||
|
||||
static bool8 sub_8095138(void);
|
||||
static bool8 sub_8095234(void);
|
||||
static bool8 sub_80952A0(void);
|
||||
static bool8 sub_8095314(void);
|
||||
static bool8 sub_8095394(void);
|
||||
static bool8 sub_80953BC(void);
|
||||
static void sub_8095520(void);
|
||||
static void sub_80955C4(u8 arg0, u8 arg1, u8 arg2);
|
||||
static void sub_80955FC(u8 arg0, u8 arg1, u8 arg2);
|
||||
static void sub_8095634(u8 arg0, u8 arg1, u8 arg2);
|
||||
static void sub_809566C(u8 arg0, u8 arg1, u8 arg2);
|
||||
static void sub_80956A4(u8 x, u8 y);
|
||||
static void sub_809572C(u8 x, u8 y);
|
||||
static void sub_8095780(u16 bgX, u16 bgY, u16 duration);
|
||||
static u8 sub_8095790(void);
|
||||
static void sub_80957C8(void);
|
||||
static void sub_80958A0(void);
|
||||
static void sub_8095918(void);
|
||||
static void sub_80959A8(void);
|
||||
static void sub_8095A58(void);
|
||||
|
||||
static const struct WindowTemplate gUnknown_83D35D4 = {
|
||||
.bg = 0,
|
||||
.tilemapLeft = 10,
|
||||
.tilemapTop = 3,
|
||||
.width = 20,
|
||||
.height = 18,
|
||||
.paletteNum = 9,
|
||||
.baseBlock = 0x00a
|
||||
};
|
||||
|
||||
bool8 sub_8095050(void)
|
||||
{
|
||||
sMoveMonsPtr = Alloc(sizeof(*sMoveMonsPtr));
|
||||
if (sMoveMonsPtr != NULL)
|
||||
{
|
||||
gPSSData->field_2200 = AddWindow8Bit(&gUnknown_83D35D4);
|
||||
if (gPSSData->field_2200 != 0xFF)
|
||||
{
|
||||
FillWindowPixelBuffer(gPSSData->field_2200, PIXEL_FILL(0));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_80950A4(void)
|
||||
{
|
||||
if (sMoveMonsPtr != NULL)
|
||||
Free(sMoveMonsPtr);
|
||||
}
|
||||
|
||||
void sub_80950BC(u8 arg0)
|
||||
{
|
||||
sMoveMonsPtr->field_0 = arg0;
|
||||
sMoveMonsPtr->state = 0;
|
||||
}
|
||||
|
||||
bool8 sub_80950D0(void)
|
||||
{
|
||||
switch (sMoveMonsPtr->field_0)
|
||||
{
|
||||
case 0:
|
||||
return sub_8095138();
|
||||
case 1:
|
||||
return sub_8095234();
|
||||
case 2:
|
||||
return sub_80952A0();
|
||||
case 3:
|
||||
return sub_8095314();
|
||||
case 4:
|
||||
return sub_8095394();
|
||||
case 5:
|
||||
return sub_80953BC();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_8095138(void)
|
||||
{
|
||||
switch (sMoveMonsPtr->state)
|
||||
{
|
||||
case 0:
|
||||
HideBg(0);
|
||||
LoadMonIconPalettesAt(0x80);
|
||||
sMoveMonsPtr->state++;
|
||||
break;
|
||||
case 1:
|
||||
sub_8094CD4(&sMoveMonsPtr->fromRow, &sMoveMonsPtr->fromColumn);
|
||||
sMoveMonsPtr->toRow = sMoveMonsPtr->fromRow;
|
||||
sMoveMonsPtr->toColumn = sMoveMonsPtr->fromColumn;
|
||||
ChangeBgX(0, -1024, 0);
|
||||
ChangeBgY(0, -1024, 0);
|
||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
||||
FillWindowPixelBuffer8Bit(gPSSData->field_2200, PIXEL_FILL(0));
|
||||
sub_80956A4(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn);
|
||||
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
|
||||
PutWindowTilemap(gPSSData->field_2200);
|
||||
CopyWindowToVram8Bit(gPSSData->field_2200, COPYWIN_FULL);
|
||||
BlendPalettes(0x3F00, 8, RGB_WHITE);
|
||||
sub_8094D14(2);
|
||||
SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
||||
sMoveMonsPtr->state++;
|
||||
break;
|
||||
case 2:
|
||||
if (!IsDma3ManagerBusyWithBgCopy())
|
||||
{
|
||||
ShowBg(0);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 sub_8095234(void)
|
||||
{
|
||||
switch (sMoveMonsPtr->state)
|
||||
{
|
||||
case 0:
|
||||
HideBg(0);
|
||||
sMoveMonsPtr->state++;
|
||||
break;
|
||||
case 1:
|
||||
sub_8095A58();
|
||||
sub_8094D14(0);
|
||||
sMoveMonsPtr->state++;
|
||||
break;
|
||||
case 2:
|
||||
if (!IsDma3ManagerBusyWithBgCopy())
|
||||
{
|
||||
sub_8094D40();
|
||||
LoadPalette(stdpal_get(3), 0xD0, 0x20);
|
||||
ShowBg(0);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 sub_80952A0(void)
|
||||
{
|
||||
switch (sMoveMonsPtr->state)
|
||||
{
|
||||
case 0:
|
||||
if (!sub_80924A8())
|
||||
{
|
||||
sub_8094CD4(&sMoveMonsPtr->field_6, &sMoveMonsPtr->field_7);
|
||||
sub_8095520();
|
||||
sMoveMonsPtr->toRow = sMoveMonsPtr->field_6;
|
||||
sMoveMonsPtr->toColumn = sMoveMonsPtr->field_7;
|
||||
CopyWindowToVram8Bit(gPSSData->field_2200, COPYWIN_GFX);
|
||||
sMoveMonsPtr->state++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return IsDma3ManagerBusyWithBgCopy();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 sub_8095314(void)
|
||||
{
|
||||
u8 var1, var2;
|
||||
|
||||
switch (sMoveMonsPtr->state)
|
||||
{
|
||||
case 0:
|
||||
sub_80957C8();
|
||||
sub_80958A0();
|
||||
sub_8092BAC(FALSE);
|
||||
sMoveMonsPtr->state++;
|
||||
break;
|
||||
case 1:
|
||||
if (!DoMonPlaceChange())
|
||||
{
|
||||
sub_8094D14(3);
|
||||
sub_8095780(0, 256, 8);
|
||||
sub_8092BAC(TRUE);
|
||||
sMoveMonsPtr->state++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
var1 = sub_8095790();
|
||||
var2 = DoMonPlaceChange();
|
||||
if (!var1 && !var2)
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 sub_8095394(void)
|
||||
{
|
||||
u8 var1 = sub_80924A8();
|
||||
u8 var2 = sub_8095790();
|
||||
|
||||
if (!var1 && !var2)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 sub_80953BC(void)
|
||||
{
|
||||
switch (sMoveMonsPtr->state)
|
||||
{
|
||||
case 0:
|
||||
sub_80959A8();
|
||||
sub_8095780(0, -256, 8);
|
||||
sub_8092BAC(FALSE);
|
||||
sMoveMonsPtr->state++;
|
||||
break;
|
||||
case 1:
|
||||
if (!DoMonPlaceChange() && !sub_8095790())
|
||||
{
|
||||
sub_8095918();
|
||||
sub_8094D14(2);
|
||||
sub_8092BAC(TRUE);
|
||||
HideBg(0);
|
||||
sMoveMonsPtr->state++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!DoMonPlaceChange())
|
||||
{
|
||||
sub_8094D14(0);
|
||||
sub_8095A58();
|
||||
sMoveMonsPtr->state++;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!IsDma3ManagerBusyWithBgCopy())
|
||||
{
|
||||
LoadPalette(stdpal_get(3), 0xD0, 0x20);
|
||||
sub_8094D40();
|
||||
ShowBg(0);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_8095474(u8 arg0)
|
||||
{
|
||||
switch (arg0)
|
||||
{
|
||||
case 0: // up
|
||||
if (sMoveMonsPtr->minColumn == 0)
|
||||
return FALSE;
|
||||
sMoveMonsPtr->minColumn--;
|
||||
sub_8095780(0, 1024, 6);
|
||||
break;
|
||||
case 1: // down
|
||||
if (sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal >= 5)
|
||||
return FALSE;
|
||||
sMoveMonsPtr->minColumn++;
|
||||
sub_8095780(0, -1024, 6);
|
||||
break;
|
||||
case 2: // left
|
||||
if (sMoveMonsPtr->minRow == 0)
|
||||
return FALSE;
|
||||
sMoveMonsPtr->minRow--;
|
||||
sub_8095780(1024, 0, 6);
|
||||
break;
|
||||
case 3: // right
|
||||
if (sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal > 5)
|
||||
return FALSE;
|
||||
sMoveMonsPtr->minRow++;
|
||||
sub_8095780(-1024, 0, 6);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void sub_8095520(void)
|
||||
{
|
||||
s16 var = (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->field_6)) - (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->toRow));
|
||||
s16 var2 = (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->field_7)) - (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->toColumn));
|
||||
|
||||
if (var > 0)
|
||||
sub_80955C4(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
|
||||
|
||||
if (var < 0)
|
||||
{
|
||||
sub_8095634(sMoveMonsPtr->toRow, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
|
||||
sub_80955C4(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
|
||||
}
|
||||
|
||||
if (var2 > 0)
|
||||
sub_80955FC(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
|
||||
|
||||
if (var2 < 0)
|
||||
{
|
||||
sub_809566C(sMoveMonsPtr->toColumn, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
|
||||
sub_80955FC(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_80955C4(u8 arg0, u8 arg1, u8 arg2)
|
||||
{
|
||||
u8 var1 = arg1;
|
||||
|
||||
if (arg1 > arg2)
|
||||
{
|
||||
arg1 = arg2;
|
||||
arg2 = var1;
|
||||
}
|
||||
|
||||
while (arg1 <= arg2)
|
||||
sub_80956A4(arg0, arg1++);
|
||||
}
|
||||
|
||||
static void sub_80955FC(u8 arg0, u8 arg1, u8 arg2)
|
||||
{
|
||||
u8 var1 = arg1;
|
||||
|
||||
if (arg1 > arg2)
|
||||
{
|
||||
arg1 = arg2;
|
||||
arg2 = var1;
|
||||
}
|
||||
|
||||
while (arg1 <= arg2)
|
||||
sub_80956A4(arg1++, arg0);
|
||||
}
|
||||
|
||||
static void sub_8095634(u8 arg0, u8 arg1, u8 arg2)
|
||||
{
|
||||
u8 var1 = arg1;
|
||||
|
||||
if (arg1 > arg2)
|
||||
{
|
||||
arg1 = arg2;
|
||||
arg2 = var1;
|
||||
}
|
||||
|
||||
while (arg1 <= arg2)
|
||||
sub_809572C(arg0, arg1++);
|
||||
}
|
||||
|
||||
static void sub_809566C(u8 arg0, u8 arg1, u8 arg2)
|
||||
{
|
||||
u8 var1 = arg1;
|
||||
|
||||
if (arg1 > arg2)
|
||||
{
|
||||
arg1 = arg2;
|
||||
arg2 = var1;
|
||||
}
|
||||
|
||||
while (arg1 <= arg2)
|
||||
sub_809572C(arg1++, arg0);
|
||||
}
|
||||
|
||||
static void sub_80956A4(u8 x, u8 y)
|
||||
{
|
||||
u8 position = x + (IN_BOX_ROWS * y);
|
||||
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
||||
u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY);
|
||||
|
||||
if (species != SPECIES_NONE)
|
||||
{
|
||||
const u8 *iconGfx = GetMonIconPtr(species, personality, 1);
|
||||
u8 index = GetValidMonIconPalIndex(species) + 8;
|
||||
|
||||
BlitBitmapRectToWindow4BitTo8Bit(gPSSData->field_2200,
|
||||
iconGfx,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32,
|
||||
24 * x,
|
||||
24 * y,
|
||||
32,
|
||||
32,
|
||||
index);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809572C(u8 x, u8 y)
|
||||
{
|
||||
u8 position = x + (IN_BOX_ROWS * y);
|
||||
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
||||
|
||||
if (species != SPECIES_NONE)
|
||||
{
|
||||
FillWindowPixelRect8Bit(gPSSData->field_2200,
|
||||
PIXEL_FILL(0),
|
||||
24 * x,
|
||||
24 * y,
|
||||
32,
|
||||
32);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_8095780(u16 bgX, u16 bgY, u16 duration)
|
||||
{
|
||||
sMoveMonsPtr->bgX = bgX;
|
||||
sMoveMonsPtr->bgY = bgY;
|
||||
sMoveMonsPtr->field_10 = duration;
|
||||
}
|
||||
|
||||
static u8 sub_8095790(void)
|
||||
{
|
||||
if (sMoveMonsPtr->field_10 != 0)
|
||||
{
|
||||
ChangeBgX(0, sMoveMonsPtr->bgX, 1);
|
||||
ChangeBgY(0, sMoveMonsPtr->bgY, 1);
|
||||
sMoveMonsPtr->field_10--;
|
||||
}
|
||||
|
||||
return sMoveMonsPtr->field_10;
|
||||
}
|
||||
|
||||
static void sub_80957C8(void)
|
||||
{
|
||||
s32 i, j;
|
||||
s32 rowCount, columnCount;
|
||||
u8 boxId;
|
||||
u8 monArrayId;
|
||||
|
||||
sMoveMonsPtr->minRow = min(sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow);
|
||||
sMoveMonsPtr->minColumn = min(sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn);
|
||||
sMoveMonsPtr->rowsTotal = abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->toRow) + 1;
|
||||
sMoveMonsPtr->columsTotal = abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->toColumn) + 1;
|
||||
boxId = StorageGetCurrentBox();
|
||||
monArrayId = 0;
|
||||
rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
|
||||
columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
|
||||
for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
|
||||
{
|
||||
u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
|
||||
for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
|
||||
{
|
||||
struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition);
|
||||
// UB: possible null dereference
|
||||
#ifdef UBFIX
|
||||
if (boxMon != NULL)
|
||||
sMoveMonsPtr->boxMons[monArrayId] = *boxMon;
|
||||
#else
|
||||
sMoveMonsPtr->boxMons[monArrayId] = *boxMon;
|
||||
#endif
|
||||
monArrayId++;
|
||||
boxPosition++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_80958A0(void)
|
||||
{
|
||||
s32 i, j;
|
||||
s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
|
||||
s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
|
||||
u8 boxId = StorageGetCurrentBox();
|
||||
|
||||
for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
|
||||
{
|
||||
u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
|
||||
for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
|
||||
{
|
||||
DestroyBoxMonIconAtPosition(boxPosition);
|
||||
ZeroBoxMonAt(boxId, boxPosition);
|
||||
boxPosition++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_8095918(void)
|
||||
{
|
||||
s32 i, j;
|
||||
s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
|
||||
s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
|
||||
u8 monArrayId = 0;
|
||||
|
||||
for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
|
||||
{
|
||||
u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
|
||||
for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
|
||||
{
|
||||
if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
||||
sub_80901EC(boxPosition);
|
||||
monArrayId++;
|
||||
boxPosition++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_80959A8(void)
|
||||
{
|
||||
s32 i, j;
|
||||
s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
|
||||
s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
|
||||
u8 boxId = StorageGetCurrentBox();
|
||||
u8 monArrayId = 0;
|
||||
|
||||
for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
|
||||
{
|
||||
u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
|
||||
for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
|
||||
{
|
||||
if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
||||
SetBoxMonAt(boxId, boxPosition, &sMoveMonsPtr->boxMons[monArrayId]);
|
||||
boxPosition++;
|
||||
monArrayId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_8095A58(void)
|
||||
{
|
||||
ChangeBgX(0, 0, 0);
|
||||
ChangeBgY(0, 0, 0);
|
||||
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0);
|
||||
ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
}
|
||||
|
||||
u8 sub_8095AA0(void)
|
||||
{
|
||||
return (IN_BOX_ROWS * sMoveMonsPtr->fromColumn) + sMoveMonsPtr->fromRow;
|
||||
}
|
||||
|
||||
bool8 sub_8095ABC(void)
|
||||
{
|
||||
s32 i, j;
|
||||
s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal;
|
||||
s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal;
|
||||
u8 monArrayId = 0;
|
||||
|
||||
for (i = sMoveMonsPtr->minColumn; i < columnCount; i++)
|
||||
{
|
||||
u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow;
|
||||
for (j = sMoveMonsPtr->minRow; j < rowCount; j++)
|
||||
{
|
||||
if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)
|
||||
&& GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES))
|
||||
return FALSE;
|
||||
|
||||
monArrayId++;
|
||||
boxPosition++;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,877 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "gflib.h"
|
||||
#include "decompress.h"
|
||||
#include "item.h"
|
||||
#include "item_menu_icons.h"
|
||||
#include "menu.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "pokemon_storage_system_internal.h"
|
||||
#include "trig.h"
|
||||
#include "constants/items.h"
|
||||
|
||||
// IDs for the item icon sprite callbacks
|
||||
enum {
|
||||
ITEM_CB_WAIT_ANIM,
|
||||
ITEM_CB_TO_HAND,
|
||||
ITEM_CB_TO_MON,
|
||||
ITEM_CB_SWAP_TO_HAND,
|
||||
ITEM_CB_SWAP_TO_MON,
|
||||
ITEM_CB_UNUSED_1,
|
||||
ITEM_CB_UNUSED_2,
|
||||
ITEM_CB_HIDE_PARTY,
|
||||
};
|
||||
|
||||
static u8 GetNewItemIconIdx(void);
|
||||
static bool32 IsItemIconAtPosition(u8 cursorArea, u8 cursorPos);
|
||||
static u8 GetItemIconIdxByPosition(u8 cursorArea, u8 cursorPos);
|
||||
static void SetItemIconPosition(u8 id, u8 cursorArea, u8 cursorPos);
|
||||
static void LoadItemIconGfx(u8 id, const u32 * tiles, const u32 * pal);
|
||||
static void SetItemIconAffineAnim(u8 id, u8 affineAnimNo);
|
||||
static void SetItemIconCallback(u8 id, u8 command, u8 cursorArea, u8 cursorPos);
|
||||
static void SetItemIconActive(u8 id, bool8 show);
|
||||
static const u32 *GetItemIconPic(u16 itemId);
|
||||
static const u32 *GetItemIconPalette(u16 itemId);
|
||||
static void DrawItemInfoWindow(u32 x);
|
||||
static void SpriteCB_ItemIcon_WaitAnim(struct Sprite *sprite);
|
||||
static void SpriteCB_ItemIcon_ToHand(struct Sprite *sprite);
|
||||
static void SpriteCB_ItemIcon_SetPosToCursor(struct Sprite *sprite);
|
||||
static void SpriteCB_ItemIcon_ToMon(struct Sprite *sprite);
|
||||
static void SpriteCB_ItemIcon_SwapToHand(struct Sprite *sprite);
|
||||
static void SpriteCB_ItemIcon_SwapToMon(struct Sprite *sprite);
|
||||
static void SpriteCB_ItemIcon_HideParty(struct Sprite *sprite);
|
||||
|
||||
static const u32 sItemInfoFrame_Gfx[] = INCBIN_U32("graphics/interface/pss_unk_83D35DC.4bpp");
|
||||
|
||||
static const struct OamData gUnknown_83D365C = {
|
||||
.y = 0,
|
||||
.affineMode = ST_OAM_AFFINE_NORMAL,
|
||||
.objMode = ST_OAM_OBJ_NORMAL,
|
||||
.mosaic = FALSE,
|
||||
.bpp = ST_OAM_4BPP,
|
||||
.shape = SPRITE_SHAPE(32x32),
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = SPRITE_SIZE(32x32),
|
||||
.tileNum = 0x000,
|
||||
.priority = 1,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83D3664[] = {
|
||||
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83D3674[] = {
|
||||
AFFINEANIMCMD_FRAME(88, 88, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(5, 5, 0, 8),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83D368C[] = {
|
||||
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(-5, -5, 0, 8),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83D36A4[] = {
|
||||
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(10, 10, 0, 12),
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83D36C4[] = {
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(-10, -10, 0, 12),
|
||||
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83D36E4[] = {
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_FRAME(-5, -5, 0, 16),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83D36FC[] = {
|
||||
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd *const gUnknown_83D370C[] = {
|
||||
gUnknown_83D3664,
|
||||
gUnknown_83D3674,
|
||||
gUnknown_83D368C,
|
||||
gUnknown_83D36A4,
|
||||
gUnknown_83D36C4,
|
||||
gUnknown_83D36E4,
|
||||
gUnknown_83D36FC
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_ItemIcon = {
|
||||
.tileTag = TAG_TILE_7,
|
||||
.paletteTag = TAG_PAL_DACB,
|
||||
.oam = &gUnknown_83D365C,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
.affineAnims = gUnknown_83D370C,
|
||||
.callback = SpriteCallbackDummy,
|
||||
};
|
||||
|
||||
void CreateItemIconSprites(void)
|
||||
{
|
||||
s32 i;
|
||||
u8 spriteId;
|
||||
struct CompressedSpriteSheet spriteSheet;
|
||||
struct SpriteTemplate spriteTemplate;
|
||||
static u32 sItemIconGfxBuffer[0x61];
|
||||
|
||||
if (gPSSData->boxOption == OPTION_MOVE_ITEMS)
|
||||
{
|
||||
spriteSheet.data = sItemIconGfxBuffer;
|
||||
spriteSheet.size = 0x200;
|
||||
spriteTemplate = sSpriteTemplate_ItemIcon;
|
||||
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
spriteSheet.tag = TAG_TILE_7 + i;
|
||||
LoadCompressedSpriteSheet(&spriteSheet);
|
||||
gPSSData->itemIcons[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * TILE_SIZE_4BPP + (void *)(OBJ_VRAM0);
|
||||
gPSSData->itemIcons[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i);
|
||||
gPSSData->itemIcons[i].palIndex *= 16;
|
||||
gPSSData->itemIcons[i].palIndex += 0x100;
|
||||
spriteTemplate.tileTag = TAG_TILE_7 + i;
|
||||
spriteTemplate.paletteTag = TAG_PAL_DACB + i;
|
||||
spriteId = CreateSprite(&spriteTemplate, 0, 0, 11);
|
||||
gPSSData->itemIcons[i].sprite = &gSprites[spriteId];
|
||||
gPSSData->itemIcons[i].sprite->invisible = TRUE;
|
||||
gPSSData->itemIcons[i].active = FALSE;
|
||||
}
|
||||
}
|
||||
gPSSData->movingItemId = ITEM_NONE;
|
||||
}
|
||||
|
||||
void sub_8095C84(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u16 heldItem;
|
||||
|
||||
if (gPSSData->boxOption != OPTION_MOVE_ITEMS)
|
||||
return;
|
||||
if (IsItemIconAtPosition(cursorArea, cursorPos))
|
||||
return;
|
||||
|
||||
switch (cursorArea)
|
||||
{
|
||||
case CURSOR_AREA_IN_BOX:
|
||||
if (!GetCurrentBoxMonData(cursorPos, MON_DATA_SANITY_HAS_SPECIES))
|
||||
return;
|
||||
heldItem = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM);
|
||||
break;
|
||||
case CURSOR_AREA_IN_PARTY:
|
||||
if (!GetMonData(&gPlayerParty[cursorPos], MON_DATA_SANITY_HAS_SPECIES))
|
||||
return;
|
||||
heldItem = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (heldItem != ITEM_NONE)
|
||||
{
|
||||
const u32 *tiles = GetItemIconPic(heldItem);
|
||||
const u32 *pal = GetItemIconPalette(heldItem);
|
||||
u8 id = GetNewItemIconIdx();
|
||||
|
||||
SetItemIconPosition(id, cursorArea, cursorPos);
|
||||
LoadItemIconGfx(id, tiles, pal);
|
||||
SetItemIconAffineAnim(id, 1);
|
||||
SetItemIconActive(id, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8095D44(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u8 id;
|
||||
|
||||
if (gPSSData->boxOption != OPTION_MOVE_ITEMS)
|
||||
return;
|
||||
|
||||
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
||||
SetItemIconAffineAnim(id, 2);
|
||||
SetItemIconCallback(id, 0, cursorArea, cursorPos);
|
||||
}
|
||||
|
||||
void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u8 id;
|
||||
u16 item;
|
||||
|
||||
if (gPSSData->boxOption != OPTION_MOVE_ITEMS)
|
||||
return;
|
||||
|
||||
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
||||
item = 0;
|
||||
SetItemIconAffineAnim(id, 3);
|
||||
SetItemIconCallback(id, 1, cursorArea, cursorPos);
|
||||
SetItemIconPosition(id, 2, 0);
|
||||
if (cursorArea == CURSOR_AREA_IN_BOX)
|
||||
{
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item);
|
||||
SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item);
|
||||
SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
|
||||
}
|
||||
|
||||
gPSSData->movingItemId = gPSSData->displayMonItemId;
|
||||
}
|
||||
|
||||
void sub_8095E2C(u16 item)
|
||||
{
|
||||
const u32 *tiles = GetItemIconPic(item);
|
||||
const u32 *pal = GetItemIconPalette(item);
|
||||
u8 id = GetNewItemIconIdx();
|
||||
|
||||
LoadItemIconGfx(id, tiles, pal);
|
||||
SetItemIconAffineAnim(id, 6);
|
||||
SetItemIconCallback(id, 1, CURSOR_AREA_IN_BOX, 0);
|
||||
SetItemIconPosition(id, CURSOR_AREA_BOX, 0);
|
||||
SetItemIconActive(id, TRUE);
|
||||
gPSSData->movingItemId = item;
|
||||
}
|
||||
|
||||
void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u8 id;
|
||||
u16 item;
|
||||
|
||||
if (gPSSData->boxOption != OPTION_MOVE_ITEMS)
|
||||
return;
|
||||
|
||||
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
||||
SetItemIconAffineAnim(id, 3);
|
||||
SetItemIconCallback(id, 3, CURSOR_AREA_BOX, 0);
|
||||
if (cursorArea == CURSOR_AREA_IN_BOX)
|
||||
{
|
||||
item = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM);
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &gPSSData->movingItemId);
|
||||
gPSSData->movingItemId = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
item = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM);
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &gPSSData->movingItemId);
|
||||
gPSSData->movingItemId = item;
|
||||
}
|
||||
|
||||
id = GetItemIconIdxByPosition(2, 0);
|
||||
SetItemIconAffineAnim(id, 4);
|
||||
SetItemIconCallback(id, 4, cursorArea, cursorPos);
|
||||
}
|
||||
|
||||
void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u8 id;
|
||||
|
||||
if (gPSSData->boxOption != OPTION_MOVE_ITEMS)
|
||||
return;
|
||||
|
||||
id = GetItemIconIdxByPosition(2, 0);
|
||||
SetItemIconAffineAnim(id, 4);
|
||||
SetItemIconCallback(id, 2, cursorArea, cursorPos);
|
||||
if (cursorArea == CURSOR_AREA_IN_BOX)
|
||||
{
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &gPSSData->movingItemId);
|
||||
SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &gPSSData->movingItemId);
|
||||
SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void Item_TakeMons(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u8 id;
|
||||
u16 item;
|
||||
|
||||
if (gPSSData->boxOption != OPTION_MOVE_ITEMS)
|
||||
return;
|
||||
|
||||
item = 0;
|
||||
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
||||
SetItemIconAffineAnim(id, 2);
|
||||
SetItemIconCallback(id, 0, cursorArea, cursorPos);
|
||||
if (cursorArea == CURSOR_AREA_IN_BOX)
|
||||
{
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item);
|
||||
SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item);
|
||||
SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8096088(void)
|
||||
{
|
||||
if (gPSSData->boxOption == OPTION_MOVE_ITEMS)
|
||||
{
|
||||
u8 id = GetItemIconIdxByPosition(2, 0);
|
||||
SetItemIconAffineAnim(id, 5);
|
||||
SetItemIconCallback(id, 0, CURSOR_AREA_BOX, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80960C0(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
if (gPSSData->boxOption != OPTION_MOVE_ITEMS)
|
||||
return;
|
||||
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
if (gPSSData->itemIcons[i].active && gPSSData->itemIcons[i].cursorArea == CURSOR_AREA_IN_PARTY)
|
||||
SetItemIconCallback(i, 7, CURSOR_AREA_BOX, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_809610C(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
if (gPSSData->itemIcons[i].active)
|
||||
{
|
||||
if (!gPSSData->itemIcons[i].sprite->affineAnimEnded && gPSSData->itemIcons[i].sprite->affineAnimBeginning)
|
||||
return TRUE;
|
||||
if (gPSSData->itemIcons[i].sprite->callback != SpriteCallbackDummy && gPSSData->itemIcons[i].sprite->callback != SpriteCB_ItemIcon_SetPosToCursor)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 IsActiveItemMoving(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
if (gPSSData->boxOption == OPTION_MOVE_ITEMS)
|
||||
{
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
if (gPSSData->itemIcons[i].active && gPSSData->itemIcons[i].cursorArea == CURSOR_AREA_BOX)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const u8 *GetMovingItemName(void)
|
||||
{
|
||||
return ItemId_GetName(gPSSData->movingItemId);
|
||||
}
|
||||
|
||||
u16 GetMovingItem(void)
|
||||
{
|
||||
return gPSSData->movingItemId;
|
||||
}
|
||||
|
||||
static u8 GetNewItemIconIdx(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
if (!gPSSData->itemIcons[i].active)
|
||||
{
|
||||
gPSSData->itemIcons[i].active = TRUE;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return MAX_ITEM_ICONS;
|
||||
}
|
||||
|
||||
static bool32 IsItemIconAtPosition(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
if (gPSSData->itemIcons[i].active
|
||||
&& gPSSData->itemIcons[i].cursorArea == cursorArea
|
||||
&& gPSSData->itemIcons[i].cursorPos == cursorPos)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static u8 GetItemIconIdxByPosition(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
if (gPSSData->itemIcons[i].active
|
||||
&& gPSSData->itemIcons[i].cursorArea == cursorArea
|
||||
&& gPSSData->itemIcons[i].cursorPos == cursorPos)
|
||||
return i;
|
||||
}
|
||||
|
||||
return MAX_ITEM_ICONS;
|
||||
}
|
||||
|
||||
static u8 GetItemIconIdxBySprite(struct Sprite *sprite)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
||||
{
|
||||
if (gPSSData->itemIcons[i].active
|
||||
&& gPSSData->itemIcons[i].sprite == sprite)
|
||||
return i;
|
||||
}
|
||||
|
||||
return MAX_ITEM_ICONS;
|
||||
}
|
||||
|
||||
static void SetItemIconPosition(u8 id, u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
u8 row, column;
|
||||
|
||||
if (id >= MAX_ITEM_ICONS)
|
||||
return;
|
||||
|
||||
switch (cursorArea)
|
||||
{
|
||||
case CURSOR_AREA_IN_BOX:
|
||||
row = cursorPos % IN_BOX_ROWS;
|
||||
column = cursorPos / IN_BOX_ROWS;
|
||||
gPSSData->itemIcons[id].sprite->x = (24 * row) + 112;
|
||||
gPSSData->itemIcons[id].sprite->y = (24 * column) + 56;
|
||||
gPSSData->itemIcons[id].sprite->oam.priority = 2;
|
||||
break;
|
||||
case CURSOR_AREA_IN_PARTY:
|
||||
if (cursorPos == 0)
|
||||
{
|
||||
gPSSData->itemIcons[id].sprite->x = 116;
|
||||
gPSSData->itemIcons[id].sprite->y = 76;
|
||||
}
|
||||
else
|
||||
{
|
||||
gPSSData->itemIcons[id].sprite->x = 164;
|
||||
gPSSData->itemIcons[id].sprite->y = 24 * (cursorPos - 1) + 28;
|
||||
}
|
||||
gPSSData->itemIcons[id].sprite->oam.priority = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
gPSSData->itemIcons[id].cursorArea = cursorArea;
|
||||
gPSSData->itemIcons[id].cursorPos = cursorPos;
|
||||
}
|
||||
|
||||
static void LoadItemIconGfx(u8 id, const u32 *itemTiles, const u32 *itemPal)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
if (id >= MAX_ITEM_ICONS)
|
||||
return;
|
||||
|
||||
CpuFastFill(0, gPSSData->itemIconBuffer, 0x200);
|
||||
LZ77UnCompWram(itemTiles, gPSSData->field_22C4);
|
||||
for (i = 0; i < 3; i++)
|
||||
CpuFastCopy(gPSSData->field_22C4 + (i * 0x60), gPSSData->itemIconBuffer + (i * 0x80), 0x60);
|
||||
|
||||
CpuFastCopy(gPSSData->itemIconBuffer, gPSSData->itemIcons[id].tiles, 0x200);
|
||||
LZ77UnCompWram(itemPal, gPSSData->itemIconBuffer);
|
||||
LoadPalette(gPSSData->itemIconBuffer, gPSSData->itemIcons[id].palIndex, 0x20);
|
||||
}
|
||||
|
||||
static void SetItemIconAffineAnim(u8 id, u8 animNum)
|
||||
{
|
||||
if (id >= MAX_ITEM_ICONS)
|
||||
return;
|
||||
|
||||
StartSpriteAffineAnim(gPSSData->itemIcons[id].sprite, animNum);
|
||||
}
|
||||
|
||||
#define sItemIconId data[0]
|
||||
#define sState data[0]
|
||||
#define sCursorArea data[6]
|
||||
#define sCursorPos data[7]
|
||||
|
||||
static void SetItemIconCallback(u8 id, u8 callbackId, u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
if (id >= MAX_ITEM_ICONS)
|
||||
return;
|
||||
|
||||
switch (callbackId)
|
||||
{
|
||||
case ITEM_CB_WAIT_ANIM:
|
||||
gPSSData->itemIcons[id].sprite->sItemIconId = id;
|
||||
gPSSData->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_WaitAnim;
|
||||
break;
|
||||
case ITEM_CB_TO_HAND:
|
||||
gPSSData->itemIcons[id].sprite->sState = 0;
|
||||
gPSSData->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_ToHand;
|
||||
break;
|
||||
case ITEM_CB_TO_MON:
|
||||
gPSSData->itemIcons[id].sprite->sState = 0;
|
||||
gPSSData->itemIcons[id].sprite->sCursorArea = cursorArea;
|
||||
gPSSData->itemIcons[id].sprite->sCursorPos = cursorPos;
|
||||
gPSSData->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_ToMon;
|
||||
break;
|
||||
case ITEM_CB_SWAP_TO_HAND:
|
||||
gPSSData->itemIcons[id].sprite->sState = 0;
|
||||
gPSSData->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_SwapToHand;
|
||||
gPSSData->itemIcons[id].sprite->sCursorArea = cursorArea;
|
||||
gPSSData->itemIcons[id].sprite->sCursorPos = cursorPos;
|
||||
break;
|
||||
case ITEM_CB_SWAP_TO_MON:
|
||||
gPSSData->itemIcons[id].sprite->sState = 0;
|
||||
gPSSData->itemIcons[id].sprite->sCursorArea = cursorArea;
|
||||
gPSSData->itemIcons[id].sprite->sCursorPos = cursorPos;
|
||||
gPSSData->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_SwapToMon;
|
||||
break;
|
||||
case ITEM_CB_HIDE_PARTY:
|
||||
// If cursor is on a Pokémon with a held item and
|
||||
// the player closes the party menu, have the held
|
||||
// item follow the Pokémon as the menu slides out
|
||||
gPSSData->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_HideParty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SetItemIconActive(u8 id, bool8 show)
|
||||
{
|
||||
if (id >= MAX_ITEM_ICONS)
|
||||
return;
|
||||
|
||||
gPSSData->itemIcons[id].active = show;
|
||||
gPSSData->itemIcons[id].sprite->invisible = (show == FALSE);
|
||||
}
|
||||
|
||||
static const u32 *GetItemIconPic(u16 itemId)
|
||||
{
|
||||
return GetItemIconGfxPtr(itemId, 0);
|
||||
}
|
||||
|
||||
static const u32 *GetItemIconPalette(u16 itemId)
|
||||
{
|
||||
return GetItemIconGfxPtr(itemId, 1);
|
||||
}
|
||||
|
||||
void PrintItemDescription(void)
|
||||
{
|
||||
const u8 *description;
|
||||
|
||||
if (IsActiveItemMoving())
|
||||
description = ItemId_GetDescription(gPSSData->movingItemId);
|
||||
else
|
||||
description = ItemId_GetDescription(gPSSData->displayMonItemId);
|
||||
|
||||
FillWindowPixelBuffer(2, PIXEL_FILL(1));
|
||||
AddTextPrinterParameterized5(2, FONT_2, description, 2, 0, 0, NULL, 0, 0);
|
||||
}
|
||||
|
||||
void InitItemInfoWindow(void)
|
||||
{
|
||||
gPSSData->itemInfoWindowOffset = 25;
|
||||
LoadBgTiles(0, sItemInfoFrame_Gfx, 0x80, 0x1A4);
|
||||
DrawItemInfoWindow(0);
|
||||
}
|
||||
|
||||
bool8 UpdateItemInfoWindowSlideIn(void)
|
||||
{
|
||||
s32 i, pos;
|
||||
|
||||
if (gPSSData->itemInfoWindowOffset == 0)
|
||||
return FALSE;
|
||||
|
||||
gPSSData->itemInfoWindowOffset--;
|
||||
pos = 25 - gPSSData->itemInfoWindowOffset;
|
||||
for (i = 0; i < pos; i++)
|
||||
{
|
||||
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + gPSSData->itemInfoWindowOffset + i, i, 12, 1, 8, 15, 25);
|
||||
}
|
||||
|
||||
DrawItemInfoWindow(pos);
|
||||
return (gPSSData->itemInfoWindowOffset != 0);
|
||||
}
|
||||
|
||||
bool8 UpdateItemInfoWindowSlideOut(void)
|
||||
{
|
||||
s32 i, pos;
|
||||
|
||||
if (gPSSData->itemInfoWindowOffset == 25)
|
||||
return FALSE;
|
||||
|
||||
if (gPSSData->itemInfoWindowOffset == 0)
|
||||
FillBgTilemapBufferRect(0, 0, 25, 11, 1, 10, 17);
|
||||
|
||||
gPSSData->itemInfoWindowOffset++;
|
||||
pos = 25 - gPSSData->itemInfoWindowOffset;
|
||||
for (i = 0; i < pos; i++)
|
||||
{
|
||||
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + gPSSData->itemInfoWindowOffset + i, i, 12, 1, 8, 15, 25);
|
||||
}
|
||||
|
||||
DrawItemInfoWindow(pos);
|
||||
|
||||
FillBgTilemapBufferRect(0, 0, pos, 11, 1, 10, 0x11);
|
||||
return (gPSSData->itemInfoWindowOffset != 25);
|
||||
}
|
||||
|
||||
static void DrawItemInfoWindow(u32 x)
|
||||
{
|
||||
if (x != 0)
|
||||
{
|
||||
FillBgTilemapBufferRect(0, 0x1A4, 0, 0xB, x, 1, 0xFu);
|
||||
FillBgTilemapBufferRect(0, 0x9A4, 0, 0x14, x, 1, 0xFu);
|
||||
}
|
||||
FillBgTilemapBufferRect(0, 0x1A5, x, 0xC, 1, 8, 0xFu);
|
||||
FillBgTilemapBufferRect(0, 0x1A6, x, 0xB, 1, 1, 0xFu);
|
||||
FillBgTilemapBufferRect(0, 0x1A7, x, 0x14, 1, 1, 0xFu);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
}
|
||||
|
||||
static void SpriteCB_ItemIcon_WaitAnim(struct Sprite *sprite)
|
||||
{
|
||||
if (sprite->affineAnimEnded)
|
||||
{
|
||||
SetItemIconActive(sprite->data[0], FALSE);
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
}
|
||||
}
|
||||
|
||||
static void SpriteCB_ItemIcon_ToHand(struct Sprite *sprite)
|
||||
{
|
||||
switch (sprite->data[0])
|
||||
{
|
||||
case 0:
|
||||
sprite->data[1] = sprite->x << 4;
|
||||
sprite->data[2] = sprite->y << 4;
|
||||
sprite->data[3] = 10;
|
||||
sprite->data[4] = 21;
|
||||
sprite->data[5] = 0;
|
||||
sprite->data[0]++;
|
||||
case 1:
|
||||
sprite->data[1] -= sprite->data[3];
|
||||
sprite->data[2] -= sprite->data[4];
|
||||
sprite->x = sprite->data[1] >> 4;
|
||||
sprite->y = sprite->data[2] >> 4;
|
||||
if (++sprite->data[5] > 11)
|
||||
sprite->callback = SpriteCB_ItemIcon_SetPosToCursor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SpriteCB_ItemIcon_SetPosToCursor(struct Sprite *sprite)
|
||||
{
|
||||
sprite->x = gPSSData->cursorSprite->x + 4;
|
||||
sprite->y = gPSSData->cursorSprite->y + gPSSData->cursorSprite->y2 + 8;
|
||||
sprite->oam.priority = gPSSData->cursorSprite->oam.priority;
|
||||
}
|
||||
|
||||
static void SpriteCB_ItemIcon_ToMon(struct Sprite *sprite)
|
||||
{
|
||||
switch (sprite->data[0])
|
||||
{
|
||||
case 0:
|
||||
sprite->data[1] = sprite->x << 4;
|
||||
sprite->data[2] = sprite->y << 4;
|
||||
sprite->data[3] = 10;
|
||||
sprite->data[4] = 21;
|
||||
sprite->data[5] = 0;
|
||||
sprite->data[0]++;
|
||||
case 1:
|
||||
sprite->data[1] += sprite->data[3];
|
||||
sprite->data[2] += sprite->data[4];
|
||||
sprite->x = sprite->data[1] >> 4;
|
||||
sprite->y = sprite->data[2] >> 4;
|
||||
if (++sprite->data[5] > 11)
|
||||
{
|
||||
SetItemIconPosition(GetItemIconIdxBySprite(sprite), sprite->data[6], sprite->data[7]);
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SpriteCB_ItemIcon_SwapToHand(struct Sprite *sprite)
|
||||
{
|
||||
switch (sprite->data[0])
|
||||
{
|
||||
case 0:
|
||||
sprite->data[1] = sprite->x << 4;
|
||||
sprite->data[2] = sprite->y << 4;
|
||||
sprite->data[3] = 10;
|
||||
sprite->data[4] = 21;
|
||||
sprite->data[5] = 0;
|
||||
sprite->data[0]++;
|
||||
case 1:
|
||||
sprite->data[1] -= sprite->data[3];
|
||||
sprite->data[2] -= sprite->data[4];
|
||||
sprite->x = sprite->data[1] >> 4;
|
||||
sprite->y = sprite->data[2] >> 4;
|
||||
sprite->x2 = gSineTable[sprite->data[5] * 8] >> 4;
|
||||
if (++sprite->data[5] > 11)
|
||||
{
|
||||
SetItemIconPosition(GetItemIconIdxBySprite(sprite), sprite->data[6], sprite->data[7]);
|
||||
sprite->x2 = 0;
|
||||
sprite->callback = SpriteCB_ItemIcon_SetPosToCursor;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SpriteCB_ItemIcon_SwapToMon(struct Sprite *sprite)
|
||||
{
|
||||
switch (sprite->data[0])
|
||||
{
|
||||
case 0:
|
||||
sprite->data[1] = sprite->x << 4;
|
||||
sprite->data[2] = sprite->y << 4;
|
||||
sprite->data[3] = 10;
|
||||
sprite->data[4] = 21;
|
||||
sprite->data[5] = 0;
|
||||
sprite->data[0]++;
|
||||
case 1:
|
||||
sprite->data[1] += sprite->data[3];
|
||||
sprite->data[2] += sprite->data[4];
|
||||
sprite->x = sprite->data[1] >> 4;
|
||||
sprite->y = sprite->data[2] >> 4;
|
||||
sprite->x2 = -(gSineTable[sprite->data[5] * 8] >> 4);
|
||||
if (++sprite->data[5] > 11)
|
||||
{
|
||||
SetItemIconPosition(GetItemIconIdxBySprite(sprite), sprite->data[6], sprite->data[7]);
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
sprite->x2 = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void SpriteCB_ItemIcon_HideParty(struct Sprite *sprite)
|
||||
{
|
||||
sprite->y -= 8;
|
||||
if (sprite->y + sprite->y2 < -16)
|
||||
{
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
SetItemIconActive(GetItemIconIdxBySprite(sprite), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
#undef sState
|
||||
#undef sItemIconId
|
||||
#undef sCursorArea
|
||||
#undef sCursorPos
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// SECTION: UnkUtil
|
||||
//
|
||||
// Some data transfer utility that goes functionally unused.
|
||||
// It gets initialized with UnkUtil_Init, and run every vblank in Pokémon
|
||||
// Storage with UnkUtil_Run, but neither of the Add functions are ever used,
|
||||
// so UnkUtil_Run performs no actions.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
static EWRAM_DATA struct UnkUtil *sUnkUtil = NULL;
|
||||
|
||||
static void UnkUtil_CpuRun(struct UnkUtilData *unkStruct);
|
||||
static void UnkUtil_DmaRun(struct UnkUtilData *unkStruct);
|
||||
|
||||
void UnkUtil_Init(struct UnkUtil *util, struct UnkUtilData *data, u32 max)
|
||||
{
|
||||
sUnkUtil = util;
|
||||
util->data = data;
|
||||
util->max = max;
|
||||
util->numActive = 0;
|
||||
}
|
||||
|
||||
void UnkUtil_Run(void)
|
||||
{
|
||||
u16 i;
|
||||
if (sUnkUtil->numActive)
|
||||
{
|
||||
for (i = 0; i < sUnkUtil->numActive; i++)
|
||||
{
|
||||
struct UnkUtilData *data = &sUnkUtil->data[i];
|
||||
data->func(data);
|
||||
}
|
||||
sUnkUtil->numActive = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Unused
|
||||
static bool8 UnkUtil_CpuAdd(u8 *dest, u16 dLeft, u16 dTop, const u8 *src, u16 sLeft, u16 sTop, u16 width, u16 height, u16 unkArg)
|
||||
{
|
||||
struct UnkUtilData *data;
|
||||
|
||||
if (sUnkUtil->numActive >= sUnkUtil->max)
|
||||
return FALSE;
|
||||
|
||||
data = &sUnkUtil->data[sUnkUtil->numActive++];
|
||||
data->size = width * 2;
|
||||
data->dest = dest + 2 * (dTop * 32 + dLeft);
|
||||
data->src = src + 2 * (sTop * unkArg + sLeft);
|
||||
data->height = height;
|
||||
data->unk = unkArg;
|
||||
data->func = UnkUtil_CpuRun;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Functionally unused
|
||||
static void UnkUtil_CpuRun(struct UnkUtilData *data)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < data->height; i++)
|
||||
{
|
||||
CpuCopy16(data->src, data->dest, data->size);
|
||||
data->dest += 64;
|
||||
data->src += (data->unk * 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Unused
|
||||
static bool8 UnkUtil_DmaAdd(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height)
|
||||
{
|
||||
struct UnkUtilData *data;
|
||||
|
||||
if (sUnkUtil->numActive >= sUnkUtil->max)
|
||||
return FALSE;
|
||||
|
||||
data = &sUnkUtil->data[sUnkUtil->numActive++];
|
||||
data->size = width * 2;
|
||||
data->dest = dest + ((dTop * 32) + dLeft) * 2;
|
||||
data->height = height;
|
||||
data->func = UnkUtil_DmaRun;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Functionally unused
|
||||
static void UnkUtil_DmaRun(struct UnkUtilData *data)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < data->height; i++)
|
||||
{
|
||||
Dma3FillLarge_(0, data->dest, data->size, 16);
|
||||
data->dest += 64;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -16,22 +16,20 @@
|
||||
#include "constants/help_system.h"
|
||||
|
||||
static EWRAM_DATA u8 sPreviousBoxOption = 0;
|
||||
static EWRAM_DATA struct ChooseBoxMenu *sBoxSelectionPopupSpriteManager = NULL;
|
||||
static EWRAM_DATA struct ChooseBoxMenu *sChooseBoxMenu = NULL;
|
||||
|
||||
static void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr);
|
||||
static void CreatePCMainMenu(u8 whichMenu, s16 *windowIdPtr);
|
||||
static void ChooseBoxMenu_CreateSprites(u8 curBox);
|
||||
static void sub_808CBA4(void);
|
||||
static void UpdateBoxNameAndCountSprite_WraparoundRight(void);
|
||||
static void UpdateBoxNameAndCountSprite_WraparoundLeft(void);
|
||||
static void PrintBoxNameAndCountToSprite(void);
|
||||
static void PrintToSpriteWithTagUnk0240(const u8 *a0, u16 x, u16 y);
|
||||
static void sub_808CD64(struct Sprite *sprite);
|
||||
static void ChooseBoxMenu_DestroySprites(void);
|
||||
static void ChooseBoxMenu_MoveRight(void);
|
||||
static void ChooseBoxMenu_MoveLeft(void);
|
||||
static void ChooseBoxMenu_PrintBoxNameAndCount(void);
|
||||
static void ChooseBoxMenu_PrintTextToSprite(const u8 *a0, u16 x, u16 y);
|
||||
static void SpriteCB_ChooseBoxArrow(struct Sprite *sprite);
|
||||
|
||||
// Forward declarations
|
||||
|
||||
static const u16 sBoxSelectionPopupPalette[];
|
||||
static const u16 sBoxSelectionPopupCenterTiles[];
|
||||
static const u16 sBoxSelectionPopupSidesTiles[];
|
||||
static const u16 sChooseBoxMenu_Pal[];
|
||||
static const u8 sChooseBoxMenuCenter_Gfx[];
|
||||
static const u8 sChooseBoxMenuCorners_Gfx[];
|
||||
|
||||
struct {
|
||||
const u8 *text;
|
||||
@@ -44,7 +42,7 @@ struct {
|
||||
[OPTION_EXIT] = {gText_SeeYa, gText_SeeYaDescription}
|
||||
};
|
||||
|
||||
void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, u8 *buffer, s32 bytesToBuffer)
|
||||
void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, u8 *unused, s32 bytesToBuffer)
|
||||
{
|
||||
s32 i, tileBytesToBuffer, remainingBytes;
|
||||
u16 windowId;
|
||||
@@ -90,7 +88,7 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero
|
||||
RemoveWindow(windowId);
|
||||
}
|
||||
|
||||
static void PrintStringToBufferCopyNow(const u8 *string, void *dst, u16 rise, u8 bgClr, u8 fgClr, u8 shClr, u8 *buffer)
|
||||
static void PrintStringToBufferCopyNow(const u8 *string, void *dst, u16 offset, u8 bgColor, u8 fgColor, u8 shadowColor, u8 *unused)
|
||||
{
|
||||
u32 var;
|
||||
u8 windowId;
|
||||
@@ -102,15 +100,15 @@ static void PrintStringToBufferCopyNow(const u8 *string, void *dst, u16 rise, u8
|
||||
winTemplate.height = 2;
|
||||
var = winTemplate.width * 32;
|
||||
windowId = AddWindow(&winTemplate);
|
||||
FillWindowPixelBuffer(windowId, PIXEL_FILL(bgClr));
|
||||
FillWindowPixelBuffer(windowId, PIXEL_FILL(bgColor));
|
||||
tileData1 = (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA);
|
||||
tileData2 = (winTemplate.width * 32) + tileData1;
|
||||
txtColor[0] = bgClr;
|
||||
txtColor[1] = fgClr;
|
||||
txtColor[2] = shClr;
|
||||
txtColor[0] = bgColor;
|
||||
txtColor[1] = fgColor;
|
||||
txtColor[2] = shadowColor;
|
||||
AddTextPrinterParameterized4(windowId, FONT_1, 0, 2, 0, 0, txtColor, -1, string);
|
||||
CpuCopy16(tileData1, dst, var);
|
||||
CpuCopy16(tileData2, dst + rise, var);
|
||||
CpuCopy16(tileData2, dst + offset, var);
|
||||
RemoveWindow(windowId);
|
||||
}
|
||||
|
||||
@@ -147,10 +145,8 @@ u8 CountPartyNonEggMons(void)
|
||||
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
||||
{
|
||||
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -163,12 +159,10 @@ u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore)
|
||||
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (i != slotToIgnore
|
||||
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
|
||||
{
|
||||
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
|
||||
&& GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -186,9 +180,7 @@ u8 CountPartyMons(void)
|
||||
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -205,7 +197,8 @@ static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n)
|
||||
return str;
|
||||
}
|
||||
|
||||
static void sub_808C25C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width)
|
||||
// Unused
|
||||
static void UnusedWriteRectCpu(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
@@ -231,16 +224,6 @@ static void UnusedWriteRectDma(u16 *dest, u16 dest_left, u16 dest_top, u16 width
|
||||
Dma3FillLarge16_(0, dest, width);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// SECTION: Main menu
|
||||
//
|
||||
// The below functions generally handle the PC main menu where the main
|
||||
// options can be selected (Withdraw, Deposit, etc.), as well as exiting
|
||||
// Pokémon Storage back to this menu.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
enum {
|
||||
STATE_LOAD,
|
||||
STATE_FADE_IN,
|
||||
@@ -263,7 +246,7 @@ static void Task_PCMainMenu(u8 taskId)
|
||||
{
|
||||
case STATE_LOAD:
|
||||
SetHelpContext(HELPCONTEXT_BILLS_PC);
|
||||
PSS_CreatePCMenu(task->tSelectedOption, &task->tWindowId);
|
||||
CreatePCMainMenu(task->tSelectedOption, &task->tWindowId);
|
||||
LoadStdWindowFrameGfx();
|
||||
DrawDialogueFrame(0, FALSE);
|
||||
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
||||
@@ -274,9 +257,8 @@ static void Task_PCMainMenu(u8 taskId)
|
||||
break;
|
||||
case STATE_FADE_IN:
|
||||
if (IsWeatherNotFadingIn())
|
||||
{
|
||||
task->tState++;
|
||||
}
|
||||
|
||||
break;
|
||||
case STATE_HANDLE_INPUT:
|
||||
task->tInput = Menu_ProcessInput();
|
||||
@@ -300,19 +282,19 @@ static void Task_PCMainMenu(u8 taskId)
|
||||
case OPTION_EXIT:
|
||||
ClearStdWindowAndFrame(0, TRUE);
|
||||
ClearStdWindowAndFrame(task->tWindowId, TRUE);
|
||||
ScriptContext2_Disable();
|
||||
EnableBothScriptContexts();
|
||||
UnlockPlayerFieldControls();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
break;
|
||||
default:
|
||||
if (task->tInput == 0 && CountPartyMons() == PARTY_SIZE)
|
||||
if (task->tInput == OPTION_WITHDRAW && CountPartyMons() == PARTY_SIZE)
|
||||
{
|
||||
// Can't withdraw
|
||||
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
||||
AddTextPrinterParameterized2(0, FONT_2, gText_PartyFull, 0, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
|
||||
task->tState = 3;
|
||||
task->tState = STATE_ERROR_MSG;
|
||||
}
|
||||
else if (task->tInput == 1 && CountPartyMons() == 1)
|
||||
else if (task->tInput == OPTION_DEPOSIT && CountPartyMons() == 1)
|
||||
{
|
||||
// Can't deposit
|
||||
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
||||
@@ -362,7 +344,7 @@ static void Task_PCMainMenu(u8 taskId)
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
CleanupOverworldWindowsAndTilemaps();
|
||||
Cb2_EnterPSS(task->tInput);
|
||||
EnterPokeStorage(task->tInput);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -372,9 +354,9 @@ static void Task_PCMainMenu(u8 taskId)
|
||||
void ShowPokemonStorageSystemPC(void)
|
||||
{
|
||||
u8 taskId = CreateTask(Task_PCMainMenu, 80);
|
||||
gTasks[taskId].tState = 0;
|
||||
gTasks[taskId].tState = STATE_LOAD;
|
||||
gTasks[taskId].tSelectedOption = 0;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void FieldTask_ReturnToPcMenu(void)
|
||||
@@ -384,14 +366,14 @@ static void FieldTask_ReturnToPcMenu(void)
|
||||
|
||||
SetVBlankCallback(NULL);
|
||||
taskId = CreateTask(Task_PCMainMenu, 80);
|
||||
gTasks[taskId].tState = 0;
|
||||
gTasks[taskId].tState = STATE_LOAD;
|
||||
gTasks[taskId].tSelectedOption = sPreviousBoxOption;
|
||||
Task_PCMainMenu(taskId);
|
||||
SetVBlankCallback(vblankCb);
|
||||
FadeInFromBlack();
|
||||
}
|
||||
|
||||
static const struct WindowTemplate sUnknown_83CDA48 = {
|
||||
static const struct WindowTemplate sWindowTemplate_MainMenu = {
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
@@ -401,14 +383,13 @@ static const struct WindowTemplate sUnknown_83CDA48 = {
|
||||
.baseBlock = 0x001
|
||||
};
|
||||
|
||||
static void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr)
|
||||
static void CreatePCMainMenu(u8 whichMenu, s16 *windowIdPtr)
|
||||
{
|
||||
s16 windowId;
|
||||
windowId = AddWindow(&sUnknown_83CDA48);
|
||||
s16 windowId = AddWindow(&sWindowTemplate_MainMenu);
|
||||
|
||||
DrawStdWindowFrame(windowId, FALSE);
|
||||
PrintTextArray(windowId, FONT_2, GetMenuCursorDimensionByFont(FONT_2, 0), 2, 16, NELEMS(sMainMenuTexts), (void *)sMainMenuTexts);
|
||||
Menu_InitCursor(windowId, FONT_2, 0, 2, 16, NELEMS(sMainMenuTexts), whichMenu);
|
||||
PrintTextArray(windowId, FONT_2, GetMenuCursorDimensionByFont(FONT_2, 0), 2, 16, ARRAY_COUNT(sMainMenuTexts), (void *)sMainMenuTexts);
|
||||
Menu_InitCursor(windowId, FONT_2, 0, 2, 16, ARRAY_COUNT(sMainMenuTexts), whichMenu);
|
||||
*windowIdPtr = windowId;
|
||||
}
|
||||
|
||||
@@ -439,54 +420,44 @@ void ResetPokemonStorageSystem(void)
|
||||
SetBoxWallpaper(boxId, boxId % (MAX_DEFAULT_WALLPAPER + 1));
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// SECTION: Choose Box menu
|
||||
//
|
||||
// The below functions handle the popup menu that allows the player to cycle
|
||||
// through the boxes and select one. Used when storing Pokémon in Deposit mode
|
||||
// and for the Jump feature.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void LoadChooseBoxMenuGfx(struct ChooseBoxMenu *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal)
|
||||
void LoadChooseBoxMenuGfx(struct ChooseBoxMenu *menu, u16 tileTag, u16 palTag, u8 subpriority, bool32 loadPal)
|
||||
{
|
||||
struct SpritePalette palette = {
|
||||
sBoxSelectionPopupPalette, palTag
|
||||
sChooseBoxMenu_Pal, palTag
|
||||
};
|
||||
struct SpriteSheet sheets[] = {
|
||||
{sBoxSelectionPopupCenterTiles, 0x800, tileTag},
|
||||
{sBoxSelectionPopupSidesTiles, 0x180, tileTag + 1},
|
||||
{sChooseBoxMenuCenter_Gfx, 0x800, tileTag},
|
||||
{sChooseBoxMenuCorners_Gfx, 0x180, tileTag + 1},
|
||||
{}
|
||||
};
|
||||
|
||||
if (loadPal)
|
||||
if (loadPal) // Always false
|
||||
LoadSpritePalette(&palette);
|
||||
|
||||
LoadSpriteSheets(sheets);
|
||||
sBoxSelectionPopupSpriteManager = a0;
|
||||
a0->tileTag = tileTag;
|
||||
a0->paletteTag = palTag;
|
||||
a0->subpriority = a3;
|
||||
a0->loadedPalette = loadPal;
|
||||
sChooseBoxMenu = menu;
|
||||
menu->tileTag = tileTag;
|
||||
menu->paletteTag = palTag;
|
||||
menu->subpriority = subpriority;
|
||||
menu->loadedPalette = loadPal;
|
||||
}
|
||||
|
||||
void FreeBoxSelectionPopupSpriteGfx(void)
|
||||
{
|
||||
if (sBoxSelectionPopupSpriteManager->loadedPalette)
|
||||
FreeSpritePaletteByTag(sBoxSelectionPopupSpriteManager->paletteTag);
|
||||
FreeSpriteTilesByTag(sBoxSelectionPopupSpriteManager->tileTag);
|
||||
FreeSpriteTilesByTag(sBoxSelectionPopupSpriteManager->tileTag + 1);
|
||||
if (sChooseBoxMenu->loadedPalette)
|
||||
FreeSpritePaletteByTag(sChooseBoxMenu->paletteTag);
|
||||
FreeSpriteTilesByTag(sChooseBoxMenu->tileTag);
|
||||
FreeSpriteTilesByTag(sChooseBoxMenu->tileTag + 1);
|
||||
}
|
||||
|
||||
void sub_808C940(u8 curBox)
|
||||
void CreateChooseBoxMenuSprites(u8 curBox)
|
||||
{
|
||||
ChooseBoxMenu_CreateSprites(curBox);
|
||||
}
|
||||
|
||||
void sub_808C950(void)
|
||||
void DestroyChooseBoxMenuSprites(void)
|
||||
{
|
||||
sub_808CBA4();
|
||||
ChooseBoxMenu_DestroySprites();
|
||||
}
|
||||
|
||||
u8 HandleBoxChooseSelectionInput(void)
|
||||
@@ -494,60 +465,61 @@ u8 HandleBoxChooseSelectionInput(void)
|
||||
if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return 201;
|
||||
return BOXID_CANCELED;
|
||||
}
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return sBoxSelectionPopupSpriteManager->curBox;
|
||||
return sChooseBoxMenu->curBox;
|
||||
}
|
||||
if (JOY_NEW(DPAD_LEFT))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
UpdateBoxNameAndCountSprite_WraparoundLeft();
|
||||
ChooseBoxMenu_MoveLeft();
|
||||
}
|
||||
else if (JOY_NEW(DPAD_RIGHT))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
UpdateBoxNameAndCountSprite_WraparoundRight();
|
||||
ChooseBoxMenu_MoveRight();
|
||||
}
|
||||
return 200;
|
||||
return BOXID_NONE_CHOSEN;
|
||||
}
|
||||
|
||||
static const union AnimCmd gUnknown_83CDA50[] = {
|
||||
static const union AnimCmd sAnim_ChooseBoxMenu_TopLeft[] = {
|
||||
ANIMCMD_FRAME( 0, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd gUnknown_83CDA58[] = {
|
||||
static const union AnimCmd sAnim_ChooseBoxMenu_BottomLeft[] = {
|
||||
ANIMCMD_FRAME( 4, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd gUnknown_83CDA60[] = {
|
||||
static const union AnimCmd sAnim_ChooseBoxMenu_TopRight[] = {
|
||||
ANIMCMD_FRAME( 6, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd gUnknown_83CDA68[] = {
|
||||
static const union AnimCmd sAnim_ChooseBoxMenu_BottomRight[] = {
|
||||
ANIMCMD_FRAME(10, 5),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const gUnknown_83CDA70[] = {
|
||||
gUnknown_83CDA50,
|
||||
gUnknown_83CDA58,
|
||||
gUnknown_83CDA60,
|
||||
gUnknown_83CDA68
|
||||
static const union AnimCmd *const sAnims_ChooseBoxMenu[] = {
|
||||
sAnim_ChooseBoxMenu_TopLeft,
|
||||
sAnim_ChooseBoxMenu_BottomLeft,
|
||||
sAnim_ChooseBoxMenu_TopRight,
|
||||
sAnim_ChooseBoxMenu_BottomRight,
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd gUnknown_83CDA80[] = {
|
||||
static const union AffineAnimCmd sAffineAnim_ChooseBoxMenu[] = {
|
||||
AFFINEANIMCMD_FRAME(224, 224, 0, 0),
|
||||
AFFINEANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AffineAnimCmd *const gUnknown_83CDA90[] = {
|
||||
gUnknown_83CDA80
|
||||
// Unused
|
||||
static const union AffineAnimCmd *const sAffineAnims_ChooseBoxMenu[] = {
|
||||
sAffineAnim_ChooseBoxMenu
|
||||
};
|
||||
|
||||
static void ChooseBoxMenu_CreateSprites(u8 curBox)
|
||||
@@ -562,112 +534,112 @@ static void ChooseBoxMenu_CreateSprites(u8 curBox)
|
||||
0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
|
||||
};
|
||||
{
|
||||
const u8 gUnknown_83CDA94[] = _("/30");
|
||||
const u8 sText_OutOf30[] = _("/30");
|
||||
|
||||
sBoxSelectionPopupSpriteManager->curBox = curBox;
|
||||
template.tileTag = sBoxSelectionPopupSpriteManager->tileTag;
|
||||
template.paletteTag = sBoxSelectionPopupSpriteManager->paletteTag;
|
||||
sChooseBoxMenu->curBox = curBox;
|
||||
template.tileTag = sChooseBoxMenu->tileTag;
|
||||
template.paletteTag = sChooseBoxMenu->paletteTag;
|
||||
|
||||
spriteId = CreateSprite(&template, 160, 96, 0);
|
||||
sBoxSelectionPopupSpriteManager->menuSprite = gSprites + spriteId;
|
||||
sChooseBoxMenu->menuSprite = gSprites + spriteId;
|
||||
|
||||
// Manual subsprites
|
||||
oamData.shape = SPRITE_SHAPE(8x32);
|
||||
oamData.size = SPRITE_SIZE(8x32);
|
||||
template.tileTag = sBoxSelectionPopupSpriteManager->tileTag + 1;
|
||||
template.anims = gUnknown_83CDA70;
|
||||
for (i = 0; i < 4; i++)
|
||||
template.tileTag = sChooseBoxMenu->tileTag + 1;
|
||||
template.anims = sAnims_ChooseBoxMenu;
|
||||
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->menuCornerSprites); i++)
|
||||
{
|
||||
u16 r5;
|
||||
spriteId = CreateSprite(&template, 124, 80, sBoxSelectionPopupSpriteManager->subpriority);
|
||||
sBoxSelectionPopupSpriteManager->menuSideSprites[i] = gSprites + spriteId;
|
||||
r5 = 0;
|
||||
// corner sprites are created in order of top left, bottom left, top right, bottom right
|
||||
u16 animNum;
|
||||
spriteId = CreateSprite(&template, 124, 80, sChooseBoxMenu->subpriority); // place at top left
|
||||
sChooseBoxMenu->menuCornerSprites[i] = &gSprites[spriteId];
|
||||
animNum = 0;
|
||||
if (i & 2)
|
||||
{
|
||||
sBoxSelectionPopupSpriteManager->menuSideSprites[i]->x = 196;
|
||||
r5 = 2;
|
||||
sChooseBoxMenu->menuCornerSprites[i]->x = 196; // move to bottom
|
||||
animNum = 2;
|
||||
}
|
||||
if (i & 1)
|
||||
{
|
||||
sBoxSelectionPopupSpriteManager->menuSideSprites[i]->y = 112;
|
||||
sBoxSelectionPopupSpriteManager->menuSideSprites[i]->oam.size = SPRITE_SIZE(8x16);
|
||||
r5++;
|
||||
sChooseBoxMenu->menuCornerSprites[i]->y = 112; // move to right
|
||||
sChooseBoxMenu->menuCornerSprites[i]->oam.size = SPRITE_SIZE(8x16);
|
||||
animNum++;
|
||||
}
|
||||
StartSpriteAnim(sBoxSelectionPopupSpriteManager->menuSideSprites[i], r5);
|
||||
StartSpriteAnim(sChooseBoxMenu->menuCornerSprites[i], animNum);
|
||||
}
|
||||
for (i = 0; i < 2; i++)
|
||||
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->arrowSprites); i++)
|
||||
{
|
||||
sBoxSelectionPopupSpriteManager->arrowSprites[i] = CreateChooseBoxArrows(72 * i + 0x7c, 0x58, i, 0, sBoxSelectionPopupSpriteManager->subpriority);
|
||||
if (sBoxSelectionPopupSpriteManager->arrowSprites[i])
|
||||
sChooseBoxMenu->arrowSprites[i] = CreateChooseBoxArrows(72 * i + 124, 88, i, 0, sChooseBoxMenu->subpriority);
|
||||
if (sChooseBoxMenu->arrowSprites[i])
|
||||
{
|
||||
sBoxSelectionPopupSpriteManager->arrowSprites[i]->data[0] = (i == 0 ? -1 : 1);
|
||||
sBoxSelectionPopupSpriteManager->arrowSprites[i]->callback = sub_808CD64;
|
||||
sChooseBoxMenu->arrowSprites[i]->data[0] = (i == 0 ? -1 : 1);
|
||||
sChooseBoxMenu->arrowSprites[i]->callback = SpriteCB_ChooseBoxArrow;
|
||||
}
|
||||
}
|
||||
PrintBoxNameAndCountToSprite();
|
||||
PrintToSpriteWithTagUnk0240(gUnknown_83CDA94, 5, 3);
|
||||
ChooseBoxMenu_PrintBoxNameAndCount();
|
||||
ChooseBoxMenu_PrintTextToSprite(sText_OutOf30, 5, 3);
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_808CBA4(void)
|
||||
static void ChooseBoxMenu_DestroySprites(void)
|
||||
{
|
||||
u16 i;
|
||||
if (sBoxSelectionPopupSpriteManager->menuSprite)
|
||||
if (sChooseBoxMenu->menuSprite)
|
||||
{
|
||||
DestroySprite(sBoxSelectionPopupSpriteManager->menuSprite);
|
||||
sBoxSelectionPopupSpriteManager->menuSprite = NULL;
|
||||
DestroySprite(sChooseBoxMenu->menuSprite);
|
||||
sChooseBoxMenu->menuSprite = NULL;
|
||||
}
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->menuCornerSprites); i++)
|
||||
{
|
||||
if (sBoxSelectionPopupSpriteManager->menuSideSprites[i])
|
||||
if (sChooseBoxMenu->menuCornerSprites[i])
|
||||
{
|
||||
DestroySprite(sBoxSelectionPopupSpriteManager->menuSideSprites[i]);
|
||||
sBoxSelectionPopupSpriteManager->menuSideSprites[i] = NULL;
|
||||
DestroySprite(sChooseBoxMenu->menuCornerSprites[i]);
|
||||
sChooseBoxMenu->menuCornerSprites[i] = NULL;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 2; i++)
|
||||
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->arrowSprites); i++)
|
||||
{
|
||||
if (sBoxSelectionPopupSpriteManager->arrowSprites[i])
|
||||
DestroySprite(sBoxSelectionPopupSpriteManager->arrowSprites[i]);
|
||||
if (sChooseBoxMenu->arrowSprites[i])
|
||||
DestroySprite(sChooseBoxMenu->arrowSprites[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateBoxNameAndCountSprite_WraparoundRight(void)
|
||||
static void ChooseBoxMenu_MoveRight(void)
|
||||
{
|
||||
if (++sBoxSelectionPopupSpriteManager->curBox >= TOTAL_BOXES_COUNT)
|
||||
sBoxSelectionPopupSpriteManager->curBox = 0;
|
||||
PrintBoxNameAndCountToSprite();
|
||||
if (++sChooseBoxMenu->curBox >= TOTAL_BOXES_COUNT)
|
||||
sChooseBoxMenu->curBox = 0;
|
||||
ChooseBoxMenu_PrintBoxNameAndCount();
|
||||
}
|
||||
|
||||
static void UpdateBoxNameAndCountSprite_WraparoundLeft(void)
|
||||
static void ChooseBoxMenu_MoveLeft(void)
|
||||
{
|
||||
sBoxSelectionPopupSpriteManager->curBox = (sBoxSelectionPopupSpriteManager->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : sBoxSelectionPopupSpriteManager->curBox - 1);
|
||||
PrintBoxNameAndCountToSprite();
|
||||
sChooseBoxMenu->curBox = (sChooseBoxMenu->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : sChooseBoxMenu->curBox - 1);
|
||||
ChooseBoxMenu_PrintBoxNameAndCount();
|
||||
}
|
||||
|
||||
static void PrintBoxNameAndCountToSprite(void)
|
||||
static void ChooseBoxMenu_PrintBoxNameAndCount(void)
|
||||
{
|
||||
u8 nPokemonInBox = CountMonsInBox(sBoxSelectionPopupSpriteManager->curBox);
|
||||
u8 *boxName = StringCopy(sBoxSelectionPopupSpriteManager->strbuf, GetBoxNamePtr(sBoxSelectionPopupSpriteManager->curBox));
|
||||
u8 numMonInBox = CountMonsInBox(sChooseBoxMenu->curBox);
|
||||
u8 *boxName = StringCopy(sChooseBoxMenu->strbuf, GetBoxNamePtr(sChooseBoxMenu->curBox));
|
||||
|
||||
while (boxName < sBoxSelectionPopupSpriteManager->strbuf + BOX_NAME_LENGTH)
|
||||
while (boxName < sChooseBoxMenu->strbuf + BOX_NAME_LENGTH)
|
||||
*boxName++ = CHAR_SPACE;
|
||||
*boxName = EOS;
|
||||
|
||||
PrintToSpriteWithTagUnk0240(sBoxSelectionPopupSpriteManager->strbuf, 0, 1);
|
||||
ChooseBoxMenu_PrintTextToSprite(sChooseBoxMenu->strbuf, 0, 1);
|
||||
|
||||
ConvertIntToDecimalStringN(sBoxSelectionPopupSpriteManager->strbuf, nPokemonInBox, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
||||
ConvertIntToDecimalStringN(sChooseBoxMenu->strbuf, numMonInBox, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
||||
|
||||
PrintToSpriteWithTagUnk0240(sBoxSelectionPopupSpriteManager->strbuf, 3, 3);
|
||||
ChooseBoxMenu_PrintTextToSprite(sChooseBoxMenu->strbuf, 3, 3);
|
||||
}
|
||||
|
||||
static void PrintToSpriteWithTagUnk0240(const u8 *str, u16 x, u16 y)
|
||||
static void ChooseBoxMenu_PrintTextToSprite(const u8 *str, u16 x, u16 y)
|
||||
{
|
||||
u16 tileStart = GetSpriteTileStartByTag(sBoxSelectionPopupSpriteManager->tileTag);
|
||||
PrintStringToBufferCopyNow(str, (void *)(OBJ_VRAM0 + tileStart * 32 + 256 * y + 32 * x), 0x100, TEXT_COLOR_RED, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5, sBoxSelectionPopupSpriteManager->buffer);
|
||||
void *dst = (void *)(OBJ_VRAM0 + GetSpriteTileStartByTag(sChooseBoxMenu->tileTag) * 32 + 256 * y + 32 * x);
|
||||
PrintStringToBufferCopyNow(str, dst, 0x100, TEXT_COLOR_RED, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5, sChooseBoxMenu->buffer);
|
||||
}
|
||||
|
||||
static void sub_808CD64(struct Sprite *sprite)
|
||||
static void SpriteCB_ChooseBoxArrow(struct Sprite *sprite)
|
||||
{
|
||||
if (++sprite->data[1] > 3)
|
||||
{
|
||||
@@ -681,8 +653,8 @@ static void sub_808CD64(struct Sprite *sprite)
|
||||
}
|
||||
}
|
||||
|
||||
// Forward-declared rodata
|
||||
// Unused, since LoadChooseBoxMenuGfx is always called with `loadPal` as false
|
||||
static const u16 sChooseBoxMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/unused_choose_box_menu.gbapal");
|
||||
|
||||
static const u16 sBoxSelectionPopupPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CDA98.gbapal");
|
||||
static const u16 sBoxSelectionPopupCenterTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CDAB8.4bpp");
|
||||
static const u16 sBoxSelectionPopupSidesTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CE2B8.4bpp");
|
||||
static const u8 sChooseBoxMenuCenter_Gfx[] = INCBIN_U8("graphics/pokemon_storage/choose_box_menu_center.4bpp");
|
||||
static const u8 sChooseBoxMenuCorners_Gfx[] = INCBIN_U8("graphics/pokemon_storage/choose_box_menu_corners.4bpp");
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -256,7 +256,7 @@ static void QLogCB_Playback(void)
|
||||
else
|
||||
{
|
||||
sQuestLogCurrentScene.sceneEndMode = 2;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
QuestLog_BeginFadeAtEndOfScene(0);
|
||||
}
|
||||
}
|
||||
@@ -791,7 +791,7 @@ static void QuestLog_AdvancePlayhead(void)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
if (++sCurrentSceneNum < QUEST_LOG_SCENE_COUNT && gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType != 0)
|
||||
{
|
||||
sNumScenes--;
|
||||
@@ -1051,7 +1051,7 @@ static void QuestLog_WaitFadeAndCancelPlayback(void)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
for (sCurrentSceneNum = sCurrentSceneNum; sCurrentSceneNum < QUEST_LOG_SCENE_COUNT; sCurrentSceneNum++)
|
||||
{
|
||||
if (gSaveBlock1Ptr->questLog[sCurrentSceneNum].startType == 0)
|
||||
@@ -1087,12 +1087,12 @@ static void Task_FinalScene_WaitFade(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
if (ScriptContext2_IsEnabled() != TRUE)
|
||||
if (ArePlayerFieldControlsLocked() != TRUE)
|
||||
{
|
||||
FreezeObjectEvents();
|
||||
HandleEnforcedLookDirectionOnPlayerStopMoving();
|
||||
StopPlayerAvatar();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
task->func = Task_QuestLogScene_SavedGame;
|
||||
}
|
||||
}
|
||||
@@ -1113,7 +1113,7 @@ static void Task_QuestLogScene_SavedGame(u8 taskId)
|
||||
task->data[1] = 0;
|
||||
task->func = Task_WaitAtEndOfQuestLog;
|
||||
FreezeObjectEvents();
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1179,7 +1179,7 @@ static void Task_EndQuestLog(u8 taskId)
|
||||
Free(sPalettesBackup);
|
||||
sQuestLogCurrentScene = (struct UnkStruct_203AE94){};
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
gTextFlags.autoScroll = FALSE;
|
||||
gGlobalFieldTintMode = QL_TINT_NONE;
|
||||
DisableWildEncounters(FALSE);
|
||||
@@ -1417,7 +1417,7 @@ void sub_81127F8(struct FieldInput * a0)
|
||||
sCurQuestLogEntry[sQuestLogCursor].mapGroup = r2 >> 16;
|
||||
sCurQuestLogEntry[sQuestLogCursor].animId = r2 >> 24; // always 0
|
||||
sQuestLogCursor++;
|
||||
if (ScriptContext2_IsEnabled())
|
||||
if (ArePlayerFieldControlsLocked())
|
||||
sNextStepDelay = TRUE;
|
||||
else
|
||||
sNextStepDelay = FALSE;
|
||||
@@ -1590,7 +1590,7 @@ void sub_8112B3C(void)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (ScriptContext2_IsEnabled() != TRUE)
|
||||
if (ArePlayerFieldControlsLocked() != TRUE)
|
||||
{
|
||||
sNextStepDelay++;
|
||||
if (sQuestLogCursor >= sNumEventsInLogEntry)
|
||||
@@ -1627,7 +1627,7 @@ u8 sub_8112CAC(void)
|
||||
|
||||
static bool8 RecordHeadAtEndOfEntryOrScriptContext2Enabled(void)
|
||||
{
|
||||
if (sQuestLogCursor >= sNumEventsInLogEntry || ScriptContext2_IsEnabled() == TRUE)
|
||||
if (sQuestLogCursor >= sNumEventsInLogEntry || ArePlayerFieldControlsLocked() == TRUE)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ static void QL_GfxTransition_Fish(void)
|
||||
if (gQuestLogPlaybackState == 1 || gQuestLogPlaybackState == 3)
|
||||
{
|
||||
u8 taskId;
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
taskId = CreateTask(Task_QLFishMovement, 0xFF);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
@@ -129,7 +129,7 @@ static void Task_QLFishMovement(u8 taskId)
|
||||
ObjectEventTurn(objectEvent, objectEvent->movementDirection);
|
||||
sprite->x2 = 0;
|
||||
sprite->y2 = 0;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
break;
|
||||
@@ -166,7 +166,7 @@ static void Task_QLVSSeekerMovement(u8 taskId)
|
||||
if (!FieldEffectActiveListContains(FLDEFF_USE_VS_SEEKER))
|
||||
{
|
||||
UnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ static bool32 TryReleaseUnionRoomPlayerObjectEvent(u32 playerIdx)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
if (!ArePlayerFieldControlsLocked())
|
||||
{
|
||||
UnfreezeObjectEvent(object);
|
||||
}
|
||||
|
||||
+5
-5
@@ -46,7 +46,7 @@ bool8 SafariZoneTakeStep(void)
|
||||
gSafariZoneStepCounter--;
|
||||
if (gSafariZoneStepCounter == 0)
|
||||
{
|
||||
ScriptContext1_SetupScript(SafariZone_EventScript_TimesUp);
|
||||
ScriptContext_SetupScript(SafariZone_EventScript_TimesUp);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -54,7 +54,7 @@ bool8 SafariZoneTakeStep(void)
|
||||
|
||||
void SafariZoneRetirePrompt(void)
|
||||
{
|
||||
ScriptContext1_SetupScript(SafariZone_EventScript_RetirePrompt);
|
||||
ScriptContext_SetupScript(SafariZone_EventScript_RetirePrompt);
|
||||
}
|
||||
|
||||
void CB2_EndSafariBattle(void)
|
||||
@@ -65,15 +65,15 @@ void CB2_EndSafariBattle(void)
|
||||
}
|
||||
else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS)
|
||||
{
|
||||
ScriptContext2_RunNewScript(SafariZone_EventScript_OutOfBallsMidBattle);
|
||||
RunScriptImmediately(SafariZone_EventScript_OutOfBallsMidBattle);
|
||||
WarpIntoMap();
|
||||
gFieldCallback = FieldCB_SafariZoneRanOutOfBalls;
|
||||
SetMainCallback2(CB2_LoadMap);
|
||||
}
|
||||
else if (gBattleOutcome == B_OUTCOME_CAUGHT)
|
||||
{
|
||||
ScriptContext1_SetupScript(SafariZone_EventScript_OutOfBalls);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_SetupScript(SafariZone_EventScript_OutOfBalls);
|
||||
ScriptContext_Stop();
|
||||
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -125,7 +125,7 @@ bool8 ScrCmd_callnative(struct ScriptContext * ctx)
|
||||
|
||||
bool8 ScrCmd_waitstate(struct ScriptContext * ctx)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ bool8 ScrCmd_callstd_if(struct ScriptContext * ctx)
|
||||
|
||||
bool8 ScrCmd_returnram(struct ScriptContext * ctx)
|
||||
{
|
||||
ScriptJump(ctx, gRAMScriptPtr);
|
||||
ScriptJump(ctx, gRamScriptRetAddr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ bool8 ScrCmd_trywondercardscript(struct ScriptContext * ctx)
|
||||
const u8 * script = GetSavedRamScriptIfValid();
|
||||
if (script != NULL)
|
||||
{
|
||||
gRAMScriptPtr = ctx->scriptPtr;
|
||||
gRamScriptRetAddr = ctx->scriptPtr;
|
||||
ScriptJump(ctx, script);
|
||||
}
|
||||
return FALSE;
|
||||
@@ -604,7 +604,7 @@ bool8 ScrCmd_setworldmapflag(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_animateflash(struct ScriptContext * ctx)
|
||||
{
|
||||
AnimateFlash(ScriptReadByte(ctx));
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1414,7 +1414,7 @@ bool8 ScrCmd_yesnobox(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_YesNo(left, top) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1432,7 +1432,7 @@ bool8 ScrCmd_multichoice(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1451,7 +1451,7 @@ bool8 ScrCmd_multichoicedefault(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_MultichoiceWithDefault(left, top, multichoiceId, ignoreBPress, defaultChoice) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1481,7 +1481,7 @@ bool8 ScrCmd_multichoicegrid(struct ScriptContext * ctx)
|
||||
|
||||
if (ScriptMenu_MultichoiceGrid(left, top, multichoiceId, ignoreBPress, numColumns) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1510,7 +1510,7 @@ bool8 ScrCmd_drawboxtext(struct ScriptContext * ctx)
|
||||
|
||||
/*if (Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE)
|
||||
{
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}*/
|
||||
return FALSE;
|
||||
@@ -1548,7 +1548,7 @@ bool8 ScrCmd_showcontestpainting(struct ScriptContext * ctx)
|
||||
SetContestWinnerForPainting(contestWinnerId);
|
||||
|
||||
ShowContestPainting();
|
||||
ScriptContext1_Stop()
|
||||
ScriptContext_Stop()
|
||||
return TRUE;
|
||||
*/
|
||||
return FALSE;
|
||||
@@ -1932,7 +1932,7 @@ bool8 ScrCmd_setwildbattle(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_dowildbattle(struct ScriptContext * ctx)
|
||||
{
|
||||
StartScriptedWildBattle();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1941,7 +1941,7 @@ bool8 ScrCmd_pokemart(struct ScriptContext * ctx)
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
CreatePokemartMenu(ptr);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1950,7 +1950,7 @@ bool8 ScrCmd_pokemartdecoration(struct ScriptContext * ctx)
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
CreateDecorationShop1Menu(ptr);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1960,7 +1960,7 @@ bool8 ScrCmd_pokemartdecoration2(struct ScriptContext * ctx)
|
||||
const void *ptr = (void *)ScriptReadWord(ctx);
|
||||
|
||||
CreateDecorationShop2Menu(ptr);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1969,7 +1969,7 @@ bool8 ScrCmd_playslotmachine(struct ScriptContext * ctx)
|
||||
u8 slotMachineIndex = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
PlaySlotMachine(slotMachineIndex, CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1997,7 +1997,7 @@ bool8 ScrCmd_getpokenewsactive(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_choosecontestmon(struct ScriptContext * ctx)
|
||||
{
|
||||
// ChooseContestMon();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2005,7 +2005,7 @@ bool8 ScrCmd_choosecontestmon(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_startcontest(struct ScriptContext * ctx)
|
||||
{
|
||||
// StartContest();
|
||||
// ScriptContext1_Stop();
|
||||
// ScriptContext_Stop();
|
||||
// return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2013,7 +2013,7 @@ bool8 ScrCmd_startcontest(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_showcontestresults(struct ScriptContext * ctx)
|
||||
{
|
||||
// ShowContestResults();
|
||||
// ScriptContext1_Stop();
|
||||
// ScriptContext_Stop();
|
||||
// return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2021,7 +2021,7 @@ bool8 ScrCmd_showcontestresults(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_contestlinktransfer(struct ScriptContext * ctx)
|
||||
{
|
||||
// ContestLinkTransfer(gSpecialVar_ContestCategory);
|
||||
// ScriptContext1_Stop();
|
||||
// ScriptContext_Stop();
|
||||
// return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -2176,7 +2176,7 @@ bool8 ScrCmd_addelevmenuitem(struct ScriptContext * ctx)
|
||||
bool8 ScrCmd_showelevmenu(struct ScriptContext * ctx)
|
||||
{
|
||||
/*ScriptShowElevatorMenu();
|
||||
ScriptContext1_Stop();
|
||||
ScriptContext_Stop();
|
||||
return TRUE;*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+109
-81
@@ -3,32 +3,35 @@
|
||||
#include "event_data.h"
|
||||
#include "quest_log.h"
|
||||
#include "constants/maps.h"
|
||||
|
||||
#define RAM_SCRIPT_MAGIC 51
|
||||
#define SCRIPT_STACK_SIZE 20
|
||||
|
||||
#include "constants/map_scripts.h"
|
||||
|
||||
extern void ResetContextNpcTextColor(void); // field_specials
|
||||
extern u16 CalcCRC16WithTable(u8 *data, int length); // util
|
||||
extern bool32 ValidateReceivedWonderCard(void); // mevent
|
||||
|
||||
enum
|
||||
{
|
||||
#define RAM_SCRIPT_MAGIC 51
|
||||
|
||||
enum {
|
||||
SCRIPT_MODE_STOPPED,
|
||||
SCRIPT_MODE_BYTECODE,
|
||||
SCRIPT_MODE_NATIVE,
|
||||
};
|
||||
|
||||
EWRAM_DATA u8 gWalkAwayFromSignInhibitTimer = 0;
|
||||
EWRAM_DATA const u8 *gRAMScriptPtr = NULL;
|
||||
enum {
|
||||
CONTEXT_RUNNING,
|
||||
CONTEXT_WAITING,
|
||||
CONTEXT_SHUTDOWN,
|
||||
};
|
||||
|
||||
// iwram bss
|
||||
static u8 sScriptContext1Status;
|
||||
EWRAM_DATA u8 gWalkAwayFromSignInhibitTimer = 0;
|
||||
EWRAM_DATA const u8 *gRamScriptRetAddr = NULL;
|
||||
|
||||
static u8 sGlobalScriptContextStatus;
|
||||
static u32 sUnusedVariable1;
|
||||
static struct ScriptContext sScriptContext1;
|
||||
static struct ScriptContext sGlobalScriptContext;
|
||||
static u32 sUnusedVariable2;
|
||||
static struct ScriptContext sScriptContext2;
|
||||
static bool8 sScriptContext2Enabled;
|
||||
static struct ScriptContext sImmediateScriptContext;
|
||||
static bool8 sLockFieldControls;
|
||||
static u8 sMsgBoxWalkawayDisabled;
|
||||
static u8 sMsgBoxIsCancelable;
|
||||
static u8 sQuestLogInput;
|
||||
@@ -50,10 +53,10 @@ void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTable
|
||||
ctx->cmdTable = cmdTable;
|
||||
ctx->cmdTableEnd = cmdTableEnd;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < (int)ARRAY_COUNT(ctx->data); i++)
|
||||
ctx->data[i] = 0;
|
||||
|
||||
for (i = 0; i < SCRIPT_STACK_SIZE; i++)
|
||||
for (i = 0; i < (int)ARRAY_COUNT(ctx->stack); i++)
|
||||
ctx->stack[i] = 0;
|
||||
}
|
||||
|
||||
@@ -90,6 +93,8 @@ bool8 RunScriptCommand(struct ScriptContext *ctx)
|
||||
case SCRIPT_MODE_STOPPED:
|
||||
return FALSE;
|
||||
case SCRIPT_MODE_NATIVE:
|
||||
// Try to call a function in C
|
||||
// Continue to bytecode if no function or it returns TRUE
|
||||
if (ctx->nativePtr)
|
||||
{
|
||||
if (ctx->nativePtr() == TRUE)
|
||||
@@ -97,6 +102,7 @@ bool8 RunScriptCommand(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
ctx->mode = SCRIPT_MODE_BYTECODE;
|
||||
// fallthrough
|
||||
case SCRIPT_MODE_BYTECODE:
|
||||
while (1)
|
||||
{
|
||||
@@ -133,9 +139,9 @@ bool8 RunScriptCommand(struct ScriptContext *ctx)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr)
|
||||
static u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr)
|
||||
{
|
||||
if (ctx->stackDepth + 1 >= SCRIPT_STACK_SIZE)
|
||||
if (ctx->stackDepth + 1 >= (int)ARRAY_COUNT(ctx->stack))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -147,7 +153,7 @@ u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *ScriptPop(struct ScriptContext *ctx)
|
||||
static const u8 *ScriptPop(struct ScriptContext *ctx)
|
||||
{
|
||||
if (ctx->stackDepth == 0)
|
||||
return NULL;
|
||||
@@ -188,19 +194,19 @@ u32 ScriptReadWord(struct ScriptContext *ctx)
|
||||
return (((((value3 << 8) + value2) << 8) + value1) << 8) + value0;
|
||||
}
|
||||
|
||||
void ScriptContext2_Enable(void)
|
||||
void LockPlayerFieldControls(void)
|
||||
{
|
||||
sScriptContext2Enabled = TRUE;
|
||||
sLockFieldControls = TRUE;
|
||||
}
|
||||
|
||||
void ScriptContext2_Disable(void)
|
||||
void UnlockPlayerFieldControls(void)
|
||||
{
|
||||
sScriptContext2Enabled = FALSE;
|
||||
sLockFieldControls = FALSE;
|
||||
}
|
||||
|
||||
bool8 ScriptContext2_IsEnabled(void)
|
||||
bool8 ArePlayerFieldControlsLocked(void)
|
||||
{
|
||||
return sScriptContext2Enabled;
|
||||
return sLockFieldControls;
|
||||
}
|
||||
|
||||
void SetQuestLogInputIsDpadFlag(void)
|
||||
@@ -294,70 +300,86 @@ void ResetFacingNpcOrSignPostVars(void)
|
||||
MsgSetNotSignPost();
|
||||
}
|
||||
|
||||
bool8 ScriptContext1_IsScriptSetUp(void)
|
||||
// The ScriptContext_* functions work with the primary script context,
|
||||
// which yields control back to native code should the script make a wait call.
|
||||
|
||||
// Checks if the global script context is able to be run right now.
|
||||
bool8 ScriptContext_IsEnabled(void)
|
||||
{
|
||||
if (sScriptContext1Status == 0)
|
||||
if (sGlobalScriptContextStatus == CONTEXT_RUNNING)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ScriptContext1_Init(void)
|
||||
// Re-initializes the global script context to zero.
|
||||
void ScriptContext_Init(void)
|
||||
{
|
||||
InitScriptContext(&sScriptContext1, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
sScriptContext1Status = 2;
|
||||
InitScriptContext(&sGlobalScriptContext, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
sGlobalScriptContextStatus = CONTEXT_SHUTDOWN;
|
||||
}
|
||||
|
||||
bool8 ScriptContext2_RunScript(void)
|
||||
// Runs the script until the script makes a wait* call, then returns true if
|
||||
// there's more script to run, or false if the script has hit the end.
|
||||
// This function also returns false if the context is finished
|
||||
// or waiting (after a call to _Stop)
|
||||
bool8 ScriptContext_RunScript(void)
|
||||
{
|
||||
if (sScriptContext1Status == 2)
|
||||
return 0;
|
||||
if (sGlobalScriptContextStatus == CONTEXT_SHUTDOWN)
|
||||
return FALSE;
|
||||
|
||||
if (sScriptContext1Status == 1)
|
||||
return 0;
|
||||
if (sGlobalScriptContextStatus == CONTEXT_WAITING)
|
||||
return FALSE;
|
||||
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
|
||||
if (!RunScriptCommand(&sScriptContext1))
|
||||
if (!RunScriptCommand(&sGlobalScriptContext))
|
||||
{
|
||||
sScriptContext1Status = 2;
|
||||
ScriptContext2_Disable();
|
||||
return 0;
|
||||
sGlobalScriptContextStatus = CONTEXT_SHUTDOWN;
|
||||
UnlockPlayerFieldControls();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ScriptContext1_SetupScript(const u8 *ptr)
|
||||
// Sets up a new script in the global context and enables the context
|
||||
void ScriptContext_SetupScript(const u8 *ptr)
|
||||
{
|
||||
ClearMsgBoxCancelableState();
|
||||
EnableMsgBoxWalkaway();
|
||||
ClearQuestLogInputIsDpadFlag();
|
||||
InitScriptContext(&sScriptContext1, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sScriptContext1, ptr);
|
||||
ScriptContext2_Enable();
|
||||
sScriptContext1Status = 0;
|
||||
|
||||
InitScriptContext(&sGlobalScriptContext, gScriptCmdTable, gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sGlobalScriptContext, ptr);
|
||||
LockPlayerFieldControls();
|
||||
sGlobalScriptContextStatus = CONTEXT_RUNNING;
|
||||
}
|
||||
|
||||
void ScriptContext1_Stop(void)
|
||||
// Puts the script into waiting mode; usually called from a wait* script command.
|
||||
void ScriptContext_Stop(void)
|
||||
{
|
||||
sScriptContext1Status = 1;
|
||||
sGlobalScriptContextStatus = CONTEXT_WAITING;
|
||||
}
|
||||
|
||||
void EnableBothScriptContexts(void)
|
||||
// Puts the script into running mode.
|
||||
void ScriptContext_Enable(void)
|
||||
{
|
||||
sScriptContext1Status = 0;
|
||||
ScriptContext2_Enable();
|
||||
sGlobalScriptContextStatus = CONTEXT_RUNNING;
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void ScriptContext2_RunNewScript(const u8 *ptr)
|
||||
// Sets up and runs a script in its own context immediately. The script will be
|
||||
// finished when this function returns. Used mainly by all of the map header
|
||||
// scripts (except the frame table scripts).
|
||||
void RunScriptImmediately(const u8 *ptr)
|
||||
{
|
||||
InitScriptContext(&sScriptContext2, &gScriptCmdTable, &gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sScriptContext2, ptr);
|
||||
while (RunScriptCommand(&sScriptContext2) == TRUE);
|
||||
InitScriptContext(&sImmediateScriptContext, &gScriptCmdTable, &gScriptCmdTableEnd);
|
||||
SetupBytecodeScript(&sImmediateScriptContext, ptr);
|
||||
while (RunScriptCommand(&sImmediateScriptContext) == TRUE);
|
||||
}
|
||||
|
||||
u8 *mapheader_get_tagged_pointer(u8 tag)
|
||||
static u8 *MapHeaderGetScriptTable(u8 tag)
|
||||
{
|
||||
const u8 *mapScripts = gMapHeader.mapScripts;
|
||||
|
||||
@@ -377,16 +399,16 @@ u8 *mapheader_get_tagged_pointer(u8 tag)
|
||||
}
|
||||
}
|
||||
|
||||
void mapheader_run_script_by_tag(u8 tag)
|
||||
static void MapHeaderRunScriptType(u8 tag)
|
||||
{
|
||||
u8 *ptr = mapheader_get_tagged_pointer(tag);
|
||||
u8 *ptr = MapHeaderGetScriptTable(tag);
|
||||
if (ptr != NULL)
|
||||
ScriptContext2_RunNewScript(ptr);
|
||||
RunScriptImmediately(ptr);
|
||||
}
|
||||
|
||||
u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag)
|
||||
static u8 *MapHeaderCheckScriptTable(u8 tag)
|
||||
{
|
||||
u8 *ptr = mapheader_get_tagged_pointer(tag);
|
||||
u8 *ptr = MapHeaderGetScriptTable(tag);
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
@@ -395,64 +417,70 @@ u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag)
|
||||
{
|
||||
u16 varIndex1;
|
||||
u16 varIndex2;
|
||||
varIndex1 = ptr[0] | (ptr[1] << 8);
|
||||
|
||||
// Read first var (or .2byte terminal value)
|
||||
varIndex1 = T1_READ_16(ptr);
|
||||
if (!varIndex1)
|
||||
return NULL;
|
||||
return NULL; // Reached end of table
|
||||
ptr += 2;
|
||||
varIndex2 = ptr[0] | (ptr[1] << 8);
|
||||
|
||||
// Read second var
|
||||
varIndex2 = T1_READ_16(ptr);
|
||||
ptr += 2;
|
||||
|
||||
// Run map script if vars are equal
|
||||
if (VarGet(varIndex1) == VarGet(varIndex2))
|
||||
return (u8 *)(ptr[0] + (ptr[1] << 8) + (ptr[2] << 16) + (ptr[3] << 24));
|
||||
return T2_READ_PTR(ptr);
|
||||
ptr += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void RunOnLoadMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(1);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_LOAD);
|
||||
}
|
||||
|
||||
void RunOnTransitionMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(3);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_TRANSITION);
|
||||
}
|
||||
|
||||
void RunOnResumeMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(5);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_RESUME);
|
||||
}
|
||||
|
||||
void RunOnReturnToFieldMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(7);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_RETURN_TO_FIELD);
|
||||
}
|
||||
|
||||
void RunOnDiveWarpMapScript(void)
|
||||
{
|
||||
mapheader_run_script_by_tag(6);
|
||||
MapHeaderRunScriptType(MAP_SCRIPT_ON_DIVE_WARP);
|
||||
}
|
||||
|
||||
bool8 TryRunOnFrameMapScript(void)
|
||||
{
|
||||
u8 *ptr;
|
||||
|
||||
if(gQuestLogState == QL_STATE_PLAYBACK_LAST)
|
||||
return 0;
|
||||
if (gQuestLogState == QL_STATE_PLAYBACK_LAST)
|
||||
return FALSE;
|
||||
|
||||
ptr = mapheader_get_first_match_from_tagged_ptr_list(2);
|
||||
ptr = MapHeaderCheckScriptTable(MAP_SCRIPT_ON_FRAME_TABLE);
|
||||
|
||||
if (!ptr)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
ScriptContext1_SetupScript(ptr);
|
||||
return 1;
|
||||
ScriptContext_SetupScript(ptr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TryRunOnWarpIntoMapScript(void)
|
||||
{
|
||||
u8 *ptr = mapheader_get_first_match_from_tagged_ptr_list(4);
|
||||
u8 *ptr = MapHeaderCheckScriptTable(MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE);
|
||||
if (ptr)
|
||||
ScriptContext2_RunNewScript(ptr);
|
||||
RunScriptImmediately(ptr);
|
||||
}
|
||||
|
||||
u32 CalculateRamScriptChecksum(void)
|
||||
@@ -486,7 +514,7 @@ bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objec
|
||||
const u8 *GetRamScript(u8 objectId, const u8 *script)
|
||||
{
|
||||
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
|
||||
gRAMScriptPtr = NULL;
|
||||
gRamScriptRetAddr = NULL;
|
||||
if (scriptData->magic != RAM_SCRIPT_MAGIC)
|
||||
return script;
|
||||
if (scriptData->mapGroup != gSaveBlock1Ptr->location.mapGroup)
|
||||
@@ -502,7 +530,7 @@ const u8 *GetRamScript(u8 objectId, const u8 *script)
|
||||
}
|
||||
else
|
||||
{
|
||||
gRAMScriptPtr = script;
|
||||
gRamScriptRetAddr = script;
|
||||
return scriptData->script;
|
||||
}
|
||||
}
|
||||
@@ -547,9 +575,9 @@ u8 *GetSavedRamScriptIfValid(void)
|
||||
}
|
||||
}
|
||||
|
||||
void MEventSetRamScript(u8 *script, u16 scriptSize)
|
||||
void InitRamScript_NoObjectEvent(u8 *script, u16 scriptSize)
|
||||
{
|
||||
if (scriptSize > sizeof(gSaveBlock1Ptr->ramScript.data.script))
|
||||
scriptSize = sizeof(gSaveBlock1Ptr->ramScript.data.script);
|
||||
InitRamScript(script, scriptSize, 0xFF, 0xFF, 0xFF);
|
||||
InitRamScript(script, scriptSize, MAP_GROUP(UNDEFINED), MAP_NUM(UNDEFINED), 0xFF);
|
||||
}
|
||||
|
||||
+4
-4
@@ -816,7 +816,7 @@ static void Task_MultichoiceMenu_HandleInput(u8 taskId)
|
||||
}
|
||||
DestroyScriptMenuWindow(data[6]);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -885,7 +885,7 @@ static void Task_YesNoMenu_HandleInput(u8 taskId)
|
||||
break;
|
||||
}
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -936,7 +936,7 @@ static void Hask_MultichoiceGridMenu_HandleInput(u8 taskId)
|
||||
}
|
||||
DestroyScriptMenuWindow(data[6]);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
bool8 CreatePCMenu(void)
|
||||
@@ -1172,7 +1172,7 @@ void QLPlaybackCB_DestroyScriptMenuMonPicSprites(void)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
ScriptContext1_SetupScript(EventScript_ReleaseEnd);
|
||||
ScriptContext_SetupScript(EventScript_ReleaseEnd);
|
||||
taskId = FindTaskIdByFunc(Task_ScriptShowMonPic);
|
||||
if (taskId != 0xFF)
|
||||
{
|
||||
|
||||
+3
-3
@@ -1129,7 +1129,7 @@ void CreatePokemartMenu(const u16 *itemsForSale)
|
||||
{
|
||||
SetShopItemsForSale(itemsForSale);
|
||||
CreateShopMenu(MART_TYPE_REGULAR);
|
||||
SetShopMenuCallback(EnableBothScriptContexts);
|
||||
SetShopMenuCallback(ScriptContext_Enable);
|
||||
DebugFunc_PrintShopMenuHistoryBeforeClearMaybe();
|
||||
memset(&gShopMenuHistory, 0, sizeof(gShopMenuHistory));
|
||||
gShopMenuHistory[0].unk8 = gMapHeader.regionMapSectionId;
|
||||
@@ -1140,13 +1140,13 @@ void CreateDecorationShop1Menu(const u16 *itemsForSale)
|
||||
{
|
||||
SetShopItemsForSale(itemsForSale);
|
||||
CreateShopMenu(MART_TYPE_DECOR);
|
||||
SetShopMenuCallback(EnableBothScriptContexts);
|
||||
SetShopMenuCallback(ScriptContext_Enable);
|
||||
}
|
||||
|
||||
void CreateDecorationShop2Menu(const u16 *itemsForSale)
|
||||
{
|
||||
SetShopItemsForSale(itemsForSale);
|
||||
CreateShopMenu(MART_TYPE_DECOR2);
|
||||
SetShopMenuCallback(EnableBothScriptContexts);
|
||||
SetShopMenuCallback(ScriptContext_Enable);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ static void Task_SSAnneFinish(u8 taskId)
|
||||
FreeSpriteTilesByTag(SPRITE_TAG_WAKE);
|
||||
FreeSpriteTilesByTag(SPRITE_TAG_SMOKE);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -394,7 +394,7 @@ void ShowStartMenu(void)
|
||||
StopPlayerAvatar();
|
||||
}
|
||||
OpenStartMenuWithFollowupFunc(Task_StartMenuHandleInput);
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static bool8 StartCB_HandleInput(void)
|
||||
@@ -575,7 +575,7 @@ static bool8 StartCB_Save2(void)
|
||||
case SAVECB_RETURN_OKAY:
|
||||
ClearDialogWindowAndFrameToTransparent(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
RestoreHelpContext();
|
||||
return TRUE;
|
||||
case SAVECB_RETURN_CANCEL:
|
||||
@@ -587,7 +587,7 @@ static bool8 StartCB_Save2(void)
|
||||
case SAVECB_RETURN_ERROR:
|
||||
ClearDialogWindowAndFrameToTransparent(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
RestoreHelpContext();
|
||||
return TRUE;
|
||||
}
|
||||
@@ -641,7 +641,7 @@ static void task50_save_game(u8 taskId)
|
||||
break;
|
||||
}
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
RestoreHelpContext();
|
||||
}
|
||||
|
||||
@@ -995,7 +995,7 @@ static void CloseStartMenu(void)
|
||||
ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE);
|
||||
RemoveStartMenuWindow();
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
void AppendToList(u8 *list, u8 *cursor, u8 newEntry)
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
#include "global.h"
|
||||
#include "bg.h"
|
||||
#include "tilemap_util.h"
|
||||
#include "malloc.h"
|
||||
|
||||
// Handles 3 particular tilemaps ("PKMN Data" text, party menu, close box
|
||||
// button) used for Pokémon Storage System in a somewhat unusual way.
|
||||
// For example, while the cursor is on the Close Box button it flashes between
|
||||
// two states alternately. Both these states are their own part of the same
|
||||
// tilemap that's always present. The utility shifts the tilemap up and down
|
||||
// to show/hide the states, and limits the view with a rectangle that only
|
||||
// reveals one at a time.
|
||||
|
||||
struct TilemapUtil_RectData
|
||||
{
|
||||
s16 x;
|
||||
s16 y;
|
||||
u16 width;
|
||||
u16 height;
|
||||
s16 destX;
|
||||
s16 destY;
|
||||
};
|
||||
|
||||
struct TilemapUtil
|
||||
{
|
||||
struct TilemapUtil_RectData prev; // Only read in unused function
|
||||
struct TilemapUtil_RectData cur;
|
||||
const void *savedTilemap; // Only written in unused function
|
||||
const void *tilemap;
|
||||
u16 altWidth; // Never read
|
||||
u16 altHeight; // Never read
|
||||
u16 width;
|
||||
u16 height;
|
||||
u16 rowSize; // Never read
|
||||
u8 tileSize;
|
||||
u8 bg;
|
||||
bool8 active; // Only read in unused function
|
||||
};
|
||||
|
||||
static EWRAM_DATA struct TilemapUtil *sTilemapUtil = NULL;
|
||||
static EWRAM_DATA u16 sNumTilemapUtilIds = 0;
|
||||
|
||||
static void TilemapUtil_DrawPrev(u8 tilemapId);
|
||||
static void TilemapUtil_Draw(u8 tilemapId);
|
||||
|
||||
static const struct {
|
||||
u16 width;
|
||||
u16 height;
|
||||
} sTilemapDimensions[2][4] = {
|
||||
{
|
||||
{ 256, 256},
|
||||
{ 512, 256},
|
||||
{ 256, 512},
|
||||
{ 512, 512}
|
||||
}, {
|
||||
{ 128, 128},
|
||||
{ 256, 256},
|
||||
{ 512, 512},
|
||||
{1024, 1024}
|
||||
}
|
||||
};
|
||||
|
||||
void TilemapUtil_Init(u8 numTilemapIds)
|
||||
{
|
||||
u16 i;
|
||||
sTilemapUtil = Alloc(numTilemapIds * sizeof(struct TilemapUtil));
|
||||
sNumTilemapUtilIds = sTilemapUtil == NULL ? 0 : numTilemapIds;
|
||||
for (i = 0; i < sNumTilemapUtilIds; i++)
|
||||
{
|
||||
sTilemapUtil[i].savedTilemap = NULL;
|
||||
sTilemapUtil[i].active = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void TilemapUtil_Free(void)
|
||||
{
|
||||
Free(sTilemapUtil);
|
||||
}
|
||||
|
||||
// Unused
|
||||
void TilemapUtil_UpdateAll(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sNumTilemapUtilIds; i++)
|
||||
{
|
||||
if (sTilemapUtil[i].active == TRUE)
|
||||
TilemapUtil_Update(i);
|
||||
}
|
||||
}
|
||||
|
||||
void TilemapUtil_SetTilemap(u8 tilemapId, u8 bg, const void *tilemap, u16 width, u16 height)
|
||||
{
|
||||
u16 screenSize;
|
||||
u16 bgType;
|
||||
|
||||
if (tilemapId < sNumTilemapUtilIds)
|
||||
{
|
||||
sTilemapUtil[tilemapId].savedTilemap = NULL;
|
||||
sTilemapUtil[tilemapId].tilemap = tilemap;
|
||||
sTilemapUtil[tilemapId].bg = bg;
|
||||
sTilemapUtil[tilemapId].width = width;
|
||||
sTilemapUtil[tilemapId].height = height;
|
||||
|
||||
screenSize = GetBgAttribute(bg, BG_ATTR_SCREENSIZE);
|
||||
bgType = GetBgAttribute(bg, BG_ATTR_BGTYPE);
|
||||
sTilemapUtil[tilemapId].altWidth = sTilemapDimensions[bgType][screenSize].width;
|
||||
sTilemapUtil[tilemapId].altHeight = sTilemapDimensions[bgType][screenSize].height;
|
||||
if (bgType != 0)
|
||||
sTilemapUtil[tilemapId].tileSize = 1;
|
||||
else
|
||||
sTilemapUtil[tilemapId].tileSize = 2;
|
||||
sTilemapUtil[tilemapId].rowSize = width * sTilemapUtil[tilemapId].tileSize;
|
||||
sTilemapUtil[tilemapId].cur.width = width;
|
||||
sTilemapUtil[tilemapId].cur.height = height;
|
||||
sTilemapUtil[tilemapId].cur.x = 0;
|
||||
sTilemapUtil[tilemapId].cur.y = 0;
|
||||
sTilemapUtil[tilemapId].cur.destX = 0;
|
||||
sTilemapUtil[tilemapId].cur.destY = 0;
|
||||
sTilemapUtil[tilemapId].prev = sTilemapUtil[tilemapId].cur;
|
||||
sTilemapUtil[tilemapId].active = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Unused
|
||||
void TilemapUtil_SetSavedMap(u8 tilemapId, const void *tilemap)
|
||||
{
|
||||
if (tilemapId < sNumTilemapUtilIds)
|
||||
{
|
||||
sTilemapUtil[tilemapId].savedTilemap = tilemap;
|
||||
sTilemapUtil[tilemapId].active = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void TilemapUtil_SetPos(u8 tilemapId, u16 destX, u16 destY)
|
||||
{
|
||||
if (tilemapId < sNumTilemapUtilIds)
|
||||
{
|
||||
sTilemapUtil[tilemapId].cur.destX = destX;
|
||||
sTilemapUtil[tilemapId].cur.destY = destY;
|
||||
sTilemapUtil[tilemapId].active = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void TilemapUtil_SetRect(u8 tilemapId, u16 x, u16 y, u16 width, u16 height)
|
||||
{
|
||||
if (tilemapId < sNumTilemapUtilIds)
|
||||
{
|
||||
sTilemapUtil[tilemapId].cur.x = x;
|
||||
sTilemapUtil[tilemapId].cur.y = y;
|
||||
sTilemapUtil[tilemapId].cur.width = width;
|
||||
sTilemapUtil[tilemapId].cur.height = height;
|
||||
sTilemapUtil[tilemapId].active = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void TilemapUtil_Move(u8 tilemapId, u8 mode, s8 param)
|
||||
{
|
||||
if (tilemapId < sNumTilemapUtilIds)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
sTilemapUtil[tilemapId].cur.destX += param;
|
||||
sTilemapUtil[tilemapId].cur.width -= param;
|
||||
break;
|
||||
case 1:
|
||||
sTilemapUtil[tilemapId].cur.x += param;
|
||||
sTilemapUtil[tilemapId].cur.width += param;
|
||||
break;
|
||||
case 2:
|
||||
sTilemapUtil[tilemapId].cur.destY += param;
|
||||
sTilemapUtil[tilemapId].cur.height -= param;
|
||||
break;
|
||||
case 3: // this is the only mode ever used
|
||||
sTilemapUtil[tilemapId].cur.y -= param;
|
||||
sTilemapUtil[tilemapId].cur.height += param;
|
||||
break;
|
||||
case 4:
|
||||
sTilemapUtil[tilemapId].cur.destX += param;
|
||||
break;
|
||||
case 5:
|
||||
sTilemapUtil[tilemapId].cur.destY += param;
|
||||
break;
|
||||
}
|
||||
sTilemapUtil[tilemapId].active = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void TilemapUtil_Update(u8 tilemapId)
|
||||
{
|
||||
if (tilemapId < sNumTilemapUtilIds)
|
||||
{
|
||||
if (sTilemapUtil[tilemapId].savedTilemap != NULL) // Always false
|
||||
TilemapUtil_DrawPrev(tilemapId);
|
||||
TilemapUtil_Draw(tilemapId);
|
||||
sTilemapUtil[tilemapId].prev = sTilemapUtil[tilemapId].cur;
|
||||
}
|
||||
}
|
||||
|
||||
// Never called, see TilemapUtil_Update
|
||||
static void TilemapUtil_DrawPrev(u8 tilemapId)
|
||||
{
|
||||
int i;
|
||||
int rowSize = sTilemapUtil[tilemapId].tileSize * sTilemapUtil[tilemapId].altWidth;
|
||||
const void *tiles = sTilemapUtil[tilemapId].savedTilemap
|
||||
+ rowSize * sTilemapUtil[tilemapId].prev.destY
|
||||
+ sTilemapUtil[tilemapId].prev.destX * sTilemapUtil[tilemapId].tileSize;
|
||||
for (i = 0; i < sTilemapUtil[tilemapId].prev.height; i++)
|
||||
{
|
||||
CopyToBgTilemapBufferRect(sTilemapUtil[tilemapId].bg,
|
||||
tiles,
|
||||
sTilemapUtil[tilemapId].prev.destX,
|
||||
sTilemapUtil[tilemapId].prev.destY + i,
|
||||
sTilemapUtil[tilemapId].prev.width,
|
||||
1);
|
||||
tiles += rowSize;
|
||||
}
|
||||
}
|
||||
|
||||
static void TilemapUtil_Draw(u8 tilemapId)
|
||||
{
|
||||
int i;
|
||||
int rowSize = sTilemapUtil[tilemapId].tileSize * sTilemapUtil[tilemapId].width;
|
||||
const void *tiles = sTilemapUtil[tilemapId].tilemap
|
||||
+ rowSize * sTilemapUtil[tilemapId].cur.y
|
||||
+ sTilemapUtil[tilemapId].cur.x * sTilemapUtil[tilemapId].tileSize;
|
||||
for (i = 0; i < sTilemapUtil[tilemapId].cur.height; i++)
|
||||
{
|
||||
CopyToBgTilemapBufferRect(sTilemapUtil[tilemapId].bg,
|
||||
tiles,
|
||||
sTilemapUtil[tilemapId].cur.destX,
|
||||
sTilemapUtil[tilemapId].cur.destY + i,
|
||||
sTilemapUtil[tilemapId].cur.width,
|
||||
1);
|
||||
tiles += rowSize;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -953,7 +953,7 @@ static void Task_SelectTMAction_Type3(u8 taskId)
|
||||
|
||||
if (!itemid_is_unique(BagGetItemIdByPocketPosition(POCKET_TM_CASE, data[1])))
|
||||
{
|
||||
sTMCaseDynamicResources->savedCallback = Cb2_ReturnToPSS;
|
||||
sTMCaseDynamicResources->savedCallback = CB2_ReturnToPokeStorage;
|
||||
Task_BeginFadeOutFromTMCase(taskId);
|
||||
}
|
||||
else
|
||||
|
||||
+1
-1
@@ -2726,7 +2726,7 @@ static void LinkTrade_TearDownAssets(void)
|
||||
|
||||
void DoInGameTradeScene(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
CreateTask(Task_WaitFadeAndStartInGameTradeAnim, 10);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
HelpSystem_Disable();
|
||||
|
||||
+1
-1
@@ -550,7 +550,7 @@ void EndTrainerApproach(void)
|
||||
static void Task_DestroyTrainerApproachTask(u8 taskId)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
// Trainer See Excl Mark Field Effect
|
||||
|
||||
+9
-9
@@ -1019,12 +1019,12 @@ static void Task_TryBecomeLinkLeader(u8 taskId)
|
||||
data->state++;
|
||||
break;
|
||||
case 24:
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
gSpecialVar_Result = 5;
|
||||
break;
|
||||
case 22:
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
DestroyTask(taskId);
|
||||
gSpecialVar_Result = 8;
|
||||
break;
|
||||
@@ -2003,7 +2003,7 @@ static void Task_StartActivity(u8 taskId)
|
||||
|
||||
DestroyTask(taskId);
|
||||
gSpecialVar_Result = 1;
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
}
|
||||
|
||||
static void Task_RunScriptAndFadeToActivity(u8 taskId)
|
||||
@@ -2015,11 +2015,11 @@ static void Task_RunScriptAndFadeToActivity(u8 taskId)
|
||||
{
|
||||
case 0:
|
||||
gSpecialVar_Result = 1;
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (!ScriptContext1_IsScriptSetUp())
|
||||
if (!ScriptContext_IsEnabled())
|
||||
{
|
||||
FadeScreen(FADE_TO_BLACK, 0);
|
||||
data[0]++;
|
||||
@@ -2776,7 +2776,7 @@ static void Task_RunUnionRoom(u8 taskId)
|
||||
gSpecialVar_Result = 0;
|
||||
}
|
||||
}
|
||||
else if (ScriptContext2_IsEnabled() != TRUE)
|
||||
else if (ArePlayerFieldControlsLocked() != TRUE)
|
||||
{
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
@@ -3977,7 +3977,7 @@ static void JoinGroup_BlankBg0AndEnableScriptContexts(void)
|
||||
{
|
||||
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0);
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
|
||||
static void UR_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 colorIdx)
|
||||
@@ -4644,7 +4644,7 @@ static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade * trade, u8 mul
|
||||
static void HandleCancelTrade(bool32 unlockObjs)
|
||||
{
|
||||
UR_BlankBg0();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
UnionRoom_UnlockPlayerAndChatPartner();
|
||||
sPlayerCurrActivity = 0;
|
||||
if (unlockObjs)
|
||||
@@ -4656,7 +4656,7 @@ static void HandleCancelTrade(bool32 unlockObjs)
|
||||
|
||||
static void UR_EnableScriptContext2AndFreezeObjectEvents(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
LockPlayerFieldControls();
|
||||
FreezeObjects_WaitForPlayer();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -624,7 +624,7 @@ static void Task_ResetObjectsRematchWantedState(u8 taskId)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
StopPlayerAvatar();
|
||||
EnableBothScriptContexts();
|
||||
ScriptContext_Enable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,7 +837,7 @@ static void Task_VsSeeker_3(u8 taskId)
|
||||
StartAllRespondantIdleMovements();
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
ClearPlayerHeldMovementAndUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
UnlockPlayerFieldControls();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
Free(sVsSeeker);
|
||||
|
||||
@@ -593,7 +593,7 @@ bool8 UpdateRepelCounter(void)
|
||||
VarSet(VAR_REPEL_STEP_COUNT, steps);
|
||||
if (steps == 0)
|
||||
{
|
||||
ScriptContext1_SetupScript(EventScript_RepelWoreOff);
|
||||
ScriptContext_SetupScript(EventScript_RepelWoreOff);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user