diff options
author | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-10 16:38:27 +0100 |
---|---|---|
committer | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-10 16:38:27 +0100 |
commit | 37ae6a7758d0f16394f31c367f5c1eb86d34327f (patch) | |
tree | 7bb49a63ef7eddaedd1e8cf7cba9649a4f02488f /src | |
parent | fb30acbc30518469e98a72f4e6df0fb9dd835344 (diff) |
move more pokeblock data to C and label
Diffstat (limited to 'src')
-rw-r--r-- | src/pokeblock_feed.c | 192 | ||||
-rw-r--r-- | src/use_pokeblock.c | 17 |
2 files changed, 178 insertions, 31 deletions
diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 1659e4d77..58a8667fd 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -21,6 +21,7 @@ #include "m4a.h" #include "sound.h" #include "trig.h" +#include "graphics.h" #include "battle.h" // to get rid of once gMonSpritesGfxPtr is put elsewhere struct PokeblockFeedStruct @@ -45,12 +46,10 @@ struct PokeblockFeedStruct u8 pokeblockSpriteId; s16 field_1060[15]; s16 loadGfxState; - u8 somefield[2]; + u8 unused; }; -extern u8 gPokeblockMonId; extern u16 gSpecialVar_ItemId; -extern s16 gPokeblockGain; extern struct MusicPlayerInfo gMPlay_BGM; extern struct SpriteTemplate gUnknown_0202499C; @@ -58,16 +57,9 @@ extern const u8 gBattleTerrainPalette_Frontier[]; extern const u8 gBattleTerrainTiles_Building[]; extern const u8 gUnknown_08D9BA44[]; extern const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet; -extern const struct CompressedSpriteSheet gPokeblock_SpriteSheet; extern const struct CompressedSpritePalette gPokeblockCase_SpritePal; extern const struct CompressedSpriteSheet gMonFrontPicTable[]; extern const u16 gUnknown_0860F074[]; -extern const u8 *sPokeblocksPals[]; -extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F05B0[]; -extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0664[]; -extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0668[]; -extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F066C[]; -extern const struct SpriteTemplate sThrownPokeblockSpriteTemplate; extern bool8 sub_81221EC(void); extern void sub_806A068(u16, u8); @@ -95,6 +87,7 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon); static u8 CreatePokeblockSprite(void); static u8 CreatePokeblockCaseSpriteForFeeding(void); static u8 CreateMonSprite(struct Pokemon *mon); +static void SpriteCB_ThrownPokeblock(struct Sprite* sprite); // ram variables EWRAM_DATA static struct PokeblockFeedStruct *sPokeblockFeed = NULL; @@ -399,6 +392,136 @@ static const struct WindowTemplate sWindowTemplates[] = DUMMY_WIN_TEMPLATE }; +static const u8* const sPokeblocksPals[] = +{ + gPokeblockRed_Pal, + gPokeblockBlue_Pal, + gPokeblockPink_Pal, + gPokeblockGreen_Pal, + gPokeblockYellow_Pal, + gPokeblockPurple_Pal, + gPokeblockIndigo_Pal, + gPokeblockBrown_Pal, + gPokeblockLiteBlue_Pal, + gPokeblockOlive_Pal, + gPokeblockGray_Pal, + gPokeblockBlack_Pal, + gPokeblockWhite_Pal, + gPokeblockGold_Pal +}; + +static const union AffineAnimCmd sSpriteAffineAnim_84120DC[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_MonNoFlip[] = +{ + sSpriteAffineAnim_84120DC +}; + +static const union AffineAnimCmd sSpriteAffineAnim_84120F0[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8412148[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_85F0664[] = +{ + sSpriteAffineAnim_84120DC +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_85F0668[] = +{ + sSpriteAffineAnim_84120F0 +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_85F066C[] = +{ + sSpriteAffineAnim_8412148 +}; + +static const struct OamData sThrownPokeblockOamData = +{ + .y = 0, + .affineMode = 3, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sThrownPokeblockSpriteAnim[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sThrownPokeblockAnimTable[] = +{ + sThrownPokeblockSpriteAnim, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_84121C0[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-8, -8, 0, 1), + AFFINEANIMCMD_JUMP(1) +}; + +static const union AffineAnimCmd *const sThrownPokeblockAffineAnimTable[] = +{ + sSpriteAffineAnim_84121C0 +}; + +static const struct CompressedSpriteSheet sPokeblock_SpriteSheet = +{ + gPokeblock_Gfx, 0x20, TAG_POKEBLOCK_GFX +}; + +static const struct SpriteTemplate sThrownPokeblockSpriteTemplate = +{ + .tileTag = TAG_POKEBLOCK_GFX, + .paletteTag = TAG_POKEBLOCK_GFX, + .oam = &sThrownPokeblockOamData, + .anims = sThrownPokeblockAnimTable, + .images = NULL, + .affineAnims = sThrownPokeblockAffineAnimTable, + .callback = SpriteCB_ThrownPokeblock +}; + // code static void CB2_PokeblockFeed(void) { @@ -554,7 +677,7 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon) sPokeblockFeed->loadGfxState++; break; case 4: - LoadCompressedObjectPic(&gPokeblock_SpriteSheet); + LoadCompressedObjectPic(&sPokeblock_SpriteSheet); sPokeblockFeed->loadGfxState++; break; case 5: @@ -601,6 +724,8 @@ static void SetPokeblockSpritePal(u8 pokeblockCaseId) sPokeblockSpritePal.tag = TAG_POKEBLOCK_GFX; } +// defines for task data fields + #define tFrames data[0] #define tData1 data[1] @@ -697,6 +822,12 @@ static void Task_PaletteFadeToReturn(u8 taskId) #undef tFrames #undef tData1 +// defines for mon sprite data fields + +#define tDelta data[0] +#define tDeltaMod data[1] +#define tSpecies data[2] + static u8 CreateMonSprite(struct Pokemon* mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES2); @@ -705,13 +836,13 @@ static u8 CreateMonSprite(struct Pokemon* mon) sPokeblockFeed->species = species; sPokeblockFeed->monSpriteId_ = spriteId; sPokeblockFeed->nature = GetNature(mon); - gSprites[spriteId].data[2] = species; + gSprites[spriteId].tSpecies = species; gSprites[spriteId].callback = SpriteCallbackDummy; sPokeblockFeed->noMonFlip = TRUE; if (!IsPokeSpriteNotFlipped(species)) { - gSprites[spriteId].affineAnims = sSpriteAffineAnimTable_85F05B0; + gSprites[spriteId].affineAnims = sSpriteAffineAnimTable_MonNoFlip; gSprites[spriteId].oam.affineMode = 3; CalcCenterToCornerVec(&gSprites[spriteId], gSprites[spriteId].oam.shape, gSprites[spriteId].oam.size, gSprites[spriteId].oam.affineMode); sPokeblockFeed->noMonFlip = FALSE; @@ -724,23 +855,27 @@ static void PrepareMonToMoveToPokeblock(u8 spriteId) { gSprites[spriteId].pos1.x = 48; gSprites[spriteId].pos1.y = 80; - gSprites[spriteId].data[0] = -8; - gSprites[spriteId].data[1] = 1; + gSprites[spriteId].tDelta = -8; + gSprites[spriteId].tDeltaMod = 1; gSprites[spriteId].callback = sub_817A468; } static void sub_817A468(struct Sprite* sprite) { sprite->pos1.x += 4; - sprite->pos1.y += sprite->data[0]; - sprite->data[0] += sprite->data[1]; + sprite->pos1.y += sprite->tDelta; + sprite->tDelta += sprite->tDeltaMod; - if (sprite->data[0] == 0) - PlayCry1(sprite->data[2], 0); - if (sprite->data[0] == 9) + if (sprite->tDelta == 0) + PlayCry1(sprite->tSpecies, 0); + if (sprite->tDelta == 9) sprite->callback = SpriteCallbackDummy; } +#undef tDelta +#undef tDeltaMod +#undef tSpecies + static u8 CreatePokeblockCaseSpriteForFeeding(void) { u8 spriteId = CreatePokeblockCaseSprite(188, 100, 2); @@ -764,23 +899,30 @@ static void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 a1) InitSpriteAffineAnim(&gSprites[spriteId]); } +// defines for the pokeblock sprite data fields +#define tDelta data[0] +#define tDeltaMod data[1] + static u8 CreatePokeblockSprite(void) { u8 spriteId = CreateSprite(&sThrownPokeblockSpriteTemplate, 174, 84, 1); - gSprites[spriteId].data[0] = -12; - gSprites[spriteId].data[1] = 1; + gSprites[spriteId].tDelta = -12; + gSprites[spriteId].tDeltaMod = 1; return spriteId; } static void SpriteCB_ThrownPokeblock(struct Sprite* sprite) { sprite->pos1.x -= 4; - sprite->pos1.y += sprite->data[0]; - sprite->data[0] += sprite->data[1]; - if (sprite->data[0] == 10) + sprite->pos1.y += sprite->tDelta; + sprite->tDelta += sprite->tDeltaMod; + if (sprite->tDelta == 10) DestroySprite(sprite); } +#undef tDelta +#undef tDeltaMod + static void sub_817A5CC(void) { u8 animId, i; diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 64d1cb4a5..1a210b101 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -37,12 +37,6 @@ struct UsePokeblockStruct struct UsePokeblockSubStruct info; }; -extern struct UsePokeblockStruct *gUnknown_0203BCAC; -extern struct UsePokeblockSubStruct *gUnknown_0203BC90; -extern struct Pokeblock *gUnknown_0203BC98; -extern void (*gUnknown_0203BC94)(void); -extern u8 gPokeblockMonId; - extern u16 gKeyRepeatStartDelay; // this file's functions @@ -64,6 +58,17 @@ void sub_8167BA0(u16 arg0, u8 copyToVramMode); extern const struct BgTemplate gUnknown_085DFCCC[4]; extern const struct WindowTemplate gUnknown_085DFCDC[]; +// ram variables +EWRAM_DATA struct UsePokeblockSubStruct *gUnknown_0203BC90 = NULL; +EWRAM_DATA void (*gUnknown_0203BC94)(void) = NULL; +EWRAM_DATA struct Pokeblock *gUnknown_0203BC98 = NULL; +EWRAM_DATA u8 gPokeblockMonId = 0; +EWRAM_DATA s16 gPokeblockGain = 0; +EWRAM_DATA void *gUnknown_0203BCA0 = NULL; +EWRAM_DATA void *gUnknown_0203BCA4 = NULL; +EWRAM_DATA void *gUnknown_0203BCA8 = NULL; +EWRAM_DATA struct UsePokeblockStruct *gUnknown_0203BCAC = NULL; + void ChooseMonToGivePokeblock(struct Pokeblock *pokeblock, void (*callback)(void)) { gUnknown_0203BCAC = AllocZeroed(0x806C); |