From 031da44cab0d99210aff87533333d59a71a0b85f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 28 Feb 2021 17:22:26 -0500 Subject: [PATCH] Document mon markings --- .../marker.png => misc/mon_markings_menu.png} | Bin include/graphics.h | 5 +- include/mon_markings.h | 59 ++- src/graphics.c | 4 +- src/mon_markings.c | 371 +++++++++--------- src/pokemon_storage_system.c | 14 +- src/pokemon_summary_screen.c | 2 +- src/pokenav_conditions_1.c | 2 +- src/pokenav_conditions_2.c | 10 +- 9 files changed, 240 insertions(+), 227 deletions(-) rename graphics/{pokenav/condition/marker.png => misc/mon_markings_menu.png} (100%) diff --git a/graphics/pokenav/condition/marker.png b/graphics/misc/mon_markings_menu.png similarity index 100% rename from graphics/pokenav/condition/marker.png rename to graphics/misc/mon_markings_menu.png diff --git a/include/graphics.h b/include/graphics.h index 0057563c4..b1a781fff 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4015,8 +4015,6 @@ extern const u32 gPokenavCondition_Tilemap[]; extern const u16 gPokenavOptions_Tilemap[]; extern const u32 gPokenavOptions_Gfx[]; extern const u16 gPokenavOptions_Pal[]; -extern const u8 gPokenavConditionMarker_Gfx[]; -extern const u16 gPokenavConditionMarker_Pal[]; extern const u16 gPokenavLeftHeader_Pal[]; extern const u16 gPokenavHeader_Pal[]; extern const u32 gPokenavHeader_Gfx[]; @@ -5063,4 +5061,7 @@ extern const u8 gMailTilemap_Fab[]; extern const u8 gMailTiles_Retro[]; extern const u8 gMailTilemap_Retro[]; +extern const u8 gMonMarkingsMenu_Gfx[]; +extern const u16 gMonMarkingsMenu_Pal[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/mon_markings.h b/include/mon_markings.h index 3cb04ad48..7ac88d8d2 100644 --- a/include/mon_markings.h +++ b/include/mon_markings.h @@ -1,37 +1,36 @@ -#ifndef POKEEMERALD_MON_MARKINGS_H -#define POKEEMERALD_MON_MARKINGS_H +#ifndef MON_MARKINGS_H +#define MON_MARKINGS_H #define NUM_MON_MARKINGS 4 struct PokemonMarkMenu { - /*0x0000*/ u16 baseTileTag; - /*0x0002*/ u16 basePaletteTag; - /*0x0004*/ u8 markings; // bit flags - /*0x0005*/ s8 cursorPos; - /*0x0006*/ bool8 markingsArray[NUM_MON_MARKINGS]; - /*0x000A*/ u8 cursorBaseY; - /*0x000B*/ bool8 spriteSheetLoadRequired; - /*0x000C*/ struct Sprite *menuWindowSprites[2]; // upper and lower halves of menu window - /*0x0014*/ struct Sprite *menuMarkingSprites[NUM_MON_MARKINGS]; - /*0x0024*/ struct Sprite *unkSprite; - /*0x0028*/ struct Sprite *menuTextSprite; - /*0x002C*/ const u8 *frameTiles; - /*0x0030*/ const u16 *framePalette; - /*0x0034*/ u8 menuWindowSpriteTiles[0x1000]; - /*0x1034*/ u8 filler1030[0x80]; - /*0x10B4*/ u8 tileLoadState; -}; // 10b8 + u16 baseTileTag; + u16 basePaletteTag; + u8 markings; // bit flags + s8 cursorPos; + bool8 markingsArray[NUM_MON_MARKINGS]; + u8 cursorBaseY; + bool8 spriteSheetLoadRequired; + struct Sprite *windowSprites[2]; // upper and lower halves of menu window + struct Sprite *markingSprites[NUM_MON_MARKINGS]; + struct Sprite *cursorSprite; + struct Sprite *textSprite; + const u8 *frameTiles; + const u16 *framePalette; + u8 windowSpriteTiles[0x1000]; + u8 unused[0x80]; + u8 tileLoadState; +}; -void sub_811F90C(struct PokemonMarkMenu *ptr); -void sub_811F918(void); -bool8 sub_811F960(void); -void sub_811FA90(void); -void sub_811FAA4(u8 markings, s16 x, s16 y); -void sub_811FAF8(void); -bool8 MonMarkingsMenuHandleInput(void); -struct Sprite *CreateMonMarkingsSpriteWithPal(u16 tileTag, u16 paletteTag, const u16 *palette); -struct Sprite *sub_811FFB4(u16 tileTag, u16 paletteTag, const u16 *palette); -void sub_8120084(u8 markings, void *dest); +void InitMonMarkingsMenu(struct PokemonMarkMenu *ptr); +void BufferMonMarkingsMenuWindowTiles(void); +void BufferMonMarkingsMenuTiles(void); +void OpenMonMarkingsMenu(u8 markings, s16 x, s16 y); +void FreeMonMarkingsMenu(void); +bool8 HandleMonMarkingsMenuInput(void); +struct Sprite *CreateMonMarkingAllCombosSprite(u16 tileTag, u16 paletteTag, const u16 *palette); +struct Sprite *CreateMonMarkingComboSprite(u16 tileTag, u16 paletteTag, const u16 *palette); +void UpdateMonMarkingTiles(u8 markings, void *dest); -#endif //POKEEMERALD_MON_MARKINGS_H +#endif //MON_MARKINGS_H diff --git a/src/graphics.c b/src/graphics.c index 30f5ce91f..1a3423fb6 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1346,8 +1346,8 @@ const u32 gRegionMapCityZoomText_Gfx[] = INCBIN_U32("graphics/pokenav/city_zoom_ const u16 gPokenavConditionCancel_Pal[] = INCBIN_U16("graphics/pokenav/condition/cancel.gbapal"); const u8 gPokenavConditionCancel_Gfx[] = INCBIN_U8("graphics/pokenav/condition/cancel.4bpp"); -const u16 gPokenavConditionMarker_Pal[] = INCBIN_U16("graphics/pokenav/condition/marker.gbapal"); -const u8 gPokenavConditionMarker_Gfx[] = INCBIN_U8("graphics/pokenav/condition/marker.4bpp"); +const u16 gMonMarkingsMenu_Pal[] = INCBIN_U16("graphics/misc/mon_markings_menu.gbapal"); +const u8 gMonMarkingsMenu_Gfx[] = INCBIN_U8("graphics/misc/mon_markings_menu.4bpp"); const u16 gBerryBlenderMiscPalette[] = INCBIN_U16("graphics/berry_blender/misc.gbapal"); const u16 gBerryBlenderArrowPalette[] = INCBIN_U16("graphics/berry_blender/arrow.gbapal"); diff --git a/src/mon_markings.c b/src/mon_markings.c index a819d4f9a..f27cca7c4 100644 --- a/src/mon_markings.c +++ b/src/mon_markings.c @@ -10,20 +10,24 @@ #include "sprite.h" #include "text_window.h" +#define ANIM_CURSOR (NUM_MON_MARKINGS * 2) +#define ANIM_TEXT (ANIM_CURSOR + 1) + +#define SELECTION_OK NUM_MON_MARKINGS +#define SELECTION_CANCEL (SELECTION_OK + 1) + #define MENU_TEXT_SPRITE_X_OFFSET 32 -// static functions -static void sub_811FC80(s16, s16, u16, u16); -static void TaskDummy7(struct Sprite *); -static void sub_811FF40(struct Sprite *); -static void sub_811FF7C(struct Sprite *); -static struct Sprite *sub_811FFD4(u16, u16, const u16 *, u16); +static void CreateMonMarkingsMenuSprites(s16, s16, u16, u16); +static void SpriteCB_Dummy(struct Sprite *); +static void SpriteCB_Marking(struct Sprite *); +static void SpriteCB_Cursor(struct Sprite *); +static struct Sprite *CreateMarkingComboSprite(u16, u16, const u16 *, u16); -// .rodata -static const u16 gUnknown_0859E65C[] = INCBIN_U16("graphics/misc/mon_markings.gbapal"); -static const u8 gUnknown_0859E67C[] = INCBIN_U8("graphics/misc/mon_markings.4bpp"); +static const u16 sMonMarkings_Pal[] = INCBIN_U16("graphics/misc/mon_markings.gbapal"); +static const u8 sMonMarkings_Gfx[] = INCBIN_U8("graphics/misc/mon_markings.4bpp"); -static const struct OamData gUnknown_0859EE7C = +static const struct OamData sOamData_MenuWindow = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -40,7 +44,8 @@ static const struct OamData gUnknown_0859EE7C = .affineParam = 0, }; -static const struct OamData gUnknown_0859EE84 = +// Used for the markings, OK/Cancel text, and cursor sprites +static const struct OamData sOamData_8x8 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -57,99 +62,99 @@ static const struct OamData gUnknown_0859EE84 = .affineParam = 0, }; -static const union AnimCmd gUnknown_0859EE8C[] = +static const union AnimCmd sAnim_Marking_CircleOff[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EE94[] = +static const union AnimCmd sAnim_Marking_CircleOn[] = { ANIMCMD_FRAME(1, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EE9C[] = +static const union AnimCmd sAnim_Marking_SquareOff[] = { ANIMCMD_FRAME(2, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EEA4[] = +static const union AnimCmd sAnim_Marking_SquareOn[] = { ANIMCMD_FRAME(3, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EEAC[] = +static const union AnimCmd sAnim_Marking_TriangleOff[] = { ANIMCMD_FRAME(4, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EEB4[] = +static const union AnimCmd sAnim_Marking_TriangleOn[] = { ANIMCMD_FRAME(5, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EEBC[] = +static const union AnimCmd sAnim_Marking_HeartOff[] = { ANIMCMD_FRAME(6, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EEC4[] = +static const union AnimCmd sAnim_Marking_HeartOn[] = { ANIMCMD_FRAME(7, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EECC[] = +static const union AnimCmd sAnim_Cursor[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EED4[] = +static const union AnimCmd sAnim_OKCancelText[] = { ANIMCMD_FRAME(9, 5), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_0859EEDC[] = +static const union AnimCmd *const sAnims_MenuSprite[] = { - gUnknown_0859EE8C, - gUnknown_0859EE94, - gUnknown_0859EE9C, - gUnknown_0859EEA4, - gUnknown_0859EEAC, - gUnknown_0859EEB4, - gUnknown_0859EEBC, - gUnknown_0859EEC4, - gUnknown_0859EECC, - gUnknown_0859EED4, + sAnim_Marking_CircleOff, + sAnim_Marking_CircleOn, + sAnim_Marking_SquareOff, + sAnim_Marking_SquareOn, + sAnim_Marking_TriangleOff, + sAnim_Marking_TriangleOn, + sAnim_Marking_HeartOff, + sAnim_Marking_HeartOn, + [ANIM_CURSOR] = sAnim_Cursor, + [ANIM_TEXT] = sAnim_OKCancelText, }; -static const union AnimCmd gUnknown_0859EF04[] = +static const union AnimCmd sAnim_MenuWindow_UpperHalf[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF0C[] = +static const union AnimCmd sAnim_MenuWindow_LowerHalf[] = { ANIMCMD_FRAME(64, 5), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_0859EF14[] = +static const union AnimCmd *const sAnims_MenuWindow[] = { - gUnknown_0859EF04, - gUnknown_0859EF0C, + sAnim_MenuWindow_UpperHalf, + sAnim_MenuWindow_LowerHalf, }; -static const struct OamData gUnknown_0859EF1C = +static const struct OamData sOamData_MarkingCombo = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -166,169 +171,166 @@ static const struct OamData gUnknown_0859EF1C = .affineParam = 0, }; -static const union AnimCmd gUnknown_0859EF24[] = +static const union AnimCmd sAnim_MarkingCombo_AllOff[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF2C[] = +static const union AnimCmd sAnim_MarkingCombo_Circle[] = { ANIMCMD_FRAME(4, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF34[] = +static const union AnimCmd sAnim_MarkingCombo_Square[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF3C[] = +static const union AnimCmd sAnim_MarkingCombo_CircleSquare[] = { ANIMCMD_FRAME(12, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF44[] = +static const union AnimCmd sAnim_MarkingCombo_Triangle[] = { ANIMCMD_FRAME(16, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF4C[] = +static const union AnimCmd sAnim_MarkingCombo_CircleTriangle[] = { ANIMCMD_FRAME(20, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF54[] = +static const union AnimCmd sAnim_MarkingCombo_SquareTriangle[] = { ANIMCMD_FRAME(24, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF5C[] = +static const union AnimCmd sAnim_MarkingCombo_CircleSquareTriangle[] = { ANIMCMD_FRAME(28, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF64[] = +static const union AnimCmd sAnim_MarkingCombo_Heart[] = { ANIMCMD_FRAME(32, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF6C[] = +static const union AnimCmd sAnim_MarkingCombo_CircleHeart[] = { ANIMCMD_FRAME(36, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF74[] = +static const union AnimCmd sAnim_MarkingCombo_SquareHeart[] = { ANIMCMD_FRAME(40, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF7C[] = +static const union AnimCmd sAnim_MarkingCombo_CircleSquareHeart[] = { ANIMCMD_FRAME(44, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF84[] = +static const union AnimCmd sAnim_MarkingCombo_TriangleHeart[] = { ANIMCMD_FRAME(48, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF8C[] = +static const union AnimCmd sAnim_MarkingCombo_CircleTriangleHeart[] = { ANIMCMD_FRAME(52, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF94[] = +static const union AnimCmd sAnim_MarkingCombo_SquareTriangleHeart[] = { ANIMCMD_FRAME(56, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_0859EF9C[] = +static const union AnimCmd sAnim_MarkingCombo_AllOn[] = { ANIMCMD_FRAME(60, 5), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_0859EFA4[] = +static const union AnimCmd *const sAnims_MarkingCombo[] = { - gUnknown_0859EF24, - gUnknown_0859EF2C, - gUnknown_0859EF34, - gUnknown_0859EF3C, - gUnknown_0859EF44, - gUnknown_0859EF4C, - gUnknown_0859EF54, - gUnknown_0859EF5C, - gUnknown_0859EF64, - gUnknown_0859EF6C, - gUnknown_0859EF74, - gUnknown_0859EF7C, - gUnknown_0859EF84, - gUnknown_0859EF8C, - gUnknown_0859EF94, - gUnknown_0859EF9C, + sAnim_MarkingCombo_AllOff, + sAnim_MarkingCombo_Circle, + sAnim_MarkingCombo_Square, + sAnim_MarkingCombo_CircleSquare, + sAnim_MarkingCombo_Triangle, + sAnim_MarkingCombo_CircleTriangle, + sAnim_MarkingCombo_SquareTriangle, + sAnim_MarkingCombo_CircleSquareTriangle, + sAnim_MarkingCombo_Heart, + sAnim_MarkingCombo_CircleHeart, + sAnim_MarkingCombo_SquareHeart, + sAnim_MarkingCombo_CircleSquareHeart, + sAnim_MarkingCombo_TriangleHeart, + sAnim_MarkingCombo_CircleTriangleHeart, + sAnim_MarkingCombo_SquareTriangleHeart, + sAnim_MarkingCombo_AllOn, }; static EWRAM_DATA struct PokemonMarkMenu *sMenu = NULL; -void sub_811F90C(struct PokemonMarkMenu *ptr) +void InitMonMarkingsMenu(struct PokemonMarkMenu *ptr) { sMenu = ptr; } -void sub_811F918(void) +static void BufferMenuWindowTiles(void) { const struct TilesPal *frame = GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType); sMenu->frameTiles = frame->tiles; sMenu->framePalette = frame->pal; sMenu->tileLoadState = 0; - CpuFill16(0, sMenu->menuWindowSpriteTiles, sizeof(sMenu->menuWindowSpriteTiles)); + CpuFill16(0, sMenu->windowSpriteTiles, sizeof(sMenu->windowSpriteTiles)); } -bool8 sub_811F960(void) +static bool8 BufferMenuFrameTiles(void) { u16 i; - u8 *dest = sMenu->menuWindowSpriteTiles + sMenu->tileLoadState * 0x100; + u8 *dest = sMenu->windowSpriteTiles + sMenu->tileLoadState * 0x100; switch (sMenu->tileLoadState) { case 0: CpuFastCopy(sMenu->frameTiles, dest, TILE_SIZE_4BPP); for (i = 0; i < 6; i++) - { CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP); - } + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 2, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP); sMenu->tileLoadState++; break; default: CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 3, dest, TILE_SIZE_4BPP); for (i = 0; i < 6; i++) - { CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 4, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP); - } + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 5, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP); sMenu->tileLoadState++; break; case 13: CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 6, dest, TILE_SIZE_4BPP); for (i = 0; i < 6; i++) - { CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 7, dest + TILE_SIZE_4BPP * (i + 1), TILE_SIZE_4BPP); - } + CpuFastCopy(sMenu->frameTiles + TILE_SIZE_4BPP * 8, dest + TILE_SIZE_4BPP * 7, TILE_SIZE_4BPP); sMenu->tileLoadState++; return FALSE; @@ -339,23 +341,23 @@ bool8 sub_811F960(void) return TRUE; } -void sub_811FA90(void) +void BufferMonMarkingsMenuTiles(void) { - sub_811F918(); - while (sub_811F960()); + BufferMenuWindowTiles(); + while (BufferMenuFrameTiles()); } -void sub_811FAA4(u8 markings, s16 x, s16 y) +void OpenMonMarkingsMenu(u8 markings, s16 x, s16 y) { u16 i; sMenu->cursorPos = 0; sMenu->markings = markings; for (i = 0; i < NUM_MON_MARKINGS; i++) sMenu->markingsArray[i] = (sMenu->markings >> i) & 1; - sub_811FC80(x, y, sMenu->baseTileTag, sMenu->basePaletteTag); + CreateMonMarkingsMenuSprites(x, y, sMenu->baseTileTag, sMenu->basePaletteTag); } -void sub_811FAF8(void) +void FreeMonMarkingsMenu(void) { u16 i; @@ -364,33 +366,33 @@ void sub_811FAF8(void) FreeSpriteTilesByTag(sMenu->baseTileTag + i); FreeSpritePaletteByTag(sMenu->basePaletteTag + i); } - for (i = 0; i < 2; i++) + for (i = 0; i < ARRAY_COUNT(sMenu->windowSprites); i++) { - if (!sMenu->menuWindowSprites[i]) + if (!sMenu->windowSprites[i]) return; - DestroySprite(sMenu->menuWindowSprites[i]); - sMenu->menuWindowSprites[i] = NULL; + DestroySprite(sMenu->windowSprites[i]); + sMenu->windowSprites[i] = NULL; } for (i = 0; i < NUM_MON_MARKINGS; i++) { - if (!sMenu->menuMarkingSprites[i]) + if (!sMenu->markingSprites[i]) return; - DestroySprite(sMenu->menuMarkingSprites[i]); - sMenu->menuMarkingSprites[i] = NULL; + DestroySprite(sMenu->markingSprites[i]); + sMenu->markingSprites[i] = NULL; } - if (sMenu->unkSprite) + if (sMenu->cursorSprite) { - DestroySprite(sMenu->unkSprite); - sMenu->unkSprite = NULL; + DestroySprite(sMenu->cursorSprite); + sMenu->cursorSprite = NULL; } - if (sMenu->menuTextSprite) + if (sMenu->textSprite) { - DestroySprite(sMenu->menuTextSprite); - sMenu->menuTextSprite = NULL; + DestroySprite(sMenu->textSprite); + sMenu->textSprite = NULL; } } -bool8 MonMarkingsMenuHandleInput(void) +bool8 HandleMonMarkingsMenuInput(void) { u16 i; @@ -400,7 +402,7 @@ bool8 MonMarkingsMenuHandleInput(void) PlaySE(SE_SELECT); pos = --sMenu->cursorPos; if (pos < 0) - sMenu->cursorPos = 5; + sMenu->cursorPos = SELECTION_CANCEL; return TRUE; } @@ -409,7 +411,7 @@ bool8 MonMarkingsMenuHandleInput(void) s8 pos; PlaySE(SE_SELECT); pos = ++sMenu->cursorPos; - if (pos > 5) + if (pos > SELECTION_CANCEL) sMenu->cursorPos = 0; return TRUE; } @@ -420,12 +422,12 @@ bool8 MonMarkingsMenuHandleInput(void) switch (sMenu->cursorPos) { - case 4: + case SELECTION_OK: sMenu->markings = 0; for (i = 0; i < NUM_MON_MARKINGS; i++) sMenu->markings |= sMenu->markingsArray[i] << i; return FALSE; - case 5: + case SELECTION_CANCEL: return FALSE; } @@ -442,170 +444,181 @@ bool8 MonMarkingsMenuHandleInput(void) return TRUE; } -static void sub_811FC80(s16 x, s16 y, u16 baseTileTag, u16 basePaletteTag) +#define sMarkingId data[0] +#define sCursorYOffset data[0] + +static void CreateMonMarkingsMenuSprites(s16 x, s16 y, u16 baseTileTag, u16 basePaletteTag) { u16 i; u8 spriteId; struct SpriteSheet sheets[] = { - { sMenu->menuWindowSpriteTiles, 0x1000, baseTileTag }, - { gPokenavConditionMarker_Gfx, 0x320, baseTileTag + 1 }, - { NULL, 0 } + { sMenu->windowSpriteTiles, 0x1000, baseTileTag }, + { gMonMarkingsMenu_Gfx, 0x320, baseTileTag + 1 }, + {} }; struct SpritePalette palettes[] = { { sMenu->framePalette, basePaletteTag }, - { gPokenavConditionMarker_Pal, basePaletteTag + 1}, - { NULL, 0 } + { gMonMarkingsMenu_Pal, basePaletteTag + 1}, + {} }; - struct SpriteTemplate sprTemplate = + struct SpriteTemplate template = { - baseTileTag, - basePaletteTag, - &gUnknown_0859EE7C, - gUnknown_0859EF14, - NULL, - gDummySpriteAffineAnimTable, - TaskDummy7, + .tileTag = baseTileTag, + .paletteTag = basePaletteTag, + .oam = &sOamData_MenuWindow, + .anims = sAnims_MenuWindow, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_Dummy, }; LoadSpriteSheets(sheets); LoadSpritePalettes(palettes); - for (i = 0; i < 2; i++) + // Create window sprites + for (i = 0; i < ARRAY_COUNT(sMenu->windowSprites); i++) { - spriteId = CreateSprite(&sprTemplate, x + 32, y + 32, 1); + spriteId = CreateSprite(&template, x + 32, y + 32, 1); if (spriteId != MAX_SPRITES) { - sMenu->menuWindowSprites[i] = &gSprites[spriteId]; + sMenu->windowSprites[i] = &gSprites[spriteId]; StartSpriteAnim(&gSprites[spriteId], i); } else { - sMenu->menuWindowSprites[i] = NULL; + sMenu->windowSprites[i] = NULL; return; } } + sMenu->windowSprites[1]->pos1.y = y + 96; - sMenu->menuWindowSprites[1]->pos1.y = y + 96; - - sprTemplate.tileTag++; - sprTemplate.paletteTag++; - sprTemplate.anims = gUnknown_0859EEDC; - sprTemplate.callback = sub_811FF40; - sprTemplate.oam = &gUnknown_0859EE84; + // Create marking sprites + template.tileTag++; + template.paletteTag++; + template.anims = sAnims_MenuSprite; + template.callback = SpriteCB_Marking; + template.oam = &sOamData_8x8; for (i = 0; i < NUM_MON_MARKINGS; i++) { - spriteId = CreateSprite(&sprTemplate, x + 32, y + 16 + 16 * i, 0); + spriteId = CreateSprite(&template, x + 32, y + 16 + 16 * i, 0); if (spriteId != MAX_SPRITES) { - sMenu->menuMarkingSprites[i] = &gSprites[spriteId]; - gSprites[spriteId].data[0] = i; + sMenu->markingSprites[i] = &gSprites[spriteId]; + gSprites[spriteId].sMarkingId = i; } else { - sMenu->menuMarkingSprites[i] = NULL; + sMenu->markingSprites[i] = NULL; return; } } - sprTemplate.callback = SpriteCallbackDummy; - - spriteId = CreateSprite(&sprTemplate, 0, 0, 0); - + // Create OK/Cancel text sprite + template.callback = SpriteCallbackDummy; + spriteId = CreateSprite(&template, 0, 0, 0); if (spriteId != MAX_SPRITES) { - sMenu->menuTextSprite = &gSprites[spriteId]; - sMenu->menuTextSprite->oam.shape = SPRITE_SHAPE(32x32); - sMenu->menuTextSprite->oam.size = SPRITE_SIZE(32x32); - StartSpriteAnim(sMenu->menuTextSprite, 9); - sMenu->menuTextSprite->pos1.x = x + MENU_TEXT_SPRITE_X_OFFSET; - sMenu->menuTextSprite->pos1.y = y + 80; - CalcCenterToCornerVec(sMenu->menuTextSprite, SPRITE_SHAPE(32x16), SPRITE_SIZE(32x16), ST_OAM_AFFINE_OFF); + sMenu->textSprite = &gSprites[spriteId]; + sMenu->textSprite->oam.shape = SPRITE_SHAPE(32x32); + sMenu->textSprite->oam.size = SPRITE_SIZE(32x32); + StartSpriteAnim(sMenu->textSprite, ANIM_TEXT); + sMenu->textSprite->pos1.x = x + MENU_TEXT_SPRITE_X_OFFSET; + sMenu->textSprite->pos1.y = y + 80; + CalcCenterToCornerVec(sMenu->textSprite, SPRITE_SHAPE(32x16), SPRITE_SIZE(32x16), ST_OAM_AFFINE_OFF); } else { - sMenu->menuTextSprite = NULL; + sMenu->textSprite = NULL; } - sprTemplate.callback = sub_811FF7C; - spriteId = CreateSprite(&sprTemplate, x + 12, 0, 0); + // Create cursor sprite + template.callback = SpriteCB_Cursor; + spriteId = CreateSprite(&template, x + 12, 0, 0); if (spriteId != MAX_SPRITES) { - sMenu->unkSprite = &gSprites[spriteId]; - sMenu->unkSprite->data[0] = y + 16; - StartSpriteAnim(sMenu->unkSprite, 8); + sMenu->cursorSprite = &gSprites[spriteId]; + sMenu->cursorSprite->sCursorYOffset = y + 16; + StartSpriteAnim(sMenu->cursorSprite, ANIM_CURSOR); } else { - sMenu->unkSprite = NULL; + sMenu->cursorSprite = NULL; } } -static void TaskDummy7(struct Sprite *sprite) +static void SpriteCB_Dummy(struct Sprite *sprite) { } -static void sub_811FF40(struct Sprite *sprite) +static void SpriteCB_Marking(struct Sprite *sprite) { - if (sMenu->markingsArray[sprite->data[0]]) - StartSpriteAnim(sprite, 2 * sprite->data[0] + 1); + if (sMenu->markingsArray[sprite->sMarkingId]) + StartSpriteAnim(sprite, 2 * sprite->sMarkingId + 1); // Set marking 'on' else - StartSpriteAnim(sprite, 2 * sprite->data[0]); + StartSpriteAnim(sprite, 2 * sprite->sMarkingId); // Set marking 'off' } -static void sub_811FF7C(struct Sprite *sprite) +#undef sMarkingId + +static void SpriteCB_Cursor(struct Sprite *sprite) { - sprite->pos1.y = (16 * sMenu->cursorPos) + sprite->data[0]; + sprite->pos1.y = (16 * sMenu->cursorPos) + sprite->sCursorYOffset; } -struct Sprite *CreateMonMarkingsSpriteWithPal(u16 tileTag, u16 paletteTag, const u16 *palette) +#undef sCursorYOffset + +// Creates a mon marking combination sprite with a spritesheet that holds every possible combination, used by the summary screen / Pokénav +struct Sprite *CreateMonMarkingAllCombosSprite(u16 tileTag, u16 paletteTag, const u16 *palette) { if (!palette) - palette = gUnknown_0859E65C; - return sub_811FFD4(tileTag, paletteTag, palette, 16); + palette = sMonMarkings_Pal; + return CreateMarkingComboSprite(tileTag, paletteTag, palette, 1 << NUM_MON_MARKINGS); } -struct Sprite *sub_811FFB4(u16 tileTag, u16 paletteTag, const u16 *palette) +// Creates a mon marking combination sprite with a spritesheet that holds only one combination, used for the currently selected PC mon +struct Sprite *CreateMonMarkingComboSprite(u16 tileTag, u16 paletteTag, const u16 *palette) { if (!palette) - palette = gUnknown_0859E65C; - return sub_811FFD4(tileTag, paletteTag, palette, 1); + palette = sMonMarkings_Pal; + return CreateMarkingComboSprite(tileTag, paletteTag, palette, 1); } -static struct Sprite *sub_811FFD4(u16 tileTag, u16 paletteTag, const u16 *palette, u16 size) +static struct Sprite *CreateMarkingComboSprite(u16 tileTag, u16 paletteTag, const u16 *palette, u16 size) { u8 spriteId; - struct SpriteTemplate sprTemplate; - struct SpriteSheet sheet = { gUnknown_0859E67C, 0x80, tileTag }; + struct SpriteTemplate template; + struct SpriteSheet sheet = { sMonMarkings_Gfx, 0x80, tileTag }; struct SpritePalette sprPalette = { palette, paletteTag }; - sprTemplate.tileTag = tileTag; - sprTemplate.paletteTag = paletteTag; - sprTemplate.oam = &gUnknown_0859EF1C; - sprTemplate.anims = gUnknown_0859EFA4; - sprTemplate.images = NULL; - sprTemplate.affineAnims = gDummySpriteAffineAnimTable; - sprTemplate.callback = TaskDummy7; + template.tileTag = tileTag; + template.paletteTag = paletteTag; + template.oam = &sOamData_MarkingCombo; + template.anims = sAnims_MarkingCombo; + template.images = NULL; + template.affineAnims = gDummySpriteAffineAnimTable; + template.callback = SpriteCB_Dummy; sheet.size = size * 0x80; LoadSpriteSheet(&sheet); LoadSpritePalette(&sprPalette); - spriteId = CreateSprite(&sprTemplate, 0, 0, 0); + spriteId = CreateSprite(&template, 0, 0, 0); if (spriteId != MAX_SPRITES) return &gSprites[spriteId]; else return NULL; } -void sub_8120084(u8 markings, void *dest) +// Update what combination is shown, used for sprites created with CreateMonMarkingComboSprite +void UpdateMonMarkingTiles(u8 markings, void *dest) { - RequestDma3Copy(gUnknown_0859E67C + markings * 0x80, dest, 0x80, 0x10); + RequestDma3Copy(&sMonMarkings_Gfx[markings * 0x80], dest, 0x80, 0x10); } diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index a542d222c..c004c8cce 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -2323,8 +2323,8 @@ static void Cb_InitPSS(u8 taskId) { sPSSData->markMenu.baseTileTag = TAG_TILE_D; sPSSData->markMenu.basePaletteTag = TAG_PAL_DACE; - sub_811F90C(&sPSSData->markMenu); - sub_811FA90(); + InitMonMarkingsMenu(&sPSSData->markMenu); + BufferMonMarkingsMenuTiles(); } else { @@ -3179,13 +3179,13 @@ static void Cb_ShowMarkMenu(u8 taskId) case 0: PrintStorageActionText(PC_TEXT_MARK_POKE); sPSSData->markMenu.markings = sPSSData->cursorMonMarkings; - sub_811FAA4(sPSSData->cursorMonMarkings, 0xb0, 0x10); + OpenMonMarkingsMenu(sPSSData->cursorMonMarkings, 0xb0, 0x10); sPSSData->state++; break; case 1: - if (!MonMarkingsMenuHandleInput()) + if (!HandleMonMarkingsMenuInput()) { - sub_811FAF8(); + FreeMonMarkingsMenu(); ClearBottomWindow(); SetMonMarkings(sPSSData->markMenu.markings); RefreshCursorMonData(); @@ -3983,7 +3983,7 @@ static void sub_80CA0D8(void) static void sub_80CA154(void) { - sPSSData->field_D94 = sub_811FFB4(TAG_TILE_10, TAG_PAL_DAC8, NULL); + sPSSData->field_D94 = CreateMonMarkingComboSprite(TAG_TILE_10, TAG_PAL_DAC8, NULL); sPSSData->field_D94->oam.priority = 1; sPSSData->field_D94->subpriority = 1; sPSSData->field_D94->pos1.x = 40; @@ -4126,7 +4126,7 @@ static void PrintCursorMonInfo(void) CopyWindowToVram(0, 2); if (sPSSData->cursorMonSpecies != SPECIES_NONE) { - sub_8120084(sPSSData->cursorMonMarkings, sPSSData->field_DA0); + UpdateMonMarkingTiles(sPSSData->cursorMonMarkings, sPSSData->field_DA0); sPSSData->field_D94->invisible = FALSE; } else diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 6e27ae5f4..7dcfd7b99 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3976,7 +3976,7 @@ static void StopPokemonAnimations(void) // A subtle effect, this function stops static void CreateMonMarkingsSprite(struct Pokemon *mon) { - struct Sprite *sprite = CreateMonMarkingsSpriteWithPal(TAG_MON_MARKINGS, TAG_MON_MARKINGS, sSummaryMarkingsPalette); + struct Sprite *sprite = CreateMonMarkingAllCombosSprite(TAG_MON_MARKINGS, TAG_MON_MARKINGS, sSummaryMarkingsPalette); sMonSummaryScreen->markingsSprite = sprite; if (sprite != NULL) diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index c27cd410c..0545ff1c1 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -123,7 +123,7 @@ u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) u8 markings; u32 ret = PARTY_CONDITION_FUNC_NONE, boxId, monId; - if (!MonMarkingsMenuHandleInput()) + if (!HandleMonMarkingsMenuInput()) { structPtr->monMarks[structPtr->mark] = GetMonMarkingsData(); monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index 039ce0c5f..412d9b8aa 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -514,7 +514,7 @@ u32 LoopedTask_OpenMonMarkingsWindow(s32 state) switch (state) { case 0: - sub_811FAA4(TryGetMonMarkId(), 176, 32); + OpenMonMarkingsMenu(TryGetMonMarkId(), 176, 32); return LT_INC_AND_CONTINUE; case 1: PrintHelpBarText(HELPBAR_CONDITION_MARKINGS); @@ -533,7 +533,7 @@ u32 LoopedTask_CloseMonMarkingsWindow(s32 state) switch (state) { case 0: - sub_811FAF8(); + FreeMonMarkingsMenu(); return LT_INC_AND_CONTINUE; case 1: PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS); @@ -668,9 +668,9 @@ void CreateMonMarkingsOrPokeballIndicators(void) { structPtr->monMarks.baseTileTag = 0x6A; structPtr->monMarks.basePaletteTag = 0x6A; - sub_811F90C(&structPtr->monMarks); - sub_811FA90(); - sprite = CreateMonMarkingsSpriteWithPal(0x69, 0x69, sConditionGraphMonMarkingsPal); + InitMonMarkingsMenu(&structPtr->monMarks); + BufferMonMarkingsMenuTiles(); + sprite = CreateMonMarkingAllCombosSprite(0x69, 0x69, sConditionGraphMonMarkingsPal); sprite->oam.priority = 3; sprite->pos1.x = 192; sprite->pos1.y = 32;