From 62e849a5df791e92f0648827081f2c6247f09c5f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 4 Mar 2018 20:03:11 +0100 Subject: [PATCH] item menu is done --- data/item_menu_icons.s | 44 ---------- include/graphics.h | 1 + include/item_menu_icons.h | 19 +++-- src/item_menu.c | 166 +------------------------------------- src/item_menu_icons.c | 160 +++++++++++++++++++++++++++++------- 5 files changed, 151 insertions(+), 239 deletions(-) diff --git a/data/item_menu_icons.s b/data/item_menu_icons.s index aaf242dc2..30cb7e66b 100644 --- a/data/item_menu_icons.s +++ b/data/item_menu_icons.s @@ -4,50 +4,6 @@ .section .rodata - .align 2 -gUnknown_0857FDEC:: @ 857FDEC - obj_tiles gBerryCheckCircle_Gfx, 0x0800, 0x2710 - - .align 2 -gUnknown_0857FDF4:: @ 857FDF4 - obj_pal gUnknown_08D9BEF0, 0x2710 - - .align 2 -gOamData_857FDFC:: @ 857FDFC - .2byte 0x0000, 0xc000, 0x0400, 0x0000 - - .align 2 -gSpriteAnim_857FE04:: @ 857FE04 - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FE0C:: @ 857FE0C - .4byte gSpriteAnim_857FE04 - - .align 2 -gUnknown_0857FE10:: @ 857FE10 - spr_template 0x2710, 0x2710, gOamData_857FDFC, gSpriteAnimTable_857FE0C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_0857FE28:: @ 857FE28 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5860 - - .align 2 -gUnknown_0857FE40:: @ 857FE40 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D58F8 - - .align 2 -gUnknown_0857FE58:: @ 857FE58 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5968 - - .align 2 -gUnknown_0857FE70:: @ 857FE70 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5A94 - - .align 2 -gUnknown_0857FE88:: @ 857FE88 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5B48 - @ 857FEA0 .include "data/text/item_descriptions.inc" diff --git a/include/graphics.h b/include/graphics.h index 88d19ceb4..9afcb75ad 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2729,6 +2729,7 @@ extern const u8 gBagMenuHMIcon_Gfx[]; extern const u8 gBagMaleTiles[]; extern const u8 gBagFemaleTiles[]; extern const u8 gBagPalette[]; +extern const u8 gBerryCheckCircle_Gfx[]; //intro graphics extern const u8 gIntro1SparkleGfx[]; diff --git a/include/item_menu_icons.h b/include/item_menu_icons.h index 0347e8f94..aee7599df 100644 --- a/include/item_menu_icons.h +++ b/include/item_menu_icons.h @@ -1,16 +1,25 @@ #ifndef GUARD_ITEM_MENU_ICONS #define GUARD_ITEM_MENU_ICONS +extern const struct CompressedSpriteSheet gUnknown_0857FB34; +extern const struct CompressedSpriteSheet gUnknown_0857FB3C; +extern const struct CompressedSpritePalette gUnknown_0857FB44; extern const struct CompressedSpriteSheet gUnknown_0857FDEC; extern const struct CompressedSpritePalette gUnknown_0857FDF4; -u8 sub_80D511C(u8 a0, u8 a1, u8 a2, u8 a3); +void RemoveBagSprite(u8 id); +void AddBagVisualSprite(u8 bagPocketId); +void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets); +void ShakeBagVisual(void); +void AddSwitchPocketRotatingBallSprite(s16 rotationDirection); +void AddBagItemIconSprite(u16 itemId, u8 id); +void RemoveBagItemIconSprite(u8 id); +void sub_80D4FAC(void); +void sub_80D4FC8(u8 arg0); +void sub_80D4FEC(u8 arg0); u8 CreateBerryTagSprite(u8 id, s16 x, s16 y); void FreeBerryTagSpritePalette(void); +u8 sub_80D511C(u8 berryId, u8 x, u8 y, bool8 startAffine); u8 CreateBerryFlavorCircleSprite(s16 x); -void sub_80D4FAC(void); -void RemoveBagItemIconSprite(u8); -void sub_80D4FEC(u8); -void sub_80D4FC8(u8); #endif // GUARD_ITEM_MENU_ICONS diff --git a/src/item_menu.c b/src/item_menu.c index fe756c2bb..270e79a47 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -59,7 +59,6 @@ void load_bag_item_list_buffers(u8); void bag_menu_print_pocket_names(u8*, u8*); void bag_menu_copy_pocket_name_to_window(u32); void bag_menu_draw_pocket_indicator_square(u8, u8); -void AddBagVisualSprite(u8); void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); void bag_menu_add_list_scroll_arrow_indicators_maybe(void); void bag_menu_prepare_tmhm_move_window(void); @@ -68,7 +67,6 @@ void Task_WallyTutorialBagMenu(u8); void Task_BagMenu(u8); void get_name(s8*, u16); u16 ItemIdToBattleMoveId(u16); -void ShakeBagVisual(void); u16 BagGetItemIdByPocketPosition(u8, u16); void AddBagItemIconSprite(u16, u8); void bag_menu_print_description_box_text(int); @@ -87,9 +85,6 @@ u8 GetSwitchBagPocketDirection(void); void SwitchBagPocket(u8, s16, u16); bool8 sub_81AC2C0(void); void bag_menu_swap_items(u8); -void SetBagVisualPocketId(u8, u8); -void RemoveBagSprite(u8); -void AddSwitchPocketRotatingBallSprite(s16); void sub_81AC10C(u8); void sub_81AC3C0(u8); void sub_81AC498(u8); @@ -280,14 +275,11 @@ void (*gFieldCallback)(void); extern u8 *gPocketNamesStringsTable[]; extern u8 gUnknown_08D9A88C[]; -extern struct CompressedSpriteSheet gUnknown_0857FB34; -extern struct CompressedSpriteSheet gUnknown_0857FB3C; -extern struct CompressedSpritePalette gUnknown_0857FB44; extern struct ListMenuTemplate gUnknown_08613F9C; -extern u8 gMoveNames[][0xD]; +extern const u8 gMoveNames[][0xD]; extern u8* gReturnToXStringsTable[]; extern u32 gUnknown_0203CE5E[]; -extern u8 EventScript_2736B3[]; +extern const u8 EventScript_2736B3[]; extern const u16 gUnknown_0860F074[]; void ResetBagScrollPositions(void) @@ -1010,13 +1002,11 @@ void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) *bagPocketId += deltaBagPocketId; } -#ifdef NONMATCHING void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) { s16* data = gTasks[taskId].data; u8 pocketId; - data[13] = 0; data[12] = 0; data[11] = deltaBagPocketId; @@ -1026,7 +1016,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) ClearWindowTilemap(1); sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); schedule_bg_copy_tilemap_to_vram(0); - gSprites[gUnknown_0203CE54->unk806[gUnknown_0203CE54->unk81B_1 ^ 1]].invisible = 1; + gSprites[gUnknown_0203CE54->unk804[2 + (gUnknown_0203CE54->unk81B_1 ^ 1)]].invisible = 1; sub_81AB824(); } pocketId = gUnknown_0203CE58.pocket; @@ -1050,156 +1040,6 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) AddSwitchPocketRotatingBallSprite(deltaBagPocketId); SetTaskFuncWithFollowupFunc(taskId, sub_81AC10C, gTasks[taskId].func); } -#else -__attribute__((naked)) -void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) -{ - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - sub sp, 0xC\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - lsls r1, 16\n\ - lsrs r5, r1, 16\n\ - lsls r2, 16\n\ - lsls r0, r6, 2\n\ - adds r0, r6\n\ - lsls r0, 3\n\ - ldr r1, =gTasks + 0x8\n\ - adds r4, r0, r1\n\ - movs r0, 0\n\ - strh r0, [r4, 0x1A]\n\ - strh r0, [r4, 0x18]\n\ - strh r5, [r4, 0x16]\n\ - cmp r2, 0\n\ - bne _081AC026\n\ - movs r0, 0\n\ - bl ClearWindowTilemap\n\ - movs r0, 0x1\n\ - bl ClearWindowTilemap\n\ - ldrb r0, [r4]\n\ - ldr r3, =gUnknown_0203CE58\n\ - ldrb r2, [r3, 0x5]\n\ - lsls r2, 1\n\ - adds r1, r3, 0\n\ - adds r1, 0x12\n\ - adds r1, r2, r1\n\ - adds r3, 0x8\n\ - adds r2, r3\n\ - bl sub_81AE6C8\n\ - movs r0, 0\n\ - bl schedule_bg_copy_tilemap_to_vram\n\ - ldr r3, =gSprites\n\ - ldr r0, =gUnknown_0203CE54\n\ - ldr r2, [r0]\n\ - ldr r1, =0x0000081b\n\ - adds r0, r2, r1\n\ - ldrb r1, [r0]\n\ - lsls r1, 26\n\ - lsrs r1, 30\n\ - movs r0, 0x1\n\ - eors r0, r1\n\ - adds r2, r0\n\ - ldr r0, =0x00000806\n\ - adds r2, r0\n\ - ldrb r1, [r2]\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r0, r3\n\ - adds r0, 0x3E\n\ - ldrb r1, [r0]\n\ - movs r2, 0x4\n\ - orrs r1, r2\n\ - strb r1, [r0]\n\ - bl sub_81AB824\n\ -_081AC026:\n\ - ldr r4, =gUnknown_0203CE58\n\ - ldrb r1, [r4, 0x5]\n\ - add r0, sp, 0x8\n\ - strb r1, [r0]\n\ - lsls r1, r5, 24\n\ - asrs r1, 24\n\ - bl ChangeBagPocketId\n\ - lsls r0, r5, 16\n\ - asrs r1, r0, 16\n\ - adds r5, r0, 0\n\ - cmp r1, 0x1\n\ - bne _081AC07C\n\ - ldr r2, =gPocketNamesStringsTable\n\ - ldrb r0, [r4, 0x5]\n\ - lsls r0, 2\n\ - adds r0, r2\n\ - ldr r0, [r0]\n\ - add r1, sp, 0x8\n\ - ldrb r1, [r1]\n\ - lsls r1, 2\n\ - adds r1, r2\n\ - ldr r1, [r1]\n\ - bl bag_menu_print_pocket_names\n\ - movs r0, 0\n\ - bl bag_menu_copy_pocket_name_to_window\n\ - b _081AC09A\n\ - .pool\n\ -_081AC07C:\n\ - ldr r2, =gPocketNamesStringsTable\n\ - add r0, sp, 0x8\n\ - ldrb r0, [r0]\n\ - lsls r0, 2\n\ - adds r0, r2\n\ - ldr r0, [r0]\n\ - ldrb r1, [r4, 0x5]\n\ - lsls r1, 2\n\ - adds r1, r2\n\ - ldr r1, [r1]\n\ - bl bag_menu_print_pocket_names\n\ - movs r0, 0x8\n\ - bl bag_menu_copy_pocket_name_to_window\n\ -_081AC09A:\n\ - ldr r0, =gUnknown_0203CE58\n\ - ldrb r0, [r0, 0x5]\n\ - movs r1, 0\n\ - bl bag_menu_draw_pocket_indicator_square\n\ - add r0, sp, 0x8\n\ - ldrb r0, [r0]\n\ - movs r1, 0x1\n\ - bl bag_menu_draw_pocket_indicator_square\n\ - movs r0, 0xF\n\ - str r0, [sp]\n\ - movs r0, 0x10\n\ - str r0, [sp, 0x4]\n\ - movs r0, 0x2\n\ - movs r1, 0xB\n\ - movs r2, 0xE\n\ - movs r3, 0x2\n\ - bl FillBgTilemapBufferRect_Palette0\n\ - movs r0, 0x2\n\ - bl schedule_bg_copy_tilemap_to_vram\n\ - add r0, sp, 0x8\n\ - ldrb r0, [r0]\n\ - movs r1, 0x1\n\ - bl SetBagVisualPocketId\n\ - movs r0, 0x1\n\ - bl RemoveBagSprite\n\ - asrs r0, r5, 16\n\ - bl AddSwitchPocketRotatingBallSprite\n\ - ldr r1, =sub_81AC10C\n\ - ldr r2, =gTasks\n\ - lsls r0, r6, 2\n\ - adds r0, r6\n\ - lsls r0, 3\n\ - adds r0, r2\n\ - ldr r2, [r0]\n\ - adds r0, r6, 0\n\ - bl SetTaskFuncWithFollowupFunc\n\ - add sp, 0xC\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void sub_81AC10C(u8 taskId) { diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index 001731727..843c9eec3 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -16,18 +16,23 @@ struct CompressedTilesPal const u8 *pal; }; -// this file's functions -void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets); -void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite); -void SpriteCB_ShakeBagVisual(struct Sprite *sprite); -void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite); -void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); +extern void sub_80D5860(struct Sprite *sprite); +extern void sub_80D58F8(struct Sprite *sprite); +extern void sub_80D5968(struct Sprite *sprite); +extern void sub_80D5A94(struct Sprite *sprite); +extern void sub_80D5B48(struct Sprite *sprite); -// const rom data -const u16 gUnknown_0857F564[] = INCBIN_U16("graphics/interface/bag_spinner.gbapal"); -const u8 gUnknown_0857F584[] = INCBIN_U8("graphics/interface/bag_spinner.4bpp"); -const u8 gUnknown_0857F604[] = INCBIN_U8("graphics/unused/cherry.4bpp"); -const u16 gUnknown_0857FA84[] = INCBIN_U16("graphics/unused/cherry.gbapal"); +// this file's functions +static void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite); +static void SpriteCB_ShakeBagVisual(struct Sprite *sprite); +static void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite); +static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); + +// static const rom data +static const u16 gUnknown_0857F564[] = INCBIN_U16("graphics/interface/bag_spinner.gbapal"); +static const u8 gUnknown_0857F584[] = INCBIN_U8("graphics/interface/bag_spinner.4bpp"); +static const u8 gUnknown_0857F604[] = INCBIN_U8("graphics/unused/cherry.4bpp"); +static const u16 gUnknown_0857FA84[] = INCBIN_U16("graphics/unused/cherry.gbapal"); static const struct OamData sOamData_857FAA4 = { @@ -128,7 +133,7 @@ const struct CompressedSpritePalette gUnknown_0857FB44 = gBagPalette, 100 }; -const struct SpriteTemplate gUnknown_0857FB4C = +static const struct SpriteTemplate gUnknown_0857FB4C = { .tileTag = 100, .paletteTag = 100, @@ -189,17 +194,17 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB9C[] = sSpriteAffineAnim_857FB88, }; -const struct SpriteSheet gUnknown_0857FBA0 = +static const struct SpriteSheet gUnknown_0857FBA0 = { gUnknown_0857F584, 0x80, 101 }; -const struct SpritePalette gUnknown_0857FBA8 = +static const struct SpritePalette gUnknown_0857FBA8 = { gUnknown_0857F564, 101 }; -const struct SpriteTemplate gUnknown_0857FBB0 = +static const struct SpriteTemplate gUnknown_0857FBB0 = { .tileTag = 101, .paletteTag = 101, @@ -260,7 +265,7 @@ static const struct SpriteFrameImage sSpriteImageTable_857FBE4[] = {&gDecompressionBuffer[0], 0x800}, }; -const struct SpriteTemplate gUnknown_0857FBEC = +static const struct SpriteTemplate gUnknown_0857FBEC = { .tileTag = 65535, .paletteTag = 30020, @@ -299,7 +304,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FC74[] = sSpriteAffineAnim_857FC3C }; -const struct SpriteTemplate gUnknown_0857FC7C = +static const struct SpriteTemplate gUnknown_0857FC7C = { .tileTag = 0xFFFF, .paletteTag = 0x7544, @@ -357,8 +362,109 @@ static const struct CompressedTilesPal gBerryPicTable[] = {gBerryPic_Enigma, gBerryPalette_Enigma}, }; -extern const struct SpriteTemplate gUnknown_0857FBEC; -extern const struct SpriteTemplate gUnknown_0857FE10; +const struct CompressedSpriteSheet gUnknown_0857FDEC = +{ + gBerryCheckCircle_Gfx, 0x800, 10000 +}; + +const struct CompressedSpritePalette gUnknown_0857FDF4 = +{ + gUnknown_08D9BEF0, 10000 +}; + +static const struct OamData sOamData_857FDFC = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FE04[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FE0C[] = +{ + sSpriteAnim_857FE04 +}; + +static const struct SpriteTemplate gUnknown_0857FE10 = +{ + .tileTag = 10000, + .paletteTag = 10000, + .oam = &sOamData_857FDFC, + .anims = sSpriteAnimTable_857FE0C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +const struct SpriteTemplate gUnknown_0857FE28 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5860, +}; + +const struct SpriteTemplate gUnknown_0857FE40 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D58F8, +}; + +const struct SpriteTemplate gUnknown_0857FE58 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5968, +}; + +const struct SpriteTemplate gUnknown_0857FE70 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5A94, +}; + +const struct SpriteTemplate gUnknown_0857FE88 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5B48, +}; // code void RemoveBagSprite(u8 id) @@ -397,7 +503,7 @@ void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets) } } -void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite) +static void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite) { if (sprite->pos2.y != 0) { @@ -420,7 +526,7 @@ void ShakeBagVisual(void) } } -void SpriteCB_ShakeBagVisual(struct Sprite *sprite) +static void SpriteCB_ShakeBagVisual(struct Sprite *sprite) { if (sprite->affineAnimEnded) { @@ -429,7 +535,7 @@ void SpriteCB_ShakeBagVisual(struct Sprite *sprite) } } -void AddSwitchPocketRotatingBallSprite(u16 rotationDirection) +void AddSwitchPocketRotatingBallSprite(s16 rotationDirection) { u8 *spriteId = &gUnknown_0203CE54->unk804[1]; LoadSpriteSheet(&gUnknown_0857FBA0); @@ -438,13 +544,13 @@ void AddSwitchPocketRotatingBallSprite(u16 rotationDirection) gSprites[*spriteId].data[0] = rotationDirection; } -void update_switch_pocket_rotating_ball_coords(struct Sprite *sprite) +static void update_switch_pocket_rotating_ball_coords(struct Sprite *sprite) { sprite->centerToCornerVecX = sprite->data[1] - ((sprite->data[3] + 1) & 1); sprite->centerToCornerVecY = sprite->data[1] - ((sprite->data[3] + 1) & 1); } -void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) +static void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) { sprite->oam.affineMode = 1; if (sprite->data[0] == -1) @@ -459,7 +565,7 @@ void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) sprite->callback = SpriteCB_SwitchPocketRotatingBallContinue; } -void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite) +static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite) { sprite->data[3]++; update_switch_pocket_rotating_ball_coords(sprite); @@ -506,7 +612,7 @@ void sub_80D4FEC(u8 arg0) sub_8122448(&gUnknown_0203CE54->unk804[4], 136, 120, (arg0 + 1) * 16); } -void sub_80D5018(void *mem0, void *mem1) +static void sub_80D5018(void *mem0, void *mem1) { u8 i, j; @@ -526,7 +632,7 @@ void sub_80D5018(void *mem0, void *mem1) } } -void sub_80D5070(u8 berryId) +static void sub_80D5070(u8 berryId) { struct CompressedSpritePalette pal;