From 8ac17e09486006c7d2d066173c8fa907aceb72de Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 11 Dec 2017 16:52:28 +0100 Subject: [PATCH] move data from asm to pokeblock.c --- asm/item_use.s | 4 +- asm/pokeblock.s | 88 +++++++++---------- data/graphics.s | 10 ++- data/pokeblock.s | 51 ----------- data/strings.s | 28 +++--- include/graphics.h | 5 ++ include/pokeblock.h | 8 +- include/rom6.h | 2 +- include/strings.h | 42 +++++++-- ld_script.txt | 1 - src/berry_blender.c | 2 - src/lilycove_lady.c | 2 +- src/pokeblock.c | 200 +++++++++++++++++++++++++++++++++++++++++++ src/pokeblock_feed.c | 10 +-- src/pokemon_3.c | 12 +-- src/safari_zone.c | 2 +- 16 files changed, 329 insertions(+), 138 deletions(-) delete mode 100644 data/pokeblock.s diff --git a/asm/item_use.s b/asm/item_use.s index 172080b16..378ed09f1 100644 --- a/asm/item_use.s +++ b/asm/item_use.s @@ -1497,7 +1497,7 @@ sub_80FDBEC: @ 80FDBEC push {lr} ldr r1, =bag_menu_mail_related movs r0, 0 - bl sub_81357FC + bl OpenPokeblockCase pop {r0} bx r0 .pool @@ -1517,7 +1517,7 @@ sub_80FDC00: @ 80FDC00 bl overworld_free_bg_tilemaps ldr r1, =c2_exit_to_overworld_2_switch movs r0, 0 - bl sub_81357FC + bl OpenPokeblockCase adds r0, r4, 0 bl DestroyTask _080FDC24: diff --git a/asm/pokeblock.s b/asm/pokeblock.s index 3b5e50ac3..c5273a731 100644 --- a/asm/pokeblock.s +++ b/asm/pokeblock.s @@ -5,8 +5,8 @@ .text - thumb_func_start sub_81357FC -sub_81357FC: @ 81357FC + thumb_func_start OpenPokeblockCase +OpenPokeblockCase: @ 81357FC push {r4-r6,lr} adds r4, r0, 0 adds r6, r1, 0 @@ -53,7 +53,7 @@ _08135864: _0813586A: ldr r0, =0x00000804 adds r1, r5, r0 - ldr r0, =gUnknown_085B269B + ldr r0, =sActionsInBattle str r0, [r1] ldr r4, =0x00000808 adds r1, r5, r4 @@ -63,7 +63,7 @@ _0813586A: _08135888: ldr r1, =0x00000804 adds r0, r5, r1 - ldr r1, =gUnknown_085B269D + ldr r1, =sActionsOnPokeblockFeeder str r1, [r0] ldr r4, =0x00000808 adds r0, r5, r4 @@ -73,7 +73,7 @@ _08135888: _081358A4: ldr r0, =0x00000804 adds r1, r5, r0 - ldr r0, =gUnknown_085B269F + ldr r0, =sActionsWhenGivingToLady str r0, [r1] ldr r4, =0x00000808 adds r1, r5, r4 @@ -85,7 +85,7 @@ _081358C0: ldr r1, [r0] ldr r0, =0x00000804 adds r2, r1, r0 - ldr r0, =gUnknown_085B2698 + ldr r0, =sActionsOnField str r0, [r2] ldr r4, =0x00000808 adds r1, r4 @@ -99,14 +99,14 @@ _081358D4: pop {r0} bx r0 .pool - thumb_func_end sub_81357FC + thumb_func_end OpenPokeblockCase thumb_func_start sub_81358F4 sub_81358F4: @ 81358F4 push {lr} ldr r1, =SetCB2ToReshowScreenAfterMenu2 movs r0, 0x1 - bl sub_81357FC + bl OpenPokeblockCase pop {r0} bx r0 .pool @@ -117,7 +117,7 @@ sub_8135908: @ 8135908 push {lr} ldr r1, =c2_exit_to_overworld_2_switch movs r0, 0x2 - bl sub_81357FC + bl OpenPokeblockCase pop {r0} bx r0 .pool @@ -491,7 +491,7 @@ _08135C98: lsrs r0, 24 cmp r0, 0x1 beq _08135D18 - ldr r0, =gMenuPokeblockDevice_Gfx + ldr r0, =gMenuPokeblock_Tilemap ldr r4, =gUnknown_0203AB50 ldr r1, [r4] bl LZDecompressWram @@ -593,7 +593,7 @@ sub_8135D7C: @ 8135D7C movs r4, 0 str r4, [sp] str r4, [sp, 0x4] - ldr r3, =gUnknown_085B271C + ldr r3, =sTextColorInPokeblockMenu str r3, [sp, 0x8] str r4, [sp, 0xC] str r1, [sp, 0x10] @@ -1407,7 +1407,7 @@ CreatePokeblockCaseSprite: @ 8136444 adds r3, r2, 0 lsls r3, 24 lsrs r3, 24 - ldr r0, =gUnknown_085B2704 + ldr r0, =sSpriteTemplate_PokeblockCase lsls r4, 16 asrs r4, 16 lsls r5, 16 @@ -1449,7 +1449,7 @@ _0813648E: movs r1, 0x1 orrs r0, r1 strb r0, [r4, 0x1] - ldr r0, =gUnknown_085B26F0 + ldr r0, =sSpriteAffineAnimTable_85B26F0 str r0, [r4, 0x10] adds r0, r4, 0 bl InitSpriteAffineAnim @@ -1996,7 +1996,7 @@ _0813696A: ldr r4, =0x00000808 adds r1, r3, r4 ldrb r1, [r1] - ldr r2, =gUnknown_085B2668 + ldr r2, =sPokeblockMenuActions mov r12, r2 ldr r2, =0x00000804 adds r3, r2 @@ -2050,12 +2050,12 @@ sub_81369E0: @ 81369E0 movs r0, 0x5 bl PlaySE adds r0, r5, 0 - bl sub_8136DE8 + bl PokeblockAction_Cancel b _08136A3C _08136A18: movs r0, 0x5 bl PlaySE - ldr r1, =gUnknown_085B2668 + ldr r1, =sPokeblockMenuActions ldr r0, =gUnknown_0203AB50 ldr r0, [r0] ldr r2, =0x00000804 @@ -2076,8 +2076,8 @@ _08136A3C: .pool thumb_func_end sub_81369E0 - thumb_func_start sub_8136A50 -sub_8136A50: @ 8136A50 + thumb_func_start PokeblockAction_UseOnField +PokeblockAction_UseOnField: @ 8136A50 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2092,7 +2092,7 @@ sub_8136A50: @ 8136A50 pop {r0} bx r0 .pool - thumb_func_end sub_8136A50 + thumb_func_end PokeblockAction_UseOnField thumb_func_start sub_8136A74 sub_8136A74: @ 8136A74 @@ -2118,14 +2118,14 @@ sub_8136AA0: @ 8136AA0 ldr r0, =gUnknown_0203AB48 ldr r1, [r0] movs r0, 0 - bl sub_81357FC + bl OpenPokeblockCase pop {r0} bx r0 .pool thumb_func_end sub_8136AA0 - thumb_func_start sub_8136AB4 -sub_8136AB4: @ 8136AB4 + thumb_func_start PokeblockAction_Toss +PokeblockAction_Toss: @ 8136AB4 push {r4,r5,lr} sub sp, 0x10 adds r4, r0, 0 @@ -2177,7 +2177,7 @@ sub_8136AB4: @ 8136AB4 pop {r0} bx r0 .pool - thumb_func_end sub_8136AB4 + thumb_func_end PokeblockAction_Toss thumb_func_start sub_8136B48 sub_8136B48: @ 8136B48 @@ -2192,7 +2192,7 @@ sub_8136B48: @ 8136B48 str r2, [sp, 0x4] movs r2, 0xE str r2, [sp, 0x8] - ldr r2, =gUnknown_085B26A4 + ldr r2, =sTossYesNoFuncTable str r2, [sp, 0xC] movs r2, 0x1 movs r3, 0 @@ -2203,8 +2203,8 @@ sub_8136B48: @ 8136B48 .pool thumb_func_end sub_8136B48 - thumb_func_start sub_8136B78 -sub_8136B78: @ 8136B78 + thumb_func_start TossPokeblockChoice_Yes +TossPokeblockChoice_Yes: @ 8136B78 push {r4,r5,lr} sub sp, 0x10 adds r4, r0, 0 @@ -2233,7 +2233,7 @@ sub_8136B78: @ 8136B78 pop {r0} bx r0 .pool - thumb_func_end sub_8136B78 + thumb_func_end TossPokeblockChoice_Yes thumb_func_start sub_8136BC0 sub_8136BC0: @ 8136BC0 @@ -2283,7 +2283,7 @@ sub_8136BC0: @ 8136BC0 movs r0, 0x1 bl schedule_bg_copy_tilemap_to_vram adds r0, r7, 0 - bl sub_8136C54 + bl TossPokeblockChoice_No _08136C36: pop {r4-r7} pop {r0} @@ -2291,8 +2291,8 @@ _08136C36: .pool thumb_func_end sub_8136BC0 - thumb_func_start sub_8136C54 -sub_8136C54: @ 8136C54 + thumb_func_start TossPokeblockChoice_No +TossPokeblockChoice_No: @ 8136C54 push {r4,lr} adds r4, r0, 0 lsls r4, 24 @@ -2314,10 +2314,10 @@ sub_8136C54: @ 8136C54 pop {r0} bx r0 .pool - thumb_func_end sub_8136C54 + thumb_func_end TossPokeblockChoice_No - thumb_func_start sub_8136C8C -sub_8136C8C: @ 8136C8C + thumb_func_start PokeblockAction_UseInBattle +PokeblockAction_UseInBattle: @ 8136C8C push {r4-r7,lr} mov r7, r8 push {r7} @@ -2385,10 +2385,10 @@ _08136D1A: pop {r4-r7} pop {r0} bx r0 - thumb_func_end sub_8136C8C + thumb_func_end PokeblockAction_UseInBattle - thumb_func_start sub_8136D2C -sub_8136D2C: @ 8136D2C + thumb_func_start PokeblockAction_UseOnPokeblockFeeder +PokeblockAction_UseOnPokeblockFeeder: @ 8136D2C push {r4,r5,lr} adds r4, r0, 0 lsls r4, 24 @@ -2424,10 +2424,10 @@ sub_8136D2C: @ 8136D2C pop {r0} bx r0 .pool - thumb_func_end sub_8136D2C + thumb_func_end PokeblockAction_UseOnPokeblockFeeder - thumb_func_start sub_8136D90 -sub_8136D90: @ 8136D90 + thumb_func_start PokeblockAction_GiveToContestLady +PokeblockAction_GiveToContestLady: @ 8136D90 push {r4-r6,lr} adds r4, r0, 0 lsls r4, 24 @@ -2459,10 +2459,10 @@ sub_8136D90: @ 8136D90 pop {r0} bx r0 .pool - thumb_func_end sub_8136D90 + thumb_func_end PokeblockAction_GiveToContestLady - thumb_func_start sub_8136DE8 -sub_8136DE8: @ 8136DE8 + thumb_func_start PokeblockAction_Cancel +PokeblockAction_Cancel: @ 8136DE8 push {r4,r5,lr} lsls r0, 24 lsrs r0, 24 @@ -2485,7 +2485,7 @@ sub_8136DE8: @ 8136DE8 pop {r0} bx r0 .pool - thumb_func_end sub_8136DE8 + thumb_func_end PokeblockAction_Cancel thumb_func_start sub_8136E20 sub_8136E20: @ 8136E20 @@ -2815,7 +2815,7 @@ sub_8137068: @ 8137068 ldr r7, =gPokeblockNames _08137074: lsls r1, r4, 3 - ldr r0, =gUnknown_085B2720 + ldr r0, =sFavoritePokeblocksTable adds r1, r0 adds r0, r5, 0 bl PokeblockGetGain diff --git a/data/graphics.s b/data/graphics.s index 60787a2c5..60a56a0ac 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -884,9 +884,15 @@ gMenuPokeblock_Gfx:: @ 8D9B2B4 .incbin "baserom.gba", 0xd9b2b4, 0x1bc gMenuPokeblock_Pal:: @ 8D9B470 - .incbin "baserom.gba", 0xd9b470, 0x358 + .incbin "baserom.gba", 0xd9b470, 0x70 + +gMenuPokeblockDevice_Gfx:: @ 8D9B4E0 + .incbin "baserom.gba", 0xd9b4e0, 0x2c0 + +gMenuPokeblockDevice_Pal:: @ 8D9B7A0 + .incbin "baserom.gba", 0xd9b7a0, 0x28 -gMenuPokeblockDevice_Gfx:: @ 8D9B7C8 +gMenuPokeblock_Tilemap:: @ 8D9B7C8 .incbin "baserom.gba", 0xd9b7c8, 0x148 .align 2 diff --git a/data/pokeblock.s b/data/pokeblock.s deleted file mode 100644 index 179d5ea60..000000000 --- a/data/pokeblock.s +++ /dev/null @@ -1,51 +0,0 @@ -@ the fourth big chunk of data - - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gPokeblockFlavorCompatibilityTable:: @ 85B25A0 - .incbin "baserom.gba", 0x5b25a0, 0x80 - -gUnknown_085B2620:: @ 85B2620 - .incbin "baserom.gba", 0x5b2620, 0xc - -gPokeblockNames:: @ 85B262C - .incbin "baserom.gba", 0x5b262c, 0x3c - -gUnknown_085B2668:: @ 85B2668 - .incbin "baserom.gba", 0x5b2668, 0x30 - -gUnknown_085B2698:: @ 85B2698 - .incbin "baserom.gba", 0x5b2698, 0x3 - -gUnknown_085B269B:: @ 85B269B - .incbin "baserom.gba", 0x5b269b, 0x2 - -gUnknown_085B269D:: @ 85B269D - .incbin "baserom.gba", 0x5b269d, 0x2 - -gUnknown_085B269F:: @ 85B269F - .incbin "baserom.gba", 0x5b269f, 0x5 - -gUnknown_085B26A4:: @ 85B26A4 - .incbin "baserom.gba", 0x5b26a4, 0x4c - -gUnknown_085B26F0:: @ 85B26F0 - .incbin "baserom.gba", 0x5b26f0, 0x4 - -gPokeblockCase_SpriteSheet:: @ 85B26F4 - .incbin "baserom.gba", 0x5b26f4, 0x8 - -gPokeblockCase_SpritePal:: @ 85B26FC - .incbin "baserom.gba", 0x5b26fc, 0x8 - -gUnknown_085B2704:: @ 85B2704 - .incbin "baserom.gba", 0x5b2704, 0x18 - -gUnknown_085B271C:: @ 85B271C - .incbin "baserom.gba", 0x5b271c, 0x4 - -gUnknown_085B2720:: @ 85B2720 - .incbin "baserom.gba", 0x5b2720, 0x28 diff --git a/data/strings.s b/data/strings.s index 1eb65f494..977cf51a3 100644 --- a/data/strings.s +++ b/data/strings.s @@ -832,46 +832,46 @@ gText_UnkF908Var1Var2:: @ 85E9263 gText_BerryTag:: @ 85E926B .string "BERRY TAG$" -gUnknown_085E9275:: @ 85E9275 +gText_RedPokeblock:: @ 85E9275 .string "RED {POKEBLOCK}$" -gUnknown_085E927F:: @ 85E927F +gText_BluePokeblock:: @ 85E927F .string "BLUE {POKEBLOCK}$" -gUnknown_085E928A:: @ 85E928A +gText_PinkPokeblock:: @ 85E928A .string "PINK {POKEBLOCK}$" -gUnknown_085E9295:: @ 85E9295 +gText_GreenPokeblock:: @ 85E9295 .string "GREEN {POKEBLOCK}$" -gUnknown_085E92A1:: @ 85E92A1 +gText_YellowPokeblock:: @ 85E92A1 .string "YELLOW {POKEBLOCK}$" -gUnknown_085E92AE:: @ 85E92AE +gText_PurplePokeblock:: @ 85E92AE .string "PURPLE {POKEBLOCK}$" -gUnknown_085E92BB:: @ 85E92BB +gText_IndigoPokeblock:: @ 85E92BB .string "INDIGO {POKEBLOCK}$" -gUnknown_085E92C8:: @ 85E92C8 +gText_BrownPokeblock:: @ 85E92C8 .string "BROWN {POKEBLOCK}$" -gUnknown_085E92D4:: @ 85E92D4 +gText_LiteBluePokeblock:: @ 85E92D4 .string "LITEBLUE {POKEBLOCK}$" -gUnknown_085E92E3:: @ 85E92E3 +gText_OlivePokeblock:: @ 85E92E3 .string "OLIVE {POKEBLOCK}$" -gUnknown_085E92EF:: @ 85E92EF +gText_GrayPokeblock:: @ 85E92EF .string "GRAY {POKEBLOCK}$" -gUnknown_085E92FA:: @ 85E92FA +gText_BlackPokeblock:: @ 85E92FA .string "BLACK {POKEBLOCK}$" -gUnknown_085E9306:: @ 85E9306 +gText_WhitePokeblock:: @ 85E9306 .string "WHITE {POKEBLOCK}$" -gUnknown_085E9312:: @ 85E9312 +gText_GoldPokeblock:: @ 85E9312 .string "GOLD {POKEBLOCK}$" gText_Spicy:: @ 85E931D diff --git a/include/graphics.h b/include/graphics.h index ed0bfb108..24448308d 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -29,6 +29,11 @@ extern const u8 gInterfacePal_PremierBall[]; extern const u8 gOpenPokeballGfx[]; // pokeblock +extern const u8 gMenuPokeblock_Gfx[]; +extern const u8 gMenuPokeblock_Pal[]; +extern const u8 gMenuPokeblock_Tilemap[]; +extern const u8 gMenuPokeblockDevice_Gfx[]; +extern const u8 gMenuPokeblockDevice_Pal[]; extern const u8 gPokeblockRed_Pal[]; extern const u8 gPokeblockBlue_Pal[]; extern const u8 gPokeblockPink_Pal[]; diff --git a/include/pokeblock.h b/include/pokeblock.h index 058c0815e..5d691df22 100644 --- a/include/pokeblock.h +++ b/include/pokeblock.h @@ -1,7 +1,8 @@ #ifndef GUARD_POKEBLOCK_H #define GUARD_POKEBLOCK_H -#define TAG_POKEBLOCK_GFX 0x39E2 +#define GFX_TAG_POKEBLOCK 14818 +#define GFX_TAG_POKEBLOCK_CASE 14800 enum { @@ -34,6 +35,11 @@ void ChooseMonToGivePokeblock(struct Pokeblock *pokeblock, void (*callback)(void void CB2_PreparePokeblockFeedScene(void); // pokeblock +extern const s8 gPokeblockFlavorCompatibilityTable[]; +extern const u8 *const gPokeblockNames[]; +extern const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet; +extern const struct CompressedSpritePalette gPokeblockCase_SpritePal; + u8 CreatePokeblockCaseSprite(s16 x, s16 y, u8 subpriority); u8 GetPokeblockData(const struct Pokeblock *pokeblock, u8 dataId); void ClearPokeblocks(void); diff --git a/include/rom6.h b/include/rom6.h index b4a972794..3804f27d1 100644 --- a/include/rom6.h +++ b/include/rom6.h @@ -1,7 +1,7 @@ #ifndef GUARD_ROM6_H #define GUARD_ROM6_H -void sub_81357FC(u8, void(void)); +void OpenPokeblockCase(u8, void(void)); u8 GetLeadMonIndex(void); u8 GetSSTidalLocation(u8 *grp, u8 *num, s16 *x, s16 *y); void sub_813BADC(bool8); diff --git a/include/strings.h b/include/strings.h index d9e5921a1..6a379ee19 100644 --- a/include/strings.h +++ b/include/strings.h @@ -1,45 +1,50 @@ #ifndef GUARD_STRINGS_H #define GUARD_STRINGS_H -// Exported type declarations - -// Exported RAM declarations - -// Exported ROM declarations - extern const u8 gText_FromSpace[]; + extern const u8 gText_Lv50[]; extern const u8 gText_OpenLevel[]; + extern const u8 gText_Mom[]; extern const u8 gText_Dad[]; + extern const u8 gText_Cool[]; extern const u8 gText_Beauty[]; extern const u8 gText_Cute[]; extern const u8 gText_Smart[]; extern const u8 gText_Tough[]; + extern const u8 gText_Single[]; extern const u8 gText_Double[]; + extern const u8 gText_Spicy2[]; extern const u8 gText_Dry2[]; extern const u8 gText_Sweet2[]; extern const u8 gText_Bitter2[]; extern const u8 gText_Sour2[]; + extern const u8 gText_Excellent[]; extern const u8 gText_VeryGood[]; extern const u8 gText_Good[]; extern const u8 gText_SoSo[]; extern const u8 gText_Bad[]; extern const u8 gText_TheWorst[]; + extern const u8 gText_Slots[]; extern const u8 gText_Roulette[]; extern const u8 gText_Jackpot[]; + extern const u8 gText_First[]; extern const u8 gText_Second[]; extern const u8 gText_Third[]; + extern const u8 gText_NoDecorations[]; extern const u8 gText_NoDecorationsInUse[]; + extern const u8 gText_Exit[]; extern const u8 gText_Cancel[]; + extern const u8 gText_Color161Shadow161[]; extern const u8 gText_GoBackPrevMenu[]; extern const u8 gText_CantPlaceInRoom[]; @@ -56,12 +61,14 @@ extern const u8 gText_NoDecorationHere[]; extern const u8 gText_DecorationWillBeDiscarded[]; extern const u8 gText_CantThrowAwayInUse[]; extern const u8 gText_DecorationThrownAway[]; + extern const u8 gText_Desk[]; extern const u8 gText_Chair[]; extern const u8 gText_Plant[]; extern const u8 gText_Ornament[]; extern const u8 gText_Mat[]; extern const u8 gText_Poster[]; + extern const u8 gText_PutOutSelectedDecorItem[]; extern const u8 gText_StoreChosenDecorInPC[]; extern const u8 gText_ThrowAwayUnwantedDecors[]; @@ -84,8 +91,31 @@ extern const u8 gText_RegisteredDataDeleted[]; extern const u8 gUnknown_085EA79D[]; extern const u8 gText_PkmnFainted3[]; extern const u8 gText_Coins[]; + extern const u8 gText_Var1AteTheVar2[]; extern const u8 gText_Var1HappilyAteVar2[]; extern const u8 gText_Var1DisdainfullyAteVar2[]; +extern const u8 gText_RedPokeblock[]; +extern const u8 gText_BluePokeblock[]; +extern const u8 gText_PinkPokeblock[]; +extern const u8 gText_GreenPokeblock[]; +extern const u8 gText_YellowPokeblock[]; +extern const u8 gText_PurplePokeblock[]; +extern const u8 gText_IndigoPokeblock[]; +extern const u8 gText_BrownPokeblock[]; +extern const u8 gText_LiteBluePokeblock[]; +extern const u8 gText_OlivePokeblock[]; +extern const u8 gText_GrayPokeblock[]; +extern const u8 gText_BlackPokeblock[]; +extern const u8 gText_WhitePokeblock[]; +extern const u8 gText_GoldPokeblock[]; + +extern const u8 gMenuText_Use[]; +extern const u8 gMenuText_Toss[]; +extern const u8 gMenuText_Give[]; +extern const u8 gMenuText_Give2[]; + +extern const u8 gText_Cancel2[]; + #endif //GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index e14999887..7cf793391 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -427,7 +427,6 @@ SECTIONS { data/starter_choose.o(.rodata); data/data4c.o(.rodata); src/pokeblock.o(.rodata); - data/pokeblock.o(.rodata); data/data4d.o(.rodata); src/battle_controller_link_partner.o(.rodata); src/battle_message.o(.rodata); diff --git a/src/berry_blender.c b/src/berry_blender.c index 7c90391fa..aed7814d8 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -132,8 +132,6 @@ extern u8 gInGameOpponentsNo; extern u8 gUnknown_020322D5; extern u8 gResultsWindowId; -extern const u8 * const gPokeblockNames[]; - // graphics extern const u8 gBerryBlenderArrowTiles[]; extern const u8 gBerryBlenderStartTiles[]; diff --git a/src/lilycove_lady.c b/src/lilycove_lady.c index e18733e37..a85cf8945 100644 --- a/src/lilycove_lady.c +++ b/src/lilycove_lady.c @@ -1079,7 +1079,7 @@ void sub_818E914(void) void sub_818E92C(void) { - sub_81357FC(3, c2_exit_to_overworld_2_switch); + OpenPokeblockCase(3, c2_exit_to_overworld_2_switch); } void sub_818E940(void) diff --git a/src/pokeblock.c b/src/pokeblock.c index 023b7c3e7..4c8a9504f 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -1,4 +1,204 @@ #include "global.h" #include "pokeblock.h" +#include "bg.h" +#include "strings.h" +#include "text.h" +#include "menu.h" +#include "task.h" +#include "menu_helpers.h" +#include "pokemon.h" +#include "graphics.h" +enum +{ + PKBL_USE_ON_FIELD, + PKBL_TOSS, + PKBL_CANCEL, + PKBL_USE_IN_BATTLE, + PKBL_USE_ON_FEEDER, + PKBL_GIVE_TO_LADY +}; +// this file's functions +void PokeblockAction_UseOnField(u8 taskId); +void PokeblockAction_Toss(u8 taskId); +void PokeblockAction_Cancel(u8 taskId); +void PokeblockAction_UseInBattle(u8 taskId); +void PokeblockAction_UseOnPokeblockFeeder(u8 taskId); +void PokeblockAction_GiveToContestLady(u8 taskId); +void TossPokeblockChoice_Yes(u8 taskId); +void TossPokeblockChoice_No(u8 taskId); + +// const rom data +const s8 gPokeblockFlavorCompatibilityTable[] = +{ + // Cool, Beauty, Cute, Smart, Tough + 0, 0, 0, 0, 0, // Hardy + 1, 0, 0, 0, -1, // Lonely + 1, 0, -1, 0, 0, // Brave + 1, -1, 0, 0, 0, // Adamant + 1, 0, 0, -1, 0, // Naughty + -1, 0, 0, 0, 1, // Bold + 0, 0, 0, 0, 0, // Docile + 0, 0, -1, 0, 1, // Relaxed + 0, -1, 0, 0, 1, // Impish + 0, 0, 0, -1, 1, // Lax + -1, 0, 1, 0, 0, // Timid + 0, 0, 1, 0, -1, // Hasty + 0, 0, 0, 0, 0, // Serious + 0, -1, 1, 0, 0, // Jolly + 0, 0, 1, -1, 0, // Naive + -1, 1, 0, 0, 0, // Modest + 0, 1, 0, 0, -1, // Mild + 0, 1, -1, 0, 0, // Quiet + 0, 0, 0, 0, 0, // Bashful + 0, 1, 0, -1, 0, // Rash + -1, 0, 0, 1, 0, // Calm + 0, 0, 0, 1, -1, // Gentle + 0, 0, -1, 1, 0, // Sassy + 0, -1, 0, 1, 0, // Careful + 0, 0, 0, 0, 0 // Quirky +}; + +const struct BgTemplate gUnknown_085B2620[] = +{ + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .bg = 2, + .charBaseIndex = 3, + .mapBaseIndex = 29, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + } +}; + +const u8 *const gPokeblockNames[] = +{ + NULL, + gText_RedPokeblock, + gText_BluePokeblock, + gText_PinkPokeblock, + gText_GreenPokeblock, + gText_YellowPokeblock, + gText_PurplePokeblock, + gText_IndigoPokeblock, + gText_BrownPokeblock, + gText_LiteBluePokeblock, + gText_OlivePokeblock, + gText_GrayPokeblock, + gText_BlackPokeblock, + gText_WhitePokeblock, + gText_GoldPokeblock +}; + +const struct MenuAction sPokeblockMenuActions[] = +{ + {gMenuText_Use, PokeblockAction_UseOnField}, + {gMenuText_Toss, PokeblockAction_Toss}, + {gText_Cancel2, PokeblockAction_Cancel}, + {gMenuText_Use, PokeblockAction_UseInBattle}, + {gMenuText_Use, PokeblockAction_UseOnPokeblockFeeder}, + {gMenuText_Give2, PokeblockAction_GiveToContestLady}, +}; + +const u8 sActionsOnField[] = {PKBL_USE_ON_FIELD, PKBL_TOSS, PKBL_CANCEL}; +const u8 sActionsInBattle[] = {PKBL_USE_IN_BATTLE, PKBL_CANCEL}; +const u8 sActionsOnPokeblockFeeder[] = {PKBL_USE_ON_FEEDER, PKBL_CANCEL}; +const u8 sActionsWhenGivingToLady[] = {PKBL_GIVE_TO_LADY, PKBL_CANCEL}; + +const struct YesNoFuncTable sTossYesNoFuncTable = {TossPokeblockChoice_Yes, TossPokeblockChoice_No}; + +static const u8 sContestStatsMonData[] = {MON_DATA_COOL, MON_DATA_BEAUTY, MON_DATA_CUTE, MON_DATA_SMART, MON_DATA_TOUGH}; + +static const struct OamData sOamData_PokeblockCase = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sSpriteAnim_PokeblockCase[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_PokeblockCase[] = +{ + sSpriteAnim_PokeblockCase +}; + +static const union AffineAnimCmd gSpriteAffineAnim_85B26C8[] = +{ + AFFINEANIMCMD_FRAME(0, 0, -2, 2), + AFFINEANIMCMD_FRAME(0, 0, 2, 4), + AFFINEANIMCMD_FRAME(0, 0, -2, 4), + AFFINEANIMCMD_FRAME(0, 0, 2, 2), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const sSpriteAffineAnimTable_85B26F0[] = +{ + gSpriteAffineAnim_85B26C8 +}; + +const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet = +{ + gMenuPokeblockDevice_Gfx, 0x800, GFX_TAG_POKEBLOCK_CASE +}; + +const struct CompressedSpritePalette gPokeblockCase_SpritePal = +{ + gMenuPokeblockDevice_Pal, GFX_TAG_POKEBLOCK_CASE +}; + +const struct SpriteTemplate sSpriteTemplate_PokeblockCase = +{ + GFX_TAG_POKEBLOCK_CASE, + GFX_TAG_POKEBLOCK_CASE, + &sOamData_PokeblockCase, + sSpriteAnimTable_PokeblockCase, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +const struct TextColor sTextColorInPokeblockMenu = {0, 2, 3}; + +const struct Pokeblock sFavoritePokeblocksTable[] = +{ + { PBLOCK_CLR_RED, 20, 0, 0, 0, 0, 20}, + { PBLOCK_CLR_BLUE, 0, 20, 0, 0, 0, 20}, + { PBLOCK_CLR_PINK, 0, 0, 20, 0, 0, 20}, + { PBLOCK_CLR_GREEN, 0, 0, 0, 20, 0, 20}, + { PBLOCK_CLR_YELLOW, 0, 0, 0, 0, 20, 20} +}; diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 58a8667fd..ec5f3074f 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -56,8 +56,6 @@ extern struct SpriteTemplate gUnknown_0202499C; extern const u8 gBattleTerrainPalette_Frontier[]; extern const u8 gBattleTerrainTiles_Building[]; extern const u8 gUnknown_08D9BA44[]; -extern const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet; -extern const struct CompressedSpritePalette gPokeblockCase_SpritePal; extern const struct CompressedSpriteSheet gMonFrontPicTable[]; extern const u16 gUnknown_0860F074[]; @@ -508,13 +506,13 @@ static const union AffineAnimCmd *const sThrownPokeblockAffineAnimTable[] = static const struct CompressedSpriteSheet sPokeblock_SpriteSheet = { - gPokeblock_Gfx, 0x20, TAG_POKEBLOCK_GFX + gPokeblock_Gfx, 0x20, GFX_TAG_POKEBLOCK }; static const struct SpriteTemplate sThrownPokeblockSpriteTemplate = { - .tileTag = TAG_POKEBLOCK_GFX, - .paletteTag = TAG_POKEBLOCK_GFX, + .tileTag = GFX_TAG_POKEBLOCK, + .paletteTag = GFX_TAG_POKEBLOCK, .oam = &sThrownPokeblockOamData, .anims = sThrownPokeblockAnimTable, .images = NULL, @@ -721,7 +719,7 @@ static void SetPokeblockSpritePal(u8 pokeblockCaseId) { u8 colorId = GetPokeblockData(&gSaveBlock1Ptr->pokeblocks[pokeblockCaseId], PBLOCK_COLOR); sPokeblockSpritePal.data = sPokeblocksPals[colorId - 1]; - sPokeblockSpritePal.tag = TAG_POKEBLOCK_GFX; + sPokeblockSpritePal.tag = GFX_TAG_POKEBLOCK; } // defines for task data fields diff --git a/src/pokemon_3.c b/src/pokemon_3.c index b89b00e8e..634923777 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -22,6 +22,7 @@ #include "abilities.h" #include "pokemon_animation.h" #include "pokedex.h" +#include "pokeblock.h" extern struct BattlePokemon gBattleMons[4]; extern struct BattleEnigmaBerry gEnigmaBerries[4]; @@ -59,7 +60,6 @@ extern const u8 gText_PkmnsXPreventsSwitching[]; extern const struct CompressedSpritePalette gMonPaletteTable[]; extern const struct CompressedSpritePalette gMonShinyPaletteTable[]; extern const u16 gHMMoves[]; -extern const s8 gPokeblockFlavorCompatibilityTable[]; extern const u8 gMonAnimationDelayTable[]; extern const u8 gMonFrontAnimIdsTable[]; @@ -1297,21 +1297,21 @@ bool8 IsPokeSpriteNotFlipped(u16 species) return gBaseStats[species].noFlip; } -s8 GetMonFlavorRelation(struct Pokemon *mon, u8 a2) +s8 GetMonFlavorRelation(struct Pokemon *mon, u8 flavour) { u8 nature = GetNature(mon); - return gPokeblockFlavorCompatibilityTable[nature * 5 + a2]; + return gPokeblockFlavorCompatibilityTable[nature * 5 + flavour]; } -s8 GetFlavorRelationByPersonality(u32 personality, u8 a2) +s8 GetFlavorRelationByPersonality(u32 personality, u8 flavour) { u8 nature = GetNatureFromPersonality(personality); - return gPokeblockFlavorCompatibilityTable[nature * 5 + a2]; + return gPokeblockFlavorCompatibilityTable[nature * 5 + flavour]; } bool8 IsTradedMon(struct Pokemon *mon) { - u8 otName[8]; + u8 otName[OT_NAME_LENGTH + 1]; u32 otId; GetMonData(mon, MON_DATA_OT_NAME, otName); otId = GetMonData(mon, MON_DATA_OT_ID, 0); diff --git a/src/safari_zone.c b/src/safari_zone.c index d3d40af28..53027b57e 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -5,6 +5,7 @@ #include "main.h" #include "battle.h" #include "string_util.h" +#include "pokeblock.h" struct PokeblockFeeder { @@ -24,7 +25,6 @@ extern u8 EventScript_2A4B8A[]; extern u8 EventScript_2A4B6F[]; extern u8 EventScript_2A4B4C[]; extern u8 EventScript_2A4B9B[]; -extern const u8* const gPokeblockNames[]; extern void sub_80EE44C(u8, u8); extern void IncrementGameStat(u8 index);