Merge pull request #1550 from GriffinRichards/doc-pokenav

Document Pokénav
This commit is contained in:
GriffinR 2021-11-17 14:47:34 -05:00 committed by GitHub
commit ecb13cdbf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 6364 additions and 6169 deletions

View File

@ -13,8 +13,8 @@
#include "dynamic_placeholder_text_util.h"
#include "fonts.h"
static u16 RenderText(struct TextPrinter *textPrinter);
static u32 RenderFont(struct TextPrinter *textPrinter);
static u16 RenderText(struct TextPrinter *);
static u32 RenderFont(struct TextPrinter *);
static u16 FontFunc_Small(struct TextPrinter *);
static u16 FontFunc_Normal(struct TextPrinter *);
static u16 FontFunc_Short(struct TextPrinter *);
@ -23,32 +23,32 @@ static u16 FontFunc_ShortCopy2(struct TextPrinter *);
static u16 FontFunc_ShortCopy3(struct TextPrinter *);
static u16 FontFunc_Narrow(struct TextPrinter *);
static u16 FontFunc_SmallNarrow(struct TextPrinter *);
static void DecompressGlyph_Small(u16 glyphId, bool32 isJapanese);
static void DecompressGlyph_Normal(u16 glyphId, bool32 isJapanese);
static void DecompressGlyph_Short(u16 glyphId, bool32 isJapanese);
static void DecompressGlyph_Narrow(u16 glyphId, bool32 isJapanese);
static void DecompressGlyph_SmallNarrow(u16 glyphId, bool32 isJapanese);
static void DecompressGlyph_Bold(u16 glyphId);
static u32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese);
static u32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese);
static u32 GetGlyphWidth_Short(u16 glyphId, bool32 isJapanese);
static u32 GetGlyphWidth_Narrow(u16 glyphId, bool32 isJapanese);
static u32 GetGlyphWidth_SmallNarrow(u16 glyphId, bool32 isJapanese);
static void DecompressGlyph_Small(u16, bool32);
static void DecompressGlyph_Normal(u16, bool32);
static void DecompressGlyph_Short(u16, bool32);
static void DecompressGlyph_Narrow(u16, bool32);
static void DecompressGlyph_SmallNarrow(u16, bool32);
static void DecompressGlyph_Bold(u16);
static u32 GetGlyphWidth_Small(u16, bool32);
static u32 GetGlyphWidth_Normal(u16, bool32);
static u32 GetGlyphWidth_Short(u16, bool32);
static u32 GetGlyphWidth_Narrow(u16, bool32);
static u32 GetGlyphWidth_SmallNarrow(u16, bool32);
EWRAM_DATA struct TextPrinter gTempTextPrinter = {0};
EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0};
static EWRAM_DATA struct TextPrinter sTempTextPrinter = {0};
static EWRAM_DATA struct TextPrinter sTextPrinters[NUM_TEXT_PRINTERS] = {0};
static u16 gFontHalfRowLookupTable[0x51];
static u16 gLastTextBgColor;
static u16 gLastTextFgColor;
static u16 gLastTextShadowColor;
static u16 sFontHalfRowLookupTable[0x51];
static u16 sLastTextBgColor;
static u16 sLastTextFgColor;
static u16 sLastTextShadowColor;
const struct FontInfo *gFonts;
bool8 gDisableTextPrinters;
struct TextGlyph gCurGlyph;
TextFlags gTextFlags;
const u8 gFontHalfRowOffsets[] =
static const u8 sFontHalfRowOffsets[] =
{
0x00, 0x01, 0x02, 0x00, 0x03, 0x04, 0x05, 0x03, 0x06, 0x07, 0x08, 0x06, 0x00, 0x01, 0x02, 0x00,
0x09, 0x0A, 0x0B, 0x09, 0x0C, 0x0D, 0x0E, 0x0C, 0x0F, 0x10, 0x11, 0x0F, 0x09, 0x0A, 0x0B, 0x09,
@ -68,12 +68,16 @@ const u8 gFontHalfRowOffsets[] =
0x00, 0x01, 0x02, 0x00, 0x03, 0x04, 0x05, 0x03, 0x06, 0x07, 0x08, 0x06, 0x00, 0x01, 0x02, 0x00
};
const u8 gDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow.4bpp");
const u8 gDarkDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow_RS.4bpp");
const u8 gUnusedFRLGBlankedDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_blanked_down_arrow.4bpp");
const u8 gUnusedFRLGDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_down_arrow.4bpp");
const u8 gDownArrowYCoords[] = { 0, 1, 2, 1 };
const u8 gWindowVerticalScrollSpeeds[] = { 1, 2, 4, 0x0 };
static const u8 sDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow.4bpp");
static const u8 sDarkDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow_alt.4bpp");
static const u8 sUnusedFRLGBlankedDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_blanked_down_arrow.4bpp");
static const u8 sUnusedFRLGDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_down_arrow.4bpp");
static const u8 sDownArrowYCoords[] = { 0, 1, 2, 1 };
static const u8 sWindowVerticalScrollSpeeds[] = {
[OPTIONS_TEXT_SPEED_SLOW] = 1,
[OPTIONS_TEXT_SPEED_MID] = 2,
[OPTIONS_TEXT_SPEED_FAST] = 4,
};
static const struct GlyphWidthFunc sGlyphWidthFuncs[] =
{
@ -88,24 +92,29 @@ static const struct GlyphWidthFunc sGlyphWidthFuncs[] =
{ FONT_SMALL_NARROW, GetGlyphWidth_SmallNarrow }
};
const struct KeypadIcon gKeypadIcons[] =
struct
{
[CHAR_A_BUTTON] = { 0x0, 0x8, 0xC },
[CHAR_B_BUTTON] = { 0x1, 0x8, 0xC },
[CHAR_L_BUTTON] = { 0x2, 0x10, 0xC },
[CHAR_R_BUTTON] = { 0x4, 0x10, 0xC },
[CHAR_START_BUTTON] = { 0x6, 0x18, 0xC },
[CHAR_SELECT_BUTTON] = { 0x9, 0x18, 0xC },
[CHAR_DPAD_UP] = { 0xC, 0x8, 0xC },
[CHAR_DPAD_DOWN] = { 0xD, 0x8, 0xC },
[CHAR_DPAD_LEFT] = { 0xE, 0x8, 0xC },
[CHAR_DPAD_RIGHT] = { 0xF, 0x8, 0xC },
[CHAR_DPAD_UPDOWN] = { 0x20, 0x8, 0xC },
[CHAR_DPAD_LEFTRIGHT] = { 0x21, 0x8, 0xC },
[CHAR_DPAD_NONE] = { 0x22, 0x8, 0xC }
u16 tileOffset;
u8 width;
u8 height;
} static const sKeypadIcons[] =
{
[CHAR_A_BUTTON] = { 0x00, 8, 12 },
[CHAR_B_BUTTON] = { 0x01, 8, 12 },
[CHAR_L_BUTTON] = { 0x02, 16, 12 },
[CHAR_R_BUTTON] = { 0x04, 16, 12 },
[CHAR_START_BUTTON] = { 0x06, 24, 12 },
[CHAR_SELECT_BUTTON] = { 0x09, 24, 12 },
[CHAR_DPAD_UP] = { 0x0C, 8, 12 },
[CHAR_DPAD_DOWN] = { 0x0D, 8, 12 },
[CHAR_DPAD_LEFT] = { 0x0E, 8, 12 },
[CHAR_DPAD_RIGHT] = { 0x0F, 8, 12 },
[CHAR_DPAD_UPDOWN] = { 0x20, 8, 12 },
[CHAR_DPAD_LEFTRIGHT] = { 0x21, 8, 12 },
[CHAR_DPAD_NONE] = { 0x22, 8, 12 }
};
const u8 gKeypadIconTiles[] = INCBIN_U8("graphics/fonts/keypad_icons.4bpp");
static const u8 sKeypadIconTiles[] = INCBIN_U8("graphics/fonts/keypad_icons.4bpp");
static const struct FontInfo sFontInfos[] =
{
@ -225,7 +234,7 @@ static const u8 sMenuCursorDimensions[][2] =
[FONT_BOLD] = {}
};
const u16 gFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/bold.hwjpnfont");
static const u16 sFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/bold.hwjpnfont");
static void SetFontsPointer(const struct FontInfo *fonts)
{
@ -236,7 +245,7 @@ void DeactivateAllTextPrinters(void)
{
int printer;
for (printer = 0; printer < NUM_TEXT_PRINTERS; ++printer)
gTextPrinters[printer].active = FALSE;
sTextPrinters[printer].active = FALSE;
}
u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16))
@ -267,41 +276,41 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
if (!gFonts)
return FALSE;
gTempTextPrinter.active = TRUE;
gTempTextPrinter.state = RENDER_STATE_HANDLE_CHAR;
gTempTextPrinter.textSpeed = speed;
gTempTextPrinter.delayCounter = 0;
gTempTextPrinter.scrollDistance = 0;
sTempTextPrinter.active = TRUE;
sTempTextPrinter.state = RENDER_STATE_HANDLE_CHAR;
sTempTextPrinter.textSpeed = speed;
sTempTextPrinter.delayCounter = 0;
sTempTextPrinter.scrollDistance = 0;
for (i = 0; i < (int)ARRAY_COUNT(gTempTextPrinter.subStructFields); i++)
gTempTextPrinter.subStructFields[i] = 0;
for (i = 0; i < (int)ARRAY_COUNT(sTempTextPrinter.subStructFields); i++)
sTempTextPrinter.subStructFields[i] = 0;
gTempTextPrinter.printerTemplate = *printerTemplate;
gTempTextPrinter.callback = callback;
gTempTextPrinter.minLetterSpacing = 0;
gTempTextPrinter.japanese = 0;
sTempTextPrinter.printerTemplate = *printerTemplate;
sTempTextPrinter.callback = callback;
sTempTextPrinter.minLetterSpacing = 0;
sTempTextPrinter.japanese = 0;
GenerateFontHalfRowLookupTable(printerTemplate->fgColor, printerTemplate->bgColor, printerTemplate->shadowColor);
if (speed != TEXT_SKIP_DRAW && speed != 0)
{
--gTempTextPrinter.textSpeed;
gTextPrinters[printerTemplate->windowId] = gTempTextPrinter;
--sTempTextPrinter.textSpeed;
sTextPrinters[printerTemplate->windowId] = sTempTextPrinter;
}
else
{
gTempTextPrinter.textSpeed = 0;
sTempTextPrinter.textSpeed = 0;
// Render all text (up to limit) at once
for (j = 0; j < 0x400; ++j)
{
if (RenderFont(&gTempTextPrinter) == RENDER_FINISH)
if (RenderFont(&sTempTextPrinter) == RENDER_FINISH)
break;
}
// All the text is rendered to the window but don't draw it yet.
if (speed != TEXT_SKIP_DRAW)
CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, COPYWIN_GFX);
gTextPrinters[printerTemplate->windowId].active = FALSE;
CopyWindowToVram(sTempTextPrinter.printerTemplate.windowId, COPYWIN_GFX);
sTextPrinters[printerTemplate->windowId].active = FALSE;
}
gDisableTextPrinters = FALSE;
return TRUE;
@ -315,19 +324,19 @@ void RunTextPrinters(void)
{
for (i = 0; i < NUM_TEXT_PRINTERS; ++i)
{
if (gTextPrinters[i].active)
if (sTextPrinters[i].active)
{
u16 temp = RenderFont(&gTextPrinters[i]);
u16 temp = RenderFont(&sTextPrinters[i]);
switch (temp)
{
case RENDER_PRINT:
CopyWindowToVram(gTextPrinters[i].printerTemplate.windowId, COPYWIN_GFX);
CopyWindowToVram(sTextPrinters[i].printerTemplate.windowId, COPYWIN_GFX);
case RENDER_UPDATE:
if (gTextPrinters[i].callback != 0)
gTextPrinters[i].callback(&gTextPrinters[i].printerTemplate, temp);
if (sTextPrinters[i].callback != 0)
sTextPrinters[i].callback(&sTextPrinters[i].printerTemplate, temp);
break;
case RENDER_FINISH:
gTextPrinters[i].active = FALSE;
sTextPrinters[i].active = FALSE;
break;
}
}
@ -337,7 +346,7 @@ void RunTextPrinters(void)
bool16 IsTextPrinterActive(u8 id)
{
return gTextPrinters[id].active;
return sTextPrinters[id].active;
}
static u32 RenderFont(struct TextPrinter *textPrinter)
@ -356,11 +365,11 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor)
u32 fg12, bg12, shadow12;
u32 temp;
u16 *current = gFontHalfRowLookupTable;
u16 *current = sFontHalfRowLookupTable;
gLastTextBgColor = bgColor;
gLastTextFgColor = fgColor;
gLastTextShadowColor = shadowColor;
sLastTextBgColor = bgColor;
sLastTextFgColor = fgColor;
sLastTextShadowColor = shadowColor;
bg12 = bgColor << 12;
fg12 = fgColor << 12;
@ -504,9 +513,9 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor)
void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor)
{
*bgColor = gLastTextBgColor;
*fgColor = gLastTextFgColor;
*shadowColor = gLastTextShadowColor;
*bgColor = sLastTextBgColor;
*fgColor = sLastTextFgColor;
*shadowColor = sLastTextShadowColor;
}
void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor)
@ -521,40 +530,41 @@ void DecompressGlyphTile(const void *src_, void *dest_)
u32 *dest = dest_;
temp = *(src++);
*(dest)++ = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest)++ = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
temp = *(src++);
*(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
temp = *(src++);
*(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
temp = *(src++);
*(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
temp = *(src++);
*(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
temp = *(src++);
*(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
temp = *(src++);
*(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
temp = *(src++);
*(dest++) = ((gFontHalfRowLookupTable[gFontHalfRowOffsets[temp & 0xFF]]) << 16) | (gFontHalfRowLookupTable[gFontHalfRowOffsets[temp >> 8]]);
*(dest++) = ((sFontHalfRowLookupTable[sFontHalfRowOffsets[temp & 0xFF]]) << 16) | (sFontHalfRowLookupTable[sFontHalfRowOffsets[temp >> 8]]);
}
u8 GetLastTextColor(u8 colorType)
// Unused
static u8 GetLastTextColor(u8 colorType)
{
switch (colorType)
{
case 0:
return gLastTextFgColor;
return sLastTextFgColor;
case 2:
return gLastTextBgColor;
return sLastTextBgColor;
case 1:
return gLastTextShadowColor;
return sLastTextShadowColor;
default:
return 0;
}
@ -644,7 +654,7 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
struct TextGlyph *glyph;
u8* glyphHeight;
if (gLastTextBgColor != 0)
if (sLastTextBgColor != TEXT_COLOR_TRANSPARENT)
{
window = &gWindows[textPrinter->printerTemplate.windowId];
pixels_data.pixels = window->tileData;
@ -660,7 +670,7 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
textPrinter->printerTemplate.currentY,
width,
*glyphHeight,
gLastTextBgColor);
sLastTextBgColor);
}
}
@ -800,10 +810,10 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
{
case FALSE:
default:
arrowTiles = gDownArrowTiles;
arrowTiles = sDownArrowTiles;
break;
case TRUE:
arrowTiles = gDarkDownArrowTiles;
arrowTiles = sDarkDownArrowTiles;
break;
}
@ -811,7 +821,7 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
textPrinter->printerTemplate.windowId,
arrowTiles,
0,
gDownArrowYCoords[subStruct->downArrowYPosIdx],
sDownArrowYCoords[subStruct->downArrowYPosIdx],
8,
16,
textPrinter->printerTemplate.currentX,
@ -905,26 +915,16 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c
{
switch (gTextFlags.useAlternateDownArrow)
{
case 0:
case FALSE:
default:
arrowTiles = gDownArrowTiles;
arrowTiles = sDownArrowTiles;
break;
case 1:
arrowTiles = gDarkDownArrowTiles;
case TRUE:
arrowTiles = sDarkDownArrowTiles;
break;
}
BlitBitmapRectToWindow(
windowId,
arrowTiles,
0,
gDownArrowYCoords[*yCoordIndex & 3],
0x8,
0x10,
x,
y - 2,
0x8,
0x10);
BlitBitmapRectToWindow(windowId, arrowTiles, 0, sDownArrowYCoords[*yCoordIndex & 3], 8, 16, x, y - 2, 8, 16);
CopyWindowToVram(windowId, COPYWIN_GFX);
*counter = 8;
++*yCoordIndex;
@ -942,7 +942,7 @@ static u16 RenderText(struct TextPrinter *textPrinter)
switch (textPrinter->state)
{
case RENDER_STATE_HANDLE_CHAR:
if ((JOY_HELD(A_BUTTON | B_BUTTON)) && subStruct->hasPrintBeenSpedUp)
if (JOY_HELD(A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp)
textPrinter->delayCounter = 0;
if (textPrinter->delayCounter && textPrinter->textSpeed)
@ -1191,7 +1191,7 @@ static u16 RenderText(struct TextPrinter *textPrinter)
if (textPrinter->scrollDistance)
{
int scrollSpeed = GetPlayerTextSpeed();
int speed = gWindowVerticalScrollSpeeds[scrollSpeed];
int speed = sWindowVerticalScrollSpeeds[scrollSpeed];
if (textPrinter->scrollDistance < speed)
{
ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
@ -1612,31 +1612,31 @@ u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y)
{
BlitBitmapRectToWindow(
windowId,
gKeypadIconTiles + (gKeypadIcons[keypadIconId].tileOffset * 0x20),
sKeypadIconTiles + (sKeypadIcons[keypadIconId].tileOffset * 0x20),
0,
0,
0x80,
0x80,
x,
y,
gKeypadIcons[keypadIconId].width,
gKeypadIcons[keypadIconId].height);
return gKeypadIcons[keypadIconId].width;
sKeypadIcons[keypadIconId].width,
sKeypadIcons[keypadIconId].height);
return sKeypadIcons[keypadIconId].width;
}
u8 GetKeypadIconTileOffset(u8 keypadIconId)
{
return gKeypadIcons[keypadIconId].tileOffset;
return sKeypadIcons[keypadIconId].tileOffset;
}
u8 GetKeypadIconWidth(u8 keypadIconId)
{
return gKeypadIcons[keypadIconId].width;
return sKeypadIcons[keypadIconId].width;
}
u8 GetKeypadIconHeight(u8 keypadIconId)
{
return gKeypadIcons[keypadIconId].height;
return sKeypadIcons[keypadIconId].height;
}
void SetDefaultFontsPointer(void)
@ -1898,7 +1898,7 @@ static void DecompressGlyph_Bold(u16 glyphId)
{
const u16* glyphs;
glyphs = gFontBoldJapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF));
glyphs = sFontBoldJapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF));
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gCurGlyph.width = 8;

View File

@ -117,13 +117,6 @@ struct GlyphWidthFunc
u32 (*func)(u16 glyphId, bool32 isJapanese);
};
struct KeypadIcon
{
u16 tileOffset;
u8 width;
u8 height;
};
typedef struct {
bool8 canABSpeedUpPrint:1;
bool8 useAlternateDownArrow:1;
@ -153,7 +146,6 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
void DecompressGlyphTile(const void *src_, void *dest_);
u8 GetLastTextColor(u8 colorType);
void CopyGlyphToWindow(struct TextPrinter *x);
void ClearTextSpan(struct TextPrinter *textPrinter, u32 width);
u8 GetMenuCursorDimensionByFont(u8, u8);

View File

Before

Width:  |  Height:  |  Size: 156 B

After

Width:  |  Height:  |  Size: 156 B

View File

Before

Width:  |  Height:  |  Size: 134 B

After

Width:  |  Height:  |  Size: 134 B

View File

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

View File

Before

Width:  |  Height:  |  Size: 197 B

After

Width:  |  Height:  |  Size: 197 B

View File

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

View File

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

View File

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 164 B

View File

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 251 B

View File

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 209 B

View File

Before

Width:  |  Height:  |  Size: 630 B

After

Width:  |  Height:  |  Size: 630 B

View File

@ -1,35 +0,0 @@
JASC-PAL
0100
32
0 197 0
246 197 123
255 255 255
106 115 123
0 0 0
189 106 65
49 65 74
255 222 156
180 131 82
189 139 106
197 197 197
255 255 255
0 0 0
0 0 0
0 0 0
255 74 16
0 197 0
246 197 123
255 255 255
106 115 123
0 0 0
189 106 65
49 65 74
255 222 156
180 131 82
189 139 106
197 197 197
197 197 197
0 0 0
0 0 0
0 0 0
189 106 65

View File

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 239 B

View File

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 194 B

View File

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

View File

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 291 B

View File

Before

Width:  |  Height:  |  Size: 160 B

After

Width:  |  Height:  |  Size: 160 B

View File

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

View File

@ -697,7 +697,7 @@ $(PKNAVGFXDIR)/header.4bpp: %.4bpp: %.png
$(PKNAVGFXDIR)/device_outline.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 53
$(PKNAVGFXDIR)/ui_matchcall.4bpp: %.4bpp: %.png
$(PKNAVGFXDIR)/match_call/ui.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 13
$(INTERFACEGFXDIR)/region_map.8bpp: %.8bpp: %.png

View File

@ -270,7 +270,9 @@
#define FRIENDSHIP_EVENT_FAINT_FIELD_PSN 7
#define FRIENDSHIP_EVENT_FAINT_LARGE 8 // If opponent was >= 30 levels higher. See AdjustFriendshipOnBattleFaint
#define MAX_FRIENDSHIP 0xFF
#define MAX_FRIENDSHIP 255
#define MAX_SHEEN 255
#define MAX_CONDITION 255
#define MAX_PER_STAT_IVS 31
#define MAX_IV_MASK 31

View File

@ -6,7 +6,6 @@
#define TRUE 1
#define FALSE 0
#define BSS_DATA __attribute__((section(".bss")))
#define IWRAM_DATA __attribute__((section("iwram_data")))
#define EWRAM_DATA __attribute__((section("ewram_data")))
#define UNUSED __attribute__((unused))

View File

@ -482,6 +482,7 @@
#define REG_SIODATA32 (*(vu32 *)REG_ADDR_SIODATA32)
#define REG_SIOMLT_SEND (*(vu16 *)REG_ADDR_SIOMLT_SEND)
#define REG_SIOMLT_RECV (*(vu64 *)REG_ADDR_SIOMLT_RECV)
#define REG_SIOMULTI(n) (*(vu16 *)(REG_ADDR_SIOMULTI0 + (n) * 2))
#define REG_SIOMULTI0 (*(vu16 *)REG_ADDR_SIOMULTI0)
#define REG_SIOMULTI1 (*(vu16 *)REG_ADDR_SIOMULTI1)
#define REG_SIOMULTI2 (*(vu16 *)REG_ADDR_SIOMULTI2)

View File

@ -7,14 +7,6 @@
#include "pokemon.h"
#include "constants/berry.h"
#define TAG_CONDITION_MON 100
#define TAG_CONDITION_BALL 101
#define TAG_CONDITION_CANCEL 102
#define TAG_CONDITION_BALL_PLACEHOLDER 103
#define TAG_CONDITION_SPARKLE 104
#define MAX_CONDITION_SPARKLES 10
// Window IDs for the Player PC Mailbox
enum {
MAILBOXWIN_TITLE,
@ -23,61 +15,115 @@ enum {
MAILBOXWIN_COUNT
};
struct UnknownSubStruct_81D1ED4
{
u16 unk0;
u16 unk2;
enum {
TAG_CONDITION_MON = 100,
TAG_CONDITION_BALL,
TAG_CONDITION_CANCEL,
TAG_CONDITION_BALL_PLACEHOLDER,
TAG_CONDITION_SPARKLE,
TAG_CONDITION_MON_MARKINGS,
TAG_CONDITION_MARKINGS_MENU,
TAG_CONDITION_MARKINGS_MENU_2, // Used implicitly by CreateMonMarkingsMenuSprites
};
enum {
CONDITION_ICON_SELECTED,
CONDITION_ICON_UNSELECTED,
};
#define MAX_CONDITION_SPARKLES 10
// The number of extra sparkles shown on a Pokémon's condition screen.
// All Pokémon start with 1, so the max here is MAX_CONDITION_SPARKLES - 1
#define GET_NUM_CONDITION_SPARKLES(sheen)((sheen) != MAX_SHEEN) ? (sheen) / ((u32)MAX_SHEEN / (MAX_CONDITION_SPARKLES - 1) + 1) : MAX_CONDITION_SPARKLES - 1;
#define CONDITION_GRAPH_TOP_Y 56
#define CONDITION_GRAPH_BOTTOM_Y 121
#define CONDITION_GRAPH_HEIGHT (CONDITION_GRAPH_BOTTOM_Y - CONDITION_GRAPH_TOP_Y + 1)
#define CONDITION_GRAPH_CENTER_X 155
#define CONDITION_GRAPH_CENTER_Y ((CONDITION_GRAPH_BOTTOM_Y + CONDITION_GRAPH_TOP_Y) / 2 + 3)
#define CONDITION_GRAPH_UPDATE_STEPS 10
#define CONDITION_GRAPH_LOAD_MAX 4
// Equivalent to flavor and contest values, but in a different order.
enum {
CONDITION_COOL,
CONDITION_TOUGH,
CONDITION_SMART,
CONDITION_CUTE,
CONDITION_BEAUTY,
CONDITION_COUNT
};
// Yet another order. This one is the same (by coincidence) as the contest categories
enum {
GRAPH_COOL,
GRAPH_BEAUTY,
GRAPH_CUTE,
GRAPH_SMART,
GRAPH_TOUGH,
};
struct ConditionGraph
{
/*0x000*/ u8 stat[4][FLAVOR_COUNT];
/*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][FLAVOR_COUNT];
/*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[10][FLAVOR_COUNT];
/*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[FLAVOR_COUNT];
/*0x140*/ u16 unk140[66][2];
/*0x248*/ u16 unk248[66][2];
/*0x350*/ u16 unk350;
/*0x352*/ u16 unk352;
/*0x354*/ u8 unk354;
/*0x355*/ u8 state;
/*0x000*/ u8 conditions[CONDITION_GRAPH_LOAD_MAX][CONDITION_COUNT];
/*0x014*/ struct UCoords16 savedPositions[CONDITION_GRAPH_LOAD_MAX][CONDITION_COUNT];
/*0x064*/ struct UCoords16 newPositions[CONDITION_GRAPH_UPDATE_STEPS][CONDITION_COUNT];
/*0x12C*/ struct UCoords16 curPositions[CONDITION_COUNT];
/*0x140*/ u16 scanlineRight[CONDITION_GRAPH_HEIGHT][2];
/*0x248*/ u16 scanlineLeft[CONDITION_GRAPH_HEIGHT][2];
/*0x350*/ u16 bottom;
/*0x352*/ u16 updateCounter;
/*0x354*/ bool8 needsDraw;
/*0x355*/ u8 scanlineResetState;
};
// Mailbox menu
bool8 MailboxMenu_Alloc(u8 count);
u8 MailboxMenu_AddWindow(u8 windowIdx);
u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page);
void MailboxMenu_AddScrollArrows(struct PlayerPCItemPageStruct *page);
void MailboxMenu_Free(void);
void MailboxMenu_RemoveWindow(u8 windowIdx);
void InitConditionGraphData(struct ConditionGraph *graph);
void sub_81D2108(struct ConditionGraph *graph);
void SetConditionGraphIOWindows(u8 bg);
void InitConditionGraphState(struct ConditionGraph *graph);
void sub_81D2230(struct ConditionGraph *graph);
bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph);
bool32 TransitionConditionGraph(struct ConditionGraph *graph);
void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1);
void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2);
void MoveRelearnerPrintText(u8 *str);
bool16 MoveRelearnerRunTextPrinters(void);
void MoveRelearnerCreateYesNoMenu(void);
u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices);
void InitMoveRelearnerWindows(bool8 useContextWindow);
s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst);
// Condition graph
void ConditionGraph_Init(struct ConditionGraph *graph);
void ConditionGraph_InitWindow(u8 bg);
void ConditionGraph_InitResetScanline(struct ConditionGraph *graph);
bool8 ConditionGraph_ResetScanline(struct ConditionGraph *graph);
void ConditionGraph_Draw(struct ConditionGraph *graph);
bool8 ConditionGraph_TryUpdate(struct ConditionGraph *graph);
void ConditionGraph_Update(struct ConditionGraph *graph);
void ConditionGraph_CalcPositions(u8 *conditions, struct UCoords16 *positions);
void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords16 *arg1, struct UCoords16 *arg2);
// Condition menu
bool8 ConditionMenu_UpdateMonEnter(struct ConditionGraph *graph, s16 *x);
bool8 ConditionMenu_UpdateMonExit(struct ConditionGraph *graph, s16 *x);
bool8 MoveConditionMonOnscreen(s16 *x);
bool8 MoveConditionMonOffscreen(s16 *x);
void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel);
void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel);
void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel);
bool8 MoveConditionMonOnscreen(s16 *x);
bool8 MoveConditionMonOffscreen(s16 *x);
bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x);
bool8 TryUpdateConditionMonTransitionOff(struct ConditionGraph *graph, s16 *x);
void LoadConditionMonPicTemplate(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal);
void LoadConditionSelectionIcons(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals);
s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst);
// Condition sparkles
void LoadConditionSparkle(struct SpriteSheet *sheet, struct SpritePalette *pal);
void ResetConditionSparkleSprites(struct Sprite **sprites);
void CreateConditionSparkleSprites(struct Sprite **sprites, u8 monSpriteId, u8 count);
void DestroyConditionSparkleSprites(struct Sprite **sprites);
void FreeConditionSparkles(struct Sprite **sprites);
// Move relearner
void MoveRelearnerPrintText(u8 *str);
bool16 MoveRelearnerRunTextPrinters(void);
void MoveRelearnerCreateYesNoMenu(void);
u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices);
void InitMoveRelearnerWindows(bool8 useContextWindow);
// Level up window
void DrawLevelUpWindowPg1(u16 windowId, u16 *statsBefore, u16 *statsAfter, u8 bgClr, u8 fgClr, u8 shadowClr);
void DrawLevelUpWindowPg2(u16 windowId, u16 *currStats, u8 bgClr, u8 fgClr, u8 shadowClr);
void GetMonLevelUpWindowStats(struct Pokemon *mon, u16 *currStats);

View File

@ -7,47 +7,51 @@
typedef u32 (*LoopedTask)(s32 state);
struct PokenavMonList
struct PokenavMonListItem
{
u8 boxId;
u8 monId;
u16 data;
};
struct PokenavMatchCallEntries
struct PokenavMatchCallEntry
{
bool8 isSpecialTrainer;
u8 mapSec;
u16 headerId;
};
struct PokenavListTemplate
struct PokenavListItem
{
union {
struct PokenavMonList *monList;
struct PokenavMatchCallEntries *matchCallEntries;
} list;
struct PokenavMonListItem mon;
struct PokenavMatchCallEntry call;
} item;
};
typedef void (*PokenavListBufferItemFunc)(struct PokenavListItem *, u8 *);
struct PokenavListTemplate
{
struct PokenavListItem * list;
u16 count;
u16 unk6;
u8 unk8;
u16 startIndex;
u8 itemSize;
u8 item_X;
u8 windowWidth;
u8 listTop;
u8 maxShowed;
u8 fillValue;
u8 fontId;
union {
void (*printMonFunc)(struct PokenavMonList *item, u8 *dest);
void (*unk10_2)(struct PokenavMatchCallEntries *, u8 *a1);
} listFunc;
void (*unk14)(u16 a0, u32 a1, u32 a2);
PokenavListBufferItemFunc bufferItemFunc;
void (*iconDrawFunc)(u16 windowId, u32 listItemId, u32 baseTile);
};
struct PokenavSub18
struct PokenavMonList
{
u16 listCount;
u16 currIndex;
struct PokenavMonList monData[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE];
struct PokenavMonListItem monData[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE];
};
// Return values of LoopedTask functions.
@ -65,27 +69,26 @@ enum
POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone
};
// TODO - refine these names
enum Substructures
enum
{
POKENAV_SUBSTRUCT_MAIN_MENU,
POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER,
POKENAV_SUBSTRUCT_MENU_ICONS,
POKENAV_SUBSTRUCT_MENU_GFX,
POKENAV_SUBSTRUCT_REGION_MAP_STATE,
POKENAV_SUBSTRUCT_REGION_MAP_ZOOM,
POKENAV_SUBSTRUCT_MATCH_CALL_MAIN,
POKENAV_SUBSTRUCT_MATCH_CALL_OPEN,
POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS,
POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST,
POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX,
POKENAV_SUBSTRUCT_RIBBONS_MON_LIST,
POKENAV_SUBSTRUCT_RIBBONS_MON_MENU,
POKENAV_SUBSTRUCT_CONDITION_GRAPH,
POKENAV_SUBSTRUCT_MON_MARK_MENU,
POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU,
POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX,
POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST,
POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU,
POKENAV_SUBSTRUCT_15, //unused
POKENAV_SUBSTRUCT_UNUSED,
POKENAV_SUBSTRUCT_REGION_MAP,
POKENAV_SUBSTRUCT_MATCH_CALL_LIST,
POKENAV_SUBSTRUCT_LIST,
POKENAV_SUBSTRUCT_MON_LIST,
POKENAV_SUBSTRUCT_COUNT,
};
@ -113,21 +116,21 @@ enum
#define POKENAV_MENU_IDS_START 100000
enum
{
POKENAV_MAIN_MENU = POKENAV_MENU_IDS_START,
POKENAV_MAIN_MENU = POKENAV_MENU_IDS_START, // The main menu where the player selects Hoenn Map/Condition/Match Call/Ribbons
POKENAV_MAIN_MENU_CURSOR_ON_MAP,
POKENAV_CONDITION_MENU,
POKENAV_CONDITION_SEARCH_MENU,
POKENAV_CONDITION_MENU, // The first Condition screen where the player selects Party or Search
POKENAV_CONDITION_SEARCH_MENU, // The Condition search menu where the player selects a search parameter
POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL,
POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS,
POKENAV_REGION_MAP,
POKENAV_CONDITION_PARTY,
POKENAV_CONDITION_SEARCH_RESULTS,
POKENAV_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list
POKENAV_RETURN_CONDITION_SEARCH, //return to search list from condition graph
POKENAV_CONDITION_GRAPH_PARTY, // The Condition graph screen when Party has been selected
POKENAV_CONDITION_SEARCH_RESULTS, // The list of results from a Condition search
POKENAV_CONDITION_GRAPH_SEARCH, // The Condition graph screen when a search result has been selected
POKENAV_RETURN_CONDITION_SEARCH, // Exited the graph screen back to the list of Condition search results
POKENAV_MATCH_CALL,
POKENAV_RIBBONS_MON_LIST,
POKENAV_RIBBONS_SUMMARY_SCREEN,
POKENAV_RIBBONS_RETURN_TO_MON_LIST,
POKENAV_RIBBONS_MON_LIST, // The list of Pokémon with ribbons
POKENAV_RIBBONS_SUMMARY_SCREEN, // The ribbon summary screen shown when a Pokémon has been selected
POKENAV_RIBBONS_RETURN_TO_MON_LIST, // Exited the summary screen back to the ribbon list
};
enum
@ -245,15 +248,22 @@ enum RegionMapFuncIds
POKENAV_MENU_FUNC_OPEN_FEATURE,
};
enum PartyConditionFuncIds
enum
{
PARTY_CONDITION_FUNC_NONE,
PARTY_CONDITION_FUNC_SLIDE_MON_IN,
PARTY_CONDITION_FUNC_RETURN,
PARTY_CONDITION_FUNC_NO_TRANSITION,
PARTY_CONDITION_FUNC_SLIDE_MON_OUT,
PARTY_CONDITION_FUNC_ADD_MARKINGS,
PARTY_CONDITION_FUNC_CLOSE_MARKINGS,
CONDITION_FUNC_NONE,
CONDITION_FUNC_SLIDE_MON_IN,
CONDITION_FUNC_RETURN,
CONDITION_FUNC_NO_TRANSITION,
CONDITION_FUNC_SLIDE_MON_OUT,
CONDITION_FUNC_ADD_MARKINGS,
CONDITION_FUNC_CLOSE_MARKINGS,
};
enum
{
CONDITION_LOAD_MON_INFO,
CONDITION_LOAD_GRAPH,
CONDITION_LOAD_MON_PIC,
};
#define POKENAV_MENU_FUNC_EXIT -1
@ -270,7 +280,7 @@ enum
POKENAV_MC_FUNC_CANCEL,
POKENAV_MC_FUNC_CALL_MSG,
POKENAV_MC_FUNC_NEARBY_MSG,
POKENAV_MC_FUNC_10,
POKENAV_MC_FUNC_EXIT_CALL,
POKENAV_MC_FUNC_SHOW_CHECK_PAGE,
POKENAV_MC_FUNC_CHECK_PAGE_UP,
POKENAV_MC_FUNC_CHECK_PAGE_DOWN,
@ -287,6 +297,14 @@ enum
POKENAV_MAP_FUNC_EXIT,
};
// Modes for PokenavFadeScreen
enum {
POKENAV_FADE_TO_BLACK,
POKENAV_FADE_FROM_BLACK,
POKENAV_FADE_TO_BLACK_ALL,
POKENAV_FADE_FROM_BLACK_ALL,
};
// pokenav.c
void SetSelectedConditionSearch(u32);
u32 GetSelectedConditionSearch(void);
@ -305,23 +323,23 @@ bool32 CanViewRibbonsMenu(void);
void SetPokenavVBlankCallback(void);
void SetVBlankCallback_(IntrCallback callback);
// pokenav_match_call_ui.c
u32 GetSelectedPokenavListIndex(void);
bool32 sub_81C8224(void);
int MatchCall_MoveCursorUp(void);
int MatchCall_MoveCursorDown(void);
int MatchCall_PageDown(void);
int MatchCall_PageUp(void);
bool32 IsMonListLoopedTaskActive(void);
void ToggleMatchCallVerticalArrows(bool32 shouldHide);
void sub_81C8838(void);
void sub_81C877C(void);
bool32 IsMatchCallListTaskActive(void);
void PrintCheckPageInfo(s16 a0);
u32 GetMatchCallListTopIndex(void);
void sub_81C87F0(void);
bool32 sub_81C81D4(const struct BgTemplate *arg0, struct PokenavListTemplate *arg1, s32 arg2);
void sub_81C8234(void);
// pokenav_list.c
bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset);
bool32 IsCreatePokenavListTaskActive(void);
void DestroyPokenavList(void);
u32 PokenavList_GetSelectedIndex(void);
int PokenavList_MoveCursorUp(void);
int PokenavList_MoveCursorDown(void);
int PokenavList_PageDown(void);
int PokenavList_PageUp(void);
bool32 PokenavList_IsMoveWindowTaskActive(void);
void PokenavList_ToggleVerticalArrows(bool32 shouldHide);
void PokenavList_DrawCurrentItemIcon(void);
void PokenavList_EraseListForCheckPage(void);
bool32 PokenavList_IsTaskActive(void);
void PrintCheckPageInfo(s16 delta);
u32 PokenavList_GetTopIndex(void);
void PokenavList_ReshowListFromCheckPage(void);
// pokenav_match_call_data.c
bool32 MatchCall_HasCheckPage(u32 idx);
@ -352,9 +370,9 @@ void SlideMenuHeaderDown(void);
bool32 MainMenuLoopedTaskIsBusy(void);
void SetLeftHeaderSpritesInvisibility(void);
void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette);
void sub_81C7B40(void);
struct Sprite *PauseSpinningPokenavSprite(void);
void ResumeSpinningPokenavSprite(void);
void FadeToBlackExceptPrimary(void);
struct Sprite *GetSpinningPokenavSprite(void);
void HideSpinningPokenavSprite(void);
void UpdateRegionMapRightHeaderTiles(u32 arg0);
void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide);
void SlideMenuHeaderUp(void);
@ -364,7 +382,7 @@ bool32 WaitForPokenavShutdownFade(void);
void SetActiveMenuLoopTasks(void *func1, void *func2);
void ShutdownPokenav(void);
// pokenav_menu_handler_1.c
// pokenav_menu_handler.c
bool32 PokenavCallback_Init_MainMenuCursorOnMap(void);
bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void);
bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void);
@ -377,7 +395,7 @@ int GetPokenavCursorPos(void);
int GetCurrentMenuItemId(void);
u16 GetHelpBarTextId(void);
// pokenav_menu_handler_2.c
// pokenav_menu_handler_gfx.c
bool32 OpenPokenavMenuInitial(void);
bool32 OpenPokenavMenuNotInitial(void);
void CreateMenuHandlerLoopedTask(s32 ltIdx);
@ -385,29 +403,28 @@ bool32 IsMenuHandlerLoopedTaskActive(void);
void FreeMenuHandlerSubstruct2(void);
void ResetBldCnt_(void);
// pokenav_match_call_1.c
// pokenav_match_call_list.c
bool32 PokenavCallback_Init_MatchCall(void);
u32 GetMatchCallCallback(void);
void FreeMatchCallSubstruct1(void);
int sub_81CAE28(void);
int IsMatchCallListInitFinished(void);
int GetNumberRegistered(void);
int sub_81CAE48(void);
struct PokenavMatchCallEntries *sub_81CAE94(void);
struct PokenavMatchCallEntry *GetMatchCallList(void);
u16 GetMatchCallMapSec(int);
bool32 ShouldDrawRematchPokeballIcon(int index);
void ClearRematchPokeballIcon(u16 windowId, u32 a1);
int GetMatchCallTrainerPic(int index);
const u8 *GetMatchCallFlavorText(int index, int textType);
const u8 *GetMatchCallMessageText(int index, u8 *arg1);
const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest);
u16 GetMatchCallOptionCursorPos(void);
u16 GetMatchCallOptionId(int arg0);
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries * arg0, u8 *str);
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry * arg0, u8 *str);
u8 GetMatchTableMapSectionId(int rematchIndex);
int GetIndexDeltaOfNextCheckPageDown(int index);
int GetIndexDeltaOfNextCheckPageUp(int index);
bool32 IsRematchEntryRegistered(int index);
// pokenav_match_call_2.c
// pokenav_match_call_gfx.c
bool32 OpenMatchCall(void);
void CreateMatchCallLoopedTask(s32 index);
bool32 IsMatchCallLoopedTaskActive(void);
@ -422,33 +439,33 @@ bool32 IsRegionMapLoopedTaskActive(void);
void FreeRegionMapSubstruct1(void);
void FreeRegionMapSubstruct2(void);
// pokenav_conditions_1.c
u32 PokenavCallback_Init_PartyCondition(void);
u32 PokenavCallback_Init_ConditionGraphFromSearch(void);
u32 GetPartyConditionCallback(void);
void FreePartyConditionSubstruct1(void);
bool32 LoadPartyConditionMenuGfx(void);
// pokenav_conditions.c
u32 PokenavCallback_Init_ConditionGraph_Party(void);
u32 PokenavCallback_Init_ConditionGraph_Search(void);
u32 GetConditionGraphMenuCallback(void);
void FreeConditionGraphMenuSubstruct1(void);
bool32 LoadConditionGraphMenuGfx(void);
bool32 IsConditionMenuSearchMode(void);
struct ConditionGraph *GetConditionGraphDataPtr(void);
u16 GetConditionGraphCurrentMonIndex(void);
struct ConditionGraph *GetConditionGraphPtr(void);
u16 GetConditionGraphCurrentListIndex(void);
u16 GetMonListCount(void);
u8 GetMonSheen(void);
bool32 SetConditionGraphData(u8 arg0);
u8 GetNumConditionMonSparkles(void);
bool32 LoadNextConditionMenuMonData(u8 mode);
u8 TryGetMonMarkId(void);
u8 *GetConditionMonNameBuffer(u8 id);
u8 *GetConditionMonLocationBuffer(u8 id);
u8 *GetConditionMonNameText(u8 id);
u8 *GetConditionMonLocationText(u8 id);
u16 GetConditionMonDataBuffer(void);
void *GetConditionMonPicGfx(u8 id);
void *GetConditionMonPal(u8 id);
// pokenav_conditions_2.c
bool32 OpenPartyConditionMenu(void);
void CreatePartyConditionLoopedTask(s32);
u32 IsPartyConditionLoopedTaskActive(void);
void FreePartyConditionSubstruct2(void);
// pokenav_conditions_gfx.c
bool32 OpenConditionGraphMenu(void);
void CreateConditionGraphMenuLoopedTask(s32);
u32 IsConditionGraphMenuLoopedTaskActive(void);
void FreeConditionGraphMenuSubstruct2(void);
u8 GetMonMarkingsData(void);
// pokenav_conditions_3.c
// pokenav_conditions_search_results.c
u32 PokenavCallback_Init_ConditionSearch(void);
u32 PokenavCallback_Init_ReturnToMonSearchList(void);
u32 GetConditionSearchResultsCallback(void);
@ -459,18 +476,18 @@ void CreateSearchResultsLoopedTask(s32);
u32 IsSearchResultLoopedTaskActive(void);
void FreeSearchResultSubstruct2(void);
// pokenav_ribbons_1.c
// pokenav_ribbons_list.c
u32 PokenavCallback_Init_MonRibbonList(void);
u32 PokenavCallback_Init_RibbonsMonListFromSummary(void);
u32 GetRibbonsMonListCallback(void);
void FreeRibbonsMonList1(void);
void FreeRibbonsMonList(void);
bool32 OpenRibbonsMonList(void);
bool32 OpenRibbonsMonListFromRibbonsSummary(void);
void CreateRibbonsMonListLoopedTask(s32);
u32 IsRibbonsMonListLoopedTaskActive(void);
void FreeRibbonsMonList2(void);
void FreeRibbonsMonMenu(void);
// pokenav_ribbons_2.c
// pokenav_ribbons_summary.c
u32 PokenavCallback_Init_RibbonsSummaryMenu(void);
u32 GetRibbonsSummaryMenuCallback(void);
void FreeRibbonsSummaryScreen1(void);

View File

@ -2978,8 +2978,8 @@ extern const u8 gText_FindToughPokemon[];
extern const u8 gText_ReturnToConditionMenu[];
extern const u8 gText_NoRibbonWinners[];
// Pokenav Ribbons
extern const u8 gText_NumberF700[];
// Pokenav
extern const u8 gText_NumberIndex[];
extern const u8 gText_RibbonsF700[];
// use_pokeblock

View File

@ -312,17 +312,17 @@ SECTIONS {
src/battle_pyramid_bag.o(.text);
src/pokenav.o(.text);
src/pokenav_main_menu.o(.text);
src/pokenav_match_call_ui.o(.text);
src/pokenav_menu_handler_1.o(.text);
src/pokenav_menu_handler_2.o(.text);
src/pokenav_match_call_1.o(.text);
src/pokenav_match_call_2.o(.text);
src/pokenav_list.o(.text);
src/pokenav_menu_handler.o(.text);
src/pokenav_menu_handler_gfx.o(.text);
src/pokenav_match_call_list.o(.text);
src/pokenav_match_call_gfx.o(.text);
src/pokenav_region_map.o(.text);
src/pokenav_conditions_1.o(.text);
src/pokenav_conditions_2.o(.text);
src/pokenav_conditions_3.o(.text);
src/pokenav_ribbons_1.o(.text);
src/pokenav_ribbons_2.o(.text);
src/pokenav_conditions.o(.text);
src/pokenav_conditions_gfx.o(.text);
src/pokenav_conditions_search_results.o(.text);
src/pokenav_ribbons_list.o(.text);
src/pokenav_ribbons_summary.o(.text);
src/pokenav_match_call_data.o(.text);
src/menu_specialized.o(.text);
src/ereader_helpers.o(.text);
@ -669,16 +669,16 @@ SECTIONS {
src/battle_pyramid_bag.o(.rodata);
src/pokenav.o(.rodata);
src/pokenav_main_menu.o(.rodata);
src/pokenav_match_call_ui.o(.rodata);
src/pokenav_menu_handler_1.o(.rodata);
src/pokenav_menu_handler_2.o(.rodata);
src/pokenav_match_call_1.o(.rodata);
src/pokenav_match_call_2.o(.rodata);
src/pokenav_list.o(.rodata);
src/pokenav_menu_handler.o(.rodata);
src/pokenav_menu_handler_gfx.o(.rodata);
src/pokenav_match_call_list.o(.rodata);
src/pokenav_match_call_gfx.o(.rodata);
src/pokenav_region_map.o(.rodata);
src/pokenav_conditions_2.o(.rodata);
src/pokenav_conditions_3.o(.rodata);
src/pokenav_ribbons_1.o(.rodata);
src/pokenav_ribbons_2.o(.rodata);
src/pokenav_conditions_gfx.o(.rodata);
src/pokenav_conditions_search_results.o(.rodata);
src/pokenav_ribbons_list.o(.rodata);
src/pokenav_ribbons_summary.o(.rodata);
src/pokenav_match_call_data.o(.rodata);
src/menu_specialized.o(.rodata);
src/ereader_helpers.o(.rodata);

View File

@ -2404,12 +2404,12 @@ void AnimTask_SketchDrawMon(u8 taskId)
if (GetBattlerSpriteBGPriorityRank(gBattleAnimTarget) == 1)
{
task->data[6] = gBattle_BG1_X;
params.dmaDest = (u16 *)REG_ADDR_BG1HOFS;
params.dmaDest = &REG_BG1HOFS;
}
else
{
task->data[6] = gBattle_BG2_X;
params.dmaDest = (u16 *)REG_ADDR_BG2HOFS;
params.dmaDest = &REG_BG2HOFS;
}
for (i = task->data[0] - 0x40; i <= task->data[0]; i++)

View File

@ -653,9 +653,9 @@ static void AnimTask_SpiteTargetShadow_Step1(u8 taskId)
startLine = 0;
if (position == 1)
task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 4, 1);
task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG1HOFS, 1);
else
task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 8, 1);
task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG2HOFS, 1);
task->data[15]++;
break;

View File

@ -960,7 +960,7 @@ static void AnimTask_SurfWaveScanlineEffect(u8 taskId)
else
gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2];
params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA;
params.dmaDest = &REG_BLDALPHA;
params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT;
params.initState = 1;
params.unused9 = 0;

View File

@ -870,7 +870,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
static const struct ScanlineEffectParams sTourneyTreeScanlineEffectParams =
{
.dmaDest = (void *)REG_ADDR_BG3CNT,
.dmaDest = &REG_BG3CNT,
.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT,
.initState = 1,
};

View File

@ -249,13 +249,13 @@ u8 gBattleControllerData[MAX_BATTLERS_COUNT]; // Used by the battle controllers
static const struct ScanlineEffectParams sIntroScanlineParams16Bit =
{
(void *)REG_ADDR_BG3HOFS, SCANLINE_EFFECT_DMACNT_16BIT, 1
&REG_BG3HOFS, SCANLINE_EFFECT_DMACNT_16BIT, 1
};
// unused
static const struct ScanlineEffectParams sIntroScanlineParams32Bit =
{
(void *)REG_ADDR_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1
&REG_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1
};
const struct SpriteTemplate gUnusedBattleInitSprite =

View File

@ -8,7 +8,11 @@
// For printing braille messages, see ScrCmd_braillemessage
ALIGNED(4)
static const u8 sScrollDistances[] = {1, 2, 4};
static const u8 sScrollDistances[] = {
[OPTIONS_TEXT_SPEED_SLOW] = 1,
[OPTIONS_TEXT_SPEED_MID] = 2,
[OPTIONS_TEXT_SPEED_FAST] = 4,
};
static const u16 sFont_Braille[] = INCBIN_U16("graphics/fonts/braille.fwjpnfont");
static void DecompressGlyph_Braille(u16);

View File

@ -56,7 +56,7 @@ const s32 gMaxFlashLevel = ARRAY_COUNT(sFlashLevelPixelRadii) - 1;
const struct ScanlineEffectParams sFlashEffectParams =
{
(void *)REG_ADDR_WIN0H,
&REG_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
1
};

View File

@ -1848,7 +1848,7 @@ static void Task_Scene3_StartGroudon(u8 taskId)
{
gTasks[taskId].tState = 0;
gTasks[taskId].func = Task_Scene3_Groudon;
ScanlineEffect_InitWave(0, 160, 4, 4, 1, 4, 0);
ScanlineEffect_InitWave(0, 160, 4, 4, 1, SCANLINE_EFFECT_REG_BG1HOFS, 0);
}
#define tScreenX data[1]
@ -2058,7 +2058,7 @@ static void Task_Scene3_LoadKyogre(u8 taskId)
gTasks[taskId].tDelay = 16;
gTasks[taskId].tZoom = 256;
PanFadeAndZoomScreen(gTasks[taskId].tScreenX, gTasks[taskId].tScreenY, gTasks[taskId].tZoom, 0);
ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, 6, 0);
ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, SCANLINE_EFFECT_REG_BG1VOFS, 0);
}
static void Task_Scene3_Kyogre(u8 taskId)

View File

@ -31,7 +31,7 @@ void AGBPrintFlush1Block(void);
void AGBPrintInit(void)
{
volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR;
u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT;
u16 *pWSCNT = &REG_WAITCNT;
u16 *pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR;
u16 nOldWSCNT = *pWSCNT;
*pWSCNT = WSCNT_DATA;
@ -57,7 +57,7 @@ static void AGBPutcInternal(const char cChr)
void AGBPutc(const char cChr)
{
u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT;
u16 *pWSCNT = &REG_WAITCNT;
u16 nOldWSCNT = *pWSCNT;
volatile struct AGBPrintStruct *pPrint;
*pWSCNT = WSCNT_DATA;
@ -71,7 +71,7 @@ void AGBPutc(const char cChr)
void AGBPrint(const char *pBuf)
{
volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR;
u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT;
u16 *pWSCNT = &REG_WAITCNT;
u16 nOldWSCNT = *pWSCNT;
*pWSCNT = WSCNT_DATA;
while (*pBuf)
@ -105,9 +105,9 @@ static void AGBPrintTransferDataInternal(u32 bAllData)
pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR;
pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR;
lpfnFuncFlush = (LPFN_PRINT_FLUSH)AGB_PRINT_FLUSH_ADDR;
pIME = (u16 *)REG_ADDR_IME;
pIME = &REG_IME;
nIME = *pIME;
pWSCNT = (u16 *)REG_ADDR_WAITCNT;
pWSCNT = &REG_WAITCNT;
nOldWSCNT = *pWSCNT;
*pIME = nIME & ~1;
*pWSCNT = WSCNT_DATA;

View File

@ -336,8 +336,8 @@ static u16 handshake_wait(u16 slot)
static void STWI_set_timer_in_RAM(u8 count)
{
vu16* regTMCNTL = (vu16*)(REG_ADDR_TMCNT_L + gSTWIStatus->timerSelect * 4);
vu16* regTMCNTH = (vu16*)(REG_ADDR_TMCNT_H + gSTWIStatus->timerSelect * 4);
vu16* regTMCNTL = &REG_TMCNT_L(gSTWIStatus->timerSelect);
vu16* regTMCNTH = &REG_TMCNT_H(gSTWIStatus->timerSelect);
REG_IME = 0;
switch (count)
{

View File

@ -1187,10 +1187,10 @@ static void StartMatchCall(void)
CreateTask(ExecuteMatchCall, 1);
}
static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call_window.gbapal");
static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call_window.4bpp");
static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/icon.gbapal");
static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/icon.4bpp.lz");
static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call/window.gbapal");
static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call/window.4bpp");
static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/match_call/nav_icon.gbapal");
static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/nav_icon.4bpp.lz");
static const u8 sText_PokenavCallEllipsis[] = _("………………\p");
@ -1499,7 +1499,7 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str)
{
u32 matchCallId;
const struct MatchCallText *matchCallText;
bool32 retVal = FALSE;
bool32 newRematchRequest = FALSE;
matchCallId = GetTrainerMatchCallId(trainerId);
sBattleFrontierStreakInfo.facilityId = 0;
@ -1517,7 +1517,7 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str)
else if (ShouldTrainerRequestBattle(matchCallId))
{
matchCallText = GetDifferentRouteMatchCallText(matchCallId, str);
retVal = TRUE;
newRematchRequest = TRUE;
UpdateRematchIfDefeated(matchCallId);
}
else if (Random() % 3)
@ -1532,7 +1532,7 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str)
}
BuildMatchCallString(matchCallId, matchCallText, str);
return retVal;
return newRematchRequest;
}
static int GetTrainerMatchCallId(int trainerId)

View File

@ -31,14 +31,14 @@ extern const struct CompressedSpriteSheet gMonFrontPicTable[];
EWRAM_DATA static u8 sMailboxWindowIds[MAILBOXWIN_COUNT] = {0};
EWRAM_DATA static struct ListMenuItem *sMailboxList = NULL;
static void MailboxMenu_MoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list);
static void sub_81D24A4(struct ConditionGraph *a0);
static void sub_81D2634(struct ConditionGraph *a0);
static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list);
static void nullsub_79(void);
static void SetNextConditionSparkle(struct Sprite *sprite);
static void SpriteCB_ConditionSparkle(struct Sprite *sprite);
static void ShowAllConditionSparkles(struct Sprite *sprite);
static void MailboxMenu_MoveCursorFunc(s32, bool8, struct ListMenu *);
static void ConditionGraph_CalcRightHalf(struct ConditionGraph *);
static void ConditionGraph_CalcLeftHalf(struct ConditionGraph *);
static void MoveRelearnerCursorCallback(s32, bool8, struct ListMenu *);
static void MoveRelearnerDummy(void);
static void SetNextConditionSparkle(struct Sprite *);
static void SpriteCB_ConditionSparkle(struct Sprite *);
static void ShowAllConditionSparkles(struct Sprite *);
static const struct WindowTemplate sWindowTemplates_MailboxMenu[MAILBOXWIN_COUNT] =
{
@ -80,46 +80,29 @@ static const u8 sEmptyItemName[] = _("");
static const struct ScanlineEffectParams sConditionGraphScanline =
{
.dmaDest = (void*)REG_ADDR_WIN0H,
.dmaDest = &REG_WIN0H,
.dmaControl = SCANLINE_EFFECT_DMACNT_32BIT,
.initState = 1,
};
static const u8 sUnknown_08625410[] =
static const u8 sConditionToLineLength[MAX_CONDITION + 1] =
{
4,
5,
6,
7,
8,
9, 9,
10, 10,
0xB, 0xB,
0xC, 0xC,
0xD, 0xD,
0xD, 0xD,
0xE, 0xE, 0xE, 0xE,
0xF, 0xF, 0xF, 0xF,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16,
0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19,
0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B,
0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C,
0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D,
0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x23
4, 5, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13,
13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21,
21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34,
34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35
};
@ -207,6 +190,10 @@ static const struct ListMenuTemplate sMoveRelearnerMovesListTemplate =
.cursorKind = 0
};
//--------------
// Mailbox menu
//--------------
bool8 MailboxMenu_Alloc(u8 count)
{
u8 i;
@ -320,67 +307,83 @@ void MailboxMenu_Free(void)
Free(sMailboxList);
}
void InitConditionGraphData(struct ConditionGraph *graph)
//---------------------------------------
// Condition graph
//
// This is the graph in the Pokénav and
// Pokéblock case that shows a Pokémon's
// conditions (Beauty, Tough, etc.).
// It works by using scanlines to
// selectively reveal a bg that has been
// filled with the graph color.
//---------------------------------------
#define SHIFT_RIGHT_ADJUSTED(n, s)(((n) >> (s)) + (((n) >> ((s) - 1)) & 1))
void ConditionGraph_Init(struct ConditionGraph *graph)
{
u8 i, j;
for (j = 0; j < FLAVOR_COUNT; j++)
for (j = 0; j < CONDITION_COUNT; j++)
{
for (i = 0; i < 10; i++)
for (i = 0; i < CONDITION_GRAPH_UPDATE_STEPS; i++)
{
graph->unk64[i][j].unk0 = 0;
graph->unk64[i][j].unk2 = 0;
}
for (i = 0; i < 4; i++)
{
graph->stat[i][j] = 0;
graph->unk14[i][j].unk0 = 155;
graph->unk14[i][j].unk2 = 91;
graph->newPositions[i][j].x = 0;
graph->newPositions[i][j].y = 0;
}
graph->unk12C[j].unk0 = 0;
graph->unk12C[j].unk2 = 0;
for (i = 0; i < CONDITION_GRAPH_LOAD_MAX; i++)
{
graph->conditions[i][j] = 0;
graph->savedPositions[i][j].x = CONDITION_GRAPH_CENTER_X;
graph->savedPositions[i][j].y = CONDITION_GRAPH_CENTER_Y;
}
graph->unk354 = 0;
graph->unk352 = 0;
graph->curPositions[j].x = 0;
graph->curPositions[j].y = 0;
}
graph->needsDraw = FALSE;
graph->updateCounter = 0;
}
void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2)
// Fills the newPositions array with incremental positions between
// old and new for the graph transition when switching between Pokémon.
void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords16 *old, struct UCoords16 *new)
{
u16 i, j;
s32 r5, r6;
s32 coord, increment;
for (i = 0; i < FLAVOR_COUNT; i++)
for (i = 0; i < CONDITION_COUNT; i++)
{
r5 = arg1[i].unk0 << 8;
r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / 10;
for (j = 0; j < 9; j++)
coord = old[i].x << 8;
increment = ((new[i].x - old[i].x) << 8) / CONDITION_GRAPH_UPDATE_STEPS;
for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++)
{
graph->unk64[j][i].unk0 = (r5 >> 8) + ((r5 >> 7) & 1);
r5 += r6;
graph->newPositions[j][i].x = SHIFT_RIGHT_ADJUSTED(coord, 8);
coord += increment;
}
graph->unk64[j][i].unk0 = arg2[i].unk0;
graph->newPositions[j][i].x = new[i].x;
r5 = arg1[i].unk2 << 8;
r6 = ((arg2[i].unk2 - arg1[i].unk2) << 8) / 10;
for (j = 0; j < 9; j++)
coord = old[i].y << 8;
increment = ((new[i].y - old[i].y) << 8) / CONDITION_GRAPH_UPDATE_STEPS;
for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++)
{
graph->unk64[j][i].unk2 = (r5 >> 8) + ((r5 >> 7) & 1);
r5 += r6;
graph->newPositions[j][i].y = SHIFT_RIGHT_ADJUSTED(coord, 8);
coord += increment;
}
graph->unk64[j][i].unk2 = arg2[i].unk2;
graph->newPositions[j][i].y = new[i].y;
}
graph->unk352 = 0;
graph->updateCounter = 0;
}
bool32 TransitionConditionGraph(struct ConditionGraph *graph)
bool8 ConditionGraph_TryUpdate(struct ConditionGraph *graph)
{
if (graph->unk352 < 10)
if (graph->updateCounter < CONDITION_GRAPH_UPDATE_STEPS)
{
sub_81D2230(graph);
return (++graph->unk352 != 10);
ConditionGraph_Update(graph);
return (++graph->updateCounter != CONDITION_GRAPH_UPDATE_STEPS);
}
else
{
@ -388,294 +391,316 @@ bool32 TransitionConditionGraph(struct ConditionGraph *graph)
}
}
void InitConditionGraphState(struct ConditionGraph *graph)
void ConditionGraph_InitResetScanline(struct ConditionGraph *graph)
{
graph->state = 0;
graph->scanlineResetState = 0;
}
bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph)
bool8 ConditionGraph_ResetScanline(struct ConditionGraph *graph)
{
struct ScanlineEffectParams params;
switch (graph->state)
switch (graph->scanlineResetState)
{
case 0:
ScanlineEffect_Clear();
graph->state++;
graph->scanlineResetState++;
return TRUE;
case 1:
params = sConditionGraphScanline;
ScanlineEffect_SetParams(params);
graph->state++;
graph->scanlineResetState++;
return FALSE;
default:
return FALSE;
}
}
void sub_81D2108(struct ConditionGraph *graph)
void ConditionGraph_Draw(struct ConditionGraph *graph)
{
u16 i;
if (graph->unk354 == 0)
if (!graph->needsDraw)
return;
sub_81D24A4(graph);
sub_81D2634(graph);
ConditionGraph_CalcRightHalf(graph);
ConditionGraph_CalcLeftHalf(graph);
for (i = 0; i < 66; i++)
for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++)
{
gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (graph->unk140[i][0] << 8) | (graph->unk140[i][1]);
gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (graph->unk248[i][0] << 8) | (graph->unk248[i][1]);
// Draw right half
gScanlineEffectRegBuffers[1][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 0] = // double assignment
gScanlineEffectRegBuffers[0][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 0] = (graph->scanlineRight[i][0] << 8) | (graph->scanlineRight[i][1]);
// Draw left half
gScanlineEffectRegBuffers[1][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 1] = // double assignment
gScanlineEffectRegBuffers[0][(i + CONDITION_GRAPH_TOP_Y - 1) * 2 + 1] = (graph->scanlineLeft[i][0] << 8) | (graph->scanlineLeft[i][1]);
}
graph->unk354 = 0;
graph->needsDraw = FALSE;
}
void SetConditionGraphIOWindows(u8 bg)
void ConditionGraph_InitWindow(u8 bg)
{
u32 flags;
if (bg > 3)
if (bg >= NUM_BACKGROUNDS)
bg = 0;
// Unset the WINOUT flag for the bg.
flags = (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ) & ~(1 << bg);
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE( 0, DISPLAY_WIDTH));
SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE( 0, 155));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(56, 121));
SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(56, 121));
// Set limits for graph data
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE( 0, DISPLAY_WIDTH)); // Right side horizontal
SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE( 0, CONDITION_GRAPH_CENTER_X)); // Left side horizontal
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(CONDITION_GRAPH_TOP_Y, CONDITION_GRAPH_BOTTOM_Y)); // Right side vertical
SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(CONDITION_GRAPH_TOP_Y, CONDITION_GRAPH_BOTTOM_Y)); // Left side vertical
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
SetGpuReg(REG_OFFSET_WINOUT, flags);
}
void sub_81D2230(struct ConditionGraph *graph)
void ConditionGraph_Update(struct ConditionGraph *graph)
{
u16 i;
for (i = 0; i < FLAVOR_COUNT; i++)
graph->unk12C[i] = graph->unk64[graph->unk352][i];
for (i = 0; i < CONDITION_COUNT; i++)
graph->curPositions[i] = graph->newPositions[graph->updateCounter][i];
graph->unk354 = 1;
graph->needsDraw = TRUE;
}
static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownSubStruct_81D1ED4 *arg2, struct UnknownSubStruct_81D1ED4 *arg3, u8 arg4, u16 *arg5)
static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline, struct UCoords16 *pos1, struct UCoords16 *pos2, bool8 dir, u16 *overflowScanline)
{
u16 i, r8, r10, r0, var_30;
u16 i, height, top, bottom, x2;
u16 *ptr;
s32 r4, var_2C;
s32 x, xIncrement = 0;
var_2C = 0;
if (arg2->unk2 < arg3->unk2)
if (pos1->y < pos2->y)
{
r10 = arg2->unk2;
r0 = arg3->unk2;
r4 = arg2->unk0 << 10;
var_30 = arg3->unk0;
r8 = r0 - r10;
if (r8 != 0)
var_2C = ((var_30 - arg2->unk0) << 10) / r8;
top = pos1->y;
bottom = pos2->y;
x = pos1->x << 10;
x2 = pos2->x;
height = bottom - top;
if (height != 0)
xIncrement = ((x2 - pos1->x) << 10) / height;
}
else
{
r0 = arg2->unk2;
r10 = arg3->unk2;
r4 = arg3->unk0 << 10;
var_30 = arg2->unk0;
r8 = r0 - r10;
if (r8 != 0)
var_2C = ((var_30 - arg3->unk0) << 10) / r8;
bottom = pos1->y;
top = pos2->y;
x = pos2->x << 10;
x2 = pos1->x;
height = bottom - top;
if (height != 0)
xIncrement = ((x2 - pos2->x) << 10) / height;
}
r8++;
if (arg5 == NULL)
height++;
if (overflowScanline == NULL)
{
arg1 += (r10 - 56) * 2;
for (i = 0; i < r8; i++)
scanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
for (i = 0; i < height; i++)
{
arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
r4 += var_2C;
arg1 += 2;
scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
x += xIncrement;
scanline += 2;
}
ptr = arg1 - 2;
ptr = scanline - 2;
}
else if (var_2C > 0)
else if (xIncrement > 0)
{
arg5 += (r10 - 56) * 2;
overflowScanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
// Less readable than the other loops, but it has to be written this way to match.
for (i = 0; i < r8; arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4, r4 += var_2C, arg5 += 2, i++)
for (i = 0; i < height; overflowScanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir, x += xIncrement, overflowScanline += 2, i++)
{
if (r4 >= (155 << 10))
if (x >= (CONDITION_GRAPH_CENTER_X << 10))
break;
}
graph->unk350 = r10 + i;
arg1 += (graph->unk350 - 56) * 2;
for (; i < r8; i++)
graph->bottom = top + i;
scanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2;
for (; i < height; i++)
{
arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
r4 += var_2C;
arg1 += 2;
scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
x += xIncrement;
scanline += 2;
}
ptr = arg1 - 2;
ptr = scanline - 2;
}
else if (var_2C < 0)
else if (xIncrement < 0)
{
arg1 += (r10 - 56) * 2;
for (i = 0; i < r8; i++)
scanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
for (i = 0; i < height; i++)
{
arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
if (r4 < (155 << 10))
scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
if (x < (CONDITION_GRAPH_CENTER_X << 10))
{
arg1[arg4] = 155;
scanline[dir] = CONDITION_GRAPH_CENTER_X;
break;
}
r4 += var_2C;
arg1 += 2;
x += xIncrement;
scanline += 2;
}
graph->unk350 = r10 + i;
arg5 += (graph->unk350 - 56) * 2;
for (; i < r8; i++)
graph->bottom = top + i;
overflowScanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2;
for (; i < height; i++)
{
arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
r4 += var_2C;
arg5 += 2;
overflowScanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
x += xIncrement;
overflowScanline += 2;
}
ptr = arg5 - 2;
ptr = overflowScanline - 2;
}
else
{
graph->unk350 = r10;
arg1 += (r10 - 56) * 2;
arg5 += (r10 - 56) * 2;
arg1[1] = arg2->unk0 + 1;
arg5[0] = arg3->unk0;
arg5[1] = 155;
graph->bottom = top;
scanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
overflowScanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
scanline[1] = pos1->x + 1;
overflowScanline[0] = pos2->x;
overflowScanline[1] = CONDITION_GRAPH_CENTER_X;
return;
}
ptr[arg4] = arg4 + var_30;
ptr[dir] = dir + x2;
}
static void sub_81D24A4(struct ConditionGraph *graph)
static void ConditionGraph_CalcRightHalf(struct ConditionGraph *graph)
{
u16 i, r6, varMax;
u16 i, y, bottom;
if (graph->unk12C[0].unk2 < graph->unk12C[1].unk2)
// Calculate Cool -> Beauty line
if (graph->curPositions[GRAPH_COOL].y < graph->curPositions[GRAPH_BEAUTY].y)
{
r6 = graph->unk12C[0].unk2;
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[0], &graph->unk12C[1], 1, NULL);
y = graph->curPositions[GRAPH_COOL].y;
ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_COOL], &graph->curPositions[GRAPH_BEAUTY], TRUE, NULL);
}
else
{
r6 = graph->unk12C[1].unk2;
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[0], 0, NULL);
y = graph->curPositions[GRAPH_BEAUTY].y;
ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_BEAUTY], &graph->curPositions[GRAPH_COOL], FALSE, NULL);
}
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[2], 1, NULL);
// Calculate Beauty -> Cute line
// No need for conditional, positions on the Beauty line are always above the Cute line
ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_BEAUTY], &graph->curPositions[GRAPH_CUTE], TRUE, NULL);
i = (graph->unk12C[2].unk2 <= graph->unk12C[3].unk2);
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[2], &graph->unk12C[3], i, graph->unk248[0]);
for (i = 56; i < r6; i++)
// Calculate Cute -> Tough line (includes left scanline because this crosses the halfway point)
i = (graph->curPositions[GRAPH_CUTE].y <= graph->curPositions[GRAPH_SMART].y);
ConditionGraph_CalcLine(graph, graph->scanlineRight[0], &graph->curPositions[GRAPH_CUTE], &graph->curPositions[GRAPH_SMART], i, graph->scanlineLeft[0]);
// Clear down to new top
for (i = CONDITION_GRAPH_TOP_Y; i < y; i++)
{
graph->unk140[i - 56][0] = 0;
graph->unk140[i - 56][1] = 0;
graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0;
graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0;
}
for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++)
graph->unk140[i - 56][0] = 155;
for (i = graph->curPositions[GRAPH_COOL].y; i <= graph->bottom; i++)
graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X;
varMax = max(graph->unk350, graph->unk12C[2].unk2);
for (i = varMax + 1; i < 122; i++)
// Clear after new bottom
bottom = max(graph->bottom, graph->curPositions[GRAPH_CUTE].y);
for (i = bottom + 1; i <= CONDITION_GRAPH_BOTTOM_Y; i++)
{
graph->unk140[i - 56][0] = 0;
graph->unk140[i - 56][1] = 0;
graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0;
graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0;
}
for (i = 56; i < 122; i++)
for (i = CONDITION_GRAPH_TOP_Y; i <= CONDITION_GRAPH_BOTTOM_Y; i++)
{
if (graph->unk140[i - 56][0] == 0 && graph->unk140[i - 56][1] != 0)
graph->unk140[i - 56][0] = 155;
if (graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] == 0
&& graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] != 0)
graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X;
}
}
static void sub_81D2634(struct ConditionGraph *graph)
static void ConditionGraph_CalcLeftHalf(struct ConditionGraph *graph)
{
s32 i, r6, varMax;
s32 i, y, bottom;
if (graph->unk12C[0].unk2 < graph->unk12C[4].unk2)
// Calculate Cool -> Tough line
if (graph->curPositions[GRAPH_COOL].y < graph->curPositions[GRAPH_TOUGH].y)
{
r6 = graph->unk12C[0].unk2;
sub_81D2278(graph, graph->unk248[0], &graph->unk12C[0], &graph->unk12C[4], 0, NULL);
y = graph->curPositions[GRAPH_COOL].y;
ConditionGraph_CalcLine(graph, graph->scanlineLeft[0], &graph->curPositions[GRAPH_COOL], &graph->curPositions[GRAPH_TOUGH], FALSE, NULL);
}
else
{
r6 = graph->unk12C[4].unk2;
sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[0], 1, NULL);
y = graph->curPositions[GRAPH_TOUGH].y;
ConditionGraph_CalcLine(graph, graph->scanlineLeft[0], &graph->curPositions[GRAPH_TOUGH], &graph->curPositions[GRAPH_COOL], TRUE, NULL);
}
sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[3], 0, NULL);
// Calculate Tough -> Smart line
// No need for conditional, positions on the Tough line are always above the Smart line
ConditionGraph_CalcLine(graph, graph->scanlineLeft[0], &graph->curPositions[GRAPH_TOUGH], &graph->curPositions[GRAPH_SMART], FALSE, NULL);
for (i = 56; i < r6; i++)
// Clear down to new top
for (i = CONDITION_GRAPH_TOP_Y; i < y; i++)
{
graph->unk140[i + 10][0] = 0;
graph->unk140[i + 10][1] = 0;
graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][0] = 0;
graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][1] = 0;
}
for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++)
graph->unk140[i + 10][1] = 155;
for (i = graph->curPositions[GRAPH_COOL].y; i <= graph->bottom; i++)
graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][1] = CONDITION_GRAPH_CENTER_X;
varMax = max(graph->unk350, graph->unk12C[3].unk2 + 1);
for (i = varMax; i < 122; i++)
// Clear after new bottom
bottom = max(graph->bottom, graph->curPositions[GRAPH_SMART].y + 1);
for (i = bottom; i <= CONDITION_GRAPH_BOTTOM_Y; i++)
{
graph->unk140[i + 10][0] = 0;
graph->unk140[i + 10][1] = 0;
graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][0] = 0;
graph->scanlineLeft[i - CONDITION_GRAPH_TOP_Y][1] = 0;
}
for (i = 0; i < 66; i++)
for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++)
{
if (graph->unk248[i][0] >= graph->unk248[i][1])
if (graph->scanlineLeft[i][0] >= graph->scanlineLeft[i][1])
{
graph->unk248[i][1] = 0;
graph->unk248[i][0] = 0;
graph->scanlineLeft[i][1] = 0;
graph->scanlineLeft[i][0] = 0;
}
}
}
void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1)
void ConditionGraph_CalcPositions(u8 *conditions, struct UCoords16 *positions)
{
u8 r2, r7;
s8 r12;
u8 lineLength, sinIdx;
s8 posIdx;
u16 i;
r2 = sUnknown_08625410[*(arg0++)];
arg1->unk0 = 155;
arg1->unk2 = 91 - r2;
// Cool is straight up-and-down (not angled), so no need for Sin
lineLength = sConditionToLineLength[*(conditions++)];
positions[GRAPH_COOL].x = CONDITION_GRAPH_CENTER_X;
positions[GRAPH_COOL].y = CONDITION_GRAPH_CENTER_Y - lineLength;
r7 = 64;
r12 = 0;
for (i = 1; i < 5; i++)
sinIdx = 64;
posIdx = GRAPH_COOL;
for (i = 1; i < CONDITION_COUNT; i++)
{
r7 += 51;
if (--r12 < 0)
r12 = 4;
sinIdx += 51;
if (--posIdx < 0)
posIdx = CONDITION_COUNT - 1;
if (r12 == 2)
r7++;
if (posIdx == GRAPH_CUTE)
sinIdx++;
r2 = sUnknown_08625410[*(arg0++)];
arg1[r12].unk0 = 155 + ((r2 * gSineTable[64 + r7]) >> 8);
arg1[r12].unk2 = 91 - ((r2 * gSineTable[r7]) >> 8);
lineLength = sConditionToLineLength[*(conditions++)];
positions[posIdx].x = CONDITION_GRAPH_CENTER_X + ((lineLength * gSineTable[64 + sinIdx]) >> 8);
positions[posIdx].y = CONDITION_GRAPH_CENTER_Y - ((lineLength * gSineTable[sinIdx]) >> 8);
if (r12 < 3 && (r2 != 32 || r12 != 2))
arg1[r12].unk0 = 156 + ((r2 * gSineTable[64 + r7]) >> 8);
if (posIdx <= GRAPH_CUTE && (lineLength != 32 || posIdx != GRAPH_CUTE))
positions[posIdx].x++;
}
}
//----------------
// Move relearner
//----------------
void InitMoveRelearnerWindows(bool8 useContextWindow)
{
u8 i;
@ -685,10 +710,8 @@ void InitMoveRelearnerWindows(bool8 useContextWindow)
LoadUserWindowBorderGfx(0, 1, 0xE0);
LoadPalette(gStandardMenuPalette, 0xF0, 0x20);
for (i = 0; i < 5; i++)
{
for (i = 0; i < ARRAY_COUNT(sMoveRelearnerWindowTemplates) - 1; i++)
FillWindowPixelBuffer(i, PIXEL_FILL(1));
}
if (!useContextWindow)
{
@ -704,11 +727,11 @@ void InitMoveRelearnerWindows(bool8 useContextWindow)
PutWindowTilemap(3);
DrawStdFrameWithCustomTileAndPalette(2, 0, 1, 0xE);
DrawStdFrameWithCustomTileAndPalette(3, 0, 1, 0xE);
nullsub_79();
MoveRelearnerDummy();
ScheduleBgCopyTilemapToVram(1);
}
static void nullsub_79(void)
static void MoveRelearnerDummy(void)
{
}
@ -720,13 +743,10 @@ u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices)
gMultiuseListMenuTemplate.items = items;
if (numChoices < 6)
{
gMultiuseListMenuTemplate.maxShowed = numChoices;
}
else
{
gMultiuseListMenuTemplate.maxShowed = 6;
}
return gMultiuseListMenuTemplate.maxShowed;
}
@ -734,7 +754,7 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
{
s32 x;
const struct BattleMove *move;
u8 buffer[0x20];
u8 buffer[32];
const u8 *str;
FillWindowPixelBuffer(0, PIXEL_FILL(1));
@ -856,6 +876,10 @@ void MoveRelearnerCreateYesNoMenu(void)
CreateYesNoMenu(&sMoveRelearnerYesNoMenuTemplate, 1, 0xE, 0);
}
//----------------
// Condition menu
//----------------
s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst)
{
s32 ret;
@ -1010,7 +1034,7 @@ void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId
}
}
void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel)
void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *numSparkles, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel)
{
u16 i;
@ -1019,25 +1043,23 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16
if (partyId != numMons)
{
graph->stat[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
graph->stat[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
graph->stat[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
graph->stat[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
graph->stat[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
graph->conditions[id][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
graph->conditions[id][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
graph->conditions[id][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
graph->conditions[id][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
graph->conditions[id][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF)
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u
: 9;
numSparkles[id] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL));
sub_81D2754(graph->stat[id], graph->unk14[id]);
ConditionGraph_CalcPositions(graph->conditions[id], graph->savedPositions[id]);
}
else
{
for (i = 0; i < FLAVOR_COUNT; i++)
for (i = 0; i < CONDITION_COUNT; i++)
{
graph->stat[id][i] = 0;
graph->unk14[id][i].unk0 = 155;
graph->unk14[id][i].unk2 = 91;
graph->conditions[id][i] = 0;
graph->savedPositions[id][i].x = CONDITION_GRAPH_CENTER_X;
graph->savedPositions[id][i].y = CONDITION_GRAPH_CENTER_Y;
}
}
}
@ -1076,17 +1098,17 @@ bool8 MoveConditionMonOffscreen(s16 *x)
return (*x != -80);
}
bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x)
bool8 ConditionMenu_UpdateMonEnter(struct ConditionGraph *graph, s16 *x)
{
bool8 graphUpdating = TransitionConditionGraph(graph);
bool8 graphUpdating = ConditionGraph_TryUpdate(graph);
bool8 monUpdating = MoveConditionMonOnscreen(x);
return (graphUpdating || monUpdating);
}
bool8 TryUpdateConditionMonTransitionOff(struct ConditionGraph *graph, s16 *x)
bool8 ConditionMenu_UpdateMonExit(struct ConditionGraph *graph, s16 *x)
{
bool8 graphUpdating = TransitionConditionGraph(graph);
bool8 graphUpdating = ConditionGraph_TryUpdate(graph);
bool8 monUpdating = MoveConditionMonOffscreen(x);
return (graphUpdating || monUpdating);
@ -1145,8 +1167,8 @@ static const union AnimCmd sAnim_ConditionSelectionIcon_Unselected[] =
static const union AnimCmd *const sAnims_ConditionSelectionIcon[] =
{
sAnim_ConditionSelectionIcon_Selected,
sAnim_ConditionSelectionIcon_Unselected
[CONDITION_ICON_SELECTED] = sAnim_ConditionSelectionIcon_Selected,
[CONDITION_ICON_UNSELECTED] = sAnim_ConditionSelectionIcon_Unselected
};
// Just loads the generic data, up to the caller to load the actual sheet/pal for the specific mon

View File

@ -90,7 +90,7 @@ output_burst:
k = 0x0e;
for (i = MULTIBOOT_NCHILD; i != 0; i--)
{
if (*(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2) != 0xffff)
if (REG_SIOMULTI(i) != 0xffff)
{
break;
}
@ -102,7 +102,7 @@ output_burst:
for (i = MULTIBOOT_NCHILD; i != 0; i--)
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
if (mp->client_bit & (1 << i))
{
if (j != ((MULTIBOOT_CLIENT_INFO << 8) | (1 << i)))
@ -141,7 +141,7 @@ output_burst:
mp->probe_target_bit = 0;
for (i = MULTIBOOT_NCHILD; i != 0; i--)
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
if ((j >> 8) == MULTIBOOT_CLIENT_INFO)
{
MultiBoot_required_data[i - 1] = j;
@ -166,7 +166,7 @@ output_burst:
{
if (mp->probe_target_bit & (1 << i))
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
if (j != MultiBoot_required_data[i - 1])
{
mp->probe_target_bit ^= 1 << i;
@ -179,7 +179,7 @@ output_burst:
k = 1;
for (i = MULTIBOOT_NCHILD; i != 0; i--)
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
mp->client_data[i - 1] = j;
if (mp->probe_target_bit & (1 << i))
{
@ -214,7 +214,7 @@ output_burst:
case 0xd1:
for (i = MULTIBOOT_NCHILD; i != 0; i--)
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
if (mp->probe_target_bit & (1 << i))
{
if ((j >> 8) != MULTIBOOT_CLIENT_DLREADY)
@ -242,7 +242,7 @@ output_burst:
{
if (mp->probe_target_bit & (1 << i))
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
if ((j >> 8) != (MULTIBOOT_MASTER_START_PROBE + 1 - (mp->probe_count >> 1))
|| ((j & 0xff) != (1 << i)))
{
@ -391,7 +391,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp)
default:
for (i = MULTIBOOT_NCHILD; i != 0; i--)
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
if ((mp->client_bit & (1 << i))
&& j != must_data)
{
@ -413,7 +413,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp)
case 0xe8:
for (i = MULTIBOOT_NCHILD; i != 0; i--)
{
j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2);
j = REG_SIOMULTI(i);
if ((mp->client_bit & (1 << i)) && j != must_data)
{
MultiBootInit(mp);

View File

@ -313,7 +313,7 @@ static const struct BgTemplate sOverworldBgTemplates[] =
static const struct ScanlineEffectParams sFlashEffectParams =
{
(void *)REG_ADDR_WIN0H,
&REG_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
1,
0,

View File

@ -49,7 +49,6 @@ static void Task_RunLoopedTask(u8 taskId);
static void Task_Pokenav(u8 taskId);
static void CB2_InitPokenavForTutorial(void);
// TODO: Use MENU ids
const struct PokenavCallbacks PokenavMenuCallbacks[15] =
{
[POKENAV_MAIN_MENU - POKENAV_MENU_IDS_START] =
@ -122,15 +121,15 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.free1 = FreeRegionMapSubstruct1,
.free2 = FreeRegionMapSubstruct2,
},
[POKENAV_CONDITION_PARTY - POKENAV_MENU_IDS_START] =
[POKENAV_CONDITION_GRAPH_PARTY - POKENAV_MENU_IDS_START] =
{
.init = PokenavCallback_Init_PartyCondition,
.callback = GetPartyConditionCallback,
.open = OpenPartyConditionMenu,
.createLoopTask = CreatePartyConditionLoopedTask,
.isLoopTaskActive = IsPartyConditionLoopedTaskActive,
.free1 = FreePartyConditionSubstruct1,
.free2 = FreePartyConditionSubstruct2,
.init = PokenavCallback_Init_ConditionGraph_Party,
.callback = GetConditionGraphMenuCallback,
.open = OpenConditionGraphMenu,
.createLoopTask = CreateConditionGraphMenuLoopedTask,
.isLoopTaskActive = IsConditionGraphMenuLoopedTaskActive,
.free1 = FreeConditionGraphMenuSubstruct1,
.free2 = FreeConditionGraphMenuSubstruct2,
},
[POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] =
{
@ -142,15 +141,15 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.free1 = FreeSearchResultSubstruct1,
.free2 = FreeSearchResultSubstruct2,
},
[POKENAV_CONDITION_GRAPH_FROM_SEARCH - POKENAV_MENU_IDS_START] =
[POKENAV_CONDITION_GRAPH_SEARCH - POKENAV_MENU_IDS_START] =
{
.init = PokenavCallback_Init_ConditionGraphFromSearch,
.callback = GetPartyConditionCallback,
.open = OpenPartyConditionMenu,
.createLoopTask = CreatePartyConditionLoopedTask,
.isLoopTaskActive = IsPartyConditionLoopedTaskActive,
.free1 = FreePartyConditionSubstruct1,
.free2 = FreePartyConditionSubstruct2,
.init = PokenavCallback_Init_ConditionGraph_Search,
.callback = GetConditionGraphMenuCallback,
.open = OpenConditionGraphMenu,
.createLoopTask = CreateConditionGraphMenuLoopedTask,
.isLoopTaskActive = IsConditionGraphMenuLoopedTaskActive,
.free1 = FreeConditionGraphMenuSubstruct1,
.free2 = FreeConditionGraphMenuSubstruct2,
},
[POKENAV_RETURN_CONDITION_SEARCH - POKENAV_MENU_IDS_START] =
{
@ -179,8 +178,8 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.open = OpenRibbonsMonList,
.createLoopTask = CreateRibbonsMonListLoopedTask,
.isLoopTaskActive = IsRibbonsMonListLoopedTaskActive,
.free1 = FreeRibbonsMonList1,
.free2 = FreeRibbonsMonList2,
.free1 = FreeRibbonsMonList,
.free2 = FreeRibbonsMonMenu,
},
[POKENAV_RIBBONS_SUMMARY_SCREEN - POKENAV_MENU_IDS_START] =
{
@ -199,8 +198,8 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.open = OpenRibbonsMonListFromRibbonsSummary,
.createLoopTask = CreateRibbonsMonListLoopedTask,
.isLoopTaskActive = IsRibbonsMonListLoopedTaskActive,
.free1 = FreeRibbonsMonList1,
.free2 = FreeRibbonsMonList2,
.free1 = FreeRibbonsMonList,
.free2 = FreeRibbonsMonMenu,
},
};

630
src/pokenav_conditions.c Normal file
View File

@ -0,0 +1,630 @@
#include "global.h"
#include "data.h"
#include "decompress.h"
#include "main.h"
#include "menu_specialized.h"
#include "mon_markings.h"
#include "pokenav.h"
#include "pokemon.h"
#include "pokemon_storage_system.h"
#include "sound.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
#include "constants/songs.h"
#define CONDITION_MONS_LOADED 3
struct Pokenav_ConditionMenu
{
u32 monPal[CONDITION_MONS_LOADED][0x20];
u8 fill[0x180];
u32 monPicGfx[CONDITION_MONS_LOADED][MON_PIC_SIZE];
bool8 inSearchMode;
s16 toLoadListIndex;
u32 (*callback)(struct Pokenav_ConditionMenu *);
u8 fill2[0x18];
u8 locationText[CONDITION_MONS_LOADED][24];
u8 nameText[CONDITION_MONS_LOADED][64];
struct ConditionGraph graph;
u8 numSparkles[CONDITION_MONS_LOADED];
u8 monMarks[CONDITION_MONS_LOADED];
s8 loadId;
s8 nextLoadIdDown;
s8 nextLoadIdUp;
s8 toLoadId;
u8 state;
};
static void InitPartyConditionListParameters(void);
static void InitSearchResultsConditionList(void);
static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *);
static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *);
static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *);
static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *);
static u8 SwitchConditionSummaryIndex(bool8);
static void CopyMonNameGenderLocation(s16, u8);
static void GetMonConditionGraphData(s16, u8);
static void ConditionGraphDrawMonPic(s16, u8);
bool32 PokenavCallback_Init_ConditionGraph_Party(void)
{
struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu));
if (menu == NULL)
return FALSE;
ConditionGraph_Init(&menu->graph);
InitPartyConditionListParameters();
gKeyRepeatStartDelay = 20;
menu->callback = HandleConditionMenuInput;
return TRUE;
}
bool32 PokenavCallback_Init_ConditionGraph_Search(void)
{
struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu));
if (menu == NULL)
return FALSE;
ConditionGraph_Init(&menu->graph);
InitSearchResultsConditionList();
gKeyRepeatStartDelay = 20;
menu->callback = HandleConditionMenuInput;
return TRUE;
}
u32 GetConditionGraphMenuCallback(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->callback(menu);
}
static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *menu)
{
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u32 ret = ConditionGraphHandleDpadInput(menu);
if (ret == CONDITION_FUNC_NONE)
{
if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
menu->callback = GetConditionReturnCallback;
ret = CONDITION_FUNC_RETURN;
}
else if (JOY_NEW(A_BUTTON))
{
if (!menu->inSearchMode)
{
// In Party mode, pressing A only applies to the Cancel button
if (monListPtr->currIndex == monListPtr->listCount - 1)
{
// Cancel
PlaySE(SE_SELECT);
menu->callback = GetConditionReturnCallback;
ret = CONDITION_FUNC_RETURN;
}
}
else
{
// In Search mode pressing A brings up the markings menu
PlaySE(SE_SELECT);
ret = CONDITION_FUNC_ADD_MARKINGS;
menu->callback = OpenMarkingsMenu;
}
}
}
return ret;
}
static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *menu)
{
struct PokenavMonList *monListPtr;
u8 markings;
u32 ret = CONDITION_FUNC_NONE, boxId, monId;
if (!HandleMonMarkingsMenuInput())
{
menu->monMarks[menu->loadId] = GetMonMarkingsData();
monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[monListPtr->currIndex].boxId;
monId = monListPtr->monData[monListPtr->currIndex].monId;
markings = menu->monMarks[menu->loadId];
if (boxId == TOTAL_BOXES_COUNT)
SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings);
else
SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings);
menu->callback = HandleConditionMenuInput;
ret = CONDITION_FUNC_CLOSE_MARKINGS;
}
return ret;
}
static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *menu)
{
if (!menu->inSearchMode)
return POKENAV_CONDITION_MENU;
else
return POKENAV_RETURN_CONDITION_SEARCH;
}
void FreeConditionGraphMenuSubstruct1(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (!menu->inSearchMode)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
}
static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *menu)
{
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u8 ret = CONDITION_FUNC_NONE;
if (JOY_HELD(DPAD_UP))
{
// Prevent input wrapping in search mode
if (!menu->inSearchMode || monListPtr->currIndex != 0)
{
PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(TRUE);
}
}
else if (JOY_HELD(DPAD_DOWN))
{
// Prevent input wrapping in search mode
if (!menu->inSearchMode || monListPtr->currIndex < monListPtr->listCount - 1)
{
PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(FALSE);
}
}
return ret;
}
static u8 SwitchConditionSummaryIndex(u8 moveUp)
{
u16 newLoadId;
bool8 wasNotLastMon, isNotLastMon;
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
newLoadId = (moveUp) ? menu->nextLoadIdUp : menu->nextLoadIdDown;
ConditionGraph_SetNewPositions(&menu->graph, menu->graph.savedPositions[menu->loadId], menu->graph.savedPositions[newLoadId]);
wasNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1));
if (moveUp)
{
menu->nextLoadIdUp = menu->nextLoadIdDown;
menu->nextLoadIdDown = menu->loadId;
menu->loadId = newLoadId;
menu->toLoadId = menu->nextLoadIdUp;
monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1;
menu->toLoadListIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1;
}
else
{
menu->nextLoadIdDown = menu->nextLoadIdUp;
menu->nextLoadIdUp = menu->loadId;
menu->loadId = newLoadId;
menu->toLoadId = menu->nextLoadIdDown;
monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
menu->toLoadListIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
}
isNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1));
if (!wasNotLastMon)
return CONDITION_FUNC_NO_TRANSITION;
else if (!isNotLastMon)
return CONDITION_FUNC_SLIDE_MON_OUT;
else
return CONDITION_FUNC_SLIDE_MON_IN;
}
bool32 LoadConditionGraphMenuGfx(void)
{
s32 var;
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
switch (menu->state)
{
case 0:
CopyMonNameGenderLocation(monListPtr->currIndex, 0);
break;
case 1:
GetMonConditionGraphData(monListPtr->currIndex, 0);
break;
case 2:
ConditionGraphDrawMonPic(monListPtr->currIndex, 0);
break;
case 3:
if (monListPtr->listCount == 1)
{
menu->loadId = 0;
menu->nextLoadIdDown = 0;
menu->nextLoadIdUp = 0;
menu->state = 0;
return TRUE;
}
else
{
menu->loadId = 0;
menu->nextLoadIdDown = 1;
menu->nextLoadIdUp = 2;
}
break;
// These were probably ternaries just like cases 7-9, but couldn't match it any other way.
case 4:
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
var = 0;
CopyMonNameGenderLocation(var, 1);
break;
case 5:
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
var = 0;
GetMonConditionGraphData(var, 1);
break;
case 6:
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
var = 0;
ConditionGraphDrawMonPic(var, 1);
break;
case 7:
CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
break;
case 8:
GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
break;
case 9:
ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
menu->state = 0;
return TRUE;
}
menu->state++;
return FALSE;
}
bool32 LoadNextConditionMenuMonData(u8 mode)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
switch (mode)
{
case CONDITION_LOAD_MON_INFO:
CopyMonNameGenderLocation(menu->toLoadListIndex, menu->toLoadId);
break;
case CONDITION_LOAD_GRAPH:
GetMonConditionGraphData(menu->toLoadListIndex, menu->toLoadId);
break;
case CONDITION_LOAD_MON_PIC:
ConditionGraphDrawMonPic(menu->toLoadListIndex, menu->toLoadId);
return TRUE;
}
return FALSE;
}
u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n)
{
while (*src != EOS)
*dst++ = *src++, n--;
while (n-- > 0)
*dst++ = CHAR_SPACE;
*dst = EOS;
return dst;
}
static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3)
{
u16 boxId, monId, gender, species, level, lvlDigits;
struct BoxPokemon *boxMon;
u8 *txtPtr, *str_;
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[listId].monId;
*(str++) = EXT_CTRL_CODE_BEGIN;
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str++) = TEXT_COLOR_BLUE;
*(str++) = TEXT_COLOR_TRANSPARENT;
*(str++) = TEXT_COLOR_LIGHT_BLUE;
if (GetBoxOrPartyMonData(boxId, monId, MON_DATA_IS_EGG, NULL))
return StringCopyPadded(str, gText_EggNickname, CHAR_SPACE, 12);
GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, str);
StringGetEnd10(str);
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL);
if (boxId == TOTAL_BOXES_COUNT)
{
level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
gender = GetMonGender(&gPlayerParty[monId]);
}
else
{
boxMon = GetBoxedMonPtr(boxId, monId);
gender = GetBoxMonGender(boxMon);
level = GetLevelFromBoxMonExp(boxMon);
}
if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(str, gSpeciesNames[species]))
gender = MON_GENDERLESS;
str_ = str; // For some reason, a variable is needed to match.
while (*str_ != EOS)
(str_++);
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_SKIP;
*(str_++) = 60;
switch (gender)
{
default:
*(str_++) = CHAR_SPACER; // Genderless
break;
case MON_MALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
*(str_++) = TEXT_COLOR_RED;
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_RED;
*(str_++) = CHAR_MALE;
break;
case MON_FEMALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
*(str_++) = TEXT_COLOR_GREEN;
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_GREEN;
*(str_++) = CHAR_FEMALE;
break;
}
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str_++) = TEXT_COLOR_BLUE;
*(str_++) = TEXT_COLOR_TRANSPARENT;
*(str_++) = TEXT_COLOR_LIGHT_BLUE;
*(str_++) = CHAR_SLASH;
*(str_++) = CHAR_EXTRA_SYMBOL;
*(str_++) = CHAR_LV_2;
txtPtr = str_;
str_ = ConvertIntToDecimalStringN(str_, level, STR_CONV_MODE_LEFT_ALIGN, 3);
lvlDigits = str_ - txtPtr;
*(str_++) = CHAR_SPACE;
if (!arg3)
{
lvlDigits = 3 - lvlDigits;
while (lvlDigits-- != 0)
*(str_++) = CHAR_SPACE;
}
*str_ = EOS;
return str_;
}
static void CopyMonNameGenderLocation(s16 listId, u8 loadId)
{
u16 boxId, i;
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1))
{
CopyConditionMonNameGender(menu->nameText[loadId], listId, FALSE);
boxId = monListPtr->monData[listId].boxId;
menu->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN;
menu->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
menu->locationText[loadId][2] = TEXT_COLOR_BLUE;
menu->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT;
menu->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE;
if (boxId == TOTAL_BOXES_COUNT)
CopyStringLeftAlignedToConditionData(&menu->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH);
else
CopyStringLeftAlignedToConditionData(&menu->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH);
}
else
{
for (i = 0; i < 12; i++)
menu->nameText[loadId][i] = CHAR_SPACE;
menu->nameText[loadId][i] = EOS;
for (i = 0; i < BOX_NAME_LENGTH; i++)
menu->locationText[loadId][i] = CHAR_SPACE;
menu->locationText[loadId][i] = EOS;
}
}
static void InitPartyConditionListParameters(void)
{
u16 i, count;
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavMonList *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavMonList));
menu->inSearchMode = FALSE;
for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++)
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{
monListPtr->monData[count].boxId = TOTAL_BOXES_COUNT;
monListPtr->monData[count].monId = i;
monListPtr->monData[count].data = 0;
count++;
}
}
monListPtr->monData[count].boxId = 0;
monListPtr->monData[count].monId = 0;
monListPtr->monData[count].data = 0;
monListPtr->currIndex = 0;
monListPtr->listCount = count + 1;
menu->state = 0;
}
static void InitSearchResultsConditionList(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
menu->inSearchMode = TRUE;
menu->state = 0;
}
static void GetMonConditionGraphData(s16 listId, u8 loadId)
{
u16 boxId, monId, i;
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1))
{
boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[listId].monId;
menu->graph.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
menu->graph.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
menu->graph.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
menu->graph.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
menu->graph.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
menu->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL));
menu->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
ConditionGraph_CalcPositions(menu->graph.conditions[loadId], menu->graph.savedPositions[loadId]);
}
else
{
// Set empty graph point
for (i = 0; i < CONDITION_COUNT; i++)
{
menu->graph.conditions[loadId][i] = 0;
menu->graph.savedPositions[loadId][i].x = CONDITION_GRAPH_CENTER_X;
menu->graph.savedPositions[loadId][i].y = CONDITION_GRAPH_CENTER_Y;
}
}
}
static void ConditionGraphDrawMonPic(s16 listId, u8 loadId)
{
u16 boxId, monId, species;
u32 personality, tid;
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (listId == (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1))
return;
boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[listId].monId;
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL);
tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL);
personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL);
LoadSpecialPokePic(&gMonFrontPicTable[species], menu->monPicGfx[loadId], species, personality, TRUE);
LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), menu->monPal[loadId]);
}
u16 GetMonListCount(void)
{
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->listCount;
}
u16 GetConditionGraphCurrentListIndex(void)
{
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->currIndex;
}
struct ConditionGraph *GetConditionGraphPtr(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return &menu->graph;
}
u8 GetConditionGraphMenuCurrentLoadIndex(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->loadId;
}
u8 GetConditionGraphMenuToLoadListIndex(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->toLoadListIndex;
}
void *GetConditionMonPicGfx(u8 loadId)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->monPicGfx[loadId];
}
void *GetConditionMonPal(u8 loadId)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->monPal[loadId];
}
u8 GetConditionGraphMenuToLoadId(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->toLoadId;
}
u8 *GetConditionMonNameText(u8 loadId)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->nameText[loadId];
}
u8 *GetConditionMonLocationText(u8 loadId)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->locationText[loadId];
}
u16 GetConditionMonDataBuffer(void)
{
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->monData[monListPtr->currIndex].data;
}
bool32 IsConditionMenuSearchMode(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (menu->inSearchMode == TRUE)
return TRUE;
else
return FALSE;
}
// Markings are only shown in search mode
u8 TryGetMonMarkId(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (menu->inSearchMode == TRUE)
return menu->monMarks[menu->loadId];
else
return 0;
}
u8 GetNumConditionMonSparkles(void)
{
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->numSparkles[menu->loadId];
}

View File

@ -1,624 +0,0 @@
#include "global.h"
#include "data.h"
#include "decompress.h"
#include "main.h"
#include "menu_specialized.h"
#include "mon_markings.h"
#include "pokenav.h"
#include "pokemon.h"
#include "pokemon_storage_system.h"
#include "sound.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
#include "constants/songs.h"
struct PokenavSub11
{
u32 monPal[3][0x20];
u8 fill[0x180];
u32 monPicGfx[3][MON_PIC_SIZE];
u8 searchMode;
s16 monIndex;
u32 (*callback)(struct PokenavSub11 *);
u8 fill2[0x6320 - 0x6308];
u8 searchLocBuffer[3][24];
u8 nameBuffer[3][64];
struct ConditionGraph conditionData;
u8 sheen[3];
u8 monMarks[3];
s8 mark;
s8 unk6787;
s8 unk6788;
s8 unk6789;
u8 state;
};
void InitPartyConditionListParameters(void);
void sub_81CD9F8(void);
u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr);
u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr);
u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr);
u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr);
u8 SwitchConditionSummaryIndex(u8 moveUp);
void CopyMonNameGenderLocation(s16 id, u8 arg1);
void GetMonConditionGraphData(s16 id, u8 arg1);
void ConditionGraphDrawMonPic(s16 id, u8 arg1);
// code
bool32 PokenavCallback_Init_PartyCondition(void)
{
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11));
if (structPtr == NULL)
return FALSE;
InitConditionGraphData(&structPtr->conditionData);
InitPartyConditionListParameters();
gKeyRepeatStartDelay = 20;
structPtr->callback = HandlePartyConditionInput;
return TRUE;
}
bool32 PokenavCallback_Init_ConditionGraphFromSearch(void)
{
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11));
if (structPtr == NULL)
return FALSE;
InitConditionGraphData(&structPtr->conditionData);
sub_81CD9F8();
gKeyRepeatStartDelay = 20;
structPtr->callback = HandlePartyConditionInput;
return TRUE;
}
u32 GetPartyConditionCallback(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->callback(structPtr);
}
u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr)
{
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u32 ret = ConditionGraphHandleDpadInput(structPtr);
if (ret == PARTY_CONDITION_FUNC_NONE)
{
if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
structPtr->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN;
}
else if (JOY_NEW(A_BUTTON))
{
if (structPtr->searchMode == 0)
{
if (monListPtr->currIndex == monListPtr->listCount - 1)
{
PlaySE(SE_SELECT);
structPtr->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN;
}
}
else
{
PlaySE(SE_SELECT);
ret = PARTY_CONDITION_FUNC_ADD_MARKINGS;
structPtr->callback = ConditionMenu_OpenMarkingsMenu;
}
}
}
return ret;
}
u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr)
{
struct PokenavSub18 *monListPtr;
u8 markings;
u32 ret = PARTY_CONDITION_FUNC_NONE, boxId, monId;
if (!HandleMonMarkingsMenuInput())
{
structPtr->monMarks[structPtr->mark] = GetMonMarkingsData();
monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[monListPtr->currIndex].boxId;
monId = monListPtr->monData[monListPtr->currIndex].monId;
markings = structPtr->monMarks[structPtr->mark];
if (boxId == TOTAL_BOXES_COUNT)
SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings);
else
SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings);
structPtr->callback = HandlePartyConditionInput;
ret = PARTY_CONDITION_FUNC_CLOSE_MARKINGS;
}
return ret;
}
u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr)
{
if (structPtr->searchMode == 0)
return POKENAV_CONDITION_MENU;
else
return POKENAV_RETURN_CONDITION_SEARCH;
}
void FreePartyConditionSubstruct1(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 0)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
}
u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
{
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u8 ret = 0;
if (JOY_HELD(DPAD_UP))
{
if (structPtr->searchMode == 0 || monListPtr->currIndex != 0)
{
PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(1);
}
}
else if (JOY_HELD(DPAD_DOWN))
{
if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1)
{
PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(0);
}
}
return ret;
}
u8 SwitchConditionSummaryIndex(u8 moveUp)
{
u16 r7;
bool8 wasNotLastMon, isNotLastMon;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787;
sub_81D1F84(&structPtr->conditionData, structPtr->conditionData.unk14[structPtr->mark], structPtr->conditionData.unk14[r7]);
wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
if (moveUp)
{
structPtr->unk6788 = structPtr->unk6787;
structPtr->unk6787 = structPtr->mark;
structPtr->mark = r7;
structPtr->unk6789 = structPtr->unk6788;
monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1;
structPtr->monIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1;
}
else
{
structPtr->unk6787 = structPtr->unk6788;
structPtr->unk6788 = structPtr->mark;
structPtr->mark = r7;
structPtr->unk6789 = structPtr->unk6787;
monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
structPtr->monIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
}
isNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
if (!wasNotLastMon)
return PARTY_CONDITION_FUNC_NO_TRANSITION;
else if (!isNotLastMon)
return PARTY_CONDITION_FUNC_SLIDE_MON_OUT;
else
return PARTY_CONDITION_FUNC_SLIDE_MON_IN;
}
bool32 LoadPartyConditionMenuGfx(void)
{
s32 var;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
switch (structPtr->state)
{
case 0:
CopyMonNameGenderLocation(monListPtr->currIndex, 0);
break;
case 1:
GetMonConditionGraphData(monListPtr->currIndex, 0);
break;
case 2:
ConditionGraphDrawMonPic(monListPtr->currIndex, 0);
break;
case 3:
if (monListPtr->listCount == 1)
{
structPtr->mark = 0;
structPtr->unk6787 = 0;
structPtr->unk6788 = 0;
structPtr->state = 0;
return TRUE;
}
else
{
structPtr->mark = 0;
structPtr->unk6787 = 1;
structPtr->unk6788 = 2;
}
break;
// These were probably ternaries just like cases 7-9, but couldn't match it any other way.
case 4:
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
var = 0;
CopyMonNameGenderLocation(var, 1);
break;
case 5:
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
var = 0;
GetMonConditionGraphData(var, 1);
break;
case 6:
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
var = 0;
ConditionGraphDrawMonPic(var, 1);
break;
case 7:
CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
break;
case 8:
GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
break;
case 9:
ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
structPtr->state = 0;
return TRUE;
}
structPtr->state++;
return FALSE;
}
bool32 SetConditionGraphData(u8 mode)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
switch (mode)
{
case 0:
CopyMonNameGenderLocation(structPtr->monIndex, structPtr->unk6789);
break;
case 1:
GetMonConditionGraphData(structPtr->monIndex, structPtr->unk6789);
break;
case 2:
ConditionGraphDrawMonPic(structPtr->monIndex, structPtr->unk6789);
return TRUE;
}
return FALSE;
}
u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n)
{
while (*src != EOS)
*dst++ = *src++, n--;
while (n-- > 0)
*dst++ = CHAR_SPACE;
*dst = EOS;
return dst;
}
u8 *CopyMonConditionNameGender(u8 *str, u16 id, bool8 arg3)
{
u16 boxId, monId, gender, species, level, lvlDigits;
struct BoxPokemon *boxMon;
u8 *txtPtr, *str_;
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[id].boxId;
monId = monListPtr->monData[id].monId;
*(str++) = EXT_CTRL_CODE_BEGIN;
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str++) = TEXT_COLOR_BLUE;
*(str++) = TEXT_COLOR_TRANSPARENT;
*(str++) = TEXT_COLOR_LIGHT_BLUE;
if (GetBoxOrPartyMonData(boxId, monId, MON_DATA_IS_EGG, NULL))
return StringCopyPadded(str, gText_EggNickname, CHAR_SPACE, 12);
GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, str);
StringGetEnd10(str);
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL);
if (boxId == TOTAL_BOXES_COUNT)
{
level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
gender = GetMonGender(&gPlayerParty[monId]);
}
else
{
boxMon = GetBoxedMonPtr(boxId, monId);
gender = GetBoxMonGender(boxMon);
level = GetLevelFromBoxMonExp(boxMon);
}
if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(str, gSpeciesNames[species]))
gender = MON_GENDERLESS;
str_ = str; // For some reason, a variable is needed to match.
while (*str_ != EOS)
(str_++);
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_SKIP;
*(str_++) = 60;
switch (gender)
{
default:
*(str_++) = CHAR_SPACER; // Genderless
break;
case MON_MALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
*(str_++) = TEXT_COLOR_RED;
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_RED;
*(str_++) = CHAR_MALE;
break;
case MON_FEMALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
*(str_++) = TEXT_COLOR_GREEN;
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_GREEN;
*(str_++) = CHAR_FEMALE;
break;
}
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str_++) = TEXT_COLOR_BLUE;
*(str_++) = TEXT_COLOR_TRANSPARENT;
*(str_++) = TEXT_COLOR_LIGHT_BLUE;
*(str_++) = CHAR_SLASH;
*(str_++) = CHAR_EXTRA_SYMBOL;
*(str_++) = CHAR_LV_2;
txtPtr = str_;
str_ = ConvertIntToDecimalStringN(str_, level, STR_CONV_MODE_LEFT_ALIGN, 3);
lvlDigits = str_ - txtPtr;
*(str_++) = CHAR_SPACE;
if (!arg3)
{
lvlDigits = 3 - lvlDigits;
while (lvlDigits-- != 0)
*(str_++) = CHAR_SPACE;
}
*str_ = EOS;
return str_;
}
void CopyMonNameGenderLocation(s16 id, u8 arg1)
{
u16 boxId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
{
CopyMonConditionNameGender(structPtr->nameBuffer[arg1], id, FALSE);
boxId = monListPtr->monData[id].boxId;
structPtr->searchLocBuffer[arg1][0] = EXT_CTRL_CODE_BEGIN;
structPtr->searchLocBuffer[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
structPtr->searchLocBuffer[arg1][2] = TEXT_COLOR_BLUE;
structPtr->searchLocBuffer[arg1][3] = TEXT_COLOR_TRANSPARENT;
structPtr->searchLocBuffer[arg1][4] = TEXT_COLOR_LIGHT_BLUE;
if (boxId == TOTAL_BOXES_COUNT)
CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], gText_InParty, 8);
else
CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH);
}
else
{
for (i = 0; i < 12; i++)
structPtr->nameBuffer[arg1][i] = CHAR_SPACE;
structPtr->nameBuffer[arg1][i] = EOS;
for (i = 0; i < 8; i++)
structPtr->searchLocBuffer[arg1][i] = CHAR_SPACE;
structPtr->searchLocBuffer[arg1][i] = EOS;
}
}
void InitPartyConditionListParameters(void)
{
u16 i, count;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
structPtr->searchMode = 0;
for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++)
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{
monListPtr->monData[count].boxId = TOTAL_BOXES_COUNT;
monListPtr->monData[count].monId = i;
monListPtr->monData[count].data = 0;
count++;
}
}
monListPtr->monData[count].boxId = 0;
monListPtr->monData[count].monId = 0;
monListPtr->monData[count].data = 0;
monListPtr->currIndex = 0;
monListPtr->listCount = count + 1;
structPtr->state = 0;
}
void sub_81CD9F8(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
structPtr->searchMode = 1;
structPtr->state = 0;
}
void GetMonConditionGraphData(s16 id, u8 arg1)
{
u16 boxId, monId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
{
boxId = monListPtr->monData[id].boxId;
monId = monListPtr->monData[id].monId;
structPtr->conditionData.stat[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
structPtr->conditionData.stat[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
structPtr->conditionData.stat[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
structPtr->conditionData.stat[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
structPtr->conditionData.stat[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
structPtr->sheen[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255)
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u
: 9;
structPtr->monMarks[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
sub_81D2754(structPtr->conditionData.stat[arg1], structPtr->conditionData.unk14[arg1]);
}
else
{
for (i = 0; i < FLAVOR_COUNT; i++)
{
structPtr->conditionData.stat[arg1][i] = 0;
structPtr->conditionData.unk14[arg1][i].unk0 = 155;
structPtr->conditionData.unk14[arg1][i].unk2 = 91;
}
}
}
void ConditionGraphDrawMonPic(s16 index, u8 arg1)
{
u16 boxId, monId, species;
u32 personality, tid;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (index == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
return;
boxId = monListPtr->monData[index].boxId;
monId = monListPtr->monData[index].monId;
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL);
tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL);
personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL);
LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[arg1], species, personality, TRUE);
LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[arg1]);
}
u16 GetMonListCount(void)
{
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->listCount;
}
u16 GetConditionGraphCurrentMonIndex(void)
{
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->currIndex;
}
struct ConditionGraph *GetConditionGraphDataPtr(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return &structPtr->conditionData;
}
u8 GetMonMarkIndex(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->mark;
}
u8 sub_81CDC9C(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->monIndex;
}
void *GetConditionMonPicGfx(u8 id)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->monPicGfx[id];
}
void *GetConditionMonPal(u8 id)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->monPal[id];
}
u8 sub_81CDCEC(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->unk6789;
}
u8 *GetConditionMonNameBuffer(u8 id)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->nameBuffer[id];
}
u8 *GetConditionMonLocationBuffer(u8 id)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->searchLocBuffer[id];
}
u16 GetConditionMonDataBuffer(void)
{
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->monData[monListPtr->currIndex].data;
}
bool32 IsConditionMenuSearchMode(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 1)
return TRUE;
else
return FALSE;
}
u8 TryGetMonMarkId(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 1)
return structPtr->monMarks[structPtr->mark];
else
return 0;
}
u8 GetMonSheen(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->sheen[structPtr->mark];
}

View File

@ -1,885 +0,0 @@
#include "global.h"
#include "bg.h"
#include "window.h"
#include "pokenav.h"
#include "decompress.h"
#include "gpu_regs.h"
#include "graphics.h"
#include "menu.h"
#include "menu_specialized.h"
#include "mon_markings.h"
#include "palette.h"
#include "pokenav.h"
#include "scanline_effect.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
u32 LoopedTask_TransitionMons(s32);
u32 LoopedTask_ExitPartyConditionMenu(s32);
u32 LoopedTask_MoveCursorNoTransition(s32);
u32 LoopedTask_SlideMonOut(s32);
u32 LoopedTask_OpenMonMarkingsWindow(s32);
u32 LoopedTask_CloseMonMarkingsWindow(s32);
BSS_DATA u8 gUnknown_030012BC;
const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal");
const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal");
const u32 gUnknown_08623228[] = INCBIN_U32("graphics/pokenav/8623228.4bpp.lz");
const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz");
const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal");
const struct BgTemplate sPartyConditionBgTemplates[3] =
{
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 0x1F,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 3,
.mapBaseIndex = 0x1D,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 0x1E,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
const struct WindowTemplate sMonNameGenderWindowTemplate =
{
.bg = 1,
.tilemapLeft = 13,
.tilemapTop = 1,
.width = 13,
.height = 4,
.paletteNum = 15,
.baseBlock = 2
};
const struct WindowTemplate sConditionGraphListIdWindowTemplate =
{
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 6,
.width = 7,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x36
};
const struct WindowTemplate sUnusedWindowTemplate1 =
{
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 0x1C,
.width = 5,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x44
};
const struct WindowTemplate sUnusedWindowTemplate2 =
{
.bg = 1,
.tilemapLeft = 13,
.tilemapTop = 0x1C,
.width = 3,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x44
};
const LoopedTask sPartyConditionLoopedTaskFuncs[] =
{
[PARTY_CONDITION_FUNC_NONE] = NULL,
[PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons,
[PARTY_CONDITION_FUNC_RETURN] = LoopedTask_ExitPartyConditionMenu,
[PARTY_CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition,
[PARTY_CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut,
[PARTY_CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow,
[PARTY_CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow
};
struct Pokenav7Struct
{
u32 loopedTaskId;
u8 tilemapBuffers[3][BG_SCREEN_SIZE];
u8 filler[2];
u8 partyPokeballSpriteIds[10];
u32 (*callback)(void);
s16 monTransitionX;
u8 monPicSpriteId;
u16 monPalIndex;
u16 monGfxTileStart;
void *unk181C;
u8 nameGenderWindowId;
u8 listIndexWindowId;
u8 unusedWindowId1;
u8 unusedWindowId2;
struct MonMarkingsMenu monMarks;
struct Sprite *monMarksSprite;
struct Sprite *conditionSparkleSprites[MAX_CONDITION_SPARKLES];
u8 windowModeState;
u8 filler2[0x38ac - 0x2909];
};
extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c
u32 LoopedTask_OpenPartyConditionGraph(s32 state);
u32 GetPartyConditionLoopedTaskActive(void);
void CreateConditionMonPic(u8 var);
void CreateMonMarkingsOrPokeballIndicators(void);
void CopyUnusedConditionWindowsToVram(void);
bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2);
void sub_81CEE44(void);
void DoConditionGraphTransition(void);
void sub_81CEEC8(void);
void sub_81CEE68(void);
void ToggleBg2(bool8 showBg);
// code
bool32 OpenPartyConditionMenu(void)
{
struct Pokenav7Struct *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU, sizeof(struct Pokenav7Struct));
if (structPtr == NULL)
return FALSE;
structPtr->monPicSpriteId = SPRITE_NONE;
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenPartyConditionGraph, 1);
structPtr->callback = GetPartyConditionLoopedTaskActive;
structPtr->windowModeState = 0;
return TRUE;
}
void CreatePartyConditionLoopedTask(s32 id)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
structPtr->loopedTaskId = CreateLoopedTask(sPartyConditionLoopedTaskFuncs[id], 1);
structPtr->callback = GetPartyConditionLoopedTaskActive;
}
u32 IsPartyConditionLoopedTaskActive(void)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
return structPtr->callback();
}
u32 GetPartyConditionLoopedTaskActive(void)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
return IsLoopedTaskActive(structPtr->loopedTaskId);
}
u32 LoopedTask_OpenPartyConditionGraph(s32 state)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
switch (state)
{
case 0:
if (LoadPartyConditionMenuGfx() != TRUE)
return LT_PAUSE;
return LT_INC_AND_PAUSE;
case 1:
InitBgTemplates(sPartyConditionBgTemplates, ARRAY_COUNT(sPartyConditionBgTemplates));
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(2, 0, BG_COORD_SET);
ChangeBgY(2, 0, BG_COORD_SET);
ChangeBgX(3, 0, BG_COORD_SET);
ChangeBgY(3, 0, BG_COORD_SET);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
DecompressAndCopyTileDataToVram(3, gPokenavCondition_Gfx, 0, 0, 0);
return LT_INC_AND_PAUSE;
case 2:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
DecompressAndCopyTileDataToVram(2, gUnknown_08623228, 0, 0, 0);
return LT_INC_AND_PAUSE;
case 3:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
LZ77UnCompVram(gPokenavCondition_Tilemap, structPtr->tilemapBuffers[0]);
SetBgTilemapBuffer(3, structPtr->tilemapBuffers[0]);
if (IsConditionMenuSearchMode() == TRUE)
CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4);
CopyBgTilemapBufferToVram(3);
CopyPaletteIntoBufferUnfaded(gPokenavCondition_Pal, 0x10, 0x20);
CopyPaletteIntoBufferUnfaded(gConditionText_Pal, 0xF0, 0x20);
structPtr->monTransitionX = -80;
return LT_INC_AND_PAUSE;
case 4:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
LZ77UnCompVram(sConditionGraph_Tilemap, structPtr->tilemapBuffers[2]);
SetBgTilemapBuffer(2, structPtr->tilemapBuffers[2]);
CopyBgTilemapBufferToVram(2);
CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20);
SetConditionGraphIOWindows(2);
return LT_INC_AND_PAUSE;
case 5:
BgDmaFill(1, 0, 0, 1);
BgDmaFill(1, 17, 1, 1);
CpuFill32(0, structPtr->tilemapBuffers[1], BG_SCREEN_SIZE);
SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]);
return LT_INC_AND_PAUSE;
case 6:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
structPtr->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate);
if (IsConditionMenuSearchMode() == TRUE)
{
structPtr->listIndexWindowId = AddWindow(&sConditionGraphListIdWindowTemplate);
structPtr->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1);
structPtr->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2);
}
DeactivateAllTextPrinters();
return LT_INC_AND_PAUSE;
case 7:
CreateConditionMonPic(0);
return LT_INC_AND_PAUSE;
case 8:
CreateMonMarkingsOrPokeballIndicators();
return LT_INC_AND_PAUSE;
case 9:
if (IsConditionMenuSearchMode() == TRUE)
CopyUnusedConditionWindowsToVram();
return LT_INC_AND_PAUSE;
case 10:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), TRUE);
return LT_INC_AND_PAUSE;
case 11:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), TRUE);
return LT_INC_AND_PAUSE;
case 12:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), TRUE);
return LT_INC_AND_PAUSE;
case 13:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), TRUE) != TRUE)
return LT_PAUSE;
PutWindowTilemap(structPtr->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE)
{
PutWindowTilemap(structPtr->listIndexWindowId);
PutWindowTilemap(structPtr->unusedWindowId1);
PutWindowTilemap(structPtr->unusedWindowId2);
}
return LT_INC_AND_PAUSE;
case 14:
ShowBg(1);
HideBg(2);
ShowBg(3);
if (IsConditionMenuSearchMode() == TRUE)
PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS);
return LT_INC_AND_PAUSE;
case 15:
PokenavFadeScreen(1);
if (!IsConditionMenuSearchMode())
{
LoadLeftHeaderGfxForIndex(POKENAV_GFX_PARTY_MENU);
ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, TRUE, 0);
ShowLeftHeaderGfx(POKENAV_GFX_PARTY_MENU, TRUE, 0);
}
return LT_INC_AND_PAUSE;
case 16:
if (IsPaletteFadeActive())
return LT_PAUSE;
if (!IsConditionMenuSearchMode() && AreLeftHeaderSpritesMoving())
return LT_PAUSE;
SetVBlankCallback_(sub_81CEE44);
return LT_INC_AND_PAUSE;
case 17:
DoConditionGraphTransition();
InitConditionGraphState(GetConditionGraphDataPtr());
return LT_INC_AND_PAUSE;
case 18:
if (SetupConditionGraphScanlineParams(GetConditionGraphDataPtr()))
return LT_PAUSE;
return LT_INC_AND_PAUSE;
case 19:
ToggleBg2(TRUE);
return LT_INC_AND_PAUSE;
case 20:
if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
{
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount())
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen());
return LT_FINISH;
}
return LT_PAUSE;
}
return LT_FINISH;
}
u32 LoopedTask_ExitPartyConditionMenu(s32 state)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
switch (state)
{
case 0:
sub_81CEEC8();
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
case 1:
if (TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
return 2;
ToggleBg2(FALSE);
return LT_INC_AND_CONTINUE;
case 2:
PokenavFadeScreen(0);
if (!IsConditionMenuSearchMode())
SlideMenuHeaderDown();
return LT_INC_AND_PAUSE;
case 3:
if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy())
return LT_PAUSE;
FreeConditionSparkles(structPtr->conditionSparkleSprites);
HideBg(1);
HideBg(2);
HideBg(3);
return LT_INC_AND_CONTINUE;
}
return LT_FINISH;
}
u32 LoopedTask_TransitionMons(s32 state)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
struct ConditionGraph *unkPtr = GetConditionGraphDataPtr();
switch (state)
{
case 0:
SetConditionGraphData(0);
return LT_INC_AND_CONTINUE;
case 1:
SetConditionGraphData(1);
return LT_INC_AND_CONTINUE;
case 2:
SetConditionGraphData(2);
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
case 3:
TransitionConditionGraph(unkPtr);
return LT_INC_AND_CONTINUE;
case 4:
if (!MoveConditionMonOffscreen(&structPtr->monTransitionX))
{
CreateConditionMonPic(GetMonMarkIndex());
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
case 5:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 6:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 7:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 8:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
case 9:
unkPtr = GetConditionGraphDataPtr();
if (!TryUpdateConditionMonTransitionOn(unkPtr, &structPtr->monTransitionX))
{
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount())
return LT_INC_AND_CONTINUE;
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen());
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
}
return LT_FINISH;
}
u32 LoopedTask_MoveCursorNoTransition(s32 state)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
switch (state)
{
case 0:
SetConditionGraphData(0);
return LT_INC_AND_CONTINUE;
case 1:
SetConditionGraphData(1);
return LT_INC_AND_CONTINUE;
case 2:
SetConditionGraphData(2);
return LT_INC_AND_CONTINUE;
case 3:
CreateConditionMonPic(GetMonMarkIndex());
return LT_INC_AND_CONTINUE;
case 4:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 5:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 6:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 7:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
case 8:
if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
{
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen());
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
}
return LT_FINISH;
}
u32 LoopedTask_SlideMonOut(s32 state)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
switch (state)
{
case 0:
SetConditionGraphData(0);
return LT_INC_AND_CONTINUE;
case 1:
SetConditionGraphData(1);
return LT_INC_AND_CONTINUE;
case 2:
SetConditionGraphData(2);
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
case 3:
if (!TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
case 4:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 5:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 6:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 7:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
}
return LT_FINISH;
}
u32 LoopedTask_OpenMonMarkingsWindow(s32 state)
{
switch (state)
{
case 0:
OpenMonMarkingsMenu(TryGetMonMarkId(), 176, 32);
return LT_INC_AND_CONTINUE;
case 1:
PrintHelpBarText(HELPBAR_CONDITION_MARKINGS);
return LT_INC_AND_CONTINUE;
case 2:
if (WaitForHelpBar() == TRUE)
return LT_PAUSE;
return LT_INC_AND_CONTINUE;
}
return LT_FINISH;
}
u32 LoopedTask_CloseMonMarkingsWindow(s32 state)
{
switch (state)
{
case 0:
FreeMonMarkingsMenu();
return LT_INC_AND_CONTINUE;
case 1:
PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS);
return LT_INC_AND_CONTINUE;
case 2:
if (WaitForHelpBar() == TRUE)
return LT_PAUSE;
return LT_INC_AND_CONTINUE;
}
return LT_FINISH;
}
static u8 *UnusedPrintNumberString(u8 *dst, u16 num)
{
u8 *txtPtr = ConvertIntToDecimalStringN(dst, num, STR_CONV_MODE_RIGHT_ALIGN, 4);
txtPtr = StringCopy(txtPtr, gText_Number2);
return txtPtr;
}
bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode)
{
u8 text[32];
const u8 *str;
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
switch (mode)
{
case 0:
FillWindowPixelBuffer(structPtr->nameGenderWindowId, 0);
if (IsConditionMenuSearchMode() == TRUE)
FillWindowPixelBuffer(structPtr->listIndexWindowId, 0);
break;
case 1:
if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE)
{
str = GetConditionMonNameBuffer(bufferIndex);
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL);
}
break;
case 2:
if (IsConditionMenuSearchMode() == TRUE)
{
str = GetConditionMonLocationBuffer(bufferIndex);
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL);
text[0] = EXT_CTRL_CODE_BEGIN;
text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
text[2] = TEXT_COLOR_BLUE;
text[3] = TEXT_COLOR_TRANSPARENT;
text[4] = TEXT_COLOR_LIGHT_BLUE;
StringCopy(text + 5, gText_Number2);
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL);
ConvertIntToDecimalStringN(text + 5, GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4);
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL);
}
break;
case 3:
switch (structPtr->windowModeState)
{
case 0:
if (winMode)
CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_FULL);
else
CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_GFX);
if (IsConditionMenuSearchMode() == TRUE)
{
structPtr->windowModeState++;
return FALSE;
}
else
{
structPtr->windowModeState = 0;
return TRUE;
}
case 1:
if (winMode)
CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_FULL);
else
CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_GFX);
structPtr->windowModeState = 0;
return TRUE;
}
}
return FALSE;
}
void CopyUnusedConditionWindowsToVram(void)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
CopyWindowToVram(structPtr->unusedWindowId1, COPYWIN_FULL);
CopyWindowToVram(structPtr->unusedWindowId2, COPYWIN_FULL);
}
void sub_81CE964(struct Sprite *sprite)
{
if (sprite->data[0] == GetConditionGraphCurrentMonIndex())
StartSpriteAnim(sprite, 0);
else
StartSpriteAnim(sprite, 1);
}
void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite)
{
if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1)
sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x65);
else
sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x66);
}
void MonMarkingsCallback(struct Sprite *sprite)
{
StartSpriteAnim(sprite, TryGetMonMarkId());
}
void CreateMonMarkingsOrPokeballIndicators(void)
{
struct SpriteSheet sprSheets[4];
struct SpriteTemplate sprTemplate;
struct SpritePalette sprPals[3];
struct SpriteSheet sprSheet;
struct Sprite *sprite;
u16 i, spriteId;
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals);
if (IsConditionMenuSearchMode() == TRUE)
{
structPtr->monMarks.baseTileTag = 0x6A;
structPtr->monMarks.basePaletteTag = 0x6A;
InitMonMarkingsMenu(&structPtr->monMarks);
BufferMonMarkingsMenuTiles();
sprite = CreateMonMarkingAllCombosSprite(0x69, 0x69, sConditionGraphMonMarkingsPal);
sprite->oam.priority = 3;
sprite->x = 192;
sprite->y = 32;
sprite->callback = MonMarkingsCallback;
structPtr->monMarksSprite = sprite;
PokenavFillPalette(IndexOfSpritePaletteTag(0x69), 0);
}
else
{
// party mode -> add pokeballs on right hand side
LoadSpriteSheets(sprSheets);
Pokenav_AllocAndLoadPalettes(sprPals);
for (i = 0; i < GetMonListCount() - 1; i++)
{
spriteId = CreateSprite(&sprTemplate, 226, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
structPtr->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].data[0] = i;
gSprites[spriteId].callback = sub_81CE964;
}
else
{
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE;
}
}
sprTemplate.tileTag = 0x67;
sprTemplate.callback = SpriteCallbackDummy;
for (; i < 6; i++)
{
spriteId = CreateSprite(&sprTemplate, 230, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
structPtr->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].oam.size = 0;
}
else
{
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE;
}
}
sprTemplate.tileTag = 0x66;
sprTemplate.callback = HighlightCurrentPartyIndexPokeball;
spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
structPtr->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16);
gSprites[spriteId].oam.size = SPRITE_SIZE(32x16);
}
else
{
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE;
}
}
LoadConditionSparkle(&sprSheet, &sprPals[0]);
LoadSpriteSheet(&sprSheet);
sprPals[1].data = NULL;
Pokenav_AllocAndLoadPalettes(sprPals);
}
void sub_81CEBF4(struct Pokenav7Struct *structPtr)
{
u8 i;
if (IsConditionMenuSearchMode() == TRUE)
{
DestroySprite(structPtr->monMarksSprite);
FreeSpriteTilesByTag(0x6A);
FreeSpriteTilesByTag(0x69);
FreeSpritePaletteByTag(0x6A);
FreeSpritePaletteByTag(0x69);
}
else
{
for (i = 0; i < 7; i++)
DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]);
FreeSpriteTilesByTag(0x65);
FreeSpriteTilesByTag(0x66);
FreeSpriteTilesByTag(0x67);
FreeSpritePaletteByTag(0x65);
FreeSpritePaletteByTag(0x66);
}
if (structPtr->monPicSpriteId != SPRITE_NONE)
{
DestroySprite(&gSprites[structPtr->monPicSpriteId]);
FreeSpriteTilesByTag(0x64);
FreeSpritePaletteByTag(0x64);
}
}
void FreePartyConditionSubstruct2(void)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
RemoveWindow(structPtr->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE)
{
RemoveWindow(structPtr->listIndexWindowId);
RemoveWindow(structPtr->unusedWindowId1);
RemoveWindow(structPtr->unusedWindowId2);
}
else
{
SetLeftHeaderSpritesInvisibility();
}
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
sub_81CEBF4(structPtr);
sub_81CEE68();
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU);
}
void MonPicGfxSpriteCallback(struct Sprite *sprite)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
sprite->x = structPtr->monTransitionX + 38;
}
void CreateConditionMonPic(u8 id)
{
struct SpriteTemplate sprTemplate;
struct SpriteSheet sprSheet;
struct SpritePalette sprPal;
u8 spriteId;
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
if (structPtr->monPicSpriteId == SPRITE_NONE)
{
LoadConditionMonPicTemplate(&sprSheet, &sprTemplate, &sprPal);
sprSheet.data = GetConditionMonPicGfx(id);
sprPal.data = GetConditionMonPal(id);
structPtr->monPalIndex = LoadSpritePalette(&sprPal);
structPtr->monGfxTileStart = LoadSpriteSheet(&sprSheet);
spriteId = CreateSprite(&sprTemplate, 38, 104, 0);
structPtr->monPicSpriteId = spriteId;
if (spriteId == MAX_SPRITES)
{
FreeSpriteTilesByTag(0x64);
FreeSpritePaletteByTag(0x64);
structPtr->monPicSpriteId = SPRITE_NONE;
}
else
{
structPtr->monPicSpriteId = spriteId;
gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback;
structPtr->unk181C = (void*)(VRAM) + 0x10000 + (structPtr->monGfxTileStart * 32);
structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100;
}
}
else
{
DmaCopy16Defvars(3, GetConditionMonPicGfx(id), structPtr->unk181C, MON_PIC_SIZE);
LoadPalette(GetConditionMonPal(id), structPtr->monPalIndex, 0x20);
}
}
void sub_81CEE44(void)
{
struct ConditionGraph *unk = GetConditionGraphDataPtr();
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
sub_81D2108(unk);
ScanlineEffect_InitHBlankDmaTransfer();
}
void sub_81CEE68(void)
{
SetPokenavVBlankCallback();
}
void ToggleBg2(bool8 showBg)
{
if (showBg)
ShowBg(2);
else
HideBg(2);
}
void DoConditionGraphTransition(void)
{
struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr();
u8 id = GetMonMarkIndex();
gUnknown_030012BC = id;
sub_81D1F84(conditionPtr, conditionPtr->unk14[3], conditionPtr->unk14[id]);
TransitionConditionGraph(conditionPtr);
}
void sub_81CEEC8(void)
{
struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr();
if (IsConditionMenuSearchMode() || GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1)
sub_81D1F84(conditionPtr, conditionPtr->unk14[GetMonMarkIndex()], conditionPtr->unk14[3]);
}
u8 GetMonMarkingsData(void)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
if (IsConditionMenuSearchMode() == 1)
return structPtr->monMarks.markings;
else
return 0;
}

View File

@ -0,0 +1,892 @@
#include "global.h"
#include "bg.h"
#include "window.h"
#include "pokenav.h"
#include "decompress.h"
#include "gpu_regs.h"
#include "graphics.h"
#include "menu.h"
#include "menu_specialized.h"
#include "mon_markings.h"
#include "palette.h"
#include "pokenav.h"
#include "scanline_effect.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
static u32 LoopedTask_TransitionMons(s32);
static u32 LoopedTask_ExitConditionGraphMenu(s32);
static u32 LoopedTask_MoveCursorNoTransition(s32);
static u32 LoopedTask_SlideMonOut(s32);
static u32 LoopedTask_OpenMonMarkingsWindow(s32);
static u32 LoopedTask_CloseMonMarkingsWindow(s32);
static u8 sInitialLoadId; // Never read
const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal");
const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal");
static const u32 sConditionGraphData_Gfx[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz");
static const u32 sConditionGraphData_Tilemap[] = INCBIN_U32("graphics/pokenav/condition/graph_data.bin.lz");
static const u16 sMonMarkings_Pal[] = INCBIN_U16("graphics/pokenav/condition/mon_markings.gbapal");
static const struct BgTemplate sMenuBgTemplates[3] =
{
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 0x1F,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 3,
.mapBaseIndex = 0x1D,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 0x1E,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
static const struct WindowTemplate sMonNameGenderWindowTemplate =
{
.bg = 1,
.tilemapLeft = 13,
.tilemapTop = 1,
.width = 13,
.height = 4,
.paletteNum = 15,
.baseBlock = 2
};
static const struct WindowTemplate sListIndexWindowTemplate =
{
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 6,
.width = 7,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x36
};
static const struct WindowTemplate sUnusedWindowTemplate1 =
{
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 0x1C,
.width = 5,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x44
};
static const struct WindowTemplate sUnusedWindowTemplate2 =
{
.bg = 1,
.tilemapLeft = 13,
.tilemapTop = 0x1C,
.width = 3,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x44
};
static const LoopedTask sLoopedTaskFuncs[] =
{
[CONDITION_FUNC_NONE] = NULL,
[CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons,
[CONDITION_FUNC_RETURN] = LoopedTask_ExitConditionGraphMenu,
[CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition,
[CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut,
[CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow,
[CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow
};
struct Pokenav_ConditionMenuGfx
{
u32 loopedTaskId;
u8 tilemapBuffers[3][BG_SCREEN_SIZE];
u8 filler[2];
u8 partyPokeballSpriteIds[PARTY_SIZE + 1];
u32 (*callback)(void);
s16 monTransitionX;
u8 monPicSpriteId;
u16 monPalIndex;
u16 monGfxTileStart;
void *monGfxPtr;
u8 nameGenderWindowId;
u8 listIndexWindowId;
u8 unusedWindowId1;
u8 unusedWindowId2;
struct MonMarkingsMenu marksMenu;
struct Sprite *monMarksSprite;
struct Sprite *conditionSparkleSprites[MAX_CONDITION_SPARKLES];
u8 windowModeState;
u8 filler2[0xFA3];
};
extern s8 GetConditionGraphMenuCurrentLoadIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions.c
static u32 LoopedTask_OpenConditionGraphMenu(s32);
static u32 GetConditionGraphMenuLoopedTaskActive(void);
static void CreateConditionMonPic(u8);
static void CreateMonMarkingsOrPokeballIndicators(void);
static void CopyUnusedConditionWindowsToVram(void);
static bool32 UpdateConditionGraphMenuWindows(u8, u16, bool8);
static void VBlankCB_PokenavConditionGraph(void);
static void DoConditionGraphEnterTransition(void);
static void DoConditionGraphExitTransition(void);
static void SetExitVBlank(void);
static void ToggleGraphData(bool8);
bool32 OpenConditionGraphMenu(void)
{
struct Pokenav_ConditionMenuGfx *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX, sizeof(struct Pokenav_ConditionMenuGfx));
if (menu == NULL)
return FALSE;
menu->monPicSpriteId = SPRITE_NONE;
menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionGraphMenu, 1);
menu->callback = GetConditionGraphMenuLoopedTaskActive;
menu->windowModeState = 0;
return TRUE;
}
void CreateConditionGraphMenuLoopedTask(s32 id)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
menu->loopedTaskId = CreateLoopedTask(sLoopedTaskFuncs[id], 1);
menu->callback = GetConditionGraphMenuLoopedTaskActive;
}
u32 IsConditionGraphMenuLoopedTaskActive(void)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
return menu->callback();
}
static u32 GetConditionGraphMenuLoopedTaskActive(void)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
return IsLoopedTaskActive(menu->loopedTaskId);
}
static u32 LoopedTask_OpenConditionGraphMenu(s32 state)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state)
{
case 0:
if (LoadConditionGraphMenuGfx() != TRUE)
return LT_PAUSE;
return LT_INC_AND_PAUSE;
case 1:
InitBgTemplates(sMenuBgTemplates, ARRAY_COUNT(sMenuBgTemplates));
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(2, 0, BG_COORD_SET);
ChangeBgY(2, 0, BG_COORD_SET);
ChangeBgX(3, 0, BG_COORD_SET);
ChangeBgY(3, 0, BG_COORD_SET);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
DecompressAndCopyTileDataToVram(3, gPokenavCondition_Gfx, 0, 0, 0);
return LT_INC_AND_PAUSE;
case 2:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
DecompressAndCopyTileDataToVram(2, sConditionGraphData_Gfx, 0, 0, 0);
return LT_INC_AND_PAUSE;
case 3:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
LZ77UnCompVram(gPokenavCondition_Tilemap, menu->tilemapBuffers[0]);
SetBgTilemapBuffer(3, menu->tilemapBuffers[0]);
if (IsConditionMenuSearchMode() == TRUE)
CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4);
CopyBgTilemapBufferToVram(3);
CopyPaletteIntoBufferUnfaded(gPokenavCondition_Pal, 0x10, 0x20);
CopyPaletteIntoBufferUnfaded(gConditionText_Pal, 0xF0, 0x20);
menu->monTransitionX = -80;
return LT_INC_AND_PAUSE;
case 4:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
LZ77UnCompVram(sConditionGraphData_Tilemap, menu->tilemapBuffers[2]);
SetBgTilemapBuffer(2, menu->tilemapBuffers[2]);
CopyBgTilemapBufferToVram(2);
CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20);
ConditionGraph_InitWindow(2);
return LT_INC_AND_PAUSE;
case 5:
BgDmaFill(1, 0, 0, 1);
BgDmaFill(1, 17, 1, 1);
CpuFill32(0, menu->tilemapBuffers[1], BG_SCREEN_SIZE);
SetBgTilemapBuffer(1, menu->tilemapBuffers[1]);
return LT_INC_AND_PAUSE;
case 6:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
menu->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate);
if (IsConditionMenuSearchMode() == TRUE)
{
menu->listIndexWindowId = AddWindow(&sListIndexWindowTemplate);
menu->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1);
menu->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2);
}
DeactivateAllTextPrinters();
return LT_INC_AND_PAUSE;
case 7:
CreateConditionMonPic(0);
return LT_INC_AND_PAUSE;
case 8:
CreateMonMarkingsOrPokeballIndicators();
return LT_INC_AND_PAUSE;
case 9:
if (IsConditionMenuSearchMode() == TRUE)
CopyUnusedConditionWindowsToVram();
return LT_INC_AND_PAUSE;
case 10:
UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), TRUE);
return LT_INC_AND_PAUSE;
case 11:
UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), TRUE);
return LT_INC_AND_PAUSE;
case 12:
UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), TRUE);
return LT_INC_AND_PAUSE;
case 13:
if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), TRUE) != TRUE)
return LT_PAUSE;
PutWindowTilemap(menu->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE)
{
PutWindowTilemap(menu->listIndexWindowId);
PutWindowTilemap(menu->unusedWindowId1);
PutWindowTilemap(menu->unusedWindowId2);
}
return LT_INC_AND_PAUSE;
case 14:
ShowBg(1);
HideBg(2);
ShowBg(3);
if (IsConditionMenuSearchMode() == TRUE)
PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS);
return LT_INC_AND_PAUSE;
case 15:
PokenavFadeScreen(POKENAV_FADE_FROM_BLACK);
if (!IsConditionMenuSearchMode())
{
LoadLeftHeaderGfxForIndex(POKENAV_GFX_PARTY_MENU);
ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, TRUE, 0);
ShowLeftHeaderGfx(POKENAV_GFX_PARTY_MENU, TRUE, 0);
}
return LT_INC_AND_PAUSE;
case 16:
if (IsPaletteFadeActive())
return LT_PAUSE;
if (!IsConditionMenuSearchMode() && AreLeftHeaderSpritesMoving())
return LT_PAUSE;
SetVBlankCallback_(VBlankCB_PokenavConditionGraph);
return LT_INC_AND_PAUSE;
case 17:
DoConditionGraphEnterTransition();
ConditionGraph_InitResetScanline(GetConditionGraphPtr());
return LT_INC_AND_PAUSE;
case 18:
if (ConditionGraph_ResetScanline(GetConditionGraphPtr()))
return LT_PAUSE;
return LT_INC_AND_PAUSE;
case 19:
ToggleGraphData(TRUE);
return LT_INC_AND_PAUSE;
case 20:
if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &menu->monTransitionX))
{
ResetConditionSparkleSprites(menu->conditionSparkleSprites);
if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentListIndex() != GetMonListCount())
CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles());
return LT_FINISH;
}
return LT_PAUSE;
}
return LT_FINISH;
}
static u32 LoopedTask_ExitConditionGraphMenu(s32 state)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state)
{
case 0:
DoConditionGraphExitTransition();
DestroyConditionSparkleSprites(menu->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
case 1:
if (ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &menu->monTransitionX))
return 2;
ToggleGraphData(FALSE);
return LT_INC_AND_CONTINUE;
case 2:
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
if (!IsConditionMenuSearchMode())
SlideMenuHeaderDown();
return LT_INC_AND_PAUSE;
case 3:
if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy())
return LT_PAUSE;
FreeConditionSparkles(menu->conditionSparkleSprites);
HideBg(1);
HideBg(2);
HideBg(3);
return LT_INC_AND_CONTINUE;
}
return LT_FINISH;
}
static u32 LoopedTask_TransitionMons(s32 state)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
struct ConditionGraph *graph = GetConditionGraphPtr();
switch (state)
{
case 0:
LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO);
return LT_INC_AND_CONTINUE;
case 1:
LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH);
return LT_INC_AND_CONTINUE;
case 2:
LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC);
DestroyConditionSparkleSprites(menu->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
case 3:
ConditionGraph_TryUpdate(graph);
return LT_INC_AND_CONTINUE;
case 4:
if (!MoveConditionMonOffscreen(&menu->monTransitionX))
{
CreateConditionMonPic(GetConditionGraphMenuCurrentLoadIndex());
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
case 5:
UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 6:
UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 7:
UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 8:
if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
case 9:
graph = GetConditionGraphPtr();
if (!ConditionMenu_UpdateMonEnter(graph, &menu->monTransitionX))
{
ResetConditionSparkleSprites(menu->conditionSparkleSprites);
if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentListIndex() == GetMonListCount())
return LT_INC_AND_CONTINUE;
CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles());
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
}
return LT_FINISH;
}
static u32 LoopedTask_MoveCursorNoTransition(s32 state)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state)
{
case 0:
LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO);
return LT_INC_AND_CONTINUE;
case 1:
LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH);
return LT_INC_AND_CONTINUE;
case 2:
LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC);
return LT_INC_AND_CONTINUE;
case 3:
CreateConditionMonPic(GetConditionGraphMenuCurrentLoadIndex());
return LT_INC_AND_CONTINUE;
case 4:
UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 5:
UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 6:
UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 7:
if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
case 8:
if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &menu->monTransitionX))
{
ResetConditionSparkleSprites(menu->conditionSparkleSprites);
CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles());
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
}
return LT_FINISH;
}
static u32 LoopedTask_SlideMonOut(s32 state)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state)
{
case 0:
LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO);
return LT_INC_AND_CONTINUE;
case 1:
LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH);
return LT_INC_AND_CONTINUE;
case 2:
LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC);
DestroyConditionSparkleSprites(menu->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
case 3:
if (!ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &menu->monTransitionX))
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
case 4:
UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 5:
UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 6:
UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE;
case 7:
if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
}
return LT_FINISH;
}
static u32 LoopedTask_OpenMonMarkingsWindow(s32 state)
{
switch (state)
{
case 0:
OpenMonMarkingsMenu(TryGetMonMarkId(), 176, 32);
return LT_INC_AND_CONTINUE;
case 1:
PrintHelpBarText(HELPBAR_CONDITION_MARKINGS);
return LT_INC_AND_CONTINUE;
case 2:
if (WaitForHelpBar() == TRUE)
return LT_PAUSE;
return LT_INC_AND_CONTINUE;
}
return LT_FINISH;
}
static u32 LoopedTask_CloseMonMarkingsWindow(s32 state)
{
switch (state)
{
case 0:
FreeMonMarkingsMenu();
return LT_INC_AND_CONTINUE;
case 1:
PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS);
return LT_INC_AND_CONTINUE;
case 2:
if (WaitForHelpBar() == TRUE)
return LT_PAUSE;
return LT_INC_AND_CONTINUE;
}
return LT_FINISH;
}
static u8 *UnusedPrintNumberString(u8 *dst, u16 num)
{
u8 *txtPtr = ConvertIntToDecimalStringN(dst, num, STR_CONV_MODE_RIGHT_ALIGN, 4);
txtPtr = StringCopy(txtPtr, gText_Number2);
return txtPtr;
}
static bool32 UpdateConditionGraphMenuWindows(u8 mode, u16 bufferIndex, bool8 winMode)
{
u8 text[32];
const u8 *str;
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (mode)
{
case 0:
FillWindowPixelBuffer(menu->nameGenderWindowId, 0);
if (IsConditionMenuSearchMode() == TRUE)
FillWindowPixelBuffer(menu->listIndexWindowId, 0);
break;
case 1:
if (GetConditionGraphCurrentListIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE)
{
str = GetConditionMonNameText(bufferIndex);
AddTextPrinterParameterized(menu->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL);
}
break;
case 2:
if (IsConditionMenuSearchMode() == TRUE)
{
str = GetConditionMonLocationText(bufferIndex);
AddTextPrinterParameterized(menu->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL);
text[0] = EXT_CTRL_CODE_BEGIN;
text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
text[2] = TEXT_COLOR_BLUE;
text[3] = TEXT_COLOR_TRANSPARENT;
text[4] = TEXT_COLOR_LIGHT_BLUE;
StringCopy(&text[5], gText_Number2);
AddTextPrinterParameterized(menu->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL);
ConvertIntToDecimalStringN(&text[5], GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4);
AddTextPrinterParameterized(menu->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL);
}
break;
case 3:
switch (menu->windowModeState)
{
case 0:
if (winMode)
CopyWindowToVram(menu->nameGenderWindowId, COPYWIN_FULL);
else
CopyWindowToVram(menu->nameGenderWindowId, COPYWIN_GFX);
if (IsConditionMenuSearchMode() == TRUE)
{
menu->windowModeState++;
return FALSE;
}
else
{
menu->windowModeState = 0;
return TRUE;
}
case 1:
if (winMode)
CopyWindowToVram(menu->listIndexWindowId, COPYWIN_FULL);
else
CopyWindowToVram(menu->listIndexWindowId, COPYWIN_GFX);
menu->windowModeState = 0;
return TRUE;
}
}
return FALSE;
}
static void CopyUnusedConditionWindowsToVram(void)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
CopyWindowToVram(menu->unusedWindowId1, COPYWIN_FULL);
CopyWindowToVram(menu->unusedWindowId2, COPYWIN_FULL);
}
static void SpriteCB_PartyPokeball(struct Sprite *sprite)
{
if (sprite->data[0] == GetConditionGraphCurrentListIndex())
StartSpriteAnim(sprite, CONDITION_ICON_SELECTED);
else
StartSpriteAnim(sprite, CONDITION_ICON_UNSELECTED);
}
void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite)
{
if (GetConditionGraphCurrentListIndex() == GetMonListCount() - 1)
sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL);
else
sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL);
}
void MonMarkingsCallback(struct Sprite *sprite)
{
StartSpriteAnim(sprite, TryGetMonMarkId());
}
static void CreateMonMarkingsOrPokeballIndicators(void)
{
struct SpriteSheet sprSheets[4];
struct SpriteTemplate sprTemplate;
struct SpritePalette sprPals[3];
struct SpriteSheet sprSheet;
struct Sprite *sprite;
u16 i, spriteId;
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals);
if (IsConditionMenuSearchMode() == TRUE)
{
// Search Mode, load markings menu
menu->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU;
menu->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU;
InitMonMarkingsMenu(&menu->marksMenu);
BufferMonMarkingsMenuTiles();
sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sMonMarkings_Pal);
sprite->oam.priority = 3;
sprite->x = 192;
sprite->y = 32;
sprite->callback = MonMarkingsCallback;
menu->monMarksSprite = sprite;
PokenavFillPalette(IndexOfSpritePaletteTag(TAG_CONDITION_MON_MARKINGS), 0);
}
else
{
// Party Mode, load Pokéball selection icons
LoadSpriteSheets(sprSheets);
Pokenav_AllocAndLoadPalettes(sprPals);
// Add icons for occupied slots
for (i = 0; i < GetMonListCount() - 1; i++)
{
spriteId = CreateSprite(&sprTemplate, 226, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
menu->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].data[0] = i;
gSprites[spriteId].callback = SpriteCB_PartyPokeball;
}
else
{
menu->partyPokeballSpriteIds[i] = SPRITE_NONE;
}
}
// Add icons for empty slots
sprTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER;
sprTemplate.callback = SpriteCallbackDummy;
for (; i < PARTY_SIZE; i++)
{
spriteId = CreateSprite(&sprTemplate, 230, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
menu->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].oam.size = 0;
}
else
{
menu->partyPokeballSpriteIds[i] = SPRITE_NONE;
}
}
// Add cancel icon
sprTemplate.tileTag = TAG_CONDITION_CANCEL;
sprTemplate.callback = HighlightCurrentPartyIndexPokeball;
spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
menu->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16);
gSprites[spriteId].oam.size = SPRITE_SIZE(32x16);
}
else
{
menu->partyPokeballSpriteIds[i] = SPRITE_NONE;
}
}
LoadConditionSparkle(&sprSheet, &sprPals[0]);
LoadSpriteSheet(&sprSheet);
sprPals[1].data = NULL;
Pokenav_AllocAndLoadPalettes(sprPals);
}
static void FreeConditionMenuGfx(struct Pokenav_ConditionMenuGfx *menu)
{
u8 i;
if (IsConditionMenuSearchMode() == TRUE)
{
DestroySprite(menu->monMarksSprite);
FreeSpriteTilesByTag(TAG_CONDITION_MARKINGS_MENU);
FreeSpriteTilesByTag(TAG_CONDITION_MON_MARKINGS);
FreeSpritePaletteByTag(TAG_CONDITION_MARKINGS_MENU);
FreeSpritePaletteByTag(TAG_CONDITION_MON_MARKINGS);
}
else
{
for (i = 0; i < PARTY_SIZE + 1; i++)
DestroySprite(&gSprites[menu->partyPokeballSpriteIds[i]]);
FreeSpriteTilesByTag(TAG_CONDITION_BALL);
FreeSpriteTilesByTag(TAG_CONDITION_CANCEL);
FreeSpriteTilesByTag(TAG_CONDITION_BALL_PLACEHOLDER);
FreeSpritePaletteByTag(TAG_CONDITION_BALL);
FreeSpritePaletteByTag(TAG_CONDITION_CANCEL);
}
if (menu->monPicSpriteId != SPRITE_NONE)
{
DestroySprite(&gSprites[menu->monPicSpriteId]);
FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(TAG_CONDITION_MON);
}
}
void FreeConditionGraphMenuSubstruct2(void)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
RemoveWindow(menu->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE)
{
RemoveWindow(menu->listIndexWindowId);
RemoveWindow(menu->unusedWindowId1);
RemoveWindow(menu->unusedWindowId2);
}
else
{
SetLeftHeaderSpritesInvisibility();
}
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
FreeConditionMenuGfx(menu);
SetExitVBlank();
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
}
void MonPicGfxSpriteCallback(struct Sprite *sprite)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
sprite->x = menu->monTransitionX + 38;
}
static void CreateConditionMonPic(u8 id)
{
struct SpriteTemplate sprTemplate;
struct SpriteSheet sprSheet;
struct SpritePalette sprPal;
u8 spriteId;
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
if (menu->monPicSpriteId == SPRITE_NONE)
{
LoadConditionMonPicTemplate(&sprSheet, &sprTemplate, &sprPal);
sprSheet.data = GetConditionMonPicGfx(id);
sprPal.data = GetConditionMonPal(id);
menu->monPalIndex = LoadSpritePalette(&sprPal);
menu->monGfxTileStart = LoadSpriteSheet(&sprSheet);
spriteId = CreateSprite(&sprTemplate, 38, 104, 0);
menu->monPicSpriteId = spriteId;
if (spriteId == MAX_SPRITES)
{
FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(TAG_CONDITION_MON);
menu->monPicSpriteId = SPRITE_NONE;
}
else
{
menu->monPicSpriteId = spriteId;
gSprites[menu->monPicSpriteId].callback = MonPicGfxSpriteCallback;
menu->monGfxPtr = (void*)VRAM + BG_VRAM_SIZE + (menu->monGfxTileStart * 32);
menu->monPalIndex = (menu->monPalIndex * 16) + 0x100;
}
}
else
{
DmaCopy16Defvars(3, GetConditionMonPicGfx(id), menu->monGfxPtr, MON_PIC_SIZE);
LoadPalette(GetConditionMonPal(id), menu->monPalIndex, 0x20);
}
}
static void VBlankCB_PokenavConditionGraph(void)
{
struct ConditionGraph *graph = GetConditionGraphPtr();
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
ConditionGraph_Draw(graph);
ScanlineEffect_InitHBlankDmaTransfer();
}
static void SetExitVBlank(void)
{
SetPokenavVBlankCallback();
}
static void ToggleGraphData(bool8 showBg)
{
if (showBg)
ShowBg(2);
else
HideBg(2);
}
static void DoConditionGraphEnterTransition(void)
{
struct ConditionGraph *graph = GetConditionGraphPtr();
u8 id = GetConditionGraphMenuCurrentLoadIndex();
sInitialLoadId = id;
ConditionGraph_SetNewPositions(graph, graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1], graph->savedPositions[id]);
ConditionGraph_TryUpdate(graph);
}
// Transition the graph back to empty before exiting.
// This is skipped if the player is in party mode and the cursor
// is on Cancel, in which case the graph is already empty.
static void DoConditionGraphExitTransition(void)
{
struct ConditionGraph *graph = GetConditionGraphPtr();
if (IsConditionMenuSearchMode() || GetConditionGraphCurrentListIndex() != GetMonListCount() - 1)
ConditionGraph_SetNewPositions(graph, graph->savedPositions[GetConditionGraphMenuCurrentLoadIndex()], graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]);
}
u8 GetMonMarkingsData(void)
{
struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
if (IsConditionMenuSearchMode() == 1)
return menu->marksMenu.markings;
else
return 0;
}

View File

@ -21,50 +21,50 @@ enum
CONDITION_SEARCH_FUNC_SELECT_MON,
};
struct PokenavSub7
struct Pokenav_SearchResults
{
u32 (*callback)(struct PokenavSub7 *);
u32 (*callback)(struct Pokenav_SearchResults *);
u32 loopedTaskId;
u8 fill1[4];
s32 boxId;
s32 monId;
u32 conditionDataId;
u32 returnFromGraph;
u32 isPartyCondition;
struct PokenavSub18 *monList;
bool32 returnFromGraph;
bool32 saveResultsList;
struct PokenavMonList *monList;
};
struct PokenavSub8
struct Pokenav_SearchResultsGfx
{
bool32 (*callback)(void);
u32 ltid; //looped task Id
u32 loopedTaskId;
u16 winid;
bool32 fromGraph;
u8 buff[BG_SCREEN_SIZE];
}; // size: 0x810
static u32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr);
static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr);
static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr);
static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr);
static u32 GetConditionSearchLoopedTask(s32 state);
static u32 BuildPartyMonSearchResults(s32 state);
static u32 InitBoxMonSearchResults(s32 state);
static u32 BuildBoxMonSearchResults(s32 state);
static u32 sub_81CF278(s32 state);
static u32 LoopedTask_MoveSearchListCursorUp(s32 state);
static u32 LoopedTask_MoveSearchListCursorDown(s32 state);
static u32 LoopedTask_MoveSearchListPageUp(s32 state);
static u32 LoopedTask_MoveSearchListPageDown(s32 state);
static u32 LoopedTask_ExitConditionSearchMenu(s32 state);
static u32 LoopedTask_SelectSearchResult(s32 state);
static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item);
static u32 HandleConditionSearchInput_WaitSetup(struct Pokenav_SearchResults *);
static u32 HandleConditionSearchInput(struct Pokenav_SearchResults *);
static u32 OpenConditionGraphFromSearchList(struct Pokenav_SearchResults *);
static u32 ReturnToConditionSearchList(struct Pokenav_SearchResults *);
static u32 GetConditionSearchLoopedTask(s32);
static u32 BuildPartyMonSearchResults(s32);
static u32 InitBoxMonSearchResults(s32);
static u32 BuildBoxMonSearchResults(s32);
static u32 ConvertConditionsToListRanks(s32);
static u32 LoopedTask_MoveSearchListCursorUp(s32);
static u32 LoopedTask_MoveSearchListCursorDown(s32);
static u32 LoopedTask_MoveSearchListPageUp(s32);
static u32 LoopedTask_MoveSearchListPageDown(s32);
static u32 LoopedTask_ExitConditionSearchMenu(s32);
static u32 LoopedTask_SelectSearchResult(s32);
static void InsertMonListItem(struct Pokenav_SearchResults *, struct PokenavMonListItem *);
static bool32 GetSearchResultCurrentLoopedTaskActive(void);
static u32 LoopedTask_OpenConditionSearchResults(s32 state);
static void AddSearchResultListMenuWindow(struct PokenavSub8 *);
static void PrintSearchResultListMenuItems(struct PokenavSub8 *);
static void InitConditionSearchListMenuTemplate(void);
static void PrintSearchMonListItem(struct PokenavMonList *, u8 *);
static u32 LoopedTask_OpenConditionSearchResults(s32);
static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *);
static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *);
static void CreateSearchResultsList(void);
static void BufferSearchMonListItem(struct PokenavMonListItem *, u8 *);
static const u32 sSearchMonDataIds[] = {MON_DATA_COOL, MON_DATA_BEAUTY, MON_DATA_CUTE, MON_DATA_SMART, MON_DATA_TOUGH};
@ -73,13 +73,13 @@ static const LoopedTask sConditionSearchLoopedTaskFuncs[] =
BuildPartyMonSearchResults,
InitBoxMonSearchResults,
BuildBoxMonSearchResults,
sub_81CF278
ConvertConditionsToListRanks
};
static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition_search2.gbapal");
static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition_search2.4bpp.lz");
static const u32 sConditionSearchResultTilemap[] = INCBIN_U32("graphics/pokenav/condition_search2.bin.lz");
static const u16 gUnknown_08623570[] = INCBIN_U16("graphics/pokenav/8623570.gbapal");
static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition/search_results.gbapal");
static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition/search_results.4bpp.lz");
static const u32 sConditionSearchResultTilemap[] = INCBIN_U32("graphics/pokenav/condition/search_results.bin.lz");
static const u16 sListBg_Pal[] = INCBIN_U16("graphics/pokenav/condition/search_results_list.gbapal");
static const struct BgTemplate sConditionSearchResultBgTemplates[] =
{
@ -130,57 +130,57 @@ static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}");
bool32 PokenavCallback_Init_ConditionSearch(void)
{
struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7));
if (structPtr == NULL)
struct Pokenav_SearchResults *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct Pokenav_SearchResults));
if (menu == NULL)
return FALSE;
structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
if (structPtr->monList == NULL)
menu->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavMonList));
if (menu->monList == NULL)
return FALSE;
structPtr->callback = HandleConditionSearchInput_WaitSetup;
structPtr->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1);
structPtr->returnFromGraph = 0;
structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
menu->callback = HandleConditionSearchInput_WaitSetup;
menu->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1);
menu->returnFromGraph = FALSE;
menu->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
return TRUE;
}
// return to search results from condition graph
bool32 PokenavCallback_Init_ReturnToMonSearchList(void)
{
struct PokenavSub7 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct PokenavSub7));
if (structPtr == NULL)
struct Pokenav_SearchResults *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct Pokenav_SearchResults));
if (menu == NULL)
return FALSE;
structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
structPtr->callback = HandleConditionSearchInput;
structPtr->returnFromGraph = 1;
structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
menu->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
menu->callback = HandleConditionSearchInput;
menu->returnFromGraph = TRUE;
menu->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
return TRUE;
}
u32 GetConditionSearchResultsCallback(void)
{
struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return structPtr->callback(structPtr);
struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return menu->callback(menu);
}
void FreeSearchResultSubstruct1(void)
{
struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
if (structPtr->isPartyCondition == 0)
struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
if (!menu->saveResultsList)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
}
static bool32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr)
static bool32 HandleConditionSearchInput_WaitSetup(struct Pokenav_SearchResults *menu)
{
if (!IsLoopedTaskActive(structPtr->loopedTaskId))
structPtr->callback = HandleConditionSearchInput;
if (!IsLoopedTaskActive(menu->loopedTaskId))
menu->callback = HandleConditionSearchInput;
return FALSE;
}
static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr)
static u32 HandleConditionSearchInput(struct Pokenav_SearchResults *menu)
{
if (JOY_REPEAT(DPAD_UP))
return CONDITION_SEARCH_FUNC_MOVE_UP;
@ -192,60 +192,63 @@ static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr)
return CONDITION_SEARCH_FUNC_PAGE_DOWN;
else if (JOY_NEW(B_BUTTON))
{
structPtr->isPartyCondition = 0;
structPtr->callback = ReturnToConditionSearchList;
// Exiting back to main search menu
menu->saveResultsList = FALSE;
menu->callback = ReturnToConditionSearchList;
return CONDITION_SEARCH_FUNC_EXIT;
}
else if (JOY_NEW(A_BUTTON))
{
structPtr->monList->currIndex = GetSelectedPokenavListIndex();
structPtr->isPartyCondition = 1;
structPtr->callback = OpenConditionGraphFromSearchList;
// Entering graph menu
menu->monList->currIndex = PokenavList_GetSelectedIndex();
menu->saveResultsList = TRUE;
menu->callback = OpenConditionGraphFromSearchList;
return CONDITION_SEARCH_FUNC_SELECT_MON;
}
else
return CONDITION_SEARCH_FUNC_NONE;
}
static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr)
static u32 ReturnToConditionSearchList(struct Pokenav_SearchResults *menu)
{
return POKENAV_CONDITION_SEARCH_MENU;
}
static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr)
static u32 OpenConditionGraphFromSearchList(struct Pokenav_SearchResults *menu)
{
return POKENAV_CONDITION_GRAPH_FROM_SEARCH;
return POKENAV_CONDITION_GRAPH_SEARCH;
}
static u32 sub_81CF0C0(void)
static u32 GetReturningFromGraph(void)
{
struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return structPtr->returnFromGraph;
struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return menu->returnFromGraph;
}
static struct PokenavMonList * GetSearchResultsMonDataList(void)
static struct PokenavMonListItem * GetSearchResultsMonDataList(void)
{
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->monList->monData;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return menu->monList->monData;
}
static u16 GetSearchResultsMonListCount(void)
{
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->monList->listCount;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return menu->monList->listCount;
}
static s32 GetSearchResultsSelectedMonData(void)
// data below has been set by ConvertConditionsToListRanks
static s32 GetSearchResultsSelectedMonRank(void)
{
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 i = GetSelectedPokenavListIndex();
return ptr->monList->monData[i].data;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 i = PokenavList_GetSelectedIndex();
return menu->monList->monData[i].data;
}
static u16 sub_81CF10C(void)
static u16 GetSearchResultsCurrentListIndex(void)
{
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->monList->currIndex;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return menu->monList->currIndex;
}
static u32 GetConditionSearchLoopedTask(s32 state)
@ -256,12 +259,12 @@ static u32 GetConditionSearchLoopedTask(s32 state)
static u32 BuildPartyMonSearchResults(s32 state)
{
s32 i;
struct PokenavMonList item;
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
struct PokenavMonListItem item;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
ptr->monList->listCount = 0;
ptr->monList->currIndex = 0;
item.boxId = 14;
menu->monList->listCount = 0;
menu->monList->currIndex = 0;
item.boxId = TOTAL_BOXES_COUNT;
for (i = 0; i < PARTY_SIZE; i++)
{
struct Pokemon * pokemon = &gPlayerParty[i];
@ -270,8 +273,8 @@ static u32 BuildPartyMonSearchResults(s32 state)
if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG))
{
item.monId = i;
item.data = GetMonData(pokemon, ptr->conditionDataId);
sub_81CF2C4(ptr, &item);
item.data = GetMonData(pokemon, menu->conditionDataId);
InsertMonListItem(menu, &item);
}
}
@ -280,19 +283,19 @@ static u32 BuildPartyMonSearchResults(s32 state)
static u32 InitBoxMonSearchResults(s32 state)
{
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
ptr->monId = 0;
ptr->boxId = 0;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
menu->monId = 0;
menu->boxId = 0;
return LT_INC_AND_CONTINUE;
}
static u32 BuildBoxMonSearchResults(s32 state)
{
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 boxId = ptr->boxId;
s32 monId = ptr->monId;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 boxId = menu->boxId;
s32 monId = menu->monId;
s32 boxCount = 0;
struct PokenavMonList item;
struct PokenavMonListItem item;
while (boxId < TOTAL_BOXES_COUNT)
{
@ -302,15 +305,15 @@ static u32 BuildBoxMonSearchResults(s32 state)
{
item.boxId = boxId;
item.monId = monId;
item.data = GetBoxMonDataAt(boxId, monId, ptr->conditionDataId);
sub_81CF2C4(ptr, &item);
item.data = GetBoxMonDataAt(boxId, monId, menu->conditionDataId);
InsertMonListItem(menu, &item);
}
boxCount++;
monId++;
if (boxCount > 14)
if (boxCount > TOTAL_BOXES_COUNT)
{
ptr->boxId = boxId;
ptr->monId = monId;
menu->boxId = boxId;
menu->monId = monId;
return LT_CONTINUE;
}
}
@ -321,107 +324,111 @@ static u32 BuildBoxMonSearchResults(s32 state)
return LT_INC_AND_CONTINUE;
}
static u32 sub_81CF278(s32 state)
// Data below is initially set by BuildPartyMonSearchResults / BuildBoxMonSearchResults, and
// is the Pokémon's condition value for the condition they are sorted by.
// The condition value in data is then overwritten with their ranking.
static u32 ConvertConditionsToListRanks(s32 state)
{
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 r6 = ptr->monList->listCount;
s32 r4 = ptr->monList->monData[0].data;
struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 listCount = menu->monList->listCount;
s32 prevCondition = menu->monList->monData[0].data;
s32 i;
ptr->monList->monData[0].data = 1;
for (i = 1; i < r6; i++)
menu->monList->monData[0].data = 1;
for (i = 1; i < listCount; i++)
{
if (ptr->monList->monData[i].data == r4)
if (menu->monList->monData[i].data == prevCondition)
{
ptr->monList->monData[i].data = ptr->monList->monData[i - 1].data;
// Same condition value as prev, share rank
menu->monList->monData[i].data = menu->monList->monData[i - 1].data;
}
else
{
r4 = ptr->monList->monData[i].data;
ptr->monList->monData[i].data = i + 1;
prevCondition = menu->monList->monData[i].data;
menu->monList->monData[i].data = i + 1;
}
}
ptr->returnFromGraph = 1;
menu->returnFromGraph = TRUE;
return LT_FINISH;
}
static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item)
static void InsertMonListItem(struct Pokenav_SearchResults *menu, struct PokenavMonListItem *item)
{
u32 left = 0;
u32 right = structPtr->monList->listCount;
u32 right = menu->monList->listCount;
u32 insertionIdx = left + (right - left) / 2;
while (right != insertionIdx)
{
if (item->data > structPtr->monList->monData[insertionIdx].data)
if (item->data > menu->monList->monData[insertionIdx].data)
right = insertionIdx;
else
left = insertionIdx + 1;
insertionIdx = left + (right - left) / 2;
}
for (right = structPtr->monList->listCount; right > insertionIdx; right--)
structPtr->monList->monData[right] = structPtr->monList->monData[right - 1];
structPtr->monList->monData[insertionIdx] = *item;
structPtr->monList->listCount++;
for (right = menu->monList->listCount; right > insertionIdx; right--)
menu->monList->monData[right] = menu->monList->monData[right - 1];
menu->monList->monData[insertionIdx] = *item;
menu->monList->listCount++;
}
bool32 OpenConditionSearchResults(void)
{
struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8));
if (searchList == NULL)
struct Pokenav_SearchResultsGfx *gfx = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX, sizeof(struct Pokenav_SearchResultsGfx));
if (gfx == NULL)
return FALSE;
searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
searchList->callback = GetSearchResultCurrentLoopedTaskActive;
searchList->fromGraph = FALSE;
gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
gfx->callback = GetSearchResultCurrentLoopedTaskActive;
gfx->fromGraph = FALSE;
return TRUE;
}
bool32 OpenConditionSearchListFromGraph(void)
{
struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8));
if (searchList == NULL)
struct Pokenav_SearchResultsGfx *gfx = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX, sizeof(struct Pokenav_SearchResultsGfx));
if (gfx == NULL)
return FALSE;
searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
searchList->callback = GetSearchResultCurrentLoopedTaskActive;
searchList->fromGraph = TRUE;
gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
gfx->callback = GetSearchResultCurrentLoopedTaskActive;
gfx->fromGraph = TRUE;
return TRUE;
}
void CreateSearchResultsLoopedTask(s32 idx)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
searchList->ltid = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1);
searchList->callback = GetSearchResultCurrentLoopedTaskActive;
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
gfx->loopedTaskId = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1);
gfx->callback = GetSearchResultCurrentLoopedTaskActive;
}
bool32 IsSearchResultLoopedTaskActive(void)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
return searchList->callback();
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
return gfx->callback();
}
bool32 GetSearchResultCurrentLoopedTaskActive(void)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
return IsLoopedTaskActive(searchList->ltid);
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
return IsLoopedTaskActive(gfx->loopedTaskId);
}
void FreeSearchResultSubstruct2(void)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
sub_81C8234();
RemoveWindow(searchList->winid);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
DestroyPokenavList();
RemoveWindow(gfx->winid);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
}
static u32 LoopedTask_OpenConditionSearchResults(s32 state)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state)
{
case 0:
InitBgTemplates(sConditionSearchResultBgTemplates, ARRAY_COUNT(sConditionSearchResultBgTemplates));
DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0);
SetBgTilemapBuffer(1, searchList->buff);
SetBgTilemapBuffer(1, gfx->buff);
CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
CopyPaletteIntoBufferUnfaded(sConditionSearchResultFramePal, 0x10, 0x20);
@ -430,19 +437,19 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state)
case 1:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
if (!sub_81CF0C0())
if (!GetReturningFromGraph())
return LT_PAUSE;
return LT_INC_AND_PAUSE;
case 2:
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 32);
InitConditionSearchListMenuTemplate();
CopyPaletteIntoBufferUnfaded(sListBg_Pal, 0x20, 32);
CreateSearchResultsList();
return LT_INC_AND_PAUSE;
case 3:
if (sub_81C8224())
if (IsCreatePokenavListTaskActive())
return LT_PAUSE;
AddSearchResultListMenuWindow(searchList);
AddSearchResultListMenuWindow(gfx);
PrintHelpBarText(HELPBAR_CONDITION_MON_LIST);
return LT_INC_AND_PAUSE;
case 4:
@ -453,14 +460,14 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state)
ShowBg(1);
ShowBg(2);
HideBg(3);
if (!searchList->fromGraph)
if (!gfx->fromGraph)
{
u8 searchGfxId = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL;
LoadLeftHeaderGfxForIndex(searchGfxId);
ShowLeftHeaderGfx(searchGfxId, 1, 0);
ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, 1, 0);
}
PokenavFadeScreen(1);
PokenavFadeScreen(POKENAV_FADE_FROM_BLACK);
return LT_INC_AND_PAUSE;
case 5:
if (IsPaletteFadeActive())
@ -474,11 +481,11 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state)
static u32 LoopedTask_MoveSearchListCursorUp(s32 state)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state)
{
case 0:
switch (MatchCall_MoveCursorUp())
switch (PokenavList_MoveCursorUp())
{
case 0:
return LT_FINISH;
@ -491,11 +498,11 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
PrintSearchResultListMenuItems(searchList);
PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -507,11 +514,11 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state)
static u32 LoopedTask_MoveSearchListCursorDown(s32 state)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state)
{
case 0:
switch (MatchCall_MoveCursorDown())
switch (PokenavList_MoveCursorDown())
{
case 0:
return LT_FINISH;
@ -524,11 +531,11 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
PrintSearchResultListMenuItems(searchList);
PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -540,11 +547,11 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state)
static u32 LoopedTask_MoveSearchListPageUp(s32 state)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state)
{
case 0:
switch (MatchCall_PageUp())
switch (PokenavList_PageUp())
{
case 0:
return LT_FINISH;
@ -557,11 +564,11 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
PrintSearchResultListMenuItems(searchList);
PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -573,11 +580,11 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state)
static u32 LoopedTask_MoveSearchListPageDown(s32 state)
{
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state)
{
case 0:
switch (MatchCall_PageDown())
switch (PokenavList_PageDown())
{
case 0:
return LT_FINISH;
@ -590,11 +597,11 @@ static u32 LoopedTask_MoveSearchListPageDown(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
PrintSearchResultListMenuItems(searchList);
PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -610,7 +617,7 @@ static u32 LoopedTask_ExitConditionSearchMenu(s32 state)
{
case 0:
PlaySE(SE_SELECT);
PokenavFadeScreen(0);
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
SlideMenuHeaderDown();
return LT_INC_AND_PAUSE;
case 1:
@ -630,7 +637,7 @@ static u32 LoopedTask_SelectSearchResult(s32 state)
{
case 0:
PlaySE(SE_SELECT);
PokenavFadeScreen(0);
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
return LT_INC_AND_PAUSE;
case 1:
if (IsPaletteFadeActive())
@ -640,47 +647,47 @@ static u32 LoopedTask_SelectSearchResult(s32 state)
return LT_FINISH;
}
static void AddSearchResultListMenuWindow(struct PokenavSub8 *searchList)
static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *gfx)
{
searchList->winid = AddWindow(&sSearchResultListMenuWindowTemplate);
PutWindowTilemap(searchList->winid);
CopyWindowToVram(searchList->winid, COPYWIN_MAP);
PrintSearchResultListMenuItems(searchList);
gfx->winid = AddWindow(&sSearchResultListMenuWindowTemplate);
PutWindowTilemap(gfx->winid);
CopyWindowToVram(gfx->winid, COPYWIN_MAP);
PrintSearchResultListMenuItems(gfx);
}
static void PrintSearchResultListMenuItems(struct PokenavSub8 *searchList)
static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *gfx)
{
s32 r7 = GetSearchResultsSelectedMonData();
s32 rank = GetSearchResultsSelectedMonRank();
DynamicPlaceholderTextUtil_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
*gStringVar1 = EOS;
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberF700);
AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar2, 4, 1, TEXT_SKIP_DRAW, NULL);
ConvertIntToDecimalStringN(gStringVar1, r7, STR_CONV_MODE_RIGHT_ALIGN, 3);
AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar1, 34, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(searchList->winid, COPYWIN_GFX);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberIndex);
AddTextPrinterParameterized(gfx->winid, FONT_NORMAL, gStringVar2, 4, 1, TEXT_SKIP_DRAW, NULL);
ConvertIntToDecimalStringN(gStringVar1, rank, STR_CONV_MODE_RIGHT_ALIGN, 3);
AddTextPrinterParameterized(gfx->winid, FONT_NORMAL, gStringVar1, 34, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(gfx->winid, COPYWIN_GFX);
}
static void InitConditionSearchListMenuTemplate(void)
static void CreateSearchResultsList(void)
{
struct PokenavListTemplate template;
template.list.monList = GetSearchResultsMonDataList();
template.list = (struct PokenavListItem *)GetSearchResultsMonDataList();
template.count = GetSearchResultsMonListCount();
template.unk8 = 4;
template.unk6 = sub_81CF10C();
template.itemSize = sizeof(struct PokenavListItem);
template.startIndex = GetSearchResultsCurrentListIndex();
template.item_X = 13;
template.windowWidth = 17;
template.listTop = 1;
template.maxShowed = 8;
template.fillValue = 2;
template.fontId = FONT_NORMAL;
template.listFunc.printMonFunc = PrintSearchMonListItem;
template.unk14 = NULL;
sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0);
template.bufferItemFunc = (PokenavListBufferItemFunc)BufferSearchMonListItem;
template.iconDrawFunc = NULL;
CreatePokenavList(&sConditionSearchResultBgTemplates[1], &template, 0);
}
static void PrintSearchMonListItem(struct PokenavMonList * item, u8 * dest)
static void BufferSearchMonListItem(struct PokenavMonListItem * item, u8 * dest)
{
u8 gender;
u8 level;

1011
src/pokenav_list.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
#include "menu.h"
#include "dma3.h"
struct PokenavMainMenuResources
struct Pokenav_MainMenu
{
void (*loopTask)(u32);
u32 (*isLoopTaskActiveFunc)(void);
@ -24,7 +24,7 @@ struct PokenavMainMenuResources
struct Sprite *spinningPokenav;
struct Sprite *leftHeaderSprites[2];
struct Sprite *submenuLeftHeaderSprites[2];
u8 tilemapBuffer[0x800];
u8 tilemapBuffer[BG_SCREEN_SIZE];
};
// This struct uses a 32bit tag, and doesn't have a size field.
@ -36,26 +36,26 @@ struct CompressedSpriteSheetNoSize
};
static void CleanupPokenavMainMenuResources(void);
static void LoadLeftHeaderGfxForSubMenu(u32 arg0);
static void LoadLeftHeaderGfxForMenu(u32 index);
static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide);
static void HideLeftHeaderSprites(bool32 isOnRightSide);
static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide);
static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide);
static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration);
static void SpriteCB_MoveLeftHeader(struct Sprite *sprite);
static void LoadLeftHeaderGfxForSubMenu(u32);
static void LoadLeftHeaderGfxForMenu(u32);
static void HideLeftHeaderSubmenuSprites(bool32);
static void HideLeftHeaderSprites(bool32);
static void ShowLeftHeaderSprites(u32, bool32);
static void ShowLeftHeaderSubmenuSprites(u32, bool32);
static void MoveLeftHeader(struct Sprite *, s32, s32, s32);
static void SpriteCB_MoveLeftHeader(struct Sprite *);
static void InitPokenavMainMenuResources(void);
static void InitHoennMapHeaderSprites(void);
static void CreateLeftHeaderSprites(void);
static void InitHelpBar(void);
static u32 LoopedTask_SlideMenuHeaderUp(s32 a0);
static u32 LoopedTask_SlideMenuHeaderDown(s32 a0);
static void DrawHelpBar(u32 windowId);
static void SpriteCB_SpinningPokenav(struct Sprite* sprite);
static u32 LoopedTask_InitPokenavMenu(s32 a0);
static u32 LoopedTask_SlideMenuHeaderUp(s32);
static u32 LoopedTask_SlideMenuHeaderDown(s32);
static void DrawHelpBar(u32);
static void SpriteCB_SpinningPokenav(struct Sprite*);
static u32 LoopedTask_InitPokenavMenu(s32);
const u16 gSpinningPokenavPaletteData[] = INCBIN_U16("graphics/pokenav/icon2.gbapal");
const u32 gSpinningPokenavGfx[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz");
const u32 gUnused_SpinningPokenavGfx2[] = INCBIN_U32("graphics/pokenav/icon2_unused.4bpp.lz");
static const u16 sSpinningPokenav_Pal[] = INCBIN_U16("graphics/pokenav/nav_icon.gbapal");
static const u32 sSpinningPokenav_Gfx[] = INCBIN_U32("graphics/pokenav/nav_icon.4bpp.lz");
static const u32 sBlueLightCopy[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); // Unused copy of sMatchCallBlueLightTiles
const struct BgTemplate gPokenavMainMenuBgTemplates[] =
{
@ -108,7 +108,7 @@ static const u8 sHelpBarTextColors[3] =
static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] =
{
{
.data = gSpinningPokenavGfx,
.data = sSpinningPokenav_Gfx,
.size = 0x1000,
.tag = 0,
}
@ -117,20 +117,20 @@ static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] =
static const struct SpritePalette gSpinningNavgearPalettes[] =
{
{
.data = gSpinningPokenavPaletteData,
.data = sSpinningPokenav_Pal,
.tag = 0,
},
{}
};
static const struct CompressedSpriteSheet sPokenavHoennMapLeftHeaderSpriteSheet =
static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheet =
{
.data = gPokenavLeftHeaderHoennMap_Gfx,
.data = gPokenavLeftHeaderHoennMap_Gfx, // Hoenn map is the first of the headers listed
.size = 0xC00,
.tag = 2
};
static const struct CompressedSpriteSheet sPokenavMenuLeftHeaderSpriteSheets[] =
static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheets[] =
{
[POKENAV_GFX_MAIN_MENU] = {
.data = gPokenavLeftHeaderMainMenu_Gfx,
@ -239,7 +239,7 @@ static const struct SpriteTemplate sSpinningPokenavSpriteTemplate =
.callback = SpriteCB_SpinningPokenav
};
static const struct OamData sPokenavLeftHeaderHoennMapSpriteOam =
static const struct OamData sOamData_LeftHeader =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@ -253,7 +253,7 @@ static const struct OamData sPokenavLeftHeaderHoennMapSpriteOam =
.paletteNum = 0,
};
static const struct OamData sUnknown_0861FB24 =
static const struct OamData sOamData_SubmenuLeftHeader =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@ -268,22 +268,22 @@ static const struct OamData sUnknown_0861FB24 =
.paletteNum = 0,
};
static const struct SpriteTemplate sPokenavLeftHeaderHoennMapSpriteTemplate =
static const struct SpriteTemplate sLeftHeaderSpriteTemplate =
{
.tileTag = 2,
.paletteTag = 1,
.oam = &sPokenavLeftHeaderHoennMapSpriteOam,
.oam = &sOamData_LeftHeader,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sUnknown_0861FB44 =
static const struct SpriteTemplate sSubmenuLeftHeaderSpriteTemplate =
{
.tileTag = 2,
.paletteTag = 2,
.oam = &sUnknown_0861FB24,
.oam = &sOamData_SubmenuLeftHeader,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
@ -292,22 +292,22 @@ static const struct SpriteTemplate sUnknown_0861FB44 =
bool32 InitPokenavMainMenu(void)
{
struct PokenavMainMenuResources *structPtr;
struct Pokenav_MainMenu *menu;
structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct PokenavMainMenuResources));
if (structPtr == NULL)
menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct Pokenav_MainMenu));
if (menu == NULL)
return FALSE;
ResetSpriteData();
FreeAllSpritePalettes();
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1);
menu->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1);
return TRUE;
}
u32 PokenavMainMenuLoopedTaskIsActive(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return IsLoopedTaskActive(structPtr->currentTaskId);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return IsLoopedTaskActive(menu->currentTaskId);
}
void ShutdownPokenav(void)
@ -330,11 +330,11 @@ bool32 WaitForPokenavShutdownFade(void)
return TRUE;
}
static u32 LoopedTask_InitPokenavMenu(s32 a0)
static u32 LoopedTask_InitPokenavMenu(s32 state)
{
struct PokenavMainMenuResources *structPtr;
struct Pokenav_MainMenu *menu;
switch (a0)
switch (state)
{
case 0:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
@ -345,9 +345,9 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0)
ResetTempTileDataBuffers();
return LT_INC_AND_CONTINUE;
case 1:
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0);
SetBgTilemapBuffer(0, structPtr->tilemapBuffer);
SetBgTilemapBuffer(0, menu->tilemapBuffer);
CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0);
CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, 0, 0x20);
CopyBgTilemapBufferToVram(0);
@ -363,7 +363,7 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0)
return LT_PAUSE;
InitPokenavMainMenuResources();
InitHoennMapHeaderSprites();
CreateLeftHeaderSprites();
ShowBg(0);
return LT_FINISH;
default:
@ -373,46 +373,46 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0)
void SetActiveMenuLoopTasks(void *createLoopTask, void *isLoopTaskActive) // Fix types later.
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->loopTask = createLoopTask;
structPtr->isLoopTaskActiveFunc = isLoopTaskActive;
structPtr->unused = 0;
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
menu->loopTask = createLoopTask;
menu->isLoopTaskActiveFunc = isLoopTaskActive;
menu->unused = 0;
}
void RunMainMenuLoopedTask(u32 a0)
void RunMainMenuLoopedTask(u32 state)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->unused = 0;
structPtr->loopTask(a0);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
menu->unused = 0;
menu->loopTask(state);
}
u32 IsActiveMenuLoopTaskActive(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return structPtr->isLoopTaskActiveFunc();
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return menu->isLoopTaskActiveFunc();
}
void SlideMenuHeaderUp(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4);
}
void SlideMenuHeaderDown(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4);
}
bool32 MainMenuLoopedTaskIsBusy(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return IsLoopedTaskActive(structPtr->currentTaskId);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return IsLoopedTaskActive(menu->currentTaskId);
}
static u32 LoopedTask_SlideMenuHeaderUp(s32 a0)
static u32 LoopedTask_SlideMenuHeaderUp(s32 state)
{
switch (a0)
switch (state)
{
default:
return LT_FINISH;
@ -431,7 +431,7 @@ static u32 LoopedTask_SlideMenuHeaderUp(s32 a0)
}
}
static u32 LoopedTask_SlideMenuHeaderDown(s32 a0)
static u32 LoopedTask_SlideMenuHeaderDown(s32 state)
{
if (ChangeBgY(0, 384, BG_COORD_SUB) <= 0)
{
@ -473,7 +473,6 @@ void PokenavFillPalette(u32 palIndex, u16 fillValue)
void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a4, u16 *palette)
{
if (a4 == 0)
{
CpuCopy16(src, palette, size * 2);
@ -496,11 +495,11 @@ void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a
g1 = ((((GET_G(*dest) << 8) - (g << 8)) / a3) * a4) >> 8;
b1 = ((((GET_B(*dest) << 8) - (b << 8)) / a3) * a4) >> 8;
r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of ((r + r1) & 0x1F) to r
g = (g + g1) & 0x1F; //See above
b = (b + b1) & 0x1F; //See above
r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match
g = (g + g1) & 0x1F;
b = (b + b1) & 0x1F;
*palette = RGB2(r, g, b); //See above comment
*palette = RGB2(r, g, b);
src++, dest++;
palette++;
@ -510,20 +509,20 @@ void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a
void PokenavFadeScreen(s32 fadeType)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
switch (fadeType)
{
case 0:
BeginNormalPaletteFade(structPtr->palettes, -2, 0, 16, RGB_BLACK);
case POKENAV_FADE_TO_BLACK:
BeginNormalPaletteFade(menu->palettes, -2, 0, 16, RGB_BLACK);
break;
case 1:
BeginNormalPaletteFade(structPtr->palettes, -2, 16, 0, RGB_BLACK);
case POKENAV_FADE_FROM_BLACK:
BeginNormalPaletteFade(menu->palettes, -2, 16, 0, RGB_BLACK);
break;
case 2:
case POKENAV_FADE_TO_BLACK_ALL:
BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK);
break;
case 3:
case POKENAV_FADE_FROM_BLACK_ALL:
BeginNormalPaletteFade(PALETTES_ALL, -2, 16, 0, RGB_BLACK);
break;
}
@ -534,9 +533,10 @@ bool32 IsPaletteFadeActive(void)
return gPaletteFade.active;
}
void sub_81C7B40(void)
// Excludes the first obj and bg palettes
void FadeToBlackExceptPrimary(void)
{
BlendPalettes(PALETTES_ALL & ~(0x10000 | 0x1), 16, RGB_BLACK);
BlendPalettes(PALETTES_ALL & ~(1 << 16 | 1), 16, RGB_BLACK);
}
void InitBgTemplates(const struct BgTemplate *templates, int count)
@ -549,21 +549,21 @@ void InitBgTemplates(const struct BgTemplate *templates, int count)
static void InitHelpBar(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
InitWindows(&sHelpBarWindowTemplate[0]);
structPtr->helpBarWindowId = 0;
DrawHelpBar(structPtr->helpBarWindowId);
PutWindowTilemap(structPtr->helpBarWindowId);
CopyWindowToVram(structPtr->helpBarWindowId, COPYWIN_FULL);
menu->helpBarWindowId = 0;
DrawHelpBar(menu->helpBarWindowId);
PutWindowTilemap(menu->helpBarWindowId);
CopyWindowToVram(menu->helpBarWindowId, COPYWIN_FULL);
}
void PrintHelpBarText(u32 textId)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
DrawHelpBar(structPtr->helpBarWindowId);
AddTextPrinterParameterized3(structPtr->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]);
DrawHelpBar(menu->helpBarWindowId);
AddTextPrinterParameterized3(menu->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]);
}
bool32 WaitForHelpBar(void)
@ -581,22 +581,22 @@ static void InitPokenavMainMenuResources(void)
{
s32 i;
u8 spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++)
LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]);
Pokenav_AllocAndLoadPalettes(gSpinningNavgearPalettes);
structPtr->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0));
menu->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0));
spriteId = CreateSprite(&sSpinningPokenavSpriteTemplate, 220, 12, 0);
structPtr->spinningPokenav = &gSprites[spriteId];
menu->spinningPokenav = &gSprites[spriteId];
}
static void CleanupPokenavMainMenuResources(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
DestroySprite(structPtr->spinningPokenav);
DestroySprite(menu->spinningPokenav);
FreeSpriteTilesByTag(0);
FreeSpritePaletteByTag(0);
}
@ -607,47 +607,50 @@ static void SpriteCB_SpinningPokenav(struct Sprite *sprite)
sprite->y2 = (GetBgY(0) / 256u) * -1;
}
struct Sprite *PauseSpinningPokenavSprite(void)
struct Sprite *GetSpinningPokenavSprite(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->spinningPokenav->callback = SpriteCallbackDummy;
return structPtr->spinningPokenav;
menu->spinningPokenav->callback = SpriteCallbackDummy;
return menu->spinningPokenav;
}
void ResumeSpinningPokenavSprite(void)
void HideSpinningPokenavSprite(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->spinningPokenav->x = 220;
structPtr->spinningPokenav->y = 12;
structPtr->spinningPokenav->callback = SpriteCB_SpinningPokenav;
structPtr->spinningPokenav->invisible = FALSE;
structPtr->spinningPokenav->oam.priority = 0;
structPtr->spinningPokenav->subpriority = 0;
// Move sprite so it's no longer visible
menu->spinningPokenav->x = 220;
menu->spinningPokenav->y = 12;
menu->spinningPokenav->callback = SpriteCB_SpinningPokenav;
menu->spinningPokenav->invisible = FALSE;
menu->spinningPokenav->oam.priority = 0;
menu->spinningPokenav->subpriority = 0;
}
static void InitHoennMapHeaderSprites(void)
static void CreateLeftHeaderSprites(void)
{
s32 i, spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet);
LoadCompressedSpriteSheet(&sMenuLeftHeaderSpriteSheet);
AllocSpritePalette(1);
AllocSpritePalette(2);
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
{
spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1);
structPtr->leftHeaderSprites[i] = &gSprites[spriteId];
structPtr->leftHeaderSprites[i]->invisible = TRUE;
structPtr->leftHeaderSprites[i]->x2 = i * 64;
// Create main left header
spriteId = CreateSprite(&sLeftHeaderSpriteTemplate, 0, 0, 1);
menu->leftHeaderSprites[i] = &gSprites[spriteId];
menu->leftHeaderSprites[i]->invisible = TRUE;
menu->leftHeaderSprites[i]->x2 = i * 64;
spriteId = CreateSprite(&sUnknown_0861FB44, 0, 0, 2);
structPtr->submenuLeftHeaderSprites[i] = &gSprites[spriteId];
structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE;
structPtr->submenuLeftHeaderSprites[i]->x2 = i * 32;
structPtr->submenuLeftHeaderSprites[i]->y2 = 18;
structPtr->submenuLeftHeaderSprites[i]->oam.tileNum += (i * 8) + 64;
// Create submenu left header
spriteId = CreateSprite(&sSubmenuLeftHeaderSpriteTemplate, 0, 0, 2);
menu->submenuLeftHeaderSprites[i] = &gSprites[spriteId];
menu->submenuLeftHeaderSprites[i]->invisible = TRUE;
menu->submenuLeftHeaderSprites[i]->x2 = i * 32;
menu->submenuLeftHeaderSprites[i]->y2 = 18;
menu->submenuLeftHeaderSprites[i]->oam.tileNum += (i * 8) + 64;
}
}
@ -661,34 +664,34 @@ void LoadLeftHeaderGfxForIndex(u32 menuGfxId)
void UpdateRegionMapRightHeaderTiles(u32 menuGfxId)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT)
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32;
menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32;
else
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64;
menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64;
}
static void LoadLeftHeaderGfxForMenu(u32 menuGfxId)
{
struct PokenavMainMenuResources *structPtr;
struct Pokenav_MainMenu *menu;
u32 size, tag;
if (menuGfxId >= POKENAV_GFX_SUBMENUS_START)
return;
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag;
size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data);
menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
tag = sMenuLeftHeaderSpriteSheets[menuGfxId].tag;
size = GetDecompressedDataSize(sMenuLeftHeaderSpriteSheets[menuGfxId].data);
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20);
LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer);
LZ77UnCompWram(sMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer);
RequestDma3Copy(gDecompressionBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1);
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].size;
menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sMenuLeftHeaderSpriteSheets[menuGfxId].size;
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN)
structPtr->leftHeaderSprites[1]->x2 = 56;
menu->leftHeaderSprites[1]->x2 = 56;
else
structPtr->leftHeaderSprites[1]->x2 = 64;
menu->leftHeaderSprites[1]->x2 = 64;
}
static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId)
@ -731,20 +734,20 @@ void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide)
void SetLeftHeaderSpritesInvisibility(void)
{
s32 i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
{
structPtr->leftHeaderSprites[i]->invisible = TRUE;
structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE;
menu->leftHeaderSprites[i]->invisible = TRUE;
menu->submenuLeftHeaderSprites[i]->invisible = TRUE;
}
}
bool32 AreLeftHeaderSpritesMoving(void)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (structPtr->leftHeaderSprites[0]->callback == SpriteCallbackDummy && structPtr->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy)
if (menu->leftHeaderSprites[0]->callback == SpriteCallbackDummy && menu->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy)
return FALSE;
else
return TRUE;
@ -753,66 +756,66 @@ bool32 AreLeftHeaderSpritesMoving(void)
static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
{
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide)
start = -96, end = 32;
else
start = 256, end = 160;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
{
structPtr->leftHeaderSprites[i]->y = startY;
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
menu->leftHeaderSprites[i]->y = startY;
MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12);
}
}
static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
{
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide)
start = -96, end = 16;
else
start = 256, end = 192;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++)
{
structPtr->submenuLeftHeaderSprites[i]->y = startY;
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
menu->submenuLeftHeaderSprites[i]->y = startY;
MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12);
}
}
static void HideLeftHeaderSprites(bool32 isOnRightSide)
{
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide)
start = 32, end = -96;
else
start = 192, end = 256;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
{
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12);
}
}
static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
{
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide)
start = 16, end = -96;
else
start = 192, end = 256;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++)
{
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12);
}
}

File diff suppressed because it is too large Load Diff

1301
src/pokenav_match_call_gfx.c Executable file

File diff suppressed because it is too large Load Diff

View File

@ -14,27 +14,27 @@
#include "strings.h"
#include "constants/songs.h"
struct Pokenav3Struct
struct Pokenav_MatchCallMenu
{
u16 optionCursorPos;
u16 maxOptionId;
const u8 *matchCallOptions;
u16 headerId;
u16 numRegistered;
u16 unkC;
u32 unk10;
u32 unk14;
u32 (*callback)(struct Pokenav3Struct*);
struct PokenavMatchCallEntries matchCallEntries[MAX_REMATCH_ENTRIES - 1];
u16 numSpecialTrainers;
bool32 initFinished;
u32 loopedTaskId;
u32 (*callback)(struct Pokenav_MatchCallMenu*);
struct PokenavMatchCallEntry matchCallEntries[MAX_REMATCH_ENTRIES - 1];
};
static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *);
static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *);
static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *);
static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *);
static u32 CB2_HandleCallInput(struct Pokenav3Struct *);
static u32 sub_81CAD20(s32);
static bool32 sub_81CB1D0(void);
static u32 CB2_HandleMatchCallInput(struct Pokenav_MatchCallMenu *);
static u32 GetExitMatchCallMenuId(struct Pokenav_MatchCallMenu *);
static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav_MatchCallMenu *);
static u32 CB2_HandleCheckPageInput(struct Pokenav_MatchCallMenu *);
static u32 CB2_HandleCallExitInput(struct Pokenav_MatchCallMenu *);
static u32 LoopedTask_BuildMatchCallList(s32);
static bool32 ShouldDoNearbyMessage(void);
#include "data/text/match_call_messages.h"
@ -53,20 +53,20 @@ static const u8 sMatchCallOptionsHasCheckPage[] =
bool32 PokenavCallback_Init_MatchCall(void)
{
struct Pokenav3Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav3Struct));
struct Pokenav_MatchCallMenu *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav_MatchCallMenu));
if (!state)
return FALSE;
state->callback = CB2_HandleMatchCallInput;
state->headerId = 0;
state->unk10 = 0;
state->unk14 = CreateLoopedTask(sub_81CAD20, 1);
state->initFinished = FALSE;
state->loopedTaskId = CreateLoopedTask(LoopedTask_BuildMatchCallList, 1);
return TRUE;
}
u32 GetMatchCallCallback(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->callback(state);
}
@ -75,7 +75,7 @@ void FreeMatchCallSubstruct1(void)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
}
static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
static u32 CB2_HandleMatchCallInput(struct Pokenav_MatchCallMenu *state)
{
int selection;
@ -92,7 +92,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
{
state->callback = CB2_HandleMatchCallOptionsInput;
state->optionCursorPos = 0;
selection = GetSelectedPokenavListIndex();
selection = PokenavList_GetSelectedIndex();
if (!state->matchCallEntries[selection].isSpecialTrainer || MatchCall_HasCheckPage(state->matchCallEntries[selection].headerId))
{
@ -125,20 +125,20 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
return POKENAV_MC_FUNC_NONE;
}
static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *state)
static u32 GetExitMatchCallMenuId(struct Pokenav_MatchCallMenu *state)
{
return POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL;
}
static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state)
static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav_MatchCallMenu *state)
{
if ((JOY_NEW(DPAD_UP)) && state->optionCursorPos)
if (JOY_NEW(DPAD_UP) && state->optionCursorPos)
{
state->optionCursorPos--;
return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR;
}
if ((JOY_NEW(DPAD_DOWN)) && state->optionCursorPos < state->maxOptionId)
if (JOY_NEW(DPAD_DOWN) && state->optionCursorPos < state->maxOptionId)
{
state->optionCursorPos++;
return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR;
@ -155,8 +155,8 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state)
if (GetPokenavMode() == POKENAV_MODE_FORCE_CALL_READY)
SetPokenavMode(POKENAV_MODE_FORCE_CALL_EXIT);
state->callback = CB2_HandleCallInput;
if (sub_81CB1D0())
state->callback = CB2_HandleCallExitInput;
if (ShouldDoNearbyMessage())
return POKENAV_MC_FUNC_NEARBY_MSG;
return POKENAV_MC_FUNC_CALL_MSG;
@ -175,7 +175,7 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state)
return POKENAV_MC_FUNC_NONE;
}
static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state)
static u32 CB2_HandleCheckPageInput(struct Pokenav_MatchCallMenu *state)
{
if (JOY_REPEAT(DPAD_UP))
return POKENAV_MC_FUNC_CHECK_PAGE_UP;
@ -191,21 +191,21 @@ static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state)
return POKENAV_MC_FUNC_NONE;
}
static u32 CB2_HandleCallInput(struct Pokenav3Struct *state)
static u32 CB2_HandleCallExitInput(struct Pokenav_MatchCallMenu *state)
{
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
state->callback = CB2_HandleMatchCallInput;
return POKENAV_MC_FUNC_10;
return POKENAV_MC_FUNC_EXIT_CALL;
}
return POKENAV_MC_FUNC_NONE;
}
static u32 sub_81CAD20(s32 taskState)
static u32 LoopedTask_BuildMatchCallList(s32 taskState)
{
int i, j;
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
switch (taskState)
{
case 0:
@ -213,6 +213,7 @@ static u32 sub_81CAD20(s32 taskState)
state->numRegistered = 0;
return LT_INC_AND_CONTINUE;
case 1:
// Load special trainers (e.g. Rival, gym leaders)
for (i = 0, j = state->headerId; i < 30; i++, j++)
{
if (MatchCall_GetEnabled(j))
@ -225,7 +226,7 @@ static u32 sub_81CAD20(s32 taskState)
if (++state->headerId >= MC_HEADER_COUNT)
{
state->unkC = state->headerId;
state->numSpecialTrainers = state->headerId;
state->headerId = 0;
return LT_INC_AND_CONTINUE;
}
@ -233,6 +234,7 @@ static u32 sub_81CAD20(s32 taskState)
return LT_CONTINUE;
case 2:
// Load normal trainers
for (i = 0, j = state->headerId; i < 30; i++, j++)
{
if (!MatchCall_HasRematchId(state->headerId) && IsRematchEntryRegistered(state->headerId))
@ -249,7 +251,7 @@ static u32 sub_81CAD20(s32 taskState)
return LT_CONTINUE;
case 3:
state->unk10 = 1;
state->initFinished = TRUE;
break;
}
@ -264,55 +266,58 @@ bool32 IsRematchEntryRegistered(int rematchIndex)
return FALSE;
}
int sub_81CAE28(void)
int IsMatchCallListInitFinished(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->unk10;
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->initFinished;
}
int GetNumberRegistered(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->numRegistered;
}
int sub_81CAE48(void)
// Unused
static int GetNumSpecialTrainers(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->unkC;
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->numSpecialTrainers;
}
int unref_sub_81CAE58(void)
// Unused
static int GetNumNormalTrainers(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->numRegistered - state->unkC;
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->numRegistered - state->numSpecialTrainers;
}
int unref_sub_81CAE6C(int arg0)
// Unused
static int GetNormalTrainerHeaderId(int index)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
arg0 += state->unkC;
if (arg0 >= state->numRegistered)
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
index += state->numSpecialTrainers;
if (index >= state->numRegistered)
return REMATCH_TABLE_ENTRIES;
return state->matchCallEntries[arg0].headerId;
return state->matchCallEntries[index].headerId;
}
struct PokenavMatchCallEntries *sub_81CAE94(void)
struct PokenavMatchCallEntry *GetMatchCallList(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->matchCallEntries;
}
u16 GetMatchCallMapSec(int index)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->matchCallEntries[index].mapSec;
}
bool32 ShouldDrawRematchPokeballIcon(int index)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (!state->matchCallEntries[index].isSpecialTrainer)
index = state->matchCallEntries[index].headerId;
else
@ -327,7 +332,7 @@ bool32 ShouldDrawRematchPokeballIcon(int index)
int GetMatchCallTrainerPic(int index)
{
int headerId;
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (!state->matchCallEntries[index].isSpecialTrainer)
{
index = GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId);
@ -346,15 +351,15 @@ int GetMatchCallTrainerPic(int index)
return gFacilityClassToPicIndex[index];
}
const u8 *GetMatchCallMessageText(int index, u8 *arg1)
const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
*arg1 = 0;
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
*newRematchRequest = FALSE;
if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType))
return gText_CallCantBeMadeHere;
if (!state->matchCallEntries[index].isSpecialTrainer)
*arg1 = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId), gStringVar4);
*newRematchRequest = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId), gStringVar4);
else
MatchCall_GetMessage(state->matchCallEntries[index].headerId, gStringVar4);
@ -364,7 +369,7 @@ const u8 *GetMatchCallMessageText(int index, u8 *arg1)
const u8 *GetMatchCallFlavorText(int index, int checkPageEntry)
{
int rematchId;
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (state->matchCallEntries[index].isSpecialTrainer)
{
rematchId = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId);
@ -381,20 +386,20 @@ const u8 *GetMatchCallFlavorText(int index, int checkPageEntry)
u16 GetMatchCallOptionCursorPos(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->optionCursorPos;
}
u16 GetMatchCallOptionId(int optionId)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (state->maxOptionId < optionId)
return MATCH_CALL_OPTION_COUNT;
return state->matchCallOptions[optionId];
}
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries *matchCallEntry, u8 *str)
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry *matchCallEntry, u8 *str)
{
const u8 *trainerName;
const u8 *className;
@ -431,7 +436,7 @@ u8 GetMatchTableMapSectionId(int rematchIndex)
int GetIndexDeltaOfNextCheckPageDown(int index)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
int count = 1;
while (++index < state->numRegistered)
{
@ -448,7 +453,7 @@ int GetIndexDeltaOfNextCheckPageDown(int index)
int GetIndexDeltaOfNextCheckPageUp(int index)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
int count = -1;
while (--index >= 0)
{
@ -463,7 +468,8 @@ int GetIndexDeltaOfNextCheckPageUp(int index)
return 0;
}
bool32 unref_sub_81CB16C(void)
// Unused
static bool32 HasRematchEntry(void)
{
int i;
@ -486,10 +492,10 @@ bool32 unref_sub_81CB16C(void)
return FALSE;
}
static bool32 sub_81CB1D0(void)
static bool32 ShouldDoNearbyMessage(void)
{
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
int selection = GetSelectedPokenavListIndex();
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
int selection = PokenavList_GetSelectedIndex();
if (!state->matchCallEntries[selection].isSpecialTrainer)
{
if (GetMatchCallMapSec(selection) == gMapHeader.regionMapSectionId)

View File

@ -1,997 +0,0 @@
#include "global.h"
#include "pokenav.h"
#include "window.h"
#include "strings.h"
#include "text.h"
#include "bg.h"
#include "menu.h"
#include "decompress.h"
#include "international_string_util.h"
// TODO: This UI isnt just for match call, seems to be the general pokenav list UI
struct PokenavListMenuWindow {
u8 bg;
u8 unk1;
u8 unk2;
u8 unk3;
u8 unk4;
u8 fontId;
u16 unk6;
u16 windowId;
u16 unkA;
u16 unkC;
u16 unkE;
};
struct MatchCallWindowState {
// The index of the element at the top of the window.
u16 windowTopIndex;
u16 listLength;
u16 unk4;
// The index of the cursor, relative to the top of the window.
u16 selectedIndexOffset;
u16 visibleEntries;
u16 unkA;
u32 unkC;
void * unk10;
};
struct PokenavSub17Substruct
{
struct PokenavListMenuWindow listWindow;
u32 unk10;
u32 unk14;
u32 unk18;
void * unk1C;
s32 unk20;
s32 unk24;
u32 loopedTaskId;
s32 unk2C;
u32 unk30;
void (*unk34)(struct PokenavMatchCallEntries *, u8*);
void (*unk38)(u16, u32, u32);
struct Sprite *rightArrow;
struct Sprite *upArrow;
struct Sprite *downArrow;
u8 unkTextBuffer[0x40];
};
// Generally at index 0x11 (17)
struct PokenavSub17
{
struct PokenavSub17Substruct list;
u8 tilemapBuffer[0x800];
struct MatchCallWindowState unk888;
s32 unk89C;
u32 loopedTaskId;
};
void sub_81C82E4(struct PokenavSub17 *matchCall);
bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3);
void InitMatchCallWindowState(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1);
void SpriteCB_MatchCallUpArrow(struct Sprite *sprite);
void SpriteCB_MatchCallDownArrow(struct Sprite *sprite);
void SpriteCB_MatchCallRightArrow(struct Sprite *sprite);
void ToggleMatchCallArrows(struct PokenavSub17Substruct *a0, u32 a1);
void DestroyMatchCallListArrows(struct PokenavSub17Substruct *a0);
void CreateMatchCallArrowSprites(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1);
void sub_81C8ED0(void);
static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1, u32 a2);
void PrintMatchCallFieldNames(struct PokenavSub17Substruct *a0, u32 a1);
void sub_81C8D4C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1);
void sub_81C8CB4(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1);
void sub_81C8B70(struct PokenavListMenuWindow *a0, s32 a1, s32 a2);
void sub_81C8568(s32 a0, struct PokenavSub17Substruct *a1);
void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5);
void sub_81C837C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1);
void sub_81C835C(struct PokenavListMenuWindow *a0);
u32 LoopedTask_sub_81C8254(s32 state);
bool32 sub_81C83E0(void);
u32 LoopedTask_sub_81C83F0(s32 state);
u32 LoopedTask_sub_81C85A0(s32 state);
u32 LoopedTask_sub_81C8870(s32 state);
u32 LoopedTask_sub_81C8A28(s32 state);
u32 LoopedTask_PrintCheckPageInfo(s32 state);
static const u16 sMatchcallArrowPaletteData[] = INCBIN_U16("graphics/pokenav/arrows_matchcall.gbapal");
static const u32 sMatchcallArrowSpriteSheetData[] = INCBIN_U32("graphics/pokenav/arrows_matchcall.4bpp.lz");
EWRAM_DATA u32 gUnknown_0203CF44 = 0;
bool32 sub_81C81D4(const struct BgTemplate *arg0, struct PokenavListTemplate *arg1, s32 arg2)
{
struct PokenavSub17 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_LIST, sizeof(struct PokenavSub17));
if (structPtr == NULL)
return FALSE;
InitMatchCallWindowState(&structPtr->unk888, arg1);
if (!CopyPokenavListMenuTemplate(&structPtr->list, arg0, arg1, arg2))
return FALSE;
CreateLoopedTask(LoopedTask_sub_81C8254, 6);
return TRUE;
}
bool32 sub_81C8224(void)
{
return FuncIsActiveLoopedTask(LoopedTask_sub_81C8254);
}
void sub_81C8234(void)
{
struct PokenavSub17 *structPtr;
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
DestroyMatchCallListArrows(&structPtr->list);
RemoveWindow(structPtr->list.listWindow.windowId);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
}
u32 LoopedTask_sub_81C8254(s32 state)
{
struct PokenavSub17 *structPtr;
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
switch (state)
{
case 0:
sub_81C82E4(structPtr);
return LT_INC_AND_PAUSE;
case 1:
sub_81C835C(&structPtr->list.listWindow);
return LT_INC_AND_PAUSE;
case 2:
sub_81C837C(&structPtr->unk888, &structPtr->list);
return LT_INC_AND_PAUSE;
case 3:
if (sub_81C83E0())
{
return LT_PAUSE;
}
else
{
sub_81C8ED0();
return LT_INC_AND_CONTINUE;
}
case 4:
CreateMatchCallArrowSprites(&structPtr->unk888, &structPtr->list);
return LT_FINISH;
default:
return LT_FINISH;
}
}
void sub_81C82E4(struct PokenavSub17 *matchCall)
{
u16 tileNum = (matchCall->list.listWindow.unk1 << 12) | matchCall->list.listWindow.unk6;
BgDmaFill(matchCall->list.listWindow.bg, PIXEL_FILL(1), matchCall->list.listWindow.unk6, 1);
BgDmaFill(matchCall->list.listWindow.bg, PIXEL_FILL(4), matchCall->list.listWindow.unk6 + 1, 1);
SetBgTilemapBuffer(matchCall->list.listWindow.bg, matchCall->tilemapBuffer);
FillBgTilemapBufferRect_Palette0(matchCall->list.listWindow.bg, tileNum, 0, 0, 32, 32);
ChangeBgY(matchCall->list.listWindow.bg, 0, BG_COORD_SET);
ChangeBgX(matchCall->list.listWindow.bg, 0, BG_COORD_SET);
ChangeBgY(matchCall->list.listWindow.bg, matchCall->list.listWindow.unk3 << 11, BG_COORD_SUB);
CopyBgTilemapBufferToVram(matchCall->list.listWindow.bg);
}
void sub_81C835C(struct PokenavListMenuWindow *listWindow)
{
FillWindowPixelBuffer(listWindow->windowId, PIXEL_FILL(1));
PutWindowTilemap(listWindow->windowId);
CopyWindowToVram(listWindow->windowId, COPYWIN_MAP);
}
void sub_81C837C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *a1)
{
s32 arg2 = state->listLength - state->windowTopIndex;
if (arg2 > state->visibleEntries)
arg2 = state->visibleEntries;
sub_81C83AC(state->unk10, state->windowTopIndex, arg2, state->unkC, 0, a1);
}
void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *list)
{
if (a2 == 0)
return;
list->unk1C = a0 + a1 * a3;
list->unk18 = a3;
list->listWindow.unkC = 0;
list->listWindow.unkE = a2;
list->unk14 = a1;
list->unk10 = a4;
CreateLoopedTask(LoopedTask_sub_81C83F0, 5);
}
bool32 sub_81C83E0(void)
{
return FuncIsActiveLoopedTask(LoopedTask_sub_81C83F0);
}
u32 LoopedTask_sub_81C83F0(s32 state)
{
u32 v1;
struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
switch (state)
{
case 0:
v1 = (structPtr->listWindow.unkA + structPtr->listWindow.unkC + structPtr->unk10) & 0xF;
structPtr->unk34(structPtr->unk1C, structPtr->unkTextBuffer);
if (structPtr->unk38 != NULL)
structPtr->unk38(structPtr->listWindow.windowId, structPtr->unk14, v1);
AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->unkTextBuffer, 8, (v1 << 4) + 1, 255, NULL);
if (++structPtr->listWindow.unkC >= structPtr->listWindow.unkE)
{
if (structPtr->unk38 != NULL)
CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_FULL);
else
CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_GFX);
return LT_INC_AND_PAUSE;
}
else
{
structPtr->unk1C += structPtr->unk18;
structPtr->unk14++;
return LT_CONTINUE;
}
case 1:
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
return LT_FINISH;
}
return LT_FINISH;
}
bool32 ShouldShowUpArrow(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return (structPtr->unk888.windowTopIndex != 0);
}
bool32 ShouldShowDownArrow(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
struct MatchCallWindowState *subPtr = &structPtr->unk888;
return (subPtr->windowTopIndex + subPtr->visibleEntries < subPtr->listLength);
}
void MatchCall_MoveWindow(s32 a0, bool32 a1)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
struct MatchCallWindowState *subPtr = &structPtr->unk888;
if (a0 < 0)
{
if (subPtr->windowTopIndex + a0 < 0)
a0 = -1 * subPtr->windowTopIndex;
if (a1)
sub_81C83AC(subPtr->unk10, subPtr->windowTopIndex + a0, a0 * -1, subPtr->unkC, a0, &structPtr->list);
}
else if (a1)
{
s32 temp = gUnknown_0203CF44 = subPtr->windowTopIndex + subPtr->visibleEntries;
if (temp + a0 >= subPtr->listLength)
a0 = subPtr->listLength - temp;
sub_81C83AC(subPtr->unk10, gUnknown_0203CF44, a0, subPtr->unkC, subPtr->visibleEntries, &structPtr->list);
}
sub_81C8568(a0, &structPtr->list);
subPtr->windowTopIndex += a0;
}
void sub_81C8568(s32 a0, struct PokenavSub17Substruct *list)
{
list->unk20 = GetBgY(list->listWindow.bg);
list->unk24 = list->unk20 + (a0 << 12);
if (a0 > 0)
list->unk30 = BG_COORD_ADD;
else
list->unk30 = BG_COORD_SUB;
list->unk2C = a0;
list->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C85A0, 6);
}
u32 LoopedTask_sub_81C85A0(s32 state)
{
s32 y, v1;
bool32 flag;
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
struct PokenavSub17Substruct *subPtr = &structPtr->list;
switch (state)
{
case 0:
if (!sub_81C83E0())
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
case 1:
flag = FALSE;
y = GetBgY(subPtr->listWindow.bg);
v1 = ChangeBgY(subPtr->listWindow.bg, 0x1000, subPtr->unk30);
if (subPtr->unk30 == BG_COORD_SUB)
{
if ((y > subPtr->unk24 || y <= subPtr->unk20) && v1 <= subPtr->unk24)
flag = TRUE;
}
else // BG_COORD_ADD
{
if ((y < subPtr->unk24 || y >= subPtr->unk20) && v1 >= subPtr->unk24)
flag = TRUE;
}
if (flag)
{
subPtr->listWindow.unkA = (subPtr->listWindow.unkA + subPtr->unk2C) & 0xF;
ChangeBgY(subPtr->listWindow.bg, subPtr->unk24, BG_COORD_SET);
return LT_FINISH;
}
return LT_PAUSE;
}
return LT_FINISH;
}
bool32 IsMonListLoopedTaskActive(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return IsLoopedTaskActive(structPtr->list.loopedTaskId);
}
struct MatchCallWindowState *GetMatchCallWindowStruct(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return &structPtr->unk888;
}
int MatchCall_MoveCursorUp(void)
{
struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct();
if (structPtr->selectedIndexOffset != 0)
{
structPtr->selectedIndexOffset--;
return 1;
}
if (ShouldShowUpArrow())
{
MatchCall_MoveWindow(-1, TRUE);
return 2;
}
return 0;
}
int MatchCall_MoveCursorDown(void)
{
struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct();
if (structPtr->windowTopIndex + structPtr->selectedIndexOffset >= structPtr->listLength - 1)
return 0;
if (structPtr->selectedIndexOffset < structPtr->visibleEntries - 1)
{
structPtr->selectedIndexOffset++;
return 1;
}
if (ShouldShowDownArrow())
{
MatchCall_MoveWindow(1, TRUE);
return 2;
}
return 0;
}
int MatchCall_PageUp(void)
{
s32 scroll;
struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct();
if (ShouldShowUpArrow())
{
if (structPtr->windowTopIndex >= structPtr->visibleEntries)
scroll = structPtr->visibleEntries;
else
scroll = structPtr->windowTopIndex;
MatchCall_MoveWindow(scroll * -1, TRUE);
return 2;
}
else if (structPtr->selectedIndexOffset != 0)
{
structPtr->selectedIndexOffset = 0;
return 1;
}
return 0;
}
int MatchCall_PageDown(void)
{
struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct();
if (ShouldShowDownArrow())
{
s32 windowBottomIndex = structPtr->windowTopIndex + structPtr->visibleEntries;
s32 scroll = structPtr->unk4 - structPtr->windowTopIndex;
if (windowBottomIndex <= structPtr->unk4)
scroll = structPtr->visibleEntries;
MatchCall_MoveWindow(scroll, TRUE);
return 2;
}
else
{
s32 cursor, lastVisibleIndex;
if (structPtr->listLength >= structPtr->visibleEntries)
{
cursor = structPtr->selectedIndexOffset;
lastVisibleIndex = structPtr->visibleEntries;
}
else
{
cursor = structPtr->selectedIndexOffset;
lastVisibleIndex = structPtr->listLength;
}
lastVisibleIndex -= 1;
if (cursor >= lastVisibleIndex)
return 0;
structPtr->selectedIndexOffset = lastVisibleIndex;
return 1;
}
}
u32 GetSelectedPokenavListIndex(void)
{
struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct();
return structPtr->windowTopIndex + structPtr->selectedIndexOffset;
}
u32 GetMatchCallListTopIndex(void)
{
struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct();
return structPtr->windowTopIndex;
}
void sub_81C877C(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->unk89C = 0;
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8870, 6);
}
void PrintCheckPageInfo(s16 a0)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->unk888.windowTopIndex += a0;
structPtr->unk89C = 0;
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6);
}
void sub_81C87F0(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->unk89C = 0;
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8A28, 6);
}
bool32 IsMatchCallListTaskActive(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return IsLoopedTaskActive(structPtr->loopedTaskId);
}
void sub_81C8838(void)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
struct MatchCallWindowState *subPtr = &structPtr->unk888;
structPtr->list.unk38(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF);
CopyWindowToVram(structPtr->list.listWindow.windowId, COPYWIN_MAP);
}
// TODO:
u32 LoopedTask_sub_81C8870(s32 state)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
switch (state)
{
case 0:
ToggleMatchCallArrows(&structPtr->list, 1);
// fall-through
case 1:
if (structPtr->unk89C != structPtr->unk888.selectedIndexOffset)
sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, 1);
structPtr->unk89C++;
return LT_INC_AND_PAUSE;
case 2:
if (!IsDma3ManagerBusyWithBgCopy())
{
if (structPtr->unk89C != structPtr->unk888.visibleEntries)
return 6;
if (structPtr->unk888.selectedIndexOffset != 0)
sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, structPtr->unk888.selectedIndexOffset);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 3:
if (!IsDma3ManagerBusyWithBgCopy())
{
if (structPtr->unk888.selectedIndexOffset != 0)
{
MatchCall_MoveWindow(structPtr->unk888.selectedIndexOffset, FALSE);
return LT_INC_AND_PAUSE;
}
return LT_FINISH;
}
return LT_PAUSE;
case 4:
if (IsMonListLoopedTaskActive())
return LT_PAUSE;
structPtr->unk888.selectedIndexOffset = 0;
return LT_FINISH;
}
return LT_FINISH;
}
u32 LoopedTask_PrintCheckPageInfo(s32 state)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
switch (state)
{
case 0:
sub_81C8CB4(&structPtr->unk888, &structPtr->list);
break;
case 1:
PrintMatchCallFieldNames(&structPtr->list, 0);
break;
case 2:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_STRATEGY);
break;
case 3:
PrintMatchCallFieldNames(&structPtr->list, 1);
break;
case 4:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_POKEMON);
break;
case 5:
PrintMatchCallFieldNames(&structPtr->list, 2);
break;
case 6:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_1);
break;
case 7:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_2);
break;
default:
return LT_FINISH;
}
return LT_INC_AND_PAUSE;
}
u32 LoopedTask_sub_81C8A28(s32 state)
{
struct PokenavSub17 *structPtr;
struct MatchCallWindowState *subPtr888;
struct PokenavSub17Substruct *subPtr0;
s32 r5, *ptr;
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
subPtr888 = &structPtr->unk888;
subPtr0 = &structPtr->list;
switch (state)
{
case 0:
sub_81C8D4C(subPtr888, subPtr0);
return LT_INC_AND_PAUSE;
case 1:
ptr = &structPtr->unk89C;
if (++(*ptr) < structPtr->unk888.visibleEntries)
{
sub_81C8B70(&subPtr0->listWindow, *ptr, 1);
return LT_PAUSE;
}
*ptr = 0;
if (subPtr888->listLength <= subPtr888->visibleEntries)
{
if (subPtr888->windowTopIndex != 0)
{
s32 r4 = subPtr888->windowTopIndex;
r5 = -r4;
sub_81C8B70(&subPtr0->listWindow, r5, r4);
subPtr888->selectedIndexOffset = r4;
*ptr = r5;
return LT_INC_AND_PAUSE;
}
}
else
{
if (subPtr888->windowTopIndex + subPtr888->visibleEntries > subPtr888->listLength)
{
s32 r4 = subPtr888->windowTopIndex + subPtr888->visibleEntries - subPtr888->listLength;
r5 = -r4;
sub_81C8B70(&subPtr0->listWindow, r5, r4);
subPtr888->selectedIndexOffset = r4;
*ptr = r5;
return LT_INC_AND_PAUSE;
}
}
return 9;
case 2:
MatchCall_MoveWindow(structPtr->unk89C, FALSE);
return LT_INC_AND_PAUSE;
case 3:
if (!IsMonListLoopedTaskActive())
{
structPtr->unk89C = 0;
return 1;
}
return 2;
case 4:
sub_81C83AC(subPtr888->unk10, subPtr888->windowTopIndex + structPtr->unk89C, 1, subPtr888->unkC, structPtr->unk89C, &structPtr->list);
return LT_INC_AND_PAUSE;
case 5:
if (sub_81C83E0())
return LT_PAUSE;
if (++structPtr->unk89C >= subPtr888->listLength || structPtr->unk89C >= subPtr888->visibleEntries)
return LT_INC_AND_CONTINUE;
return 9;
case 6:
ToggleMatchCallArrows(subPtr0, 0);
return LT_FINISH;
}
return LT_FINISH;
}
void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2)
{
u8 *v1 = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA);
u32 v2 = listWindow->unk4 * 64;
a1 = (listWindow->unkA + a1) & 0xF;
if (a1 + a2 <= 16)
{
CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, a2 * v2);
CopyWindowToVram(listWindow->windowId, COPYWIN_GFX);
}
else
{
u32 v3 = 16 - a1;
u32 v4 = a2 - v3;
CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, v3 * v2);
CpuFastFill8(PIXEL_FILL(1), v1, v4 * v2);
CopyWindowToVram(listWindow->windowId, COPYWIN_GFX);
}
for (a2--; a2 != -1; a1 = (a1 + 1) & 0xF, a2--)
ClearRematchPokeballIcon(listWindow->windowId, a1);
CopyWindowToVram(listWindow->windowId, COPYWIN_MAP);
}
void sub_81C8C64(struct PokenavListMenuWindow *listWindow, u32 a1)
{
u16 var;
u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG));
v1 += ((listWindow->unkA << 6) + listWindow->unk2) - 1;
if (a1 != 0)
var = (listWindow->unk1 << 12) | (listWindow->unk6 + 1);
else
var = (listWindow->unk1 << 12) | (listWindow->unk6);
v1[0] = var;
v1[0x20] = var;
}
void sub_81C8CB4(struct MatchCallWindowState *state, struct PokenavSub17Substruct *list)
{
u8 colors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_RED};
list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer);
list->unk38(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA);
FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16);
AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SKIP_DRAW, list->unkTextBuffer);
sub_81C8C64(&list->listWindow, 1);
CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_FULL, 0, list->listWindow.unkA * 2, list->listWindow.unk4, 2);
}
void sub_81C8D4C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *list)
{
list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer);
FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16);
AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->unkTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SKIP_DRAW, NULL);
sub_81C8C64(&list->listWindow, 0);
CopyWindowToVram(list->listWindow.windowId, COPYWIN_FULL);
}
void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId)
{
const u8 *fieldNames[] = {gText_PokenavMatchCall_Strategy, gText_PokenavMatchCall_TrainerPokemon, gText_PokenavMatchCall_SelfIntroduction};
u8 colors[3] = {TEXT_COLOR_WHITE, TEXT_COLOR_RED, TEXT_COLOR_LIGHT_RED};
u32 top = (list->listWindow.unkA + 1 + (fieldId * 2)) & 0xF;
FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.unk4, 16);
AddTextPrinterParameterized3(list->listWindow.windowId, FONT_NARROW, 2, (top << 4) + 1, colors, TEXT_SKIP_DRAW, fieldNames[fieldId]);
CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, top << 1, list->listWindow.unk4, 2);
}
static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry)
{
// lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames
static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] =
{
[CHECK_PAGE_STRATEGY] = 2,
[CHECK_PAGE_POKEMON] = 4,
[CHECK_PAGE_INTRO_1] = 6,
[CHECK_PAGE_INTRO_2] = 7
};
u32 r6 = (list->listWindow.unkA + lineOffsets[checkPageEntry]) & 0xF;
const u8 *str = GetMatchCallFlavorText(a0->windowTopIndex, checkPageEntry);
if (str != NULL)
{
FillWindowTilesByRow(list->listWindow.windowId, 1, r6 * 2, list->listWindow.unk4 - 1, 2);
AddTextPrinterParameterized(list->listWindow.windowId, FONT_NARROW, str, 2, (r6 << 4) + 1, TEXT_SKIP_DRAW, NULL);
CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, r6 * 2, list->listWindow.unk4, 2);
}
}
static const struct CompressedSpriteSheet sMatchcallArrowSpriteSheets[] =
{
{
.data = sMatchcallArrowSpriteSheetData,
.size = 192,
.tag = 0xA
}
};
static const struct SpritePalette sMatchcallArrowPalettes[] =
{
{
.data = sMatchcallArrowPaletteData,
.tag = 0x14
},
{}
};
static const struct OamData sMatchCallRightArrowSpriteOam =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(8x16),
.x = 0,
.size = SPRITE_SIZE(8x16),
.tileNum = 0,
.priority = 2,
.paletteNum = 0
};
static const struct SpriteTemplate sMatchCallRightArrowSprite =
{
.tileTag = 0xA,
.paletteTag = 0x14,
.oam = &sMatchCallRightArrowSpriteOam,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_MatchCallRightArrow
};
static const struct OamData sMatchCallUpDownArrowSpriteOam =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(16x8),
.x = 0,
.size = SPRITE_SIZE(16x8),
.tileNum = 0,
.priority = 2,
.paletteNum = 0
};
static const struct SpriteTemplate sMatchCallUpDownArrowSprite =
{
.tileTag = 0xA,
.paletteTag = 0x14,
.oam = &sMatchCallUpDownArrowSpriteOam,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
void sub_81C8ED0(void)
{
u32 i;
const struct CompressedSpriteSheet *ptr;
for (i = 0, ptr = sMatchcallArrowSpriteSheets; i < ARRAY_COUNT(sMatchcallArrowSpriteSheets); ptr++, i++)
LoadCompressedSpriteSheet(ptr);
Pokenav_AllocAndLoadPalettes(sMatchcallArrowPalettes);
}
void CreateMatchCallArrowSprites(struct MatchCallWindowState *windowState, struct PokenavSub17Substruct *list)
{
u32 spriteId;
s16 x;
spriteId = CreateSprite(&sMatchCallRightArrowSprite, list->listWindow.unk2 * 8 + 3, (list->listWindow.unk3 + 1) * 8, 7);
list->rightArrow = &gSprites[spriteId];
x = list->listWindow.unk2 * 8 + (list->listWindow.unk4 - 1) * 4;
spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8 + windowState->visibleEntries * 16, 7);
list->downArrow = &gSprites[spriteId];
list->downArrow->oam.tileNum += 2;
list->downArrow->callback = SpriteCB_MatchCallDownArrow;
spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8, 7);
list->upArrow = &gSprites[spriteId];
list->upArrow->oam.tileNum += 4;
list->upArrow->callback = SpriteCB_MatchCallUpArrow;
}
void DestroyMatchCallListArrows(struct PokenavSub17Substruct *list)
{
DestroySprite(list->rightArrow);
DestroySprite(list->upArrow);
DestroySprite(list->downArrow);
FreeSpriteTilesByTag(0xA);
FreeSpritePaletteByTag(0x14);
}
void ToggleMatchCallArrows(struct PokenavSub17Substruct *list, bool32 shouldHide)
{
if (shouldHide)
{
list->rightArrow->callback = SpriteCallbackDummy;
list->upArrow->callback = SpriteCallbackDummy;
list->downArrow->callback = SpriteCallbackDummy;
}
else
{
list->rightArrow->callback = SpriteCB_MatchCallRightArrow;
list->upArrow->callback = SpriteCB_MatchCallUpArrow;
list->downArrow->callback = SpriteCB_MatchCallDownArrow;
}
list->rightArrow->invisible = shouldHide;
list->upArrow->invisible = shouldHide;
list->downArrow->invisible = shouldHide;
}
void SpriteCB_MatchCallRightArrow(struct Sprite *sprite)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
sprite->y2 = structPtr->unk888.selectedIndexOffset << 4;
}
void SpriteCB_MatchCallDownArrow(struct Sprite *sprite)
{
if (sprite->data[7] == 0 && ShouldShowDownArrow())
sprite->invisible = FALSE;
else
sprite->invisible = TRUE;
if (++sprite->data[0] > 3)
{
s16 offset;
sprite->data[0] = 0;
offset = (sprite->data[1] + 1) & 7;
sprite->data[1] = offset;
sprite->y2 = offset;
}
}
void SpriteCB_MatchCallUpArrow(struct Sprite *sprite)
{
if (sprite->data[7] == 0 && ShouldShowUpArrow())
sprite->invisible = FALSE;
else
sprite->invisible = TRUE;
if (++sprite->data[0] > 3)
{
s16 offset;
sprite->data[0] = 0;
offset = (sprite->data[1] + 1) & 7;
sprite->data[1] = offset;
sprite->y2 = -1 * offset;
}
}
void ToggleMatchCallVerticalArrows(bool32 shouldHide)
{
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->list.upArrow->data[7] = shouldHide;
structPtr->list.downArrow->data[7] = shouldHide;
}
void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavListTemplate *template)
{
dst->unk10 = template->list.matchCallEntries;
dst->windowTopIndex = template->unk6;
dst->listLength = template->count;
dst->unkC = template->unk8;
dst->visibleEntries = template->maxShowed;
if (dst->visibleEntries >= dst->listLength)
{
dst->windowTopIndex = 0;
dst->unk4 = 0;
dst->selectedIndexOffset = template->unk6;
}
else
{
dst->unk4 = dst->listLength - dst->visibleEntries;
if (dst->windowTopIndex + dst->visibleEntries > dst->listLength)
{
dst->selectedIndexOffset = dst->windowTopIndex + dst->visibleEntries - dst->listLength;
dst->windowTopIndex = template->unk6 - dst->selectedIndexOffset;
}
else
{
dst->selectedIndexOffset = 0;
}
}
}
bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 a3)
{
struct WindowTemplate window;
dest->listWindow.bg = bgTemplate->bg;
dest->listWindow.unk6 = a3;
dest->unk34 = template->listFunc.unk10_2;
dest->unk38 = template->unk14;
dest->listWindow.unk1 = template->fillValue;
dest->listWindow.unk2 = template->item_X;
dest->listWindow.unk3 = template->listTop;
dest->listWindow.unk4 = template->windowWidth;
dest->listWindow.fontId = template->fontId;
window.bg = bgTemplate->bg;
window.tilemapLeft = template->item_X;
window.tilemapTop = 0;
window.width = template->windowWidth;
window.height = 32;
window.paletteNum = template->fillValue;
window.baseBlock = a3 + 2;
dest->listWindow.windowId = AddWindow(&window);
if (dest->listWindow.windowId == WINDOW_NONE)
return FALSE;
dest->listWindow.unkA = 0;
dest->rightArrow = NULL;
dest->upArrow = NULL;
dest->downArrow = NULL;
return 1;
}

513
src/pokenav_menu_handler.c Normal file
View File

@ -0,0 +1,513 @@
#include "global.h"
#include "pokenav.h"
#include "event_data.h"
#include "main.h"
#include "sound.h"
#include "constants/songs.h"
struct Pokenav_Menu
{
u16 menuType;
s16 cursorPos;
u16 currMenuItem;
u16 helpBarIndex;
u32 menuId;
u32 (*callback)(struct Pokenav_Menu*);
};
static bool32 UpdateMenuCursorPos(struct Pokenav_Menu *);
static void ReturnToConditionMenu(struct Pokenav_Menu *);
static void ReturnToMainMenu(struct Pokenav_Menu *);
static u32 GetMenuId(struct Pokenav_Menu *);
static void SetMenuIdAndCB(struct Pokenav_Menu *, u32);
static u32 CB2_ReturnToConditionMenu(struct Pokenav_Menu *);
static u32 CB2_ReturnToMainMenu(struct Pokenav_Menu *);
static u32 HandleConditionSearchMenuInput(struct Pokenav_Menu *);
static u32 HandleConditionMenuInput(struct Pokenav_Menu *);
static u32 HandleCantOpenRibbonsInput(struct Pokenav_Menu *);
static u32 HandleMainMenuInputEndTutorial(struct Pokenav_Menu *);
static u32 HandleMainMenuInputTutorial(struct Pokenav_Menu *);
static u32 HandleMainMenuInput(struct Pokenav_Menu *);
static u32 (*GetMainMenuInputHandler(void))(struct Pokenav_Menu*);
static void SetMenuInputHandler(struct Pokenav_Menu *);
// Number of entries - 1 for that menu type
static const u8 sLastCursorPositions[] =
{
[POKENAV_MENU_TYPE_DEFAULT] = 2,
[POKENAV_MENU_TYPE_UNLOCK_MC] = 3,
[POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] = 4,
[POKENAV_MENU_TYPE_CONDITION] = 2,
[POKENAV_MENU_TYPE_CONDITION_SEARCH] = 5
};
static const u8 sMenuItems[][MAX_POKENAV_MENUITEMS] =
{
[POKENAV_MENU_TYPE_DEFAULT] =
{
POKENAV_MENUITEM_MAP,
POKENAV_MENUITEM_CONDITION,
[2 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_UNLOCK_MC] =
{
POKENAV_MENUITEM_MAP,
POKENAV_MENUITEM_CONDITION,
POKENAV_MENUITEM_MATCH_CALL,
[3 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] =
{
POKENAV_MENUITEM_MAP,
POKENAV_MENUITEM_CONDITION,
POKENAV_MENUITEM_MATCH_CALL,
POKENAV_MENUITEM_RIBBONS,
[4 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_CONDITION] =
{
POKENAV_MENUITEM_CONDITION_PARTY,
POKENAV_MENUITEM_CONDITION_SEARCH,
POKENAV_MENUITEM_CONDITION_CANCEL,
[3 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_CONDITION_SEARCH] =
{
POKENAV_MENUITEM_CONDITION_SEARCH_COOL,
POKENAV_MENUITEM_CONDITION_SEARCH_BEAUTY,
POKENAV_MENUITEM_CONDITION_SEARCH_CUTE,
POKENAV_MENUITEM_CONDITION_SEARCH_SMART,
POKENAV_MENUITEM_CONDITION_SEARCH_TOUGH,
POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL
},
};
static u8 GetPokenavMainMenuType(void)
{
u8 menuType = POKENAV_MENU_TYPE_DEFAULT;
if (FlagGet(FLAG_ADDED_MATCH_CALL_TO_POKENAV))
{
menuType = POKENAV_MENU_TYPE_UNLOCK_MC;
if (FlagGet(FLAG_SYS_RIBBON_GET))
menuType = POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS;
}
return menuType;
}
bool32 PokenavCallback_Init_MainMenuCursorOnMap(void)
{
struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu));
if (!menu)
return FALSE;
menu->menuType = GetPokenavMainMenuType();
menu->cursorPos = POKENAV_MENUITEM_MAP;
menu->currMenuItem = POKENAV_MENUITEM_MAP;
menu->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(menu);
return TRUE;
}
bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void)
{
struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu));
if (!menu)
return FALSE;
menu->menuType = GetPokenavMainMenuType();
menu->cursorPos = POKENAV_MENUITEM_MATCH_CALL;
menu->currMenuItem = POKENAV_MENUITEM_MATCH_CALL;
menu->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(menu);
return TRUE;
}
bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void)
{
struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu));
if (!menu)
return FALSE;
menu->menuType = GetPokenavMainMenuType();
menu->cursorPos = POKENAV_MENUITEM_RIBBONS;
menu->currMenuItem = POKENAV_MENUITEM_RIBBONS;
SetMenuInputHandler(menu);
return TRUE;
}
bool32 PokenavCallback_Init_ConditionMenu(void)
{
struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu));
if (!menu)
return FALSE;
menu->menuType = POKENAV_MENU_TYPE_CONDITION;
menu->cursorPos = 0; //party
menu->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY;
menu->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(menu);
return TRUE;
}
bool32 PokenavCallback_Init_ConditionSearchMenu(void)
{
struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu));
if (!menu)
return FALSE;
menu->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH;
menu->cursorPos = GetSelectedConditionSearch();
menu->currMenuItem = menu->cursorPos + POKENAV_MENUITEM_CONDITION_SEARCH_COOL;
menu->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(menu);
return TRUE;
}
static void SetMenuInputHandler(struct Pokenav_Menu *menu)
{
switch (menu->menuType)
{
case POKENAV_MENU_TYPE_DEFAULT:
SetPokenavMode(POKENAV_MODE_NORMAL);
// fallthrough
case POKENAV_MENU_TYPE_UNLOCK_MC:
case POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS:
menu->callback = GetMainMenuInputHandler();
break;
case POKENAV_MENU_TYPE_CONDITION:
menu->callback = HandleConditionMenuInput;
break;
case POKENAV_MENU_TYPE_CONDITION_SEARCH:
menu->callback = HandleConditionSearchMenuInput;
break;
}
}
static u32 (*GetMainMenuInputHandler(void))(struct Pokenav_Menu*)
{
switch (GetPokenavMode())
{
default:
case POKENAV_MODE_NORMAL:
return HandleMainMenuInput;
case POKENAV_MODE_FORCE_CALL_READY:
return HandleMainMenuInputTutorial;
case POKENAV_MODE_FORCE_CALL_EXIT:
return HandleMainMenuInputEndTutorial;
}
}
u32 GetMenuHandlerCallback(void)
{
struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return menu->callback(menu);
}
void FreeMenuHandlerSubstruct1(void)
{
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
}
static u32 HandleMainMenuInput(struct Pokenav_Menu *menu)
{
if (UpdateMenuCursorPos(menu))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
switch (sMenuItems[menu->menuType][menu->cursorPos])
{
case POKENAV_MENUITEM_MAP:
menu->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? HELPBAR_MAP_ZOOMED_IN : HELPBAR_MAP_ZOOMED_OUT;
SetMenuIdAndCB(menu, POKENAV_REGION_MAP);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
case POKENAV_MENUITEM_CONDITION:
menu->menuType = POKENAV_MENU_TYPE_CONDITION;
menu->cursorPos = 0;
menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][0];
menu->callback = HandleConditionMenuInput;
return POKENAV_MENU_FUNC_OPEN_CONDITION;
case POKENAV_MENUITEM_MATCH_CALL:
menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST;
SetMenuIdAndCB(menu, POKENAV_MATCH_CALL);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
case POKENAV_MENUITEM_RIBBONS:
if (CanViewRibbonsMenu())
{
menu->helpBarIndex = HELPBAR_RIBBONS_MON_LIST;
SetMenuIdAndCB(menu, POKENAV_RIBBONS_MON_LIST);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
menu->callback = HandleCantOpenRibbonsInput;
return POKENAV_MENU_FUNC_NO_RIBBON_WINNERS;
}
case POKENAV_MENUITEM_SWITCH_OFF:
return POKENAV_MENU_FUNC_EXIT;
}
}
if (JOY_NEW(B_BUTTON))
return POKENAV_MENU_FUNC_EXIT;
return POKENAV_MENU_FUNC_NONE;
}
// Force the player to select Match Call during the call Mr. Stone pokenav tutorial
static u32 HandleMainMenuInputTutorial(struct Pokenav_Menu *menu)
{
if (UpdateMenuCursorPos(menu))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
if (sMenuItems[menu->menuType][menu->cursorPos] == POKENAV_MENUITEM_MATCH_CALL)
{
menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST;
SetMenuIdAndCB(menu, POKENAV_MATCH_CALL);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
PlaySE(SE_FAILURE);
return POKENAV_MENU_FUNC_NONE;
}
}
if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_FAILURE);
return POKENAV_MENU_FUNC_NONE;
}
return POKENAV_MENU_FUNC_NONE;
}
// After calling Mr. Stone during the pokenav tutorial, force player to exit or use Match Call again
static u32 HandleMainMenuInputEndTutorial(struct Pokenav_Menu *menu)
{
if (UpdateMenuCursorPos(menu))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
u32 menuItem = sMenuItems[menu->menuType][menu->cursorPos];
if (menuItem != POKENAV_MENUITEM_MATCH_CALL && menuItem != POKENAV_MENUITEM_SWITCH_OFF)
{
PlaySE(SE_FAILURE);
return POKENAV_MENU_FUNC_NONE;
}
else if (menuItem == POKENAV_MENUITEM_MATCH_CALL)
{
menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST;
SetMenuIdAndCB(menu, POKENAV_MATCH_CALL);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
return -1;
}
}
else if (JOY_NEW(B_BUTTON))
{
return -1;
}
return POKENAV_MENU_FUNC_NONE;
}
// Handles input after selecting Ribbons when there are no ribbon winners left
// Selecting it again just reprints the Ribbon description to replace the "No Ribbon winners" message
static u32 HandleCantOpenRibbonsInput(struct Pokenav_Menu *menu)
{
if (UpdateMenuCursorPos(menu))
{
menu->callback = GetMainMenuInputHandler();
return POKENAV_MENU_FUNC_MOVE_CURSOR;
}
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
menu->callback = GetMainMenuInputHandler();
return POKENAV_MENU_FUNC_RESHOW_DESCRIPTION;
}
return POKENAV_MENU_FUNC_NONE;
}
static u32 HandleConditionMenuInput(struct Pokenav_Menu *menu)
{
if (UpdateMenuCursorPos(menu))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
switch (sMenuItems[menu->menuType][menu->cursorPos])
{
case POKENAV_MENUITEM_CONDITION_SEARCH:
menu->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH;
menu->cursorPos = 0;
menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION_SEARCH][0];
menu->callback = HandleConditionSearchMenuInput;
return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH;
case POKENAV_MENUITEM_CONDITION_PARTY:
menu->helpBarIndex = 0;
SetMenuIdAndCB(menu, POKENAV_CONDITION_GRAPH_PARTY);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
case POKENAV_MENUITEM_CONDITION_CANCEL:
PlaySE(SE_SELECT);
ReturnToMainMenu(menu);
return POKENAV_MENU_FUNC_RETURN_TO_MAIN;
}
}
if (JOY_NEW(B_BUTTON))
{
if (menu->cursorPos != sLastCursorPositions[menu->menuType])
{
menu->cursorPos = sLastCursorPositions[menu->menuType];
menu->callback = CB2_ReturnToMainMenu;
return POKENAV_MENU_FUNC_MOVE_CURSOR;
}
else
{
PlaySE(SE_SELECT);
ReturnToMainMenu(menu);
return POKENAV_MENU_FUNC_RETURN_TO_MAIN;
}
}
return POKENAV_MENU_FUNC_NONE;
}
static u32 HandleConditionSearchMenuInput(struct Pokenav_Menu *menu)
{
if (UpdateMenuCursorPos(menu))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
u8 menuItem = sMenuItems[menu->menuType][menu->cursorPos];
if (menuItem != POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL)
{
SetSelectedConditionSearch(menuItem - POKENAV_MENUITEM_CONDITION_SEARCH_COOL);
SetMenuIdAndCB(menu, POKENAV_CONDITION_SEARCH_RESULTS);
menu->helpBarIndex = HELPBAR_CONDITION_MON_LIST;
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
PlaySE(SE_SELECT);
ReturnToConditionMenu(menu);
return POKENAV_MENU_FUNC_RETURN_TO_CONDITION;
}
}
if (JOY_NEW(B_BUTTON))
{
if (menu->cursorPos != sLastCursorPositions[menu->menuType])
{
menu->cursorPos = sLastCursorPositions[menu->menuType];
menu->callback = CB2_ReturnToConditionMenu;
return POKENAV_MENU_FUNC_MOVE_CURSOR;
}
else
{
PlaySE(SE_SELECT);
ReturnToConditionMenu(menu);
return POKENAV_MENU_FUNC_RETURN_TO_CONDITION;
}
}
return POKENAV_MENU_FUNC_NONE;
}
static u32 CB2_ReturnToMainMenu(struct Pokenav_Menu *menu)
{
ReturnToMainMenu(menu);
return POKENAV_MENU_FUNC_RETURN_TO_MAIN;
}
static u32 CB2_ReturnToConditionMenu(struct Pokenav_Menu *menu)
{
ReturnToConditionMenu(menu);
return POKENAV_MENU_FUNC_RETURN_TO_CONDITION;
}
static void SetMenuIdAndCB(struct Pokenav_Menu *menu, u32 menuId)
{
menu->menuId = menuId;
menu->callback = GetMenuId;
}
static u32 GetMenuId(struct Pokenav_Menu *menu)
{
return menu->menuId;
}
static void ReturnToMainMenu(struct Pokenav_Menu *menu)
{
menu->menuType = GetPokenavMainMenuType();
menu->cursorPos = 1;
menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos];
menu->callback = HandleMainMenuInput;
}
static void ReturnToConditionMenu(struct Pokenav_Menu *menu)
{
menu->menuType = POKENAV_MENU_TYPE_CONDITION;
menu->cursorPos = 1;
menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][1];
menu->callback = HandleConditionMenuInput;
}
static bool32 UpdateMenuCursorPos(struct Pokenav_Menu *menu)
{
if (JOY_NEW(DPAD_UP))
{
if (--menu->cursorPos < 0)
menu->cursorPos = sLastCursorPositions[menu->menuType];
menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos];
return TRUE;
}
else if (JOY_NEW(DPAD_DOWN))
{
menu->cursorPos++;
if (menu->cursorPos > sLastCursorPositions[menu->menuType])
menu->cursorPos = 0;
menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos];
return TRUE;
}
else
{
return FALSE;
}
}
int GetPokenavMenuType(void)
{
struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return menu->menuType;
}
// Position of cursor relative to number of current menu options
int GetPokenavCursorPos(void)
{
struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return menu->cursorPos;
}
// ID of menu item the cursor is currently on
int GetCurrentMenuItemId(void)
{
struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return menu->currMenuItem;
}
u16 GetHelpBarTextId(void)
{
struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return menu->helpBarIndex;
}

View File

@ -1,513 +0,0 @@
#include "global.h"
#include "pokenav.h"
#include "event_data.h"
#include "main.h"
#include "sound.h"
#include "constants/songs.h"
struct Pokenav1Struct
{
u16 menuType;
s16 cursorPos;
u16 currMenuItem;
u16 helpBarIndex;
u32 menuId;
u32 (*callback)(struct Pokenav1Struct*);
};
static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state);
static void ReturnToConditionMenu(struct Pokenav1Struct *state);
static void ReturnToMainMenu(struct Pokenav1Struct *state);
static u32 GetMenuId(struct Pokenav1Struct *state);
static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 a1);
static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state);
static u32 CB2_ReturnToMainMenu(struct Pokenav1Struct *state);
static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state);
static u32 HandleConditionMenuInput(struct Pokenav1Struct *state);
static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state);
static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state);
static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state);
static u32 HandleMainMenuInput(struct Pokenav1Struct *state);
static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*);
static void SetMenuInputHandler(struct Pokenav1Struct *state);
// Number of entries - 1 for that menu type
static const u8 sLastCursorPositions[] =
{
[POKENAV_MENU_TYPE_DEFAULT] = 2,
[POKENAV_MENU_TYPE_UNLOCK_MC] = 3,
[POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] = 4,
[POKENAV_MENU_TYPE_CONDITION] = 2,
[POKENAV_MENU_TYPE_CONDITION_SEARCH] = 5
};
static const u8 sMenuItems[][6] =
{
[POKENAV_MENU_TYPE_DEFAULT] =
{
POKENAV_MENUITEM_MAP,
POKENAV_MENUITEM_CONDITION,
[2 ... 5] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_UNLOCK_MC] =
{
POKENAV_MENUITEM_MAP,
POKENAV_MENUITEM_CONDITION,
POKENAV_MENUITEM_MATCH_CALL,
[3 ... 5] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] =
{
POKENAV_MENUITEM_MAP,
POKENAV_MENUITEM_CONDITION,
POKENAV_MENUITEM_MATCH_CALL,
POKENAV_MENUITEM_RIBBONS,
[4 ... 5] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_CONDITION] =
{
POKENAV_MENUITEM_CONDITION_PARTY,
POKENAV_MENUITEM_CONDITION_SEARCH,
POKENAV_MENUITEM_CONDITION_CANCEL,
[3 ... 5] = POKENAV_MENUITEM_SWITCH_OFF
},
[POKENAV_MENU_TYPE_CONDITION_SEARCH] =
{
POKENAV_MENUITEM_CONDITION_SEARCH_COOL,
POKENAV_MENUITEM_CONDITION_SEARCH_BEAUTY,
POKENAV_MENUITEM_CONDITION_SEARCH_CUTE,
POKENAV_MENUITEM_CONDITION_SEARCH_SMART,
POKENAV_MENUITEM_CONDITION_SEARCH_TOUGH,
POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL
},
};
static u8 GetPokenavMainMenuType(void)
{
u8 menuType = POKENAV_MENU_TYPE_DEFAULT;
if (FlagGet(FLAG_ADDED_MATCH_CALL_TO_POKENAV))
{
menuType = POKENAV_MENU_TYPE_UNLOCK_MC;
if (FlagGet(FLAG_SYS_RIBBON_GET))
menuType = POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS;
}
return menuType;
}
bool32 PokenavCallback_Init_MainMenuCursorOnMap(void)
{
struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct));
if (!state)
return FALSE;
state->menuType = GetPokenavMainMenuType();
state->cursorPos = POKENAV_MENUITEM_MAP;
state->currMenuItem = POKENAV_MENUITEM_MAP;
state->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(state);
return TRUE;
}
bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void)
{
struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct));
if (!state)
return FALSE;
state->menuType = GetPokenavMainMenuType();
state->cursorPos = POKENAV_MENUITEM_MATCH_CALL;
state->currMenuItem = POKENAV_MENUITEM_MATCH_CALL;
state->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(state);
return TRUE;
}
bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void)
{
struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct));
if (!state)
return FALSE;
state->menuType = GetPokenavMainMenuType();
state->cursorPos = POKENAV_MENUITEM_RIBBONS;
state->currMenuItem = POKENAV_MENUITEM_RIBBONS;
SetMenuInputHandler(state);
return TRUE;
}
bool32 PokenavCallback_Init_ConditionMenu(void)
{
struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct));
if (!state)
return FALSE;
state->menuType = POKENAV_MENU_TYPE_CONDITION;
state->cursorPos = 0; //party
state->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY;
state->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(state);
return TRUE;
}
bool32 PokenavCallback_Init_ConditionSearchMenu(void)
{
struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct));
if (!state)
return FALSE;
state->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH;
state->cursorPos = GetSelectedConditionSearch();
state->currMenuItem = state->cursorPos + POKENAV_MENUITEM_CONDITION_SEARCH_COOL;
state->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(state);
return TRUE;
}
static void SetMenuInputHandler(struct Pokenav1Struct *state)
{
switch (state->menuType)
{
case POKENAV_MENU_TYPE_DEFAULT:
SetPokenavMode(POKENAV_MODE_NORMAL);
// fallthrough
case POKENAV_MENU_TYPE_UNLOCK_MC:
case POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS:
state->callback = GetMainMenuInputHandler();
break;
case POKENAV_MENU_TYPE_CONDITION:
state->callback = HandleConditionMenuInput;
break;
case POKENAV_MENU_TYPE_CONDITION_SEARCH:
state->callback = HandleConditionSearchMenuInput;
break;
}
}
static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*)
{
switch (GetPokenavMode())
{
default:
case POKENAV_MODE_NORMAL:
return HandleMainMenuInput;
case POKENAV_MODE_FORCE_CALL_READY:
return HandleMainMenuInputTutorial;
case POKENAV_MODE_FORCE_CALL_EXIT:
return HandleMainMenuInputEndTutorial;
}
}
u32 GetMenuHandlerCallback(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->callback(state);
}
void FreeMenuHandlerSubstruct1(void)
{
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
}
static u32 HandleMainMenuInput(struct Pokenav1Struct *state)
{
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
switch (sMenuItems[state->menuType][state->cursorPos])
{
case POKENAV_MENUITEM_MAP:
state->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? HELPBAR_MAP_ZOOMED_IN : HELPBAR_MAP_ZOOMED_OUT;
SetMenuIdAndCB(state, POKENAV_REGION_MAP);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
case POKENAV_MENUITEM_CONDITION:
state->menuType = POKENAV_MENU_TYPE_CONDITION;
state->cursorPos = 0;
state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][0];
state->callback = HandleConditionMenuInput;
return POKENAV_MENU_FUNC_OPEN_CONDITION;
case POKENAV_MENUITEM_MATCH_CALL:
state->helpBarIndex = HELPBAR_MC_TRAINER_LIST;
SetMenuIdAndCB(state, POKENAV_MATCH_CALL);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
case POKENAV_MENUITEM_RIBBONS:
if (CanViewRibbonsMenu())
{
state->helpBarIndex = HELPBAR_RIBBONS_MON_LIST;
SetMenuIdAndCB(state, POKENAV_RIBBONS_MON_LIST);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
state->callback = HandleCantOpenRibbonsInput;
return POKENAV_MENU_FUNC_NO_RIBBON_WINNERS;
}
case POKENAV_MENUITEM_SWITCH_OFF:
return POKENAV_MENU_FUNC_EXIT;
}
}
if (JOY_NEW(B_BUTTON))
return POKENAV_MENU_FUNC_EXIT;
return POKENAV_MENU_FUNC_NONE;
}
// Force the player to select Match Call during the call Mr. Stone pokenav tutorial
static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state)
{
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
if (sMenuItems[state->menuType][state->cursorPos] == POKENAV_MENUITEM_MATCH_CALL)
{
state->helpBarIndex = HELPBAR_MC_TRAINER_LIST;
SetMenuIdAndCB(state, POKENAV_MATCH_CALL);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
PlaySE(SE_FAILURE);
return POKENAV_MENU_FUNC_NONE;
}
}
if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_FAILURE);
return POKENAV_MENU_FUNC_NONE;
}
return POKENAV_MENU_FUNC_NONE;
}
// After calling Mr. Stone during the pokenav tutorial, force player to exit or use Match Call again
static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state)
{
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
u32 menuItem = sMenuItems[state->menuType][state->cursorPos];
if (menuItem != POKENAV_MENUITEM_MATCH_CALL && menuItem != POKENAV_MENUITEM_SWITCH_OFF)
{
PlaySE(SE_FAILURE);
return POKENAV_MENU_FUNC_NONE;
}
else if (menuItem == POKENAV_MENUITEM_MATCH_CALL)
{
state->helpBarIndex = HELPBAR_MC_TRAINER_LIST;
SetMenuIdAndCB(state, POKENAV_MATCH_CALL);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
return -1;
}
}
else if (JOY_NEW(B_BUTTON))
{
return -1;
}
return POKENAV_MENU_FUNC_NONE;
}
// Handles input after selecting Ribbons when there are no ribbon winners left
// Selecting it again just reprints the Ribbon description to replace the "No Ribbon winners" message
static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state)
{
if (UpdateMenuCursorPos(state))
{
state->callback = GetMainMenuInputHandler();
return POKENAV_MENU_FUNC_MOVE_CURSOR;
}
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
state->callback = GetMainMenuInputHandler();
return POKENAV_MENU_FUNC_RESHOW_DESCRIPTION;
}
return POKENAV_MENU_FUNC_NONE;
}
static u32 HandleConditionMenuInput(struct Pokenav1Struct *state)
{
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
switch (sMenuItems[state->menuType][state->cursorPos])
{
case POKENAV_MENUITEM_CONDITION_SEARCH:
state->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH;
state->cursorPos = 0;
state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION_SEARCH][0];
state->callback = HandleConditionSearchMenuInput;
return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH;
case POKENAV_MENUITEM_CONDITION_PARTY:
state->helpBarIndex = 0;
SetMenuIdAndCB(state, POKENAV_CONDITION_PARTY);
return POKENAV_MENU_FUNC_OPEN_FEATURE;
case POKENAV_MENUITEM_CONDITION_CANCEL:
PlaySE(SE_SELECT);
ReturnToMainMenu(state);
return POKENAV_MENU_FUNC_RETURN_TO_MAIN;
}
}
if (JOY_NEW(B_BUTTON))
{
if (state->cursorPos != sLastCursorPositions[state->menuType])
{
state->cursorPos = sLastCursorPositions[state->menuType];
state->callback = CB2_ReturnToMainMenu;
return POKENAV_MENU_FUNC_MOVE_CURSOR;
}
else
{
PlaySE(SE_SELECT);
ReturnToMainMenu(state);
return POKENAV_MENU_FUNC_RETURN_TO_MAIN;
}
}
return POKENAV_MENU_FUNC_NONE;
}
static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state)
{
if (UpdateMenuCursorPos(state))
return POKENAV_MENU_FUNC_MOVE_CURSOR;
if (JOY_NEW(A_BUTTON))
{
u8 menuItem = sMenuItems[state->menuType][state->cursorPos];
if (menuItem != POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL)
{
SetSelectedConditionSearch(menuItem - POKENAV_MENUITEM_CONDITION_SEARCH_COOL);
SetMenuIdAndCB(state, POKENAV_CONDITION_SEARCH_RESULTS);
state->helpBarIndex = HELPBAR_CONDITION_MON_LIST;
return POKENAV_MENU_FUNC_OPEN_FEATURE;
}
else
{
PlaySE(SE_SELECT);
ReturnToConditionMenu(state);
return POKENAV_MENU_FUNC_RETURN_TO_CONDITION;
}
}
if (JOY_NEW(B_BUTTON))
{
if (state->cursorPos != sLastCursorPositions[state->menuType])
{
state->cursorPos = sLastCursorPositions[state->menuType];
state->callback = CB2_ReturnToConditionMenu;
return POKENAV_MENU_FUNC_MOVE_CURSOR;
}
else
{
PlaySE(SE_SELECT);
ReturnToConditionMenu(state);
return POKENAV_MENU_FUNC_RETURN_TO_CONDITION;
}
}
return POKENAV_MENU_FUNC_NONE;
}
static u32 CB2_ReturnToMainMenu(struct Pokenav1Struct *state)
{
ReturnToMainMenu(state);
return POKENAV_MENU_FUNC_RETURN_TO_MAIN;
}
static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state)
{
ReturnToConditionMenu(state);
return POKENAV_MENU_FUNC_RETURN_TO_CONDITION;
}
static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 menuId)
{
state->menuId = menuId;
state->callback = GetMenuId;
}
static u32 GetMenuId(struct Pokenav1Struct *state)
{
return state->menuId;
}
static void ReturnToMainMenu(struct Pokenav1Struct *state)
{
state->menuType = GetPokenavMainMenuType();
state->cursorPos = 1;
state->currMenuItem = sMenuItems[state->menuType][state->cursorPos];
state->callback = HandleMainMenuInput;
}
static void ReturnToConditionMenu(struct Pokenav1Struct *state)
{
state->menuType = POKENAV_MENU_TYPE_CONDITION;
state->cursorPos = 1;
state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][1];
state->callback = HandleConditionMenuInput;
}
static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state)
{
if (JOY_NEW(DPAD_UP))
{
if (--state->cursorPos < 0)
state->cursorPos = sLastCursorPositions[state->menuType];
state->currMenuItem = sMenuItems[state->menuType][state->cursorPos];
return TRUE;
}
else if (JOY_NEW(DPAD_DOWN))
{
state->cursorPos++;
if (state->cursorPos > sLastCursorPositions[state->menuType])
state->cursorPos = 0;
state->currMenuItem = sMenuItems[state->menuType][state->cursorPos];
return TRUE;
}
else
{
return FALSE;
}
}
int GetPokenavMenuType(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->menuType;
}
// Position of cursor relative to number of current menu options
int GetPokenavCursorPos(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->cursorPos;
}
// ID of menu item the cursor is currently on
int GetCurrentMenuItemId(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->currMenuItem;
}
u16 GetHelpBarTextId(void)
{
struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->helpBarIndex;
}

View File

@ -17,22 +17,25 @@
#include "constants/songs.h"
#include "constants/region_map_sections.h"
#define GFXTAG_CITY_ZOOM 6
#define PALTAG_CITY_ZOOM 11
#define NUM_CITY_MAPS 22
struct Pokenav5Struct
struct Pokenav_RegionMapMenu
{
u8 filler0[0xC];
u8 unused[12];
bool32 zoomDisabled;
u32 (*callback)(struct Pokenav5Struct *);
u32 (*callback)(struct Pokenav_RegionMapMenu *);
};
struct Pokenav5Struct_2
struct Pokenav_RegionMapGfx
{
bool32 (*isTaskActiveCB)(void);
u32 loopTaskId;
u16 infoWindowId;
struct Sprite *cityZoomTextSprites[3];
u8 tilemapBuffer[0x800];
u8 tilemapBuffer[BG_SCREEN_SIZE];
u8 cityZoomPics[NUM_CITY_MAPS][200];
};
@ -43,9 +46,9 @@ struct CityMapEntry
const u32 *tilemap;
};
static u32 HandleRegionMapInput(struct Pokenav5Struct *);
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *);
static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *);
static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *);
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *);
static u32 GetExitRegionMapMenuId(struct Pokenav_RegionMapMenu *);
static u32 LoopedTask_OpenRegionMap(s32);
static u32 LoopedTask_DecompressCityMaps(s32);
static bool32 GetCurrentLoopedTaskActive(void);
@ -53,15 +56,15 @@ static void FreeCityZoomViewGfx(void);
static void LoadCityZoomViewGfx(void);
static void DecompressCityMaps(void);
static bool32 IsDecompressCityMapsActive(void);
static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *);
static void LoadPokenavRegionMapGfx(struct Pokenav_RegionMapGfx *);
static bool32 TryFreeTempTileDataBuffers(void);
static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *);
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *);
static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *);
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *);
static void ChangeBgYForZoom(bool32);
static bool32 IsChangeBgYForZoomActive(void);
static void CreateCityZoomTextSprites(void);
static void DrawCityMap(struct Pokenav5Struct_2 *, int, int);
static void PrintLandmarkNames(struct Pokenav5Struct_2 *, int, int);
static void DrawCityMap(struct Pokenav_RegionMapGfx *, int, int);
static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, int, int);
static void SetCityZoomTextInvisibility(bool32);
static void Task_ChangeBgYForZoom(u8 taskId);
static void UpdateCityZoomTextPosition(void);
@ -74,7 +77,7 @@ static u32 LoopedTask_ExitRegionMap(s32);
extern const u16 gRegionMapCityZoomTiles_Pal[];
extern const u32 gRegionMapCityZoomText_Gfx[];
static const u16 sMapSecInfoWindow_Pal[] = INCBIN_U16("graphics/pokenav/region_map_info_window.gbapal");
static const u16 sMapSecInfoWindow_Pal[] = INCBIN_U16("graphics/pokenav/region_map/info_window.gbapal");
static const u32 sRegionMapCityZoomTiles_Gfx[] = INCBIN_U32("graphics/pokenav/zoom_tiles.4bpp.lz");
#include "data/region_map/city_map_tilemaps.h"
@ -121,12 +124,12 @@ static const LoopedTask sRegionMapLoopTaskFuncs[] =
static const struct CompressedSpriteSheet sCityZoomTextSpriteSheet[1] =
{
{gRegionMapCityZoomText_Gfx, 0x800, 6}
{gRegionMapCityZoomText_Gfx, 0x800, GFXTAG_CITY_ZOOM}
};
static const struct SpritePalette sCityZoomTilesSpritePalette[] =
{
{gRegionMapCityZoomTiles_Pal, 11},
{gRegionMapCityZoomTiles_Pal, PALTAG_CITY_ZOOM},
{}
};
@ -159,8 +162,8 @@ const struct OamData sCityZoomTextSprite_OamData =
static const struct SpriteTemplate sCityZoomTextSpriteTemplate =
{
.tileTag = 6,
.paletteTag = 11,
.tileTag = GFXTAG_CITY_ZOOM,
.paletteTag = PALTAG_CITY_ZOOM,
.oam = &sCityZoomTextSprite_OamData,
.anims = gDummySpriteAnimTable,
.images = NULL,
@ -170,7 +173,7 @@ static const struct SpriteTemplate sCityZoomTextSpriteTemplate =
u32 PokenavCallback_Init_RegionMap(void)
{
struct Pokenav5Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE, sizeof(struct Pokenav5Struct));
struct Pokenav_RegionMapMenu *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE, sizeof(struct Pokenav_RegionMapMenu));
if (!state)
return FALSE;
@ -195,11 +198,11 @@ void FreeRegionMapSubstruct1(void)
u32 GetRegionMapCallback(void)
{
struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
struct Pokenav_RegionMapMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
return state->callback(state);
}
static u32 HandleRegionMapInput(struct Pokenav5Struct *state)
static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state)
{
switch (DoRegionMapInputCallback())
{
@ -217,7 +220,7 @@ static u32 HandleRegionMapInput(struct Pokenav5Struct *state)
return POKENAV_MAP_FUNC_NONE;
}
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state)
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *state)
{
if (JOY_NEW(B_BUTTON))
{
@ -228,20 +231,20 @@ static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state)
return POKENAV_MAP_FUNC_NONE;
}
static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *state)
static u32 GetExitRegionMapMenuId(struct Pokenav_RegionMapMenu *state)
{
return POKENAV_MAIN_MENU_CURSOR_ON_MAP;
}
bool32 GetZoomDisabled(void)
{
struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
struct Pokenav_RegionMapMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
return state->zoomDisabled;
}
bool32 OpenPokenavRegionMap(void)
{
struct Pokenav5Struct_2 *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, sizeof(struct Pokenav5Struct_2));
struct Pokenav_RegionMapGfx *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, sizeof(struct Pokenav_RegionMapGfx));
if (!state)
return FALSE;
@ -252,20 +255,20 @@ bool32 OpenPokenavRegionMap(void)
void CreateRegionMapLoopedTask(s32 index)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
state->loopTaskId = CreateLoopedTask(sRegionMapLoopTaskFuncs[index], 1);
state->isTaskActiveCB = GetCurrentLoopedTaskActive;
}
bool32 IsRegionMapLoopedTaskActive(void)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
return state->isTaskActiveCB();
}
void FreeRegionMapSubstruct2(void)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
FreeRegionMapIconResources();
FreeCityZoomViewGfx();
RemoveWindow(state->infoWindowId);
@ -285,7 +288,7 @@ static void VBlankCB_RegionMap(void)
static bool32 GetCurrentLoopedTaskActive(void)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
return IsLoopedTaskActive(state->loopTaskId);
}
@ -301,7 +304,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
{
int menuGfxId;
struct RegionMap *regionMap;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
switch (taskState)
{
case 0:
@ -346,7 +349,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
return LT_PAUSE;
UpdateMapSecInfoWindow(state);
sub_81C7B40();
FadeToBlackExceptPrimary();
return LT_INC_AND_PAUSE;
case 5:
if (IsDma3ManagerBusyWithBgCopy_(state))
@ -364,7 +367,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
LoadLeftHeaderGfxForIndex(menuGfxId);
ShowLeftHeaderGfx(menuGfxId, 1, 1);
PokenavFadeScreen(1);
PokenavFadeScreen(POKENAV_FADE_FROM_BLACK);
return LT_INC_AND_PAUSE;
case 7:
if (IsPaletteFadeActive() || AreLeftHeaderSpritesMoving())
@ -377,7 +380,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
static u32 LoopedTask_UpdateInfoAfterCursorMove(s32 taskState)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
switch (taskState)
{
case 0:
@ -420,7 +423,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState)
static u32 LoopedTask_RegionMapZoomIn(s32 taskState)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
switch (taskState)
{
case 0:
@ -457,7 +460,7 @@ static u32 LoopedTask_ExitRegionMap(s32 taskState)
{
case 0:
PlaySE(SE_SELECT);
PokenavFadeScreen(0);
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
return LT_INC_AND_PAUSE;
case 1:
if (IsPaletteFadeActive())
@ -492,14 +495,14 @@ static void LoadCityZoomViewGfx(void)
static void FreeCityZoomViewGfx(void)
{
int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
FreeSpriteTilesByTag(6);
FreeSpritePaletteByTag(11);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
FreeSpriteTilesByTag(GFXTAG_CITY_ZOOM);
FreeSpritePaletteByTag(PALTAG_CITY_ZOOM);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
DestroySprite(state->cityZoomTextSprites[i]);
}
static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state)
static void LoadPokenavRegionMapGfx(struct Pokenav_RegionMapGfx *state)
{
BgDmaFill(1, PIXEL_FILL(0), 0x40, 1);
BgDmaFill(1, PIXEL_FILL(1), 0x41, 1);
@ -527,7 +530,7 @@ static bool32 TryFreeTempTileDataBuffers(void)
return FreeTempTileDataBuffersIfPossible();
}
static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state)
static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *state)
{
struct RegionMap *regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP);
switch (regionMap->mapSecType)
@ -565,7 +568,7 @@ static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state)
}
}
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *state)
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *state)
{
return IsDma3ManagerBusyWithBgCopy();
}
@ -621,7 +624,7 @@ static bool32 IsDecompressCityMapsActive(void)
static u32 LoopedTask_DecompressCityMaps(s32 taskState)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
if (taskState < NUM_CITY_MAPS)
{
LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]);
@ -631,7 +634,7 @@ static u32 LoopedTask_DecompressCityMaps(s32 taskState)
return LT_FINISH;
}
static void DrawCityMap(struct Pokenav5Struct_2 *state, int mapSecId, int pos)
static void DrawCityMap(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos)
{
int i;
for (i = 0; i < NUM_CITY_MAPS && (sPokenavCityMaps[i].mapSecId != mapSecId || sPokenavCityMaps[i].index != pos); i++)
@ -644,7 +647,7 @@ static void DrawCityMap(struct Pokenav5Struct_2 *state, int mapSecId, int pos)
CopyToBgTilemapBufferRect(1, state->cityZoomPics[i], 18, 6, 10, 10);
}
static void PrintLandmarkNames(struct Pokenav5Struct_2 *state, int mapSecId, int pos)
static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos)
{
int i = 0;
while (1)
@ -664,7 +667,7 @@ static void CreateCityZoomTextSprites(void)
int i;
int y;
struct Sprite *sprite;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
// When not zoomed in the text is still created but its pushed off screen
if (!IsRegionMapZoomed())
@ -724,7 +727,7 @@ static void SpriteCB_CityZoomText(struct Sprite *sprite)
static void UpdateCityZoomTextPosition(void)
{
int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
int y = 132 - (GetBgY(1) >> 8);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
state->cityZoomTextSprites[i]->y = y;
@ -733,7 +736,7 @@ static void UpdateCityZoomTextPosition(void)
static void SetCityZoomTextInvisibility(bool32 invisible)
{
int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
state->cityZoomTextSprites[i]->invisible = invisible;
}

View File

@ -20,49 +20,49 @@ enum
};
struct PokenavSub9
struct Pokenav_RibbonsMonList
{
u32 (*callback)(struct PokenavSub9*);
u32 (*callback)(struct Pokenav_RibbonsMonList*);
u32 loopedTaskId;
u16 winid;
s32 boxId;
s32 monId;
u32 changeBgs;
u32 saveMonList;
struct PokenavSub18 *monList;
struct PokenavMonList *monList;
};
struct PokenavSub10
struct Pokenav_RibbonsMonMenu
{
bool32 (*callback)(void);
u32 ltid;
u32 loopedTaskId;
u16 winid;
bool32 fromSummary;
u8 buff[BG_SCREEN_SIZE];
};
static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr);
static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr);
static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr);
static u32 RibbonsMonMenu_ToSummaryScreen(struct PokenavSub9 *structPtr);
static u32 BuildPartyMonRibbonList(s32 state);
static u32 InitBoxMonRibbonList(s32 state);
static u32 BuildBoxMonRibbonList(s32 state);
static u32 GetMonRibbonListLoopTaskFunc(s32 state);
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item);
static u32 LoopedTask_OpenRibbonsMonList(s32 state);
static u32 HandleRibbonsMonListInput_WaitListInit(struct Pokenav_RibbonsMonList *);
static u32 HandleRibbonsMonListInput(struct Pokenav_RibbonsMonList *);
static u32 RibbonsMonMenu_ReturnToMainMenu(struct Pokenav_RibbonsMonList *);
static u32 RibbonsMonMenu_ToSummaryScreen(struct Pokenav_RibbonsMonList *);
static u32 BuildPartyMonRibbonList(s32);
static u32 InitBoxMonRibbonList(s32);
static u32 BuildBoxMonRibbonList(s32);
static u32 GetMonRibbonListLoopTaskFunc(s32);
static void InsertMonListItem(struct Pokenav_RibbonsMonList *, struct PokenavMonListItem *);
static u32 LoopedTask_OpenRibbonsMonList(s32);
static bool32 GetRibbonsMonCurrentLoopedTaskActive(void);
static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state);
static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state);
static u32 LoopedTask_RibbonsListMovePageUp(s32 state);
static u32 LoopedTask_RibbonsListMovePageDown(s32 state);
static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state);
static u32 LoopedTask_RibbonsListOpenSummary(s32 state);
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2);
static void AddRibbonsMonListWindow(struct PokenavSub10 *ptr);
static void sub_81D0288(struct PokenavSub10 *ptr);
static void InitMonRibbonPokenavListMenuTemplate(void);
static void BufferRibbonMonInfoText(struct PokenavMonList *, u8 *);
static u32 LoopedTask_RibbonsListMoveCursorUp(s32);
static u32 LoopedTask_RibbonsListMoveCursorDown(s32);
static u32 LoopedTask_RibbonsListMovePageUp(s32);
static u32 LoopedTask_RibbonsListMovePageDown(s32);
static u32 LoopedTask_RibbonsListReturnToMainMenu(s32);
static u32 LoopedTask_RibbonsListOpenSummary(s32);
static void DrawListIndexNumber(s32, s32, s32);
static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *);
static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *);
static void CreateRibbonMonsList(void);
static void BufferRibbonMonInfoText(struct PokenavListItem *, u8 *);
static const LoopedTask sMonRibbonListLoopTaskFuncs[] =
{
@ -125,54 +125,54 @@ static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}");
bool32 PokenavCallback_Init_MonRibbonList(void)
{
struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9));
if (structPtr == NULL)
struct Pokenav_RibbonsMonList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct Pokenav_RibbonsMonList));
if (list == NULL)
return FALSE;
structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
if (structPtr->monList == NULL)
list->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavMonList));
if (list->monList == NULL)
return FALSE;
structPtr->callback = HandleRibbonsMonListInput_WaitListInit;
structPtr->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1);
structPtr->changeBgs = 0;
list->callback = HandleRibbonsMonListInput_WaitListInit;
list->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1);
list->changeBgs = 0;
return TRUE;
}
bool32 PokenavCallback_Init_RibbonsMonListFromSummary(void)
{
struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9));
if (structPtr == NULL)
struct Pokenav_RibbonsMonList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct Pokenav_RibbonsMonList));
if (list == NULL)
return FALSE;
structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
structPtr->callback = HandleRibbonsMonListInput;
structPtr->changeBgs = 1;
list->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
list->callback = HandleRibbonsMonListInput;
list->changeBgs = 1;
return TRUE;
}
u32 GetRibbonsMonListCallback(void)
{
struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return structPtr->callback(structPtr);
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->callback(list);
}
void FreeRibbonsMonList1(void)
void FreeRibbonsMonList(void)
{
struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
if (!structPtr->saveMonList)
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
if (!list->saveMonList)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
}
static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr)
static u32 HandleRibbonsMonListInput_WaitListInit(struct Pokenav_RibbonsMonList *list)
{
if (!IsLoopedTaskActive(structPtr->loopedTaskId))
structPtr->callback = HandleRibbonsMonListInput;
if (!IsLoopedTaskActive(list->loopedTaskId))
list->callback = HandleRibbonsMonListInput;
return 0;
}
static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr)
static u32 HandleRibbonsMonListInput(struct Pokenav_RibbonsMonList *list)
{
if (JOY_REPEAT(DPAD_UP))
return RIBBONS_MON_LIST_FUNC_MOVE_UP;
@ -184,60 +184,60 @@ static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr)
return RIBBONS_MON_LIST_FUNC_PAGE_DOWN;
if (JOY_NEW(B_BUTTON))
{
structPtr->saveMonList = 0;
structPtr->callback = RibbonsMonMenu_ReturnToMainMenu;
list->saveMonList = 0;
list->callback = RibbonsMonMenu_ReturnToMainMenu;
return RIBBONS_MON_LIST_FUNC_EXIT;
}
if (JOY_NEW(A_BUTTON))
{
structPtr->monList->currIndex = GetSelectedPokenavListIndex();
structPtr->saveMonList = 1;
structPtr->callback = RibbonsMonMenu_ToSummaryScreen;
list->monList->currIndex = PokenavList_GetSelectedIndex();
list->saveMonList = 1;
list->callback = RibbonsMonMenu_ToSummaryScreen;
return RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY;
}
return RIBBONS_MON_LIST_FUNC_NONE;
}
static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr)
static u32 RibbonsMonMenu_ReturnToMainMenu(struct Pokenav_RibbonsMonList *list)
{
return POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS;
}
static u32 RibbonsMonMenu_ToSummaryScreen(struct PokenavSub9 *structPtr)
static u32 RibbonsMonMenu_ToSummaryScreen(struct Pokenav_RibbonsMonList *list)
{
return POKENAV_RIBBONS_SUMMARY_SCREEN;
}
static u32 UpdateMonListBgs(void)
{
struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return structPtr->changeBgs;
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->changeBgs;
}
static struct PokenavMonList *GetMonRibbonMonListData(void)
static struct PokenavMonListItem *GetMonRibbonMonListData(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->monList->monData;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->monList->monData;
}
static s32 GetRibbonsMonListCount(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->monList->listCount;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->monList->listCount;
}
//unused
static s32 GetMonRibbonSelectedMonData(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 idx = GetSelectedPokenavListIndex();
return ptr->monList->monData[idx].data;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 idx = PokenavList_GetSelectedIndex();
return list->monList->monData[idx].data;
}
static s32 GetRibbonListMenuCurrIndex(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->monList->currIndex;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->monList->currIndex;
}
static u32 GetMonRibbonListLoopTaskFunc(s32 state)
@ -248,11 +248,11 @@ static u32 GetMonRibbonListLoopTaskFunc(s32 state)
static u32 BuildPartyMonRibbonList(s32 state)
{
s32 i;
struct PokenavMonList item;
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
struct PokenavMonListItem item;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
ptr->monList->listCount = 0;
ptr->monList->currIndex = 0;
list->monList->listCount = 0;
list->monList->currIndex = 0;
item.boxId = TOTAL_BOXES_COUNT;
for (i = 0; i < PARTY_SIZE; i++)
{
@ -266,7 +266,7 @@ static u32 BuildPartyMonRibbonList(s32 state)
{
item.monId = i;
item.data = ribbonCount;
sub_81CFCEC(ptr, &item);
InsertMonListItem(list, &item);
}
}
}
@ -276,19 +276,19 @@ static u32 BuildPartyMonRibbonList(s32 state)
static u32 InitBoxMonRibbonList(s32 state)
{
struct PokenavSub9 *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
ptr->monId = 0;
ptr->boxId = 0;
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
list->monId = 0;
list->boxId = 0;
return LT_INC_AND_CONTINUE;
}
static u32 BuildBoxMonRibbonList(s32 state)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 boxId = ptr->boxId;
s32 monId = ptr->monId;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 boxId = list->boxId;
s32 monId = list->monId;
s32 boxCount = 0;
struct PokenavMonList item;
struct PokenavMonListItem item;
while (boxId < TOTAL_BOXES_COUNT)
{
@ -302,15 +302,15 @@ static u32 BuildBoxMonRibbonList(s32 state)
item.boxId = boxId;
item.monId = monId;
item.data = ribbonCount;
sub_81CFCEC(ptr, &item);
InsertMonListItem(list, &item);
}
}
boxCount++;
monId++;
if (boxCount > TOTAL_BOXES_COUNT)
{
ptr->boxId = boxId;
ptr->monId = monId;
list->boxId = boxId;
list->monId = monId;
return LT_CONTINUE;
}
}
@ -318,28 +318,28 @@ static u32 BuildBoxMonRibbonList(s32 state)
boxId++;
}
ptr->changeBgs = 1;
list->changeBgs = 1;
return LT_FINISH;
}
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item)
static void InsertMonListItem(struct Pokenav_RibbonsMonList *list, struct PokenavMonListItem *item)
{
u32 left = 0;
u32 right = structPtr->monList->listCount;
u32 right = list->monList->listCount;
u32 insertionIdx = left + (right - left) / 2;
while (right != insertionIdx)
{
if (item->data > structPtr->monList->monData[insertionIdx].data)
if (item->data > list->monList->monData[insertionIdx].data)
right = insertionIdx;
else
left = insertionIdx + 1;
insertionIdx = left + (right - left) / 2;
}
for (right = structPtr->monList->listCount; right > insertionIdx; right--)
structPtr->monList->monData[right] = structPtr->monList->monData[right - 1];
structPtr->monList->monData[insertionIdx] = *item;
structPtr->monList->listCount++;
for (right = list->monList->listCount; right > insertionIdx; right--)
list->monList->monData[right] = list->monList->monData[right - 1];
list->monList->monData[insertionIdx] = *item;
list->monList->listCount++;
}
// Unused
@ -374,62 +374,62 @@ static bool32 PlayerHasRibbonsMon(void)
bool32 OpenRibbonsMonList(void)
{
struct PokenavSub10 *ptr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10));
if (ptr == NULL)
struct Pokenav_RibbonsMonMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct Pokenav_RibbonsMonMenu));
if (menu == NULL)
return FALSE;
ptr->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
ptr->callback = GetRibbonsMonCurrentLoopedTaskActive;
ptr->fromSummary = FALSE;
menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
menu->callback = GetRibbonsMonCurrentLoopedTaskActive;
menu->fromSummary = FALSE;
return TRUE;
}
bool32 OpenRibbonsMonListFromRibbonsSummary(void)
{
struct PokenavSub10 *monMenu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10));
if (monMenu == NULL)
struct Pokenav_RibbonsMonMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct Pokenav_RibbonsMonMenu));
if (menu == NULL)
return FALSE;
monMenu->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive;
monMenu->fromSummary = TRUE;
menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
menu->callback = GetRibbonsMonCurrentLoopedTaskActive;
menu->fromSummary = TRUE;
return TRUE;
}
void CreateRibbonsMonListLoopedTask(s32 idx)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
monMenu->ltid = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1);
monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive;
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
menu->loopedTaskId = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1);
menu->callback = GetRibbonsMonCurrentLoopedTaskActive;
}
bool32 IsRibbonsMonListLoopedTaskActive(void)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return monMenu->callback();
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return menu->callback();
}
bool32 GetRibbonsMonCurrentLoopedTaskActive(void)
{
struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return IsLoopedTaskActive(ptr->ltid);
struct Pokenav_RibbonsMonMenu * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return IsLoopedTaskActive(menu->loopedTaskId);
}
void FreeRibbonsMonList2(void)
void FreeRibbonsMonMenu(void)
{
struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
sub_81C8234();
RemoveWindow(ptr->winid);
struct Pokenav_RibbonsMonMenu * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
DestroyPokenavList();
RemoveWindow(menu->winid);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
}
static u32 LoopedTask_OpenRibbonsMonList(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
InitBgTemplates(sMonRibbonListBgTemplates, ARRAY_COUNT(sMonRibbonListBgTemplates));
DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0);
SetBgTilemapBuffer(1, monMenu->buff);
SetBgTilemapBuffer(1, menu->buff);
CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0);
CopyPaletteIntoBufferUnfaded(sMonRibbonListFramePal, 0x10, 0x20);
CopyBgTilemapBufferToVram(1);
@ -447,12 +447,12 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state)
if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE;
CopyPaletteIntoBufferUnfaded(sMonRibbonListUi_Pal, 0x20, 0x20);
InitMonRibbonPokenavListMenuTemplate();
CreateRibbonMonsList();
return LT_INC_AND_PAUSE;
case 3:
if (sub_81C8224())
if (IsCreatePokenavListTaskActive())
return LT_PAUSE;
AddRibbonsMonListWindow(monMenu);
AddRibbonsMonListWindow(menu);
return LT_INC_AND_PAUSE;
case 4:
if (FreeTempTileDataBuffersIfPossible())
@ -460,8 +460,8 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state)
ShowBg(2);
HideBg(3);
PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST);
PokenavFadeScreen(1);
if (!monMenu->fromSummary)
PokenavFadeScreen(POKENAV_FADE_FROM_BLACK);
if (!menu->fromSummary)
{
LoadLeftHeaderGfxForIndex(POKENAV_GFX_RIBBONS_MENU);
ShowLeftHeaderGfx(POKENAV_GFX_RIBBONS_MENU, 1, 0);
@ -479,11 +479,11 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state)
static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
switch (MatchCall_MoveCursorUp())
switch (PokenavList_MoveCursorUp())
{
case 0:
return LT_FINISH;
@ -496,11 +496,11 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -512,11 +512,11 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state)
static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
switch (MatchCall_MoveCursorDown())
switch (PokenavList_MoveCursorDown())
{
case 0:
return LT_FINISH;
@ -529,11 +529,11 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -545,11 +545,11 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state)
static u32 LoopedTask_RibbonsListMovePageUp(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
switch (MatchCall_PageUp())
switch (PokenavList_PageUp())
{
case 0:
return LT_FINISH;
@ -562,11 +562,11 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -578,11 +578,11 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state)
static u32 LoopedTask_RibbonsListMovePageDown(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
switch (MatchCall_PageDown())
switch (PokenavList_PageDown())
{
case 0:
return LT_FINISH;
@ -595,11 +595,11 @@ static u32 LoopedTask_RibbonsListMovePageDown(s32 state)
}
return LT_INC_AND_PAUSE;
case 1:
if (IsMonListLoopedTaskActive())
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -615,7 +615,7 @@ static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state)
{
case 0:
PlaySE(SE_SELECT);
PokenavFadeScreen(0);
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
SlideMenuHeaderDown();
return LT_INC_AND_PAUSE;
case 1:
@ -635,7 +635,7 @@ static u32 LoopedTask_RibbonsListOpenSummary(s32 state)
{
case 0:
PlaySE(SE_SELECT);
PokenavFadeScreen(0);
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
return LT_INC_AND_PAUSE;
case 1:
if (IsPaletteFadeActive())
@ -645,64 +645,64 @@ static u32 LoopedTask_RibbonsListOpenSummary(s32 state)
return LT_FINISH;
}
static void AddRibbonsMonListWindow(struct PokenavSub10 *monMenu)
static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *menu)
{
s32 r2;
monMenu->winid = AddWindow(&sRibbonsMonListWindowTemplate);
PutWindowTilemap(monMenu->winid);
r2 = GetRibbonsMonListCount();
sub_81D02B0(monMenu->winid, 0, r2);
CopyWindowToVram(monMenu->winid, COPYWIN_MAP);
sub_81D0288(monMenu);
s32 listCount;
menu->winid = AddWindow(&sRibbonsMonListWindowTemplate);
PutWindowTilemap(menu->winid);
listCount = GetRibbonsMonListCount();
DrawListIndexNumber(menu->winid, 0, listCount);
CopyWindowToVram(menu->winid, COPYWIN_MAP);
UpdateIndexNumberDisplay(menu);
}
static void sub_81D0288(struct PokenavSub10 *monMenu)
static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *menu)
{
s32 r4 = GetSelectedPokenavListIndex();
s32 r2 = GetRibbonsMonListCount();
sub_81D02B0(monMenu->winid, r4 + 1, r2);
CopyWindowToVram(monMenu->winid, COPYWIN_GFX);
s32 listIndex = PokenavList_GetSelectedIndex();
s32 listCount = GetRibbonsMonListCount();
DrawListIndexNumber(menu->winid, listIndex + 1, listCount);
CopyWindowToVram(menu->winid, COPYWIN_GFX);
}
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2)
static void DrawListIndexNumber(s32 windowId, s32 index, s32 max)
{
u8 strbuf[16];
u32 x;
u8 * ptr = strbuf;
ptr = ConvertIntToDecimalStringN(ptr, val1, STR_CONV_MODE_RIGHT_ALIGN, 3);
ptr = ConvertIntToDecimalStringN(ptr, index, STR_CONV_MODE_RIGHT_ALIGN, 3);
*ptr++ = CHAR_SLASH;
ConvertIntToDecimalStringN(ptr, val2, STR_CONV_MODE_RIGHT_ALIGN, 3);
ConvertIntToDecimalStringN(ptr, max, STR_CONV_MODE_RIGHT_ALIGN, 3);
x = GetStringCenterAlignXOffset(FONT_NORMAL, strbuf, 56);
AddTextPrinterParameterized(windowId, FONT_NORMAL, strbuf, x, 1, TEXT_SKIP_DRAW, NULL);
}
static void InitMonRibbonPokenavListMenuTemplate(void)
static void CreateRibbonMonsList(void)
{
struct PokenavListTemplate template;
template.list.monList = GetMonRibbonMonListData();
template.list = (struct PokenavListItem *)GetMonRibbonMonListData();
template.count = GetRibbonsMonListCount();
template.unk8 = 4;
template.unk6 = GetRibbonListMenuCurrIndex();
template.itemSize = sizeof(struct PokenavListItem);
template.startIndex = GetRibbonListMenuCurrIndex();
template.item_X = 13;
template.windowWidth = 17;
template.listTop = 1;
template.maxShowed = 8;
template.fillValue = 2;
template.fontId = FONT_NORMAL;
template.listFunc.printMonFunc = BufferRibbonMonInfoText;
template.unk14 = NULL;
sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0);
template.bufferItemFunc = BufferRibbonMonInfoText;
template.iconDrawFunc = NULL;
CreatePokenavList(&sMonRibbonListBgTemplates[1], &template, 0);
}
// Buffers the "Nickname gender/level" text for the ribbon mon list
static void BufferRibbonMonInfoText(struct PokenavMonList * item0, u8 * dest)
static void BufferRibbonMonInfoText(struct PokenavListItem * listItem, u8 * dest)
{
u8 gender;
u8 level;
u8 * s;
const u8 * genderStr;
struct PokenavMonList * item = item0;
struct PokenavMonListItem * item = (struct PokenavMonListItem *)listItem;
// Mon is in party
if (item->boxId == TOTAL_BOXES_COUNT)

View File

@ -39,10 +39,10 @@ enum
#define MON_SPRITE_X_OFF -32
#define MON_SPRITE_Y 104
struct PokenavSub13
struct Pokenav_RibbonsSummaryList
{
u8 unused1[8];
struct PokenavSub18 *monList;
struct PokenavMonList *monList;
u16 selectedPos;
u16 normalRibbonLastRowStart;
u16 numNormalRibbons;
@ -50,10 +50,10 @@ struct PokenavSub13
u32 ribbonIds[FIRST_GIFT_RIBBON];
u32 giftRibbonIds[NUM_GIFT_RIBBONS];
u32 unused2;
u32 (*callback)(struct PokenavSub13 *);
u32 (*callback)(struct Pokenav_RibbonsSummaryList *);
};
struct PokenavSub14
struct Pokenav_RibbonsSummaryMenu
{
u32 (*callback)(void);
u32 loopedTaskId;
@ -71,31 +71,31 @@ struct PokenavSub14
static u32 sRibbonDraw_Total;
static u32 sRibbonDraw_Current;
static void PrintCurrentMonRibbonCount(struct PokenavSub14 *);
static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *);
static void PrintRibbonsMonListIndex(struct PokenavSub14 *);
static void ZoomOutSelectedRibbon(struct PokenavSub14 *);
static void UpdateAndZoomInSelectedRibbon(struct PokenavSub14 *);
static void PrintRibbonNameAndDescription(struct PokenavSub14 *);
static void ResetSpritesAndDrawMonFrontPic(struct PokenavSub14 *);
static void AddRibbonListIndexWindow(struct PokenavSub14 *);
static void DestroyRibbonsMonFrontPic(struct PokenavSub14 *);
static void SlideMonSpriteOff(struct PokenavSub14 *);
static void SlideMonSpriteOn(struct PokenavSub14 *);
static void AddRibbonCountWindow(struct PokenavSub14 *);
static void CreateBigRibbonSprite(struct PokenavSub14 *);
static void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *);
static void DrawAllRibbonsSmall(struct PokenavSub14 *);
static bool32 IsRibbonAnimating(struct PokenavSub14 *);
static bool32 IsMonSpriteAnimating(struct PokenavSub14 *);
static void GetMonRibbons(struct PokenavSub13 *);
static u32 HandleExpandedRibbonInput(struct PokenavSub13 *);
static u32 RibbonsSummaryHandleInput(struct PokenavSub13 *);
static u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *);
static bool32 TrySelectRibbonUp(struct PokenavSub13 *);
static bool32 TrySelectRibbonRight(struct PokenavSub13 *);
static bool32 TrySelectRibbonLeft(struct PokenavSub13 *);
static bool32 TrySelectRibbonDown(struct PokenavSub13 *);
static void PrintCurrentMonRibbonCount(struct Pokenav_RibbonsSummaryMenu *);
static void PrintRibbbonsSummaryMonInfo(struct Pokenav_RibbonsSummaryMenu *);
static void PrintRibbonsMonListIndex(struct Pokenav_RibbonsSummaryMenu *);
static void ZoomOutSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *);
static void UpdateAndZoomInSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *);
static void PrintRibbonNameAndDescription(struct Pokenav_RibbonsSummaryMenu *);
static void ResetSpritesAndDrawMonFrontPic(struct Pokenav_RibbonsSummaryMenu *);
static void AddRibbonListIndexWindow(struct Pokenav_RibbonsSummaryMenu *);
static void DestroyRibbonsMonFrontPic(struct Pokenav_RibbonsSummaryMenu *);
static void SlideMonSpriteOff(struct Pokenav_RibbonsSummaryMenu *);
static void SlideMonSpriteOn(struct Pokenav_RibbonsSummaryMenu *);
static void AddRibbonCountWindow(struct Pokenav_RibbonsSummaryMenu *);
static void CreateBigRibbonSprite(struct Pokenav_RibbonsSummaryMenu *);
static void AddRibbonSummaryMonNameWindow(struct Pokenav_RibbonsSummaryMenu *);
static void DrawAllRibbonsSmall(struct Pokenav_RibbonsSummaryMenu *);
static bool32 IsRibbonAnimating(struct Pokenav_RibbonsSummaryMenu *);
static bool32 IsMonSpriteAnimating(struct Pokenav_RibbonsSummaryMenu *);
static void GetMonRibbons(struct Pokenav_RibbonsSummaryList *);
static u32 HandleExpandedRibbonInput(struct Pokenav_RibbonsSummaryList *);
static u32 RibbonsSummaryHandleInput(struct Pokenav_RibbonsSummaryList *);
static u32 ReturnToRibbonsListFromSummary(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonUp(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonRight(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonLeft(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonDown(struct Pokenav_RibbonsSummaryList *);
static bool32 GetCurrentLoopedTaskActive(void);
static u32 GetRibbonsSummaryCurrentIndex(void);
static u32 GetRibbonsSummaryMonListCount(void);
@ -186,16 +186,16 @@ static const LoopedTask sRibbonsSummaryMenuLoopTaskFuncs[] =
bool32 PokenavCallback_Init_RibbonsSummaryMenu(void)
{
struct PokenavSub13 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, sizeof(struct PokenavSub13));
if (structPtr == NULL)
struct Pokenav_RibbonsSummaryList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, sizeof(struct Pokenav_RibbonsSummaryList));
if (list == NULL)
return FALSE;
structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (structPtr->monList == NULL)
list->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (list->monList == NULL)
return FALSE;
GetMonRibbons(structPtr);
structPtr->callback = RibbonsSummaryHandleInput;
GetMonRibbons(list);
list->callback = RibbonsSummaryHandleInput;
gKeyRepeatContinueDelay = 3;
gKeyRepeatStartDelay = 10;
return TRUE;
@ -203,8 +203,8 @@ bool32 PokenavCallback_Init_RibbonsSummaryMenu(void)
u32 GetRibbonsSummaryMenuCallback(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->callback(structPtr);
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->callback(list);
}
void FreeRibbonsSummaryScreen1(void)
@ -213,150 +213,150 @@ void FreeRibbonsSummaryScreen1(void)
}
// Handles input when a specific ribbon is not currently selected
static u32 RibbonsSummaryHandleInput(struct PokenavSub13 *structPtr)
static u32 RibbonsSummaryHandleInput(struct Pokenav_RibbonsSummaryList *list)
{
// Handle Up/Down movement to select a new Pokémon to show ribbons for
if (JOY_REPEAT(DPAD_UP) && structPtr->monList->currIndex != 0)
if (JOY_REPEAT(DPAD_UP) && list->monList->currIndex != 0)
{
structPtr->monList->currIndex--;
structPtr->selectedPos = 0;
GetMonRibbons(structPtr);
list->monList->currIndex--;
list->selectedPos = 0;
GetMonRibbons(list);
return RIBBONS_SUMMARY_FUNC_SWITCH_MONS;
}
if (JOY_REPEAT(DPAD_DOWN) && structPtr->monList->currIndex < structPtr->monList->listCount - 1)
if (JOY_REPEAT(DPAD_DOWN) && list->monList->currIndex < list->monList->listCount - 1)
{
structPtr->monList->currIndex++;
structPtr->selectedPos = 0;
GetMonRibbons(structPtr);
list->monList->currIndex++;
list->selectedPos = 0;
GetMonRibbons(list);
return RIBBONS_SUMMARY_FUNC_SWITCH_MONS;
}
if (JOY_NEW(A_BUTTON))
{
// Enter ribbon selection
structPtr->callback = HandleExpandedRibbonInput;
list->callback = HandleExpandedRibbonInput;
return RIBBONS_SUMMARY_FUNC_SELECT_RIBBON;
}
if (JOY_NEW(B_BUTTON))
{
// Exit ribbon summary menu
structPtr->callback = ReturnToRibbonsListFromSummary;
list->callback = ReturnToRibbonsListFromSummary;
return RIBBONS_SUMMARY_FUNC_EXIT;
}
return RIBBONS_SUMMARY_FUNC_NONE;
}
// Handles input when a ribbon is selected
static u32 HandleExpandedRibbonInput(struct PokenavSub13 *structPtr)
static u32 HandleExpandedRibbonInput(struct Pokenav_RibbonsSummaryList *list)
{
// Handle movement while a ribbon is selected
if (JOY_REPEAT(DPAD_UP) && TrySelectRibbonUp(structPtr))
if (JOY_REPEAT(DPAD_UP) && TrySelectRibbonUp(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_REPEAT(DPAD_DOWN) && TrySelectRibbonDown(structPtr))
if (JOY_REPEAT(DPAD_DOWN) && TrySelectRibbonDown(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_REPEAT(DPAD_LEFT) && TrySelectRibbonLeft(structPtr))
if (JOY_REPEAT(DPAD_LEFT) && TrySelectRibbonLeft(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_REPEAT(DPAD_RIGHT) && TrySelectRibbonRight(structPtr))
if (JOY_REPEAT(DPAD_RIGHT) && TrySelectRibbonRight(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_NEW(B_BUTTON))
{
// Exit ribbon selection
structPtr->callback = RibbonsSummaryHandleInput;
list->callback = RibbonsSummaryHandleInput;
return RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL;
}
return RIBBONS_SUMMARY_FUNC_NONE;
}
static u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *structPtr)
static u32 ReturnToRibbonsListFromSummary(struct Pokenav_RibbonsSummaryList *list)
{
return POKENAV_RIBBONS_RETURN_TO_MON_LIST;
}
static bool32 TrySelectRibbonUp(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonUp(struct Pokenav_RibbonsSummaryList *list)
{
if (structPtr->selectedPos < FIRST_GIFT_RIBBON)
if (list->selectedPos < FIRST_GIFT_RIBBON)
{
// In normal ribbons, try to move up a row
if (structPtr->selectedPos < RIBBONS_PER_ROW)
if (list->selectedPos < RIBBONS_PER_ROW)
return FALSE;
structPtr->selectedPos -= RIBBONS_PER_ROW;
list->selectedPos -= RIBBONS_PER_ROW;
return TRUE;
}
if (structPtr->numNormalRibbons != 0)
if (list->numNormalRibbons != 0)
{
// In gift ribbons, try to move up into normal ribbons
// If there's > 1 row of gift ribbons (not normally possible)
// it's impossible to move up between them
u32 ribbonPos = structPtr->selectedPos - GIFT_RIBBON_START_POS;
structPtr->selectedPos = ribbonPos + structPtr->normalRibbonLastRowStart;
if (structPtr->selectedPos >= structPtr->numNormalRibbons)
structPtr->selectedPos = structPtr->numNormalRibbons - 1;
u32 ribbonPos = list->selectedPos - GIFT_RIBBON_START_POS;
list->selectedPos = ribbonPos + list->normalRibbonLastRowStart;
if (list->selectedPos >= list->numNormalRibbons)
list->selectedPos = list->numNormalRibbons - 1;
return TRUE;
}
return FALSE;
}
static bool32 TrySelectRibbonDown(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonDown(struct Pokenav_RibbonsSummaryList *list)
{
if (structPtr->selectedPos >= FIRST_GIFT_RIBBON)
if (list->selectedPos >= FIRST_GIFT_RIBBON)
return FALSE;
if (structPtr->selectedPos < structPtr->normalRibbonLastRowStart)
if (list->selectedPos < list->normalRibbonLastRowStart)
{
// Not in last row of normal ribbons, advance to next row
structPtr->selectedPos += RIBBONS_PER_ROW;
if (structPtr->selectedPos >= structPtr->numNormalRibbons)
structPtr->selectedPos = structPtr->numNormalRibbons - 1;
list->selectedPos += RIBBONS_PER_ROW;
if (list->selectedPos >= list->numNormalRibbons)
list->selectedPos = list->numNormalRibbons - 1;
return TRUE;
}
if (structPtr->numGiftRibbons != 0)
if (list->numGiftRibbons != 0)
{
// In/beyond last of row of normal ribbons and gift ribbons present, move down to gift ribbon row
int ribbonPos = structPtr->selectedPos - structPtr->normalRibbonLastRowStart;
if (ribbonPos >= structPtr->numGiftRibbons)
ribbonPos = structPtr->numGiftRibbons - 1;
int ribbonPos = list->selectedPos - list->normalRibbonLastRowStart;
if (ribbonPos >= list->numGiftRibbons)
ribbonPos = list->numGiftRibbons - 1;
structPtr->selectedPos = ribbonPos + GIFT_RIBBON_START_POS;
list->selectedPos = ribbonPos + GIFT_RIBBON_START_POS;
return TRUE;
}
return FALSE;
}
static bool32 TrySelectRibbonLeft(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonLeft(struct Pokenav_RibbonsSummaryList *list)
{
u16 column = structPtr->selectedPos % RIBBONS_PER_ROW;
u16 column = list->selectedPos % RIBBONS_PER_ROW;
if (column != 0)
{
structPtr->selectedPos--;
list->selectedPos--;
return TRUE;
}
return FALSE;
}
static bool32 TrySelectRibbonRight(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonRight(struct Pokenav_RibbonsSummaryList *list)
{
int column = structPtr->selectedPos % RIBBONS_PER_ROW;
int column = list->selectedPos % RIBBONS_PER_ROW;
if (column >= RIBBONS_PER_ROW - 1)
return FALSE;
if (structPtr->selectedPos < GIFT_RIBBON_START_POS)
if (list->selectedPos < GIFT_RIBBON_START_POS)
{
// Move right in normal ribbon row
if (structPtr->selectedPos < structPtr->numNormalRibbons - 1)
if (list->selectedPos < list->numNormalRibbons - 1)
{
structPtr->selectedPos++;
list->selectedPos++;
return TRUE;
}
}
else
{
// Move right in gift ribbon row
if (column < structPtr->numGiftRibbons - 1)
if (column < list->numGiftRibbons - 1)
{
structPtr->selectedPos++;
list->selectedPos++;
return TRUE;
}
}
@ -365,21 +365,21 @@ static bool32 TrySelectRibbonRight(struct PokenavSub13 *structPtr)
static u32 GetRibbonsSummaryCurrentIndex(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->monList->currIndex;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->monList->currIndex;
}
static u32 GetRibbonsSummaryMonListCount(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->monList->listCount;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->monList->listCount;
}
static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavMonList *mons = list->monList;
struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
{
@ -402,9 +402,9 @@ static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender)
static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *otId)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavMonList *mons = list->monList;
struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
{
@ -426,9 +426,9 @@ static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *ot
static u32 GetCurrMonRibbonCount(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavMonList *mons = list->monList;
struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
return GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBON_COUNT);
@ -436,20 +436,20 @@ static u32 GetCurrMonRibbonCount(void)
return GetBoxMonDataAt(monInfo->boxId, monInfo->monId, MON_DATA_RIBBON_COUNT);
}
static void GetMonRibbons(struct PokenavSub13 *structPtr)
static void GetMonRibbons(struct Pokenav_RibbonsSummaryList *list)
{
u32 ribbonFlags;
s32 i, j;
struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
struct PokenavMonList *mons = list->monList;
struct PokenavMonListItem *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
ribbonFlags = GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBONS);
else
ribbonFlags = GetBoxMonDataAt(monInfo->boxId, monInfo->monId, MON_DATA_RIBBONS);
structPtr->numNormalRibbons = 0;
structPtr->numGiftRibbons = 0;
list->numNormalRibbons = 0;
list->numGiftRibbons = 0;
for (i = 0; i < ARRAY_COUNT(sRibbonData); i++)
{
// For all non-contest ribbons, numRibbons will be 1 if they have it, 0 if they don't
@ -458,119 +458,119 @@ static void GetMonRibbons(struct PokenavSub13 *structPtr)
if (!sRibbonData[i].isGiftRibbon)
{
for (j = 0; j < numRibbons; j++)
structPtr->ribbonIds[structPtr->numNormalRibbons++] = sRibbonData[i].ribbonId + j;
list->ribbonIds[list->numNormalRibbons++] = sRibbonData[i].ribbonId + j;
}
else
{
for (j = 0; j < numRibbons; j++)
structPtr->giftRibbonIds[structPtr->numGiftRibbons++] = sRibbonData[i].ribbonId + j;
list->giftRibbonIds[list->numGiftRibbons++] = sRibbonData[i].ribbonId + j;
}
ribbonFlags >>= sRibbonData[i].numBits;
}
if (structPtr->numNormalRibbons != 0)
if (list->numNormalRibbons != 0)
{
structPtr->normalRibbonLastRowStart = ((structPtr->numNormalRibbons - 1) / RIBBONS_PER_ROW) * RIBBONS_PER_ROW;
structPtr->selectedPos = 0;
list->normalRibbonLastRowStart = ((list->numNormalRibbons - 1) / RIBBONS_PER_ROW) * RIBBONS_PER_ROW;
list->selectedPos = 0;
}
else
{
// There are no normal ribbons, move cursor to first gift ribbon
structPtr->normalRibbonLastRowStart = 0;
structPtr->selectedPos = GIFT_RIBBON_START_POS;
list->normalRibbonLastRowStart = 0;
list->selectedPos = GIFT_RIBBON_START_POS;
}
}
static u32 *GetNormalRibbonIds(u32 *size)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = structPtr->numNormalRibbons;
return structPtr->ribbonIds;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = list->numNormalRibbons;
return list->ribbonIds;
}
static u32 *GetGiftRibbonIds(u32 *size)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = structPtr->numGiftRibbons;
return structPtr->giftRibbonIds;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = list->numGiftRibbons;
return list->giftRibbonIds;
}
static u16 GetSelectedPosition(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->selectedPos;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->selectedPos;
}
static u32 GetRibbonId(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
int ribbonPos = structPtr->selectedPos;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
int ribbonPos = list->selectedPos;
if (ribbonPos < FIRST_GIFT_RIBBON)
return structPtr->ribbonIds[ribbonPos];
return list->ribbonIds[ribbonPos];
else
return structPtr->giftRibbonIds[ribbonPos - GIFT_RIBBON_START_POS];
return list->giftRibbonIds[ribbonPos - GIFT_RIBBON_START_POS];
}
bool32 OpenRibbonsSummaryMenu(void)
{
struct PokenavSub14 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, sizeof(struct PokenavSub14));
if (structPtr == NULL)
struct Pokenav_RibbonsSummaryMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, sizeof(struct Pokenav_RibbonsSummaryMenu));
if (menu == NULL)
return FALSE;
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1);
structPtr->callback = GetCurrentLoopedTaskActive;
menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1);
menu->callback = GetCurrentLoopedTaskActive;
return TRUE;
}
void CreateRibbonsSummaryLoopedTask(s32 id)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
structPtr->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1);
structPtr->callback = GetCurrentLoopedTaskActive;
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
menu->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1);
menu->callback = GetCurrentLoopedTaskActive;
}
u32 IsRibbonsSummaryLoopedTaskActive(void)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return structPtr->callback();
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return menu->callback();
}
void FreeRibbonsSummaryScreen2(void)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
RemoveWindow(structPtr->ribbonCountWindowId);
RemoveWindow(structPtr->nameWindowId);
RemoveWindow(structPtr->listIdxWindowId);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
RemoveWindow(menu->ribbonCountWindowId);
RemoveWindow(menu->nameWindowId);
RemoveWindow(menu->listIdxWindowId);
#ifndef BUGFIX
RemoveWindow(structPtr->unusedWindowId); // Removing window, but window id is never set
RemoveWindow(menu->unusedWindowId); // Removing window, but window id is never set
#endif
DestroyRibbonsMonFrontPic(structPtr);
DestroyRibbonsMonFrontPic(menu);
FreeSpriteTilesByTag(GFXTAG_RIBBON_ICONS_BIG);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_1);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_2);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_3);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_4);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_5);
FreeSpriteOamMatrix(structPtr->bigRibbonSprite);
DestroySprite(structPtr->bigRibbonSprite);
FreeSpriteOamMatrix(menu->bigRibbonSprite);
DestroySprite(menu->bigRibbonSprite);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
}
static bool32 GetCurrentLoopedTaskActive(void)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return IsLoopedTaskActive(structPtr->loopedTaskId);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return IsLoopedTaskActive(menu->loopedTaskId);
}
static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
InitBgTemplates(sBgTemplates, ARRAY_COUNT(sBgTemplates));
DecompressAndCopyTileDataToVram(2, gPokenavRibbonsSummaryBg_Gfx, 0, 0, 0);
SetBgTilemapBuffer(2, structPtr->tilemapBuffers[0]);
SetBgTilemapBuffer(2, menu->tilemapBuffers[0]);
CopyToBgTilemapBuffer(2, gPokenavRibbonsSummaryBg_Tilemap, 0, 0);
CopyPaletteIntoBufferUnfaded(gPokenavRibbonsSummaryBg_Pal, 0x10, 0x20);
CopyBgTilemapBufferToVram(2);
@ -580,7 +580,7 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
{
BgDmaFill(1, 0, 0, 1);
DecompressAndCopyTileDataToVram(1, sRibbonIconsSmall_Gfx, 0, 1, 0);
SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]);
SetBgTilemapBuffer(1, menu->tilemapBuffers[1]);
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 32, 20);
CopyPaletteIntoBufferUnfaded(sRibbonIcons1_Pal, 0x20, 0xA0);
CopyPaletteIntoBufferUnfaded(sMonInfo_Pal, 0xA0, 0x20);
@ -591,21 +591,21 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
case 2:
if (!FreeTempTileDataBuffersIfPossible())
{
AddRibbonCountWindow(structPtr);
AddRibbonCountWindow(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 3:
if (!FreeTempTileDataBuffersIfPossible())
{
AddRibbonSummaryMonNameWindow(structPtr);
AddRibbonSummaryMonNameWindow(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 4:
if (!FreeTempTileDataBuffersIfPossible())
{
AddRibbonListIndexWindow(structPtr);
AddRibbonListIndexWindow(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
@ -619,18 +619,18 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
case 6:
if (!IsDma3ManagerBusyWithBgCopy())
{
ResetSpritesAndDrawMonFrontPic(structPtr);
ResetSpritesAndDrawMonFrontPic(menu);
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
case 7:
DrawAllRibbonsSmall(structPtr);
DrawAllRibbonsSmall(menu);
PrintHelpBarText(HELPBAR_RIBBONS_LIST);
return LT_INC_AND_PAUSE;
case 8:
if (!IsDma3ManagerBusyWithBgCopy())
{
CreateBigRibbonSprite(structPtr);
CreateBigRibbonSprite(menu);
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(2, 0, BG_COORD_SET);
@ -638,7 +638,7 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
ShowBg(1);
ShowBg(2);
HideBg(3);
PokenavFadeScreen(1);
PokenavFadeScreen(POKENAV_FADE_FROM_BLACK);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
@ -655,7 +655,7 @@ static u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state)
{
case 0:
PlaySE(SE_SELECT);
PokenavFadeScreen(0);
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
return LT_INC_AND_PAUSE;
case 1:
if (IsPaletteFadeActive())
@ -667,38 +667,38 @@ static u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state)
static u32 LoopedTask_SwitchRibbonsSummaryMon(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
SlideMonSpriteOff(structPtr);
SlideMonSpriteOff(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsMonSpriteAnimating(structPtr))
if (!IsMonSpriteAnimating(menu))
{
PrintRibbbonsSummaryMonInfo(structPtr);
PrintRibbbonsSummaryMonInfo(menu);
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
case 2:
DrawAllRibbonsSmall(structPtr);
DrawAllRibbonsSmall(menu);
return LT_INC_AND_CONTINUE;
case 3:
PrintRibbonsMonListIndex(structPtr);
PrintRibbonsMonListIndex(menu);
return LT_INC_AND_CONTINUE;
case 4:
PrintCurrentMonRibbonCount(structPtr);
PrintCurrentMonRibbonCount(menu);
return LT_INC_AND_CONTINUE;
case 5:
if (!IsDma3ManagerBusyWithBgCopy())
{
SlideMonSpriteOn(structPtr);
SlideMonSpriteOn(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 6:
if (IsMonSpriteAnimating(structPtr))
if (IsMonSpriteAnimating(menu))
return LT_PAUSE;
}
return LT_FINISH;
@ -706,17 +706,17 @@ static u32 LoopedTask_SwitchRibbonsSummaryMon(s32 state)
static u32 LoopedTask_ExpandSelectedRibbon(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
UpdateAndZoomInSelectedRibbon(structPtr);
UpdateAndZoomInSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
PrintRibbonNameAndDescription(structPtr);
PrintRibbonNameAndDescription(menu);
PrintHelpBarText(HELPBAR_RIBBONS_CHECK);
return LT_INC_AND_PAUSE;
}
@ -730,24 +730,24 @@ static u32 LoopedTask_ExpandSelectedRibbon(s32 state)
static u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
ZoomOutSelectedRibbon(structPtr);
ZoomOutSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
UpdateAndZoomInSelectedRibbon(structPtr);
UpdateAndZoomInSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 2:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
PrintRibbonNameAndDescription(structPtr);
PrintRibbonNameAndDescription(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
@ -760,17 +760,17 @@ static u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state)
static u32 LoopedTask_ShrinkExpandedRibbon(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
ZoomOutSelectedRibbon(structPtr);
ZoomOutSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
PrintCurrentMonRibbonCount(structPtr);
PrintCurrentMonRibbonCount(menu);
PrintHelpBarText(HELPBAR_RIBBONS_LIST);
return LT_INC_AND_PAUSE;
}
@ -793,14 +793,14 @@ static const struct WindowTemplate sRibbonCountWindowTemplate =
.baseBlock = 0x14,
};
static void AddRibbonCountWindow(struct PokenavSub14 *structPtr)
static void AddRibbonCountWindow(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate);
PutWindowTilemap(structPtr->ribbonCountWindowId);
PrintCurrentMonRibbonCount(structPtr);
menu->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate);
PutWindowTilemap(menu->ribbonCountWindowId);
PrintCurrentMonRibbonCount(menu);
}
static void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr)
static void PrintCurrentMonRibbonCount(struct Pokenav_RibbonsSummaryMenu *menu)
{
u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY};
@ -808,23 +808,23 @@ static void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr)
DynamicPlaceholderTextUtil_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_RibbonsF700);
FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4));
AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, 1, color, TEXT_SKIP_DRAW, gStringVar4);
CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX);
FillWindowPixelBuffer(menu->ribbonCountWindowId, PIXEL_FILL(4));
AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, 1, color, TEXT_SKIP_DRAW, gStringVar4);
CopyWindowToVram(menu->ribbonCountWindowId, COPYWIN_GFX);
}
static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr)
static void PrintRibbonNameAndDescription(struct Pokenav_RibbonsSummaryMenu *menu)
{
s32 i;
u32 ribbonId = GetRibbonId();
u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY};
FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4));
FillWindowPixelBuffer(menu->ribbonCountWindowId, PIXEL_FILL(4));
if (ribbonId < FIRST_GIFT_RIBBON)
{
// Print normal ribbon name/description
for (i = 0; i < 2; i++)
AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gRibbonDescriptionPointers[ribbonId][i]);
AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gRibbonDescriptionPointers[ribbonId][i]);
}
else
{
@ -840,10 +840,10 @@ static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr)
// Print gift ribbon name/description
ribbonId--;
for (i = 0; i < 2; i++)
AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gGiftRibbonDescriptionPointers[ribbonId][i]);
AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gGiftRibbonDescriptionPointers[ribbonId][i]);
}
CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX);
CopyWindowToVram(menu->ribbonCountWindowId, COPYWIN_GFX);
}
static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate =
@ -857,23 +857,23 @@ static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate =
.baseBlock = 0x54,
};
static void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *structPtr)
static void AddRibbonSummaryMonNameWindow(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate);
PutWindowTilemap(structPtr->nameWindowId);
PrintRibbbonsSummaryMonInfo(structPtr);
menu->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate);
PutWindowTilemap(menu->nameWindowId);
PrintRibbbonsSummaryMonInfo(menu);
}
static const u8 sMaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GRAY}{WHITE}{LIGHT_GRAY}");
static const u8 sFemaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GRAY}{WHITE}{LIGHT_GRAY}");
static const u8 sGenderlessIconString[] = _("{UNK_SPACER}");
static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr)
static void PrintRibbbonsSummaryMonInfo(struct Pokenav_RibbonsSummaryMenu *menu)
{
const u8 *genderTxt;
u8 *txtPtr;
u8 level, gender;
u16 windowId = structPtr->nameWindowId;
u16 windowId = menu->nameWindowId;
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
GetMonNicknameLevelGender(gStringVar3, &level, &gender);
@ -914,15 +914,15 @@ static const struct WindowTemplate sRibbonMonListIndexWindowTemplate[] =
{},
};
static void AddRibbonListIndexWindow(struct PokenavSub14 *structPtr)
static void AddRibbonListIndexWindow(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate);
FillWindowPixelBuffer(structPtr->listIdxWindowId, PIXEL_FILL(1));
PutWindowTilemap(structPtr->listIdxWindowId);
PrintRibbonsMonListIndex(structPtr);
menu->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate);
FillWindowPixelBuffer(menu->listIdxWindowId, PIXEL_FILL(1));
PutWindowTilemap(menu->listIdxWindowId);
PrintRibbonsMonListIndex(menu);
}
static void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr)
static void PrintRibbonsMonListIndex(struct Pokenav_RibbonsSummaryMenu *menu)
{
s32 x;
u8 *txtPtr;
@ -933,24 +933,24 @@ static void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr)
*(txtPtr++) = CHAR_SLASH;
ConvertIntToDecimalStringN(txtPtr, count, STR_CONV_MODE_RIGHT_ALIGN, 3);
x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar1, 56);
AddTextPrinterParameterized(structPtr->listIdxWindowId, FONT_NORMAL, gStringVar1, x, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(structPtr->listIdxWindowId, COPYWIN_GFX);
AddTextPrinterParameterized(menu->listIdxWindowId, FONT_NORMAL, gStringVar1, x, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(menu->listIdxWindowId, COPYWIN_GFX);
}
static void ResetSpritesAndDrawMonFrontPic(struct PokenavSub14 *structPtr)
static void ResetSpritesAndDrawMonFrontPic(struct Pokenav_RibbonsSummaryMenu *menu)
{
u16 species;
u32 personality, otId;
GetMonSpeciesPersonalityOtId(&species, &personality, &otId);
ResetAllPicSprites();
structPtr->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_ON, MON_SPRITE_Y);
menu->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_ON, MON_SPRITE_Y);
PokenavFillPalette(15, 0);
}
static void DestroyRibbonsMonFrontPic(struct PokenavSub14 *structPtr)
static void DestroyRibbonsMonFrontPic(struct Pokenav_RibbonsSummaryMenu *menu)
{
FreeAndDestroyMonPicSprite(structPtr->monSpriteId);
FreeAndDestroyMonPicSprite(menu->monSpriteId);
}
// x and y arguments are ignored
@ -967,25 +967,25 @@ static u16 DrawRibbonsMonFrontPic(s32 x, s32 y)
return spriteId;
}
static void SlideMonSpriteOff(struct PokenavSub14 *structPtr)
static void SlideMonSpriteOff(struct Pokenav_RibbonsSummaryMenu *menu)
{
StartMonSpriteSlide(&gSprites[structPtr->monSpriteId], MON_SPRITE_X_ON, MON_SPRITE_X_OFF, 6);
StartMonSpriteSlide(&gSprites[menu->monSpriteId], MON_SPRITE_X_ON, MON_SPRITE_X_OFF, 6);
}
static void SlideMonSpriteOn(struct PokenavSub14 *structPtr)
static void SlideMonSpriteOn(struct Pokenav_RibbonsSummaryMenu *menu)
{
// Switch to new mon sprite
FreeAndDestroyMonPicSprite(structPtr->monSpriteId);
structPtr->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_OFF, MON_SPRITE_Y);
FreeAndDestroyMonPicSprite(menu->monSpriteId);
menu->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_OFF, MON_SPRITE_Y);
// Slide on
StartMonSpriteSlide(&gSprites[structPtr->monSpriteId], MON_SPRITE_X_OFF, MON_SPRITE_X_ON, 6);
StartMonSpriteSlide(&gSprites[menu->monSpriteId], MON_SPRITE_X_OFF, MON_SPRITE_X_ON, 6);
}
// Is Pokémon summary sprite still sliding off/on
static bool32 IsMonSpriteAnimating(struct PokenavSub14 *structPtr)
static bool32 IsMonSpriteAnimating(struct Pokenav_RibbonsSummaryMenu *menu)
{
return (gSprites[structPtr->monSpriteId].callback != SpriteCallbackDummy);
return (gSprites[menu->monSpriteId].callback != SpriteCallbackDummy);
}
#define sCurrX data[0]
@ -1030,7 +1030,7 @@ static void SpriteCB_MonSpriteSlide(struct Sprite *sprite)
#undef sTime
#undef sDestX
static void DrawAllRibbonsSmall(struct PokenavSub14 *structPtr)
static void DrawAllRibbonsSmall(struct Pokenav_RibbonsSummaryMenu *menu)
{
u32 *ribbonIds;
@ -1211,7 +1211,7 @@ static const struct SpriteTemplate sSpriteTemplate_RibbonIconBig =
};
// Create dummy sprite to be used for the zoomed in version of the selected ribbon
static void CreateBigRibbonSprite(struct PokenavSub14 *structPtr)
static void CreateBigRibbonSprite(struct Pokenav_RibbonsSummaryMenu *menu)
{
u8 spriteId;
@ -1219,45 +1219,45 @@ static void CreateBigRibbonSprite(struct PokenavSub14 *structPtr)
Pokenav_AllocAndLoadPalettes(sSpritePalettes_RibbonIcons);
spriteId = CreateSprite(&sSpriteTemplate_RibbonIconBig, 0, 0, 0);
structPtr->bigRibbonSprite = &gSprites[spriteId];
structPtr->bigRibbonSprite->invisible = TRUE;
menu->bigRibbonSprite = &gSprites[spriteId];
menu->bigRibbonSprite->invisible = TRUE;
}
#define sInvisibleWhenDone data[0]
static void UpdateAndZoomInSelectedRibbon(struct PokenavSub14 *structPtr)
static void UpdateAndZoomInSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *menu)
{
u32 ribbonId;
s32 position = GetSelectedPosition();
s32 x = (position % RIBBONS_PER_ROW) * 16 + 96;
s32 y = (position / RIBBONS_PER_ROW) * 16 + 40;
structPtr->bigRibbonSprite->x = x;
structPtr->bigRibbonSprite->y = y;
menu->bigRibbonSprite->x = x;
menu->bigRibbonSprite->y = y;
// Set new selected ribbon's gfx data
ribbonId = GetRibbonId();
structPtr->bigRibbonSprite->oam.tileNum = (sRibbonGfxData[ribbonId].tileNumOffset * 16) + GetSpriteTileStartByTag(GFXTAG_RIBBON_ICONS_BIG);
structPtr->bigRibbonSprite->oam.paletteNum = IndexOfSpritePaletteTag(sRibbonGfxData[ribbonId].palNumOffset + PALTAG_RIBBON_ICONS_1);
menu->bigRibbonSprite->oam.tileNum = (sRibbonGfxData[ribbonId].tileNumOffset * 16) + GetSpriteTileStartByTag(GFXTAG_RIBBON_ICONS_BIG);
menu->bigRibbonSprite->oam.paletteNum = IndexOfSpritePaletteTag(sRibbonGfxData[ribbonId].palNumOffset + PALTAG_RIBBON_ICONS_1);
// Start zoom in animation
StartSpriteAffineAnim(structPtr->bigRibbonSprite, RIBBONANIM_ZOOM_IN);
structPtr->bigRibbonSprite->invisible = FALSE;
structPtr->bigRibbonSprite->sInvisibleWhenDone = FALSE;
structPtr->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
StartSpriteAffineAnim(menu->bigRibbonSprite, RIBBONANIM_ZOOM_IN);
menu->bigRibbonSprite->invisible = FALSE;
menu->bigRibbonSprite->sInvisibleWhenDone = FALSE;
menu->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
}
// Start animation to zoom out of selected ribbon
static void ZoomOutSelectedRibbon(struct PokenavSub14 *structPtr)
static void ZoomOutSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->bigRibbonSprite->sInvisibleWhenDone = TRUE;
StartSpriteAffineAnim(structPtr->bigRibbonSprite, RIBBONANIM_ZOOM_OUT);
structPtr->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
menu->bigRibbonSprite->sInvisibleWhenDone = TRUE;
StartSpriteAffineAnim(menu->bigRibbonSprite, RIBBONANIM_ZOOM_OUT);
menu->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
}
static bool32 IsRibbonAnimating(struct PokenavSub14 *structPtr)
static bool32 IsRibbonAnimating(struct Pokenav_RibbonsSummaryMenu *menu)
{
return (structPtr->bigRibbonSprite->callback != SpriteCallbackDummy);
return (menu->bigRibbonSprite->callback != SpriteCallbackDummy);
}
static void SpriteCB_WaitForRibbonAnimation(struct Sprite *sprite)

View File

@ -490,7 +490,7 @@ static const struct SpriteTemplate sSpriteTemplate_DuoFightPre_KyogreDorsalFin =
static const struct ScanlineEffectParams sScanlineParams_DuoFight_Clouds =
{
.dmaDest = (vu16 *)REG_ADDR_BG1HOFS,
.dmaDest = &REG_BG1HOFS,
.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT,
.initState = 1
};

View File

@ -116,19 +116,18 @@ static void CB_FadeInFlyMap(void);
static void CB_HandleFlyMapInput(void);
static void CB_ExitFlyMap(void);
// .rodata
static const u16 sRegionMapCursorPal[] = INCBIN_U16("graphics/pokenav/cursor.gbapal");
static const u32 sRegionMapCursorSmallGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_small.4bpp.lz");
static const u32 sRegionMapCursorLargeGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_large.4bpp.lz");
// NOTE: Some of the below graphics are not in graphics/pokenav/region_map
// because porymap expects them to be in their current location.
static const u16 sRegionMapCursorPal[] = INCBIN_U16("graphics/pokenav/region_map/cursor.gbapal");
static const u32 sRegionMapCursorSmallGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/cursor_small.4bpp.lz");
static const u32 sRegionMapCursorLargeGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/cursor_large.4bpp.lz");
static const u16 sRegionMapBg_Pal[] = INCBIN_U16("graphics/pokenav/region_map.gbapal");
static const u32 sRegionMapBg_GfxLZ[] = INCBIN_U32("graphics/pokenav/region_map.8bpp.lz");
static const u32 sRegionMapBg_TilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map_map.bin.lz");
static const u16 sRegionMapPlayerIcon_BrendanPal[] = INCBIN_U16("graphics/pokenav/brendan_icon.gbapal");
static const u8 sRegionMapPlayerIcon_BrendanGfx[] = INCBIN_U8("graphics/pokenav/brendan_icon.4bpp");
static const u16 sRegionMapPlayerIcon_MayPal[] = INCBIN_U16("graphics/pokenav/may_icon.gbapal");
static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/may_icon.4bpp");
static const u16 sRegionMapPlayerIcon_BrendanPal[] = INCBIN_U16("graphics/pokenav/region_map/brendan_icon.gbapal");
static const u8 sRegionMapPlayerIcon_BrendanGfx[] = INCBIN_U8("graphics/pokenav/region_map/brendan_icon.4bpp");
static const u16 sRegionMapPlayerIcon_MayPal[] = INCBIN_U16("graphics/pokenav/region_map/may_icon.gbapal");
static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/region_map/may_icon.4bpp");
static const u8 sRegionMap_MapSectionLayout[] = INCBIN_U8("graphics/pokenav/region_map_section_layout.bin");
#include "data/region_map/region_map_entries.h"
@ -283,15 +282,11 @@ static const u8 sMapSecIdsOffMap[] =
MAPSEC_NAVEL_ROCK
};
static const u16 sRegionMapFramePal[] = INCBIN_U16("graphics/pokenav/map_frame.gbapal");
static const u32 sRegionMapFrameGfxLZ[] = INCBIN_U32("graphics/pokenav/map_frame.4bpp.lz");
static const u32 sRegionMapFrameTilemapLZ[] = INCBIN_U32("graphics/pokenav/map_frame.bin.lz");
static const u16 sFlyTargetIcons_Pal[] = INCBIN_U16("graphics/pokenav/fly_target_icons.gbapal");
static const u32 sFlyTargetIcons_Gfx[] = INCBIN_U32("graphics/pokenav/fly_target_icons.4bpp.lz");
static const u16 sRegionMapFramePal[] = INCBIN_U16("graphics/pokenav/region_map/frame.gbapal");
static const u32 sRegionMapFrameGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/frame.4bpp.lz");
static const u32 sRegionMapFrameTilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map/frame.bin.lz");
static const u16 sFlyTargetIcons_Pal[] = INCBIN_U16("graphics/pokenav/region_map/fly_target_icons.gbapal");
static const u32 sFlyTargetIcons_Gfx[] = INCBIN_U32("graphics/pokenav/region_map/fly_target_icons.4bpp.lz");
static const u8 sMapHealLocations[][3] =
{

View File

@ -990,7 +990,7 @@ const u8 gText_Unknown[] = _("UNKNOWN");
const u8 gText_Call[] = _("CALL");
const u8 gText_Check[] = _("CHECK");
const u8 gText_Cancel6[] = _("CANCEL");
const u8 gText_NumberF700[] = _("No. {DYNAMIC 0}");
const u8 gText_NumberIndex[] = _("No. {DYNAMIC 0}");
const u8 gText_RibbonsF700[] = _("RIBBONS {DYNAMIC 0}");
const u8 gText_PokemonMaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_RED WHITE GREEN}♂{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused
const u8 gText_PokemonFemaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_GREEN WHITE BLUE}♀{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused

View File

@ -57,14 +57,14 @@ struct UsePokeblockSession
u8 mainState;
u8 unused1;
u8 timer;
u8 statId;
u8 condition;
u8 numEnhancements;
u8 unused2;
bool8 monInTopHalf;
u8 conditionsBeforeBlock[FLAVOR_COUNT];
u8 conditionsAfterBlock[FLAVOR_COUNT];
u8 enhancements[FLAVOR_COUNT];
s16 pokeblockStatBoosts[FLAVOR_COUNT];
u8 conditionsBeforeBlock[CONDITION_COUNT];
u8 conditionsAfterBlock[CONDITION_COUNT];
u8 enhancements[CONDITION_COUNT];
s16 pokeblockStatBoosts[CONDITION_COUNT];
u8 numSelections; // num in party + 1 (for Cancel)
u8 curSelection;
bool8 (*loadNewSelection)(void);
@ -73,7 +73,7 @@ struct UsePokeblockSession
u8 natureText[34];
};
// This struct is identical to PokenavMonList, the struct used for managing lists of pokemon in the pokenav
// This struct is identical to PokenavMonListItem, the struct used for managing lists of pokemon in the pokenav
// Given that this screen is essentially duplicated in the poknav, this struct was probably the same one with
// a more general name/purpose
// TODO: Once the pokenav conditions screens are documented, resolve the above
@ -142,7 +142,7 @@ static void LoadAndCreateUpDownSprites(void);
static void CalculateNumAdditionalSparkles(u8);
static void PrintFirstEnhancement(void);
static bool8 TryPrintNextEnhancement(void);
static void BufferEnhancedStatText(u8 *, u8, s16);
static void BufferEnhancedText(u8 *, u8, s16);
static void PrintMenuWindowText(const u8 *);
static void CalculatePokeblockEffectiveness(struct Pokeblock *, struct Pokemon *);
static void SpriteCB_UpDown(struct Sprite *);
@ -178,22 +178,22 @@ static const u32 sGraphData_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_scree
// The condition/flavors aren't listed in their normal order in this file, they're listed as shown on the graph going counter-clockwise
// Normally they would go Cool/Spicy, Beauty/Dry, Cute/Sweet, Smart/Bitter, Tough/Sour (also graph order, but clockwise)
static const u32 sMonDataConditions[FLAVOR_COUNT] =
static const u32 sConditionToMonData[CONDITION_COUNT] =
{
MON_DATA_COOL,
MON_DATA_TOUGH,
MON_DATA_SMART,
MON_DATA_CUTE,
MON_DATA_BEAUTY
[CONDITION_COOL] = MON_DATA_COOL,
[CONDITION_TOUGH] = MON_DATA_TOUGH,
[CONDITION_SMART] = MON_DATA_SMART,
[CONDITION_CUTE] = MON_DATA_CUTE,
[CONDITION_BEAUTY] = MON_DATA_BEAUTY
};
static const u8 sFlavors[FLAVOR_COUNT] =
static const u8 sConditionToFlavor[CONDITION_COUNT] =
{
FLAVOR_SPICY,
FLAVOR_SOUR,
FLAVOR_BITTER,
FLAVOR_SWEET,
FLAVOR_DRY
[CONDITION_COOL] = FLAVOR_SPICY,
[CONDITION_TOUGH] = FLAVOR_SOUR,
[CONDITION_SMART] = FLAVOR_BITTER,
[CONDITION_CUTE] = FLAVOR_SWEET,
[CONDITION_BEAUTY] = FLAVOR_DRY
};
static const u8 sNatureTextColors[] =
@ -286,13 +286,13 @@ static const struct WindowTemplate sUsePokeblockYesNoWinTemplate =
.baseBlock = 0x83
};
static const u8 *const sContestStatNames[] =
static const u8 *const sConditionNames[CONDITION_COUNT] =
{
gText_Coolness,
gText_Toughness,
gText_Smartness,
gText_Cuteness,
gText_Beauty3
[CONDITION_COOL] = gText_Coolness,
[CONDITION_TOUGH] = gText_Toughness,
[CONDITION_SMART] = gText_Smartness,
[CONDITION_CUTE] = gText_Cuteness,
[CONDITION_BEAUTY] = gText_Beauty3
};
static const struct SpriteSheet sSpriteSheet_UpDown =
@ -305,13 +305,13 @@ static const struct SpritePalette sSpritePalette_UpDown =
gUsePokeblockUpDown_Pal, TAG_UP_DOWN
};
static const s16 sUpDownCoordsOnGraph[FLAVOR_COUNT][2] =
static const s16 sUpDownCoordsOnGraph[CONDITION_COUNT][2] =
{
{156, 36},
{117, 59},
{117, 118},
{197, 118},
{197, 59}
[CONDITION_COOL] = {156, 36},
[CONDITION_TOUGH] = {117, 59},
[CONDITION_SMART] = {117, 118},
[CONDITION_CUTE] = {197, 118},
[CONDITION_BEAUTY] = {197, 59}
};
static const struct OamData sOam_UpDown =
@ -471,7 +471,7 @@ static void VBlankCB_UsePokeblockMenu(void)
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
sub_81D2108(&sMenu->graph);
ConditionGraph_Draw(&sMenu->graph);
ScanlineEffect_InitHBlankDmaTransfer();
}
@ -487,7 +487,7 @@ static void LoadUsePokeblockMenu(void)
{
case 0:
sMenu->curMonSpriteId = SPRITE_NONE;
InitConditionGraphData(&sMenu->graph);
ConditionGraph_Init(&sMenu->graph);
sInfo->mainState++;
break;
case 1:
@ -537,19 +537,19 @@ static void LoadUsePokeblockMenu(void)
sInfo->mainState++;
break;
case 11:
sub_81D2754(sMenu->graph.stat[0], sMenu->graph.unk14[0]);
InitConditionGraphState(&sMenu->graph);
ConditionGraph_CalcPositions(sMenu->graph.conditions[0], sMenu->graph.savedPositions[0]);
ConditionGraph_InitResetScanline(&sMenu->graph);
sInfo->mainState++;
break;
case 12:
if (!SetupConditionGraphScanlineParams(&sMenu->graph))
if (!ConditionGraph_ResetScanline(&sMenu->graph))
{
sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[0], sMenu->graph.unk14[0]);
ConditionGraph_SetNewPositions(&sMenu->graph, sMenu->graph.savedPositions[0], sMenu->graph.savedPositions[0]);
sInfo->mainState++;
}
break;
case 13:
sub_81D2230(&sMenu->graph);
ConditionGraph_Update(&sMenu->graph);
sInfo->mainState++;
break;
case 14:
@ -767,8 +767,6 @@ static void ShowUsePokeblockMenuForResults(void)
static void ShowPokeblockResults(void)
{
u8 var;
switch (sInfo->mainState)
{
case 0:
@ -783,14 +781,13 @@ static void ShowPokeblockResults(void)
break;
case 2:
CalculateConditionEnhancements();
sub_81D2754(sInfo->conditionsAfterBlock, sMenu->graph.unk14[3]);
sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[sMenu->curLoadId], sMenu->graph.unk14[3]);
ConditionGraph_CalcPositions(sInfo->conditionsAfterBlock, sMenu->graph.savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]);
ConditionGraph_SetNewPositions(&sMenu->graph, sMenu->graph.savedPositions[sMenu->curLoadId], sMenu->graph.savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]);
LoadAndCreateUpDownSprites();
sInfo->mainState++;
break;
case 3:
var = TransitionConditionGraph(&sMenu->graph);
if (!var)
if (!ConditionGraph_TryUpdate(&sMenu->graph))
{
CalculateNumAdditionalSparkles(GetPartyIdFromSelectionId(sMenu->info.curSelection));
if (sMenu->info.curSelection != sMenu->info.numSelections - 1)
@ -906,16 +903,16 @@ static void PrintFirstEnhancement(void)
DrawTextBorderOuter(WIN_TEXT, 151, 14);
FillWindowPixelBuffer(WIN_TEXT, 17);
for (sInfo->statId = 0; sInfo->statId < FLAVOR_COUNT; sInfo->statId++)
for (sInfo->condition = 0; sInfo->condition < CONDITION_COUNT; sInfo->condition++)
{
if (sInfo->enhancements[sInfo->statId] != 0)
if (sInfo->enhancements[sInfo->condition] != 0)
break;
}
if (sInfo->statId < FLAVOR_COUNT)
BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]);
if (sInfo->condition < CONDITION_COUNT)
BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]);
else
BufferEnhancedStatText(gStringVar4, sInfo->statId, 0);
BufferEnhancedText(gStringVar4, sInfo->condition, 0);
PrintMenuWindowText(gStringVar4);
PutWindowTilemap(WIN_TEXT);
@ -928,20 +925,20 @@ static bool8 TryPrintNextEnhancement(void)
while (1)
{
sInfo->statId++;
if (sInfo->statId < FLAVOR_COUNT)
sInfo->condition++;
if (sInfo->condition < CONDITION_COUNT)
{
if (sInfo->enhancements[sInfo->statId] != 0)
if (sInfo->enhancements[sInfo->condition] != 0)
break;
}
else
{
sInfo->statId = FLAVOR_COUNT;
sInfo->condition = CONDITION_COUNT;
return FALSE;
}
}
BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]);
BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]);
PrintMenuWindowText(gStringVar4);
CopyWindowToVram(WIN_TEXT, COPYWIN_GFX);
@ -969,7 +966,7 @@ static void PrintMenuWindowText(const u8 *message)
AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL);
}
static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement)
static void BufferEnhancedText(u8 *dest, u8 condition, s16 enhancement)
{
switch (enhancement)
{
@ -979,7 +976,7 @@ static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement)
case -32768 ... -1: // if < 0
if (enhancement)
dest[(u16)enhancement] += 0; // something you can't imagine
StringCopy(dest, sContestStatNames[statId]);
StringCopy(dest, sConditionNames[condition]);
StringAppend(dest, gText_WasEnhanced);
break;
case 0:
@ -992,36 +989,36 @@ static void GetMonConditions(struct Pokemon *mon, u8 *data)
{
u16 i;
for (i = 0; i < FLAVOR_COUNT; i++)
data[i] = GetMonData(mon, sMonDataConditions[i]);
for (i = 0; i < CONDITION_COUNT; i++)
data[i] = GetMonData(mon, sConditionToMonData[i]);
}
static void AddPokeblockToConditions(struct Pokeblock *pokeblock, struct Pokemon *mon)
{
u16 i;
s16 cstat;
s16 stat;
u8 data;
if (GetMonData(mon, MON_DATA_SHEEN) != 255)
if (GetMonData(mon, MON_DATA_SHEEN) != MAX_SHEEN)
{
CalculatePokeblockEffectiveness(pokeblock, mon);
for (i = 0; i < FLAVOR_COUNT; i++)
for (i = 0; i < CONDITION_COUNT; i++)
{
data = GetMonData(mon, sMonDataConditions[i]);
cstat = data + sInfo->pokeblockStatBoosts[i];
if (cstat < 0)
cstat = 0;
if (cstat > 255)
cstat = 255;
data = cstat;
SetMonData(mon, sMonDataConditions[i], &data);
data = GetMonData(mon, sConditionToMonData[i]);
stat = data + sInfo->pokeblockStatBoosts[i];
if (stat < 0)
stat = 0;
if (stat > MAX_CONDITION)
stat = MAX_CONDITION;
data = stat;
SetMonData(mon, sConditionToMonData[i], &data);
}
cstat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel;
if (cstat > 255)
cstat = 255;
stat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel;
if (stat > MAX_SHEEN)
stat = MAX_SHEEN;
data = cstat;
data = stat;
SetMonData(mon, MON_DATA_SHEEN, &data);
}
}
@ -1035,19 +1032,19 @@ static void CalculateConditionEnhancements(void)
GetMonConditions(mon, sInfo->conditionsBeforeBlock);
AddPokeblockToConditions(sInfo->pokeblock, mon);
GetMonConditions(mon, sInfo->conditionsAfterBlock);
for (i = 0; i < FLAVOR_COUNT; i++)
for (i = 0; i < CONDITION_COUNT; i++)
sInfo->enhancements[i] = sInfo->conditionsAfterBlock[i] - sInfo->conditionsBeforeBlock[i];
}
static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct Pokemon *mon)
{
s8 i, direction, taste;
s8 i, direction, flavor;
sInfo->pokeblockStatBoosts[0] = pokeblock->spicy;
sInfo->pokeblockStatBoosts[1] = pokeblock->sour;
sInfo->pokeblockStatBoosts[2] = pokeblock->bitter;
sInfo->pokeblockStatBoosts[3] = pokeblock->sweet;
sInfo->pokeblockStatBoosts[4] = pokeblock->dry;
sInfo->pokeblockStatBoosts[CONDITION_COOL] = pokeblock->spicy;
sInfo->pokeblockStatBoosts[CONDITION_TOUGH] = pokeblock->sour;
sInfo->pokeblockStatBoosts[CONDITION_SMART] = pokeblock->bitter;
sInfo->pokeblockStatBoosts[CONDITION_CUTE] = pokeblock->sweet;
sInfo->pokeblockStatBoosts[CONDITION_BEAUTY] = pokeblock->dry;
if (gPokeblockGain > 0)
direction = 1;
@ -1056,7 +1053,7 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct
else
return;
for (i = 0; i < FLAVOR_COUNT; i++)
for (i = 0; i < CONDITION_COUNT; i++)
{
s16 amount = sInfo->pokeblockStatBoosts[i];
s8 boost = amount / 10;
@ -1064,9 +1061,9 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct
if (amount % 10 >= 5) // round to the nearest
boost++;
taste = GetMonFlavorRelation(mon, sFlavors[i]);
if (taste == direction)
sInfo->pokeblockStatBoosts[i] += boost * taste;
flavor = GetMonFlavorRelation(mon, sConditionToFlavor[i]);
if (flavor == direction)
sInfo->pokeblockStatBoosts[i] += boost * flavor;
}
}
@ -1075,7 +1072,7 @@ static bool8 IsSheenMaxed(void)
if (GetBoxOrPartyMonData(sMenu->party[sMenu->info.curSelection].boxId,
sMenu->party[sMenu->info.curSelection].monId,
MON_DATA_SHEEN,
NULL) == 255)
NULL) == MAX_SHEEN)
return TRUE;
else
return FALSE;
@ -1125,7 +1122,7 @@ static void LoadAndCreateUpDownSprites(void)
LoadSpritePalette(&sSpritePalette_UpDown);
sInfo->numEnhancements = 0;
for (i = 0; i < FLAVOR_COUNT; i++)
for (i = 0; i < CONDITION_COUNT; i++)
{
if (sInfo->enhancements[i] != 0)
{
@ -1368,7 +1365,7 @@ static bool8 LoadUsePokeblockMenuGfx(void)
LoadBgTilemap(2, sMenu->tilemapBuffer, 1280, 0);
LoadPalette(gConditionGraphData_Pal, 48, 32);
LoadPalette(gConditionText_Pal, 240, 32);
SetConditionGraphIOWindows(2);
ConditionGraph_InitWindow(2);
break;
default:
sMenu->info.helperState = 0;
@ -1419,7 +1416,7 @@ static void UpdateSelection(bool8 up)
else
newLoadId = sMenu->nextLoadId;
sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[sMenu->curLoadId], sMenu->graph.unk14[newLoadId]);
ConditionGraph_SetNewPositions(&sMenu->graph, sMenu->graph.savedPositions[sMenu->curLoadId], sMenu->graph.savedPositions[newLoadId]);
if (sMenu->info.curSelection == sMenu->info.numSelections - 1)
startedOnMon = FALSE; // moving off of Cancel
@ -1487,7 +1484,7 @@ static bool8 LoadNewSelection_CancelToMon(void)
sMenu->info.helperState++;
break;
case 2:
if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset))
if (!ConditionMenu_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset))
{
// Load the new adjacent pokemon (not the one being shown)
LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
@ -1514,7 +1511,7 @@ static bool8 LoadNewSelection_MonToCancel(void)
switch (sMenu->info.helperState)
{
case 0:
if (!TryUpdateConditionMonTransitionOff(&sMenu->graph, &sMenu->curMonXOffset))
if (!ConditionMenu_UpdateMonExit(&sMenu->graph, &sMenu->curMonXOffset))
sMenu->info.helperState++;
break;
case 1:
@ -1538,7 +1535,7 @@ static bool8 LoadNewSelection_MonToMon(void)
switch (sMenu->info.helperState)
{
case 0:
TransitionConditionGraph(&sMenu->graph);
ConditionGraph_TryUpdate(&sMenu->graph);
if (!MoveConditionMonOffscreen(&sMenu->curMonXOffset))
{
UpdateMonPic(sMenu->curLoadId);
@ -1550,7 +1547,7 @@ static bool8 LoadNewSelection_MonToMon(void)
sMenu->info.helperState++;
break;
case 2:
if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset))
if (!ConditionMenu_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset))
{
// Load the new adjacent pokemon (not the one being shown)
LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
@ -1580,9 +1577,9 @@ static void SpriteCB_MonPic(struct Sprite *sprite)
static void SpriteCB_SelectionIconPokeball(struct Sprite *sprite)
{
if (sprite->data[0] == sMenu->info.curSelection)
StartSpriteAnim(sprite, 0);
StartSpriteAnim(sprite, CONDITION_ICON_SELECTED);
else
StartSpriteAnim(sprite, 1);
StartSpriteAnim(sprite, CONDITION_ICON_UNSELECTED);
}
static void SpriteCB_SelectionIconCancel(struct Sprite *sprite)
@ -1599,10 +1596,7 @@ static void SpriteCB_SelectionIconCancel(struct Sprite *sprite)
static void CalculateNumAdditionalSparkles(u8 monIndex)
{
u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN);
sMenu->numSparkles[sMenu->curLoadId] = (sheen != 255)
? sheen / (255 / (MAX_CONDITION_SPARKLES - 1) + 1)
: MAX_CONDITION_SPARKLES - 1;
sMenu->numSparkles[sMenu->curLoadId] = GET_NUM_CONDITION_SPARKLES(sheen);
}
static void LoadConditionGfx(void)

View File

@ -50,8 +50,8 @@
.include "src/multiboot.o"
.include "src/mirage_tower.o"
.include "src/berry_fix_program.o"
.include "src/pokenav_conditions_2.o"
.include "src/pokenav_ribbons_2.o"
.include "src/pokenav_conditions_gfx.o"
.include "src/pokenav_ribbons_summary.o"
.include "src/ereader_helpers.o"
.include "src/faraway_island.o"
.include "src/m4a_1.o"

View File

@ -143,7 +143,7 @@
.include "src/pokedex_area_region_map.o"
.include "src/battle_pyramid_bag.o"
.include "src/pokenav.o"
.include "src/pokenav_match_call_ui.o"
.include "src/pokenav_list.o"
.include "src/menu_specialized.o"
.include "src/faraway_island.o"
.include "src/trainer_hill.o"