Make nonmatching PSS functions functionally equivalent

This commit is contained in:
DizzyEggg 2019-05-26 11:07:30 +02:00 committed by huderlem
parent 5f292d621a
commit 818e1909ff

View File

@ -6936,10 +6936,24 @@ static u8 InBoxInput_Normal(void)
sPSSData->field_CD2 = 0; sPSSData->field_CD2 = 0;
sPSSData->field_CD3 = 0; sPSSData->field_CD3 = 0;
sPSSData->field_CD7 = 0; sPSSData->field_CD7 = 0;
retVal = 0;
if (!(gMain.newAndRepeatedKeys & DPAD_UP)) do
{ {
if (gMain.newAndRepeatedKeys & DPAD_DOWN) if (gMain.newAndRepeatedKeys & DPAD_UP)
{
retVal = TRUE;
if (sBoxCursorPosition >= IN_BOX_ROWS)
{
cursorPosition -= IN_BOX_ROWS;
}
else
{
cursorArea = CURSOR_AREA_BOX;
cursorPosition = 0;
}
break;
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{ {
retVal = TRUE; retVal = TRUE;
cursorPosition += IN_BOX_ROWS; cursorPosition += IN_BOX_ROWS;
@ -6951,6 +6965,7 @@ static u8 InBoxInput_Normal(void)
sPSSData->field_CD2 = 1; sPSSData->field_CD2 = 1;
sPSSData->field_CD7 = 1; sPSSData->field_CD7 = 1;
} }
break;
} }
else if (gMain.newAndRepeatedKeys & DPAD_LEFT) else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
{ {
@ -6964,6 +6979,7 @@ static u8 InBoxInput_Normal(void)
sPSSData->field_CD3 = -1; sPSSData->field_CD3 = -1;
cursorPosition += (IN_BOX_ROWS - 1); cursorPosition += (IN_BOX_ROWS - 1);
} }
break;
} }
else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
{ {
@ -6977,21 +6993,22 @@ static u8 InBoxInput_Normal(void)
sPSSData->field_CD3 = 1; sPSSData->field_CD3 = 1;
cursorPosition -= (IN_BOX_ROWS - 1); cursorPosition -= (IN_BOX_ROWS - 1);
} }
break;
} }
else if (gMain.newKeys & START_BUTTON) else if (gMain.newKeys & START_BUTTON)
{ {
retVal = TRUE; retVal = TRUE;
cursorArea = CURSOR_AREA_BOX; cursorArea = CURSOR_AREA_BOX;
cursorPosition = 0; cursorPosition = 0;
break;
} }
else
{
if ((gMain.newKeys & A_BUTTON) && sub_80CFA5C()) if ((gMain.newKeys & A_BUTTON) && sub_80CFA5C())
{ {
if (!sCanOnlyMove) if (!sCanOnlyMove)
return 8; return 8;
if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE) if (sPSSData->boxOption != BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE)
{ {
switch (sub_80CFF98(0)) switch (sub_80CFF98(0))
{ {
@ -7036,22 +7053,10 @@ static u8 InBoxInput_Normal(void)
sub_80CFDC4(); sub_80CFDC4();
return 0; return 0;
} }
retVal = FALSE;
} retVal = 0;
}
else } while (0);
{
retVal = TRUE;
if (sBoxCursorPosition >= IN_BOX_ROWS)
{
cursorPosition -= IN_BOX_ROWS;
}
else
{
cursorArea = CURSOR_AREA_BOX;
cursorPosition = 0;
}
}
if (retVal) if (retVal)
sub_80CD894(cursorArea, cursorPosition); sub_80CD894(cursorArea, cursorPosition);
@ -7533,20 +7538,30 @@ static u8 HandleInput_InParty(void)
gotoBox = FALSE; gotoBox = FALSE;
retVal = 0; retVal = 0;
if (!(gMain.newAndRepeatedKeys & DPAD_UP)) do
{ {
if (gMain.newAndRepeatedKeys & DPAD_DOWN) if (gMain.newAndRepeatedKeys & DPAD_UP)
{
if (--cursorPosition < 0)
cursorPosition = PARTY_SIZE;
if (cursorPosition != sBoxCursorPosition)
retVal = 1;
break;
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{ {
if (++cursorPosition > PARTY_SIZE) if (++cursorPosition > PARTY_SIZE)
cursorPosition = 0; cursorPosition = 0;
if (cursorPosition != sBoxCursorPosition) if (cursorPosition != sBoxCursorPosition)
retVal = 1; retVal = 1;
break;
} }
else if ((gMain.newAndRepeatedKeys & DPAD_LEFT) && sBoxCursorPosition != 0) else if (gMain.newAndRepeatedKeys & DPAD_LEFT && sBoxCursorPosition != 0)
{ {
retVal = 1; retVal = 1;
sPSSData->field_CD6 = sBoxCursorPosition; sPSSData->field_CD6 = sBoxCursorPosition;
cursorPosition = 0; cursorPosition = 0;
break;
} }
else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
{ {
@ -7561,9 +7576,9 @@ static u8 HandleInput_InParty(void)
cursorArea = CURSOR_AREA_IN_BOX; cursorArea = CURSOR_AREA_IN_BOX;
cursorPosition = 0; cursorPosition = 0;
} }
break;
} }
else
{
if (gMain.newKeys & A_BUTTON) if (gMain.newKeys & A_BUTTON)
{ {
if (sBoxCursorPosition == PARTY_SIZE) if (sBoxCursorPosition == PARTY_SIZE)
@ -7619,15 +7634,9 @@ static u8 HandleInput_InParty(void)
sub_80CFDC4(); sub_80CFDC4();
return 0; return 0;
} }
}
} } while (0);
else
{
if (--cursorPosition < 0)
cursorPosition = PARTY_SIZE;
if (cursorPosition != sBoxCursorPosition)
retVal = 1;
}
if (retVal != 0) if (retVal != 0)
{ {
if (retVal != 6) if (retVal != 6)
@ -7911,24 +7920,31 @@ _080CF7D8:\n\
static u8 HandleInput_OnBox(void) static u8 HandleInput_OnBox(void)
{ {
u8 retVal; u8 retVal;
s8 cursorArea = sBoxCursorArea; s8 cursorArea;
s8 cursorPosition = sBoxCursorPosition; s8 cursorPosition;
sPSSData->field_CD3 = 0; sPSSData->field_CD3 = 0;
sPSSData->field_CD2 = 0; sPSSData->field_CD2 = 0;
sPSSData->field_CD7 = 0; sPSSData->field_CD7 = 0;
retVal = 0;
if (!(gMain.newAndRepeatedKeys & DPAD_UP)) do
{ {
if (gMain.newAndRepeatedKeys & DPAD_DOWN) if (gMain.newAndRepeatedKeys & DPAD_UP)
{
retVal = 1;
cursorArea = CURSOR_AREA_BUTTONS;
cursorPosition = 0;
sPSSData->field_CD7 = 1;
break;
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{ {
retVal = 1; retVal = 1;
cursorArea = CURSOR_AREA_IN_BOX; cursorArea = CURSOR_AREA_IN_BOX;
cursorPosition = 2; cursorPosition = 2;
break;
} }
else
{
if (gMain.heldKeys & DPAD_LEFT) if (gMain.heldKeys & DPAD_LEFT)
return 10; return 10;
if (gMain.heldKeys & DPAD_RIGHT) if (gMain.heldKeys & DPAD_RIGHT)
@ -7959,15 +7975,8 @@ static u8 HandleInput_OnBox(void)
} }
retVal = 0; retVal = 0;
}
} } while (0);
else
{
retVal = 1;
cursorArea = CURSOR_AREA_BUTTONS;
cursorPosition = 0;
sPSSData->field_CD7 = 1;
}
if (retVal) if (retVal)
{ {
@ -8116,62 +8125,57 @@ static u8 HandleInput_OnButtons(void)
sPSSData->field_CD2 = 0; sPSSData->field_CD2 = 0;
sPSSData->field_CD7 = 0; sPSSData->field_CD7 = 0;
if (!(gMain.newAndRepeatedKeys & DPAD_UP)) do
{ {
if (gMain.newAndRepeatedKeys & (DPAD_DOWN | START_BUTTON)) if (gMain.newAndRepeatedKeys & DPAD_UP)
{
retVal = 1;
cursorArea = CURSOR_AREA_BOX;
cursorPosition = 0;
sPSSData->field_CD7 = 1;
}
else if (gMain.newAndRepeatedKeys & DPAD_LEFT)
{
retVal = 1;
if (--cursorPosition < 0)
{
cursorPosition = 1;
}
}
else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
{
retVal = 1;
if (++cursorPosition > 1)
{
cursorPosition = 0;
}
}
else if (gMain.newKeys & A_BUTTON)
{
return (cursorPosition == 0) ? 5 : 4;
}
else if (gMain.newKeys & B_BUTTON)
{
return 19;
}
else if (gMain.newKeys & SELECT_BUTTON)
{
sub_80CFDC4();
return 0;
}
else
{
retVal = 0;
}
}
else
{ {
retVal = 1; retVal = 1;
cursorArea = CURSOR_AREA_IN_BOX; cursorArea = CURSOR_AREA_IN_BOX;
sPSSData->field_CD2 = -1; sPSSData->field_CD2 = -1;
cursorPosition = (sBoxCursorPosition == 0) ? IN_BOX_COUNT - 1 - 5 : IN_BOX_COUNT - 1; cursorPosition = (sBoxCursorPosition == 0) ? IN_BOX_COUNT - 1 - 5 : IN_BOX_COUNT - 1;
sPSSData->field_CD7 = 1; sPSSData->field_CD7 = 1;
break;
}
else if (gMain.newAndRepeatedKeys & (DPAD_DOWN | START_BUTTON))
{
retVal = 1;
cursorArea = CURSOR_AREA_BOX;
cursorPosition = 0;
sPSSData->field_CD7 = 1;
break;
} }
if (retVal != 0) if (gMain.newAndRepeatedKeys & DPAD_LEFT)
{ {
sub_80CD894(cursorArea, cursorPosition); retVal = 1;
if (--cursorPosition < 0)
cursorPosition = 1;
break;
} }
else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
{
retVal = 1;
if (++cursorPosition > 1)
cursorPosition = 0;
break;
}
if (gMain.newKeys & A_BUTTON)
return (cursorPosition == 0) ? 5 : 4;
if (gMain.newKeys & B_BUTTON)
return 19;
if (gMain.newKeys & SELECT_BUTTON)
{
sub_80CFDC4();
return 0;
}
retVal = 0;
} while (0);
if (retVal != 0)
sub_80CD894(cursorArea, cursorPosition);
return retVal; return retVal;
} }
@ -8750,9 +8754,14 @@ static s16 sub_80D00AC(void)
{ {
s32 textId = -2; s32 textId = -2;
if (!(gMain.newKeys & A_BUTTON)) do
{ {
if (gMain.newKeys & B_BUTTON) if (gMain.newKeys & A_BUTTON)
{
textId = Menu_GetCursorPos();
break;
}
else if (gMain.newKeys & B_BUTTON)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
textId = -1; textId = -1;
@ -8768,11 +8777,7 @@ static s16 sub_80D00AC(void)
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
Menu_MoveCursor(1); Menu_MoveCursor(1);
} }
} } while (0);
else
{
textId = Menu_GetCursorPos();
}
if (textId != -2) if (textId != -2)
sub_80D013C(); sub_80D013C();
@ -8780,9 +8785,6 @@ static s16 sub_80D00AC(void)
if (textId >= 0) if (textId >= 0)
textId = sPSSData->menuItems[textId].textId; textId = sPSSData->menuItems[textId].textId;
#ifndef NONMATCHING
asm("":::"r4");
#endif // NONMATCHING
return textId; return textId;
} }