From 1e2dc716025614209e58c672afd73d4c86d7c2c7 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 14 Aug 2017 22:11:32 +0200 Subject: pokeblock feed is on the way --- src/mori_debug_menu.c | 2 +- src/pokeblock.c | 44 ++-- src/pokeblock_feed.c | 577 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/use_pokeblock.c | 18 +- src/wild_encounter.c | 2 +- 5 files changed, 610 insertions(+), 33 deletions(-) create mode 100644 src/pokeblock_feed.c (limited to 'src') diff --git a/src/mori_debug_menu.c b/src/mori_debug_menu.c index 273191192..4eadaa78b 100644 --- a/src/mori_debug_menu.c +++ b/src/mori_debug_menu.c @@ -134,7 +134,7 @@ s8 MoriDebugMenu_PokeblockCase(void) s32 loopCounter; for (loopCounter = 0; loopCounter <= 39; loopCounter++) - sub_810CA6C(loopCounter); + PokeblockClearIfExists(loopCounter); CloseMenu(); return 1; diff --git a/src/pokeblock.c b/src/pokeblock.c index 775280f6e..2fb544fea 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -582,7 +582,7 @@ static void sub_810BDAC(bool8 flag) v0 = ((i % 3) << 6) + 0x1a1 + (i / 3) * 6; if (gUnknown_02039248.unk0 + gUnknown_02039248.unk1 != gUnknown_02039248.unk2) { - if (sub_810CA9C(&gSaveBlock1.pokeblocks[gUnknown_02039248.unk0 + gUnknown_02039248.unk1], i + 1) > 0) + if (GetPokeblockData(&gSaveBlock1.pokeblocks[gUnknown_02039248.unk0 + gUnknown_02039248.unk1], i + 1) > 0) { gBGTilemapBuffers[2][v0] = (i << 12) + 23; gBGTilemapBuffers[2][v0 + 32] = (i << 12) + 24; @@ -894,7 +894,7 @@ static void sub_810C5EC(u8 taskId) static void sub_810C610(u8 taskId) { MenuZeroFillWindowRect(7, 6, 13, 11); - sub_810CA6C((gUnknown_02039248.unk0 + gUnknown_02039248.unk1)); + PokeblockClearIfExists((gUnknown_02039248.unk0 + gUnknown_02039248.unk1)); StringExpandPlaceholders(gStringVar4, gContestStatsText_WasThrownAway); DisplayItemMessageOnField(taskId, gStringVar4, sub_810C704, 0); sub_810BC98(); @@ -942,9 +942,9 @@ static void sub_810C748(u8 taskId) static void sub_810C788(u8 taskId) { - s16 v0 = sub_810CAE4(GetNature(&gEnemyParty[0]), &gSaveBlock1.pokeblocks[gScriptItemId]); + s16 v0 = PokeblockGetGain(GetNature(&gEnemyParty[0]), &gSaveBlock1.pokeblocks[gScriptItemId]); StringCopy(gBattleTextBuff1, gPokeblockNames[gSaveBlock1.pokeblocks[gScriptItemId].color]); - sub_810CA6C(gScriptItemId); + PokeblockClearIfExists(gScriptItemId); gScriptItemId = gSaveBlock1.pokeblocks[gScriptItemId].color << 8; if (v0 == 0) { @@ -967,7 +967,7 @@ static void sub_810C854(u8 taskId) SafariZoneActivatePokeblockFeeder(gScriptItemId); StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1.pokeblocks[gScriptItemId].color]); gScriptResult = gScriptItemId; - sub_810CA6C(gScriptItemId); + PokeblockClearIfExists(gScriptItemId); BeginNormalPaletteFade(-1, 0, 0, 16, 0); gTasks[taskId].func = sub_810C2C8; } @@ -1024,10 +1024,10 @@ u8 sub_810C9B0(struct Pokeblock *pokeblock) { u8 contestStat; u8 maxRating; - u8 rating = sub_810CA9C(pokeblock, 1); + u8 rating = GetPokeblockData(pokeblock, 1); for (contestStat=1; contestStat<5; contestStat++) { - maxRating = sub_810CA9C(pokeblock, contestStat + 1); + maxRating = GetPokeblockData(pokeblock, contestStat + 1); if (rating < maxRating) { rating = maxRating; @@ -1038,7 +1038,7 @@ u8 sub_810C9B0(struct Pokeblock *pokeblock) u8 sub_810C9E8(struct Pokeblock *pokeblock) { - u8 feel = sub_810CA9C(pokeblock, 6); + u8 feel = GetPokeblockData(pokeblock, 6); if (feel > 99) feel = 99; return feel; @@ -1068,7 +1068,7 @@ bool8 sub_810CA34(struct Pokeblock *pokeblock) return TRUE; } -bool8 sub_810CA6C(u8 pokeblockIdx) +bool8 PokeblockClearIfExists(u8 pokeblockIdx) { if (gSaveBlock1.pokeblocks[pokeblockIdx].color == 0) { @@ -1078,33 +1078,33 @@ bool8 sub_810CA6C(u8 pokeblockIdx) return TRUE; } -s16 sub_810CA9C(const struct Pokeblock *pokeblock, u8 field) +s16 GetPokeblockData(const struct Pokeblock *pokeblock, u8 field) { - if (field == 0) + if (field == PBLOCK_COLOR) return pokeblock->color; - if (field == 1) + if (field == PBLOCK_SPICY) return pokeblock->spicy; - if (field == 2) + if (field == PBLOCK_DRY) return pokeblock->dry; - if (field == 3) + if (field == PBLOCK_SWEET) return pokeblock->sweet; - if (field == 4) + if (field == PBLOCK_BITTER) return pokeblock->bitter; - if (field == 5) + if (field == PBLOCK_SOUR) return pokeblock->sour; - if (field == 6) + if (field == PBLOCK_FEEL) return pokeblock->feel; return 0; } -s16 sub_810CAE4(u8 nature, const struct Pokeblock *pokeblock) +s16 PokeblockGetGain(u8 nature, const struct Pokeblock *pokeblock) { u8 flavor; s16 curGain; s16 totalGain = 0; for (flavor=0; flavor<5; flavor++) { - curGain = sub_810CA9C(pokeblock, flavor + 1); + curGain = GetPokeblockData(pokeblock, flavor + 1); if (curGain > 0) { totalGain += curGain * gPokeblockFlavorCompatibilityTable[5 * nature + flavor]; @@ -1113,9 +1113,9 @@ s16 sub_810CAE4(u8 nature, const struct Pokeblock *pokeblock) return totalGain; } -void sub_810CB44(struct Pokeblock *pokeblock, u8 *dest) +void PokeblockCopyName(struct Pokeblock *pokeblock, u8 *dest) { - u8 color = sub_810CA9C(pokeblock, 0); + u8 color = GetPokeblockData(pokeblock, PBLOCK_COLOR); StringCopy(dest, gPokeblockNames[color]); } @@ -1124,7 +1124,7 @@ bool8 sub_810CB68(u8 nature, u8 *dest) u8 flavor; for (flavor=0; flavor<5; flavor++) { - if (sub_810CAE4(nature, &gUnknown_083F7F9C[flavor]) > 0) + if (PokeblockGetGain(nature, &gUnknown_083F7F9C[flavor]) > 0) { StringCopy(dest, gPokeblockNames[flavor + 1]); return TRUE; diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c new file mode 100644 index 000000000..f99eca690 --- /dev/null +++ b/src/pokeblock_feed.c @@ -0,0 +1,577 @@ +#include "global.h" +#include "task.h" +#include "palette.h" +#include "main.h" +#include "menu_helpers.h" +#include "text.h" +#include "text_window.h" +#include "menu.h" +#include "rom4.h" +#include "decompress.h" +#include "data2.h" +#include "sprite.h" +#include "item_use.h" +#include "pokeblock.h" +#include "party_menu.h" +#include "strings.h" +#include "string_util.h" +#include "m4a.h" +#include "field_effect.h" +#include "sound.h" +#include "trig.h" + +extern u8 ewram[]; +extern struct MusicPlayerInfo gMPlay_BGM; +extern u8 gPokeblockMonID; +extern s16 gPokeblockGain; +extern struct CompressedSpritePalette sPokeblockFeedSpritePal; + +void sub_8147F4C(u8 taskID); +bool8 sub_8040A3C(u16 species); + +// IWRAM common + +extern const struct CompressedSpriteSheet gUnknown_083F7F74; +extern const struct CompressedSpriteSheet gUnknown_084121DC; +extern const struct CompressedSpritePalette gUnknown_083F7F7C; +extern const u8 gBattleTerrainTiles_Building[]; +extern const u8 gUnknown_08E782FC[]; +extern const u8 gBattleTerrainPalette_BattleTower[]; +extern const u8* const gUnknown_084120A4[]; +extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84120EC[]; +extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84121A0[]; +extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84121A4[]; +extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84121A8[]; +extern const union AffineAnimCmd* const gSpriteAffineAnimTable_8412050[]; +extern const struct SpriteTemplate gSpriteTemplate_84121E4; +extern const u8 gNatureToMonPokeblockAnim[][2]; +extern const s16 gMonPokeblockAnims[][10]; + +// this file's functions +void sub_8147B04(void); +void sub_81481DC(void); +void sub_814825C(void); +u8 sub_81480B4(void); +u8 sub_814817C(void); +u8 sub_8147F84(struct Pokemon* mon); +bool8 sub_8147B20(struct Pokemon* mon); +void sub_8147DDC(u8); +void sub_8148044(u8); +void sub_8148078(struct Sprite* sprite); +void Task_PrintAtePokeblockText(u8 taskID); +void SetPokeblockFeedSpritePal(u8); +void sub_8148108(u8, bool8); +bool8 sub_8148540(void); +bool8 sub_81485CC(void); +static bool8 FreePokeSpriteMatrix(void); +void sub_8148710(void); +void sub_814862C(void); + +void sub_8147890(void) +{ + AnimateSprites(); + BuildOamBuffer(); + RunTasks(); + UpdatePaletteFade(); +} + +void sub_81478A8(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +bool8 sub_81478BC(void) +{ + switch (gMain.state) + { + case 0: + sub_80F9438(); + sub_80F9368(); + sub_8147B04(); + gMain.state++; + break; + case 1: + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = 1; + gMain.state++; + break; + case 2: + ResetSpriteData(); + gMain.state++; + break; + case 3: + FreeAllSpritePalettes(); + gMain.state++; + break; + case 4: + SetUpWindowConfig(&gWindowConfig_81E6E50); + gMain.state++; + break; + case 5: + MultistepInitMenuWindowBegin(&gWindowConfig_81E6E50); + gMain.state++; + break; + case 6: + if (MultistepInitMenuWindowContinue()) + { + ewram[0x1FFFF] = 0; + gMain.state++; + } + break; + case 7: + if (sub_8147B20(&gPlayerParty[gPokeblockMonID])) + { + gMain.state++; + } + break; + case 8: + ewram[0x1FFFD] = sub_81480B4(); + gMain.state++; + break; + case 9: + ewram[0x1FFFE] = sub_8147F84(&gPlayerParty[gPokeblockMonID]); + gMain.state++; + break; + case 10: + MenuDrawTextWindow(0, 14, 29, 19); + gMain.state++; + break; + case 11: + if (sub_8055870() != 1) + { + gMain.state++; + } + break; + case 12: + { + u16 savedIME = REG_IME; + REG_IME = 0; + REG_IE |= 1; + REG_IME = savedIME; + REG_DISPSTAT |= 8; + SetVBlankCallback(sub_81478A8); + gMain.state++; + } + case 13: + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gPaletteFade.bufferTransferDisabled = 0; + SetMainCallback2(sub_8147890); + return 1; + } + return 0; +} + +void sub_8147ADC(void) +{ + while (1) + { + if (sub_81478BC() == 1) + { + sub_8147DDC(1); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +void sub_8147B04(void) +{ + REG_BG1CNT = 0x1D02l; + REG_DISPCNT = 0x1340; +} + +bool8 sub_8147B20(struct Pokemon* mon) +{ + u16 species; + u32 PiD, TiD; + switch (ewram[0x1FFFF]) + { + case 0: + species = GetMonData(mon, MON_DATA_SPECIES2); + PiD = GetMonData(mon, MON_DATA_PERSONALITY); + HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, 0x2000000, gUnknown_081FAF4C[1], species, PiD); + ewram[0x1FFFF]++; + break; + case 1: + { + const struct CompressedSpritePalette* palette; + + species = GetMonData(mon, MON_DATA_SPECIES2); + PiD = GetMonData(mon, MON_DATA_PERSONALITY); + TiD = GetMonData(mon, MON_DATA_OT_ID); + palette = sub_80409C8(species, TiD, PiD); + LoadCompressedObjectPalette(palette); + GetMonSpriteTemplate_803C56C(palette->tag, 1); + ewram[0x1FFFF]++; + } + break; + case 2: + LoadCompressedObjectPic(&gUnknown_083F7F74); + ewram[0x1FFFF]++; + break; + case 3: + LoadCompressedObjectPalette(&gUnknown_083F7F7C); + ewram[0x1FFFF]++; + break; + case 4: + LoadCompressedObjectPic(&gUnknown_084121DC); + ewram[0x1FFFF]++; + break; + case 5: + SetPokeblockFeedSpritePal(gScriptItemId); + LoadCompressedObjectPalette(&sPokeblockFeedSpritePal); + ewram[0x1FFFF]++; + break; + case 6: + LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM)); + ewram[0x1FFFF]++; + break; + case 7: + LZDecompressVram(gUnknown_08E782FC, (void*)(VRAM + 0xE800)); + ewram[0x1FFFF]++; + break; + case 8: + LoadCompressedPalette(gBattleTerrainPalette_BattleTower, 0x20, 0x60); + ewram[0x1FFFF] = 0; + return 1; + } + return 0; +} + +void SetPokeblockFeedSpritePal(u8 pkbID) +{ + u8 color = GetPokeblockData(&gSaveBlock1.pokeblocks[pkbID], PBLOCK_COLOR); + sPokeblockFeedSpritePal.data = gUnknown_084120A4[color - 1]; + sPokeblockFeedSpritePal.tag = 0x39E2; +} + +extern u16 gUnknown_03005F94; +extern u16 gUnknown_03005F34; +extern u8 gUnknown_03005F3C; + +void sub_8147CC8(u8 taskID) +{ + if (!gPaletteFade.active) + { + switch (gTasks[taskID].data[0]) + { + case 0: + gUnknown_03005F3C = 0; + gUnknown_03005F94 = 0; + sub_81481DC(); + break; + case 255: + sub_8148108(ewram[0x1FFFD], gTasks[taskID].data[1]); + break; + case 269: + ewram[0x1FFFC] = sub_814817C(); + break; + case 281: + sub_8148044(ewram[0x1FFFE]); + break; + case 297: + gTasks[taskID].func = Task_PrintAtePokeblockText; + return; + } + if (gUnknown_03005F94 < gUnknown_03005F34) + sub_814825C(); + else if (gUnknown_03005F94 == gUnknown_03005F34) + gTasks[taskID].data[0] = 254; + + gUnknown_03005F94++; + gTasks[taskID].data[0]++; + } +} + +void sub_8147DDC(u8 a0) +{ + u8 taskID = CreateTask(sub_8147CC8, 0); + gTasks[taskID].data[0] = 0; + gTasks[taskID].data[1] = a0; +} + +void sub_8147E10(u8 taskID) +{ + if (MenuUpdateWindowText() == 1) + gTasks[taskID].func = sub_8147F4C; +} + +void Task_PrintAtePokeblockText(u8 taskID) +{ + struct Pokemon* mon = &gPlayerParty[gPokeblockMonID]; + struct Pokeblock* pokeblock = &gSaveBlock1.pokeblocks[gScriptItemId]; + + gPokeblockGain = PokeblockGetGain(GetNature(mon), pokeblock); + GetMonNickname(mon, gStringVar1); + PokeblockCopyName(pokeblock, gStringVar2); + + if (gPokeblockGain == 0) + StringExpandPlaceholders(gStringVar4, gContestStatsText_NormallyAte); + else if (gPokeblockGain > 0) + StringExpandPlaceholders(gStringVar4, gContestStatsText_HappilyAte); + else + StringExpandPlaceholders(gStringVar4, gContestStatsText_DisdainfullyAte); + + MenuPrintMessage(gStringVar4, 1, 15); + gTasks[taskID].func = sub_8147E10; +} + +void sub_8147F08(u8 taskID) +{ + if (!gPaletteFade.active) + { + m4aMPlayVolumeControl(&gMPlay_BGM, -1, 256); + SetMainCallback2(gMain.savedCallback); + DestroyTask(taskID); + } +} + +void sub_8147F4C(u8 taskID) +{ + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskID].func = sub_8147F08; +} + +extern u16 gPokeblockFeedMonSpecies; +extern u8 gPokeblockFeedMonSpriteID; +extern u8 gPokeblockFeedMonNature; +extern bool8 gPokeblockMonNotFlipped; + +u8 sub_8147F84(struct Pokemon* mon) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES2); + u8 spriteID = CreateSprite(&gUnknown_02024E8C, 48, 80, 2); + + gPokeblockFeedMonSpecies = species; + gPokeblockFeedMonSpriteID = spriteID; + gPokeblockFeedMonNature = GetNature(mon); + gSprites[spriteID].data2 = species; + gSprites[spriteID].callback = SpriteCallbackDummy; + gPokeblockMonNotFlipped = 1; + if (!sub_8040A3C(species)) + { + gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84120EC; + gSprites[spriteID].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[spriteID], gSprites[spriteID].oam.shape, gSprites[spriteID].oam.size, gSprites[spriteID].oam.affineMode); + gPokeblockMonNotFlipped = 0; + } + return spriteID; +} + +void sub_8148044(u8 spriteID) +{ + gSprites[spriteID].pos1.x = 48; + gSprites[spriteID].pos1.y = 80; + gSprites[spriteID].data0 = -8; + gSprites[spriteID].data1 = 1; + gSprites[spriteID].callback = sub_8148078; +} + +void sub_8148078(struct Sprite* sprite) +{ + sprite->pos1.x += 4; + sprite->pos1.y += sprite->data0; + sprite->data0 += sprite->data1; + if (sprite->data0 == 0) + PlayCry1(sprite->data2, 0); + if (sprite->data0 == 9) + sprite->callback = SpriteCallbackDummy; +} + +u8 sub_81480B4(void) +{ + u8 spriteID = sub_810BA50(188, 100, 2); + gSprites[spriteID].oam.affineMode = 1; + gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84121A0; + gSprites[spriteID].callback = SpriteCallbackDummy; + InitSpriteAffineAnim(&gSprites[spriteID]); + return spriteID; +} + +void sub_8148108(u8 spriteID, bool8 a1) +{ + FreeOamMatrix(gSprites[spriteID].oam.matrixNum); + gSprites[spriteID].oam.affineMode = 3; + if (!a1) + gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84121A4; + else + gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84121A8; + InitSpriteAffineAnim(&gSprites[spriteID]); +} + +u8 sub_814817C(void) +{ + u8 spriteID = CreateSprite(&gSpriteTemplate_84121E4, 174, 84, 1); + gSprites[spriteID].data0 = -12; + gSprites[spriteID].data1 = 1; + return spriteID; +} + +void sub_81481B0(struct Sprite* sprite) +{ + sprite->pos1.x -= 4; + sprite->pos1.y += sprite->data0; + sprite->data0 += sprite->data1; + if (sprite->data0 == 10) + DestroySprite(sprite); +} + +void sub_81481DC(void) +{ + u8 animID, i; + + gUnknown_03005F34 = 1; + animID = gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; + for (i = 0; i < 8; i++, animID++) + { + gUnknown_03005F34 += gMonPokeblockAnims[animID][4]; + if (gMonPokeblockAnims[animID][9] == 1) + break; + } +} + +extern struct Sprite gPokeblockFeedPokeSpriteCopy; +extern struct Sprite* gPokeblockFeedPokeSprite; +extern u8 gUnknown_03005F40; +extern s16 gUnknown_03005FA0[]; + +void sub_814825C(void) +{ + switch (gUnknown_03005F3C) + { + case 0: + gUnknown_03005F40 = gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; + gPokeblockFeedPokeSprite = &gSprites[gPokeblockFeedMonSpriteID]; + gPokeblockFeedPokeSpriteCopy = *gPokeblockFeedPokeSprite; + gUnknown_03005F3C = 10; + break; + case 1 ... 9: + break; + case 10: + sub_8148540(); + if (gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) + { + gPokeblockFeedPokeSprite->oam.affineMode = 3; + gPokeblockFeedPokeSprite->oam.matrixNum = 0; + gPokeblockFeedPokeSprite->affineAnims = gSpriteAffineAnimTable_8412050; + InitSpriteAffineAnim(gPokeblockFeedPokeSprite); + } + gUnknown_03005F3C = 50; + case 50: + if (gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) + { + if (gPokeblockMonNotFlipped == 0) + StartSpriteAffineAnim(gPokeblockFeedPokeSprite, gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] + 10); + else + StartSpriteAffineAnim(gPokeblockFeedPokeSprite, gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1]); + } + gUnknown_03005F3C = 60; + break; + case 60: + if (sub_81485CC() == 1) + { + if (gUnknown_03005FA0[9] == 0) + { + gUnknown_03005F40++; + sub_8148540(); + gUnknown_03005F3C = 60; + } + else + { + FreeOamMatrix(gPokeblockFeedPokeSprite->oam.matrixNum); + gUnknown_03005F3C = 70; + } + } + break; + case 70: + FreePokeSpriteMatrix(); + gUnknown_03005F40 = 0; + gUnknown_03005F3C = 0; + break; + case 71 ... 90: + break; + } +} + +bool8 sub_8148540(void) +{ + u8 i; + for (i = 0; i < 10; i++) + gUnknown_03005FA0[i] = gMonPokeblockAnims[gUnknown_03005F40][i]; + if (gUnknown_03005FA0[4] == 0) + return 1; + else + { + gUnknown_03005FA0[10] = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2]); + gUnknown_03005FA0[11] = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3]); + gUnknown_03005FA0[12] = gUnknown_03005FA0[4]; + gUnknown_03005FA0[13] = gPokeblockFeedPokeSprite->pos2.x; + gUnknown_03005FA0[14] = gPokeblockFeedPokeSprite->pos2.y; + sub_8148710(); + gUnknown_03005FA0[4] = gUnknown_03005FA0[12]; + sub_814862C(); + gUnknown_03005FA0[4] = gUnknown_03005FA0[12]; + return 0; + } +} + +bool8 sub_81485CC(void) +{ + u16 var = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; + + gPokeblockFeedPokeSprite->pos2.x = (u16)(*((u16*)(&ewram[0x1D000]) + var)); + gPokeblockFeedPokeSprite->pos2.y = (u16)(*((u16*)(&ewram[0x1D400]) + var)); + + if (--gUnknown_03005FA0[4] == 0) + return 1; + else + return 0; +} + +static bool8 FreePokeSpriteMatrix(void) +{ + FreeSpriteOamMatrix(gPokeblockFeedPokeSprite); + return 0; +} + +void sub_814862C(void) +{ + u16 i; + u16 r8 = gUnknown_03005FA0[8]; + u16 r7 = gUnknown_03005FA0[12] - r8; + s16 var3 = gUnknown_03005FA0[13] + gUnknown_03005FA0[6]; + s16 r9 = gUnknown_03005FA0[14] + gUnknown_03005FA0[7]; + + for (i = 0; i < r7 - 1; i++) + { + s16* r3 = (((u16*)(&ewram[0x1D000]) + (r8 + i))); + s16 r1 = *r3 - (var3); + + s16* r5 = (((u16*)(&ewram[0x1D400]) + (r8 + i))); + s16 r4 = *r5 - r9; + + *r3 -= r1 * (i + 1) / r7; + *r5 -= r4 * (i + 1) / r7; + } + + *((u16*)(&ewram[0x1CFFE]) + (r8 + r7)) = var3; + *((u16*)(&ewram[0x1D3FE]) + (r8 + r7)) = r9; +} + +/* +void sub_8148710(void) +{ + bool8 var_24 = 0; + s16 r8 = gUnknown_03005FA0[13] - gUnknown_03005FA0[10]; + s16 r7 = gUnknown_03005FA0[14] - gUnknown_03005FA0[11]; + s16 r5; + if (gUnknown_03005FA0[10] < 0) + r5 = -(gUnknown_03005FA0[10]) - gUnknown_03005FA0[3]; + else + r5 = (gUnknown_03005FA0[10]) - gUnknown_03005FA0[3]; + if (gUnknown_03005FA0) +} +*/ diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 3aa2f1fa5..19d2e4399 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -105,8 +105,8 @@ asm(".text\n" static EWRAM_DATA struct UnkPokenavStruct_Sub1 *gUnknown_02039304 = NULL; static EWRAM_DATA MainCallback gUnknown_02039308 = NULL; static EWRAM_DATA struct Pokeblock *gUnknown_0203930C = NULL; -EWRAM_DATA u8 gUnknown_02039310 = 0; -EWRAM_DATA s16 gUnknown_02039312 = 0; +EWRAM_DATA u8 gPokeblockMonID = 0; +EWRAM_DATA s16 gPokeblockGain = 0; extern u16 gKeyRepeatStartDelay; extern u16 gScriptItemId; // FIXME: remove after merge of #349 Pokeblock @@ -155,8 +155,8 @@ void sub_8136174(void) { gUnknown_02039304->pokeblock = gUnknown_0203930C; gUnknown_02039304->callback = gUnknown_02039308; - gUnknown_02039310 = sub_81370E4(gUnknown_02039310); - gUnknown_02039304->unk56 = gUnknown_02039310 < 4 ? 0 : 1; + gPokeblockMonID = sub_81370E4(gPokeblockMonID); + gUnknown_02039304->unk56 = gPokeblockMonID < 4 ? 0 : 1; gUnknown_083DFEC4->unkD162[0] = 2; launch_c3_walk_stairs_and_run_once(sub_8136294); SetMainCallback2(sub_81361E4); @@ -469,7 +469,7 @@ void sub_8136808(void) switch (gUnknown_02039304->unk50) { case 0: - gUnknown_02039310 = sub_81370A4(gUnknown_083DFEC4->unk87DC); + gPokeblockMonID = sub_81370A4(gUnknown_083DFEC4->unk87DC); gUnknown_02039308 = gUnknown_02039304->callback; gUnknown_0203930C = gUnknown_02039304->pokeblock; BeginNormalPaletteFade(-1, 0, 0, 16, 0); @@ -490,7 +490,7 @@ void sub_81368A4(void) switch (gUnknown_02039304->unk50) { case 0: - if (gUnknown_083DFEC4->unk87DC != gUnknown_02039310) + if (gUnknown_083DFEC4->unk87DC != gPokeblockMonID) { sub_80F5060(gUnknown_02039304->unk56); gUnknown_02039304->unk50++; @@ -578,7 +578,7 @@ void sub_81369CC(void) case 5: if (gMain.newKeys & (A_BUTTON | B_BUTTON) && !sub_8136D00()) { - sub_810CA6C((u8)gScriptItemId); + PokeblockClearIfExists((u8)gScriptItemId); launch_c3_walk_stairs_and_run_once(sub_8136B44); } break; @@ -864,9 +864,9 @@ void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) gUnknown_02039304->unk66[2] = pokeblock->bitter; gUnknown_02039304->unk66[3] = pokeblock->sweet; gUnknown_02039304->unk66[4] = pokeblock->dry; - if (gUnknown_02039312 > 0) + if (gPokeblockGain > 0) direction = 1; - else if (gUnknown_02039312 < 0) + else if (gPokeblockGain < 0) direction = -1; else return; diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 96f47c067..7001c2eaa 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -3161,7 +3161,7 @@ static u8 PickWildMonNature(void) } for (i = 0; i < 25; i++) { - if (sub_810CAE4(natures[i], safariPokeblock) > 0) + if (PokeblockGetGain(natures[i], safariPokeblock) > 0) return natures[i]; } } -- cgit v1.2.3 From be40e2196a84f0e6c3a5fb47829f52a88bd55937 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 14 Aug 2017 23:39:08 +0200 Subject: all data moved from asm to c --- src/pokeblock_feed.c | 566 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 489 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index f99eca690..18808e8af 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -24,50 +24,476 @@ extern u8 ewram[]; extern struct MusicPlayerInfo gMPlay_BGM; extern u8 gPokeblockMonID; extern s16 gPokeblockGain; -extern struct CompressedSpritePalette sPokeblockFeedSpritePal; + +extern const u8 gPokeblockRed_Pal[]; +extern const u8 gPokeblockBlue_Pal[]; +extern const u8 gPokeblockPink_Pal[]; +extern const u8 gPokeblockGreen_Pal[]; +extern const u8 gPokeblockYellow_Pal[]; +extern const u8 gPokeblockPurple_Pal[]; +extern const u8 gPokeblockIndigo_Pal[]; +extern const u8 gPokeblockBrown_Pal[]; +extern const u8 gPokeblockLiteBlue_Pal[]; +extern const u8 gPokeblockOlive_Pal[]; +extern const u8 gPokeblockGray_Pal[]; +extern const u8 gPokeblockBlack_Pal[]; +extern const u8 gPokeblockWhite_Pal[]; +extern const u8 gPokeblockGold_Pal[]; + +extern const u8 gPokeblock_Gfx[]; void sub_8147F4C(u8 taskID); bool8 sub_8040A3C(u16 species); +// this file's functions +static void sub_8147B04(void); +static void sub_81481DC(void); +static void sub_814825C(void); +static u8 sub_81480B4(void); +static u8 sub_814817C(void); +static u8 sub_8147F84(struct Pokemon* mon); +static bool8 sub_8147B20(struct Pokemon* mon); +static void sub_8147DDC(u8); +static void sub_8148044(u8); +static void sub_8148078(struct Sprite* sprite); +static void Task_PrintAtePokeblockText(u8 taskID); +static void SetPokeblockFeedSpritePal(u8); +static void sub_8148108(u8, bool8); +static bool8 sub_8148540(void); +static bool8 sub_81485CC(void); +static bool8 FreePokeSpriteMatrix(void); +void sub_8148710(void); +static void sub_81481B0(struct Sprite* sprite); +static void sub_814862C(void); + +// EWRAM +EWRAM_DATA static struct CompressedSpritePalette sPokeblockFeedSpritePal = {0}; + // IWRAM common +struct Sprite* gPokeblockFeedPokeSprite; +u16 gPokeblockFeedMonSpecies; +bool8 gPokeblockMonNotFlipped; +u8 gPokeblockFeedMonSpriteID; +u8 gPokeblockFeedMonNature; +u16 gUnknown_03005F34; +u8 gPokeblockFeedUnused0; +u8 gUnknown_03005F3C; +u8 gUnknown_03005F40; +struct Sprite gPokeblockFeedPokeSpriteCopy; +u16 gUnknown_03005F94; +s16 gUnknown_03005FA0[24]; + +// rodata + +static const u8 sNatureToMonPokeblockAnim[][2] = +{ + { 0, 0 }, // HARDY + { 3, 0 }, // LONELY + { 4, 1 }, // BRAVE + { 5, 0 }, // ADAMANT + { 10, 0 }, // NAUGHTY + { 13, 0 }, // BOLD + { 15, 0 }, // DOCILE + { 16, 2 }, // RELAXED + { 18, 0 }, // IMPISH + { 19, 0 }, // LAX + { 20, 0 }, // TIMID + { 25, 0 }, // HASTY + { 27, 3 }, // SERIOUS + { 28, 0 }, // JOLLY + { 29, 0 }, // NAIVE + { 33, 4 }, // MODEST + { 36, 0 }, // MILD + { 37, 0 }, // QUIET + { 39, 0 }, // BASHFUL + { 42, 0 }, // RASH + { 45, 0 }, // CALM + { 46, 5 }, // GENTLE + { 47, 6 }, // SASSY + { 48, 0 }, // CAREFUL + { 53, 0 }, // QUIRKY +}; + +static const s16 sMonPokeblockAnims[][10] = +{ + // HARDY + { 0, 4, 0, 8, 24, 0, 0, 0, 12, 0}, + { 0, 4, 0, 16, 24, 0, 0, 0, 12, 0}, + { 0, 4, 0, 32, 32, 0, 0, 0, 16, 1}, + + // LONELY + { 0, 3, 6, 0, 48, 0, 0, 0, 24, 1}, + + // BRAVE + { 64, 16, -24, 0, 32, 0, 0, 0, 0, 1}, + + // ADAMANT + { 0, 4, 8, 0, 16, 0, -8, 0, 0, 0}, + { 0, 0, 0, 0, 16, 0, 0, 0, 0, 0}, + { 0, 4, 8, 0, 16, 0, -8, 0, 0, 0}, + { 0, 0, 0, 0, 16, 0, 0, 0, 0, 0}, + { 0, 4, -16, 0, 4, 0, 16, 0, 0, 1}, + + // NAUGHTY + { 0, 3, 6, 0, 12, 0, 0, 0, 6, 0}, + { 0, 3, -6, 0, 12, 0, 0, 0, 6, 0}, + { 0, 16, 16, 0, 45, 1, 0, 0, 0, 1}, + + // BOLD + { 0, 16, 0, 24, 32, 0, 0, 0, 16, 0}, + { 0, 16, 0, 23, 32, 0, 0, 0, 16, 1}, + + // DOCILE + { 0, 0, 0, 0, 80, 0, 0, 0, 0, 1}, + + // RELAXED + { 0, 2, 8, 0, 32, 0, 0, 0, 0, 0}, + { 0, 2, -8, 0, 32, 0, 0, 0, 0, 1}, + + // IMPISH + { 0, 32, 2, 1, 48, 1, 0, 0, 24, 1}, + + // LAX + { 0, 2, 16, 16, 128, 0, 0, 0, 0, 1}, + + // TIMID + { 0, 2, -8, 0, 48, 0, -24, 0, 0, 0}, + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0}, + { 64, 32, 2, 0, 36, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0}, + { 0, 2, 8, 0, 48, 0, 24, 0, 0, 1}, + + // HASTY + { 64, 24, 16, 0, 32, 0, 0, 0, 0, 0}, + { 0, 28, 2, 1, 32, 1, 0, 0, 16, 1}, + + // SERIOUS + { 0, 0, 0, 0, 32, 0, 0, 0, 0, 1}, + + // JOLLY + { 64, 16, -16, 2, 48, 0, 0, 0, 32, 1}, + + // NAIVE + { 0, 12, -8, 4, 24, 0, 8, 0, 12, 0}, + { 0, 12, 8, 8, 24, 0, -16, 0, 12, 0}, + { 0, 12, -8, 16, 24, 0, 16, 0, 12, 0}, + { 0, 12, 8, 28, 24, 0, -8, 0, 12, 1}, + + // MODEST + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0}, + { 64, 16, -4, 0, 32, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 1}, + + // MILD + { 128, 4, 0, 8, 64, 0, 0, 0, 0, 1}, + + // QUIET + { 0, 2, 16, 0, 48, 0, 0, 0, 0, 0}, + { 128, 2, 16, 0, 48, 0, 0, 0, 0, 1}, + + // BASHFUL + { 0, 2, -4, 0, 48, 0, -48, 0, 0, 0}, + { 0, 0, 0, 0, 80, 0, 0, 0, 0, 0}, + { 0, 2, 8, 0, 24, 0, 48, 0, 0, 1}, + + // RASH + { 64, 4, 64, 58, 52, 0, -88, 0, 0, 0}, + { 0, 0, 0, 0, 80, 0, 0, 0, 0, 0}, + { 0, 24, 80, 0, 32, 0, 88, 0, 0, 1}, + + // CALM + { 0, 2, 16, 4, 64, 0, 0, 0, 0, 1}, + + // GENTLE + { 0, 0, 0, 0, 32, 0, 0, 0, 0, 1}, + + // SASSY + { 0, 0, 0, 0, 42, 0, 0, 0, 0, 1}, + + // CAREFUL + { 0, 4, 0, 8, 24, 0, 0, 0, 12, 0}, + { 0, 0, 0, 0, 12, 0, 0, 0, 0, 0}, + { 0, 4, 0, 12, 24, 0, 0, 0, 12, 0}, + { 0, 0, 0, 0, 12, 0, 0, 0, 0, 0}, + { 0, 4, 0, 4, 24, 0, 0, 0, 12, 1}, + + // QUIRKY + { 0, 4, 16, 12, 64, 0, 0, 0, 0, 0}, + { 0, -4, 16, 12, 64, 0, 0, 0, 0, 1}, +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411E90[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411EA0[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 12, 1), + AFFINEANIMCMD_FRAME(0, 0, 0, 30), + AFFINEANIMCMD_FRAME(0, 0, -12, 1), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411EC0[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0, 0, 12, 1), + AFFINEANIMCMD_FRAME(0, 0, 0, 28), + AFFINEANIMCMD_FRAME(0, 0, -4, 3), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411EE8[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411F08[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411F30[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411F50[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411F78[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411F98[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411FC0[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 4), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8411FE0[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 4), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8412008[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -12, 2), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8412028[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -12, 2), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_8412050[] = +{ + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411EA0, + gSpriteAffineAnim_8411EE8, + gSpriteAffineAnim_8411F30, + gSpriteAffineAnim_8411F78, + gSpriteAffineAnim_8411FC0, + gSpriteAffineAnim_8412008, + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411EC0, + gSpriteAffineAnim_8411F08, + gSpriteAffineAnim_8411F50, + gSpriteAffineAnim_8411F98, + gSpriteAffineAnim_8411FE0, + gSpriteAffineAnim_8412028, + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411E90, + gSpriteAffineAnim_8411E90, +}; + +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 gSpriteAffineAnim_84120DC[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_84120EC[] = +{ + gSpriteAffineAnim_84120DC +}; + +static const union AffineAnimCmd gSpriteAffineAnim_84120F0[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 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(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8412148[] = +{ + AFFINEANIMCMD_FRAME(0xFF00, 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(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121A0[] = +{ + gSpriteAffineAnim_84120DC +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121A4[] = +{ + gSpriteAffineAnim_84120F0 +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121A8[] = +{ + gSpriteAffineAnim_8412148 +}; + +static const struct OamData gOamData_84121AC = +{ + .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 gSpriteAnim_84121B4[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_84121BC[] = +{ + gSpriteAnim_84121B4, +}; + +static const union AffineAnimCmd gSpriteAffineAnim_84121C0[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0xFFF8, 0xFFF8, 0, 1), + AFFINEANIMCMD_JUMP(1) +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121D8[] = +{ + gSpriteAffineAnim_84121C0 +}; + +static const struct CompressedSpriteSheet gUnknown_084121DC = +{ + gPokeblock_Gfx, 0x20, 14818 +}; + +static const struct SpriteTemplate gSpriteTemplate_84121E4 = +{ + .tileTag = 14818, + .paletteTag = 14818, + .oam = &gOamData_84121AC, + .anims = gSpriteAnimTable_84121BC, + .images = NULL, + .affineAnims = gSpriteAffineAnimTable_84121D8, + .callback = sub_81481B0 +}; extern const struct CompressedSpriteSheet gUnknown_083F7F74; -extern const struct CompressedSpriteSheet gUnknown_084121DC; extern const struct CompressedSpritePalette gUnknown_083F7F7C; extern const u8 gBattleTerrainTiles_Building[]; extern const u8 gUnknown_08E782FC[]; extern const u8 gBattleTerrainPalette_BattleTower[]; -extern const u8* const gUnknown_084120A4[]; -extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84120EC[]; -extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84121A0[]; -extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84121A4[]; -extern const union AffineAnimCmd* const gSpriteAffineAnimTable_84121A8[]; -extern const union AffineAnimCmd* const gSpriteAffineAnimTable_8412050[]; -extern const struct SpriteTemplate gSpriteTemplate_84121E4; -extern const u8 gNatureToMonPokeblockAnim[][2]; -extern const s16 gMonPokeblockAnims[][10]; -// this file's functions -void sub_8147B04(void); -void sub_81481DC(void); -void sub_814825C(void); -u8 sub_81480B4(void); -u8 sub_814817C(void); -u8 sub_8147F84(struct Pokemon* mon); -bool8 sub_8147B20(struct Pokemon* mon); -void sub_8147DDC(u8); -void sub_8148044(u8); -void sub_8148078(struct Sprite* sprite); -void Task_PrintAtePokeblockText(u8 taskID); -void SetPokeblockFeedSpritePal(u8); -void sub_8148108(u8, bool8); -bool8 sub_8148540(void); -bool8 sub_81485CC(void); -static bool8 FreePokeSpriteMatrix(void); -void sub_8148710(void); -void sub_814862C(void); +// code -void sub_8147890(void) +static void sub_8147890(void) { AnimateSprites(); BuildOamBuffer(); @@ -75,14 +501,14 @@ void sub_8147890(void) UpdatePaletteFade(); } -void sub_81478A8(void) +static void sub_81478A8(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -bool8 sub_81478BC(void) +static bool8 sub_81478BC(void) { switch (gMain.state) { @@ -177,13 +603,13 @@ void sub_8147ADC(void) } } -void sub_8147B04(void) +static void sub_8147B04(void) { REG_BG1CNT = 0x1D02l; REG_DISPCNT = 0x1340; } -bool8 sub_8147B20(struct Pokemon* mon) +static bool8 sub_8147B20(struct Pokemon* mon) { u16 species; u32 PiD, TiD; @@ -241,18 +667,14 @@ bool8 sub_8147B20(struct Pokemon* mon) return 0; } -void SetPokeblockFeedSpritePal(u8 pkbID) +static void SetPokeblockFeedSpritePal(u8 pkbID) { u8 color = GetPokeblockData(&gSaveBlock1.pokeblocks[pkbID], PBLOCK_COLOR); - sPokeblockFeedSpritePal.data = gUnknown_084120A4[color - 1]; + sPokeblockFeedSpritePal.data = sPokeblocksPals[color - 1]; sPokeblockFeedSpritePal.tag = 0x39E2; } -extern u16 gUnknown_03005F94; -extern u16 gUnknown_03005F34; -extern u8 gUnknown_03005F3C; - -void sub_8147CC8(u8 taskID) +static void sub_8147CC8(u8 taskID) { if (!gPaletteFade.active) { @@ -286,20 +708,20 @@ void sub_8147CC8(u8 taskID) } } -void sub_8147DDC(u8 a0) +static void sub_8147DDC(u8 a0) { u8 taskID = CreateTask(sub_8147CC8, 0); gTasks[taskID].data[0] = 0; gTasks[taskID].data[1] = a0; } -void sub_8147E10(u8 taskID) +static void sub_8147E10(u8 taskID) { if (MenuUpdateWindowText() == 1) gTasks[taskID].func = sub_8147F4C; } -void Task_PrintAtePokeblockText(u8 taskID) +static void Task_PrintAtePokeblockText(u8 taskID) { struct Pokemon* mon = &gPlayerParty[gPokeblockMonID]; struct Pokeblock* pokeblock = &gSaveBlock1.pokeblocks[gScriptItemId]; @@ -319,7 +741,7 @@ void Task_PrintAtePokeblockText(u8 taskID) gTasks[taskID].func = sub_8147E10; } -void sub_8147F08(u8 taskID) +static void sub_8147F08(u8 taskID) { if (!gPaletteFade.active) { @@ -335,12 +757,7 @@ void sub_8147F4C(u8 taskID) gTasks[taskID].func = sub_8147F08; } -extern u16 gPokeblockFeedMonSpecies; -extern u8 gPokeblockFeedMonSpriteID; -extern u8 gPokeblockFeedMonNature; -extern bool8 gPokeblockMonNotFlipped; - -u8 sub_8147F84(struct Pokemon* mon) +static u8 sub_8147F84(struct Pokemon* mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES2); u8 spriteID = CreateSprite(&gUnknown_02024E8C, 48, 80, 2); @@ -361,7 +778,7 @@ u8 sub_8147F84(struct Pokemon* mon) return spriteID; } -void sub_8148044(u8 spriteID) +static void sub_8148044(u8 spriteID) { gSprites[spriteID].pos1.x = 48; gSprites[spriteID].pos1.y = 80; @@ -370,7 +787,7 @@ void sub_8148044(u8 spriteID) gSprites[spriteID].callback = sub_8148078; } -void sub_8148078(struct Sprite* sprite) +static void sub_8148078(struct Sprite* sprite) { sprite->pos1.x += 4; sprite->pos1.y += sprite->data0; @@ -381,7 +798,7 @@ void sub_8148078(struct Sprite* sprite) sprite->callback = SpriteCallbackDummy; } -u8 sub_81480B4(void) +static u8 sub_81480B4(void) { u8 spriteID = sub_810BA50(188, 100, 2); gSprites[spriteID].oam.affineMode = 1; @@ -391,7 +808,7 @@ u8 sub_81480B4(void) return spriteID; } -void sub_8148108(u8 spriteID, bool8 a1) +static void sub_8148108(u8 spriteID, bool8 a1) { FreeOamMatrix(gSprites[spriteID].oam.matrixNum); gSprites[spriteID].oam.affineMode = 3; @@ -402,7 +819,7 @@ void sub_8148108(u8 spriteID, bool8 a1) InitSpriteAffineAnim(&gSprites[spriteID]); } -u8 sub_814817C(void) +static u8 sub_814817C(void) { u8 spriteID = CreateSprite(&gSpriteTemplate_84121E4, 174, 84, 1); gSprites[spriteID].data0 = -12; @@ -410,7 +827,7 @@ u8 sub_814817C(void) return spriteID; } -void sub_81481B0(struct Sprite* sprite) +static void sub_81481B0(struct Sprite* sprite) { sprite->pos1.x -= 4; sprite->pos1.y += sprite->data0; @@ -419,31 +836,26 @@ void sub_81481B0(struct Sprite* sprite) DestroySprite(sprite); } -void sub_81481DC(void) +static void sub_81481DC(void) { u8 animID, i; gUnknown_03005F34 = 1; - animID = gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; + animID = sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; for (i = 0; i < 8; i++, animID++) { - gUnknown_03005F34 += gMonPokeblockAnims[animID][4]; - if (gMonPokeblockAnims[animID][9] == 1) + gUnknown_03005F34 += sMonPokeblockAnims[animID][4]; + if (sMonPokeblockAnims[animID][9] == 1) break; } } -extern struct Sprite gPokeblockFeedPokeSpriteCopy; -extern struct Sprite* gPokeblockFeedPokeSprite; -extern u8 gUnknown_03005F40; -extern s16 gUnknown_03005FA0[]; - -void sub_814825C(void) +static void sub_814825C(void) { switch (gUnknown_03005F3C) { case 0: - gUnknown_03005F40 = gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; + gUnknown_03005F40 = sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; gPokeblockFeedPokeSprite = &gSprites[gPokeblockFeedMonSpriteID]; gPokeblockFeedPokeSpriteCopy = *gPokeblockFeedPokeSprite; gUnknown_03005F3C = 10; @@ -452,7 +864,7 @@ void sub_814825C(void) break; case 10: sub_8148540(); - if (gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) + if (sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) { gPokeblockFeedPokeSprite->oam.affineMode = 3; gPokeblockFeedPokeSprite->oam.matrixNum = 0; @@ -461,12 +873,12 @@ void sub_814825C(void) } gUnknown_03005F3C = 50; case 50: - if (gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) + if (sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) { if (gPokeblockMonNotFlipped == 0) - StartSpriteAffineAnim(gPokeblockFeedPokeSprite, gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] + 10); + StartSpriteAffineAnim(gPokeblockFeedPokeSprite, sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] + 10); else - StartSpriteAffineAnim(gPokeblockFeedPokeSprite, gNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1]); + StartSpriteAffineAnim(gPokeblockFeedPokeSprite, sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1]); } gUnknown_03005F3C = 60; break; @@ -496,11 +908,11 @@ void sub_814825C(void) } } -bool8 sub_8148540(void) +static bool8 sub_8148540(void) { u8 i; for (i = 0; i < 10; i++) - gUnknown_03005FA0[i] = gMonPokeblockAnims[gUnknown_03005F40][i]; + gUnknown_03005FA0[i] = sMonPokeblockAnims[gUnknown_03005F40][i]; if (gUnknown_03005FA0[4] == 0) return 1; else @@ -518,7 +930,7 @@ bool8 sub_8148540(void) } } -bool8 sub_81485CC(void) +static bool8 sub_81485CC(void) { u16 var = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; @@ -537,7 +949,7 @@ static bool8 FreePokeSpriteMatrix(void) return 0; } -void sub_814862C(void) +static void sub_814862C(void) { u16 i; u16 r8 = gUnknown_03005FA0[8]; -- cgit v1.2.3 From dc72c86f3cd6e5f89eb3305891c451664e747296 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 15 Aug 2017 00:18:36 +0200 Subject: give better names to functions --- src/pokeblock_feed.c | 182 +++++++++++++++++++++++++-------------------------- 1 file changed, 90 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 18808e8af..300464474 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -39,10 +39,13 @@ extern const u8 gPokeblockGray_Pal[]; extern const u8 gPokeblockBlack_Pal[]; extern const u8 gPokeblockWhite_Pal[]; extern const u8 gPokeblockGold_Pal[]; - extern const u8 gPokeblock_Gfx[]; +extern const u8 gBattleTerrainTiles_Building[]; +extern const u8 gUnknown_08E782FC[]; +extern const u8 gBattleTerrainPalette_BattleTower[]; +extern const struct CompressedSpriteSheet gUnknown_083F7F74; +extern const struct CompressedSpritePalette gUnknown_083F7F7C; -void sub_8147F4C(u8 taskID); bool8 sub_8040A3C(u16 species); // this file's functions @@ -51,12 +54,13 @@ static void sub_81481DC(void); static void sub_814825C(void); static u8 sub_81480B4(void); static u8 sub_814817C(void); -static u8 sub_8147F84(struct Pokemon* mon); +static u8 PokeblockFeed_CreatePokeSprite(struct Pokemon* mon); static bool8 sub_8147B20(struct Pokemon* mon); -static void sub_8147DDC(u8); +static void LaunchPokeblockFeedTask(u8); static void sub_8148044(u8); static void sub_8148078(struct Sprite* sprite); static void Task_PrintAtePokeblockText(u8 taskID); +static void Task_PaletteFadeToReturn(u8 taskID); static void SetPokeblockFeedSpritePal(u8); static void sub_8148108(u8, bool8); static bool8 sub_8148540(void); @@ -222,13 +226,13 @@ static const s16 sMonPokeblockAnims[][10] = { 0, -4, 16, 12, 64, 0, 0, 0, 0, 1}, }; -static const union AffineAnimCmd gSpriteAffineAnim_8411E90[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411E90[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411EA0[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411EA0[] = { AFFINEANIMCMD_FRAME(0, 0, 12, 1), AFFINEANIMCMD_FRAME(0, 0, 0, 30), @@ -236,7 +240,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411EA0[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411EC0[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411EC0[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 12, 1), @@ -245,7 +249,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411EC0[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411EE8[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411EE8[] = { AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32), @@ -253,7 +257,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411EE8[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411F08[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411F08[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), @@ -262,7 +266,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411F08[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411F30[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411F30[] = { AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), @@ -270,7 +274,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411F30[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411F50[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411F50[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), @@ -279,7 +283,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411F50[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411F78[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411F78[] = { AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32), @@ -287,7 +291,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411F78[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411F98[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411F98[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), @@ -296,7 +300,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411F98[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411FC0[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411FC0[] = { AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24), @@ -304,7 +308,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411FC0[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8411FE0[] = +static const union AffineAnimCmd sSpriteAffineAnim_8411FE0[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4), @@ -313,7 +317,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8411FE0[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8412008[] = +static const union AffineAnimCmd sSpriteAffineAnim_8412008[] = { AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), @@ -321,7 +325,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_8412008[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8412028[] = +static const union AffineAnimCmd sSpriteAffineAnim_8412028[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24), @@ -330,29 +334,29 @@ static const union AffineAnimCmd gSpriteAffineAnim_8412028[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_8412050[] = -{ - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411EA0, - gSpriteAffineAnim_8411EE8, - gSpriteAffineAnim_8411F30, - gSpriteAffineAnim_8411F78, - gSpriteAffineAnim_8411FC0, - gSpriteAffineAnim_8412008, - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411EC0, - gSpriteAffineAnim_8411F08, - gSpriteAffineAnim_8411F50, - gSpriteAffineAnim_8411F98, - gSpriteAffineAnim_8411FE0, - gSpriteAffineAnim_8412028, - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411E90, - gSpriteAffineAnim_8411E90, +static const union AffineAnimCmd *const sSpriteAffineAnimTable_8412050[] = +{ + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411EA0, + sSpriteAffineAnim_8411EE8, + sSpriteAffineAnim_8411F30, + sSpriteAffineAnim_8411F78, + sSpriteAffineAnim_8411FC0, + sSpriteAffineAnim_8412008, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411EC0, + sSpriteAffineAnim_8411F08, + sSpriteAffineAnim_8411F50, + sSpriteAffineAnim_8411F98, + sSpriteAffineAnim_8411FE0, + sSpriteAffineAnim_8412028, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, }; static const u8* const sPokeblocksPals[] = @@ -373,18 +377,18 @@ static const u8* const sPokeblocksPals[] = gPokeblockGold_Pal }; -static const union AffineAnimCmd gSpriteAffineAnim_84120DC[] = +static const union AffineAnimCmd sSpriteAffineAnim_84120DC[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_END }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_84120EC[] = +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84120EC[] = { - gSpriteAffineAnim_84120DC + sSpriteAffineAnim_84120DC }; -static const union AffineAnimCmd gSpriteAffineAnim_84120F0[] = +static const union AffineAnimCmd sSpriteAffineAnim_84120F0[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), @@ -399,7 +403,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_84120F0[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8412148[] = +static const union AffineAnimCmd sSpriteAffineAnim_8412148[] = { AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), @@ -414,22 +418,22 @@ static const union AffineAnimCmd gSpriteAffineAnim_8412148[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121A0[] = +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121A0[] = { - gSpriteAffineAnim_84120DC + sSpriteAffineAnim_84120DC }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121A4[] = +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121A4[] = { - gSpriteAffineAnim_84120F0 + sSpriteAffineAnim_84120F0 }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121A8[] = +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121A8[] = { - gSpriteAffineAnim_8412148 + sSpriteAffineAnim_8412148 }; -static const struct OamData gOamData_84121AC = +static const struct OamData sOamData_84121AC = { .y = 0, .affineMode = 3, @@ -446,54 +450,48 @@ static const struct OamData gOamData_84121AC = .affineParam = 0, }; -static const union AnimCmd gSpriteAnim_84121B4[] = +static const union AnimCmd sSpriteAnim_84121B4[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_END }; -static const union AnimCmd *const gSpriteAnimTable_84121BC[] = +static const union AnimCmd *const sSpriteAnimTable_84121BC[] = { - gSpriteAnim_84121B4, + sSpriteAnim_84121B4, }; -static const union AffineAnimCmd gSpriteAffineAnim_84121C0[] = +static const union AffineAnimCmd sSpriteAffineAnim_84121C0[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0xFFF8, 0xFFF8, 0, 1), AFFINEANIMCMD_JUMP(1) }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_84121D8[] = +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121D8[] = { - gSpriteAffineAnim_84121C0 + sSpriteAffineAnim_84121C0 }; -static const struct CompressedSpriteSheet gUnknown_084121DC = +static const struct CompressedSpriteSheet sUnknown_084121DC = { gPokeblock_Gfx, 0x20, 14818 }; -static const struct SpriteTemplate gSpriteTemplate_84121E4 = +static const struct SpriteTemplate sSpriteTemplate_84121E4 = { .tileTag = 14818, .paletteTag = 14818, - .oam = &gOamData_84121AC, - .anims = gSpriteAnimTable_84121BC, + .oam = &sOamData_84121AC, + .anims = sSpriteAnimTable_84121BC, .images = NULL, - .affineAnims = gSpriteAffineAnimTable_84121D8, + .affineAnims = sSpriteAffineAnimTable_84121D8, .callback = sub_81481B0 }; -extern const struct CompressedSpriteSheet gUnknown_083F7F74; -extern const struct CompressedSpritePalette gUnknown_083F7F7C; -extern const u8 gBattleTerrainTiles_Building[]; -extern const u8 gUnknown_08E782FC[]; -extern const u8 gBattleTerrainPalette_BattleTower[]; - // code -static void sub_8147890(void) +static void CB2_PokeblockFeed(void) { AnimateSprites(); BuildOamBuffer(); @@ -501,14 +499,14 @@ static void sub_8147890(void) UpdatePaletteFade(); } -static void sub_81478A8(void) +static void VBlankCB_PokeblockFeed(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -static bool8 sub_81478BC(void) +static bool8 TransitionToPokeblockFeedScene(void) { switch (gMain.state) { @@ -557,7 +555,7 @@ static bool8 sub_81478BC(void) gMain.state++; break; case 9: - ewram[0x1FFFE] = sub_8147F84(&gPlayerParty[gPokeblockMonID]); + ewram[0x1FFFE] = PokeblockFeed_CreatePokeSprite(&gPlayerParty[gPokeblockMonID]); gMain.state++; break; case 10: @@ -577,13 +575,13 @@ static bool8 sub_81478BC(void) REG_IE |= 1; REG_IME = savedIME; REG_DISPSTAT |= 8; - SetVBlankCallback(sub_81478A8); + SetVBlankCallback(VBlankCB_PokeblockFeed); gMain.state++; } case 13: BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); gPaletteFade.bufferTransferDisabled = 0; - SetMainCallback2(sub_8147890); + SetMainCallback2(CB2_PokeblockFeed); return 1; } return 0; @@ -593,9 +591,9 @@ void sub_8147ADC(void) { while (1) { - if (sub_81478BC() == 1) + if (TransitionToPokeblockFeedScene() == 1) { - sub_8147DDC(1); + LaunchPokeblockFeedTask(1); break; } if (sub_80F9344() == 1) @@ -643,7 +641,7 @@ static bool8 sub_8147B20(struct Pokemon* mon) ewram[0x1FFFF]++; break; case 4: - LoadCompressedObjectPic(&gUnknown_084121DC); + LoadCompressedObjectPic(&sUnknown_084121DC); ewram[0x1FFFF]++; break; case 5: @@ -708,17 +706,17 @@ static void sub_8147CC8(u8 taskID) } } -static void sub_8147DDC(u8 a0) +static void LaunchPokeblockFeedTask(u8 a0) { u8 taskID = CreateTask(sub_8147CC8, 0); gTasks[taskID].data[0] = 0; gTasks[taskID].data[1] = a0; } -static void sub_8147E10(u8 taskID) +static void Task_WaitForAtePokeblockText(u8 taskID) { if (MenuUpdateWindowText() == 1) - gTasks[taskID].func = sub_8147F4C; + gTasks[taskID].func = Task_PaletteFadeToReturn; } static void Task_PrintAtePokeblockText(u8 taskID) @@ -738,10 +736,10 @@ static void Task_PrintAtePokeblockText(u8 taskID) StringExpandPlaceholders(gStringVar4, gContestStatsText_DisdainfullyAte); MenuPrintMessage(gStringVar4, 1, 15); - gTasks[taskID].func = sub_8147E10; + gTasks[taskID].func = Task_WaitForAtePokeblockText; } -static void sub_8147F08(u8 taskID) +static void Task_ReturnAfterPaletteFade(u8 taskID) { if (!gPaletteFade.active) { @@ -751,13 +749,13 @@ static void sub_8147F08(u8 taskID) } } -void sub_8147F4C(u8 taskID) +static void Task_PaletteFadeToReturn(u8 taskID) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gTasks[taskID].func = sub_8147F08; + gTasks[taskID].func = Task_ReturnAfterPaletteFade; } -static u8 sub_8147F84(struct Pokemon* mon) +static u8 PokeblockFeed_CreatePokeSprite(struct Pokemon* mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES2); u8 spriteID = CreateSprite(&gUnknown_02024E8C, 48, 80, 2); @@ -770,7 +768,7 @@ static u8 sub_8147F84(struct Pokemon* mon) gPokeblockMonNotFlipped = 1; if (!sub_8040A3C(species)) { - gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84120EC; + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84120EC; gSprites[spriteID].oam.affineMode = 3; CalcCenterToCornerVec(&gSprites[spriteID], gSprites[spriteID].oam.shape, gSprites[spriteID].oam.size, gSprites[spriteID].oam.affineMode); gPokeblockMonNotFlipped = 0; @@ -802,7 +800,7 @@ static u8 sub_81480B4(void) { u8 spriteID = sub_810BA50(188, 100, 2); gSprites[spriteID].oam.affineMode = 1; - gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84121A0; + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84121A0; gSprites[spriteID].callback = SpriteCallbackDummy; InitSpriteAffineAnim(&gSprites[spriteID]); return spriteID; @@ -813,15 +811,15 @@ static void sub_8148108(u8 spriteID, bool8 a1) FreeOamMatrix(gSprites[spriteID].oam.matrixNum); gSprites[spriteID].oam.affineMode = 3; if (!a1) - gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84121A4; + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84121A4; else - gSprites[spriteID].affineAnims = gSpriteAffineAnimTable_84121A8; + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84121A8; InitSpriteAffineAnim(&gSprites[spriteID]); } static u8 sub_814817C(void) { - u8 spriteID = CreateSprite(&gSpriteTemplate_84121E4, 174, 84, 1); + u8 spriteID = CreateSprite(&sSpriteTemplate_84121E4, 174, 84, 1); gSprites[spriteID].data0 = -12; gSprites[spriteID].data1 = 1; return spriteID; @@ -868,7 +866,7 @@ static void sub_814825C(void) { gPokeblockFeedPokeSprite->oam.affineMode = 3; gPokeblockFeedPokeSprite->oam.matrixNum = 0; - gPokeblockFeedPokeSprite->affineAnims = gSpriteAffineAnimTable_8412050; + gPokeblockFeedPokeSprite->affineAnims = sSpriteAffineAnimTable_8412050; InitSpriteAffineAnim(gPokeblockFeedPokeSprite); } gUnknown_03005F3C = 50; -- cgit v1.2.3 From 403e49189bf3f79327629d2c2245d19ece047c94 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 15 Aug 2017 10:20:19 +0200 Subject: pokeblock feed is done --- src/pokeblock_feed.c | 77 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 300464474..9cef681b0 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -53,7 +53,7 @@ static void sub_8147B04(void); static void sub_81481DC(void); static void sub_814825C(void); static u8 sub_81480B4(void); -static u8 sub_814817C(void); +static u8 CreatePokeblockSprite(void); static u8 PokeblockFeed_CreatePokeSprite(struct Pokemon* mon); static bool8 sub_8147B20(struct Pokemon* mon); static void LaunchPokeblockFeedTask(u8); @@ -67,7 +67,7 @@ static bool8 sub_8148540(void); static bool8 sub_81485CC(void); static bool8 FreePokeSpriteMatrix(void); void sub_8148710(void); -static void sub_81481B0(struct Sprite* sprite); +static void SpriteCB_ThrownPokeblock(struct Sprite* sprite); static void sub_814862C(void); // EWRAM @@ -433,7 +433,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121A8[] = sSpriteAffineAnim_8412148 }; -static const struct OamData sOamData_84121AC = +static const struct OamData sThrownPokeblockOamData = { .y = 0, .affineMode = 3, @@ -450,15 +450,15 @@ static const struct OamData sOamData_84121AC = .affineParam = 0, }; -static const union AnimCmd sSpriteAnim_84121B4[] = +static const union AnimCmd sThrownPokeblockSpriteAnim[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_END }; -static const union AnimCmd *const sSpriteAnimTable_84121BC[] = +static const union AnimCmd *const sThrownPokeblockAnimTable[] = { - sSpriteAnim_84121B4, + sThrownPokeblockSpriteAnim, }; static const union AffineAnimCmd sSpriteAffineAnim_84121C0[] = @@ -468,7 +468,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_84121C0[] = AFFINEANIMCMD_JUMP(1) }; -static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121D8[] = +static const union AffineAnimCmd *const sThrownPokeblockAffineAnimTable[] = { sSpriteAffineAnim_84121C0 }; @@ -478,15 +478,15 @@ static const struct CompressedSpriteSheet sUnknown_084121DC = gPokeblock_Gfx, 0x20, 14818 }; -static const struct SpriteTemplate sSpriteTemplate_84121E4 = +static const struct SpriteTemplate sThrownPokeblockSpriteTemplate = { .tileTag = 14818, .paletteTag = 14818, - .oam = &sOamData_84121AC, - .anims = sSpriteAnimTable_84121BC, + .oam = &sThrownPokeblockOamData, + .anims = sThrownPokeblockAnimTable, .images = NULL, - .affineAnims = sSpriteAffineAnimTable_84121D8, - .callback = sub_81481B0 + .affineAnims = sThrownPokeblockAffineAnimTable, + .callback = SpriteCB_ThrownPokeblock }; // code @@ -687,7 +687,7 @@ static void sub_8147CC8(u8 taskID) sub_8148108(ewram[0x1FFFD], gTasks[taskID].data[1]); break; case 269: - ewram[0x1FFFC] = sub_814817C(); + ewram[0x1FFFC] = CreatePokeblockSprite(); break; case 281: sub_8148044(ewram[0x1FFFE]); @@ -817,15 +817,15 @@ static void sub_8148108(u8 spriteID, bool8 a1) InitSpriteAffineAnim(&gSprites[spriteID]); } -static u8 sub_814817C(void) +static u8 CreatePokeblockSprite(void) { - u8 spriteID = CreateSprite(&sSpriteTemplate_84121E4, 174, 84, 1); + u8 spriteID = CreateSprite(&sThrownPokeblockSpriteTemplate, 174, 84, 1); gSprites[spriteID].data0 = -12; gSprites[spriteID].data1 = 1; return spriteID; } -static void sub_81481B0(struct Sprite* sprite) +static void SpriteCB_ThrownPokeblock(struct Sprite* sprite) { sprite->pos1.x -= 4; sprite->pos1.y += sprite->data0; @@ -932,8 +932,8 @@ static bool8 sub_81485CC(void) { u16 var = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; - gPokeblockFeedPokeSprite->pos2.x = (u16)(*((u16*)(&ewram[0x1D000]) + var)); - gPokeblockFeedPokeSprite->pos2.y = (u16)(*((u16*)(&ewram[0x1D400]) + var)); + gPokeblockFeedPokeSprite->pos2.x = (*((u16*)(&ewram[0x1D000]) + var)); + gPokeblockFeedPokeSprite->pos2.y = (*((u16*)(&ewram[0x1D400]) + var)); if (--gUnknown_03005FA0[4] == 0) return 1; @@ -971,17 +971,42 @@ static void sub_814862C(void) *((u16*)(&ewram[0x1D3FE]) + (r8 + r7)) = r9; } -/* void sub_8148710(void) { bool8 var_24 = 0; s16 r8 = gUnknown_03005FA0[13] - gUnknown_03005FA0[10]; s16 r7 = gUnknown_03005FA0[14] - gUnknown_03005FA0[11]; - s16 r5; - if (gUnknown_03005FA0[10] < 0) - r5 = -(gUnknown_03005FA0[10]) - gUnknown_03005FA0[3]; - else - r5 = (gUnknown_03005FA0[10]) - gUnknown_03005FA0[3]; - if (gUnknown_03005FA0) + while (1) + { + u16 r5; + u16 r4; + u16 var; + + var = abs(gUnknown_03005FA0[5]); + r5 = var + gUnknown_03005FA0[3]; + gUnknown_03005FA0[3] = r5; + + if (gUnknown_03005FA0[2] < 0) + var_24 = 1; + + r4 = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; + + if (gUnknown_03005FA0[4] == 0) + break; + + if (var_24 == 0) + { + *((u16*)(&ewram[0x1D000]) + r4) = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] + r5 / 256) + r8; + *((u16*)(&ewram[0x1D400]) + r4) = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] + r5 / 256) + r7; + } + else + { + *((u16*)(&ewram[0x1D000]) + r4) = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] - r5 / 256) + r8; + *((u16*)(&ewram[0x1D400]) + r4) = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] - r5 / 256) + r7; + } + + gUnknown_03005FA0[0] += gUnknown_03005FA0[1]; + gUnknown_03005FA0[0] &= 0xFF; + gUnknown_03005FA0[4]--; + } } -*/ -- cgit v1.2.3 From 49aebd08cc11b02c3f6ab5ad48eb9c520528ac8a Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 15 Aug 2017 12:17:14 +0200 Subject: cleaning up other pokeblock files --- src/pokeblock.c | 1 - src/pokeblock_feed.c | 2 +- src/use_pokeblock.c | 238 +++++++++++++++++++-------------------------------- 3 files changed, 90 insertions(+), 151 deletions(-) (limited to 'src') diff --git a/src/pokeblock.c b/src/pokeblock.c index 2fb544fea..029bb066f 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -25,7 +25,6 @@ #include "sound.h" #include "songs.h" #include "safari_zone.h" -#include "use_pokeblock.h" #include "event_data.h" #include "pokeblock.h" diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 9cef681b0..69917bf5d 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -587,7 +587,7 @@ static bool8 TransitionToPokeblockFeedScene(void) return 0; } -void sub_8147ADC(void) +void CB2_PreparePokeblockFeedScene(void) { while (1) { diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 19d2e4399..371c25c97 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -1,5 +1,6 @@ // // Created by Scott Norton on 5/31/17. +// Modified by Dizzy Egg on 8/15/17. // #include "global.h" @@ -16,8 +17,6 @@ #include "sound.h" #include "songs.h" #include "pokeblock.h" -#include "pokeblock_feed.h" -#include "use_pokeblock.h" #define GFX_TAG_CONDITIONUPDOWN 0 @@ -29,7 +28,7 @@ const u16 ConditionUpDownPalette[] = INCBIN_U16("graphics/misc/condition_up_down const u32 ConditionUpDownTiles[] = INCBIN_U32("graphics/misc/condition_up_down.4bpp"); #endif -const u32 gUnknown_08406118[] = { +static const u32 gUnknown_08406118[] = { MON_DATA_COOL, MON_DATA_TOUGH, MON_DATA_SMART, @@ -37,11 +36,11 @@ const u32 gUnknown_08406118[] = { MON_DATA_BEAUTY }; -const u8 gUnknown_0840612C[] = { +static const u8 gUnknown_0840612C[] = { 0, 4, 3, 2, 1 }; -const u8 *const gUnknown_08406134[] = { +static const u8 *const sContextStatNames[] = { OtherText_Coolness, OtherText_Toughness, OtherText_Smartness, @@ -49,18 +48,18 @@ const u8 *const gUnknown_08406134[] = { OtherText_Beauty }; -const struct SpriteSheet gSpriteSheet_ConditionUpDown = { +static const struct SpriteSheet gSpriteSheet_ConditionUpDown = { (u8 *)ConditionUpDownTiles, sizeof ConditionUpDownTiles, GFX_TAG_CONDITIONUPDOWN }; -const struct SpritePalette gSpritePalette_ConditionUpDown = { +static const struct SpritePalette gSpritePalette_ConditionUpDown = { ConditionUpDownPalette, GFX_TAG_CONDITIONUPDOWN }; -const s16 gUnknown_08406158[][2] = { +static const s16 gUnknown_08406158[][2] = { {0x9c, 0x1e}, {0x75, 0x35}, {0x75, 0x70}, @@ -68,28 +67,28 @@ const s16 gUnknown_08406158[][2] = { {0xc5, 0x35} }; -const struct OamData gOamData_840616C = { +static const struct OamData gOamData_840616C = { .shape = 1, .size = 2, .priority = 1 }; -const union AnimCmd gSpriteAnim_8406174[] = { +static const union AnimCmd gSpriteAnim_8406174[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd gSpriteAnim_840617C[] = { +static const union AnimCmd gSpriteAnim_840617C[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_8406184[] = { +static const union AnimCmd *const gSpriteAnimTable_8406184[] = { gSpriteAnim_8406174, gSpriteAnim_840617C }; -const struct SpriteTemplate gSpriteTemplate_840618C = { +static const struct SpriteTemplate gSpriteTemplate_840618C = { GFX_TAG_CONDITIONUPDOWN, GFX_TAG_CONDITIONUPDOWN, &gOamData_840616C, @@ -99,9 +98,6 @@ const struct SpriteTemplate gSpriteTemplate_840618C = { SpriteCallbackDummy }; -asm(".text\n" - ".include \"constants/gba_constants.inc\""); - static EWRAM_DATA struct UnkPokenavStruct_Sub1 *gUnknown_02039304 = NULL; static EWRAM_DATA MainCallback gUnknown_02039308 = NULL; static EWRAM_DATA struct Pokeblock *gUnknown_0203930C = NULL; @@ -111,35 +107,35 @@ EWRAM_DATA s16 gPokeblockGain = 0; extern u16 gKeyRepeatStartDelay; extern u16 gScriptItemId; // FIXME: remove after merge of #349 Pokeblock -void launch_c3_walk_stairs_and_run_once(void (*const)(void)); -void sub_81361E4(void); -void sub_813622C(void); -void sub_8136244(void); -void sub_8136264(void); -void sub_8136294(void); -void sub_81365A0(void); -void sub_81365C8(void); -void sub_8136638(void); -void sub_81368A4(void); +static void launch_c3_walk_stairs_and_run_once(void (*const)(void)); +static void sub_81361E4(void); +static void sub_813622C(void); +static void sub_8136244(void); +static void sub_8136264(void); +static void sub_8136294(void); +static void sub_81365A0(void); +static void sub_81365C8(void); +static void sub_8136638(void); +static void sub_81368A4(void); void sub_8089668(void); -void sub_8136B44(void); -u8 sub_81370E4(u8); -void sub_8136BB8(void); -s8 sub_8136C40(void); -bool8 sub_8137058(void); -void sub_8136D60(void); -void sub_8136808(void); -void sub_8136D8C(void); -u8 sub_81370A4(u8); -void sub_81369CC(void); -void sub_8136EF0(void); -void sub_8137138(void); -void sub_8136C6C(void); -bool8 sub_8136D00(void); -void sub_8136DC0(u8 *, u8, s16); -void sub_8136DA0(const u8 *); -void sub_8136F74(struct Pokeblock *, struct Pokemon *); -void sub_81371DC(struct Sprite *); +static void sub_8136B44(void); +static u8 sub_81370E4(u8); +static void sub_8136BB8(void); +static s8 sub_8136C40(void); +static bool8 sub_8137058(void); +static void sub_8136D60(void); +static void sub_8136808(void); +static void sub_8136D8C(void); +static u8 sub_81370A4(u8); +static void sub_81369CC(void); +static void sub_8136EF0(void); +static void sub_8137138(void); +static void sub_8136C6C(void); +static bool8 sub_8136D00(void); +static void Pokeblock_BufferEnhancedStatText(u8 *, u8, s16); +static void Pokeblock_MenuWindowTextPrint(const u8 *); +static void sub_8136F74(struct Pokeblock *, struct Pokemon *); +static void sub_81371DC(struct Sprite *); void sub_8136130(struct Pokeblock *pokeblock, MainCallback callback) { @@ -151,7 +147,7 @@ void sub_8136130(struct Pokeblock *pokeblock, MainCallback callback) SetMainCallback2(sub_8136244); } -void sub_8136174(void) +static void sub_8136174(void) { gUnknown_02039304->pokeblock = gUnknown_0203930C; gUnknown_02039304->callback = gUnknown_02039308; @@ -162,7 +158,7 @@ void sub_8136174(void) SetMainCallback2(sub_81361E4); } -void sub_81361E4(void) +static void sub_81361E4(void) { gUnknown_02039304->unk0(); AnimateSprites(); @@ -176,7 +172,7 @@ void sub_81361E4(void) } } -void sub_813622C(void) +static void sub_813622C(void) { sub_81368A4(); AnimateSprites(); @@ -184,7 +180,7 @@ void sub_813622C(void) UpdatePaletteFade(); } -void sub_8136244(void) +static void sub_8136244(void) { gUnknown_02039304->unk0(); AnimateSprites(); @@ -192,7 +188,7 @@ void sub_8136244(void) UpdatePaletteFade(); } -void sub_8136264(void) +static void sub_8136264(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -201,13 +197,13 @@ void sub_8136264(void) sub_8089668(); } -void launch_c3_walk_stairs_and_run_once(void (*const func)(void)) +static void launch_c3_walk_stairs_and_run_once(void (*const func)(void)) { gUnknown_02039304->unk0 = func; gUnknown_02039304->unk50 = 0; } -void sub_8136294(void) +static void sub_8136294(void) { bool32 c1LinkRelatedActive; switch (gUnknown_02039304->unk50) @@ -346,7 +342,7 @@ void sub_8136294(void) } } -void sub_81365A0(void) +static void sub_81365A0(void) { while (!gUnknown_02039304->unk55) { @@ -354,7 +350,7 @@ void sub_81365A0(void) } } -void sub_81365C8(void) +static void sub_81365C8(void) { switch (gUnknown_02039304->unk50) { @@ -374,7 +370,7 @@ void sub_81365C8(void) } } -void sub_8136638(void) +static void sub_8136638(void) { switch (gUnknown_02039304->unk50) { @@ -464,7 +460,7 @@ void sub_8136638(void) } } -void sub_8136808(void) +static void sub_8136808(void) { switch (gUnknown_02039304->unk50) { @@ -479,13 +475,13 @@ void sub_8136808(void) if (!gPaletteFade.active) { gMain.savedCallback = sub_8136174; - SetMainCallback2(sub_8147ADC); + SetMainCallback2(CB2_PreparePokeblockFeedScene); } break; } } -void sub_81368A4(void) +static void sub_81368A4(void) { switch (gUnknown_02039304->unk50) { @@ -538,7 +534,7 @@ void sub_81368A4(void) } } -void sub_81369CC(void) +static void sub_81369CC(void) { switch (gUnknown_02039304->unk50) { @@ -585,7 +581,7 @@ void sub_81369CC(void) } } -void sub_8136B44(void) +static void sub_8136B44(void) { switch (gUnknown_02039304->unk50) { @@ -609,7 +605,7 @@ void sub_8136B44(void) } } -void sub_8136BB8(void) +static void sub_8136BB8(void) { GetMonData(&gPlayerParty[sub_81370A4(gUnknown_083DFEC4->unk87DC)], MON_DATA_NICKNAME, gUnknown_02039304->stringBuffer); StringGetEnd10(gUnknown_02039304->stringBuffer); @@ -621,7 +617,7 @@ void sub_8136BB8(void) MoveMenuCursor(0); } -s8 sub_8136C40(void) +static s8 sub_8136C40(void) { s8 retval = ProcessMenuInputNoWrap(); if ((u8)(retval + 1) < 3) @@ -632,124 +628,68 @@ s8 sub_8136C40(void) return retval; } -void sub_8136C6C(void) +static void sub_8136C6C(void) { BasicInitMenuWindow(&gWindowConfig_81E709C); MenuDrawTextWindow(0, 16, 29, 19); for (gUnknown_02039304->unk53 = 0; gUnknown_02039304->unk53 < 5 && gUnknown_02039304->unk61[gUnknown_02039304->unk53] == 0; gUnknown_02039304->unk53++); if (gUnknown_02039304->unk53 < 5) { - sub_8136DC0(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); + Pokeblock_BufferEnhancedStatText(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); } else { - sub_8136DC0(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, 0); + Pokeblock_BufferEnhancedStatText(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, 0); } - sub_8136DA0(gUnknown_02039304->stringBuffer); + Pokeblock_MenuWindowTextPrint(gUnknown_02039304->stringBuffer); } -#ifdef NONMATCHING -bool8 sub_8136D00(void) +static bool8 sub_8136D00(void) { while (1) { - if (++gUnknown_02039304->unk53 >= 5) + gUnknown_02039304->unk53++; + if (gUnknown_02039304->unk53 < 5) { - break; + if (gUnknown_02039304->unk61[gUnknown_02039304->unk53] != 0) + break; } - if (gUnknown_02039304->unk61[gUnknown_02039304->unk53] != 0) + else { - sub_8136DC0(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); - sub_8136DA0(gUnknown_02039304->stringBuffer); - return TRUE; + gUnknown_02039304->unk53 = 5; + return FALSE; } } - gUnknown_02039304->unk53 = 5; - return FALSE; + Pokeblock_BufferEnhancedStatText(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); + Pokeblock_MenuWindowTextPrint(gUnknown_02039304->stringBuffer); + return TRUE; } -#else -__attribute__((naked)) -bool8 sub_8136D00(void) -{ - asm_unified("\tpush {r4,r5,lr}\n" - "\tldr r4, _08136D30 @ =gUnknown_02039304\n" - "\tadds r3, r4, 0\n" - "\tmovs r5, 0x5\n" - "_08136D08:\n" - "\tldr r0, [r3]\n" - "\tadds r0, 0x53\n" - "\tldrb r1, [r0]\n" - "\tadds r1, 0x1\n" - "\tstrb r1, [r0]\n" - "\tldr r2, [r3]\n" - "\tadds r1, r2, 0\n" - "\tadds r1, 0x53\n" - "\tldrb r0, [r1]\n" - "\tcmp r0, 0x4\n" - "\tbhi _08136D34\n" - "\tadds r0, r2, 0\n" - "\tadds r0, 0x61\n" - "\tldrb r1, [r1]\n" - "\tadds r0, r1\n" - "\tldrb r0, [r0]\n" - "\tcmp r0, 0\n" - "\tbne _08136D3A\n" - "\tb _08136D08\n" - "\t.align 2, 0\n" - "_08136D30: .4byte gUnknown_02039304\n" - "_08136D34:\n" - "\tstrb r5, [r1]\n" - "\tmovs r0, 0\n" - "\tb _08136D5A\n" - "_08136D3A:\n" - "\tldr r2, [r4]\n" - "\tadds r0, r2, 0\n" - "\tadds r0, 0x10\n" - "\tadds r1, r2, 0\n" - "\tadds r1, 0x53\n" - "\tldrb r1, [r1]\n" - "\tadds r2, 0x61\n" - "\tadds r2, r1\n" - "\tldrb r2, [r2]\n" - "\tbl sub_8136DC0\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0x10\n" - "\tbl sub_8136DA0\n" - "\tmovs r0, 0x1\n" - "_08136D5A:\n" - "\tpop {r4,r5}\n" - "\tpop {r1}\n" - "\tbx r1"); -} -#endif -void sub_8136D60(void) +static void sub_8136D60(void) { BasicInitMenuWindow(&gWindowConfig_81E709C); MenuDrawTextWindow(0, 16, 29, 19); MenuPrint(gOtherText_WontEat, 1, 17); } -void sub_8136D8C(void) +static void sub_8136D8C(void) { MenuZeroFillScreen(); BasicInitMenuWindow(&gWindowConfig_81E7080); } -void sub_8136DA0(const u8 *message) +static void Pokeblock_MenuWindowTextPrint(const u8 *message) { MenuDrawTextWindow(0, 16, 29, 19); MenuPrint(message, 1, 17); } #ifdef NONMATCHING -void sub_8136DC0(u8 *dest, u8 a1, s16 a2) +static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) { - u16 v0 = a2; if (a2 != 0) { - if ((v0 = max(a2, 0)) == 0); - StringCopy(dest, gUnknown_08406134[a1]); + StringCopy(dest, sContextStatNames[statID]); StringAppend(dest, gOtherText_WasEnhanced); } else @@ -759,7 +699,7 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) } #else __attribute__((naked)) -void sub_8136DC0(u8 *dest, u8 a1, s16 a2) +static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 a1, s16 a2) { asm_unified("\tpush {r4,lr}\n" "\tadds r4, r0, 0\n" @@ -775,7 +715,7 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) "\tmovs r0, 0\n" "_08136DD8:\n" "\tlsls r0, 16\n" - "\tldr r1, _08136DF4 @ =gUnknown_08406134\n" + "\tldr r1, _08136DF4 @ =sContextStatNames\n" "\tlsls r0, r3, 2\n" "\tadds r0, r1\n" "\tldr r1, [r0]\n" @@ -786,7 +726,7 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) "\tbl StringAppend\n" "\tb _08136E04\n" "\t.align 2, 0\n" - "_08136DF4: .4byte gUnknown_08406134\n" + "_08136DF4: .4byte sContextStatNames\n" "_08136DF8: .4byte gOtherText_WasEnhanced\n" "_08136DFC:\n" "\tldr r1, _08136E0C @ =gOtherText_NothingChanged\n" @@ -801,7 +741,7 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) } #endif -void sub_8136E10(struct Pokemon *pokemon, u8 *data) +static void sub_8136E10(struct Pokemon *pokemon, u8 *data) { u16 i; for (i=0; i<5; i++) @@ -810,7 +750,7 @@ void sub_8136E10(struct Pokemon *pokemon, u8 *data) } } -void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +static void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) { u16 i; s16 cstat; @@ -838,7 +778,7 @@ void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) } } -void sub_8136EF0(void) +static void sub_8136EF0(void) { u16 i; struct Pokemon *pokemon = gPlayerParty; @@ -852,7 +792,7 @@ void sub_8136EF0(void) } } -void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +static void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) { s8 direction; s8 i; @@ -884,7 +824,7 @@ void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) } } -bool8 sub_8137058(void) +static bool8 sub_8137058(void) { struct Pokemon *pokemon = gPlayerParty; pokemon += gUnknown_083DFEC4->unk893c[gUnknown_083DFEC4->unk87DC].partyIdx; @@ -893,7 +833,7 @@ bool8 sub_8137058(void) return FALSE; } -u8 sub_81370A4(u8 a0) +static u8 sub_81370A4(u8 a0) { u8 i; for (i=0; idata0 <= 5) sprite->pos2.y -= 2; -- cgit v1.2.3 From 296534003f07e6f240b11bb60fec87df42e864f4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 15 Aug 2017 12:40:10 +0200 Subject: more cleaning, make it compile --- src/use_pokeblock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 371c25c97..0c8f59959 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -28,7 +28,7 @@ const u16 ConditionUpDownPalette[] = INCBIN_U16("graphics/misc/condition_up_down const u32 ConditionUpDownTiles[] = INCBIN_U32("graphics/misc/condition_up_down.4bpp"); #endif -static const u32 gUnknown_08406118[] = { +static const u32 sContestStatsMonData[] = { MON_DATA_COOL, MON_DATA_TOUGH, MON_DATA_SMART, @@ -741,12 +741,12 @@ static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 a1, s16 a2) } #endif -static void sub_8136E10(struct Pokemon *pokemon, u8 *data) +static void Pokeblock_GetMonContestStats(struct Pokemon *pokemon, u8 *data) { u16 i; for (i=0; i<5; i++) { - data[i] = GetMonData(pokemon, gUnknown_08406118[i]); + data[i] = GetMonData(pokemon, sContestStatsMonData[i]); } } @@ -760,14 +760,14 @@ static void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) sub_8136F74(pokeblock, pokemon); for (i=0; i<5; i++) { - data = GetMonData(pokemon, gUnknown_08406118[i]); + data = GetMonData(pokemon, sContestStatsMonData[i]); cstat = data + gUnknown_02039304->unk66[i]; if (cstat < 0) cstat = 0; if (cstat > 255) cstat = 255; data = cstat; - SetMonData(pokemon, gUnknown_08406118[i], &data); + SetMonData(pokemon, sContestStatsMonData[i], &data); } cstat = (u8)GetMonData(pokemon, MON_DATA_SHEEN); cstat = cstat + pokeblock->feel; @@ -783,9 +783,9 @@ static void sub_8136EF0(void) u16 i; struct Pokemon *pokemon = gPlayerParty; pokemon += gUnknown_083DFEC4->unk893c[gUnknown_083DFEC4->unk87DC].partyIdx; - sub_8136E10(pokemon, gUnknown_02039304->unk57); + Pokeblock_GetMonContestStats(pokemon, gUnknown_02039304->unk57); sub_8136E40(gUnknown_02039304->pokeblock, pokemon); - sub_8136E10(pokemon, gUnknown_02039304->unk5c); + Pokeblock_GetMonContestStats(pokemon, gUnknown_02039304->unk5c); for (i=0; i<5; i++) { gUnknown_02039304->unk61[i] = gUnknown_02039304->unk5c[i] - gUnknown_02039304->unk57[i]; -- cgit v1.2.3 From 8eb47079f9c339f43f4b7d8dee494b495f799de1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 25 Aug 2017 00:38:49 +0200 Subject: code review changes --- src/pokeblock_feed.c | 121 ++++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 69917bf5d..8dc2f47de 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -92,30 +92,30 @@ s16 gUnknown_03005FA0[24]; static const u8 sNatureToMonPokeblockAnim[][2] = { { 0, 0 }, // HARDY - { 3, 0 }, // LONELY - { 4, 1 }, // BRAVE - { 5, 0 }, // ADAMANT - { 10, 0 }, // NAUGHTY - { 13, 0 }, // BOLD - { 15, 0 }, // DOCILE - { 16, 2 }, // RELAXED - { 18, 0 }, // IMPISH - { 19, 0 }, // LAX - { 20, 0 }, // TIMID - { 25, 0 }, // HASTY - { 27, 3 }, // SERIOUS - { 28, 0 }, // JOLLY - { 29, 0 }, // NAIVE - { 33, 4 }, // MODEST - { 36, 0 }, // MILD - { 37, 0 }, // QUIET - { 39, 0 }, // BASHFUL - { 42, 0 }, // RASH - { 45, 0 }, // CALM - { 46, 5 }, // GENTLE - { 47, 6 }, // SASSY - { 48, 0 }, // CAREFUL - { 53, 0 }, // QUIRKY + { 3, 0 }, // LONELY + { 4, 1 }, // BRAVE + { 5, 0 }, // ADAMANT + { 10, 0 }, // NAUGHTY + { 13, 0 }, // BOLD + { 15, 0 }, // DOCILE + { 16, 2 }, // RELAXED + { 18, 0 }, // IMPISH + { 19, 0 }, // LAX + { 20, 0 }, // TIMID + { 25, 0 }, // HASTY + { 27, 3 }, // SERIOUS + { 28, 0 }, // JOLLY + { 29, 0 }, // NAIVE + { 33, 4 }, // MODEST + { 36, 0 }, // MILD + { 37, 0 }, // QUIET + { 39, 0 }, // BASHFUL + { 42, 0 }, // RASH + { 45, 0 }, // CALM + { 46, 5 }, // GENTLE + { 47, 6 }, // SASSY + { 48, 0 }, // CAREFUL + { 53, 0 }, // QUIRKY }; static const s16 sMonPokeblockAnims[][10] = @@ -228,7 +228,7 @@ static const s16 sMonPokeblockAnims[][10] = static const union AffineAnimCmd sSpriteAffineAnim_8411E90[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_END }; @@ -242,7 +242,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_8411EA0[] = static const union AffineAnimCmd sSpriteAffineAnim_8411EC0[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 12, 1), AFFINEANIMCMD_FRAME(0, 0, 0, 28), AFFINEANIMCMD_FRAME(0, 0, -4, 3), @@ -259,7 +259,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_8411EE8[] = static const union AffineAnimCmd sSpriteAffineAnim_8411F08[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), @@ -276,7 +276,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_8411F30[] = static const union AffineAnimCmd sSpriteAffineAnim_8411F50[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), @@ -293,7 +293,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_8411F78[] = static const union AffineAnimCmd sSpriteAffineAnim_8411F98[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), @@ -310,7 +310,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_8411FC0[] = static const union AffineAnimCmd sSpriteAffineAnim_8411FE0[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 4), @@ -327,7 +327,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_8412008[] = static const union AffineAnimCmd sSpriteAffineAnim_8412028[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24), AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), AFFINEANIMCMD_FRAME(0x0, 0x0, -12, 2), @@ -379,7 +379,7 @@ static const u8* const sPokeblocksPals[] = static const union AffineAnimCmd sSpriteAffineAnim_84120DC[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_END }; @@ -390,7 +390,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_84120EC[] = static const union AffineAnimCmd sSpriteAffineAnim_84120F0[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), @@ -399,13 +399,13 @@ static const union AffineAnimCmd sSpriteAffineAnim_84120F0[] = AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_END }; static const union AffineAnimCmd sSpriteAffineAnim_8412148[] = { - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), @@ -414,7 +414,7 @@ static const union AffineAnimCmd sSpriteAffineAnim_8412148[] = AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), - AFFINEANIMCMD_FRAME(0xFF00, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_END }; @@ -464,7 +464,7 @@ static const union AnimCmd *const sThrownPokeblockAnimTable[] = static const union AffineAnimCmd sSpriteAffineAnim_84121C0[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), - AFFINEANIMCMD_FRAME(0xFFF8, 0xFFF8, 0, 1), + AFFINEANIMCMD_FRAME(-8, -8, 0, 1), AFFINEANIMCMD_JUMP(1) }; @@ -582,9 +582,9 @@ static bool8 TransitionToPokeblockFeedScene(void) BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); gPaletteFade.bufferTransferDisabled = 0; SetMainCallback2(CB2_PokeblockFeed); - return 1; + return TRUE; } - return 0; + return FALSE; } void CB2_PreparePokeblockFeedScene(void) @@ -660,9 +660,9 @@ static bool8 sub_8147B20(struct Pokemon* mon) case 8: LoadCompressedPalette(gBattleTerrainPalette_BattleTower, 0x20, 0x60); ewram[0x1FFFF] = 0; - return 1; + return TRUE; } - return 0; + return FALSE; } static void SetPokeblockFeedSpritePal(u8 pkbID) @@ -912,7 +912,7 @@ static bool8 sub_8148540(void) for (i = 0; i < 10; i++) gUnknown_03005FA0[i] = sMonPokeblockAnims[gUnknown_03005F40][i]; if (gUnknown_03005FA0[4] == 0) - return 1; + return TRUE; else { gUnknown_03005FA0[10] = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2]); @@ -924,27 +924,30 @@ static bool8 sub_8148540(void) gUnknown_03005FA0[4] = gUnknown_03005FA0[12]; sub_814862C(); gUnknown_03005FA0[4] = gUnknown_03005FA0[12]; - return 0; + return FALSE; } } +#define ewram1D000 ((u16 *)(ewram + 0x1D000)) +#define ewram1D400 ((u16 *)(ewram + 0x1D400)) + static bool8 sub_81485CC(void) { u16 var = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; - gPokeblockFeedPokeSprite->pos2.x = (*((u16*)(&ewram[0x1D000]) + var)); - gPokeblockFeedPokeSprite->pos2.y = (*((u16*)(&ewram[0x1D400]) + var)); + gPokeblockFeedPokeSprite->pos2.x = ewram1D000[var]; + gPokeblockFeedPokeSprite->pos2.y = ewram1D400[var]; if (--gUnknown_03005FA0[4] == 0) - return 1; + return TRUE; else - return 0; + return FALSE; } static bool8 FreePokeSpriteMatrix(void) { FreeSpriteOamMatrix(gPokeblockFeedPokeSprite); - return 0; + return FALSE; } static void sub_814862C(void) @@ -957,23 +960,23 @@ static void sub_814862C(void) for (i = 0; i < r7 - 1; i++) { - s16* r3 = (((u16*)(&ewram[0x1D000]) + (r8 + i))); + s16* r3 = &ewram1D000[r8 + i]; s16 r1 = *r3 - (var3); - s16* r5 = (((u16*)(&ewram[0x1D400]) + (r8 + i))); + s16* r5 = &ewram1D400[r8 + i]; s16 r4 = *r5 - r9; *r3 -= r1 * (i + 1) / r7; *r5 -= r4 * (i + 1) / r7; } - *((u16*)(&ewram[0x1CFFE]) + (r8 + r7)) = var3; - *((u16*)(&ewram[0x1D3FE]) + (r8 + r7)) = r9; + ewram1D000[(r8 + r7) - 1] = var3; + ewram1D400[(r8 + r7) - 1] = r9; } void sub_8148710(void) { - bool8 var_24 = 0; + bool8 var_24 = FALSE; s16 r8 = gUnknown_03005FA0[13] - gUnknown_03005FA0[10]; s16 r7 = gUnknown_03005FA0[14] - gUnknown_03005FA0[11]; while (1) @@ -987,22 +990,22 @@ void sub_8148710(void) gUnknown_03005FA0[3] = r5; if (gUnknown_03005FA0[2] < 0) - var_24 = 1; + var_24 = TRUE; r4 = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; if (gUnknown_03005FA0[4] == 0) break; - if (var_24 == 0) + if (!var_24) { - *((u16*)(&ewram[0x1D000]) + r4) = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] + r5 / 256) + r8; - *((u16*)(&ewram[0x1D400]) + r4) = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] + r5 / 256) + r7; + ewram1D000[r4] = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] + r5 / 256) + r8; + ewram1D400[r4] = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] + r5 / 256) + r7; } else { - *((u16*)(&ewram[0x1D000]) + r4) = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] - r5 / 256) + r8; - *((u16*)(&ewram[0x1D400]) + r4) = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] - r5 / 256) + r7; + ewram1D000[r4] = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] - r5 / 256) + r8; + ewram1D400[r4] = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] - r5 / 256) + r7; } gUnknown_03005FA0[0] += gUnknown_03005FA0[1]; -- cgit v1.2.3