menu_helpers.c & field_special_scene.c
This commit is contained in:
+6067
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
#include "global.h"
|
||||
|
||||
static u32 sub_80A0E78(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nullsub_57(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void nullsub_58(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void nullsub_59(void)
|
||||
{
|
||||
}
|
||||
|
||||
void nullsub_60(void)
|
||||
{
|
||||
}
|
||||
|
||||
void nullsub_61(void)
|
||||
{
|
||||
}
|
||||
+3
-3
@@ -275,7 +275,7 @@ static bool8 ItemPc_DoGfxSetup(void)
|
||||
switch (gMain.state)
|
||||
{
|
||||
case 0:
|
||||
VblankHblankHandlerSetZero();
|
||||
SetVBlankHBlankCallbacksToNull();
|
||||
clear_scheduled_bg_copies_to_vram();
|
||||
gMain.state++;
|
||||
break;
|
||||
@@ -415,7 +415,7 @@ static void Task_ItemPcWaitFadeAndBail(u8 taskId)
|
||||
|
||||
static bool8 ItemPc_InitBgs(void)
|
||||
{
|
||||
InitBgReg();
|
||||
ResetAllBgsCoordinatesAndBgCntRegs();
|
||||
sBg1TilemapBuffer = Alloc(0x800);
|
||||
if (sBg1TilemapBuffer == NULL)
|
||||
return FALSE;
|
||||
@@ -982,7 +982,7 @@ static void Task_ItemPcHandleWithdrawMultiple(u8 taskId)
|
||||
{
|
||||
s16 * data = gTasks[taskId].data;
|
||||
|
||||
if (sub_80BF848(&data[8], data[2]) == TRUE)
|
||||
if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE)
|
||||
sub_810E670(data[8]);
|
||||
else if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
#include "global.h"
|
||||
#include "task.h"
|
||||
#include "bg.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "window.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
#include "sound.h"
|
||||
#include "link.h"
|
||||
#include "overworld.h"
|
||||
#include "mail_data.h"
|
||||
#include "field_specials.h"
|
||||
#include "constants/songs.h"
|
||||
#include "constants/items.h"
|
||||
|
||||
static void Task_ContinueTaskAfterMessagePrints(u8 taskId);
|
||||
static EWRAM_DATA const struct YesNoFuncTable *gUnknown_20399C8 = NULL;
|
||||
static EWRAM_DATA TaskFunc gUnknown_20399CC = NULL;
|
||||
static EWRAM_DATA u8 gUnknown_20399D0 = {0};
|
||||
|
||||
void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc)
|
||||
{
|
||||
gUnknown_20399D0 = windowId;
|
||||
DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, arg2, arg3);
|
||||
|
||||
if (string != gStringVar4)
|
||||
StringExpandPlaceholders(gStringVar4, string);
|
||||
|
||||
gTextFlags.canABSpeedUpPrint = 1;
|
||||
AddTextPrinterParameterized2(windowId, fontId, gStringVar4, textSpeed, NULL, 2, 1, 3);
|
||||
gUnknown_20399CC = taskFunc;
|
||||
gTasks[taskId].func = Task_ContinueTaskAfterMessagePrints;
|
||||
}
|
||||
|
||||
bool16 RunTextPrintersRetIsActive(u8 textPrinterId)
|
||||
{
|
||||
RunTextPrinters();
|
||||
return IsTextPrinterActive(textPrinterId);
|
||||
}
|
||||
|
||||
static void Task_ContinueTaskAfterMessagePrints(u8 taskId)
|
||||
{
|
||||
if (!RunTextPrintersRetIsActive(gUnknown_20399D0))
|
||||
gUnknown_20399CC(taskId);
|
||||
}
|
||||
|
||||
static void Task_CallYesOrNoCallback(u8 taskId)
|
||||
{
|
||||
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
||||
{
|
||||
case 0:
|
||||
PlaySE(SE_SELECT);
|
||||
gTasks[taskId].func = gUnknown_20399C8->yesFunc;
|
||||
break;
|
||||
case 1:
|
||||
case MENU_B_PRESSED:
|
||||
PlaySE(SE_SELECT);
|
||||
gTasks[taskId].func = gUnknown_20399C8->noFunc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo)
|
||||
{
|
||||
CreateYesNoMenu(template, arg2, arg3, arg4, tileStart, palette, 0);
|
||||
gUnknown_20399C8 = yesNo;
|
||||
gTasks[taskId].func = Task_CallYesOrNoCallback;
|
||||
}
|
||||
|
||||
u8 GetLRKeysState(void)
|
||||
{
|
||||
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
|
||||
{
|
||||
if (gMain.newKeys & L_BUTTON)
|
||||
return 1;
|
||||
if (gMain.newKeys & R_BUTTON)
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 sub_80BF66C(void)
|
||||
{
|
||||
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
|
||||
{
|
||||
if (gMain.newAndRepeatedKeys & L_BUTTON)
|
||||
return 1;
|
||||
if (gMain.newAndRepeatedKeys & R_BUTTON)
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool8 sub_80BF6A8(u16 itemId)
|
||||
{
|
||||
if (itemId != ITEM_ENIGMA_BERRY)
|
||||
return TRUE;
|
||||
else if (!gSaveBlock1Ptr->location.mapGroup && gSaveBlock1Ptr->location.mapNum == 1)
|
||||
return FALSE;
|
||||
else if (InUnionRoom() != TRUE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 itemid_80BF6D8_mail_related(u16 itemId)
|
||||
{
|
||||
if (IsUpdateLinkStateCBActive() != TRUE && InUnionRoom() != TRUE)
|
||||
return TRUE;
|
||||
else if (ItemIsMail(itemId) != TRUE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MenuHelpers_LinkSomething(void)
|
||||
{
|
||||
if (IsUpdateLinkStateCBActive() == TRUE || gReceivedRemoteLinkPlayers == 1)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 sub_80BF72C(void)
|
||||
{
|
||||
if (!MenuHelpers_LinkSomething())
|
||||
return FALSE;
|
||||
else
|
||||
return sub_8058244();
|
||||
}
|
||||
|
||||
bool8 sub_80BF748(void)
|
||||
{
|
||||
if (sub_80BF72C() == TRUE)
|
||||
return TRUE;
|
||||
else if (sub_800B270() != TRUE)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void SetVBlankHBlankCallbacksToNull(void)
|
||||
{
|
||||
SetVBlankCallback(NULL);
|
||||
SetHBlankCallback(NULL);
|
||||
}
|
||||
|
||||
void ClearVramOamPltt(void)
|
||||
{
|
||||
ResetAllBgsCoordinatesAndBgCntRegs();
|
||||
CpuFill16(0, (void*) VRAM, VRAM_SIZE);
|
||||
CpuFill32(0, (void*) OAM, OAM_SIZE);
|
||||
CpuFill16(0, (void*) PLTT, PLTT_SIZE);
|
||||
}
|
||||
|
||||
void ResetAllBgsCoordinatesAndBgCntRegs(void)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG3CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG2CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0CNT, 0);
|
||||
ChangeBgX(0, 0, 0);
|
||||
ChangeBgY(0, 0, 0);
|
||||
ChangeBgX(1, 0, 0);
|
||||
ChangeBgY(1, 0, 0);
|
||||
ChangeBgX(2, 0, 0);
|
||||
ChangeBgY(2, 0, 0);
|
||||
ChangeBgX(3, 0, 0);
|
||||
ChangeBgY(3, 0, 0);
|
||||
}
|
||||
|
||||
bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1)
|
||||
{
|
||||
s16 valBefore = (*arg0);
|
||||
|
||||
if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP)
|
||||
{
|
||||
(*arg0)++;
|
||||
if ((*arg0) > arg1)
|
||||
(*arg0) = 1;
|
||||
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN)
|
||||
{
|
||||
(*arg0)--;
|
||||
if ((*arg0) <= 0)
|
||||
(*arg0) = arg1;
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT)
|
||||
{
|
||||
(*arg0) += 10;
|
||||
if ((*arg0) > arg1)
|
||||
(*arg0) = arg1;
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT)
|
||||
{
|
||||
(*arg0) -= 10;
|
||||
if ((*arg0) <= 0)
|
||||
(*arg0) = 1;
|
||||
if ((*arg0) == valBefore)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 sub_80BF8E4(void)
|
||||
{
|
||||
if(!ContextNpcGetTextColor())
|
||||
return 4;
|
||||
else
|
||||
return 5;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx)
|
||||
}
|
||||
|
||||
heldItem = GetMonData(&gPlayerParty[5], MON_DATA_HELD_ITEM);
|
||||
if (itemid_is_mail(heldItem))
|
||||
if (ItemIsMail(heldItem))
|
||||
GiveMailToMon2(&gPlayerParty[5], &mail);
|
||||
CompactPartySlots();
|
||||
CalculatePlayerPartyCount();
|
||||
|
||||
+2
-2
@@ -1201,7 +1201,7 @@ bool8 ScrCmd_turnvobject(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1215,7 +1215,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_lock(struct ScriptContext *ctx)
|
||||
{
|
||||
if (is_c1_link_related_active())
|
||||
if (IsUpdateLinkStateCBActive())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+4
-4
@@ -475,7 +475,7 @@ static void TeachyTvMainCallback(void)
|
||||
sResources->savedCallback = NULL;
|
||||
sResources->grassAnimDisabled = 0;
|
||||
sResources->scrollIndicatorArrowPairId = 0xFF;
|
||||
VblankHblankHandlerSetZero();
|
||||
SetVBlankHBlankCallbacksToNull();
|
||||
clear_scheduled_bg_copies_to_vram();
|
||||
ScanlineEffect_Stop();
|
||||
FreeAllSpritePalettes();
|
||||
@@ -521,7 +521,7 @@ static void TeachyTvMainCallback(void)
|
||||
|
||||
static void TeachyTvSetupBg(void)
|
||||
{
|
||||
InitBgReg();
|
||||
ResetAllBgsCoordinatesAndBgCntRegs();
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sBgTemplates, 4);
|
||||
SetBgTilemapBuffer(1, sResources->buffer1);
|
||||
@@ -817,7 +817,7 @@ static void TTVcmd_NpcMoveAndSetupTextPrinter(u8 taskId)
|
||||
static void TTVcmd_IdleIfTextPrinterIsActive(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
if (!sub_80BF518(0))
|
||||
if (!RunTextPrintersRetIsActive(0))
|
||||
++data[3];
|
||||
}
|
||||
|
||||
@@ -945,7 +945,7 @@ static const u8 sGrassAnimArray[] =
|
||||
static void TTVcmd_IdleIfTextPrinterIsActive2(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
if (!sub_80BF518(0))
|
||||
if (!RunTextPrintersRetIsActive(0))
|
||||
++data[3];
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -321,7 +321,7 @@ static bool8 DoSetUpTMCaseUI(void)
|
||||
switch (gMain.state)
|
||||
{
|
||||
case 0:
|
||||
VblankHblankHandlerSetZero();
|
||||
SetVBlankHBlankCallbacksToNull();
|
||||
clear_scheduled_bg_copies_to_vram();
|
||||
gMain.state++;
|
||||
break;
|
||||
@@ -426,7 +426,7 @@ static void ResetBufferPointers_NoFree(void)
|
||||
static void LoadBGTemplates(void)
|
||||
{
|
||||
void ** ptr;
|
||||
InitBgReg();
|
||||
ResetAllBgsCoordinatesAndBgCntRegs();
|
||||
ptr = &sTilemapBuffer;
|
||||
*ptr = AllocZeroed(0x800);
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
@@ -1058,7 +1058,7 @@ static void Task_QuantitySelect_HandleInput(u8 taskId)
|
||||
{
|
||||
s16 * data = gTasks[taskId].data;
|
||||
|
||||
if (sub_80BF848(&data[8], data[2]) == 1)
|
||||
if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == 1)
|
||||
{
|
||||
SellTM_PrintQuantityAndSalePrice(data[8], itemid_get_market_price(BagGetItemIdByPocketPosition(POCKET_TM_CASE, data[1])) / 2 * data[8]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user