pokeemerald/src/use_pokeblock.c

1863 lines
45 KiB
C
Raw Normal View History

2017-12-04 23:09:44 +01:00
#include "global.h"
#include "main.h"
#include "pokeblock.h"
#include "alloc.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"
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 *pokemon;
/*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;
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-23 16:41:09 +01:00
/*0x0000*/ u8 field_0[0x7B06];
/*0x7B06*/ u8 field_7B06[7];
/*0x7B0E*/ u16 field_7B0E;
/*0x7B10*/ u8 field_7B10;
/*0x7B11*/ u8 field_7B11[0xB];
/*0x7B1C*/ struct Sprite *field_7B1C[10];
/*0x7B44*/ struct Sprite *field_7B44[0x45];
/*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*/ u8 filler7FB6[0x2];
2019-03-23 17:16:53 +01:00
/*0x7FB8*/ struct Unk7FB8 field_7FB8[6];
/*0x7FD0*/ struct UsePokeblockSubStruct info;
2019-03-23 16:41:09 +01:00
/*0x804C*/ u8 filler804C[0x20];
2017-12-04 23:09:44 +01:00
};
2017-12-09 21:23:40 +01:00
extern u16 gKeyRepeatStartDelay;
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);
bool8 sub_8168328(void);
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);
void sub_8167CA0(bool8);
void sub_8166BEC(void);
void sub_8166D44(void);
s8 sub_8166DE4(void);
bool8 sub_8167268(void);
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);
extern void sub_81D2074(void);
void sub_81681F4(u8);
void sub_8166E24(void);
bool8 sub_8166EDC(void);
void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2);
void Pokeblock_MenuWindowTextPrint(const u8 *message);
void sub_8167184(struct Pokeblock *, struct Pokemon *);
extern u32 sub_81D2C68(s32, s32, s32, u8 *);
void sub_81673DC(struct Sprite *sprite);
void sub_81674BC(void);
void sub_816753C(s16, u8);
extern void sub_81D2ED4(u8, u8, u16, u8, u8, u8, u8);
extern void sub_81D2F78(u8, u8, s16, u16, u8, u8, u8, u8);
extern void sub_81D3094(u8, u8, s16, u16, u8, u8, u8);
extern void sub_81D31D0(struct SpritePalette *, struct SpritePalette *, struct SpritePalette *);
extern void sub_81D321C(struct SpriteSheet *, struct SpriteTemplate *, struct SpritePalette*);
void sub_8168180(void);
void sub_81681B4(void);
extern void sub_81D32B0(struct SpriteSheet *, struct SpritePalette*);
extern void sub_81D21DC(u8);
2017-12-09 21:23:40 +01:00
extern const struct BgTemplate gUnknown_085DFCCC[4];
extern const struct WindowTemplate gUnknown_085DFCDC[];
2019-02-23 18:08:07 +01:00
extern u16 gSpecialVar_ItemId;
extern const struct WindowTemplate sUsePokeblockYesNoWinTemplate[];
extern const u8* sContestStatNames[];
extern const u32 gUnknown_085DFCB0[];
extern const u8 gUnknown_085DFCC4[];
extern const struct SpriteSheet gSpriteSheet_ConditionUpDown;
extern const struct SpritePalette gSpritePalette_ConditionUpDown;
extern const struct SpriteTemplate gSpriteTemplate_085DFD5C;
extern const s16 gUnknown_085DFD28[][2];
extern const u32 gUnknown_085DFB60[];
extern const u32 gUnknown_085DFA80[];
extern const u32 gUnknown_085DFA60[];
extern const u32 gUnknown_085DFC0C[];
extern const u16 gUnknown_086231E8[];
extern const u16 gUnknown_08623208[];
2017-12-04 23:09:44 +01:00
// ram variables
EWRAM_DATA struct UsePokeblockSubStruct *gUnknown_0203BC90 = NULL;
EWRAM_DATA void (*gUnknown_0203BC94)(void) = NULL;
EWRAM_DATA struct Pokeblock *gUnknown_0203BC98 = NULL;
EWRAM_DATA u8 gPokeblockMonId = 0;
EWRAM_DATA s16 gPokeblockGain = 0;
EWRAM_DATA void *gUnknown_0203BCA0 = NULL;
EWRAM_DATA void *gUnknown_0203BCA4 = NULL;
EWRAM_DATA void *gUnknown_0203BCA8 = NULL;
EWRAM_DATA struct UsePokeblockStruct *gUnknown_0203BCAC = NULL;
2017-12-10 19:02:51 +01:00
// const rom data
// todo: make it static once the file is decompiled
// 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)
gUnknown_0203BC90->field_50 = var;
break;
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 (sub_8167268())
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(gUnknown_0203BCA0);
gUnknown_0203BCA0 = NULL;
Free(gUnknown_0203BCA4);
gUnknown_0203BCA4 = NULL;
Free(gUnknown_0203BCA8);
gUnknown_0203BCA8 = NULL;
Free(gUnknown_0203BCAC);
gUnknown_0203BCAC = NULL;
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
}
}
#ifdef NONMATCHING
void sub_8166A34(void)
{
switch (gUnknown_0203BC90->field_50)
{
u8 var;
2019-03-23 16:41:09 +01:00
case 0:
gUnknown_0203BC90->field_5c[0] = (u8) &gPlayerParty;
gUnknown_0203BCAC->info.field_71 = (u32) &gUnknown_0203BCAC->field_0[gUnknown_0203BCAC->info.field_71];
2019-03-23 16:41:09 +01:00
gUnknown_0203BC90->field_5c[0] = &gPlayerParty
sub_81D3520(gUnknown_0203BCAC->field_7B1C);
2019-02-23 18:08:07 +01:00
/*gUnknown_0203BCAC->pokemon = &gPlayerParty[gUnknown_083DFEC4->unk893c[gUnknown_0203BCAC->field_0[0x7B1C]].partyIdx];
move_anim_execute();*/
gUnknown_0203BC90->field_50++;
break;
case 1:
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
gUnknown_0203BC90->field_50++;
break;
case 2:
sub_8167104();
sub_81D2754(gUnknown_0203BC90->field_5c, &gUnknown_0203BCAC->field_7C58[0x50]);
sub_81D1F84(&gUnknown_0203BCAC->field_7C58[0], &gUnknown_0203BCAC->field_7C58[gUnknown_0203BCAC->field_7C58[0x35B] + 0x14], 0);
sub_8167338();
gUnknown_0203BC90->field_50++;
break;
case 3:
2019-03-23 16:41:09 +01:00
var = gUnknown_0203BCAC->field_7C58[0];
sub_81D2074();
2019-02-23 18:08:07 +01:00
if (!var)
{
sub_81681F4(sub_81672A4(gUnknown_0203BCAC->info.field_71));
2019-02-23 18:08:07 +01:00
/*sub_80F3D00();
gUnknown_0203BCAC->unk52 = 0;*/
2019-03-23 16:41:09 +01:00
if(gUnknown_0203BCAC->info.field_71 == gUnknown_0203BCAC->info.field_70 - 1)
{
gUnknown_0203BC90->field_52 = var;
}
sub_81D3480(&gUnknown_0203BCAC->field_7C58[0x35B], gUnknown_0203BCAC->field_7C58[0x35B + gUnknown_0203BCAC->field_7C58[0x358]]);
2019-02-23 18:08:07 +01:00
}
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;
}
}
#else
NAKED
void sub_8166A34(void)
{
2019-03-23 16:41:09 +01:00
asm(".syntax unified\n\
push {r4-r6,lr}\n\
ldr r1, =gUnknown_0203BC90\n\
ldr r0, [r1]\n\
adds r0, 0x50\n\
ldrb r0, [r0]\n\
adds r5, r1, 0\n\
cmp r0, 0x5\n\
bls _08166A46\n\
b _08166BDA\n\
2019-02-23 18:08:07 +01:00
_08166A46:\n\
2019-03-23 16:41:09 +01:00
lsls r0, 2\n\
ldr r1, =_08166A58\n\
adds r0, r1\n\
ldr r0, [r0]\n\
mov pc, r0\n\
.pool\n\
.align 2, 0\n\
2019-02-23 18:08:07 +01:00
_08166A58:\n\
2019-03-23 16:41:09 +01:00
.4byte _08166A70\n\
.4byte _08166AAC\n\
.4byte _08166AC0\n\
.4byte _08166B14\n\
.4byte _08166B94\n\
.4byte _08166BB6\n\
2019-02-23 18:08:07 +01:00
_08166A70:\n\
2019-03-23 16:41:09 +01:00
ldr r4, [r5]\n\
ldr r3, =gPlayerParty\n\
str r3, [r4, 0xC]\n\
ldr r0, =gUnknown_0203BCAC\n\
ldr r0, [r0]\n\
ldr r2, =0x00008041\n\
adds r1, r0, r2\n\
ldrb r1, [r1]\n\
lsls r1, 2\n\
adds r1, r0, r1\n\
subs r2, 0x88\n\
adds r1, r2\n\
ldrb r2, [r1]\n\
movs r1, 0x64\n\
muls r1, r2\n\
adds r1, r3\n\
str r1, [r4, 0xC]\n\
ldr r3, =0x00007b1c\n\
adds r0, r3\n\
bl sub_81D3520\n\
b _08166BAA\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_08166AAC:\n\
2019-03-23 16:41:09 +01:00
ldr r0, =gMain\n\
ldrh r1, [r0, 0x2E]\n\
movs r0, 0x3\n\
ands r0, r1\n\
cmp r0, 0\n\
bne _08166ABA\n\
b _08166BDA\n\
2019-02-23 18:08:07 +01:00
_08166ABA:\n\
2019-03-23 16:41:09 +01:00
b _08166BAA\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_08166AC0:\n\
2019-03-23 16:41:09 +01:00
bl sub_8167104\n\
ldr r6, =gUnknown_0203BC90\n\
ldr r0, [r6]\n\
adds r0, 0x5C\n\
ldr r4, =gUnknown_0203BCAC\n\
ldr r1, [r4]\n\
ldr r5, =0x00007ca8\n\
adds r1, r5\n\
bl sub_81D2754\n\
ldr r2, [r4]\n\
ldr r4, =0x00007c58\n\
adds r0, r2, r4\n\
ldr r3, =0x00007fb3\n\
adds r1, r2, r3\n\
movs r3, 0\n\
ldrsb r3, [r1, r3]\n\
lsls r1, r3, 2\n\
adds r1, r3\n\
lsls r1, 2\n\
adds r4, 0x14\n\
adds r1, r4\n\
adds r1, r2, r1\n\
adds r2, r5\n\
bl sub_81D1F84\n\
bl sub_8167338\n\
ldr r1, [r6]\n\
b _08166BAC\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_08166B14:\n\
2019-03-23 16:41:09 +01:00
ldr r5, =gUnknown_0203BCAC\n\
ldr r0, [r5]\n\
ldr r1, =0x00007c58\n\
adds r0, r1\n\
bl sub_81D2074\n\
lsls r0, 24\n\
lsrs r6, r0, 24\n\
cmp r6, 0\n\
bne _08166BDA\n\
ldr r0, [r5]\n\
ldr r4, =0x00008041\n\
adds r0, r4\n\
ldrb r0, [r0]\n\
bl sub_81672A4\n\
lsls r0, 24\n\
lsrs r0, 24\n\
bl sub_81681F4\n\
ldr r3, [r5]\n\
adds r4, r3, r4\n\
ldrb r1, [r4]\n\
ldr r2, =0x00008040\n\
adds r0, r3, r2\n\
ldrb r0, [r0]\n\
subs r0, 0x1\n\
cmp r1, r0\n\
beq _08166B6C\n\
ldr r4, =0x00007fb3\n\
adds r0, r3, r4\n\
movs r1, 0\n\
ldrsb r1, [r0, r1]\n\
subs r2, 0x90\n\
adds r0, r3, r2\n\
adds r0, r1\n\
ldrb r2, [r0]\n\
ldr r4, =0x00007b1c\n\
adds r0, r3, r4\n\
subs r4, 0xC\n\
adds r1, r3, r4\n\
ldrb r1, [r1]\n\
bl sub_81D3480\n\
2019-02-23 18:08:07 +01:00
_08166B6C:\n\
2019-03-23 16:41:09 +01:00
ldr r1, =gUnknown_0203BC90\n\
ldr r0, [r1]\n\
adds r0, 0x52\n\
strb r6, [r0]\n\
ldr r1, [r1]\n\
b _08166BAC\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_08166B94:\n\
2019-03-23 16:41:09 +01:00
ldr r1, [r5]\n\
adds r1, 0x52\n\
ldrb r0, [r1]\n\
adds r0, 0x1\n\
strb r0, [r1]\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x10\n\
bls _08166BDA\n\
bl sub_8166E24\n\
2019-02-23 18:08:07 +01:00
_08166BAA:\n\
2019-03-23 16:41:09 +01:00
ldr r1, [r5]\n\
2019-02-23 18:08:07 +01:00
_08166BAC:\n\
2019-03-23 16:41:09 +01:00
adds r1, 0x50\n\
ldrb r0, [r1]\n\
adds r0, 0x1\n\
strb r0, [r1]\n\
b _08166BDA\n\
2019-02-23 18:08:07 +01:00
_08166BB6:\n\
2019-03-23 16:41:09 +01:00
ldr r0, =gMain\n\
ldrh r1, [r0, 0x2E]\n\
movs r0, 0x3\n\
ands r0, r1\n\
cmp r0, 0\n\
beq _08166BDA\n\
bl sub_8166EDC\n\
lsls r0, 24\n\
cmp r0, 0\n\
bne _08166BDA\n\
ldr r0, =gSpecialVar_ItemId\n\
ldrb r0, [r0]\n\
bl TryClearPokeblock\n\
ldr r0, =sub_8166BEC\n\
bl sub_816636C\n\
2019-02-23 18:08:07 +01:00
_08166BDA:\n\
2019-03-23 16:41:09 +01:00
pop {r4-r6}\n\
pop {r0}\n\
bx r0\n\
.pool\n\
.syntax divided\n");
2019-02-23 18:08:07 +01:00
}
#endif
void sub_8166BEC(void)
{
2019-03-23 16:41:09 +01:00
u8 i;
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:
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]]);
FreeSpriteTilesByTag(0);
FreeSpriteTilesByTag(1);
FreeSpritePaletteByTag(0);
FreeSpritePaletteByTag(1);
for (i = 0; i < 2; i++)
DestroySprite(gUnknown_0203BCAC->field_7B44[i]);
if (gUnknown_0203BCAC->field_7B10 != 0xFF)
DestroySprite(&gSprites[gUnknown_0203BCAC->field_7B10]);
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);
sub_8098858(2, 151, 14);
AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL);
PutWindowTilemap(2);
CopyWindowToVram(2, 3);
CreateYesNoMenu(sUsePokeblockYesNoWinTemplate, 151, 14, 0);
2019-02-23 18:08:07 +01:00
}
s8 sub_8166DE4(void)
{
s8 retval = Menu_ProcessInputNoWrapClearOnChoose();
switch(retval)
{
2019-03-23 16:41:09 +01:00
case 0:
break;
case -1:
case 1:
PlaySE(SE_SELECT);
rbox_fill_rectangle(2);
ClearWindowTilemap(2);
break;
2019-02-23 18:08:07 +01:00
}
return retval;
}
void sub_8166E24(void)
{
2019-03-23 16:41:09 +01:00
sub_8098858(2, 151, 14);
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_61[gUnknown_0203BC90->field_53] == 0; gUnknown_0203BC90->field_53++);
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-03-23 16:41:09 +01:00
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-02-23 18:08:07 +01:00
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);
sub_8098858(2, 151, 14);
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
}
#ifdef NONMATCHING
void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2)
{
if (a2 != 0)
{
2019-03-23 17:16:53 +01:00
if (a2 > 0)
a2 = 0;
2019-02-23 18:08:07 +01:00
2019-03-23 16:41:09 +01: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
void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2)
{
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 *pokemon, u8 *data)
{
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++)
2019-02-23 18:08:07 +01:00
data[i] = GetMonData(pokemon, gUnknown_085DFCB0[i]);
}
void sub_8167054(struct Pokeblock *pokeblock, struct Pokemon *pokemon)
{
u16 i;
s16 cstat;
u8 data;
if (GetMonData(pokemon, MON_DATA_SHEEN) != 255)
{
sub_8167184(pokeblock, pokemon);
2019-03-23 17:16:53 +01:00
for (i = 0; i < 5; i++)
2019-02-23 18:08:07 +01:00
{
data = GetMonData(pokemon, gUnknown_085DFCB0[i]);
cstat = data + gUnknown_0203BC90->field_66[i];
if (cstat < 0)
cstat = 0;
if (cstat > 255)
cstat = 255;
data = cstat;
SetMonData(pokemon, gUnknown_085DFCB0[i], &data);
}
2019-03-23 17:16:53 +01:00
2019-02-23 18:08:07 +01:00
cstat = (u8)GetMonData(pokemon, MON_DATA_SHEEN);
cstat = cstat + pokeblock->feel;
if (cstat > 255)
cstat = 255;
2019-03-23 17:16:53 +01:00
2019-02-23 18:08:07 +01:00
data = cstat;
SetMonData(pokemon, MON_DATA_SHEEN, &data);
}
}
void sub_8167104(void)
{
u16 i;
struct Pokemon *pokemon = gPlayerParty;
pokemon += gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->info.field_71 * 4 + 9];
2019-02-23 18:08:07 +01:00
Pokeblock_GetMonContestStats(pokemon, gUnknown_0203BC90->field_57);
sub_8167054(gUnknown_0203BC90->pokeblock, pokemon);
Pokeblock_GetMonContestStats(pokemon, gUnknown_0203BC90->field_5c);
for (i=0; i<5; i++)
{
gUnknown_0203BC90->field_61[i] = gUnknown_0203BC90->field_5c[i] - gUnknown_0203BC90->field_57[i];
}
}
void sub_8167184(struct Pokeblock *pokeblock, struct Pokemon *pokemon)
{
s8 direction;
s8 i;
s16 amount;
s8 boost;
s8 taste;
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;
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
{
amount = gUnknown_0203BC90->field_66[i];
boost = amount / 10;
if (amount % 10 >= 5) // round to the nearest
boost++;
2019-03-23 17:16:53 +01:00
2019-02-23 18:08:07 +01:00
taste = GetMonFlavorRelation(pokemon, gUnknown_085DFCC4[i]);
if (taste == direction)
gUnknown_0203BC90->field_66[i] += boost * taste;
}
}
bool8 sub_8167268(void)
{
2019-03-23 16:41:09 +01:00
u8 *mon;
mon = (u8 *) &gUnknown_0203BCAC->field_0[gUnknown_0203BCAC->info.field_71 * 4];
2019-02-23 18:08:07 +01:00
if (sub_81D2C68(*(mon + 864 + 0x7C58), *(mon + 865 + 0x7C58), MON_DATA_SHEEN, 0) == 255)
return TRUE;
return FALSE;
}
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;
2019-03-23 17:16:53 +01:00
2019-02-23 18:08:07 +01:00
a0--;
}
}
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 flavor;
u8 spriteidx;
LoadSpriteSheet(&gSpriteSheet_ConditionUpDown);
LoadSpritePalette(&gSpritePalette_ConditionUpDown);
gUnknown_0203BC90->field_54 = 0;
2019-03-23 17:16:53 +01:00
for (flavor = 0; flavor < 5; flavor++)
2019-02-23 18:08:07 +01:00
{
if (gUnknown_0203BC90->field_61[flavor] != 0)
{
spriteidx = CreateSprite(&gSpriteTemplate_085DFD5C, gUnknown_085DFD28[flavor][0], gUnknown_085DFD28[flavor][1], 0);
if (spriteidx != MAX_SPRITES)
{
if (gUnknown_0203BC90->field_61[flavor] != 0)
gSprites[spriteidx].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;
2019-03-23 16:41:09 +01:00
2019-03-23 17:16:53 +01:00
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)
{
2019-03-23 16:41:09 +01:00
s16 var;
s16 var2;
sub_816753C(gUnknown_0203BCAC->info.field_71, 0);
gUnknown_0203BCAC->field_7FB3 = 0;
gUnknown_0203BCAC->field_7FB4 = 1;
gUnknown_0203BCAC->field_7FB5 = 2;
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
}
#ifdef NONMATCHING
void sub_816753C(s16 a1, u8 a2)
{
2019-03-23 16:41:09 +01:00
u8 *v3;
int v5;
int v6;
v3 = &gUnknown_0203BCAC->field_0[a1 << 16 >> 14];
v5 = *(0x7FB8 + v3);
v6 = *(0x7FB9 + v3);
sub_81D2ED4(gUnknown_0203BCAC->field_0[0x7B4D + 24 * a2], gUnknown_0203BCAC->field_0[0x7B95 + 64 * a2], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0);
sub_81D2F78(gUnknown_0203BCAC->field_7C58[0], gUnknown_0203BCAC->field_0[0x7FB0], v5, v6, a1, a2, gUnknown_0203BCAC->info.field_70, 0);
sub_81D3094(gUnknown_0203BCAC->field_0[(a2 << 13) + 0x304], gUnknown_0203BCAC->field_0[(a2 << 7) + 4], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0);
//gUnknown_0203BCAC->field_0[0x7B4D + a1 * 40], gUnknown_0203BCAC->field_7FB8, gUnknown_0203BCAC->field_7FB9, gUnknown_203BCAC->field_0[0], gUnknown_203BCAC->info.field_70, 0)
2019-02-23 18:08:07 +01:00
}
#else
NAKED
void sub_816753C(s16 a1, u8 a2)
{
2019-03-23 16:41:09 +01:00
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x10\n\
adds r5, r0, 0\n\
adds r4, r1, 0\n\
lsls r4, 24\n\
lsrs r4, 24\n\
ldr r0, =gUnknown_0203BCAC\n\
mov r9, r0\n\
ldr r1, [r0]\n\
lsls r5, 16\n\
asrs r0, r5, 14\n\
adds r0, r1, r0\n\
ldr r3, =0x00007fb8\n\
adds r2, r0, r3\n\
ldrb r7, [r2]\n\
ldr r2, =0x00007fb9\n\
adds r0, r2\n\
ldrb r0, [r0]\n\
mov r10, r0\n\
adds r3, 0x88\n\
adds r0, r1, r3\n\
ldrb r6, [r0]\n\
movs r0, 0\n\
mov r8, r0\n\
lsls r0, r4, 1\n\
adds r0, r4\n\
lsls r0, 3\n\
ldr r2, =0x00007b4d\n\
adds r0, r2\n\
adds r0, r1, r0\n\
lsls r2, r4, 6\n\
ldr r3, =0x00007b95\n\
adds r2, r3\n\
adds r1, r2\n\
lsrs r5, 16\n\
str r5, [sp]\n\
str r6, [sp, 0x4]\n\
mov r2, r8\n\
str r2, [sp, 0x8]\n\
adds r2, r7, 0\n\
mov r3, r10\n\
bl sub_81D2ED4\n\
mov r3, r9\n\
ldr r1, [r3]\n\
ldr r2, =0x00007c58\n\
adds r0, r1, r2\n\
ldr r3, =0x00007fb0\n\
adds r1, r3\n\
str r5, [sp]\n\
str r4, [sp, 0x4]\n\
str r6, [sp, 0x8]\n\
mov r2, r8\n\
str r2, [sp, 0xC]\n\
adds r2, r7, 0\n\
mov r3, r10\n\
bl sub_81D2F78\n\
lsls r0, r4, 13\n\
movs r1, 0xC1\n\
lsls r1, 2\n\
adds r0, r1\n\
mov r3, r9\n\
ldr r1, [r3]\n\
adds r0, r1, r0\n\
lsls r4, 7\n\
adds r4, 0x4\n\
adds r1, r4\n\
str r5, [sp]\n\
str r6, [sp, 0x4]\n\
mov r2, r8\n\
str r2, [sp, 0x8]\n\
adds r2, r7, 0\n\
mov r3, r10\n\
bl sub_81D3094\n\
add sp, 0x10\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool\n\
.syntax divided\n");
2019-02-23 18:08:07 +01:00
}
#endif
#ifdef NONMATCHING
void sub_8167608(u8 arg0)
{
2019-03-23 16:41:09 +01:00
u8 v4;
u8 *v5;
u8 *v6;
u32 v7;
struct SpritePalette array[5];
if(gUnknown_0203BCAC->field_0[0x7B10] == 255)
{
sub_81D31D0(&array[3], &array[0], &array[4]);
array[1] = (struct SpritePallete *) ((u32) gUnknown_0203BCAC->field_0[(arg0 << 13) + 772]);
array[2] = (struct SpritePallete *) ((u32) gUnknown_0203BCAC->field_0[(arg0 << 7) + 4]);
gUnknown_0203BCAC->field_0[0x7B12] = LoadSpritePalette(&array[3]);
gUnknown_0203BCAC->field_0[0x7B14] = LoadSpritePalette(&array[4]);
v4 = CreateSprite(array[0], 38, 104, 0);
gUnknown_0203BCAC->field_0[0x7B10] = v4;
if(v4 == 64)
{
FreeSpriteTilesByTag(100);
FreeSpritePaletteByTag(100);
gUnknown_0203BCAC->field_0[0x7B10] = 255;
}
else
{
gUnknown_0203BCAC->field_0[0x7B10] = v4;
v5 = &gUnknown_0203BCAC->field_0[0];
v6 = &gUnknown_0203BCAC->field_0[0x7B10];
gSprites[v6].callback = sub_8168168;
gSprites[v6].pos2.y -= 32;
*(v5+0x7B18) = 32 * *(v5+0x7B14) + 0x06010000;
*(v5+0x7B12) = 16 * *(v5+0x7B12) + 0x100;
}
}
else
{
v7 = gUnknown_0203BCAC->field_0[0x7B18];
REG_ADDR_DMA3SAD = gUnknown_0203BCAC->field_0[(arg0 << 13) + 772];
REG_ADDR_DMA3DAD = v7;
REG_ADDR_DMA3CNT = 0x80000400;
LoadPalette(gUnknown_0203BCAC->field_0[arg0 << 7) + 4), gUnknown_0203BCAC->field_0[0x7B12], 32);
}
2019-02-23 18:08:07 +01:00
}
#else
NAKED
void sub_8167608(u8 arg0)
{
2019-03-23 16:41:09 +01:00
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r8\n\
push {r7}\n\
sub sp, 0x28\n\
lsls r0, 24\n\
lsrs r6, r0, 24\n\
ldr r1, =gUnknown_0203BCAC\n\
ldr r3, [r1]\n\
ldr r0, =0x00007b10\n\
mov r8, r0\n\
adds r0, r3, r0\n\
ldrb r0, [r0]\n\
adds r7, r1, 0\n\
cmp r0, 0xFF\n\
bne _08167714\n\
add r5, sp, 0x18\n\
add r4, sp, 0x20\n\
adds r0, r5, 0\n\
mov r1, sp\n\
adds r2, r4, 0\n\
bl sub_81D31D0\n\
lsls r0, r6, 13\n\
movs r1, 0xC1\n\
lsls r1, 2\n\
adds r0, r1\n\
ldr r1, [r7]\n\
adds r0, r1, r0\n\
str r0, [sp, 0x18]\n\
lsls r0, r6, 7\n\
adds r0, 0x4\n\
adds r1, r0\n\
str r1, [sp, 0x20]\n\
adds r0, r4, 0\n\
bl LoadSpritePalette\n\
ldr r1, [r7]\n\
lsls r0, 24\n\
lsrs r0, 24\n\
ldr r2, =0x00007b12\n\
adds r1, r2\n\
strh r0, [r1]\n\
adds r0, r5, 0\n\
bl LoadSpriteSheet\n\
ldr r1, [r7]\n\
ldr r3, =0x00007b14\n\
adds r1, r3\n\
strh r0, [r1]\n\
mov r0, sp\n\
movs r1, 0x26\n\
movs r2, 0x68\n\
movs r3, 0\n\
bl CreateSprite\n\
lsls r0, 24\n\
lsrs r1, r0, 24\n\
ldr r0, [r7]\n\
ldr r2, =0x00007b10\n\
adds r0, r2\n\
strb r1, [r0]\n\
cmp r1, 0x40\n\
bne _081676AC\n\
movs r0, 0x64\n\
bl FreeSpriteTilesByTag\n\
movs r0, 0x64\n\
bl FreeSpritePaletteByTag\n\
ldr r0, [r7]\n\
add r0, r8\n\
movs r1, 0xFF\n\
strb r1, [r0]\n\
b _08167742\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_081676AC:\n\
2019-03-23 16:41:09 +01:00
ldr r0, [r7]\n\
add r0, r8\n\
strb r1, [r0]\n\
ldr r4, =gSprites\n\
ldr r2, [r7]\n\
mov r0, r8\n\
adds r3, r2, r0\n\
ldrb r1, [r3]\n\
lsls r0, r1, 4\n\
adds r0, r1\n\
lsls r0, 2\n\
adds r1, r4, 0\n\
adds r1, 0x1C\n\
adds r0, r1\n\
ldr r1, =sub_8168168\n\
str r1, [r0]\n\
ldrb r1, [r3]\n\
lsls r0, r1, 4\n\
adds r0, r1\n\
lsls r0, 2\n\
adds r0, r4\n\
ldrh r1, [r0, 0x26]\n\
subs r1, 0x22\n\
strh r1, [r0, 0x26]\n\
ldr r3, =0x00007b18\n\
adds r1, r2, r3\n\
subs r3, 0x4\n\
adds r0, r2, r3\n\
ldrh r0, [r0]\n\
lsls r0, 5\n\
ldr r3, =0x06010000\n\
adds r0, r3\n\
str r0, [r1]\n\
ldr r0, =0x00007b12\n\
adds r2, r0\n\
ldrh r0, [r2]\n\
lsls r0, 4\n\
movs r1, 0x80\n\
lsls r1, 1\n\
adds r0, r1\n\
strh r0, [r2]\n\
b _08167742\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_08167714:\n\
2019-03-23 16:41:09 +01:00
lsls r1, r6, 13\n\
movs r0, 0xC1\n\
lsls r0, 2\n\
adds r1, r0\n\
adds r1, r3, r1\n\
ldr r2, =0x00007b18\n\
adds r0, r3, r2\n\
ldr r2, [r0]\n\
ldr r0, =0x040000d4\n\
str r1, [r0]\n\
str r2, [r0, 0x4]\n\
ldr r1, =0x80000400\n\
str r1, [r0, 0x8]\n\
ldr r0, [r0, 0x8]\n\
lsls r0, r6, 7\n\
adds r0, 0x4\n\
adds r0, r3, r0\n\
ldr r2, =0x00007b12\n\
adds r1, r3, r2\n\
ldrh r1, [r1]\n\
movs r2, 0x20\n\
bl LoadPalette\n\
2019-02-23 18:08:07 +01:00
_08167742:\n\
2019-03-23 16:41:09 +01:00
add sp, 0x28\n\
pop {r3}\n\
mov r8, r3\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool\n\
.syntax divided\n");
2019-02-23 18:08:07 +01:00
}
#endif
#ifdef NONMATCHING
void sub_8167760(void)
{
2019-03-23 16:41:09 +01:00
s32 i;
u8 v1;
u8 v2;
u8 v3;
u32 v4;
struct SpriteSheet *v6;
struct SpriteTemplate *v7;
void (*funcCB) (void);
struct SpritePalette *v9;
struct SpriteSheet *v10;
struct SpritePalette *v11;
sub_81D321C(v6, v7, v9);
LoadSpriteSheets(v6);
LoadSpritePalettes(v9);
for(i = 0; i < gUnknown_0203BCAC->info.field_70 - 1; i++)
{
v1 = CreateSprite(v7, 226, (0x140000 * i + 0x80000) >> 16, 0);
if(v1 == 64)
{
gUnknown_0203BCAC->field_0[0x7B06 + i] = -1;
}
else
{
gUnknown_0203BCAC->field_0[0x7B06 + i] = v1;
gSprites[v1].data[0] = i;
gSprites[v1].callback = (SpriteCallback) sub_8168180;
}
}
for(v7->tileTag = 103; i <= 5; i++)
{
v2 = CreateSprite(v7, 230, (0x140000 * i + 0x80000) >> 16, 0);
if(v2 == 64 )
{
gUnknown_0203BCAC->field_0[0x7B06 + i] = -1;
}
else
{
gUnknown_0203BCAC->field_0[0x7B06 + i] = v2;
gSprites[v2].oam.tileNum &= 0x3F;
}
}
v7->tileTag = 102;
funcCB = sub_81681B4;
v3 = CreateSprite(v7, 222, (0x140000 * i + 0x80000) >> 16, 0);
if(v3 == 64)
{
gUnknown_0203BCAC->field_0[0x7B06 + i] = -1;
}
else
{
gUnknown_0203BCAC->field_0[0x7B06 + i] = v3;
v4 = 68 * v3 + 0x2020630;
(v4 + 1) = gSprites[v2].oam.affineMode & (0x3F | 0x40);
(v4 + 3) = (v4 + 3) & (0x3F | 0x80);
}
sub_81D32B0(v10, v11);
LoadSpriteSheet(v10);
LoadSpritePalette(v11);
2019-02-23 18:08:07 +01:00
}
#else
NAKED
void sub_8167760(void)
{
2019-03-23 16:41:09 +01:00
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
sub sp, 0x60\n\
add r5, sp, 0x20\n\
add r4, sp, 0x38\n\
mov r0, sp\n\
adds r1, r5, 0\n\
adds r2, r4, 0\n\
bl sub_81D321C\n\
mov r0, sp\n\
bl LoadSpriteSheets\n\
adds r0, r4, 0\n\
bl LoadSpritePalettes\n\
movs r4, 0\n\
ldr r1, =gUnknown_0203BCAC\n\
ldr r0, [r1]\n\
ldr r2, =0x00008040\n\
adds r0, r2\n\
ldrb r0, [r0]\n\
subs r0, 0x1\n\
adds r6, r5, 0\n\
add r2, sp, 0x50\n\
mov r9, r2\n\
add r2, sp, 0x58\n\
mov r10, r2\n\
cmp r4, r0\n\
bge _0816781C\n\
adds r5, r1, 0\n\
ldr r7, =gSprites\n\
movs r0, 0x1C\n\
adds r0, r7\n\
mov r8, r0\n\
2019-02-23 18:08:07 +01:00
_081677AC:\n\
2019-03-23 16:41:09 +01:00
lsls r2, r4, 2\n\
adds r2, r4\n\
lsls r2, 18\n\
movs r1, 0x80\n\
lsls r1, 12\n\
adds r2, r1\n\
asrs r2, 16\n\
adds r0, r6, 0\n\
movs r1, 0xE2\n\
movs r3, 0\n\
bl CreateSprite\n\
lsls r0, 24\n\
lsrs r3, r0, 24\n\
cmp r3, 0x40\n\
beq _081677FC\n\
ldr r0, [r5]\n\
ldr r2, =0x00007b06\n\
adds r0, r2\n\
adds r0, r4\n\
strb r3, [r0]\n\
lsls r0, r3, 4\n\
adds r0, r3\n\
lsls r0, 2\n\
adds r1, r0, r7\n\
strh r4, [r1, 0x2E]\n\
add r0, r8\n\
ldr r1, =sub_8168180\n\
str r1, [r0]\n\
b _08167808\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_081677FC:\n\
2019-03-23 16:41:09 +01:00
ldr r0, [r5]\n\
ldr r1, =0x00007b06\n\
adds r0, r1\n\
adds r0, r4\n\
movs r1, 0xFF\n\
strb r1, [r0]\n\
2019-02-23 18:08:07 +01:00
_08167808:\n\
2019-03-23 16:41:09 +01:00
adds r0, r4, 0x1\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
ldr r0, [r5]\n\
ldr r2, =0x00008040\n\
adds r0, r2\n\
ldrb r0, [r0]\n\
subs r0, 0x1\n\
cmp r4, r0\n\
blt _081677AC\n\
2019-02-23 18:08:07 +01:00
_0816781C:\n\
2019-03-23 16:41:09 +01:00
movs r0, 0x67\n\
strh r0, [r6]\n\
cmp r4, 0x5\n\
bhi _0816788A\n\
ldr r5, =gUnknown_0203BCAC\n\
ldr r7, =gSprites\n\
2019-02-23 18:08:07 +01:00
_08167828:\n\
2019-03-23 16:41:09 +01:00
lsls r2, r4, 2\n\
adds r2, r4\n\
lsls r2, 18\n\
movs r0, 0x80\n\
lsls r0, 12\n\
adds r2, r0\n\
asrs r2, 16\n\
adds r0, r6, 0\n\
movs r1, 0xE6\n\
movs r3, 0\n\
bl CreateSprite\n\
lsls r0, 24\n\
lsrs r3, r0, 24\n\
cmp r3, 0x40\n\
beq _08167874\n\
ldr r0, [r5]\n\
ldr r1, =0x00007b06\n\
adds r0, r1\n\
adds r0, r4\n\
strb r3, [r0]\n\
lsls r1, r3, 4\n\
adds r1, r3\n\
lsls r1, 2\n\
adds r1, r7\n\
ldrb r2, [r1, 0x3]\n\
movs r0, 0x3F\n\
ands r0, r2\n\
strb r0, [r1, 0x3]\n\
b _08167880\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_08167874:\n\
2019-03-23 16:41:09 +01:00
ldr r0, [r5]\n\
ldr r2, =0x00007b06\n\
adds r0, r2\n\
adds r0, r4\n\
movs r1, 0xFF\n\
strb r1, [r0]\n\
2019-02-23 18:08:07 +01:00
_08167880:\n\
2019-03-23 16:41:09 +01:00
adds r0, r4, 0x1\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
cmp r4, 0x5\n\
bls _08167828\n\
2019-02-23 18:08:07 +01:00
_0816788A:\n\
2019-03-23 16:41:09 +01:00
movs r0, 0x66\n\
strh r0, [r6]\n\
ldr r0, =sub_81681B4\n\
str r0, [r6, 0x14]\n\
lsls r2, r4, 2\n\
adds r2, r4\n\
lsls r2, 18\n\
movs r0, 0x80\n\
lsls r0, 12\n\
adds r2, r0\n\
asrs r2, 16\n\
adds r0, r6, 0\n\
movs r1, 0xDE\n\
movs r3, 0\n\
bl CreateSprite\n\
lsls r0, 24\n\
lsrs r3, r0, 24\n\
cmp r3, 0x40\n\
beq _081678F4\n\
ldr r0, =gUnknown_0203BCAC\n\
ldr r0, [r0]\n\
ldr r1, =0x00007b06\n\
adds r0, r1\n\
adds r0, r4\n\
strb r3, [r0]\n\
ldr r0, =gSprites\n\
lsls r2, r3, 4\n\
adds r2, r3\n\
lsls r2, 2\n\
adds r2, r0\n\
ldrb r3, [r2, 0x1]\n\
movs r1, 0x3F\n\
adds r0, r1, 0\n\
ands r0, r3\n\
movs r3, 0x40\n\
orrs r0, r3\n\
strb r0, [r2, 0x1]\n\
ldrb r0, [r2, 0x3]\n\
ands r1, r0\n\
movs r0, 0x80\n\
orrs r1, r0\n\
strb r1, [r2, 0x3]\n\
b _08167902\n\
.pool\n\
2019-02-23 18:08:07 +01:00
_081678F4:\n\
2019-03-23 16:41:09 +01:00
ldr r0, =gUnknown_0203BCAC\n\
ldr r0, [r0]\n\
ldr r2, =0x00007b06\n\
adds r0, r2\n\
adds r0, r4\n\
movs r1, 0xFF\n\
strb r1, [r0]\n\
2019-02-23 18:08:07 +01:00
_08167902:\n\
2019-03-23 16:41:09 +01:00
mov r0, r9\n\
mov r1, r10\n\
bl sub_81D32B0\n\
mov r0, r9\n\
bl LoadSpriteSheet\n\
mov r0, r10\n\
bl LoadSpritePalette\n\
add sp, 0x60\n\
pop {r3-r5}\n\
mov r8, r3\n\
mov r9, r4\n\
mov r10, r5\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool\n\
.syntax divided\n");
2019-02-23 18:08:07 +01:00
}
#endif
bool8 sub_8167930(void)
{
2019-03-23 16:41:09 +01:00
bool8 retvalue;
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:
(u32 *) gUnknown_0203BCA4 = Alloc(6656);
(u32 *) gUnknown_0203BCA0 = Alloc(1280);
(u32 *) 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:
LZ77UnCompVram(gUnknown_085DFC0C, &gUnknown_0203BCAC->field_0[0x7304]);
break;
case 11:
LoadBgTilemap(2, &gUnknown_0203BCAC->field_0[0x7304], 1280, 0);
LoadPalette(gUnknown_086231E8, 48, 32);
LoadPalette(gUnknown_08623208, 240, 32);
sub_81D21DC(2);
break;
default:
gUnknown_0203BCAC->info.unk78 = 0;
retvalue = 0;
return retvalue;
}
gUnknown_0203BCAC->info.unk78++;
retvalue = 1;
return retvalue;
2019-02-23 18:08:07 +01:00
}