pokeemerald/src/use_pokeblock.c

1665 lines
43 KiB
C
Raw Normal View History

2017-12-04 23:09:44 +01:00
#include "global.h"
#include "main.h"
#include "pokeblock.h"
#include "malloc.h"
#include "decompress.h"
#include "graphics.h"
2017-12-09 21:23:40 +01:00
#include "palette.h"
#include "pokenav.h"
#include "menu_specialized.h"
2018-01-29 17:47:12 +01:00
#include "scanline_effect.h"
2017-12-09 21:23:40 +01:00
#include "text.h"
#include "bg.h"
#include "window.h"
#include "text_window.h"
2019-02-23 18:08:07 +01:00
#include "constants/rgb.h"
#include "sound.h"
#include "constants/songs.h"
#include "sprite.h"
#include "string_util.h"
#include "strings.h"
#include "menu.h"
#include "gpu_regs.h"
#include "graphics.h"
2019-04-04 23:53:06 +02:00
#include "pokemon_summary_screen.h"
#include "item_menu.h"
2017-12-04 23:09:44 +01:00
struct UsePokeblockSubStruct
{
/*0x00*/ void (*field_0)(void);
/*0x04*/ void (*callback)(void);
/*0x08*/ struct Pokeblock *pokeblock;
/*0x0C*/ struct Pokemon *mon;
/*0x10*/ u8 stringBuffer[0x40];
/*0x50*/ u8 field_50;
/*0x51*/ u8 field_51;
/*0x52*/ u8 field_52;
/*0x53*/ u8 field_53;
/*0x54*/ u8 field_54;
/*0x55*/ u8 field_55;
/*0x56*/ u8 field_56;
/*0x57*/ u8 field_57[5];
/*0x5C*/ u8 field_5c[5];
/*0x61*/ u8 field_61[5];
/*0x66*/ s16 field_66[5];
2019-03-23 16:41:09 +01:00
/*0x70*/ u8 field_70;
/*0x71*/ u8 field_71;
2019-03-23 16:41:09 +01:00
/*0x74*/ u8 (*unk74)(void);
/*0x78*/ u8 unk78;
/*0x79*/ u8 filler79[0x1];
/*0x7A*/ u8 field_7A[0x22];
2017-12-04 23:09:44 +01:00
};
2019-03-23 17:16:53 +01:00
struct Unk7FB8
{
u8 unk0;
u8 unk1;
u16 unk2;
};
2017-12-09 21:23:40 +01:00
struct UsePokeblockStruct
2017-12-04 23:09:44 +01:00
{
2019-03-31 14:32:26 +02:00
/*0x0000*/ u8 filler0[4];
/*0x0000*/ u16 field_4[6][0x40];
/*0x0304*/ u8 field_304[3][0x2000];
2019-03-31 14:32:26 +02:00
/*0x6304*/ u8 filler_6304[0x1000];
/*0x7304*/ u8 tilemapBuffer[BG_SCREEN_SIZE + 2];
2019-03-23 16:41:09 +01:00
/*0x7B06*/ u8 field_7B06[7];
/*0x7B0E*/ s16 field_7B0E;
2019-03-23 16:41:09 +01:00
/*0x7B10*/ u8 field_7B10;
/*0x7B12*/ u16 field_7B12;
/*0x7B12*/ u16 field_7B14;
/*0x7B12*/ u8 *field_7B18;
2019-03-23 16:41:09 +01:00
/*0x7B1C*/ struct Sprite *field_7B1C[10];
/*0x7B44*/ struct Sprite *field_7B44[2];
/*0x7B4C*/ u8 field_7B4C;
2019-03-31 14:32:26 +02:00
/*0x7B4D*/ u8 field_7B4D[3][24];
/*0x7B95*/ u8 field_7B95[3][64];
/*0x7C58*/ struct UnknownStruct_81D1ED4 field_7C58;
2019-03-23 16:10:51 +01:00
/*0x7FB0*/ u8 unk7FB0[3];
2019-03-23 17:22:41 +01:00
/*0x7FB3*/ s8 field_7FB3;
/*0x7FB4*/ s8 field_7FB4;
/*0x7FB5*/ s8 field_7FB5;
/*0x7FB6*/ s8 field_7FB6;
2019-03-23 17:16:53 +01:00
/*0x7FB8*/ struct Unk7FB8 field_7FB8[6];
/*0x7FD0*/ struct UsePokeblockSubStruct info;
2017-12-04 23:09:44 +01:00
};
2019-07-31 02:21:17 +02:00
#define TAG_TILE_CONDITION_UP_DOWN 0
#define TAG_PAL_CONDITION_UP_DOWN 0
#define TAG_PAL_POKEBLOCK_CONDITION 1
extern void sub_81D21DC(u8);
2017-12-04 23:09:44 +01:00
// this file's functions
2017-12-09 21:23:40 +01:00
void sub_816636C(void (*func)(void));
2017-12-04 23:09:44 +01:00
void sub_8166380(void);
void sub_816631C(void);
2017-12-09 21:23:40 +01:00
void sub_81662C0(void);
void sub_8166564(void);
void sub_8166304(void);
void sub_81668F8(void);
void sub_8167420(void);
void sub_8167760(void);
u8 sub_81672E4(u8 arg0);
static bool8 sub_8168328(void);
2017-12-09 21:23:40 +01:00
bool8 sub_8167930(void);
void sub_8167608(u8 arg0);
void sub_8167BA0(u16 arg0, u8 copyToVramMode);
2019-02-23 18:08:07 +01:00
void sub_8166634(void);
static void sub_8167CA0(bool8);
2019-02-23 18:08:07 +01:00
void sub_8166BEC(void);
void sub_8166D44(void);
s8 sub_8166DE4(void);
bool8 IsSheenMaxed(void);
2019-02-23 18:08:07 +01:00
void sub_8166F50(void);
void sub_816681C(void);
void sub_8166F94(void);
u8 sub_81672A4(u8 a0);
void sub_8166A34(void);
void sub_8167104(void);
void sub_8167338(void);
void sub_81681F4(u8);
void sub_8166E24(void);
bool8 sub_8166EDC(void);
2019-03-31 14:32:26 +02:00
void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2);
2019-02-23 18:08:07 +01:00
void Pokeblock_MenuWindowTextPrint(const u8 *message);
void sub_8167184(struct Pokeblock *, struct Pokemon *);
void sub_81673DC(struct Sprite *sprite);
void sub_81674BC(void);
void sub_816753C(s16, u8);
static u8 sub_8167EA4(void);
static u8 sub_8167FA4(void);
static u8 sub_8168048(void);
void sub_8168180(struct Sprite *sprite);
void sub_81681B4(struct Sprite *sprite);
void sub_8168168(struct Sprite *sprite);
2019-07-31 02:21:17 +02:00
void sub_8168374(struct Sprite *sprite);
2017-12-09 21:23:40 +01:00
2019-02-23 18:08:07 +01:00
extern const u16 gUnknown_086231E8[];
extern const u16 gUnknown_08623208[];
2019-07-31 02:21:17 +02:00
extern const struct SpritePalette gSpritePalette_085DFDB8;
extern const struct SpriteTemplate gSpriteTemplate_085DFDA0;
// ram variables
EWRAM_DATA struct UsePokeblockSubStruct *gUnknown_0203BC90 = NULL;
EWRAM_DATA void (*gUnknown_0203BC94)(void) = NULL;
EWRAM_DATA struct Pokeblock *gUnknown_0203BC98 = NULL;
EWRAM_DATA u8 gPokeblockMonId = 0;
EWRAM_DATA s16 gPokeblockGain = 0;
EWRAM_DATA u8 *gUnknown_0203BCA0 = NULL;
EWRAM_DATA u8 *gUnknown_0203BCA4 = NULL;
EWRAM_DATA u8 *gUnknown_0203BCA8 = NULL;
EWRAM_DATA struct UsePokeblockStruct *gUnknown_0203BCAC = NULL;
2017-12-10 19:02:51 +01:00
// const rom data
// todo: make it static once the file is decompiled
2019-07-31 02:21:17 +02:00
const u32 gUnknown_085DFA60[] = INCBIN_U32("graphics/interface/85DFA60.bin");
const u32 gUnknown_085DFA80[] = INCBIN_U32("graphics/interface/85DFA80.4bpp");
const u32 gUnknown_085DFB60[] = INCBIN_U32("graphics/interface/85DFB60.bin");
const u32 gUnknown_085DFC0C[] = INCBIN_U32("graphics/interface/85DFC0C.bin");
const u32 gUnknown_085DFCB0[] =
{
2019-07-31 02:25:19 +02:00
MON_DATA_COOL,
MON_DATA_TOUGH,
MON_DATA_SMART,
MON_DATA_CUTE,
MON_DATA_BEAUTY
2019-07-31 02:21:17 +02:00
};
const u8 gUnknown_085DFCC4[] =
{
2019-07-31 02:25:19 +02:00
0, // Spicy/Cool
4, // Dry/Beauty
3, // Sweet/Cute
2, // Bitter/Smart
1 // Sour/Tough
2019-07-31 02:21:17 +02:00
};
const u8 gUnknown_085DFCC9[] =
{
2019-07-31 02:25:19 +02:00
0,
8,
1
2019-07-31 02:21:17 +02:00
};
const struct BgTemplate gUnknown_085DFCCC[4] =
{
2019-07-31 02:25:19 +02:00
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 0x1F,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 0x1E,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 3,
.mapBaseIndex = 0x1D,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0x100
},
{
.bg = 2,
.charBaseIndex = 0,
.mapBaseIndex = 0x17,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
}
2019-07-31 02:21:17 +02:00
};
const struct WindowTemplate gUnknown_085DFCDC[] =
{
2019-07-31 02:25:19 +02:00
{
.bg = 0,
.tilemapLeft = 0xD,
.tilemapTop = 1,
.width = 0xD,
.height = 4,
.paletteNum = 0xF,
.baseBlock = 1
},
{
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 0xE,
.width = 0xB,
.height = 2,
.paletteNum = 0xF,
.baseBlock = 0x35
},
{
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 0x11,
.width = 0x1C,
.height = 2,
.paletteNum = 0xF,
.baseBlock = 0x4B
},
DUMMY_WIN_TEMPLATE
2019-07-31 02:21:17 +02:00
};
const struct WindowTemplate sUsePokeblockYesNoWinTemplate =
{
2019-07-31 02:25:19 +02:00
.bg = 0,
.tilemapLeft = 0x18,
.tilemapTop = 0xB,
.width = 5,
.height = 4,
.paletteNum = 0xF,
.baseBlock = 0x83
2019-07-31 02:21:17 +02:00
};
const u8 *const sContestStatNames[] =
{
2019-07-31 02:25:19 +02:00
gText_Coolness,
gText_Toughness,
gText_Smartness,
gText_Cuteness,
gText_Beauty3
2019-07-31 02:21:17 +02:00
};
const struct SpriteSheet gSpriteSheet_ConditionUpDown =
{
gUsePokeblockUpDown_Gfx, 0x200, TAG_TILE_CONDITION_UP_DOWN
};
const struct SpritePalette gSpritePalette_ConditionUpDown =
{
2019-07-31 02:25:19 +02:00
gUsePokeblockUpDown_Pal, TAG_PAL_CONDITION_UP_DOWN
2019-07-31 02:21:17 +02:00
};
const s16 gUnknown_085DFD28[][2] =
{
2019-07-31 02:25:19 +02:00
{0x9C, 0x24},
{0x75, 0x3B},
{0x75, 0x76},
{0xC5, 0x76},
{0xC5, 0x3B}
2019-07-31 02:21:17 +02:00
};
const struct OamData gOamData_085DFD3C =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.bpp = 0,
.shape = SPRITE_SHAPE(32x16),
.x = 0,
.size = SPRITE_SIZE(32x16),
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
};
const union AnimCmd gSpriteAnim_085DFD44[] =
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END
};
const union AnimCmd gSpriteAnim_085DFD4C[] =
{
ANIMCMD_FRAME(8, 5),
ANIMCMD_END
};
const union AnimCmd *const gSpriteAnimTable_085DFD54[] =
{
gSpriteAnim_085DFD44,
gSpriteAnim_085DFD4C
};
const struct SpriteTemplate gSpriteTemplate_085DFD5C =
{
2019-07-31 02:25:19 +02:00
.tileTag = 0,
2019-07-31 02:21:17 +02:00
.paletteTag = 0,
.oam = &gOamData_085DFD3C,
.anims = gSpriteAnimTable_085DFD54,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
};
const struct OamData gOamData_085DFD74 =
{
.y = 0,
.affineMode = 0,
.objMode = 0,
.bpp = 0,
.shape = SPRITE_SHAPE(64x32),
.x = 0,
.size = SPRITE_SIZE(64x32),
.tileNum = 0,
.priority = 1,
.paletteNum = 0,
};
const union AnimCmd gSpriteAnim_085DFD7C[] =
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END
};
const union AnimCmd gSpriteAnim_085DFD84[] =
{
ANIMCMD_FRAME(32, 5),
ANIMCMD_END
};
const union AnimCmd gSpriteAnim_085DFD8C[] =
{
ANIMCMD_FRAME(64, 5),
ANIMCMD_END
};
const union AnimCmd *const gSpriteAnimTable_085DFD94[] =
{
gSpriteAnim_085DFD7C,
gSpriteAnim_085DFD84,
gSpriteAnim_085DFD8C
};
const struct SpriteTemplate gSpriteTemplate_085DFDA0 =
{
2019-07-31 02:25:19 +02:00
.tileTag = 1,
2019-07-31 02:21:17 +02:00
.paletteTag = 1,
.oam = &gOamData_085DFD74,
.anims = gSpriteAnimTable_085DFD94,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = sub_8168374,
};
const struct SpritePalette gSpritePalette_085DFDB8 =
{
2019-07-31 02:25:19 +02:00
gUsePokeblockCondition_Pal, TAG_PAL_POKEBLOCK_CONDITION
2019-07-31 02:21:17 +02:00
};
2017-12-10 19:02:51 +01:00
// code
2017-12-09 21:23:40 +01:00
void ChooseMonToGivePokeblock(struct Pokeblock *pokeblock, void (*callback)(void))
2017-12-04 23:09:44 +01:00
{
2019-03-23 16:41:09 +01:00
gUnknown_0203BCAC = AllocZeroed(sizeof(*gUnknown_0203BCAC));
2017-12-04 23:09:44 +01:00
gUnknown_0203BC90 = &gUnknown_0203BCAC->info;
gUnknown_0203BC90->pokeblock = pokeblock;
gUnknown_0203BC90->callback = callback;
sub_816636C(sub_8166380);
SetMainCallback2(sub_816631C);
}
2017-12-09 21:23:40 +01:00
void CB2_ReturnAndChooseMonToGivePokeblock(void)
{
2019-03-23 16:41:09 +01:00
gUnknown_0203BCAC = AllocZeroed(sizeof(*gUnknown_0203BCAC));
2017-12-09 21:23:40 +01:00
gUnknown_0203BC90 = &gUnknown_0203BCAC->info;
gUnknown_0203BC90->pokeblock = gUnknown_0203BC98;
gUnknown_0203BC90->callback = gUnknown_0203BC94;
gPokeblockMonId = sub_81672E4(gPokeblockMonId);
gUnknown_0203BC90->field_56 = gPokeblockMonId < 4 ? 0 : 1;
sub_816636C(sub_8166380);
SetMainCallback2(sub_81662C0);
}
void sub_81662C0(void)
{
gUnknown_0203BC90->field_0();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
if (gUnknown_0203BC90->field_0 == sub_8166564)
{
gUnknown_0203BC90->field_50 = 0;
SetMainCallback2(sub_8166304);
}
}
void sub_8166304(void)
{
sub_81668F8();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
void sub_816631C(void)
{
gUnknown_0203BC90->field_0();
AnimateSprites();
BuildOamBuffer();
RunTextPrinters();
UpdatePaletteFade();
}
void sub_8166340(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
2019-03-06 02:32:14 +01:00
sub_81D2108(&gUnknown_0203BCAC->field_7C58);
2018-01-29 17:47:12 +01:00
ScanlineEffect_InitHBlankDmaTransfer();
2017-12-09 21:23:40 +01:00
}
void sub_816636C(void (*func)(void))
{
gUnknown_0203BC90->field_0 = func;
gUnknown_0203BC90->field_50 = 0;
}
void sub_8166380(void)
{
switch (gUnknown_0203BC90->field_50)
{
2019-03-23 16:41:09 +01:00
case 0:
gUnknown_0203BCAC->field_7B10 = 0xFF;
sub_81D1ED4(&gUnknown_0203BCAC->field_7C58);
gUnknown_0203BC90->field_50++;
break;
case 1:
ResetSpriteData();
FreeAllSpritePalettes();
gUnknown_0203BC90->field_50++;
break;
case 2:
SetVBlankCallback(NULL);
CpuFill32(0, (void*)(VRAM), VRAM_SIZE);
gUnknown_0203BC90->field_50++;
break;
case 3:
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_085DFCCC, ARRAY_COUNT(gUnknown_085DFCCC));
InitWindows(gUnknown_085DFCDC);
DeactivateAllTextPrinters();
LoadUserWindowBorderGfx(0, 0x97, 0xE0);
gUnknown_0203BC90->field_50++;
break;
case 4:
gUnknown_0203BC90->field_50++;
break;
case 5:
if (!sub_8168328())
2017-12-09 21:23:40 +01:00
gUnknown_0203BC90->field_50++;
2019-03-23 16:41:09 +01:00
break;
case 6:
gKeyRepeatStartDelay = 20;
sub_8167420();
gUnknown_0203BC90->field_50++;
break;
case 7:
if (!sub_8167930())
2017-12-09 21:23:40 +01:00
gUnknown_0203BC90->field_50++;
2019-03-23 16:41:09 +01:00
break;
case 8:
sub_8167608(0);
sub_8167760();
gUnknown_0203BC90->field_50++;
break;
case 9:
if (!sub_81D312C(&gUnknown_0203BCAC->field_7B0E))
2017-12-09 21:23:40 +01:00
gUnknown_0203BC90->field_50++;
2019-03-23 16:41:09 +01:00
break;
case 10:
gUnknown_0203BC90->field_50++;
break;
case 11:
sub_81D2754(gUnknown_0203BCAC->field_7C58.unk0[0], gUnknown_0203BCAC->field_7C58.unk14[0]);
sub_81D20AC(&gUnknown_0203BCAC->field_7C58);
gUnknown_0203BC90->field_50++;
break;
case 12:
if (!sub_81D20BC(&gUnknown_0203BCAC->field_7C58))
{
sub_81D1F84(&gUnknown_0203BCAC->field_7C58, gUnknown_0203BCAC->field_7C58.unk14[0], gUnknown_0203BCAC->field_7C58.unk14[0]);
2017-12-09 21:23:40 +01:00
gUnknown_0203BC90->field_50++;
2019-03-23 16:41:09 +01:00
}
break;
case 13:
sub_81D2230(&gUnknown_0203BCAC->field_7C58);
gUnknown_0203BC90->field_50++;
break;
case 14:
PutWindowTilemap(0);
PutWindowTilemap(1);
sub_8167BA0(0, 1);
gUnknown_0203BC90->field_50++;
break;
case 15:
sub_816636C(sub_8166564);
break;
2017-12-09 21:23:40 +01:00
}
}
2019-02-23 18:08:07 +01:00
void sub_8166564(void)
{
switch (gUnknown_0203BC90->field_50)
{
2019-03-23 16:41:09 +01:00
case 0:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
SetVBlankCallback(sub_8166340);
ShowBg(0);
ShowBg(1);
ShowBg(3);
ShowBg(2);
gUnknown_0203BC90->field_50++;
break;
case 1:
if (!gPaletteFade.active)
{
sub_81D3464(gUnknown_0203BCAC->field_7B1C);
if (gUnknown_0203BCAC->info.field_71 != gUnknown_0203BCAC->info.field_70 - 1)
2019-03-23 16:10:51 +01:00
{
2019-03-23 17:22:41 +01:00
u8 var0 = gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3];
2019-03-23 16:41:09 +01:00
sub_81D3480(gUnknown_0203BCAC->field_7B1C, gUnknown_0203BCAC->field_7B10, var0);
2019-02-23 18:08:07 +01:00
}
2019-03-23 16:41:09 +01:00
sub_816636C(sub_8166634);
}
break;
2019-02-23 18:08:07 +01:00
}
}
void sub_8166634(void)
{
2019-03-23 16:41:09 +01:00
u8 var;
2019-02-23 18:08:07 +01:00
switch (gUnknown_0203BC90->field_50)
{
2019-03-23 16:41:09 +01:00
case 0:
if (gMain.heldKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
sub_8167CA0(TRUE);
sub_81D3520(gUnknown_0203BCAC->field_7B1C);
gUnknown_0203BC90->field_50 = 1;
}
else if (gMain.heldKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
sub_8167CA0(FALSE);
sub_81D3520(gUnknown_0203BCAC->field_7B1C);
gUnknown_0203BC90->field_50 = 1;
}
else if (gMain.newKeys & B_BUTTON)
{
PlaySE(SE_SELECT);
gUnknown_0203BC90->field_50 = 3;
}
else if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
if (gUnknown_0203BCAC->info.field_71 == gUnknown_0203BCAC->info.field_70 - 1)
2019-02-23 18:08:07 +01:00
gUnknown_0203BC90->field_50 = 3;
2019-03-23 16:41:09 +01:00
else
gUnknown_0203BC90->field_50 = 5;
}
break;
case 1:
var = gUnknown_0203BCAC->info.unk74();
if (!var)
2019-03-23 16:41:09 +01:00
gUnknown_0203BC90->field_50 = var;
break;
2019-03-23 16:41:09 +01:00
case 2:
break;
case 3:
sub_816636C(sub_8166BEC);
break;
case 4:
break;
case 5:
sub_8166D44();
gUnknown_0203BC90->field_50++;
break;
case 6:
switch (sub_8166DE4())
{
2019-02-23 18:08:07 +01:00
case 1:
2019-03-23 16:41:09 +01:00
case -1:
gUnknown_0203BC90->field_50 = 0;
2019-02-23 18:08:07 +01:00
break;
2019-03-23 16:41:09 +01:00
case 0:
if (IsSheenMaxed())
2019-02-23 18:08:07 +01:00
{
2019-03-23 16:41:09 +01:00
sub_8166F50();
gUnknown_0203BC90->field_50 = 7;
2019-02-23 18:08:07 +01:00
}
2019-03-23 16:41:09 +01:00
else
2019-02-23 18:08:07 +01:00
{
2019-03-23 16:41:09 +01:00
sub_816636C(sub_816681C);
2019-02-23 18:08:07 +01:00
}
break;
2019-03-23 16:41:09 +01:00
}
break;
case 7:
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
sub_8166F94();
gUnknown_0203BC90->field_50 = 0;
}
break;
2019-02-23 18:08:07 +01:00
}
}
void sub_816681C(void)
{
switch (gUnknown_0203BC90->field_50)
{
2019-03-23 16:41:09 +01:00
case 0:
gPokeblockMonId = sub_81672A4(gUnknown_0203BCAC->info.field_71);
gUnknown_0203BC94 = gUnknown_0203BC90->callback;
gUnknown_0203BC98 = gUnknown_0203BC90->pokeblock;
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gUnknown_0203BC90->field_50++;
break;
case 1:
if (!gPaletteFade.active)
{
SetVBlankCallback(NULL);
FREE_AND_SET_NULL(gUnknown_0203BCA0);
FREE_AND_SET_NULL(gUnknown_0203BCA4);
FREE_AND_SET_NULL(gUnknown_0203BCA8);
FREE_AND_SET_NULL(gUnknown_0203BCAC);
2019-03-23 16:41:09 +01:00
FreeAllWindowBuffers();
gMain.savedCallback = CB2_ReturnAndChooseMonToGivePokeblock;
CB2_PreparePokeblockFeedScene();
}
break;
2019-02-23 18:08:07 +01:00
}
}
void sub_81668F8(void)
{
2019-03-23 16:41:09 +01:00
u16 var;
2019-02-23 18:08:07 +01:00
switch (gUnknown_0203BC90->field_50)
{
2019-03-23 16:41:09 +01:00
case 0:
if (gUnknown_0203BCAC->info.field_71 != gPokeblockMonId)
{
sub_8167CA0(gUnknown_0203BC90->field_56);
2019-02-23 18:08:07 +01:00
gUnknown_0203BC90->field_50++;
2019-03-23 16:41:09 +01:00
}
else
{
gUnknown_0203BC90->field_50 = 3;
}
break;
case 1:
var = gUnknown_0203BCAC->info.unk74();
if (!var)
gUnknown_0203BC90->field_50 = var;
break;
case 2:
break;
case 3:
BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK);
gUnknown_0203BC90->field_50++;
break;
case 4:
ShowBg(0);
ShowBg(1);
ShowBg(3);
ShowBg(2);
gUnknown_0203BC90->field_50++;
break;
case 5:
SetVBlankCallback(sub_8166340);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
gUnknown_0203BC90->field_50++;
break;
case 6:
if (!gPaletteFade.active)
{
sub_81D3464(gUnknown_0203BCAC->field_7B1C);
sub_816636C(sub_8166A34);
SetMainCallback2(sub_816631C);
}
break;
2019-02-23 18:08:07 +01:00
}
}
void sub_8166A34(void)
{
u8 var;
2019-02-23 18:08:07 +01:00
switch (gUnknown_0203BC90->field_50)
{
case 0:
gUnknown_0203BC90->mon = gPlayerParty;
gUnknown_0203BC90->mon += gUnknown_0203BCAC->field_7FB8[gUnknown_0203BCAC->info.field_71].unk1;
sub_81D3520(gUnknown_0203BCAC->field_7B1C);
gUnknown_0203BC90->field_50++;
break;
case 1:
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
2019-02-23 18:08:07 +01:00
gUnknown_0203BC90->field_50++;
break;
case 2:
sub_8167104();
sub_81D2754(gUnknown_0203BC90->field_5c, gUnknown_0203BCAC->field_7C58.unk14[3]);
sub_81D1F84(&gUnknown_0203BCAC->field_7C58, gUnknown_0203BCAC->field_7C58.unk14[gUnknown_0203BCAC->field_7FB3], gUnknown_0203BCAC->field_7C58.unk14[3]);
sub_8167338();
gUnknown_0203BC90->field_50++;
break;
case 3:
var = sub_81D2074(&gUnknown_0203BCAC->field_7C58);
if (!var)
{
2019-03-24 21:02:10 +01:00
sub_81681F4(sub_81672A4(gUnknown_0203BCAC->info.field_71));
if (gUnknown_0203BCAC->info.field_71 != gUnknown_0203BCAC->info.field_70 - 1)
2019-02-23 18:08:07 +01:00
{
2019-03-24 21:02:10 +01:00
u8 var0 = gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3];
sub_81D3480(gUnknown_0203BCAC->field_7B1C, gUnknown_0203BCAC->field_7B10, var0);
2019-02-23 18:08:07 +01:00
}
2019-03-24 21:02:10 +01:00
gUnknown_0203BC90->field_52 = 0;
gUnknown_0203BC90->field_50++;
}
break;
case 4:
if (++gUnknown_0203BC90->field_52 > 16)
{
sub_8166E24();
gUnknown_0203BC90->field_50++;
}
break;
case 5:
if (gMain.newKeys & (A_BUTTON | B_BUTTON) && !sub_8166EDC())
{
TryClearPokeblock((u8)gSpecialVar_ItemId);
sub_816636C(sub_8166BEC);
}
break;
2019-02-23 18:08:07 +01:00
}
}
void sub_8166BEC(void)
{
u8 i, var;
2019-02-23 18:08:07 +01:00
switch (gUnknown_0203BC90->field_50)
{
2019-03-23 16:41:09 +01:00
case 0:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gUnknown_0203BC90->field_50++;
break;
case 1:
if (!gPaletteFade.active)
gUnknown_0203BC90->field_50 = 2;
break;
case 2:
gScanlineEffect.state = 3;
ScanlineEffect_InitHBlankDmaTransfer();
gUnknown_0203BC90->field_50++;
break;
case 3:
SetMainCallback2(gUnknown_0203BC90->callback);
sub_81D354C(gUnknown_0203BCAC->field_7B1C);
for (i = 0; i < 7; i++)
DestroySprite(&gSprites[gUnknown_0203BCAC->field_7B06[i]]);
2019-03-23 16:41:09 +01:00
FreeSpriteTilesByTag(0);
FreeSpriteTilesByTag(1);
FreeSpritePaletteByTag(0);
FreeSpritePaletteByTag(1);
2019-03-23 16:41:09 +01:00
for (i = 0; i < 2; i++)
DestroySprite(gUnknown_0203BCAC->field_7B44[i]);
2019-03-23 16:41:09 +01:00
if (gUnknown_0203BCAC->field_7B10 != 0xFF)
DestroySprite(&gSprites[gUnknown_0203BCAC->field_7B10]);
2019-03-23 16:41:09 +01:00
SetVBlankCallback(NULL);
FREE_AND_SET_NULL(gUnknown_0203BCA0);
FREE_AND_SET_NULL(gUnknown_0203BCA4);
FREE_AND_SET_NULL(gUnknown_0203BCA8);
FREE_AND_SET_NULL(gUnknown_0203BCAC);
FreeAllWindowBuffers();
break;
2019-02-23 18:08:07 +01:00
}
}
void sub_8166D44(void)
{
2019-03-23 16:41:09 +01:00
u8 stringBuffer[0x40];
GetMonData(&gPlayerParty[sub_81672A4(gUnknown_0203BCAC->info.field_71)], MON_DATA_NICKNAME, stringBuffer);
2019-02-23 18:08:07 +01:00
StringGetEnd10(stringBuffer);
StringAppend(stringBuffer, gText_GetsAPokeBlockQuestion);
2019-03-23 16:41:09 +01:00
StringCopy(gStringVar4, stringBuffer);
FillWindowPixelBuffer(2, 17);
2019-04-01 00:59:52 +02:00
DrawTextBorderOuter(2, 151, 14);
2019-03-23 16:41:09 +01:00
AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL);
PutWindowTilemap(2);
CopyWindowToVram(2, 3);
2019-07-31 02:21:17 +02:00
CreateYesNoMenu(&sUsePokeblockYesNoWinTemplate, 151, 14, 0);
2019-02-23 18:08:07 +01:00
}
s8 sub_8166DE4(void)
{
s8 menuItem = Menu_ProcessInputNoWrapClearOnChoose();
switch (menuItem)
2019-02-23 18:08:07 +01:00
{
2019-03-23 16:41:09 +01:00
case 0:
break;
case MENU_B_PRESSED:
2019-03-23 16:41:09 +01:00
case 1:
PlaySE(SE_SELECT);
rbox_fill_rectangle(2);
ClearWindowTilemap(2);
break;
2019-02-23 18:08:07 +01:00
}
return menuItem;
2019-02-23 18:08:07 +01:00
}
void sub_8166E24(void)
{
2019-04-01 00:59:52 +02:00
DrawTextBorderOuter(2, 151, 14);
2019-03-23 16:41:09 +01:00
FillWindowPixelBuffer(2, 17);
2019-02-23 18:08:07 +01:00
for (gUnknown_0203BC90->field_53 = 0; gUnknown_0203BC90->field_53 < 5; gUnknown_0203BC90->field_53++)
{
if (gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53] != 0)
break;
}
2019-03-23 16:41:09 +01:00
if (gUnknown_0203BC90->field_53 < 5)
Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53]);
else
2019-03-23 17:16:53 +01:00
Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, 0);
2019-03-23 16:41:09 +01:00
Pokeblock_MenuWindowTextPrint(gStringVar4);
PutWindowTilemap(2);
CopyWindowToVram(2, 3);
2019-02-23 18:08:07 +01:00
}
bool8 sub_8166EDC(void)
{
2019-03-23 16:41:09 +01:00
FillWindowPixelBuffer(2, 17);
2019-02-23 18:08:07 +01:00
while (1)
{
gUnknown_0203BC90->field_53++;
if (gUnknown_0203BC90->field_53 < 5)
{
if (gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53] != 0)
break;
}
else
{
gUnknown_0203BC90->field_53 = 5;
return FALSE;
}
}
2019-02-23 18:08:07 +01:00
Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53]);
Pokeblock_MenuWindowTextPrint(gStringVar4);
2019-03-23 16:41:09 +01:00
CopyWindowToVram(2, 2);
2019-03-23 16:41:09 +01:00
return TRUE;
2019-02-23 18:08:07 +01:00
}
void sub_8166F50(void)
{
2019-03-23 16:41:09 +01:00
FillWindowPixelBuffer(2, 17);
2019-04-01 00:59:52 +02:00
DrawTextBorderOuter(2, 151, 14);
2019-03-23 16:41:09 +01:00
AddTextPrinterParameterized(2, 1, gText_WontEatAnymore, 0, 1, 0, NULL);
PutWindowTilemap(2);
CopyWindowToVram(2, 3);
2019-02-23 18:08:07 +01:00
}
void sub_8166F94(void)
{
2019-03-23 16:41:09 +01:00
rbox_fill_rectangle(2);
ClearWindowTilemap(2);
CopyWindowToVram(2, 3);
2019-02-23 18:08:07 +01:00
}
void Pokeblock_MenuWindowTextPrint(const u8 *message)
{
2019-03-23 16:41:09 +01:00
AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL);
2019-02-23 18:08:07 +01:00
}
2019-03-31 14:32:26 +02:00
// This function is a joke.
2019-02-23 18:08:07 +01:00
#ifdef NONMATCHING
2019-03-31 14:32:26 +02:00
void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2)
2019-02-23 18:08:07 +01:00
{
if (a2 != 0)
{
2019-03-31 14:32:26 +02:00
StringCopy(dest, sContestStatNames[statId]);
2019-02-23 18:08:07 +01:00
StringAppend(dest, gText_WasEnhanced);
}
2019-03-23 16:41:09 +01:00
else
{
StringCopy(dest, gText_NothingChanged);
}
2019-02-23 18:08:07 +01:00
}
#else
NAKED
2019-03-31 14:32:26 +02:00
void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2)
2019-02-23 18:08:07 +01:00
{
2019-03-23 16:41:09 +01:00
asm(".syntax unified\n\
2019-02-23 18:08:07 +01:00
push {r4,lr}\n\
2019-03-23 16:41:09 +01:00
adds r4, r0, 0\n\
lsls r1, 24\n\
lsrs r3, r1, 24\n\
lsls r2, 16\n\
lsrs r0, r2, 16\n\
asrs r2, 16\n\
cmp r2, 0\n\
beq _08167010\n\
cmp r2, 0\n\
ble _08166FEC\n\
movs r0, 0\n\
2019-02-23 18:08:07 +01:00
_08166FEC:\n\
2019-03-23 16:41:09 +01:00
lsls r0, 16\n\
ldr r1, =sContestStatNames\n\
lsls r0, r3, 2\n\
adds r0, r1\n\
ldr r1, [r0]\n\
adds r0, r4, 0\n\
bl StringCopy\n\
ldr r1, =gText_WasEnhanced\n\
adds r0, r4, 0\n\
bl StringAppend\n\
b _08167018\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_08167010:\n\
2019-03-23 16:41:09 +01:00
ldr r1, =gText_NothingChanged\n\
adds r0, r4, 0\n\
bl StringCopy\n\
2019-02-23 18:08:07 +01:00
_08167018:\n\
2019-03-23 16:41:09 +01:00
pop {r4}\n\
pop {r0}\n\
bx r0\n\
.pool\n\
.syntax divided\n");
2019-02-23 18:08:07 +01:00
}
#endif
void Pokeblock_GetMonContestStats(struct Pokemon *mon, u8 *data)
2019-02-23 18:08:07 +01:00
{
2019-03-23 17:16:53 +01:00
u16 i;
2019-02-23 18:08:07 +01:00
2019-03-23 17:16:53 +01:00
for (i = 0; i < 5; i++)
data[i] = GetMonData(mon, gUnknown_085DFCB0[i]);
2019-02-23 18:08:07 +01:00
}
void sub_8167054(struct Pokeblock *pokeblock, struct Pokemon *mon)
2019-02-23 18:08:07 +01:00
{
u16 i;
s16 cstat;
u8 data;
if (GetMonData(mon, MON_DATA_SHEEN) != 255)
2019-02-23 18:08:07 +01:00
{
sub_8167184(pokeblock, mon);
2019-03-23 17:16:53 +01:00
for (i = 0; i < 5; i++)
2019-02-23 18:08:07 +01:00
{
data = GetMonData(mon, gUnknown_085DFCB0[i]);
2019-02-23 18:08:07 +01:00
cstat = data + gUnknown_0203BC90->field_66[i];
if (cstat < 0)
cstat = 0;
if (cstat > 255)
cstat = 255;
data = cstat;
SetMonData(mon, gUnknown_085DFCB0[i], &data);
2019-02-23 18:08:07 +01:00
}
2019-03-23 17:16:53 +01:00
cstat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel;
2019-02-23 18:08:07 +01:00
if (cstat > 255)
cstat = 255;
2019-03-23 17:16:53 +01:00
2019-02-23 18:08:07 +01:00
data = cstat;
SetMonData(mon, MON_DATA_SHEEN, &data);
2019-02-23 18:08:07 +01:00
}
}
void sub_8167104(void)
{
u16 i;
struct Pokemon *mon = gPlayerParty;
mon += gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->info.field_71 * 4 + 9];
Pokeblock_GetMonContestStats(mon, gUnknown_0203BC90->field_57);
sub_8167054(gUnknown_0203BC90->pokeblock, mon);
Pokeblock_GetMonContestStats(mon, gUnknown_0203BC90->field_5c);
for (i = 0; i < 5; i++)
2019-02-23 18:08:07 +01:00
gUnknown_0203BC90->field_61[i] = gUnknown_0203BC90->field_5c[i] - gUnknown_0203BC90->field_57[i];
}
void sub_8167184(struct Pokeblock *pokeblock, struct Pokemon *mon)
2019-02-23 18:08:07 +01:00
{
s8 i, direction, taste;
2019-02-23 18:08:07 +01:00
gUnknown_0203BC90->field_66[0] = pokeblock->spicy;
gUnknown_0203BC90->field_66[1] = pokeblock->sour;
gUnknown_0203BC90->field_66[2] = pokeblock->bitter;
gUnknown_0203BC90->field_66[3] = pokeblock->sweet;
gUnknown_0203BC90->field_66[4] = pokeblock->dry;
2019-02-23 18:08:07 +01:00
if (gPokeblockGain > 0)
direction = 1;
else if (gPokeblockGain < 0)
direction = -1;
else
return;
2019-03-23 17:16:53 +01:00
for (i = 0; i < 5; i++)
2019-02-23 18:08:07 +01:00
{
s16 amount = gUnknown_0203BC90->field_66[i];
s8 boost = amount / 10;
2019-02-23 18:08:07 +01:00
if (amount % 10 >= 5) // round to the nearest
boost++;
2019-03-23 17:16:53 +01:00
taste = GetMonFlavorRelation(mon, gUnknown_085DFCC4[i]);
2019-02-23 18:08:07 +01:00
if (taste == direction)
gUnknown_0203BC90->field_66[i] += boost * taste;
}
}
bool8 IsSheenMaxed(void)
2019-02-23 18:08:07 +01:00
{
if (GetBoxOrPartyMonData(gUnknown_0203BCAC->field_7FB8[gUnknown_0203BCAC->info.field_71].unk0,
gUnknown_0203BCAC->field_7FB8[gUnknown_0203BCAC->info.field_71].unk1,
MON_DATA_SHEEN,
NULL) == 255)
2019-02-23 18:08:07 +01:00
return TRUE;
else
return FALSE;
2019-02-23 18:08:07 +01:00
}
u8 sub_81672A4(u8 a0)
{
u8 i;
2019-03-23 17:16:53 +01:00
for (i = 0; i < PARTY_SIZE; i++)
2019-02-23 18:08:07 +01:00
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{
if (a0 == 0)
return i;
a0--;
}
}
2019-02-23 18:08:07 +01:00
return 0;
}
2019-03-23 17:16:53 +01:00
u8 sub_81672E4(u8 partyCount)
2019-02-23 18:08:07 +01:00
{
2019-03-23 17:16:53 +01:00
u8 i, numEggs;
for (i = 0, numEggs = 0; i < partyCount; i++)
2019-02-23 18:08:07 +01:00
{
if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
2019-03-23 17:16:53 +01:00
numEggs++;
2019-02-23 18:08:07 +01:00
}
2019-03-23 17:16:53 +01:00
return partyCount - numEggs;
2019-02-23 18:08:07 +01:00
}
u8 sub_8167324(u8 a0)
{
return sub_81672A4(a0);
}
void sub_8167338(void)
{
u16 i, spriteId;
2019-02-23 18:08:07 +01:00
LoadSpriteSheet(&gSpriteSheet_ConditionUpDown);
LoadSpritePalette(&gSpritePalette_ConditionUpDown);
gUnknown_0203BC90->field_54 = 0;
for (i = 0; i < 5; i++)
2019-02-23 18:08:07 +01:00
{
if (gUnknown_0203BC90->field_61[i] != 0)
2019-02-23 18:08:07 +01:00
{
spriteId = CreateSprite(&gSpriteTemplate_085DFD5C, gUnknown_085DFD28[i][0], gUnknown_085DFD28[i][1], 0);
if (spriteId != MAX_SPRITES)
2019-02-23 18:08:07 +01:00
{
if (gUnknown_0203BC90->field_61[i] != 0)
gSprites[spriteId].callback = sub_81673DC;
2019-03-23 17:16:53 +01:00
2019-02-23 18:08:07 +01:00
gUnknown_0203BC90->field_54++;
}
}
}
}
void sub_81673DC(struct Sprite *sprite)
{
2019-03-23 17:16:53 +01:00
if (sprite->data[0] < 6)
2019-02-23 18:08:07 +01:00
sprite->pos2.y -= 2;
2019-03-23 17:16:53 +01:00
else if (sprite->data[0] < 12)
2019-02-23 18:08:07 +01:00
sprite->pos2.y += 2;
2019-03-23 17:16:53 +01:00
if (++sprite->data[0] > 60)
2019-02-23 18:08:07 +01:00
{
DestroySprite(sprite);
2019-03-23 17:16:53 +01:00
gUnknown_0203BC90->field_54--;
2019-02-23 18:08:07 +01:00
}
}
void sub_8167420(void)
{
2019-03-23 16:41:09 +01:00
u16 i;
2019-03-23 17:16:53 +01:00
u16 numMons;
for (i = 0, numMons = 0; i < CalculatePlayerPartyCount(); i++)
2019-02-23 18:08:07 +01:00
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{
2019-03-23 17:16:53 +01:00
gUnknown_0203BCAC->field_7FB8[numMons].unk0 = 14;
gUnknown_0203BCAC->field_7FB8[numMons].unk1 = i;
gUnknown_0203BCAC->field_7FB8[numMons].unk2 = 0;
numMons++;
2019-02-23 18:08:07 +01:00
}
}
2019-03-23 17:16:53 +01:00
2019-03-23 16:41:09 +01:00
gUnknown_0203BCAC->info.field_71 = 0;
2019-03-23 17:16:53 +01:00
gUnknown_0203BCAC->info.field_70 = numMons + 1;
2019-03-23 16:41:09 +01:00
sub_81674BC();
2019-02-23 18:08:07 +01:00
}
void sub_81674BC(void)
{
s16 var, var2;
2019-03-23 16:41:09 +01:00
sub_816753C(gUnknown_0203BCAC->info.field_71, 0);
gUnknown_0203BCAC->field_7FB3 = 0;
gUnknown_0203BCAC->field_7FB4 = 1;
gUnknown_0203BCAC->field_7FB5 = 2;
2019-03-23 16:41:09 +01:00
var = gUnknown_0203BCAC->info.field_71 + 1;
2019-03-23 17:22:41 +01:00
if (var >= gUnknown_0203BCAC->info.field_70)
2019-03-23 16:41:09 +01:00
var = 0;
2019-03-23 17:22:41 +01:00
var2 = gUnknown_0203BCAC->info.field_71 - 1;
if (var2 < 0)
var2 = gUnknown_0203BCAC->info.field_70 - 1;
2019-03-23 16:41:09 +01:00
sub_816753C(var, 1);
sub_816753C(var2, 2);
2019-02-23 18:08:07 +01:00
}
2019-03-31 14:32:26 +02:00
void sub_816753C(s16 id1, u8 id2)
2019-02-23 18:08:07 +01:00
{
2019-03-31 14:32:26 +02:00
u8 boxId = gUnknown_0203BCAC->field_7FB8[id1].unk0;
u8 monId = gUnknown_0203BCAC->field_7FB8[id1].unk1;
u8 r6 = gUnknown_0203BCAC->info.field_70;
bool8 r8 = FALSE;
sub_81D2ED4(gUnknown_0203BCAC->field_7B4D[id2], gUnknown_0203BCAC->field_7B95[id2], boxId, monId, id1, r6, r8);
sub_81D2F78(&gUnknown_0203BCAC->field_7C58, gUnknown_0203BCAC->unk7FB0, boxId, monId, id1, id2, r6, r8);
sub_81D3094(gUnknown_0203BCAC->field_304[id2], gUnknown_0203BCAC->field_4[id2], boxId, monId, id1, r6, r8);
2019-02-23 18:08:07 +01:00
}
void sub_8167608(u8 arg0)
{
u8 spriteId;
struct SpriteTemplate spriteTemplate;
struct SpriteSheet spriteSheet;
struct SpritePalette spritePal;
if (gUnknown_0203BCAC->field_7B10 == 0xFF)
2019-03-23 16:41:09 +01:00
{
sub_81D31D0(&spriteSheet, &spriteTemplate, &spritePal);
spriteSheet.data = gUnknown_0203BCAC->field_304[arg0];
spritePal.data = gUnknown_0203BCAC->field_4[arg0];
gUnknown_0203BCAC->field_7B12 = LoadSpritePalette(&spritePal);
gUnknown_0203BCAC->field_7B14 = LoadSpriteSheet(&spriteSheet);
spriteId = CreateSprite(&spriteTemplate, 38, 104, 0);
gUnknown_0203BCAC->field_7B10 = spriteId;
if (spriteId == MAX_SPRITES)
2019-03-23 16:41:09 +01:00
{
FreeSpriteTilesByTag(100);
FreeSpritePaletteByTag(100);
gUnknown_0203BCAC->field_7B10 = 0xFF;
2019-03-23 16:41:09 +01:00
}
else
{
gUnknown_0203BCAC->field_7B10 = spriteId;
gSprites[gUnknown_0203BCAC->field_7B10].callback = sub_8168168;
gSprites[gUnknown_0203BCAC->field_7B10].pos2.y -= 34;
gUnknown_0203BCAC->field_7B18 = (void*)(OBJ_VRAM0 + (gUnknown_0203BCAC->field_7B14 * 32));
gUnknown_0203BCAC->field_7B12 = (gUnknown_0203BCAC->field_7B12 * 16) + 0x100;
2019-03-23 16:41:09 +01:00
}
}
else
{
do {} while(0); // Surprised to see something like this? It's a very neat trick for generating the same assembly. It has no practical purpose, feel free to remove it.
DmaCopy16Defvars(3, gUnknown_0203BCAC->field_304[arg0], gUnknown_0203BCAC->field_7B18, 0x800);
LoadPalette(gUnknown_0203BCAC->field_4[arg0], gUnknown_0203BCAC->field_7B12, 32);
2019-03-23 16:41:09 +01:00
}
2019-02-23 18:08:07 +01:00
}
void sub_8167760(void)
{
u16 i, spriteId;
struct SpriteSheet spriteSheets[4];
struct SpriteTemplate spriteTemplate;
struct SpritePalette spritePals[3];
struct SpriteSheet spriteSheet2;
struct SpritePalette spritePal2;
sub_81D321C(spriteSheets, &spriteTemplate, spritePals);
LoadSpriteSheets(spriteSheets);
LoadSpritePalettes(spritePals);
for (i = 0; i < gUnknown_0203BCAC->info.field_70 - 1; i++)
2019-03-23 16:41:09 +01:00
{
spriteId = CreateSprite(&spriteTemplate, 226, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
2019-03-23 16:41:09 +01:00
{
gUnknown_0203BCAC->field_7B06[i] = spriteId;
gSprites[spriteId].data[0] = i;
gSprites[spriteId].callback = sub_8168180;
2019-03-23 16:41:09 +01:00
}
else
{
gUnknown_0203BCAC->field_7B06[i] = -1;
2019-03-23 16:41:09 +01:00
}
}
spriteTemplate.tileTag = 103;
for (; i < 6; i++)
2019-03-23 16:41:09 +01:00
{
spriteId = CreateSprite(&spriteTemplate, 230, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
2019-03-23 16:41:09 +01:00
{
gUnknown_0203BCAC->field_7B06[i] = spriteId;
gSprites[spriteId].oam.size = 0;
2019-03-23 16:41:09 +01:00
}
else
{
gUnknown_0203BCAC->field_7B06[i] = -1;
2019-03-23 16:41:09 +01:00
}
}
spriteTemplate.tileTag = 102;
spriteTemplate.callback = sub_81681B4;
spriteId = CreateSprite(&spriteTemplate, 222, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
2019-03-23 16:41:09 +01:00
{
gUnknown_0203BCAC->field_7B06[i] = spriteId;
gSprites[spriteId].oam.shape = 1;
gSprites[spriteId].oam.size = 2;
}
else
2019-03-23 16:41:09 +01:00
{
gUnknown_0203BCAC->field_7B06[i] = -1;
2019-03-23 16:41:09 +01:00
}
sub_81D32B0(&spriteSheet2, &spritePal2);
LoadSpriteSheet(&spriteSheet2);
LoadSpritePalette(&spritePal2);
2019-02-23 18:08:07 +01:00
}
bool8 sub_8167930(void)
{
switch (gUnknown_0203BCAC->info.unk78)
{
case 0:
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ChangeBgX(2, 0, 0);
ChangeBgY(2, 0, 0);
ChangeBgX(3, 0, 0);
ChangeBgY(3, 136 << 6, 0);
SetGpuReg(REG_OFFSET_DISPCNT, 28736);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2|BLDCNT_EFFECT_BLEND|BLDCNT_TGT2_BG1);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
break;
case 1:
gUnknown_0203BCA4 = Alloc(6656);
gUnknown_0203BCA0 = Alloc(1280);
gUnknown_0203BCA8 = Alloc(1280);
break;
case 2:
LZ77UnCompVram(gUnknown_085DFB60, gUnknown_0203BCA8);
break;
case 3:
LoadBgTiles(3, gUnknown_085DFA80, 224, 0);
break;
case 4:
LoadBgTilemap(3, gUnknown_0203BCA8, 1280, 0);
break;
case 5:
LoadPalette(gUnknown_085DFA60, 208, 32);
gUnknown_0203BCAC->field_7B0E = 0xFFB0;
break;
case 6:
LZ77UnCompVram(gUsePokeblockGraph_Gfx, gUnknown_0203BCA4);
break;
case 7:
LZ77UnCompVram(gUsePokeblockGraph_Tilemap, gUnknown_0203BCA0);
LoadPalette(gUsePokeblockGraph_Pal, 32, 32);
break;
case 8:
LoadBgTiles(1, gUnknown_0203BCA4, 6656, 160 << 2);
break;
case 9:
SetBgTilemapBuffer(1, gUnknown_0203BCA0);
CopyToBgTilemapBufferRect(1, gUsePokeblockNatureWin_Pal, 0, 13, 12, 4);
CopyBgTilemapBufferToVram(1);
break;
case 10:
2019-03-31 14:32:26 +02:00
LZ77UnCompVram(gUnknown_085DFC0C, gUnknown_0203BCAC->tilemapBuffer);
break;
case 11:
2019-03-31 14:32:26 +02:00
LoadBgTilemap(2, gUnknown_0203BCAC->tilemapBuffer, 1280, 0);
LoadPalette(gUnknown_086231E8, 48, 32);
LoadPalette(gUnknown_08623208, 240, 32);
sub_81D21DC(2);
break;
default:
gUnknown_0203BCAC->info.unk78 = 0;
return FALSE;
}
gUnknown_0203BCAC->info.unk78++;
return TRUE;
2019-02-23 18:08:07 +01:00
}
void sub_8167BA0(u16 arg0, u8 copyToVramMode)
{
u8 partyIndex;
u8 nature;
u8 *str;
2019-02-23 18:08:07 +01:00
FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(1, PIXEL_FILL(0));
if (gUnknown_0203BCAC->info.field_71 != gUnknown_0203BCAC->info.field_70 - 1)
{
AddTextPrinterParameterized(0, 1, gUnknown_0203BCAC->field_7B95[arg0], 0, 1, 0, NULL);
partyIndex = sub_81672A4(gUnknown_0203BCAC->info.field_71);
nature = GetNature(&gPlayerParty[partyIndex]);
str = StringCopy(gUnknown_0203BCAC->info.field_7A, gText_NatureSlash);
str = StringCopy(str, gNatureNamePointers[nature]);
AddTextPrinterParameterized3(1, 1, 2, 1, gUnknown_085DFCC9, 0, gUnknown_0203BCAC->info.field_7A);
}
2019-02-23 18:08:07 +01:00
if (copyToVramMode)
{
CopyWindowToVram(0, 3);
CopyWindowToVram(1, 3);
}
else
{
CopyWindowToVram(0, 2);
CopyWindowToVram(1, 2);
}
}
2019-02-23 18:08:07 +01:00
static void sub_8167CA0(bool8 arg0)
{
u16 var0;
bool32 r8, r4;
2019-02-23 18:08:07 +01:00
if (arg0)
var0 = gUnknown_0203BCAC->field_7FB5;
else
var0 = gUnknown_0203BCAC->field_7FB4;
2019-02-23 18:08:07 +01:00
sub_81D1F84(
&gUnknown_0203BCAC->field_7C58,
gUnknown_0203BCAC->field_7C58.unk14[gUnknown_0203BCAC->field_7FB3],
gUnknown_0203BCAC->field_7C58.unk14[var0]);
2019-02-23 18:08:07 +01:00
r8 = (gUnknown_0203BCAC->info.field_71 ^ (gUnknown_0203BCAC->info.field_70 - 1)) ? 1 : 0;
if (arg0)
{
gUnknown_0203BCAC->field_7FB5 = gUnknown_0203BCAC->field_7FB4;
gUnknown_0203BCAC->field_7FB4 = gUnknown_0203BCAC->field_7FB3;
gUnknown_0203BCAC->field_7FB3 = var0;
gUnknown_0203BCAC->field_7FB6 = gUnknown_0203BCAC->field_7FB5;
gUnknown_0203BCAC->info.field_71 = (gUnknown_0203BCAC->info.field_71 == 0)
? gUnknown_0203BCAC->info.field_70 - 1
: gUnknown_0203BCAC->info.field_71 - 1;
gUnknown_0203BCAC->field_7B4C = (gUnknown_0203BCAC->info.field_71 == 0)
? gUnknown_0203BCAC->info.field_70 - 1
: gUnknown_0203BCAC->info.field_71 - 1;
}
else
{
gUnknown_0203BCAC->field_7FB4 = gUnknown_0203BCAC->field_7FB5;
gUnknown_0203BCAC->field_7FB5 = gUnknown_0203BCAC->field_7FB3;
gUnknown_0203BCAC->field_7FB3 = var0;
gUnknown_0203BCAC->field_7FB6 = gUnknown_0203BCAC->field_7FB4;
gUnknown_0203BCAC->info.field_71 = (gUnknown_0203BCAC->info.field_71 < gUnknown_0203BCAC->info.field_70 - 1)
? gUnknown_0203BCAC->info.field_71 + 1
: 0;
gUnknown_0203BCAC->field_7B4C = (gUnknown_0203BCAC->info.field_71 < gUnknown_0203BCAC->info.field_70 - 1)
? gUnknown_0203BCAC->info.field_71 + 1
: 0;
}
2019-02-23 18:08:07 +01:00
r4 = (gUnknown_0203BCAC->info.field_71 ^ (gUnknown_0203BCAC->info.field_70 - 1)) ? 1 : 0;
sub_81D3520(gUnknown_0203BCAC->field_7B1C);
2019-02-23 18:08:07 +01:00
if (!r8)
gUnknown_0203BCAC->info.unk74 = sub_8167EA4;
else if (!r4)
gUnknown_0203BCAC->info.unk74 = sub_8167FA4;
else
gUnknown_0203BCAC->info.unk74 = sub_8168048;
}
2019-02-23 18:08:07 +01:00
static u8 sub_8167EA4(void)
{
switch (gUnknown_0203BCAC->info.unk78)
{
case 0:
sub_8167608(gUnknown_0203BCAC->field_7FB3);
gUnknown_0203BCAC->info.unk78++;
break;
case 1:
sub_8167BA0(gUnknown_0203BCAC->field_7FB3, 0);
gUnknown_0203BCAC->info.unk78++;
break;
case 2:
if (!sub_81D3178(&gUnknown_0203BCAC->field_7C58, &gUnknown_0203BCAC->field_7B0E))
{
sub_816753C(gUnknown_0203BCAC->field_7B4C, gUnknown_0203BCAC->field_7FB6);
gUnknown_0203BCAC->info.unk78++;
}
break;
case 3:
sub_81D3464(gUnknown_0203BCAC->field_7B1C);
if (gUnknown_0203BCAC->info.field_71 != gUnknown_0203BCAC->info.field_70 - 1)
{
u8 var0 = gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3];
sub_81D3480(gUnknown_0203BCAC->field_7B1C, gUnknown_0203BCAC->field_7B10, var0);
}
2019-02-23 18:08:07 +01:00
gUnknown_0203BCAC->info.unk78 = 0;
return FALSE;
}
2019-02-23 18:08:07 +01:00
return TRUE;
}
2019-02-23 18:08:07 +01:00
static u8 sub_8167FA4(void)
{
switch (gUnknown_0203BCAC->info.unk78)
{
case 0:
if (!sub_81D31A4(&gUnknown_0203BCAC->field_7C58, &gUnknown_0203BCAC->field_7B0E))
gUnknown_0203BCAC->info.unk78++;
break;
case 1:
sub_8167BA0(gUnknown_0203BCAC->field_7FB3, 0);
gUnknown_0203BCAC->info.unk78++;
break;
case 2:
sub_816753C(gUnknown_0203BCAC->field_7B4C, gUnknown_0203BCAC->field_7FB6);
gUnknown_0203BCAC->info.unk78++;
break;
case 3:
gUnknown_0203BCAC->info.unk78 = 0;
return FALSE;
}
2019-02-23 18:08:07 +01:00
return TRUE;
}
2019-02-23 18:08:07 +01:00
static u8 sub_8168048(void)
{
switch (gUnknown_0203BCAC->info.unk78)
{
case 0:
sub_81D2074(&gUnknown_0203BCAC->field_7C58);
if (!sub_81D3150(&gUnknown_0203BCAC->field_7B0E))
{
sub_8167608(gUnknown_0203BCAC->field_7FB3);
gUnknown_0203BCAC->info.unk78++;
}
break;
case 1:
sub_8167BA0(gUnknown_0203BCAC->field_7FB3, 0);
gUnknown_0203BCAC->info.unk78++;
break;
case 2:
if (!sub_81D3178(&gUnknown_0203BCAC->field_7C58, &gUnknown_0203BCAC->field_7B0E))
{
sub_816753C(gUnknown_0203BCAC->field_7B4C, gUnknown_0203BCAC->field_7FB6);
gUnknown_0203BCAC->info.unk78++;
}
break;
case 3:
sub_81D3464(gUnknown_0203BCAC->field_7B1C);
if (gUnknown_0203BCAC->info.field_71 != gUnknown_0203BCAC->info.field_70 - 1)
{
u8 var0 = gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3];
sub_81D3480(gUnknown_0203BCAC->field_7B1C, gUnknown_0203BCAC->field_7B10, var0);
}
2019-02-23 18:08:07 +01:00
gUnknown_0203BCAC->info.unk78 = 0;
return FALSE;
}
2019-02-23 18:08:07 +01:00
return TRUE;
}
2019-02-23 18:08:07 +01:00
void sub_8168168(struct Sprite *sprite)
{
sprite->pos1.x = gUnknown_0203BCAC->field_7B0E + 38;
}
2019-02-23 18:08:07 +01:00
void sub_8168180(struct Sprite *sprite)
{
if (sprite->data[0] == gUnknown_0203BCAC->info.field_71)
StartSpriteAnim(sprite, 0);
else
StartSpriteAnim(sprite, 1);
}
2019-02-23 18:08:07 +01:00
void sub_81681B4(struct Sprite *sprite)
{
if (gUnknown_0203BCAC->info.field_71 == gUnknown_0203BCAC->info.field_70 - 1)
sprite->oam.paletteNum = IndexOfSpritePaletteTag(101);
else
sprite->oam.paletteNum = IndexOfSpritePaletteTag(102);
}
2019-02-23 18:08:07 +01:00
void sub_81681F4(u8 monIndex)
{
u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN);
gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3] = (sheen != 255)
? sheen / 29
: 9;
}
2019-02-23 18:08:07 +01:00
static void sub_8168248(void)
{
struct CompressedSpriteSheet spriteSheet;
struct SpritePalette spritePalette;
2019-07-31 02:21:17 +02:00
spritePalette = gSpritePalette_085DFDB8;
spriteSheet.data = gUsePokeblockCondition_Gfx;
spriteSheet.size = 0x800;
spriteSheet.tag = 1;
LoadCompressedSpriteSheet(&spriteSheet);
LoadSpritePalette(&spritePalette);
}
2019-02-23 18:08:07 +01:00
static void sub_8168294(void)
{
u16 i;
s16 xDiff, xStart;
int yStart = 17;
int var = 8;
struct Sprite **sprites = gUnknown_0203BCAC->field_7B44;
2019-07-31 02:21:17 +02:00
const struct SpriteTemplate *template = &gSpriteTemplate_085DFDA0;
2019-02-23 18:08:07 +01:00
for (i = 0, xDiff = 64, xStart = -96; i < 2; i++)
{
u8 spriteId = CreateSprite(template, i * xDiff + xStart, yStart, 0);
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].data[0] = var;
gSprites[spriteId].data[1] = (i * xDiff) | 0x20;
gSprites[spriteId].data[2] = i;
StartSpriteAnim(&gSprites[spriteId], i);
sprites[i] = &gSprites[spriteId];
}
}
}
2019-02-23 18:08:07 +01:00
static bool8 sub_8168328(void)
{
switch (gUnknown_0203BCAC->info.unk78)
{
case 0:
sub_8168248();
gUnknown_0203BCAC->info.unk78++;
return TRUE;
case 1:
sub_8168294();
gUnknown_0203BCAC->info.unk78 = 0;
return FALSE;
}
2019-02-23 18:08:07 +01:00
return FALSE;
}
2019-02-23 18:08:07 +01:00
void sub_8168374(struct Sprite *sprite)
{
s16 prevX = sprite->pos1.x;
sprite->pos1.x += sprite->data[0];
if ((prevX <= sprite->data[1] && sprite->pos1.x >= sprite->data[1])
|| (prevX >= sprite->data[1] && sprite->pos1.x <= sprite->data[1]))
{
sprite->pos1.x = sprite->data[1];
sprite->callback = SpriteCallbackDummy;
}
}