Next big honkin' function done

This commit is contained in:
Diegoisawesome 2018-12-28 13:42:34 -06:00
parent f30270dffe
commit 146ad2bdd4
2 changed files with 520 additions and 2108 deletions

File diff suppressed because it is too large Load Diff

View File

@ -200,6 +200,7 @@ extern const struct SpriteTemplate gUnknown_08338D88;
extern const struct SpriteTemplate gSpriteTemplate_8338DC8;
extern const union AffineAnimCmd *const gSpriteAffineAnimTable_8338ECC[];
extern const struct SpriteTemplate gSpriteTemplate_8338E74;
extern const struct SpriteTemplate gSpriteTemplate_8338E8C;
// external to this file
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
@ -251,7 +252,9 @@ void sub_807AAE0(struct Sprite *);
void sub_807E6AC(struct Sprite *);
void sub_807F14C(void);
void sub_807E784(void);
void c3_08054588(u8);
void c3_0805465C(u8);
void sub_807F39C(u8);
bool8 sub_8077170(const void *a0, u32 a1)
{
@ -3727,14 +3730,13 @@ bool8 sub_807BBEC(void)
gUnknown_020322A0->unk_94++;
}
break;
/*case 13:
case 13:
// The game waits here for the sprite to finish its animation sequence.
break;*/
break;
case 14:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gUnknown_020322A0->unk_94 = 20;
break;
case 20:
if (!gPaletteFade.active)
{
@ -4162,3 +4164,518 @@ bool8 sub_807BBEC(void)
}
return FALSE;
}
bool8 sub_807CFC8(void)
{
u16 evoTarget;
switch (gUnknown_020322A0->unk_94)
{
case 0:
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = -180;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[0]].y_offset;
gUnknown_020322A0->unk_94++;
gUnknown_020322A0->unk_F4 = GetCurrentMapMusic();
PlayNewMapMusic(MUS_SHINKA);
break;
case 1:
if (gUnknown_020322A0->bg2hofs > 0)
{
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x += 3;
gUnknown_020322A0->bg2hofs -= 3;
}
else
{
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = 0;
gUnknown_020322A0->bg2hofs = 0;
gUnknown_020322A0->unk_94 = 10;
}
break;
case 10:
StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY);
sub_807F1A8(0, gStringVar4, 0);
if (gUnknown_020322A0->tradeSpecies[0] != SPECIES_EGG)
{
PlayCry1(gUnknown_020322A0->tradeSpecies[0], 0);
}
gUnknown_020322A0->unk_94 = 11;
gUnknown_020322A0->unk_64 = 0;
break;
case 11:
if (++gUnknown_020322A0->unk_64 == 80)
{
gUnknown_020322A0->unk_D2 = sub_807671C(gUnknown_020322A0->pokePicSpriteIdxs[0], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff);
gUnknown_020322A0->unk_94++;
StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1);
sub_807F1A8(0, gStringVar4, 0);
}
break;
case 12:
if (gSprites[gUnknown_020322A0->unk_D2].callback == SpriteCallbackDummy)
{
gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0);
gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E5D8;
DestroySprite(&gSprites[gUnknown_020322A0->unk_D2]);
gUnknown_020322A0->unk_94++;
}
break;
case 13:
// The game waits here for the sprite to finish its animation sequence.
break;
case 14:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gUnknown_020322A0->unk_94 = 20;
break;
case 20:
if (!gPaletteFade.active)
{
sub_807B62C(4);
FillWindowPixelBuffer(0, 0xFF);
CopyWindowToVram(0, 3);
gUnknown_020322A0->unk_94++;
}
break;
case 21:
BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK);
gUnknown_020322A0->unk_94++;
break;
case 22:
if (!gPaletteFade.active)
{
gUnknown_020322A0->unk_94 = 23;
}
break;
case 23:
if (gUnknown_020322A0->unk_EA > 0x100)
{
gUnknown_020322A0->unk_EA -= 0x34;
}
else
{
sub_807B62C(1);
gUnknown_020322A0->unk_EA = 0x80;
gUnknown_020322A0->unk_94 = 124;
gUnknown_020322A0->unk_64 = 0;
}
gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA;
break;
case 124:
if (++gUnknown_020322A0->unk_64 > 20)
{
sub_807B62C(3);
gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0);
gUnknown_020322A0->unk_94++;
}
break;
case 125:
if (gSprites[gUnknown_020322A0->unk_91].animEnded)
{
DestroySprite(&gSprites[gUnknown_020322A0->unk_91]);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 |
BLDCNT_TGT1_OBJ |
BLDCNT_EFFECT_BLEND |
BLDCNT_TGT2_BG2);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 4));
CreateTask(c3_08054588, 5);
gUnknown_020322A0->unk_94++;
}
break;
case 126:
if (!FuncIsActiveTask(c3_08054588))
{
gUnknown_020322A0->unk_94 = 26;
}
break;
case 26:
if (--gUnknown_020322A0->bg1vofs == 316)
{
gUnknown_020322A0->unk_94++;
}
break;
case 27:
gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3);
gSprites[gUnknown_020322A0->unk_90].callback = sub_807AA4C;
gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, 80, 0);
StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1);
gUnknown_020322A0->unk_94++;
break;
case 28:
if ((gUnknown_020322A0->bg1vofs -= 3) == 166)
{
gUnknown_020322A0->unk_94 = 200;
}
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_BG1_ON |
DISPCNT_OBJ_ON);
break;
case 200:
gSprites[gUnknown_020322A0->unk_90].pos1.y -= 2;
gSprites[gUnknown_020322A0->unk_91].pos1.y -= 2;
if (gSprites[gUnknown_020322A0->unk_90].pos1.y < -8)
{
gUnknown_020322A0->unk_94 = 29;
}
break;
case 29:
BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK);
gUnknown_020322A0->unk_94 = 30;
break;
case 30:
if (!gPaletteFade.active)
{
DestroySprite(&gSprites[gUnknown_020322A0->unk_90]);
DestroySprite(&gSprites[gUnknown_020322A0->unk_91]);
sub_807B62C(2);
gUnknown_020322A0->unk_94++;
}
break;
case 31:
BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK);
gUnknown_020322A0->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0);
gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0);
gUnknown_020322A0->unk_94++;
break;
case 32:
if (!gPaletteFade.active)
{
PlaySE(SE_TK_WARPOUT);
gUnknown_020322A0->unk_94++;
}
gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3;
gSprites[gUnknown_020322A0->unk_91].pos2.y += 3;
break;
case 33:
gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3;
gSprites[gUnknown_020322A0->unk_91].pos2.y += 3;
if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -90)
{
gSprites[gUnknown_020322A0->unk_90].data[1] = 1;
gSprites[gUnknown_020322A0->unk_91].data[1] = 1;
gUnknown_020322A0->unk_94++;
CreateTask(c3_0805465C, 5);
}
break;
case 34:
BlendPalettes(0x8, 16, RGB_WHITEALPHA);
gUnknown_020322A0->unk_94++;
break;
case 35:
BlendPalettes(0x8, 16, RGB_WHITEALPHA);
gUnknown_020322A0->unk_94++;
break;
case 36:
BlendPalettes(0x8, 16, RGB_WHITEALPHA);
gUnknown_020322A0->unk_94++;
break;
case 37:
if (!IsMonSpriteNotFlipped(gUnknown_020322A0->tradeSpecies[0]))
{
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.affineMode = 3;
CalcCenterToCornerVec(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0, 3, 3);
StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0);
}
else
{
StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0);
}
StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0);
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.x = 40;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 200;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.y = 192;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = -32;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = FALSE;
gUnknown_020322A0->unk_94++;
break;
case 38:
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y -= 3;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y += 3;
if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y >= -163)
{
PlaySE(SE_TK_WARPIN);
}
if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -222)
{
gSprites[gUnknown_020322A0->unk_90].data[1] = 0;
gSprites[gUnknown_020322A0->unk_91].data[1] = 0;
gUnknown_020322A0->unk_94++;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = TRUE;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = TRUE;
CreateTask(sub_807F39C, 5);
}
break;
case 39:
gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3;
gSprites[gUnknown_020322A0->unk_91].pos2.y += 3;
if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -222)
{
BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK);
gUnknown_020322A0->unk_94++;
DestroySprite(&gSprites[gUnknown_020322A0->unk_90]);
DestroySprite(&gSprites[gUnknown_020322A0->unk_91]);
}
break;
case 40:
if (!gPaletteFade.active)
{
gUnknown_020322A0->unk_94++;
sub_807B62C(1);
gUnknown_020322A0->bg1vofs = 166;
sub_807B62C(3);
gUnknown_020322A0->bg2vofs = 412;
gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3);
gSprites[gUnknown_020322A0->unk_90].callback = sub_807AA4C;
gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, -20, 0);
StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1);
}
break;
case 41:
BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK);
gUnknown_020322A0->unk_94++;
break;
case 42:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_BG1_ON |
DISPCNT_OBJ_ON);
if (!gPaletteFade.active)
{
gUnknown_020322A0->unk_94++;
}
break;
case 43:
gSprites[gUnknown_020322A0->unk_90].pos2.y += 4;
gSprites[gUnknown_020322A0->unk_91].pos2.y += 4;
if (gSprites[gUnknown_020322A0->unk_90].pos2.y + gSprites[gUnknown_020322A0->unk_90].pos1.y == 64)
{
gUnknown_020322A0->unk_94 = 144;
gUnknown_020322A0->unk_64 = 0;
}
break;
case 144:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_BG1_ON |
DISPCNT_BG2_ON |
DISPCNT_OBJ_ON);
gUnknown_020322A0->bg1vofs += 3;
gUnknown_020322A0->bg2vofs += 3;
if (++gUnknown_020322A0->unk_64 == 10)
{
u8 taskId = CreateTask(c3_08054588, 5);
gTasks[taskId].data[2] = 1;
}
if (gUnknown_020322A0->bg1vofs > 316)
{
gUnknown_020322A0->bg1vofs = 316;
gUnknown_020322A0->unk_94++;
}
break;
case 145:
DestroySprite(&gSprites[gUnknown_020322A0->unk_90]);
DestroySprite(&gSprites[gUnknown_020322A0->unk_91]);
gUnknown_020322A0->unk_94++;
gUnknown_020322A0->unk_64 = 0;
break;
case 146:
if (!FuncIsActiveTask(c3_08054588))
{
gUnknown_020322A0->unk_94 = 46;
gUnknown_020322A0->unk_64 = 0;
}
break;
case 46:
if (++gUnknown_020322A0->unk_64 == 10)
{
gUnknown_020322A0->unk_94++;
}
break;
case 47:
if (++gUnknown_020322A0->bg1vofs > 348)
{
gUnknown_020322A0->bg1vofs = 348;
gUnknown_020322A0->unk_94++;
}
break;
case 48:
gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0);
gUnknown_020322A0->unk_94 = 50;
break;
case 50:
if (gSprites[gUnknown_020322A0->unk_91].animEnded)
{
DestroySprite(&gSprites[gUnknown_020322A0->unk_91]);
sub_807B62C(6);
gUnknown_020322A0->unk_94++;
PlaySE(SE_W028);
}
break;
case 51:
if (gUnknown_020322A0->unk_EA < 0x400)
{
gUnknown_020322A0->unk_EA += 0x34;
}
else
{
gUnknown_020322A0->unk_EA = 0x400;
gUnknown_020322A0->unk_94++;
}
gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA;
break;
case 52:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gUnknown_020322A0->unk_94 = 60;
break;
case 60:
if (!gPaletteFade.active)
{
sub_807B62C(5);
sub_807B62C(7);
gPaletteFade.bufferTransferDisabled = TRUE;
gUnknown_020322A0->unk_94++;
}
break;
case 61:
gPaletteFade.bufferTransferDisabled = FALSE;
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
gUnknown_020322A0->unk_94++;
break;
case 62:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_BG2_ON |
DISPCNT_OBJ_ON);
if (!gPaletteFade.active)
{
gUnknown_020322A0->unk_94++;
}
break;
case 63:
gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0);
gSprites[gUnknown_020322A0->unk_D3].data[3] = 74;
gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E6AC;
StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_D3], 1);
StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->unk_D3], 2);
BlendPalettes(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA);
gUnknown_020322A0->unk_94++;
gUnknown_020322A0->unk_64 = 0;
break;
case 64:
BeginNormalPaletteFade(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA);
gUnknown_020322A0->unk_94++;
break;
case 65:
if (gSprites[gUnknown_020322A0->unk_D3].callback == SpriteCallbackDummy)
{
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[gUnknown_020322A0->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], gUnknown_020322A0->tradeSpecies[1], gUnknown_020322A0->unk_68[1]);
gUnknown_020322A0->unk_94++;
}
break;
case 66:
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 120;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[1]].y_offset + 60;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.x = 0;
gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y = 0;
StartSpriteAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0);
CreatePokeballSpriteToReleaseMon(gUnknown_020322A0->pokePicSpriteIdxs[1], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, gUnknown_020322A0->tradeSpecies[1]);
FreeSpriteOamMatrix(&gSprites[gUnknown_020322A0->unk_D3]);
DestroySprite(&gSprites[gUnknown_020322A0->unk_D3]);
gUnknown_020322A0->unk_94++;
break;
case 67:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_BG0_ON |
DISPCNT_BG2_ON |
DISPCNT_OBJ_ON);
StringExpandPlaceholders(gStringVar4, gText_XSentOverY);
sub_807F1A8(0, gStringVar4, 0);
gUnknown_020322A0->unk_94 = 167;
gUnknown_020322A0->unk_64 = 0;
break;
// 167 and 267 are extra cases added in for animations
case 167:
if (++gUnknown_020322A0->unk_64 > 60)
{
gUnknown_020322A0->unk_94 = 267;
gUnknown_020322A0->unk_64 = 0;
}
break;
case 267:
if (IsCryFinished())
{
gUnknown_020322A0->unk_94 = 68;
}
break;
case 68:
if (++gUnknown_020322A0->unk_64 == 10)
{
PlayFanfare(MUS_FANFA5);
}
if (gUnknown_020322A0->unk_64 == 250)
{
gUnknown_020322A0->unk_94++;
StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX);
sub_807F1A8(0, gStringVar4, 0);
gUnknown_020322A0->unk_64 = 0;
}
break;
case 69:
if (++gUnknown_020322A0->unk_64 == 60)
{
gUnknown_020322A0->unk_94++;
}
break;
case 70:
sub_807F14C();
gUnknown_020322A0->unk_94++;
break;
case 71:
if (gUnknown_020322A0->isLinkTrade)
{
return TRUE;
}
else if (gMain.newKeys & A_BUTTON)
{
gUnknown_020322A0->unk_94++;
}
break;
case 72: // Only if in-game trade
sub_807B4D0(gSpecialVar_0x8005, 0);
gCB2_AfterEvolution = sub_807B60C;
evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gUnknown_02032298[0]], TRUE, ITEM_NONE);
if (evoTarget != SPECIES_NONE)
{
TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]);
}
gUnknown_020322A0->unk_94++;
break;
case 73:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gUnknown_020322A0->unk_94++;
break;
case 74:
if (!gPaletteFade.active)
{
PlayNewMapMusic(gUnknown_020322A0->unk_F4);
if (gUnknown_020322A0)
{
FreeAllWindowBuffers();
Free(GetBgTilemapBuffer(3));
Free(GetBgTilemapBuffer(1));
Free(GetBgTilemapBuffer(0));
FreeMonSpritesGfx();
FREE_AND_SET_NULL(gUnknown_020322A0);
}
SetMainCallback2(CB2_ReturnToField);
sub_807E784();
}
break;
}
return FALSE;
}